diff --git a/NOTICE b/NOTICE index 4c99a05109185..0bae4345e6446 100644 --- a/NOTICE +++ b/NOTICE @@ -1,5 +1,5 @@ Apache Ignite -Copyright 2018 The Apache Software Foundation +Copyright 2019 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/assembly/NOTICE_HADOOP b/assembly/NOTICE_HADOOP index 4c99a05109185..0bae4345e6446 100644 --- a/assembly/NOTICE_HADOOP +++ b/assembly/NOTICE_HADOOP @@ -1,5 +1,5 @@ Apache Ignite -Copyright 2018 The Apache Software Foundation +Copyright 2019 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/assembly/NOTICE_IGNITE b/assembly/NOTICE_IGNITE index 964fd359ad713..fffcc7c694029 100644 --- a/assembly/NOTICE_IGNITE +++ b/assembly/NOTICE_IGNITE @@ -1,5 +1,5 @@ Apache Ignite -Copyright 2018 The Apache Software Foundation +Copyright 2019 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/bin/control.bat b/bin/control.bat index d6f97984e2133..fb5f11a352752 100644 --- a/bin/control.bat +++ b/bin/control.bat @@ -49,10 +49,10 @@ for /f "tokens=* USEBACKQ" %%f in (`%cmd% -version 2^>^&1`) do ( ) :LoopEscape -set var=%var:~14% -set var=%var:"=% -for /f "tokens=1,2 delims=." %%a in ("%var%") do set MAJOR_JAVA_VER=%%a & set MINOR_JAVA_VER=%%b +for /f "tokens=1-3 delims= " %%a in ("%var%") do set JAVA_VER_STR=%%c +set JAVA_VER_STR=%JAVA_VER_STR:"=% +for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set MAJOR_JAVA_VER=%%a& set MINOR_JAVA_VER=%%b if %MAJOR_JAVA_VER% == 1 set MAJOR_JAVA_VER=%MINOR_JAVA_VER% if %MAJOR_JAVA_VER% LSS 8 ( @@ -60,14 +60,7 @@ if %MAJOR_JAVA_VER% LSS 8 ( echo The version of JAVA installed in %JAVA_HOME% is incorrect. echo Please point JAVA_HOME variable to installation of JDK 1.8 or later. echo You can also download latest JDK at http://java.com/download. - goto error_finish -) - -if %MAJOR_JAVA_VER% GTR 9 ( - echo %0, WARNING: - echo The version of JAVA installed in %JAVA_HOME% was not tested with Apache Ignite. - echo Run it on your own risk or point JAVA_HOME variable to installation of JDK 1.8 or JDK 9. - echo You can also download latest JDK at http://java.com/download. + goto error_finish ) :: Check IGNITE_HOME. @@ -220,7 +213,37 @@ if "%MAIN_CLASS%" == "" set MAIN_CLASS=org.apache.ignite.internal.commandline.Co :: :: Final JVM_OPTS for Java 9+ compatibility :: -if %MAJOR_JAVA_VER% GEQ 9 set JVM_OPTS=--add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-modules java.xml.bind %JVM_OPTS% +if %MAJOR_JAVA_VER% == 8 ( + set JVM_OPTS= ^ + -XX:+AggressiveOpts ^ + %JVM_OPTS% +) + +if %MAJOR_JAVA_VER% GEQ 9 if %MAJOR_JAVA_VER% LSS 11 ( + set JVM_OPTS= ^ + -XX:+AggressiveOpts ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + --add-modules=java.transaction ^ + --add-modules=java.xml.bind ^ + %JVM_OPTS% +) + +if %MAJOR_JAVA_VER% == 11 ( + set JVM_OPTS= ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + -Djdk.tls.client.protocols=TLSv1.2 ^ + %JVM_OPTS% +) if "%INTERACTIVE%" == "1" ( "%JAVA_HOME%\bin\java.exe" %JVM_OPTS% %QUIET% %RESTART_SUCCESS_OPT% %JMX_MON% ^ diff --git a/bin/control.sh b/bin/control.sh index 7f84696831c50..07193675b789f 100755 --- a/bin/control.sh +++ b/bin/control.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o nounset +set -o errexit +set -o pipefail +set -o errtrace +set -o functrace + # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -23,7 +29,7 @@ # # Import common functions. # -if [ "${IGNITE_HOME}" = "" ]; +if [ "${IGNITE_HOME:-}" = "" ]; then IGNITE_HOME_TMP="$(dirname "$(cd "$(dirname "$0")"; "pwd")")"; else IGNITE_HOME_TMP=${IGNITE_HOME}; fi @@ -45,7 +51,7 @@ checkJava # setIgniteHome -if [ "${DEFAULT_CONFIG}" == "" ]; then +if [ "${DEFAULT_CONFIG:-}" == "" ]; then DEFAULT_CONFIG=config/default-config.xml fi @@ -68,14 +74,14 @@ RESTART_SUCCESS_OPT="-DIGNITE_SUCCESS_FILE=${RESTART_SUCCESS_FILE}" # # This is executed when -nojmx is not specified # -if [ "${NOJMX}" == "0" ] ; then +if [ "${NOJMXI:-}" == "0" ] ; then findAvailableJmxPort fi # Mac OS specific support to display correct name in the dock. osname=`uname` -if [ "${DOCK_OPTS}" == "" ]; then +if [ "${DOCK_OPTS:-}" == "" ]; then DOCK_OPTS="-Xdock:name=Ignite Node" fi @@ -84,7 +90,7 @@ fi # # ADD YOUR/CHANGE ADDITIONAL OPTIONS HERE # -if [ -z "$JVM_OPTS" ] ; then +if [ -z "${JVM_OPTS:-}" ] ; then if [[ `"$JAVA" -version 2>&1 | egrep "1\.[7]\."` ]]; then JVM_OPTS="-Xms256m -Xmx1g" else @@ -122,14 +128,14 @@ ENABLE_ASSERTIONS="1" # # Set '-ea' options if assertions are enabled. # -if [ "${ENABLE_ASSERTIONS}" = "1" ]; then +if [ "${ENABLE_ASSERTIONS:-}" = "1" ]; then JVM_OPTS="${JVM_OPTS} -ea" fi # # Set main class to start service (grid node by default). # -if [ "${MAIN_CLASS}" = "" ]; then +if [ "${MAIN_CLASS:-}" = "" ]; then MAIN_CLASS=org.apache.ignite.internal.commandline.CommandHandler fi @@ -140,45 +146,68 @@ fi # JVM_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787 ${JVM_OPTS}" # -# Final JVM_OPTS for Java 9 compatibility -# -${JAVA_HOME}/bin/java -version 2>&1 | grep -qE 'java version "9.*"' && { -JVM_OPTS="--add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ - --add-exports java.base/sun.nio.ch=ALL-UNNAMED \ - --add-exports java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ - --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ - --add-modules java.xml.bind \ - ${JVM_OPTS}" -} || true +# Final JVM_OPTS for Java 9+ compatibility +# +javaMajorVersion "${JAVA_HOME}/bin/java" + +if [ $version -eq 8 ] ; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + ${JVM_OPTS}" + +elif [ $version -gt 8 ] && [ $version -lt 11 ]; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + --add-modules=java.transaction \ + --add-modules=java.xml.bind \ + ${JVM_OPTS}" + +elif [ $version -eq 11 ] ; then + JVM_OPTS="\ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + -Djdk.tls.client.protocols=TLSv1.2 \ + ${JVM_OPTS}" +fi ERRORCODE="-1" while [ "${ERRORCODE}" -ne "130" ] do - if [ "${INTERACTIVE}" == "1" ] ; then + if [ "${INTERACTIVE:-}" == "1" ] ; then case $osname in Darwin*) - "$JAVA" ${JVM_OPTS} ${QUIET} "${DOCK_OPTS}" "${RESTART_SUCCESS_OPT}" ${JMX_MON} \ + "$JAVA" ${JVM_OPTS} ${QUIET:-} "${DOCK_OPTS}" "${RESTART_SUCCESS_OPT}" ${JMX_MON:-} \ -DIGNITE_UPDATE_NOTIFIER=false -DIGNITE_HOME="${IGNITE_HOME}" \ - -DIGNITE_PROG_NAME="$0" ${JVM_XOPTS} -cp "${CP}" ${MAIN_CLASS} $@ + -DIGNITE_PROG_NAME="$0" ${JVM_XOPTS:-} -cp "${CP}" ${MAIN_CLASS} $@ ;; *) - "$JAVA" ${JVM_OPTS} ${QUIET} "${RESTART_SUCCESS_OPT}" ${JMX_MON} \ + "$JAVA" ${JVM_OPTS} ${QUIET:-} "${RESTART_SUCCESS_OPT}" ${JMX_MON:-} \ -DIGNITE_UPDATE_NOTIFIER=false -DIGNITE_HOME="${IGNITE_HOME}" \ - -DIGNITE_PROG_NAME="$0" ${JVM_XOPTS} -cp "${CP}" ${MAIN_CLASS} $@ + -DIGNITE_PROG_NAME="$0" ${JVM_XOPTS:-} -cp "${CP}" ${MAIN_CLASS} $@ ;; esac else case $osname in Darwin*) - "$JAVA" ${JVM_OPTS} ${QUIET} "${DOCK_OPTS}" "${RESTART_SUCCESS_OPT}" ${JMX_MON} \ + "$JAVA" ${JVM_OPTS} ${QUIET:-} "${DOCK_OPTS}" "${RESTART_SUCCESS_OPT}" ${JMX_MON:-} \ -DIGNITE_UPDATE_NOTIFIER=false -DIGNITE_HOME="${IGNITE_HOME}" \ - -DIGNITE_PROG_NAME="$0" ${JVM_XOPTS} -cp "${CP}" ${MAIN_CLASS} $@ + -DIGNITE_PROG_NAME="$0" ${JVM_XOPTS:-} -cp "${CP}" ${MAIN_CLASS} $@ ;; *) - "$JAVA" ${JVM_OPTS} ${QUIET} "${RESTART_SUCCESS_OPT}" ${JMX_MON} \ + "$JAVA" ${JVM_OPTS} ${QUIET:-} "${RESTART_SUCCESS_OPT}" ${JMX_MON:-} \ -DIGNITE_UPDATE_NOTIFIER=false -DIGNITE_HOME="${IGNITE_HOME}" \ - -DIGNITE_PROG_NAME="$0" ${JVM_XOPTS} -cp "${CP}" ${MAIN_CLASS} $@ + -DIGNITE_PROG_NAME="$0" ${JVM_XOPTS:-} -cp "${CP}" ${MAIN_CLASS} $@ ;; esac fi diff --git a/bin/ignite-tf.sh b/bin/ignite-tf.sh index a6499ae45eb66..7b4d0d2fc30b3 100644 --- a/bin/ignite-tf.sh +++ b/bin/ignite-tf.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o nounset +set -o errexit +set -o pipefail +set -o errtrace +set -o functrace + # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -23,7 +29,7 @@ # # Import common functions. # -if [ "${IGNITE_HOME}" = "" ]; +if [ "${IGNITE_HOME:-}" = "" ]; then IGNITE_HOME_TMP="$(dirname "$(cd "$(dirname "$0")"; "pwd")")"; else IGNITE_HOME_TMP=${IGNITE_HOME}; fi @@ -45,7 +51,7 @@ checkJava # setIgniteHome -if [ "${DEFAULT_CONFIG}" == "" ]; then +if [ "${DEFAULT_CONFIG:-}" == "" ]; then DEFAULT_CONFIG=config/default-config.xml fi @@ -65,7 +71,7 @@ RESTART_SUCCESS_OPT="-DIGNITE_SUCCESS_FILE=${RESTART_SUCCESS_FILE}" # Mac OS specific support to display correct name in the dock. osname=`uname` -if [ "${DOCK_OPTS}" == "" ]; then +if [ "${DOCK_OPTS:-}" == "" ]; then DOCK_OPTS="-Xdock:name=Ignite Node" fi @@ -74,7 +80,7 @@ fi # # ADD YOUR/CHANGE ADDITIONAL OPTIONS HERE # -if [ -z "$JVM_OPTS" ] ; then +if [ -z "${JVM_OPTS:-}" ] ; then JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m" fi @@ -103,7 +109,7 @@ ENABLE_ASSERTIONS="1" # # Set '-ea' options if assertions are enabled. # -if [ "${ENABLE_ASSERTIONS}" = "1" ]; then +if [ "${ENABLE_ASSERTIONS:-}" = "1" ]; then JVM_OPTS="${JVM_OPTS} -ea" fi @@ -146,6 +152,7 @@ elif [ $version -eq 11 ] ; then --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ --illegal-access=permit \ + -Djdk.tls.client.protocols=TLSv1.2 \ ${JVM_OPTS}" fi @@ -158,12 +165,12 @@ while [ "${ERRORCODE}" -ne "130" ] do case $osname in Darwin*) - "$JAVA" ${JVM_OPTS} ${QUIET} "${DOCK_OPTS}" "${RESTART_SUCCESS_OPT}" \ + "$JAVA" ${JVM_OPTS:-} ${QUIET:-} "${DOCK_OPTS}" "${RESTART_SUCCESS_OPT}" \ -DIGNITE_UPDATE_NOTIFIER=false -DIGNITE_HOME="${IGNITE_HOME}" \ - -DIGNITE_PROG_NAME="$0" -cp "${CP}" ${MAIN_CLASS} "${CONFIG}" "$@" + -DIGNITE_PROG_NAME="$0" -cp "${CP}" ${MAIN_CLASS} "${CONFIG:-}" "$@" ;; *) - "$JAVA" ${JVM_OPTS} ${QUIET} "${RESTART_SUCCESS_OPT}" \ + "$JAVA" ${JVM_OPTS:-} ${QUIET:-} "${RESTART_SUCCESS_OPT}" \ -DIGNITE_UPDATE_NOTIFIER=false -DIGNITE_HOME="${IGNITE_HOME}" \ -DIGNITE_PROG_NAME="$0" -cp "${CP}" ${MAIN_CLASS} "$@" ;; diff --git a/bin/ignite.bat b/bin/ignite.bat index 2d5a08d3a9e4c..915be598c9f34 100644 --- a/bin/ignite.bat +++ b/bin/ignite.bat @@ -52,7 +52,7 @@ for /f "tokens=* USEBACKQ" %%f in (`%cmd% -version 2^>^&1`) do ( for /f "tokens=1-3 delims= " %%a in ("%var%") do set JAVA_VER_STR=%%c set JAVA_VER_STR=%JAVA_VER_STR:"=% -for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set MAJOR_JAVA_VER=%%a & set MINOR_JAVA_VER=%%b +for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set MAJOR_JAVA_VER=%%a& set MINOR_JAVA_VER=%%b if %MAJOR_JAVA_VER% == 1 set MAJOR_JAVA_VER=%MINOR_JAVA_VER% if %MAJOR_JAVA_VER% LSS 8 ( @@ -228,7 +228,7 @@ if "%MAIN_CLASS%" == "" set MAIN_CLASS=org.apache.ignite.startup.cmdline.Command :: :: Final JVM_OPTS for Java 9+ compatibility :: -if "%MAJOR_JAVA_VER%" == "8" ( +if %MAJOR_JAVA_VER% == 8 ( set JVM_OPTS= ^ -XX:+AggressiveOpts ^ %JVM_OPTS% @@ -248,7 +248,7 @@ if %MAJOR_JAVA_VER% GEQ 9 if %MAJOR_JAVA_VER% LSS 11 ( %JVM_OPTS% ) -if "%MAJOR_JAVA_VER%" == "11" ( +if %MAJOR_JAVA_VER% == 11 ( set JVM_OPTS= ^ --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ @@ -256,6 +256,7 @@ if "%MAJOR_JAVA_VER%" == "11" ( --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ --illegal-access=permit ^ + -Djdk.tls.client.protocols=TLSv1.2 ^ %JVM_OPTS% ) diff --git a/bin/ignite.sh b/bin/ignite.sh index 8ef040cdb711b..f70880bb0a796 100755 --- a/bin/ignite.sh +++ b/bin/ignite.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o nounset +set -o errexit +set -o pipefail +set -o errtrace +set -o functrace + # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -23,7 +29,7 @@ # # Import common functions. # -if [ "${IGNITE_HOME}" = "" ]; +if [ "${IGNITE_HOME:-}" = "" ]; then IGNITE_HOME_TMP="$(dirname "$(cd "$(dirname "$0")"; "pwd")")"; else IGNITE_HOME_TMP=${IGNITE_HOME}; fi @@ -45,7 +51,7 @@ checkJava # setIgniteHome -if [ "${DEFAULT_CONFIG}" == "" ]; then +if [ "${DEFAULT_CONFIG:-}" == "" ]; then DEFAULT_CONFIG=config/default-config.xml fi @@ -80,7 +86,7 @@ fi # Mac OS specific support to display correct name in the dock. osname=`uname` -if [ "${DOCK_OPTS}" == "" ]; then +if [ "${DOCK_OPTS:-}" == "" ]; then DOCK_OPTS="-Xdock:name=Ignite Node" fi @@ -134,7 +140,7 @@ fi # # Set main class to start service (grid node by default). # -if [ "${MAIN_CLASS}" = "" ]; then +if [ "${MAIN_CLASS:-}" = "" ]; then MAIN_CLASS=org.apache.ignite.startup.cmdline.CommandLineStartup fi @@ -147,7 +153,7 @@ fi # # Final JVM_OPTS for Java 9+ compatibility # -javaMajorVersion "${JAVA_HOME}/bin/java" +javaMajorVersion "${JAVA}" if [ $version -eq 8 ] ; then JVM_OPTS="\ @@ -175,6 +181,7 @@ elif [ $version -eq 11 ] ; then --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ --illegal-access=permit \ + -Djdk.tls.client.protocols=TLSv1.2 \ ${JVM_OPTS}" fi diff --git a/bin/ignitevisorcmd.bat b/bin/ignitevisorcmd.bat index 82238c2d38858..0a92999b5b609 100644 --- a/bin/ignitevisorcmd.bat +++ b/bin/ignitevisorcmd.bat @@ -49,25 +49,18 @@ for /f "tokens=* USEBACKQ" %%f in (`%cmd% -version 2^>^&1`) do ( ) :LoopEscape -set var=%var:~14% -set var=%var:"=% -for /f "tokens=1,2 delims=." %%a in ("%var%") do set MAJOR_JAVA_VER=%%a & set MINOR_JAVA_VER=%%b +for /f "tokens=1-3 delims= " %%a in ("%var%") do set JAVA_VER_STR=%%c +set JAVA_VER_STR=%JAVA_VER_STR:"=% +for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set MAJOR_JAVA_VER=%%a& set MINOR_JAVA_VER=%%b if %MAJOR_JAVA_VER% == 1 set MAJOR_JAVA_VER=%MINOR_JAVA_VER% if %MAJOR_JAVA_VER% LSS 8 ( echo %0, ERROR: - echo The %MAJOR_JAVA_VER% version of JAVA installed in %JAVA_HOME% is incorrect. + echo The version of JAVA installed in %JAVA_HOME% is incorrect. echo Please point JAVA_HOME variable to installation of JDK 1.8 or later. echo You can also download latest JDK at http://java.com/download. - goto error_finish -) - -if %MAJOR_JAVA_VER% GTR 9 ( - echo %0, WARNING: - echo The %MAJOR_JAVA_VER% version of JAVA installed in %JAVA_HOME% was not tested with Apache Ignite. - echo Run it on your own risk or point JAVA_HOME variable to installation of JDK 1.8 or JDK 9. - echo You can also download latest JDK at http://java.com/download. + goto error_finish ) :: Check IGNITE_HOME. @@ -162,9 +155,39 @@ if %ENABLE_ASSERTIONS% == 1 set JVM_OPTS_VISOR=%JVM_OPTS_VISOR% -ea if "%ARGS%" == "" set ARGS=%* :: -:: Final JVM_OPTS for Java 9+ compatibility +:: Final JVM_OPTS_VISOR for Java 9+ compatibility :: -if %MAJOR_JAVA_VER% GEQ 9 set JVM_OPTS=--add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-modules java.xml.bind %JVM_OPTS% +if %MAJOR_JAVA_VER% == 8 ( + set JVM_OPTS_VISOR= ^ + -XX:+AggressiveOpts ^ + %JVM_OPTS_VISOR% +) + +if %MAJOR_JAVA_VER% GEQ 9 if %MAJOR_JAVA_VER% LSS 11 ( + set JVM_OPTS_VISOR= ^ + -XX:+AggressiveOpts ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + --add-modules=java.transaction ^ + --add-modules=java.xml.bind ^ + %JVM_OPTS_VISOR% +) + +if %MAJOR_JAVA_VER% == 11 ( + set JVM_OPTS_VISOR= ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + -Djdk.tls.client.protocols=TLSv1.2 ^ + %JVM_OPTS_VISOR% +) :: :: Starts Visor console. diff --git a/bin/ignitevisorcmd.sh b/bin/ignitevisorcmd.sh index 1fcc127b4caf0..67f670c4ad3e8 100755 --- a/bin/ignitevisorcmd.sh +++ b/bin/ignitevisorcmd.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o nounset +set -o errexit +set -o pipefail +set -o errtrace +set -o functrace + # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -22,7 +28,7 @@ ARGS=$@ # # Import common functions. # -if [ "${IGNITE_HOME}" = "" ]; +if [ "${IGNITE_HOME:-}" = "" ]; then IGNITE_HOME_TMP="$(dirname "$(cd "$(dirname "$0")"; "pwd")")"; else IGNITE_HOME_TMP=${IGNITE_HOME}; fi @@ -66,7 +72,7 @@ JVM_OPTS="-Xms1g -Xmx1g -XX:MaxPermSize=128M -server ${JVM_OPTS}" # Mac OS specific support to display correct name in the dock. osname=`uname` -if [ "${DOCK_OPTS}" == "" ]; then +if [ "${DOCK_OPTS:-}" == "" ]; then DOCK_OPTS="-Xdock:name=Visor - Ignite Shell Console" fi @@ -106,17 +112,38 @@ function restoreSttySettings() { trap restoreSttySettings INT # -# Final JVM_OPTS for Java 9 compatibility +# Final JVM_OPTS for Java 9+ compatibility # javaMajorVersion "${JAVA_HOME}/bin/java" -if [ $version -gt 8 ]; then - JVM_OPTS="--add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ - --add-exports java.base/sun.nio.ch=ALL-UNNAMED \ - --add-exports java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ - --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ - --add-modules java.xml.bind \ - ${JVM_OPTS}" +if [ $version -eq 8 ] ; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + ${JVM_OPTS}" + +elif [ $version -gt 8 ] && [ $version -lt 11 ]; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + --add-modules=java.transaction \ + --add-modules=java.xml.bind \ + ${JVM_OPTS}" + +elif [ $version -eq 11 ] ; then + JVM_OPTS="\ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + -Djdk.tls.client.protocols=TLSv1.2 \ + ${JVM_OPTS}" fi # diff --git a/bin/include/functions.sh b/bin/include/functions.sh index 7bdcefd8cf4dd..199fd4e875113 100755 --- a/bin/include/functions.sh +++ b/bin/include/functions.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o nounset +set -o errexit +set -o pipefail +set -o errtrace +set -o functrace + # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -55,7 +61,7 @@ javaMajorVersion() { # checkJava() { # Check JAVA_HOME. - if [ "$JAVA_HOME" = "" ]; then + if [ "${JAVA_HOME:-}" = "" ]; then JAVA=`type -p java` RETCODE=$? @@ -96,7 +102,7 @@ setIgniteHome() { # # Set IGNITE_HOME, if needed. # - if [ "${IGNITE_HOME}" = "" ]; then + if [ "${IGNITE_HOME:-}" = "" ]; then export IGNITE_HOME=${IGNITE_HOME_TMP} fi diff --git a/bin/include/parseargs.sh b/bin/include/parseargs.sh index 3ab255eae1659..3b4a0702c24b9 100755 --- a/bin/include/parseargs.sh +++ b/bin/include/parseargs.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o nounset +set -o errexit +set -o pipefail +set -o errtrace +set -o functrace + # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -34,7 +40,7 @@ # in other scripts to parse common command lines parameters. # -CONFIG=${DEFAULT_CONFIG} +CONFIG=${DEFAULT_CONFIG:-} INTERACTIVE="0" NOJMX="0" QUIET="-DIGNITE_QUIET=true" @@ -51,3 +57,13 @@ do esac shift done + +# +# Set 'file.encoding' to UTF-8 default if not specified otherwise +# +case "${JVM_OPTS:-}" in + *-Dfile.encoding=*) + ;; + *) + JVM_OPTS="${JVM_OPTS:-} -Dfile.encoding=UTF-8";; +esac diff --git a/bin/include/setenv.sh b/bin/include/setenv.sh index 4b82cf9c9ba3f..7290ccd8e73e0 100755 --- a/bin/include/setenv.sh +++ b/bin/include/setenv.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o nounset +set -o errexit +set -o pipefail +set -o errtrace +set -o functrace + # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -27,7 +33,7 @@ # # Check IGNITE_HOME. # -if [ "${IGNITE_HOME}" = "" ]; then +if [ "${IGNITE_HOME:-}" = "" ]; then echo $0", ERROR: Ignite installation folder is not found." echo "Please create IGNITE_HOME variable pointing to location of" echo "Ignite installation folder." @@ -62,12 +68,12 @@ IFS=$(echo -en "\n\b") for file in ${IGNITE_HOME}/libs/* do if [ -d ${file} ] && [ "${file}" != "${IGNITE_HOME}"/libs/optional ]; then - IGNITE_LIBS=${IGNITE_LIBS}${SEP}${file}/* + IGNITE_LIBS=${IGNITE_LIBS:-}${SEP}${file}/* fi done IFS=$SAVEIFS -if [ "${USER_LIBS}" != "" ]; then - IGNITE_LIBS=${USER_LIBS}${SEP}${IGNITE_LIBS} +if [ "${USER_LIBS:-}" != "" ]; then + IGNITE_LIBS=${USER_LIBS:-}${SEP}${IGNITE_LIBS} fi diff --git a/modules/web-console/docker/standalone/Dockerfile b/docker/web-console/standalone/Dockerfile similarity index 53% rename from modules/web-console/docker/standalone/Dockerfile rename to docker/web-console/standalone/Dockerfile index 9b007349b6a62..dfcb188b2dac6 100644 --- a/modules/web-console/docker/standalone/Dockerfile +++ b/docker/web-console/standalone/Dockerfile @@ -15,62 +15,71 @@ # limitations under the License. # + +#~~~~~~~~~~~~~~~~~~# +# Frontend build # +#~~~~~~~~~~~~~~~~~~# FROM node:8-slim as frontend-build ENV NPM_CONFIG_LOGLEVEL error WORKDIR /opt/web-console -# Install node modules for frontend. -COPY frontend/package*.json frontend/ -RUN (cd frontend && npm install --no-optional) - -# Copy source. +# Install node modules and build sources COPY frontend frontend +RUN cd frontend && \ + npm install --no-optional && \ + npm run build -RUN (cd frontend && npm run build) +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# +# Web Console Standalone assemble # +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# FROM node:8-slim ENV NPM_CONFIG_LOGLEVEL error -# Update package list & install. -RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 \ - && echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list - -# Update package list & install. -RUN apt-get update \ - && apt-get install -y nginx-light mongodb-org-server dos2unix \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Install global node packages. +# Install global node packages RUN npm install -g pm2 -WORKDIR /opt/web-console - -COPY docker/standalone/docker-entrypoint.sh docker-entrypoint.sh +# Update software sources and install missing applications +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 && \ + echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" > /etc/apt/sources.list.d/mongodb-org-3.4.list && \ + apt update && \ + apt install -y --no-install-recommends \ + nginx-light \ + mongodb-org-server \ + dos2unix && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* -RUN chmod +x docker-entrypoint.sh \ - && dos2unix docker-entrypoint.sh - -# Copy nginx config. -COPY docker/standalone/nginx/* /etc/nginx/ +WORKDIR /opt/web-console -# Install node modules for frontend and backend modules. +# Install node modules for backend COPY backend/package*.json backend/ -RUN (cd backend && npm install --no-optional --production) +RUN cd backend && \ + npm install --no-optional --production -# Copy source. +# Copy and build sources COPY backend backend +RUN cd backend && \ + npm run build -COPY web-agent/target/ignite-web-agent-*.zip backend/agent_dists +# Copy Ignite Web Agent module package +COPY ignite-web-agent-*.zip backend/agent_dists +# Copy previously built frontend COPY --from=frontend-build /opt/web-console/frontend/build static -VOLUME ["/etc/nginx"] -VOLUME ["/data/db"] -VOLUME ["/opt/web-console/serve/agent_dists"] +# Copy and fix entrypoint script +COPY docker-entrypoint.sh docker-entrypoint.sh +RUN chmod +x docker-entrypoint.sh \ + && dos2unix docker-entrypoint.sh + +# Copy nginx configuration +COPY nginx/* /etc/nginx/ EXPOSE 80 + ENTRYPOINT ["/opt/web-console/docker-entrypoint.sh"] + diff --git a/docker/web-console/standalone/README.txt b/docker/web-console/standalone/README.txt new file mode 100644 index 0000000000000..c97e7924fbdc8 --- /dev/null +++ b/docker/web-console/standalone/README.txt @@ -0,0 +1,35 @@ +Apache Ignite Web Console Standalone Docker module +================================================== +Apache Ignite Web Console Standalone Docker module provides Dockerfile and accompanying files +for building docker image of Web Console. + + +Ignite Web Console Standalone Docker Image Build Instructions +============================================================= +1) Build ignite-web-console module + + mvn clean install -P web-console -DskipTests -T 2C -pl :ignite-web-console -am + +2) Copy ignite-web-agent-.zip from 'modules/web-console/web-agent/target' + to 'docker/web-console/standalone' directory + + cp -rf modules/web-console/web-agent/target/ignite-web-agent-*.zip docker/web-console/standalone + +3) Go to Apache Ignite Web Console Docker module directory and copy Apache + Ignite Web Console's frontend and backend directory + + cd docker/web-console/standalone + cp -rf ../../../modules/web-console/backend ./ + cp -rf ../../../modules/web-console/frontend ./ + +4) Build docker image + + docker build . -t apacheignite/web-console-standalone:[:] + + Prepared image will be available in local docker registry (can be seen + issuing `docker images` command) + +5) Clean up + + rm -rf backend frontend ignite-web-agent* + diff --git a/modules/web-console/docker/standalone/docker-entrypoint.sh b/docker/web-console/standalone/docker-entrypoint.sh similarity index 100% rename from modules/web-console/docker/standalone/docker-entrypoint.sh rename to docker/web-console/standalone/docker-entrypoint.sh diff --git a/modules/web-console/docker/standalone/nginx/nginx.conf b/docker/web-console/standalone/nginx/nginx.conf similarity index 100% rename from modules/web-console/docker/standalone/nginx/nginx.conf rename to docker/web-console/standalone/nginx/nginx.conf diff --git a/modules/web-console/docker/standalone/nginx/web-console.conf b/docker/web-console/standalone/nginx/web-console.conf similarity index 100% rename from modules/web-console/docker/standalone/nginx/web-console.conf rename to docker/web-console/standalone/nginx/web-console.conf diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000000000..6357bf90816a4 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,30 @@ +# Apache Ignite Examples + +This module contains examples of how to run [Apache Ignite](ignite.apache.org) and [Apache Ignite](ignite.apache.org) with 3rd party components. + +Instructions on how to start examples can be found in [README.txt](README.txt). + +How to start examples in the developer's environment, please see [DEVNOTES.txt](DEVNOTES.txt). + +## Running examples on JDK 9/10/11 +Ignite uses proprietary SDK APIs that are not available by default. See also [How to run Ignite on JDK 9,10 and 11](https://apacheignite.readme.io/docs/getting-started#section-running-ignite-with-java-9-10-11) + +To set up local IDE to easier access to examples, it is possible to add following options as default for all applications + +``--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED + --illegal-access=permit`` + +For example, for IntelliJ IDEA it is possible to use Application Templates. + +Use 'Run' -> 'Edit Configuration' menu. + + + +## Contributing to Examples +*Notice* When updating classpath of examples and in case any modifications required in [pom.xml](pom.xml) +please make sure that corresponding changes were applied to + [pom-standalone.xml](pom-standalone.xml). This pom file is finalized during release and placed to examples folder with these examples code. \ No newline at end of file diff --git a/examples/config/encryption/example-encrypted-store.xml b/examples/config/encryption/example-encrypted-store.xml index e526ae3e7b401..7ce5482ad5ca7 100644 --- a/examples/config/encryption/example-encrypted-store.xml +++ b/examples/config/encryption/example-encrypted-store.xml @@ -28,6 +28,8 @@ + + diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml index 3ccccbf96b94d..1490dabbc0804 100644 --- a/examples/pom-standalone.xml +++ b/examples/pom-standalone.xml @@ -95,6 +95,31 @@ spymemcached 2.8.4 + + + + org.jpmml + pmml-model + 1.4.7 + + + + com.fasterxml.jackson.core + jackson-core + 2.7.3 + + + + com.fasterxml.jackson.core + jackson-databind + 2.7.3 + + + + com.fasterxml.jackson.core + jackson-annotations + 2.7.3 + diff --git a/examples/pom.xml b/examples/pom.xml index e745beb7204d4..c6b0a5f59db0d 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -145,7 +145,7 @@ org.scalatest scalatest_2.11 - 2.2.4 + ${scala.test.version} test diff --git a/examples/sql/world.sql b/examples/sql/world.sql index a34ee71fbf5dd..560b0bd585395 100644 --- a/examples/sql/world.sql +++ b/examples/sql/world.sql @@ -2,40 +2,40 @@ DROP TABLE IF EXISTS Country; CREATE TABLE Country ( Code CHAR(3) PRIMARY KEY, - Name CHAR(52), - Continent CHAR(50), - Region CHAR(26), + Name VARCHAR, + Continent VARCHAR, + Region VARCHAR, SurfaceArea DECIMAL(10,2), - IndepYear SMALLINT(6), - Population INT(11), + IndepYear SMALLINT, + Population INT, LifeExpectancy DECIMAL(3,1), GNP DECIMAL(10,2), GNPOld DECIMAL(10,2), - LocalName CHAR(45), - GovernmentForm CHAR(45), - HeadOfState CHAR(60), - Capital INT(11), + LocalName VARCHAR, + GovernmentForm VARCHAR, + HeadOfState VARCHAR, + Capital INT, Code2 CHAR(2) ) WITH "template=partitioned, backups=1, CACHE_NAME=Country, VALUE_TYPE=demo.model.Country"; DROP TABLE IF EXISTS City; CREATE TABLE City ( - ID INT(11), - Name CHAR(35), + ID INT, + Name VARCHAR, CountryCode CHAR(3), - District CHAR(20), - Population INT(11), + District VARCHAR, + Population INT, PRIMARY KEY (ID, CountryCode) ) WITH "template=partitioned, backups=1, affinityKey=CountryCode, CACHE_NAME=City, KEY_TYPE=demo.model.CityKey, VALUE_TYPE=demo.model.City"; -CREATE INDEX idx_country_code ON city (CountryCode); +CREATE INDEX idx_country_code ON City (CountryCode); DROP TABLE IF EXISTS CountryLanguage; CREATE TABLE CountryLanguage ( CountryCode CHAR(3), - Language CHAR(30), + Language VARCHAR, IsOfficial CHAR(2), Percentage DECIMAL(4,1), PRIMARY KEY (CountryCode, Language) diff --git a/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java b/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java index 68767d77c4198..93e24b0694c3b 100644 --- a/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java +++ b/examples/src/test/java-lgpl/org/apache/ignite/examples/HibernateL2CacheExampleSelfTest.java @@ -19,15 +19,15 @@ import org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** * Tests the {@link HibernateL2CacheExample}. */ public class HibernateL2CacheExampleSelfTest extends GridAbstractExamplesTest { - /** - * @throws Exception If failed. - */ - public void testHibernateL2CacheExample() throws Exception { + /** */ + @Test + public void testHibernateL2CacheExample() { HibernateL2CacheExample.main(EMPTY_ARGS); } } diff --git a/examples/src/test/java-lgpl/org/apache/ignite/examples/SpatialQueryExampleSelfTest.java b/examples/src/test/java-lgpl/org/apache/ignite/examples/SpatialQueryExampleSelfTest.java index ac59d8e567b43..ea88cff99cbe6 100644 --- a/examples/src/test/java-lgpl/org/apache/ignite/examples/SpatialQueryExampleSelfTest.java +++ b/examples/src/test/java-lgpl/org/apache/ignite/examples/SpatialQueryExampleSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.examples.datagrid.SpatialQueryExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** * Tests {@link SpatialQueryExample}. @@ -27,6 +28,7 @@ public class SpatialQueryExampleSelfTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testSpatialQueryExample() throws Exception { SpatialQueryExample.main(EMPTY_ARGS); } diff --git a/examples/src/test/java-lgpl/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java b/examples/src/test/java-lgpl/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java index 3c9101a31594c..a5e714abecada 100644 --- a/examples/src/test/java-lgpl/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java +++ b/examples/src/test/java-lgpl/org/apache/ignite/testsuites/IgniteLgplExamplesSelfTestSuite.java @@ -17,36 +17,39 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.examples.HibernateL2CacheExampleMultiNodeSelfTest; import org.apache.ignite.examples.HibernateL2CacheExampleSelfTest; import org.apache.ignite.examples.SpatialQueryExampleMultiNodeSelfTest; import org.apache.ignite.examples.SpatialQueryExampleSelfTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP; /** * Examples test suite.

Contains only Spring ignite examples tests. */ -public class IgniteLgplExamplesSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteLgplExamplesSelfTestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, GridTestUtils.getNextMulticastGroup(IgniteLgplExamplesSelfTestSuite.class)); TestSuite suite = new TestSuite("Ignite Examples Test Suite"); - suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class)); - suite.addTest(new TestSuite(SpatialQueryExampleSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheExampleSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SpatialQueryExampleSelfTest.class)); // Multi-node. - suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(SpatialQueryExampleMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheExampleMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SpatialQueryExampleMultiNodeSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/examples/src/test/java/org/apache/ignite/examples/BasicExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/BasicExamplesSelfTest.java index 41ae90a634449..fa1e630230774 100644 --- a/examples/src/test/java/org/apache/ignite/examples/BasicExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/BasicExamplesSelfTest.java @@ -23,6 +23,7 @@ import org.apache.ignite.examples.computegrid.ComputeRunnableExample; import org.apache.ignite.examples.datastructures.IgniteExecutorServiceExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** * Closure examples self test. @@ -31,6 +32,7 @@ public class BasicExamplesSelfTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testBroadcastExample() throws Exception { ComputeBroadcastExample.main(EMPTY_ARGS); } @@ -38,6 +40,7 @@ public void testBroadcastExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCallableExample() throws Exception { ComputeCallableExample.main(EMPTY_ARGS); } @@ -45,6 +48,7 @@ public void testCallableExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClosureExample() throws Exception { ComputeClosureExample.main(EMPTY_ARGS); } @@ -52,6 +56,7 @@ public void testClosureExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExecutorExample() throws Exception { IgniteExecutorServiceExample.main(EMPTY_ARGS); } @@ -67,6 +72,7 @@ public void testExecutorExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRunnableExample() throws Exception { ComputeRunnableExample.main(EMPTY_ARGS); } diff --git a/examples/src/test/java/org/apache/ignite/examples/CacheClientBinaryExampleTest.java b/examples/src/test/java/org/apache/ignite/examples/CacheClientBinaryExampleTest.java index 01be0bc7e0552..db25c603fd4fb 100644 --- a/examples/src/test/java/org/apache/ignite/examples/CacheClientBinaryExampleTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/CacheClientBinaryExampleTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.examples.binary.datagrid.CacheClientBinaryPutGetExample; import org.apache.ignite.examples.binary.datagrid.CacheClientBinaryQueryExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** * @@ -33,6 +34,7 @@ public class CacheClientBinaryExampleTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testBinaryPutGetExample() throws Exception { CacheClientBinaryPutGetExample.main(new String[] {}); } @@ -40,6 +42,7 @@ public void testBinaryPutGetExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryQueryExample() throws Exception { CacheClientBinaryQueryExample.main(new String[] {}); } diff --git a/examples/src/test/java/org/apache/ignite/examples/CacheContinuousQueryExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/CacheContinuousQueryExamplesSelfTest.java index 1a1ae4e8e8e9e..d3aa704edcd2d 100644 --- a/examples/src/test/java/org/apache/ignite/examples/CacheContinuousQueryExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/CacheContinuousQueryExamplesSelfTest.java @@ -21,6 +21,7 @@ import org.apache.ignite.examples.datagrid.CacheContinuousQueryExample; import org.apache.ignite.examples.datagrid.CacheContinuousQueryWithTransformerExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** */ @@ -28,6 +29,7 @@ public class CacheContinuousQueryExamplesSelfTest extends GridAbstractExamplesTe /** * @throws Exception If failed. */ + @Test public void testCacheContinuousAsyncQueryExample() throws Exception { CacheContinuousAsyncQueryExample.main(new String[] {}); } @@ -35,6 +37,7 @@ public void testCacheContinuousAsyncQueryExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheContinuousQueryExample() throws Exception { CacheContinuousQueryExample.main(new String[] {}); } @@ -42,6 +45,7 @@ public void testCacheContinuousQueryExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheContinuousQueryWithTransformerExample() throws Exception { CacheContinuousQueryWithTransformerExample.main(new String[] {}); } diff --git a/examples/src/test/java/org/apache/ignite/examples/CacheExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/CacheExamplesSelfTest.java index 0085573133ce8..258adbc5139eb 100644 --- a/examples/src/test/java/org/apache/ignite/examples/CacheExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/CacheExamplesSelfTest.java @@ -21,6 +21,7 @@ import org.apache.ignite.examples.datagrid.CacheEntryProcessorExample; import org.apache.ignite.examples.datagrid.CacheApiExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; //import org.apache.ignite.examples.datagrid.starschema.*; //import org.apache.ignite.examples.datagrid.store.dummy.*; @@ -33,6 +34,7 @@ public class CacheExamplesSelfTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testCacheAffinityExample() throws Exception { CacheAffinityExample.main(EMPTY_ARGS); } @@ -40,6 +42,7 @@ public void testCacheAffinityExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheEntryProcessorExample() throws Exception { CacheEntryProcessorExample.main(EMPTY_ARGS); } @@ -112,6 +115,7 @@ public void testCacheEntryProcessorExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheApiExample() throws Exception { CacheApiExample.main(EMPTY_ARGS); } diff --git a/examples/src/test/java/org/apache/ignite/examples/CheckpointExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/CheckpointExamplesSelfTest.java index 03185c8a14f67..5327bed40e78c 100644 --- a/examples/src/test/java/org/apache/ignite/examples/CheckpointExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/CheckpointExamplesSelfTest.java @@ -18,10 +18,12 @@ package org.apache.ignite.examples; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * Checkpoint examples self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class CheckpointExamplesSelfTest extends GridAbstractExamplesTest { /** * TODO: IGNITE-711 next example(s) should be implemented for java 8 diff --git a/examples/src/test/java/org/apache/ignite/examples/ClusterGroupExampleSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ClusterGroupExampleSelfTest.java index 35b251012018d..d6c5d49650529 100644 --- a/examples/src/test/java/org/apache/ignite/examples/ClusterGroupExampleSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/ClusterGroupExampleSelfTest.java @@ -18,10 +18,12 @@ package org.apache.ignite.examples; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class ClusterGroupExampleSelfTest extends GridAbstractExamplesTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { diff --git a/examples/src/test/java/org/apache/ignite/examples/ComputeClientBinaryExampleTest.java b/examples/src/test/java/org/apache/ignite/examples/ComputeClientBinaryExampleTest.java index 5dcad62d2ddb8..30480f0ea3a34 100644 --- a/examples/src/test/java/org/apache/ignite/examples/ComputeClientBinaryExampleTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/ComputeClientBinaryExampleTest.java @@ -18,6 +18,7 @@ import org.apache.ignite.examples.binary.computegrid.ComputeClientBinaryTaskExecutionExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** * @@ -31,6 +32,7 @@ public class ComputeClientBinaryExampleTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testBinaryTaskExecutionExample() throws Exception { ComputeClientBinaryTaskExecutionExample.main(new String[] {}); } diff --git a/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesMultiNodeSelfTest.java index f73a74d3aa394..01aa4c973a2b9 100644 --- a/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesMultiNodeSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesMultiNodeSelfTest.java @@ -17,12 +17,15 @@ package org.apache.ignite.examples; +import org.junit.Ignore; + /** * Continuation example multi-node self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class ContinuationExamplesMultiNodeSelfTest extends ContinuationExamplesSelfTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startRemoteNodes(); } -} \ No newline at end of file +} diff --git a/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesSelfTest.java index 512a55b794df5..5ee93f6ea4053 100644 --- a/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/ContinuationExamplesSelfTest.java @@ -20,10 +20,12 @@ //import org.apache.ignite.examples.computegrid.*; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * Continuation example self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class ContinuationExamplesSelfTest extends GridAbstractExamplesTest { /** * TODO: IGNITE-711 next example(s) should be implemented for java 8 diff --git a/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesMultiNodeSelfTest.java index e85e28186b79a..2495e6d15d74b 100644 --- a/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesMultiNodeSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesMultiNodeSelfTest.java @@ -17,12 +17,15 @@ package org.apache.ignite.examples; +import org.junit.Ignore; + /** * ContinuousMapperExample multi-node self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class ContinuousMapperExamplesMultiNodeSelfTest extends ContinuationExamplesSelfTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startRemoteNodes(); } -} \ No newline at end of file +} diff --git a/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesSelfTest.java index 0ae7dc1c420a7..0029a5cb5d84a 100644 --- a/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/ContinuousMapperExamplesSelfTest.java @@ -18,10 +18,12 @@ package org.apache.ignite.examples; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * ContinuousMapperExample self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class ContinuousMapperExamplesSelfTest extends GridAbstractExamplesTest { /** * TODO: IGNITE-711 next example(s) should be implemented for java 8 diff --git a/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesMultiNodeSelfTest.java index c57f2851bd682..2edf75eb53ef2 100644 --- a/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesMultiNodeSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesMultiNodeSelfTest.java @@ -17,11 +17,14 @@ package org.apache.ignite.examples; +import org.junit.Ignore; + /** * Deployment examples multi-node self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class DeploymentExamplesMultiNodeSelfTest extends DeploymentExamplesSelfTest { - // TODO: IGNITE-711 next example(s) should be implemented for java 8 + // TODO: IGNITE-711 next example(s) should be implemented for java 8 // or testing method(s) should be removed if example(s) does not applicable for java 8. /** {@inheritDoc} */ // @Override public void testDeploymentExample() throws Exception { @@ -29,4 +32,4 @@ public class DeploymentExamplesMultiNodeSelfTest extends DeploymentExamplesSelfT // // super.testDeploymentExample(); // } -} \ No newline at end of file +} diff --git a/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesSelfTest.java index 8a01b9b823605..2711d25cea928 100644 --- a/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/DeploymentExamplesSelfTest.java @@ -20,10 +20,12 @@ //import org.apache.ignite.examples.misc.deployment.*; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * Deployment examples self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class DeploymentExamplesSelfTest extends GridAbstractExamplesTest { // TODO: IGNITE-711 next example(s) should be implemented for java 8 // or testing method(s) should be removed if example(s) does not applicable for java 8. diff --git a/examples/src/test/java/org/apache/ignite/examples/EncryptedCacheExampleSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/EncryptedCacheExampleSelfTest.java index 234a3aca08d1c..66cd4cf341ac9 100644 --- a/examples/src/test/java/org/apache/ignite/examples/EncryptedCacheExampleSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/EncryptedCacheExampleSelfTest.java @@ -19,10 +19,12 @@ import org.apache.ignite.examples.encryption.EncryptedCacheExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** */ public class EncryptedCacheExampleSelfTest extends GridAbstractExamplesTest { + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { cleanPersistenceDir(); } @@ -30,6 +32,7 @@ public class EncryptedCacheExampleSelfTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testBinaryPutGetExample() throws Exception { EncryptedCacheExample.main(new String[] {}); } diff --git a/examples/src/test/java/org/apache/ignite/examples/EventsExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/EventsExamplesSelfTest.java index 8e675a3c0be7b..635b247ad76f5 100644 --- a/examples/src/test/java/org/apache/ignite/examples/EventsExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/EventsExamplesSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.examples.events.EventsExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** * Events examples self test. @@ -27,6 +28,7 @@ public class EventsExamplesSelfTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testEventsExample() throws Exception { EventsExample.main(EMPTY_ARGS); } diff --git a/examples/src/test/java/org/apache/ignite/examples/IgfsExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/IgfsExamplesSelfTest.java index 1be686ca86882..d227acb79bb0d 100644 --- a/examples/src/test/java/org/apache/ignite/examples/IgfsExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/IgfsExamplesSelfTest.java @@ -21,10 +21,12 @@ //import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * IGFS examples self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class IgfsExamplesSelfTest extends GridAbstractExamplesTest { /** IGFS config with shared memory IPC. */ private static final String IGFS_SHMEM_CFG = "modules/core/src/test/config/igfs-shmem.xml"; diff --git a/examples/src/test/java/org/apache/ignite/examples/LifecycleExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/LifecycleExamplesSelfTest.java index b89a8f7fbc48c..2b80865943d5f 100644 --- a/examples/src/test/java/org/apache/ignite/examples/LifecycleExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/LifecycleExamplesSelfTest.java @@ -20,10 +20,12 @@ //import org.apache.ignite.examples.misc.lifecycle.*; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * LifecycleExample self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class LifecycleExamplesSelfTest extends GridAbstractExamplesTest { /** * TODO: IGNITE-711 next example(s) should be implemented for java 8 diff --git a/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesMultiNodeSelfTest.java index fd57fbb0171a6..3972084e9786f 100644 --- a/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesMultiNodeSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesMultiNodeSelfTest.java @@ -19,15 +19,18 @@ //import org.apache.ignite.examples.misc.client.memcache.*; +import org.junit.Ignore; + /** * MemcacheRestExample multi-node self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class MemcacheRestExamplesMultiNodeSelfTest extends MemcacheRestExamplesSelfTest { - // TODO: IGNITE-711 next example(s) should be implemented for java 8 + // TODO: IGNITE-711 next example(s) should be implemented for java 8 // or testing method(s) should be removed if example(s) does not applicable for java 8. /** {@inheritDoc} */ // @Override protected void beforeTest() throws Exception { // for (int i = 0; i < RMT_NODES_CNT; i++) // startGrid("memcache-rest-examples-" + i, MemcacheRestExampleNodeStartup.configuration()); // } -} \ No newline at end of file +} diff --git a/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesSelfTest.java index 762343d31f261..f2b7b6e5019df 100644 --- a/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/MemcacheRestExamplesSelfTest.java @@ -20,10 +20,12 @@ //import org.apache.ignite.examples.misc.client.memcache.*; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * MemcacheRestExample self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class MemcacheRestExamplesSelfTest extends GridAbstractExamplesTest { // TODO: IGNITE-711 next example(s) should be implemented for java 8 // or testing method(s) should be removed if example(s) does not applicable for java 8. diff --git a/examples/src/test/java/org/apache/ignite/examples/MessagingExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/MessagingExamplesSelfTest.java index 3c94d3b20a6c2..0686dffc9c541 100644 --- a/examples/src/test/java/org/apache/ignite/examples/MessagingExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/MessagingExamplesSelfTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.examples.messaging.MessagingExample; import org.apache.ignite.examples.messaging.MessagingPingPongExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** * Messaging examples self test. @@ -33,6 +34,7 @@ public class MessagingExamplesSelfTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testMessagingExample() throws Exception { MessagingExample.main(EMPTY_ARGS); } @@ -40,6 +42,7 @@ public void testMessagingExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMessagingPingPongExample() throws Exception { MessagingPingPongExample.main(EMPTY_ARGS); } diff --git a/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesMultiNodeSelfTest.java index f641a45aaa2c3..135f8649f399f 100644 --- a/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesMultiNodeSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesMultiNodeSelfTest.java @@ -17,12 +17,15 @@ package org.apache.ignite.examples; +import org.junit.Ignore; + /** * PrimeExample multi-node self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class MonteCarloExamplesMultiNodeSelfTest extends MonteCarloExamplesSelfTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startRemoteNodes(); } -} \ No newline at end of file +} diff --git a/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesSelfTest.java index beba341d5d2a1..66026b2f55b21 100644 --- a/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/MonteCarloExamplesSelfTest.java @@ -20,6 +20,7 @@ //import org.apache.ignite.examples.computegrid.montecarlo.*; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * Ignite examples self test. Excludes Ignite Spring tests. @@ -65,6 +66,7 @@ * Classpath should contain the {@code ${IGNITE_HOME}/modules/tests/config/aop/aspectj} folder. * */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class MonteCarloExamplesSelfTest extends GridAbstractExamplesTest { /** * TODO: IGNITE-711 next example(s) should be implemented for java 8 diff --git a/examples/src/test/java/org/apache/ignite/examples/SpringBeanExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/SpringBeanExamplesSelfTest.java index 4cc209f0e9cdf..c9c69dc52a488 100644 --- a/examples/src/test/java/org/apache/ignite/examples/SpringBeanExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/SpringBeanExamplesSelfTest.java @@ -20,10 +20,12 @@ //import org.apache.ignite.examples.misc.springbean.*; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * Spring bean examples self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class SpringBeanExamplesSelfTest extends GridAbstractExamplesTest { /** * TODO: IGNITE-711 next example(s) should be implemented for java 8 diff --git a/examples/src/test/java/org/apache/ignite/examples/SpringDataExampleSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/SpringDataExampleSelfTest.java index 516ad4546347c..bba21b3d66808 100644 --- a/examples/src/test/java/org/apache/ignite/examples/SpringDataExampleSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/SpringDataExampleSelfTest.java @@ -18,6 +18,7 @@ import org.apache.ignite.examples.springdata.SpringDataExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** * Spring Data example test. @@ -26,6 +27,7 @@ public class SpringDataExampleSelfTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testSpringDataExample() throws Exception { SpringDataExample.main(EMPTY_ARGS); } diff --git a/examples/src/test/java/org/apache/ignite/examples/SqlExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/SqlExamplesSelfTest.java index 0bf01d8a534d2..c105335b9e73c 100644 --- a/examples/src/test/java/org/apache/ignite/examples/SqlExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/SqlExamplesSelfTest.java @@ -21,6 +21,7 @@ import org.apache.ignite.examples.sql.SqlDmlExample; import org.apache.ignite.examples.sql.SqlQueriesExample; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Test; /** * SQL examples self test. @@ -29,6 +30,7 @@ public class SqlExamplesSelfTest extends GridAbstractExamplesTest { /** * @throws Exception If failed. */ + @Test public void testSqlJavaExample() throws Exception { SqlQueriesExample.main(EMPTY_ARGS); } @@ -36,6 +38,7 @@ public void testSqlJavaExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlDmlExample() throws Exception { SqlDmlExample.main(EMPTY_ARGS); } @@ -43,6 +46,7 @@ public void testSqlDmlExample() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlDdlExample() throws Exception { SqlDdlExample.main(EMPTY_ARGS); } diff --git a/examples/src/test/java/org/apache/ignite/examples/TaskExamplesMultiNodeSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/TaskExamplesMultiNodeSelfTest.java index 06c4dd831fb86..676123425e5cf 100644 --- a/examples/src/test/java/org/apache/ignite/examples/TaskExamplesMultiNodeSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/TaskExamplesMultiNodeSelfTest.java @@ -17,12 +17,15 @@ package org.apache.ignite.examples; +import org.junit.Ignore; + /** * Hello world examples multi-node self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class TaskExamplesMultiNodeSelfTest extends TaskExamplesSelfTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startRemoteNodes(); } -} \ No newline at end of file +} diff --git a/examples/src/test/java/org/apache/ignite/examples/TaskExamplesSelfTest.java b/examples/src/test/java/org/apache/ignite/examples/TaskExamplesSelfTest.java index 72ad3c7f87e8d..a9b7f95c0a338 100644 --- a/examples/src/test/java/org/apache/ignite/examples/TaskExamplesSelfTest.java +++ b/examples/src/test/java/org/apache/ignite/examples/TaskExamplesSelfTest.java @@ -20,10 +20,12 @@ //import org.apache.ignite.examples.computegrid.*; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.Ignore; /** * Hello world examples self test. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-711") public class TaskExamplesSelfTest extends GridAbstractExamplesTest { // TODO: IGNITE-711 next example(s) should be implemented for java 8 // or testing method(s) should be removed if example(s) does not applicable for java 8. diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesJ8SelfTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesJ8SelfTestSuite.java index f73d977916845..f281ec57252bf 100644 --- a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesJ8SelfTestSuite.java +++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesJ8SelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.examples.BasicExamplesMultiNodeSelfTest; import org.apache.ignite.examples.BasicExamplesSelfTest; @@ -45,35 +46,35 @@ public static TestSuite suite() throws Exception { TestSuite suite = new TestSuite("Ignite Examples Test Suite"); - suite.addTest(new TestSuite(CacheExamplesSelfTest.class)); - suite.addTest(new TestSuite(BasicExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BasicExamplesSelfTest.class)); -// suite.addTest(new TestSuite(ContinuationExamplesSelfTest.class)); -// suite.addTest(new TestSuite(ContinuousMapperExamplesSelfTest.class)); -// suite.addTest(new TestSuite(DeploymentExamplesSelfTest.class)); - suite.addTest(new TestSuite(EventsExamplesSelfTest.class)); -// suite.addTest(new TestSuite(LifecycleExamplesSelfTest.class)); - suite.addTest(new TestSuite(MessagingExamplesSelfTest.class)); -// suite.addTest(new TestSuite(MemcacheRestExamplesSelfTest.class)); -// suite.addTest(new TestSuite(MonteCarloExamplesSelfTest.class)); -// suite.addTest(new TestSuite(TaskExamplesSelfTest.class)); -// suite.addTest(new TestSuite(SpringBeanExamplesSelfTest.class)); -// suite.addTest(new TestSuite(IgfsExamplesSelfTest.class)); -// suite.addTest(new TestSuite(CheckpointExamplesSelfTest.class)); -// suite.addTest(new TestSuite(HibernateL2CacheExampleSelfTest.class)); -// suite.addTest(new TestSuite(ClusterGroupExampleSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(ContinuationExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(ContinuousMapperExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(DeploymentExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(EventsExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(LifecycleExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(MessagingExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(MemcacheRestExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(MonteCarloExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(TaskExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(SpringBeanExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(IgfsExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(CheckpointExamplesSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(HibernateL2CacheExampleSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(ClusterGroupExampleSelfTest.class)); // Multi-node. - suite.addTest(new TestSuite(CacheExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(BasicExamplesMultiNodeSelfTest.class)); -// suite.addTest(new TestSuite(ContinuationExamplesMultiNodeSelfTest.class)); -// suite.addTest(new TestSuite(ContinuousMapperExamplesMultiNodeSelfTest.class)); -// suite.addTest(new TestSuite(DeploymentExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(EventsExamplesMultiNodeSelfTest.class)); -// suite.addTest(new TestSuite(TaskExamplesMultiNodeSelfTest.class)); -// suite.addTest(new TestSuite(MemcacheRestExamplesMultiNodeSelfTest.class)); -// suite.addTest(new TestSuite(MonteCarloExamplesMultiNodeSelfTest.class)); -// suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BasicExamplesMultiNodeSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(ContinuationExamplesMultiNodeSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(ContinuousMapperExamplesMultiNodeSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(DeploymentExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(EventsExamplesMultiNodeSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(TaskExamplesMultiNodeSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(MemcacheRestExamplesMultiNodeSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(MonteCarloExamplesMultiNodeSelfTest.class)); +// suite.addTest(new JUnit4TestAdapter(HibernateL2CacheExampleMultiNodeSelfTest.class)); return suite; } diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java index 6b41301ccef50..8551460dd76dd 100644 --- a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java +++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesMLTestSuite.java @@ -27,12 +27,21 @@ import javassist.ClassClassPath; import javassist.ClassPool; import javassist.CtClass; +import javassist.CtMethod; import javassist.CtNewMethod; import javassist.NotFoundException; +import javassist.bytecode.AnnotationsAttribute; +import javassist.bytecode.ClassFile; +import javassist.bytecode.ConstPool; +import javassist.bytecode.annotation.Annotation; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.examples.ml.util.MLExamplesCommonArgs; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP; @@ -41,13 +50,21 @@ *

* Contains only ML Grid Ignite examples tests.

*/ -public class IgniteExamplesMLTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteExamplesMLTestSuite { /** Base package to create test classes in. */ private static final String basePkgForTests = "org.apache.ignite.examples.ml"; /** Test class name pattern. */ private static final String clsNamePtrn = ".*Example$"; + /** */ + @BeforeClass + public static void init() { + System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, + GridTestUtils.getNextMulticastGroup(IgniteExamplesMLTestSuite.class)); + } + /** * Creates test suite for Ignite ML examples. * @@ -55,13 +72,10 @@ public class IgniteExamplesMLTestSuite extends TestSuite { * @throws Exception If failed. */ public static TestSuite suite() throws Exception { - System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, - GridTestUtils.getNextMulticastGroup(IgniteExamplesMLTestSuite.class)); - TestSuite suite = new TestSuite("Ignite ML Examples Test Suite"); for (Class clazz : getClasses(basePkgForTests)) - suite.addTest(new TestSuite(makeTestClass(clazz))); + suite.addTest(new JUnit4TestAdapter(makeTestClass(clazz))); return suite; } @@ -79,15 +93,25 @@ private static Class makeTestClass(Class exampleCls) ClassPool cp = ClassPool.getDefault(); cp.insertClassPath(new ClassClassPath(IgniteExamplesMLTestSuite.class)); - CtClass cl = cp.makeClass(basePkgForTests + "." + exampleCls.getSimpleName() + "SelfName"); + CtClass cl = cp.makeClass(basePkgForTests + "." + exampleCls.getSimpleName() + "SelfTest"); cl.setSuperclass(cp.get(GridAbstractExamplesTest.class.getName())); - cl.addMethod(CtNewMethod.make("public void testExample() { " + CtMethod mtd = CtNewMethod.make("public void testExample() { " + exampleCls.getCanonicalName() + ".main(" + MLExamplesCommonArgs.class.getName() - + ".EMPTY_ARGS_ML); }", cl)); + + ".EMPTY_ARGS_ML); }", cl); + + // Create and add annotation. + ClassFile ccFile = cl.getClassFile(); + ConstPool constpool = ccFile.getConstPool(); + AnnotationsAttribute attr = new AnnotationsAttribute(constpool, AnnotationsAttribute.visibleTag); + Annotation annot = new Annotation("org.junit.Test", constpool); + attr.addAnnotation(annot); + mtd.getMethodInfo().addAttribute(attr); + + cl.addMethod(mtd); return cl.toClass(); } diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java index 9553103c5d036..31e9a6c48135d 100644 --- a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java +++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.examples.BasicExamplesMultiNodeSelfTest; import org.apache.ignite.examples.BasicExamplesSelfTest; @@ -48,62 +49,64 @@ import org.apache.ignite.examples.SqlExamplesSelfTest; import org.apache.ignite.examples.TaskExamplesMultiNodeSelfTest; import org.apache.ignite.examples.TaskExamplesSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Examples test suite. *

* Contains all Ignite examples tests.

*/ -public class IgniteExamplesSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteExamplesSelfTestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { // System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, // GridTestUtils.getNextMulticastGroup(IgniteExamplesSelfTestSuite.class)); TestSuite suite = new TestSuite("Ignite Examples Test Suite"); - suite.addTest(new TestSuite(CacheExamplesSelfTest.class)); - suite.addTest(new TestSuite(SqlExamplesSelfTest.class)); - suite.addTest(new TestSuite(BasicExamplesSelfTest.class)); - suite.addTest(new TestSuite(ContinuationExamplesSelfTest.class)); - suite.addTest(new TestSuite(ContinuousMapperExamplesSelfTest.class)); - suite.addTest(new TestSuite(DeploymentExamplesSelfTest.class)); - suite.addTest(new TestSuite(EventsExamplesSelfTest.class)); - suite.addTest(new TestSuite(LifecycleExamplesSelfTest.class)); - suite.addTest(new TestSuite(MessagingExamplesSelfTest.class)); - suite.addTest(new TestSuite(MemcacheRestExamplesSelfTest.class)); - suite.addTest(new TestSuite(MonteCarloExamplesSelfTest.class)); - suite.addTest(new TestSuite(TaskExamplesSelfTest.class)); - suite.addTest(new TestSuite(SpringBeanExamplesSelfTest.class)); - suite.addTest(new TestSuite(SpringDataExampleSelfTest.class)); - suite.addTest(new TestSuite(IgfsExamplesSelfTest.class)); - suite.addTest(new TestSuite(CheckpointExamplesSelfTest.class)); - suite.addTest(new TestSuite(ClusterGroupExampleSelfTest.class)); - suite.addTest(new TestSuite(CacheContinuousQueryExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SqlExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BasicExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ContinuationExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ContinuousMapperExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DeploymentExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(EventsExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(LifecycleExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(MessagingExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(MemcacheRestExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(MonteCarloExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TaskExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SpringBeanExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SpringDataExampleSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CheckpointExamplesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClusterGroupExampleSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryExamplesSelfTest.class)); // Multi-node. - suite.addTest(new TestSuite(CacheExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(BasicExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(ContinuationExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(ContinuousMapperExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(DeploymentExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(EventsExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(TaskExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(MemcacheRestExamplesMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(MonteCarloExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BasicExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ContinuationExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ContinuousMapperExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DeploymentExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(EventsExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TaskExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(MemcacheRestExamplesMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(MonteCarloExamplesMultiNodeSelfTest.class)); // Binary. - suite.addTest(new TestSuite(CacheClientBinaryExampleTest.class)); - suite.addTest(new TestSuite(ComputeClientBinaryExampleTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheClientBinaryExampleTest.class)); + suite.addTest(new JUnit4TestAdapter(ComputeClientBinaryExampleTest.class)); // ML Grid. - suite.addTest(IgniteExamplesMLTestSuite.suite()); + suite.addTest(new JUnit4TestAdapter(IgniteExamplesMLTestSuite.class)); // Encryption. - suite.addTestSuite(EncryptedCacheExampleSelfTest.class); + suite.addTest(new JUnit4TestAdapter(EncryptedCacheExampleSelfTest.class)); return suite; } diff --git a/examples/src/test/spark/org/apache/ignite/spark/testsuites/IgniteExamplesSparkSelfTestSuite.java b/examples/src/test/spark/org/apache/ignite/spark/testsuites/IgniteExamplesSparkSelfTestSuite.java index 6328ee241a190..43a1198ce569f 100644 --- a/examples/src/test/spark/org/apache/ignite/spark/testsuites/IgniteExamplesSparkSelfTestSuite.java +++ b/examples/src/test/spark/org/apache/ignite/spark/testsuites/IgniteExamplesSparkSelfTestSuite.java @@ -17,11 +17,14 @@ package org.apache.ignite.spark.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spark.examples.IgniteDataFrameSelfTest; import org.apache.ignite.spark.examples.JavaIgniteDataFrameSelfTest; import org.apache.ignite.spark.examples.SharedRDDExampleSelfTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP; @@ -30,20 +33,20 @@ *

* Contains only Spring ignite examples tests. */ -public class IgniteExamplesSparkSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteExamplesSparkSelfTestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, GridTestUtils.getNextMulticastGroup(IgniteExamplesSparkSelfTestSuite.class)); TestSuite suite = new TestSuite("Ignite Spark Examples Test Suite"); - suite.addTest(new TestSuite(SharedRDDExampleSelfTest.class)); - suite.addTest(new TestSuite(IgniteDataFrameSelfTest.class)); - suite.addTest(new TestSuite(JavaIgniteDataFrameSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SharedRDDExampleSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDataFrameSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JavaIgniteDataFrameSelfTest.class)); return suite; } diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java index 33f2cddbfaddf..0bb60688734a3 100644 --- a/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java @@ -28,11 +28,11 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.deployment.local.LocalDeploymentSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestClassLoader; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CLASS_DEPLOYED; import static org.apache.ignite.events.EventType.EVT_TASK_DEPLOYED; @@ -40,11 +40,9 @@ /** * Abstract AOP test. */ -@SuppressWarnings( {"OverlyStrongTypeCast", "JUnitAbstractTestClassNamingConvention", "ProhibitedExceptionDeclared", "IfMayBeConditional"}) +@SuppressWarnings( {"OverlyStrongTypeCast", "ProhibitedExceptionDeclared", "IfMayBeConditional"}) +@RunWith(JUnit4.class) public abstract class AbstractAopTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private DeploymentMode depMode = DeploymentMode.PRIVATE; @@ -54,8 +52,6 @@ public abstract class AbstractAopTest extends GridCommonAbstractTest { cfg.setDeploymentSpi(new LocalDeploymentSpi()); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setMetricsUpdateFrequency(500); cfg.setDeploymentMode(depMode); @@ -65,6 +61,7 @@ public abstract class AbstractAopTest extends GridCommonAbstractTest { /** * @throws Exception If test failed. */ + @Test public void testDefaultPrivate() throws Exception { checkDefault(DeploymentMode.PRIVATE); } @@ -72,6 +69,7 @@ public void testDefaultPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultIsolated() throws Exception { checkDefault(DeploymentMode.ISOLATED); } @@ -79,6 +77,7 @@ public void testDefaultIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultContinuous() throws Exception { checkDefault(DeploymentMode.CONTINUOUS); } @@ -86,6 +85,7 @@ public void testDefaultContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultShared() throws Exception { checkDefault(DeploymentMode.SHARED); } @@ -93,6 +93,7 @@ public void testDefaultShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultWithUserClassLoaderPrivate() throws Exception { checkDefaultWithUserClassLoader(DeploymentMode.PRIVATE); } @@ -100,6 +101,7 @@ public void testDefaultWithUserClassLoaderPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultWithUserClassLoaderIsolated() throws Exception { checkDefaultWithUserClassLoader(DeploymentMode.ISOLATED); } @@ -107,6 +109,7 @@ public void testDefaultWithUserClassLoaderIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultWithUserClassLoaderContinuous() throws Exception { checkDefaultWithUserClassLoader(DeploymentMode.CONTINUOUS); } @@ -114,6 +117,7 @@ public void testDefaultWithUserClassLoaderContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultWithUserClassLoaderShared() throws Exception { checkDefaultWithUserClassLoader(DeploymentMode.SHARED); } @@ -121,6 +125,7 @@ public void testDefaultWithUserClassLoaderShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testSingleDeploymentWithUserClassLoaderPrivate() throws Exception { checkSingleDeploymentWithUserClassLoader(DeploymentMode.PRIVATE); } @@ -128,6 +133,7 @@ public void testSingleDeploymentWithUserClassLoaderPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testSingleDeploymentWithUserClassLoaderIsolated() throws Exception { checkSingleDeploymentWithUserClassLoader(DeploymentMode.ISOLATED); } @@ -135,6 +141,7 @@ public void testSingleDeploymentWithUserClassLoaderIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testSingleDeploymentWithUserClassLoaderContinuous() throws Exception { checkSingleDeploymentWithUserClassLoader(DeploymentMode.CONTINUOUS); } @@ -142,6 +149,7 @@ public void testSingleDeploymentWithUserClassLoaderContinuous() throws Exception /** * @throws Exception If test failed. */ + @Test public void testSingleDeploymentWithUserClassLoaderShared() throws Exception { checkSingleDeploymentWithUserClassLoader(DeploymentMode.SHARED); } @@ -149,6 +157,7 @@ public void testSingleDeploymentWithUserClassLoaderShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceWithUserClassLoaderPrivate() throws Exception { checkDefaultResourceWithUserClassLoader(DeploymentMode.PRIVATE); } @@ -156,6 +165,7 @@ public void testDefaultResourceWithUserClassLoaderPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceWithUserClassLoaderIsolated() throws Exception { checkDefaultResourceWithUserClassLoader(DeploymentMode.ISOLATED); } @@ -163,6 +173,7 @@ public void testDefaultResourceWithUserClassLoaderIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceWithUserClassLoaderContinuous() throws Exception { checkDefaultResourceWithUserClassLoader(DeploymentMode.CONTINUOUS); } @@ -170,6 +181,7 @@ public void testDefaultResourceWithUserClassLoaderContinuous() throws Exception /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceWithUserClassLoaderShared() throws Exception { checkDefaultResourceWithUserClassLoader(DeploymentMode.SHARED); } @@ -177,6 +189,7 @@ public void testDefaultResourceWithUserClassLoaderShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassPrivate() throws Exception { checkNonDefaultClass(DeploymentMode.PRIVATE); } @@ -184,6 +197,7 @@ public void testNonDefaultClassPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassIsolated() throws Exception { checkNonDefaultClass(DeploymentMode.ISOLATED); } @@ -191,6 +205,7 @@ public void testNonDefaultClassIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassContinuous() throws Exception { checkNonDefaultClass(DeploymentMode.CONTINUOUS); } @@ -198,6 +213,7 @@ public void testNonDefaultClassContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassShared() throws Exception { checkNonDefaultClass(DeploymentMode.SHARED); } @@ -205,6 +221,7 @@ public void testNonDefaultClassShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNamePrivate() throws Exception { checkNonDefaultName(DeploymentMode.PRIVATE); } @@ -212,6 +229,7 @@ public void testNonDefaultNamePrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameIsolated() throws Exception { checkNonDefaultName(DeploymentMode.ISOLATED); } @@ -219,6 +237,7 @@ public void testNonDefaultNameIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameContinuous() throws Exception { checkNonDefaultName(DeploymentMode.CONTINUOUS); } @@ -226,6 +245,7 @@ public void testNonDefaultNameContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameShared() throws Exception { checkNonDefaultName(DeploymentMode.SHARED); } @@ -233,6 +253,7 @@ public void testNonDefaultNameShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultExceptionPrivate() throws Exception { checkDefaultException(DeploymentMode.PRIVATE); } @@ -240,6 +261,7 @@ public void testDefaultExceptionPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultExceptionIsolated() throws Exception { checkDefaultException(DeploymentMode.ISOLATED); } @@ -247,6 +269,7 @@ public void testDefaultExceptionIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultExceptionContinuous() throws Exception { checkDefaultException(DeploymentMode.CONTINUOUS); } @@ -254,6 +277,7 @@ public void testDefaultExceptionContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultExceptionShared() throws Exception { checkDefaultException(DeploymentMode.SHARED); } @@ -261,6 +285,7 @@ public void testDefaultExceptionShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourcePrivate() throws Exception { checkDefaultResource(DeploymentMode.PRIVATE); } @@ -268,6 +293,7 @@ public void testDefaultResourcePrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceIsolated() throws Exception { checkDefaultResource(DeploymentMode.ISOLATED); } @@ -275,6 +301,7 @@ public void testDefaultResourceIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceContinuous() throws Exception { checkDefaultResource(DeploymentMode.CONTINUOUS); } @@ -282,6 +309,7 @@ public void testDefaultResourceContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceShared() throws Exception { checkDefaultResource(DeploymentMode.SHARED); } @@ -289,6 +317,7 @@ public void testDefaultResourceShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassResourcePrivate() throws Exception { checkNonDefaultClassResource(DeploymentMode.PRIVATE); } @@ -296,6 +325,7 @@ public void testNonDefaultClassResourcePrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassResourceIsolated() throws Exception { checkNonDefaultClassResource(DeploymentMode.ISOLATED); } @@ -303,6 +333,7 @@ public void testNonDefaultClassResourceIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassResourceContinuous() throws Exception { checkNonDefaultClassResource(DeploymentMode.CONTINUOUS); } @@ -310,6 +341,7 @@ public void testNonDefaultClassResourceContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassResourceShared() throws Exception { checkNonDefaultClassResource(DeploymentMode.SHARED); } @@ -317,6 +349,7 @@ public void testNonDefaultClassResourceShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameResourcePrivate() throws Exception { checkNonDefaultNameResource(DeploymentMode.PRIVATE); } @@ -324,6 +357,7 @@ public void testNonDefaultNameResourcePrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameResourceIsolated() throws Exception { checkNonDefaultNameResource(DeploymentMode.ISOLATED); } @@ -331,6 +365,7 @@ public void testNonDefaultNameResourceIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameResourceContinuous() throws Exception { checkNonDefaultNameResource(DeploymentMode.CONTINUOUS); } @@ -338,6 +373,7 @@ public void testNonDefaultNameResourceContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameResourceShared() throws Exception { checkNonDefaultNameResource(DeploymentMode.SHARED); } @@ -557,7 +593,6 @@ private void checkNonDefaultName(DeploymentMode depMode) throws Exception { * @param depMode Deployment mode to use. * @throws Exception If failed. */ - @SuppressWarnings({"CatchGenericClass"}) private void checkDefaultException(DeploymentMode depMode) throws Exception { this.depMode = depMode; diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/BasicAopSelfTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/BasicAopSelfTest.java index 54ac74fd2c4a3..024a5364717f7 100644 --- a/modules/aop/src/test/java/org/apache/ignite/gridify/BasicAopSelfTest.java +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/BasicAopSelfTest.java @@ -26,6 +26,9 @@ import java.util.Collection; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tries to execute dummy gridified task. It should fail because grid is not started. @@ -33,10 +36,12 @@ * The main purpose of this test is to check that AOP is properly configured. It should * be included in all suites that require AOP. */ +@RunWith(JUnit4.class) public class BasicAopSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAop() throws Exception { try { gridify(); @@ -71,4 +76,4 @@ private static class TestTask extends GridifyTaskSplitAdapter { return null; } } -} \ No newline at end of file +} diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXNonSpringAopSelfTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXNonSpringAopSelfTest.java index 2ebd272e6c604..14a7bff5585fe 100644 --- a/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXNonSpringAopSelfTest.java +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXNonSpringAopSelfTest.java @@ -25,6 +25,9 @@ import java.util.List; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * To run this test with JBoss AOP make sure of the following: @@ -51,10 +54,12 @@ * 2. Classpath should contains the ${IGNITE_HOME}/modules/tests/config/aop/aspectj folder. */ @GridCommonTest(group="AOP") +@RunWith(JUnit4.class) public class GridifySetToXXXNonSpringAopSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testGridifySetToSet() throws Exception { try { startGrid("GridifySetToSetTarget"); @@ -111,6 +116,7 @@ public void testGridifySetToSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGridifySetToValue() throws Exception { try { startGrid("GridifySetToValueTarget"); @@ -206,4 +212,4 @@ private static class MathEnumerationAdapter implements Enumeration { return iter.next(); } } -} \ No newline at end of file +} diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXSpringAopSelfTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXSpringAopSelfTest.java index 1dd499a031a16..7ff56d09a8b59 100644 --- a/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXSpringAopSelfTest.java +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/GridifySetToXXXSpringAopSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.compute.gridify.aop.spring.GridifySpringEnhancer; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * To run this test with JBoss AOP make sure of the following: @@ -52,10 +55,12 @@ * 2. Classpath should contains the ${IGNITE_HOME}/modules/tests/config/aop/aspectj folder. */ @GridCommonTest(group="AOP") +@RunWith(JUnit4.class) public class GridifySetToXXXSpringAopSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testGridifySetToSet() throws Exception { try { startGrid("GridifySetToSetTarget"); @@ -112,6 +117,7 @@ public void testGridifySetToSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGridifySetToValue() throws Exception { try { startGrid("GridifySetToValueTarget"); @@ -207,4 +213,4 @@ private static class MathEnumerationAdapter implements Enumeration { return iter.next(); } } -} \ No newline at end of file +} diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridifyHierarchyTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridifyHierarchyTest.java index 3dc8d53b87326..232d92892a725 100644 --- a/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridifyHierarchyTest.java +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/hierarchy/GridifyHierarchyTest.java @@ -18,10 +18,14 @@ package org.apache.ignite.gridify.hierarchy; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Gridify hierarchy test. */ +@RunWith(JUnit4.class) public class GridifyHierarchyTest extends GridCommonAbstractTest { /** */ public GridifyHierarchyTest() { @@ -38,6 +42,7 @@ public void noneTestGridifyHierarchyProtected() { /** * @throws Exception If failed. */ + @Test public void testGridifyHierarchyPrivate() throws Exception { Target target = new Target(); @@ -48,4 +53,4 @@ public void testGridifyHierarchyPrivate() throws Exception { @Override public String getTestIgniteInstanceName() { return "GridifyHierarchyTest"; } -} \ No newline at end of file +} diff --git a/modules/aop/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerAopTest.java b/modules/aop/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerAopTest.java index 8236f435f9c1d..672225f404afc 100644 --- a/modules/aop/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerAopTest.java +++ b/modules/aop/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerAopTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_TASK_FINISHED; @@ -44,6 +47,7 @@ * * */ +@RunWith(JUnit4.class) public class OptimizedMarshallerAopTest extends GridCommonAbstractTest { /** */ private static final AtomicInteger cntr = new AtomicInteger(); @@ -71,6 +75,7 @@ public OptimizedMarshallerAopTest() { * * @throws Exception If failed. */ + @Test public void testUp() throws Exception { G.ignite().events().localListen(new IgnitePredicate() { @Override public boolean apply(Event evt) { @@ -95,4 +100,4 @@ public void testUp() throws Exception { private void gridify1() { X.println("Executes on grid"); } -} \ No newline at end of file +} diff --git a/modules/aop/src/test/java/org/apache/ignite/p2p/P2PGridifySelfTest.java b/modules/aop/src/test/java/org/apache/ignite/p2p/P2PGridifySelfTest.java index 7511d61b07fb4..42e527c08f613 100644 --- a/modules/aop/src/test/java/org/apache/ignite/p2p/P2PGridifySelfTest.java +++ b/modules/aop/src/test/java/org/apache/ignite/p2p/P2PGridifySelfTest.java @@ -28,12 +28,16 @@ import org.apache.ignite.testframework.GridTestClassLoader; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class P2PGridifySelfTest extends GridCommonAbstractTest { /** Current deployment mode. Used in {@link #getConfiguration(String)}. */ private DeploymentMode depMode; @@ -174,6 +178,7 @@ public Integer executeGridifyResource(int res) { * * @throws Exception if error occur. */ + @Test public void testPrivateMode() throws Exception { processTestBothNodesDeploy(DeploymentMode.PRIVATE); } @@ -183,6 +188,7 @@ public void testPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testIsolatedMode() throws Exception { processTestBothNodesDeploy(DeploymentMode.ISOLATED); } @@ -192,6 +198,7 @@ public void testIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { processTestBothNodesDeploy(DeploymentMode.CONTINUOUS); } @@ -201,6 +208,7 @@ public void testContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { processTestBothNodesDeploy(DeploymentMode.SHARED); } @@ -210,6 +218,7 @@ public void testSharedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testResourcePrivateMode() throws Exception { processTestGridifyResource(DeploymentMode.PRIVATE); } @@ -219,6 +228,7 @@ public void testResourcePrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testResourceIsolatedMode() throws Exception { processTestGridifyResource(DeploymentMode.ISOLATED); } @@ -228,6 +238,7 @@ public void testResourceIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testResourceContinuousMode() throws Exception { processTestGridifyResource(DeploymentMode.CONTINUOUS); } @@ -237,7 +248,8 @@ public void testResourceContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testResourceSharedMode() throws Exception { processTestGridifyResource(DeploymentMode.SHARED); } -} \ No newline at end of file +} diff --git a/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java b/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java index b2dcea2f61633..399d759135de8 100644 --- a/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java +++ b/modules/aop/src/test/java/org/apache/ignite/testsuites/IgniteAopSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.gridify.BasicAopSelfTest; import org.apache.ignite.gridify.GridifySetToXXXNonSpringAopSelfTest; @@ -24,6 +25,8 @@ import org.apache.ignite.gridify.NonSpringAopSelfTest; import org.apache.ignite.gridify.SpringAopSelfTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; import org.test.gridify.ExternalNonSpringAopSelfTest; import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP; @@ -31,26 +34,26 @@ /** * AOP test suite. */ -public class IgniteAopSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteAopSelfTestSuite { /** * @return AOP test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite AOP Test Suite"); // Test configuration. - suite.addTestSuite(BasicAopSelfTest.class); + suite.addTest(new JUnit4TestAdapter(BasicAopSelfTest.class)); - suite.addTestSuite(SpringAopSelfTest.class); - suite.addTestSuite(NonSpringAopSelfTest.class); - suite.addTestSuite(GridifySetToXXXSpringAopSelfTest.class); - suite.addTestSuite(GridifySetToXXXNonSpringAopSelfTest.class); - suite.addTestSuite(ExternalNonSpringAopSelfTest.class); + suite.addTest(new JUnit4TestAdapter(SpringAopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(NonSpringAopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridifySetToXXXSpringAopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridifySetToXXXNonSpringAopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ExternalNonSpringAopSelfTest.class)); // Examples System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, GridTestUtils.getNextMulticastGroup(IgniteAopSelfTestSuite.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/SingleSplitsLoadTest.java b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/SingleSplitsLoadTest.java index 888a2f5f6353d..48a57bc092b3a 100644 --- a/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/SingleSplitsLoadTest.java +++ b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/SingleSplitsLoadTest.java @@ -31,11 +31,15 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.apache.log4j.Level; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Single split load test. */ @GridCommonTest(group = "Load Test") +@RunWith(JUnit4.class) public class SingleSplitsLoadTest extends GridCommonAbstractTest { /** */ public SingleSplitsLoadTest() { @@ -81,6 +85,7 @@ private int getThreadCount() { * * @throws Exception If task execution failed. */ + @Test public void testLoad() throws Exception { final Ignite ignite = G.ignite(getTestIgniteInstanceName()); diff --git a/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifySingleSplitLoadTest.java b/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifySingleSplitLoadTest.java index 9abeb6ed1767d..f417c3c0157c2 100644 --- a/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifySingleSplitLoadTest.java +++ b/modules/aop/src/test/java/org/apache/loadtests/gridify/GridifySingleSplitLoadTest.java @@ -31,12 +31,15 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.apache.log4j.Level; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Gridify single split load test. */ -@SuppressWarnings({"CatchGenericClass"}) @GridCommonTest(group = "Load Test") +@RunWith(JUnit4.class) public class GridifySingleSplitLoadTest extends GridCommonAbstractTest { /** */ public GridifySingleSplitLoadTest() { @@ -45,7 +48,6 @@ public GridifySingleSplitLoadTest() { /** {@inheritDoc} */ - @SuppressWarnings("ConstantConditions") @Override public String getTestIgniteInstanceName() { // Gridify task has empty Ignite instance name by default so we need to change it // here. @@ -99,7 +101,7 @@ private int getThreadCount() { * * @throws Exception If task execution failed. */ - @SuppressWarnings("unchecked") + @Test public void testGridifyLoad() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); diff --git a/modules/aop/src/test/java/org/test/gridify/ExternalNonSpringAopSelfTest.java b/modules/aop/src/test/java/org/test/gridify/ExternalNonSpringAopSelfTest.java index 44fa48d3b73ca..55017339e63cd 100644 --- a/modules/aop/src/test/java/org/test/gridify/ExternalNonSpringAopSelfTest.java +++ b/modules/aop/src/test/java/org/test/gridify/ExternalNonSpringAopSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * To run this test with JBoss AOP make sure of the following: @@ -52,6 +55,7 @@ * 2. Classpath should contains the ${IGNITE_HOME}/modules/tests/config/aop/aspectj folder. */ @GridCommonTest(group="AOP") +@RunWith(JUnit4.class) public class ExternalNonSpringAopSelfTest extends GridCommonAbstractTest { /** */ private DeploymentMode depMode = DeploymentMode.PRIVATE; @@ -79,6 +83,7 @@ private void deployTask() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultPrivate() throws Exception { checkDefault(DeploymentMode.PRIVATE); } @@ -86,6 +91,7 @@ public void testDefaultPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultIsolated() throws Exception { checkDefault(DeploymentMode.ISOLATED); } @@ -93,6 +99,7 @@ public void testDefaultIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultContinuous() throws Exception { checkDefault(DeploymentMode.CONTINUOUS); } @@ -100,6 +107,7 @@ public void testDefaultContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultShared() throws Exception { checkDefault(DeploymentMode.SHARED); } @@ -107,6 +115,7 @@ public void testDefaultShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassPrivate() throws Exception { checkNonDefaultClass(DeploymentMode.PRIVATE); } @@ -114,6 +123,7 @@ public void testNonDefaultClassPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassIsolated() throws Exception { checkNonDefaultClass(DeploymentMode.ISOLATED); } @@ -121,6 +131,7 @@ public void testNonDefaultClassIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultContinuous() throws Exception { checkNonDefaultClass(DeploymentMode.CONTINUOUS); } @@ -128,6 +139,7 @@ public void testNonDefaultContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultShared() throws Exception { checkNonDefaultClass(DeploymentMode.SHARED); } @@ -135,6 +147,7 @@ public void testNonDefaultShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNamePrivate() throws Exception { checkNonDefaultName(DeploymentMode.PRIVATE); } @@ -142,6 +155,7 @@ public void testNonDefaultNamePrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameIsolated() throws Exception { checkNonDefaultName(DeploymentMode.ISOLATED); } @@ -149,6 +163,7 @@ public void testNonDefaultNameIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameContinuous() throws Exception { checkNonDefaultName(DeploymentMode.CONTINUOUS); } @@ -156,6 +171,7 @@ public void testNonDefaultNameContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameShared() throws Exception { checkNonDefaultName(DeploymentMode.SHARED); } @@ -163,6 +179,7 @@ public void testNonDefaultNameShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testTaskNameAndTaskClassPrivate() throws Exception { checkTaskNameAndTaskClass(DeploymentMode.PRIVATE); } @@ -170,6 +187,7 @@ public void testTaskNameAndTaskClassPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testTaskNameAndTaskClassIsolated() throws Exception { checkTaskNameAndTaskClass(DeploymentMode.ISOLATED); } @@ -177,6 +195,7 @@ public void testTaskNameAndTaskClassIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testTaskNameAndTaskClassContinuous() throws Exception { checkTaskNameAndTaskClass(DeploymentMode.CONTINUOUS); } @@ -184,6 +203,7 @@ public void testTaskNameAndTaskClassContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testTaskNameAndTaskClassShared() throws Exception { checkTaskNameAndTaskClass(DeploymentMode.SHARED); } @@ -191,6 +211,7 @@ public void testTaskNameAndTaskClassShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultExceptionPrivate() throws Exception { checkDefaultException(DeploymentMode.PRIVATE); } @@ -198,6 +219,7 @@ public void testDefaultExceptionPrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultExceptionIsolated() throws Exception { checkDefaultException(DeploymentMode.ISOLATED); } @@ -205,6 +227,7 @@ public void testDefaultExceptionIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultExceptionContinuous() throws Exception { checkDefaultException(DeploymentMode.CONTINUOUS); } @@ -212,6 +235,7 @@ public void testDefaultExceptionContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultExceptionShared() throws Exception { checkDefaultException(DeploymentMode.SHARED); } @@ -219,6 +243,7 @@ public void testDefaultExceptionShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourcePrivate() throws Exception { checkDefaultResource(DeploymentMode.PRIVATE); } @@ -226,6 +251,7 @@ public void testDefaultResourcePrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceIsolated() throws Exception { checkDefaultResource(DeploymentMode.ISOLATED); } @@ -233,6 +259,7 @@ public void testDefaultResourceIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceContinuous() throws Exception { checkDefaultResource(DeploymentMode.CONTINUOUS); } @@ -240,6 +267,7 @@ public void testDefaultResourceContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDefaultResourceShared() throws Exception { checkDefaultResource(DeploymentMode.SHARED); } @@ -247,6 +275,7 @@ public void testDefaultResourceShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassResourcePrivate() throws Exception { checkNonDefaultClassResource(DeploymentMode.PRIVATE); } @@ -254,6 +283,7 @@ public void testNonDefaultClassResourcePrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassResourceIsolated() throws Exception { checkNonDefaultClassResource(DeploymentMode.ISOLATED); } @@ -261,6 +291,7 @@ public void testNonDefaultClassResourceIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassResourceContinuous() throws Exception { checkNonDefaultClassResource(DeploymentMode.CONTINUOUS); } @@ -268,6 +299,7 @@ public void testNonDefaultClassResourceContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultClassResourceShared() throws Exception { checkNonDefaultClassResource(DeploymentMode.SHARED); } @@ -275,6 +307,7 @@ public void testNonDefaultClassResourceShared() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameResourcePrivate() throws Exception { checkNonDefaultNameResource(DeploymentMode.PRIVATE); } @@ -282,6 +315,7 @@ public void testNonDefaultNameResourcePrivate() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameResourceIsolated() throws Exception { checkNonDefaultNameResource(DeploymentMode.ISOLATED); } @@ -289,6 +323,7 @@ public void testNonDefaultNameResourceIsolated() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameResourceContinuous() throws Exception { checkNonDefaultNameResource(DeploymentMode.CONTINUOUS); } @@ -296,6 +331,7 @@ public void testNonDefaultNameResourceContinuous() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonDefaultNameResourceShared() throws Exception { checkNonDefaultNameResource(DeploymentMode.SHARED); } diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointManagerSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointManagerSelfTest.java index acda385d5fb7e..7816e7ba0af47 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointManagerSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointManagerSelfTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManagerAbstractSelfTest; import org.apache.ignite.testsuites.IgniteIgnore; import org.apache.ignite.testsuites.IgniteS3TestSuite; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checkpoint manager test using {@link S3CheckpointSpi}. */ +@RunWith(JUnit4.class) public class S3CheckpointManagerSelfTest extends GridCheckpointManagerAbstractSelfTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -52,6 +56,7 @@ public class S3CheckpointManagerSelfTest extends GridCheckpointManagerAbstractSe * @throws Exception Thrown if any exception occurs. */ @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420") + @Test public void testS3Based() throws Exception { retries = 6; @@ -62,9 +67,10 @@ public void testS3Based() throws Exception { * @throws Exception Thrown if any exception occurs. */ @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420") + @Test public void testMultiNodeS3Based() throws Exception { retries = 6; doMultiNodeTest("s3"); } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiConfigSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiConfigSelfTest.java index 727845b0d9915..446c715e0c96b 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiConfigSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiConfigSelfTest.java @@ -19,16 +19,21 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid S3 checkpoint SPI config self test. */ @GridSpiTest(spi = S3CheckpointSpi.class, group = "Checkpoint SPI") +@RunWith(JUnit4.class) public class S3CheckpointSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new S3CheckpointSpi(), "awsCredentials", null); } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiSelfTest.java index cb38083506e69..a25b5be481a53 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiSelfTest.java @@ -39,11 +39,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testsuites.IgniteIgnore; import org.apache.ignite.testsuites.IgniteS3TestSuite; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid S3 checkpoint SPI self test. */ @GridSpiTest(spi = S3CheckpointSpi.class, group = "Checkpoint SPI") +@RunWith(JUnit4.class) public class S3CheckpointSpiSelfTest extends GridSpiAbstractTest { /** */ private static final int CHECK_POINT_COUNT = 10; @@ -96,6 +100,7 @@ public class S3CheckpointSpiSelfTest extends GridSpiAbstractTest { - /** {@inheritDoc} */ @Override protected void spiConfigure(S3CheckpointSpi spi) throws Exception { AWSCredentials cred = new BasicAWSCredentials(IgniteS3TestSuite.getAccessKey(), @@ -43,8 +46,9 @@ public class S3CheckpointSpiStartStopBucketEndpointSelfTest extends GridSpiStart } /** {@inheritDoc} */ - @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420") + @Ignore("https://issues.apache.org/jira/browse/IGNITE-2420") + @Test @Override public void testStartStop() throws Exception { super.testStartStop(); } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiStartStopSSEAlgorithmSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiStartStopSSEAlgorithmSelfTest.java index 7bfb75dd7888e..cf4495225abd8 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiStartStopSSEAlgorithmSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiStartStopSSEAlgorithmSelfTest.java @@ -21,13 +21,17 @@ import com.amazonaws.auth.BasicAWSCredentials; import org.apache.ignite.spi.GridSpiStartStopAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.apache.ignite.testsuites.IgniteIgnore; import org.apache.ignite.testsuites.IgniteS3TestSuite; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid S3 checkpoint SPI start stop self test. */ @GridSpiTest(spi = S3CheckpointSpi.class, group = "Checkpoint SPI") +@RunWith(JUnit4.class) public class S3CheckpointSpiStartStopSSEAlgorithmSelfTest extends GridSpiStartStopAbstractTest { /** {@inheritDoc} */ @Override protected void spiConfigure(S3CheckpointSpi spi) throws Exception { @@ -42,8 +46,9 @@ public class S3CheckpointSpiStartStopSSEAlgorithmSelfTest extends GridSpiStartSt } /** {@inheritDoc} */ - @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420") + @Ignore("https://issues.apache.org/jira/browse/IGNITE-2420") + @Test @Override public void testStartStop() throws Exception { super.testStartStop(); } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiStartStopSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiStartStopSelfTest.java index a062b51f28e3f..5fec5027d1cdd 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiStartStopSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3CheckpointSpiStartStopSelfTest.java @@ -23,11 +23,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testsuites.IgniteIgnore; import org.apache.ignite.testsuites.IgniteS3TestSuite; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid S3 checkpoint SPI start stop self test. */ @GridSpiTest(spi = S3CheckpointSpi.class, group = "Checkpoint SPI") +@RunWith(JUnit4.class) public class S3CheckpointSpiStartStopSelfTest extends GridSpiStartStopAbstractTest { /** {@inheritDoc} */ @Override protected void spiConfigure(S3CheckpointSpi spi) throws Exception { @@ -43,7 +47,8 @@ public class S3CheckpointSpiStartStopSelfTest extends GridSpiStartStopAbstractTe /** {@inheritDoc} */ @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420") + @Test @Override public void testStartStop() throws Exception { super.testStartStop(); } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3SessionCheckpointSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3SessionCheckpointSelfTest.java index 54a7910d030f3..99a0cc5e8ba57 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3SessionCheckpointSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/checkpoint/s3/S3SessionCheckpointSelfTest.java @@ -24,15 +24,20 @@ import org.apache.ignite.session.GridSessionCheckpointSelfTest; import org.apache.ignite.testsuites.IgniteIgnore; import org.apache.ignite.testsuites.IgniteS3TestSuite; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid session checkpoint self test using {@link S3CheckpointSpi}. */ +@RunWith(JUnit4.class) public class S3SessionCheckpointSelfTest extends GridSessionCheckpointAbstractSelfTest { /** * @throws Exception If failed. */ @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420") + @Test public void testS3Checkpoint() throws Exception { IgniteConfiguration cfg = getConfiguration(); @@ -51,4 +56,4 @@ public void testS3Checkpoint() throws Exception { checkCheckpoints(cfg); } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinderSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinderSelfTest.java index 1217d8b4f98eb..85568f0f50540 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinderSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/elb/TcpDiscoveryElbIpFinderSelfTest.java @@ -19,10 +19,14 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * TcpDiscoveryElbIpFinderSelfTest test. */ +@RunWith(JUnit4.class) public class TcpDiscoveryElbIpFinderSelfTest extends TcpDiscoveryIpFinderAbstractSelfTest { /** * Constructor. @@ -44,6 +48,7 @@ public TcpDiscoveryElbIpFinderSelfTest() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testIpFinder() throws Exception { TcpDiscoveryElbIpFinder ipFinder = new TcpDiscoveryElbIpFinder(); @@ -78,4 +83,4 @@ public TcpDiscoveryElbIpFinderSelfTest() throws Exception { assertTrue(e.getMessage().startsWith("One or more configuration parameters are invalid")); } } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAbstractSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAbstractSelfTest.java index 768e44da70f3d..37a0accc208f5 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAbstractSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAbstractSelfTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.testsuites.IgniteIgnore; import org.apache.ignite.testsuites.IgniteS3TestSuite; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Abstract TcpDiscoveryS3IpFinder to test with different ways of setting AWS credentials. */ +@RunWith(JUnit4.class) abstract class TcpDiscoveryS3IpFinderAbstractSelfTest extends TcpDiscoveryIpFinderAbstractSelfTest { /** Bucket endpoint */ @@ -83,6 +87,7 @@ abstract class TcpDiscoveryS3IpFinderAbstractSelfTest /** {@inheritDoc} */ @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-2420") + @Test @Override public void testIpFinder() throws Exception { super.testIpFinder(); } diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAwsCredentialsProviderSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAwsCredentialsProviderSelfTest.java index 9ff5571a26e5e..06524d24d8cd1 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAwsCredentialsProviderSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAwsCredentialsProviderSelfTest.java @@ -20,10 +20,14 @@ import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.BasicAWSCredentials; import org.apache.ignite.testsuites.IgniteS3TestSuite; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * TcpDiscoveryS3IpFinder test using AWS credentials provider. */ +@RunWith(JUnit4.class) public class TcpDiscoveryS3IpFinderAwsCredentialsProviderSelfTest extends TcpDiscoveryS3IpFinderAbstractSelfTest { /** * Constructor. @@ -41,7 +45,8 @@ public TcpDiscoveryS3IpFinderAwsCredentialsProviderSelfTest() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testIpFinder() throws Exception { super.testIpFinder(); } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAwsCredentialsSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAwsCredentialsSelfTest.java index 5bea2515530c5..db287108016c5 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAwsCredentialsSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderAwsCredentialsSelfTest.java @@ -19,10 +19,14 @@ import com.amazonaws.auth.BasicAWSCredentials; import org.apache.ignite.testsuites.IgniteS3TestSuite; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * TcpDiscoveryS3IpFinder test using AWS credentials. */ +@RunWith(JUnit4.class) public class TcpDiscoveryS3IpFinderAwsCredentialsSelfTest extends TcpDiscoveryS3IpFinderAbstractSelfTest { /** * Constructor. @@ -40,7 +44,8 @@ public TcpDiscoveryS3IpFinderAwsCredentialsSelfTest() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testIpFinder() throws Exception { super.testIpFinder(); } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderBucketEndpointSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderBucketEndpointSelfTest.java index 07d4839d959d7..11481d8f42286 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderBucketEndpointSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderBucketEndpointSelfTest.java @@ -19,12 +19,16 @@ import com.amazonaws.auth.BasicAWSCredentials; import org.apache.ignite.testsuites.IgniteS3TestSuite; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * TcpDiscoveryS3IpFinder tests bucket endpoint for IP finder. * For information about possible endpoint names visit * docs.aws.amazon.com. */ +@RunWith(JUnit4.class) public class TcpDiscoveryS3IpFinderBucketEndpointSelfTest extends TcpDiscoveryS3IpFinderAbstractSelfTest { /** * Constructor. @@ -49,6 +53,7 @@ public TcpDiscoveryS3IpFinderBucketEndpointSelfTest() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testIpFinder() throws Exception { super.testIpFinder(); } diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderKeyPrefixSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderKeyPrefixSelfTest.java index 6e4960bdb3939..bb01f0b4e8503 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderKeyPrefixSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderKeyPrefixSelfTest.java @@ -19,12 +19,16 @@ import com.amazonaws.auth.BasicAWSCredentials; import org.apache.ignite.spi.discovery.tcp.ipfinder.s3.client.DummyS3Client; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.mockito.Mockito; /** * TcpDiscoveryS3IpFinder tests key prefix for IP finder. For information about key prefix visit: * . */ +@RunWith(JUnit4.class) public class TcpDiscoveryS3IpFinderKeyPrefixSelfTest extends TcpDiscoveryS3IpFinderAbstractSelfTest { /** * Constructor. @@ -58,6 +62,7 @@ public TcpDiscoveryS3IpFinderKeyPrefixSelfTest() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testIpFinder() throws Exception { injectLogger(finder); diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderSSEAlgorithmSelfTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderSSEAlgorithmSelfTest.java index 838a3c67f37c7..b909fac99adde 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderSSEAlgorithmSelfTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/TcpDiscoveryS3IpFinderSSEAlgorithmSelfTest.java @@ -19,12 +19,16 @@ import com.amazonaws.auth.BasicAWSCredentials; import org.apache.ignite.testsuites.IgniteS3TestSuite; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * TcpDiscoveryS3IpFinder tests server-side encryption algorithm for Amazon S3-managed encryption keys. * For information about possible S3-managed encryption keys visit * docs.aws.amazon.com. */ +@RunWith(JUnit4.class) public class TcpDiscoveryS3IpFinderSSEAlgorithmSelfTest extends TcpDiscoveryS3IpFinderAbstractSelfTest { /** * Constructor. @@ -42,7 +46,8 @@ public TcpDiscoveryS3IpFinderSSEAlgorithmSelfTest() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testIpFinder() throws Exception { super.testIpFinder(); } -} \ No newline at end of file +} diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/client/DummyObjectListingTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/client/DummyObjectListingTest.java index 2598af0c7af58..9016b52f5de20 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/client/DummyObjectListingTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/client/DummyObjectListingTest.java @@ -23,14 +23,19 @@ import java.util.List; import java.util.Set; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Class to test {@link DummyObjectListing}. */ +@RunWith(JUnit4.class) public class DummyObjectListingTest extends GridCommonAbstractTest { /** * Test cases for various object listing functions for S3 bucket. */ + @Test public void testDummyObjectListing() { Set fakeKeyPrefixSet = new HashSet<>(); diff --git a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/client/DummyS3ClientTest.java b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/client/DummyS3ClientTest.java index bd1b12fd548f6..88c205c629e3e 100644 --- a/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/client/DummyS3ClientTest.java +++ b/modules/aws/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/s3/client/DummyS3ClientTest.java @@ -26,10 +26,14 @@ import java.util.Map; import java.util.Set; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Class to test {@link DummyS3Client}. */ +@RunWith(JUnit4.class) public class DummyS3ClientTest extends GridCommonAbstractTest { /** Instance of {@link DummyS3Client} to be used for tests. */ private DummyS3Client s3; @@ -54,6 +58,7 @@ public class DummyS3ClientTest extends GridCommonAbstractTest { /** * Test cases to check the 'doesBucketExist' method. */ + @Test public void testDoesBucketExist() { assertTrue("The bucket 'testBucket' should exist", s3.doesBucketExist("testBucket")); assertFalse("The bucket 'nonExistentBucket' should not exist", s3.doesBucketExist("nonExistentBucket")); @@ -62,6 +67,7 @@ public void testDoesBucketExist() { /** * Test cases for various object listing functions for S3 bucket. */ + @Test public void testListObjects() { ObjectListing listing = s3.listObjects("testBucket"); @@ -98,6 +104,7 @@ public void testListObjects() { /** * Test cases for various object listing functions for S3 bucket and key prefix. */ + @Test public void testListObjectsWithAPrefix() { ObjectListing listing = s3.listObjects("testBucket", "/test"); @@ -149,6 +156,7 @@ public void testListObjectsWithAPrefix() { /** * Test case to check if a bucket is created properly. */ + @Test public void testCreateBucket() { s3.createBucket("testBucket1"); diff --git a/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteElbTestSuite.java b/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteElbTestSuite.java index 28f7e0e47ec6c..5c6566da19418 100644 --- a/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteElbTestSuite.java +++ b/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteElbTestSuite.java @@ -17,22 +17,25 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.discovery.tcp.ipfinder.elb.TcpDiscoveryElbIpFinderSelfTest; import org.apache.ignite.testframework.IgniteTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * ELB IP finder test suite. */ -public class IgniteElbTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteElbTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new IgniteTestSuite("ELB Integration Test Suite"); - suite.addTestSuite(TcpDiscoveryElbIpFinderSelfTest.class); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryElbIpFinderSelfTest.class)); return suite; } diff --git a/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteS3TestSuite.java b/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteS3TestSuite.java index a5b5eaabf12a2..1b28376b6d69e 100644 --- a/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteS3TestSuite.java +++ b/modules/aws/src/test/java/org/apache/ignite/testsuites/IgniteS3TestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.checkpoint.s3.S3CheckpointManagerSelfTest; import org.apache.ignite.spi.checkpoint.s3.S3CheckpointSpiConfigSelfTest; @@ -33,35 +34,37 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.s3.client.DummyObjectListingTest; import org.apache.ignite.spi.discovery.tcp.ipfinder.s3.client.DummyS3ClientTest; import org.apache.ignite.testframework.IgniteTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * S3 integration tests. */ -public class IgniteS3TestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteS3TestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new IgniteTestSuite("S3 Integration Test Suite"); // Checkpoint SPI. - suite.addTestSuite(S3CheckpointSpiConfigSelfTest.class); - suite.addTestSuite(S3CheckpointSpiSelfTest.class); - suite.addTestSuite(S3CheckpointSpiStartStopSelfTest.class); - suite.addTestSuite(S3CheckpointManagerSelfTest.class); - suite.addTestSuite(S3SessionCheckpointSelfTest.class); - suite.addTestSuite(S3CheckpointSpiStartStopBucketEndpointSelfTest.class); - suite.addTestSuite(S3CheckpointSpiStartStopSSEAlgorithmSelfTest.class); + suite.addTest(new JUnit4TestAdapter(S3CheckpointSpiConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(S3CheckpointSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(S3CheckpointSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(S3CheckpointManagerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(S3SessionCheckpointSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(S3CheckpointSpiStartStopBucketEndpointSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(S3CheckpointSpiStartStopSSEAlgorithmSelfTest.class)); // S3 IP finder. - suite.addTestSuite(DummyS3ClientTest.class); - suite.addTestSuite(DummyObjectListingTest.class); - suite.addTestSuite(TcpDiscoveryS3IpFinderAwsCredentialsSelfTest.class); - suite.addTestSuite(TcpDiscoveryS3IpFinderAwsCredentialsProviderSelfTest.class); - suite.addTestSuite(TcpDiscoveryS3IpFinderBucketEndpointSelfTest.class); - suite.addTestSuite(TcpDiscoveryS3IpFinderSSEAlgorithmSelfTest.class); - suite.addTestSuite(TcpDiscoveryS3IpFinderKeyPrefixSelfTest.class); + suite.addTest(new JUnit4TestAdapter(DummyS3ClientTest.class)); + suite.addTest(new JUnit4TestAdapter(DummyObjectListingTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryS3IpFinderAwsCredentialsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryS3IpFinderAwsCredentialsProviderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryS3IpFinderBucketEndpointSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryS3IpFinderSSEAlgorithmSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryS3IpFinderKeyPrefixSelfTest.class)); return suite; } diff --git a/modules/benchmarks/pom.xml b/modules/benchmarks/pom.xml index 1ea984c6c544e..06e0e505cd2ae 100644 --- a/modules/benchmarks/pom.xml +++ b/modules/benchmarks/pom.xml @@ -62,6 +62,16 @@ ${jmh.version} provided + + org.mockito + mockito-all + ${mockito.version} + + + com.google.guava + guava + ${guava.version} + @@ -131,4 +141,4 @@ - \ No newline at end of file + diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/algo/BenchmarkCRC.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/algo/BenchmarkCRC.java new file mode 100644 index 0000000000000..5c922fead0c80 --- /dev/null +++ b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/algo/BenchmarkCRC.java @@ -0,0 +1,95 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.benchmarks.jmh.algo; + +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc; +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; + +import java.nio.ByteBuffer; +import java.util.Random; + +import static java.util.concurrent.TimeUnit.NANOSECONDS; +import static org.openjdk.jmh.annotations.Mode.AverageTime; +import static org.openjdk.jmh.annotations.Scope.Thread; + +/** + * + */ +@State(Thread) +@OutputTimeUnit(NANOSECONDS) +@BenchmarkMode(AverageTime) +@Fork(value = 1, jvmArgsAppend = {"-XX:+UnlockDiagnosticVMOptions"}) +@Warmup(iterations = 5) +@Measurement(iterations = 5) +public class BenchmarkCRC { + /** */ + static final int SIZE = 1024; + + /** */ + static final int BUF_LEN = 4096; + + /** */ + @State(Thread) + public static class Context { + /** */ + final int[] results = new int[SIZE]; + + /** */ + final ByteBuffer bb = ByteBuffer.allocate(BUF_LEN); + + /** */ + @Setup + public void setup() { + new Random().ints(BUF_LEN, Byte.MIN_VALUE, Byte.MAX_VALUE).forEach(k -> bb.put((byte) k)); + } + } + + /** */ + @Benchmark + public int[] pureJavaCrc32(Context context) { + for (int i = 0; i < SIZE; i++) { + context.bb.rewind(); + + context.results[i] = PureJavaCrc32.calcCrc32(context.bb, BUF_LEN); + } + + return context.results; + } + + /** */ + @Benchmark + public int[] crc32(Context context) { + for (int i = 0; i < SIZE; i++) { + context.bb.rewind(); + + context.results[i] = FastCrc.calcCrc(context.bb, BUF_LEN); + } + + return context.results; + } +} + + diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/misc/GridDhtPartitionsStateValidatorBenchmark.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/misc/GridDhtPartitionsStateValidatorBenchmark.java new file mode 100644 index 0000000000000..f3bbcb96d6cb9 --- /dev/null +++ b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/misc/GridDhtPartitionsStateValidatorBenchmark.java @@ -0,0 +1,185 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.benchmarks.jmh.misc; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import org.apache.ignite.internal.benchmarks.jmh.JmhAbstractBenchmark; +import org.apache.ignite.internal.benchmarks.jmh.runner.JmhIdeBenchmarkRunner; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionsStateValidator; +import org.apache.ignite.internal.util.typedef.T2; +import org.jetbrains.annotations.Nullable; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.IntStream; + +import static org.openjdk.jmh.annotations.Scope.Thread; + +/** */ +@State(Scope.Benchmark) +public class GridDhtPartitionsStateValidatorBenchmark extends JmhAbstractBenchmark { + /** */ + @State(Thread) + public static class Context { + /** */ + private final UUID localNodeId = UUID.randomUUID(); + + /** */ + private GridCacheSharedContext cctxMock; + + /** */ + private GridDhtPartitionTopology topologyMock; + + /** */ + private GridDhtPartitionsStateValidator validator; + + /** */ + private Map messages = new HashMap<>(); + + /** */ + private UUID ignoreNode = UUID.randomUUID(); + + /** */ + private static final int NODES = 3; + + /** */ + private static final int PARTS = 100; + + /** + * @return Partition mock with specified {@code id}, {@code updateCounter} and {@code size}. + */ + private GridDhtLocalPartition partitionMock(int id, long updateCounter, long size) { + GridDhtLocalPartition partitionMock = Mockito.mock(GridDhtLocalPartition.class); + Mockito.when(partitionMock.id()).thenReturn(id); + Mockito.when(partitionMock.updateCounter()).thenReturn(updateCounter); + Mockito.when(partitionMock.fullSize()).thenReturn(size); + Mockito.when(partitionMock.state()).thenReturn(GridDhtPartitionState.OWNING); + return partitionMock; + } + + /** + * @param countersMap Update counters map. + * @param sizesMap Sizes map. + * @return Message with specified {@code countersMap} and {@code sizeMap}. + */ + private GridDhtPartitionsSingleMessage from(@Nullable Map> countersMap, @Nullable Map sizesMap) { + GridDhtPartitionsSingleMessage msg = new GridDhtPartitionsSingleMessage(); + if (countersMap != null) + msg.addPartitionUpdateCounters(0, countersMap); + if (sizesMap != null) + msg.addPartitionSizes(0, sizesMap); + return msg; + } + + /** */ + @Setup + public void setup() { + // Prepare mocks. + cctxMock = Mockito.mock(GridCacheSharedContext.class); + Mockito.when(cctxMock.localNodeId()).thenReturn(localNodeId); + + topologyMock = Mockito.mock(GridDhtPartitionTopology.class); + Mockito.when(topologyMock.partitionState(Matchers.any(), Matchers.anyInt())).thenReturn(GridDhtPartitionState.OWNING); + Mockito.when(topologyMock.groupId()).thenReturn(0); + + Mockito.when(topologyMock.partitions()).thenReturn(PARTS); + + List localPartitions = Lists.newArrayList(); + + Map> updateCountersMap = new HashMap<>(); + + Map cacheSizesMap = new HashMap<>(); + + IntStream.range(0, PARTS).forEach(k -> { localPartitions.add(partitionMock(k, k + 1, k + 1)); + long us = k > 20 && k <= 30 ? 0 :k + 2L; + updateCountersMap.put(k, new T2<>(k + 2L, us)); + cacheSizesMap.put(k, us); }); + + Mockito.when(topologyMock.localPartitions()).thenReturn(localPartitions); + Mockito.when(topologyMock.currentLocalPartitions()).thenReturn(localPartitions); + + // Form single messages map. + Map messages = new HashMap<>(); + + for (int n = 0; n < NODES; ++n) { + UUID remoteNode = UUID.randomUUID(); + + messages.put(remoteNode, from(updateCountersMap, cacheSizesMap)); + } + + messages.put(ignoreNode, from(updateCountersMap, cacheSizesMap)); + + validator = new GridDhtPartitionsStateValidator(cctxMock); + } + } + + /** */ + @Benchmark + public void testValidatePartitionsUpdateCounters(Context context) { + context.validator.validatePartitionsUpdateCounters(context.topologyMock, + context.messages, Sets.newHashSet(context.ignoreNode)); + } + + /** */ + @Benchmark + public void testValidatePartitionsSizes(Context context) { + context.validator.validatePartitionsSizes(context.topologyMock, context + .messages, Sets.newHashSet(context.ignoreNode)); + } + + /** + * Run benchmarks. + * + * @param args Arguments. + * @throws Exception If failed. + */ + public static void main(String[] args) throws Exception { + run(1); + } + + /** + * Run benchmark. + * + * @param threads Amount of threads. + * @throws Exception If failed. + */ + private static void run(int threads) throws Exception { + JmhIdeBenchmarkRunner.create() + .forks(1) + .threads(threads) + .warmupIterations(5) + .measurementIterations(10) + .benchmarks(GridDhtPartitionsStateValidatorBenchmark.class.getSimpleName()) + .jvmArguments("-XX:+UseG1GC", "-Xms4g", "-Xmx4g") + .run(); + } +} diff --git a/modules/camel/src/test/java/org/apache/ignite/stream/camel/IgniteCamelStreamerTest.java b/modules/camel/src/test/java/org/apache/ignite/stream/camel/IgniteCamelStreamerTest.java index 88b7eb8845757..b384d1a294202 100644 --- a/modules/camel/src/test/java/org/apache/ignite/stream/camel/IgniteCamelStreamerTest.java +++ b/modules/camel/src/test/java/org/apache/ignite/stream/camel/IgniteCamelStreamerTest.java @@ -56,12 +56,16 @@ import org.apache.ignite.stream.StreamMultipleTupleExtractor; import org.apache.ignite.stream.StreamSingleTupleExtractor; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; /** * Test class for {@link CamelStreamer}. */ +@RunWith(JUnit4.class) public class IgniteCamelStreamerTest extends GridCommonAbstractTest { /** text/plain media type. */ private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain;charset=utf-8"); @@ -127,6 +131,7 @@ public IgniteCamelStreamerTest() { /** * @throws Exception */ + @Test public void testSendOneEntryPerMessage() throws Exception { streamer.setSingleTupleExtractor(singleTupleExtractor()); @@ -147,6 +152,7 @@ public void testSendOneEntryPerMessage() throws Exception { /** * @throws Exception */ + @Test public void testMultipleEntriesInOneMessage() throws Exception { streamer.setMultipleTupleExtractor(multipleTupleExtractor()); @@ -167,6 +173,7 @@ public void testMultipleEntriesInOneMessage() throws Exception { /** * @throws Exception */ + @Test public void testResponseProcessorIsCalled() throws Exception { streamer.setSingleTupleExtractor(singleTupleExtractor()); streamer.setResponseProcessor(new Processor() { @@ -195,6 +202,7 @@ public void testResponseProcessorIsCalled() throws Exception { /** * @throws Exception */ + @Test public void testUserSpecifiedCamelContext() throws Exception { final AtomicInteger cnt = new AtomicInteger(); @@ -228,6 +236,7 @@ public void testUserSpecifiedCamelContext() throws Exception { /** * @throws Exception */ + @Test public void testUserSpecifiedCamelContextWithPropertyPlaceholders() throws Exception { // Create a CamelContext with a custom property placeholder. CamelContext context = new DefaultCamelContext(); @@ -266,6 +275,7 @@ public void testUserSpecifiedCamelContextWithPropertyPlaceholders() throws Excep /** * @throws Exception */ + @Test public void testInvalidEndpointUri() throws Exception { streamer.setSingleTupleExtractor(singleTupleExtractor()); streamer.setEndpointUri("abc"); diff --git a/modules/camel/src/test/java/org/apache/ignite/stream/camel/IgniteCamelStreamerTestSuite.java b/modules/camel/src/test/java/org/apache/ignite/stream/camel/IgniteCamelStreamerTestSuite.java index c45272ed00c57..8e9f0b10fa07d 100644 --- a/modules/camel/src/test/java/org/apache/ignite/stream/camel/IgniteCamelStreamerTestSuite.java +++ b/modules/camel/src/test/java/org/apache/ignite/stream/camel/IgniteCamelStreamerTestSuite.java @@ -18,29 +18,31 @@ package org.apache.ignite.stream.camel; import java.util.Set; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Camel streamer tests. Included into 'Streamers' run configuration. */ -public class IgniteCamelStreamerTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCamelStreamerTestSuite { /** * @return {@link IgniteCamelStreamerTest} test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** - * @param ignoredTests + * @param ignoredTests List of ignored tests. * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite(Set ignoredTests) throws Exception { + public static TestSuite suite(Set ignoredTests) { TestSuite suite = new TestSuite("IgniteCamelStreamer Test Suite"); - suite.addTestSuite(IgniteCamelStreamerTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCamelStreamerTest.class)); return suite; } diff --git a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/CassandraConfigTest.java b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/CassandraConfigTest.java index 98d7ef1bae92b..63ec90b446e86 100644 --- a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/CassandraConfigTest.java +++ b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/CassandraConfigTest.java @@ -17,22 +17,22 @@ package org.apache.ignite.tests; -import junit.framework.TestCase; -import org.apache.ignite.cache.affinity.AffinityKeyMapped; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.cache.store.cassandra.persistence.KeyPersistenceSettings; import org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; /** * Simple test for DDL generator. */ -public class CassandraConfigTest extends TestCase { +public class CassandraConfigTest { /** * Check if same DDL generated for similar keys and same KeyPersistenceConfiguration. - * - * @throws Exception */ - public void testDDLGeneration() throws Exception { + @Test + public void testDDLGeneration() { KeyPersistenceSettings keyPersistenceSettingsA = getKeyPersistenceSettings(KeyA.class); KeyPersistenceSettings keyPersistenceSettingsB = getKeyPersistenceSettings(KeyB.class); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/TaskEventSubjectIdSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/TaskEventSubjectIdSelfTest.java index 46aaa6ba387b6..881122ed09f65 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/TaskEventSubjectIdSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/TaskEventSubjectIdSelfTest.java @@ -45,6 +45,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION; @@ -57,6 +60,7 @@ /** * Tests for security subject ID in task events. */ +@RunWith(JUnit4.class) public class TaskEventSubjectIdSelfTest extends GridCommonAbstractTest { /** */ private static final Collection evts = new ArrayList<>(); @@ -117,6 +121,7 @@ public class TaskEventSubjectIdSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSimpleTask() throws Exception { latch = new CountDownLatch(3); @@ -161,6 +166,7 @@ public void testSimpleTask() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailedTask() throws Exception { latch = new CountDownLatch(2); @@ -207,6 +213,7 @@ public void testFailedTask() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimedOutTask() throws Exception { latch = new CountDownLatch(2); @@ -262,6 +269,7 @@ public void testTimedOutTask() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClosure() throws Exception { latch = new CountDownLatch(3); @@ -308,8 +316,12 @@ public void testClosure() throws Exception { } /** + * Events for class tasks that was started from external clients should contain + * client subject id instead of the node where it was started. This test checks it. + * * @throws Exception If failed. */ + @Test public void testClient() throws Exception { latch = new CountDownLatch(3); @@ -328,7 +340,7 @@ public void testClient() throws Exception { assert evt != null; assertEquals(EVT_TASK_STARTED, evt.type()); - assertEquals(nodeId, evt.subjectId()); + assertEquals(client.id(), evt.subjectId()); assert it.hasNext(); @@ -337,7 +349,7 @@ public void testClient() throws Exception { assert evt != null; assertEquals(EVT_TASK_REDUCED, evt.type()); - assertEquals(nodeId, evt.subjectId()); + assertEquals(client.id(), evt.subjectId()); assert it.hasNext(); @@ -346,7 +358,7 @@ public void testClient() throws Exception { assert evt != null; assertEquals(EVT_TASK_FINISHED, evt.type()); - assertEquals(nodeId, evt.subjectId()); + assertEquals(client.id(), evt.subjectId()); assert !it.hasNext(); } diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientAbstractMultiThreadedSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientAbstractMultiThreadedSelfTest.java index fb46bb2c87950..4a1967f0059a8 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientAbstractMultiThreadedSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientAbstractMultiThreadedSelfTest.java @@ -43,12 +43,11 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -59,10 +58,8 @@ /** * */ +@RunWith(JUnit4.class) public abstract class ClientAbstractMultiThreadedSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Partitioned cache name. */ protected static final String PARTITIONED_CACHE_NAME = "partitioned"; @@ -174,12 +171,6 @@ protected int cachePutCount() { c.setConnectorConfiguration(clientCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - c.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME), cacheConfiguration(PARTITIONED_CACHE_NAME), cacheConfiguration(REPLICATED_CACHE_NAME), cacheConfiguration(PARTITIONED_ASYNC_BACKUP_CACHE_NAME), cacheConfiguration(REPLICATED_ASYNC_CACHE_NAME)); @@ -246,6 +237,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String cacheName) throws /** * @throws Exception If failed. */ + @Test public void testMultithreadedTaskRun() throws Exception { final AtomicLong cnt = new AtomicLong(); @@ -397,4 +389,4 @@ private static class TestTask extends ComputeTaskSplitAdapter { return locNodeId; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java index c62cf8a547c92..5004b875f84f0 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java @@ -37,23 +37,21 @@ import org.apache.ignite.internal.processors.rest.GridRestCommand; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.SB; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT; /** * Tests that client is able to connect to a grid with only default cache enabled. */ +@RunWith(JUnit4.class) public class ClientDefaultCacheSelfTest extends GridCommonAbstractTest { /** Path to jetty config configured with SSL. */ private static final String REST_JETTY_CFG = "modules/clients/src/test/resources/jetty/rest-jetty.xml"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Host. */ private static final String HOST = "127.0.0.1"; @@ -104,12 +102,6 @@ public class ClientDefaultCacheSelfTest extends GridCommonAbstractTest { cfg.setConnectorConfiguration(clientCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cLoc = new CacheConfiguration(DEFAULT_CACHE_NAME); cLoc.setName(LOCAL_CACHE); @@ -183,6 +175,7 @@ private JsonNode jsonResponse(String content) throws IOException { /** * Json format string in cache should not transform to Json object on get request. */ + @Test public void testSkipString2JsonTransformation() throws Exception { String val = "{\"v\":\"my Value\",\"t\":1422559650154}"; diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientReconnectionSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientReconnectionSelfTest.java index f1085b3ec361a..453243c83f7a8 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientReconnectionSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientReconnectionSelfTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testsuites.IgniteIgnore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class ClientReconnectionSelfTest extends GridCommonAbstractTest { /** */ public static final String HOST = "127.0.0.1"; @@ -83,6 +87,7 @@ private GridClient client(String host) throws GridClientException { /** * @throws Exception If failed. */ + @Test public void testNoFailedReconnection() throws Exception { for (int i = 0; i < ClientTestRestServer.SERVERS_CNT; i++) runServer(i, false); @@ -140,6 +145,7 @@ public void testNoFailedReconnection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCorrectInit() throws Exception { for (int i = 0; i < ClientTestRestServer.SERVERS_CNT; i++) runServer(i, i == 0); @@ -157,6 +163,7 @@ public void testCorrectInit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailedInit() throws Exception { for (int i = 0; i < ClientTestRestServer.SERVERS_CNT; i++) runServer(i, true); @@ -184,9 +191,10 @@ public void testFailedInit() throws Exception { * @throws Exception If failed. */ @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-590", forceFailure = true) + @Test public void testIdleConnection() throws Exception { int srvsCnt = 4; // TODO: IGNITE-590 it may be wrong value. Need to investigate after IGNITE-590 will be fixed. - + for (int i = 0; i < srvsCnt; i++) runServer(i, false); @@ -235,4 +243,4 @@ private ClientTestRestServer runServer(int idx, boolean failOnConnect) throws I return srv; } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientSslParametersTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientSslParametersTest.java new file mode 100644 index 0000000000000..c2e10b8135557 --- /dev/null +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientSslParametersTest.java @@ -0,0 +1,338 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.client; + +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Callable; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.ConnectorConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.client.ssl.GridSslBasicContextFactory; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.ssl.SslContextFactory; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.jetbrains.annotations.NotNull; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests cases when node connects to cluster with different set of cipher suites. + */ +@RunWith(JUnit4.class) +public class ClientSslParametersTest extends GridCommonAbstractTest { + /** */ + public static final String TEST_CACHE_NAME = "TEST"; + + /** */ + private volatile String[] cipherSuites; + + /** */ + private volatile String[] protocols; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + cfg.setSslContextFactory(createSslFactory()); + + cfg.setConnectorConfiguration(new ConnectorConfiguration() + .setSslEnabled(true) + .setSslClientAuth(true)); + + cfg.setCacheConfiguration(new CacheConfiguration(TEST_CACHE_NAME)); + + return cfg; + } + + /** + * @return Client configuration. + */ + protected GridClientConfiguration getClientConfiguration() { + GridClientConfiguration cfg = new GridClientConfiguration(); + + cfg.setServers(Collections.singleton("127.0.0.1:11211")); + + cfg.setSslContextFactory(createOldSslFactory()); + + return cfg; + } + + /** + * @return SSL factory. + */ + @NotNull private SslContextFactory createSslFactory() { + SslContextFactory factory = (SslContextFactory)GridTestUtils.sslFactory(); + + factory.setCipherSuites(cipherSuites); + + factory.setProtocols(protocols); + + return factory; + } + + /** + * @return SSL Factory. + */ + @NotNull private GridSslBasicContextFactory createOldSslFactory() { + GridSslBasicContextFactory factory = (GridSslBasicContextFactory)GridTestUtils.sslContextFactory(); + + factory.setCipherSuites(cipherSuites); + + factory.setProtocols(protocols); + + return factory; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + protocols = null; + + cipherSuites = null; + } + + /** + * @throws Exception If failed. + */ + @Test + public void testSameCipherSuite() throws Exception { + cipherSuites = new String[] { + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" + }; + + startGrid(); + + checkSuccessfulClientStart( + new String[] { + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" + }, + null + ); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testOneCommonCipherSuite() throws Exception { + cipherSuites = new String[] { + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" + }; + + startGrid(); + + checkSuccessfulClientStart( + new String[] { + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" + }, + null + ); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testNoCommonCipherSuite() throws Exception { + cipherSuites = new String[] { + "TLS_RSA_WITH_AES_128_GCM_SHA256" + }; + + startGrid(); + + checkClientStartFailure( + new String[] { + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" + }, + null + ); + } + + /** + * @throws Exception If failed. + */ + @Test + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10245") + public void testNonExistentCipherSuite() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10245"); + + cipherSuites = new String[] { + "TLS_RSA_WITH_AES_128_GCM_SHA256" + }; + + startGrid(); + + checkClientStartFailure( + new String[] { + "TLC_FAKE_CIPHER", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" + }, + null, + "Unsupported ciphersuite" + ); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testNoCommonProtocols() throws Exception { + protocols = new String[] { + "TLSv1.1", + "SSLv3" + }; + + startGrid(); + + checkClientStartFailure( + null, + new String[] { + "TLSv1", + "TLSv1.2" + } + ); + } + + /** + * @throws Exception If failed. + */ + @Test + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10245") + public void testNonExistentProtocol() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10245"); + + protocols = new String[] { + "SSLv3" + }; + + startGrid(); + + checkClientStartFailure( + null, + new String[] { + "SSLv3", + "SSLvDoesNotExist" + }, + "SSLvDoesNotExist" + ); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testSameProtocols() throws Exception { + protocols = new String[] { + "TLSv1.1", + "TLSv1.2" + }; + + startGrid(); + + checkSuccessfulClientStart( + null, + new String[] { + "TLSv1.1", + "TLSv1.2" + } + ); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testOneCommonProtocol() throws Exception { + protocols = new String[] { + "TLSv1", + "TLSv1.1", + "TLSv1.2" + }; + + startGrid(); + + checkSuccessfulClientStart( + null, + new String[] { + "TLSv1.1", + "SSLv3" + } + ); + } + + /** + * @param cipherSuites list of cipher suites + * @param protocols list of protocols + * @throws Exception If failed. + */ + private void checkSuccessfulClientStart(String[] cipherSuites, String[] protocols) throws Exception { + this.cipherSuites = F.isEmpty(cipherSuites) ? null : cipherSuites; + this.protocols = F.isEmpty(protocols) ? null : protocols; + + try (GridClient client = GridClientFactory.start(getClientConfiguration())) { + List top = client.compute().refreshTopology(false, false); + + assertEquals(1, top.size()); + } + } + + /** + * @param cipherSuites list of cipher suites + * @param protocols list of protocols + */ + private void checkClientStartFailure(String[] cipherSuites, String[] protocols) { + checkClientStartFailure(cipherSuites, protocols, "Latest topology update failed."); + } + + /** + * @param cipherSuites list of cipher suites + * @param protocols list of protocols + * @param msg exception message + */ + private void checkClientStartFailure(String[] cipherSuites, String[] protocols, String msg) { + this.cipherSuites = F.isEmpty(cipherSuites) ? null : cipherSuites; + this.protocols = F.isEmpty(protocols) ? null : protocols; + + GridTestUtils.assertThrows( + null, + new Callable() { + @Override public Object call() throws Exception { + GridClient client = GridClientFactory.start(getClientConfiguration()); + + client.compute().refreshTopology(false, false); + + return null; + } + }, + GridClientException.class, + msg + ); + } +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpSslAuthenticationSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpSslAuthenticationSelfTest.java index 922526201b194..c43c3c0c4354f 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpSslAuthenticationSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpSslAuthenticationSelfTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests */ +@RunWith(JUnit4.class) public class ClientTcpSslAuthenticationSelfTest extends GridCommonAbstractTest { /** REST TCP port. */ private static final int REST_TCP_PORT = 12121; @@ -112,6 +116,7 @@ private GridClientImpl createClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerAuthenticated() throws Exception { checkServerAuthenticatedByClient(false); } @@ -119,6 +124,7 @@ public void testServerAuthenticated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerNotAuthenticatedByClient() throws Exception { try { checkServerAuthenticatedByClient(true); @@ -131,6 +137,7 @@ public void testServerNotAuthenticatedByClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientAuthenticated() throws Exception { checkClientAuthenticatedByServer(false); } @@ -138,6 +145,7 @@ public void testClientAuthenticated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNotAuthenticated() throws Exception { try { checkServerAuthenticatedByClient(true); @@ -264,4 +272,4 @@ public void reset() { srvCheckCallCnt.set(0); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpTaskExecutionAfterTopologyRestartSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpTaskExecutionAfterTopologyRestartSelfTest.java index 4b63fff1d925c..ca7347596bb5e 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpTaskExecutionAfterTopologyRestartSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpTaskExecutionAfterTopologyRestartSelfTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Ensures */ +@RunWith(JUnit4.class) public class ClientTcpTaskExecutionAfterTopologyRestartSelfTest extends GridCommonAbstractTest { /** Port. */ private static final int PORT = 11211; @@ -54,6 +58,7 @@ public class ClientTcpTaskExecutionAfterTopologyRestartSelfTest extends GridComm /** * @throws Exception If failed. */ + @Test public void testTaskAfterRestart() throws Exception { startGrids(1); @@ -72,4 +77,4 @@ public void testTaskAfterRestart() throws Exception { cli.compute().execute(ClientTcpTask.class.getName(), Collections.singletonList("arg")); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientCacheFlagsCodecTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientCacheFlagsCodecTest.java index a9bda0aff1452..8d7b4b5c237d2 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientCacheFlagsCodecTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientCacheFlagsCodecTest.java @@ -21,18 +21,20 @@ import java.util.EnumSet; import java.util.Set; -import junit.framework.TestCase; - import org.apache.ignite.internal.client.GridClientCacheFlag; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; + +import static junit.framework.Assert.assertTrue; /** * Tests conversions between GridClientCacheFlag. */ -public class ClientCacheFlagsCodecTest extends TestCase { +public class ClientCacheFlagsCodecTest { /** * Tests that each client flag will be correctly converted to server flag. */ + @Test public void testEncodingDecodingFullness() { for (GridClientCacheFlag f : GridClientCacheFlag.values()) { int bits = GridClientCacheFlag.encodeCacheFlags(EnumSet.of(f)); @@ -48,6 +50,7 @@ public void testEncodingDecodingFullness() { /** * Tests that groups of client flags can be correctly converted to corresponding server flag groups. */ + @Test public void testGroupEncodingDecoding() { // All. doTestGroup(GridClientCacheFlag.values()); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientComputeImplSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientComputeImplSelfTest.java index 7777f334f56c9..7fd50574883c6 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientComputeImplSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientComputeImplSelfTest.java @@ -24,6 +24,9 @@ import org.apache.ignite.internal.client.GridClientNode; import org.apache.ignite.internal.client.GridClientPredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; @@ -31,6 +34,7 @@ * Simple unit test for GridClientComputeImpl which checks method parameters. * It tests only those methods that can produce assertion underneath upon incorrect arguments. */ +@RunWith(JUnit4.class) public class ClientComputeImplSelfTest extends GridCommonAbstractTest { /** Mocked client compute. */ private GridClientCompute compute = allocateInstance0(GridClientComputeImpl.class); @@ -38,6 +42,7 @@ public class ClientComputeImplSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testProjection_byGridClientNode() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -49,6 +54,7 @@ public void testProjection_byGridClientNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExecute() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -60,6 +66,7 @@ public void testExecute() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExecuteAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -71,6 +78,7 @@ public void testExecuteAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityExecute() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -82,6 +90,7 @@ public void testAffinityExecute() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityExecuteAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -93,6 +102,7 @@ public void testAffinityExecuteAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNode() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -104,6 +114,7 @@ public void testNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodesByIds() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -115,6 +126,7 @@ public void testNodesByIds() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodesByFilter() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -126,6 +138,7 @@ public void testNodesByFilter() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRefreshNodeById() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -137,6 +150,7 @@ public void testRefreshNodeById() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRefreshNodeByIdAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -148,6 +162,7 @@ public void testRefreshNodeByIdAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRefreshNodeByIp() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -159,6 +174,7 @@ public void testRefreshNodeByIp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRefreshNodeByIpAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -166,4 +182,4 @@ public void testRefreshNodeByIpAsync() throws Exception { } }, NullPointerException.class, "Ouch! Argument cannot be null: ip"); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientDataImplSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientDataImplSelfTest.java index 1638f31239193..61379d1368134 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientDataImplSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientDataImplSelfTest.java @@ -20,12 +20,16 @@ import java.util.concurrent.Callable; import org.apache.ignite.internal.client.GridClientData; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; /** * Simple unit test for GridClientDataImpl which checks method parameters. */ +@RunWith(JUnit4.class) public class ClientDataImplSelfTest extends GridCommonAbstractTest { /** Mocked client data. */ private GridClientData data = allocateInstance0(GridClientDataImpl.class); @@ -33,6 +37,7 @@ public class ClientDataImplSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -54,6 +59,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -75,6 +81,7 @@ public void testPutAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAll() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -88,6 +95,7 @@ public void testPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -101,6 +109,7 @@ public void testPutAllAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -112,6 +121,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -123,6 +133,7 @@ public void testGetAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAll() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -134,6 +145,7 @@ public void testGetAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -145,6 +157,7 @@ public void testGetAllAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -158,6 +171,7 @@ public void testRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -169,6 +183,7 @@ public void testRemoveAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAll() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -182,6 +197,7 @@ public void testRemoveAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAllAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -195,6 +211,7 @@ public void testRemoveAllAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplace() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -216,6 +233,7 @@ public void testReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplaceAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -233,6 +251,7 @@ public void testReplaceAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCas() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -246,6 +265,7 @@ public void testCas() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCasAsync() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -257,6 +277,7 @@ public void testCasAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinity() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -264,4 +285,4 @@ public void testAffinity() throws Exception { } }, NullPointerException.class, "Ouch! Argument cannot be null: key"); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientFutureAdapterSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientFutureAdapterSelfTest.java index 67df048d13fe2..0d017cff11b5b 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientFutureAdapterSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientFutureAdapterSelfTest.java @@ -24,14 +24,19 @@ import org.apache.ignite.internal.client.GridClientFuture; import org.apache.ignite.internal.client.GridClientFutureTimeoutException; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid client future implementation self test. */ +@RunWith(JUnit4.class) public class ClientFutureAdapterSelfTest extends GridCommonAbstractTest { /** * Test finished futures. */ + @Test public void testFinished() { GridClientFutureAdapter fut = new GridClientFutureAdapter<>(); @@ -50,6 +55,7 @@ public void testFinished() { * * @throws org.apache.ignite.internal.client.GridClientException On any exception. */ + @Test public void testChains() throws GridClientException { // Synchronous notifications. testChains(1, 100); @@ -114,4 +120,4 @@ private void testChains(int chainSize, long waitDelay) throws GridClientExceptio info("Time consumption for " + chainSize + " chained futures: " + (System.currentTimeMillis() - start)); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientPropertiesConfigurationSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientPropertiesConfigurationSelfTest.java index 55aadfd01b51d..964b14e0de01f 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientPropertiesConfigurationSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/impl/ClientPropertiesConfigurationSelfTest.java @@ -39,6 +39,9 @@ import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.context.support.FileSystemXmlApplicationContext; import static org.apache.ignite.internal.client.GridClientConfiguration.DFLT_MAX_CONN_IDLE_TIME; @@ -47,6 +50,7 @@ /** * Properties-based configuration self test. */ +@RunWith(JUnit4.class) public class ClientPropertiesConfigurationSelfTest extends GridCommonAbstractTest { /** * Grid client spring configuration. @@ -73,6 +77,7 @@ public class ClientPropertiesConfigurationSelfTest extends GridCommonAbstractTes * * @throws Exception In case of exception. */ + @Test public void testCreation() throws Exception { // Validate default configuration. GridClientConfiguration cfg = new GridClientConfiguration(); @@ -131,6 +136,7 @@ public void testCreation() throws Exception { * * @throws Exception In case of any exception. */ + @Test public void testSpringConfig() throws Exception { GridClientConfiguration cfg = new FileSystemXmlApplicationContext( GRID_CLIENT_SPRING_CONFIG.toString()).getBean(GridClientConfiguration.class); @@ -242,4 +248,4 @@ private void validateConfig(int expDataCfgs, GridClientConfiguration cfg) { assertEquals(null, cfg.getSslContextFactory(), null); assertEquals(DFLT_TOP_REFRESH_FREQ, cfg.getTopologyRefreshFrequency()); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractConnectivitySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractConnectivitySelfTest.java index 8207ccfb6f15c..327c56f95a4be 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractConnectivitySelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractConnectivitySelfTest.java @@ -38,10 +38,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests the REST client-server connectivity with various configurations. */ +@RunWith(JUnit4.class) public abstract class ClientAbstractConnectivitySelfTest extends GridCommonAbstractTest { /** */ private static final String WILDCARD_IP = "0.0.0.0"; @@ -122,6 +126,7 @@ protected GridClient startClient(String addr, int port) throws GridClientExcepti * * @throws Exception If failed. */ + @Test public void testOneNodeDefaultHostAndPort() throws Exception { startRestNode("grid1", null, null); @@ -136,6 +141,7 @@ public void testOneNodeDefaultHostAndPort() throws Exception { * Simple test of address list filtering. * @throws Exception If failed. */ + @Test public void testResolveReachableOneAddress() throws Exception { InetAddress addr = InetAddress.getByAddress(new byte[] {127, 0, 0, 1} ); @@ -151,6 +157,7 @@ public void testResolveReachableOneAddress() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testOneNodeLoopbackHost() throws Exception { startRestNode("grid1", LOOPBACK_IP, defaultRestPort()); @@ -164,6 +171,7 @@ public void testOneNodeLoopbackHost() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testOneNodeZeroIpv4Address() throws Exception { startRestNode("grid1", WILDCARD_IP, defaultRestPort()); @@ -208,6 +216,7 @@ public void testOneNodeZeroIpv4Address() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testTwoNodesDefaultHostAndPort() throws Exception { startRestNode("grid1", null, null); startRestNode("grid2", null, null); @@ -256,6 +265,7 @@ public void testTwoNodesDefaultHostAndPort() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testRefreshTopologyOnNodeLeft() throws Exception { startRestNode("grid1", null, null); startRestNode("grid2", null, null); @@ -323,4 +333,4 @@ private static class IpV4AddressPredicate implements P1 { return s.matches("\\d+\\.\\d+\\.\\d+\\.\\d+"); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java index 3481f34cf17aa..5ee06375634de 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java @@ -68,13 +68,13 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -87,11 +87,8 @@ /** * Tests basic client behavior with multiple nodes. */ -@SuppressWarnings("ThrowableResultOfMethodCallIgnored") +@RunWith(JUnit4.class) public abstract class ClientAbstractMultiNodeSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Partitioned cache name. */ private static final String PARTITIONED_CACHE_NAME = "partitioned"; @@ -178,12 +175,6 @@ public abstract class ClientAbstractMultiNodeSelfTest extends GridCommonAbstract c.setConnectorConfiguration(clientCfg); } - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - TestCommunicationSpi spi = new TestCommunicationSpi(); spi.setLocalPort(GridTestUtils.getNextCommPort(getClass())); @@ -255,6 +246,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String cacheName) throws /** * @throws Exception If failed. */ + @Test public void testEmptyProjections() throws Exception { final GridClientCompute dflt = client.compute(); @@ -290,6 +282,7 @@ public void testEmptyProjections() throws Exception { /** * @throws Exception If failed. */ + @Test public void testProjectionRun() throws Exception { GridClientCompute dflt = client.compute(); @@ -319,6 +312,7 @@ public void testProjectionRun() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopologyListener() throws Exception { final Collection added = new ArrayList<>(1); final Collection rmvd = new ArrayList<>(1); @@ -431,7 +425,6 @@ private static class TestTask extends ComputeTaskSplitAdapter { for (int i = 0; i < gridSize; i++) { jobs.add(new ComputeJobAdapter() { - @SuppressWarnings("OverlyStrongTypeCast") @Override public Object execute() { try { Thread.sleep(1000); @@ -475,7 +468,6 @@ private static class TestTask extends ComputeTaskSplitAdapter { /** * Communication SPI which checks cache flags. */ - @SuppressWarnings("unchecked") private static class TestCommunicationSpi extends TcpCommunicationSpi { /** {@inheritDoc} */ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure ackC) diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java index 597121840e702..382c40e25a7a6 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java @@ -66,12 +66,12 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -83,10 +83,8 @@ * Tests for Java client. */ @SuppressWarnings("deprecation") +@RunWith(JUnit4.class) public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE_NAME = "cache"; @@ -233,12 +231,6 @@ protected Object getTaskArgument() { cfg.setConnectorConfiguration(clientCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME), cacheConfiguration("replicated"), cacheConfiguration("partitioned"), cacheConfiguration(CACHE_NAME)); @@ -346,6 +338,7 @@ protected GridClientConfiguration clientConfiguration() throws GridClientExcepti /** * @throws Exception If failed. */ + @Test public void testConnectable() throws Exception { GridClient client = client(); @@ -359,6 +352,7 @@ public void testConnectable() throws Exception { * * @throws Exception If failed. */ + @Test public void testNoAsyncExceptions() throws Exception { GridClient client = client(); @@ -404,6 +398,7 @@ public void testNoAsyncExceptions() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGracefulShutdown() throws Exception { GridClientCompute compute = client.compute(); @@ -422,6 +417,7 @@ public void testGracefulShutdown() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForceShutdown() throws Exception { GridClientCompute compute = client.compute(); @@ -445,6 +441,7 @@ public void testForceShutdown() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShutdown() throws Exception { GridClient c = client(); @@ -486,6 +483,7 @@ public void testShutdown() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExecute() throws Exception { String taskName = getTaskName(); Object taskArg = getTaskArgument(); @@ -499,6 +497,7 @@ public void testExecute() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopology() throws Exception { GridClientCompute compute = client.compute(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientPreferDirectSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientPreferDirectSelfTest.java index b012d3b85fe6f..40f35eb256b88 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientPreferDirectSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientPreferDirectSelfTest.java @@ -36,10 +36,10 @@ import org.apache.ignite.internal.client.balancer.GridClientRandomBalancer; import org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.client.integration.ClientAbstractMultiNodeSelfTest.HOST; import static org.apache.ignite.internal.client.integration.ClientAbstractMultiNodeSelfTest.REST_TCP_PORT_BASE; @@ -48,10 +48,8 @@ /** * */ +@RunWith(JUnit4.class) public class ClientPreferDirectSelfTest extends GridCommonAbstractTest { - /** VM ip finder for TCP discovery. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES_CNT = 6; @@ -64,12 +62,6 @@ public class ClientPreferDirectSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - c.setLocalHost(HOST); assert c.getConnectorConfiguration() == null; @@ -86,6 +78,7 @@ public class ClientPreferDirectSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRandomBalancer() throws Exception { GridClientRandomBalancer b = new GridClientRandomBalancer(); @@ -97,6 +90,7 @@ public void testRandomBalancer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRoundRobinBalancer() throws Exception { GridClientRoundRobinBalancer b = new GridClientRoundRobinBalancer(); @@ -195,4 +189,4 @@ private static class TestTask extends ComputeTaskSplitAdapter { return ignite.cluster().localNode().id().toString(); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/router/ClientFailedInitSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/router/ClientFailedInitSelfTest.java index 971dcb186b157..cc9fad1c0f30d 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/router/ClientFailedInitSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/router/ClientFailedInitSelfTest.java @@ -38,10 +38,10 @@ import org.apache.ignite.internal.client.GridServerUnreachableException; import org.apache.ignite.internal.client.impl.connection.GridClientConnectionResetException; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT; import static org.apache.ignite.internal.client.GridClientProtocol.TCP; @@ -53,6 +53,7 @@ /** * */ +@RunWith(JUnit4.class) public class ClientFailedInitSelfTest extends GridCommonAbstractTest { /** */ private static final int RECONN_CNT = 3; @@ -66,9 +67,6 @@ public class ClientFailedInitSelfTest extends GridCommonAbstractTest { /** */ private static final int ROUTER_JETTY_PORT = 8081; - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { GridClientFactory.stopAll(); @@ -91,18 +89,13 @@ public class ClientFailedInitSelfTest extends GridCommonAbstractTest { cfg.setConnectorConfiguration(clientCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } /** * */ + @Test public void testEmptyAddresses() { try { GridClientFactory.start(new GridClientConfiguration()); @@ -117,6 +110,7 @@ public void testEmptyAddresses() { /** * */ + @Test public void testRoutersAndServersAddressesProvided() { try { GridClientConfiguration c = new GridClientConfiguration(); @@ -136,6 +130,7 @@ public void testRoutersAndServersAddressesProvided() { /** * @throws Exception If failed. */ + @Test public void testTcpClient() throws Exception { doTestClient(TCP); } @@ -143,6 +138,7 @@ public void testTcpClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTcpRouter() throws Exception { doTestRouter(TCP); } @@ -288,4 +284,4 @@ private static class TestTask extends ComputeTaskSplitAdapter { return results.get(0).getData(); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/router/RouterFactorySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/router/RouterFactorySelfTest.java index 5df424c4cabce..7a292a1ed032c 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/router/RouterFactorySelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/router/RouterFactorySelfTest.java @@ -24,19 +24,18 @@ import java.util.Iterator; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT; /** * Test routers factory. */ +@RunWith(JUnit4.class) public class RouterFactorySelfTest extends GridCommonAbstractTest { - /** Shared IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_HTTP_PORT = 11087; @@ -44,7 +43,7 @@ public class RouterFactorySelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); + discoSpi.setIpFinder(sharedStaticIpFinder); IgniteConfiguration cfg = new IgniteConfiguration(); @@ -59,6 +58,7 @@ public class RouterFactorySelfTest extends GridCommonAbstractTest { * * @throws Exception In case of any exception. */ + @Test public void testRouterFactory() throws Exception { try { System.setProperty(IGNITE_JETTY_PORT, String.valueOf(GRID_HTTP_PORT)); @@ -109,4 +109,4 @@ public void testRouterFactory() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/router/TcpRouterAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/router/TcpRouterAbstractSelfTest.java index 628006ebfa2ac..c3ae3d2671aac 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/router/TcpRouterAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/router/TcpRouterAbstractSelfTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.internal.client.router.impl.GridTcpRouterImpl; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.logger.log4j.Log4JLogger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Abstract base class for http routing tests. */ +@RunWith(JUnit4.class) public abstract class TcpRouterAbstractSelfTest extends ClientAbstractSelfTest { /** Port number to use by router. */ private static final int ROUTER_PORT = BINARY_PORT + 1; @@ -117,6 +121,7 @@ public GridTcpRouterConfiguration routerConfiguration() throws IgniteCheckedExce /** * @throws Exception If failed. */ + @Test @Override public void testConnectable() throws Exception { GridClient client = client(); @@ -124,4 +129,4 @@ public GridTcpRouterConfiguration routerConfiguration() throws IgniteCheckedExce assertFalse(F.first(nodes).connectable()); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/router/TcpSslRouterSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/router/TcpSslRouterSelfTest.java index 3b47ae5ca9d87..3e710f08796a5 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/router/TcpSslRouterSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/router/TcpSslRouterSelfTest.java @@ -20,12 +20,12 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.client.ssl.GridSslContextFactory; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testsuites.IgniteIgnore; +import org.junit.Ignore; /** * */ -@IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-433", forceFailure = true) +@Ignore(value = "https://issues.apache.org/jira/browse/IGNITE-433") public class TcpSslRouterSelfTest extends TcpRouterAbstractSelfTest { /** {@inheritDoc} */ @Override protected boolean useSsl() { @@ -47,4 +47,4 @@ public class TcpSslRouterSelfTest extends TcpRouterAbstractSelfTest { return cfg; } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/suite/IgniteClientTestSuite.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/suite/IgniteClientTestSuite.java index 657fda4a80179..ae8ab987608d2 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/suite/IgniteClientTestSuite.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/suite/IgniteClientTestSuite.java @@ -17,10 +17,12 @@ package org.apache.ignite.internal.client.suite; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.TaskEventSubjectIdSelfTest; import org.apache.ignite.internal.client.ClientDefaultCacheSelfTest; import org.apache.ignite.internal.client.ClientReconnectionSelfTest; +import org.apache.ignite.internal.client.ClientSslParametersTest; import org.apache.ignite.internal.client.ClientTcpMultiThreadedSelfTest; import org.apache.ignite.internal.client.ClientTcpSslAuthenticationSelfTest; import org.apache.ignite.internal.client.ClientTcpSslMultiThreadedSelfTest; @@ -53,6 +55,7 @@ import org.apache.ignite.internal.processors.rest.ClientMemcachedProtocolSelfTest; import org.apache.ignite.internal.processors.rest.JettyRestProcessorAuthenticationWithCredsSelfTest; import org.apache.ignite.internal.processors.rest.JettyRestProcessorAuthenticationWithTokenSelfTest; +import org.apache.ignite.internal.processors.rest.JettyRestProcessorBaselineSelfTest; import org.apache.ignite.internal.processors.rest.JettyRestProcessorGetAllAsArrayTest; import org.apache.ignite.internal.processors.rest.JettyRestProcessorSignedSelfTest; import org.apache.ignite.internal.processors.rest.JettyRestProcessorUnsignedSelfTest; @@ -79,91 +82,95 @@ public class IgniteClientTestSuite extends TestSuite { public static TestSuite suite() { TestSuite suite = new IgniteTestSuite("Ignite Clients Test Suite"); - suite.addTestSuite(RouterFactorySelfTest.class); + suite.addTest(new JUnit4TestAdapter(RouterFactorySelfTest.class)); // Parser standalone test. - suite.addTestSuite(TcpRestParserSelfTest.class); + suite.addTest(new JUnit4TestAdapter(TcpRestParserSelfTest.class)); // Test memcache protocol with custom test client. - suite.addTestSuite(RestMemcacheProtocolSelfTest.class); + suite.addTest(new JUnit4TestAdapter(RestMemcacheProtocolSelfTest.class)); // Test custom binary protocol with test client. - suite.addTestSuite(RestBinaryProtocolSelfTest.class); - suite.addTestSuite(TcpRestUnmarshalVulnerabilityTest.class); + suite.addTest(new JUnit4TestAdapter(RestBinaryProtocolSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpRestUnmarshalVulnerabilityTest.class)); // Test jetty rest processor - suite.addTestSuite(JettyRestProcessorSignedSelfTest.class); - suite.addTestSuite(JettyRestProcessorUnsignedSelfTest.class); - suite.addTestSuite(JettyRestProcessorAuthenticationWithCredsSelfTest.class); - suite.addTestSuite(JettyRestProcessorAuthenticationWithTokenSelfTest.class); - suite.addTestSuite(JettyRestProcessorGetAllAsArrayTest.class); + suite.addTest(new JUnit4TestAdapter(JettyRestProcessorSignedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JettyRestProcessorUnsignedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JettyRestProcessorAuthenticationWithCredsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JettyRestProcessorAuthenticationWithTokenSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JettyRestProcessorGetAllAsArrayTest.class)); + suite.addTest(new JUnit4TestAdapter(JettyRestProcessorBaselineSelfTest.class)); // Test TCP rest processor with original memcache client. - suite.addTestSuite(ClientMemcachedProtocolSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientMemcachedProtocolSelfTest.class)); // Test TCP rest processor with original REDIS client. - suite.addTestSuite(RedisProtocolStringSelfTest.class); - suite.addTestSuite(RedisProtocolGetAllAsArrayTest.class); - suite.addTestSuite(RedisProtocolConnectSelfTest.class); - suite.addTestSuite(RedisProtocolServerSelfTest.class); + suite.addTest(new JUnit4TestAdapter(RedisProtocolStringSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(RedisProtocolGetAllAsArrayTest.class)); + suite.addTest(new JUnit4TestAdapter(RedisProtocolConnectSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(RedisProtocolServerSelfTest.class)); - suite.addTestSuite(RestProcessorStartSelfTest.class); + suite.addTest(new JUnit4TestAdapter(RestProcessorStartSelfTest.class)); // Test cache flag conversion. - suite.addTestSuite(ClientCacheFlagsCodecTest.class); + suite.addTest(new JUnit4TestAdapter(ClientCacheFlagsCodecTest.class)); // Test multi-start. - suite.addTestSuite(RestProcessorMultiStartSelfTest.class); + suite.addTest(new JUnit4TestAdapter(RestProcessorMultiStartSelfTest.class)); // Test clients. - suite.addTestSuite(ClientDataImplSelfTest.class); - suite.addTestSuite(ClientComputeImplSelfTest.class); - suite.addTestSuite(ClientTcpSelfTest.class); - suite.addTestSuite(ClientTcpDirectSelfTest.class); - suite.addTestSuite(ClientTcpSslSelfTest.class); - suite.addTestSuite(ClientTcpSslDirectSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientDataImplSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientComputeImplSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientTcpSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientTcpDirectSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientTcpSslSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientTcpSslDirectSelfTest.class)); // Test client with many nodes. - suite.addTestSuite(ClientTcpMultiNodeSelfTest.class); - suite.addTestSuite(ClientTcpDirectMultiNodeSelfTest.class); - suite.addTestSuite(ClientTcpSslMultiNodeSelfTest.class); - suite.addTestSuite(ClientTcpSslDirectMultiNodeSelfTest.class); - suite.addTestSuite(ClientTcpUnreachableMultiNodeSelfTest.class); - suite.addTestSuite(ClientPreferDirectSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientTcpMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientTcpDirectMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientTcpSslMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientTcpSslDirectMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientTcpUnreachableMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientPreferDirectSelfTest.class)); // Test client with many nodes and in multithreaded scenarios - suite.addTestSuite(ClientTcpMultiThreadedSelfTest.class); - suite.addTestSuite(ClientTcpSslMultiThreadedSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientTcpMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientTcpSslMultiThreadedSelfTest.class)); // Test client authentication. - suite.addTestSuite(ClientTcpSslAuthenticationSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientTcpSslAuthenticationSelfTest.class)); - suite.addTestSuite(ClientTcpConnectivitySelfTest.class); - suite.addTestSuite(ClientReconnectionSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientTcpConnectivitySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientReconnectionSelfTest.class)); // Rest task command handler test. - suite.addTestSuite(TaskCommandHandlerSelfTest.class); - suite.addTestSuite(ChangeStateCommandHandlerTest.class); - suite.addTestSuite(TaskEventSubjectIdSelfTest.class); + suite.addTest(new JUnit4TestAdapter(TaskCommandHandlerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ChangeStateCommandHandlerTest.class)); + suite.addTest(new JUnit4TestAdapter(TaskEventSubjectIdSelfTest.class)); // Default cache only test. - suite.addTestSuite(ClientDefaultCacheSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientDefaultCacheSelfTest.class)); - suite.addTestSuite(ClientFutureAdapterSelfTest.class); - suite.addTestSuite(ClientPropertiesConfigurationSelfTest.class); - suite.addTestSuite(ClientConsistentHashSelfTest.class); - suite.addTestSuite(ClientJavaHasherSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientFutureAdapterSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientPropertiesConfigurationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientConsistentHashSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientJavaHasherSelfTest.class)); - suite.addTestSuite(ClientByteUtilsTest.class); + suite.addTest(new JUnit4TestAdapter(ClientByteUtilsTest.class)); // Router tests. - suite.addTestSuite(TcpRouterSelfTest.class); - suite.addTestSuite(TcpSslRouterSelfTest.class); - suite.addTestSuite(TcpRouterMultiNodeSelfTest.class); + suite.addTest(new JUnit4TestAdapter(TcpRouterSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpSslRouterSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpRouterMultiNodeSelfTest.class)); - suite.addTestSuite(ClientFailedInitSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientFailedInitSelfTest.class)); - suite.addTestSuite(ClientTcpTaskExecutionAfterTopologyRestartSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClientTcpTaskExecutionAfterTopologyRestartSelfTest.class)); + + // SSL params. + suite.addTest(new JUnit4TestAdapter(ClientSslParametersTest.class)); return suite; } diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientByteUtilsTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientByteUtilsTest.java index 72112cb8e6fd9..93aa8cd17b310 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientByteUtilsTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientByteUtilsTest.java @@ -25,6 +25,9 @@ import org.apache.ignite.internal.util.GridClientByteUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.util.GridClientByteUtils.bytesToInt; import static org.apache.ignite.internal.util.GridClientByteUtils.bytesToLong; @@ -36,12 +39,14 @@ /** * Test case for client's byte convertion utility. */ +@RunWith(JUnit4.class) public class ClientByteUtilsTest extends GridCommonAbstractTest { /** * Test UUID conversions from string to binary and back. * * @throws Exception On any exception. */ + @Test public void testUuidConvertions() throws Exception { Map map = new LinkedHashMap<>(); @@ -92,6 +97,7 @@ public void testUuidConvertions() throws Exception { } } + @Test public void testShortToBytes() throws Exception { Map map = new HashMap<>(); @@ -116,6 +122,7 @@ public void testShortToBytes() throws Exception { } } + @Test public void testIntToBytes() throws Exception { Map map = new HashMap<>(); @@ -140,6 +147,7 @@ public void testIntToBytes() throws Exception { } } + @Test public void testLongToBytes() throws Exception { Map map = new LinkedHashMap<>(); @@ -177,4 +185,4 @@ private byte[] asByteArray(String text) { return b; } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientConsistentHashSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientConsistentHashSelfTest.java index fa9d4b49a4d89..b0c7217c72512 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientConsistentHashSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientConsistentHashSelfTest.java @@ -31,10 +31,14 @@ import java.util.TreeSet; import java.util.UUID; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for consistent hash management class. */ +@RunWith(JUnit4.class) public class ClientConsistentHashSelfTest extends GridCommonAbstractTest { /** Replicas count. */ private static final int REPLICAS = 512; @@ -44,6 +48,7 @@ public class ClientConsistentHashSelfTest extends GridCommonAbstractTest { * * @throws Exception In case of any exception. */ + @Test public void testCollisions() throws Exception { Map> map = new HashMap<>(); @@ -95,6 +100,7 @@ public void testCollisions() throws Exception { * * @throws Exception In case of any exception. */ + @Test public void testTreeSetRestrictions() throws Exception { // Constructs hash without explicit node's comparator. GridClientConsistentHash hash = new GridClientConsistentHash<>(); @@ -129,6 +135,7 @@ public void testTreeSetRestrictions() throws Exception { * Validate generated hashes.

* Note! This test should be ported into all supported platforms. */ + @Test public void testHashGeneraton() { // Validate strings. checkHash("", -1484017934); @@ -167,7 +174,7 @@ public void testHashGeneraton() { /** * Test mapping to nodes. */ - @SuppressWarnings("UnaryPlus") + @Test public void testMappingToNodes() { String n1 = "node #1"; String n2 = "node #2"; @@ -289,4 +296,4 @@ private void checkHash(Object o, int code) { assertEquals("Check affinity for object: " + o, code, i); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientJavaHasherSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientJavaHasherSelfTest.java index 765c58d88eeca..432cd895ae43d 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientJavaHasherSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/util/ClientJavaHasherSelfTest.java @@ -21,14 +21,19 @@ import java.util.Map; import java.util.UUID; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for Java hash codes calculations - SHOULD BE PORTED to other languages. */ +@RunWith(JUnit4.class) public class ClientJavaHasherSelfTest extends GridCommonAbstractTest { /** * Validate known Java hash codes. */ + @Test public void testPredefined() { Map map = new LinkedHashMap<>(); @@ -82,4 +87,4 @@ public void testPredefined() { fail("Java hash codes validation fails."); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcAbstractDmlStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcAbstractDmlStatementSelfTest.java index 1cc5740c2f761..60e680d5aff41 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcAbstractDmlStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcAbstractDmlStatementSelfTest.java @@ -131,7 +131,7 @@ protected String getCfgUrl() { /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { - ((IgniteEx)ignite(0)).context().cache().dynamicDestroyCache(DEFAULT_CACHE_NAME, true, true, false); + ((IgniteEx)ignite(0)).context().cache().dynamicDestroyCache(DEFAULT_CACHE_NAME, true, true, false, null); if (conn != null) { conn.close(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcBlobTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcBlobTest.java index 9e0e0d2f6aab1..a8267aa238512 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcBlobTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcBlobTest.java @@ -21,15 +21,20 @@ import java.io.InputStream; import java.sql.SQLException; import java.util.Arrays; -import junit.framework.TestCase; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.fail; /** * */ -public class JdbcBlobTest extends TestCase { +public class JdbcBlobTest { /** * @throws Exception If failed. */ + @Test public void testLength() throws Exception { JdbcBlob blob = new JdbcBlob(new byte[16]); @@ -50,6 +55,7 @@ public void testLength() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetBytes() throws Exception { byte[] arr = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; @@ -124,6 +130,7 @@ public void testGetBytes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetBinaryStream() throws Exception { byte[] arr = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; @@ -150,6 +157,7 @@ public void testGetBinaryStream() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetBinaryStreamWithParams() throws Exception { byte[] arr = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; @@ -222,6 +230,7 @@ public void testGetBinaryStreamWithParams() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPositionBytePattern() throws Exception { byte[] arr = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; @@ -256,6 +265,7 @@ public void testPositionBytePattern() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPositionBlobPattern() throws Exception { byte[] arr = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; @@ -290,6 +300,7 @@ public void testPositionBlobPattern() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetBytes() throws Exception { byte[] arr = new byte[] {0, 1, 2, 3, 4, 5, 6, 7}; @@ -341,6 +352,7 @@ public void testSetBytes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetBytesWithOffsetAndLength() throws Exception { byte[] arr = new byte[] {0, 1, 2, 3, 4, 5, 6, 7}; @@ -419,6 +431,7 @@ public void testSetBytesWithOffsetAndLength() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTruncate() throws Exception { byte[] arr = new byte[] {0, 1, 2, 3, 4, 5, 6, 7}; @@ -482,4 +495,4 @@ private static byte[] readBytes(InputStream is) throws IOException { return res; } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcBulkLoadSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcBulkLoadSelfTest.java index 753a98c9cc775..df12cbec784f8 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcBulkLoadSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcBulkLoadSelfTest.java @@ -37,12 +37,16 @@ import java.util.Collections; import java.util.Properties; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** COPY command test for the regular JDBC driver. */ +@RunWith(JUnit4.class) public class JdbcBulkLoadSelfTest extends GridCommonAbstractTest { /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + @@ -124,6 +128,7 @@ private Connection createConnection() throws Exception { * * @throws Exception if failed. */ + @Test public void testBulkLoadThrows() throws Exception { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcComplexQuerySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcComplexQuerySelfTest.java index 8b1390e2c58d8..b006cb61c042f 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcComplexQuerySelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcComplexQuerySelfTest.java @@ -28,11 +28,11 @@ import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -42,10 +42,8 @@ /** * Tests for complex queries (joins, etc.). */ +@RunWith(JUnit4.class) public class JdbcComplexQuerySelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + "cache=pers@modules/clients/src/test/config/jdbc-config.xml"; @@ -60,12 +58,6 @@ public class JdbcComplexQuerySelfTest extends GridCommonAbstractTest { cacheConfiguration("pers", AffinityKey.class, Person.class), cacheConfiguration("org", String.class, Organization.class)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -131,6 +123,7 @@ protected CacheConfiguration cacheConfiguration(@NotNull String name, Class c /** * @throws Exception If failed. */ + @Test public void testJoin() throws Exception { ResultSet rs = stmt.executeQuery( "select p.id, p.name, o.name as orgName from \"pers\".Person p, \"org\".Organization o where p.orgId = o.id"); @@ -166,6 +159,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testJoinWithoutAlias() throws Exception { ResultSet rs = stmt.executeQuery( "select p.id, p.name, o.name from \"pers\".Person p, \"org\".Organization o where p.orgId = o.id"); @@ -204,6 +198,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testIn() throws Exception { ResultSet rs = stmt.executeQuery("select name from \"pers\".Person where age in (25, 35)"); @@ -224,6 +219,7 @@ public void testIn() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBetween() throws Exception { ResultSet rs = stmt.executeQuery("select name from \"pers\".Person where age between 24 and 36"); @@ -244,6 +240,7 @@ public void testBetween() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCalculatedValue() throws Exception { ResultSet rs = stmt.executeQuery("select age * 2 from \"pers\".Person"); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionReopenTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionReopenTest.java index 531b4e52352f6..554626b059467 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionReopenTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionReopenTest.java @@ -22,12 +22,16 @@ import org.apache.ignite.Ignite; import org.apache.ignite.internal.IgnitionEx; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; /** * Connection test. */ +@RunWith(JUnit4.class) public class JdbcConnectionReopenTest extends GridCommonAbstractTest { /** * @return Config URL to use in test. @@ -39,6 +43,7 @@ private String configURL() { /** * @throws Exception If failed. */ + @Test public void testReopenSameInstanceName() throws Exception { String url = CFG_URL_PREFIX + configURL(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java index d560d74a2c898..999ca2f38f0f0 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcConnectionSelfTest.java @@ -25,22 +25,20 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; /** * Connection test. */ +@RunWith(JUnit4.class) public class JdbcConnectionSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Custom cache name. */ private static final String CUSTOM_CACHE_NAME = "custom-cache"; @@ -66,12 +64,6 @@ protected String configURL() { cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME), cacheConfiguration(CUSTOM_CACHE_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setDaemon(daemon); cfg.setClientMode(client); @@ -100,6 +92,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) throws Excep /** * @throws Exception If failed. */ + @Test public void testDefaults() throws Exception { String url = CFG_URL_PREFIX + configURL(); @@ -117,6 +110,7 @@ public void testDefaults() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeId() throws Exception { String url = CFG_URL_PREFIX + "nodeId=" + grid(0).localNode().id() + '@' + configURL(); @@ -134,6 +128,7 @@ public void testNodeId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWrongNodeId() throws Exception { UUID wrongId = UUID.randomUUID(); @@ -156,6 +151,7 @@ public void testWrongNodeId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNodeId() throws Exception { client = true; @@ -182,6 +178,7 @@ public void testClientNodeId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDaemonNodeId() throws Exception { daemon = true; @@ -208,6 +205,7 @@ public void testDaemonNodeId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomCache() throws Exception { String url = CFG_URL_PREFIX + "cache=" + CUSTOM_CACHE_NAME + '@' + configURL(); @@ -219,6 +217,7 @@ public void testCustomCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWrongCache() throws Exception { final String url = CFG_URL_PREFIX + "cache=wrongCacheName@" + configURL(); @@ -239,6 +238,7 @@ public void testWrongCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClose() throws Exception { String url = CFG_URL_PREFIX + configURL(); @@ -268,6 +268,7 @@ public void testClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxAllowedCommit() throws Exception { String url = CFG_URL_PREFIX + "transactionsAllowed=true@" + configURL(); @@ -285,6 +286,7 @@ public void testTxAllowedCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxAllowedRollback() throws Exception { String url = CFG_URL_PREFIX + "transactionsAllowed=true@" + configURL(); @@ -302,6 +304,7 @@ public void testTxAllowedRollback() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlHints() throws Exception { try (final Connection conn = DriverManager.getConnection(CFG_URL_PREFIX + "enforceJoinOrder=true@" + configURL())) { diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDeleteStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDeleteStatementSelfTest.java index 3eec5a025d947..5652fb1177368 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDeleteStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDeleteStatementSelfTest.java @@ -21,14 +21,19 @@ import java.sql.SQLException; import java.util.Arrays; import java.util.HashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class JdbcDeleteStatementSelfTest extends JdbcAbstractUpdateStatementSelfTest { /** * */ + @Test public void testExecute() throws SQLException { conn.createStatement().execute("delete from Person where cast(substring(_key, 2, 1) as int) % 2 = 0"); @@ -39,6 +44,7 @@ public void testExecute() throws SQLException { /** * */ + @Test public void testExecuteUpdate() throws SQLException { int res = conn.createStatement().executeUpdate("delete from Person where cast(substring(_key, 2, 1) as int) % 2 = 0"); @@ -51,6 +57,7 @@ public void testExecuteUpdate() throws SQLException { /** * */ + @Test public void testBatch() throws SQLException { PreparedStatement ps = conn.prepareStatement("delete from Person where firstName = ?"); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDistributedJoinsQueryTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDistributedJoinsQueryTest.java index 2a58e0280676b..7972683129ed3 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDistributedJoinsQueryTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDistributedJoinsQueryTest.java @@ -27,10 +27,10 @@ import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -40,10 +40,8 @@ /** * Tests for complex queries with distributed joins enabled (joins, etc.). */ +@RunWith(JUnit4.class) public class JdbcDistributedJoinsQueryTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + "cache=default:distributedJoins=true@modules/clients/src/test/config/jdbc-config.xml"; @@ -64,12 +62,6 @@ public class JdbcDistributedJoinsQueryTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -116,6 +108,7 @@ public class JdbcDistributedJoinsQueryTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testJoin() throws Exception { ResultSet rs = stmt.executeQuery( "select p.id, p.name, o.name as orgName from Person p, Organization o where p.orgId = o.id"); @@ -151,6 +144,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testJoinWithoutAlias() throws Exception { ResultSet rs = stmt.executeQuery( "select p.id, p.name, o.name from Person p, Organization o where p.orgId = o.id"); @@ -189,6 +183,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testIn() throws Exception { ResultSet rs = stmt.executeQuery("select name from Person where age in (25, 35)"); @@ -209,6 +204,7 @@ public void testIn() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBetween() throws Exception { ResultSet rs = stmt.executeQuery("select name from Person where age between 24 and 36"); @@ -229,6 +225,7 @@ public void testBetween() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCalculatedValue() throws Exception { ResultSet rs = stmt.executeQuery("select age * 2 from Person"); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java index 9485d0d54212c..0ffc073d5cd55 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcDynamicIndexAbstractSelfTest.java @@ -31,10 +31,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that checks indexes handling with JDBC. */ +@RunWith(JUnit4.class) public abstract class JdbcDynamicIndexAbstractSelfTest extends JdbcAbstractDmlStatementSelfTest { /** */ private final static String CREATE_INDEX = "create index idx on Person (id desc)"; @@ -136,6 +140,7 @@ private Object getSingleValue(ResultSet rs) throws SQLException { /** * Test that after index creation index is used by queries. */ + @Test public void testCreateIndex() throws SQLException { assertSize(3); @@ -165,6 +170,7 @@ public void testCreateIndex() throws SQLException { /** * Test that creating an index with duplicate name yields an error. */ + @Test public void testCreateIndexWithDuplicateName() throws SQLException { jdbcRun(CREATE_INDEX); @@ -179,6 +185,7 @@ public void testCreateIndexWithDuplicateName() throws SQLException { /** * Test that creating an index with duplicate name does not yield an error with {@code IF NOT EXISTS}. */ + @Test public void testCreateIndexIfNotExists() throws SQLException { jdbcRun(CREATE_INDEX); @@ -189,6 +196,7 @@ public void testCreateIndexIfNotExists() throws SQLException { /** * Test that after index drop there are no attempts to use it, and data state remains intact. */ + @Test public void testDropIndex() throws SQLException { assertSize(3); @@ -218,6 +226,7 @@ public void testDropIndex() throws SQLException { /** * Test that dropping a non-existent index yields an error. */ + @Test public void testDropMissingIndex() { assertSqlException(new RunnableX() { /** {@inheritDoc} */ @@ -230,6 +239,7 @@ public void testDropMissingIndex() { /** * Test that dropping a non-existent index does not yield an error with {@code IF EXISTS}. */ + @Test public void testDropMissingIndexIfExists() throws SQLException { // Despite index missing, this does not yield an error. jdbcRun(DROP_INDEX_IF_EXISTS); @@ -238,6 +248,7 @@ public void testDropMissingIndexIfExists() throws SQLException { /** * Test that changes in cache affect index, and vice versa. */ + @Test public void testIndexState() throws SQLException { IgniteCache cache = cache(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcEmptyCacheSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcEmptyCacheSelfTest.java index 25b97ea1c17c6..5fc9f751e9322 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcEmptyCacheSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcEmptyCacheSelfTest.java @@ -18,12 +18,12 @@ package org.apache.ignite.internal.jdbc2; import org.apache.ignite.configuration.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.testframework.junits.common.*; import java.sql.*; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.*; import static org.apache.ignite.cache.CacheMode.*; @@ -32,10 +32,8 @@ /** * Tests for empty cache. */ +@RunWith(JUnit4.class) public class JdbcEmptyCacheSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -62,12 +60,6 @@ public class JdbcEmptyCacheSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -99,6 +91,7 @@ public class JdbcEmptyCacheSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSelectNumber() throws Exception { ResultSet rs = stmt.executeQuery("select 1"); @@ -117,6 +110,7 @@ public void testSelectNumber() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSelectString() throws Exception { ResultSet rs = stmt.executeQuery("select 'str'"); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcErrorsSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcErrorsSelfTest.java index 63f0c84a67f76..a701b91514670 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcErrorsSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcErrorsSelfTest.java @@ -22,10 +22,14 @@ import java.sql.SQLException; import org.apache.ignite.jdbc.JdbcErrorsAbstractSelfTest; import org.apache.ignite.lang.IgniteCallable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test SQLSTATE codes propagation with thin client driver. */ +@RunWith(JUnit4.class) public class JdbcErrorsSelfTest extends JdbcErrorsAbstractSelfTest { /** Path to JDBC configuration for node that is to start. */ private static final String CFG_PATH = "modules/clients/src/test/config/jdbc-config.xml"; @@ -40,6 +44,7 @@ public class JdbcErrorsSelfTest extends JdbcErrorsAbstractSelfTest { * due to communication problems (not due to clear misconfiguration). * @throws SQLException if failed. */ + @Test public void testConnectionError() throws SQLException { final String path = "jdbc:ignite:сfg://cache=test@/unknown/path"; @@ -56,6 +61,7 @@ public void testConnectionError() throws SQLException { * Test error code for the case when connection string is a mess. * @throws SQLException if failed. */ + @Test public void testInvalidConnectionStringFormat() throws SQLException { final String cfgPath = "cache="; diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcInsertStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcInsertStatementSelfTest.java index 44a45b7323b4a..70c1d2df1e52a 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcInsertStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcInsertStatementSelfTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Statement test. */ +@RunWith(JUnit4.class) public class JdbcInsertStatementSelfTest extends JdbcAbstractDmlStatementSelfTest { /** SQL query. */ private static final String SQL = "insert into Person(_key, id, firstName, lastName, age, data) values " + @@ -136,6 +140,7 @@ public class JdbcInsertStatementSelfTest extends JdbcAbstractDmlStatementSelfTes /** * @throws SQLException If failed. */ + @Test public void testExecuteUpdate() throws SQLException { int res = stmt.executeUpdate(SQL); @@ -145,6 +150,7 @@ public void testExecuteUpdate() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testExecute() throws SQLException { boolean res = stmt.execute(SQL); @@ -154,6 +160,7 @@ public void testExecute() throws SQLException { /** * */ + @Test public void testDuplicateKeys() { jcache(0).put("p2", new Person(2, "Joe", "Black", 35)); @@ -177,6 +184,7 @@ public void testDuplicateKeys() { /** * @throws SQLException if failed. */ + @Test public void testBatch() throws SQLException { formBatch(1, 2); formBatch(3, 4); @@ -189,6 +197,7 @@ public void testBatch() throws SQLException { /** * @throws SQLException if failed. */ + @Test public void testSingleItemBatch() throws SQLException { formBatch(1, 2); @@ -200,6 +209,7 @@ public void testSingleItemBatch() throws SQLException { /** * @throws SQLException if failed. */ + @Test public void testSingleItemBatchError() throws SQLException { formBatch(1, 2); @@ -223,6 +233,7 @@ public void testSingleItemBatchError() throws SQLException { /** * @throws SQLException if failed. */ + @Test public void testErrorAmidstBatch() throws SQLException { formBatch(1, 2); formBatch(3, 1); // Duplicate key @@ -248,6 +259,7 @@ public void testErrorAmidstBatch() throws SQLException { /** * @throws Exception If failed. */ + @Test public void testClearBatch() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws SQLException { diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcLocalCachesSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcLocalCachesSelfTest.java index 46379cba70b81..4174975b9c854 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcLocalCachesSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcLocalCachesSelfTest.java @@ -25,10 +25,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; import static org.apache.ignite.IgniteJdbcDriver.PROP_NODE_ID; @@ -38,10 +38,8 @@ /** * Test JDBC with several local caches. */ +@RunWith(JUnit4.class) public class JdbcLocalCachesSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -65,12 +63,6 @@ public class JdbcLocalCachesSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -98,6 +90,7 @@ public class JdbcLocalCachesSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCache1() throws Exception { Properties cfg = new Properties(); @@ -129,6 +122,7 @@ public void testCache1() throws Exception { * * @throws Exception If failed. */ + @Test public void testCountAll() throws Exception { Properties cfg = new Properties(); @@ -154,6 +148,7 @@ public void testCountAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCache2() throws Exception { Properties cfg = new Properties(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMergeStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMergeStatementSelfTest.java index 489bacd8ea906..b9fc04ec24426 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMergeStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMergeStatementSelfTest.java @@ -23,10 +23,14 @@ import java.sql.Statement; import java.util.Arrays; import org.apache.ignite.cache.CachePeekMode; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * MERGE statement test. */ +@RunWith(JUnit4.class) public class JdbcMergeStatementSelfTest extends JdbcAbstractDmlStatementSelfTest { /** SQL query. */ private static final String SQL = "merge into Person(_key, id, firstName, lastName, age, data) values " + @@ -130,6 +134,7 @@ public class JdbcMergeStatementSelfTest extends JdbcAbstractDmlStatementSelfTest /** * @throws SQLException If failed. */ + @Test public void testExecuteUpdate() throws SQLException { int res = stmt.executeUpdate(SQL); @@ -139,6 +144,7 @@ public void testExecuteUpdate() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testExecute() throws SQLException { boolean res = stmt.execute(SQL); @@ -148,6 +154,7 @@ public void testExecute() throws SQLException { /** * @throws SQLException if failed. */ + @Test public void testBatch() throws SQLException { prepStmt.setString(1, "p1"); prepStmt.setInt(2, 1); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMetadataSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMetadataSelfTest.java index c3d0824ff1230..fc4265f6f0081 100755 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMetadataSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcMetadataSelfTest.java @@ -44,11 +44,11 @@ import org.apache.ignite.internal.IgniteVersionUtils; import org.apache.ignite.internal.processors.query.QueryEntityEx; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.sql.Types.INTEGER; import static java.sql.Types.VARCHAR; @@ -60,10 +60,8 @@ /** * Metadata tests. */ +@RunWith(JUnit4.class) public class JdbcMetadataSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + "cache=pers@modules/clients/src/test/config/jdbc-config.xml"; @@ -91,12 +89,6 @@ public class JdbcMetadataSelfTest extends GridCommonAbstractTest { cacheConfiguration("org").setQueryEntities(Arrays.asList( new QueryEntity(AffinityKey.class, Organization.class)))); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -137,6 +129,7 @@ protected CacheConfiguration cacheConfiguration(@NotNull String name) { /** * @throws Exception If failed. */ + @Test public void testResultSetMetaData() throws Exception { try (Connection conn = DriverManager.getConnection(BASE_URL)) { Statement stmt = conn.createStatement(); @@ -171,6 +164,7 @@ public void testResultSetMetaData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetTables() throws Exception { try (Connection conn = DriverManager.getConnection(BASE_URL)) { DatabaseMetaData meta = conn.getMetaData(); @@ -207,6 +201,7 @@ public void testGetTables() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetColumns() throws Exception { try (Connection conn = DriverManager.getConnection(BASE_URL)) { DatabaseMetaData meta = conn.getMetaData(); @@ -295,6 +290,7 @@ public void testGetColumns() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMetadataResultSetClose() throws Exception { try (Connection conn = DriverManager.getConnection(BASE_URL); ResultSet tbls = conn.getMetaData().getTables(null, null, "%", null)) { @@ -313,6 +309,7 @@ public void testMetadataResultSetClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIndexMetadata() throws Exception { try (Connection conn = DriverManager.getConnection(BASE_URL); ResultSet rs = conn.getMetaData().getIndexInfo(null, "pers", "PERSON", false, false)) { @@ -351,6 +348,7 @@ else if ("AGE".equals(field)) /** * @throws Exception If failed. */ + @Test public void testPrimaryKeyMetadata() throws Exception { try (Connection conn = DriverManager.getConnection(BASE_URL); ResultSet rs = conn.getMetaData().getPrimaryKeys(null, "pers", "PERSON")) { @@ -370,6 +368,7 @@ public void testPrimaryKeyMetadata() throws Exception { /** * @throws Exception If failed. */ + @Test public void testParametersMetadata() throws Exception { try (Connection conn = DriverManager.getConnection(BASE_URL)) { conn.setSchema("pers"); @@ -394,6 +393,7 @@ public void testParametersMetadata() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSchemasMetadata() throws Exception { try (Connection conn = DriverManager.getConnection(BASE_URL)) { ResultSet rs = conn.getMetaData().getSchemas(); @@ -415,6 +415,7 @@ public void testSchemasMetadata() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersions() throws Exception { try (Connection conn = DriverManager.getConnection(BASE_URL)) { assertEquals("Apache Ignite", conn.getMetaData().getDatabaseProductName()); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoCacheStreamingSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoCacheStreamingSelfTest.java index e32e07036bb0a..e3bdfec4dded7 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoCacheStreamingSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoCacheStreamingSelfTest.java @@ -31,6 +31,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -39,6 +42,7 @@ /** * Data streaming test for thick driver and no explicit caches. */ +@RunWith(JUnit4.class) public class JdbcNoCacheStreamingSelfTest extends GridCommonAbstractTest { /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + @@ -123,6 +127,7 @@ protected Connection createConnection(boolean allowOverwrite) throws Exception { /** * @throws Exception if failed. */ + @Test public void testStreamedInsert() throws Exception { for (int i = 10; i <= 100; i += 10) ignite(0).cache(DEFAULT_CACHE_NAME).put(i, i * 100); @@ -152,6 +157,7 @@ public void testStreamedInsert() throws Exception { /** * @throws Exception if failed. */ + @Test public void testStreamedInsertWithOverwritesAllowed() throws Exception { for (int i = 10; i <= 100; i += 10) ignite(0).cache(DEFAULT_CACHE_NAME).put(i, i * 100); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java index 5c549a82712b6..34207eb572f10 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcNoDefaultCacheTest.java @@ -26,22 +26,20 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; /** * */ +@RunWith(JUnit4.class) public class JdbcNoDefaultCacheTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** First cache name. */ private static final String CACHE1_NAME = "cache1"; @@ -60,12 +58,6 @@ public class JdbcNoDefaultCacheTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheConfiguration(CACHE1_NAME), cacheConfiguration(CACHE2_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -102,6 +94,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) throws Excep /** * @throws Exception If failed. */ + @Test public void testDefaults() throws Exception { String url = CFG_URL_PREFIX + CFG_URL; @@ -119,6 +112,7 @@ public void testDefaults() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoCacheNameQuery() throws Exception { try ( Connection conn = DriverManager.getConnection(CFG_URL_PREFIX + CFG_URL); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java index 0a48961cfbf16..713d66ba0152a 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java @@ -33,10 +33,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.sql.Types.BIGINT; import static java.sql.Types.BINARY; @@ -59,10 +59,8 @@ /** * Prepared statement test. */ +@RunWith(JUnit4.class) public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + "cache=default@modules/clients/src/test/config/jdbc-config.xml"; @@ -87,12 +85,6 @@ public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -154,6 +146,7 @@ public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRepeatableUsage() throws Exception { stmt = conn.prepareStatement("select * from TestObject where id = ?"); @@ -189,6 +182,7 @@ public void testRepeatableUsage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { stmt = conn.prepareStatement("select * from TestObject where boolVal is not distinct from ?"); @@ -226,6 +220,7 @@ public void testBoolean() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByte() throws Exception { stmt = conn.prepareStatement("select * from TestObject where byteVal is not distinct from ?"); @@ -263,6 +258,7 @@ public void testByte() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { stmt = conn.prepareStatement("select * from TestObject where shortVal is not distinct from ?"); @@ -300,6 +296,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInteger() throws Exception { stmt = conn.prepareStatement("select * from TestObject where intVal is not distinct from ?"); @@ -337,6 +334,7 @@ public void testInteger() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { stmt = conn.prepareStatement("select * from TestObject where longVal is not distinct from ?"); @@ -374,6 +372,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { stmt = conn.prepareStatement("select * from TestObject where floatVal is not distinct from ?"); @@ -411,6 +410,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { stmt = conn.prepareStatement("select * from TestObject where doubleVal is not distinct from ?"); @@ -448,6 +448,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimal() throws Exception { stmt = conn.prepareStatement("select * from TestObject where bigVal is not distinct from ?"); @@ -485,6 +486,7 @@ public void testBigDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testString() throws Exception { stmt = conn.prepareStatement("select * from TestObject where strVal is not distinct from ?"); @@ -522,6 +524,7 @@ public void testString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArray() throws Exception { stmt = conn.prepareStatement("select * from TestObject where arrVal is not distinct from ?"); @@ -559,6 +562,7 @@ public void testArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlob() throws Exception { stmt = conn.prepareStatement("select * from TestObject where blobVal is not distinct from ?"); @@ -600,6 +604,7 @@ public void testBlob() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDate() throws Exception { stmt = conn.prepareStatement("select * from TestObject where dateVal is not distinct from ?"); @@ -637,6 +642,7 @@ public void testDate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTime() throws Exception { stmt = conn.prepareStatement("select * from TestObject where timeVal is not distinct from ?"); @@ -674,6 +680,7 @@ public void testTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { stmt = conn.prepareStatement("select * from TestObject where tsVal is not distinct from ?"); @@ -711,6 +718,7 @@ public void testTimestamp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUrl() throws Exception { stmt = conn.prepareStatement("select * from TestObject where urlVal is not distinct from ?"); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java index bd73bcd8d274d..b51ca530bb04e 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java @@ -40,11 +40,11 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -55,10 +55,8 @@ * Result set test. */ @SuppressWarnings("FloatingPointEquality") +@RunWith(JUnit4.class) public class JdbcResultSetSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + "cache=default@modules/clients/src/test/config/jdbc-config.xml"; @@ -87,12 +85,6 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -164,6 +156,7 @@ private TestObject createObjectWithData(int id) throws MalformedURLException { /** * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -244,6 +237,7 @@ public void testBoolean() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBoolean2() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -264,6 +258,7 @@ public void testBoolean2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBoolean3() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -284,6 +279,7 @@ public void testBoolean3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBoolean4() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -304,6 +300,7 @@ public void testBoolean4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByte() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -344,6 +341,7 @@ public void testByte() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -384,6 +382,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInteger() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -424,6 +423,7 @@ public void testInteger() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -464,6 +464,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -504,6 +505,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -544,6 +546,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimal() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -584,6 +587,7 @@ public void testBigDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimalScale() throws Exception { assert "0.12".equals(convertStringToBigDecimalViaJdbc("0.1234", 2).toString()); assert "1.001".equals(convertStringToBigDecimalViaJdbc("1.0005", 3).toString()); @@ -608,6 +612,7 @@ private BigDecimal convertStringToBigDecimalViaJdbc(String strDec, int scale) th /** * @throws Exception If failed. */ + @Test public void testString() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -647,6 +652,7 @@ public void testString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArray() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -668,6 +674,7 @@ public void testArray() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testDate() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -696,6 +703,7 @@ public void testDate() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testTime() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -723,6 +731,7 @@ public void testTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -750,6 +759,7 @@ public void testTimestamp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUrl() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -770,6 +780,7 @@ public void testUrl() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObject() throws Exception { final Ignite ignite = ignite(0); final boolean binaryMarshaller = ignite.configuration().getMarshaller() instanceof BinaryMarshaller; @@ -804,6 +815,7 @@ public void testObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNavigation() throws Exception { ResultSet rs = stmt.executeQuery("select * from TestObject where id > 0"); @@ -849,6 +861,7 @@ public void testNavigation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFetchSize() throws Exception { stmt.setFetchSize(1); @@ -864,6 +877,7 @@ public void testFetchSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNewQueryTaskFetchSize() throws Exception { stmt.setFetchSize(1); @@ -883,6 +897,7 @@ public void testNewQueryTaskFetchSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFindColumn() throws Exception { final ResultSet rs = stmt.executeQuery(SQL); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcSpringSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcSpringSelfTest.java index 7a29b13d7ee5f..f5ab95ccc0ef0 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcSpringSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcSpringSelfTest.java @@ -31,12 +31,16 @@ import org.apache.ignite.internal.util.spring.IgniteSpringHelper; import org.apache.ignite.resources.SpringApplicationContextResource; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; /** * Test of cluster and JDBC driver with config that contains cache with POJO store and datasource bean. */ +@RunWith(JUnit4.class) public class JdbcSpringSelfTest extends JdbcConnectionSelfTest { /** Grid count. */ private static final int GRID_CNT = 2; @@ -61,6 +65,7 @@ public class JdbcSpringSelfTest extends JdbcConnectionSelfTest { } /** {@inheritDoc} */ + @Test @Override public void testClientNodeId() throws Exception { IgniteEx client = (IgniteEx) startGridWithSpringCtx(getTestIgniteInstanceName(), true, configURL()); @@ -96,6 +101,7 @@ private static class TestInjectTarget { * * @throws Exception If test failed. */ + @Test public void testSpringBean() throws Exception { String url = CFG_URL_PREFIX + configURL(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementBatchingSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementBatchingSelfTest.java index c9169b98a6bd7..88fe2358cabb3 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementBatchingSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementBatchingSelfTest.java @@ -23,10 +23,14 @@ import java.sql.Statement; import java.util.concurrent.Callable; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Statement batch test. */ +@RunWith(JUnit4.class) public class JdbcStatementBatchingSelfTest extends JdbcAbstractDmlStatementSelfTest { /** {@inheritDoc} */ @@ -39,6 +43,7 @@ public class JdbcStatementBatchingSelfTest extends JdbcAbstractDmlStatementSelfT /** * @throws SQLException If failed. */ + @Test public void testDatabaseMetadataBatchSupportFlag() throws SQLException { DatabaseMetaData meta = conn.getMetaData(); @@ -50,6 +55,7 @@ public void testDatabaseMetadataBatchSupportFlag() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatch() throws SQLException { try (Statement stmt = conn.createStatement()) { stmt.addBatch("INSERT INTO Person(_key, id, firstName, lastName, age, data) " + @@ -78,6 +84,7 @@ public void testBatch() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testErrorAmidstBatch() throws SQLException { BatchUpdateException reason = (BatchUpdateException) GridTestUtils.assertThrows(log, @@ -110,6 +117,7 @@ public void testErrorAmidstBatch() throws SQLException { /** * @throws Exception If failed. */ + @Test public void testClearBatch() throws Exception { try (Statement stmt = conn.createStatement()) { GridTestUtils.assertThrows(log, new Callable() { diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementSelfTest.java index f778fde2f3b5b..4812bd27928be 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStatementSelfTest.java @@ -28,10 +28,10 @@ import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -40,10 +40,8 @@ /** * Statement test. */ +@RunWith(JUnit4.class) public class JdbcStatementSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + "cache=default:multipleStatementsAllowed=true@modules/clients/src/test/config/jdbc-config.xml"; @@ -72,12 +70,6 @@ public class JdbcStatementSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -119,6 +111,7 @@ public class JdbcStatementSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testExecuteQuery() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -151,6 +144,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testExecute() throws Exception { assert stmt.execute(SQL); @@ -185,6 +179,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testMaxRows() throws Exception { stmt.setMaxRows(1); @@ -248,6 +243,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testExecuteQueryMultipleOnlyResultSets() throws Exception { assert conn.getMetaData().supportsMultipleResultSets(); @@ -276,6 +272,7 @@ public void testExecuteQueryMultipleOnlyResultSets() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExecuteQueryMultipleOnlyDml() throws Exception { assert conn.getMetaData().supportsMultipleResultSets(); @@ -312,6 +309,7 @@ public void testExecuteQueryMultipleOnlyDml() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExecuteQueryMultipleMixed() throws Exception { assert conn.getMetaData().supportsMultipleResultSets(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java index bc545ac70f1fa..bd390ba413154 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingSelfTest.java @@ -26,7 +26,6 @@ import java.util.Properties; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteJdbcDriver; -import org.apache.ignite.IgniteLogger; import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.binary.BinaryObjectBuilder; import org.apache.ignite.configuration.CacheConfiguration; @@ -39,7 +38,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -48,6 +49,7 @@ /** * Data streaming test. */ +@RunWith(JUnit4.class) public class JdbcStreamingSelfTest extends JdbcThinAbstractSelfTest { /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + @@ -165,6 +167,7 @@ protected Connection createStreamedConnection(boolean allowOverwrite, long flush /** * @throws Exception if failed. */ + @Test public void testStreamedInsert() throws Exception { for (int i = 10; i <= 100; i += 10) put(i, nameForId(i * 100)); @@ -195,6 +198,7 @@ public void testStreamedInsert() throws Exception { /** * @throws Exception if failed. */ + @Test public void testStreamedInsertWithoutColumnsList() throws Exception { for (int i = 10; i <= 100; i += 10) put(i, nameForId(i * 100)); @@ -225,6 +229,7 @@ public void testStreamedInsertWithoutColumnsList() throws Exception { /** * @throws Exception if failed. */ + @Test public void testStreamedInsertWithOverwritesAllowed() throws Exception { for (int i = 10; i <= 100; i += 10) put(i, nameForId(i * 100)); @@ -250,6 +255,7 @@ public void testStreamedInsertWithOverwritesAllowed() throws Exception { } /** */ + @Test public void testOnlyInsertsAllowed() { assertStatementForbidden("CREATE TABLE PUBLIC.X (x int primary key, y int)"); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingToPublicCacheTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingToPublicCacheTest.java index 20fd0fbbe392f..e4491ae59d151 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingToPublicCacheTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcStreamingToPublicCacheTest.java @@ -31,6 +31,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -39,6 +42,7 @@ /** * Data streaming test. */ +@RunWith(JUnit4.class) public class JdbcStreamingToPublicCacheTest extends GridCommonAbstractTest { /** JDBC URL. */ private static final String BASE_URL = CFG_URL_PREFIX + "cache=%s@modules/clients/src/test/config/jdbc-config.xml"; @@ -105,6 +109,7 @@ private Connection createConnection(String cacheName, boolean streaming) throws /** * @throws Exception if failed. */ + @Test public void testStreamedInsert() throws Exception { // Create table try (Connection conn = createConnection(DEFAULT_CACHE_NAME, false)) { diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcUpdateStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcUpdateStatementSelfTest.java index 07b5587ffedde..3da079fae5ec2 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcUpdateStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcUpdateStatementSelfTest.java @@ -22,14 +22,19 @@ import java.util.Arrays; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class JdbcUpdateStatementSelfTest extends JdbcAbstractUpdateStatementSelfTest { /** * */ + @Test public void testExecute() throws SQLException { conn.createStatement().execute("update Person set firstName = 'Jack' where " + "cast(substring(_key, 2, 1) as int) % 2 = 0"); @@ -41,6 +46,7 @@ public void testExecute() throws SQLException { /** * */ + @Test public void testExecuteUpdate() throws SQLException { conn.createStatement().executeUpdate("update Person set firstName = 'Jack' where " + "cast(substring(_key, 2, 1) as int) % 2 = 0"); @@ -52,6 +58,7 @@ public void testExecuteUpdate() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatch() throws SQLException { PreparedStatement ps = conn.prepareStatement("update Person set lastName = concat(firstName, 'son') " + "where firstName = ?"); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/AbstractRestProcessorSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/AbstractRestProcessorSelfTest.java index e5c658ccfae82..d765718d961fa 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/AbstractRestProcessorSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/AbstractRestProcessorSelfTest.java @@ -21,18 +21,12 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** * Abstract class for REST protocols tests. */ public abstract class AbstractRestProcessorSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Local host. */ protected static final String LOC_HOST = "127.0.0.1"; @@ -84,12 +78,6 @@ public abstract class AbstractRestProcessorSelfTest extends GridCommonAbstractTe cfg.setConnectorConfiguration(clientCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - CacheConfiguration ccfg = defaultCacheConfiguration(); ccfg.setStatisticsEnabled(true); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ChangeStateCommandHandlerTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ChangeStateCommandHandlerTest.java index cb882e7393c8f..c73833a412dfa 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ChangeStateCommandHandlerTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ChangeStateCommandHandlerTest.java @@ -26,20 +26,18 @@ import org.apache.ignite.internal.client.GridClientConfiguration; import org.apache.ignite.internal.client.GridClientException; import org.apache.ignite.internal.client.GridClientFactory; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.client.GridClientProtocol.TCP; /** * */ +@RunWith(JUnit4.class) public class ChangeStateCommandHandlerTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ public static final String HOST = "127.0.0.1"; @@ -61,12 +59,6 @@ public class ChangeStateCommandHandlerTest extends GridCommonAbstractTest { cfg.setConnectorConfiguration(clientCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -94,6 +86,7 @@ public class ChangeStateCommandHandlerTest extends GridCommonAbstractTest { /** * */ + @Test public void testActivateDeActivate() throws GridClientException { GridClientClusterState state = client.state(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ClientMemcachedProtocolSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ClientMemcachedProtocolSelfTest.java index f80b5e92a52e5..6f83f50e16b99 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ClientMemcachedProtocolSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/ClientMemcachedProtocolSelfTest.java @@ -29,12 +29,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.junit.Assert.assertArrayEquals; /** * Tests for TCP binary protocol. */ +@RunWith(JUnit4.class) public class ClientMemcachedProtocolSelfTest extends AbstractRestProcessorSelfTest { /** Grid count. */ private static final int GRID_CNT = 1; @@ -92,6 +96,7 @@ private MemcachedClientIF startClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { jcache().put("getKey1", "getVal1"); jcache().put("getKey2", "getVal2"); @@ -104,6 +109,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetBulk() throws Exception { jcache().put("getKey1", "getVal1"); jcache().put("getKey2", "getVal2"); @@ -122,6 +128,7 @@ public void testGetBulk() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSet() throws Exception { Assert.assertTrue(client.set("setKey", 0, "setVal").get()); @@ -131,6 +138,7 @@ public void testSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetWithExpiration() throws Exception { Assert.assertTrue(client.set("setKey", 2000, "setVal").get()); @@ -144,6 +152,7 @@ public void testSetWithExpiration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAdd() throws Exception { jcache().put("addKey1", "addVal1"); @@ -157,6 +166,7 @@ public void testAdd() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddWithExpiration() throws Exception { Assert.assertTrue(client.add("addKey", 2000, "addVal").get()); @@ -170,6 +180,7 @@ public void testAddWithExpiration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplace() throws Exception { Assert.assertFalse(client.replace("replaceKey", 0, "replaceVal").get()); @@ -184,6 +195,7 @@ public void testReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplaceWithExpiration() throws Exception { jcache().put("replaceKey", "replaceVal"); @@ -199,6 +211,7 @@ public void testReplaceWithExpiration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDelete() throws Exception { Assert.assertFalse(client.delete("deleteKey").get()); @@ -212,6 +225,7 @@ public void testDelete() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrement() throws Exception { Assert.assertEquals(5, client.incr("incrKey", 3, 2)); @@ -225,6 +239,7 @@ public void testIncrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDecrement() throws Exception { Assert.assertEquals(5, client.decr("decrKey", 10, 15)); @@ -238,6 +253,7 @@ public void testDecrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFlush() throws Exception { jcache().put("flushKey1", "flushVal1"); jcache().put("flushKey2", "flushVal2"); @@ -252,6 +268,7 @@ public void testFlush() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStat() throws Exception { jcache().put("statKey1", "statVal1"); assertEquals("statVal1", jcache().get("statKey1")); @@ -283,6 +300,7 @@ public void testStat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAppend() throws Exception { Assert.assertFalse(client.append(0, "appendKey", "_suffix").get()); @@ -298,6 +316,7 @@ public void testAppend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrepend() throws Exception { Assert.assertFalse(client.append(0, "prependKey", "_suffix").get()); @@ -313,6 +332,7 @@ public void testPrepend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSpecialTypes() throws Exception { Assert.assertTrue(client.set("boolKey", 0, true).get()); @@ -361,6 +381,7 @@ public void testSpecialTypes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testComplexObject() throws Exception { Assert.assertTrue(client.set("objKey", 0, new ValueObject(10, "String")).get()); @@ -370,6 +391,7 @@ public void testComplexObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomPort() throws Exception { customPort = 11212; @@ -392,6 +414,7 @@ public void testCustomPort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersion() throws Exception { Map map = client.getVersions(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java index a972bc33f1999..1f6d1391a1153 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java @@ -139,6 +139,9 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -154,6 +157,7 @@ * Tests for Jetty REST protocol. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public abstract class JettyRestProcessorAbstractSelfTest extends JettyRestProcessorCommonSelfTest { /** Used to sent request charset. */ private static final String CHARSET = StandardCharsets.UTF_8.name(); @@ -285,6 +289,7 @@ protected JsonNode jsonTaskResult(String content) throws IOException { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { jcache().put("getKey", "getVal"); @@ -313,6 +318,7 @@ private void checkJson(String json, Person p) throws IOException { /** * @throws Exception If failed. */ + @Test public void testGetBinaryObjects() throws Exception { Person p = new Person(1, "John", "Doe", 300); @@ -409,6 +415,7 @@ public void testGetBinaryObjects() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNullMapKeyAndValue() throws Exception { Map map1 = new HashMap<>(); map1.put(null, null); @@ -442,6 +449,7 @@ public void testNullMapKeyAndValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleObject() throws Exception { SimplePerson p = new SimplePerson(1, "Test", java.sql.Date.valueOf("1977-01-26"), 1000.55, 39, "CIO", 25); @@ -465,6 +473,7 @@ public void testSimpleObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDate() throws Exception { java.util.Date utilDate = new java.util.Date(); @@ -502,6 +511,7 @@ public void testDate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUUID() throws Exception { UUID uuid = UUID.randomUUID(); @@ -527,6 +537,7 @@ public void testUUID() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTuple() throws Exception { T2 t = new T2("key", "value"); @@ -545,6 +556,7 @@ public void testTuple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheSize() throws Exception { jcache().removeAll(); @@ -560,6 +572,7 @@ public void testCacheSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteName() throws Exception { String ret = content(null, GridRestCommand.NAME); @@ -613,6 +626,7 @@ private void checkGetOrCreateAndDestroy( /** * @throws Exception If failed. */ + @Test public void testGetOrCreateCache() throws Exception { checkGetOrCreateAndDestroy("testCache", PARTITIONED, 0, FULL_SYNC, null, null); @@ -662,6 +676,7 @@ public void testGetOrCreateCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAll() throws Exception { final Map entries = F.asMap("getKey1", "getVal1", "getKey2", "getVal2"); @@ -684,6 +699,7 @@ public void testGetAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncorrectPut() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_PUT, "key", "key0"); @@ -694,6 +710,7 @@ public void testIncorrectPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContainsKey() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put("key0", "val0"); @@ -705,6 +722,7 @@ public void testContainsKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContainsKeys() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put("key0", "val0"); grid(0).cache(DEFAULT_CACHE_NAME).put("key1", "val1"); @@ -720,6 +738,7 @@ public void testContainsKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPut() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put("key0", "val0"); @@ -736,6 +755,7 @@ public void testGetAndPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPutIfAbsent() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put("key0", "val0"); @@ -752,6 +772,7 @@ public void testGetAndPutIfAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsent2() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_PUT_IF_ABSENT, "key", "key0", @@ -766,6 +787,7 @@ public void testPutIfAbsent2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveValue() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put("key0", "val0"); @@ -791,6 +813,7 @@ public void testRemoveValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndRemove() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put("key0", "val0"); @@ -804,6 +827,7 @@ public void testGetAndRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplaceValue() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put("key0", "val0"); @@ -831,6 +855,7 @@ public void testReplaceValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndReplace() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put("key0", "val0"); @@ -847,6 +872,7 @@ public void testGetAndReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeactivateActivate() throws Exception { assertClusterState(true); @@ -863,6 +889,7 @@ public void testDeactivateActivate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_PUT, "key", "putKey", @@ -879,6 +906,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutWithExpiration() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_PUT, "key", "putKey", @@ -898,6 +926,7 @@ public void testPutWithExpiration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAdd() throws Exception { jcache().put("addKey1", "addVal1"); @@ -915,6 +944,7 @@ public void testAdd() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddWithExpiration() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_ADD, "key", "addKey", @@ -934,6 +964,7 @@ public void testAddWithExpiration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAll() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_PUT_ALL, "k1", "putKey1", @@ -953,6 +984,7 @@ public void testPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { jcache().put("rmvKey", "rmvVal"); @@ -970,6 +1002,7 @@ public void testRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAll() throws Exception { jcache().put("rmvKey1", "rmvVal1"); jcache().put("rmvKey2", "rmvVal2"); @@ -1011,6 +1044,7 @@ public void testRemoveAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCas() throws Exception { jcache().put("casKey", "casOldVal"); @@ -1034,6 +1068,7 @@ public void testCas() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplace() throws Exception { jcache().put("repKey", "repOldVal"); @@ -1054,6 +1089,7 @@ public void testReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplaceWithExpiration() throws Exception { jcache().put("replaceKey", "replaceVal"); @@ -1078,6 +1114,7 @@ public void testReplaceWithExpiration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAppend() throws Exception { jcache().put("appendKey", "appendVal"); @@ -1094,6 +1131,7 @@ public void testAppend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrepend() throws Exception { jcache().put("prependKey", "prependVal"); @@ -1110,6 +1148,7 @@ public void testPrepend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrement() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.ATOMIC_INCREMENT, "key", "incrKey", @@ -1136,6 +1175,7 @@ public void testIncrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDecrement() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.ATOMIC_DECREMENT, "key", "decrKey", @@ -1162,6 +1202,7 @@ public void testDecrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCar() throws Exception { jcache().put("casKey", "casOldVal"); @@ -1182,6 +1223,7 @@ public void testCar() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsent() throws Exception { assertNull(jcache().localPeek("casKey")); @@ -1200,6 +1242,7 @@ public void testPutIfAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCasRemove() throws Exception { jcache().put("casKey", "casVal"); @@ -1217,6 +1260,7 @@ public void testCasRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMetrics() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_METRICS); @@ -1306,6 +1350,7 @@ private void testMetadata(Collection metas, JsonNode arr) /** * @throws Exception If failed. */ + @Test public void testMetadataLocal() throws Exception { IgniteCacheProxy cache = F.first(grid(0).context().cache().publicCaches()); @@ -1347,6 +1392,7 @@ public void testMetadataLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMetadataRemote() throws Exception { CacheConfiguration partialCacheCfg = new CacheConfiguration<>("partial"); @@ -1386,6 +1432,7 @@ public void testMetadataRemote() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopology() throws Exception { String ret = content(null, GridRestCommand.TOPOLOGY, "attr", "false", @@ -1428,11 +1475,31 @@ public void testTopology() throws Exception { assertEquals(publicCache.getConfiguration(CacheConfiguration.class).getCacheMode(), cacheMode); } } + + // Test that caches not included. + ret = content(null, GridRestCommand.TOPOLOGY, + "attr", "false", + "mtr", "false", + "caches", "false" + ); + + info("Topology command result: " + ret); + + res = jsonResponse(ret); + + assertEquals(gridCount(), res.size()); + + for (JsonNode node : res) { + assertTrue(node.get("attributes").isNull()); + assertTrue(node.get("metrics").isNull()); + assertTrue(node.get("caches").isNull()); + } } /** * @throws Exception If failed. */ + @Test public void testNode() throws Exception { String ret = content(null, GridRestCommand.NODE, "attr", "true", @@ -1447,6 +1514,12 @@ public void testNode() throws Exception { assertTrue(res.get("attributes").isObject()); assertTrue(res.get("metrics").isObject()); + JsonNode caches = res.get("caches"); + + assertTrue(caches.isArray()); + assertFalse(caches.isNull()); + assertEquals(grid(0).context().cache().publicCaches().size(), caches.size()); + ret = content(null, GridRestCommand.NODE, "attr", "false", "mtr", "false", @@ -1472,6 +1545,22 @@ public void testNode() throws Exception { res = jsonResponse(ret); assertTrue(res.isNull()); + + // Check that caches not included. + ret = content(null, GridRestCommand.NODE, + "id", grid(0).localNode().id().toString(), + "attr", "false", + "mtr", "false", + "caches", "false" + ); + + info("Topology command result: " + ret); + + res = jsonResponse(ret); + + assertTrue(res.get("attributes").isNull()); + assertTrue(res.get("metrics").isNull()); + assertTrue(res.get("caches").isNull()); } /** @@ -1481,6 +1570,7 @@ public void testNode() throws Exception { * * @throws Exception If failed. */ + @Test public void testExe() throws Exception { String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.EXE); @@ -1526,6 +1616,7 @@ public void testExe() throws Exception { * * @throws Exception If failed. */ + @Test public void testVisorGateway() throws Exception { ClusterNode locNode = grid(1).localNode(); @@ -1883,6 +1974,7 @@ public void testVisorGateway() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersion() throws Exception { String ret = content(null, GridRestCommand.VERSION); @@ -1894,6 +1986,7 @@ public void testVersion() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryArgs() throws Exception { String qry = "salary > ? and salary <= ?"; @@ -1915,6 +2008,7 @@ public void testQueryArgs() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryScan() throws Exception { String ret = content("person", GridRestCommand.EXECUTE_SCAN_QUERY, "pageSize", "10", @@ -1931,6 +2025,7 @@ public void testQueryScan() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFilterQueryScan() throws Exception { String ret = content("person", GridRestCommand.EXECUTE_SCAN_QUERY, "pageSize", "10", @@ -1947,6 +2042,7 @@ public void testFilterQueryScan() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncorrectFilterQueryScan() throws Exception { String clsName = ScanFilter.class.getName() + 1; @@ -1961,6 +2057,7 @@ public void testIncorrectFilterQueryScan() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQuery() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put("1", "1"); grid(0).cache(DEFAULT_CACHE_NAME).put("2", "2"); @@ -2006,6 +2103,7 @@ public void testQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedJoinsQuery() throws Exception { String qry = "select * from Person, \"organization\".Organization " + "where \"organization\".Organization.id = Person.orgId " + @@ -2029,6 +2127,7 @@ public void testDistributedJoinsQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlFieldsQuery() throws Exception { String qry = "select concat(firstName, ' ', lastName) from Person"; @@ -2047,6 +2146,7 @@ public void testSqlFieldsQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedJoinsSqlFieldsQuery() throws Exception { String qry = "select * from \"person\".Person p, \"organization\".Organization o where o.id = p.orgId"; @@ -2066,6 +2166,7 @@ public void testDistributedJoinsSqlFieldsQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlFieldsMetadataQuery() throws Exception { String qry = "select firstName, lastName from Person"; @@ -2096,6 +2197,7 @@ public void testSqlFieldsMetadataQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryClose() throws Exception { String qry = "salary > ? and salary <= ?"; @@ -2125,6 +2227,7 @@ public void testQueryClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryDelay() throws Exception { String qry = "salary > ? and salary <= ?"; @@ -2187,6 +2290,7 @@ private void putTypedValue(String type, String k, String v, int status) throws E /** * @throws Exception If failed. */ + @Test public void testTypedPut() throws Exception { // Test boolean type. putTypedValue("boolean", "true", "false", STATUS_SUCCESS); @@ -2364,6 +2468,7 @@ private void getTypedValue(String keyType, String k, String exp) throws Exceptio /** * @throws Exception If failed. */ + @Test public void testTypedGet() throws Exception { // Test boolean type. IgniteCache cBool = typedCache(); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAuthenticationAbstractTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAuthenticationAbstractTest.java index 0ed9e95e9c62a..2e2982d136a76 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAuthenticationAbstractTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAuthenticationAbstractTest.java @@ -26,12 +26,16 @@ import org.apache.ignite.internal.processors.authentication.IgniteAuthenticationProcessor; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.configuration.WALMode.NONE; /** * Test REST with enabled authentication. */ +@RunWith(JUnit4.class) public abstract class JettyRestProcessorAuthenticationAbstractTest extends JettyRestProcessorUnsignedSelfTest { /** */ protected static final String DFLT_USER = "ignite"; @@ -90,6 +94,7 @@ public abstract class JettyRestProcessorAuthenticationAbstractTest extends Jetty /** * @throws Exception If failed. */ + @Test public void testAuthenticationCommand() throws Exception { String ret = content(null, GridRestCommand.AUTHENTICATE); @@ -99,6 +104,7 @@ public void testAuthenticationCommand() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddUpdateRemoveUser() throws Exception { // Add user. String ret = content(null, GridRestCommand.ADD_USER, diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAuthenticationWithTokenSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAuthenticationWithTokenSelfTest.java index 0a1b6b9d802f1..bf2ddac9b0f1b 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAuthenticationWithTokenSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAuthenticationWithTokenSelfTest.java @@ -18,10 +18,14 @@ package org.apache.ignite.internal.processors.rest; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test REST with enabled authentication and token. */ +@RunWith(JUnit4.class) public class JettyRestProcessorAuthenticationWithTokenSelfTest extends JettyRestProcessorAuthenticationAbstractTest { /** */ private String tok = ""; @@ -56,6 +60,7 @@ public class JettyRestProcessorAuthenticationWithTokenSelfTest extends JettyRest /** * @throws Exception If failed. */ + @Test public void testInvalidSessionToken() throws Exception { tok = null; diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorBaselineSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorBaselineSelfTest.java new file mode 100644 index 0000000000000..1a83a43cd743a --- /dev/null +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorBaselineSelfTest.java @@ -0,0 +1,218 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.rest; + +import com.fasterxml.jackson.databind.JsonNode; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import org.apache.ignite.cluster.BaselineNode; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.rest.handlers.cluster.GridBaselineCommandResponse; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; +import org.junit.Test; + +import static org.apache.ignite.configuration.WALMode.NONE; +import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_SUCCESS; + +/** + * Test REST with enabled authentication. + */ +public class JettyRestProcessorBaselineSelfTest extends JettyRestProcessorCommonSelfTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", true); + + super.beforeTestsStarted(); + + // We need to activate cluster. + grid(0).cluster().active(true); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + grid(0).cluster().setBaselineTopology(grid(0).cluster().topologyVersion()); + } + + /** {@inheritDoc} */ + @Override protected String signature() { + return null; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + DataStorageConfiguration dsCfg = new DataStorageConfiguration() + .setDefaultDataRegionConfiguration(new DataRegionConfiguration() + .setMaxSize(100 * 1024 * 1024) + .setPersistenceEnabled(true)) + .setWalMode(NONE); + + cfg.setDataStorageConfiguration(dsCfg); + + return cfg; + } + + /** + * @param nodes Collection of grid nodes. + * @return Collection of node consistent IDs for given collection of grid nodes. + */ + private static Collection nodeConsistentIds(@Nullable Collection nodes) { + if (nodes == null || nodes.isEmpty()) + return Collections.emptyList(); + + return F.viewReadOnly(nodes, n -> String.valueOf(n.consistentId())); + } + + /** + * @param content Content to check. + * @param baselineSz Expected baseline size. + * @param srvsSz Expected server nodes count. + */ + private void assertBaseline(String content, int baselineSz, int srvsSz) throws IOException { + assertNotNull(content); + assertFalse(content.isEmpty()); + + JsonNode node = JSON_MAPPER.readTree(content); + + assertEquals(STATUS_SUCCESS, node.get("successStatus").asInt()); + assertTrue(node.get("error").isNull()); + + assertNotSame(securityEnabled(), node.get("sessionToken").isNull()); + + JsonNode res = node.get("response"); + + assertFalse(res.isNull()); + + GridBaselineCommandResponse baseline = JSON_MAPPER.treeToValue(res, GridBaselineCommandResponse.class); + + assertTrue(baseline.isActive()); + assertEquals(grid(0).cluster().topologyVersion(), baseline.getTopologyVersion()); + assertEquals(baselineSz, baseline.getBaseline().size()); + assertEqualsCollections(nodeConsistentIds(grid(0).cluster().currentBaselineTopology()), baseline.getBaseline()); + assertEquals(srvsSz, baseline.getServers().size()); + assertEqualsCollections(nodeConsistentIds(grid(0).cluster().nodes()), baseline.getServers()); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBaseline() throws Exception { + int sz = gridCount(); + + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz); + + // Stop one node. It will stay in baseline. + stopGrid(sz - 1); + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz - 1); + + // Start one node. Server node will be added, but baseline will not change. + startGrid(sz - 1); + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBaselineSet() throws Exception { + int sz = gridCount(); + + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz); + + startGrid(sz); + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz + 1); + + assertBaseline(content(null, GridRestCommand.BASELINE_SET, "topVer", + String.valueOf(grid(0).cluster().topologyVersion())), sz + 1, sz + 1); + + stopGrid(sz); + + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz + 1, sz); + + assertBaseline(content(null, GridRestCommand.BASELINE_SET, "topVer", + String.valueOf(grid(0).cluster().topologyVersion())), sz, sz); + + startGrid(sz); + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz + 1); + + ArrayList params = new ArrayList<>(); + int i = 1; + + for (BaselineNode n : grid(0).cluster().nodes()) { + params.add("consistentId" + i++); + params.add(String.valueOf(n.consistentId())); + } + + assertBaseline(content(null, GridRestCommand.BASELINE_SET, params.toArray(new String[0])), + sz + 1, sz + 1); + + stopGrid(sz); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBaselineAdd() throws Exception { + int sz = gridCount(); + + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz); + + startGrid(sz); + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz + 1); + + assertBaseline(content(null, GridRestCommand.BASELINE_ADD, "consistentId1", + grid(sz).localNode().consistentId().toString()), sz + 1, sz + 1); + + stopGrid(sz); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBaselineRemove() throws Exception { + int sz = gridCount(); + + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz); + + startGrid(sz); + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz, sz + 1); + + assertBaseline(content(null, GridRestCommand.BASELINE_SET, "topVer", + String.valueOf(grid(0).cluster().topologyVersion())), sz + 1, sz + 1); + + String consistentId = grid(sz).localNode().consistentId().toString(); + + stopGrid(sz); + assertBaseline(content(null, GridRestCommand.BASELINE_CURRENT_STATE), sz + 1, sz); + + assertBaseline(content(null, GridRestCommand.BASELINE_REMOVE, "consistentId1", + consistentId), sz, sz); + } +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorGetAllAsArrayTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorGetAllAsArrayTest.java index 521d7c18e9916..3017d87a558ca 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorGetAllAsArrayTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorGetAllAsArrayTest.java @@ -22,11 +22,15 @@ import java.util.Map; import java.util.Set; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_REST_GETALL_AS_ARRAY; import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_SUCCESS; /** */ +@RunWith(JUnit4.class) public class JettyRestProcessorGetAllAsArrayTest extends JettyRestProcessorCommonSelfTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -45,6 +49,7 @@ public class JettyRestProcessorGetAllAsArrayTest extends JettyRestProcessorCommo /** * @throws Exception If failed. */ + @Test public void testGetAll() throws Exception { final Map entries = F.asMap("getKey1", "getVal1", "getKey2", "getVal2"); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSignedSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSignedSelfTest.java index 3be99b489eef3..b5860dccd8344 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSignedSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorSignedSelfTest.java @@ -25,10 +25,14 @@ import java.util.Base64; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class JettyRestProcessorSignedSelfTest extends JettyRestProcessorAbstractSelfTest { /** */ protected static final String REST_SECRET_KEY = "secret-key"; @@ -52,6 +56,7 @@ public class JettyRestProcessorSignedSelfTest extends JettyRestProcessorAbstract /** * @throws Exception If failed. */ + @Test public void testUnauthorized() throws Exception { String addr = "http://" + LOC_HOST + ":" + restPort() + "/ignite?cacheName=default&cmd=top"; diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestBinaryProtocolSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestBinaryProtocolSelfTest.java index fb56b77a54332..249e273190b28 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestBinaryProtocolSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestBinaryProtocolSelfTest.java @@ -39,13 +39,12 @@ import org.apache.ignite.internal.processors.rest.client.message.GridClientNodeBean; import org.apache.ignite.internal.processors.rest.client.message.GridClientTaskResultBean; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -54,10 +53,8 @@ * TCP protocol test. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class RestBinaryProtocolSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE_NAME = "cache"; @@ -102,12 +99,6 @@ public class RestBinaryProtocolSelfTest extends GridCommonAbstractTest { cfg.setConnectorConfiguration(clientCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME), cacheConfiguration(CACHE_NAME)); return cfg; @@ -140,6 +131,7 @@ private TestBinaryClient client() throws IgniteCheckedException { /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { assertTrue(client.cachePut(DEFAULT_CACHE_NAME, "key1", "val1")); assertEquals("val1", grid().cache(DEFAULT_CACHE_NAME).get("key1")); @@ -151,6 +143,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAll() throws Exception { client.cachePutAll(DEFAULT_CACHE_NAME, F.asMap("key1", "val1", "key2", "val2")); @@ -172,6 +165,7 @@ public void testPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { grid().cache(DEFAULT_CACHE_NAME).put("key", "val"); @@ -185,6 +179,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailure() throws Exception { IgniteKernal kernal = ((IgniteKernal)grid()); @@ -220,6 +215,7 @@ public void testFailure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAll() throws Exception { IgniteCache jcacheDflt = grid().cache(DEFAULT_CACHE_NAME); IgniteCache jcacheName = grid().cache(CACHE_NAME); @@ -264,6 +260,7 @@ public void testGetAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { IgniteCache jcacheDflt = grid().cache(DEFAULT_CACHE_NAME); IgniteCache jcacheName = grid().cache(CACHE_NAME); @@ -287,6 +284,7 @@ public void testRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAll() throws Exception { IgniteCache jcacheDflt = grid().cache(DEFAULT_CACHE_NAME); @@ -320,6 +318,7 @@ public void testRemoveAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplace() throws Exception { assertFalse(client.cacheReplace(DEFAULT_CACHE_NAME, "key1", "val1")); @@ -342,6 +341,7 @@ public void testReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCompareAndSet() throws Exception { assertFalse(client.cacheCompareAndSet(DEFAULT_CACHE_NAME, "key", null, null)); @@ -404,6 +404,7 @@ public void testCompareAndSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMetrics() throws Exception { IgniteCache jcacheDft = grid().cache(DEFAULT_CACHE_NAME); IgniteCache jcacheName = grid().cache(CACHE_NAME); @@ -446,6 +447,7 @@ public void testMetrics() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAppend() throws Exception { grid().cache(DEFAULT_CACHE_NAME).remove("key"); grid().cache(CACHE_NAME).remove("key"); @@ -470,6 +472,7 @@ public void testAppend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrepend() throws Exception { grid().cache(DEFAULT_CACHE_NAME).remove("key"); grid().cache(CACHE_NAME).remove("key"); @@ -494,6 +497,7 @@ public void testPrepend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExecute() throws Exception { GridClientTaskResultBean res = client.execute(TestTask.class.getName(), Arrays.asList("executing", 3, "test", 5, "task")); @@ -505,6 +509,7 @@ public void testExecute() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNode() throws Exception { assertNull(client.node(UUID.randomUUID(), false, false)); assertNull(client.node("wrongHost", false, false)); @@ -549,6 +554,7 @@ public void testNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopology() throws Exception { List top = client.topology(true, true); @@ -614,4 +620,4 @@ private static class TestTask extends ComputeTaskSplitAdapter, Inte return sum; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestMemcacheProtocolSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestMemcacheProtocolSelfTest.java index 9ac62703d04ac..6a4ee7ef7afce 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestMemcacheProtocolSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestMemcacheProtocolSelfTest.java @@ -23,12 +23,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -36,11 +35,8 @@ /** * TCP protocol test. */ -@SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class RestMemcacheProtocolSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE_NAME = "cache"; @@ -85,12 +81,6 @@ public class RestMemcacheProtocolSelfTest extends GridCommonAbstractTest { cfg.setConnectorConfiguration(clientCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME), cacheConfiguration(CACHE_NAME)); return cfg; @@ -123,6 +113,7 @@ private TestMemcacheClient client() throws IgniteCheckedException { /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { assertTrue(client.cachePut(null, "key1", "val1")); assertEquals("val1", grid().cache(DEFAULT_CACHE_NAME).get("key1")); @@ -134,6 +125,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { grid().cache(DEFAULT_CACHE_NAME).put("key", "val"); @@ -147,6 +139,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { grid().cache(DEFAULT_CACHE_NAME).put("key", "val"); @@ -166,6 +159,7 @@ public void testRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAdd() throws Exception { assertTrue(client.cacheAdd(null, "key", "val")); assertEquals("val", grid().cache(DEFAULT_CACHE_NAME).get("key")); @@ -181,6 +175,7 @@ public void testAdd() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplace() throws Exception { assertFalse(client.cacheReplace(null, "key1", "val1")); grid().cache(DEFAULT_CACHE_NAME).put("key1", "val1"); @@ -200,6 +195,7 @@ public void testReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMetrics() throws Exception { grid().cache(DEFAULT_CACHE_NAME).localMxBean().clear(); grid().cache(CACHE_NAME).localMxBean().clear(); @@ -238,6 +234,7 @@ public void testMetrics() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrement() throws Exception { assertEquals(15L, client().increment("key", 10L, 5L)); assertEquals(15L, grid().atomicLong("key", 0, true).get()); @@ -261,6 +258,7 @@ public void testIncrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDecrement() throws Exception { assertEquals(15L, client().decrement("key", 20L, 5L)); assertEquals(15L, grid().atomicLong("key", 0, true).get()); @@ -284,6 +282,7 @@ public void testDecrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAppend() throws Exception { assertFalse(client.cacheAppend(null, "wrongKey", "_suffix")); assertFalse(client.cacheAppend(CACHE_NAME, "wrongKey", "_suffix")); @@ -300,6 +299,7 @@ public void testAppend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrepend() throws Exception { assertFalse(client.cachePrepend(null, "wrongKey", "prefix_")); assertFalse(client.cachePrepend(CACHE_NAME, "wrongKey", "prefix_")); @@ -316,6 +316,7 @@ public void testPrepend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersion() throws Exception { assertNotNull(client.version()); } @@ -323,6 +324,7 @@ public void testVersion() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoop() throws Exception { client.noop(); } @@ -330,7 +332,8 @@ public void testNoop() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQuit() throws Exception { client.quit(); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java index 24274d77d55b7..9be68b13d4085 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorMultiStartSelfTest.java @@ -22,10 +22,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Rest processor test. */ +@RunWith(JUnit4.class) public class RestProcessorMultiStartSelfTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 3; @@ -55,6 +59,7 @@ public class RestProcessorMultiStartSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testMultiStart() throws Exception { try { for (int i = 0; i < GRID_CNT; i++) @@ -72,6 +77,7 @@ public void testMultiStart() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultiStartWithClient() throws Exception { try { int clnIdx = GRID_CNT - 1; diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorStartSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorStartSelfTest.java index 477c41ab35bbc..ba7551a54042e 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorStartSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestProcessorStartSelfTest.java @@ -30,19 +30,18 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class RestProcessorStartSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String HOST = "127.0.0.1"; @@ -71,7 +70,7 @@ public class RestProcessorStartSelfTest extends GridCommonAbstractTest { TestDiscoverySpi disc = new TestDiscoverySpi(); - disc.setIpFinder(IP_FINDER); + disc.setIpFinder(sharedStaticIpFinder); cfg.setDiscoverySpi(disc); @@ -92,6 +91,7 @@ public class RestProcessorStartSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTcpStart() throws Exception { GridClientConfiguration clCfg = new GridClientConfiguration(); @@ -165,4 +165,4 @@ private class TestDiscoverySpi extends TcpDiscoverySpi { super.spiStart(igniteInstanceName); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TaskCommandHandlerSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TaskCommandHandlerSelfTest.java index 60e620be4edcd..b6e9c72f7ef51 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TaskCommandHandlerSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TaskCommandHandlerSelfTest.java @@ -41,13 +41,13 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jsr166.ConcurrentLinkedHashMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -58,10 +58,8 @@ /** * Test for {@code GridTaskCommandHandler} */ +@RunWith(JUnit4.class) public class TaskCommandHandlerSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE_NAME = "cache"; @@ -113,12 +111,6 @@ public class TaskCommandHandlerSelfTest extends GridCommonAbstractTest { cfg.setConnectorConfiguration(clientCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME), cacheConfiguration("replicated"), cacheConfiguration("partitioned"), cacheConfiguration(CACHE_NAME)); @@ -164,6 +156,7 @@ private GridClientConfiguration clientConfiguration() { /** * @throws Exception If failed. */ + @Test public void testManyTasksRun() throws Exception { GridClientCompute compute = client.compute(); @@ -221,4 +214,4 @@ private static class TestTask extends ComputeTaskSplitAdapter { return sum; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TcpRestUnmarshalVulnerabilityTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TcpRestUnmarshalVulnerabilityTest.java index 92d824be329db..cbb14ffaaa1c3 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TcpRestUnmarshalVulnerabilityTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TcpRestUnmarshalVulnerabilityTest.java @@ -38,6 +38,9 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_BLACKLIST; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_WHITELIST; @@ -47,6 +50,7 @@ /** * Tests for whitelist and blacklist ot avoiding deserialization vulnerability. */ +@RunWith(JUnit4.class) public class TcpRestUnmarshalVulnerabilityTest extends GridCommonAbstractTest { /** Marshaller. */ private static final GridClientJdkMarshaller MARSH = new GridClientJdkMarshaller(); @@ -89,6 +93,7 @@ public class TcpRestUnmarshalVulnerabilityTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNoLists() throws Exception { testExploit(true); } @@ -96,6 +101,7 @@ public void testNoLists() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWhiteListIncluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_included.txt").getPath(); @@ -107,6 +113,7 @@ public void testWhiteListIncluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWhiteListExcluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_excluded.txt").getPath(); @@ -118,6 +125,7 @@ public void testWhiteListExcluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlackListIncluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_included.txt").getPath(); @@ -129,6 +137,7 @@ public void testBlackListIncluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlackListExcluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_excluded.txt").getPath(); @@ -140,6 +149,7 @@ public void testBlackListExcluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBothListIncluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_included.txt").getPath(); @@ -266,4 +276,4 @@ private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOE // No-op. } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/TcpRestParserSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/TcpRestParserSelfTest.java index fecd2b977bbdf..e230ad4414552 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/TcpRestParserSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/TcpRestParserSelfTest.java @@ -34,6 +34,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest.GridCacheOperation.CAS; import static org.apache.ignite.internal.processors.rest.protocols.tcp.GridMemcachedMessage.IGNITE_HANDSHAKE_FLAG; @@ -45,6 +48,7 @@ * This class tests that parser confirms memcache extended specification. */ @SuppressWarnings("TypeMayBeWeakened") +@RunWith(JUnit4.class) public class TcpRestParserSelfTest extends GridCommonAbstractTest { /** Marshaller. */ private GridClientMarshaller marshaller = new GridClientOptimizedMarshaller(); @@ -58,6 +62,7 @@ public class TcpRestParserSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSimplePacketParsing() throws Exception { GridNioSession ses = new MockNioSession(); @@ -93,6 +98,7 @@ public void testSimplePacketParsing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncorrectPackets() throws Exception { final GridNioSession ses = new MockNioSession(); @@ -142,6 +148,7 @@ public void testIncorrectPackets() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomMessages() throws Exception { GridClientCacheRequest req = new GridClientCacheRequest(CAS); @@ -178,6 +185,7 @@ public void testCustomMessages() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMixedParsing() throws Exception { GridNioSession ses1 = new MockNioSession(); GridNioSession ses2 = new MockNioSession(); @@ -247,6 +255,7 @@ public void testMixedParsing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testParseContinuousSplit() throws Exception { ByteBuffer tmp = ByteBuffer.allocate(10 * 1024); @@ -301,6 +310,7 @@ public void testParseContinuousSplit() throws Exception { * * @throws Exception If failed. */ + @Test public void testParseClientHandshake() throws Exception { for (int splitPos = 1; splitPos < 5; splitPos++) { log.info("Checking split position: " + splitPos); @@ -453,4 +463,4 @@ private ByteBuffer rawPacket(byte magic, byte opCode, byte[] opaque, @Nullable b return res; } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisCommonAbstractTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisCommonAbstractTest.java index 3db7706042ece..241e239d08411 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisCommonAbstractTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisCommonAbstractTest.java @@ -21,9 +21,6 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; @@ -35,9 +32,6 @@ public class RedisCommonAbstractTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 2; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Local host. */ protected static final String HOST = "127.0.0.1"; @@ -88,12 +82,6 @@ public class RedisCommonAbstractTest extends GridCommonAbstractTest { cfg.setConnectorConfiguration(redisCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - CacheConfiguration ccfg = defaultCacheConfiguration(); ccfg.setStatisticsEnabled(true); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolConnectSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolConnectSelfTest.java index f7fd69a6d58cf..ca3859f72a00e 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolConnectSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolConnectSelfTest.java @@ -18,15 +18,20 @@ package org.apache.ignite.internal.processors.rest.protocols.tcp.redis; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import redis.clients.jedis.Jedis; /** * Tests for Connection commands of Redis protocol. */ +@RunWith(JUnit4.class) public class RedisProtocolConnectSelfTest extends RedisCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPing() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals("PONG", jedis.ping()); @@ -36,6 +41,7 @@ public void testPing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEcho() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals("Hello, grid!", jedis.echo("Hello, grid!")); @@ -45,6 +51,7 @@ public void testEcho() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSelect() throws Exception { try (Jedis jedis = pool.getResource()) { // connected to cache with index 0 diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolServerSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolServerSelfTest.java index a424d77e89c8f..f0f5f477cfb41 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolServerSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolServerSelfTest.java @@ -19,15 +19,20 @@ import java.util.HashMap; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import redis.clients.jedis.Jedis; /** * Tests for Server commands of Redis protocol. */ +@RunWith(JUnit4.class) public class RedisProtocolServerSelfTest extends RedisCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDbSize() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals(0, (long)jedis.dbSize()); @@ -46,6 +51,7 @@ public void testDbSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFlushDb() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals(0, (long)jedis.dbSize()); @@ -82,6 +88,7 @@ public void testFlushDb() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFlushAll() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals(0, (long)jedis.dbSize()); diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolStringSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolStringSelfTest.java index 21a988268c232..e192c004f5b22 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolStringSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolStringSelfTest.java @@ -21,16 +21,21 @@ import java.util.HashSet; import java.util.List; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import redis.clients.jedis.Jedis; import redis.clients.jedis.exceptions.JedisDataException; /** * Tests for String commands of Redis protocol. */ +@RunWith(JUnit4.class) public class RedisProtocolStringSelfTest extends RedisCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { try (Jedis jedis = pool.getResource()) { jcache().put("getKey1", "getVal1"); @@ -54,6 +59,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSet() throws Exception { try (Jedis jedis = pool.getResource()) { jcache().put("getSetKey1", "1"); @@ -77,6 +83,7 @@ public void testGetSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMGet() throws Exception { try (Jedis jedis = pool.getResource()) { jcache().put("getKey1", "getVal1"); @@ -96,6 +103,7 @@ public void testMGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSet() throws Exception { long EXPIRE_MS = 1000L; int EXPIRE_SEC = 1; @@ -131,6 +139,7 @@ public void testSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMSet() throws Exception { try (Jedis jedis = pool.getResource()) { jedis.mset("setKey1", "1", "setKey2", "2"); @@ -143,6 +152,7 @@ public void testMSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrDecr() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals(1, (long)jedis.incr("newKeyIncr")); @@ -226,6 +236,7 @@ public void testIncrDecr() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrDecrBy() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals(2, (long)jedis.incrBy("newKeyIncrBy", 2)); @@ -282,6 +293,7 @@ public void testIncrDecrBy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAppend() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals(5, (long)jedis.append("appendKey1", "Hello")); @@ -303,6 +315,7 @@ public void testAppend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStrlen() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals(0, (long)jedis.strlen("strlenKeyNonExisting")); @@ -327,6 +340,7 @@ public void testStrlen() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetRange() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals(0, (long)jedis.setrange("setRangeKey1", 0, "")); @@ -375,6 +389,7 @@ public void testSetRange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetRange() throws Exception { try (Jedis jedis = pool.getResource()) { Assert.assertEquals("", jedis.getrange("getRangeKeyNonExisting", 0, 0)); @@ -402,6 +417,7 @@ public void testGetRange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDel() throws Exception { jcache().put("delKey1", "abc"); jcache().put("delKey2", "abcd"); @@ -415,6 +431,7 @@ public void testDel() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExists() throws Exception { jcache().put("existsKey1", "abc"); jcache().put("existsKey2", "abcd"); @@ -427,6 +444,7 @@ public void testExists() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExpire() throws Exception { testExpire(new Expiration() { @Override public long expire(Jedis jedis, String key) { @@ -438,6 +456,7 @@ public void testExpire() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExpireMs() throws Exception { testExpire(new Expiration() { @Override public long expire(Jedis jedis, String key) { diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/AbstractJdbcPojoQuerySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/AbstractJdbcPojoQuerySelfTest.java index cc8d72e71187e..a8dc8621dd336 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/AbstractJdbcPojoQuerySelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/AbstractJdbcPojoQuerySelfTest.java @@ -31,9 +31,6 @@ import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -44,9 +41,6 @@ * Test for Jdbc driver query without class on client */ public abstract class AbstractJdbcPojoQuerySelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** TestObject class name. */ protected static final String TEST_OBJECT = "org.apache.ignite.internal.JdbcTestObject"; @@ -70,11 +64,6 @@ public abstract class AbstractJdbcPojoQuerySelfTest extends GridCommonAbstractTe cache.setWriteSynchronizationMode(FULL_SYNC); cache.setAtomicityMode(TRANSACTIONAL); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); cfg.setConnectorConfiguration(new ConnectorConfiguration()); QueryEntity queryEntity = new QueryEntity(); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcComplexQuerySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcComplexQuerySelfTest.java index 3c00288e0fdae..a3be96920046c 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcComplexQuerySelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcComplexQuerySelfTest.java @@ -28,10 +28,10 @@ import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -40,10 +40,8 @@ /** * Tests for complex queries (joins, etc.). */ +@RunWith(JUnit4.class) public class JdbcComplexQuerySelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite://127.0.0.1/pers"; @@ -56,12 +54,6 @@ public class JdbcComplexQuerySelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheConfiguration()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -126,6 +118,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testJoin() throws Exception { ResultSet rs = stmt.executeQuery( "select p.id, p.name, o.name as orgName from \"pers\".Person p, \"org\".Organization o where p.orgId = o.id"); @@ -161,6 +154,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testJoinWithoutAlias() throws Exception { ResultSet rs = stmt.executeQuery( "select p.id, p.name, o.name from \"pers\".Person p, \"org\".Organization o where p.orgId = o.id"); @@ -199,6 +193,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testIn() throws Exception { ResultSet rs = stmt.executeQuery("select name from \"pers\".Person where age in (25, 35)"); @@ -219,6 +214,7 @@ public void testIn() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBetween() throws Exception { ResultSet rs = stmt.executeQuery("select name from \"pers\".Person where age between 24 and 36"); @@ -239,6 +235,7 @@ public void testBetween() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCalculatedValue() throws Exception { ResultSet rs = stmt.executeQuery("select age * 2 from \"pers\".Person"); @@ -318,4 +315,4 @@ private Organization(int id, String name) { this.name = name; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcConnectionSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcConnectionSelfTest.java index 14d21469468bc..99d6b9d841e5c 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcConnectionSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcConnectionSelfTest.java @@ -24,21 +24,18 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Connection test. */ +@RunWith(JUnit4.class) public class JdbcConnectionSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Custom cache name. */ private static final String CUSTOM_CACHE_NAME = "custom-cache"; @@ -57,12 +54,6 @@ public class JdbcConnectionSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME), cacheConfiguration(CUSTOM_CACHE_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - assert cfg.getConnectorConfiguration() == null; ConnectorConfiguration clientCfg = new ConnectorConfiguration(); @@ -96,6 +87,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) throws Excep /** * @throws Exception If failed. */ + @Test public void testDefaults() throws Exception { String url = URL_PREFIX + HOST; @@ -106,6 +98,7 @@ public void testDefaults() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeId() throws Exception { String url = URL_PREFIX + HOST + "/?nodeId=" + grid(0).localNode().id(); @@ -119,6 +112,7 @@ public void testNodeId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomCache() throws Exception { String url = URL_PREFIX + HOST + "/" + CUSTOM_CACHE_NAME; @@ -128,6 +122,7 @@ public void testCustomCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomPort() throws Exception { String url = URL_PREFIX + HOST + ":" + CUSTOM_PORT; @@ -138,6 +133,7 @@ public void testCustomPort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomCacheNameAndPort() throws Exception { String url = URL_PREFIX + HOST + ":" + CUSTOM_PORT + "/" + CUSTOM_CACHE_NAME; @@ -147,6 +143,7 @@ public void testCustomCacheNameAndPort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWrongCache() throws Exception { final String url = URL_PREFIX + HOST + "/wrongCacheName"; @@ -167,6 +164,7 @@ public void testWrongCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWrongPort() throws Exception { final String url = URL_PREFIX + HOST + ":33333"; @@ -187,6 +185,7 @@ public void testWrongPort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClose() throws Exception { String url = URL_PREFIX + HOST; @@ -212,4 +211,4 @@ public void testClose() throws Exception { "Connection is closed." ); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcEmptyCacheSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcEmptyCacheSelfTest.java index 897f71e11cbca..7ae46ebf25e19 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcEmptyCacheSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcEmptyCacheSelfTest.java @@ -23,10 +23,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -34,10 +34,8 @@ /** * Tests for empty cache. */ +@RunWith(JUnit4.class) public class JdbcEmptyCacheSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -63,12 +61,6 @@ public class JdbcEmptyCacheSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -100,6 +92,7 @@ public class JdbcEmptyCacheSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSelectNumber() throws Exception { ResultSet rs = stmt.executeQuery("select 1"); @@ -118,6 +111,7 @@ public void testSelectNumber() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSelectString() throws Exception { ResultSet rs = stmt.executeQuery("select 'str'"); @@ -131,4 +125,4 @@ public void testSelectString() throws Exception { assert cnt == 1; } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcErrorsAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcErrorsAbstractSelfTest.java index c44e00725731b..0f7c6c1fdb2c0 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcErrorsAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcErrorsAbstractSelfTest.java @@ -41,10 +41,14 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test SQLSTATE codes propagation with (any) Ignite JDBC driver. */ +@RunWith(JUnit4.class) public abstract class JdbcErrorsAbstractSelfTest extends GridCommonAbstractTest { /** */ protected static final String CACHE_STORE_TEMPLATE = "cache_store"; @@ -73,6 +77,7 @@ public abstract class JdbcErrorsAbstractSelfTest extends GridCommonAbstractTest * Test that H2 specific error codes get propagated to Ignite SQL exceptions. * @throws SQLException if failed. */ + @Test public void testParsingErrors() throws SQLException { checkErrorState("gibberish", "42000", "Failed to parse query. Syntax error in SQL statement \"GIBBERISH[*] \""); @@ -82,6 +87,7 @@ public void testParsingErrors() throws SQLException { * Test that error codes from tables related DDL operations get propagated to Ignite SQL exceptions. * @throws SQLException if failed. */ + @Test public void testTableErrors() throws SQLException { checkErrorState("DROP TABLE \"PUBLIC\".missing", "42000", "Table doesn't exist: MISSING"); } @@ -90,6 +96,7 @@ public void testTableErrors() throws SQLException { * Test that error codes from indexes related DDL operations get propagated to Ignite SQL exceptions. * @throws SQLException if failed. */ + @Test public void testIndexErrors() throws SQLException { checkErrorState("DROP INDEX \"PUBLIC\".missing", "42000", "Index doesn't exist: MISSING"); } @@ -98,6 +105,7 @@ public void testIndexErrors() throws SQLException { * Test that error codes from DML operations get propagated to Ignite SQL exceptions. * @throws SQLException if failed. */ + @Test public void testDmlErrors() throws SQLException { checkErrorState("INSERT INTO \"test\".INTEGER(_key, _val) values(1, null)", "22004", "Value for INSERT, COPY, MERGE, or UPDATE must not be null"); @@ -110,6 +118,7 @@ public void testDmlErrors() throws SQLException { * Test error code for the case when user attempts to refer a future currently unsupported. * @throws SQLException if failed. */ + @Test public void testUnsupportedSql() throws SQLException { checkErrorState("ALTER TABLE \"test\".Integer MODIFY COLUMN _key CHAR", "0A000", "ALTER COLUMN is not supported"); @@ -119,6 +128,7 @@ public void testUnsupportedSql() throws SQLException { * Test error code for the case when user attempts to use a closed connection. * @throws SQLException if failed. */ + @Test public void testConnectionClosed() throws SQLException { checkErrorState(new IgniteCallable() { @Override public Void call() throws Exception { @@ -231,6 +241,7 @@ public void testConnectionClosed() throws SQLException { * Test error code for the case when user attempts to use a closed result set. * @throws SQLException if failed. */ + @Test public void testResultSetClosed() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -252,6 +263,7 @@ public void testResultSetClosed() throws SQLException { * from column whose value can't be converted to an {@code int}. * @throws SQLException if failed. */ + @Test public void testInvalidIntFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -271,6 +283,7 @@ public void testInvalidIntFormat() throws SQLException { * from column whose value can't be converted to an {@code long}. * @throws SQLException if failed. */ + @Test public void testInvalidLongFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -290,6 +303,7 @@ public void testInvalidLongFormat() throws SQLException { * from column whose value can't be converted to an {@code float}. * @throws SQLException if failed. */ + @Test public void testInvalidFloatFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -309,6 +323,7 @@ public void testInvalidFloatFormat() throws SQLException { * from column whose value can't be converted to an {@code double}. * @throws SQLException if failed. */ + @Test public void testInvalidDoubleFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -328,6 +343,7 @@ public void testInvalidDoubleFormat() throws SQLException { * from column whose value can't be converted to an {@code byte}. * @throws SQLException if failed. */ + @Test public void testInvalidByteFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -347,6 +363,7 @@ public void testInvalidByteFormat() throws SQLException { * from column whose value can't be converted to an {@code short}. * @throws SQLException if failed. */ + @Test public void testInvalidShortFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -366,6 +383,7 @@ public void testInvalidShortFormat() throws SQLException { * from column whose value can't be converted to an {@code BigDecimal}. * @throws SQLException if failed. */ + @Test public void testInvalidBigDecimalFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -385,6 +403,7 @@ public void testInvalidBigDecimalFormat() throws SQLException { * from column whose value can't be converted to an {@code boolean}. * @throws SQLException if failed. */ + @Test public void testInvalidBooleanFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -404,6 +423,7 @@ public void testInvalidBooleanFormat() throws SQLException { * from column whose value can't be converted to an {@code boolean}. * @throws SQLException if failed. */ + @Test public void testInvalidObjectFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -423,6 +443,7 @@ public void testInvalidObjectFormat() throws SQLException { * from column whose value can't be converted to a {@link Date}. * @throws SQLException if failed. */ + @Test public void testInvalidDateFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -442,6 +463,7 @@ public void testInvalidDateFormat() throws SQLException { * from column whose value can't be converted to a {@link Time}. * @throws SQLException if failed. */ + @Test public void testInvalidTimeFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -461,6 +483,7 @@ public void testInvalidTimeFormat() throws SQLException { * from column whose value can't be converted to a {@link Timestamp}. * @throws SQLException if failed. */ + @Test public void testInvalidTimestampFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -480,6 +503,7 @@ public void testInvalidTimestampFormat() throws SQLException { * from column whose value can't be converted to a {@link URL}. * @throws SQLException if failed. */ + @Test public void testInvalidUrlFormat() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -499,6 +523,7 @@ public void testInvalidUrlFormat() throws SQLException { * * @throws SQLException if failed. */ + @Test public void testNotNullViolation() throws SQLException { try (Connection conn = getConnection()) { conn.setSchema("PUBLIC"); @@ -528,6 +553,7 @@ public void testNotNullViolation() throws SQLException { * * @throws SQLException if failed. */ + @Test public void testNotNullRestrictionReadThroughCacheStore() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -548,6 +574,7 @@ public void testNotNullRestrictionReadThroughCacheStore() throws SQLException { * * @throws SQLException if failed. */ + @Test public void testNotNullRestrictionCacheInterceptor() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -566,6 +593,7 @@ public void testNotNullRestrictionCacheInterceptor() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testSelectWrongTable() throws SQLException { checkSqlErrorMessage("select from wrong", "42000", "Failed to parse query. Table \"WRONG\" not found"); @@ -576,6 +604,7 @@ public void testSelectWrongTable() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testSelectWrongColumnName() throws SQLException { checkSqlErrorMessage("select wrong from test", "42000", "Failed to parse query. Column \"WRONG\" not found"); @@ -586,6 +615,7 @@ public void testSelectWrongColumnName() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testSelectWrongSyntax() throws SQLException { checkSqlErrorMessage("select from test where", "42000", "Failed to parse query. Syntax error in SQL statement \"SELECT FROM TEST WHERE[*]"); @@ -596,6 +626,7 @@ public void testSelectWrongSyntax() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testDmlWrongTable() throws SQLException { checkSqlErrorMessage("insert into wrong (id, val) values (3, 'val3')", "42000", "Failed to parse query. Table \"WRONG\" not found"); @@ -615,6 +646,7 @@ public void testDmlWrongTable() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testDmlWrongColumnName() throws SQLException { checkSqlErrorMessage("insert into test (id, wrong) values (3, 'val3')", "42000", "Failed to parse query. Column \"WRONG\" not found"); @@ -634,6 +666,7 @@ public void testDmlWrongColumnName() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testDmlWrongSyntax() throws SQLException { checkSqlErrorMessage("insert test (id, val) values (3, 'val3')", "42000", "Failed to parse query. Syntax error in SQL statement \"INSERT TEST[*] (ID, VAL)"); @@ -653,6 +686,7 @@ public void testDmlWrongSyntax() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testDdlWrongTable() throws SQLException { checkSqlErrorMessage("create table test (id int primary key, val varchar)", "42000", "Table already exists: TEST"); @@ -675,6 +709,7 @@ public void testDdlWrongTable() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testDdlWrongColumnName() throws SQLException { checkSqlErrorMessage("create index idx1 on test (wrong)", "42000", "Column doesn't exist: WRONG"); @@ -688,6 +723,7 @@ public void testDdlWrongColumnName() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testDdlWrongSyntax() throws SQLException { checkSqlErrorMessage("create table test2 (id int wrong key, val varchar)", "42000", "Failed to parse query. Syntax error in SQL statement \"CREATE TABLE TEST2 (ID INT WRONG[*]"); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcLocalCachesSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcLocalCachesSelfTest.java index 9350e0d597241..639df29cdcc65 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcLocalCachesSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcLocalCachesSelfTest.java @@ -25,10 +25,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.PROP_NODE_ID; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -37,10 +37,8 @@ /** * Test JDBC with several local caches. */ +@RunWith(JUnit4.class) public class JdbcLocalCachesSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -62,12 +60,6 @@ public class JdbcLocalCachesSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -95,6 +87,7 @@ public class JdbcLocalCachesSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCache1() throws Exception { Properties cfg = new Properties(); @@ -123,6 +116,7 @@ public void testCache1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCache2() throws Exception { Properties cfg = new Properties(); @@ -147,4 +141,4 @@ public void testCache2() throws Exception { conn.close(); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcMetadataSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcMetadataSelfTest.java index f270910a77949..f262ffe768f6a 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcMetadataSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcMetadataSelfTest.java @@ -34,10 +34,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.sql.Types.INTEGER; import static java.sql.Types.OTHER; @@ -48,10 +48,8 @@ /** * Metadata tests. */ +@RunWith(JUnit4.class) public class JdbcMetadataSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite://127.0.0.1/pers"; @@ -59,12 +57,6 @@ public class JdbcMetadataSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -108,6 +100,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testResultSetMetaData() throws Exception { Statement stmt = DriverManager.getConnection(URL).createStatement(); @@ -176,6 +169,7 @@ public void testGetTables() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetColumns() throws Exception { final boolean primitivesInformationIsLostAfterStore = ignite(0).configuration().getMarshaller() instanceof BinaryMarshaller; try (Connection conn = DriverManager.getConnection(URL)) { @@ -269,6 +263,7 @@ public void testGetColumns() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMetadataResultSetClose() throws Exception { try (Connection conn = DriverManager.getConnection(URL); ResultSet tbls = conn.getMetaData().getTables(null, null, "%", null)) { diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java index adb5c306aeb94..ac4142d1e84e9 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcNoDefaultCacheTest.java @@ -26,19 +26,17 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class JdbcNoDefaultCacheTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** First cache name. */ private static final String CACHE1_NAME = "cache1"; @@ -57,12 +55,6 @@ public class JdbcNoDefaultCacheTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheConfiguration(CACHE1_NAME), cacheConfiguration(CACHE2_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -109,6 +101,7 @@ protected String getUrl() { /** * @throws Exception If failed. */ + @Test public void testDefaults() throws Exception { String url = getUrl(); @@ -124,6 +117,7 @@ public void testDefaults() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoCacheNameQuery() throws Exception { Statement stmt; diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPojoLegacyQuerySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPojoLegacyQuerySelfTest.java index 4fa7ba5443870..4f63caf8bd2b0 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPojoLegacyQuerySelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPojoLegacyQuerySelfTest.java @@ -18,10 +18,14 @@ package org.apache.ignite.jdbc; import java.sql.ResultSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for Jdbc driver query without class on client */ +@RunWith(JUnit4.class) public class JdbcPojoLegacyQuerySelfTest extends AbstractJdbcPojoQuerySelfTest { /** URL. */ private static final String URL = "jdbc:ignite://127.0.0.1/"; @@ -29,6 +33,7 @@ public class JdbcPojoLegacyQuerySelfTest extends AbstractJdbcPojoQuerySelfTest { /** * @throws Exception If failed. */ + @Test public void testJdbcQuery() throws Exception { stmt.execute("select * from JdbcTestObject"); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPojoQuerySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPojoQuerySelfTest.java index 6729d0491c67d..31ac22f8206de 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPojoQuerySelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPojoQuerySelfTest.java @@ -18,12 +18,16 @@ package org.apache.ignite.jdbc; import java.sql.ResultSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteJdbcDriver.CFG_URL_PREFIX; /** * Test for Jdbc driver query without class on client */ +@RunWith(JUnit4.class) public class JdbcPojoQuerySelfTest extends AbstractJdbcPojoQuerySelfTest { /** URL. */ private static final String URL = CFG_URL_PREFIX + "cache=default@modules/clients/src/test/config/jdbc-bin-config.xml"; @@ -31,6 +35,7 @@ public class JdbcPojoQuerySelfTest extends AbstractJdbcPojoQuerySelfTest { /** * @throws Exception If failed. */ + @Test public void testJdbcQueryTask2() throws Exception { stmt.execute("select * from JdbcTestObject"); @@ -42,6 +47,7 @@ public void testJdbcQueryTask2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJdbcQueryTask1() throws Exception { ResultSet rs = stmt.executeQuery("select * from JdbcTestObject"); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPreparedStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPreparedStatementSelfTest.java index 9bdb7d804b2ae..a23280c7b3654 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPreparedStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPreparedStatementSelfTest.java @@ -32,10 +32,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.sql.Types.BIGINT; import static java.sql.Types.BINARY; @@ -57,10 +57,8 @@ /** * Prepared statement test. */ +@RunWith(JUnit4.class) public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite://127.0.0.1/"; @@ -85,12 +83,6 @@ public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -151,6 +143,7 @@ public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRepeatableUsage() throws Exception { stmt = conn.prepareStatement("select * from TestObject where id = ?"); @@ -186,6 +179,7 @@ public void testRepeatableUsage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { stmt = conn.prepareStatement("select * from TestObject where boolVal is not distinct from ?"); @@ -223,6 +217,7 @@ public void testBoolean() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByte() throws Exception { stmt = conn.prepareStatement("select * from TestObject where byteVal is not distinct from ?"); @@ -260,6 +255,7 @@ public void testByte() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { stmt = conn.prepareStatement("select * from TestObject where shortVal is not distinct from ?"); @@ -297,6 +293,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInteger() throws Exception { stmt = conn.prepareStatement("select * from TestObject where intVal is not distinct from ?"); @@ -334,6 +331,7 @@ public void testInteger() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { stmt = conn.prepareStatement("select * from TestObject where longVal is not distinct from ?"); @@ -371,6 +369,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { stmt = conn.prepareStatement("select * from TestObject where floatVal is not distinct from ?"); @@ -408,6 +407,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { stmt = conn.prepareStatement("select * from TestObject where doubleVal is not distinct from ?"); @@ -445,6 +445,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimal() throws Exception { stmt = conn.prepareStatement("select * from TestObject where bigVal is not distinct from ?"); @@ -482,6 +483,7 @@ public void testBigDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testString() throws Exception { stmt = conn.prepareStatement("select * from TestObject where strVal is not distinct from ?"); @@ -519,6 +521,7 @@ public void testString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArray() throws Exception { stmt = conn.prepareStatement("select * from TestObject where arrVal is not distinct from ?"); @@ -556,6 +559,7 @@ public void testArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDate() throws Exception { stmt = conn.prepareStatement("select * from TestObject where dateVal is not distinct from ?"); @@ -593,6 +597,7 @@ public void testDate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTime() throws Exception { stmt = conn.prepareStatement("select * from TestObject where timeVal is not distinct from ?"); @@ -630,6 +635,7 @@ public void testTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { stmt = conn.prepareStatement("select * from TestObject where tsVal is not distinct from ?"); @@ -667,6 +673,7 @@ public void testTimestamp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUrl() throws Exception { stmt = conn.prepareStatement("select * from TestObject where urlVal is not distinct from ?"); @@ -773,4 +780,4 @@ private TestObject(int id) { this.id = id; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcResultSetSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcResultSetSelfTest.java index 0fe55f2b0a63f..467a1fcf56bb2 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcResultSetSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcResultSetSelfTest.java @@ -28,9 +28,6 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; @@ -44,6 +41,9 @@ import java.util.Arrays; import java.util.Objects; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -52,10 +52,8 @@ * Result set test. */ @SuppressWarnings("FloatingPointEquality") +@RunWith(JUnit4.class) public class JdbcResultSetSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite://127.0.0.1/"; @@ -83,12 +81,6 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -156,6 +148,7 @@ private TestObject createObjectWithData(int id) throws MalformedURLException { /** * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -176,6 +169,7 @@ public void testBoolean() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByte() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -196,6 +190,7 @@ public void testByte() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -216,6 +211,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInteger() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -236,6 +232,7 @@ public void testInteger() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -256,6 +253,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -276,6 +274,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -296,6 +295,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimal() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -316,6 +316,7 @@ public void testBigDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testString() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -336,6 +337,7 @@ public void testString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArray() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -357,6 +359,7 @@ public void testArray() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testDate() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -378,6 +381,7 @@ public void testDate() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testTime() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -398,6 +402,7 @@ public void testTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -418,6 +423,7 @@ public void testTimestamp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUrl() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -507,6 +513,7 @@ private static String removeIdHash(String str) { /** * @throws Exception If failed. */ + @Test public void testObject() throws Exception { final Ignite ignite = ignite(0); final boolean binaryMarshaller = ignite.configuration().getMarshaller() instanceof BinaryMarshaller; @@ -541,6 +548,7 @@ public void testObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNavigation() throws Exception { ResultSet rs = stmt.executeQuery("select * from TestObject where id > 0"); @@ -578,6 +586,7 @@ public void testNavigation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFindColumn() throws Exception { final ResultSet rs = stmt.executeQuery(SQL); @@ -790,4 +799,4 @@ private TestObjectField(int a, String b) { return S.toString(TestObjectField.class, this); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcStatementSelfTest.java index 4d72b8e19720d..5f94238a09fec 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcStatementSelfTest.java @@ -28,10 +28,10 @@ import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -39,10 +39,8 @@ /** * Statement test. */ +@RunWith(JUnit4.class) public class JdbcStatementSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite://127.0.0.1/"; @@ -70,12 +68,6 @@ public class JdbcStatementSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; @@ -117,6 +109,7 @@ public class JdbcStatementSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testExecuteQuery() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -149,6 +142,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testExecute() throws Exception { assert stmt.execute(SQL); @@ -185,6 +179,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testMaxRows() throws Exception { stmt.setMaxRows(1); @@ -283,4 +278,4 @@ private Person(int id, String firstName, String lastName, int age) { this.age = age; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcVersionMismatchSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcVersionMismatchSelfTest.java index 19e18a216285e..19a1be60bfc46 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcVersionMismatchSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcVersionMismatchSelfTest.java @@ -28,10 +28,14 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * JDBC version mismatch test. */ +@RunWith(JUnit4.class) public class JdbcVersionMismatchSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { @@ -53,6 +57,7 @@ public class JdbcVersionMismatchSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testVersionMismatchJdbc() throws Exception { try (Connection conn1 = connect(); Connection conn2 = connect()) { conn1.setAutoCommit(false); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverMvccTestSuite.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverMvccTestSuite.java index 66eafae17a4af..f89bc44dcc2a1 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverMvccTestSuite.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverMvccTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.jdbc.suite; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.jdbc.JdbcVersionMismatchSelfTest; import org.apache.ignite.jdbc.thin.JdbcThinConnectionMvccEnabledSelfTest; @@ -26,25 +27,28 @@ import org.apache.ignite.jdbc.thin.JdbcThinTransactionsServerNoAutoCommitComplexSelfTest; import org.apache.ignite.jdbc.thin.JdbcThinTransactionsWithMvccEnabledSelfTest; import org.apache.ignite.jdbc.thin.MvccJdbcTransactionFinishOnDeactivatedClusterSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** */ -public class IgniteJdbcDriverMvccTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteJdbcDriverMvccTestSuite { /** * @return JDBC Driver Test Suite. */ public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite JDBC Driver Test Suite"); - suite.addTestSuite(JdbcThinConnectionMvccEnabledSelfTest.class); - suite.addTestSuite(JdbcVersionMismatchSelfTest.class); + suite.addTest(new JUnit4TestAdapter(JdbcThinConnectionMvccEnabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcVersionMismatchSelfTest.class)); // Transactions - suite.addTestSuite(JdbcThinTransactionsWithMvccEnabledSelfTest.class); - suite.addTestSuite(JdbcThinTransactionsClientAutoCommitComplexSelfTest.class); - suite.addTestSuite(JdbcThinTransactionsServerAutoCommitComplexSelfTest.class); - suite.addTestSuite(JdbcThinTransactionsClientNoAutoCommitComplexSelfTest.class); - suite.addTestSuite(JdbcThinTransactionsServerNoAutoCommitComplexSelfTest.class); - suite.addTestSuite(MvccJdbcTransactionFinishOnDeactivatedClusterSelfTest.class); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsWithMvccEnabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsClientAutoCommitComplexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsServerAutoCommitComplexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsClientNoAutoCommitComplexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsServerNoAutoCommitComplexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(MvccJdbcTransactionFinishOnDeactivatedClusterSelfTest.class)); return suite; } diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java index 2e98d689deaa6..977feed61813c 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.jdbc.suite; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.jdbc2.JdbcBlobTest; import org.apache.ignite.internal.jdbc2.JdbcBulkLoadSelfTest; @@ -66,6 +67,7 @@ import org.apache.ignite.jdbc.thin.JdbcThinLocalQueriesSelfTest; import org.apache.ignite.jdbc.thin.JdbcThinMergeStatementSelfTest; import org.apache.ignite.jdbc.thin.JdbcThinMergeStatementSkipReducerOnUpdateSelfTest; +import org.apache.ignite.jdbc.thin.JdbcThinMetadataPrimaryKeysSelfTest; import org.apache.ignite.jdbc.thin.JdbcThinMetadataSelfTest; import org.apache.ignite.jdbc.thin.JdbcThinMissingLongArrayResultsTest; import org.apache.ignite.jdbc.thin.JdbcThinNoDefaultSchemaTest; @@ -85,137 +87,140 @@ import org.apache.ignite.jdbc.thin.JdbcThinUpdateStatementSelfTest; import org.apache.ignite.jdbc.thin.JdbcThinUpdateStatementSkipReducerOnUpdateSelfTest; import org.apache.ignite.jdbc.thin.JdbcThinWalModeChangeSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * JDBC driver test suite. */ -public class IgniteJdbcDriverTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteJdbcDriverTestSuite { /** * @return JDBC Driver Test Suite. - * @throws Exception In case of error. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite JDBC Driver Test Suite"); // Thin client based driver tests. - suite.addTest(new TestSuite(JdbcConnectionSelfTest.class)); - suite.addTest(new TestSuite(JdbcStatementSelfTest.class)); - suite.addTest(new TestSuite(JdbcPreparedStatementSelfTest.class)); - suite.addTest(new TestSuite(JdbcResultSetSelfTest.class)); - suite.addTest(new TestSuite(JdbcComplexQuerySelfTest.class)); - suite.addTest(new TestSuite(JdbcMetadataSelfTest.class)); - suite.addTest(new TestSuite(JdbcEmptyCacheSelfTest.class)); - suite.addTest(new TestSuite(JdbcLocalCachesSelfTest.class)); - suite.addTest(new TestSuite(JdbcNoDefaultCacheTest.class)); - suite.addTest(new TestSuite(JdbcDefaultNoOpCacheTest.class)); - suite.addTest(new TestSuite(JdbcPojoQuerySelfTest.class)); - suite.addTest(new TestSuite(JdbcPojoLegacyQuerySelfTest.class)); - suite.addTest(new TestSuite(JdbcConnectionReopenTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcConnectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcPreparedStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcResultSetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcComplexQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcMetadataSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcEmptyCacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcLocalCachesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcNoDefaultCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcDefaultNoOpCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcPojoQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcPojoLegacyQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcConnectionReopenTest.class)); // Ignite client node based driver tests - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcConnectionSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcSpringSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcStatementSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcPreparedStatementSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcResultSetSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcComplexQuerySelfTest.class)); - suite.addTest(new TestSuite(JdbcDistributedJoinsQueryTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcMetadataSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcEmptyCacheSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcLocalCachesSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcNoDefaultCacheTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcDefaultNoOpCacheTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcMergeStatementSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcBinaryMarshallerMergeStatementSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcUpdateStatementSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcInsertStatementSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcBinaryMarshallerInsertStatementSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcDeleteStatementSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcStatementBatchingSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcErrorsSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcStreamingToPublicCacheTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcNoCacheStreamingSelfTest.class)); - suite.addTest(new TestSuite(JdbcBulkLoadSelfTest.class)); - - suite.addTest(new TestSuite(JdbcBlobTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcStreamingSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinStreamingNotOrderedSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinStreamingOrderedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcConnectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcSpringSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcPreparedStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcResultSetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcComplexQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcDistributedJoinsQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcMetadataSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcEmptyCacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcLocalCachesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcNoDefaultCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcDefaultNoOpCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcMergeStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcBinaryMarshallerMergeStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcUpdateStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcInsertStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcBinaryMarshallerInsertStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcDeleteStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcStatementBatchingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcErrorsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcStreamingToPublicCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcNoCacheStreamingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcBulkLoadSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(JdbcBlobTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcStreamingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinStreamingNotOrderedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinStreamingOrderedSelfTest.class)); // DDL tests. - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexAtomicPartitionedNearSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexAtomicPartitionedSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexAtomicReplicatedSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexTransactionalPartitionedNearSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexTransactionalPartitionedSelfTest.class)); - suite.addTest(new TestSuite(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexTransactionalReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexAtomicPartitionedNearSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexAtomicPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexAtomicReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexTransactionalPartitionedNearSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexTransactionalPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(org.apache.ignite.internal.jdbc2.JdbcDynamicIndexTransactionalReplicatedSelfTest.class)); // New thin JDBC - suite.addTest(new TestSuite(JdbcThinConnectionSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinConnectionMvccEnabledSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinConnectionMultipleAddressesTest.class)); - suite.addTest(new TestSuite(JdbcThinTcpIoTest.class)); - suite.addTest(new TestSuite(JdbcThinConnectionSSLTest.class)); - suite.addTest(new TestSuite(JdbcThinDataSourceSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinPreparedStatementSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinResultSetSelfTest.class)); - - suite.addTest(new TestSuite(JdbcThinStatementSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinComplexQuerySelfTest.class)); - suite.addTest(new TestSuite(JdbcThinNoDefaultSchemaTest.class)); - suite.addTest(new TestSuite(JdbcThinSchemaCaseTest.class)); - suite.addTest(new TestSuite(JdbcThinEmptyCacheSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinMetadataSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinErrorsSelfTest.class)); - - suite.addTest(new TestSuite(JdbcThinInsertStatementSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinUpdateStatementSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinMergeStatementSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinDeleteStatementSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinAutoCloseServerCursorTest.class)); - suite.addTest(new TestSuite(JdbcThinBatchSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinMissingLongArrayResultsTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinConnectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinConnectionMvccEnabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinConnectionMultipleAddressesTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTcpIoTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinConnectionSSLTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinDataSourceSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinPreparedStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinResultSetSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(JdbcThinStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinComplexQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinNoDefaultSchemaTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinSchemaCaseTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinEmptyCacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinMetadataSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinMetadataPrimaryKeysSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinErrorsSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(JdbcThinInsertStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinUpdateStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinMergeStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinDeleteStatementSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinAutoCloseServerCursorTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinBatchSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinMissingLongArrayResultsTest.class)); // New thin JDBC driver, DDL tests - suite.addTest(new TestSuite(JdbcThinDynamicIndexAtomicPartitionedNearSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinDynamicIndexAtomicPartitionedSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinDynamicIndexAtomicReplicatedSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinDynamicIndexTransactionalPartitionedNearSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinDynamicIndexTransactionalPartitionedSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinDynamicIndexTransactionalReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinDynamicIndexAtomicPartitionedNearSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinDynamicIndexAtomicPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinDynamicIndexAtomicReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinDynamicIndexTransactionalPartitionedNearSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinDynamicIndexTransactionalPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinDynamicIndexTransactionalReplicatedSelfTest.class)); // New thin JDBC driver, DML tests - suite.addTest(new TestSuite(JdbcThinBulkLoadAtomicPartitionedNearSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinBulkLoadAtomicPartitionedSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinBulkLoadAtomicReplicatedSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinBulkLoadTransactionalPartitionedNearSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinBulkLoadTransactionalPartitionedSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinBulkLoadTransactionalReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinBulkLoadAtomicPartitionedNearSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinBulkLoadAtomicPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinBulkLoadAtomicReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinBulkLoadTransactionalPartitionedNearSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinBulkLoadTransactionalPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinBulkLoadTransactionalReplicatedSelfTest.class)); // New thin JDBC driver, full SQL tests - suite.addTest(new TestSuite(JdbcThinComplexDmlDdlSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinComplexDmlDdlSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinSelectAfterAlterTable.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinSelectAfterAlterTable.class)); // Update on server - suite.addTest(new TestSuite(JdbcThinInsertStatementSkipReducerOnUpdateSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinUpdateStatementSkipReducerOnUpdateSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinMergeStatementSkipReducerOnUpdateSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinComplexDmlDdlSkipReducerOnUpdateSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinComplexDmlDdlCustomSchemaSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinInsertStatementSkipReducerOnUpdateSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinUpdateStatementSkipReducerOnUpdateSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinMergeStatementSkipReducerOnUpdateSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinComplexDmlDdlSkipReducerOnUpdateSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinComplexDmlDdlCustomSchemaSelfTest.class)); // Transactions - suite.addTest(new TestSuite(JdbcThinTransactionsSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinTransactionsClientAutoCommitComplexSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinTransactionsServerAutoCommitComplexSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinTransactionsClientNoAutoCommitComplexSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinTransactionsServerNoAutoCommitComplexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsClientAutoCommitComplexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsServerAutoCommitComplexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsClientNoAutoCommitComplexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinTransactionsServerNoAutoCommitComplexSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinLocalQueriesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinLocalQueriesSelfTest.class)); // Various commands. - suite.addTest(new TestSuite(JdbcThinWalModeChangeSelfTest.class)); - suite.addTest(new TestSuite(JdbcThinAuthenticateConnectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinWalModeChangeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcThinAuthenticateConnectionSelfTest.class)); return suite; } diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractDmlStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractDmlStatementSelfTest.java index 936346760e8dd..1fb009a7ffb3d 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractDmlStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractDmlStatementSelfTest.java @@ -29,9 +29,6 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -40,9 +37,6 @@ * Statement test. */ public abstract class JdbcThinAbstractDmlStatementSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** SQL SELECT query for verification. */ static final String SQL_SELECT = "select _key, id, firstName, lastName, age from Person"; @@ -95,12 +89,6 @@ protected Connection createConnection() throws SQLException { private IgniteConfiguration getConfiguration0(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(new ConnectorConfiguration()); return cfg; diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAuthenticateConnectionSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAuthenticateConnectionSelfTest.java index cb4d7f3cf70c9..7184e0295567a 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAuthenticateConnectionSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAuthenticateConnectionSelfTest.java @@ -27,19 +27,17 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.authentication.AuthorizationContext; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for authenticated an non authenticated JDBC thin connection. */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class JdbcThinAuthenticateConnectionSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String URL = "jdbc:ignite:thin://127.0.0.1"; @@ -48,12 +46,6 @@ public class JdbcThinAuthenticateConnectionSelfTest extends JdbcThinAbstractSelf @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(new BinaryMarshaller()); cfg.setAuthenticationEnabled(true); @@ -93,6 +85,7 @@ public class JdbcThinAuthenticateConnectionSelfTest extends JdbcThinAbstractSelf /** * @throws Exception If failed. */ + @Test public void testConnection() throws Exception { checkConnection(URL, "ignite", "ignite"); checkConnection(URL, "another_user", "passwd"); @@ -102,6 +95,7 @@ public void testConnection() throws Exception { /** */ + @Test public void testInvalidUserPassword() { String err = "Unauthenticated sessions are prohibited"; checkInvalidUserPassword(URL, null, null, err); @@ -119,6 +113,7 @@ public void testInvalidUserPassword() { /** * @throws SQLException On failed. */ + @Test public void testUserSqlOnAuthorized() throws SQLException { try (Connection conn = DriverManager.getConnection(URL, "ignite", "ignite")) { conn.createStatement().execute("CREATE USER test WITH PASSWORD 'test'"); @@ -139,6 +134,7 @@ public void testUserSqlOnAuthorized() throws SQLException { /** * @throws SQLException On error. */ + @Test public void testUserSqlWithNotIgniteUser() throws SQLException { try (Connection conn = DriverManager.getConnection(URL, "another_user", "passwd")) { String err = "User management operations are not allowed for user"; @@ -157,6 +153,7 @@ public void testUserSqlWithNotIgniteUser() throws SQLException { /** * @throws SQLException On error. */ + @Test public void testQuotedUsername() throws SQLException { // Spaces checkUserPassword(" test", " "); @@ -235,4 +232,4 @@ private void checkUnauthorizedOperation(final Connection conn, final String sql, } }, SQLException.class, err); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAutoCloseServerCursorTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAutoCloseServerCursorTest.java index bb2696f570cc5..22768b64d5551 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAutoCloseServerCursorTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAutoCloseServerCursorTest.java @@ -30,10 +30,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -42,10 +42,8 @@ * Tests an optional optimization that server cursor is closed automatically * when last result set page is transmitted. */ +@RunWith(JUnit4.class) public class JdbcThinAutoCloseServerCursorTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -67,12 +65,6 @@ public class JdbcThinAutoCloseServerCursorTest extends JdbcThinAbstractSelfTest cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -95,7 +87,7 @@ public class JdbcThinAutoCloseServerCursorTest extends JdbcThinAbstractSelfTest * * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testQuery() throws Exception { IgniteCache cache = grid(0).cache(CACHE_NAME); @@ -189,6 +181,7 @@ public void testQuery() throws Exception { * * @throws Exception If failed. */ + @Test public void testInsert() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { conn.setSchema('"' + CACHE_NAME + '"'); @@ -218,6 +211,7 @@ public void testInsert() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdate() throws Exception { IgniteCache cache = grid(0).cache(CACHE_NAME); @@ -243,6 +237,7 @@ public void testUpdate() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelete() throws Exception { IgniteCache cache = grid(0).cache(CACHE_NAME); @@ -288,7 +283,6 @@ private void checkResultSet(ResultSet rs, Person[] persons) throws Exception { /** * Person. */ - @SuppressWarnings("UnusedDeclaration") static class Person implements Serializable { /** ID. */ @QuerySqlField diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinBatchSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinBatchSelfTest.java index fe7c170729595..376ec1d648f03 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinBatchSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinBatchSelfTest.java @@ -26,12 +26,16 @@ import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.processors.odbc.SqlStateCode; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.junit.Assert.assertArrayEquals; /** * Statement test. */ +@RunWith(JUnit4.class) public class JdbcThinBatchSelfTest extends JdbcThinAbstractDmlStatementSelfTest { /** SQL query. */ private static final String SQL_PREPARED = "insert into Person(_key, id, firstName, lastName, age) values " + @@ -75,6 +79,7 @@ public class JdbcThinBatchSelfTest extends JdbcThinAbstractDmlStatementSelfTest /** * @throws SQLException If failed. */ + @Test public void testBatch() throws SQLException { final int BATCH_SIZE = 10; @@ -94,6 +99,7 @@ public void testBatch() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchOnClosedStatement() throws SQLException { final Statement stmt2 = conn.createStatement(); final PreparedStatement pstmt2 = conn.prepareStatement(""); @@ -153,6 +159,7 @@ public void testBatchOnClosedStatement() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchException() throws SQLException { final int BATCH_SIZE = 7; @@ -195,6 +202,7 @@ public void testBatchException() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchParseException() throws SQLException { final int BATCH_SIZE = 7; @@ -237,6 +245,7 @@ public void testBatchParseException() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchMerge() throws SQLException { final int BATCH_SIZE = 7; @@ -256,6 +265,7 @@ public void testBatchMerge() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchMergeParseException() throws SQLException { final int BATCH_SIZE = 7; @@ -295,10 +305,10 @@ public void testBatchMergeParseException() throws SQLException { } } - /** * @throws SQLException If failed. */ + @Test public void testBatchKeyDuplicatesException() throws SQLException { final int BATCH_SIZE = 7; @@ -343,6 +353,7 @@ public void testBatchKeyDuplicatesException() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testHeterogeneousBatch() throws SQLException { stmt.addBatch("insert into Person (_key, id, firstName, lastName, age) values ('p0', 0, 'Name0', 'Lastname0', 10)"); stmt.addBatch("insert into Person (_key, id, firstName, lastName, age) values ('p1', 1, 'Name1', 'Lastname1', 20), ('p2', 2, 'Name2', 'Lastname2', 30)"); @@ -360,6 +371,7 @@ public void testHeterogeneousBatch() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testHeterogeneousBatchException() throws SQLException { stmt.addBatch("insert into Person (_key, id, firstName, lastName, age) values ('p0', 0, 'Name0', 'Lastname0', 10)"); stmt.addBatch("insert into Person (_key, id, firstName, lastName, age) values ('p1', 1, 'Name1', 'Lastname1', 20), ('p2', 2, 'Name2', 'Lastname2', 30)"); @@ -390,6 +402,7 @@ public void testHeterogeneousBatchException() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchClear() throws SQLException { final int BATCH_SIZE = 7; @@ -412,6 +425,7 @@ public void testBatchClear() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchPrepared() throws SQLException { final int BATCH_SIZE = 10; @@ -438,6 +452,7 @@ public void testBatchPrepared() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchExceptionPrepared() throws SQLException { final int BATCH_SIZE = 7; @@ -502,6 +517,7 @@ public void testBatchExceptionPrepared() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchMergePrepared() throws SQLException { final int BATCH_SIZE = 10; @@ -531,6 +547,7 @@ public void testBatchMergePrepared() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchMergeExceptionPrepared() throws SQLException { final int BATCH_SIZE = 7; @@ -611,6 +628,7 @@ private void populateTable(int size) throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchUpdatePrepared() throws SQLException { final int BATCH_SIZE = 10; @@ -635,6 +653,7 @@ public void testBatchUpdatePrepared() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchUpdateExceptionPrepared() throws SQLException { final int BATCH_SIZE = 7; @@ -690,6 +709,7 @@ public void testBatchUpdateExceptionPrepared() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchDeletePrepared() throws SQLException { final int BATCH_SIZE = 10; @@ -714,6 +734,7 @@ public void testBatchDeletePrepared() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchDeleteExceptionPrepared() throws SQLException { final int BATCH_SIZE = 7; @@ -769,6 +790,7 @@ public void testBatchDeleteExceptionPrepared() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testBatchClearPrepared() throws SQLException { final int BATCH_SIZE = 10; diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinBulkLoadAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinBulkLoadAbstractSelfTest.java index 2a4c7995fbdf6..a1432fcdab76e 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinBulkLoadAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinBulkLoadAbstractSelfTest.java @@ -17,22 +17,12 @@ package org.apache.ignite.jdbc.thin; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.QueryEntity; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.bulkload.BulkLoadCsvFormat; -import org.apache.ignite.internal.processors.bulkload.BulkLoadCsvParser; -import org.apache.ignite.internal.processors.query.QueryUtils; -import org.apache.ignite.lang.IgniteClosure; -import org.apache.ignite.testframework.GridTestUtils; - import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.nio.charset.CodingErrorAction; import java.nio.charset.UnsupportedCharsetException; import java.sql.BatchUpdateException; +import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -41,6 +31,20 @@ import java.util.Collections; import java.util.Objects; import java.util.concurrent.Callable; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.bulkload.BulkLoadCsvFormat; +import org.apache.ignite.internal.processors.bulkload.BulkLoadCsvParser; +import org.apache.ignite.internal.processors.query.QueryUtils; +import org.apache.ignite.lang.IgniteClosure; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -49,6 +53,7 @@ /** * COPY statement tests. */ +@RunWith(JUnit4.class) public abstract class JdbcThinBulkLoadAbstractSelfTest extends JdbcThinAbstractDmlStatementSelfTest { /** Subdirectory with CSV files */ private static final String CSV_FILE_SUBDIR = "/modules/clients/src/test/resources/"; @@ -194,6 +199,7 @@ private CacheConfiguration cacheConfigWithQueryEntity() { * * @throws SQLException If failed. */ + @Test public void testBasicStatement() throws SQLException { int updatesCnt = stmt.executeUpdate(BASIC_SQL_COPY_STMT); @@ -208,6 +214,7 @@ public void testBasicStatement() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testEmptyFile() throws SQLException { int updatesCnt = stmt.executeUpdate( "copy from '" + BULKLOAD_EMPTY_CSV_FILE + "' into " + TBL_NAME + @@ -224,6 +231,7 @@ public void testEmptyFile() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testOneLineFile() throws SQLException { int updatesCnt = stmt.executeUpdate( "copy from '" + BULKLOAD_ONE_LINE_CSV_FILE + "' into " + TBL_NAME + @@ -238,6 +246,7 @@ public void testOneLineFile() throws SQLException { /** * Verifies that error is reported for empty charset name. */ + @Test public void testEmptyCharset() { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -254,6 +263,7 @@ public void testEmptyCharset() { /** * Verifies that error is reported for unsupported charset name. */ + @Test public void testNotSupportedCharset() { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -270,6 +280,7 @@ public void testNotSupportedCharset() { /** * Verifies that error is reported for unknown charset name. */ + @Test public void testUnknownCharset() { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -288,6 +299,7 @@ public void testUnknownCharset() { * * @throws SQLException If failed. */ + @Test public void testAsciiCharset() throws SQLException { int updatesCnt = stmt.executeUpdate( "copy from '" + BULKLOAD_TWO_LINES_CSV_FILE + "'" + @@ -306,6 +318,7 @@ public void testAsciiCharset() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testUtf8Charset() throws SQLException { checkBulkLoadWithCharset(BULKLOAD_UTF8_CSV_FILE, "utf-8"); } @@ -315,6 +328,7 @@ public void testUtf8Charset() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testWin1251Charset() throws SQLException { checkBulkLoadWithCharset(BULKLOAD_CP1251_CSV_FILE, "windows-1251"); } @@ -344,6 +358,7 @@ private void checkBulkLoadWithCharset(String fileName, String charsetName) throw * * @throws SQLException If failed. */ + @Test public void testWrongCharset_Utf8AsWin1251() throws SQLException { checkBulkLoadWithWrongCharset(BULKLOAD_UTF8_CSV_FILE, "UTF-8", "windows-1251"); } @@ -354,6 +369,7 @@ public void testWrongCharset_Utf8AsWin1251() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testWrongCharset_Win1251AsUtf8() throws SQLException { checkBulkLoadWithWrongCharset(BULKLOAD_CP1251_CSV_FILE, "windows-1251", "UTF-8"); } @@ -364,6 +380,7 @@ public void testWrongCharset_Win1251AsUtf8() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testWrongCharset_Utf8AsAscii() throws SQLException { checkBulkLoadWithWrongCharset(BULKLOAD_UTF8_CSV_FILE, "UTF-8", "ascii"); } @@ -374,6 +391,7 @@ public void testWrongCharset_Utf8AsAscii() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testWrongCharset_Win1251AsAscii() throws SQLException { checkBulkLoadWithWrongCharset(BULKLOAD_CP1251_CSV_FILE, "windows-1251", "ascii"); } @@ -384,6 +402,7 @@ public void testWrongCharset_Win1251AsAscii() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testPacketSize_1() throws SQLException { int updatesCnt = stmt.executeUpdate(BASIC_SQL_COPY_STMT + " packet_size 1"); @@ -398,6 +417,7 @@ public void testPacketSize_1() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testDefaultCharset() throws SQLException { int updatesCnt = stmt.executeUpdate( "copy from '" + BULKLOAD_UTF8_CSV_FILE + "' into " + TBL_NAME + @@ -409,6 +429,33 @@ public void testDefaultCharset() throws SQLException { checkNationalCacheContents(TBL_NAME); } + /** + * Test imports CSV file into a table on not affinity node and checks the created entries using SELECT statement. + * + * @throws SQLException If failed. + */ + @Test + public void testBulkLoadToNonAffinityNode() throws Exception { + IgniteEx client = startGrid(getConfiguration("client").setClientMode(true)); + + try (Connection con = connect(client, null)) { + con.setSchema('"' + DEFAULT_CACHE_NAME + '"'); + + try (Statement stmt = con.createStatement()) { + int updatesCnt = stmt.executeUpdate( + "copy from '" + BULKLOAD_UTF8_CSV_FILE + "' into " + TBL_NAME + + " (_key, age, firstName, lastName)" + + " format csv"); + + assertEquals(2, updatesCnt); + + checkNationalCacheContents(TBL_NAME); + } + } + + stopGrid(client.name()); + } + /** * Imports two-entry CSV file with UTF-8 characters into a table using packet size of one byte * (thus splitting each two-byte UTF-8 character into two packets) @@ -416,6 +463,7 @@ public void testDefaultCharset() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testDefaultCharsetPacketSize1() throws SQLException { int updatesCnt = stmt.executeUpdate( "copy from '" + BULKLOAD_UTF8_CSV_FILE + "' into " + TBL_NAME + @@ -430,6 +478,7 @@ public void testDefaultCharsetPacketSize1() throws SQLException { /** * Checks that error is reported for a non-existent file. */ + @Test public void testWrongFileName() { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -446,6 +495,7 @@ public void testWrongFileName() { /** * Checks that error is reported if the destination table is missing. */ + @Test public void testMissingTable() { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -462,6 +512,7 @@ public void testMissingTable() { /** * Checks that error is reported when a non-existing column is specified in the SQL command. */ + @Test public void testWrongColumnName() { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -478,6 +529,7 @@ public void testWrongColumnName() { /** * Checks that error is reported if field read from CSV file cannot be converted to the type of the column. */ + @Test public void testWrongColumnType() { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -496,6 +548,7 @@ public void testWrongColumnType() { * * @throws SQLException If failed. */ + @Test public void testFieldsSubset() throws SQLException { int updatesCnt = stmt.executeUpdate( "copy from '" + BULKLOAD_TWO_LINES_CSV_FILE + "'" + @@ -516,6 +569,7 @@ public void testFieldsSubset() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testCreateAndBulkLoadTable() throws SQLException { String tblName = QueryUtils.DFLT_SCHEMA + ".\"PersonTbl\""; @@ -541,6 +595,7 @@ public void testCreateAndBulkLoadTable() throws SQLException { * @throws SQLException If failed. */ @SuppressWarnings("unchecked") + @Test public void testConfigureQueryEntityAndBulkLoad() throws SQLException { ignite(0).getOrCreateCache(cacheConfigWithQueryEntity()); @@ -556,6 +611,7 @@ public void testConfigureQueryEntityAndBulkLoad() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testMultipleStatement() throws SQLException { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -581,6 +637,7 @@ public void testMultipleStatement() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testExecuteQuery() throws SQLException { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -596,6 +653,7 @@ public void testExecuteQuery() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testExecute() throws SQLException { boolean isRowSet = stmt.execute(BASIC_SQL_COPY_STMT); @@ -609,6 +667,7 @@ public void testExecute() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testPreparedStatementWithExecuteUpdate() throws SQLException { PreparedStatement pstmt = conn.prepareStatement(BASIC_SQL_COPY_STMT); @@ -624,6 +683,7 @@ public void testPreparedStatementWithExecuteUpdate() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testPreparedStatementWithParameter() throws SQLException { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -646,6 +706,7 @@ public void testPreparedStatementWithParameter() throws SQLException { * * @throws SQLException If failed. */ + @Test public void testPreparedStatementWithExecute() throws SQLException { PreparedStatement pstmt = conn.prepareStatement(BASIC_SQL_COPY_STMT); @@ -659,6 +720,7 @@ public void testPreparedStatementWithExecute() throws SQLException { /** * Verifies that COPY command is rejected by PreparedStatement.executeQuery(). */ + @Test public void testPreparedStatementWithExecuteQuery() { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexDmlDdlCustomSchemaSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexDmlDdlCustomSchemaSelfTest.java index 8fd9356533be5..e4d7d1519c2d2 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexDmlDdlCustomSchemaSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexDmlDdlCustomSchemaSelfTest.java @@ -22,10 +22,14 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Base class for complex SQL tests based on JDBC driver. */ +@RunWith(JUnit4.class) public class JdbcThinComplexDmlDdlCustomSchemaSelfTest extends JdbcThinComplexDmlDdlSelfTest { /** Simple schema. */ private static final String SCHEMA_1 = "SCHEMA_1"; @@ -55,6 +59,7 @@ public class JdbcThinComplexDmlDdlCustomSchemaSelfTest extends JdbcThinComplexDm * * @throws Exception If failed. */ + @Test public void testCreateSelectDropEscapedSchema() throws Exception { try { curSchema = SCHEMA_2; @@ -71,8 +76,9 @@ public void testCreateSelectDropEscapedSchema() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultiple() throws Exception { testCreateSelectDrop(); testCreateSelectDrop(); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexDmlDdlSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexDmlDdlSelfTest.java index 36ee34a5fc950..ebadf8e59c0e6 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexDmlDdlSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexDmlDdlSelfTest.java @@ -34,19 +34,17 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Base class for complex SQL tests based on JDBC driver. */ +@RunWith(JUnit4.class) public class JdbcThinComplexDmlDdlSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache mode to test with. */ private final CacheMode cacheMode = CacheMode.PARTITIONED; @@ -68,12 +66,6 @@ public class JdbcThinComplexDmlDdlSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -127,7 +119,7 @@ protected Connection createConnection() throws SQLException { /** * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCreateSelectDrop() throws Exception { conn = createConnection(); @@ -477,4 +469,4 @@ private Row(Object[] row) { return Arrays.toString(row); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexQuerySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexQuerySelfTest.java index 692de7ca7de7c..fd87164ef655e 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexQuerySelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinComplexQuerySelfTest.java @@ -28,9 +28,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -39,10 +39,8 @@ /** * Tests for complex queries (joins, etc.). */ +@RunWith(JUnit4.class) public class JdbcThinComplexQuerySelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite:thin://127.0.0.1/"; @@ -55,12 +53,6 @@ public class JdbcThinComplexQuerySelfTest extends JdbcThinAbstractSelfTest { cfg.setCacheConfiguration(cacheConfiguration()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -130,6 +122,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testJoin() throws Exception { ResultSet rs = stmt.executeQuery( "select p.id, p.name, o.name as orgName from \"pers\".Person p, \"org\".Organization o where p.orgId = o.id"); @@ -165,6 +158,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testJoinWithoutAlias() throws Exception { ResultSet rs = stmt.executeQuery( "select p.id, p.name, o.name from \"pers\".Person p, \"org\".Organization o where p.orgId = o.id"); @@ -203,6 +197,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @Test public void testIn() throws Exception { ResultSet rs = stmt.executeQuery("select name from \"pers\".Person where age in (25, 35)"); @@ -223,6 +218,7 @@ public void testIn() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBetween() throws Exception { ResultSet rs = stmt.executeQuery("select name from \"pers\".Person where age between 24 and 36"); @@ -243,6 +239,7 @@ public void testBetween() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCalculatedValue() throws Exception { ResultSet rs = stmt.executeQuery("select age * 2 from \"pers\".Person"); @@ -322,4 +319,4 @@ private Organization(int id, String name) { this.name = name; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionMultipleAddressesTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionMultipleAddressesTest.java index 4f6651c2c0b7b..c8ad285a6d15b 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionMultipleAddressesTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionMultipleAddressesTest.java @@ -40,20 +40,18 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.mxbean.ClientProcessorMXBean; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * JDBC driver reconnect test with multiple addresses. */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class JdbcThinConnectionMultipleAddressesTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Nodes count. */ private static final int NODES_CNT = 3; @@ -83,12 +81,6 @@ private static String url() { cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(new BinaryMarshaller()); cfg.setClientConnectorConfiguration( @@ -131,6 +123,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) throws Excep /** * @throws Exception If failed. */ + @Test public void testMultipleAddressesConnect() throws Exception { try (Connection conn = DriverManager.getConnection(url())) { try (Statement stmt = conn.createStatement()) { @@ -148,6 +141,7 @@ public void testMultipleAddressesConnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPortRangeConnect() throws Exception { try (Connection conn = DriverManager.getConnection(URL_PORT_RANGE)) { try (Statement stmt = conn.createStatement()) { @@ -165,6 +159,7 @@ public void testPortRangeConnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleAddressesOneNodeFailoverOnStatementExecute() throws Exception { checkReconnectOnStatementExecute(url(), false); } @@ -172,6 +167,7 @@ public void testMultipleAddressesOneNodeFailoverOnStatementExecute() throws Exce /** * @throws Exception If failed. */ + @Test public void testMultipleAddressesAllNodesFailoverOnStatementExecute() throws Exception { checkReconnectOnStatementExecute(url(), true); } @@ -179,6 +175,7 @@ public void testMultipleAddressesAllNodesFailoverOnStatementExecute() throws Exc /** * @throws Exception If failed. */ + @Test public void testPortRangeAllNodesFailoverOnStatementExecute() throws Exception { checkReconnectOnStatementExecute(URL_PORT_RANGE, true); } @@ -186,6 +183,7 @@ public void testPortRangeAllNodesFailoverOnStatementExecute() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleAddressesOneNodeFailoverOnResultSet() throws Exception { checkReconnectOnResultSet(url(), false); } @@ -193,6 +191,7 @@ public void testMultipleAddressesOneNodeFailoverOnResultSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleAddressesAllNodesFailoverOnResultSet() throws Exception { checkReconnectOnResultSet(url(), true); } @@ -200,6 +199,7 @@ public void testMultipleAddressesAllNodesFailoverOnResultSet() throws Exception /** * @throws Exception If failed. */ + @Test public void testPortRangeAllNodesFailoverOnResultSet() throws Exception { checkReconnectOnResultSet(URL_PORT_RANGE, true); } @@ -207,6 +207,7 @@ public void testPortRangeAllNodesFailoverOnResultSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleAddressesOneNodeFailoverOnMeta() throws Exception { checkReconnectOnMeta(url(), false); } @@ -214,6 +215,7 @@ public void testMultipleAddressesOneNodeFailoverOnMeta() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleAddressesAllNodesFailoverOnMeta() throws Exception { checkReconnectOnMeta(url(), true); } @@ -221,6 +223,7 @@ public void testMultipleAddressesAllNodesFailoverOnMeta() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPortRangeAllNodesFailoverOnMeta() throws Exception { checkReconnectOnMeta(URL_PORT_RANGE, true); } @@ -228,6 +231,7 @@ public void testPortRangeAllNodesFailoverOnMeta() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleAddressesOneNodeFailoverOnStreaming() throws Exception { checkReconnectOnStreaming(url(), false); } @@ -235,6 +239,7 @@ public void testMultipleAddressesOneNodeFailoverOnStreaming() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientConnectionMXBean() throws Exception { Connection conn = DriverManager.getConnection(URL_PORT_RANGE); @@ -548,4 +553,4 @@ private void restart(boolean all) throws Exception { if (all) startGrids(NODES_CNT); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionMvccEnabledSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionMvccEnabledSelfTest.java index a26f547dbdf76..895e26a8fd4a4 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionMvccEnabledSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionMvccEnabledSelfTest.java @@ -27,12 +27,12 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.sql.Connection.TRANSACTION_NONE; import static java.sql.Connection.TRANSACTION_READ_COMMITTED; @@ -44,10 +44,8 @@ * Connection test. */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class JdbcThinConnectionMvccEnabledSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String URL = "jdbc:ignite:thin://127.0.0.1"; @@ -58,12 +56,6 @@ public class JdbcThinConnectionMvccEnabledSelfTest extends JdbcThinAbstractSelfT cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME).setNearConfiguration(null)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(new BinaryMarshaller()); cfg.setGridLogger(new GridStringLogger()); @@ -99,6 +91,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) { /** * @throws Exception If failed. */ + @Test public void testMetadataDefaults() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { DatabaseMetaData meta = conn.getMetaData(); @@ -117,6 +110,7 @@ public void testMetadataDefaults() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetAutoCommit() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assertTrue(conn.getMetaData().supportsTransactions()); @@ -145,6 +139,7 @@ public void testGetSetAutoCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommit() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assertTrue(conn.getMetaData().supportsTransactions()); @@ -180,6 +175,7 @@ public void testCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollback() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assertTrue(conn.getMetaData().supportsTransactions()); @@ -215,6 +211,7 @@ public void testRollback() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetSavepoint() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assert !conn.getMetaData().supportsSavepoints(); @@ -254,6 +251,7 @@ public void testSetSavepoint() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetSavepointName() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assert !conn.getMetaData().supportsSavepoints(); @@ -308,6 +306,7 @@ public void testSetSavepointName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollbackSavePoint() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assert !conn.getMetaData().supportsSavepoints(); @@ -373,4 +372,4 @@ private Savepoint getFakeSavepoint() { } }; } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSSLTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSSLTest.java index 355a198c56672..be7cbd6024606 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSSLTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSSLTest.java @@ -32,20 +32,18 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.ssl.SslContextFactory; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * SSL connection test. */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class JdbcThinConnectionSSLTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Client key store path. */ private static final String CLI_KEY_STORE_PATH = U.getIgniteHome() + "/modules/clients/src/test/keystore/client.jks"; @@ -72,12 +70,6 @@ public class JdbcThinConnectionSSLTest extends JdbcThinAbstractSelfTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(new BinaryMarshaller()); cfg.setClientConnectorConfiguration( @@ -95,6 +87,7 @@ public class JdbcThinConnectionSSLTest extends JdbcThinAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testConnection() throws Exception { setSslCtxFactoryToCli = true; sslCtxFactory = getTestSslContextFactory(); @@ -118,6 +111,7 @@ public void testConnection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionTrustAll() throws Exception { setSslCtxFactoryToCli = true; sslCtxFactory = getTestSslContextFactory(); @@ -140,6 +134,7 @@ public void testConnectionTrustAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionUseIgniteFactory() throws Exception { setSslCtxFactoryToIgnite = true; sslCtxFactory = getTestSslContextFactory(); @@ -163,6 +158,7 @@ public void testConnectionUseIgniteFactory() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultContext() throws Exception { // Store exists default SSL context to restore after test. final SSLContext dfltSslCtx = SSLContext.getDefault(); @@ -200,6 +196,7 @@ public void testDefaultContext() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContextFactory() throws Exception { setSslCtxFactoryToCli = true; sslCtxFactory = getTestSslContextFactory(); @@ -218,6 +215,7 @@ public void testContextFactory() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSslServerAndPlainClient() throws Exception { setSslCtxFactoryToCli = true; sslCtxFactory = getTestSslContextFactory(); @@ -241,6 +239,7 @@ public void testSslServerAndPlainClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvalidKeystoreConfig() throws Exception { setSslCtxFactoryToCli = true; @@ -329,6 +328,7 @@ public void testInvalidKeystoreConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUnknownClientCertificate() throws Exception { setSslCtxFactoryToCli = true; sslCtxFactory = getTestSslContextFactory(); @@ -356,6 +356,7 @@ public void testUnknownClientCertificate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUnsupportedSslProtocol() throws Exception { setSslCtxFactoryToCli = true; sslCtxFactory = getTestSslContextFactory(); @@ -384,6 +385,7 @@ public void testUnsupportedSslProtocol() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvalidKeyAlgorithm() throws Exception { setSslCtxFactoryToCli = true; sslCtxFactory = getTestSslContextFactory(); @@ -412,6 +414,7 @@ public void testInvalidKeyAlgorithm() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvalidKeyStoreType() throws Exception { setSslCtxFactoryToCli = true; sslCtxFactory = getTestSslContextFactory(); @@ -476,4 +479,4 @@ public static class TestSSLFactory implements Factory { return getTestSslContextFactory().create().getSocketFactory(); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java index 5e12bae2f11f3..cc2b235599667 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java @@ -47,12 +47,12 @@ import org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo; import org.apache.ignite.internal.util.HostAndPortRange; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.sql.Connection.TRANSACTION_NONE; import static java.sql.Connection.TRANSACTION_READ_COMMITTED; @@ -72,10 +72,8 @@ * Connection test. */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class JdbcThinConnectionSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String URL = "jdbc:ignite:thin://127.0.0.1"; @@ -94,12 +92,6 @@ public class JdbcThinConnectionSelfTest extends JdbcThinAbstractSelfTest { cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(new BinaryMarshaller()); cfg.setGridLogger(new GridStringLogger()); @@ -131,6 +123,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) throws Excep * @throws Exception If failed. */ @SuppressWarnings({"EmptyTryBlock", "unused"}) + @Test public void testDefaults() throws Exception { try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1")) { // No-op. @@ -144,6 +137,7 @@ public void testDefaults() throws Exception { /** * Test invalid endpoint. */ + @Test public void testInvalidEndpoint() { assertInvalid("jdbc:ignite:thin://", "Host name is empty"); assertInvalid("jdbc:ignite:thin://:10000", "Host name is empty"); @@ -160,6 +154,7 @@ public void testInvalidEndpoint() { * * @throws Exception If failed. */ + @Test public void testSocketBuffers() throws Exception { final int dfltDufSize = 64 * 1024; @@ -197,6 +192,7 @@ public void testSocketBuffers() throws Exception { * * @throws Exception If failed. */ + @Test public void testSocketBuffersSemicolon() throws Exception { final int dfltDufSize = 64 * 1024; @@ -229,6 +225,7 @@ public void testSocketBuffersSemicolon() throws Exception { * * @throws Exception If failed. */ + @Test public void testSqlHints() throws Exception { try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1")) { assertHints(conn, false, false, false, false, false, false); @@ -269,6 +266,7 @@ public void testSqlHints() throws Exception { * * @throws Exception If failed. */ + @Test public void testSqlHintsSemicolon() throws Exception { try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1;distributedJoins=true")) { assertHints(conn, true, false, false, false, false, false); @@ -327,6 +325,7 @@ private void assertHints(Connection conn, boolean distributedJoins, boolean enfo * * @throws Exception If failed. */ + @Test public void testTcpNoDelay() throws Exception { assertInvalid("jdbc:ignite:thin://127.0.0.1?tcpNoDelay=0", "Invalid property value. [name=tcpNoDelay, val=0, choices=[true, false]]"); @@ -366,6 +365,7 @@ public void testTcpNoDelay() throws Exception { * * @throws Exception If failed. */ + @Test public void testTcpNoDelaySemicolon() throws Exception { assertInvalid("jdbc:ignite:thin://127.0.0.1;tcpNoDelay=0", "Invalid property value. [name=tcpNoDelay, val=0, choices=[true, false]]"); @@ -401,6 +401,7 @@ public void testTcpNoDelaySemicolon() throws Exception { * * @throws Exception If failed. */ + @Test public void testAutoCloseServerCursorProperty() throws Exception { String url = "jdbc:ignite:thin://127.0.0.1?autoCloseServerCursor"; @@ -437,6 +438,7 @@ public void testAutoCloseServerCursorProperty() throws Exception { * * @throws Exception If failed. */ + @Test public void testAutoCloseServerCursorPropertySemicolon() throws Exception { String url = "jdbc:ignite:thin://127.0.0.1;autoCloseServerCursor"; @@ -469,6 +471,7 @@ public void testAutoCloseServerCursorPropertySemicolon() throws Exception { * * @throws Exception If failed. */ + @Test public void testSchema() throws Exception { assertInvalid("jdbc:ignite:thin://127.0.0.1/qwe/qwe", "Invalid URL format (only schema name is allowed in URL path parameter 'host:port[/schemaName]')" ); @@ -491,6 +494,7 @@ public void testSchema() throws Exception { * * @throws Exception If failed. */ + @Test public void testSchemaSemicolon() throws Exception { try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1;schema=public")) { assertEquals("Invalid schema", "PUBLIC", conn.getSchema()); @@ -539,6 +543,7 @@ private void assertInvalid(final String url, String errMsg) { * @throws Exception If failed. */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testClose() throws Exception { final Connection conn; @@ -565,6 +570,7 @@ public void testClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateStatement() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { try (Statement stmt = conn.createStatement()) { @@ -587,6 +593,7 @@ public void testCreateStatement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateStatement2() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { int [] rsTypes = new int[] @@ -640,6 +647,7 @@ public void testCreateStatement2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateStatement3() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { int [] rsTypes = new int[] @@ -699,6 +707,7 @@ public void testCreateStatement3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrepareStatement() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // null query text @@ -732,6 +741,7 @@ public void testPrepareStatement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrepareStatement3() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { final String sqlText = "select * from test where param = ?"; @@ -792,6 +802,7 @@ public void testPrepareStatement3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrepareStatement4() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { final String sqlText = "select * from test where param = ?"; @@ -857,6 +868,7 @@ public void testPrepareStatement4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrepareStatementAutoGeneratedKeysUnsupported() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { final String sqlText = "insert into test (val) values (?)"; @@ -906,6 +918,7 @@ public void testPrepareStatementAutoGeneratedKeysUnsupported() throws Exception /** * @throws Exception If failed. */ + @Test public void testPrepareCallUnsupported() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { final String sqlText = "exec test()"; @@ -946,6 +959,7 @@ public void testPrepareCallUnsupported() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNativeSql() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // null query text @@ -977,6 +991,7 @@ public void testNativeSql() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetAutoCommit() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { boolean ac0 = conn.getAutoCommit(); @@ -1001,6 +1016,7 @@ public void testGetSetAutoCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommit() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // Should not be called in auto-commit mode @@ -1045,6 +1061,7 @@ public void testCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollback() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // Should not be called in auto-commit mode @@ -1074,6 +1091,7 @@ public void testRollback() throws Exception { /** * @throws Exception if failed. */ + @Test public void testBeginFailsWhenMvccIsDisabled() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { conn.createStatement().execute("BEGIN"); @@ -1088,6 +1106,7 @@ public void testBeginFailsWhenMvccIsDisabled() throws Exception { /** * @throws Exception if failed. */ + @Test public void testCommitIgnoredWhenMvccIsDisabled() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { conn.setAutoCommit(false); @@ -1101,6 +1120,7 @@ public void testCommitIgnoredWhenMvccIsDisabled() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRollbackIgnoredWhenMvccIsDisabled() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { conn.setAutoCommit(false); @@ -1115,6 +1135,7 @@ public void testRollbackIgnoredWhenMvccIsDisabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetMetaData() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { DatabaseMetaData meta = conn.getMetaData(); @@ -1135,6 +1156,7 @@ public void testGetMetaData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetReadOnly() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { conn.close(); @@ -1158,6 +1180,7 @@ public void testGetSetReadOnly() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetCatalog() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assert !conn.getMetaData().supportsCatalogsInDataManipulation(); @@ -1189,6 +1212,7 @@ public void testGetSetCatalog() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetTransactionIsolation() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // Invalid parameter value @@ -1239,6 +1263,7 @@ public void testGetSetTransactionIsolation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearGetWarnings() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { SQLWarning warn = conn.getWarnings(); @@ -1272,6 +1297,7 @@ public void testClearGetWarnings() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetTypeMap() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { GridTestUtils.assertThrows(log, @@ -1327,6 +1353,7 @@ public void testGetSetTypeMap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetHoldability() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // default value @@ -1380,6 +1407,7 @@ public void testGetSetHoldability() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetSavepoint() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assert !conn.getMetaData().supportsSavepoints(); @@ -1410,6 +1438,7 @@ public void testSetSavepoint() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetSavepointName() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assert !conn.getMetaData().supportsSavepoints(); @@ -1455,6 +1484,7 @@ public void testSetSavepointName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollbackSavePoint() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assert !conn.getMetaData().supportsSavepoints(); @@ -1500,6 +1530,7 @@ public void testRollbackSavePoint() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReleaseSavepoint() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assert !conn.getMetaData().supportsSavepoints(); @@ -1538,6 +1569,7 @@ public void testReleaseSavepoint() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateClob() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // Unsupported @@ -1568,6 +1600,7 @@ public void testCreateClob() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateBlob() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // Unsupported @@ -1598,6 +1631,7 @@ public void testCreateBlob() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateNClob() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // Unsupported @@ -1628,6 +1662,7 @@ public void testCreateNClob() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateSQLXML() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // Unsupported @@ -1658,6 +1693,7 @@ public void testCreateSQLXML() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetClientInfoPair() throws Exception { // fail("https://issues.apache.org/jira/browse/IGNITE-5425"); @@ -1693,6 +1729,7 @@ public void testGetSetClientInfoPair() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetClientInfoProperties() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { final String name = "ApplicationName"; @@ -1731,6 +1768,7 @@ public void testGetSetClientInfoProperties() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateArrayOf() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { final String typeName = "varchar"; @@ -1771,6 +1809,7 @@ public void testCreateArrayOf() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateStruct() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // Invalid typename @@ -1807,6 +1846,7 @@ public void testCreateStruct() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetSchema() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assertEquals("PUBLIC", conn.getSchema()); @@ -1840,6 +1880,7 @@ public void testGetSetSchema() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAbort() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { //Invalid executor @@ -1866,6 +1907,7 @@ public void testAbort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetSetNetworkTimeout() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // default @@ -1924,7 +1966,7 @@ public void testGetSetNetworkTimeout() throws Exception { /** * Test that attempting to supply invalid nested TX mode to driver fails on the client. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testInvalidNestedTxMode() { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { @@ -1940,7 +1982,7 @@ public void testInvalidNestedTxMode() { * We have to do this without explicit {@link Connection} as long as there's no other way to bypass validation and * supply a malformed {@link ConnectionProperties} to {@link JdbcThinTcpIo}. */ - @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ThrowFromFinallyBlock"}) + @Test public void testInvalidNestedTxModeOnServerSide() throws SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, IOException { ConnectionPropertiesImpl connProps = new ConnectionPropertiesImpl(); @@ -1975,6 +2017,7 @@ public void testInvalidNestedTxModeOnServerSide() throws SQLException, NoSuchMet /** */ + @Test public void testSslClientAndPlainServer() { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1992,6 +2035,7 @@ public void testSslClientAndPlainServer() { /** * @throws Exception If failed. */ + @Test public void testMultithreadingException() throws Exception { int threadCnt = 10; diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDataSourceSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDataSourceSelfTest.java index 6040bed3e2cf8..4ef4506893daf 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDataSourceSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDataSourceSelfTest.java @@ -39,19 +39,17 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.jdbc.thin.JdbcThinConnection; import org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * DataSource test. */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class JdbcThinDataSourceSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @SuppressWarnings("deprecation") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -59,12 +57,6 @@ public class JdbcThinDataSourceSelfTest extends JdbcThinAbstractSelfTest { cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(new BinaryMarshaller()); return cfg; @@ -98,6 +90,7 @@ private CacheConfiguration cacheConfiguration(String name) throws Exception { /** * @throws Exception If failed. */ + @Test public void testJndi() throws Exception { IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource(); @@ -117,6 +110,7 @@ public void testJndi() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUrlCompose() throws Exception { IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource(); @@ -139,6 +133,7 @@ public void testUrlCompose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testResetUrl() throws Exception { IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource(); @@ -157,6 +152,7 @@ public void testResetUrl() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlHints() throws Exception { IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource(); @@ -195,6 +191,7 @@ public void testSqlHints() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTcpNoDelay() throws Exception { IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource(); @@ -218,6 +215,7 @@ public void testTcpNoDelay() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSocketBuffers() throws Exception { final IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource(); @@ -426,4 +424,4 @@ public static class JndiMockContext implements Context { return null; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDeleteStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDeleteStatementSelfTest.java index 9d0665b8fe3d2..d11e5bb958615 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDeleteStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDeleteStatementSelfTest.java @@ -20,14 +20,19 @@ import java.sql.SQLException; import java.util.Arrays; import java.util.HashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class JdbcThinDeleteStatementSelfTest extends JdbcThinAbstractUpdateStatementSelfTest { /** * @throws SQLException If failed. */ + @Test public void testExecute() throws SQLException { conn.createStatement().execute("delete from Person where cast(substring(_key, 2, 1) as int) % 2 = 0"); @@ -38,6 +43,7 @@ public void testExecute() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testExecuteUpdate() throws SQLException { int res = conn.createStatement().executeUpdate("delete from Person where cast(substring(_key, 2, 1) as int) % 2 = 0"); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDynamicIndexAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDynamicIndexAbstractSelfTest.java index 539713aeb4cdb..765ca839d2759 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDynamicIndexAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDynamicIndexAbstractSelfTest.java @@ -33,10 +33,14 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that checks indexes handling with JDBC. */ +@RunWith(JUnit4.class) public abstract class JdbcThinDynamicIndexAbstractSelfTest extends JdbcThinAbstractDmlStatementSelfTest { /** */ private static final String CREATE_INDEX = "create index idx on Person (id desc)"; @@ -143,6 +147,7 @@ private Object getSingleValue(ResultSet rs) throws SQLException { * Test that after index creation index is used by queries. * @throws SQLException If failed. */ + @Test public void testCreateIndex() throws SQLException { assertSize(3); @@ -173,6 +178,7 @@ public void testCreateIndex() throws SQLException { * Test that creating an index with duplicate name yields an error. * @throws SQLException If failed. */ + @Test public void testCreateIndexWithDuplicateName() throws SQLException { jdbcRun(CREATE_INDEX); @@ -189,6 +195,7 @@ public void testCreateIndexWithDuplicateName() throws SQLException { * Test that creating an index with duplicate name does not yield an error with {@code IF NOT EXISTS}. * @throws SQLException If failed. */ + @Test public void testCreateIndexIfNotExists() throws SQLException { jdbcRun(CREATE_INDEX); @@ -200,6 +207,7 @@ public void testCreateIndexIfNotExists() throws SQLException { * Test that after index drop there are no attempts to use it, and data state remains intact. * @throws SQLException If failed. */ + @Test public void testDropIndex() throws SQLException { assertSize(3); @@ -229,6 +237,7 @@ public void testDropIndex() throws SQLException { /** * Test that dropping a non-existent index yields an error. */ + @Test public void testDropMissingIndex() { GridTestUtils.assertThrowsAnyCause(log, new Callable() { @Override public Void call() throws Exception { @@ -243,6 +252,7 @@ public void testDropMissingIndex() { * Test that dropping a non-existent index does not yield an error with {@code IF EXISTS}. * @throws SQLException If failed. */ + @Test public void testDropMissingIndexIfExists() throws SQLException { // Despite index missing, this does not yield an error. jdbcRun(DROP_INDEX_IF_EXISTS); @@ -252,6 +262,7 @@ public void testDropMissingIndexIfExists() throws SQLException { * Test that changes in cache affect index, and vice versa. * @throws SQLException If failed. */ + @Test public void testIndexState() throws SQLException { IgniteCache cache = cache(); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinEmptyCacheSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinEmptyCacheSelfTest.java index 87c1428f78b34..47708d85e95a5 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinEmptyCacheSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinEmptyCacheSelfTest.java @@ -23,9 +23,9 @@ import java.sql.Statement; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -33,10 +33,8 @@ /** * Tests for empty cache. */ +@RunWith(JUnit4.class) public class JdbcThinEmptyCacheSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -62,12 +60,6 @@ public class JdbcThinEmptyCacheSelfTest extends JdbcThinAbstractSelfTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -104,6 +96,7 @@ public class JdbcThinEmptyCacheSelfTest extends JdbcThinAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testSelectNumber() throws Exception { ResultSet rs = stmt.executeQuery("select 1"); @@ -122,6 +115,7 @@ public void testSelectNumber() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSelectString() throws Exception { ResultSet rs = stmt.executeQuery("select 'str'"); @@ -135,4 +129,4 @@ public void testSelectString() throws Exception { assert cnt == 1; } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinErrorsSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinErrorsSelfTest.java index 2ff3e9f83d1ee..e14feb34b7b88 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinErrorsSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinErrorsSelfTest.java @@ -24,12 +24,16 @@ import java.sql.Statement; import org.apache.ignite.jdbc.JdbcErrorsAbstractSelfTest; import org.apache.ignite.lang.IgniteCallable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.junit.Assert.assertArrayEquals; /** * Test SQLSTATE codes propagation with thin client driver. */ +@RunWith(JUnit4.class) public class JdbcThinErrorsSelfTest extends JdbcErrorsAbstractSelfTest { /** {@inheritDoc} */ @Override protected Connection getConnection() throws SQLException { @@ -41,6 +45,7 @@ public class JdbcThinErrorsSelfTest extends JdbcErrorsAbstractSelfTest { * due to communication problems (not due to clear misconfiguration). * @throws SQLException if failed. */ + @Test public void testConnectionError() throws SQLException { checkErrorState(new IgniteCallable() { @Override public Void call() throws Exception { @@ -55,6 +60,7 @@ public void testConnectionError() throws SQLException { * Test error code for the case when connection string is a mess. * @throws SQLException if failed. */ + @Test public void testInvalidConnectionStringFormat() throws SQLException { checkErrorState(new IgniteCallable() { @Override public Void call() throws Exception { @@ -71,6 +77,7 @@ public void testInvalidConnectionStringFormat() throws SQLException { * @throws SQLException if failed. */ @SuppressWarnings("MagicConstant") + @Test public void testInvalidIsolationLevel() throws SQLException { checkErrorState(new ConnClosure() { @Override public void run(Connection conn) throws Exception { @@ -83,7 +90,7 @@ public void testInvalidIsolationLevel() throws SQLException { * Test error code for the case when error is caused on batch execution. * @throws SQLException if failed. */ - @SuppressWarnings("MagicConstant") + @Test public void testBatchUpdateException() throws SQLException { try (final Connection conn = getConnection()) { try (Statement stmt = conn.createStatement()) { diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinInsertStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinInsertStatementSelfTest.java index bf55da0879eb2..50c197aad5ffb 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinInsertStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinInsertStatementSelfTest.java @@ -25,10 +25,14 @@ import java.util.HashSet; import java.util.concurrent.Callable; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Statement test. */ +@RunWith(JUnit4.class) public class JdbcThinInsertStatementSelfTest extends JdbcThinAbstractDmlStatementSelfTest { /** SQL query. */ private static final String SQL = "insert into Person(_key, id, firstName, lastName, age) values " + @@ -140,6 +144,7 @@ public class JdbcThinInsertStatementSelfTest extends JdbcThinAbstractDmlStatemen /** * @throws SQLException If failed. */ + @Test public void testExecuteUpdate() throws SQLException { assertEquals(3, stmt.executeUpdate(SQL)); } @@ -147,6 +152,7 @@ public void testExecuteUpdate() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testPreparedExecuteUpdate() throws SQLException { assertEquals(3, prepStmt.executeUpdate()); } @@ -154,6 +160,7 @@ public void testPreparedExecuteUpdate() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testExecute() throws SQLException { assertFalse(stmt.execute(SQL)); } @@ -161,6 +168,7 @@ public void testExecute() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testPreparedExecute() throws SQLException { assertFalse(prepStmt.execute()); } @@ -168,6 +176,7 @@ public void testPreparedExecute() throws SQLException { /** * */ + @Test public void testDuplicateKeys() { jcache(0).put("p2", new Person(2, "Joe", "Black", 35)); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinLocalQueriesSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinLocalQueriesSelfTest.java index 1e28e52d3e3d6..7bb7168e6e6e7 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinLocalQueriesSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinLocalQueriesSelfTest.java @@ -23,10 +23,14 @@ import java.util.Map; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that replicated-only query is executed locally. */ +@RunWith(JUnit4.class) public class JdbcThinLocalQueriesSelfTest extends JdbcThinAbstractSelfTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { @@ -47,6 +51,7 @@ public class JdbcThinLocalQueriesSelfTest extends JdbcThinAbstractSelfTest { /** * */ + @Test public void testLocalThinJdbcQuery() throws SQLException { try (Connection c = connect(grid(0), "replicatedOnly=true")) { execute(c, "CREATE TABLE Company(id int primary key, name varchar) WITH " + diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMergeStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMergeStatementSelfTest.java index 9d9467f3bd754..11911ba83f07f 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMergeStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMergeStatementSelfTest.java @@ -21,10 +21,14 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * MERGE statement test. */ +@RunWith(JUnit4.class) public class JdbcThinMergeStatementSelfTest extends JdbcThinAbstractDmlStatementSelfTest { /** SQL query. */ private static final String SQL = "merge into Person(_key, id, firstName, lastName, age) values " + @@ -117,6 +121,7 @@ public class JdbcThinMergeStatementSelfTest extends JdbcThinAbstractDmlStatement /** * @throws SQLException If failed. */ + @Test public void testExecuteUpdate() throws SQLException { assertEquals(3, stmt.executeUpdate(SQL)); } @@ -124,6 +129,7 @@ public void testExecuteUpdate() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testExecute() throws SQLException { assertFalse(stmt.execute(SQL)); } diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataPrimaryKeysSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataPrimaryKeysSelfTest.java new file mode 100644 index 0000000000000..a4ef3119b3c2b --- /dev/null +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataPrimaryKeysSelfTest.java @@ -0,0 +1,160 @@ +/* + * 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. + */ + +package org.apache.ignite.jdbc.thin; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Verifies that primary keys in the metadata are valid. + */ +@RunWith(JUnit4.class) +public class JdbcThinMetadataPrimaryKeysSelfTest extends GridCommonAbstractTest { + /** Url. */ + private static final String URL = "jdbc:ignite:thin://127.0.0.1"; + + /** COLUMN_NAME column index in the metadata table. */ + private static final int COL_NAME_IDX = 4; + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + startGrid(1); + } + + /** + * Execute update sql operation using new connection. + * + * @param sql update SQL query. + * @return update count. + * @throws SQLException on error. + */ + private int executeUpdate(String sql) throws SQLException { + try (Connection conn = DriverManager.getConnection(URL)) { + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + return stmt.executeUpdate(); + } + } + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + executeUpdate("DROP TABLE IF EXISTS TEST;"); + } + + /** + * Checks for PK that contains single unwrapped field. + */ + @Test + public void testSingleUnwrappedKey() throws Exception { + executeUpdate("CREATE TABLE TEST (ID LONG PRIMARY KEY, NAME VARCHAR);"); + + checkPKFields("TEST", "ID"); + } + + /** + * Checks for PK that contains single field. Key is forcibly wrapped. + */ + @Test + public void testSingleWrappedKey() throws Exception { + executeUpdate("CREATE TABLE TEST (" + + "ID LONG PRIMARY KEY, " + + "NAME VARCHAR) " + + "WITH \"wrap_key=true\";"); + + checkPKFields("TEST", "ID"); + } + + /** + * Checks for composite (so implicitly wrapped) primary key. + */ + @Test + public void testCompositeKey() throws Exception { + executeUpdate("CREATE TABLE TEST (" + + "ID LONG, " + + "SEC_ID LONG, " + + "NAME VARCHAR, " + + "PRIMARY KEY (ID, SEC_ID));"); + + checkPKFields("TEST", "ID", "SEC_ID"); + } + + /** + * Checks for composite (so implicitly wrapped) primary key. Additionally, affinity key is used. + */ + @Test + public void testCompositeKeyWithAK() throws Exception { + final String tpl = "CREATE TABLE TEST (" + + "ID LONG, " + + "SEC_ID LONG, " + + "NAME VARCHAR, " + + "PRIMARY KEY (ID, SEC_ID)) " + + "WITH \"affinity_key=%s\";"; + + executeUpdate(String.format(tpl, "ID")); + + checkPKFields("TEST", "ID", "SEC_ID"); + + executeUpdate("DROP TABLE TEST;"); + + executeUpdate(String.format(tpl, "SEC_ID")); + + checkPKFields("TEST", "ID", "SEC_ID"); + } + + /** + * Checks that field names in the metadata matches specified expected fields. + * + * @param tabName part of the sql query after CREATE TABLE TESTER. + * @param expPKFields Expected primary key fields. + */ + private void checkPKFields(String tabName, String... expPKFields) throws Exception { + try (Connection conn = DriverManager.getConnection(URL)) { + DatabaseMetaData md = conn.getMetaData(); + + ResultSet rs = md.getPrimaryKeys(conn.getCatalog(), "", tabName); + + List colNames = new ArrayList<>(); + + while (rs.next()) + colNames.add(rs.getString(COL_NAME_IDX)); + + assertEquals("Field names in the primary key are not correct", + Arrays.asList(expPKFields), colNames); + } + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataSelfTest.java index 59382f1854704..b8aeb3b6fa4c3 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataSelfTest.java @@ -42,13 +42,12 @@ import org.apache.ignite.cache.affinity.AffinityKey; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteVersionUtils; import org.apache.ignite.internal.processors.query.QueryEntityEx; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.sql.Types.INTEGER; import static java.sql.Types.OTHER; @@ -59,26 +58,11 @@ /** * Metadata tests. */ +@RunWith(JUnit4.class) public class JdbcThinMetadataSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite:thin://127.0.0.1/"; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - /** * @param qryEntity Query entity. * @return Cache configuration. @@ -102,7 +86,7 @@ protected CacheConfiguration cacheConfiguration(QueryEntity qryEntity) { startGridsMultiThreaded(3); Map orgPrecision = new HashMap<>(); - + orgPrecision.put("name", 42); IgniteCache orgCache = jcache(grid(0), @@ -143,7 +127,7 @@ protected CacheConfiguration cacheConfiguration(QueryEntity qryEntity) { personCache.put(new AffinityKey<>("p2", "o1"), new Person("Joe Black", 35, 1)); personCache.put(new AffinityKey<>("p3", "o2"), new Person("Mike Green", 40, 2)); - IgniteCache departmentCache = jcache(grid(0), + IgniteCache departmentCache = jcache(grid(0), defaultCacheConfiguration().setIndexedTypes(Integer.class, Department.class), "dep"); try (Connection conn = DriverManager.getConnection(URL)) { @@ -155,12 +139,14 @@ protected CacheConfiguration cacheConfiguration(QueryEntity qryEntity) { stmt.execute("CREATE INDEX \"MyTestIndex quoted\" on \"Quoted\" (\"Id\" DESC)"); stmt.execute("CREATE INDEX IDX ON TEST (ID ASC)"); stmt.execute("CREATE TABLE TEST_DECIMAL_COLUMN (ID INT primary key, DEC_COL DECIMAL(8, 3))"); + stmt.execute("CREATE TABLE TEST_DECIMAL_COLUMN_PRECISION (ID INT primary key, DEC_COL DECIMAL(8))"); } } /** * @throws Exception If failed. */ + @Test public void testResultSetMetaData() throws Exception { Connection conn = DriverManager.getConnection(URL); @@ -197,6 +183,7 @@ public void testResultSetMetaData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetTables() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { DatabaseMetaData meta = conn.getMetaData(); @@ -241,6 +228,7 @@ public void testGetTables() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllTables() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { DatabaseMetaData meta = conn.getMetaData(); @@ -253,7 +241,8 @@ public void testGetAllTables() throws Exception { "dep.DEPARTMENT", "PUBLIC.TEST", "PUBLIC.Quoted", - "PUBLIC.TEST_DECIMAL_COLUMN")); + "PUBLIC.TEST_DECIMAL_COLUMN", + "PUBLIC.TEST_DECIMAL_COLUMN_PRECISION")); Set actualTbls = new HashSet<>(expectedTbls.size()); @@ -270,6 +259,7 @@ public void testGetAllTables() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetColumns() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { conn.setSchema("pers"); @@ -382,6 +372,7 @@ else if ("_VAL".equals(name)) { /** * @throws Exception If failed. */ + @Test public void testGetAllColumns() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { DatabaseMetaData meta = conn.getMetaData(); @@ -403,7 +394,9 @@ public void testGetAllColumns() throws Exception { "PUBLIC.Quoted.Id.null", "PUBLIC.Quoted.Name.null.50", "PUBLIC.TEST_DECIMAL_COLUMN.ID.null", - "PUBLIC.TEST_DECIMAL_COLUMN.DEC_COL.null.8.3" + "PUBLIC.TEST_DECIMAL_COLUMN.DEC_COL.null.8.3", + "PUBLIC.TEST_DECIMAL_COLUMN_PRECISION.ID.null", + "PUBLIC.TEST_DECIMAL_COLUMN_PRECISION.DEC_COL.null.8" )); Set actualCols = new HashSet<>(expectedCols.size()); @@ -430,6 +423,7 @@ public void testGetAllColumns() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvalidCatalog() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { DatabaseMetaData meta = conn.getMetaData(); @@ -459,6 +453,7 @@ public void testInvalidCatalog() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIndexMetadata() throws Exception { try (Connection conn = DriverManager.getConnection(URL); ResultSet rs = conn.getMetaData().getIndexInfo(null, "pers", "PERSON", false, false)) { @@ -497,6 +492,7 @@ else if ("AGE".equals(field)) /** * @throws Exception If failed. */ + @Test public void testGetAllIndexes() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { ResultSet rs = conn.getMetaData().getIndexInfo(null, null, null, false, false); @@ -525,6 +521,7 @@ public void testGetAllIndexes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryKeyMetadata() throws Exception { try (Connection conn = DriverManager.getConnection(URL); ResultSet rs = conn.getMetaData().getPrimaryKeys(null, "pers", "PERSON")) { @@ -544,6 +541,7 @@ public void testPrimaryKeyMetadata() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllPrimaryKeys() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { ResultSet rs = conn.getMetaData().getPrimaryKeys(null, null, null); @@ -555,7 +553,8 @@ public void testGetAllPrimaryKeys() throws Exception { "PUBLIC.TEST.PK_PUBLIC_TEST.ID", "PUBLIC.TEST.PK_PUBLIC_TEST.NAME", "PUBLIC.Quoted.PK_PUBLIC_Quoted.Id", - "PUBLIC.TEST_DECIMAL_COLUMN.ID._KEY")); + "PUBLIC.TEST_DECIMAL_COLUMN.ID.ID", + "PUBLIC.TEST_DECIMAL_COLUMN_PRECISION.ID.ID")); Set actualPks = new HashSet<>(expectedPks.size()); @@ -574,6 +573,7 @@ public void testGetAllPrimaryKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testParametersMetadata() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { conn.setSchema("\"pers\""); @@ -598,6 +598,7 @@ public void testParametersMetadata() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSchemasMetadata() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { ResultSet rs = conn.getMetaData().getSchemas(); @@ -620,6 +621,7 @@ public void testSchemasMetadata() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEmptySchemasMetadata() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { ResultSet rs = conn.getMetaData().getSchemas(null, "qqq"); @@ -631,6 +633,7 @@ public void testEmptySchemasMetadata() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersions() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { assert conn.getMetaData().getDatabaseProductVersion().equals(IgniteVersionUtils.VER.toString()); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMissingLongArrayResultsTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMissingLongArrayResultsTest.java index 633c74bb52c91..157bf99996b21 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMissingLongArrayResultsTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMissingLongArrayResultsTest.java @@ -31,18 +31,16 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class JdbcThinMissingLongArrayResultsTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** First cache name. */ private static final String CACHE_NAME = "test"; @@ -67,12 +65,6 @@ public class JdbcThinMissingLongArrayResultsTest extends JdbcThinAbstractSelfTes cfg.setCacheConfiguration(cacheConfiguration(CACHE_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -164,7 +156,8 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) throws Excep /** * @throws Exception If failed. */ - @SuppressWarnings({"EmptyTryBlock", "unused"}) + @SuppressWarnings({"unused"}) + @Test public void testDefaults() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { conn.setSchema('"' + CACHE_NAME + '"'); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinNoDefaultSchemaTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinNoDefaultSchemaTest.java index 53425c8bbb054..254cbbd3c7fa9 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinNoDefaultSchemaTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinNoDefaultSchemaTest.java @@ -27,19 +27,17 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class JdbcThinNoDefaultSchemaTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** First cache name. */ private static final String CACHE1_NAME = "cache1"; @@ -58,12 +56,6 @@ public class JdbcThinNoDefaultSchemaTest extends JdbcThinAbstractSelfTest { cfg.setCacheConfiguration(cacheConfiguration(CACHE1_NAME), cacheConfiguration(CACHE2_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -104,6 +96,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) throws Excep * @throws Exception If failed. */ @SuppressWarnings({"EmptyTryBlock", "unused"}) + @Test public void testDefaults() throws Exception { try (Connection conn = DriverManager.getConnection(URL)) { // No-op. @@ -117,6 +110,7 @@ public void testDefaults() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSchemaNameInQuery() throws Exception { Connection conn = DriverManager.getConnection(URL); @@ -155,6 +149,7 @@ public void testSchemaNameInQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSchemaInUrl() throws Exception { try(Connection conn = DriverManager.getConnection(URL + "/\"cache1\"")) { Statement stmt = conn.createStatement(); @@ -182,6 +177,7 @@ public void testSchemaInUrl() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSchemaInUrlAndInQuery() throws Exception { try(Connection conn = DriverManager.getConnection(URL + "/\"cache2\"")) { Statement stmt = conn.createStatement(); @@ -201,6 +197,7 @@ public void testSchemaInUrlAndInQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetSchema() throws Exception { try(Connection conn = DriverManager.getConnection(URL)) { // Try to execute query without set schema diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java index 85efb4d487319..9660760f595da 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java @@ -40,10 +40,10 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.sql.Types.BIGINT; import static java.sql.Types.BINARY; @@ -65,10 +65,8 @@ * Prepared statement test. */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class JdbcThinPreparedStatementSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite:thin://127.0.0.1/"; @@ -99,12 +97,6 @@ public class JdbcThinPreparedStatementSelfTest extends JdbcThinAbstractSelfTest cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -167,6 +159,7 @@ public class JdbcThinPreparedStatementSelfTest extends JdbcThinAbstractSelfTest /** * @throws Exception If failed. */ + @Test public void testRepeatableUsage() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where id = ?"); @@ -202,6 +195,7 @@ public void testRepeatableUsage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryExecuteException() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where boolVal is not distinct from ?"); @@ -259,6 +253,7 @@ public void testQueryExecuteException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where boolVal is not distinct from ?"); @@ -298,6 +293,7 @@ public void testBoolean() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByte() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where byteVal is not distinct from ?"); @@ -337,6 +333,7 @@ public void testByte() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where shortVal is not distinct from ?"); @@ -376,6 +373,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInteger() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where intVal is not distinct from ?"); @@ -415,6 +413,7 @@ public void testInteger() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where longVal is not distinct from ?"); @@ -454,6 +453,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where floatVal is not distinct from ?"); @@ -493,6 +493,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where doubleVal is not distinct from ?"); @@ -532,6 +533,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimal() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where bigVal is not distinct from ?"); @@ -571,6 +573,7 @@ public void testBigDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testString() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where strVal is not distinct from ?"); @@ -610,6 +613,7 @@ public void testString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArray() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where arrVal is not distinct from ?"); @@ -649,6 +653,7 @@ public void testArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDate() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where dateVal is not distinct from ?"); @@ -688,6 +693,7 @@ public void testDate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTime() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where timeVal is not distinct from ?"); @@ -727,6 +733,7 @@ public void testTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where tsVal is not distinct from ?"); @@ -766,6 +773,7 @@ public void testTimestamp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearParameter() throws Exception { stmt = conn.prepareStatement(SQL_PART + " where boolVal is not distinct from ?"); @@ -789,6 +797,7 @@ public void testClearParameter() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotSupportedTypes() throws Exception { stmt = conn.prepareStatement(""); @@ -1050,4 +1059,4 @@ private TestObject(int id) { this.id = id; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinResultSetSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinResultSetSelfTest.java index 36a0a15e92dc3..93ac9ecb12818 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinResultSetSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinResultSetSelfTest.java @@ -42,10 +42,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -54,10 +54,8 @@ * Result set test. */ @SuppressWarnings({"FloatingPointEquality", "ThrowableNotThrown", "AssertWithSideEffects"}) +@RunWith(JUnit4.class) public class JdbcThinResultSetSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite:thin://127.0.0.1/"; @@ -85,12 +83,6 @@ public class JdbcThinResultSetSelfTest extends JdbcThinAbstractSelfTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -163,6 +155,7 @@ private TestObject createObjectWithData(int id) throws MalformedURLException { /** * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -243,6 +236,7 @@ public void testBoolean() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByte() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -282,6 +276,7 @@ public void testByte() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -321,6 +316,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInteger() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -360,6 +356,7 @@ public void testInteger() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -399,6 +396,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -438,6 +436,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -477,6 +476,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimal() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -516,6 +516,7 @@ public void testBigDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimalScale() throws Exception { assert "0.12".equals(convertStringToBigDecimalViaJdbc("0.1234", 2).toString()); assert "1.001".equals(convertStringToBigDecimalViaJdbc("1.0005", 3).toString()); @@ -540,6 +541,7 @@ private BigDecimal convertStringToBigDecimalViaJdbc(String strDec, int scale) th /** * @throws Exception If failed. */ + @Test public void testString() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -579,6 +581,7 @@ public void testString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArray() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -600,6 +603,7 @@ public void testArray() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testDate() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -628,6 +632,7 @@ public void testDate() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testTime() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -655,6 +660,7 @@ public void testTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -682,6 +688,7 @@ public void testTimestamp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectNotSupported() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable() { @Override public Object call() throws Exception { @@ -695,6 +702,7 @@ public void testObjectNotSupported() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNavigation() throws Exception { ResultSet rs = stmt.executeQuery("select id from TestObject where id > 0"); @@ -736,6 +744,7 @@ public void testNavigation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFindColumn() throws Exception { final ResultSet rs = stmt.executeQuery(SQL); @@ -761,6 +770,7 @@ public void testFindColumn() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotSupportedTypes() throws Exception { final ResultSet rs = stmt.executeQuery(SQL); @@ -902,6 +912,7 @@ public void testNotSupportedTypes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateNotSupported() throws Exception { final ResultSet rs = stmt.executeQuery(SQL); @@ -1409,6 +1420,7 @@ public void testUpdateNotSupported() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExceptionOnClosedResultSet() throws Exception { final ResultSet rs = stmt.executeQuery(SQL); @@ -1842,4 +1854,4 @@ private TestObjectField(int a, String b) { return S.toString(TestObjectField.class, this); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinSchemaCaseTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinSchemaCaseTest.java index 8f1108743cdd7..56e2fee73f1ff 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinSchemaCaseTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinSchemaCaseTest.java @@ -24,19 +24,17 @@ import java.util.concurrent.Callable; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class JdbcThinSchemaCaseTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite:thin://127.0.0.1"; @@ -52,12 +50,6 @@ public class JdbcThinSchemaCaseTest extends JdbcThinAbstractSelfTest { cacheConfiguration("test1", "tEst1"), cacheConfiguration("test2", "\"TestCase\"")); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -90,7 +82,8 @@ private CacheConfiguration cacheConfiguration(@NotNull String name, @NotNull Str /** * @throws Exception If failed. */ - @SuppressWarnings({"EmptyTryBlock", "unused"}) + @SuppressWarnings({"unused"}) + @Test public void testSchemaName() throws Exception { checkSchemaConnection("test0"); checkSchemaConnection("test1"); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinSelectAfterAlterTable.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinSelectAfterAlterTable.java index ef711dcfd1e92..887740658bca6 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinSelectAfterAlterTable.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinSelectAfterAlterTable.java @@ -27,19 +27,17 @@ import org.apache.ignite.configuration.ClientConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Base class for complex SQL tests based on JDBC driver. */ +@RunWith(JUnit4.class) public class JdbcThinSelectAfterAlterTable extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Client connection port. */ private int cliPort = ClientConnectorConfiguration.DFLT_PORT; @@ -55,12 +53,6 @@ public class JdbcThinSelectAfterAlterTable extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setClientConnectorConfiguration(new ClientConnectorConfiguration().setPort(cliPort++)); return cfg; @@ -119,7 +111,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name) throws Excep /** * @throws Exception If failed. */ - @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unchecked"}) + @Test public void testSelectAfterAlterTableSingleNode() throws Exception { stmt.executeUpdate("alter table person add age int"); @@ -129,7 +121,7 @@ public void testSelectAfterAlterTableSingleNode() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unchecked"}) + @Test public void testSelectAfterAlterTableMultiNode() throws Exception { try (Connection conn2 = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:" + (ClientConnectorConfiguration.DFLT_PORT + 1))) { @@ -165,4 +157,4 @@ public void checkNewColumn(Statement stmt) throws SQLException { assertTrue(newColExists); } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java index 6d6e72db0b087..655bdd20147fc 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java @@ -33,10 +33,9 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -44,11 +43,9 @@ /** * Statement test. */ -@SuppressWarnings({"ThrowableNotThrown", "ThrowableResultOfMethodCallIgnored"}) +@SuppressWarnings({"ThrowableNotThrown"}) +@RunWith(JUnit4.class) public class JdbcThinStatementSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** URL. */ private static final String URL = "jdbc:ignite:thin://127.0.0.1/"; @@ -77,12 +74,6 @@ public class JdbcThinStatementSelfTest extends JdbcThinAbstractSelfTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -124,6 +115,7 @@ public class JdbcThinStatementSelfTest extends JdbcThinAbstractSelfTest { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecuteQuery0() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -156,6 +148,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecuteQuery1() throws Exception { final String sqlText = "select val from test"; @@ -182,6 +175,7 @@ public void testExecuteQuery1() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecute() throws Exception { assert stmt.execute(SQL); @@ -220,6 +214,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @org.junit.Test public void testMaxRows() throws Exception { stmt.setMaxRows(1); @@ -285,6 +280,7 @@ else if (id == 3) { /** * @throws Exception If failed. */ + @org.junit.Test public void testCloseResultSet0() throws Exception { ResultSet rs0 = stmt.executeQuery(SQL); ResultSet rs1 = stmt.executeQuery(SQL); @@ -303,6 +299,7 @@ public void testCloseResultSet0() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testCloseResultSet1() throws Exception { stmt.execute(SQL); @@ -316,6 +313,7 @@ public void testCloseResultSet1() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testCloseResultSetByConnectionClose() throws Exception { ResultSet rs = stmt.executeQuery(SQL); @@ -328,6 +326,7 @@ public void testCloseResultSetByConnectionClose() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testCloseOnCompletionAfterQuery() throws Exception { assert !stmt.isCloseOnCompletion() : "Invalid default closeOnCompletion"; @@ -357,6 +356,7 @@ public void testCloseOnCompletionAfterQuery() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testCloseOnCompletionBeforeQuery() throws Exception { assert !stmt.isCloseOnCompletion() : "Invalid default closeOnCompletion"; @@ -386,6 +386,7 @@ public void testCloseOnCompletionBeforeQuery() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecuteQueryTimeout() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-5438"); @@ -408,6 +409,7 @@ public void testExecuteQueryTimeout() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecuteQueryMultipleOnlyResultSets() throws Exception { assert conn.getMetaData().supportsMultipleResultSets(); @@ -436,6 +438,7 @@ public void testExecuteQueryMultipleOnlyResultSets() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecuteQueryMultipleOnlyDml() throws Exception { conn.setSchema(null); @@ -471,6 +474,7 @@ public void testExecuteQueryMultipleOnlyDml() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecuteQueryMultipleMixed() throws Exception { conn.setSchema(null); @@ -531,6 +535,7 @@ public void testExecuteQueryMultipleMixed() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecuteUpdate() throws Exception { final String sqlText = "update test set val=1 where _key=1"; @@ -548,6 +553,7 @@ public void testExecuteUpdate() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecuteUpdateProducesResultSet() throws Exception { final String sqlText = "select * from test"; @@ -565,6 +571,7 @@ public void testExecuteUpdateProducesResultSet() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExecuteUpdateTimeout() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-5438"); @@ -587,6 +594,7 @@ public void testExecuteUpdateTimeout() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testClose() throws Exception { String sqlText = "select * from test"; @@ -609,6 +617,7 @@ public void testClose() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testGetSetMaxFieldSizeUnsupported() throws Exception { assertEquals(0, stmt.getMaxFieldSize()); @@ -646,6 +655,7 @@ public void testGetSetMaxFieldSizeUnsupported() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testGetSetMaxRows() throws Exception { assertEquals(0, stmt.getMaxRows()); @@ -696,6 +706,7 @@ public void testGetSetMaxRows() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testSetEscapeProcessing() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-5440"); @@ -733,6 +744,7 @@ public void testSetEscapeProcessing() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testGetSetQueryTimeout() throws Exception { assertEquals(0, stmt.getQueryTimeout()); @@ -777,6 +789,7 @@ public void testGetSetQueryTimeout() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testMaxFieldSize() throws Exception { assert stmt.getMaxFieldSize() >= 0; @@ -802,6 +815,7 @@ public void testMaxFieldSize() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testQueryTimeout() throws Exception { assert stmt.getQueryTimeout() == 0 : "Default timeout invalid: " + stmt.getQueryTimeout(); @@ -827,6 +841,7 @@ public void testQueryTimeout() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testWarningsOnClosedStatement() throws Exception { stmt.clearWarnings(); @@ -850,6 +865,7 @@ public void testWarningsOnClosedStatement() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testCursorName() throws Exception { checkNotSupported(new RunnableX() { @Override public void run() throws Exception { @@ -869,6 +885,7 @@ public void testCursorName() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testGetMoreResults() throws Exception { assert !stmt.getMoreResults(); @@ -894,6 +911,7 @@ public void testGetMoreResults() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testGetMoreResults1() throws Exception { assert !stmt.getMoreResults(Statement.CLOSE_CURRENT_RESULT); assert !stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT); @@ -921,8 +939,11 @@ public void testGetMoreResults1() throws Exception { } /** + * Verifies that emty batch can be performed. + * * @throws Exception If failed. */ + @org.junit.Test public void testBatchEmpty() throws Exception { assert conn.getMetaData().supportsBatchUpdates(); @@ -945,6 +966,7 @@ public void testBatchEmpty() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testFetchDirection() throws Exception { assert stmt.getFetchDirection() == ResultSet.FETCH_FORWARD; @@ -978,6 +1000,7 @@ public void testFetchDirection() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testAutogenerated() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @@ -1049,6 +1072,7 @@ public void testAutogenerated() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testCancel() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-5439"); @@ -1095,6 +1119,7 @@ public void testCancel() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testStatementTypeMismatchSelectForCachedQuery() throws Exception { // Put query to cache. stmt.executeQuery("select 1;"); @@ -1116,6 +1141,7 @@ public void testStatementTypeMismatchSelectForCachedQuery() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testStatementTypeMismatchUpdate() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @@ -1224,4 +1250,4 @@ private Person(int id, String firstName, String lastName, int age) { this.age = age; } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStreamingAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStreamingAbstractSelfTest.java index c83977c692d19..70dc7815f8162 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStreamingAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStreamingAbstractSelfTest.java @@ -40,10 +40,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for streaming via thin driver. */ +@RunWith(JUnit4.class) public abstract class JdbcThinStreamingAbstractSelfTest extends JdbcStreamingSelfTest { /** */ protected int batchSize = 17; @@ -96,6 +100,7 @@ public abstract class JdbcThinStreamingAbstractSelfTest extends JdbcStreamingSel /** * @throws Exception if failed. */ + @Test public void testStreamedBatchedInsert() throws Exception { for (int i = 10; i <= 100; i += 10) put(i, nameForId(i * 100)); @@ -132,6 +137,7 @@ public void testStreamedBatchedInsert() throws Exception { /** * @throws SQLException if failed. */ + @Test public void testSimultaneousStreaming() throws Exception { try (Connection anotherConn = createOrdinaryConnection()) { execute(anotherConn, "CREATE TABLE PUBLIC.T(x int primary key, y int) WITH " + @@ -212,6 +218,7 @@ public void testSimultaneousStreaming() throws Exception { /** * */ + @Test public void testStreamingWithMixedStatementTypes() throws Exception { String prepStmtStr = "insert into Person(\"id\", \"name\") values (?, ?)"; @@ -268,6 +275,7 @@ public void testStreamingWithMixedStatementTypes() throws Exception { /** * @throws SQLException if failed. */ + @Test public void testStreamingOffToOn() throws Exception { try (Connection conn = createOrdinaryConnection()) { assertStreamingState(false); @@ -281,6 +289,7 @@ public void testStreamingOffToOn() throws Exception { /** * @throws SQLException if failed. */ + @Test public void testStreamingOffToOff() throws Exception { try (Connection conn = createOrdinaryConnection()) { assertStreamingState(false); @@ -294,6 +303,7 @@ public void testStreamingOffToOff() throws Exception { /** * @throws SQLException if failed. */ + @Test public void testStreamingOnToOff() throws Exception { try (Connection conn = createStreamedConnection(false)) { assertStreamingState(true); @@ -307,6 +317,7 @@ public void testStreamingOnToOff() throws Exception { /** * @throws SQLException if failed. */ + @Test public void testFlush() throws Exception { try (Connection conn = createStreamedConnection(false, 10000)) { assertStreamingState(true); @@ -337,6 +348,7 @@ public void testFlush() throws Exception { /** * @throws SQLException if failed. */ + @Test public void testStreamingReEnabled() throws Exception { try (Connection conn = createStreamedConnection(false, 10000)) { assertStreamingState(true); @@ -381,6 +393,7 @@ public void testStreamingReEnabled() throws Exception { * */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testNonStreamedBatch() { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { @@ -407,6 +420,7 @@ public void testNonStreamedBatch() { * */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testStreamingStatementInTheMiddleOfNonPreparedBatch() { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { @@ -428,6 +442,7 @@ public void testStreamingStatementInTheMiddleOfNonPreparedBatch() { * */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testBatchingSetStreamingStatement() { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { @@ -513,4 +528,4 @@ static final class IndexingWithContext extends IgniteH2Indexing { return super.querySqlFields(schemaName, qry, cliCtx, keepBinary, failOnMultipleStmts, tracker, cancel); } } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTcpIoTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTcpIoTest.java index fc3704b6b7b50..dab2d88d95c8e 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTcpIoTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTcpIoTest.java @@ -32,11 +32,14 @@ import org.apache.ignite.internal.util.HostAndPortRange; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for JdbcThinTcpIo. */ -@SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class JdbcThinTcpIoTest extends GridCommonAbstractTest { /** Server port range. */ private static final int[] SERVER_PORT_RANGE = {59000, 59020}; @@ -116,6 +119,7 @@ private JdbcThinTcpIo createTcpIo(String[] addrs, int port) throws SQLException * @throws SQLException On connection error or reject. * @throws IOException On IO error in handshake. */ + @Test public void testHostWithManyAddresses() throws SQLException, IOException, InterruptedException { CountDownLatch connectionAccepted = new CountDownLatch(1); @@ -142,6 +146,7 @@ public void testHostWithManyAddresses() throws SQLException, IOException, Interr * @throws SQLException On connection error or reject. * @throws IOException On IO error in handshake. */ + @Test public void testExceptionMessage() throws SQLException, IOException { try (ServerSocket sock = createServerSocket(null)) { String[] addrs = {INACCESSIBLE_ADDRESSES[0], INACCESSIBLE_ADDRESSES[1]}; diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsAbstractComplexSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsAbstractComplexSelfTest.java index a17556885fed0..ff9d6b383d443 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsAbstractComplexSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsAbstractComplexSelfTest.java @@ -44,13 +44,18 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test to check various transactional scenarios. */ +@RunWith(JUnit4.class) public abstract class JdbcThinTransactionsAbstractComplexSelfTest extends JdbcThinAbstractSelfTest { /** Client node index. */ - final static int CLI_IDX = 1; + static final int CLI_IDX = 1; /** * Closure to perform ordinary delete after repeatable read. @@ -227,6 +232,7 @@ public abstract class JdbcThinTransactionsAbstractComplexSelfTest extends JdbcTh /** * */ + @Test public void testSingleDmlStatement() throws SQLException { insertPerson(6, "John", "Doe", 2, 2); @@ -237,6 +243,7 @@ public void testSingleDmlStatement() throws SQLException { /** * */ + @Test public void testMultipleDmlStatements() throws SQLException { executeInTransaction(new TransactionClosure() { @Override public void apply(Connection conn) { @@ -259,6 +266,7 @@ public void testMultipleDmlStatements() throws SQLException { /** * */ + @Test public void testBatchDmlStatements() throws SQLException { doBatchedInsert(); @@ -271,7 +279,7 @@ public void testBatchDmlStatements() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testBatchDmlStatementsIntermediateFailure() throws SQLException { insertPerson(6, "John", "Doe", 2, 2); @@ -339,6 +347,8 @@ private void doBatchedInsert() throws SQLException { /** * */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10770") + @Test public void testInsertAndQueryMultipleCaches() throws SQLException { executeInTransaction(new TransactionClosure() { @Override public void apply(Connection conn) { @@ -360,6 +370,7 @@ public void testInsertAndQueryMultipleCaches() throws SQLException { /** * */ + @Test public void testColocatedJoinSelectAndInsertInTransaction() throws SQLException { // We'd like to put some Google into cities with over 1K population which don't have it yet executeInTransaction(new TransactionClosure() { @@ -383,6 +394,7 @@ public void testColocatedJoinSelectAndInsertInTransaction() throws SQLException /** * */ + @Test public void testDistributedJoinSelectAndInsertInTransaction() throws SQLException { try (Connection c = connect("distributedJoins=true")) { // We'd like to put some Google into cities with over 1K population which don't have it yet @@ -408,6 +420,7 @@ public void testDistributedJoinSelectAndInsertInTransaction() throws SQLExceptio /** * */ + @Test public void testInsertFromExpression() throws SQLException { executeInTransaction(new TransactionClosure() { @Override public void apply(Connection conn) { @@ -420,6 +433,7 @@ public void testInsertFromExpression() throws SQLException { /** * */ + @Test public void testAutoRollback() throws SQLException { try (Connection c = connect()) { begin(c); @@ -435,6 +449,7 @@ public void testAutoRollback() throws SQLException { /** * */ + @Test public void testRepeatableReadWithConcurrentDelete() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -446,6 +461,7 @@ public void testRepeatableReadWithConcurrentDelete() throws Exception { /** * */ + @Test public void testRepeatableReadWithConcurrentFastDelete() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -457,6 +473,7 @@ public void testRepeatableReadWithConcurrentFastDelete() throws Exception { /** * */ + @Test public void testRepeatableReadWithConcurrentCacheRemove() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -468,6 +485,7 @@ public void testRepeatableReadWithConcurrentCacheRemove() throws Exception { /** * */ + @Test public void testRepeatableReadAndDeleteWithConcurrentDelete() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -479,6 +497,7 @@ public void testRepeatableReadAndDeleteWithConcurrentDelete() throws Exception { /** * */ + @Test public void testRepeatableReadAndDeleteWithConcurrentFastDelete() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -490,6 +509,7 @@ public void testRepeatableReadAndDeleteWithConcurrentFastDelete() throws Excepti /** * */ + @Test public void testRepeatableReadAndDeleteWithConcurrentCacheRemove() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -501,6 +521,7 @@ public void testRepeatableReadAndDeleteWithConcurrentCacheRemove() throws Except /** * */ + @Test public void testRepeatableReadAndFastDeleteWithConcurrentDelete() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -512,6 +533,7 @@ public void testRepeatableReadAndFastDeleteWithConcurrentDelete() throws Excepti /** * */ + @Test public void testRepeatableReadAndFastDeleteWithConcurrentFastDelete() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -523,6 +545,7 @@ public void testRepeatableReadAndFastDeleteWithConcurrentFastDelete() throws Exc /** * */ + @Test public void testRepeatableReadAndFastDeleteWithConcurrentCacheRemove() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -534,6 +557,7 @@ public void testRepeatableReadAndFastDeleteWithConcurrentCacheRemove() throws Ex /** * */ + @Test public void testRepeatableReadAndDeleteWithConcurrentDeleteAndRollback() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -545,6 +569,7 @@ public void testRepeatableReadAndDeleteWithConcurrentDeleteAndRollback() throws /** * */ + @Test public void testRepeatableReadAndDeleteWithConcurrentFastDeleteAndRollback() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -556,6 +581,7 @@ public void testRepeatableReadAndDeleteWithConcurrentFastDeleteAndRollback() thr /** * */ + @Test public void testRepeatableReadAndDeleteWithConcurrentCacheRemoveAndRollback() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -567,6 +593,7 @@ public void testRepeatableReadAndDeleteWithConcurrentCacheRemoveAndRollback() th /** * */ + @Test public void testRepeatableReadAndFastDeleteWithConcurrentDeleteAndRollback() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -578,6 +605,7 @@ public void testRepeatableReadAndFastDeleteWithConcurrentDeleteAndRollback() thr /** * */ + @Test public void testRepeatableReadAndFastDeleteWithConcurrentFastDeleteAndRollback() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -589,6 +617,7 @@ public void testRepeatableReadAndFastDeleteWithConcurrentFastDeleteAndRollback() /** * */ + @Test public void testRepeatableReadAndFastDeleteWithConcurrentCacheRemoveAndRollback() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -600,6 +629,7 @@ public void testRepeatableReadAndFastDeleteWithConcurrentCacheRemoveAndRollback( /** * */ + @Test public void testRepeatableReadWithConcurrentUpdate() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -611,6 +641,7 @@ public void testRepeatableReadWithConcurrentUpdate() throws Exception { /** * */ + @Test public void testRepeatableReadWithConcurrentCacheReplace() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -628,6 +659,7 @@ public void testRepeatableReadWithConcurrentCacheReplace() throws Exception { /** * */ + @Test public void testRepeatableReadAndUpdateWithConcurrentUpdate() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -639,6 +671,7 @@ public void testRepeatableReadAndUpdateWithConcurrentUpdate() throws Exception { /** * */ + @Test public void testRepeatableReadAndUpdateWithConcurrentCacheReplace() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -656,6 +689,7 @@ public void testRepeatableReadAndUpdateWithConcurrentCacheReplace() throws Excep /** * */ + @Test public void testRepeatableReadAndUpdateWithConcurrentUpdateAndRollback() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -667,6 +701,7 @@ public void testRepeatableReadAndUpdateWithConcurrentUpdateAndRollback() throws /** * */ + @Test public void testRepeatableReadAndUpdateWithConcurrentCacheReplaceAndRollback() throws Exception { doTestRepeatableRead(new IgniteInClosure() { @Override public void apply(Connection conn) { @@ -688,7 +723,6 @@ public void testRepeatableReadAndUpdateWithConcurrentCacheReplaceAndRollback() t * (must yield an exception). * @throws Exception if failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") private void doTestRepeatableRead(final IgniteInClosure concurrentWriteClo, final IgniteInClosure afterReadClo) throws Exception { final CountDownLatch repeatableReadLatch = new CountDownLatch(1); @@ -1016,7 +1050,7 @@ private void insertProduct(Connection c, int id, String name, int companyId) { /** * Person class. */ - private final static class Person { + private static final class Person { /** */ @QuerySqlField public int id; diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsSelfTest.java index 783a8cd69f532..bccca4d369854 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsSelfTest.java @@ -34,20 +34,18 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.query.NestedTxMode; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests to check behavior with transactions on. */ +@RunWith(JUnit4.class) public class JdbcThinTransactionsSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String URL = "jdbc:ignite:thin://127.0.0.1"; @@ -61,12 +59,6 @@ public class JdbcThinTransactionsSelfTest extends JdbcThinAbstractSelfTest { cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME).setNearConfiguration(null)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(new BinaryMarshaller()); cfg.setGridLogger(log = new GridStringLogger()); @@ -124,6 +116,7 @@ private static Connection c(boolean autoCommit, NestedTxMode nestedTxMode) throw /** * */ + @Test public void testTransactionsBeginCommitRollback() throws IgniteCheckedException { final AtomicBoolean stop = new AtomicBoolean(); @@ -160,6 +153,7 @@ public void testTransactionsBeginCommitRollback() throws IgniteCheckedException /** * */ + @Test public void testTransactionsBeginCommitRollbackAutocommit() throws IgniteCheckedException { GridTestUtils.runMultiThreadedAsync(new Runnable() { @Override public void run() { @@ -186,7 +180,7 @@ public void testTransactionsBeginCommitRollbackAutocommit() throws IgniteChecked /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testIgnoreNestedTxAutocommitOff() throws SQLException { try (Connection c = c(false, NestedTxMode.IGNORE)) { doNestedTxStart(c, false); @@ -198,7 +192,7 @@ public void testIgnoreNestedTxAutocommitOff() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCommitNestedTxAutocommitOff() throws SQLException { try (Connection c = c(false, NestedTxMode.COMMIT)) { doNestedTxStart(c, false); @@ -210,7 +204,7 @@ public void testCommitNestedTxAutocommitOff() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testErrorNestedTxAutocommitOff() throws SQLException { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -226,7 +220,7 @@ public void testErrorNestedTxAutocommitOff() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testIgnoreNestedTxAutocommitOn() throws SQLException { try (Connection c = c(true, NestedTxMode.IGNORE)) { doNestedTxStart(c, false); @@ -238,7 +232,7 @@ public void testIgnoreNestedTxAutocommitOn() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCommitNestedTxAutocommitOn() throws SQLException { try (Connection c = c(true, NestedTxMode.COMMIT)) { doNestedTxStart(c, false); @@ -250,7 +244,7 @@ public void testCommitNestedTxAutocommitOn() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testErrorNestedTxAutocommitOn() throws SQLException { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -266,7 +260,7 @@ public void testErrorNestedTxAutocommitOn() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testIgnoreNestedTxAutocommitOffBatched() throws SQLException { try (Connection c = c(false, NestedTxMode.IGNORE)) { doNestedTxStart(c, true); @@ -278,7 +272,7 @@ public void testIgnoreNestedTxAutocommitOffBatched() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCommitNestedTxAutocommitOffBatched() throws SQLException { try (Connection c = c(false, NestedTxMode.COMMIT)) { doNestedTxStart(c, true); @@ -290,7 +284,7 @@ public void testCommitNestedTxAutocommitOffBatched() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testErrorNestedTxAutocommitOffBatched() throws SQLException { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -306,7 +300,7 @@ public void testErrorNestedTxAutocommitOffBatched() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testIgnoreNestedTxAutocommitOnBatched() throws SQLException { try (Connection c = c(true, NestedTxMode.IGNORE)) { doNestedTxStart(c, true); @@ -318,7 +312,7 @@ public void testIgnoreNestedTxAutocommitOnBatched() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCommitNestedTxAutocommitOnBatched() throws SQLException { try (Connection c = c(true, NestedTxMode.COMMIT)) { doNestedTxStart(c, true); @@ -330,7 +324,7 @@ public void testCommitNestedTxAutocommitOnBatched() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testErrorNestedTxAutocommitOnBatched() throws SQLException { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -371,6 +365,7 @@ private void doNestedTxStart(Connection conn, boolean batched) throws SQLExcepti /** * @throws SQLException if failed. */ + @Test public void testAutoCommitSingle() throws SQLException { doTestAutoCommit(false); } @@ -378,6 +373,7 @@ public void testAutoCommitSingle() throws SQLException { /** * @throws SQLException if failed. */ + @Test public void testAutoCommitBatched() throws SQLException { doTestAutoCommit(true); } @@ -422,7 +418,7 @@ private void doTestAutoCommit(boolean batched) throws SQLException { * Test that exception in one of the statements does not kill connection worker altogether. * @throws SQLException if failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testExceptionHandling() throws SQLException { try (Connection c = c(true, NestedTxMode.ERROR)) { try (Statement s = c.createStatement()) { @@ -449,7 +445,7 @@ public void testExceptionHandling() throws SQLException { * Test that exception in one of the statements does not kill connection worker altogether. * @throws SQLException if failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testParsingErrorHasNoSideEffect() throws SQLException { try (Connection c = c(false, NestedTxMode.ERROR)) { try (Statement s = c.createStatement()) { diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsWithMvccEnabledSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsWithMvccEnabledSelfTest.java index 3ee003a2cc711..f1441b55c3f7d 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsWithMvccEnabledSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinTransactionsWithMvccEnabledSelfTest.java @@ -34,20 +34,18 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.query.NestedTxMode; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests to check behavior with transactions on. */ +@RunWith(JUnit4.class) public class JdbcThinTransactionsWithMvccEnabledSelfTest extends JdbcThinAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String URL = "jdbc:ignite:thin://127.0.0.1"; @@ -61,12 +59,6 @@ public class JdbcThinTransactionsWithMvccEnabledSelfTest extends JdbcThinAbstrac cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME).setNearConfiguration(null)); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(new BinaryMarshaller()); cfg.setGridLogger(log = new GridStringLogger()); @@ -123,6 +115,7 @@ private static Connection c(boolean autoCommit, NestedTxMode nestedTxMode) throw /** * */ + @Test public void testTransactionsBeginCommitRollback() throws IgniteCheckedException { final AtomicBoolean stop = new AtomicBoolean(); @@ -159,6 +152,7 @@ public void testTransactionsBeginCommitRollback() throws IgniteCheckedException /** * */ + @Test public void testTransactionsBeginCommitRollbackAutocommit() throws IgniteCheckedException { GridTestUtils.runMultiThreadedAsync(new Runnable() { @Override public void run() { @@ -185,7 +179,7 @@ public void testTransactionsBeginCommitRollbackAutocommit() throws IgniteChecked /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testIgnoreNestedTxAutocommitOff() throws SQLException { try (Connection c = c(false, NestedTxMode.IGNORE)) { doNestedTxStart(c, false); @@ -197,7 +191,7 @@ public void testIgnoreNestedTxAutocommitOff() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCommitNestedTxAutocommitOff() throws SQLException { try (Connection c = c(false, NestedTxMode.COMMIT)) { doNestedTxStart(c, false); @@ -209,7 +203,7 @@ public void testCommitNestedTxAutocommitOff() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testErrorNestedTxAutocommitOff() { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -225,7 +219,7 @@ public void testErrorNestedTxAutocommitOff() { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testIgnoreNestedTxAutocommitOn() throws SQLException { try (Connection c = c(true, NestedTxMode.IGNORE)) { doNestedTxStart(c, false); @@ -237,7 +231,7 @@ public void testIgnoreNestedTxAutocommitOn() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCommitNestedTxAutocommitOn() throws SQLException { try (Connection c = c(true, NestedTxMode.COMMIT)) { doNestedTxStart(c, false); @@ -249,7 +243,7 @@ public void testCommitNestedTxAutocommitOn() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testErrorNestedTxAutocommitOn() { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -265,7 +259,7 @@ public void testErrorNestedTxAutocommitOn() { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testIgnoreNestedTxAutocommitOffBatched() throws SQLException { try (Connection c = c(false, NestedTxMode.IGNORE)) { doNestedTxStart(c, true); @@ -277,7 +271,7 @@ public void testIgnoreNestedTxAutocommitOffBatched() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCommitNestedTxAutocommitOffBatched() throws SQLException { try (Connection c = c(false, NestedTxMode.COMMIT)) { doNestedTxStart(c, true); @@ -289,7 +283,7 @@ public void testCommitNestedTxAutocommitOffBatched() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testErrorNestedTxAutocommitOffBatched() { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -305,7 +299,7 @@ public void testErrorNestedTxAutocommitOffBatched() { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testIgnoreNestedTxAutocommitOnBatched() throws SQLException { try (Connection c = c(true, NestedTxMode.IGNORE)) { doNestedTxStart(c, true); @@ -317,7 +311,7 @@ public void testIgnoreNestedTxAutocommitOnBatched() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCommitNestedTxAutocommitOnBatched() throws SQLException { try (Connection c = c(true, NestedTxMode.COMMIT)) { doNestedTxStart(c, true); @@ -329,7 +323,7 @@ public void testCommitNestedTxAutocommitOnBatched() throws SQLException { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testErrorNestedTxAutocommitOnBatched() { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -370,6 +364,7 @@ private void doNestedTxStart(Connection conn, boolean batched) throws SQLExcepti /** * @throws SQLException if failed. */ + @Test public void testAutoCommitSingle() throws SQLException { doTestAutoCommit(false); } @@ -377,6 +372,7 @@ public void testAutoCommitSingle() throws SQLException { /** * @throws SQLException if failed. */ + @Test public void testAutoCommitBatched() throws SQLException { doTestAutoCommit(true); } @@ -421,7 +417,7 @@ private void doTestAutoCommit(boolean batched) throws SQLException { * Test that exception in one of the statements does not kill connection worker altogether. * @throws SQLException if failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testExceptionHandling() throws SQLException { try (Connection c = c(true, NestedTxMode.ERROR)) { try (Statement s = c.createStatement()) { diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinUpdateStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinUpdateStatementSelfTest.java index f749dbeba7bf2..1f5fd8564b076 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinUpdateStatementSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinUpdateStatementSelfTest.java @@ -21,14 +21,19 @@ import java.util.Arrays; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class JdbcThinUpdateStatementSelfTest extends JdbcThinAbstractUpdateStatementSelfTest { /** * @throws SQLException If failed. */ + @Test public void testExecute() throws SQLException { conn.createStatement().execute("update Person set firstName = 'Jack' where " + "cast(substring(_key, 2, 1) as int) % 2 = 0"); @@ -40,6 +45,7 @@ public void testExecute() throws SQLException { /** * @throws SQLException If failed. */ + @Test public void testExecuteUpdate() throws SQLException { conn.createStatement().executeUpdate("update Person set firstName = 'Jack' where " + "cast(substring(_key, 2, 1) as int) % 2 = 0"); diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/MvccJdbcTransactionFinishOnDeactivatedClusterSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/MvccJdbcTransactionFinishOnDeactivatedClusterSelfTest.java index 8a4fbe3e5c994..dab44bfa38ba4 100644 --- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/MvccJdbcTransactionFinishOnDeactivatedClusterSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/MvccJdbcTransactionFinishOnDeactivatedClusterSelfTest.java @@ -35,8 +35,12 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class MvccJdbcTransactionFinishOnDeactivatedClusterSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { @@ -60,6 +64,7 @@ public class MvccJdbcTransactionFinishOnDeactivatedClusterSelfTest extends GridC /** * @throws Exception If failed. */ + @Test public void testTxCommitAfterDeactivation() throws Exception { checkTxFinishAfterDeactivation(true); } @@ -67,6 +72,7 @@ public void testTxCommitAfterDeactivation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxRollbackAfterDeactivation() throws Exception { checkTxFinishAfterDeactivation(false); } diff --git a/modules/clients/src/test/java/org/apache/ignite/loadtests/client/ClientMarshallerBenchmarkTest.java b/modules/clients/src/test/java/org/apache/ignite/loadtests/client/ClientMarshallerBenchmarkTest.java index 08c2cbe375213..3b9b494523f97 100644 --- a/modules/clients/src/test/java/org/apache/ignite/loadtests/client/ClientMarshallerBenchmarkTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/loadtests/client/ClientMarshallerBenchmarkTest.java @@ -31,12 +31,16 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.marshaller.MarshallerUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest.GridCacheOperation.CAS; /** * Tests basic performance of marshallers. */ +@RunWith(JUnit4.class) public class ClientMarshallerBenchmarkTest extends GridCommonAbstractTest { /** Marshallers to test. */ private GridClientMarshaller[] marshallers; @@ -58,6 +62,7 @@ public ClientMarshallerBenchmarkTest() { /** * @throws Exception If failed. */ + @Test public void testCacheRequestTime() throws Exception { GridClientCacheRequest req = new GridClientCacheRequest(CAS); @@ -162,4 +167,4 @@ private T runMarshallUnmarshalLoop(T obj, int iterCnt, GridClientMarshaller return (T)res; } -} \ No newline at end of file +} diff --git a/modules/clients/src/test/java/org/apache/ignite/loadtests/client/ClientTcpSslLoadTest.java b/modules/clients/src/test/java/org/apache/ignite/loadtests/client/ClientTcpSslLoadTest.java index 669c1104dde78..bd8d57d9482f9 100644 --- a/modules/clients/src/test/java/org/apache/ignite/loadtests/client/ClientTcpSslLoadTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/loadtests/client/ClientTcpSslLoadTest.java @@ -20,10 +20,14 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.internal.client.ClientTcpSslMultiThreadedSelfTest; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Makes a long run to ensure stability and absence of memory leaks. */ +@RunWith(JUnit4.class) public class ClientTcpSslLoadTest extends ClientTcpSslMultiThreadedSelfTest { /** Test duration. */ private static final long TEST_RUN_TIME = 8 * 60 * 60 * 1000; @@ -37,6 +41,7 @@ public class ClientTcpSslLoadTest extends ClientTcpSslMultiThreadedSelfTest { /** * @throws Exception If failed. */ + @Test public void testLongRun() throws Exception { long start = System.currentTimeMillis(); @@ -83,4 +88,4 @@ private void clearCaches() { log.error("Cache clear failed.", e); } } -} \ No newline at end of file +} diff --git a/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java b/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java index c754553ef66e4..f76c9037929e7 100644 --- a/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java +++ b/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java @@ -25,10 +25,15 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAbstractSelfTest; import org.apache.ignite.testsuites.IgniteCloudTestSuite; import org.apache.ignite.testsuites.IgniteIgnore; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * TcpDiscoveryCloudIpFinder test. */ +@RunWith(JUnit4.class) public class TcpDiscoveryCloudIpFinderSelfTest extends TcpDiscoveryIpFinderAbstractSelfTest { /** @@ -40,18 +45,20 @@ public TcpDiscoveryCloudIpFinderSelfTest() throws Exception { // No-op. } - @Override protected void beforeTest() throws Exception { + /** {@inheritDoc} */ + @Override protected void beforeTest() { // No-op. } - /* {@inheritDoc} */ - @Override protected TcpDiscoveryCloudIpFinder ipFinder() throws Exception { + /** {@inheritDoc} */ + @Override protected TcpDiscoveryCloudIpFinder ipFinder() { // No-op. return null; } - /* {@inheritDoc} */ - @Override public void testIpFinder() throws Exception { + /** {@inheritDoc} */ + @Test + @Override public void testIpFinder() { // No-op } @@ -61,6 +68,7 @@ public TcpDiscoveryCloudIpFinderSelfTest() throws Exception { * @throws Exception If any error occurs. */ @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-845") + @Test public void testAmazonWebServices() throws Exception { testCloudProvider("aws-ec2"); } @@ -71,6 +79,7 @@ public void testAmazonWebServices() throws Exception { * @throws Exception If any error occurs. */ @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-1585") + @Test public void testGoogleComputeEngine() throws Exception { testCloudProvider("google-compute-engine"); } @@ -80,9 +89,9 @@ public void testGoogleComputeEngine() throws Exception { * * @throws Exception If any error occurs. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9444") + @Test public void testRackspace() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-9444"); - testCloudProvider("rackspace-cloudservers-us"); } @@ -123,4 +132,4 @@ private void testCloudProvider(String provider) throws Exception { assert addresses.size() == ipFinder.getRegisteredAddresses().size(); } -} \ No newline at end of file +} diff --git a/modules/cloud/src/test/java/org/apache/ignite/testsuites/IgniteCloudTestSuite.java b/modules/cloud/src/test/java/org/apache/ignite/testsuites/IgniteCloudTestSuite.java index 632cddc6c7bbc..5be6d3b45449b 100644 --- a/modules/cloud/src/test/java/org/apache/ignite/testsuites/IgniteCloudTestSuite.java +++ b/modules/cloud/src/test/java/org/apache/ignite/testsuites/IgniteCloudTestSuite.java @@ -19,23 +19,26 @@ import java.util.Collection; import java.util.LinkedList; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinderSelfTest; import org.apache.ignite.testframework.IgniteTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Ignite Cloud integration test. */ -public class IgniteCloudTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCloudTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new IgniteTestSuite("Cloud Integration Test Suite"); // Cloud Nodes IP finder. - suite.addTestSuite(TcpDiscoveryCloudIpFinderSelfTest.class); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryCloudIpFinderSelfTest.class)); return suite; } @@ -51,7 +54,7 @@ public static String getAccessKey(String provider) { String key = System.getenv("test." + provider + ".access.key"); assert key != null : "Environment variable 'test." + provider + ".access.key' is not set"; - + return key; } @@ -111,4 +114,4 @@ public static Collection getRegions(String provider) { return list; } -} \ No newline at end of file +} diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java index 7492e51977b11..ca2dcdc2b98f7 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java @@ -43,7 +43,7 @@ import org.apache.ignite.internal.GridDirectMap; import org.apache.ignite.internal.GridDirectTransient; import org.apache.ignite.internal.IgniteCodeGeneratingFail; -import org.apache.ignite.internal.processors.cache.mvcc.msg.MvccRecoveryFinishedMessage; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; @@ -116,6 +116,7 @@ public class MessageCodeGenerator { TYPES.put(BitSet.class, MessageCollectionItemType.BIT_SET); TYPES.put(UUID.class, MessageCollectionItemType.UUID); TYPES.put(IgniteUuid.class, MessageCollectionItemType.IGNITE_UUID); + TYPES.put(AffinityTopologyVersion.class, MessageCollectionItemType.AFFINITY_TOPOLOGY_VERSION); } /** @@ -169,9 +170,7 @@ public static void main(String[] args) throws Exception { // gen.generateAll(true); - gen.generateAndWrite(MvccRecoveryFinishedMessage.class); - -// gen.generateAndWrite(GridNearAtomicUpdateRequest.class); +// gen.generateAndWrite(GridCacheMessage.class); // gen.generateAndWrite(GridMessageCollection.class); // gen.generateAndWrite(DataStreamerEntry.class); @@ -663,6 +662,8 @@ else if (type == UUID.class) returnFalseIfFailed(write, "writer.writeUuid", field, getExpr); else if (type == IgniteUuid.class) returnFalseIfFailed(write, "writer.writeIgniteUuid", field, getExpr); + else if (type == AffinityTopologyVersion.class) + returnFalseIfFailed(write, "writer.writeAffinityTopologyVersion", field, getExpr); else if (type.isEnum()) { String arg = getExpr + " != null ? (byte)" + getExpr + ".ordinal() : -1"; @@ -745,6 +746,8 @@ else if (type == UUID.class) returnFalseIfReadFailed(name, "reader.readUuid", setExpr, field); else if (type == IgniteUuid.class) returnFalseIfReadFailed(name, "reader.readIgniteUuid", setExpr, field); + else if (type == AffinityTopologyVersion.class) + returnFalseIfReadFailed(name, "reader.readAffinityTopologyVersion", setExpr, field); else if (type.isEnum()) { String loc = name + "Ord"; diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/PdsWithTtlCompatibilityTest.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/PdsWithTtlCompatibilityTest.java index 946caddb5f203..ffb05bb2e2102 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/PdsWithTtlCompatibilityTest.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/PdsWithTtlCompatibilityTest.java @@ -43,6 +43,9 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test PendingTree upgrading to per-partition basis. Test fill cache with persistence enabled and with ExpirePolicy @@ -51,6 +54,7 @@ * Note: Test for ignite-2.3 version will always fails due to entry ttl update fails with assertion on checkpoint lock * check. */ +@RunWith(JUnit4.class) public class PdsWithTtlCompatibilityTest extends IgnitePersistenceCompatibilityAbstractTest { /** */ static final String TEST_CACHE_NAME = PdsWithTtlCompatibilityTest.class.getSimpleName(); @@ -84,6 +88,7 @@ public class PdsWithTtlCompatibilityTest extends IgnitePersistenceCompatibilityA * * @throws Exception If failed. */ + @Test public void testNodeStartByOldVersionPersistenceData_2_1() throws Exception { doTestStartupWithOldVersion("2.1.0"); } diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/FoldersReuseCompatibilityTest.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/FoldersReuseCompatibilityTest.java index e04f39f99321d..a667c15267375 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/FoldersReuseCompatibilityTest.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/FoldersReuseCompatibilityTest.java @@ -36,12 +36,16 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.persistence.filename.PdsConsistentIdProcessor.parseSubFolderName; /** * Test for new and old style persistent storage folders generation and compatible startup of current ignite version */ +@RunWith(JUnit4.class) public class FoldersReuseCompatibilityTest extends IgnitePersistenceCompatibilityAbstractTest { /** Cache name for test. */ private static final String CACHE_NAME = "dummy"; @@ -80,6 +84,7 @@ public void ignored_testFoldersReuseCompatibility_2_3() throws Exception { * * @throws Exception if failed. */ + @Test public void testFoldersReuseCompatibility_2_2() throws Exception { runFoldersReuse("2.2.0"); } @@ -90,6 +95,7 @@ public void testFoldersReuseCompatibility_2_2() throws Exception { * * @throws Exception if failed. */ + @Test public void testFoldersReuseCompatibility_2_1() throws Exception { runFoldersReuse("2.1.0"); } diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/MigratingToWalV2SerializerWithCompactionTest.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/MigratingToWalV2SerializerWithCompactionTest.java index d4c58f8f4b3c5..84d0cfa610e63 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/MigratingToWalV2SerializerWithCompactionTest.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/MigratingToWalV2SerializerWithCompactionTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Saves data using previous version of ignite and then load this data using actual version */ +@RunWith(JUnit4.class) public class MigratingToWalV2SerializerWithCompactionTest extends IgnitePersistenceCompatibilityAbstractTest { /** */ private static final String TEST_CACHE_NAME = MigratingToWalV2SerializerWithCompactionTest.class.getSimpleName(); @@ -78,6 +82,7 @@ public class MigratingToWalV2SerializerWithCompactionTest extends IgnitePersiste * * @throws Exception If failed. */ + @Test public void testCompactingOldWalFiles() throws Exception { doTestStartupWithOldVersion("2.3.0"); } diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/PersistenceBasicCompatibilityTest.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/PersistenceBasicCompatibilityTest.java index f27caa34a2843..8088dda909bb0 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/PersistenceBasicCompatibilityTest.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/PersistenceBasicCompatibilityTest.java @@ -38,10 +38,14 @@ import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfTest; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Saves data using previous version of ignite and then load this data using actual version. */ +@RunWith(JUnit4.class) public class PersistenceBasicCompatibilityTest extends IgnitePersistenceCompatibilityAbstractTest { /** */ protected static final String TEST_CACHE_NAME = PersistenceBasicCompatibilityTest.class.getSimpleName(); @@ -76,6 +80,7 @@ public class PersistenceBasicCompatibilityTest extends IgnitePersistenceCompatib * * @throws Exception If failed. */ + @Test public void testNodeStartByOldVersionPersistenceData_2_2() throws Exception { doTestStartupWithOldVersion("2.2.0"); } @@ -85,6 +90,7 @@ public void testNodeStartByOldVersionPersistenceData_2_2() throws Exception { * * @throws Exception If failed. */ + @Test public void testNodeStartByOldVersionPersistenceData_2_1() throws Exception { doTestStartupWithOldVersion("2.1.0"); } @@ -94,10 +100,41 @@ public void testNodeStartByOldVersionPersistenceData_2_1() throws Exception { * * @throws Exception If failed. */ + @Test public void testNodeStartByOldVersionPersistenceData_2_3() throws Exception { doTestStartupWithOldVersion("2.3.0"); } + /** + * Tests opportunity to read data from previous Ignite DB version. + * + * @throws Exception If failed. + */ + @Test + public void testNodeStartByOldVersionPersistenceData_2_4() throws Exception { + doTestStartupWithOldVersion("2.4.0"); + } + + /** + * Tests opportunity to read data from previous Ignite DB version. + * + * @throws Exception If failed. + */ + @Test + public void testNodeStartByOldVersionPersistenceData_2_5() throws Exception { + doTestStartupWithOldVersion("2.5.0"); + } + + /** + * Tests opportunity to read data from previous Ignite DB version. + * + * @throws Exception If failed. + */ + @Test + public void testNodeStartByOldVersionPersistenceData_2_6() throws Exception { + doTestStartupWithOldVersion("2.6.0"); + } + /** * Tests opportunity to read data from previous Ignite DB version. * diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/Dependency.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/Dependency.java index 56da0e982bec8..1316203d9f504 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/Dependency.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/Dependency.java @@ -17,70 +17,76 @@ package org.apache.ignite.compatibility.testframework.junits; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Module dependency: Should be filtered out from current test classpath for separate JVM classpath. */ public class Dependency { + /** Default value of group id. */ + private static final String DEFAULT_GROUP_ID = "org.apache.ignite"; + /** Local module name. Folder name where module is located. */ - private String locModuleName; + private final String locModuleName; - /** Group name. Null means ignite default group name. */ - @Nullable - private String groupName; + /** Group id. */ + private final String groupId; - /** Artifact name (artifact ID) without group name. */ - private String artifactName; + /** Artifact id. */ + private final String artifactId; - /** Version. Null means default Ignite version is to be used. May be used for 3rd party dependencies. */ - @Nullable - private String version; + /** Version. {@code null} means default Ignite version is to be used. May be used for 3rd party dependencies. */ + @Nullable private final String ver; - /** Test flag. Test jar should have {@code true} value. Default is {@code false}. */ - private boolean test; + /** Test flag. Test jar should have {@code true} value. */ + private final boolean test; /** - * Creates dependency. + * Creates dependency with {@link #DEFAULT_GROUP_ID} as group id. * * @param locModuleName Local module name. Folder name where module is located. - * @param artifactName Artifact name (artifact ID) without group name. - * @param test Test flag. Test jar should have {@code true} value. Default is {@code false}. + * @param artifactId Artifact id. + * @param test Test flag. Test jar should have {@code true} value. */ - public Dependency(String locModuleName, String artifactName, boolean test) { - this.locModuleName = locModuleName; - this.artifactName = artifactName; - this.test = test; + public Dependency(String locModuleName, String artifactId, boolean test) { + this(locModuleName, artifactId, null, test); } /** - * Creates dependency. + * Creates dependency with {@link #DEFAULT_GROUP_ID} as group id. * * @param locModuleName Local module name. Folder name where module is located. - * @param artifactName Artifact name (artifact ID) without group name. + * @param artifactId Artifact id. + * @param ver Version, {@code null} means default Ignite version is to be used. + * @param test Test flag. Test jar should have {@code true} value. */ - public Dependency(String locModuleName, String artifactName) { - this.locModuleName = locModuleName; - this.artifactName = artifactName; + public Dependency(String locModuleName, String artifactId, String ver, boolean test) { + this(locModuleName, DEFAULT_GROUP_ID, artifactId, ver, test); } /** + * Creates dependency with given parameters. + * * @param locModuleName Local module name. Folder name where module is located. - * @param grpName Group name. Null means ignite default group name. - * @param artifactName Artifact name (artifact ID) without group na - * @param version Version. Null means default Ignite version is to be used. M + * @param groupId Group id. + * @param artifactId Artifact id. + * @param ver Dependency version, {@code null} means default Ignite version is to be used. + * @param test Test flag. Test jar should have {@code true} value. */ - public Dependency(String locModuleName, @Nullable String grpName, String artifactName, @Nullable String version) { + public Dependency(@NotNull String locModuleName, @NotNull String groupId, @NotNull String artifactId, + @Nullable String ver, boolean test) { this.locModuleName = locModuleName; - this.groupName = grpName; - this.artifactName = artifactName; - this.version = version; + this.groupId = groupId; + this.artifactId = artifactId; + this.ver = ver; + this.test = test; } /** - * @return path based on local module name to exclude from classpath + * @return Template of sources path based on local module name. */ - public String localPathTemplate() { + public String sourcePathTemplate() { return "modules/" + locModuleName + "/target/" + @@ -88,30 +94,37 @@ public String localPathTemplate() { } /** - * @return {@link #artifactName} + * @return Template of artifact's path in Maven repository. + */ + public String artifactPathTemplate() { + return "repository/" + groupId.replaceAll("\\.", "/") + "/" + artifactId; + } + + /** + * @return Dependency artifact id. */ - public String artifactName() { - return artifactName; + public String artifactId() { + return artifactId; } /** - * @return classifier or {@code} null depending on {@link #test} flag + * @return Classifier or {@code null} depending on {@link #test} flag. */ @Nullable public String classifier() { return test ? "tests" : null; } /** - * @return {@link #version} + * @return Dependency version. */ @Nullable public String version() { - return version; + return ver; } /** - * @return {@link #groupName} + * @return Dependency group id. */ - @Nullable public String groupName() { - return groupName; + public String groupId() { + return groupId; } } diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java index 2301717b2068b..b0e4001d3bc80 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/junits/IgniteCompatibilityAbstractTest.java @@ -21,11 +21,12 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; +import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteLogger; import org.apache.ignite.compatibility.testframework.junits.logger.ListenedGridTestLog4jLogger; @@ -168,7 +169,7 @@ protected IgniteEx startGrid(final String igniteInstanceName, final String ver, final Collection dependencies = getDependencies(ver); - Set excluded = dependencies.stream().map(Dependency::localPathTemplate).collect(Collectors.toSet()); + Set excluded = getExcluded(ver, dependencies); StringBuilder pathBuilder = new StringBuilder(); @@ -180,11 +181,10 @@ protected IgniteEx startGrid(final String igniteInstanceName, final String ver, } for (Dependency dependency : dependencies) { - final String artifactVer = dependency.version() != null ? dependency.version() : ver; - final String grpName = dependency.groupName() != null ? dependency.groupName() : "org.apache.ignite"; + final String artifactVer = Optional.ofNullable(dependency.version()).orElse(ver); - String pathToArtifact = MavenUtils.getPathToIgniteArtifact(grpName, dependency.artifactName(), - artifactVer, dependency.classifier()); + String pathToArtifact = MavenUtils.getPathToIgniteArtifact(dependency.groupId(), + dependency.artifactId(), artifactVer, dependency.classifier()); pathBuilder.append(pathToArtifact).append(File.pathSeparator); } @@ -240,12 +240,35 @@ protected long getNodeJoinTimeout() { @NotNull protected Collection getDependencies(String igniteVer) { final Collection dependencies = new ArrayList<>(); - dependencies.add(new Dependency("core", "ignite-core")); + dependencies.add(new Dependency("core", "ignite-core", false)); dependencies.add(new Dependency("core", "ignite-core", true)); return dependencies; } + /** + * These dependencies will not be translated from current code dependencies into separate node's classpath. + * + * Include here all dependencies which will be set up manually, leave all version independent dependencies. + * + * @param ver Ignite version. + * @param dependencies Dependencies to filter. + * @return Set of paths to exclude. + */ + protected Set getExcluded(String ver, Collection dependencies) { + Set excluded = new HashSet<>(); + + for (Dependency dependency : dependencies) { + excluded.add(dependency.sourcePathTemplate()); + excluded.add(dependency.artifactPathTemplate()); + } + + // Just to exclude indexing module + excluded.add("indexing"); + + return excluded; + } + /** * Allows to setup JVM arguments for standalone JVM * diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java index 7eb3131a3fa01..a05cfd95c2840 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java @@ -46,23 +46,24 @@ public class MavenUtils { private static boolean useGgRepo; /** - * Gets a path to an artifact with given version and groupId=org.apache.ignite and artifactId={@code artifactName}. + * Gets a path to an artifact with given version and groupId=org.apache.ignite and artifactId={@code artifactId}. *
* At first, artifact is looked for in the Maven local repository, if it isn't exists there, it will be downloaded * and stored via Maven. *
- * @param groupName group name, e.g. 'org.apache.ignite'. + * + * @param groupId group name, e.g. 'org.apache.ignite'. * @param ver Version of ignite or 3rd party library artifact. * @param classifier Artifact classifier. * @return Path to the artifact. * @throws Exception In case of an error. * @see #getPathToArtifact(String) */ - public static String getPathToIgniteArtifact(@NotNull String groupName, - @NotNull String artifactName, @NotNull String ver, + public static String getPathToIgniteArtifact(@NotNull String groupId, + @NotNull String artifactId, @NotNull String ver, @Nullable String classifier) throws Exception { - String artifact = groupName + - ":" + artifactName + ":" + ver; + String artifact = groupId + + ":" + artifactId + ":" + ver; if (classifier != null) artifact += ":jar:" + classifier; @@ -213,6 +214,6 @@ private static String buildMvnCommand() { if (m2Home == null) return "mvn"; - return m2Home + "/bin/mvn" ; + return m2Home + "/bin/mvn"; } } diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java index f6dd73606d16d..12ef3d091c6bd 100644 --- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java +++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.compatibility.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.compatibility.PdsWithTtlCompatibilityTest; import org.apache.ignite.compatibility.persistence.FoldersReuseCompatibilityTest; @@ -29,18 +30,17 @@ public class IgniteCompatibilityBasicTestSuite { /** * @return Test suite. - * @throws Exception In case of an error. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Compatibility Basic Test Suite"); - suite.addTestSuite(PersistenceBasicCompatibilityTest.class); + suite.addTest(new JUnit4TestAdapter(PersistenceBasicCompatibilityTest.class)); - suite.addTestSuite(PdsWithTtlCompatibilityTest.class); + suite.addTest(new JUnit4TestAdapter(PdsWithTtlCompatibilityTest.class)); - suite.addTestSuite(FoldersReuseCompatibilityTest.class); + suite.addTest(new JUnit4TestAdapter(FoldersReuseCompatibilityTest.class)); - suite.addTestSuite(MigratingToWalV2SerializerWithCompactionTest.class); + suite.addTest(new JUnit4TestAdapter(MigratingToWalV2SerializerWithCompactionTest.class)); return suite; } diff --git a/modules/core/src/main/java/META-INF/NOTICE b/modules/core/src/main/java/META-INF/NOTICE index 4c99a05109185..0bae4345e6446 100644 --- a/modules/core/src/main/java/META-INF/NOTICE +++ b/modules/core/src/main/java/META-INF/NOTICE @@ -1,5 +1,5 @@ Apache Ignite -Copyright 2018 The Apache Software Foundation +Copyright 2019 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index 8479420910f16..395c8f89a8692 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -441,9 +441,9 @@ public IgniteFuture localLoadCacheAsync(@Nullable IgniteBiPredicate public void localEvict(Collection keys); /** - * Peeks at in-memory cached value using default optional peek mode. + * Peeks at a value in the local storage using an optional peek mode. *

- * This method will not load value from any persistent store or from a remote node. + * This method will not load a value from the configured {@link CacheStore} or from a remote node. *

Transactions

* This method does not participate in any transactions. * @@ -1516,7 +1516,7 @@ public IgniteFuture>> invokeAllAsync(Set lostPartitions(); @@ -1531,4 +1531,51 @@ public IgniteFuture>> invokeAllAsync(Set + * This is useful for fast iteration over cache partition data if persistence is enabled and the data is "cold". + *

+ * Preload will reduce available amount of page memory for subsequent operations and may lead to earlier page + * replacement. + *

+ * This method is irrelevant for in-memory caches. Calling this method on an in-memory cache will result in + * exception. + * + * @param partition Partition. + */ + public void preloadPartition(int partition); + + /** + * Efficiently preloads cache partition into page memory. + *

+ * This is useful for fast iteration over cache partition data if persistence is enabled and the data is "cold". + *

+ * Preload will reduce available amount of page memory for subsequent operations and may lead to earlier page + * replacement. + *

+ * This method is irrelevant for in-memory caches. Calling this method on an in-memory cache will result in + * exception. + * + * @param partition Partition. + * @return A future representing pending completion of the partition preloading. + */ + public IgniteFuture preloadPartitionAsync(int partition); + + /** + * Efficiently preloads cache partition into page memory if it exists on the local node. + *

+ * This is useful for fast iteration over cache partition data if persistence is enabled and the data is "cold". + *

+ * Preload will reduce available amount of page memory for subsequent operations and may lead to earlier page + * replacement. + *

+ * This method is irrelevant for in-memory caches. Calling this method on an in-memory cache will result in + * exception. + * + * @param partition Partition. + * @return {@code True} if partition was preloaded, {@code false} if it doesn't belong to local node. + */ + public boolean localPreloadPartition(int partition); } diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCacheRestartingException.java b/modules/core/src/main/java/org/apache/ignite/IgniteCacheRestartingException.java index a3a749070cec1..1dbfc67dc69dd 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCacheRestartingException.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCacheRestartingException.java @@ -18,6 +18,7 @@ package org.apache.ignite; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.lang.IgniteFuture; import org.jetbrains.annotations.Nullable; @@ -29,26 +30,34 @@ public class IgniteCacheRestartingException extends IgniteException { private static final long serialVersionUID = 0L; /** */ - private final IgniteFuture restartFut; + private final transient IgniteFuture restartFut; + + /** + * @param cacheName Error message. + */ + public IgniteCacheRestartingException(String cacheName) { + this(null, cacheName, null); + } /** * @param restartFut Restart future. - * @param msg Error message. + * @param cacheName Error message. */ - public IgniteCacheRestartingException(IgniteFuture restartFut, String msg) { - this(restartFut, msg, null); + public IgniteCacheRestartingException(IgniteFuture restartFut, String cacheName) { + this(restartFut, cacheName, null); } /** * @param restartFut Restart future. - * @param msg Error message. + * @param cacheName Cache name what is restarting. * @param cause Optional nested exception (can be {@code null}). */ public IgniteCacheRestartingException( IgniteFuture restartFut, - String msg, - @Nullable Throwable cause) { - super(msg, cause); + String cacheName, + @Nullable Throwable cause + ) { + super("Cache is restarting:" + cacheName + ", you could wait restart completion with restartFuture", cause); this.restartFut = restartFut; } diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index 52d6a363851f5..3a65f5d42f5b7 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -259,6 +259,13 @@ public final class IgniteSystemProperties { */ public static final String IGNITE_TX_DEADLOCK_DETECTION_TIMEOUT = "IGNITE_TX_DEADLOCK_DETECTION_TIMEOUT"; + /** + * System property to enable pending transaction tracker. + * Affects impact of {@link IgniteSystemProperties#IGNITE_DISABLE_WAL_DURING_REBALANCING} property: + * if this property is set, WAL anyway won't be disabled during rebalancing triggered by baseline topology change. + */ + public static final String IGNITE_PENDING_TX_TRACKER_ENABLED = "IGNITE_PENDING_TX_TRACKER_ENABLED"; + /** * System property to override multicast group taken from configuration. * Used for testing purposes. @@ -899,6 +906,11 @@ public final class IgniteSystemProperties { */ public static final String IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE = "IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE"; + /** + * Count of WAL compressor worker threads. Default value is 4. + */ + public static final String IGNITE_WAL_COMPRESSOR_WORKER_THREAD_CNT = "IGNITE_WAL_COMPRESSOR_WORKER_THREAD_CNT"; + /** * Whenever read load balancing is enabled, that means 'get' requests will be distributed between primary and backup * nodes if it is possible and {@link CacheConfiguration#readFromBackup} is {@code true}. @@ -997,6 +1009,17 @@ public final class IgniteSystemProperties { */ public static final String IGNITE_REUSE_MEMORY_ON_DEACTIVATE = "IGNITE_REUSE_MEMORY_ON_DEACTIVATE"; + /** + * Timeout for waiting schema update if schema was not found for last accepted version. + */ + public static final String IGNITE_WAIT_SCHEMA_UPDATE = "IGNITE_WAIT_SCHEMA_UPDATE"; + + /** + * System property to override {@link CacheConfiguration#rebalanceThrottle} configuration property for all caches. + * {@code 0} by default, which means that override is disabled. + */ + public static final String IGNITE_REBALANCE_THROTTLE_OVERRIDE = "IGNITE_REBALANCE_THROTTLE_OVERRIDE"; + /** * Maximum inactivity period for system worker in milliseconds. When this value is exceeded, worker is considered * blocked with consequent critical failure handler invocation. @@ -1008,6 +1031,40 @@ public final class IgniteSystemProperties { */ public static final String IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT = "IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT"; + /** + * Enables start caches in parallel. + * + * Default is {@code true}. + */ + public static final String IGNITE_ALLOW_START_CACHES_IN_PARALLEL = "IGNITE_ALLOW_START_CACHES_IN_PARALLEL"; + + /** For test purposes only. Force Mvcc mode. */ + public static final String IGNITE_FORCE_MVCC_MODE_IN_TESTS = "IGNITE_FORCE_MVCC_MODE_IN_TESTS"; + + /** + * Allows to log additional information about all restored partitions after binary and logical recovery phases. + * + * Default is {@code true}. + */ + public static final String IGNITE_RECOVERY_VERBOSE_LOGGING = "IGNITE_RECOVERY_VERBOSE_LOGGING"; + + /** + * Disables cache interceptor triggering in case of conflicts. + * + * Default is {@code false}. + */ + public static final String IGNITE_DISABLE_TRIGGERING_CACHE_INTERCEPTOR_ON_CONFLICT = "IGNITE_DISABLE_TRIGGERING_CACHE_INTERCEPTOR_ON_CONFLICT"; + + /** + * When set to {@code true}, cache metrics are not included into the discovery metrics update message (in this + * case message contains only cluster metrics). By default cache metrics are included into the message and + * calculated each time the message is sent. + *

+ * Cache metrics sending can also be turned off by disabling statistics per each cache, but in this case some cache + * metrics will be unavailable via JMX too. + */ + public static final String IGNITE_DISCOVERY_DISABLE_CACHE_METRICS_UPDATE = "IGNITE_DISCOVERY_DISABLE_CACHE_METRICS_UPDATE"; + /** * Enforces singleton. */ diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityKeyMapped.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityKeyMapped.java index 8b19338571805..e7e9eba1ccfd7 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityKeyMapped.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityKeyMapped.java @@ -91,8 +91,8 @@ * is otherwise known as {@code Collocation Of Computations And Data}. In this case, * {@code @AffinityKeyMapped} annotation allows to specify a routing affinity key for a * {@link org.apache.ignite.compute.ComputeJob} or any other grid computation, such as {@link Runnable}, - * {@link Callable}, or {@link org.apache.ignite.lang.IgniteClosure}. It should be attached to a method or - * field that provides affinity key for the computation. Only one annotation per class is allowed. + * {@link Callable}, or {@link org.apache.ignite.lang.IgniteClosure}. It should be attached to a field + * that provides affinity key for the computation. Only one annotation per class is allowed. * Whenever such annotation is detected, then {@link org.apache.ignite.spi.loadbalancing.LoadBalancingSpi} * will be bypassed, and computation will be routed to the grid node where the specified affinity key is cached. *

diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java index e4d6d0ad36837..0d1444b7eac5c 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java @@ -213,7 +213,16 @@ public CacheEntryEventSerializableFilter getRemoteFilter() { return (ContinuousQuery)super.setPageSize(pageSize); } - /** {@inheritDoc} */ + /** + * Sets whether this query should be executed on local node only. + * + * Note: backup event queues are not kept for local continuous queries. It may lead to loss of notifications in case + * of node failures. Use {@link ContinuousQuery#setRemoteFilterFactory(Factory)} to register cache event listeners + * on all cache nodes, if delivery guarantee is required. + * + * @param loc Local flag. + * @return {@code this} for chaining. + */ @Override public ContinuousQuery setLocal(boolean loc) { return (ContinuousQuery)super.setLocal(loc); } diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java index 4e12b8ca03ecc..6945f25fe7d4a 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java @@ -273,7 +273,9 @@ public boolean isDistributedJoins() { * * @param replicatedOnly The query contains only replicated tables. * @return {@code this} For chaining. + * @deprecated No longer used as of Apache Ignite 2.8. */ + @Deprecated public SqlFieldsQuery setReplicatedOnly(boolean replicatedOnly) { this.replicatedOnly = replicatedOnly; @@ -284,7 +286,9 @@ public SqlFieldsQuery setReplicatedOnly(boolean replicatedOnly) { * Check is the query contains only replicated tables. * * @return {@code true} If the query contains only replicated tables. + * @deprecated No longer used as of Apache Ignite 2.8. */ + @Deprecated public boolean isReplicatedOnly() { return replicatedOnly; } diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java index a5994b92c0924..5b0667c1f06bf 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java @@ -238,7 +238,9 @@ public boolean isDistributedJoins() { * * @param replicatedOnly The query contains only replicated tables. * @return {@code this} For chaining. + * @deprecated No longer used as of Apache Ignite 2.8. */ + @Deprecated public SqlQuery setReplicatedOnly(boolean replicatedOnly) { this.replicatedOnly = replicatedOnly; @@ -249,7 +251,9 @@ public SqlQuery setReplicatedOnly(boolean replicatedOnly) { * Check is the query contains only replicated tables. * * @return {@code true} If the query contains only replicated tables. + * @deprecated No longer used as of Apache Ignite 2.8. */ + @Deprecated public boolean isReplicatedOnly() { return replicatedOnly; } diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java index 795fcfde9ce8e..05be893392b02 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java @@ -50,9 +50,7 @@ import org.apache.ignite.cache.store.CacheStore; import org.apache.ignite.cache.store.CacheStoreSessionListener; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.spi.encryption.EncryptionSpi; import org.apache.ignite.internal.binary.BinaryContext; -import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi; import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.A; @@ -60,6 +58,8 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.plugin.CachePluginConfiguration; +import org.apache.ignite.spi.encryption.EncryptionSpi; +import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi; import org.jetbrains.annotations.Nullable; /** @@ -318,7 +318,7 @@ public class CacheConfiguration extends MutableConfiguration { private long rebalanceThrottle = DFLT_REBALANCE_THROTTLE; /** */ - private CacheInterceptor interceptor; + private CacheInterceptor interceptor; /** */ private Class[] sqlFuncCls; @@ -1630,9 +1630,8 @@ public CacheConfiguration setMaxQueryIteratorsCount(int maxQryIterCnt) { * * @return Cache interceptor. */ - @SuppressWarnings({"unchecked"}) @Nullable public CacheInterceptor getInterceptor() { - return (CacheInterceptor)interceptor; + return interceptor; } /** diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java index e7ccaf556ccf7..a04fc53f681aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java @@ -21,6 +21,7 @@ import java.lang.management.ManagementFactory; import java.util.Map; import java.util.UUID; +import java.util.zip.Deflater; import javax.cache.configuration.Factory; import javax.cache.event.CacheEntryListener; import javax.cache.expiry.ExpiryPolicy; @@ -40,7 +41,6 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.compute.ComputeJob; import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.spi.encryption.EncryptionSpi; import org.apache.ignite.events.Event; import org.apache.ignite.events.EventType; import org.apache.ignite.failure.FailureHandler; @@ -69,6 +69,7 @@ import org.apache.ignite.spi.deployment.local.LocalDeploymentSpi; import org.apache.ignite.spi.discovery.DiscoverySpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.encryption.EncryptionSpi; import org.apache.ignite.spi.eventstorage.EventStorageSpi; import org.apache.ignite.spi.eventstorage.NoopEventStorageSpi; import org.apache.ignite.spi.failover.FailoverSpi; @@ -119,6 +120,9 @@ public class IgniteConfiguration { /** Default maximum timeout to wait for network responses in milliseconds (value is {@code 5,000ms}). */ public static final long DFLT_NETWORK_TIMEOUT = 5000; + /** Default compression level for network messages (value is Deflater.BEST_SPEED. */ + public static final int DFLT_NETWORK_COMPRESSION = Deflater.BEST_SPEED; + /** Default interval between message send retries. */ public static final long DFLT_SEND_RETRY_DELAY = 1000; @@ -302,6 +306,9 @@ public class IgniteConfiguration { /** Maximum network requests timeout. */ private long netTimeout = DFLT_NETWORK_TIMEOUT; + /** Compression level for network binary messages. */ + private int netCompressionLevel = DFLT_NETWORK_COMPRESSION; + /** Interval between message send retries. */ private long sndRetryDelay = DFLT_SEND_RETRY_DELAY; @@ -1478,6 +1485,29 @@ public IgniteConfiguration setNetworkTimeout(long netTimeout) { return this; } + /** + * Compression level of internal network messages. + *

+ * If not provided, then default value + * Deflater.BEST_SPEED is used. + * + * @return Network messages default compression level. + */ + public int getNetworkCompressionLevel() { + return netCompressionLevel; + } + + /** + * Compression level for internal network messages. + *

+ * If not provided, then default value + * Deflater.BEST_SPEED is used. + * + */ + public void setNetworkCompressionLevel(int netCompressionLevel) { + this.netCompressionLevel = netCompressionLevel; + } + /** * Interval in milliseconds between message send retries. *

diff --git a/modules/core/src/main/java/org/apache/ignite/events/EventType.java b/modules/core/src/main/java/org/apache/ignite/events/EventType.java index 485e5671e6423..97017d638dd0a 100644 --- a/modules/core/src/main/java/org/apache/ignite/events/EventType.java +++ b/modules/core/src/main/java/org/apache/ignite/events/EventType.java @@ -244,6 +244,16 @@ public interface EventType { */ public static final int EVT_TASK_REDUCED = 25; + /** + * Built-in event type: Visor or Web Console management task started. + *

+ * NOTE: all types in range from 1 to 1000 are reserved for + * internal Ignite events and should not be used by user-defined events. + * + * @see TaskEvent + */ + public static final int EVT_MANAGEMENT_TASK_STARTED = 26; + /** * Built-in event type: non-task class deployed. *

diff --git a/modules/core/src/main/java/org/apache/ignite/failure/AbstractFailureHandler.java b/modules/core/src/main/java/org/apache/ignite/failure/AbstractFailureHandler.java index d3685c002a1fc..79b1f8f6ea591 100644 --- a/modules/core/src/main/java/org/apache/ignite/failure/AbstractFailureHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/failure/AbstractFailureHandler.java @@ -18,11 +18,13 @@ package org.apache.ignite.failure; import java.util.Collections; +import java.util.EnumSet; import java.util.Set; import org.apache.ignite.Ignite; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; +import static org.apache.ignite.failure.FailureType.SYSTEM_CRITICAL_OPERATION_TIMEOUT; import static org.apache.ignite.failure.FailureType.SYSTEM_WORKER_BLOCKED; /** @@ -33,7 +35,8 @@ public abstract class AbstractFailureHandler implements FailureHandler { /** */ @GridToStringInclude - private Set ignoredFailureTypes = Collections.singleton(SYSTEM_WORKER_BLOCKED); + private Set ignoredFailureTypes = + Collections.unmodifiableSet(EnumSet.of(SYSTEM_WORKER_BLOCKED, SYSTEM_CRITICAL_OPERATION_TIMEOUT)); /** * Sets failure types that must be ignored by failure handler. diff --git a/modules/core/src/main/java/org/apache/ignite/failure/FailureType.java b/modules/core/src/main/java/org/apache/ignite/failure/FailureType.java index fbd5529fc8792..114e432e1ef73 100644 --- a/modules/core/src/main/java/org/apache/ignite/failure/FailureType.java +++ b/modules/core/src/main/java/org/apache/ignite/failure/FailureType.java @@ -31,5 +31,8 @@ public enum FailureType { SYSTEM_WORKER_BLOCKED, /** Critical error - error which leads to the system's inoperability. */ - CRITICAL_ERROR + CRITICAL_ERROR, + + /** System-critical operation has been timed out. */ + SYSTEM_CRITICAL_OPERATION_TIMEOUT } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java index aaa69eaff7190..ac3a87336fc9f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java @@ -201,4 +201,4 @@ public boolean system() { @Override public String toString() { return S.toString(GridJobCancelRequest.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java index 4357d1da07dce..ebfeb0153ffdc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java @@ -664,7 +664,7 @@ public AffinityTopologyVersion getTopVer() { writer.incrementState(); case 24: - if (!writer.writeMessage("topVer", topVer)) + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -885,7 +885,7 @@ public AffinityTopologyVersion getTopVer() { reader.incrementState(); case 24: - topVer = reader.readMessage("topVer"); + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java index 312435e922750..f052edf07d446 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java @@ -282,7 +282,7 @@ public AffinityTopologyVersion getRetryTopologyVersion() { writer.incrementState(); case 6: - if (!writer.writeMessage("retry", retry)) + if (!writer.writeAffinityTopologyVersion("retry", retry)) return false; writer.incrementState(); @@ -355,7 +355,7 @@ public AffinityTopologyVersion getRetryTopologyVersion() { reader.incrementState(); case 6: - retry = reader.readMessage("retry"); + retry = reader.readAffinityTopologyVersion("retry"); if (!reader.isLastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java index 8a11cef33aa21..d743a355f8d8e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java @@ -161,4 +161,4 @@ public byte[] topicBytes() { @Override public String toString() { return S.toString(GridJobSiblingsRequest.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java index 3911446d2b86b..dc59ab5f3057c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java @@ -141,4 +141,4 @@ public void unmarshalSiblings(Marshaller marsh) throws IgniteCheckedException { @Override public String toString() { return S.toString(GridJobSiblingsResponse.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java index 970b8e7150ac5..a43312cc8ac6a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java @@ -698,4 +698,9 @@ public interface GridKernalContext extends Iterable { * @return Default uncaught exception handler used by thread pools. */ public Thread.UncaughtExceptionHandler uncaughtExceptionHandler(); + + /** + * @return {@code True} if node is in recovery mode (before join to topology). + */ + public boolean recoveryMode(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java index f23e65042c0da..08090f2bff1f3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java @@ -415,6 +415,9 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable /** Failure processor. */ private FailureProcessor failureProc; + /** Recovery mode flag. Flag is set to {@code false} when discovery manager started. */ + private boolean recoveryMode = true; + /** * No-arg constructor is required by externalization. */ @@ -1180,6 +1183,18 @@ public Thread.UncaughtExceptionHandler uncaughtExceptionHandler() { return hnd; } + /** {@inheritDoc} */ + @Override public boolean recoveryMode() { + return recoveryMode; + } + + /** + * @param recoveryMode Recovery mode. + */ + public void recoveryMode(boolean recoveryMode) { + this.recoveryMode = recoveryMode; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridKernalContextImpl.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java index 273d0a777a468..71c318b537dd5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java @@ -124,4 +124,4 @@ public IgniteUuid sessionId() { @Override public String toString() { return S.toString(GridTaskCancelRequest.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java index dbac893189e38..576392e097fc3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java @@ -189,4 +189,4 @@ public IgniteUuid getJobId() { @Override public String toString() { return S.toString(GridTaskSessionRequest.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index c6ec9be1e1848..6ff0c86eea08c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -102,7 +102,6 @@ import org.apache.ignite.internal.binary.BinaryUtils; import org.apache.ignite.internal.cluster.ClusterGroupAdapter; import org.apache.ignite.internal.cluster.IgniteClusterEx; -import org.apache.ignite.internal.managers.encryption.GridEncryptionManager; import org.apache.ignite.internal.managers.GridManager; import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager; import org.apache.ignite.internal.managers.collision.GridCollisionManager; @@ -110,6 +109,7 @@ import org.apache.ignite.internal.managers.deployment.GridDeploymentManager; import org.apache.ignite.internal.managers.discovery.DiscoveryLocalJoinData; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; +import org.apache.ignite.internal.managers.encryption.GridEncryptionManager; import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager; import org.apache.ignite.internal.managers.failover.GridFailoverManager; import org.apache.ignite.internal.managers.indexing.GridIndexingManager; @@ -129,7 +129,6 @@ import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl; import org.apache.ignite.internal.processors.cache.mvcc.MvccProcessorImpl; import org.apache.ignite.internal.processors.cache.persistence.DataRegion; -import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.DataStorageMXBeanImpl; import org.apache.ignite.internal.processors.cache.persistence.filename.PdsConsistentIdProcessor; import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor; @@ -202,9 +201,9 @@ import org.apache.ignite.marshaller.MarshallerExclusions; import org.apache.ignite.marshaller.MarshallerUtils; import org.apache.ignite.marshaller.jdk.JdkMarshaller; -import org.apache.ignite.mxbean.FailureHandlingMxBean; import org.apache.ignite.mxbean.ClusterMetricsMXBean; import org.apache.ignite.mxbean.DataStorageMXBean; +import org.apache.ignite.mxbean.FailureHandlingMxBean; import org.apache.ignite.mxbean.IgniteMXBean; import org.apache.ignite.mxbean.StripedExecutorMXBean; import org.apache.ignite.mxbean.ThreadPoolMXBean; @@ -274,6 +273,7 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SPI_CLASS; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_TX_CONFIG; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_USER_NAME; +import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_VALIDATE_CACHE_REQUESTS; import static org.apache.ignite.internal.IgniteVersionUtils.ACK_VER_STR; import static org.apache.ignite.internal.IgniteVersionUtils.BUILD_TSTAMP_STR; import static org.apache.ignite.internal.IgniteVersionUtils.COPYRIGHT; @@ -1046,6 +1046,10 @@ public void start( fillNodeAttributes(clusterProc.updateNotifierEnabled()); ctx.cache().context().database().notifyMetaStorageSubscribersOnReadyForRead(); + + ctx.cache().context().database().startMemoryRestore(ctx); + + ctx.recoveryMode(false); } catch (Throwable e) { U.error( @@ -1085,6 +1089,14 @@ public void start( IgniteInternalFuture transitionWaitFut = joinData.transitionWaitFuture(); + // Notify discovery manager the first to make sure that topology is discovered. + // Active flag is not used in managers, so it is safe to pass true. + ctx.discovery().onKernalStart(true); + + // Notify IO manager the second so further components can send and receive messages. + // Must notify the IO manager before transition state await to make sure IO connection can be established. + ctx.io().onKernalStart(true); + boolean active; if (transitionWaitFut != null) { @@ -1098,12 +1110,6 @@ public void start( else active = joinData.active(); - // Notify discovery manager the first to make sure that topology is discovered. - ctx.discovery().onKernalStart(active); - - // Notify IO manager the second so further components can send and receive messages. - ctx.io().onKernalStart(active); - boolean recon = false; // Callbacks. @@ -1561,6 +1567,8 @@ private void fillNodeAttributes(boolean notifyEnabled) throws IgniteCheckedExcep add(ATTR_CONSISTENCY_CHECK_SKIPPED, getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK)); + add(ATTR_VALIDATE_CACHE_REQUESTS, Boolean.TRUE); + if (cfg.getConsistentId() != null) add(ATTR_NODE_CONSISTENT_ID, cfg.getConsistentId()); @@ -2101,12 +2109,7 @@ private void ackNodeMetrics(DecimalFormat dblFmt, pdsUsedSummary += pdsUsed; - // TODO https://issues.apache.org/jira/browse/IGNITE-9455 - // TODO Print actual value for meta store region when issue will be fixed. - boolean metastore = - GridCacheDatabaseSharedManager.METASTORE_DATA_REGION_NAME.equals(region.config().getName()); - - String pdsUsedSize = metastore ? "unknown" : dblFmt.format(pdsUsedMBytes) + "MB"; + String pdsUsedSize = dblFmt.format(pdsUsedMBytes) + "MB"; pdsRegionsInfo.append(" ^-- ") .append(region.config().getName()).append(" region") @@ -2581,19 +2584,25 @@ private void ackSpis() { * */ private void ackRebalanceConfiguration() throws IgniteCheckedException { - if (cfg.getSystemThreadPoolSize() <= cfg.getRebalanceThreadPoolSize()) - throw new IgniteCheckedException("Rebalance thread pool size exceed or equals System thread pool size. " + - "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start."); - - if (cfg.getRebalanceThreadPoolSize() < 1) - throw new IgniteCheckedException("Rebalance thread pool size minimal allowed value is 1. " + - "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start."); - - for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { - if (ccfg.getRebalanceBatchesPrefetchCount() < 1) - throw new IgniteCheckedException("Rebalance batches prefetch count minimal allowed value is 1. " + - "Change CacheConfiguration.rebalanceBatchesPrefetchCount property before next start. " + - "[cache=" + ccfg.getName() + "]"); + if (cfg.isClientMode()) { + if (cfg.getRebalanceThreadPoolSize() != IgniteConfiguration.DFLT_REBALANCE_THREAD_POOL_SIZE) + U.warn(log, "Setting the rebalance pool size has no effect on the client mode"); + } + else { + if (cfg.getSystemThreadPoolSize() <= cfg.getRebalanceThreadPoolSize()) + throw new IgniteCheckedException("Rebalance thread pool size exceed or equals System thread pool size. " + + "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start."); + + if (cfg.getRebalanceThreadPoolSize() < 1) + throw new IgniteCheckedException("Rebalance thread pool size minimal allowed value is 1. " + + "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start."); + + for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { + if (ccfg.getRebalanceBatchesPrefetchCount() < 1) + throw new IgniteCheckedException("Rebalance batches prefetch count minimal allowed value is 1. " + + "Change CacheConfiguration.rebalanceBatchesPrefetchCount property before next start. " + + "[cache=" + ccfg.getName() + "]"); + } } } @@ -2997,7 +3006,10 @@ public IgniteInternalCache getCache(String name) { @Override public IgniteBiTuple, Boolean> getOrCreateCache0( CacheConfiguration cacheCfg, boolean sql) { A.notNull(cacheCfg, "cacheCfg"); - CU.validateNewCacheName(cacheCfg.getName()); + + String cacheName = cacheCfg.getName(); + + CU.validateNewCacheName(cacheName); guard(); @@ -3006,18 +3018,22 @@ public IgniteInternalCache getCache(String name) { Boolean res = false; - if (ctx.cache().cache(cacheCfg.getName()) == null) { + IgniteCacheProxy cache = ctx.cache().publicJCache(cacheName, false, true); + + if (cache == null) { res = sql ? ctx.cache().dynamicStartSqlCache(cacheCfg).get() : ctx.cache().dynamicStartCache(cacheCfg, - cacheCfg.getName(), + cacheName, null, false, true, true).get(); - } - return new IgniteBiTuple<>((IgniteCache)ctx.cache().publicJCache(cacheCfg.getName()), res); + return new IgniteBiTuple<>(ctx.cache().publicJCache(cacheName), res); + } + else + return new IgniteBiTuple<>(cache, res); } catch (IgniteCheckedException e) { throw CU.convertToCacheException(e); @@ -3265,7 +3281,7 @@ public IgniteInternalFuture destroyCacheAsync(String cacheName, boolean try { checkClusterState(); - return ctx.cache().dynamicDestroyCache(cacheName, sql, checkThreadTx, false); + return ctx.cache().dynamicDestroyCache(cacheName, sql, checkThreadTx, false, null); } finally { unguard(); @@ -3285,7 +3301,7 @@ public IgniteInternalFuture destroyCachesAsync(Collection cacheNames, try { checkClusterState(); - return ctx.cache().dynamicDestroyCaches(cacheNames, checkThreadTx, false); + return ctx.cache().dynamicDestroyCaches(cacheNames, checkThreadTx); } finally { unguard(); @@ -3301,10 +3317,15 @@ public IgniteInternalFuture destroyCachesAsync(Collection cacheNames, try { checkClusterState(); - if (ctx.cache().cache(cacheName) == null) + IgniteCacheProxy cache = ctx.cache().publicJCache(cacheName, false, true); + + if (cache == null) { ctx.cache().getOrCreateFromTemplate(cacheName, true).get(); - return ctx.cache().publicJCache(cacheName); + return ctx.cache().publicJCache(cacheName); + } + + return cache; } catch (IgniteCheckedException e) { throw CU.convertToCacheException(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java index 4ca4f1b40585a..3945adf33d38d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java @@ -205,6 +205,9 @@ public final class IgniteNodeAttributes { /** Internal attribute name constant. */ public static final String ATTR_DYNAMIC_CACHE_START_ROLLBACK_SUPPORTED = ATTR_PREFIX + ".dynamic.cache.start.rollback.supported"; + /** Internal attribute indicates that incoming cache requests should be validated on primary node as well. */ + public static final String ATTR_VALIDATE_CACHE_REQUESTS = ATTR_CACHE + ".validate.cache.requests"; + /** * Enforces singleton. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java index 8a459522e70b2..d12560e813a72 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java @@ -37,6 +37,9 @@ public class IgniteVersionUtils { /** Build timestamp in seconds. */ public static final long BUILD_TSTAMP; + /** Build timestamp string property value. */ + private static final String BUILD_TSTAMP_FROM_PROPERTY; + /** Revision hash. */ public static final String REV_HASH_STR; @@ -47,7 +50,7 @@ public class IgniteVersionUtils { public static final String ACK_VER_STR; /** Copyright blurb. */ - public static final String COPYRIGHT = "2018 Copyright(C) Apache Software Foundation"; + public static final String COPYRIGHT; /** * Static initializer. @@ -58,10 +61,18 @@ public class IgniteVersionUtils { .replace(".b", "-b") .replace(".final", "-final"); - BUILD_TSTAMP = Long.valueOf(IgniteProperties.get("ignite.build")); + BUILD_TSTAMP_FROM_PROPERTY = IgniteProperties.get("ignite.build"); + + //Development ignite.properties file contains ignite.build = 0, so we will add the check for it. + BUILD_TSTAMP = !BUILD_TSTAMP_FROM_PROPERTY.isEmpty() && Long.parseLong(BUILD_TSTAMP_FROM_PROPERTY) != 0 + ? Long.parseLong(BUILD_TSTAMP_FROM_PROPERTY) : System.currentTimeMillis() / 1000; + BUILD_TSTAMP_STR = new SimpleDateFormat("yyyyMMdd").format(new Date(BUILD_TSTAMP * 1000)); + COPYRIGHT = BUILD_TSTAMP_STR.substring(0, 4) + " Copyright(C) Apache Software Foundation"; + REV_HASH_STR = IgniteProperties.get("ignite.revision"); + RELEASE_DATE_STR = IgniteProperties.get("ignite.rel.date"); String rev = REV_HASH_STR.length() > 8 ? REV_HASH_STR.substring(0, 8) : REV_HASH_STR; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java index 1e56cde9e052a..d3dde71d22d5e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java @@ -1157,9 +1157,11 @@ private static T2 start0(GridStartContext startCtx try { grid.start(startCtx); } - catch (IgniteInterruptedCheckedException e) { - if (grid.starterThreadInterrupted) - Thread.interrupted(); + catch (Exception e) { + if (X.hasCause(e, IgniteInterruptedCheckedException.class, InterruptedException.class)) { + if (grid.starterThreadInterrupted) + Thread.interrupted(); + } throw e; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java index 9bad1eacb772e..7d5bbda4100ad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java @@ -576,10 +576,10 @@ public Iterator>> currentMappings() { } /** - * @return custom marshaller mapping files directory. Used for standalone WAL iteration + * @return {@code True} if marshaller context is initialized. */ - @Nullable public File getMarshallerMappingFileStoreDir() { - return marshallerMappingFileStoreDir; + public boolean initialized() { + return fileStore != null; } /** @@ -656,4 +656,4 @@ static final class CombinedMap extends AbstractMap return userMap.containsKey(key) || sysMap.containsKey(key); } } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/TransactionsMXBeanImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/TransactionsMXBeanImpl.java index 16738de12343d..a8a3c886617b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/TransactionsMXBeanImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/TransactionsMXBeanImpl.java @@ -72,12 +72,8 @@ else if ("servers".equals(prj)) VisorTxSortOrder sortOrder = null; - if (order != null) { - if ("DURATION".equals(order)) - sortOrder = VisorTxSortOrder.DURATION; - else if ("SIZE".equals(order)) - sortOrder = VisorTxSortOrder.SIZE; - } + if (order != null) + sortOrder = VisorTxSortOrder.valueOf(order.toUpperCase()); VisorTxTaskArg arg = new VisorTxTaskArg(kill ? VisorTxOperation.KILL : VisorTxOperation.LIST, limit, minDuration == null ? null : minDuration * 1000, minSize, null, proj, consIds, xid, lbRegex, sortOrder); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java index 87c4f3e18d8fc..7d138a30e6d82 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.UUID; import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.internal.UnregisteredBinaryTypeException; import org.apache.ignite.internal.UnregisteredClassException; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.typedef.F; @@ -156,7 +157,7 @@ public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectExce write0(obj, writer); } catch (Exception ex) { - if (ex instanceof UnregisteredClassException) + if (ex instanceof UnregisteredClassException || ex instanceof UnregisteredBinaryTypeException) throw ex; if (S.INCLUDE_SENSITIVE && !F.isEmpty(name)) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataHandler.java index 85ab1372f49f2..3652d98aa50a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataHandler.java @@ -20,13 +20,15 @@ import java.util.Collection; import org.apache.ignite.binary.BinaryObjectException; import org.apache.ignite.binary.BinaryType; +import org.apache.ignite.internal.processors.cache.binary.MetadataUpdateProposedMessage; /** - * Binary meta data handler. + * Binary metadata handler. */ public interface BinaryMetadataHandler { /** - * Adds meta data. + * Adds a new or updates an existing metadata to the latest version. + * See {@link MetadataUpdateProposedMessage} javadoc for detailed protocol description. * * @param typeId Type ID. * @param meta Metadata. @@ -36,7 +38,7 @@ public interface BinaryMetadataHandler { public void addMeta(int typeId, BinaryType meta, boolean failIfUnregistered) throws BinaryObjectException; /** - * Gets meta data for provided type ID. + * Gets metadata for provided type ID. * * @param typeId Type ID. * @return Metadata. @@ -45,7 +47,7 @@ public interface BinaryMetadataHandler { public BinaryType metadata(int typeId) throws BinaryObjectException; /** - * Gets unwrapped meta data for provided type ID. + * Gets unwrapped metadata for provided type ID. * * @param typeId Type ID. * @return Metadata. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java index 920a296856213..f213ad916cc51 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java @@ -32,6 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; /** @@ -201,12 +202,17 @@ private String toString(BinaryReaderHandles ctx, IdentityHashMap AUX_COMMANDS = new HashSet<>(); static { AUX_COMMANDS.add(CMD_HELP); + AUX_COMMANDS.add(CMD_HOST); AUX_COMMANDS.add(CMD_PORT); + AUX_COMMANDS.add(CMD_PASSWORD); AUX_COMMANDS.add(CMD_USER); + AUX_COMMANDS.add(CMD_AUTO_CONFIRMATION); + AUX_COMMANDS.add(CMD_PING_INTERVAL); AUX_COMMANDS.add(CMD_PING_TIMEOUT); + + AUX_COMMANDS.add(CMD_SSL_PROTOCOL); + AUX_COMMANDS.add(CMD_SSL_KEY_ALGORITHM); + AUX_COMMANDS.add(CMD_SSL_CIPHER_SUITES); + + AUX_COMMANDS.add(CMD_KEYSTORE); + AUX_COMMANDS.add(CMD_KEYSTORE_PASSWORD); + AUX_COMMANDS.add(CMD_KEYSTORE_TYPE); + + AUX_COMMANDS.add(CMD_TRUSTSTORE); + AUX_COMMANDS.add(CMD_TRUSTSTORE_PASSWORD); + AUX_COMMANDS.add(CMD_TRUSTSTORE_TYPE); } /** Broadcast uuid. */ @@ -205,10 +291,10 @@ public class CommandHandler { private static final String BASELINE_SET_VERSION = "version"; /** Parameter name for validate_indexes command. */ - static final String VI_CHECK_FIRST = "checkFirst"; + static final String VI_CHECK_FIRST = "--check-first"; /** Parameter name for validate_indexes command. */ - static final String VI_CHECK_THROUGH = "checkThrough"; + static final String VI_CHECK_THROUGH = "--check-through"; /** */ static final String WAL_PRINT = "print"; @@ -247,37 +333,61 @@ public class CommandHandler { private static final String VALIDATE_INDEXES_TASK = "org.apache.ignite.internal.visor.verify.VisorValidateIndexesTask"; /** */ - private static final String TX_LIMIT = "limit"; + private static final String TX_LIMIT = "--limit"; + + /** */ + private static final String TX_ORDER = "--order"; + + /** */ + private static final String TX_SERVERS = "--servers"; + + /** */ + private static final String TX_CLIENTS = "--clients"; /** */ - private static final String TX_ORDER = "order"; + private static final String TX_DURATION = "--min-duration"; /** */ - public static final String CMD_TX_ORDER_START_TIME = "START_TIME"; + private static final String TX_SIZE = "--min-size"; /** */ - private static final String TX_SERVERS = "servers"; + private static final String TX_LABEL = "--label"; /** */ - private static final String TX_CLIENTS = "clients"; + private static final String TX_NODES = "--nodes"; /** */ - private static final String TX_DURATION = "minDuration"; + private static final String TX_XID = "--xid"; /** */ - private static final String TX_SIZE = "minSize"; + private static final String TX_KILL = "--kill"; /** */ - private static final String TX_LABEL = "label"; + private static final String OUTPUT_FORMAT = "--output-format"; /** */ - private static final String TX_NODES = "nodes"; + private static final String CONFIG = "--config"; + + /** Utility name. */ + private static final String UTILITY_NAME = "control.sh"; + + /** Common options. */ + private static final String COMMON_OPTIONS = j(" ", getCommonOptions()); + + /** Utility name with common options. */ + private static final String UTILITY_NAME_WITH_COMMON_OPTIONS = j(" ", UTILITY_NAME, COMMON_OPTIONS); + + /** Indent for help output. */ + private static final String INDENT = " "; /** */ - private static final String TX_XID = "xid"; + private static final String NULL = "null"; /** */ - private static final String TX_KILL = "kill"; + private static final String NODE_ID = "nodeId"; + + /** */ + private static final String OP_NODE_ID = op(NODE_ID); /** */ private Iterator argsIt; @@ -294,6 +404,34 @@ public class CommandHandler { /** Check if experimental commands are enabled. Default {@code false}. */ private final boolean enableExperimental = IgniteSystemProperties.getBoolean(IGNITE_ENABLE_EXPERIMENTAL_COMMAND, false); + /** + * Creates list of common utility options. + * + * @return List of common utility options. + */ + private static List getCommonOptions() { + List list = new ArrayList<>(32); + + list.add(op(CMD_HOST, "HOST_OR_IP")); + list.add(op(CMD_PORT, "PORT")); + list.add(op(CMD_USER, "USER")); + list.add(op(CMD_PASSWORD, "PASSWORD")); + list.add(op(CMD_PING_INTERVAL, "PING_INTERVAL")); + list.add(op(CMD_PING_TIMEOUT, "PING_TIMEOUT")); + + list.add(op(CMD_SSL_PROTOCOL, "SSL_PROTOCOL[, SSL_PROTOCOL_2, ..., SSL_PROTOCOL_N]")); + list.add(op(CMD_SSL_CIPHER_SUITES, "SSL_CIPHER_1[, SSL_CIPHER_2, ..., SSL_CIPHER_N]")); + list.add(op(CMD_SSL_KEY_ALGORITHM, "SSL_KEY_ALGORITHM")); + list.add(op(CMD_KEYSTORE_TYPE, "KEYSTORE_TYPE")); + list.add(op(CMD_KEYSTORE, "KEYSTORE_PATH")); + list.add(op(CMD_KEYSTORE_PASSWORD, "KEYSTORE_PASSWORD")); + list.add(op(CMD_TRUSTSTORE_TYPE, "TRUSTSTORE_TYPE")); + list.add(op(CMD_TRUSTSTORE, "TRUSTSTORE_PATH")); + list.add(op(CMD_TRUSTSTORE_PASSWORD, "TRUSTSTORE_PASSWORD")); + + return list; + } + /** * Output specified string to console. * @@ -303,6 +441,57 @@ private void log(String s) { System.out.println(s); } + /** + * Adds indent to begin of object's string representation. + * + * @param o Input object. + * @return Indented string. + */ + private static String i(Object o) { + return i(o, 1); + } + + /** + * Adds specified indents to begin of object's string representation. + * + * @param o Input object. + * @param indentCnt Number of indents. + * @return Indented string. + */ + private static String i(Object o, int indentCnt) { + assert indentCnt >= 0; + + String s = o == null ? null : o.toString(); + + switch (indentCnt) { + case 0: + return s; + + case 1: + return INDENT + s; + + default: + int sLen = s == null ? 4 : s.length(); + + SB sb = new SB(sLen + indentCnt * INDENT.length()); + + for (int i = 0; i < indentCnt; i++) + sb.a(INDENT); + + return sb.a(s).toString(); + } + } + + /** + * Format and output specified string to console. + * + * @param format A format string as described in Format string syntax. + * @param args Arguments referenced by the format specifiers in the format string. + */ + private void log(String format, Object... args) { + System.out.printf(format, args); + } + /** * Provides a prompt, then reads a single line of text from the console. * @@ -319,7 +508,7 @@ private String readLine(String prompt) { * Output empty line. */ private void nl() { - System.out.println(""); + System.out.println(); } /** @@ -490,6 +679,41 @@ private R executeTask(GridClient client, Class> return executeTaskByNameOnNode(client, taskCls.getName(), taskArgs, null); } + /** + * @param client Client. + * @return List of hosts. + */ + private Stream> listHosts(GridClient client) throws GridClientException { + return client.compute() + .nodes(GridClientNode::connectable) + .stream() + .flatMap(node -> Stream.concat( + node.tcpAddresses() == null ? Stream.empty() : node.tcpAddresses().stream(), + node.tcpHostNames() == null ? Stream.empty() : node.tcpHostNames().stream() + ) + .map(addr -> new IgniteBiTuple<>(node, addr + ":" + node.tcpPort()))); + } + + /** + * @param client Client. + * @return List of hosts. + */ + private Stream>> listHostsByClientNode( + GridClient client + ) throws GridClientException { + return client.compute().nodes(GridClientNode::connectable).stream() + .map( + node -> new IgniteBiTuple<>( + node, + Stream.concat( + node.tcpAddresses() == null ? Stream.empty() : node.tcpAddresses().stream(), + node.tcpHostNames() == null ? Stream.empty() : node.tcpHostNames().stream() + ) + .map(addr -> addr + ":" + node.tcpPort()).collect(Collectors.toList()) + ) + ); + } + /** * @param client Client * @param taskClsName Task class name. @@ -498,7 +722,12 @@ private R executeTask(GridClient client, Class> * @return Task result. * @throws GridClientException If failed to execute task. */ - private R executeTaskByNameOnNode(GridClient client, String taskClsName, Object taskArgs, UUID nodeId + @SuppressWarnings("unchecked") + private R executeTaskByNameOnNode( + GridClient client, + String taskClsName, + Object taskArgs, + UUID nodeId ) throws GridClientException { GridClientCompute compute = client.compute(); @@ -518,22 +747,34 @@ private R executeTaskByNameOnNode(GridClient client, String taskClsName, Obj GridClientNode node = null; if (nodeId == null) { - Collection nodes = compute.nodes(GridClientNode::connectable); - // Prefer node from connect string. - String origAddr = clientCfg.getServers().iterator().next(); + final String cfgAddr = clientCfg.getServers().iterator().next(); - for (GridClientNode clientNode : nodes) { - Iterator it = F.concat(clientNode.tcpAddresses().iterator(), clientNode.tcpHostNames().iterator()); + String[] parts = cfgAddr.split(":"); - while (it.hasNext()) { - if (origAddr.equals(it.next() + ":" + clientNode.tcpPort())) { - node = clientNode; + if (DFLT_HOST.equals(parts[0])) { + InetAddress addr; - break; - } + try { + addr = IgniteUtils.getLocalHost(); } + catch (IOException e) { + throw new GridClientException("Can't get localhost name.", e); + } + + if (addr.isLoopbackAddress()) + throw new GridClientException("Can't find localhost name."); + + String origAddr = addr.getHostName() + ":" + parts[1]; + + node = listHosts(client).filter(tuple -> origAddr.equals(tuple.get2())).findFirst().map(IgniteBiTuple::get1).orElse(null); + + if (node == null) + node = listHostsByClientNode(client).filter(tuple -> tuple.get2().size() == 1 && cfgAddr.equals(tuple.get2().get(0))). + findFirst().map(IgniteBiTuple::get1).orElse(null); } + else + node = listHosts(client).filter(tuple -> cfgAddr.equals(tuple.get2())).findFirst().map(IgniteBiTuple::get1).orElse(null); // Otherwise choose random node. if (node == null) @@ -613,23 +854,26 @@ private void cache(GridClient client, CacheArguments cacheArgs) throws Throwable } } - /** - * - */ + /** */ private void printCacheHelp() { - log("--cache subcommand allows to do the following operations:"); - - usage(" Show information about caches, groups or sequences that match a regex:", CACHE, " list regexPattern [groups|seq] [nodeId]"); - usage(" Show hot keys that are point of contention for multiple transactions:", CACHE, " contention minQueueSize [nodeId] [maxPrint]"); - usage(" Verify partition counters and hashes between primary and backups on idle cluster:", CACHE, " idle_verify [--dump] [--skipZeros] [cache1,...,cacheN]"); - usage(" Validate custom indexes on idle cluster:", CACHE, " validate_indexes [cache1,...,cacheN] [nodeId] [checkFirst|checkThrough]"); - usage(" Collect partition distribution information:", CACHE, " distribution nodeId|null [cacheName1,...,cacheNameN] [--user-attributes attributeName1[,...,attributeNameN]]"); - usage(" Reset lost partitions:", CACHE, " reset_lost_partitions cacheName1[,...,cacheNameN]"); - - log(" If [nodeId] is not specified, contention and validate_indexes commands will be broadcasted to all server nodes."); - log(" Another commands where [nodeId] is optional will run on a random server node."); - log(" checkFirst numeric parameter for validate_indexes specifies number of first K keys to be validated."); - log(" checkThrough numeric parameter for validate_indexes allows to check each Kth key."); + log(i("The '" + CACHE + " subcommand' is used to get information about and perform actions with caches. The command has the following syntax:")); + nl(); + log(i(UTILITY_NAME_WITH_COMMON_OPTIONS + " " + CACHE + "[subcommand] ")); + nl(); + log(i("The subcommands that take " + OP_NODE_ID + " as an argument ('" + LIST + "', '" + CONTENTION + "' and '" + VALIDATE_INDEXES + "') will be executed on the given node or on all server nodes if the option is not specified. Other commands will run on a random server node.")); + nl(); + nl(); + log(i("Subcommands:")); + + usageCache(LIST, "regexPattern", op(or("groups", "seq")), OP_NODE_ID, op(CONFIG), op(OUTPUT_FORMAT, MULTI_LINE)); + usageCache(CONTENTION, "minQueueSize", OP_NODE_ID, op("maxPrint")); + usageCache(IDLE_VERIFY, op(CMD_DUMP), op(CMD_SKIP_ZEROS), op(or(CMD_EXCLUDE_CACHES + " cache1,...,cacheN", + op(CACHE_FILTER, or(CacheFilterEnum.ALL.toString(), CacheFilterEnum.SYSTEM.toString(), + CacheFilterEnum.PERSISTENT.toString(), CacheFilterEnum.NOT_PERSISTENT.toString())), "cache1,...," + + "cacheN"))); + usageCache(VALIDATE_INDEXES, "[cache1,...,cacheN]", OP_NODE_ID, op(or(VI_CHECK_FIRST + " N", VI_CHECK_THROUGH + " K"))); + usageCache(DISTRIBUTION, or(NODE_ID, NULL), "[cacheName1,...,cacheNameN]", op(CMD_USER_ATTRIBUTES, "attrName1,...,attrNameN")); + usageCache(RESET_LOST_PARTITIONS, "cacheName1,...,cacheNameN"); nl(); } @@ -650,7 +894,7 @@ private void cacheContention(GridClient client, CacheArguments cacheArgs) throws log("Contention check failed on nodes:"); for (Map.Entry e : res.exceptions().entrySet()) { - log("Node ID = " + e.getKey()); + log("Node ID: " + e.getKey()); log("Exception message:"); log(e.getValue().getMessage()); @@ -669,42 +913,55 @@ private void cacheContention(GridClient client, CacheArguments cacheArgs) throws private void cacheValidateIndexes(GridClient client, CacheArguments cacheArgs) throws GridClientException { VisorValidateIndexesTaskArg taskArg = new VisorValidateIndexesTaskArg( cacheArgs.caches(), + cacheArgs.nodeId() != null ? Collections.singleton(cacheArgs.nodeId()) : null, cacheArgs.checkFirst(), cacheArgs.checkThrough() ); - UUID nodeId = cacheArgs.nodeId() == null ? BROADCAST_UUID : cacheArgs.nodeId(); - VisorValidateIndexesTaskResult taskRes = executeTaskByNameOnNode( - client, VALIDATE_INDEXES_TASK, taskArg, nodeId); + client, VALIDATE_INDEXES_TASK, taskArg, null); + + boolean errors = false; if (!F.isEmpty(taskRes.exceptions())) { + errors = true; + log("Index validation failed on nodes:"); for (Map.Entry e : taskRes.exceptions().entrySet()) { - log("Node ID = " + e.getKey()); + log(i("Node ID: " + e.getKey())); - log("Exception message:"); - log(e.getValue().getMessage()); + log(i("Exception message:")); + log(i(e.getValue().getMessage(), 2)); nl(); } } - boolean errors = false; - for (Map.Entry nodeEntry : taskRes.results().entrySet()) { + if (!nodeEntry.getValue().hasIssues()) + continue; + + errors = true; + + log("Index issues found on node " + nodeEntry.getKey() + ":"); + + Collection integrityCheckFailures = nodeEntry.getValue().integrityCheckFailures(); + + if (!integrityCheckFailures.isEmpty()) { + for (IndexIntegrityCheckIssue is : integrityCheckFailures) + log(i(is)); + } + Map partRes = nodeEntry.getValue().partitionResult(); for (Map.Entry e : partRes.entrySet()) { ValidateIndexesPartitionResult res = e.getValue(); if (!res.issues().isEmpty()) { - errors = true; - - log(e.getKey().toString() + " " + e.getValue().toString()); + log(i(j(" ", e.getKey(), e.getValue()))); for (IndexValidationIssue is : res.issues()) - log(is.toString()); + log(i(is, 2)); } } @@ -714,20 +971,20 @@ private void cacheValidateIndexes(GridClient client, CacheArguments cacheArgs) t ValidateIndexesPartitionResult res = e.getValue(); if (!res.issues().isEmpty()) { - errors = true; - - log("SQL Index " + e.getKey() + " " + e.getValue().toString()); + log(i(j(" ", "SQL Index", e.getKey(), e.getValue()))); for (IndexValidationIssue is : res.issues()) - log(is.toString()); + log(i(is, 2)); } } } if (!errors) - log("validate_indexes has finished, no issues found."); + log("no issues found."); else - log("validate_indexes has finished with errors (listed above)."); + log("issues found (listed above)."); + + nl(); } /** @@ -740,8 +997,11 @@ private void cacheView(GridClient client, CacheArguments cacheArgs) throws GridC VisorViewCacheTaskResult res = executeTaskByNameOnNode( client, VisorViewCacheTask.class.getName(), taskArg, cacheArgs.nodeId()); - for (CacheInfo info : res.cacheInfos()) - info.print(cacheArgs.cacheCommand()); + if (cacheArgs.fullConfig() && cacheArgs.cacheCommand() == CACHES) + cachesConfig(client, cacheArgs, res); + else + printCacheInfos(res.cacheInfos(), cacheArgs.cacheCommand()); + } /** @@ -782,7 +1042,7 @@ else if (idleVerifyV2) */ private void legacyCacheIdleVerify(GridClient client, CacheArguments cacheArgs) throws GridClientException { VisorIdleVerifyTaskResult res = executeTask( - client, VisorIdleVerifyTask.class, new VisorIdleVerifyTaskArg(cacheArgs.caches())); + client, VisorIdleVerifyTask.class, new VisorIdleVerifyTaskArg(cacheArgs.caches(), cacheArgs.excludeCaches())); Map> conflicts = res.getConflicts(); @@ -816,6 +1076,100 @@ private void cacheDistribution(GridClient client, CacheArguments cacheArgs) thro res.print(System.out); } + /** + * @param client Client. + * @param cacheArgs Cache args. + * @param viewRes Cache view task result. + */ + private void cachesConfig(GridClient client, CacheArguments cacheArgs, + VisorViewCacheTaskResult viewRes) throws GridClientException { + VisorCacheConfigurationCollectorTaskArg taskArg = new VisorCacheConfigurationCollectorTaskArg(cacheArgs.regex()); + + UUID nodeId = cacheArgs.nodeId() == null ? BROADCAST_UUID : cacheArgs.nodeId(); + + Map res = + executeTaskByNameOnNode(client, VisorCacheConfigurationCollectorTask.class.getName(), taskArg, nodeId); + + Map cacheToMapped = + viewRes.cacheInfos().stream().collect(Collectors.toMap(CacheInfo::getCacheName, CacheInfo::getMapped)); + + printCachesConfig(res, cacheArgs.outputFormat(), cacheToMapped); + } + + /** + * Prints caches info. + * + * @param infos Caches info. + * @param cmd Command. + */ + private void printCacheInfos(Collection infos, VisorViewCacheCmd cmd) { + for (CacheInfo info : infos) { + Map map = info.toMap(cmd); + + SB sb = new SB("["); + + for (Map.Entry e : map.entrySet()) + sb.a(e.getKey()).a("=").a(e.getValue()).a(", "); + + sb.setLength(sb.length() - 2); + + sb.a("]"); + + log(sb.toString()); + } + } + + /** + * Prints caches config. + * + * @param caches Caches config. + * @param outputFormat Output format. + * @param cacheToMapped Map cache name to mapped. + */ + private void printCachesConfig( + Map caches, + OutputFormat outputFormat, + Map cacheToMapped + ) { + + for (Map.Entry entry : caches.entrySet()) { + String cacheName = entry.getKey(); + + switch (outputFormat) { + case MULTI_LINE: + Map params = mapToPairs(entry.getValue()); + + params.put("Mapped", cacheToMapped.get(cacheName)); + + log("[cache = '%s']%n", cacheName); + + for (Map.Entry innerEntry : params.entrySet()) + log("%s: %s%n", innerEntry.getKey(), innerEntry.getValue()); + + nl(); + + break; + + default: + int mapped = cacheToMapped.get(cacheName); + + log("%s: %s %s=%s%n", entry.getKey(), toString(entry.getValue()), "mapped", mapped); + + break; + } + } + } + + /** + * Invokes toString() method and cuts class name from result string. + * + * @param cfg Visor cache configuration for invocation. + * @return String representation without class name in begin of string. + */ + private String toString(VisorCacheConfiguration cfg) { + return cfg.toString().substring(cfg.getClass().getSimpleName().length() + 1); + } + /** * @param client Client. * @param cacheArgs Cache args. @@ -837,7 +1191,8 @@ private void cacheIdleVerifyDump(GridClient client, CacheArguments cacheArgs) th String path = executeTask( client, VisorIdleVerifyDumpTask.class, - new VisorIdleVerifyDumpTaskArg(cacheArgs.caches(), cacheArgs.isSkipZeros()) + new VisorIdleVerifyDumpTaskArg(cacheArgs.caches(), cacheArgs.excludeCaches(), cacheArgs.isSkipZeros(), cacheArgs + .getCacheFilterEnum()) ); log("VisorIdleVerifyDumpTask successfully written output to '" + path + "'"); @@ -849,7 +1204,7 @@ private void cacheIdleVerifyDump(GridClient client, CacheArguments cacheArgs) th */ private void cacheIdleVerifyV2(GridClient client, CacheArguments cacheArgs) throws GridClientException { IdleVerifyResultV2 res = executeTask( - client, VisorIdleVerifyTaskV2.class, new VisorIdleVerifyTaskArg(cacheArgs.caches())); + client, VisorIdleVerifyTaskV2.class, new VisorIdleVerifyTaskArg(cacheArgs.caches(), cacheArgs.excludeCaches())); res.print(System.out::print); } @@ -954,8 +1309,9 @@ private void baselinePrint0(VisorBaselineTaskResult res) { log("Baseline nodes:"); for (VisorBaselineNode node : baseline.values()) { - log(" ConsistentID=" + node.getConsistentId() + ", STATE=" + - (srvs.containsKey(node.getConsistentId()) ? "ONLINE" : "OFFLINE")); + boolean online = srvs.containsKey(node.getConsistentId()); + + log(i("ConsistentID=" + node.getConsistentId() + ", STATE=" + (online ? "ONLINE" : "OFFLINE"), 2)); } log(DELIM); @@ -976,7 +1332,7 @@ private void baselinePrint0(VisorBaselineTaskResult res) { log("Other nodes:"); for (VisorBaselineNode node : others) - log(" ConsistentID=" + node.getConsistentId()); + log(i("ConsistentID=" + node.getConsistentId(), 2)); log("Number of other nodes: " + others.size()); } @@ -1209,10 +1565,10 @@ private void printUnusedWalSegments0(VisorWalTaskResult taskRes) { VisorClusterNode node = nodesInfo.get(entry.getKey()); log("Node=" + node.getConsistentId()); - log(" addresses " + U.addressesAsString(node.getAddresses(), node.getHostNames())); + log(i("addresses " + U.addressesAsString(node.getAddresses(), node.getHostNames()), 2)); for (String fileName : entry.getValue()) - log(" " + fileName); + log(i(fileName)); nl(); } @@ -1221,8 +1577,8 @@ private void printUnusedWalSegments0(VisorWalTaskResult taskRes) { VisorClusterNode node = nodesInfo.get(entry.getKey()); log("Node=" + node.getConsistentId()); - log(" addresses " + U.addressesAsString(node.getAddresses(), node.getHostNames())); - log(" failed with error: " + entry.getValue().getMessage()); + log(i("addresses " + U.addressesAsString(node.getAddresses(), node.getHostNames())), 2); + log(i("failed with error: " + entry.getValue().getMessage())); nl(); } } @@ -1244,7 +1600,7 @@ private void printDeleteWalSegments0(VisorWalTaskResult taskRes) { VisorClusterNode node = nodesInfo.get(entry.getKey()); log("Node=" + node.getConsistentId()); - log(" addresses " + U.addressesAsString(node.getAddresses(), node.getHostNames())); + log(i("addresses " + U.addressesAsString(node.getAddresses(), node.getHostNames())), 2); nl(); } @@ -1252,8 +1608,8 @@ private void printDeleteWalSegments0(VisorWalTaskResult taskRes) { VisorClusterNode node = nodesInfo.get(entry.getKey()); log("Node=" + node.getConsistentId()); - log(" addresses " + U.addressesAsString(node.getAddresses(), node.getHostNames())); - log(" failed with error: " + entry.getValue().getMessage()); + log(i("addresses " + U.addressesAsString(node.getAddresses(), node.getHostNames())), 2); + log(i("failed with error: " + entry.getValue().getMessage())); nl(); } } @@ -1286,11 +1642,190 @@ private boolean isConnectionError(Throwable e) { */ private void usage(String desc, Command cmd, String... args) { log(desc); - log(" control.sh [--host HOST_OR_IP] [--port PORT] [--user USER] [--password PASSWORD] " + - " [--ping-interval PING_INTERVAL] [--ping-timeout PING_TIMEOUT] " + cmd.text() + String.join("", args)); + log(i(j(" ", UTILITY_NAME, cmd, j(" ", args)), 2)); nl(); } + /** + * Print cache command usage with default indention. + * + * @param cmd Cache command. + * @param args Cache command arguments. + */ + private void usageCache(CacheCommand cmd, String... args) { + usageCache(1, cmd, args); + } + + /** + * Print cache command usage. + * + * @param indentsNum Number of indents. + * @param cmd Cache command. + * @param args Cache command arguments. + */ + private void usageCache(int indentsNum, CacheCommand cmd, String... args) { + log(i(DELIM, indentsNum)); + nl(); + log(i(j(" ", CACHE, cmd, j(" ", args)), indentsNum++)); + nl(); + log(i(getCacheSubcommandDesc(cmd), indentsNum)); + nl(); + + Map paramsDesc = createCacheArgsDesc(cmd); + + if (!paramsDesc.isEmpty()) { + log(i("Parameters:", indentsNum)); + + usageCacheParams(paramsDesc, indentsNum + 1); + + nl(); + } + } + + /** + * Print cache command arguments usage. + * + * @param paramsDesc Cache command arguments description. + * @param indentsNum Number of indents. + */ + private void usageCacheParams(Map paramsDesc, int indentsNum) { + int maxParamLen = paramsDesc.keySet().stream().max(Comparator.comparingInt(String::length)).get().length(); + + for (Map.Entry param : paramsDesc.entrySet()) + log(i(extendToLen(param.getKey(), maxParamLen) + INDENT + "- " + param.getValue(), indentsNum)); + } + + /** + * Appends spaces to end of input string for extending to needed length. + * + * @param s Input string. + * @param targetLen Needed length. + * @return String with appended spaces on the end. + */ + private String extendToLen(String s, int targetLen) { + assert targetLen >= 0; + assert s.length() <= targetLen; + + if (s.length() == targetLen) + return s; + + SB sb = new SB(targetLen); + + sb.a(s); + + for (int i = 0; i < targetLen - s.length(); i++) + sb.a(" "); + + return sb.toString(); + } + + /** + * Gets cache command description by cache command. + * + * @param cmd Cache command. + * @return Cache command description. + */ + private String getCacheSubcommandDesc(CacheCommand cmd) { + switch (cmd) { + case LIST: + return "Show information about caches, groups or sequences that match a regular expression. When executed without parameters, this subcommand prints the list of caches."; + + case CONTENTION: + return "Show the keys that are point of contention for multiple transactions."; + + case IDLE_VERIFY: + return "Verify counters and hash sums of primary and backup partitions for the specified caches on an idle cluster and print out the differences, if any."; + + case VALIDATE_INDEXES: + return "Validate indexes on an idle cluster and print out the keys that are missing in the indexes."; + + case DISTRIBUTION: + return "Prints the information about partition distribution."; + + case RESET_LOST_PARTITIONS: + return "Reset the state of lost partitions for the specified caches."; + + default: + throw new IllegalArgumentException("Unknown command: " + cmd); + } + } + + /** + * Gets cache command arguments description by cache command. + * + * @param cmd Cache command. + * @return Cache command arguments description. + */ + private Map createCacheArgsDesc(CacheCommand cmd) { + Map map = U.newLinkedHashMap(16); + switch (cmd) { + case LIST: + map.put(CONFIG, "print a all configuration parameters for each cache."); + map.put(OUTPUT_FORMAT + " " + MULTI_LINE.text(), "print configuration parameters per line. This option has effect only when used with " + CONFIG + " and without [groups|seq]."); + + break; + case VALIDATE_INDEXES: + map.put(VI_CHECK_FIRST + " N", "validate only the first N keys"); + map.put(VI_CHECK_THROUGH + " K", "validate every Kth key"); + + break; + } + return map; + } + + /** + * Join input parameters with space and wrap optional braces {@code []}. + * + * @param params Other input parameter. + * @return Joined parameters wrapped optional braces. + */ + private static String op(Object... params) { + return j(new SB(), "[", " ", params).a("]").toString(); + } + + /** + * Join input parameters with specified {@code delimeter} between them. + * + * @param delimeter Specified delimeter. + * @param params Other input parameter. + * @return Joined paramaters with specified {@code delimeter}. + */ + private static String j(String delimeter, Object... params) { + return j(new SB(), "", delimeter, params).toString(); + } + + /** + * Join input parameters with specified {@code delimeter} between them and append to the end {@code delimeter}. + * + * @param sb Specified string builder. + * @param sbDelimeter Delimeter between {@code sb} and appended {@code param}. + * @param delimeter Specified delimeter. + * @param params Other input parameter. + * @return SB with appended to the end joined paramaters with specified {@code delimeter}. + */ + private static SB j(SB sb, String sbDelimeter, String delimeter, Object... params) { + if (!F.isEmpty(params)) { + sb.a(sbDelimeter); + + for (Object par : params) + sb.a(par).a(delimeter); + + sb.setLength(sb.length() - delimeter.length()); + } + + return sb; + } + + /** + * Concatenates input parameters to single string with OR delimiter {@code |}. + * + * @param params Remaining parameters. + * @return Concatenated string. + */ + private static String or(Object... params) { + return j("|", params); + } + /** * Extract next argument. * @@ -1362,6 +1897,24 @@ Arguments parseAndValidate(List rawArgs) { VisorTxTaskArg txArgs = null; + String sslProtocol = DFLT_SSL_PROTOCOL; + + String sslCipherSuites = ""; + + String sslKeyAlgorithm = SslContextFactory.DFLT_KEY_ALGORITHM; + + String sslKeyStoreType = SslContextFactory.DFLT_STORE_TYPE; + + String sslKeyStorePath = null; + + char sslKeyStorePassword[] = null; + + String sslTrustStoreType = SslContextFactory.DFLT_STORE_TYPE; + + String sslTrustStorePath = null; + + char sslTrustStorePassword[] = null; + while (hasNextArg()) { String str = nextArg("").toLowerCase(); @@ -1474,6 +2027,51 @@ Arguments parseAndValidate(List rawArgs) { break; + case CMD_SSL_PROTOCOL: + sslProtocol = nextArg("Expected SSL protocol"); + + break; + + case CMD_SSL_CIPHER_SUITES: + sslCipherSuites = nextArg("Expected SSL cipher suites"); + + break; + + case CMD_SSL_KEY_ALGORITHM: + sslKeyAlgorithm = nextArg("Expected SSL key algorithm"); + + break; + + case CMD_KEYSTORE: + sslKeyStorePath = nextArg("Expected SSL key store path"); + + break; + + case CMD_KEYSTORE_PASSWORD: + sslKeyStorePassword = nextArg("Expected SSL key store password").toCharArray(); + + break; + + case CMD_KEYSTORE_TYPE: + sslKeyStoreType = nextArg("Expected SSL key store type"); + + break; + + case CMD_TRUSTSTORE: + sslTrustStorePath = nextArg("Expected SSL trust store path"); + + break; + + case CMD_TRUSTSTORE_PASSWORD: + sslTrustStorePassword = nextArg("Expected SSL trust store password").toCharArray(); + + break; + + case CMD_TRUSTSTORE_TYPE: + sslTrustStoreType = nextArg("Expected SSL trust store type"); + + break; + case CMD_AUTO_CONFIRMATION: autoConfirmation = true; @@ -1495,14 +2093,14 @@ Arguments parseAndValidate(List rawArgs) { Command cmd = commands.get(0); - boolean hasUsr = F.isEmpty(user); - boolean hasPwd = F.isEmpty(pwd); - - if (hasUsr != hasPwd) - throw new IllegalArgumentException("Both user and password should be specified"); - - return new Arguments(cmd, host, port, user, pwd, baselineAct, baselineArgs, txArgs, cacheArgs, walAct, walArgs, - pingTimeout, pingInterval, autoConfirmation); + return new Arguments(cmd, host, port, user, pwd, + baselineAct, baselineArgs, + txArgs, cacheArgs, + walAct, walArgs, + pingTimeout, pingInterval, autoConfirmation, + sslProtocol, sslCipherSuites, + sslKeyAlgorithm, sslKeyStorePath, sslKeyStorePassword, sslKeyStoreType, + sslTrustStorePath, sslTrustStorePassword, sslTrustStoreType); } /** @@ -1539,10 +2137,30 @@ private CacheArguments parseAndValidateCacheArgs() { if (CMD_DUMP.equals(nextArg)) cacheArgs.dump(true); + else if (CMD_EXCLUDE_CACHES.equals(nextArg)) { + if (cacheArgs.caches() != null || cacheArgs.getCacheFilterEnum() != CacheFilterEnum.ALL) + throw new IllegalArgumentException(ONE_CACHE_FILTER_OPT_SHOULD_USED_MSG); + + parseExcludeCacheNames(nextArg("Specify caches, which will be excluded."), + cacheArgs); + } else if (CMD_SKIP_ZEROS.equals(nextArg)) cacheArgs.skipZeros(true); - else + else if (CACHE_FILTER.equals(nextArg)) { + if (cacheArgs.caches() != null || cacheArgs.excludeCaches() != null) + throw new IllegalArgumentException(ONE_CACHE_FILTER_OPT_SHOULD_USED_MSG); + + String filter = nextArg("The cache filter should be specified. The following values can be " + + "used: " + Arrays.toString(CacheFilterEnum.values()) + '.'); + + cacheArgs.setCacheFilterEnum(CacheFilterEnum.valueOf(filter.toUpperCase())); + } + else { + if (cacheArgs.excludeCaches() != null || cacheArgs.getCacheFilterEnum() != CacheFilterEnum.ALL) + throw new IllegalArgumentException(ONE_CACHE_FILTER_OPT_SHOULD_USED_MSG); + parseCacheNames(nextArg, cacheArgs); + } } break; @@ -1612,27 +2230,27 @@ else if (CMD_SKIP_ZEROS.equals(nextArg)) case DISTRIBUTION: String nodeIdStr = nextArg("Node id expected or null"); - if (!"null".equals(nodeIdStr)) + if (!NULL.equals(nodeIdStr)) cacheArgs.nodeId(UUID.fromString(nodeIdStr)); while (hasNextCacheArg()) { String nextArg = nextArg(""); - if (CMD_USER_ATTRIBUTES.equals(nextArg)){ + if (CMD_USER_ATTRIBUTES.equals(nextArg)) { nextArg = nextArg("User attributes are expected to be separated by commas"); - Set userAttributes = new HashSet(); + Set userAttrs = new HashSet<>(); - for (String userAttribute:nextArg.split(",")) - userAttributes.add(userAttribute.trim()); + for (String userAttribute : nextArg.split(",")) + userAttrs.add(userAttribute.trim()); - cacheArgs.setUserAttributes(userAttributes); + cacheArgs.setUserAttributes(userAttrs); nextArg = (hasNextCacheArg()) ? nextArg("") : null; } - if (nextArg!=null) + if (nextArg != null) parseCacheNames(nextArg, cacheArgs); } @@ -1643,20 +2261,36 @@ else if (CMD_SKIP_ZEROS.equals(nextArg)) break; - default: + case LIST: cacheArgs.regex(nextArg("Regex is expected")); - if (hasNextCacheArg()) { - String tmp = nextArg(""); + VisorViewCacheCmd cacheCmd = CACHES; + + OutputFormat outputFormat = SINGLE_LINE; + + while (hasNextCacheArg()) { + String tmp = nextArg("").toLowerCase(); switch (tmp) { case "groups": - cacheArgs.cacheCommand(GROUPS); + cacheCmd = GROUPS; break; case "seq": - cacheArgs.cacheCommand(SEQ); + cacheCmd = SEQ; + + break; + + case OUTPUT_FORMAT: + String tmp2 = nextArg("output format must be defined!").toLowerCase(); + + outputFormat = OutputFormat.fromConsoleName(tmp2); + + break; + + case CONFIG: + cacheArgs.fullConfig(true); break; @@ -1665,7 +2299,13 @@ else if (CMD_SKIP_ZEROS.equals(nextArg)) } } + cacheArgs.cacheCommand(cacheCmd); + cacheArgs.outputFormat(outputFormat); + break; + + default: + throw new IllegalArgumentException("Unknown --cache subcommand " + cmd); } if (hasNextCacheArg()) @@ -1698,6 +2338,24 @@ private void parseCacheNames(String cacheNames, CacheArguments cacheArgs) { cacheArgs.caches(cacheNamesSet); } + /** + * @param cacheNames Cache names arg. + * @param cacheArgs Cache args. + */ + private void parseExcludeCacheNames(String cacheNames, CacheArguments cacheArgs) { + String[] cacheNamesArr = cacheNames.split(","); + Set cacheNamesSet = new HashSet<>(); + + for (String cacheName : cacheNamesArr) { + if (F.isEmpty(cacheName)) + throw new IllegalArgumentException("Non-empty cache names expected."); + + cacheNamesSet.add(cacheName.trim()); + } + + cacheArgs.excludeCaches(cacheNamesSet); + } + /** * Get ping param for grid client. * @@ -1760,7 +2418,7 @@ private VisorTxTaskArg parseTransactionArguments() { case TX_ORDER: nextArg(""); - sortOrder = VisorTxSortOrder.fromString(nextArg(TX_ORDER)); + sortOrder = VisorTxSortOrder.valueOf(nextArg(TX_ORDER).toUpperCase()); break; @@ -1851,6 +2509,41 @@ private long nextLongArg(String lb) { } } + /** + * Requests password from console with message. + * + * @param msg Message. + * @return Password. + */ + private char[] requestPasswordFromConsole(String msg) { + Console console = System.console(); + + if (console == null) + throw new UnsupportedOperationException("Failed to securely read password (console is unavailable): " + msg); + else + return console.readPassword(msg); + } + + /** + * Requests user data from console with message. + * + * @param msg Message. + * @return Input user data. + */ + private String requestDataFromConsole(String msg) { + Console console = System.console(); + + if (console != null) + return console.readLine(msg); + else { + Scanner scanner = new Scanner(System.in); + + log(msg); + + return scanner.nextLine(); + } + } + /** * Check if raw arg is command or option. * @@ -1860,6 +2553,200 @@ private boolean isCommandOrOption(String raw) { return raw != null && raw.contains("--"); } + /** + * Maps VisorCacheConfiguration to key-value pairs. + * + * @param cfg Visor cache configuration. + * @return map of key-value pairs. + */ + private Map mapToPairs(VisorCacheConfiguration cfg) { + Map params = new LinkedHashMap<>(); + + VisorCacheAffinityConfiguration affinityCfg = cfg.getAffinityConfiguration(); + VisorCacheNearConfiguration nearCfg = cfg.getNearConfiguration(); + VisorCacheRebalanceConfiguration rebalanceCfg = cfg.getRebalanceConfiguration(); + VisorCacheEvictionConfiguration evictCfg = cfg.getEvictionConfiguration(); + VisorCacheStoreConfiguration storeCfg = cfg.getStoreConfiguration(); + VisorQueryConfiguration qryCfg = cfg.getQueryConfiguration(); + + params.put("Name", cfg.getName()); + params.put("Group", cfg.getGroupName()); + params.put("Dynamic Deployment ID", cfg.getDynamicDeploymentId()); + params.put("System", cfg.isSystem()); + + params.put("Mode", cfg.getMode()); + params.put("Atomicity Mode", cfg.getAtomicityMode()); + params.put("Statistic Enabled", cfg.isStatisticsEnabled()); + params.put("Management Enabled", cfg.isManagementEnabled()); + + params.put("On-heap cache enabled", cfg.isOnheapCacheEnabled()); + params.put("Partition Loss Policy", cfg.getPartitionLossPolicy()); + params.put("Query Parallelism", cfg.getQueryParallelism()); + params.put("Copy On Read", cfg.isCopyOnRead()); + params.put("Listener Configurations", cfg.getListenerConfigurations()); + params.put("Load Previous Value", cfg.isLoadPreviousValue()); + params.put("Memory Policy Name", cfg.getMemoryPolicyName()); + params.put("Node Filter", cfg.getNodeFilter()); + params.put("Read From Backup", cfg.isReadFromBackup()); + params.put("Topology Validator", cfg.getTopologyValidator()); + + params.put("Time To Live Eager Flag", cfg.isEagerTtl()); + + params.put("Write Synchronization Mode", cfg.getWriteSynchronizationMode()); + params.put("Invalidate", cfg.isInvalidate()); + + params.put("Affinity Function", affinityCfg.getFunction()); + params.put("Affinity Backups", affinityCfg.getPartitionedBackups()); + params.put("Affinity Partitions", affinityCfg.getPartitions()); + params.put("Affinity Exclude Neighbors", affinityCfg.isExcludeNeighbors()); + params.put("Affinity Mapper", affinityCfg.getMapper()); + + params.put("Rebalance Mode", rebalanceCfg.getMode()); + params.put("Rebalance Batch Size", rebalanceCfg.getBatchSize()); + params.put("Rebalance Timeout", rebalanceCfg.getTimeout()); + params.put("Rebalance Delay", rebalanceCfg.getPartitionedDelay()); + params.put("Time Between Rebalance Messages", rebalanceCfg.getThrottle()); + params.put("Rebalance Batches Count", rebalanceCfg.getBatchesPrefetchCnt()); + params.put("Rebalance Cache Order", rebalanceCfg.getRebalanceOrder()); + + params.put("Eviction Policy Enabled", (evictCfg.getPolicy() != null)); + params.put("Eviction Policy Factory", evictCfg.getPolicy()); + params.put("Eviction Policy Max Size", evictCfg.getPolicyMaxSize()); + params.put("Eviction Filter", evictCfg.getFilter()); + + params.put("Near Cache Enabled", nearCfg.isNearEnabled()); + params.put("Near Start Size", nearCfg.getNearStartSize()); + params.put("Near Eviction Policy Factory", nearCfg.getNearEvictPolicy()); + params.put("Near Eviction Policy Max Size", nearCfg.getNearEvictMaxSize()); + + params.put("Default Lock Timeout", cfg.getDefaultLockTimeout()); + params.put("Query Entities", cfg.getQueryEntities()); + params.put("Cache Interceptor", cfg.getInterceptor()); + + params.put("Store Enabled", storeCfg.isEnabled()); + params.put("Store Class", storeCfg.getStore()); + params.put("Store Factory Class", storeCfg.getStoreFactory()); + params.put("Store Keep Binary", storeCfg.isStoreKeepBinary()); + params.put("Store Read Through", storeCfg.isReadThrough()); + params.put("Store Write Through", storeCfg.isWriteThrough()); + params.put("Store Write Coalescing", storeCfg.getWriteBehindCoalescing()); + + params.put("Write-Behind Enabled", storeCfg.isWriteBehindEnabled()); + params.put("Write-Behind Flush Size", storeCfg.getFlushSize()); + params.put("Write-Behind Frequency", storeCfg.getFlushFrequency()); + params.put("Write-Behind Flush Threads Count", storeCfg.getFlushThreadCount()); + params.put("Write-Behind Batch Size", storeCfg.getBatchSize()); + + params.put("Concurrent Asynchronous Operations Number", cfg.getMaxConcurrentAsyncOperations()); + + params.put("Loader Factory Class Name", cfg.getLoaderFactory()); + params.put("Writer Factory Class Name", cfg.getWriterFactory()); + params.put("Expiry Policy Factory Class Name", cfg.getExpiryPolicyFactory()); + + params.put("Query Execution Time Threshold", qryCfg.getLongQueryWarningTimeout()); + params.put("Query Escaped Names", qryCfg.isSqlEscapeAll()); + params.put("Query SQL Schema", qryCfg.getSqlSchema()); + params.put("Query SQL functions", qryCfg.getSqlFunctionClasses()); + params.put("Query Indexed Types", qryCfg.getIndexedTypes()); + params.put("Maximum payload size for offheap indexes", cfg.getSqlIndexMaxInlineSize()); + params.put("Query Metrics History Size", cfg.getQueryDetailMetricsSize()); + + return params; + } + + /** + * Split string into items. + * + * @param s String to process. + * @param delim Delimiter. + * @return List with items. + */ + private List split(String s, String delim) { + if (F.isEmpty(s)) + return Collections.emptyList(); + + return Arrays.stream(s.split(delim)) + .map(String::trim) + .filter(item -> !item.isEmpty()) + .collect(Collectors.toList()); + } + + /** + * @return Transaction command options. + */ + private String[] getTxOptions() { + List list = new ArrayList<>(); + + list.add(op(TX_XID, "XID")); + list.add(op(TX_DURATION, "SECONDS")); + list.add(op(TX_SIZE, "SIZE")); + list.add(op(TX_LABEL, "PATTERN_REGEX")); + list.add(op(or(TX_SERVERS, TX_CLIENTS))); + list.add(op(TX_NODES, "consistentId1[,consistentId2,....,consistentIdN]")); + list.add(op(TX_LIMIT, "NUMBER")); + list.add(op(TX_ORDER, or(VisorTxSortOrder.values()))); + list.add(op(TX_KILL)); + list.add(op(CMD_AUTO_CONFIRMATION)); + + return list.toArray(new String[list.size()]); + } + + /** */ + private void printHelp() { + final String constistIds = "consistentId1[,consistentId2,....,consistentIdN]"; + + log("Control.sh is used to execute admin commands on cluster or get common cluster info. The command has the following syntax:"); + nl(); + + log(i(j(" ", UTILITY_NAME_WITH_COMMON_OPTIONS, op("command"), ""))); + nl(); + nl(); + + log("This utility can do the following commands:"); + + usage(i("Activate cluster:"), ACTIVATE); + usage(i("Deactivate cluster:"), DEACTIVATE, op(CMD_AUTO_CONFIRMATION)); + usage(i("Print current cluster state:"), STATE); + usage(i("Print cluster baseline topology:"), BASELINE); + usage(i("Add nodes into baseline topology:"), BASELINE, BASELINE_ADD, constistIds, op(CMD_AUTO_CONFIRMATION)); + usage(i("Remove nodes from baseline topology:"), BASELINE, BASELINE_REMOVE, constistIds, op(CMD_AUTO_CONFIRMATION)); + usage(i("Set baseline topology:"), BASELINE, BASELINE_SET, constistIds, op(CMD_AUTO_CONFIRMATION)); + usage(i("Set baseline topology based on version:"), BASELINE, BASELINE_SET_VERSION + " topologyVersion", op(CMD_AUTO_CONFIRMATION)); + usage(i("List or kill transactions:"), TX, getTxOptions()); + + if (enableExperimental) { + usage(i("Print absolute paths of unused archived wal segments on each node:"), WAL, WAL_PRINT, "[consistentId1,consistentId2,....,consistentIdN]"); + usage(i("Delete unused archived wal segments on each node:"), WAL, WAL_DELETE, "[consistentId1,consistentId2,....,consistentIdN]", op(CMD_AUTO_CONFIRMATION)); + } + + log(i("View caches information in a cluster. For more details type:")); + log(i(j(" ", UTILITY_NAME, CACHE, HELP), 2)); + nl(); + + log("By default commands affecting the cluster require interactive confirmation."); + log("Use " + CMD_AUTO_CONFIRMATION + " option to disable it."); + nl(); + + log("Default values:"); + log(i("HOST_OR_IP=" + DFLT_HOST, 2)); + log(i("PORT=" + DFLT_PORT, 2)); + log(i("PING_INTERVAL=" + DFLT_PING_INTERVAL, 2)); + log(i("PING_TIMEOUT=" + DFLT_PING_TIMEOUT, 2)); + log(i("SSL_PROTOCOL=" + SslContextFactory.DFLT_SSL_PROTOCOL, 2)); + log(i("SSL_KEY_ALGORITHM=" + SslContextFactory.DFLT_KEY_ALGORITHM, 2)); + log(i("KEYSTORE_TYPE=" + SslContextFactory.DFLT_STORE_TYPE, 2)); + log(i("TRUSTSTORE_TYPE=" + SslContextFactory.DFLT_STORE_TYPE, 2)); + + nl(); + + log("Exit codes:"); + log(i(EXIT_CODE_OK + " - successful execution.", 2)); + log(i(EXIT_CODE_INVALID_ARGUMENTS + " - invalid arguments.", 2)); + log(i(EXIT_CODE_CONNECTION_FAILED + " - connection failed.", 2)); + log(i(ERR_AUTHENTICATION_FAILED + " - authentication failed.", 2)); + log(i(EXIT_CODE_UNEXPECTED_ERROR + " - unexpected error.", 2)); + } + /** * Parse and execute command. * @@ -1874,54 +2761,19 @@ public int execute(List rawArgs) { try { if (F.isEmpty(rawArgs) || (rawArgs.size() == 1 && CMD_HELP.equalsIgnoreCase(rawArgs.get(0)))) { - log("This utility can do the following commands:"); - - usage(" Activate cluster:", ACTIVATE); - usage(" Deactivate cluster:", DEACTIVATE, " [" + CMD_AUTO_CONFIRMATION + "]"); - usage(" Print current cluster state:", STATE); - usage(" Print cluster baseline topology:", BASELINE); - usage(" Add nodes into baseline topology:", BASELINE, " add consistentId1[,consistentId2,....,consistentIdN] [" + CMD_AUTO_CONFIRMATION + "]"); - usage(" Remove nodes from baseline topology:", BASELINE, " remove consistentId1[,consistentId2,....,consistentIdN] [" + CMD_AUTO_CONFIRMATION + "]"); - usage(" Set baseline topology:", BASELINE, " set consistentId1[,consistentId2,....,consistentIdN] [" + CMD_AUTO_CONFIRMATION + "]"); - usage(" Set baseline topology based on version:", BASELINE, " version topologyVersion [" + CMD_AUTO_CONFIRMATION + "]"); - usage(" List or kill transactions:", TX, " [xid XID] [minDuration SECONDS] " + - "[minSize SIZE] [label PATTERN_REGEX] [servers|clients] " + - "[nodes consistentId1[,consistentId2,....,consistentIdN] [limit NUMBER] [order DURATION|SIZE|", CMD_TX_ORDER_START_TIME, "] [kill] [" + CMD_AUTO_CONFIRMATION + "]"); - - if (enableExperimental) { - usage(" Print absolute paths of unused archived wal segments on each node:", WAL, - " print [consistentId1,consistentId2,....,consistentIdN]"); - usage(" Delete unused archived wal segments on each node:", WAL, - " delete [consistentId1,consistentId2,....,consistentIdN] [" + CMD_AUTO_CONFIRMATION + "]"); - } + printHelp(); - log(" View caches information in a cluster. For more details type:"); - log(" control.sh --cache help"); - nl(); - - log("By default commands affecting the cluster require interactive confirmation."); - log("Use " + CMD_AUTO_CONFIRMATION + " option to disable it."); - nl(); + return EXIT_CODE_OK; + } - log("Default values:"); - log(" HOST_OR_IP=" + DFLT_HOST); - log(" PORT=" + DFLT_PORT); - log(" PING_INTERVAL=" + DFLT_PING_INTERVAL); - log(" PING_TIMEOUT=" + DFLT_PING_TIMEOUT); - nl(); + Arguments args = parseAndValidate(rawArgs); - log("Exit codes:"); - log(" " + EXIT_CODE_OK + " - successful execution."); - log(" " + EXIT_CODE_INVALID_ARGUMENTS + " - invalid arguments."); - log(" " + EXIT_CODE_CONNECTION_FAILED + " - connection failed."); - log(" " + ERR_AUTHENTICATION_FAILED + " - authentication failed."); - log(" " + EXIT_CODE_UNEXPECTED_ERROR + " - unexpected error."); + if (args.command() == CACHE && args.cacheArgs().command() == HELP) { + printCacheHelp(); return EXIT_CODE_OK; } - Arguments args = parseAndValidate(rawArgs); - if (!args.autoConfirmation() && !confirm(args)) { log("Operation cancelled."); @@ -1936,51 +2788,128 @@ public int execute(List rawArgs) { clientCfg.setServers(Collections.singletonList(args.host() + ":" + args.port())); - if (!F.isEmpty(args.user())) { - clientCfg.setSecurityCredentialsProvider( - new SecurityCredentialsBasicProvider(new SecurityCredentials(args.user(), args.password()))); - } + boolean tryConnectAgain = true; - try (GridClient client = GridClientFactory.start(clientCfg)) { - switch (args.command()) { - case ACTIVATE: - activate(client); + int tryConnectMaxCount = 3; - break; + while (tryConnectAgain) { + tryConnectAgain = false; - case DEACTIVATE: - deactivate(client); + if (!F.isEmpty(args.getUserName())) { + SecurityCredentialsProvider securityCredential = clientCfg.getSecurityCredentialsProvider(); - break; + if (securityCredential == null) { + securityCredential = new SecurityCredentialsBasicProvider( + new SecurityCredentials(args.getUserName(), args.getPassword())); - case STATE: - state(client); + clientCfg.setSecurityCredentialsProvider(securityCredential); + } + final SecurityCredentials credential = securityCredential.credentials(); + credential.setLogin(args.getUserName()); + credential.setPassword(args.getPassword()); + } - break; + if (!F.isEmpty(args.sslKeyStorePath())) { + GridSslBasicContextFactory factory = new GridSslBasicContextFactory(); - case BASELINE: - baseline(client, args.baselineAction(), args.baselineArguments()); + List sslProtocols = split(args.sslProtocol(), ","); - break; + String sslProtocol = F.isEmpty(sslProtocols) ? DFLT_SSL_PROTOCOL : sslProtocols.get(0); - case TX: - transactions(client, args.transactionArguments()); + factory.setProtocol(sslProtocol); + factory.setKeyAlgorithm(args.sslKeyAlgorithm()); - break; + if (sslProtocols.size() > 1) + factory.setProtocols(sslProtocols); - case CACHE: - cache(client, args.cacheArgs()); + factory.setCipherSuites(split(args.getSslCipherSuites(), ",")); - break; + factory.setKeyStoreFilePath(args.sslKeyStorePath()); - case WAL: - wal(client, args.walAction(), args.walArguments()); + if (args.sslKeyStorePassword() != null) + factory.setKeyStorePassword(args.sslKeyStorePassword()); + else + factory.setKeyStorePassword(requestPasswordFromConsole("SSL keystore password: ")); - break; + factory.setKeyStoreType(args.sslKeyStoreType()); + + if (F.isEmpty(args.sslTrustStorePath())) + factory.setTrustManagers(GridSslBasicContextFactory.getDisabledTrustManager()); + else { + factory.setTrustStoreFilePath(args.sslTrustStorePath()); + + if (args.sslTrustStorePassword() != null) + factory.setTrustStorePassword(args.sslTrustStorePassword()); + else + factory.setTrustStorePassword(requestPasswordFromConsole("SSL truststore password: ")); + + factory.setTrustStoreType(args.sslTrustStoreType()); + } + + clientCfg.setSslContextFactory(factory); } - } - return 0; + try (GridClient client = GridClientFactory.start(clientCfg)) { + switch (args.command()) { + case ACTIVATE: + activate(client); + + break; + + case DEACTIVATE: + deactivate(client); + + break; + + case STATE: + state(client); + + break; + + case BASELINE: + baseline(client, args.baselineAction(), args.baselineArguments()); + + break; + + case TX: + transactions(client, args.transactionArguments()); + + break; + + case CACHE: + cache(client, args.cacheArgs()); + + break; + + case WAL: + wal(client, args.walAction(), args.walArguments()); + + break; + } + } + catch (Throwable e) { + if (tryConnectMaxCount > 0 && isAuthError(e)) { + log("Authentication error, try connection again."); + + if (F.isEmpty(args.getUserName())) + args.setUserName(requestDataFromConsole("user: ")); + + args.setPassword(new String(requestPasswordFromConsole("password: "))); + + tryConnectAgain = true; + + tryConnectMaxCount--; + } + else { + if (tryConnectMaxCount == 0) + throw new GridClientAuthenticationException("Authentication error, maximum number of " + + "retries exceeded"); + + throw e; + } + } + } + return EXIT_CODE_OK; } catch (IllegalArgumentException e) { return error(EXIT_CODE_INVALID_ARGUMENTS, "Check arguments.", e); @@ -2010,7 +2939,6 @@ public static void main(String[] args) { * * @return Last operation result; */ - @SuppressWarnings("unchecked") public T getLastOperationResult() { return (T)lastOperationRes; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/commandline/OutputFormat.java b/modules/core/src/main/java/org/apache/ignite/internal/commandline/OutputFormat.java new file mode 100644 index 0000000000000..356cb4b2e88e5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/commandline/OutputFormat.java @@ -0,0 +1,66 @@ +/* + * 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. + */ +package org.apache.ignite.internal.commandline; + +import org.jetbrains.annotations.NotNull; + +/** + * + */ +public enum OutputFormat { + /** Single line. */ + SINGLE_LINE("single-line"), + + /** Multi line. */ + MULTI_LINE("multi-line"); + + /** */ + private final String text; + + /** */ + OutputFormat(String text) { + this.text = text; + } + + /** + * @return Text. + */ + public String text() { + return text; + } + + /** + * Converts format name in console to enumerated value. + * + * @param text Format name in console. + * @return Enumerated value. + * @throws IllegalArgumentException If enumerated value not found. + */ + public static OutputFormat fromConsoleName(@NotNull String text) { + for (OutputFormat format : values()) { + if (format.text.equals(text)) + return format; + } + + throw new IllegalArgumentException("Unknown output format " + text); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return text; + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/CacheArguments.java b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/CacheArguments.java index 97d234aeb879d..46110b7272a7e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/CacheArguments.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/CacheArguments.java @@ -18,6 +18,8 @@ import java.util.Set; import java.util.UUID; +import org.apache.ignite.internal.commandline.OutputFormat; +import org.apache.ignite.internal.visor.verify.CacheFilterEnum; import org.apache.ignite.internal.visor.verify.VisorViewCacheCmd; import org.jetbrains.annotations.Nullable; @@ -31,6 +33,9 @@ public class CacheArguments { /** Caches. */ private Set caches; + /** Exclude caches or groups. */ + private Set excludeCaches; + /** Partition id. */ private int partId; @@ -64,6 +69,39 @@ public class CacheArguments { /** Additional user attributes in result. Set of attribute names whose values will be searched in ClusterNode.attributes(). */ private Set userAttributes; + /** Output format. */ + private OutputFormat outputFormat; + + /** Full config flag. */ + private boolean fullConfig; + + /** Cache filter. */ + private CacheFilterEnum cacheFilterEnum = CacheFilterEnum.ALL; + + /** + * @return Gets filter of caches, which will by checked. + */ + public CacheFilterEnum getCacheFilterEnum() { + return cacheFilterEnum; + } + + /** + * @param cacheFilterEnum Cache filter. + */ + public void setCacheFilterEnum(CacheFilterEnum cacheFilterEnum) { + this.cacheFilterEnum = cacheFilterEnum; + } + + /** + * @return Full config flag. + */ + public boolean fullConfig(){ return fullConfig; } + + /** + * @param fullConfig New full config flag. + */ + public void fullConfig(boolean fullConfig) { this.fullConfig = fullConfig; } + /** * @return Command. */ @@ -106,6 +144,20 @@ public void caches(Set caches) { this.caches = caches; } + /** + * @return Exclude caches or groups. + */ + public Set excludeCaches() { + return excludeCaches; + } + + /** + * @param excludeCaches Excluse caches or groups. + */ + public void excludeCaches(Set excludeCaches) { + this.excludeCaches = excludeCaches; + } + /** * @return Partition id. */ @@ -245,4 +297,14 @@ public Set getUserAttributes() { public void setUserAttributes(Set userAttrs) { userAttributes = userAttrs; } + + /** + * @return Output format. + */ + public OutputFormat outputFormat() { return outputFormat; } + + /** + * @param outputFormat New output format. + */ + public void outputFormat(OutputFormat outputFormat) { this.outputFormat = outputFormat; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/CacheCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/CacheCommand.java index af222a8bc0973..63a55d8c9f41d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/CacheCommand.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/CacheCommand.java @@ -100,4 +100,9 @@ public String text() { @Nullable public static CacheCommand fromOrdinal(int ord) { return ord >= 0 && ord < VALS.length ? VALS[ord] : null; } + + /** {@inheritDoc} */ + @Override public String toString() { + return name; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTaskResult.java index 71de3bbc0dd05..52c6eec308afb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTaskResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/commandline/cache/distribution/CacheDistributionTaskResult.java @@ -294,10 +294,10 @@ public void setUserAttributes(Map userAttrs) { Row other = (Row)o; - int res = grpId - other.grpId; + int res = Integer.compare(grpId, other.grpId); if (res == 0) { - res = partId - other.partId; + res = Integer.compare(partId, other.partId); if (res == 0) res = nodeId.compareTo(other.nodeId); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java index 47d7877816824..b8208016aba53 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java @@ -27,6 +27,9 @@ import org.apache.ignite.internal.direct.stream.DirectByteBufferStream; import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1; import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2; +import org.apache.ignite.internal.direct.stream.v3.DirectByteBufferStreamImplV3; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteOutClosure; import org.apache.ignite.lang.IgniteUuid; @@ -41,8 +44,13 @@ */ public class DirectMessageReader implements MessageReader { /** State. */ + @GridToStringInclude private final DirectMessageState state; + /** Protocol version. */ + @GridToStringInclude + private final byte protoVer; + /** Whether last field was fully read. */ private boolean lastRead; @@ -56,6 +64,8 @@ public DirectMessageReader(final MessageFactory msgFactory, final byte protoVer) return new StateItem(msgFactory, protoVer); } }); + + this.protoVer = protoVer; } /** {@inheritDoc} */ @@ -304,6 +314,21 @@ public DirectMessageReader(final MessageFactory msgFactory, final byte protoVer) return val; } + /** {@inheritDoc} */ + @Override public AffinityTopologyVersion readAffinityTopologyVersion(String name) { + if (protoVer >= 3) { + DirectByteBufferStream stream = state.item().stream; + + AffinityTopologyVersion val = stream.readAffinityTopologyVersion(); + + lastRead = stream.lastFinished(); + + return val; + } + + return readMessage(name); + } + /** {@inheritDoc} */ @Nullable @Override public T readMessage(String name) { DirectByteBufferStream stream = state.item().stream; @@ -409,6 +434,11 @@ public StateItem(MessageFactory msgFactory, byte protoVer) { break; + case 3: + stream = new DirectByteBufferStreamImplV3(msgFactory); + + break; + default: throw new IllegalStateException("Invalid protocol version: " + protoVer); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java index 51cea174e9a1d..bb88ffc851669 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java @@ -27,6 +27,8 @@ import org.apache.ignite.internal.direct.stream.DirectByteBufferStream; import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1; import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2; +import org.apache.ignite.internal.direct.stream.v3.DirectByteBufferStreamImplV3; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteOutClosure; @@ -44,6 +46,10 @@ public class DirectMessageWriter implements MessageWriter { @GridToStringInclude private final DirectMessageState state; + /** Protocol version. */ + @GridToStringInclude + private final byte protoVer; + /** * @param protoVer Protocol version. */ @@ -53,6 +59,8 @@ public DirectMessageWriter(final byte protoVer) { return new StateItem(protoVer); } }); + + this.protoVer = protoVer; } /** {@inheritDoc} */ @@ -272,6 +280,19 @@ public DirectMessageWriter(final byte protoVer) { return stream.lastFinished(); } + /** {@inheritDoc} */ + @Override public boolean writeAffinityTopologyVersion(String name, AffinityTopologyVersion val) { + if (protoVer >= 3) { + DirectByteBufferStream stream = state.item().stream; + + stream.writeAffinityTopologyVersion(val); + + return stream.lastFinished(); + } + + return writeMessage(name, val); + } + /** {@inheritDoc} */ @Override public boolean writeMessage(String name, @Nullable Message msg) { DirectByteBufferStream stream = state.item().stream; @@ -376,6 +397,11 @@ public StateItem(byte protoVer) { break; + case 3: + stream = new DirectByteBufferStreamImplV3(null); + + break; + default: throw new IllegalStateException("Invalid protocol version: " + protoVer); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java index 204e6b034530b..ae5502eb75f8e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.Map; import java.util.UUID; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; @@ -160,6 +161,11 @@ public interface DirectByteBufferStream { */ public void writeIgniteUuid(IgniteUuid val); + /** + * @param val Value. + */ + public void writeAffinityTopologyVersion(AffinityTopologyVersion val); + /** * @param msg Message. * @param writer Writer. @@ -289,6 +295,11 @@ public void writeMap(Map map, MessageCollectionItemType keyType, Me */ public IgniteUuid readIgniteUuid(); + /** + * @return Value. + */ + public AffinityTopologyVersion readAffinityTopologyVersion(); + /** * @param reader Reader. * @return Message. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java index c78c47914fdfe..118e1f1d0cbe7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java @@ -27,6 +27,7 @@ import java.util.NoSuchElementException; import java.util.UUID; import org.apache.ignite.internal.direct.stream.DirectByteBufferStream; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.internal.S; @@ -494,6 +495,11 @@ public DirectByteBufferStreamImplV1(MessageFactory msgFactory) { writeByteArray(val != null ? U.igniteUuidToBytes(val) : null); } + /** {@inheritDoc} */ + @Override public void writeAffinityTopologyVersion(AffinityTopologyVersion val) { + throw new UnsupportedOperationException("Not implemented"); + } + /** {@inheritDoc} */ @Override public void writeMessage(Message msg, MessageWriter writer) { if (msg != null) { @@ -811,6 +817,11 @@ public DirectByteBufferStreamImplV1(MessageFactory msgFactory) { return arr != null ? U.bytesToIgniteUuid(arr, 0) : null; } + /** {@inheritDoc} */ + @Override public AffinityTopologyVersion readAffinityTopologyVersion() { + throw new UnsupportedOperationException("Not implemented"); + } + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public T readMessage(MessageReader reader) { @@ -1212,6 +1223,7 @@ private void write(MessageCollectionItemType type, Object val, MessageWriter wri break; + case AFFINITY_TOPOLOGY_VERSION: case MSG: try { if (val != null) @@ -1298,6 +1310,7 @@ private Object read(MessageCollectionItemType type, MessageReader reader) { case IGNITE_UUID: return readIgniteUuid(); + case AFFINITY_TOPOLOGY_VERSION: case MSG: return readMessage(reader); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java index e338bc0187d46..fd93cfb81f832 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java @@ -29,6 +29,7 @@ import java.util.UUID; import org.apache.ignite.IgniteException; import org.apache.ignite.internal.direct.stream.DirectByteBufferStream; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.internal.S; @@ -298,7 +299,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream { private long uuidLocId; /** */ - private boolean lastFinished; + protected boolean lastFinished; /** * @param msgFactory Message factory. @@ -657,6 +658,11 @@ public DirectByteBufferStreamImplV2(MessageFactory msgFactory) { } } + /** {@inheritDoc} */ + @Override public void writeAffinityTopologyVersion(AffinityTopologyVersion val) { + throw new UnsupportedOperationException("Not implemented"); + } + /** {@inheritDoc} */ @Override public void writeMessage(Message msg, MessageWriter writer) { if (msg != null) { @@ -1152,6 +1158,11 @@ private void writeRandomAccessList(List list, MessageCollectionItemType i return val; } + /** {@inheritDoc} */ + @Override public AffinityTopologyVersion readAffinityTopologyVersion() { + throw new UnsupportedOperationException("Not implemented"); + } + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public T readMessage(MessageReader reader) { @@ -1587,7 +1598,7 @@ T readArrayLE(ArrayCreator creator, int typeSize, int lenShift, long off) * @param val Value. * @param writer Writer. */ - private void write(MessageCollectionItemType type, Object val, MessageWriter writer) { + protected void write(MessageCollectionItemType type, Object val, MessageWriter writer) { switch (type) { case BYTE: writeByte((Byte)val); @@ -1689,6 +1700,7 @@ private void write(MessageCollectionItemType type, Object val, MessageWriter wri break; + case AFFINITY_TOPOLOGY_VERSION: case MSG: try { if (val != null) @@ -1713,7 +1725,7 @@ private void write(MessageCollectionItemType type, Object val, MessageWriter wri * @param reader Reader. * @return Value. */ - private Object read(MessageCollectionItemType type, MessageReader reader) { + protected Object read(MessageCollectionItemType type, MessageReader reader) { switch (type) { case BYTE: return readByte(); @@ -1775,6 +1787,7 @@ private Object read(MessageCollectionItemType type, MessageReader reader) { case IGNITE_UUID: return readIgniteUuid(); + case AFFINITY_TOPOLOGY_VERSION: case MSG: return readMessage(reader); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v3/DirectByteBufferStreamImplV3.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v3/DirectByteBufferStreamImplV3.java new file mode 100644 index 0000000000000..89043ebcbc0c5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v3/DirectByteBufferStreamImplV3.java @@ -0,0 +1,298 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.direct.stream.v3; + +import java.util.BitSet; +import java.util.UUID; +import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; +import org.apache.ignite.plugin.extensions.communication.MessageFactory; +import org.apache.ignite.plugin.extensions.communication.MessageReader; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; + +/** + * + */ +public class DirectByteBufferStreamImplV3 extends DirectByteBufferStreamImplV2 { + /** */ + private byte topVerState; + + /** */ + private long topVerMajor; + + /** */ + private int topVerMinor; + + /** + * @param msgFactory Message factory. + */ + public DirectByteBufferStreamImplV3(MessageFactory msgFactory) { + super(msgFactory); + } + + /** {@inheritDoc} */ + @Override public void writeAffinityTopologyVersion(AffinityTopologyVersion val) { + if (val != null) { + switch (topVerState) { + case 0: + writeInt(val.minorTopologyVersion()); + + if (!lastFinished) + return; + + topVerState++; + + case 1: + writeLong(val.topologyVersion()); + + if (!lastFinished) + return; + + topVerState = 0; + } + } + else + writeInt(-1); + } + + /** {@inheritDoc} */ + @Override public AffinityTopologyVersion readAffinityTopologyVersion() { + switch (topVerState) { + case 0: + topVerMinor = readInt(); + + if (!lastFinished || topVerMinor == -1) + return null; + + topVerState++; + + case 1: + topVerMajor = readLong(); + + if (!lastFinished) + return null; + + topVerState = 0; + } + + return new AffinityTopologyVersion(topVerMajor, topVerMinor); + } + + /** {@inheritDoc} */ + @Override protected void write(MessageCollectionItemType type, Object val, MessageWriter writer) { + switch (type) { + case BYTE: + writeByte((Byte)val); + + break; + + case SHORT: + writeShort((Short)val); + + break; + + case INT: + writeInt((Integer)val); + + break; + + case LONG: + writeLong((Long)val); + + break; + + case FLOAT: + writeFloat((Float)val); + + break; + + case DOUBLE: + writeDouble((Double)val); + + break; + + case CHAR: + writeChar((Character)val); + + break; + + case BOOLEAN: + writeBoolean((Boolean)val); + + break; + + case BYTE_ARR: + writeByteArray((byte[])val); + + break; + + case SHORT_ARR: + writeShortArray((short[])val); + + break; + + case INT_ARR: + writeIntArray((int[])val); + + break; + + case LONG_ARR: + writeLongArray((long[])val); + + break; + + case FLOAT_ARR: + writeFloatArray((float[])val); + + break; + + case DOUBLE_ARR: + writeDoubleArray((double[])val); + + break; + + case CHAR_ARR: + writeCharArray((char[])val); + + break; + + case BOOLEAN_ARR: + writeBooleanArray((boolean[])val); + + break; + + case STRING: + writeString((String)val); + + break; + + case BIT_SET: + writeBitSet((BitSet)val); + + break; + + case UUID: + writeUuid((UUID)val); + + break; + + case IGNITE_UUID: + writeIgniteUuid((IgniteUuid)val); + + break; + + case AFFINITY_TOPOLOGY_VERSION: + writeAffinityTopologyVersion((AffinityTopologyVersion)val); + + break; + case MSG: + try { + if (val != null) + writer.beforeInnerMessageWrite(); + + writeMessage((Message)val, writer); + } + finally { + if (val != null) + writer.afterInnerMessageWrite(lastFinished); + } + + break; + + default: + throw new IllegalArgumentException("Unknown type: " + type); + } + } + + /** {@inheritDoc} */ + @Override protected Object read(MessageCollectionItemType type, MessageReader reader) { + switch (type) { + case BYTE: + return readByte(); + + case SHORT: + return readShort(); + + case INT: + return readInt(); + + case LONG: + return readLong(); + + case FLOAT: + return readFloat(); + + case DOUBLE: + return readDouble(); + + case CHAR: + return readChar(); + + case BOOLEAN: + return readBoolean(); + + case BYTE_ARR: + return readByteArray(); + + case SHORT_ARR: + return readShortArray(); + + case INT_ARR: + return readIntArray(); + + case LONG_ARR: + return readLongArray(); + + case FLOAT_ARR: + return readFloatArray(); + + case DOUBLE_ARR: + return readDoubleArray(); + + case CHAR_ARR: + return readCharArray(); + + case BOOLEAN_ARR: + return readBooleanArray(); + + case STRING: + return readString(); + + case BIT_SET: + return readBitSet(); + + case UUID: + return readUuid(); + + case IGNITE_UUID: + return readIgniteUuid(); + + case AFFINITY_TOPOLOGY_VERSION: + return readAffinityTopologyVersion(); + + case MSG: + return readMessage(reader); + + default: + throw new IllegalArgumentException("Unknown type: " + type); + } + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java index 8b21ff2fe5382..4b25e0b687662 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java @@ -177,4 +177,4 @@ public String getCheckpointSpi() { @Override public String toString() { return S.toString(GridCheckpointRequest.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index b3c80b05f635b..ae117bb073558 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -135,7 +135,7 @@ public class GridIoManager extends GridManagerAdapter CUR_PLC = new ThreadLocal<>(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java index 332a9de511c79..408fad773f93e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java @@ -358,4 +358,4 @@ public void deployment(GridDeployment dep) { @Override public String toString() { return S.toString(GridIoUserMessage.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java index 0a8b2b7a38e60..a6a2469736ef2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessage.java @@ -20,6 +20,7 @@ import java.nio.ByteBuffer; import java.util.UUID; import org.apache.ignite.internal.GridDirectTransient; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageReader; @@ -28,6 +29,7 @@ /** * */ +@IgniteCodeGeneratingFail public class IgniteIoTestMessage implements Message { /** */ private static byte FLAG_PROC_FROM_NIO = 1; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeployment.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeployment.java index c3efc592b1347..3450aa5195c4a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeployment.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeployment.java @@ -35,6 +35,7 @@ import org.apache.ignite.compute.ComputeTask; import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.GridLeanSet; import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter; import org.apache.ignite.internal.util.lang.GridPeerDeployAware; @@ -45,6 +46,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteUuid; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.concurrent.ConcurrentHashMap; @@ -383,6 +385,20 @@ public boolean internalTask(@Nullable ComputeTask task, Class taskCls) { return res; } + /** + * Checks whether task class is annotated with {@link GridVisorManagementTask}. + * + * @param task Task. + * @param taskCls Task class. + * @return {@code True} if task is internal. + */ + @SuppressWarnings("unchecked") + public boolean visorManagementTask(@Nullable ComputeTask task, @NotNull Class taskCls) { + return annotation(task instanceof GridPeerDeployAware ? + ((GridPeerDeployAware)task).deployClass() : taskCls, + GridVisorManagementTask.class) != null; + } + /** * @param cls Class to create new instance of (using default constructor). * @return New instance. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java index 2a5f7cae1224b..e14c8dfafcb10 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java @@ -204,9 +204,9 @@ private void processResourceRequest(UUID nodeId, GridDeploymentRequest req) { // since it was already performed before (and was successful). if (!(ldr instanceof GridDeploymentClassLoader)) { // First check for @GridNotPeerDeployable annotation. - try { - String clsName = req.resourceName().replace('/', '.'); + String clsName = req.resourceName().replace('/', '.'); + try { int idx = clsName.indexOf(".class"); if (idx >= 0) @@ -228,8 +228,10 @@ private void processResourceRequest(UUID nodeId, GridDeploymentRequest req) { return; } } - catch (ClassNotFoundException ignore) { - // Safely ignore it here - resource wasn't a class name. + catch (LinkageError | ClassNotFoundException e) { + U.warn(log, "Failed to resolve class: " + clsName, e); + // Defined errors can be safely ignored here, because of resource which is able to be not a class name. + // Unsuccessful response will be sent below if the resource failed to be loaded. } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java index 7f58ce36001ab..72f5ec6b30579 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java @@ -277,4 +277,4 @@ public GridDeploymentInfoBean(GridDeploymentInfo dep) { @Override public String toString() { return S.toString(GridDeploymentInfoBean.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java index 729cf4c54278e..708c64860579e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java @@ -278,4 +278,4 @@ public void nodeIds(Collection nodeIds) { @Override public String toString() { return S.toString(GridDeploymentRequest.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java index d1b0384f0fb6a..591957d37bd2f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java @@ -197,4 +197,4 @@ void errorMessage(String errMsg) { @Override public String toString() { return S.toString(GridDeploymentResponse.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoCache.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoCache.java index 70e2013d1065a..e99e4782ba3c8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoCache.java @@ -26,7 +26,6 @@ import org.apache.ignite.cluster.BaselineNode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState; import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -109,14 +108,10 @@ public class DiscoCache { /** */ private final P1 aliveNodePred; - /** */ - private final MvccCoordinator mvccCrd; - /** * @param topVer Topology version. * @param state Current cluster state. * @param loc Local node. - * @param mvccCrd MVCC coordinator node. * @param rmtNodes Remote nodes. * @param allNodes All nodes. * @param srvNodes Server nodes. @@ -135,7 +130,6 @@ public class DiscoCache { AffinityTopologyVersion topVer, DiscoveryDataClusterState state, ClusterNode loc, - MvccCoordinator mvccCrd, List rmtNodes, List allNodes, List srvNodes, @@ -154,7 +148,6 @@ public class DiscoCache { this.topVer = topVer; this.state = state; this.loc = loc; - this.mvccCrd = mvccCrd; this.rmtNodes = rmtNodes; this.allNodes = allNodes; this.srvNodes = srvNodes; @@ -183,13 +176,6 @@ public class DiscoCache { }; } - /** - * @return Mvcc coordinator node. - */ - @Nullable public MvccCoordinator mvccCoordinator() { - return mvccCrd; - } - /** * @return Topology version. */ @@ -475,7 +461,6 @@ public DiscoCache copy(AffinityTopologyVersion ver, @Nullable DiscoveryDataClust ver, state == null ? this.state : state, loc, - mvccCrd, rmtNodes, allNodes, srvNodes, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java index 30d169f0be1cb..13334e5633e02 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java @@ -48,6 +48,7 @@ import org.apache.ignite.IgniteClientDisconnectedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteInterruptedException; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cache.CacheMetrics; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cluster.BaselineNode; @@ -85,8 +86,6 @@ import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; -import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cluster.BaselineTopology; import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage; import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage; @@ -109,7 +108,6 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.util.worker.GridWorker; import org.apache.ignite.lang.IgniteClosure; @@ -659,8 +657,6 @@ private void onDiscovery0( updateClientNodes(node.id()); } - ctx.coordinators().onDiscoveryEvent(type, topSnapshot, topVer, customMsg); - boolean locJoinEvt = type == EVT_NODE_JOINED && node.id().equals(locNode.id()); ChangeGlobalStateFinishMessage stateFinishMsg = null; @@ -771,8 +767,6 @@ else if (customMsg instanceof ChangeGlobalStateMessage) { // Current version. discoCache = discoCache(); - final DiscoCache discoCache0 = discoCache; - // If this is a local join event, just save it and do not notify listeners. if (locJoinEvt) { if (gridStartTime == 0) @@ -793,6 +787,8 @@ else if (customMsg instanceof ChangeGlobalStateMessage) { discoWrk.discoCache = discoCache; if (!isLocDaemon && !ctx.clientDisconnected()) { + ctx.cache().context().coordinators().onLocalJoin(discoEvt); + ctx.cache().context().exchange().onLocalJoin(discoEvt, discoCache); ctx.authentication().onLocalJoin(); @@ -858,7 +854,7 @@ else if (type == EVT_CLIENT_NODE_RECONNECTED) { try { fut.get(); - discoWrk.addEvent(type, nextTopVer, node, discoCache0, topSnapshot, null); + discoWrk.addEvent(EVT_CLIENT_NODE_RECONNECTED, nextTopVer, node, discoCache, topSnapshot, null); } catch (IgniteException ignore) { // No-op. @@ -1098,6 +1094,10 @@ private GridLocalMetrics createMetrics() { */ public DiscoveryMetricsProvider createMetricsProvider() { return new DiscoveryMetricsProvider() { + /** Disable cache metrics update. */ + private final boolean disableCacheMetricsUpdate = IgniteSystemProperties.getBoolean( + IgniteSystemProperties.IGNITE_DISCOVERY_DISABLE_CACHE_METRICS_UPDATE, false); + /** */ private final long startTime = U.currentTimeMillis(); @@ -1109,6 +1109,9 @@ public DiscoveryMetricsProvider createMetricsProvider() { /** {@inheritDoc} */ @Override public Map cacheMetrics() { try { + if (disableCacheMetricsUpdate) + return Collections.emptyMap(); + /** Caches should not be accessed while state transition is in progress. */ if (ctx.state().clusterState().transition()) return Collections.emptyMap(); @@ -2061,6 +2064,21 @@ private DiscoCache resolveDiscoCache(int grpId, AffinityTopologyVersion topVer) snap.discoCache : discoCacheHist.get(topVer); if (cache == null) { + AffinityTopologyVersion lastAffChangedTopVer = + ctx.cache().context().exchange().lastAffinityChangedTopologyVersion(topVer); + + if (!lastAffChangedTopVer.equals(topVer)) { + assert lastAffChangedTopVer.compareTo(topVer) < 0; + + for (Map.Entry e : discoCacheHist.descendingEntrySet()) { + if (e.getKey().isBetween(lastAffChangedTopVer, topVer)) + return e.getValue(); + + if (e.getKey().compareTo(lastAffChangedTopVer) < 0) + break; + } + } + CacheGroupDescriptor desc = ctx.cache().cacheGroupDescriptors().get(grpId); throw new IgniteException("Failed to resolve nodes topology [" + @@ -2340,8 +2358,6 @@ public void reconnect() { Collection topSnapshot) { assert topSnapshot.contains(loc); - MvccCoordinator mvccCrd = ctx.coordinators().assignedCoordinator(); - HashSet alives = U.newHashSet(topSnapshot.size()); HashMap nodeMap = U.newHashMap(topSnapshot.size()); @@ -2443,7 +2459,6 @@ else if (node.version().compareTo(minVer) < 0) topVer, state, loc, - mvccCrd, Collections.unmodifiableList(rmtNodes), Collections.unmodifiableList(allNodes), Collections.unmodifiableList(srvNodes), @@ -2465,7 +2480,7 @@ else if (node.version().compareTo(minVer) < 0) * * @param cacheMap Map to add to. * @param cacheName Cache name. - * @param rich Node to add + * @param node Node to add */ private void addToMap(Map> cacheMap, String cacheName, ClusterNode rich) { List cacheNodes = cacheMap.get(CU.cacheId(cacheName)); @@ -2615,8 +2630,8 @@ public void scheduleSegmentCheck() { AffinityTopologyVersion.NONE, ctx.state().clusterState(), node, - locNodeOnlyTop - ), locNodeOnlyTop, + locNodeOnlyTop), + locNodeOnlyTop, null); lastSegChkRes.set(false); @@ -3450,7 +3465,6 @@ public DiscoCache createDiscoCacheOnCacheChange( topVer, discoCache.state(), discoCache.localNode(), - discoCache.mvccCoordinator(), discoCache.remoteNodes(), allNodes, discoCache.serverNodes(), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java index d4daab85c0ed7..92a2eefe0bcf3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageManager.java @@ -316,6 +316,9 @@ public void record(DiscoveryEvent evt, DiscoCache discoCache) { private void record0(Event evt, Object... params) { assert evt != null; + if (ctx.recoveryMode()) + return; + if (!enterBusy()) return; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index 515500b91d0f1..fd5326cf0577c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -445,4 +445,4 @@ void exceptionBytes(byte[] exBytes) { @Override public String toString() { return S.toString(GridEventStorageMessage.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdAllocator.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdAllocator.java index c6aeabe087975..d91d31da32957 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdAllocator.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdAllocator.java @@ -35,6 +35,12 @@ public interface PageIdAllocator { /** Special partition reserved for index space. */ public static final int INDEX_PARTITION = 0xFFFF; + /** Old special partition reserved for metastore space. */ + public static final int OLD_METASTORE_PARTITION = 0x0; + + /** Special partition reserved for metastore space. */ + public static final int METASTORE_PARTITION = 0x1; + /** * Allocates a page from the space for the given partition ID and the given flags. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java index 66d713cd7095f..4ba19c2d71594 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java @@ -163,6 +163,11 @@ public class PageMemoryNoStoreImpl implements PageMemory { /** Shared context. */ private final GridCacheSharedContext ctx; + /** + * Marker that stop was invoked and memory is not supposed for any usage. + */ + private volatile boolean stopped; + /** * @param log Logger. * @param directMemoryProvider Memory allocator to use. @@ -202,6 +207,8 @@ public PageMemoryNoStoreImpl( /** {@inheritDoc} */ @Override public void start() throws IgniteException { + stopped = false; + long startSize = dataRegionCfg.getInitialSize(); long maxSize = dataRegionCfg.getMaxSize(); @@ -243,6 +250,8 @@ public PageMemoryNoStoreImpl( if (log.isDebugEnabled()) log.debug("Stopping page memory."); + stopped = true; + directMemoryProvider.shutdown(deallocate); if (directMemoryProvider instanceof Closeable) { @@ -262,6 +271,8 @@ public PageMemoryNoStoreImpl( /** {@inheritDoc} */ @Override public long allocatePage(int grpId, int partId, byte flags) { + assert !stopped; + long relPtr = borrowFreePage(); long absPtr = 0; @@ -326,6 +337,8 @@ public PageMemoryNoStoreImpl( /** {@inheritDoc} */ @Override public boolean freePage(int cacheId, long pageId) { + assert !stopped; + releaseFreePage(pageId); return true; @@ -445,6 +458,8 @@ private long fromSegmentIndex(int segIdx, long pageIdx) { /** {@inheritDoc} */ @Override public long acquirePage(int cacheId, long pageId) { + assert !stopped; + int pageIdx = PageIdUtils.pageIndex(pageId); Segment seg = segment(pageIdx); @@ -454,6 +469,8 @@ private long fromSegmentIndex(int segIdx, long pageIdx) { /** {@inheritDoc} */ @Override public void releasePage(int cacheId, long pageId, long page) { + assert !stopped; + if (trackAcquiredPages) { Segment seg = segment(PageIdUtils.pageIndex(pageId)); @@ -463,6 +480,8 @@ private long fromSegmentIndex(int segIdx, long pageIdx) { /** {@inheritDoc} */ @Override public long readLock(int cacheId, long pageId, long page) { + assert !stopped; + if (rwLock.readLock(page + LOCK_OFFSET, PageIdUtils.tag(pageId))) return page + PAGE_OVERHEAD; @@ -471,6 +490,8 @@ private long fromSegmentIndex(int segIdx, long pageIdx) { /** {@inheritDoc} */ @Override public long readLockForce(int cacheId, long pageId, long page) { + assert !stopped; + if (rwLock.readLock(page + LOCK_OFFSET, -1)) return page + PAGE_OVERHEAD; @@ -479,11 +500,15 @@ private long fromSegmentIndex(int segIdx, long pageIdx) { /** {@inheritDoc} */ @Override public void readUnlock(int cacheId, long pageId, long page) { + assert !stopped; + rwLock.readUnlock(page + LOCK_OFFSET); } /** {@inheritDoc} */ @Override public long writeLock(int cacheId, long pageId, long page) { + assert !stopped; + if (rwLock.writeLock(page + LOCK_OFFSET, PageIdUtils.tag(pageId))) return page + PAGE_OVERHEAD; @@ -492,6 +517,8 @@ private long fromSegmentIndex(int segIdx, long pageIdx) { /** {@inheritDoc} */ @Override public long tryWriteLock(int cacheId, long pageId, long page) { + assert !stopped; + if (rwLock.tryWriteLock(page + LOCK_OFFSET, PageIdUtils.tag(pageId))) return page + PAGE_OVERHEAD; @@ -506,6 +533,8 @@ private long fromSegmentIndex(int segIdx, long pageIdx) { Boolean walPlc, boolean dirtyFlag ) { + assert !stopped; + long actualId = PageIO.getPageId(page + PAGE_OVERHEAD); rwLock.writeUnlock(page + LOCK_OFFSET, PageIdUtils.tag(actualId)); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java index d7c61e9b114ff..1408383be168e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java @@ -19,6 +19,7 @@ import java.nio.ByteBuffer; import java.util.Map; +import java.util.function.Predicate; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.pagemem.PageMemory; @@ -243,10 +244,19 @@ public void initializeForCache(CacheGroupDescriptor grpDesc, StoredCacheData cac public void cleanupPersistentSpace(CacheConfiguration cacheConfiguration) throws IgniteCheckedException; /** - * Cleanup persistent space for all caches. + * Cleanup persistent space for all caches except metastore. */ public void cleanupPersistentSpace() throws IgniteCheckedException; + /** + * Cleanup cache store whether it matches the provided predicate and if matched + * store was previously initizlized. + * + * @param cacheGrpPred Predicate to match by id cache group stores to clean. + * @param cleanFiles {@code True} to delete all persisted files related to particular store. + */ + public void cleanupPageStoreIfMatch(Predicate cacheGrpPred, boolean cleanFiles); + /** * Creates and initializes cache work directory retrieved from {@code cacheCfg}. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/IgniteWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/IgniteWriteAheadLogManager.java index 12fd3e94bd0fe..7b8333f17aa04 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/IgniteWriteAheadLogManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/IgniteWriteAheadLogManager.java @@ -19,10 +19,13 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.pagemem.wal.record.RolloverType; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.processors.cache.GridCacheSharedManager; import org.apache.ignite.internal.processors.cache.persistence.StorageException; import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport; +import org.apache.ignite.lang.IgniteBiPredicate; +import org.jetbrains.annotations.Nullable; /** * @@ -46,13 +49,15 @@ public interface IgniteWriteAheadLogManager extends GridCacheSharedManager, Igni /** * Resumes logging after start. When WAL manager is started, it will skip logging any updates until this * method is called to avoid logging changes induced by the state restore procedure. + * + * @throws IgniteCheckedException If fails. */ public void resumeLogging(WALPointer lastWrittenPtr) throws IgniteCheckedException; /** * Appends the given log entry to the write-ahead log. * - * @param entry entry to log. + * @param entry Entry to log. * @return WALPointer that may be passed to {@link #flush(WALPointer, boolean)} method to make sure the record is * written to the log. * @throws IgniteCheckedException If failed to construct log entry. @@ -60,6 +65,22 @@ public interface IgniteWriteAheadLogManager extends GridCacheSharedManager, Igni */ public WALPointer log(WALRecord entry) throws IgniteCheckedException, StorageException; + /** + * Appends the given log entry to the write-ahead log. If entry logging leads to rollover, caller can specify + * whether to write the entry to the current segment or to th next one. + * + * @param entry Entry to log. + * @param rolloverType Rollover type. + * @return WALPointer that may be passed to {@link #flush(WALPointer, boolean)} method to make sure the record is + * written to the log. + * @throws IgniteCheckedException If failed to construct log entry. + * @throws StorageException If IO error occurred while writing log entry. + * + * @see RolloverType + */ + public WALPointer log(WALRecord entry, RolloverType rolloverType) + throws IgniteCheckedException, StorageException; + /** * Makes sure that all log entries written to the log up until the specified pointer are actually written * to the underlying storage. @@ -72,6 +93,16 @@ public interface IgniteWriteAheadLogManager extends GridCacheSharedManager, Igni */ public void flush(WALPointer ptr, boolean explicitFsync) throws IgniteCheckedException, StorageException; + /** + * Reads WAL record by the specified pointer. + * + * @param ptr WAL pointer. + * @return WAL record. + * @throws IgniteCheckedException If failed to read. + * @throws StorageException If IO error occurred while reading WAL entries. + */ + public WALRecord read(WALPointer ptr) throws IgniteCheckedException, StorageException; + /** * Invoke this method to iterate over the written log entries. * @@ -82,13 +113,26 @@ public interface IgniteWriteAheadLogManager extends GridCacheSharedManager, Igni */ public WALIterator replay(WALPointer start) throws IgniteCheckedException, StorageException; + /** + * Invoke this method to iterate over the written log entries. + * + * @param start Optional WAL pointer from which to start iteration. + * @param recordDeserializeFilter Specify a filter to skip WAL records. Those records will not be explicitly deserialized. + * @return Records iterator. + * @throws IgniteException If failed to start iteration. + * @throws StorageException If IO error occurred while reading WAL entries. + */ + public WALIterator replay( + WALPointer start, + @Nullable IgniteBiPredicate recordDeserializeFilter + ) throws IgniteCheckedException, StorageException; + /** * Invoke this method to reserve WAL history since provided pointer and prevent it's deletion. * * @param start WAL pointer. - * @throws IgniteException If failed to reserve. */ - public boolean reserve(WALPointer start) throws IgniteCheckedException; + public boolean reserve(WALPointer start); /** * Invoke this method to release WAL history since provided pointer that was previously reserved. @@ -162,9 +206,4 @@ public interface IgniteWriteAheadLogManager extends GridCacheSharedManager, Igni * @param grpId Group id. */ public boolean disabled(int grpId); - - /** - * Cleanup all directories relating to WAL (e.g. work WAL dir, archive WAL dir). - */ - public void cleanupWalDirectories() throws IgniteCheckedException; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/WALIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/WALIterator.java index 14fdfda8fe9cd..b3c9726f7f88c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/WALIterator.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/WALIterator.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.pagemem.wal; +import java.util.Optional; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.util.lang.GridCloseableIterator; import org.apache.ignite.lang.IgniteBiTuple; @@ -25,5 +26,8 @@ * */ public interface WALIterator extends GridCloseableIterator> { - // Iterator alias. + /** + * @return Pointer of last read valid record. Empty if no records were read. + */ + public Optional lastRead(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java index 7a4d6b8793a21..ef6c3bafbc307 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/DataRecord.java @@ -76,6 +76,16 @@ public DataRecord(List writeEntries, long timestamp) { this.writeEntries = writeEntries; } + /** + * @param writeEntries Write entries. + * @return {@code this} for chaining. + */ + public DataRecord setWriteEntries(List writeEntries) { + this.writeEntries = writeEntries; + + return this; + } + /** * @return Collection of write entries. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java index 403d77889e292..ba2fabc9f0eeb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java @@ -31,7 +31,7 @@ * Represents Data Entry ({@link #key}, {@link #val value}) pair update {@link #op operation}.
* This Data entry was not converted to key, value pair during record deserialization. */ -public class LazyDataEntry extends DataEntry { +public class LazyDataEntry extends DataEntry implements MarshalledDataEntry { /** */ private GridCacheSharedContext cctx; @@ -124,23 +124,23 @@ public LazyDataEntry( return val; } - /** @return Data Entry Key type code. See {@link CacheObject} for built-in value type codes */ - public byte getKeyType() { + /** {@inheritDoc} */ + @Override public byte getKeyType() { return keyType; } - /** @return Key value bytes. */ - public byte[] getKeyBytes() { + /** {@inheritDoc} */ + @Override public byte[] getKeyBytes() { return keyBytes; } - /** @return Data Entry Value type code. See {@link CacheObject} for built-in value type codes */ - public byte getValType() { + /** {@inheritDoc} */ + @Override public byte getValType() { return valType; } - /** @return Value value bytes. */ - public byte[] getValBytes() { + /** {@inheritDoc} */ + @Override public byte[] getValBytes() { return valBytes; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyMvccDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyMvccDataEntry.java index 15b146807dc44..a7ad86f4eaf82 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyMvccDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyMvccDataEntry.java @@ -32,7 +32,7 @@ * Represents Data Entry ({@link #key}, {@link #val value}) pair update {@link #op operation}.
* This Data entry was not converted to key, value pair during record deserialization. */ -public class LazyMvccDataEntry extends MvccDataEntry { +public class LazyMvccDataEntry extends MvccDataEntry implements MarshalledDataEntry { /** */ private GridCacheSharedContext cctx; @@ -127,23 +127,23 @@ public LazyMvccDataEntry( return val; } - /** @return Data Entry Key type code. See {@link CacheObject} for built-in value type codes */ - public byte getKeyType() { + /** {@inheritDoc} */ + @Override public byte getKeyType() { return keyType; } - /** @return Key value bytes. */ - public byte[] getKeyBytes() { + /** {@inheritDoc} */ + @Override public byte[] getKeyBytes() { return keyBytes; } - /** @return Data Entry Value type code. See {@link CacheObject} for built-in value type codes */ - public byte getValType() { + /** {@inheritDoc} */ + @Override public byte getValType() { return valType; } - /** @return Value value bytes. */ - public byte[] getValBytes() { + /** {@inheritDoc} */ + @Override public byte[] getValBytes() { return valBytes; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java new file mode 100644 index 0000000000000..c977d527941e9 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java @@ -0,0 +1,45 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.pagemem.wal.record; + +import org.apache.ignite.internal.processors.cache.CacheObject; + +/** + * Interface for Data Entry record that was not converted to key, value pair during record deserialization. + */ +public interface MarshalledDataEntry { + /** + * @return Data Entry Key type code. See {@link CacheObject} for built-in value type codes. + */ + byte getKeyType(); + + /** + * @return Key value bytes. + */ + byte[] getKeyBytes(); + + /** + * @return Data Entry Value type code. See {@link CacheObject} for built-in value type codes. + */ + byte getValType(); + + /** + * @return Value value bytes. + */ + byte[] getValBytes(); +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MemoryRecoveryRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MemoryRecoveryRecord.java index 8843eeedef90e..5a48b340d0ca4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MemoryRecoveryRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MemoryRecoveryRecord.java @@ -20,11 +20,11 @@ import org.apache.ignite.internal.util.typedef.internal.S; /** - * Marker that we start memory recovering + * Marker indicates that binary memory recovery has finished. */ public class MemoryRecoveryRecord extends WALRecord { /** Create timestamp, millis */ - private long time; + private final long time; /** * Default constructor. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MetastoreDataRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MetastoreDataRecord.java index e269de2adc012..9e734244c7b84 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MetastoreDataRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MetastoreDataRecord.java @@ -18,13 +18,14 @@ package org.apache.ignite.internal.pagemem.wal.record; +import org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage; import org.apache.ignite.internal.util.typedef.internal.S; import org.jetbrains.annotations.Nullable; /** * */ -public class MetastoreDataRecord extends WALRecord { +public class MetastoreDataRecord extends WALRecord implements WalRecordCacheGroupAware { /** */ private final String key; @@ -59,4 +60,9 @@ public String key() { @Override public String toString() { return S.toString(MetastoreDataRecord.class, this, "super", super.toString()); } + + /** {@inheritDoc} */ + @Override public int groupId() { + return MetaStorage.METASTORAGE_CACHE_ID; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MvccTxRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MvccTxRecord.java index 82c4409951f8d..86ad983db209e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MvccTxRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MvccTxRecord.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.Map; import org.apache.ignite.internal.processors.cache.mvcc.MvccVersion; +import org.apache.ignite.internal.processors.cache.mvcc.txlog.TxLog; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.transactions.TransactionState; @@ -29,7 +30,7 @@ * Logical data record indented for MVCC transaction related actions.
* This record is marker of prepare, commit, and rollback transactions. */ -public class MvccTxRecord extends TxRecord { +public class MvccTxRecord extends TxRecord implements WalRecordCacheGroupAware { /** Transaction mvcc snapshot version. */ private final MvccVersion mvccVer; @@ -85,6 +86,11 @@ public MvccVersion mvccVersion() { return mvccVer; } + /** {@inheritDoc} */ + @Override public int groupId() { + return TxLog.TX_LOG_CACHE_ID; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(MvccTxRecord.class, this, "super", super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/RolloverType.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/RolloverType.java new file mode 100644 index 0000000000000..1d99de1e79741 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/RolloverType.java @@ -0,0 +1,38 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.pagemem.wal.record; + +/** + * Defines WAL logging type with regard to segment rollover. + */ +public enum RolloverType { + /** Record being logged is not a rollover record. */ + NONE, + + /** + * Record being logged is a rollover record and it should get to the current segment whenever possible. + * If current segment is full, then the record gets to the next segment. Anyway, logging implementation should + * guarantee segment rollover afterwards. + */ + CURRENT_SEGMENT, + + /** + * Record being logged is a rollover record and it should become the first record in the next segment. + */ + NEXT_SEGMENT; +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/SnapshotRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/SnapshotRecord.java index c6b63295c781b..caa1494b00e3e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/SnapshotRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/SnapshotRecord.java @@ -51,11 +51,6 @@ public boolean isFull() { return full; } - /** {@inheritDoc} */ - @Override public boolean rollOver() { - return true; - } - /** * */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java index dbcc65176b6fa..5dd268b3b8ca8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java @@ -27,7 +27,7 @@ /** * Data Entry for automatic unwrapping key and value from Data Entry */ -public class UnwrapDataEntry extends DataEntry { +public class UnwrapDataEntry extends DataEntry implements UnwrappedDataEntry { /** Cache object value context. Context is used for unwrapping objects. */ private final CacheObjectValueContext cacheObjValCtx; @@ -64,13 +64,8 @@ public UnwrapDataEntry( this.keepBinary = keepBinary; } - /** - * Unwraps key value from cache key object into primitive boxed type or source class. If client classes were used - * in key, call of this method requires classes to be available in classpath. - * - * @return Key which was placed into cache. Or null if failed to convert. - */ - public Object unwrappedKey() { + /** {@inheritDoc} */ + @Override public Object unwrappedKey() { try { if (keepBinary && key instanceof BinaryObject) return key; @@ -93,13 +88,8 @@ public Object unwrappedKey() { } } - /** - * Unwraps value value from cache value object into primitive boxed type or source class. If client classes were - * used in key, call of this method requires classes to be available in classpath. - * - * @return Value which was placed into cache. Or null for delete operation or for failure. - */ - public Object unwrappedValue() { + /** {@inheritDoc} */ + @Override public Object unwrappedValue() { try { if (val == null) return null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapMvccDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapMvccDataEntry.java index 25d7a6e3f947b..c3c12a372e757 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapMvccDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapMvccDataEntry.java @@ -28,7 +28,7 @@ /** * Data Entry for automatic unwrapping key and value from Mvcc Data Entry */ -public class UnwrapMvccDataEntry extends MvccDataEntry { +public class UnwrapMvccDataEntry extends MvccDataEntry implements UnwrappedDataEntry { /** Cache object value context. Context is used for unwrapping objects. */ private final CacheObjectValueContext cacheObjValCtx; @@ -68,13 +68,8 @@ public UnwrapMvccDataEntry( this.keepBinary = keepBinary; } - /** - * Unwraps key value from cache key object into primitive boxed type or source class. If client classes were used - * in key, call of this method requires classes to be available in classpath. - * - * @return Key which was placed into cache. Or null if failed to convert. - */ - public Object unwrappedKey() { + /** {@inheritDoc} */ + @Override public Object unwrappedKey() { try { if (keepBinary && key instanceof BinaryObject) return key; @@ -97,13 +92,8 @@ public Object unwrappedKey() { } } - /** - * Unwraps value value from cache value object into primitive boxed type or source class. If client classes were - * used in key, call of this method requires classes to be available in classpath. - * - * @return Value which was placed into cache. Or null for delete operation or for failure. - */ - public Object unwrappedValue() { + /** {@inheritDoc} */ + @Override public Object unwrappedValue() { try { if (val == null) return null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java new file mode 100644 index 0000000000000..b3a20b9ca0525 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java @@ -0,0 +1,39 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.pagemem.wal.record; + +/** + * Interface for Data Entry for automatic unwrapping key and value from Data Entry + */ +public interface UnwrappedDataEntry { + /** + * Unwraps key value from cache key object into primitive boxed type or source class. If client classes were used in + * key, call of this method requires classes to be available in classpath. + * + * @return Key which was placed into cache. Or null if failed to convert. + */ + Object unwrappedKey(); + + /** + * Unwraps value value from cache value object into primitive boxed type or source class. If client classes were + * used in key, call of this method requires classes to be available in classpath. + * + * @return Value which was placed into cache. Or null for delete operation or for failure. + */ + Object unwrappedValue(); +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/WALRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/WALRecord.java index 88f24af0dedc1..5d7276838ed3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/WALRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/WALRecord.java @@ -19,9 +19,12 @@ import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.internal.S; +import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordPurpose.*; + /** * Log entry abstract class. */ @@ -32,126 +35,126 @@ public abstract class WALRecord { */ public enum RecordType { /** */ - TX_RECORD, + TX_RECORD (LOGICAL), /** */ - PAGE_RECORD, + PAGE_RECORD (PHYSICAL), /** */ - DATA_RECORD, + DATA_RECORD (LOGICAL), /** Checkpoint (begin) record */ - CHECKPOINT_RECORD, + CHECKPOINT_RECORD (PHYSICAL), /** WAL segment header record. */ - HEADER_RECORD, + HEADER_RECORD (INTERNAL), // Delta records. /** */ - INIT_NEW_PAGE_RECORD, + INIT_NEW_PAGE_RECORD (PHYSICAL), /** */ - DATA_PAGE_INSERT_RECORD, + DATA_PAGE_INSERT_RECORD (PHYSICAL), /** */ - DATA_PAGE_INSERT_FRAGMENT_RECORD, + DATA_PAGE_INSERT_FRAGMENT_RECORD (PHYSICAL), /** */ - DATA_PAGE_REMOVE_RECORD, + DATA_PAGE_REMOVE_RECORD (PHYSICAL), /** */ - DATA_PAGE_SET_FREE_LIST_PAGE, + DATA_PAGE_SET_FREE_LIST_PAGE (PHYSICAL), /** */ - BTREE_META_PAGE_INIT_ROOT, + BTREE_META_PAGE_INIT_ROOT (PHYSICAL), /** */ - BTREE_META_PAGE_ADD_ROOT, + BTREE_META_PAGE_ADD_ROOT (PHYSICAL), /** */ - BTREE_META_PAGE_CUT_ROOT, + BTREE_META_PAGE_CUT_ROOT (PHYSICAL), /** */ - BTREE_INIT_NEW_ROOT, + BTREE_INIT_NEW_ROOT (PHYSICAL), /** */ - BTREE_PAGE_RECYCLE, + BTREE_PAGE_RECYCLE (PHYSICAL), /** */ - BTREE_PAGE_INSERT, + BTREE_PAGE_INSERT (PHYSICAL), /** */ - BTREE_FIX_LEFTMOST_CHILD, + BTREE_FIX_LEFTMOST_CHILD (PHYSICAL), /** */ - BTREE_FIX_COUNT, + BTREE_FIX_COUNT (PHYSICAL), /** */ - BTREE_PAGE_REPLACE, + BTREE_PAGE_REPLACE (PHYSICAL), /** */ - BTREE_PAGE_REMOVE, + BTREE_PAGE_REMOVE (PHYSICAL), /** */ - BTREE_PAGE_INNER_REPLACE, + BTREE_PAGE_INNER_REPLACE (PHYSICAL), /** */ - BTREE_FIX_REMOVE_ID, + BTREE_FIX_REMOVE_ID (PHYSICAL), /** */ - BTREE_FORWARD_PAGE_SPLIT, + BTREE_FORWARD_PAGE_SPLIT (PHYSICAL), /** */ - BTREE_EXISTING_PAGE_SPLIT, + BTREE_EXISTING_PAGE_SPLIT (PHYSICAL), /** */ - BTREE_PAGE_MERGE, + BTREE_PAGE_MERGE (PHYSICAL), /** */ - PAGES_LIST_SET_NEXT, + PAGES_LIST_SET_NEXT (PHYSICAL), /** */ - PAGES_LIST_SET_PREVIOUS, + PAGES_LIST_SET_PREVIOUS (PHYSICAL), /** */ - PAGES_LIST_INIT_NEW_PAGE, + PAGES_LIST_INIT_NEW_PAGE (PHYSICAL), /** */ - PAGES_LIST_ADD_PAGE, + PAGES_LIST_ADD_PAGE (PHYSICAL), /** */ - PAGES_LIST_REMOVE_PAGE, + PAGES_LIST_REMOVE_PAGE (PHYSICAL), /** */ - META_PAGE_INIT, + META_PAGE_INIT (PHYSICAL), /** */ - PARTITION_META_PAGE_UPDATE_COUNTERS, + PARTITION_META_PAGE_UPDATE_COUNTERS (PHYSICAL), /** Memory recovering start marker */ MEMORY_RECOVERY, /** */ - TRACKING_PAGE_DELTA, + TRACKING_PAGE_DELTA (PHYSICAL), /** Meta page update last successful snapshot id. */ - META_PAGE_UPDATE_LAST_SUCCESSFUL_SNAPSHOT_ID, + META_PAGE_UPDATE_LAST_SUCCESSFUL_SNAPSHOT_ID (MIXED), /** Meta page update last successful full snapshot id. */ - META_PAGE_UPDATE_LAST_SUCCESSFUL_FULL_SNAPSHOT_ID, + META_PAGE_UPDATE_LAST_SUCCESSFUL_FULL_SNAPSHOT_ID (MIXED), /** Meta page update next snapshot id. */ - META_PAGE_UPDATE_NEXT_SNAPSHOT_ID, + META_PAGE_UPDATE_NEXT_SNAPSHOT_ID (MIXED), /** Meta page update last allocated index. */ - META_PAGE_UPDATE_LAST_ALLOCATED_INDEX, + META_PAGE_UPDATE_LAST_ALLOCATED_INDEX (MIXED), /** Partition meta update state. */ - PART_META_UPDATE_STATE, + PART_META_UPDATE_STATE (MIXED), /** Page list meta reset count record. */ - PAGE_LIST_META_RESET_COUNT_RECORD, + PAGE_LIST_META_RESET_COUNT_RECORD (PHYSICAL), /** Switch segment record. * Marker record for indicate end of segment. @@ -160,22 +163,22 @@ public enum RecordType { * that one byte in the end,then we write SWITCH_SEGMENT_RECORD as marker end of segment. * No need write CRC or WAL pointer for this record. It is byte marker record. * */ - SWITCH_SEGMENT_RECORD, + SWITCH_SEGMENT_RECORD (INTERNAL), /** */ - DATA_PAGE_UPDATE_RECORD, + DATA_PAGE_UPDATE_RECORD (PHYSICAL), /** init */ - BTREE_META_PAGE_INIT_ROOT2, + BTREE_META_PAGE_INIT_ROOT2 (PHYSICAL), /** Partition destroy. */ - PARTITION_DESTROY, + PARTITION_DESTROY (PHYSICAL), /** Snapshot record. */ SNAPSHOT, /** Metastore data record. */ - METASTORE_DATA_RECORD, + METASTORE_DATA_RECORD (LOGICAL), /** Exchange record. */ EXCHANGE, @@ -184,28 +187,57 @@ public enum RecordType { RESERVED, /** Rotated id part record. */ - ROTATED_ID_PART_RECORD, + ROTATED_ID_PART_RECORD (PHYSICAL), /** */ - MVCC_DATA_PAGE_MARK_UPDATED_RECORD, + MVCC_DATA_PAGE_MARK_UPDATED_RECORD (PHYSICAL), /** */ - MVCC_DATA_PAGE_TX_STATE_HINT_UPDATED_RECORD, + MVCC_DATA_PAGE_TX_STATE_HINT_UPDATED_RECORD (PHYSICAL), /** */ - MVCC_DATA_PAGE_NEW_TX_STATE_HINT_UPDATED_RECORD, + MVCC_DATA_PAGE_NEW_TX_STATE_HINT_UPDATED_RECORD (PHYSICAL), /** Encrypted WAL-record. */ - ENCRYPTED_RECORD, + ENCRYPTED_RECORD (PHYSICAL), /** Ecnrypted data record. */ - ENCRYPTED_DATA_RECORD, + ENCRYPTED_DATA_RECORD (LOGICAL), /** Mvcc data record. */ - MVCC_DATA_RECORD, + MVCC_DATA_RECORD (LOGICAL), /** Mvcc Tx state change record. */ - MVCC_TX_RECORD; + MVCC_TX_RECORD (LOGICAL); + + /** + * When you're adding a new record don't forget to choose record purpose explicitly + * if record is needed for physical or logical recovery. + * By default the purpose of record is {@link RecordPurpose#CUSTOM} and this record will not be used in recovery process. + * For more information read description of {@link RecordPurpose}. + */ + private final RecordPurpose purpose; + + /** + * @param purpose Purpose. + */ + RecordType(RecordPurpose purpose) { + this.purpose = purpose; + } + + /** + * Default constructor. + */ + RecordType() { + this(CUSTOM); + } + + /** + * @return Purpose of record. + */ + public RecordPurpose purpose() { + return purpose; + } /** */ private static final RecordType[] VALS = RecordType.values(); @@ -223,6 +255,37 @@ public static RecordType fromOrdinal(int ord) { public static final int STOP_ITERATION_RECORD_TYPE = 0; } + /** + * Record purposes set. + */ + public enum RecordPurpose { + /** + * Internal records are needed for correct iterating over WAL structure. + * These records will never be returned to user during WAL iteration. + */ + INTERNAL, + /** + * Physical records are needed for correct recovering physical state of {@link org.apache.ignite.internal.pagemem.PageMemory}. + * {@link org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager#restoreBinaryMemory(org.apache.ignite.lang.IgnitePredicate, org.apache.ignite.lang.IgniteBiPredicate)}. + */ + PHYSICAL, + /** + * Logical records are needed to replay logical updates since last checkpoint. + * {@link GridCacheDatabaseSharedManager#applyLogicalUpdates(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.CheckpointStatus, org.apache.ignite.lang.IgnitePredicate, org.apache.ignite.lang.IgniteBiPredicate, boolean)} + */ + LOGICAL, + /** + * Physical-logical records are used both for physical and logical recovery. + * Usually these records contain meta-information about partitions. + * NOTE: Not recommend to use this type without strong reason. + */ + MIXED, + /** + * Custom records are needed for any custom iterations over WAL in various components. + */ + CUSTOM + } + /** */ private int size; @@ -296,13 +359,6 @@ public void size(int size) { this.size = size; } - /** - * @return Need wal rollOver. - */ - public boolean rollOver(){ - return false; - } - /** * @return Entry type. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateNextSnapshotId.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateNextSnapshotId.java index 2046ecd274d95..5068fe5b45ec5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateNextSnapshotId.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdateNextSnapshotId.java @@ -27,22 +27,22 @@ */ public class MetaPageUpdateNextSnapshotId extends PageDeltaRecord { /** */ - private final long nextSnapshotId; + private final long nextSnapshotTag; /** * @param pageId Meta page ID. */ - public MetaPageUpdateNextSnapshotId(int grpId, long pageId, long nextSnapshotId) { + public MetaPageUpdateNextSnapshotId(int grpId, long pageId, long nextSnapshotTag) { super(grpId, pageId); - this.nextSnapshotId = nextSnapshotId; + this.nextSnapshotTag = nextSnapshotTag; } /** {@inheritDoc} */ @Override public void applyDelta(PageMemory pageMem, long pageAddr) throws IgniteCheckedException { PageMetaIO io = PageMetaIO.VERSIONS.forPage(pageAddr); - io.setNextSnapshotTag(pageAddr, nextSnapshotId); + io.setNextSnapshotTag(pageAddr, nextSnapshotTag); } /** {@inheritDoc} */ @@ -54,7 +54,7 @@ public MetaPageUpdateNextSnapshotId(int grpId, long pageId, long nextSnapshotId) * @return Root ID. */ public long nextSnapshotId() { - return nextSnapshotId; + return nextSnapshotTag; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdatePartitionDataRecord.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdatePartitionDataRecord.java index e5bd343bcb5ee..28294a9f2cd5b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdatePartitionDataRecord.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/delta/MetaPageUpdatePartitionDataRecord.java @@ -55,7 +55,8 @@ public MetaPageUpdatePartitionDataRecord( long updateCntr, long globalRmvId, int partSize, - long cntrsPageId, byte state, + long cntrsPageId, + byte state, int allocatedIdxCandidate ) { super(grpId, pageId); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityAssignment.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityAssignment.java index eb06d3e60b873..b603c32a8f6ec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityAssignment.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityAssignment.java @@ -22,7 +22,6 @@ import java.util.Set; import java.util.UUID; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; /** * Cached affinity calculations. @@ -84,9 +83,4 @@ public interface AffinityAssignment { * @return Backup partitions for specified node ID. */ public Set backupPartitions(UUID nodeId); - - /** - * @return Mvcc coordinator. - */ - public MvccCoordinator mvccCoordinator(); } \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityTopologyVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityTopologyVersion.java index 44b27534dee62..2c02f26be6641 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityTopologyVersion.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/AffinityTopologyVersion.java @@ -112,6 +112,15 @@ public int minorTopologyVersion() { return cmp; } + /** + * @param lower Lower bound. + * @param upper Upper bound. + * @return {@code True} if this topology version is within provided bounds (inclusive). + */ + public boolean isBetween(AffinityTopologyVersion lower, AffinityTopologyVersion upper) { + return compareTo(lower) >= 0 && compareTo(upper) <= 0; + } + /** {@inheritDoc} */ @Override public void onAckReceived() { // No-op. @@ -219,4 +228,4 @@ public int minorTopologyVersion() { @Override public String toString() { return S.toString(AffinityTopologyVersion.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java index fe5103681a999..95cf76fc58144 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java @@ -27,7 +27,6 @@ import java.util.Set; import java.util.UUID; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; import org.apache.ignite.internal.util.typedef.internal.S; /** @@ -41,9 +40,6 @@ public class GridAffinityAssignment implements AffinityAssignment, Serializable /** Topology version. */ private final AffinityTopologyVersion topVer; - /** */ - private final MvccCoordinator mvccCrd; - /** Collection of calculated affinity nodes. */ private List> assignment; @@ -74,7 +70,6 @@ public class GridAffinityAssignment implements AffinityAssignment, Serializable this.topVer = topVer; primary = new HashMap<>(); backup = new HashMap<>(); - mvccCrd = null; } /** @@ -84,8 +79,7 @@ public class GridAffinityAssignment implements AffinityAssignment, Serializable */ GridAffinityAssignment(AffinityTopologyVersion topVer, List> assignment, - List> idealAssignment, - MvccCoordinator mvccCrd) { + List> idealAssignment) { assert topVer != null; assert assignment != null; assert idealAssignment != null; @@ -93,7 +87,6 @@ public class GridAffinityAssignment implements AffinityAssignment, Serializable this.topVer = topVer; this.assignment = assignment; this.idealAssignment = idealAssignment.equals(assignment) ? assignment : idealAssignment; - this.mvccCrd = mvccCrd; primary = new HashMap<>(); backup = new HashMap<>(); @@ -112,7 +105,6 @@ public class GridAffinityAssignment implements AffinityAssignment, Serializable idealAssignment = aff.idealAssignment; primary = aff.primary; backup = aff.backup; - mvccCrd = aff.mvccCrd; } /** @@ -275,11 +267,6 @@ private void initPrimaryBackupMaps() { } } - /** {@inheritDoc} */ - @Override public MvccCoordinator mvccCoordinator() { - return mvccCrd; - } - /** {@inheritDoc} */ @Override public int hashCode() { return topVer.hashCode(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java index 2290ce6bee725..8510a9006526b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java @@ -43,7 +43,6 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.NodeOrderComparator; import org.apache.ignite.internal.managers.discovery.DiscoCache; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; import org.apache.ignite.internal.processors.cache.ExchangeDiscoveryEvents; import org.apache.ignite.internal.processors.cluster.BaselineTopology; import org.apache.ignite.internal.util.future.GridFutureAdapter; @@ -203,28 +202,11 @@ public int groupId() { * @param affAssignment Affinity assignment for topology version. */ public void initialize(AffinityTopologyVersion topVer, List> affAssignment) { - MvccCoordinator mvccCrd = null; - - if (!locCache) - mvccCrd = ctx.cache().context().coordinators().currentCoordinator(topVer); - - initialize(topVer, affAssignment, mvccCrd); - } - - /** - * Initializes affinity with given topology version and assignment. - * - * @param topVer Topology version. - * @param affAssignment Affinity assignment for topology version. - * @param mvccCrd Mvcc coordinator. - */ - public void initialize(AffinityTopologyVersion topVer, List> affAssignment, MvccCoordinator mvccCrd) { assert topVer.compareTo(lastVersion()) >= 0 : "[topVer = " + topVer + ", last=" + lastVersion() + ']'; assert idealAssignment != null; - assert mvccCrd == null || topVer.compareTo(mvccCrd.topologyVersion()) >= 0 : "[mvccCrd=" + mvccCrd + ", topVer=" + topVer + ']'; - GridAffinityAssignment assignment = new GridAffinityAssignment(topVer, affAssignment, idealAssignment, mvccCrd); + GridAffinityAssignment assignment = new GridAffinityAssignment(topVer, affAssignment, idealAssignment); HistoryAffinityAssignment hAff = affCache.put(topVer, new HistoryAffinityAssignment(assignment)); @@ -691,19 +673,41 @@ public AffinityAssignment readyAffinity(AffinityTopologyVersion topVer) { * @return Cached affinity. */ public AffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) { + AffinityTopologyVersion lastAffChangeTopVer = + ctx.cache().context().exchange().lastAffinityChangedTopologyVersion(topVer); + + return cachedAffinity(topVer, lastAffChangeTopVer); + } + + /** + * Get cached affinity for specified topology version. + * + * @param topVer Topology version. + * @return Cached affinity. + */ + public AffinityAssignment cachedAffinity(AffinityTopologyVersion topVer, AffinityTopologyVersion lastAffChangeTopVer) { if (topVer.equals(AffinityTopologyVersion.NONE)) - topVer = lastVersion(); - else - awaitTopologyVersion(topVer); + topVer = lastAffChangeTopVer = lastVersion(); + else { + if (lastAffChangeTopVer.equals(AffinityTopologyVersion.NONE)) + lastAffChangeTopVer = topVer; + + awaitTopologyVersion(lastAffChangeTopVer); + } assert topVer.topologyVersion() >= 0 : topVer; AffinityAssignment cache = head.get(); - if (!cache.topologyVersion().equals(topVer)) { - cache = affCache.get(topVer); + if (!(cache.topologyVersion().compareTo(lastAffChangeTopVer) >= 0 && + cache.topologyVersion().compareTo(topVer) <= 0)) { - if (cache == null) { + Map.Entry e = affCache.ceilingEntry(lastAffChangeTopVer); + + if (e != null) + cache = e.getValue(); + + if (cache == null || cache.topologyVersion().compareTo(topVer) > 0) { throw new IllegalStateException("Getting affinity for topology version earlier than affinity is " + "calculated [locNode=" + ctx.discovery().localNode() + ", grp=" + cacheOrGrpName + @@ -714,7 +718,8 @@ public AffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) { } } - assert cache.topologyVersion().equals(topVer) : "Invalid cached affinity: " + cache; + assert cache.topologyVersion().compareTo(lastAffChangeTopVer) >= 0 && + cache.topologyVersion().compareTo(topVer) <= 0 : "Invalid cached affinity: [cache=" + cache + ", topVer=" + topVer + ", lastAffChangedTopVer=" + lastAffChangeTopVer + "]"; return cache; } @@ -765,7 +770,7 @@ public void init(GridAffinityAssignmentCache aff) { AffinityAssignment assign = aff.cachedAffinity(aff.lastVersion()); - initialize(aff.lastVersion(), assign.assignment(), assign.mvccCoordinator()); + initialize(aff.lastVersion(), assign.assignment()); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java index 4a0908c6071f6..08333c33e131a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java @@ -423,7 +423,7 @@ private Map> keysToNodes(@Nullable final String c try { GridAffinityAssignment assign = assign0 instanceof GridAffinityAssignment ? (GridAffinityAssignment)assign0 : - new GridAffinityAssignment(topVer, assign0.assignment(), assign0.idealAssignment(), assign0.mvccCoordinator()); + new GridAffinityAssignment(topVer, assign0.assignment(), assign0.idealAssignment()); AffinityInfo info = new AffinityInfo( cctx.config().getAffinity(), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java index 15d7e4e437ea7..abd5292799958 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityUtils.java @@ -184,7 +184,7 @@ public AffinityJob() { GridAffinityAssignment assign = assign0 instanceof GridAffinityAssignment ? (GridAffinityAssignment)assign0 : - new GridAffinityAssignment(topVer, assign0.assignment(), assign0.idealAssignment(), assign0.mvccCoordinator()); + new GridAffinityAssignment(topVer, assign0.assignment(), assign0.idealAssignment()); return F.t( affinityMessage(ctx, cctx.config().getAffinity()), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/HistoryAffinityAssignment.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/HistoryAffinityAssignment.java index a9496486fb965..6bdf7f0f52092 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/HistoryAffinityAssignment.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/HistoryAffinityAssignment.java @@ -17,16 +17,14 @@ package org.apache.ignite.internal.processors.affinity; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; - import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.UUID; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; /** * @@ -42,9 +40,6 @@ public class HistoryAffinityAssignment implements AffinityAssignment { /** */ private final List> idealAssignment; - /** */ - private final MvccCoordinator mvccCrd; - /** * @param assign Assignment. */ @@ -52,12 +47,6 @@ public class HistoryAffinityAssignment implements AffinityAssignment { this.topVer = assign.topologyVersion(); this.assignment = assign.assignment(); this.idealAssignment = assign.idealAssignment(); - this.mvccCrd = assign.mvccCoordinator(); - } - - /** {@inheritDoc} */ - @Override public MvccCoordinator mvccCoordinator() { - return mvccCrd; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/UserAuthenticateResponseMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/UserAuthenticateResponseMessage.java index d86b1ad91a551..e3dee3ce92a4f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/UserAuthenticateResponseMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/UserAuthenticateResponseMessage.java @@ -98,7 +98,6 @@ public IgniteUuid id() { writer.incrementState(); - } return true; @@ -127,6 +126,7 @@ public IgniteUuid id() { return false; reader.incrementState(); + } return reader.afterMessageRead(UserAuthenticateResponseMessage.class); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java index 0dda7ef496678..4cc0788bfbfeb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java @@ -23,14 +23,17 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.stream.Collectors; import javax.cache.CacheException; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cache.affinity.AffinityFunction; import org.apache.ignite.cluster.ClusterNode; @@ -58,7 +61,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState; import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.internal.util.GridPartitionStateMap; @@ -359,11 +361,7 @@ public Set waitGroups() { void onCacheGroupCreated(CacheGroupContext grp) { if (!grpHolders.containsKey(grp.groupId())) { cctx.io().addCacheGroupHandler(grp.groupId(), GridDhtAffinityAssignmentResponse.class, - new IgniteBiInClosure() { - @Override public void apply(UUID nodeId, GridDhtAffinityAssignmentResponse res) { - processAffinityAssignmentResponse(nodeId, res); - } - }); + (IgniteBiInClosure) this::processAffinityAssignmentResponse); } } @@ -425,25 +423,43 @@ void onCacheGroupCreated(CacheGroupContext grp) { Map fetchFuts = U.newHashMap(startDescs.size()); - Set startedCaches = U.newHashSet(startDescs.size()); - Map startedInfos = U.newHashMap(startDescs.size()); - for (DynamicCacheDescriptor desc : startDescs) { - try { - startedCaches.add(desc.cacheName()); - - DynamicCacheChangeRequest startReq = startReqs.get(desc.cacheName()); + List startCacheInfos = startDescs.stream() + .map(desc -> { + DynamicCacheChangeRequest changeReq = startReqs.get(desc.cacheName()); - cctx.cache().prepareCacheStart( - desc.cacheConfiguration(), + return new StartCacheInfo( desc, - startReq.nearCacheConfiguration(), + changeReq.nearCacheConfiguration(), topVer, - startReq.disabledAfterStart() + changeReq.disabledAfterStart() ); + }) + .collect(Collectors.toList()); + + Set startedCaches = startCacheInfos.stream() + .map(info -> info.getCacheDescriptor().cacheName()) + .collect(Collectors.toSet()); + + try { + cctx.cache().prepareStartCaches(startCacheInfos); + } + catch (IgniteCheckedException e) { + cctx.cache().closeCaches(startedCaches, false); + + cctx.cache().completeClientCacheChangeFuture(msg.requestId(), e); + + return null; + } + + for (StartCacheInfo startCacheInfo : startCacheInfos) { + try { + DynamicCacheDescriptor desc = startCacheInfo.getCacheDescriptor(); + + startedCaches.add(desc.cacheName()); - startedInfos.put(desc.cacheId(), startReq.nearCacheConfiguration() != null); + startedInfos.put(desc.cacheId(), startCacheInfo.getReqNearCfg() != null); CacheGroupContext grp = cctx.cache().cacheGroup(desc.groupId()); @@ -463,7 +479,6 @@ void onCacheGroupCreated(CacheGroupContext grp) { grp.topology().updateTopologyVersion(topFut, discoCache, - cctx.coordinators().currentCoordinator(), -1, false); @@ -513,7 +528,6 @@ else if (!fetchFuts.containsKey(grp.groupId())) { assert grp != null; GridDhtAffinityAssignmentResponse res = fetchAffinity(topVer, - cctx.coordinators().currentCoordinator(), null, discoCache, grp.affinity(), @@ -538,7 +552,6 @@ else if (!fetchFuts.containsKey(grp.groupId())) { grp.topology().updateTopologyVersion(topFut, discoCache, - cctx.coordinators().currentCoordinator(), -1, false); @@ -785,15 +798,12 @@ public IgniteInternalFuture onCacheChangeRequest( ) throws IgniteCheckedException { assert exchActions != null && !exchActions.empty() : exchActions; - long time = System.currentTimeMillis(); - IgniteInternalFuture res = cachesRegistry.update(exchActions); // Affinity did not change for existing caches. onCustomMessageNoAffinityChange(fut, crd, exchActions); - if (log.isInfoEnabled()) - log.info("Updating caches registry performed in " + (System.currentTimeMillis() - time) + " ms."); + fut.timeBag().finishGlobalStage("Update caches registry"); processCacheStartRequests(fut, crd, exchActions); @@ -856,7 +866,7 @@ private void processCacheStartRequests( final ExchangeDiscoveryEvents evts = fut.context().events(); - long time = System.currentTimeMillis(); + Map startCacheInfos = new LinkedHashMap<>(); for (ExchangeActions.CacheActionData action : exchActions.cacheStartRequests()) { DynamicCacheDescriptor cacheDesc = action.descriptor(); @@ -893,47 +903,80 @@ private void processCacheStartRequests( } } - try { - if (startCache) { - cctx.cache().prepareCacheStart( + if (startCache) { + startCacheInfos.put( + new StartCacheInfo( req.startCacheConfiguration(), cacheDesc, nearCfg, evts.topologyVersion(), req.disabledAfterStart() - ); - - if (fut.cacheAddedOnExchange(cacheDesc.cacheId(), cacheDesc.receivedFrom())) { - if (fut.events().discoveryCache().cacheGroupAffinityNodes(cacheDesc.groupId()).isEmpty()) - U.quietAndWarn(log, "No server nodes found for cache client: " + req.cacheName()); - } - } + ), + req + ); } - catch (IgniteCheckedException e) { + } + + Map failedCaches = cctx.cache().prepareStartCachesIfPossible(startCacheInfos.keySet()); + + for (Map.Entry entry : failedCaches.entrySet()) { + if (cctx.localNode().isClient()) { U.error(log, "Failed to initialize cache. Will try to rollback cache start routine. " + - "[cacheName=" + req.cacheName() + ']', e); + "[cacheName=" + entry.getKey().getStartedConfiguration().getName() + ']', entry.getValue()); - cctx.cache().closeCaches(Collections.singleton(req.cacheName()), false); + cctx.cache().closeCaches(Collections.singleton(entry.getKey().getStartedConfiguration().getName()), false); - cctx.cache().completeCacheStartFuture(req, false, e); + cctx.cache().completeCacheStartFuture(startCacheInfos.get(entry.getKey()), false, entry.getValue()); } + else + throw entry.getValue(); } - if (log.isInfoEnabled()) - log.info("Caches starting performed in " + (System.currentTimeMillis() - time) + " ms."); + Set failedCacheInfos = failedCaches.keySet(); + + List cacheInfos = startCacheInfos.keySet().stream() + .filter(failedCacheInfos::contains) + .collect(Collectors.toList()); - time = System.currentTimeMillis(); + for (StartCacheInfo info : cacheInfos) { + if (fut.cacheAddedOnExchange(info.getCacheDescriptor().cacheId(), info.getCacheDescriptor().receivedFrom())) { + if (fut.events().discoveryCache().cacheGroupAffinityNodes(info.getCacheDescriptor().groupId()).isEmpty()) + U.quietAndWarn(log, "No server nodes found for cache client: " + info.getCacheDescriptor().cacheName()); + } + } - Set gprs = new HashSet<>(); + fut.timeBag().finishGlobalStage("Start caches"); - for (ExchangeActions.CacheActionData action : exchActions.cacheStartRequests()) { - int grpId = action.descriptor().groupId(); + initAffinityOnCacheGroupsStart(fut, exchActions, crd); + + fut.timeBag().finishGlobalStage("Affinity initialization on cache group start"); + } - if (gprs.add(grpId)) { + /** + * Initializes affinity for started cache groups received during {@code fut}. + * + * @param fut Exchange future. + * @param exchangeActions Exchange actions. + * @param crd {@code True} if local node is coordinator. + */ + private void initAffinityOnCacheGroupsStart( + GridDhtPartitionsExchangeFuture fut, + ExchangeActions exchangeActions, + boolean crd + ) throws IgniteCheckedException { + List startedGroups = exchangeActions.cacheStartRequests().stream() + .map(action -> action.descriptor().groupDescriptor()) + .distinct() + .collect(Collectors.toList()); + + U.doInParallel( + cctx.kernalContext().getSystemExecutorService(), + startedGroups, + grpDesc -> { if (crd) - initStartedGroupOnCoordinator(fut, action.descriptor().groupDescriptor()); + initStartedGroupOnCoordinator(fut, grpDesc); else { - CacheGroupContext grp = cctx.cache().cacheGroup(grpId); + CacheGroupContext grp = cctx.cache().cacheGroup(grpDesc.groupId()); if (grp != null && !grp.isLocal() && grp.localStartVersion().equals(fut.initialVersion())) { assert grp.affinity().lastVersion().equals(AffinityTopologyVersion.NONE) : grp.affinity().lastVersion(); @@ -941,11 +984,13 @@ private void processCacheStartRequests( initAffinity(cachesRegistry.group(grp.groupId()), grp.affinity(), fut); } } - } - } - if (log.isInfoEnabled()) - log.info("Affinity initialization for started caches performed in " + (System.currentTimeMillis() - time) + " ms."); + fut.timeBag().finishLocalStage("Affinity initialization on cache group start " + + "[grp=" + grpDesc.cacheOrGroupName() + "]"); + + return null; + } + ); } /** @@ -954,7 +999,7 @@ private void processCacheStartRequests( * @param fut Exchange future. * @param crd Coordinator flag. * @param exchActions Cache change requests. - * @param forceClose + * @param forceClose Force close flag. * @return Set of cache groups to be stopped. */ private Set processCacheStopRequests( @@ -1011,9 +1056,11 @@ public void clearGroupHoldersAndRegistry() { * @param crd Coordinator flag. * @param msg Affinity change message. */ - public void onExchangeChangeAffinityMessage(GridDhtPartitionsExchangeFuture exchFut, + public void onExchangeChangeAffinityMessage( + GridDhtPartitionsExchangeFuture exchFut, boolean crd, - CacheAffinityChangeMessage msg) { + CacheAffinityChangeMessage msg + ) { if (log.isDebugEnabled()) { log.debug("Process exchange affinity change message [exchVer=" + exchFut.initialVersion() + ", msg=" + msg + ']'); @@ -1027,7 +1074,7 @@ public void onExchangeChangeAffinityMessage(GridDhtPartitionsExchangeFuture exch assert assignment != null; - final Map>> affCache = new HashMap<>(); + final Map>> affCache = new ConcurrentHashMap<>(); forAllCacheGroups(crd, new IgniteInClosureX() { @Override public void applyx(GridAffinityAssignmentCache aff) throws IgniteCheckedException { @@ -1049,6 +1096,9 @@ public void onExchangeChangeAffinityMessage(GridDhtPartitionsExchangeFuture exch newAssignment = idealAssignment; aff.initialize(topVer, cachedAssignment(aff, newAssignment, affCache)); + + exchFut.timeBag().finishLocalStage("Affinity recalculate by change affinity message " + + "[grp=" + aff.cacheOrGroupName() + "]"); } }); } @@ -1061,10 +1111,11 @@ public void onExchangeChangeAffinityMessage(GridDhtPartitionsExchangeFuture exch * @param msg Message. * @throws IgniteCheckedException If failed. */ - public void onChangeAffinityMessage(final GridDhtPartitionsExchangeFuture exchFut, + public void onChangeAffinityMessage( + final GridDhtPartitionsExchangeFuture exchFut, boolean crd, - final CacheAffinityChangeMessage msg) - throws IgniteCheckedException { + final CacheAffinityChangeMessage msg + ) { assert msg.topologyVersion() != null && msg.exchangeId() == null : msg; final AffinityTopologyVersion topVer = exchFut.initialVersion(); @@ -1080,7 +1131,7 @@ public void onChangeAffinityMessage(final GridDhtPartitionsExchangeFuture exchFu final Map deploymentIds = msg.cacheDeploymentIds(); - final Map>> affCache = new HashMap<>(); + final Map>> affCache = new ConcurrentHashMap<>(); forAllCacheGroups(crd, new IgniteInClosureX() { @Override public void applyx(GridAffinityAssignmentCache aff) throws IgniteCheckedException { @@ -1132,6 +1183,9 @@ public void onChangeAffinityMessage(final GridDhtPartitionsExchangeFuture exchFu aff.clientEventTopologyChange(exchFut.firstEvent(), topVer); cctx.exchange().exchangerUpdateHeartbeat(); + + exchFut.timeBag().finishLocalStage("Affinity change by custom message " + + "[grp=" + aff.cacheOrGroupName() + "]"); } }); } @@ -1196,14 +1250,21 @@ private void processAffinityAssignmentResponse(UUID nodeId, GridDhtAffinityAssig /** * @param c Cache closure. - * @throws IgniteCheckedException If failed */ - private void forAllRegisteredCacheGroups(IgniteInClosureX c) throws IgniteCheckedException { - for (CacheGroupDescriptor cacheDesc : cachesRegistry.allGroups().values()) { - if (cacheDesc.config().getCacheMode() == LOCAL) - continue; + private void forAllRegisteredCacheGroups(IgniteInClosureX c) { + Collection affinityCaches = cachesRegistry.allGroups().values().stream() + .filter(desc -> desc.config().getCacheMode() != LOCAL) + .collect(Collectors.toList()); - c.applyx(cacheDesc); + try { + U.doInParallel(cctx.kernalContext().getSystemExecutorService(), affinityCaches, t -> { + c.applyx(t); + + return null; + }); + } + catch (IgniteCheckedException e) { + throw new IgniteException("Failed to execute affinity operation on cache groups", e); } } @@ -1212,17 +1273,30 @@ private void forAllRegisteredCacheGroups(IgniteInClosureX * @param c Closure. */ private void forAllCacheGroups(boolean crd, IgniteInClosureX c) { + Collection affinityCaches; + if (crd) { - for (CacheGroupHolder grp : grpHolders.values()) - c.apply(grp.affinity()); + affinityCaches = grpHolders.values().stream() + .map(CacheGroupHolder::affinity) + .collect(Collectors.toList()); } else { - for (CacheGroupContext grp : cctx.kernalContext().cache().cacheGroups()) { - if (grp.isLocal()) - continue; + affinityCaches = cctx.kernalContext().cache().cacheGroups().stream() + .filter(grp -> !grp.isLocal()) + .filter(grp -> !grp.isRecoveryMode()) + .map(CacheGroupContext::affinity) + .collect(Collectors.toList()); + } - c.apply(grp.affinity()); - } + try { + U.doInParallel(cctx.kernalContext().getSystemExecutorService(), affinityCaches, t -> { + c.applyx(t); + + return null; + }); + } + catch (IgniteCheckedException e) { + throw new IgniteException("Failed to execute affinity operation on cache groups", e); } } @@ -1291,6 +1365,9 @@ public IgniteInternalFuture initStartedCaches( calculateAndInit(fut.events(), cache.affinity(), fut.initialVersion()); cctx.exchange().exchangerUpdateHeartbeat(); + + fut.timeBag().finishLocalStage("Affinity initialization (crd, new cache) " + + "[grp=" + desc.cacheOrGroupName() + "]"); } } }); @@ -1302,6 +1379,9 @@ public IgniteInternalFuture initStartedCaches( initAffinity(cachesRegistry.group(aff.groupId()), aff, fut); cctx.exchange().exchangerUpdateHeartbeat(); + + fut.timeBag().finishLocalStage("Affinity initialization (new cache) " + + "[grp=" + aff.cacheOrGroupName() + "]"); } } }); @@ -1335,7 +1415,6 @@ private void initAffinity(CacheGroupDescriptor desc, fetchFut.init(false); fetchAffinity(evts.topologyVersion(), - cctx.coordinators().currentCoordinator(), evts, evts.discoveryCache(), aff, @@ -1384,13 +1463,14 @@ public GridAffinityAssignmentCache affinity(Integer grpId) { * @param fut Current exchange future. * @param msg Finish exchange message. */ - public void applyAffinityFromFullMessage(final GridDhtPartitionsExchangeFuture fut, - final GridDhtPartitionsFullMessage msg) { - final Map nodesByOrder = new HashMap<>(); - - final Map>> affCache = new HashMap<>(); + public void applyAffinityFromFullMessage( + final GridDhtPartitionsExchangeFuture fut, + final GridDhtPartitionsFullMessage msg + ) { + // Please do not use following pattern of code (nodesByOrder, affCache). NEVER. + final Map nodesByOrder = new ConcurrentHashMap<>(); - long time = System.currentTimeMillis(); + final Map>> affCache = new ConcurrentHashMap<>(); forAllCacheGroups(false, new IgniteInClosureX() { @Override public void applyx(GridAffinityAssignmentCache aff) throws IgniteCheckedException { @@ -1423,11 +1503,11 @@ public void applyAffinityFromFullMessage(final GridDhtPartitionsExchangeFuture f newAssignment = idealAssignment; aff.initialize(evts.topologyVersion(), cachedAssignment(aff, newAssignment, affCache)); + + fut.timeBag().finishLocalStage("Affinity applying from full message " + + "[grp=" + aff.cacheOrGroupName() + "]"); } }); - - if (log.isInfoEnabled()) - log.info("Affinity applying from full message performed in " + (System.currentTimeMillis() - time) + " ms."); } /** @@ -1435,13 +1515,13 @@ public void applyAffinityFromFullMessage(final GridDhtPartitionsExchangeFuture f * @param msg Message finish message. * @param resTopVer Result topology version. */ - public void onLocalJoin(final GridDhtPartitionsExchangeFuture fut, + public void onLocalJoin( + final GridDhtPartitionsExchangeFuture fut, GridDhtPartitionsFullMessage msg, - final AffinityTopologyVersion resTopVer) { + final AffinityTopologyVersion resTopVer + ) { final Set affReq = fut.context().groupsAffinityRequestOnJoin(); - final Map nodesByOrder = new HashMap<>(); - final Map receivedAff = msg.joinedNodeAffinity(); assert F.isEmpty(affReq) || (!F.isEmpty(receivedAff) && receivedAff.size() >= affReq.size()) @@ -1450,7 +1530,7 @@ public void onLocalJoin(final GridDhtPartitionsExchangeFuture fut, ", receivedCnt=" + (receivedAff != null ? receivedAff.size() : "none") + ", msg=" + msg + "]"); - long time = System.currentTimeMillis(); + final Map nodesByOrder = new ConcurrentHashMap<>(); forAllCacheGroups(false, new IgniteInClosureX() { @Override public void applyx(GridAffinityAssignmentCache aff) throws IgniteCheckedException { @@ -1461,7 +1541,7 @@ public void onLocalJoin(final GridDhtPartitionsExchangeFuture fut, assert grp != null; if (affReq != null && affReq.contains(aff.groupId())) { - assert AffinityTopologyVersion.NONE.equals(aff.lastVersion()); + assert AffinityTopologyVersion.NONE.equals(aff.lastVersion()) : aff.lastVersion(); CacheGroupAffinityMessage affMsg = receivedAff.get(aff.groupId()); @@ -1469,7 +1549,8 @@ public void onLocalJoin(final GridDhtPartitionsExchangeFuture fut, List> assignments = affMsg.createAssignments(nodesByOrder, evts.discoveryCache()); - assert resTopVer.equals(evts.topologyVersion()); + assert resTopVer.equals(evts.topologyVersion()) : "resTopVer=" + resTopVer + + ", evts.topVer=" + evts.topologyVersion(); List> idealAssign = affMsg.createIdealAssignments(nodesByOrder, evts.discoveryCache()); @@ -1477,7 +1558,7 @@ public void onLocalJoin(final GridDhtPartitionsExchangeFuture fut, if (idealAssign != null) aff.idealAssignment(idealAssign); else { - assert !aff.centralizedAffinityFunction(); + assert !aff.centralizedAffinityFunction() : aff; // Calculate ideal assignments. aff.calculate(evts.topologyVersion(), evts, evts.discoveryCache()); @@ -1489,11 +1570,11 @@ else if (fut.cacheGroupAddedOnExchange(aff.groupId(), grp.receivedFrom())) calculateAndInit(evts, aff, evts.topologyVersion()); grp.topology().initPartitionsWhenAffinityReady(resTopVer, fut); + + fut.timeBag().finishLocalStage("Affinity initialization (local join) " + + "[grp=" + grp.cacheOrGroupName() + "]"); } }); - - if (log.isInfoEnabled()) - log.info("Affinity initialization on local join performed in " + (System.currentTimeMillis() - time) + " ms."); } /** @@ -1508,8 +1589,6 @@ public void onServerJoinWithExchangeMergeProtocol(GridDhtPartitionsExchangeFutur assert fut.context().mergeExchanges(); assert evts.hasServerJoin() && !evts.hasServerLeft(); - long time = System.currentTimeMillis(); - WaitRebalanceInfo waitRebalanceInfo = initAffinityOnNodeJoin(fut, crd); this.waitInfo = waitRebalanceInfo != null && !waitRebalanceInfo.empty() ? waitRebalanceInfo : null; @@ -1522,10 +1601,6 @@ public void onServerJoinWithExchangeMergeProtocol(GridDhtPartitionsExchangeFutur ", waitGrps=" + (info != null ? groupNames(info.waitGrps.keySet()) : null) + ']'); } } - - if (log.isInfoEnabled()) - log.info("Affinity recalculation (on server join) performed in " - + (System.currentTimeMillis() - time) + " ms."); } /** @@ -1536,8 +1611,6 @@ public void onServerJoinWithExchangeMergeProtocol(GridDhtPartitionsExchangeFutur public Map onServerLeftWithExchangeMergeProtocol( final GridDhtPartitionsExchangeFuture fut) throws IgniteCheckedException { - long time = System.currentTimeMillis(); - final ExchangeDiscoveryEvents evts = fut.context().events(); assert fut.context().mergeExchanges(); @@ -1545,10 +1618,6 @@ public Map onServerLeftWithExchangeMergeProt Map result = onReassignmentEnforced(fut); - if (log.isInfoEnabled()) - log.info("Affinity recalculation (on server left) performed in " - + (System.currentTimeMillis() - time) + " ms."); - return result; } @@ -1564,14 +1633,8 @@ public Map onCustomEventWithEnforcedAffinity { assert DiscoveryCustomEvent.requiresCentralizedAffinityAssignment(fut.firstEvent()); - long time = System.currentTimeMillis(); - Map result = onReassignmentEnforced(fut); - if (log.isInfoEnabled()) - log.info("Affinity recalculation (custom message) performed in " - + (System.currentTimeMillis() - time) + " ms."); - return result; } @@ -1597,6 +1660,9 @@ private Map onReassignmentEnforced( if (!cache.rebalanceEnabled || fut.cacheGroupAddedOnExchange(desc.groupId(), desc.receivedFrom())) cache.affinity().initialize(topVer, assign); + + fut.timeBag().finishLocalStage("Affinity initialization (enforced) " + + "[grp=" + desc.cacheOrGroupName() + "]"); } }); @@ -1634,11 +1700,17 @@ public void onServerJoin(final GridDhtPartitionsExchangeFuture fut, boolean crd) calculateAndInit(fut.events(), grpHolder.affinity(), topVer); cctx.exchange().exchangerUpdateHeartbeat(); + + fut.timeBag().finishLocalStage("First node affinity initialization (node join) " + + "[grp=" + desc.cacheOrGroupName() + "]"); } }); } - else + else { fetchAffinityOnJoin(fut); + + fut.timeBag().finishLocalStage("Affinity fetch"); + } } else waitRebalanceInfo = initAffinityOnNodeJoin(fut, crd); @@ -1773,7 +1845,6 @@ private void fetchAffinityOnJoin(GridDhtPartitionsExchangeFuture fut) throws Ign int grpId = fetchFut.groupId(); fetchAffinity(topVer, - cctx.coordinators().currentCoordinator(), fut.events(), fut.events().discoveryCache(), cctx.cache().cacheGroup(grpId).affinity(), @@ -1785,7 +1856,6 @@ private void fetchAffinityOnJoin(GridDhtPartitionsExchangeFuture fut) throws Ign /** * @param topVer Topology version. - * @param mvccCrd Mvcc coordinator to set in affinity. * @param events Discovery events. * @param discoCache Discovery data cache. * @param affCache Affinity. @@ -1795,12 +1865,11 @@ private void fetchAffinityOnJoin(GridDhtPartitionsExchangeFuture fut) throws Ign */ private GridDhtAffinityAssignmentResponse fetchAffinity( AffinityTopologyVersion topVer, - MvccCoordinator mvccCrd, @Nullable ExchangeDiscoveryEvents events, DiscoCache discoCache, GridAffinityAssignmentCache affCache, - GridDhtAssignmentFetchFuture fetchFut) - throws IgniteCheckedException { + GridDhtAssignmentFetchFuture fetchFut + ) throws IgniteCheckedException { assert affCache != null; GridDhtAffinityAssignmentResponse res = fetchFut.get(); @@ -1808,7 +1877,7 @@ private GridDhtAffinityAssignmentResponse fetchAffinity( if (res == null) { List> aff = affCache.calculate(topVer, events, discoCache); - affCache.initialize(topVer, aff, mvccCrd); + affCache.initialize(topVer, aff); } else { List> idealAff = res.idealAffinityAssignment(discoCache); @@ -1825,7 +1894,7 @@ private GridDhtAffinityAssignmentResponse fetchAffinity( assert aff != null : res; - affCache.initialize(topVer, aff, mvccCrd); + affCache.initialize(topVer, aff); } return res; @@ -1852,6 +1921,9 @@ public boolean onCentralizedAffinityChange(final GridDhtPartitionsExchangeFuture cache.aff.calculate(fut.initialVersion(), fut.events(), fut.events().discoveryCache()); cctx.exchange().exchangerUpdateHeartbeat(); + + fut.timeBag().finishLocalStage("Affinity centralized initialization (crd) " + + "[grp=" + desc.cacheOrGroupName() + "]"); } }); } @@ -1861,6 +1933,9 @@ public boolean onCentralizedAffinityChange(final GridDhtPartitionsExchangeFuture aff.calculate(fut.initialVersion(), fut.events(), fut.events().discoveryCache()); cctx.exchange().exchangerUpdateHeartbeat(); + + fut.timeBag().finishLocalStage("Affinity centralized initialization " + + "[grp=" + aff.cacheOrGroupName() + "]"); } }); } @@ -1882,7 +1957,7 @@ public IgniteInternalFuture initCoordinatorCaches( final GridDhtPartitionsExchangeFuture fut, final boolean newAff ) throws IgniteCheckedException { - final List> futs = new ArrayList<>(); + final List> futs = Collections.synchronizedList(new ArrayList<>()); final AffinityTopologyVersion topVer = fut.initialVersion(); @@ -1925,34 +2000,53 @@ public IgniteInternalFuture initCoordinatorCaches( assert idx >= 0 && idx < exchFuts.size() - 1 : "Invalid exchange futures state [cur=" + idx + ", total=" + exchFuts.size() + ']'; - final GridDhtPartitionsExchangeFuture prev = exchFuts.get(idx + 1); + GridDhtPartitionsExchangeFuture futureToFetchAffinity = null; + + for (int i = idx + 1; i < exchFuts.size(); i++) { + GridDhtPartitionsExchangeFuture prev = exchFuts.get(i); + + assert prev.isDone() && prev.topologyVersion().compareTo(topVer) < 0; + + if (prev.isMerged()) + continue; + + futureToFetchAffinity = prev; + + break; + } - assert prev.isDone() && prev.topologyVersion().compareTo(topVer) < 0 : prev; + if (futureToFetchAffinity == null) + throw new IgniteCheckedException("Failed to find completed exchange future to fetch affinity."); if (log.isDebugEnabled()) { log.debug("Need initialize affinity on coordinator [" + "cacheGrp=" + desc.cacheOrGroupName() + - "prevAff=" + prev.topologyVersion() + ']'); + "prevAff=" + futureToFetchAffinity.topologyVersion() + ']'); } - GridDhtAssignmentFetchFuture fetchFut = new GridDhtAssignmentFetchFuture(cctx, - desc.groupId(), - prev.topologyVersion(), - prev.events().discoveryCache()); + GridDhtAssignmentFetchFuture fetchFut = new GridDhtAssignmentFetchFuture( + cctx, + desc.groupId(), + futureToFetchAffinity.topologyVersion(), + futureToFetchAffinity.events().discoveryCache() + ); fetchFut.init(false); final GridFutureAdapter affFut = new GridFutureAdapter<>(); + final GridDhtPartitionsExchangeFuture futureToFetchAffinity0 = futureToFetchAffinity; + fetchFut.listen(new IgniteInClosureX>() { @Override public void applyx(IgniteInternalFuture fetchFut) - throws IgniteCheckedException { - fetchAffinity(prev.topologyVersion(), - null, // Pass null mvcc coordinator, this affinity version should be used for queries. - prev.events(), - prev.events().discoveryCache(), - aff, - (GridDhtAssignmentFetchFuture)fetchFut); + throws IgniteCheckedException { + fetchAffinity( + futureToFetchAffinity0.topologyVersion(), + futureToFetchAffinity0.events(), + futureToFetchAffinity0.events().discoveryCache(), + aff, + (GridDhtAssignmentFetchFuture)fetchFut + ); aff.calculate(topVer, fut.events(), fut.events().discoveryCache()); @@ -1983,6 +2077,9 @@ public IgniteInternalFuture initCoordinatorCaches( assert old == null : old; cctx.exchange().exchangerUpdateHeartbeat(); + + fut.timeBag().finishLocalStage("Coordinator affinity cache init " + + "[grp=" + desc.cacheOrGroupName() + "]"); } }); @@ -2039,31 +2136,33 @@ private CacheGroupHolder groupHolder(AffinityTopologyVersion topVer, final Cache /** * @param fut Current exchange future. * @param crd Coordinator flag. - * @throws IgniteCheckedException If failed. * @return Rabalance info. */ - @Nullable private WaitRebalanceInfo initAffinityOnNodeJoin(final GridDhtPartitionsExchangeFuture fut, boolean crd) - throws IgniteCheckedException { + @Nullable private WaitRebalanceInfo initAffinityOnNodeJoin(final GridDhtPartitionsExchangeFuture fut, boolean crd) { final ExchangeDiscoveryEvents evts = fut.context().events(); - final Map>> affCache = new HashMap<>(); + final Map>> affCache = new ConcurrentHashMap<>(); if (!crd) { - for (CacheGroupContext grp : cctx.cache().cacheGroups()) { - if (grp.isLocal()) - continue; + forAllCacheGroups(false, new IgniteInClosureX() { + @Override public void applyx(GridAffinityAssignmentCache grpAffCache) throws IgniteCheckedException { + CacheGroupContext grp = cctx.cache().cacheGroup(grpAffCache.groupId()); - boolean latePrimary = grp.rebalanceEnabled(); + assert grp != null; - initAffinityOnNodeJoin(evts, - evts.nodeJoined(grp.receivedFrom()), - grp.affinity(), - null, - latePrimary, - affCache); + initAffinityOnNodeJoin(evts, + evts.nodeJoined(grp.receivedFrom()), + grp.affinity(), + null, + grp.rebalanceEnabled(), + affCache); - cctx.exchange().exchangerUpdateHeartbeat(); - } + cctx.exchange().exchangerUpdateHeartbeat(); + + fut.timeBag().finishLocalStage("Affinity initialization (node join) " + + "[grp=" + grp.cacheOrGroupName() + "]"); + } + }); return null; } @@ -2100,6 +2199,9 @@ private CacheGroupHolder groupHolder(AffinityTopologyVersion topVer, final Cache } cctx.exchange().exchangerUpdateHeartbeat(); + + fut.timeBag().finishLocalStage("Affinity initialization (crd, node join) " + + "[grp=" + desc.cacheOrGroupName() + "]"); } }); @@ -2107,6 +2209,9 @@ private CacheGroupHolder groupHolder(AffinityTopologyVersion topVer, final Cache } } + /** + * @param aff Affinity assignment. + */ private Map affinityFullMap(AffinityAssignment aff) { Map map = new HashMap<>(); @@ -2272,7 +2377,7 @@ public IgniteInternalFuture>>> initAffinity try { resFut.onDone(initAffinityBasedOnPartitionsAvailability(fut.initialVersion(), fut, NODE_TO_ID, false)); } - catch (IgniteCheckedException e) { + catch (Exception e) { resFut.onDone(e); } } @@ -2292,14 +2397,15 @@ public IgniteInternalFuture>>> initAffinity * @param fut Exchange future. * @param c Closure converting affinity diff. * @param initAff {@code True} if need initialize affinity. - * @return Affinity assignment. - * @throws IgniteCheckedException If failed. + * + * @return Affinity assignment for each of registered cache group. */ - private Map>> initAffinityBasedOnPartitionsAvailability(final AffinityTopologyVersion topVer, + private Map>> initAffinityBasedOnPartitionsAvailability( + final AffinityTopologyVersion topVer, final GridDhtPartitionsExchangeFuture fut, final IgniteClosure c, - final boolean initAff) - throws IgniteCheckedException { + final boolean initAff + ) { final boolean enforcedCentralizedAssignment = DiscoveryCustomEvent.requiresCentralizedAffinityAssignment(fut.firstEvent()); @@ -2309,7 +2415,7 @@ private Map>> initAffinityBasedOnPartitionsAva final Collection aliveNodes = fut.context().events().discoveryCache().serverNodes(); - final Map>> assignment = new HashMap<>(); + final Map>> assignment = new ConcurrentHashMap<>(); forAllRegisteredCacheGroups(new IgniteInClosureX() { @Override public void applyx(CacheGroupDescriptor desc) throws IgniteCheckedException { @@ -2441,6 +2547,9 @@ else if (curPrimary != null && !curPrimary.equals(newPrimary)) { if (initAff) grpHolder.affinity().initialize(topVer, newAssignment0); + + fut.timeBag().finishLocalStage("Affinity recalculation (partitions availability) " + + "[grp=" + desc.cacheOrGroupName() + "]"); } }); @@ -2705,13 +2814,13 @@ class WaitRebalanceInfo { private final AffinityTopologyVersion topVer; /** */ - private Map> waitGrps; + private final Map> waitGrps = new ConcurrentHashMap<>(); /** */ - private Map>> assignments; + private final Map>> assignments = new ConcurrentHashMap<>(); /** */ - private Map deploymentIds; + private final Map deploymentIds = new ConcurrentHashMap<>(); /** * @param topVer Topology version. @@ -2724,14 +2833,15 @@ class WaitRebalanceInfo { * @return {@code True} if there are partitions waiting for rebalancing. */ boolean empty() { - if (waitGrps != null) { - assert !waitGrps.isEmpty(); + boolean isEmpty = waitGrps.isEmpty(); + + if (!isEmpty) { assert waitGrps.size() == assignments.size(); return false; } - return true; + return isEmpty; } /** @@ -2743,28 +2853,11 @@ boolean empty() { void add(Integer grpId, Integer part, UUID waitNode, List assignment) { assert !F.isEmpty(assignment) : assignment; - if (waitGrps == null) { - waitGrps = new HashMap<>(); - assignments = new HashMap<>(); - deploymentIds = new HashMap<>(); - } - - Map cacheWaitParts = waitGrps.get(grpId); - - if (cacheWaitParts == null) { - waitGrps.put(grpId, cacheWaitParts = new HashMap<>()); - - deploymentIds.put(grpId, cachesRegistry.group(grpId).deploymentId()); - } - - cacheWaitParts.put(part, waitNode); - - Map> cacheAssignment = assignments.get(grpId); + deploymentIds.putIfAbsent(grpId, cachesRegistry.group(grpId).deploymentId()); - if (cacheAssignment == null) - assignments.put(grpId, cacheAssignment = new HashMap<>()); + waitGrps.computeIfAbsent(grpId, k -> new HashMap<>()).put(part, waitNode); - cacheAssignment.put(part, assignment); + assignments.computeIfAbsent(grpId, k -> new HashMap<>()).put(part, assignment); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConflictResolutionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConflictResolutionManager.java index 6d65d828fc298..9790f754a8d5a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConflictResolutionManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConflictResolutionManager.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.cache; -import org.apache.ignite.internal.processors.cache.version.*; +import org.apache.ignite.internal.processors.cache.version.CacheVersionConflictResolver; /** * Conflict resolver manager. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java index 614d7c06fbf56..968afd5212640 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java @@ -128,4 +128,4 @@ public void add(GridCacheEntryInfo info) { @Override public byte fieldsCount() { return 1; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java index 61cbb9e04fb54..36312a1591135 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicate.java @@ -42,4 +42,4 @@ public interface CacheEntryPredicate extends IgnitePredicate, * @param locked Entry locked */ public void entryLocked(boolean locked); -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java index e41938997daa2..62325323e1d3e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java @@ -97,4 +97,4 @@ public abstract class CacheEntryPredicateAdapter implements CacheEntryPredicate @Override public void onAckReceived() { // No-op. } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java index 76806a44f5cfd..ad9861cf8b24e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java @@ -19,6 +19,7 @@ import java.nio.ByteBuffer; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.CU; @@ -60,6 +61,9 @@ public CacheEntryPredicateContainsValue(CacheObject val) { GridCacheContext cctx = e.context(); + if (this.val instanceof BinaryObject && val instanceof BinaryObject) + return F.eq(val, this.val); + Object thisVal = CU.value(this.val, cctx, false); Object cacheVal = CU.value(val, cctx, false); @@ -140,4 +144,4 @@ public CacheEntryPredicateContainsValue(CacheObject val) { @Override public String toString() { return S.toString(CacheEntryPredicateContainsValue.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateHasValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateHasValue.java index cac04357a5816..210cc7059b21d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateHasValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateHasValue.java @@ -28,4 +28,4 @@ public class CacheEntryPredicateHasValue extends CacheEntryPredicateAdapter { @Override public boolean apply(GridCacheEntryEx e) { return peekVisibleValue(e) != null; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateNoValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateNoValue.java index 2790170e959e8..4c8917fcc68be 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateNoValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateNoValue.java @@ -28,4 +28,4 @@ public class CacheEntryPredicateNoValue extends CacheEntryPredicateAdapter { @Override public boolean apply(GridCacheEntryEx e) { return peekVisibleValue(e) == null; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java index 9057e41fbfbfc..257433636e6b4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java @@ -156,4 +156,4 @@ public CacheEntryPredicate predicate() { @Override public byte fieldsCount() { return 1; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java index bcaf890ab2f89..b7c882372ed03 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java @@ -87,7 +87,7 @@ protected CacheEvictableEntryImpl(GridCacheEntryEx cached) { */ @Nullable public V peek() { try { - CacheObject val = cached.peek(null); + CacheObject val = cached.peek(); return val != null ? val.value(cached.context().cacheObjectContext(), false) : null; } @@ -151,7 +151,7 @@ protected CacheEvictableEntryImpl(GridCacheEntryEx cached) { return null; try { - CacheObject val = e.peek(null); + CacheObject val = e.peek(); return val != null ? val.value(cached.context().cacheObjectContext(), false) : null; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionEntry.java index 2717b1e03e22e..96b85df2f0721 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionEntry.java @@ -185,4 +185,4 @@ public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws Ignite @Override public byte fieldsCount() { return 3; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionManager.java index b614728f25946..2a9a0e8b10d76 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictionManager.java @@ -19,7 +19,6 @@ import java.util.Collection; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.jetbrains.annotations.Nullable; @@ -35,10 +34,9 @@ public interface CacheEvictionManager extends GridCacheManager { public void touch(IgniteTxEntry txEntry, boolean loc); /** - * @param e Entry for eviction policy notification. - * @param topVer Topology version. + * @param e Entry for eviction policy notification. */ - public void touch(GridCacheEntryEx e, AffinityTopologyVersion topVer); + public void touch(GridCacheEntryEx e); /** * @param entry Entry to attempt to evict. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java index a546a369f099e..fdb30b7f2d95f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java @@ -20,10 +20,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Iterator; +import java.util.Collections; import java.util.List; import java.util.Set; import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cache.affinity.AffinityFunction; @@ -39,9 +40,9 @@ import org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentRequest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopologyImpl; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader; import org.apache.ignite.internal.processors.cache.persistence.DataRegion; import org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager; import org.apache.ignite.internal.processors.cache.persistence.freelist.FreeList; @@ -78,13 +79,13 @@ public class CacheGroupContext { private final int grpId; /** Node ID cache group was received from. */ - private final UUID rcvdFrom; + private volatile UUID rcvdFrom; /** Flag indicating that this cache group is in a recovery mode due to partitions loss. */ private boolean needsRecovery; /** */ - private final AffinityTopologyVersion locStartVer; + private volatile AffinityTopologyVersion locStartVer; /** */ private final CacheConfiguration ccfg; @@ -93,7 +94,7 @@ public class CacheGroupContext { private final GridCacheSharedContext ctx; /** */ - private final boolean affNode; + private volatile boolean affNode; /** */ private final CacheType cacheType; @@ -107,26 +108,26 @@ public class CacheGroupContext { /** */ private final boolean storeCacheId; - /** */ - private volatile List caches; + /** We modify content under lock, by making defencive copy, field always contains unmodifiable list. */ + private volatile List caches = Collections.unmodifiableList(new ArrayList<>()); - /** */ private volatile List contQryCaches; /** */ private final IgniteLogger log; /** */ - private GridAffinityAssignmentCache aff; + private volatile GridAffinityAssignmentCache aff; /** */ - private GridDhtPartitionTopologyImpl top; + private volatile GridDhtPartitionTopologyImpl top; /** */ - private IgniteCacheOffheapManager offheapMgr; + private volatile IgniteCacheOffheapManager offheapMgr; /** */ - private GridCachePreloader preldr; + private volatile GridCachePreloader preldr; + /** */ private final DataRegion dataRegion; @@ -143,16 +144,16 @@ public class CacheGroupContext { private final ReuseList reuseList; /** */ - private boolean drEnabled; + private volatile boolean drEnabled; /** */ - private boolean qryEnabled; + private volatile boolean qryEnabled; /** */ - private boolean mvccEnabled; + private final boolean mvccEnabled; /** MXBean. */ - private CacheGroupMetricsMXBean mxBean; + private final CacheGroupMetricsMXBean mxBean; /** */ private volatile boolean localWalEnabled; @@ -160,6 +161,9 @@ public class CacheGroupContext { /** */ private volatile boolean globalWalEnabled; + /** Flag indicates that cache group is under recovering and not attached to topology. */ + private final AtomicBoolean recoveryMode; + /** * @param ctx Context. * @param grpId Group ID. @@ -188,7 +192,8 @@ public class CacheGroupContext { ReuseList reuseList, AffinityTopologyVersion locStartVer, boolean persistenceEnabled, - boolean walEnabled + boolean walEnabled, + boolean recoveryMode ) { assert ccfg != null; assert dataRegion != null || !affNode; @@ -208,8 +213,7 @@ public class CacheGroupContext { this.globalWalEnabled = walEnabled; this.persistenceEnabled = persistenceEnabled; this.localWalEnabled = true; - - persistGlobalWalState(walEnabled); + this.recoveryMode = new AtomicBoolean(recoveryMode); ioPlc = cacheType.ioPolicy(); @@ -221,8 +225,6 @@ public class CacheGroupContext { log = ctx.kernalContext().log(getClass()); - caches = new ArrayList<>(); - mxBean = new CacheGroupMetricsMXBeanImpl(this); } @@ -292,10 +294,9 @@ void onCacheStarted(GridCacheContext cctx) throws IgniteCheckedException { public boolean hasCache(String cacheName) { List caches = this.caches; - for (int i = 0; i < caches.size(); i++) { - if (caches.get(i).name().equals(cacheName)) + for (GridCacheContext cacheContext : caches) + if (cacheContext.name().equals(cacheName)) return true; - } return false; } @@ -307,11 +308,17 @@ private void addCacheContext(GridCacheContext cctx) { assert cacheType.userCache() == cctx.userCache() : cctx.name(); assert grpId == cctx.groupId() : cctx.name(); - ArrayList caches = new ArrayList<>(this.caches); + final boolean add; - assert sharedGroup() || caches.isEmpty(); + synchronized (this) { + List copy = new ArrayList<>(caches); + + assert sharedGroup() || copy.isEmpty(); - boolean add = caches.add(cctx); + add = copy.add(cctx); + + caches = Collections.unmodifiableList(copy); + } assert add : cctx.name(); @@ -320,39 +327,39 @@ private void addCacheContext(GridCacheContext cctx) { if (!drEnabled && cctx.isDrEnabled()) drEnabled = true; - - this.caches = caches; } /** * @param cctx Cache context. */ private void removeCacheContext(GridCacheContext cctx) { - ArrayList caches = new ArrayList<>(this.caches); + final List copy; - // It is possible cache was not added in case of errors on cache start. - for (Iterator it = caches.iterator(); it.hasNext();) { - GridCacheContext next = it.next(); + synchronized (this) { + copy = new ArrayList<>(caches); - if (next == cctx) { - assert sharedGroup() || caches.size() == 1 : caches.size(); + for (GridCacheContext next : copy) { + if (next == cctx) { + assert sharedGroup() || copy.size() == 1 : copy.size(); - it.remove(); + copy.remove(next); - break; + break; + } } + + caches = Collections.unmodifiableList(copy); } if (QueryUtils.isEnabled(cctx.config())) { boolean qryEnabled = false; - for (int i = 0; i < caches.size(); i++) { - if (QueryUtils.isEnabled(caches.get(i).config())) { + for (GridCacheContext cacheContext : copy) + if (QueryUtils.isEnabled(cacheContext.config())) { qryEnabled = true; break; } - } this.qryEnabled = qryEnabled; } @@ -360,18 +367,15 @@ private void removeCacheContext(GridCacheContext cctx) { if (cctx.isDrEnabled()) { boolean drEnabled = false; - for (int i = 0; i < caches.size(); i++) { - if (caches.get(i).isDrEnabled()) { + for (GridCacheContext cacheContext : copy) + if (QueryUtils.isEnabled(cacheContext.config())) { drEnabled = true; break; } - } this.drEnabled = drEnabled; } - - this.caches = caches; } /** @@ -393,11 +397,8 @@ public GridCacheContext singleCacheContext() { public void unwindUndeploys() { List caches = this.caches; - for (int i = 0; i < caches.size(); i++) { - GridCacheContext cctx = caches.get(i); - + for (GridCacheContext cctx : caches) cctx.deploy().unwind(cctx); - } } /** @@ -435,9 +436,7 @@ public void addRebalanceEvent(int part, int type, ClusterNode discoNode, int dis List caches = this.caches; - for (int i = 0; i < caches.size(); i++) { - GridCacheContext cctx = caches.get(i); - + for (GridCacheContext cctx : caches) if (!cctx.config().isEventsDisabled() && cctx.recordEvent(type)) { cctx.gridEvents().record(new CacheRebalancingEvent(cctx.name(), cctx.localNode(), @@ -448,7 +447,6 @@ public void addRebalanceEvent(int part, int type, ClusterNode discoNode, int dis discoType, discoTs)); } - } } /** @@ -463,9 +461,7 @@ public void addUnloadEvent(int part) { List caches = this.caches; - for (int i = 0; i < caches.size(); i++) { - GridCacheContext cctx = caches.get(i); - + for (GridCacheContext cctx : caches) if (!cctx.config().isEventsDisabled()) cctx.gridEvents().record(new CacheRebalancingEvent(cctx.name(), cctx.localNode(), @@ -475,7 +471,6 @@ public void addUnloadEvent(int part) { null, 0, 0)); - } } /** @@ -502,9 +497,7 @@ public void addCacheEvent( ) { List caches = this.caches; - for (int i = 0; i < caches.size(); i++) { - GridCacheContext cctx = caches.get(i); - + for (GridCacheContext cctx : caches) if (!cctx.config().isEventsDisabled()) cctx.events().addEvent(part, key, @@ -520,7 +513,6 @@ public void addCacheEvent( null, null, keepBinary); - } } /** @@ -715,9 +707,11 @@ public boolean sharedGroup() { * */ public void onKernalStop() { - aff.cancelFutures(new IgniteCheckedException("Failed to wait for topology update, node is stopping.")); + if (!isRecoveryMode()) { + aff.cancelFutures(new IgniteCheckedException("Failed to wait for topology update, node is stopping.")); - preldr.onKernalStop(); + preldr.onKernalStop(); + } offheapMgr.onKernalStop(); } @@ -739,6 +733,11 @@ void stopCache(GridCacheContext cctx, boolean destroy) { * */ void stopGroup() { + offheapMgr.stop(); + + if (isRecoveryMode()) + return; + IgniteCheckedException err = new IgniteCheckedException("Failed to wait for topology update, cache (or node) is stopping."); @@ -748,11 +747,67 @@ void stopGroup() { preldr.onKernalStop(); - offheapMgr.stop(); - ctx.io().removeCacheGroupHandlers(grpId); } + /** + * Finishes recovery for current cache group. + * Attaches topology version and initializes I/O. + * + * @param startVer Cache group start version. + * @param originalReceivedFrom UUID of node that was first who initiated cache group creating. + * This is needed to decide should node calculate affinity locally or fetch from other nodes. + * @param affinityNode Flag indicates, is local node affinity node or not. This may be calculated only after node joined to topology. + * @throws IgniteCheckedException If failed. + */ + public void finishRecovery( + AffinityTopologyVersion startVer, + UUID originalReceivedFrom, + boolean affinityNode + ) throws IgniteCheckedException { + if (!recoveryMode.compareAndSet(true, false)) + return; + + affNode = affinityNode; + + rcvdFrom = originalReceivedFrom; + + locStartVer = startVer; + + persistGlobalWalState(globalWalEnabled); + + initializeIO(); + + ctx.affinity().onCacheGroupCreated(this); + } + + /** + * @return {@code True} if current cache group is in recovery mode. + */ + public boolean isRecoveryMode() { + return recoveryMode.get(); + } + + /** + * Initializes affinity and rebalance I/O handlers. + */ + private void initializeIO() throws IgniteCheckedException { + assert !recoveryMode.get() : "Couldn't initialize I/O handlers, recovery mode is on for group " + this; + + if (ccfg.getCacheMode() != LOCAL) { + if (!ctx.kernalContext().clientNode()) { + ctx.io().addCacheGroupHandler(groupId(), GridDhtAffinityAssignmentRequest.class, + (IgniteBiInClosure) this::processAffinityAssignmentRequest); + } + + preldr = new GridDhtPreloader(this); + + preldr.start(); + } + else + preldr = new GridCachePreloaderAdapter(this); + } + /** * @return IDs of caches in this group. */ @@ -761,23 +816,25 @@ public Set cacheIds() { Set ids = U.newHashSet(caches.size()); - for (int i = 0; i < caches.size(); i++) - ids.add(caches.get(i).cacheId()); + for (GridCacheContext cctx : caches) + ids.add(cctx.cacheId()); return ids; } /** * @return Caches in this group. + * + * caches is already Unmodifiable list, so we don't need to explicitly wrap it here. */ public List caches() { - return this.caches; + return caches; } /** * @return {@code True} if group contains caches. */ - boolean hasCaches() { + public boolean hasCaches() { List caches = this.caches; return !caches.isEmpty(); @@ -789,9 +846,7 @@ boolean hasCaches() { public void onPartitionEvicted(int part) { List caches = this.caches; - for (int i = 0; i < caches.size(); i++) { - GridCacheContext cctx = caches.get(i); - + for (GridCacheContext cctx : caches) { if (cctx.isDrEnabled()) cctx.dr().partitionEvicted(part); @@ -904,39 +959,25 @@ public void start() throws IgniteCheckedException { ccfg.getCacheMode() == LOCAL, persistenceEnabled()); - if (ccfg.getCacheMode() != LOCAL) { + if (ccfg.getCacheMode() != LOCAL) top = new GridDhtPartitionTopologyImpl(ctx, this); - if (!ctx.kernalContext().clientNode()) { - ctx.io().addCacheGroupHandler(groupId(), GridDhtAffinityAssignmentRequest.class, - new IgniteBiInClosure() { - @Override public void apply(UUID nodeId, GridDhtAffinityAssignmentRequest msg) { - processAffinityAssignmentRequest(nodeId, msg); - } - }); - } - - preldr = new GridDhtPreloader(this); - - preldr.start(); + try { + offheapMgr = persistenceEnabled + ? new GridCacheOffheapManager() + : new IgniteCacheOffheapManagerImpl(); } - else - preldr = new GridCachePreloaderAdapter(this); - - if (persistenceEnabled()) { - try { - offheapMgr = new GridCacheOffheapManager(); - } - catch (Exception e) { - throw new IgniteCheckedException("Failed to initialize offheap manager", e); - } + catch (Exception e) { + throw new IgniteCheckedException("Failed to initialize offheap manager", e); } - else - offheapMgr = new IgniteCacheOffheapManagerImpl(); offheapMgr.start(ctx, this); - ctx.affinity().onCacheGroupCreated(this); + if (!isRecoveryMode()) { + initializeIO(); + + ctx.affinity().onCacheGroupCreated(this); + } } /** @@ -950,8 +991,7 @@ public boolean persistenceEnabled() { * @param nodeId Node ID. * @param req Request. */ - private void processAffinityAssignmentRequest(final UUID nodeId, - final GridDhtAffinityAssignmentRequest req) { + private void processAffinityAssignmentRequest(UUID nodeId, GridDhtAffinityAssignmentRequest req) { if (log.isDebugEnabled()) log.debug("Processing affinity assignment request [node=" + nodeId + ", req=" + req + ']'); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java index 70cdcc735af62..e72de28a05674 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java @@ -23,6 +23,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.UUID; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -311,4 +312,22 @@ public boolean persistenceEnabled() { @Override public String toString() { return S.toString(CacheGroupDescriptor.class, this, "cacheName", cacheCfg.getName()); } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (o == null || getClass() != o.getClass()) + return false; + + CacheGroupDescriptor that = (CacheGroupDescriptor) o; + + return grpId == that.grpId; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return Objects.hash(grpId); + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMXBeanImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMXBeanImpl.java index 5ece77f57ba4d..753a86fdc4866 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMXBeanImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMXBeanImpl.java @@ -83,6 +83,13 @@ public GroupAllocationTracker(AllocatedPageTracker delegate) { delegate.updateTotalAllocatedPages(delta); } + + /** + * Resets count of allocated pages to zero. + */ + public void reset() { + totalAllocatedPages.reset(); + } } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java index 3b463afe8a25e..3f880339eb889 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeDirectResult.java @@ -267,4 +267,4 @@ public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws Ignite @Override public String toString() { return S.toString(CacheInvokeDirectResult.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java index 5f3001cdc7311..6bdaf9669be82 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java @@ -1148,11 +1148,13 @@ public CacheMetricsSnapshot(CacheMetrics loc, Collection metrics) rebalancingBytesRate = in.readLong(); rebalancingKeysRate = in.readLong(); - rebalancedKeys = in.readLong(); - estimatedRebalancingKeys = in.readLong(); - rebalanceStartTime = in.readLong(); - rebalanceFinishTime = in.readLong(); - rebalanceClearingPartitionsLeft = in.readLong(); + if (in.available() >= 40) { + rebalancedKeys = in.readLong(); + estimatedRebalancingKeys = in.readLong(); + rebalanceStartTime = in.readLong(); + rebalanceFinishTime = in.readLong(); + rebalanceClearingPartitionsLeft = in.readLong(); + } // 11 long and 5 float values give 108 bytes in total. if (in.available() >= 108) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java index 3bc2a6dcb0624..f9f384a7f9702 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java @@ -118,4 +118,4 @@ public interface CacheObject extends Message { * @throws IgniteCheckedException If failed. */ public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException; -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java index 67ee410d06e2e..c6d900250f6b0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectAdapter.java @@ -247,4 +247,4 @@ else if (off >= headSize) return true; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java index 57a70f83e5044..de5a9191950c0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java @@ -191,4 +191,4 @@ public CacheObjectByteArrayImpl(byte[] val) { @Override public String toString() { return "CacheObjectByteArrayImpl [arrLen=" + (val != null ? val.length : 0) + ']'; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java index 2124a97940b9b..b29c19e1e254c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java @@ -152,4 +152,4 @@ else if (kernalCtx.config().isPeerClassLoadingEnabled()) @Override public CacheObject prepareForCache(CacheObjectContext ctx) { return this; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOffheapEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOffheapEvictionManager.java index d737c8bfca328..6813fec446d9e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOffheapEvictionManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOffheapEvictionManager.java @@ -19,7 +19,6 @@ import java.util.Collection; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager; @@ -32,11 +31,11 @@ public class CacheOffheapEvictionManager extends GridCacheManagerAdapter implements CacheEvictionManager { /** {@inheritDoc} */ @Override public void touch(IgniteTxEntry txEntry, boolean loc) { - touch(txEntry.cached(), null); + touch(txEntry.cached()); } /** {@inheritDoc} */ - @Override public void touch(GridCacheEntryEx e, AffinityTopologyVersion topVer) { + @Override public void touch(GridCacheEntryEx e) { if (e.detached()) return; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachesRegistry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachesRegistry.java index fe55f979a56ec..d37f69ca5f6ad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachesRegistry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CachesRegistry.java @@ -280,7 +280,7 @@ private boolean shouldPersist(CacheConfiguration cacheCfg) { */ private IgniteInternalFuture persistCacheConfigurations(List cacheDescriptors) { List cacheConfigsToPersist = cacheDescriptors.stream() - .map(cacheDesc -> new StoredCacheData(cacheDesc.cacheConfiguration()).sql(cacheDesc.sql())) + .map(DynamicCacheDescriptor::toStoredData) .collect(Collectors.toList()); // Pre-create cache work directories if they don't exist. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java index 6ab4e679518e3..3e8e4bf34a32c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java @@ -53,7 +53,6 @@ import org.apache.ignite.internal.processors.query.QuerySchemaPatch; import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.processors.query.schema.SchemaOperationException; -import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.lang.GridFunc; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; @@ -79,6 +78,9 @@ * Logic related to cache discovery data processing. */ class ClusterCachesInfo { + /** Representation of null for restarting caches map */ + private static final IgniteUuid NULL_OBJECT = new IgniteUuid(); + /** Version since which merge of config is supports. */ private static final IgniteProductVersion V_MERGE_CONFIG_SINCE = IgniteProductVersion.fromString("2.5.0"); @@ -94,8 +96,8 @@ class ClusterCachesInfo { /** Cache templates. */ private final ConcurrentMap registeredTemplates = new ConcurrentHashMap<>(); - /** Caches currently being restarted. */ - private final Collection restartingCaches = new GridConcurrentHashSet<>(); + /** Caches currently being restarted (with restarter id). */ + private final ConcurrentHashMap restartingCaches = new ConcurrentHashMap<>(); /** */ private final IgniteLogger log; @@ -411,7 +413,7 @@ public void onCacheChangeRequested(DynamicCacheChangeFailureMessage failMsg, Aff requests.add(DynamicCacheChangeRequest.stopRequest(ctx, cacheName, cacheDescr.sql(), true)); } - processCacheChangeRequests(exchangeActions, requests, topVer,false); + processCacheChangeRequests(exchangeActions, requests, topVer, false); failMsg.exchangeActions(exchangeActions); } @@ -468,304 +470,399 @@ private CacheChangeProcessResult processCacheChangeRequests( ExchangeActions exchangeActions, Collection reqs, AffinityTopologyVersion topVer, - boolean persistedCfgs) { + boolean persistedCfgs + ) { CacheChangeProcessResult res = new CacheChangeProcessResult(); final List> reqsToComplete = new ArrayList<>(); - for (DynamicCacheChangeRequest req : reqs) { - if (req.template()) { - CacheConfiguration ccfg = req.startCacheConfiguration(); + for (DynamicCacheChangeRequest req : reqs) + processCacheChangeRequest0(req, exchangeActions, topVer, persistedCfgs, res, reqsToComplete); - assert ccfg != null : req; + if (!F.isEmpty(res.addedDescs)) { + AffinityTopologyVersion startTopVer = res.needExchange ? topVer.nextMinorVersion() : topVer; - DynamicCacheDescriptor desc = registeredTemplates.get(req.cacheName()); + for (DynamicCacheDescriptor desc : res.addedDescs) { + assert desc.template() || res.needExchange; - if (desc == null) { - DynamicCacheDescriptor templateDesc = new DynamicCacheDescriptor(ctx, - ccfg, - req.cacheType(), - null, - true, - req.initiatingNodeId(), - false, - false, - req.deploymentId(), - req.schema()); + desc.startTopologyVersion(startTopVer); + } + } - DynamicCacheDescriptor old = registeredTemplates().put(ccfg.getName(), templateDesc); + if (!F.isEmpty(reqsToComplete)) { + ctx.closure().callLocalSafe(new Callable() { + @Override public Void call() throws Exception { + for (T2 t : reqsToComplete) { + final DynamicCacheChangeRequest req = t.get1(); + AffinityTopologyVersion waitTopVer = t.get2(); - assert old == null; + IgniteInternalFuture fut = waitTopVer != null ? + ctx.cache().context().exchange().affinityReadyFuture(waitTopVer) : null; - res.addedDescs.add(templateDesc); + if (fut == null || fut.isDone()) + ctx.cache().completeCacheStartFuture(req, false, null); + else { + fut.listen(new IgniteInClosure>() { + @Override public void apply(IgniteInternalFuture fut) { + ctx.cache().completeCacheStartFuture(req, false, null); + } + }); + } + } + + return null; } + }); + } - if (!persistedCfgs) - ctx.cache().completeTemplateAddFuture(ccfg.getName(), req.deploymentId()); + return res; + } - continue; - } + /** + * @param req Cache change request. + * @param exchangeActions Exchange actions to update. + * @param topVer Topology version. + * @param persistedCfgs {@code True} if process start of persisted caches during cluster activation. + * @param res Accumulator for cache change process results. + * @param reqsToComplete Accumulator for cache change requests which should be completed after + * ({@link org.apache.ignite.internal.processors.cache.GridCacheProcessor#pendingFuts} + */ + private void processCacheChangeRequest0( + DynamicCacheChangeRequest req, + ExchangeActions exchangeActions, + AffinityTopologyVersion topVer, + boolean persistedCfgs, + CacheChangeProcessResult res, + List> reqsToComplete + ) { + String cacheName = req.cacheName(); - assert !req.clientStartOnly() : req; + if (req.template()) { + processTemplateAddRequest(persistedCfgs, res, req); - DynamicCacheDescriptor desc = registeredCaches.get(req.cacheName()); + return; + } - boolean needExchange = false; + assert !req.clientStartOnly() : req; - boolean clientCacheStart = false; + DynamicCacheDescriptor desc = registeredCaches.get(cacheName); - AffinityTopologyVersion waitTopVer = null; + boolean needExchange = false; - if (req.start()) { - // Starting a new cache. - if (desc == null) { - String conflictErr = checkCacheConflict(req.startCacheConfiguration()); + boolean clientCacheStart = false; - if (conflictErr != null) { - U.warn(log, "Ignore cache start request. " + conflictErr); + AffinityTopologyVersion waitTopVer = null; - IgniteCheckedException err = new IgniteCheckedException("Failed to start " + - "cache. " + conflictErr); + if (req.start()) { + boolean proceedFuther = true; - if (persistedCfgs) - res.errs.add(err); - else - ctx.cache().completeCacheStartFuture(req, false, err); + if (restartingCaches.containsKey(cacheName) && + ((req.restartId() == null && restartingCaches.get(cacheName) != NULL_OBJECT) + || (req.restartId() != null &&!req.restartId().equals(restartingCaches.get(cacheName))))) { - continue; - } + if (req.failIfExists()) { + ctx.cache().completeCacheStartFuture(req, false, + new CacheExistsException("Failed to start cache (a cache is restarting): " + cacheName)); + } - if (req.clientStartOnly()) { - assert !persistedCfgs; + proceedFuther = false; + } - ctx.cache().completeCacheStartFuture(req, false, new IgniteCheckedException("Failed to start " + - "client cache (a cache with the given name is not started): " + req.cacheName())); - } - else { - SchemaOperationException err = QueryUtils.checkQueryEntityConflicts( - req.startCacheConfiguration(), registeredCaches.values()); + if (proceedFuther) { + if (desc == null) { /* Starting a new cache.*/ + if (!processStartNewCacheRequest(exchangeActions, topVer, persistedCfgs, res, req, cacheName)) + return; - if (err != null) { - if (persistedCfgs) - res.errs.add(err); + needExchange = true; + } + else { + clientCacheStart = processStartAlreadyStartedCacheRequest(topVer, persistedCfgs, req, cacheName, desc); + + if (!clientCacheStart) { + if (desc.clientCacheStartVersion() != null) + waitTopVer = desc.clientCacheStartVersion(); + else { + AffinityTopologyVersion nodeStartVer = + new AffinityTopologyVersion(ctx.discovery().localNode().order(), 0); + + if (desc.startTopologyVersion() != null) + waitTopVer = desc.startTopologyVersion(); else - ctx.cache().completeCacheStartFuture(req, false, err); + waitTopVer = desc.receivedFromStartVersion(); - continue; + if (waitTopVer == null || nodeStartVer.compareTo(waitTopVer) > 0) + waitTopVer = nodeStartVer; } + } + } + } + } + else if (req.resetLostPartitions()) { + if (desc != null) { + needExchange = true; - CacheConfiguration ccfg = req.startCacheConfiguration(); + exchangeActions.addCacheToResetLostPartitions(req, desc); + } + } + else if (req.stop()) { + if (desc != null) { + if (req.sql() && !desc.sql()) { + ctx.cache().completeCacheStartFuture(req, false, + new IgniteCheckedException("Only cache created with CREATE TABLE may be removed with " + + "DROP TABLE [cacheName=" + cacheName + ']')); - assert req.cacheType() != null : req; - assert F.eq(ccfg.getName(), req.cacheName()) : req; + return; + } - int cacheId = CU.cacheId(req.cacheName()); + processStopCacheRequest(exchangeActions, req, cacheName, desc); - CacheGroupDescriptor grpDesc = registerCacheGroup(exchangeActions, - topVer, - ccfg, - cacheId, - req.initiatingNodeId(), - req.deploymentId(), - req.encryptionKey()); + needExchange = true; + } + } + else + assert false : req; - DynamicCacheDescriptor startDesc = new DynamicCacheDescriptor(ctx, - ccfg, - req.cacheType(), - grpDesc, - false, - req.initiatingNodeId(), - false, - req.sql(), - req.deploymentId(), - req.schema()); + if (!needExchange) { + if (!clientCacheStart && ctx.localNodeId().equals(req.initiatingNodeId())) + reqsToComplete.add(new T2<>(req, waitTopVer)); + } + else + res.needExchange = true; + } - DynamicCacheDescriptor old = registeredCaches.put(ccfg.getName(), startDesc); + /** + * @param req Cache change request. + * @param exchangeActions Exchange actions to update. + * @param cacheName Cache name. + * @param desc Dynamic cache descriptor. + */ + private void processStopCacheRequest( + ExchangeActions exchangeActions, + DynamicCacheChangeRequest req, + String cacheName, + DynamicCacheDescriptor desc + ) { + DynamicCacheDescriptor old = registeredCaches.remove(cacheName); - restartingCaches.remove(ccfg.getName()); + if (req.restart()) { + IgniteUuid restartId = req.restartId(); - assert old == null; + restartingCaches.put(cacheName, restartId == null ? NULL_OBJECT : restartId); + } - ctx.discovery().setCacheFilter( - startDesc.cacheId(), - grpDesc.groupId(), - ccfg.getName(), - ccfg.getNearConfiguration() != null); + assert old != null && old == desc : "Dynamic cache map was concurrently modified [req=" + req + ']'; - if (!persistedCfgs) { - ctx.discovery().addClientNode(req.cacheName(), - req.initiatingNodeId(), - req.nearCacheConfiguration() != null); - } + ctx.discovery().removeCacheFilter(cacheName); - res.addedDescs.add(startDesc); + exchangeActions.addCacheToStop(req, desc); - exchangeActions.addCacheToStart(req, startDesc); + CacheGroupDescriptor grpDesc = registeredCacheGrps.get(desc.groupId()); - needExchange = true; - } - } - else { - assert !persistedCfgs; - assert req.initiatingNodeId() != null : req; + assert grpDesc != null && grpDesc.groupId() == desc.groupId() : desc; - if (req.failIfExists()) { - ctx.cache().completeCacheStartFuture(req, false, - new CacheExistsException("Failed to start cache " + - "(a cache with the same name is already started): " + req.cacheName())); - } - else { - // Cache already exists, it is possible client cache is needed. - ClusterNode node = ctx.discovery().node(req.initiatingNodeId()); + grpDesc.onCacheStopped(desc.cacheName(), desc.cacheId()); - boolean clientReq = node != null && - !ctx.discovery().cacheAffinityNode(node, req.cacheName()); + if (!grpDesc.hasCaches()) { + registeredCacheGrps.remove(grpDesc.groupId()); - if (clientReq) { - ctx.discovery().addClientNode(req.cacheName(), - req.initiatingNodeId(), - req.nearCacheConfiguration() != null); + ctx.discovery().removeCacheGroup(grpDesc); - if (node.id().equals(req.initiatingNodeId())) { - desc.clientCacheStartVersion(topVer); + exchangeActions.addCacheGroupToStop(grpDesc, req.destroy()); - clientCacheStart = true; + assert exchangeActions.checkStopRequestConsistency(grpDesc.groupId()); - ctx.discovery().clientCacheStartEvent(req.requestId(), F.asMap(req.cacheName(), req), null); - } - } - } + // If all caches in group will be destroyed it is not necessary to destroy single cache + // because group will be stopped anyway. + if (req.destroy()) { + for (ExchangeActions.CacheActionData action : exchangeActions.cacheStopRequests()) { + if (action.descriptor().groupId() == grpDesc.groupId()) + action.request().destroy(false); } + } + } + } - if (!needExchange && !clientCacheStart && desc != null) { - if (desc.clientCacheStartVersion() != null) - waitTopVer = desc.clientCacheStartVersion(); - else { - AffinityTopologyVersion nodeStartVer = - new AffinityTopologyVersion(ctx.discovery().localNode().order(), 0); - - if (desc.startTopologyVersion() != null) - waitTopVer = desc.startTopologyVersion(); - else - waitTopVer = desc.receivedFromStartVersion(); + /** + * @param persistedCfgs {@code True} if process start of persisted caches during cluster activation. + * @param res Accumulator for cache change process results. + * @param req Dynamic cache change request. + */ + private void processTemplateAddRequest( + boolean persistedCfgs, + CacheChangeProcessResult res, + DynamicCacheChangeRequest req + ) { + CacheConfiguration ccfg = req.startCacheConfiguration(); - if (waitTopVer == null || nodeStartVer.compareTo(waitTopVer) > 0) - waitTopVer = nodeStartVer; - } - } - } - else if (req.resetLostPartitions()) { - if (desc != null) { - needExchange = true; + assert ccfg != null : req; - exchangeActions.addCacheToResetLostPartitions(req, desc); - } - } - else if (req.stop()) { - if (desc != null) { - if (req.sql() && !desc.sql()) { - ctx.cache().completeCacheStartFuture(req, false, - new IgniteCheckedException("Only cache created with CREATE TABLE may be removed with " + - "DROP TABLE [cacheName=" + req.cacheName() + ']')); - - continue; - } + DynamicCacheDescriptor desc = registeredTemplates.get(req.cacheName()); - if (!req.sql() && desc.sql()) { - ctx.cache().completeCacheStartFuture(req, false, - new IgniteCheckedException("Only cache created with cache API may be removed with " + - "direct call to destroyCache [cacheName=" + req.cacheName() + ']')); + if (desc == null) { + DynamicCacheDescriptor templateDesc = new DynamicCacheDescriptor(ctx, + ccfg, + req.cacheType(), + null, + true, + req.initiatingNodeId(), + false, + false, + req.deploymentId(), + req.schema()); - continue; - } + DynamicCacheDescriptor old = registeredTemplates().put(ccfg.getName(), templateDesc); - DynamicCacheDescriptor old = registeredCaches.remove(req.cacheName()); + assert old == null; - if (req.restart()) - restartingCaches.add(req.cacheName()); + res.addedDescs.add(templateDesc); + } - assert old != null && old == desc : "Dynamic cache map was concurrently modified [req=" + req + ']'; + if (!persistedCfgs) + ctx.cache().completeTemplateAddFuture(ccfg.getName(), req.deploymentId()); + } - ctx.discovery().removeCacheFilter(req.cacheName()); + /** + * @param topVer Topology version. + * @param persistedCfgs {@code True} if process start of persisted caches during cluster activation. + * @param req Cache change request. + * @param cacheName Cache name. + * @param desc Dynamic cache descriptor. + * @return True if it is needed to start client cache. + */ + private boolean processStartAlreadyStartedCacheRequest( + AffinityTopologyVersion topVer, + boolean persistedCfgs, + DynamicCacheChangeRequest req, + String cacheName, + DynamicCacheDescriptor desc + ) { + assert !persistedCfgs; + assert req.initiatingNodeId() != null : req; + + if (req.failIfExists()) { + ctx.cache().completeCacheStartFuture(req, false, + new CacheExistsException("Failed to start cache " + + "(a cache with the same name is already started): " + cacheName)); + } + else { + // Cache already exists, it is possible client cache is needed. + ClusterNode node = ctx.discovery().node(req.initiatingNodeId()); - needExchange = true; + boolean clientReq = node != null && + !ctx.discovery().cacheAffinityNode(node, cacheName); - exchangeActions.addCacheToStop(req, desc); + if (clientReq) { + ctx.discovery().addClientNode(cacheName, + req.initiatingNodeId(), + req.nearCacheConfiguration() != null); - CacheGroupDescriptor grpDesc = registeredCacheGrps.get(desc.groupId()); + if (node.id().equals(req.initiatingNodeId())) { + desc.clientCacheStartVersion(topVer); - assert grpDesc != null && grpDesc.groupId() == desc.groupId() : desc; + ctx.discovery().clientCacheStartEvent(req.requestId(), F.asMap(cacheName, req), null); - grpDesc.onCacheStopped(desc.cacheName(), desc.cacheId()); + return true; + } + } + } - if (!grpDesc.hasCaches()) { - registeredCacheGrps.remove(grpDesc.groupId()); + return false; + } - ctx.discovery().removeCacheGroup(grpDesc); + /** + * @param exchangeActions Exchange actions to update. + * @param topVer Topology version. + * @param persistedCfgs {@code True} if process start of persisted caches during cluster activation. + * @param res Accumulator for cache change process results. + * @param req Cache change request. + * @param cacheName Cache name. + * @return True if there was no errors. + */ + private boolean processStartNewCacheRequest( + ExchangeActions exchangeActions, + AffinityTopologyVersion topVer, + boolean persistedCfgs, + CacheChangeProcessResult res, + DynamicCacheChangeRequest req, + String cacheName + ) { + String conflictErr = checkCacheConflict(req.startCacheConfiguration()); - exchangeActions.addCacheGroupToStop(grpDesc, req.destroy()); + if (conflictErr != null) { + U.warn(log, "Ignore cache start request. " + conflictErr); - assert exchangeActions.checkStopRequestConsistency(grpDesc.groupId()); + IgniteCheckedException err = new IgniteCheckedException("Failed to start " + + "cache. " + conflictErr); - // If all caches in group will be destroyed it is not necessary to destroy single cache - // because group will be stopped anyway. - if (req.destroy()) { - for (ExchangeActions.CacheActionData action : exchangeActions.cacheStopRequests()) { - if (action.descriptor().groupId() == grpDesc.groupId()) - action.request().destroy(false); - } - } - } - } - } + if (persistedCfgs) + res.errs.add(err); else - assert false : req; + ctx.cache().completeCacheStartFuture(req, false, err); - if (!needExchange) { - if (!clientCacheStart && ctx.localNodeId().equals(req.initiatingNodeId())) - reqsToComplete.add(new T2<>(req, waitTopVer)); - } - else - res.needExchange = true; + return false; } - if (!F.isEmpty(res.addedDescs)) { - AffinityTopologyVersion startTopVer = res.needExchange ? topVer.nextMinorVersion() : topVer; + SchemaOperationException err = QueryUtils.checkQueryEntityConflicts( + req.startCacheConfiguration(), registeredCaches.values()); - for (DynamicCacheDescriptor desc : res.addedDescs) { - assert desc.template() || res.needExchange; + if (err != null) { + if (persistedCfgs) + res.errs.add(err); + else + ctx.cache().completeCacheStartFuture(req, false, err); - desc.startTopologyVersion(startTopVer); - } + return false; } - if (!F.isEmpty(reqsToComplete)) { - ctx.closure().callLocalSafe(new Callable() { - @Override public Void call() throws Exception { - for (T2 t : reqsToComplete) { - final DynamicCacheChangeRequest req = t.get1(); - AffinityTopologyVersion waitTopVer = t.get2(); + CacheConfiguration ccfg = req.startCacheConfiguration(); - IgniteInternalFuture fut = waitTopVer != null ? - ctx.cache().context().exchange().affinityReadyFuture(waitTopVer) : null; + assert req.cacheType() != null : req; + assert F.eq(ccfg.getName(), cacheName) : req; - if (fut == null || fut.isDone()) - ctx.cache().completeCacheStartFuture(req, false, null); - else { - fut.listen(new IgniteInClosure>() { - @Override public void apply(IgniteInternalFuture fut) { - ctx.cache().completeCacheStartFuture(req, false, null); - } - }); - } - } + int cacheId = CU.cacheId(cacheName); - return null; - } - }); + CacheGroupDescriptor grpDesc = registerCacheGroup(exchangeActions, + topVer, + ccfg, + cacheId, + req.initiatingNodeId(), + req.deploymentId(), + req.encryptionKey()); + + DynamicCacheDescriptor startDesc = new DynamicCacheDescriptor(ctx, + ccfg, + req.cacheType(), + grpDesc, + false, + req.initiatingNodeId(), + false, + req.sql(), + req.deploymentId(), + req.schema()); + + DynamicCacheDescriptor old = registeredCaches.put(ccfg.getName(), startDesc); + + restartingCaches.remove(ccfg.getName()); + + assert old == null; + + ctx.discovery().setCacheFilter( + startDesc.cacheId(), + grpDesc.groupId(), + ccfg.getName(), + ccfg.getNearConfiguration() != null); + + if (!persistedCfgs) { + ctx.discovery().addClientNode(cacheName, + req.initiatingNodeId(), + req.nearCacheConfiguration() != null); } - return res; + res.addedDescs.add(startDesc); + + exchangeActions.addCacheToStart(req, startDesc); + + return true; } /** @@ -787,7 +884,7 @@ boolean hasRestartingCaches() { * @return Collection of currently restarting caches. */ Collection restartingCaches() { - return restartingCaches; + return restartingCaches.keySet(); } /** @@ -995,7 +1092,7 @@ private CacheNodeCommonDiscoveryData collectCommonDiscoveryData() { templates.put(desc.cacheName(), cacheData); } - Collection restarting = new HashSet<>(restartingCaches); + Collection restarting = new HashSet<>(restartingCaches.keySet()); return new CacheNodeCommonDiscoveryData(caches, templates, @@ -1364,7 +1461,8 @@ public void onStateChangeFinish(ChangeGlobalStateFinishMessage msg) { * @return Exchange action. * @throws IgniteCheckedException If configuration validation failed. */ - public ExchangeActions onStateChangeRequest(ChangeGlobalStateMessage msg, AffinityTopologyVersion topVer, DiscoveryDataClusterState curState) + public ExchangeActions onStateChangeRequest(ChangeGlobalStateMessage msg, AffinityTopologyVersion topVer, + DiscoveryDataClusterState curState) throws IgniteCheckedException { ExchangeActions exchangeActions = new ExchangeActions(); @@ -1604,7 +1702,7 @@ else if (!schemaPatch.isEmpty() && !hasSchemaPatchConflict) //If conflict was detected we don't merge config and we leave existed config. if (!hasSchemaPatchConflict && !patchesToApply.isEmpty()) - for(Map.Entry entry: patchesToApply.entrySet()){ + for (Map.Entry entry : patchesToApply.entrySet()) { if (entry.getKey().applySchemaPatch(entry.getValue())) saveCacheConfiguration(entry.getKey()); } @@ -1765,7 +1863,8 @@ private CacheGroupDescriptor registerCacheGroup( Integer cacheId, UUID rcvdFrom, IgniteUuid deploymentId, - @Nullable byte[] encKey) { + @Nullable byte[] encKey + ) { if (startedCacheCfg.getGroupName() != null) { CacheGroupDescriptor desc = cacheGroupByName(startedCacheCfg.getGroupName()); @@ -1818,7 +1917,8 @@ private CacheGroupDescriptor registerCacheGroup( * @param exchActions Optional exchange actions to update if new group was added. * @param startedCacheCfg Started cache configuration. */ - private boolean resolvePersistentFlag(@Nullable ExchangeActions exchActions, CacheConfiguration startedCacheCfg) { + private boolean resolvePersistentFlag(@Nullable ExchangeActions exchActions, + CacheConfiguration startedCacheCfg) { if (!ctx.clientNode()) { // On server, we always can determine whether cache is persistent by local storage configuration. return CU.isPersistentCache(startedCacheCfg, ctx.config().getDataStorageConfiguration()); @@ -1957,6 +2057,7 @@ ConcurrentMap registeredCacheGroups() { /** * Returns registered cache descriptors ordered by {@code comparator} + * * @param comparator Comparator (DIRECT, REVERSE or custom) to order cache descriptors. * @return Ordered by comparator cache descriptors. */ @@ -2101,6 +2202,28 @@ private boolean surviveReconnect(String cacheName) { return CU.isUtilityCache(cacheName); } + /** + * @param cacheName Cache name. + * @return {@code True} if cache is restarting. + */ + public boolean isRestarting(String cacheName) { + return restartingCaches.containsKey(cacheName); + } + + /** + * @param cacheName Cache name which restart were cancelled. + */ + public void removeRestartingCache(String cacheName) { + restartingCaches.remove(cacheName); + } + + /** + * Clear up information about restarting caches. + */ + public void removeRestartingCaches() { + restartingCaches.clear(); + } + /** * Holds direct comparator (first system caches) and reverse comparator (first user caches). * Use DIRECT comparator for ordering cache start operations. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java index 5b8a89cb41283..812823050f4a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java @@ -17,6 +17,8 @@ package org.apache.ignite.internal.processors.cache; +import java.io.Serializable; +import java.util.UUID; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.GridKernalContext; @@ -25,9 +27,6 @@ import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; -import java.io.Serializable; -import java.util.UUID; - /** * Cache start/stop request. */ @@ -68,6 +67,9 @@ public class DynamicCacheChangeRequest implements Serializable { /** Restart flag. */ private boolean restart; + /** Restart operation id. */ + private IgniteUuid restartId; + /** Cache active on start or not*/ private boolean disabledAfterStart; @@ -264,6 +266,20 @@ public void restart(boolean restart) { this.restart = restart; } + /** + * @return Id of restart to allow only initiator start the restarting cache. + */ + public IgniteUuid restartId() { + return restartId; + } + + /** + * @param restartId Id of cache restart requester. + */ + public void restartId(IgniteUuid restartId) { + this.restartId = restartId; + } + /** * @return Cache name. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeContext.java index 34ed048542c16..4046c98b29414 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeContext.java @@ -17,15 +17,11 @@ package org.apache.ignite.internal.processors.cache; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; -import java.util.UUID; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage; -import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.internal.util.typedef.internal.S; import org.jetbrains.annotations.Nullable; @@ -55,20 +51,11 @@ public class ExchangeContext { /** */ private final boolean compatibilityNode = getBoolean(IGNITE_EXCHANGE_COMPATIBILITY_VER_1, false); - /** */ - private final boolean newMvccCrd; - - /** Currently running mvcc queries, initialized when mvcc coordinator is changed. */ - private Map activeQueries; - /** * @param crd Coordinator flag. - * @param newMvccCrd {@code True} if new coordinator assigned during this exchange. * @param fut Exchange future. */ - public ExchangeContext(boolean crd, boolean newMvccCrd, GridDhtPartitionsExchangeFuture fut) { - this.newMvccCrd = newMvccCrd; - + public ExchangeContext(boolean crd, GridDhtPartitionsExchangeFuture fut) { int protocolVer = exchangeProtocolVersion(fut.firstEventCache().minimumNodeVersion()); if (compatibilityNode || (crd && fut.localJoinExchange())) { @@ -137,34 +124,6 @@ public boolean mergeExchanges() { return merge; } - /** - * @return {@code True} if new node assigned as mvcc coordinator node during this exchange. - */ - public boolean newMvccCoordinator() { - return newMvccCrd; - } - - /** - * @return Active queries. - */ - public Map activeQueries() { - return activeQueries; - } - - /** - * @param nodeId Node ID. - * @param nodeQueries Node queries. - */ - public void addActiveQueries(UUID nodeId, @Nullable GridLongList nodeQueries) { - if (nodeQueries == null) - return; - - if (activeQueries == null) - activeQueries = new HashMap<>(); - - activeQueries.put(nodeId, nodeQueries); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(ExchangeContext.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java index 2f7753beabc02..64233ea85a8da 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java @@ -77,11 +77,6 @@ public class ExchangeDiscoveryEvents { * @param fut Current exchange future. */ public void processEvents(GridDhtPartitionsExchangeFuture fut) { - for (DiscoveryEvent evt : evts) { - if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) - fut.sharedContext().mvcc().removeExplicitNodeLocks(evt.eventNode().id(), fut.initialVersion()); - } - if (hasServerLeft()) warnNoAffinityNodes(fut.sharedContext()); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java index c99eb006002e9..ef861b945147b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java @@ -49,10 +49,8 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cluster.ClusterGroup; import org.apache.ignite.internal.AsyncSupportAdapter; -import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils; import org.apache.ignite.internal.GridKernalState; -import org.apache.ignite.internal.util.future.GridFutureAdapter; -import org.apache.ignite.internal.util.future.IgniteFutureImpl; +import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteClosure; @@ -1494,6 +1492,42 @@ public void setCacheManager(org.apache.ignite.cache.CacheManager cacheMgr) { } } + /** {@inheritDoc} */ + @Override public void preloadPartition(int part) { + CacheOperationGate opGate = onEnter(); + + try { + delegate.preloadPartition(part); + } + finally { + onLeave(opGate); + } + } + + /** {@inheritDoc} */ + @Override public IgniteFuture preloadPartitionAsync(int part) { + CacheOperationGate opGate = onEnter(); + + try { + return delegate.preloadPartitionAsync(part); + } + finally { + onLeave(opGate); + } + } + + /** {@inheritDoc} */ + @Override public boolean localPreloadPartition(int part) { + CacheOperationGate opGate = onEnter(); + + try { + return delegate.localPreloadPartition(part); + } + finally { + onLeave(opGate); + } + } + /** * Safely get CacheGateway. * @@ -1529,12 +1563,7 @@ private GridCacheGateway checkProxyIsValid(@Nullable GridCacheGateway cache = context().kernalContext().cache().publicJCache(context().name()).internalProxy(); - GridFutureAdapter fut = proxyImpl.opportunisticRestart(); - - if (fut == null) - proxyImpl.onRestarted(cache.context(), cache.context().cache()); - else - new IgniteFutureImpl<>(fut).get(); + proxyImpl.opportunisticRestart(cache); return gate(); } catch (IgniteCheckedException ice) { @@ -1551,8 +1580,18 @@ private GridCacheGateway checkProxyIsValid(@Nullable GridCacheGateway gate = checkProxyIsValid(gate(), true); - return new CacheOperationGate(gate, - lock ? gate.enter(opCtx) : gate.enterNoLock(opCtx)); + try { + return new CacheOperationGate(gate, + lock ? gate.enter(opCtx) : gate.enterNoLock(opCtx)); + } + catch (IllegalStateException e) { + boolean isCacheProxy = delegate instanceof IgniteCacheProxyImpl; + + if (isCacheProxy) + ((IgniteCacheProxyImpl) delegate).checkRestart(true); + + throw e; // If we reached this line. + } } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 3156d6d662d12..14890b1d3b9e2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -49,6 +49,7 @@ import javax.cache.processor.EntryProcessorResult; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; @@ -87,9 +88,11 @@ import org.apache.ignite.internal.processors.cache.affinity.GridCacheAffinityImpl; import org.apache.ignite.internal.processors.cache.distributed.IgniteExternalizableExpiryPolicy; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocalAdapter; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo; import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; @@ -136,12 +139,16 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteOutClosure; import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.lang.IgniteProductVersion; +import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.mxbean.CacheMetricsMXBean; import org.apache.ignite.plugin.security.SecurityPermission; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.JobContextResource; +import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionException; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; @@ -149,6 +156,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_RETRIES_COUNT; import static org.apache.ignite.internal.GridClosureCallMode.BROADCAST; import static org.apache.ignite.internal.processors.cache.CacheOperationContext.DFLT_ALLOW_ATOMIC_OPS_IN_TX; +import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING; import static org.apache.ignite.internal.processors.dr.GridDrType.DR_LOAD; import static org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE; import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_NO_FAILOVER; @@ -179,6 +187,9 @@ public abstract class GridCacheAdapter implements IgniteInternalCache> stash = new ThreadLocal>() { @@ -284,6 +295,9 @@ public abstract class GridCacheAdapter implements IgniteInternalCachecacheEntriesIterator(ctx, modes.primary, modes.backup, topVer, ctx.keepBinary())); + MvccSnapshot mvccSnapshot = ctx.mvccEnabled() ? MvccUtils.MVCC_MAX_SNAPSHOT : null; + + its.add(offheapMgr + .cacheEntriesIterator(ctx, modes.primary, modes.backup, topVer, ctx.keepBinary(), mvccSnapshot)); } } else if (modes.heap) { + if (ctx.mvccEnabled()) + return F.emptyIterator(); + if (modes.near && ctx.isNear()) its.add(ctx.near().nearEntries().iterator()); @@ -799,10 +819,8 @@ else if (modes.heap) { } /** {@inheritDoc} */ - @SuppressWarnings("ForLoopReplaceableByForEach") - @Nullable @Override public final V localPeek(K key, - CachePeekMode[] peekModes, - @Nullable IgniteCacheExpiryPolicy plc) + @Override public final V localPeek(K key, + CachePeekMode[] peekModes) throws IgniteCheckedException { A.notNull(key, "key"); @@ -811,9 +829,6 @@ else if (modes.heap) { ctx.checkSecurity(SecurityPermission.CACHE_READ); - //TODO IGNITE-7955 - MvccUtils.verifyMvccOperationSupport(ctx, "Peek"); - PeekModes modes = parsePeekModes(peekModes, false); KeyCacheObject cacheKey = ctx.toCacheKeyObject(key); @@ -872,10 +887,8 @@ else if (modes.heap) { GridCacheContext ctx0; while (true) { - if (nearKey) { - ctx0 = context(); + if (nearKey) e = peekEx(key); - } else { ctx0 = ctx.isNear() ? ctx.near().dht().context() : ctx; e = modes.offheap ? ctx0.cache().entryEx(key) : ctx0.cache().peekEx(key); @@ -885,7 +898,9 @@ else if (modes.heap) { ctx.shared().database().checkpointReadLock(); try { - cacheVal = e.peek(modes.heap, modes.offheap, topVer, plc); + cacheVal = ctx.mvccEnabled() + ? e.mvccPeek(modes.heap && !modes.offheap) + : e.peek(modes.heap, modes.offheap, topVer, null); } catch (GridCacheEntryRemovedException ignore) { if (log.isDebugEnabled()) @@ -894,7 +909,7 @@ else if (modes.heap) { continue; } finally { - e.touch(null); + e.touch(); ctx.shared().database().checkpointReadUnlock(); } @@ -906,7 +921,7 @@ else if (modes.heap) { else { while (true) { try { - cacheVal = localCachePeek0(cacheKey, modes.heap, modes.offheap, plc); + cacheVal = localCachePeek0(cacheKey, modes.heap, modes.offheap); break; } @@ -928,7 +943,6 @@ else if (modes.heap) { * @param key Key. * @param heap Read heap flag. * @param offheap Read offheap flag. - * @param plc Optional expiry policy. * @return Value. * @throws GridCacheEntryRemovedException If entry removed. * @throws IgniteCheckedException If failed. @@ -936,8 +950,7 @@ else if (modes.heap) { @SuppressWarnings("ConstantConditions") @Nullable private CacheObject localCachePeek0(KeyCacheObject key, boolean heap, - boolean offheap, - IgniteCacheExpiryPolicy plc) + boolean offheap) throws GridCacheEntryRemovedException, IgniteCheckedException { assert ctx.isLocal(); assert heap || offheap; @@ -946,10 +959,10 @@ else if (modes.heap) { if (e != null) { try { - return e.peek(heap, offheap, AffinityTopologyVersion.NONE, plc); + return e.peek(heap, offheap, AffinityTopologyVersion.NONE, null); } finally { - e.touch(null); + e.touch(); } } @@ -1261,6 +1274,31 @@ private IgniteInternalFuture executeClearTask(@Nullable Set keys return new GridFinishedFuture<>(); } + /** + * @param part Partition id. + * @return Future. + */ + private IgniteInternalFuture executePreloadTask(int part) throws IgniteCheckedException { + ClusterGroup grp = ctx.grid().cluster().forDataNodes(ctx.name()); + + @Nullable ClusterNode targetNode = ctx.affinity().primaryByPartition(part, ctx.topology().readyTopologyVersion()); + + if (targetNode == null || targetNode.version().compareTo(PRELOAD_PARTITION_SINCE) < 0) { + if (!partPreloadBadVerWarned) { + U.warn(log(), "Attempting to execute partition preloading task on outdated or not mapped node " + + "[targetNodeVer=" + (targetNode == null ? "NA" : targetNode.version()) + + ", minSupportedNodeVer=" + PRELOAD_PARTITION_SINCE + ']'); + + partPreloadBadVerWarned = true; + } + + return new GridFinishedFuture<>(); + } + + return ctx.closures().affinityRun(Collections.singleton(name()), part, + new PartitionPreloadJob(ctx.name(), part), grp.nodes(), null); + } + /** * @param keys Keys. * @param readers Readers flag. @@ -1938,7 +1976,7 @@ protected final IgniteInternalFuture> getAllAsync0( return new GridFinishedFuture<>(e); } - tx = ctx.tm().threadLocalTx(ctx); + tx = checkCurrentTx(); } if (tx == null || tx.implicit()) { @@ -2076,7 +2114,7 @@ else if (storeEnabled) readerArgs); if (res == null) - entry.touch(topVer); + entry.touch(); } } @@ -2091,7 +2129,7 @@ else if (storeEnabled) needVer); if (entry != null && (tx == null || (!tx.implicit() && tx.isolation() == READ_COMMITTED))) - entry.touch(topVer); + entry.touch(); if (keysSize == 1) // Safe to return because no locks are required in READ_COMMITTED mode. @@ -2173,7 +2211,7 @@ else if (storeEnabled) if (tx0 == null || (!tx0.implicit() && tx0.isolation() == READ_COMMITTED)) - entry.touch(topVer); + entry.touch(); break; } @@ -2216,7 +2254,7 @@ else if (storeEnabled) GridCacheEntryEx entry = peekEx(key); if (entry != null) - entry.touch(topVer); + entry.touch(); } } @@ -2246,7 +2284,7 @@ else if (storeEnabled) for (KeyCacheObject key0 : misses.keySet()) { GridCacheEntryEx entry = peekEx(key0); if (entry != null) - entry.touch(topVer); + entry.touch(); } } @@ -2279,6 +2317,19 @@ else if (storeEnabled) } } + /** */ + protected GridNearTxLocal checkCurrentTx() { + if (!ctx.mvccEnabled()) + return ctx.tm().threadLocalTx(ctx); + + try { + return MvccUtils.currentTx(ctx.kernalContext(), null); + } + catch (MvccUtils.UnsupportedTxModeException | MvccUtils.NonMvccTransactionException e) { + throw new TransactionException(e.getMessage()); + } + } + /** * @param topVer Affinity topology version for which load was performed. * @param loadKeys Keys to load. @@ -2307,7 +2358,7 @@ private void clearReservationsIfNeeded( entry.clearReserveForLoad(e.getValue().version()); if (needTouch) - entry.touch(topVer); + entry.touch(); } } } @@ -3663,7 +3714,7 @@ private void loadEntry(KeyCacheObject key, log.debug("Got removed entry during loadCache (will ignore): " + entry); } finally { - entry.touch(topVer); + entry.touch(); } CU.unwindEvicts(ctx); @@ -4009,43 +4060,6 @@ IgniteInternalFuture globalLoadCacheAsync(@Nullable IgniteBiPredicate p return entrySet().iterator(); } - /** - * @param opCtx Cache operation context. - * @return JCache Iterator. - */ - private Iterator> localIteratorHonorExpirePolicy(final CacheOperationContext opCtx) { - return F.iterator(iterator(), - new IgniteClosure, Cache.Entry>() { - private IgniteCacheExpiryPolicy expiryPlc = - ctx.cache().expiryPolicy(opCtx != null ? opCtx.expiry() : null); - - @Override public Cache.Entry apply(Cache.Entry lazyEntry) { - CacheOperationContext prev = ctx.gate().enter(opCtx); - try { - V val = localPeek(lazyEntry.getKey(), CachePeekModes.ONHEAP_ONLY, expiryPlc); - - GridCacheVersion ver = null; - - try { - ver = lazyEntry.unwrap(GridCacheVersion.class); - } - catch (IllegalArgumentException e) { - log.error("Failed to unwrap entry version information", e); - } - - return new CacheEntryImpl<>(lazyEntry.getKey(), val, ver); - } - catch (IgniteCheckedException e) { - throw CU.convertToCacheException(e); - } - finally { - ctx.gate().leave(prev); - } - } - }, false - ); - } - /** {@inheritDoc} */ @Override public Iterator> scanIterator(boolean keepBinary, @Nullable IgniteBiPredicate p) @@ -4204,7 +4218,7 @@ public void awaitLastFut() { awaitLastFut(); - GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx); + GridNearTxLocal tx = checkCurrentTx(); if (tx == null || tx.implicit()) { TransactionConfiguration tCfg = CU.transactionConfiguration(ctx, ctx.kernalContext().config()); @@ -4307,7 +4321,7 @@ private IgniteInternalFuture asyncOp(final AsyncOp op) { if (log.isDebugEnabled()) log.debug("Performing async op: " + op); - GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx); + GridNearTxLocal tx = checkCurrentTx(); CacheOperationContext opCtx = ctx.operationContextPerCall(); @@ -4961,6 +4975,55 @@ private void advance() { return new CacheEntryImpl<>((K)key0, (V)val0, entry.version()); } + /** {@inheritDoc} */ + @Override public void preloadPartition(int part) throws IgniteCheckedException { + if (isLocal()) + ctx.offheap().preloadPartition(part); + else + executePreloadTask(part).get(); + } + + /** {@inheritDoc} */ + @Override public IgniteInternalFuture preloadPartitionAsync(int part) throws IgniteCheckedException { + if (isLocal()) { + return ctx.kernalContext().closure().runLocalSafe(() -> { + try { + ctx.offheap().preloadPartition(part); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + }); + } + else + return executePreloadTask(part); + } + + /** {@inheritDoc} */ + @Override public boolean localPreloadPartition(int part) throws IgniteCheckedException { + if (!ctx.affinityNode()) + return false; + + GridDhtPartitionTopology top = ctx.group().topology(); + + @Nullable GridDhtLocalPartition p = top.localPartition(part, top.readyTopologyVersion(), false); + + if (p == null) + return false; + + try { + if (!p.reserve() || p.state() != OWNING) + return false; + + p.dataStore().preload(); + } + finally { + p.release(); + } + + return true; + } + /** * */ @@ -6691,6 +6754,52 @@ public ClearTask(String cacheName, AffinityTopologyVersion topVer, Set nodesByPartition(int part, AffinityTopologyVersion topV * @return Affinity assignment. */ public AffinityAssignment assignment(AffinityTopologyVersion topVer) { + return assignment(topVer, cctx.shared().exchange().lastAffinityChangedTopologyVersion(topVer)); + } + + /** + * Get affinity assignment for the given topology version. + * + * @param topVer Topology version. + * @return Affinity assignment. + */ + public AffinityAssignment assignment(AffinityTopologyVersion topVer, AffinityTopologyVersion lastAffChangedTopVer) { if (cctx.isLocal()) - topVer = LOC_CACHE_TOP_VER; + topVer = lastAffChangedTopVer = LOC_CACHE_TOP_VER; GridAffinityAssignmentCache aff0 = aff; if (aff0 == null) throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name()); - return aff0.cachedAffinity(topVer); - } - - public MvccCoordinator mvccCoordinator(AffinityTopologyVersion topVer) { - return assignment(topVer).mvccCoordinator(); + return aff0.cachedAffinity(topVer, lastAffChangedTopVer); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java index 75c0d0cde8c23..c390eb5275ed0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java @@ -201,7 +201,7 @@ protected final GridCacheMapEntry putEntryIfObsoleteOrAbsent( true); if (touch) - cur.touch(topVer); + cur.touch(); } assert Math.abs(sizeChange) <= 1; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java index 7eea905966b63..ef33e8b4928a5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java @@ -30,6 +30,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; @@ -109,6 +110,7 @@ import org.apache.ignite.plugin.security.SecurityPermission; import org.jetbrains.annotations.Nullable; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISABLE_TRIGGERING_CACHE_INTERCEPTOR_ON_CONFLICT; import static org.apache.ignite.IgniteSystemProperties.IGNITE_READ_LOAD_BALANCING; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -226,7 +228,7 @@ public class GridCacheContext implements Externalizable { private CacheWeakQueryIteratorsHolder> itHolder; /** Affinity node. */ - private boolean affNode; + private volatile boolean affNode; /** Conflict resolver. */ private CacheVersionConflictResolver conflictRslvr; @@ -238,10 +240,10 @@ public class GridCacheContext implements Externalizable { private CountDownLatch startLatch = new CountDownLatch(1); /** Topology version when cache was started on local node. */ - private AffinityTopologyVersion locStartTopVer; + private volatile AffinityTopologyVersion locStartTopVer; /** Dynamic cache deployment ID. */ - private IgniteUuid dynamicDeploymentId; + private volatile IgniteUuid dynamicDeploymentId; /** Updates allowed flag. */ private boolean updatesAllowed; @@ -271,7 +273,14 @@ public class GridCacheContext implements Externalizable { private boolean readFromBackup = CacheConfiguration.DFLT_READ_FROM_BACKUP; /** Local node's MAC address. */ - private String locMacs; + private volatile String locMacs; + + /** Recovery mode flag. */ + private volatile boolean recoveryMode; + + /** */ + private final boolean disableTriggeringCacheInterceptorOnConflict = + Boolean.parseBoolean(System.getProperty(IGNITE_DISABLE_TRIGGERING_CACHE_INTERCEPTOR_ON_CONFLICT, "false")); /** * Empty constructor required for {@link Externalizable}. @@ -309,8 +318,11 @@ public GridCacheContext( CacheGroupContext grp, CacheType cacheType, AffinityTopologyVersion locStartTopVer, + IgniteUuid deploymentId, boolean affNode, boolean updatesAllowed, + boolean statisticsEnabled, + boolean recoveryMode, /* * Managers in starting order! @@ -395,9 +407,46 @@ public GridCacheContext( readFromBackup = cacheCfg.isReadFromBackup(); + this.dynamicDeploymentId = deploymentId; + this.recoveryMode = recoveryMode; + + statisticsEnabled(statisticsEnabled); + + assert kernalContext().recoveryMode() == recoveryMode; + + if (!recoveryMode) { + locMacs = localNode().attribute(ATTR_MACS); + + assert locMacs != null; + } + } + + /** + * Called when cache was restored during recovery and node has joined to topology. + * + * @param topVer Cache topology join version. + * @param clusterWideDesc Cluster-wide cache descriptor received during exchange. + */ + public void finishRecovery(AffinityTopologyVersion topVer, DynamicCacheDescriptor clusterWideDesc) { + assert recoveryMode : this; + + recoveryMode = false; + + locStartTopVer = topVer; + locMacs = localNode().attribute(ATTR_MACS); assert locMacs != null; + + this.statisticsEnabled = clusterWideDesc.cacheConfiguration().isStatisticsEnabled(); + this.dynamicDeploymentId = clusterWideDesc.deploymentId(); + } + + /** + * @return {@code True} if cache is in recovery mode. + */ + public boolean isRecoveryMode() { + return recoveryMode; } /** @@ -421,13 +470,6 @@ public boolean customAffinityMapper() { return customAffMapper; } - /** - * @param dynamicDeploymentId Dynamic deployment ID. - */ - void dynamicDeploymentId(IgniteUuid dynamicDeploymentId) { - this.dynamicDeploymentId = dynamicDeploymentId; - } - /** * @return Dynamic deployment ID. */ @@ -828,6 +870,13 @@ public boolean transactionalSnapshot() { return cacheCfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT; } + /** + * @return {@code True} if cache interceptor should be skipped in case of conflicts. + */ + public boolean disableTriggeringCacheInterceptorOnConflict() { + return disableTriggeringCacheInterceptorOnConflict; + } + /** * @return Local node. */ @@ -2204,24 +2253,37 @@ else if (type == EVT_CACHE_REBALANCE_STOPPED) { * * @param affNodes All affinity nodes. * @param canRemap Flag indicating that 'get' should be done on a locked topology version. + * @param partitionId Partition ID. * @return Affinity node to get key from or {@code null} if there is no suitable alive node. */ - @Nullable public ClusterNode selectAffinityNodeBalanced(List affNodes, boolean canRemap) { + @Nullable public ClusterNode selectAffinityNodeBalanced( + List affNodes, + Set invalidNodes, + int partitionId, + boolean canRemap + ) { if (!readLoadBalancingEnabled) { if (!canRemap) { + // Find next available node if we can not wait next topology version. for (ClusterNode node : affNodes) { - if (ctx.discovery().alive(node)) + if (ctx.discovery().alive(node) && !invalidNodes.contains(node)) return node; } return null; } - else - return affNodes.get(0); + else { + ClusterNode first = affNodes.get(0); + + return !invalidNodes.contains(first) ? first : null; + } } - if (!readFromBackup) - return affNodes.get(0); + if (!readFromBackup){ + ClusterNode first = affNodes.get(0); + + return !invalidNodes.contains(first) ? first : null; + } assert locMacs != null; @@ -2230,7 +2292,7 @@ else if (type == EVT_CACHE_REBALANCE_STOPPED) { ClusterNode n0 = null; for (ClusterNode node : affNodes) { - if (canRemap || discovery().alive(node)) { + if ((canRemap || discovery().alive(node)) && !invalidNodes.contains(node)) { if (locMacs.equals(node.attribute(ATTR_MACS))) return node; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java index b34da627bd7d3..15af1f10d091d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java @@ -312,7 +312,7 @@ private boolean undeploy(ClassLoader ldr, GridCacheEntryEx e, GridCacheAdapter c Object val0; try { - CacheObject v = entry.peek(null); + CacheObject v = entry.peek(); key0 = key.value(cache.context().cacheObjectContext(), false); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java index cfd70ecc07604..26da38ba019fa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java @@ -712,6 +712,16 @@ public boolean tmLock(IgniteInternalTx tx, */ public boolean checkSerializableReadVersion(GridCacheVersion serReadVer) throws GridCacheEntryRemovedException; + /** + * Retrieves the last committed MVCC entry version. + * @param onheapOnly {@code True} if a specified peek mode instructs to look only in the on-heap storage. + * @return Last committed entry if either or {@code null} otherwise. + * @throws GridCacheEntryRemovedException If entry has been removed. + * @throws IgniteCheckedException If failed. + */ + @Nullable public CacheObject mvccPeek(boolean onheapOnly) + throws GridCacheEntryRemovedException, IgniteCheckedException; + /** * Peeks into entry without loading value or updating statistics. * @@ -732,12 +742,11 @@ public boolean tmLock(IgniteInternalTx tx, /** * Peeks into entry without loading value or updating statistics. * - * @param plc Expiry policy if TTL should be updated. * @return Value. * @throws GridCacheEntryRemovedException If entry has been removed. * @throws IgniteCheckedException If failed. */ - @Nullable public CacheObject peek(@Nullable IgniteCacheExpiryPolicy plc) + @Nullable public CacheObject peek() throws GridCacheEntryRemovedException, IgniteCheckedException; /** @@ -1199,7 +1208,6 @@ public GridCacheUpdateTxResult mvccUpdateRowsWithPreloadInfo( /** * Touch this entry in its context's eviction manager. * - * @param topVer Topology version. */ - public void touch(AffinityTopologyVersion topVer); + public void touch(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java index 3c5cf1e944ad1..ef350160eb11a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java @@ -372,6 +372,10 @@ public void addEvent( public boolean isRecordable(int type) { GridCacheContext cctx0 = cctx; + // Event recording is impossible in recovery mode. + if (cctx0 != null && cctx0.kernalContext().recoveryMode()) + return false; + return cctx0 != null && cctx0.userCache() && cctx0.gridEvents().isRecordable(type) && !cctx0.config().isEventsDisabled(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java index e5ab189329aff..f7bfa3dab3610 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java @@ -23,7 +23,6 @@ import org.apache.ignite.cache.eviction.EvictionFilter; import org.apache.ignite.cache.eviction.EvictionPolicy; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager; @@ -201,7 +200,7 @@ private boolean evict0( } /** {@inheritDoc} */ - @Override public void touch(GridCacheEntryEx e, AffinityTopologyVersion topVer) { + @Override public void touch(GridCacheEntryEx e) { assert e.context() == cctx : "Entry from another cache context passed to eviction manager: [" + "entry=" + e + ", cctx=" + cctx + diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGroupIdMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGroupIdMessage.java index 09c143b0c0dd3..bfdce35e86e62 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGroupIdMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGroupIdMessage.java @@ -50,7 +50,7 @@ public int groupId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 3; + return 4; } /** {@inheritDoc} */ @@ -68,7 +68,7 @@ public int groupId() { } switch (writer.state()) { - case 2: + case 3: if (!writer.writeInt("grpId", grpId)) return false; @@ -90,7 +90,7 @@ public int groupId() { return false; switch (reader.state()) { - case 2: + case 3: grpId = reader.readInt("grpId"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIdMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIdMessage.java index 6c20bdd15bdd6..e0944397ecf3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIdMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIdMessage.java @@ -52,7 +52,7 @@ public void cacheId(int cacheId) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 3; + return 4; } /** {@inheritDoc} */ @@ -70,7 +70,7 @@ public void cacheId(int cacheId) { } switch (writer.state()) { - case 2: + case 3: if (!writer.writeInt("cacheId", cacheId)) return false; @@ -92,7 +92,7 @@ public void cacheId(int cacheId) { return false; switch (reader.state()) { - case 2: + case 3: cacheId = reader.readInt("cacheId"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java index 2e66e5bfc3fe4..87929e50fab49 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java @@ -51,6 +51,8 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishResponse; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareResponse; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxQueryEnlistRequest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxQueryEnlistResponse; import org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicAbstractUpdateRequest; import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicNearResponse; @@ -73,10 +75,16 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse; +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxEnlistRequest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxEnlistResponse; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishResponse; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse; +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxQueryEnlistRequest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxQueryEnlistResponse; +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxQueryResultsEnlistRequest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxQueryResultsEnlistResponse; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryRequest; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryResponse; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxState; @@ -165,6 +173,11 @@ public void dumpPendingMessages(StringBuilder sb) { final GridCacheMessage cacheMsg = (GridCacheMessage)msg; + AffinityTopologyVersion rmtAffVer = cacheMsg.topologyVersion(); + AffinityTopologyVersion lastAffChangedVer = cacheMsg.lastAffinityChangedTopologyVersion(); + + cctx.exchange().lastAffinityChangedTopologyVersion(rmtAffVer, lastAffChangedVer); + IgniteInternalFuture fut = null; if (cacheMsg.partitionExchangeMessage()) { @@ -222,9 +235,8 @@ else if (desc.receivedFromStartVersion() != null) } else { AffinityTopologyVersion locAffVer = cctx.exchange().readyAffinityVersion(); - AffinityTopologyVersion rmtAffVer = cacheMsg.topologyVersion(); - if (locAffVer.compareTo(rmtAffVer) < 0) { + if (locAffVer.compareTo(lastAffChangedVer) < 0) { IgniteLogger log = cacheMsg.messageLogger(cctx); if (log.isDebugEnabled()) { @@ -234,12 +246,13 @@ else if (desc.receivedFromStartVersion() != null) msg0.append(", locTopVer=").append(locAffVer). append(", rmtTopVer=").append(rmtAffVer). + append(", lastAffChangedVer=").append(lastAffChangedVer). append(']'); log.debug(msg0.toString()); } - fut = cctx.exchange().affinityReadyFuture(rmtAffVer); + fut = cctx.exchange().affinityReadyFuture(lastAffChangedVer); } } @@ -1012,6 +1025,66 @@ private void processFailedMessage(UUID nodeId, break; + case 151: { + GridNearTxQueryEnlistRequest req = (GridNearTxQueryEnlistRequest)msg; + + GridNearTxQueryEnlistResponse res = new GridNearTxQueryEnlistResponse( + req.cacheId(), + req.futureId(), + req.miniId(), + req.version(), + req.classError()); + + sendResponseOnFailedMessage(nodeId, res, cctx, plc); + + break; + } + + case 153: { + GridNearTxQueryResultsEnlistRequest req = (GridNearTxQueryResultsEnlistRequest)msg; + + GridNearTxQueryEnlistResponse res = new GridNearTxQueryResultsEnlistResponse( + req.cacheId(), + req.futureId(), + req.miniId(), + req.version(), + req.classError()); + + sendResponseOnFailedMessage(nodeId, res, cctx, plc); + + break; + } + + case 155: /* GridDhtTxQueryEnlistRequest */ + case 156: /* GridDhtTxQueryFirstEnlistRequest */ { + GridDhtTxQueryEnlistRequest req = (GridDhtTxQueryEnlistRequest)msg; + + GridDhtTxQueryEnlistResponse res = new GridDhtTxQueryEnlistResponse( + req.cacheId(), + req.dhtFutureId(), + req.batchId(), + req.classError()); + + sendResponseOnFailedMessage(nodeId, res, cctx, plc); + + break; + } + + case 159: { + GridNearTxEnlistRequest req = (GridNearTxEnlistRequest)msg; + + GridNearTxEnlistResponse res = new GridNearTxEnlistResponse( + req.cacheId(), + req.futureId(), + req.miniId(), + req.version(), + req.classError()); + + sendResponseOnFailedMessage(nodeId, res, cctx, plc); + + break; + } + case -36: { GridDhtAtomicSingleUpdateRequest req = (GridDhtAtomicSingleUpdateRequest)msg; @@ -1155,6 +1228,8 @@ public boolean checkNodeLeft(UUID nodeId, IgniteCheckedException sndErr, boolean public void send(ClusterNode node, GridCacheMessage msg, byte plc) throws IgniteCheckedException { assert !node.isLocal() : node; + msg.lastAffinityChangedTopologyVersion(cctx.exchange().lastAffinityChangedTopologyVersion(msg.topologyVersion())); + if (!onSend(msg, node.id())) return; @@ -1222,6 +1297,8 @@ public void sendOrderedMessage(ClusterNode node, Object topic, GridCacheMessage if (!onSend(msg, node.id())) return; + msg.lastAffinityChangedTopologyVersion(cctx.exchange().lastAffinityChangedTopologyVersion(msg.topologyVersion())); + int cnt = 0; while (cnt <= retryCnt) { @@ -1278,6 +1355,8 @@ void sendNoRetry(ClusterNode node, if (!onSend(msg, null)) return; + msg.lastAffinityChangedTopologyVersion(cctx.exchange().lastAffinityChangedTopologyVersion(msg.topologyVersion())); + try { cctx.gridIO().sendToGridTopic(node, TOPIC_CACHE, msg, plc); @@ -1340,22 +1419,22 @@ private void addHandler( if (msgIdx != -1) { Map idxClsHandlers0 = msgHandlers.idxClsHandlers; - IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers0.get(hndId); + IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers0.compute(hndId, (key, clsHandlers) -> { + if (clsHandlers == null) + clsHandlers = new IgniteBiInClosure[GridCacheMessage.MAX_CACHE_MSG_LOOKUP_INDEX]; - if (cacheClsHandlers == null) { - cacheClsHandlers = new IgniteBiInClosure[GridCacheMessage.MAX_CACHE_MSG_LOOKUP_INDEX]; + if(clsHandlers[msgIdx] != null) + return null; - idxClsHandlers0.put(hndId, cacheClsHandlers); - } + clsHandlers[msgIdx] = c; + + return clsHandlers; + }); - if (cacheClsHandlers[msgIdx] != null) + if (cacheClsHandlers == null) throw new IgniteException("Duplicate cache message ID found [hndId=" + hndId + ", type=" + type + ']'); - cacheClsHandlers[msgIdx] = c; - - msgHandlers.idxClsHandlers = idxClsHandlers0; - return; } else { @@ -1572,7 +1651,7 @@ else if (msg instanceof GridCacheGroupIdMessage) */ static class MessageHandlers { /** Indexed class handlers. */ - volatile Map idxClsHandlers = new HashMap<>(); + volatile Map idxClsHandlers = new ConcurrentHashMap<>(); /** Handler registry. */ ConcurrentMap> diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index 2d788c86e2065..bcdfd1c17580b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -34,6 +34,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.cache.CacheInterceptor; import org.apache.ignite.cache.eviction.EvictableEntry; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.NodeStoppingException; @@ -75,7 +76,6 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionedEntryEx; import org.apache.ignite.internal.processors.dr.GridDrType; import org.apache.ignite.internal.processors.query.IgniteSQLException; @@ -117,6 +117,7 @@ import static org.apache.ignite.internal.processors.cache.GridCacheOperation.UPDATE; import static org.apache.ignite.internal.processors.cache.GridCacheUpdateAtomicResult.UpdateOutcome.INVOKE_NO_OP; import static org.apache.ignite.internal.processors.cache.GridCacheUpdateAtomicResult.UpdateOutcome.REMOVE_NO_VAL; +import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.MVCC_MAX_SNAPSHOT; import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.compareIgnoreOpCounter; import static org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter.RowData.NO_KEY; import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.DUPLICATE_KEY; @@ -142,7 +143,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme /** * NOTE + *
* ==== + *
* Make sure to recalculate this value any time when adding or removing fields from entry. * The size should be count as follows: *

    @@ -150,9 +153,45 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme *
  • References: 8 each
  • *
  • Each nested object should be analyzed in the same way as above.
  • *
+ * ==== + *
+ *
    + *
  • Reference fields:
      + *
    • 8 : {@link #cctx}
    • + *
    • 8 : {@link #key}
    • + *
    • 8 : {@link #val}
    • + *
    • 8 : {@link #ver}
    • + *
    • 8 : {@link #extras}
    • + *
    • 8 : {@link #lock}
    • + *
    • 8 : {@link #listenerLock}
    • + *
    • 8 : {@link GridMetadataAwareAdapter#data}
    • + *
  • + *
  • Primitive fields:
      + *
    • 4 : {@link #hash}
    • + *
    • 1 : {@link #flags}
    • + *
  • + *
  • Extras:
      + *
    • 8 : {@link GridCacheEntryExtras#ttl()}
    • + *
    • 8 : {@link GridCacheEntryExtras#expireTime()}
    • + *
  • + *
  • Version:
      + *
    • 4 : {@link GridCacheVersion#topVer}
    • + *
    • 4 : {@link GridCacheVersion#nodeOrderDrId}
    • + *
    • 8 : {@link GridCacheVersion#order}
    • + *
  • + *
  • Key:
      + *
    • 8 : {@link CacheObjectAdapter#val}
    • + *
    • 8 : {@link CacheObjectAdapter#valBytes}
    • + *
    • 4 : {@link KeyCacheObjectImpl#part}
    • + *
  • + *
  • Value:
      + *
    • 8 : {@link CacheObjectAdapter#val}
    • + *
    • 8 : {@link CacheObjectAdapter#valBytes}
    • + *
  • + *
*/ - // 7 * 8 /*references*/ + 2 * 8 /*long*/ + 1 * 4 /*int*/ + 1 * 1 /*byte*/ + array at parent = 85 - private static final int SIZE_OVERHEAD = 85 /*entry*/ + 32 /* version */ + 4 * 7 /* key + val */; + private static final int SIZE_OVERHEAD = 8 * 8 /* references */ + 5 /* primitives */ + 16 /* extras */ + + 16 /* version */ + 20 /* key */ + 16 /* value */; /** Static logger to avoid re-creation. Made static for test purpose. */ protected static final AtomicReference logRef = new AtomicReference<>(); @@ -222,7 +261,7 @@ protected GridCacheMapEntry( this.cctx = cctx; this.listenerLock = cctx.continuousQueries().getListenerReadLock(); - ver = GridCacheVersionManager.START_VER; + ver = cctx.shared().versions().startVersion(); } /** @@ -332,7 +371,7 @@ protected void value(@Nullable CacheObject val) { * @return {@code True} if start version. */ public boolean isStartVersion() { - return ver == GridCacheVersionManager.START_VER; + return cctx.shared().versions().isStartVersion(ver); } /** {@inheritDoc} */ @@ -1032,7 +1071,7 @@ private EntryGetResult entryGetResult(CacheObject val, GridCacheVersion ver, boo } finally { if (touch) - touch(cctx.affinity().affinityTopologyVersion()); + touch(); } } @@ -1120,14 +1159,17 @@ else if (res.resultType() == ResultType.FILTERED) { assert !invoke || res.invokeResult() != null; - if(invoke) // No-op invoke happened. + if (invoke) // No-op invoke happened. updRes.invokeResult(res.invokeResult()); updRes.filtered(true); + if (retVal) + updRes.prevValue(res.oldValue()); + return updRes; } - else if(noCreate && !invoke && res.resultType() == ResultType.PREV_NULL) + else if (noCreate && !invoke && res.resultType() == ResultType.PREV_NULL) return new GridCacheUpdateTxResult(false); else if (res.resultType() == ResultType.LOCKED) { unlockEntry(); @@ -1204,7 +1246,7 @@ else if (res.resultType() == ResultType.REMOVED_NOT_NULL) { if (lockedByCurrentThread()) { unlockEntry(); - cctx.evicts().touch(this, AffinityTopologyVersion.NONE); + cctx.evicts().touch(this); } } @@ -1222,7 +1264,7 @@ else if (res.resultType() == ResultType.REMOVED_NOT_NULL) { updRes.newValue(res.newValue()); - if(invoke) { + if (invoke && res.resultType() != ResultType.VERSION_FOUND) { assert res.invokeResult() != null; updRes.invokeResult(res.invokeResult()); @@ -1320,7 +1362,7 @@ else if (res.resultType() == ResultType.LOCKED) { if (lockedByCurrentThread()) { unlockEntry(); - cctx.evicts().touch(this, AffinityTopologyVersion.NONE); + cctx.evicts().touch(this); } } @@ -1329,7 +1371,7 @@ else if (res.resultType() == ResultType.LOCKED) { GridCacheUpdateTxResult updRes = valid ? new GridCacheUpdateTxResult(true, 0L, logPtr) : new GridCacheUpdateTxResult(false, logPtr); - if(retVal && (res.resultType() == ResultType.PREV_NOT_NULL || res.resultType() == ResultType.VERSION_FOUND)) + if (retVal && (res.resultType() == ResultType.PREV_NOT_NULL || res.resultType() == ResultType.VERSION_FOUND)) updRes.prevValue(res.oldValue()); if (needOldVal && compareIgnoreOpCounter(res.resultVersion(), mvccVer) != 0 && @@ -1388,7 +1430,7 @@ else if (res.resultType() == ResultType.LOCKED) { if (lockedByCurrentThread()) { unlockEntry(); - cctx.evicts().touch(this, AffinityTopologyVersion.NONE); + cctx.evicts().touch(this); } } @@ -1467,7 +1509,7 @@ else if (res.resultType() == ResultType.LOCKED) { boolean internal = isInternal() || !context().userCache(); Map lsnrCol = - notifyContinuousQueries(tx) ? + notifyContinuousQueries() ? cctx.continuousQueries().updateListeners(internal, false) : null; if (startVer && (retval || intercept || lsnrCol != null)) @@ -1480,17 +1522,18 @@ else if (res.resultType() == ResultType.LOCKED) { old = oldValPresent ? oldVal : this.val; + if (intercept) + intercept = !skipInterceptor(explicitVer); + if (intercept) { val0 = cctx.unwrapBinaryIfNeeded(val, keepBinary, false); CacheLazyEntry e = new CacheLazyEntry(cctx, key, old, keepBinary); - Object interceptorVal = cctx.config().getInterceptor().onBeforePut( - new CacheLazyEntry(cctx, key, old, keepBinary), - val0); - key0 = e.key(); + Object interceptorVal = cctx.config().getInterceptor().onBeforePut(e, val0); + if (interceptorVal == null) return new GridCacheUpdateTxResult(false, logPtr); else if (interceptorVal != val0) @@ -1700,7 +1743,7 @@ protected Object keyValue(boolean cpy) { boolean internal = isInternal() || !context().userCache(); Map lsnrCol = - notifyContinuousQueries(tx) ? + notifyContinuousQueries() ? cctx.continuousQueries().updateListeners(internal, false) : null; if (startVer && (retval || intercept || lsnrCol != null)) @@ -1708,6 +1751,9 @@ protected Object keyValue(boolean cpy) { old = oldValPresent ? oldVal : val; + if (intercept) + intercept = !skipInterceptor(explicitVer); + if (intercept) { entry0 = new CacheLazyEntry(cctx, key, old, keepBinary); @@ -1833,9 +1879,6 @@ else if (log.isDebugEnabled()) unlockListenerReadLock(); } - if (deferred) - cctx.onDeferredDelete(this, newVer); - if (marked) { assert !deferred; @@ -2032,12 +2075,12 @@ else if (ttl == CU.TTL_NOT_CHANGED) else updated = (CacheObject)writeObj; - op = updated == null ? GridCacheOperation.DELETE : GridCacheOperation.UPDATE; + op = updated == null ? DELETE : UPDATE; if (intercept) { CacheLazyEntry e; - if (op == GridCacheOperation.UPDATE) { + if (op == UPDATE) { updated0 = value(updated0, updated, keepBinary, false); e = new CacheLazyEntry(cctx, key, key0, old, old0, keepBinary); @@ -2070,7 +2113,7 @@ else if (ttl == CU.TTL_NOT_CHANGED) long ttl = CU.TTL_ETERNAL; long expireTime = CU.EXPIRE_TIME_ETERNAL; - if (op == GridCacheOperation.UPDATE) { + if (op == UPDATE) { if (expiryPlc != null) { ttl = CU.toTtl(hadVal ? expiryPlc.getExpiryForUpdate() : expiryPlc.getExpiryForCreation()); @@ -2088,14 +2131,14 @@ else if (ttl != CU.TTL_ZERO) } if (ttl == CU.TTL_ZERO) { - op = GridCacheOperation.DELETE; + op = DELETE; //If time expired no transformation needed. transformOp = false; } // Try write-through. - if (op == GridCacheOperation.UPDATE) { + if (op == UPDATE) { // Detach value before index update. updated = cctx.kernalContext().cacheObjects().prepareForCache(updated, cctx); @@ -2189,7 +2232,7 @@ else if (op == DELETE && transformOp) } if (intercept) { - if (op == GridCacheOperation.UPDATE) + if (op == UPDATE) cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, updated, updated0, keepBinary, 0L)); else cctx.config().getInterceptor().onAfterRemove(new CacheLazyEntry(cctx, key, key0, old, old0, keepBinary, 0L)); @@ -2282,7 +2325,9 @@ else if (op == DELETE && transformOp) conflictVer, conflictResolve, intercept, - updateCntr); + updateCntr, + cctx.disableTriggeringCacheInterceptorOnConflict() + ); key.valueBytes(cctx.cacheObjectContext()); @@ -2402,7 +2447,7 @@ else if (updateMetrics && REMOVE_NO_VAL.equals(updateRes.outcome()) keepBinary); } - if (c.op == GridCacheOperation.UPDATE) { + if (c.op == UPDATE) { updateVal = val; assert updateVal != null : c; @@ -2432,7 +2477,7 @@ else if (updateMetrics && REMOVE_NO_VAL.equals(updateRes.outcome()) } } else { - assert c.op == GridCacheOperation.DELETE : c.op; + assert c.op == DELETE : c.op; clearReaders(); @@ -2480,29 +2525,23 @@ else if (updateMetrics && REMOVE_NO_VAL.equals(updateRes.outcome()) topVer); } - if (intercept) { - if (c.op == GridCacheOperation.UPDATE) { - cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry( - cctx, - key, - null, - updateVal, - null, - keepBinary, - c.updateRes.updateCounter())); - } - else { - assert c.op == GridCacheOperation.DELETE : c.op; + if (intercept && c.wasIntercepted) { + assert c.op == UPDATE || c.op == DELETE : c.op; - cctx.config().getInterceptor().onAfterRemove(new CacheLazyEntry( - cctx, - key, - null, - oldVal, - null, - keepBinary, - c.updateRes.updateCounter())); - } + Cache.Entry entry = new CacheLazyEntry<>( + cctx, + key, + null, + c.op == UPDATE ? updateVal : oldVal, + null, + keepBinary, + c.updateRes.updateCounter() + ); + + if (c.op == UPDATE) + cctx.config().getInterceptor().onAfterPut(entry); + else + cctx.config().getInterceptor().onAfterRemove(entry); } } finally { @@ -2908,11 +2947,6 @@ protected final boolean markObsolete0(GridCacheVersion ver, boolean clear, GridC ver = newVer; flags &= ~IS_EVICT_DISABLED; - if (cctx.mvccEnabled()) - cctx.offheap().mvccRemoveAll(this); - else - removeValue(); - onInvalidate(); return obsoleteVersionExtras() != null; @@ -2959,13 +2993,10 @@ protected final void update(@Nullable CacheObject val, long expireTime, long ttl } /** - * @param tx Transaction. - * @return {@code True} if should notify continuous query manager. + * @return {@code True} if should notify continuous query manager on updates of this entry. */ - private boolean notifyContinuousQueries(@Nullable IgniteInternalTx tx) { - return cctx.isLocal() || - cctx.isReplicated() || - (!isNear() && !(tx != null && tx.onePhaseCommit() && !tx.local())); + private boolean notifyContinuousQueries() { + return !isNear(); } /** @@ -3094,6 +3125,26 @@ int hash() { return hash; } + /** {@inheritDoc} */ + @Nullable @Override public CacheObject mvccPeek(boolean onheapOnly) + throws GridCacheEntryRemovedException, IgniteCheckedException { + if (onheapOnly) + return null; + + lockEntry(); + + try { + checkObsolete(); + + CacheDataRow row = cctx.offheap().mvccRead(cctx, key, MVCC_MAX_SNAPSHOT); + + return row != null ? row.value() : null; + } + finally { + unlockEntry(); + } + } + /** {@inheritDoc} */ @Nullable @Override public CacheObject peek( boolean heap, @@ -3162,13 +3213,13 @@ int hash() { } /** {@inheritDoc} */ - @Nullable @Override public CacheObject peek(@Nullable IgniteCacheExpiryPolicy plc) + @Nullable @Override public CacheObject peek() throws GridCacheEntryRemovedException, IgniteCheckedException { IgniteInternalTx tx = cctx.tm().localTx(); AffinityTopologyVersion topVer = tx != null ? tx.topologyVersion() : cctx.affinity().affinityTopologyVersion(); - return peek(true, false, topVer, plc); + return peek(true, false, topVer, null); } /** @@ -3233,6 +3284,34 @@ protected final boolean hasValueUnlocked() { return val != null; } + /** + * Checks, that changes were got by DR. + * + * @param explicitVer – Explicit version (if any). + * @return {@code true} if changes were got by DR and {@code false} otherwise. + */ + private boolean isRemoteDrUpdate(@Nullable GridCacheVersion explicitVer) { + return explicitVer != null && explicitVer.dataCenterId() != cctx.dr().dataCenterId(); + } + + /** + * Checks, that cache interceptor should be skipped. + *

+ * It is expects by default behavior that Interceptor methods ({@link CacheInterceptor#onBeforePut(Cache.Entry, + * Object)}, {@link CacheInterceptor#onAfterPut(Cache.Entry)}, {@link CacheInterceptor#onBeforeRemove(Cache.Entry)} + * and {@link CacheInterceptor#onAfterRemove(Cache.Entry)}) will be called, but {@link + * CacheInterceptor#onGet(Object, Object)}. This can even make DR-update flow broken in case of non-idempotent + * Interceptor and force users to call onGet manually as the only workaround. Also, user may want to skip + * Interceptor to avoid redundant entry transformation for DR updates and exchange with internal data b/w data + * centres which is a normal case. + * + * @param explicitVer - Explicit version (if any). + * @return {@code true} if cache interceptor should be skipped and {@code false} otherwise. + */ + private boolean skipInterceptor(@Nullable GridCacheVersion explicitVer) { + return isRemoteDrUpdate(explicitVer) && cctx.disableTriggeringCacheInterceptorOnConflict(); + } + /** {@inheritDoc} */ @Override public CacheObject rawPut(CacheObject val, long ttl) { lockEntry(); @@ -3294,7 +3373,7 @@ protected final boolean hasValueUnlocked() { GridCacheVersion currentVer = row != null ? row.version() : GridCacheMapEntry.this.ver; - boolean isStartVer = currentVer == GridCacheVersionManager.START_VER; + boolean isStartVer = cctx.shared().versions().isStartVersion(currentVer); if (cctx.group().persistenceEnabled()) { if (!isStartVer) { @@ -3422,7 +3501,7 @@ else if (deletedUnlocked()) expireTime, partition(), updateCntr, - mvccVer + mvccVer == null ? MvccUtils.INITIAL_VERSION : mvccVer ))); } else { cctx.shared().wal().log(new DataRecord(new DataEntry( @@ -4295,9 +4374,9 @@ protected WALPointer logTxUpdate(IgniteInternalTx tx, CacheObject val, long expi if (tx.local()) { // For remote tx we log all updates in batch: GridDistributedTxRemoteAdapter.commitIfLocked() GridCacheOperation op; if (val == null) - op = GridCacheOperation.DELETE; + op = DELETE; else - op = this.val == null ? GridCacheOperation.CREATE : GridCacheOperation.UPDATE; + op = this.val == null ? GridCacheOperation.CREATE : UPDATE; return cctx.shared().wal().log(new DataRecord(new DataEntry( cctx.cacheId(), @@ -4331,9 +4410,9 @@ protected WALPointer logMvccUpdate(IgniteInternalTx tx, CacheObject val, long ex if (tx.local()) { // For remote tx we log all updates in batch: GridDistributedTxRemoteAdapter.commitIfLocked() GridCacheOperation op; if (val == null) - op = GridCacheOperation.DELETE; + op = DELETE; else - op = this.val == null ? GridCacheOperation.CREATE : GridCacheOperation.UPDATE; + op = this.val == null ? GridCacheOperation.CREATE : UPDATE; return cctx.shared().wal().log(new MvccDataRecord(new MvccDataEntry( cctx.cacheId(), @@ -4413,7 +4492,7 @@ protected void removeValue() throws IgniteCheckedException { return null; try { - return e.peek(null); + return e.peek(); } catch (GridCacheEntryRemovedException ignored) { // No-op. @@ -4908,7 +4987,7 @@ protected final void checkOwnerChanged(@Nullable CacheLockCandidates prevOwners, */ private void updateMetrics(GridCacheOperation op, boolean metrics, boolean transformed, boolean hasOldVal) { if (metrics && cctx.statisticsEnabled()) { - if (op == GridCacheOperation.DELETE) { + if (op == DELETE) { cctx.cache().metrics0().onRemove(); if (transformed) @@ -4957,6 +5036,11 @@ private int extrasSize() { return extras != null ? extras.size() : 0; } + /** {@inheritDoc} */ + @Override public void txUnlock(IgniteInternalTx tx) throws GridCacheEntryRemovedException { + removeLock(tx.xidVersion()); + } + /** {@inheritDoc} */ @Override public void onUnlock() { // No-op. @@ -4998,8 +5082,8 @@ private void unlockListenerReadLock() { } /** {@inheritDoc} */ - @Override public void touch(AffinityTopologyVersion topVer) { - context().evicts().touch(this, topVer); + @Override public void touch() { + context().evicts().touch(this); } /** {@inheritDoc} */ @@ -5199,7 +5283,7 @@ else if (res.resultType() == ResultType.LOCKED) { if (entry.lockedByCurrentThread()) { entry.unlockEntry(); - cctx.evicts().touch(entry, AffinityTopologyVersion.NONE); + cctx.evicts().touch(entry); } } @@ -5305,7 +5389,7 @@ else if (res.resultType() == ResultType.LOCKED) { if (entry.lockedByCurrentThread()) { entry.unlockEntry(); - cctx.evicts().touch(entry, AffinityTopologyVersion.NONE); + cctx.evicts().touch(entry); } } @@ -5480,6 +5564,9 @@ else if (res.resultType() == ResultType.FILTERED) { updRes.filtered(true); + if (needVal) + updRes.prevValue(res.oldValue()); + resFut.onDone(updRes); return; @@ -5552,7 +5639,7 @@ else if (res.resultType() == ResultType.REMOVED_NOT_NULL) { if (entry.lockedByCurrentThread()) { entry.unlockEntry(); - cctx.evicts().touch(entry, AffinityTopologyVersion.NONE); + cctx.evicts().touch(entry); } } @@ -5561,7 +5648,7 @@ else if (res.resultType() == ResultType.REMOVED_NOT_NULL) { GridCacheUpdateTxResult updRes = valid ? new GridCacheUpdateTxResult(true, 0L, logPtr) : new GridCacheUpdateTxResult(false, logPtr); - if(invoke) { + if (invoke) { assert res.invokeResult() != null; updRes.invokeResult(res.invokeResult()); @@ -5837,6 +5924,9 @@ private static class AtomicCacheUpdateClosure implements IgniteCacheOffheapManag /** */ private final Long updateCntr; + /** */ + private final boolean skipInterceptorOnConflict; + /** */ private GridCacheUpdateAtomicResult updateRes; @@ -5850,8 +5940,12 @@ private static class AtomicCacheUpdateClosure implements IgniteCacheOffheapManag private CacheDataRow oldRow; /** OldRow expiration flag. */ - private boolean oldRowExpiredFlag = false; + private boolean oldRowExpiredFlag; + + /** Disable interceptor invocation onAfter* methods flag. */ + private boolean wasIntercepted; + /** */ AtomicCacheUpdateClosure( GridCacheMapEntry entry, AffinityTopologyVersion topVer, @@ -5871,7 +5965,8 @@ private static class AtomicCacheUpdateClosure implements IgniteCacheOffheapManag @Nullable GridCacheVersion conflictVer, boolean conflictResolve, boolean intercept, - @Nullable Long updateCntr) { + @Nullable Long updateCntr, + boolean skipInterceptorOnConflict) { assert op == UPDATE || op == DELETE || op == TRANSFORM : op; this.entry = entry; @@ -5893,6 +5988,7 @@ private static class AtomicCacheUpdateClosure implements IgniteCacheOffheapManag this.conflictResolve = conflictResolve; this.intercept = intercept; this.updateCntr = updateCntr; + this.skipInterceptorOnConflict = skipInterceptorOnConflict; switch (op) { case UPDATE: @@ -6250,7 +6346,7 @@ private void update(@Nullable GridCacheVersionConflictContext conflictCtx, newExpireTime = entry.expireTimeExtras(); } else if (newSysTtl == CU.TTL_ZERO) { - op = GridCacheOperation.DELETE; + op = DELETE; writeObj = null; @@ -6270,18 +6366,16 @@ else if (newSysTtl == CU.TTL_ZERO) { newSysExpireTime = newExpireTime = conflictCtx.expireTime(); } - if (intercept) { + if (intercept && (conflictVer == null || !skipInterceptorOnConflict)) { Object updated0 = cctx.unwrapBinaryIfNeeded(updated, keepBinary, false); - CacheLazyEntry interceptEntry = new CacheLazyEntry<>(cctx, - entry.key, - null, - oldVal, - null, - keepBinary); + CacheLazyEntry interceptEntry = + new CacheLazyEntry<>(cctx, entry.key, null, oldVal, null, keepBinary); Object interceptorVal = cctx.config().getInterceptor().onBeforePut(interceptEntry, updated0); + wasIntercepted = true; + if (interceptorVal == null) { treeOp = IgniteTree.OperationType.NOOP; @@ -6380,16 +6474,14 @@ private void remove(@Nullable GridCacheVersionConflictContext conflictCtx, IgniteBiTuple interceptRes = null; - if (intercept) { - CacheLazyEntry intercepEntry = new CacheLazyEntry<>(cctx, - entry.key, - null, - oldVal, - null, - keepBinary); + if (intercept && (conflictVer == null || !skipInterceptorOnConflict)) { + CacheLazyEntry intercepEntry = + new CacheLazyEntry<>(cctx, entry.key, null, oldVal, null, keepBinary); interceptRes = cctx.config().getInterceptor().onBeforeRemove(intercepEntry); + wasIntercepted = true; + if (cctx.cancelRemove(interceptRes)) { treeOp = IgniteTree.OperationType.NOOP; @@ -6553,7 +6645,7 @@ private void remove(@Nullable GridCacheVersionConflictContext conflictCtx, assert conflictCtx.isUseNew(); // Update value is known at this point, so update operation type. - op = writeObj != null ? GridCacheOperation.UPDATE : GridCacheOperation.DELETE; + op = writeObj != null ? UPDATE : DELETE; } return conflictCtx; @@ -6675,12 +6767,14 @@ private IgniteBiTuple runEntryProcessor(CacheInvokeEntry runEntryProcessor(CacheInvokeEntry runEntryProcessor(CacheInvokeEntry fut : activeFutures()) fut.onNodeLeft(discoEvt.eventNode().id()); @@ -353,23 +355,25 @@ private IgniteInternalFuture ignoreErrors(IgniteInternalFuture f) { /** * @param leftNodeId Left node ID. - * @param topVer Topology version. */ - public void removeExplicitNodeLocks(UUID leftNodeId, AffinityTopologyVersion topVer) { - for (GridDistributedCacheEntry entry : locked()) { - try { - entry.removeExplicitNodeLocks(leftNodeId); - - entry.touch(topVer); - } - catch (GridCacheEntryRemovedException ignore) { - if (log.isDebugEnabled()) - log.debug("Attempted to remove node locks from removed entry in mvcc manager " + - "disco callback (will ignore): " + entry); - } - - cctx.exchange().exchangerUpdateHeartbeat(); - } + public void removeExplicitNodeLocks(UUID leftNodeId) { + cctx.kernalContext().closure().runLocalSafe( + new Runnable() { + @Override public void run() { + for (GridDistributedCacheEntry entry : locked()) { + try { + entry.removeExplicitNodeLocks(leftNodeId); + + entry.touch(); + } + catch (GridCacheEntryRemovedException ignore) { + if (log.isDebugEnabled()) + log.debug("Attempted to remove node locks from removed entry in cache lock manager " + + "disco callback (will ignore): " + entry); + } + } + } + }, true); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java index eb8901065381e..a568f3e7be6c2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -35,6 +34,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentNavigableMap; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; @@ -58,6 +58,7 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.IgniteNeedReconnectException; +import org.apache.ignite.internal.NodeStoppingException; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.events.DiscoveryCustomEvent; import org.apache.ignite.internal.managers.discovery.DiscoCache; @@ -109,6 +110,7 @@ import org.apache.ignite.internal.util.typedef.CI2; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; +import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; @@ -133,6 +135,8 @@ import static org.apache.ignite.internal.GridTopic.TOPIC_CACHE; import static org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT; import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL; +import static org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE; +import static org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap.PARTIAL_COUNTERS_MAP_SINCE; import static org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.nextDumpTimeout; import static org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader.DFLT_PRELOAD_RESEND_TIMEOUT; @@ -175,19 +179,23 @@ public class GridCachePartitionExchangeManager extends GridCacheSharedMana @Nullable private volatile GridDhtPartitionsExchangeFuture lastInitializedFut; /** */ - private final AtomicReference lastFinishedFut = new AtomicReference<>(); + private final AtomicReference lastFinishedFut = new AtomicReference<>(); /** */ private final ConcurrentMap readyFuts = new ConcurrentSkipListMap<>(); + /** */ + private final ConcurrentNavigableMap lastAffTopVers = + new ConcurrentSkipListMap<>(); + /** * Latest started rebalance topology version but possibly not finished yet. Value {@code NONE} * means that previous rebalance is undefined and the new one should be initiated. * * Should not be used to determine latest rebalanced topology. */ - private volatile AffinityTopologyVersion rebTopVer = AffinityTopologyVersion.NONE; + private volatile AffinityTopologyVersion rebTopVer = NONE; /** */ private GridFutureAdapter reconnectExchangeFut; @@ -430,9 +438,11 @@ else if (m instanceof GridDhtPartitionDemandLegacyMessage) { return; } + else + U.error(log, "Unsupported message type: " + m.getClass().getName()); } - U.error(log, "Unsupported message type: " + m.getClass().getName()); + U.warn(log, "Cache group with id=" + m.groupId() + " is stopped or absent"); } finally { leaveBusy(); @@ -754,7 +764,7 @@ public static Object rebalanceTopic(int idx) { stopErr = cctx.kernalContext().clientDisconnected() ? new IgniteClientDisconnectedCheckedException(cctx.kernalContext().cluster().clientReconnectFuture(), "Client node disconnected: " + cctx.igniteInstanceName()) : - new IgniteInterruptedCheckedException("Node is stopping: " + cctx.igniteInstanceName()); + new NodeStoppingException("Node is stopping: " + cctx.igniteInstanceName()); // Stop exchange worker U.cancel(exchWorker); @@ -893,11 +903,11 @@ public GridDhtPartitionsExchangeFuture lastTopologyFuture() { /** * @param fut Finished future. */ - public void lastFinishedFuture(GridDhtTopologyFuture fut) { + public void lastFinishedFuture(GridDhtPartitionsExchangeFuture fut) { assert fut != null && fut.isDone() : fut; while (true) { - GridDhtTopologyFuture cur = lastFinishedFut.get(); + GridDhtPartitionsExchangeFuture cur = lastFinishedFut.get(); if (fut.topologyVersion() != null && (cur == null || fut.topologyVersion().compareTo(cur.topologyVersion()) > 0)) { if (lastFinishedFut.compareAndSet(cur, fut)) @@ -913,6 +923,17 @@ public void lastFinishedFuture(GridDhtTopologyFuture fut) { * @return Future or {@code null} is future is already completed. */ @Nullable public IgniteInternalFuture affinityReadyFuture(AffinityTopologyVersion ver) { + GridDhtPartitionsExchangeFuture lastInitializedFut0 = lastInitializedFut; + + if (lastInitializedFut0 != null && lastInitializedFut0.initialVersion().compareTo(ver) == 0 + && lastInitializedFut0.changedAffinity()) { + if (log.isTraceEnabled()) + log.trace("Return lastInitializedFut for topology ready future " + + "[ver=" + ver + ", fut=" + lastInitializedFut0 + ']'); + + return lastInitializedFut0; + } + AffinityTopologyVersion topVer = exchFuts.readyTopVer(); if (topVer.compareTo(ver) >= 0) { @@ -977,6 +998,48 @@ public boolean hasPendingExchange() { return exchWorker.hasPendingExchange(); } + /** + * + * @param topVer Topology version. + * @return Last topology version before the provided one when affinity was modified. + */ + public AffinityTopologyVersion lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer) { + if (topVer.topologyVersion() <= 0) + return topVer; + + AffinityTopologyVersion lastAffTopVer = lastAffTopVers.get(topVer); + + return lastAffTopVer != null ? lastAffTopVer : topVer; + } + + /** + * + * @param topVer Topology version. + * @param lastAffTopVer Last topology version before the provided one when affinity was modified. + * @return {@code True} if data was modified. + */ + public boolean lastAffinityChangedTopologyVersion(AffinityTopologyVersion topVer, AffinityTopologyVersion lastAffTopVer) { + assert lastAffTopVer.compareTo(topVer) <= 0; + + if (lastAffTopVer.topologyVersion() <= 0 || lastAffTopVer.equals(topVer)) + return false; + + while (true) { + AffinityTopologyVersion old = lastAffTopVers.putIfAbsent(topVer, lastAffTopVer); + + if (old == null) + return true; + + if (lastAffTopVer.compareTo(old) < 0) { + if (lastAffTopVers.replace(topVer, old, lastAffTopVer)) + return true; + } + else + return false; + } + + } + /** * @param evt Discovery event. * @return Affinity topology version. @@ -1028,11 +1091,13 @@ public void scheduleResendPartitions() { } /** - * Partition refresh callback. + * Partition refresh callback for selected cache groups. * For coordinator causes {@link GridDhtPartitionsFullMessage FullMessages} send, * for non coordinator - {@link GridDhtPartitionsSingleMessage SingleMessages} send + * + * @param grps Cache groups for partitions refresh. */ - public void refreshPartitions() { + public void refreshPartitions(@NotNull Collection grps) { // TODO https://issues.apache.org/jira/browse/IGNITE-6857 if (cctx.snapshot().snapshotOperationInProgress()) { scheduleResendPartitions(); @@ -1040,7 +1105,14 @@ public void refreshPartitions() { return; } - ClusterNode oldest = cctx.discovery().oldestAliveServerNode(AffinityTopologyVersion.NONE); + if (grps.isEmpty()) { + if (log.isDebugEnabled()) + log.debug("Skip partitions refresh, there are no cache groups for partition refresh."); + + return; + } + + ClusterNode oldest = cctx.discovery().oldestAliveServerNode(NONE); if (oldest == null) { if (log.isDebugEnabled()) @@ -1049,8 +1121,10 @@ public void refreshPartitions() { return; } - if (log.isDebugEnabled()) - log.debug("Refreshing partitions [oldest=" + oldest.id() + ", loc=" + cctx.localNodeId() + ']'); + if (log.isDebugEnabled()) { + log.debug("Refreshing partitions [oldest=" + oldest.id() + ", loc=" + cctx.localNodeId() + + ", cacheGroups= " + grps + ']'); + } // If this is the oldest node. if (oldest.id().equals(cctx.localNodeId())) { @@ -1068,50 +1142,66 @@ public void refreshPartitions() { // No need to send to nodes which did not finish their first exchange. AffinityTopologyVersion rmtTopVer = - lastFut != null ? (lastFut.isDone() ? lastFut.topologyVersion() : lastFut.initialVersion()) : AffinityTopologyVersion.NONE; + lastFut != null ? + (lastFut.isDone() ? lastFut.topologyVersion() : lastFut.initialVersion()) + : AffinityTopologyVersion.NONE; Collection rmts = cctx.discovery().remoteAliveNodesWithCaches(rmtTopVer); if (log.isDebugEnabled()) log.debug("Refreshing partitions from oldest node: " + cctx.localNodeId()); - sendAllPartitions(rmts, rmtTopVer); + sendAllPartitions(rmts, rmtTopVer, grps); } else { if (log.isDebugEnabled()) log.debug("Refreshing local partitions from non-oldest node: " + cctx.localNodeId()); - sendLocalPartitions(oldest, null); + sendLocalPartitions(oldest, null, grps); } } + /** + * Partition refresh callback. + * For coordinator causes {@link GridDhtPartitionsFullMessage FullMessages} send, + * for non coordinator - {@link GridDhtPartitionsSingleMessage SingleMessages} send + */ + public void refreshPartitions() { refreshPartitions(cctx.cache().cacheGroups()); } + /** * @param nodes Nodes. * @param msgTopVer Topology version. Will be added to full message. + * @param grps Selected cache groups. */ private void sendAllPartitions( Collection nodes, - AffinityTopologyVersion msgTopVer + AffinityTopologyVersion msgTopVer, + Collection grps ) { long time = System.currentTimeMillis(); - GridDhtPartitionsFullMessage m = createPartitionsFullMessage(true, false, null, null, null, null); + GridDhtPartitionsFullMessage m = createPartitionsFullMessage(true, false, null, null, null, null, grps); m.topologyVersion(msgTopVer); if (log.isInfoEnabled()) { long latency = System.currentTimeMillis() - time; - if (latency > 100 || log.isDebugEnabled()) - log.info("Full Message creating for " + msgTopVer + " performed in " + latency + " ms."); + if (latency > 50 || log.isDebugEnabled()) { + log.info("Finished full message creation [msgTopVer=" + msgTopVer + ", groups=" + grps + + ", latency=" + latency + "ms]"); + } } if (log.isTraceEnabled()) - log.trace("Sending all partitions [nodeIds=" + U.nodeIds(nodes) + ", msg=" + m + ']'); + log.trace("Sending all partitions [nodeIds=" + U.nodeIds(nodes) + ", cacheGroups=" + grps + + ", msg=" + m + ']'); time = System.currentTimeMillis(); + Collection failedNodes = U.newHashSet(nodes.size()); + for (ClusterNode node : nodes) { try { assert !node.equals(cctx.localNode()); @@ -1119,22 +1209,34 @@ private void sendAllPartitions( cctx.io().sendNoRetry(node, m, SYSTEM_POOL); } catch (ClusterTopologyCheckedException ignore) { - if (log.isDebugEnabled()) - log.debug("Failed to send partition update to node because it left grid (will ignore) [node=" + - node.id() + ", msg=" + m + ']'); + if (log.isDebugEnabled()) { + log.debug("Failed to send partition update to node because it left grid (will ignore) " + + "[node=" + node.id() + ", msg=" + m + ']'); + } } catch (IgniteCheckedException e) { - U.warn(log, "Failed to send partitions full message [node=" + node + ", err=" + e + ']'); + failedNodes.add(node); + + U.warn(log, "Failed to send partitions full message [node=" + node + ", err=" + e + ']', e); } } - if (log.isInfoEnabled()) - log.info("Sending Full Message for " + msgTopVer + " performed in " + (System.currentTimeMillis() - time) + " ms."); + if (log.isInfoEnabled()) { + long latency = System.currentTimeMillis() - time; + + if (latency > 50 || log.isDebugEnabled()) { + log.info("Finished sending full message [msgTopVer=" + msgTopVer + ", groups=" + grps + + (failedNodes.isEmpty() ? "" : (", skipped=" + U.nodeIds(failedNodes))) + + ", latency=" + latency + "ms]"); + } + } } /** + * Creates partitions full message for all cache groups. + * * @param compress {@code True} if possible to compress message (properly work only if prepareMarshall/ - * finishUnmarshall methods are called). + * finishUnmarshall methods are called). * @param newCntrMap {@code True} if possible to use {@link CachePartitionFullCountersMap}. * @param exchId Non-null exchange ID if message is created for exchange. * @param lastVer Last version. @@ -1150,18 +1252,43 @@ public GridDhtPartitionsFullMessage createPartitionsFullMessage( @Nullable IgniteDhtPartitionHistorySuppliersMap partHistSuppliers, @Nullable IgniteDhtPartitionsToReloadMap partsToReload ) { - final GridDhtPartitionsFullMessage m = new GridDhtPartitionsFullMessage(exchId, - lastVer, - exchId != null ? exchId.topologyVersion() : AffinityTopologyVersion.NONE, - partHistSuppliers, - partsToReload - ); + Collection grps = cctx.cache().cacheGroups(); + + return createPartitionsFullMessage(compress, newCntrMap, exchId, lastVer, partHistSuppliers, partsToReload, grps); + } + + /** + * Creates partitions full message for selected cache groups. + * + * @param compress {@code True} if possible to compress message (properly work only if prepareMarshall/ + * finishUnmarshall methods are called). + * @param newCntrMap {@code True} if possible to use {@link CachePartitionFullCountersMap}. + * @param exchId Non-null exchange ID if message is created for exchange. + * @param lastVer Last version. + * @param partHistSuppliers Partition history suppliers map. + * @param partsToReload Partitions to reload map. + * @param grps Selected cache groups. + * @return Message. + */ + public GridDhtPartitionsFullMessage createPartitionsFullMessage( + boolean compress, + boolean newCntrMap, + @Nullable final GridDhtPartitionExchangeId exchId, + @Nullable GridCacheVersion lastVer, + @Nullable IgniteDhtPartitionHistorySuppliersMap partHistSuppliers, + @Nullable IgniteDhtPartitionsToReloadMap partsToReload, + Collection grps + ) { + AffinityTopologyVersion ver = exchId != null ? exchId.topologyVersion() : AffinityTopologyVersion.NONE; + + final GridDhtPartitionsFullMessage m = + new GridDhtPartitionsFullMessage(exchId, lastVer, ver, partHistSuppliers, partsToReload); m.compress(compress); final Map> dupData = new HashMap<>(); - for (CacheGroupContext grp : cctx.cache().cacheGroups()) { + for (CacheGroupContext grp : grps) { if (!grp.isLocal()) { if (exchId != null) { AffinityTopologyVersion startTopVer = grp.localStartVersion(); @@ -1174,14 +1301,8 @@ public GridDhtPartitionsFullMessage createPartitionsFullMessage( GridDhtPartitionFullMap locMap = grp.topology().partitionMap(true); - if (locMap != null) { - addFullPartitionsMap(m, - dupData, - compress, - grp.groupId(), - locMap, - affCache.similarAffinityKey()); - } + if (locMap != null) + addFullPartitionsMap(m, dupData, compress, grp.groupId(), locMap, affCache.similarAffinityKey()); m.addPartitionSizes(grp.groupId(), grp.topology().globalPartSizes()); @@ -1202,14 +1323,8 @@ public GridDhtPartitionsFullMessage createPartitionsFullMessage( for (GridClientPartitionTopology top : cctx.exchange().clientTopologies()) { GridDhtPartitionFullMap map = top.partitionMap(true); - if (map != null) { - addFullPartitionsMap(m, - dupData, - compress, - top.groupId(), - map, - top.similarAffinityKey()); - } + if (map != null) + addFullPartitionsMap(m, dupData, compress, top.groupId(), map, top.similarAffinityKey()); if (exchId != null) { CachePartitionFullCountersMap cntrsMap = top.fullUpdateCounters(); @@ -1269,13 +1384,20 @@ private void addFullPartitionsMap(GridDhtPartitionsFullMessage m, /** * @param node Destination cluster node. * @param id Exchange ID. + * @param grps Cache groups for send partitions. */ - private void sendLocalPartitions(ClusterNode node, @Nullable GridDhtPartitionExchangeId id) { - GridDhtPartitionsSingleMessage m = createPartitionsSingleMessage(id, - cctx.kernalContext().clientNode(), - false, - false, - null); + private void sendLocalPartitions( + ClusterNode node, + @Nullable GridDhtPartitionExchangeId id, + @NotNull Collection grps + ) { + GridDhtPartitionsSingleMessage m = + createPartitionsSingleMessage(id, + cctx.kernalContext().clientNode(), + false, + node.version().compareToIgnoreTimestamp(PARTIAL_COUNTERS_MAP_SINCE) >= 0, + null, + grps); if (log.isTraceEnabled()) log.trace("Sending local partitions [nodeId=" + node.id() + ", msg=" + m + ']'); @@ -1294,6 +1416,8 @@ private void sendLocalPartitions(ClusterNode node, @Nullable GridDhtPartitionExc } /** + * Creates partitions single message for all cache groups. + * * @param exchangeId Exchange ID. * @param clientOnlyExchange Client exchange flag. * @param sndCounters {@code True} if need send partition update counters. @@ -1306,6 +1430,29 @@ public GridDhtPartitionsSingleMessage createPartitionsSingleMessage( boolean sndCounters, boolean newCntrMap, ExchangeActions exchActions + ) { + Collection grps = cctx.cache().cacheGroups(); + + return createPartitionsSingleMessage(exchangeId, clientOnlyExchange, sndCounters, newCntrMap, exchActions, grps); + } + + /** + * Creates partitions single message for selected cache groups. + * + * @param exchangeId Exchange ID. + * @param clientOnlyExchange Client exchange flag. + * @param sndCounters {@code True} if need send partition update counters. + * @param newCntrMap {@code True} if possible to use {@link CachePartitionPartialCountersMap}. + * @param grps Selected cache groups. + * @return Message. + */ + public GridDhtPartitionsSingleMessage createPartitionsSingleMessage( + @Nullable GridDhtPartitionExchangeId exchangeId, + boolean clientOnlyExchange, + boolean sndCounters, + boolean newCntrMap, + ExchangeActions exchActions, + Collection grps ) { GridDhtPartitionsSingleMessage m = new GridDhtPartitionsSingleMessage(exchangeId, clientOnlyExchange, @@ -1314,7 +1461,7 @@ public GridDhtPartitionsSingleMessage createPartitionsSingleMessage( Map> dupData = new HashMap<>(); - for (CacheGroupContext grp : cctx.cache().cacheGroups()) { + for (CacheGroupContext grp : grps) { if (!grp.isLocal() && (exchActions == null || !exchActions.cacheGroupStopping(grp.groupId()))) { GridDhtPartitionMap locMap = grp.topology().localPartitionMap(); @@ -1326,7 +1473,7 @@ public GridDhtPartitionsSingleMessage createPartitionsSingleMessage( grp.affinity().similarAffinityKey()); if (sndCounters) { - CachePartitionPartialCountersMap cntrsMap = grp.topology().localUpdateCounters(true, true); + CachePartitionPartialCountersMap cntrsMap = grp.topology().localUpdateCounters(true); m.addPartitionUpdateCounters(grp.groupId(), newCntrMap ? cntrsMap : CachePartitionPartialCountersMap.toCountersMap(cntrsMap)); @@ -1350,7 +1497,7 @@ public GridDhtPartitionsSingleMessage createPartitionsSingleMessage( top.similarAffinityKey()); if (sndCounters) { - CachePartitionPartialCountersMap cntrsMap = top.localUpdateCounters(true, true); + CachePartitionPartialCountersMap cntrsMap = top.localUpdateCounters(true); m.addPartitionUpdateCounters(top.groupId(), newCntrMap ? cntrsMap : CachePartitionPartialCountersMap.toCountersMap(cntrsMap)); @@ -1463,30 +1610,10 @@ public void onExchangeDone(AffinityTopologyVersion topVer, AffinityTopologyVersi if (log.isDebugEnabled()) log.debug("Exchange done [topVer=" + topVer + ", err=" + err + ']'); - if (err == null) { + if (err == null) exchFuts.readyTopVer(topVer); - for (Map.Entry entry : readyFuts.entrySet()) { - if (entry.getKey().compareTo(topVer) <= 0) { - if (log.isDebugEnabled()) - log.debug("Completing created topology ready future " + - "[ver=" + topVer + ", fut=" + entry.getValue() + ']'); - - entry.getValue().onDone(topVer); - } - } - } - else { - for (Map.Entry entry : readyFuts.entrySet()) { - if (entry.getKey().compareTo(initTopVer) <= 0) { - if (log.isDebugEnabled()) - log.debug("Completing created topology ready future with error " + - "[ver=" + entry.getKey() + ", fut=" + entry.getValue() + ']'); - - entry.getValue().onDone(err); - } - } - } + completeAffReadyFuts(err == null ? topVer : initTopVer, err); ExchangeFutureSet exchFuts0 = exchFuts; @@ -1505,6 +1632,28 @@ public void onExchangeDone(AffinityTopologyVersion topVer, AffinityTopologyVersi } } + /** */ + private void completeAffReadyFuts(AffinityTopologyVersion topVer, @Nullable Throwable err) { + for (Map.Entry entry : readyFuts.entrySet()) { + if (entry.getKey().compareTo(topVer) <= 0) { + if (err == null) { + if (log.isDebugEnabled()) + log.debug("Completing created topology ready future " + + "[ver=" + topVer + ", fut=" + entry.getValue() + ']'); + + entry.getValue().onDone(topVer); + } + else { + if (log.isDebugEnabled()) + log.debug("Completing created topology ready future with error " + + "[ver=" + entry.getKey() + ", fut=" + entry.getValue() + ']'); + + entry.getValue().onDone(err); + } + } + } + } + /** * @param fut Future. * @return {@code True} if added. @@ -1741,8 +1890,12 @@ public void dumpDebugInfo(@Nullable GridDhtPartitionsExchangeFuture exchFut) thr dumpPendingObjects(exchTopVer, diagCtx); - for (CacheGroupContext grp : cctx.cache().cacheGroups()) - grp.preloader().dumpDebugInfo(); + for (CacheGroupContext grp : cctx.cache().cacheGroups()) { + GridCachePreloader preloader = grp.preloader(); + + if (preloader != null) + preloader.dumpDebugInfo(); + } cctx.affinity().dumpDebugInfo(); @@ -2139,16 +2292,15 @@ public boolean mergeExchangesOnCoordinator(GridDhtPartitionsExchangeFuture curFu break; } - ClusterNode node = evt.eventNode(); - - if ((evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) && - node.equals(cctx.coordinators().currentCoordinator())) { + if (!fut.changedAffinity()) { if (log.isInfoEnabled()) - log.info("Stop merge, need exchange for mvcc coordinator failure: " + node); + log.info("Stop merge, no-affinity exchange found: " + evt); break; } + ClusterNode node = evt.eventNode(); + if (!curFut.context().supportsMergeExchanges(node)) { if (log.isInfoEnabled()) log.info("Stop merge, node does not support merge: " + node); @@ -2311,6 +2463,38 @@ private boolean exchangeInProgress() { return false; } + /** */ + public boolean affinityChanged(AffinityTopologyVersion from, AffinityTopologyVersion to) { + if (lastAffinityChangedTopologyVersion(to).compareTo(from) >= 0) + return false; + + Collection history = exchFuts.values(); + + boolean fromFound = false; + + for (GridDhtPartitionsExchangeFuture fut : history) { + if (!fromFound) { + int cmp = fut.initialVersion().compareTo(from); + + if (cmp > 0) // We don't have history, so return true for safety + return true; + else if (cmp == 0) + fromFound = true; + else if (fut.isDone() && fut.topologyVersion().compareTo(from) >= 0) + return true; // Temporary solution for merge exchange case + } + else { + if (fut.changedAffinity()) + return true; + + if (fut.initialVersion().compareTo(to) >= 0) + return false; + } + } + + return true; + } + /** * Exchange future thread. All exchanges happen only by one thread and next * exchange will not start until previous one completes. @@ -2432,7 +2616,7 @@ private void removeMergedFutures(AffinityTopologyVersion resVer, GridDhtPartitio GridDhtPartitionsExchangeFuture fut0 = (GridDhtPartitionsExchangeFuture)task; if (resVer.compareTo(fut0.initialVersion()) >= 0) { - fut0.finishMerged(); + fut0.finishMerged(resVer); futQ.remove(fut0); } @@ -2543,7 +2727,8 @@ void dumpExchangeDebugInfo() { err = e; } catch (Throwable e) { - err = e; + if (!(stop && X.hasCause(e, IgniteInterruptedCheckedException.class))) + err = e; } finally { if (err == null && !stop && !reconnectNeeded) @@ -2664,6 +2849,28 @@ else if (task instanceof ForceRebalanceExchangeTask) { crd = newCrd = !srvNodes.isEmpty() && srvNodes.get(0).isLocal(); } + if (!exchFut.changedAffinity()) { + GridDhtPartitionsExchangeFuture lastFut = lastFinishedFut.get(); + + if (lastFut != null) { + if (!lastFut.changedAffinity()) { + // If lastFut corresponds to merged exchange, it is essential to use + // topologyVersion() instead of initialVersion() - nodes joined in this PME + // will have DiscoCache only for the last version. + AffinityTopologyVersion lastAffVer = cctx.exchange() + .lastAffinityChangedTopologyVersion(lastFut.topologyVersion()); + + cctx.exchange().lastAffinityChangedTopologyVersion(exchFut.initialVersion(), + lastAffVer); + } + else + cctx.exchange().lastAffinityChangedTopologyVersion(exchFut.initialVersion(), + lastFut.topologyVersion()); + } + } + + exchFut.timeBag().finishGlobalStage("Waiting in exchange queue"); + exchFut.init(newCrd); int dumpCnt = 0; @@ -2709,8 +2916,8 @@ else if (task instanceof ForceRebalanceExchangeTask) { "topVer=" + exchFut.initialVersion() + ", node=" + cctx.localNodeId() + "]. " + (curTimeout <= 0 && !txRolledBack ? "Consider changing " + - "TransactionConfiguration.txTimeoutOnPartitionMapSynchronization" + - " to non default value to avoid this message. " : "") + + "TransactionConfiguration.txTimeoutOnPartitionMapSynchronization" + + " to non default value to avoid this message. " : "") + "Dumping pending objects that might be the cause: "); try { @@ -2757,7 +2964,7 @@ else if (task instanceof ForceRebalanceExchangeTask) { continue; if (grp.preloader().rebalanceRequired(rebTopVer, exchFut)) - rebTopVer = AffinityTopologyVersion.NONE; + rebTopVer = NONE; changed |= grp.topology().afterExchange(exchFut); } @@ -2768,9 +2975,9 @@ else if (task instanceof ForceRebalanceExchangeTask) { // Schedule rebalance if force rebalance or force reassign occurs. if (exchFut == null) - rebTopVer = AffinityTopologyVersion.NONE; + rebTopVer = NONE; - if (!cctx.kernalContext().clientNode() && rebTopVer.equals(AffinityTopologyVersion.NONE)) { + if (!cctx.kernalContext().clientNode() && rebTopVer.equals(NONE)) { assignsMap = new HashMap<>(); IgniteCacheSnapshotManager snp = cctx.snapshot(); @@ -2801,7 +3008,7 @@ else if (task instanceof ForceRebalanceExchangeTask) { busy = false; } - if (assignsMap != null && rebTopVer.equals(AffinityTopologyVersion.NONE)) { + if (assignsMap != null && rebTopVer.equals(NONE)) { int size = assignsMap.size(); NavigableMap> orderMap = new TreeMap<>(); @@ -2984,7 +3191,7 @@ private static class ExchangeFutureSet extends GridListSet readyTopVer = - new AtomicReference<>(AffinityTopologyVersion.NONE); + new AtomicReference<>(NONE); /** * Creates ordered, not strict list set. @@ -2992,20 +3199,15 @@ private static class ExchangeFutureSet extends GridListSet() { - @Override public int compare( - GridDhtPartitionsExchangeFuture f1, - GridDhtPartitionsExchangeFuture f2 - ) { - AffinityTopologyVersion t1 = f1.exchangeId().topologyVersion(); - AffinityTopologyVersion t2 = f2.exchangeId().topologyVersion(); - - assert t1.topologyVersion() > 0; - assert t2.topologyVersion() > 0; - - // Reverse order. - return t2.compareTo(t1); - } + super((f1, f2) -> { + AffinityTopologyVersion t1 = f1.exchangeId().topologyVersion(); + AffinityTopologyVersion t2 = f2.exchangeId().topologyVersion(); + + assert t1.topologyVersion() > 0; + assert t2.topologyVersion() > 0; + + // Reverse order. + return t2.compareTo(t1); }, /*not strict*/false); this.histSize = histSize; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java index d629e94db7e84..6ac26c958fc29 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java @@ -192,4 +192,14 @@ public GridDhtFuture request(GridCacheContext cctx, * Dumps debug information. */ public void dumpDebugInfo(); + + /** + * Pause preloader. + */ + public void pause(); + + /** + * Resume preloader. + */ + public void resume(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java index c5e4a817d0418..f16305cd85456 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java @@ -181,4 +181,14 @@ public GridCachePreloaderAdapter(CacheGroupContext grp) { @Override public void dumpDebugInfo() { // No-op. } + + /** {@inheritDoc} */ + @Override public void pause() { + // No-op + } + + /** {@inheritDoc} */ + @Override public void resume() { + // No-op + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index ec88a938893c5..fc68875d779cc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -55,6 +55,7 @@ import org.apache.ignite.cache.store.CacheStoreSessionListener; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataPageEvictionMode; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.FileSystemConfiguration; @@ -62,17 +63,18 @@ import org.apache.ignite.configuration.MemoryConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; -import org.apache.ignite.configuration.WALMode; import org.apache.ignite.events.EventType; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException; import org.apache.ignite.internal.IgniteComponentType; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.IgniteNodeAttributes; import org.apache.ignite.internal.IgniteTransactionsEx; import org.apache.ignite.internal.binary.BinaryContext; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.binary.GridBinaryMarshaller; +import org.apache.ignite.internal.managers.communication.GridIoPolicy; import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager; import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; @@ -98,19 +100,21 @@ import org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache; import org.apache.ignite.internal.processors.cache.mvcc.MvccCachingManager; import org.apache.ignite.internal.processors.cache.persistence.DataRegion; +import org.apache.ignite.internal.processors.cache.persistence.DatabaseLifecycleListener; import org.apache.ignite.internal.processors.cache.persistence.DbCheckpointListener; import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.persistence.freelist.FreeList; +import org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage; import org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener; import org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadOnlyMetastorage; -import org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadWriteMetastorage; +import org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId; +import org.apache.ignite.internal.processors.cache.persistence.partstate.PartitionRecoverState; import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteCacheSnapshotManager; import org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotDiscoveryMessage; import org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseList; import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; -import org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager; import org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager; import org.apache.ignite.internal.processors.cache.query.GridCacheLocalQueryManager; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager; @@ -136,15 +140,16 @@ import org.apache.ignite.internal.processors.timeout.GridTimeoutObject; import org.apache.ignite.internal.suggestions.GridPerformanceSuggestions; import org.apache.ignite.internal.util.F0; +import org.apache.ignite.internal.util.InitializationProtector; import org.apache.ignite.internal.util.future.GridCompoundFuture; import org.apache.ignite.internal.util.future.GridFinishedFuture; import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.lang.GridPlainClosure; import org.apache.ignite.internal.util.lang.IgniteOutClosureX; +import org.apache.ignite.internal.util.lang.IgniteThrowableConsumer; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.CIX1; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.internal.util.typedef.internal.CU; @@ -193,12 +198,13 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_TX_CONFIG; import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isNearEnabled; import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isPersistentCache; +import static org.apache.ignite.internal.util.IgniteUtils.doInParallel; /** * Cache processor. */ @SuppressWarnings({"unchecked", "TypeMayBeWeakened", "deprecation"}) -public class GridCacheProcessor extends GridProcessorAdapter implements MetastorageLifecycleListener { +public class GridCacheProcessor extends GridProcessorAdapter { /** Template of message of conflicts during configuration merge*/ private static final String MERGE_OF_CONFIG_CONFLICTS_MESSAGE = "Conflicts during configuration merge for cache '%s' : \n%s"; @@ -211,8 +217,9 @@ public class GridCacheProcessor extends GridProcessorAdapter implements Metastor private final boolean startClientCaches = IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_START_CACHES_ON_JOIN, false); - private final boolean walFsyncWithDedicatedWorker = - IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_WAL_FSYNC_WITH_DEDICATED_WORKER, false); + /** Enables start caches in parallel. */ + private final boolean IGNITE_ALLOW_START_CACHES_IN_PARALLEL = + IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_ALLOW_START_CACHES_IN_PARALLEL, true); /** Shared cache context. */ private GridCacheSharedContext sharedCtx; @@ -266,6 +273,15 @@ public class GridCacheProcessor extends GridProcessorAdapter implements Metastor /** MBean group for cache group metrics */ private final String CACHE_GRP_METRICS_MBEAN_GRP = "Cache groups"; + /** Protector of initialization of specific value. */ + private final InitializationProtector initializationProtector = new InitializationProtector(); + + /** Cache recovery lifecycle state and actions. */ + private final CacheRecoveryLifecycle recovery = new CacheRecoveryLifecycle(); + + /** Tmp storage for meta migration. */ + private MetaStorage.TmpStorage tmpStorage; + /** * @param ctx Kernal context. */ @@ -524,6 +540,19 @@ private void validate(IgniteConfiguration c, assertParameter(cc.getInterceptor() == null, "interceptor cannot be used with TRANSACTIONAL_SNAPSHOT atomicity mode"); + + // Disable in-memory evictions for mvcc cache. TODO IGNITE-10738 + String memPlcName = cc.getDataRegionName(); + DataRegion dataRegion = sharedCtx.database().dataRegion(memPlcName); + + if (dataRegion != null && !dataRegion.config().isPersistenceEnabled() && + dataRegion.config().getPageEvictionMode() != DataPageEvictionMode.DISABLED) { + throw new IgniteCheckedException("Data pages evictions cannot be used with TRANSACTIONAL_SNAPSHOT " + + "cache atomicity mode for in-memory regions. Please, either disable evictions or enable " + + "persistence for data regions with TRANSACTIONAL_SNAPSHOT caches. [cacheName=" + cc.getName() + + ", dataRegionName=" + memPlcName + ", pageEvictionMode=" + + dataRegion.config().getPageEvictionMode() + ']'); + } } if (cc.isWriteBehindEnabled()) { @@ -732,41 +761,34 @@ private void cleanup(CacheConfiguration cfg, @Nullable Object rsrc, boolean near } } - /** {@inheritDoc} */ - @Override public void onReadyForRead(ReadOnlyMetastorage metastorage) throws IgniteCheckedException { - startCachesOnStart(); - } - - /** {@inheritDoc} */ - @Override public void onReadyForReadWrite(ReadWriteMetastorage metastorage) throws IgniteCheckedException { - } - /** * @throws IgniteCheckedException If failed. */ - private void startCachesOnStart() throws IgniteCheckedException { - if (!ctx.isDaemon()) { - Map caches = new HashMap<>(); + private void restoreCacheConfigurations() throws IgniteCheckedException { + if (ctx.isDaemon()) + return; + + Map caches = new HashMap<>(); - Map templates = new HashMap<>(); + Map templates = new HashMap<>(); - addCacheOnJoinFromConfig(caches, templates); + addCacheOnJoinFromConfig(caches, templates); - CacheJoinNodeDiscoveryData discoData = new CacheJoinNodeDiscoveryData( + CacheJoinNodeDiscoveryData discoData = new CacheJoinNodeDiscoveryData( IgniteUuid.randomUuid(), caches, templates, startAllCachesOnClientStart() - ); + ); - cachesInfo.onStart(discoData); - } + cachesInfo.onStart(discoData); } /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Override public void start() throws IgniteCheckedException { - ctx.internalSubscriptionProcessor().registerMetastorageListener(this); + ctx.internalSubscriptionProcessor().registerMetastorageListener(recovery); + ctx.internalSubscriptionProcessor().registerDatabaseListener(recovery); cachesInfo = new ClusterCachesInfo(ctx); @@ -792,7 +814,7 @@ private void startCachesOnStart() throws IgniteCheckedException { mgr.start(sharedCtx); if (!ctx.isDaemon() && (!CU.isPersistenceEnabled(ctx.config())) || ctx.config().isClientMode()) - startCachesOnStart(); + restoreCacheConfigurations(); if (log.isDebugEnabled()) log.debug("Started cache processor."); @@ -1098,8 +1120,8 @@ public void stopCaches(boolean cancel) { * Blocks all available gateways */ public void blockGateways() { - for (IgniteCacheProxy proxy : jCacheProxies.values()) - proxy.context().gate().onStopped(); + for (IgniteCacheProxyImpl proxy : jCacheProxies.values()) + proxy.context0().gate().onStopped(); } /** {@inheritDoc} */ @@ -1284,71 +1306,6 @@ private void stopCacheOnReconnect(GridCacheContext cctx, List return null; } - /** - * @param cache Cache to start. - * @param schema Cache schema. - * @throws IgniteCheckedException If failed to start cache. - */ - @SuppressWarnings({"TypeMayBeWeakened", "unchecked"}) - private void startCache(GridCacheAdapter cache, QuerySchema schema) throws IgniteCheckedException { - GridCacheContext cacheCtx = cache.context(); - - CacheConfiguration cfg = cacheCtx.config(); - - // Intentionally compare Boolean references using '!=' below to check if the flag has been explicitly set. - if (cfg.isStoreKeepBinary() && cfg.isStoreKeepBinary() != CacheConfiguration.DFLT_STORE_KEEP_BINARY - && !(ctx.config().getMarshaller() instanceof BinaryMarshaller)) - U.warn(log, "CacheConfiguration.isStoreKeepBinary() configuration property will be ignored because " + - "BinaryMarshaller is not used"); - - // Start managers. - for (GridCacheManager mgr : F.view(cacheCtx.managers(), F.notContains(dhtExcludes(cacheCtx)))) - mgr.start(cacheCtx); - - cacheCtx.initConflictResolver(); - - if (cfg.getCacheMode() != LOCAL && GridCacheUtils.isNearEnabled(cfg)) { - GridCacheContext dhtCtx = cacheCtx.near().dht().context(); - - // Start DHT managers. - for (GridCacheManager mgr : dhtManagers(dhtCtx)) - mgr.start(dhtCtx); - - dhtCtx.initConflictResolver(); - - // Start DHT cache. - dhtCtx.cache().start(); - - if (log.isDebugEnabled()) - log.debug("Started DHT cache: " + dhtCtx.cache().name()); - } - - ctx.continuous().onCacheStart(cacheCtx); - - cacheCtx.cache().start(); - - ctx.query().onCacheStart(cacheCtx, schema); - - cacheCtx.onStarted(); - - String memPlcName = cfg.getDataRegionName(); - - if (memPlcName == null && ctx.config().getDataStorageConfiguration() != null) - memPlcName = ctx.config().getDataStorageConfiguration().getDefaultDataRegionConfiguration().getName(); - - if (log.isInfoEnabled()) { - log.info("Started cache [name=" + cfg.getName() + - ", id=" + cacheCtx.cacheId() + - (cfg.getGroupName() != null ? ", group=" + cfg.getGroupName() : "") + - ", memoryPolicyName=" + memPlcName + - ", mode=" + cfg.getCacheMode() + - ", atomicity=" + cfg.getAtomicityMode() + - ", backups=" + cfg.getBackups() + - ", mvcc=" + cacheCtx.mvccEnabled() +']' + - ", encryptionEnabled=" + cfg.isEncryptionEnabled() +']'); - } - } - /** * @param cache Cache to stop. * @param cancel Cancel flag. @@ -1516,7 +1473,7 @@ private void onKernalStop(GridCacheAdapter cache, boolean cancel) { cache.onKernalStop(); - if (ctx.events().isRecordable(EventType.EVT_CACHE_STOPPED)) + if (!ctx.isRecoveryMode() && ctx.events().isRecordable(EventType.EVT_CACHE_STOPPED)) ctx.events().addEvent(EventType.EVT_CACHE_STOPPED); } @@ -1534,7 +1491,8 @@ private void onKernalStop(GridCacheAdapter cache, boolean cancel) { * @return Cache context. * @throws IgniteCheckedException If failed to create cache. */ - private GridCacheContext createCache(CacheConfiguration cfg, + private GridCacheContext createCacheContext( + CacheConfiguration cfg, CacheGroupContext grp, @Nullable CachePluginManager pluginMgr, DynamicCacheDescriptor desc, @@ -1542,8 +1500,9 @@ private GridCacheContext createCache(CacheConfiguration cfg, CacheObjectContext cacheObjCtx, boolean affNode, boolean updatesAllowed, - boolean disabledAfterStart) - throws IgniteCheckedException { + boolean disabledAfterStart, + boolean recoveryMode + ) throws IgniteCheckedException { assert cfg != null; if (cfg.getCacheStoreFactory() instanceof GridCacheLoaderWriterStoreFactory) { @@ -1564,7 +1523,7 @@ private GridCacheContext createCache(CacheConfiguration cfg, pluginMgr.validate(); - if (cfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) + if (!recoveryMode && cfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) sharedCtx.coordinators().ensureStarted(); sharedCtx.jta().registerCache(cfg); @@ -1600,7 +1559,13 @@ private GridCacheContext createCache(CacheConfiguration cfg, GridCacheDrManager drMgr = pluginMgr.createComponent(GridCacheDrManager.class); CacheStoreManager storeMgr = pluginMgr.createComponent(CacheStoreManager.class); - storeMgr.initialize(cfgStore, sesHolders); + if (cfgStore == null) + storeMgr.initialize(cfgStore, sesHolders); + else + initializationProtector.protect( + cfgStore, + () -> storeMgr.initialize(cfgStore, sesHolders) + ); GridCacheContext cacheCtx = new GridCacheContext( ctx, @@ -1609,8 +1574,11 @@ private GridCacheContext createCache(CacheConfiguration cfg, grp, desc.cacheType(), locStartTopVer, + desc.deploymentId(), affNode, updatesAllowed, + desc.cacheConfiguration().isStatisticsEnabled(), + recoveryMode, /* * Managers in starting order! * =========================== @@ -1628,8 +1596,6 @@ private GridCacheContext createCache(CacheConfiguration cfg, affMgr ); - cacheCtx.statisticsEnabled(desc.cacheConfiguration().isStatisticsEnabled()); - cacheCtx.cacheObjectContext(cacheObjCtx); GridCacheAdapter cache = null; @@ -1744,8 +1710,11 @@ private GridCacheContext createCache(CacheConfiguration cfg, grp, desc.cacheType(), locStartTopVer, + desc.deploymentId(), affNode, true, + desc.cacheConfiguration().isStatisticsEnabled(), + recoveryMode, /* * Managers in starting order! * =========================== @@ -1763,8 +1732,6 @@ private GridCacheContext createCache(CacheConfiguration cfg, affMgr ); - cacheCtx.statisticsEnabled(desc.cacheConfiguration().isStatisticsEnabled()); - cacheCtx.cacheObjectContext(cacheObjCtx); GridDhtCacheAdapter dht = null; @@ -1877,7 +1844,7 @@ public void completeProxyRestart( proxy.onRestarted(cacheCtx, cache); if (cacheCtx.dataStructuresCache()) - ctx.dataStructures().restart(proxy.internalProxy()); + ctx.dataStructures().restart(cache.name(), proxy.internalProxy()); } } } @@ -2017,18 +1984,13 @@ public IgniteInternalFuture startCachesOnLocalJoin( IgniteInternalFuture res = sharedCtx.affinity().initCachesOnLocalJoin( locJoinCtx.cacheGroupDescriptors(), locJoinCtx.cacheDescriptors()); - for (T2 t : locJoinCtx.caches()) { - DynamicCacheDescriptor desc = t.get1(); + List startCacheInfos = locJoinCtx.caches().stream() + .map(cacheInfo -> new StartCacheInfo(cacheInfo.get1(), cacheInfo.get2(), exchTopVer, false)) + .collect(Collectors.toList()); - prepareCacheStart( - desc.cacheConfiguration(), - desc, - t.get2(), - exchTopVer, - false); + prepareStartCaches(startCacheInfos); - context().exchange().exchangerUpdateHeartbeat(); - } + context().exchange().exchangerUpdateHeartbeat(); if (log.isInfoEnabled()) log.info("Starting caches on local join performed in " + (System.currentTimeMillis() - time) + " ms."); @@ -2036,137 +1998,610 @@ public IgniteInternalFuture startCachesOnLocalJoin( return res; } - /** - * @param node Joined node. - * @return {@code True} if there are new caches received from joined node. - */ - boolean hasCachesReceivedFromJoin(ClusterNode node) { - return cachesInfo.hasCachesReceivedFromJoin(node.id()); + /** + * @param node Joined node. + * @return {@code True} if there are new caches received from joined node. + */ + boolean hasCachesReceivedFromJoin(ClusterNode node) { + return cachesInfo.hasCachesReceivedFromJoin(node.id()); + } + + /** + * Starts statically configured caches received from remote nodes during exchange. + * + * @param nodeId Joining node ID. + * @param exchTopVer Current exchange version. + * @return Started caches descriptors. + * @throws IgniteCheckedException If failed. + */ + public Collection startReceivedCaches(UUID nodeId, AffinityTopologyVersion exchTopVer) + throws IgniteCheckedException { + List receivedCaches = cachesInfo.cachesReceivedFromJoin(nodeId); + + List startCacheInfos = receivedCaches.stream() + .filter(desc -> isLocalAffinity(desc.groupDescriptor().config())) + .map(desc -> new StartCacheInfo(desc, null, exchTopVer, false)) + .collect(Collectors.toList()); + + prepareStartCaches(startCacheInfos); + + return receivedCaches; + } + + /** + * @param cacheConfiguration Checked configuration. + * @return {@code true} if local node is affinity node for cache. + */ + private boolean isLocalAffinity(CacheConfiguration cacheConfiguration) { + return CU.affinityNode(ctx.discovery().localNode(), cacheConfiguration.getNodeFilter()); + } + + /** + * Start all input caches in parallel. + * + * @param startCacheInfos All caches information for start. + */ + void prepareStartCaches(Collection startCacheInfos) throws IgniteCheckedException { + prepareStartCaches(startCacheInfos, (data, operation) -> { + operation.accept(data);// PROXY + }); + } + + /** + * Trying to start all input caches in parallel and skip failed caches. + * + * @param startCacheInfos Caches info for start. + * @return Caches which was failed. + * @throws IgniteCheckedException if failed. + */ + Map prepareStartCachesIfPossible(Collection startCacheInfos) throws IgniteCheckedException { + HashMap failedCaches = new HashMap<>(); + + prepareStartCaches(startCacheInfos, (data, operation) -> { + try { + operation.accept(data); + } + catch (IgniteInterruptedCheckedException e) { + throw e; + } + catch (IgniteCheckedException e) { + log.warning("Cache can not be started : cache=" + data.getStartedConfiguration().getName()); + + failedCaches.put(data, e); + } + }); + + return failedCaches; + } + + /** + * Start all input caches in parallel. + * + * @param startCacheInfos All caches information for start. + * @param cacheStartFailHandler Fail handler for one cache start. + */ + private void prepareStartCaches( + Collection startCacheInfos, + StartCacheFailHandler cacheStartFailHandler + ) throws IgniteCheckedException { + if (!IGNITE_ALLOW_START_CACHES_IN_PARALLEL || startCacheInfos.size() <= 1) { + for (StartCacheInfo startCacheInfo : startCacheInfos) { + cacheStartFailHandler.handle( + startCacheInfo, + cacheInfo -> { + prepareCacheStart( + cacheInfo.getCacheDescriptor().cacheConfiguration(), + cacheInfo.getCacheDescriptor(), + cacheInfo.getReqNearCfg(), + cacheInfo.getExchangeTopVer(), + cacheInfo.isDisabledAfterStart() + ); + + return null; + } + ); + + context().exchange().exchangerUpdateHeartbeat(); + } + } + else { + Map cacheContexts = new ConcurrentHashMap<>(); + + // Reserve at least 2 threads for system operations. + int parallelismLvl = U.availableThreadCount(ctx, GridIoPolicy.SYSTEM_POOL, 2); + + doInParallel( + parallelismLvl, + sharedCtx.kernalContext().getSystemExecutorService(), + startCacheInfos, + startCacheInfo -> { + cacheStartFailHandler.handle( + startCacheInfo, + cacheInfo -> { + GridCacheContext cacheCtx = prepareCacheContext( + cacheInfo.getCacheDescriptor().cacheConfiguration(), + cacheInfo.getCacheDescriptor(), + cacheInfo.getReqNearCfg(), + cacheInfo.getExchangeTopVer(), + cacheInfo.isDisabledAfterStart() + ); + cacheContexts.put(cacheInfo, cacheCtx); + + context().exchange().exchangerUpdateHeartbeat(); + + return null; + } + ); + + return null; + } + ); + + /* + * This hack required because we can't start sql schema in parallel by folowing reasons: + * * checking index to duplicate(and other checking) require one order on every nodes. + * * onCacheStart and createSchema contains a lot of mutex. + * + * TODO IGNITE-9729 + */ + Set successfullyPreparedCaches = cacheContexts.keySet(); + + List cacheInfosInOriginalOrder = startCacheInfos.stream() + .filter(successfullyPreparedCaches::contains) + .collect(Collectors.toList()); + + for (StartCacheInfo startCacheInfo : cacheInfosInOriginalOrder) { + cacheStartFailHandler.handle( + startCacheInfo, + cacheInfo -> { + GridCacheContext cctx = cacheContexts.get(cacheInfo); + + if (!cctx.isRecoveryMode()) { + ctx.query().onCacheStart( + cctx, + cacheInfo.getCacheDescriptor().schema() != null + ? cacheInfo.getCacheDescriptor().schema() + : new QuerySchema() + ); + } + + context().exchange().exchangerUpdateHeartbeat(); + + return null; + } + ); + } + + doInParallel( + parallelismLvl, + sharedCtx.kernalContext().getSystemExecutorService(), + cacheContexts.entrySet(), + cacheCtxEntry -> { + cacheStartFailHandler.handle( + cacheCtxEntry.getKey(), + cacheInfo -> { + GridCacheContext cacheContext = cacheCtxEntry.getValue(); + + if (cacheContext.isRecoveryMode()) + finishRecovery(cacheInfo.getExchangeTopVer(), cacheContext); + else + onCacheStarted(cacheCtxEntry.getValue()); + + context().exchange().exchangerUpdateHeartbeat(); + + return null; + } + ); + + return null; + } + ); + } + } + + /** + * @param startCfg Cache configuration to use. + * @param desc Cache descriptor. + * @param reqNearCfg Near configuration if specified for client cache start request. + * @param exchTopVer Current exchange version. + * @param disabledAfterStart If true, then we will discard restarting state from proxies. If false then we will + * change state of proxies to restarting + * @throws IgniteCheckedException If failed. + */ + public void prepareCacheStart( + CacheConfiguration startCfg, + DynamicCacheDescriptor desc, + @Nullable NearCacheConfiguration reqNearCfg, + AffinityTopologyVersion exchTopVer, + boolean disabledAfterStart + ) throws IgniteCheckedException { + GridCacheContext cacheCtx = prepareCacheContext(startCfg, desc, reqNearCfg, exchTopVer, disabledAfterStart); + + if (cacheCtx.isRecoveryMode()) + finishRecovery(exchTopVer, cacheCtx); + else { + ctx.query().onCacheStart(cacheCtx, desc.schema() != null ? desc.schema() : new QuerySchema()); + + onCacheStarted(cacheCtx); + } + } + + /** + * Preparing cache context to start. + * + * @param startCfg Cache configuration to use. + * @param desc Cache descriptor. + * @param reqNearCfg Near configuration if specified for client cache start request. + * @param exchTopVer Current exchange version. + * @param disabledAfterStart If true, then we will discard restarting state from proxies. If false then we will change + * state of proxies to restarting + * @return Created {@link GridCacheContext}. + * @throws IgniteCheckedException if failed. + */ + private GridCacheContext prepareCacheContext( + CacheConfiguration startCfg, + DynamicCacheDescriptor desc, + @Nullable NearCacheConfiguration reqNearCfg, + AffinityTopologyVersion exchTopVer, + boolean disabledAfterStart + ) throws IgniteCheckedException { + if (caches.containsKey(startCfg.getName())) { + GridCacheAdapter existingCache = caches.get(startCfg.getName()); + + GridCacheContext cctx = existingCache.context(); + + assert cctx.isRecoveryMode(); + + QuerySchema localSchema = recovery.querySchemas.get(desc.cacheId()); + + QuerySchemaPatch localSchemaPatch = localSchema.makePatch(desc.schema().entities()); + + // Cache schema is changed after restart, workaround is stop existing cache and start new. + if (!localSchemaPatch.isEmpty() || localSchemaPatch.hasConflicts()) + stopCacheSafely(cctx); + else + return existingCache.context(); + } + + assert !caches.containsKey(startCfg.getName()) : startCfg.getName(); + + CacheConfiguration ccfg = new CacheConfiguration(startCfg); + + CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(ccfg); + + boolean affNode = checkForAffinityNode(desc, reqNearCfg, ccfg); + + CacheGroupContext grp = getOrCreateCacheGroupContext(desc, exchTopVer, cacheObjCtx, affNode, startCfg.getGroupName(), false); + + GridCacheContext cacheCtx = createCacheContext(ccfg, + grp, + null, + desc, + exchTopVer, + cacheObjCtx, + affNode, + true, + disabledAfterStart, + false + ); + + initCacheContext(cacheCtx, ccfg); + + return cacheCtx; + } + + /** + * Stops cache under checkpoint lock. + * @param cctx Cache context. + */ + private void stopCacheSafely(GridCacheContext cctx) { + sharedCtx.database().checkpointReadLock(); + + try { + prepareCacheStop(cctx.name(), false); + + if (!cctx.group().hasCaches()) + stopCacheGroup(cctx.group().groupId()); + } + finally { + sharedCtx.database().checkpointReadUnlock(); + } + + } + + /** + * Finishes recovery for given cache context. + * + * @param cacheStartVer Cache join to topology version. + * @param cacheContext Cache context. + * @throws IgniteCheckedException If failed. + */ + private void finishRecovery( + AffinityTopologyVersion cacheStartVer, GridCacheContext cacheContext + ) throws IgniteCheckedException { + CacheGroupContext groupContext = cacheContext.group(); + + // Take cluster-wide cache descriptor and try to update local cache and cache group parameters. + DynamicCacheDescriptor updatedDescriptor = cacheDescriptor(cacheContext.cacheId()); + + groupContext.finishRecovery( + cacheStartVer, + updatedDescriptor.receivedFrom(), + isLocalAffinity(updatedDescriptor.cacheConfiguration()) + ); + + cacheContext.finishRecovery(cacheStartVer, updatedDescriptor); + + if (cacheContext.config().getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) + sharedCtx.coordinators().ensureStarted(); + + onKernalStart(cacheContext.cache()); + + if (log.isInfoEnabled()) + log.info("Finished recovery for cache [cache=" + cacheContext.name() + + ", grp=" + groupContext.cacheOrGroupName() + ", startVer=" + cacheStartVer + "]"); + } + + /** + * Stops all caches and groups, that was recovered, but not activated on node join. + * Such caches can remain only if it was filtered by node filter on current node. + * It's impossible to check whether current node is affinity node for given cache before join to topology. + */ + public void shutdownNotFinishedRecoveryCaches() { + for (GridCacheAdapter cacheAdapter : caches.values()) { + GridCacheContext cacheContext = cacheAdapter.context(); + + if (cacheContext.isLocal()) + continue; + + if (cacheContext.isRecoveryMode()) { + assert !isLocalAffinity(cacheContext.config()) + : "Cache " + cacheAdapter.context() + " is still in recovery mode after start, but not activated."; + + stopCacheSafely(cacheContext); + } + } + } + + /** + * Check for affinity node and customize near configuration if needed. + * + * @param desc Cache descriptor. + * @param reqNearCfg Near configuration if specified for client cache start request. + * @param ccfg Cache configuration to use. + * @return {@code true} if it is affinity node for cache. + */ + private boolean checkForAffinityNode( + DynamicCacheDescriptor desc, + @Nullable NearCacheConfiguration reqNearCfg, + CacheConfiguration ccfg + ) { + if (ccfg.getCacheMode() == LOCAL) { + ccfg.setNearConfiguration(null); + + return true; + } + + if (isLocalAffinity(desc.groupDescriptor().config())) + return true; + + ccfg.setNearConfiguration(reqNearCfg); + + return false; + } + + /** + * Prepare page store for start cache. + * + * @param desc Cache descriptor. + * @param affNode {@code true} if it is affinity node for cache. + * @throws IgniteCheckedException if failed. + */ + public void preparePageStore(DynamicCacheDescriptor desc, boolean affNode) throws IgniteCheckedException { + if (sharedCtx.pageStore() != null && affNode) + initializationProtector.protect( + desc.groupDescriptor().groupId(), + () -> sharedCtx.pageStore().initializeForCache(desc.groupDescriptor(), desc.toStoredData()) + ); + } + + /** + * Prepare cache group to start cache. + * + * @param desc Cache descriptor. + * @param exchTopVer Current exchange version. + * @param cacheObjCtx Cache object context. + * @param affNode {@code true} if it is affinity node for cache. + * @param grpName Group name. + * @return Prepared cache group context. + * @throws IgniteCheckedException if failed. + */ + private CacheGroupContext getOrCreateCacheGroupContext( + DynamicCacheDescriptor desc, + AffinityTopologyVersion exchTopVer, + CacheObjectContext cacheObjCtx, + boolean affNode, + String grpName, + boolean recoveryMode + ) throws IgniteCheckedException { + if (grpName != null) { + return initializationProtector.protect( + desc.groupId(), + () -> findCacheGroup(grpName), + () -> startCacheGroup( + desc.groupDescriptor(), + desc.cacheType(), + affNode, + cacheObjCtx, + exchTopVer, + recoveryMode + ) + ); + } + + return startCacheGroup(desc.groupDescriptor(), + desc.cacheType(), + affNode, + cacheObjCtx, + exchTopVer, + recoveryMode + ); + } + + /** + * Initialize created cache context. + * + * @param cacheCtx Cache context to initializtion. + * @param cfg Cache configuration. + * @throws IgniteCheckedException if failed. + */ + private void initCacheContext( + GridCacheContext cacheCtx, + CacheConfiguration cfg + ) throws IgniteCheckedException { + GridCacheAdapter cache = cacheCtx.cache(); + + sharedCtx.addCacheContext(cacheCtx); + + caches.put(cacheCtx.name(), cache); + + // Intentionally compare Boolean references using '!=' below to check if the flag has been explicitly set. + if (cfg.isStoreKeepBinary() && cfg.isStoreKeepBinary() != CacheConfiguration.DFLT_STORE_KEEP_BINARY + && !(ctx.config().getMarshaller() instanceof BinaryMarshaller)) + U.warn(log, "CacheConfiguration.isStoreKeepBinary() configuration property will be ignored because " + + "BinaryMarshaller is not used"); + + // Start managers. + for (GridCacheManager mgr : F.view(cacheCtx.managers(), F.notContains(dhtExcludes(cacheCtx)))) + mgr.start(cacheCtx); + + cacheCtx.initConflictResolver(); + + if (cfg.getCacheMode() != LOCAL && GridCacheUtils.isNearEnabled(cfg)) { + GridCacheContext dhtCtx = cacheCtx.near().dht().context(); + + // Start DHT managers. + for (GridCacheManager mgr : dhtManagers(dhtCtx)) + mgr.start(dhtCtx); + + dhtCtx.initConflictResolver(); + + // Start DHT cache. + dhtCtx.cache().start(); + + if (log.isDebugEnabled()) + log.debug("Started DHT cache: " + dhtCtx.cache().name()); + } + + ctx.continuous().onCacheStart(cacheCtx); + + cacheCtx.cache().start(); } /** - * Starts statically configured caches received from remote nodes during exchange. + * Handle of cache context which was fully prepared. * - * @param nodeId Joining node ID. - * @param exchTopVer Current exchange version. - * @return Started caches descriptors. - * @throws IgniteCheckedException If failed. + * @param cacheCtx Fully prepared context. + * @throws IgniteCheckedException if failed. */ - public Collection startReceivedCaches(UUID nodeId, AffinityTopologyVersion exchTopVer) - throws IgniteCheckedException { - List started = cachesInfo.cachesReceivedFromJoin(nodeId); + private void onCacheStarted(GridCacheContext cacheCtx) throws IgniteCheckedException { + GridCacheAdapter cache = cacheCtx.cache(); + CacheConfiguration cfg = cacheCtx.config(); + CacheGroupContext grp = cacheGrps.get(cacheCtx.groupId()); - for (DynamicCacheDescriptor desc : started) { - IgnitePredicate filter = desc.groupDescriptor().config().getNodeFilter(); + cacheCtx.onStarted(); - if (CU.affinityNode(ctx.discovery().localNode(), filter)) { - prepareCacheStart( - desc.cacheConfiguration(), - desc, - null, - exchTopVer, - false); + String dataRegion = cfg.getDataRegionName(); - context().exchange().exchangerUpdateHeartbeat(); - } + if (dataRegion == null && ctx.config().getDataStorageConfiguration() != null) + dataRegion = ctx.config().getDataStorageConfiguration().getDefaultDataRegionConfiguration().getName(); + + if (log.isInfoEnabled()) { + log.info("Started cache [name=" + cfg.getName() + + ", id=" + cacheCtx.cacheId() + + (cfg.getGroupName() != null ? ", group=" + cfg.getGroupName() : "") + + ", dataRegionName=" + dataRegion + + ", mode=" + cfg.getCacheMode() + + ", atomicity=" + cfg.getAtomicityMode() + + ", backups=" + cfg.getBackups() + + ", mvcc=" + cacheCtx.mvccEnabled() + ']'); } - return started; + grp.onCacheStarted(cacheCtx); + + onKernalStart(cache); } /** - * @param startCfg Cache configuration to use. * @param desc Cache descriptor. - * @param reqNearCfg Near configuration if specified for client cache start request. - * @param exchTopVer Current exchange version. - * @param disabledAfterStart If true, then we will discard restarting state from proxies. If false then we will - * change state of proxies to restarting * @throws IgniteCheckedException If failed. */ - void prepareCacheStart( - CacheConfiguration startCfg, - DynamicCacheDescriptor desc, - @Nullable NearCacheConfiguration reqNearCfg, - AffinityTopologyVersion exchTopVer, - boolean disabledAfterStart + private GridCacheContext startCacheInRecoveryMode( + DynamicCacheDescriptor desc ) throws IgniteCheckedException { - assert !caches.containsKey(startCfg.getName()) : startCfg.getName(); - - CacheConfiguration ccfg = new CacheConfiguration(startCfg); - - CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(ccfg); - - boolean affNode; - - if (ccfg.getCacheMode() == LOCAL) { - affNode = true; - - ccfg.setNearConfiguration(null); - } - else if (CU.affinityNode(ctx.discovery().localNode(), desc.groupDescriptor().config().getNodeFilter())) - affNode = true; - else { - affNode = false; + CacheConfiguration cfg = desc.cacheConfiguration(); - ccfg.setNearConfiguration(reqNearCfg); - } - - if (sharedCtx.pageStore() != null && affNode) - sharedCtx.pageStore().initializeForCache(desc.groupDescriptor(), desc.toStoredData()); - - String grpName = startCfg.getGroupName(); - - CacheGroupContext grp = null; - - if (grpName != null) { - for (CacheGroupContext grp0 : cacheGrps.values()) { - if (grp0.sharedGroup() && grpName.equals(grp0.name())) { - grp = grp0; + CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(cfg); - break; - } - } + preparePageStore(desc, true); - if (grp == null) { - grp = startCacheGroup(desc.groupDescriptor(), - desc.cacheType(), - affNode, - cacheObjCtx, - exchTopVer); - } - } - else { - grp = startCacheGroup(desc.groupDescriptor(), - desc.cacheType(), - affNode, - cacheObjCtx, - exchTopVer); - } + CacheGroupContext grp = getOrCreateCacheGroupContext( + desc, + AffinityTopologyVersion.NONE, + cacheObjCtx, + true, + cfg.getGroupName(), + true + ); - GridCacheContext cacheCtx = createCache(ccfg, + GridCacheContext cacheCtx = createCacheContext(cfg, grp, null, desc, - exchTopVer, + AffinityTopologyVersion.NONE, cacheObjCtx, - affNode, true, - disabledAfterStart + true, + false, + true ); - cacheCtx.dynamicDeploymentId(desc.deploymentId()); + initCacheContext(cacheCtx, cfg); - GridCacheAdapter cache = cacheCtx.cache(); - - sharedCtx.addCacheContext(cacheCtx); + cacheCtx.onStarted(); - caches.put(cacheCtx.name(), cache); + String dataRegion = cfg.getDataRegionName(); - startCache(cache, desc.schema() != null ? desc.schema() : new QuerySchema()); + if (dataRegion == null && ctx.config().getDataStorageConfiguration() != null) + dataRegion = ctx.config().getDataStorageConfiguration().getDefaultDataRegionConfiguration().getName(); grp.onCacheStarted(cacheCtx); - onKernalStart(cache); + ctx.query().onCacheStart(cacheCtx, desc.schema() != null ? desc.schema() : new QuerySchema()); + + if (log.isInfoEnabled()) { + log.info("Started cache in recovery mode [name=" + cfg.getName() + + ", id=" + cacheCtx.cacheId() + + (cfg.getGroupName() != null ? ", group=" + cfg.getGroupName() : "") + + ", dataRegionName=" + dataRegion + + ", mode=" + cfg.getCacheMode() + + ", atomicity=" + cfg.getAtomicityMode() + + ", backups=" + cfg.getBackups() + + ", mvcc=" + cacheCtx.mvccEnabled() + ']'); + } + + return cacheCtx; + } + + /** + * @param grpName Group name. + * @return Found group or null. + */ + private CacheGroupContext findCacheGroup(String grpName) { + return cacheGrps.values().stream() + .filter(grp -> grp.sharedGroup() && grpName.equals(grp.name())) + .findAny() + .orElse(null); } /** @@ -2189,9 +2624,41 @@ public void restartProxies() { proxy.onRestarted(cacheCtx, cacheCtx.cache()); if (cacheCtx.dataStructuresCache()) - ctx.dataStructures().restart(proxy.internalProxy()); + ctx.dataStructures().restart(proxy.getName(), proxy.internalProxy()); + } + } + } + + /** + * Complete stopping of caches if they were marked as restarting but it failed. + * @return Cache names of proxies which were restarted. + */ + public List resetRestartingProxies() { + List res = new ArrayList<>(); + + for (Map.Entry> e : jCacheProxies.entrySet()) { + IgniteCacheProxyImpl proxy = e.getValue(); + + if (proxy == null) + continue; + + if (proxy.isRestarting()) { + String cacheName = e.getKey(); + + res.add(cacheName); + + jCacheProxies.remove(cacheName); + + proxy.onRestarted(null, null); + + if (DataStructuresProcessor.isDataStructureCache(cacheName)) + ctx.dataStructures().restart(cacheName, null); } } + + cachesInfo.removeRestartingCaches(); + + return res; } /** @@ -2208,8 +2675,9 @@ private CacheGroupContext startCacheGroup( CacheType cacheType, boolean affNode, CacheObjectContext cacheObjCtx, - AffinityTopologyVersion exchTopVer) - throws IgniteCheckedException { + AffinityTopologyVersion exchTopVer, + boolean recoveryMode + ) throws IgniteCheckedException { CacheConfiguration cfg = new CacheConfiguration(desc.config()); String memPlcName = cfg.getDataRegionName(); @@ -2218,7 +2686,7 @@ private CacheGroupContext startCacheGroup( FreeList freeList = sharedCtx.database().freeList(memPlcName); ReuseList reuseList = sharedCtx.database().reuseList(memPlcName); - boolean persistenceEnabled = sharedCtx.localNode().isClient() ? desc.persistenceEnabled() : + boolean persistenceEnabled = recoveryMode || sharedCtx.localNode().isClient() ? desc.persistenceEnabled() : dataRegion != null && dataRegion.config().isPersistenceEnabled(); CacheGroupContext grp = new CacheGroupContext(sharedCtx, @@ -2233,7 +2701,8 @@ private CacheGroupContext startCacheGroup( reuseList, exchTopVer, persistenceEnabled, - desc.walEnabled() + desc.walEnabled(), + recoveryMode ); for (Object obj : grp.configuredUserObjects()) @@ -2276,16 +2745,28 @@ void blockGateway(String cacheName, boolean stop, boolean restart) { cache.active(false); } - if (proxy != null) { - if (stop) { - if (restart) - proxy.restart(); + if (stop) { + if (restart) { + GridCacheAdapter cache; - proxy.context().gate().stopped(); + if (proxy == null && (cache = caches.get(cacheName)) != null) { + proxy = new IgniteCacheProxyImpl(cache.context(), cache, false); + + IgniteCacheProxyImpl oldProxy = jCacheProxies.putIfAbsent(cacheName, proxy); + + if (oldProxy != null) + proxy = oldProxy; + } + + if (proxy != null) + proxy.suspend(); } - else - proxy.closeProxy(); + + if (proxy != null) + proxy.context0().gate().stopped(); } + else if (proxy != null) + proxy.closeProxy(); } /** @@ -2309,7 +2790,7 @@ private void stopGateway(DynamicCacheChangeRequest req) { proxy = jCacheProxies.get(req.cacheName()); if (proxy != null) - proxy.restart(); + proxy.suspend(); } else { completeProxyInitialize(req.cacheName()); @@ -2318,7 +2799,7 @@ private void stopGateway(DynamicCacheChangeRequest req) { } if (proxy != null) - proxy.context().gate().onStopped(); + proxy.context0().gate().onStopped(); } /** @@ -2326,7 +2807,7 @@ private void stopGateway(DynamicCacheChangeRequest req) { * @param destroy Cache data destroy flag. Setting to true will remove all cache data. * @return Stopped cache context. */ - private GridCacheContext prepareCacheStop(String cacheName, boolean destroy) { + public GridCacheContext prepareCacheStop(String cacheName, boolean destroy) { assert sharedCtx.database().checkpointLockIsHeldByThread(); GridCacheAdapter cache = caches.remove(cacheName); @@ -2359,7 +2840,7 @@ void initCacheProxies(AffinityTopologyVersion startTopVer, @Nullable Throwable e IgniteCacheProxyImpl newProxy = new IgniteCacheProxyImpl(cache.context(), cache, false); if (!cache.active()) - newProxy.restart(); + newProxy.suspend(); addjCacheProxy(cacheCtx.name(), newProxy); } @@ -2428,17 +2909,7 @@ private void closeCache(GridCacheContext cctx) { jCacheProxies.remove(cctx.name()); - sharedCtx.database().checkpointReadLock(); - - try { - prepareCacheStop(cctx.name(), false); - } - finally { - sharedCtx.database().checkpointReadUnlock(); - } - - if (!cctx.group().hasCaches()) - stopCacheGroup(cctx.group().groupId()); + stopCacheSafely(cctx); } finally { sharedCtx.io().writeUnlock(); @@ -2462,7 +2933,9 @@ void forceCloseCaches(ExchangeActions exchActions) { * @param exchActions Change requests. */ private void processCacheStopRequestOnExchangeDone(ExchangeActions exchActions) { - // Force checkpoint if there is any cache stop request + // Reserve at least 2 threads for system operations. + int parallelismLvl = U.availableThreadCount(ctx, GridIoPolicy.SYSTEM_POOL, 2); + if (!exchActions.cacheStopRequests().isEmpty()) { try { sharedCtx.database().waitForCheckpoint("caches stop"); @@ -2472,63 +2945,88 @@ private void processCacheStopRequestOnExchangeDone(ExchangeActions exchActions) } } - for (ExchangeActions.CacheActionData action : exchActions.cacheStopRequests()) { - CacheGroupContext gctx = cacheGrps.get(action.descriptor().groupId()); + List> grpToStop = exchActions.cacheGroupsToStop().stream() + .filter(a -> cacheGrps.containsKey(a.descriptor().groupId())) + .map(a -> F.t(cacheGrps.get(a.descriptor().groupId()), a.destroy())) + .collect(Collectors.toList()); - // Cancel all operations blocking gateway - if (gctx != null) { - final String msg = "Failed to wait for topology update, cache group is stopping."; + Map> cachesToStop = exchActions.cacheStopRequests().stream() + .collect(Collectors.groupingBy(action -> action.descriptor().groupId())); - // If snapshot operation in progress we must throw CacheStoppedException - // for correct cache proxy restart. For more details see - // IgniteCacheProxy.cacheException() - gctx.affinity().cancelFutures(new CacheStoppedException(msg)); - } + try { + doInParallel( + parallelismLvl, + sharedCtx.kernalContext().getSystemExecutorService(), + cachesToStop.entrySet(), + cachesToStopByGrp -> { + CacheGroupContext gctx = cacheGrps.get(cachesToStopByGrp.getKey()); + + if (gctx != null) + gctx.preloader().pause(); - stopGateway(action.request()); + try { - sharedCtx.database().checkpointReadLock(); + if (gctx != null) { + final String msg = "Failed to wait for topology update, cache group is stopping."; - try { - prepareCacheStop(action.request().cacheName(), action.request().destroy()); - } - finally { - sharedCtx.database().checkpointReadUnlock(); - } + // If snapshot operation in progress we must throw CacheStoppedException + // for correct cache proxy restart. For more details see + // IgniteCacheProxy.cacheException() + gctx.affinity().cancelFutures(new CacheStoppedException(msg)); + } + + for (ExchangeActions.CacheActionData action: cachesToStopByGrp.getValue()) { + stopGateway(action.request()); + + sharedCtx.database().checkpointReadLock(); + + try { + prepareCacheStop(action.request().cacheName(), action.request().destroy()); + } + finally { + sharedCtx.database().checkpointReadUnlock(); + } + } + } + finally { + if (gctx != null) + gctx.preloader().resume(); + } + + return null; + } + ); + } + catch (IgniteCheckedException e) { + String msg = "Failed to stop caches"; + + log.error(msg, e); + + throw new IgniteException(msg, e); } sharedCtx.database().checkpointReadLock(); try { // Do not invoke checkpoint listeners for groups are going to be destroyed to prevent metadata corruption. - for (ExchangeActions.CacheGroupActionData action : exchActions.cacheGroupsToStop()) { - Integer groupId = action.descriptor().groupId(); - CacheGroupContext grp = cacheGrps.get(groupId); + grpToStop.forEach(grp -> { + CacheGroupContext gctx = grp.getKey(); - if (grp != null && grp.persistenceEnabled() && sharedCtx.database() instanceof GridCacheDatabaseSharedManager) { + if (gctx != null && gctx.persistenceEnabled() && sharedCtx.database() instanceof GridCacheDatabaseSharedManager) { GridCacheDatabaseSharedManager mngr = (GridCacheDatabaseSharedManager)sharedCtx.database(); - mngr.removeCheckpointListener((DbCheckpointListener)grp.offheap()); + mngr.removeCheckpointListener((DbCheckpointListener)gctx.offheap()); } - } + }); } finally { sharedCtx.database().checkpointReadUnlock(); } - List> stoppedGroups = new ArrayList<>(); - - for (ExchangeActions.CacheGroupActionData action : exchActions.cacheGroupsToStop()) { - Integer groupId = action.descriptor().groupId(); - - if (cacheGrps.containsKey(groupId)) { - stoppedGroups.add(F.t(cacheGrps.get(groupId), action.destroy())); - - stopCacheGroup(groupId); - } - } + for (IgniteBiTuple grp : grpToStop) + stopCacheGroup(grp.get1().groupId()); if (!sharedCtx.kernalContext().clientNode()) - sharedCtx.database().onCacheGroupsStopped(stoppedGroups); + sharedCtx.database().onCacheGroupsStopped(grpToStop); if (exchActions.deactivate()) sharedCtx.deactivate(); @@ -2651,13 +3149,8 @@ private GridCacheSharedContext createSharedContext(GridKernalContext kernalCtx, walMgr = ctx.plugins().createComponent(IgniteWriteAheadLogManager.class); - if (walMgr == null) { - if (ctx.config().getDataStorageConfiguration().getWalMode() == WALMode.FSYNC && - !walFsyncWithDedicatedWorker) - walMgr = new FsyncModeFileWriteAheadLogManager(ctx); - else - walMgr = new FileWriteAheadLogManager(ctx); - } + if (walMgr == null) + walMgr = new FileWriteAheadLogManager(ctx); } else { if (CU.isPersistenceEnabled(ctx.config()) && ctx.clientNode()) { @@ -3141,7 +3634,6 @@ private CacheConfiguration getOrCreateConfigFromTemplate(String cacheName) throw * @param checkThreadTx If {@code true} checks that current thread does not have active transactions. * @return Future that will be completed when cache is deployed. */ - @SuppressWarnings("IfMayBeConditional") public IgniteInternalFuture dynamicStartCache( @Nullable CacheConfiguration ccfg, String cacheName, @@ -3165,7 +3657,6 @@ public IgniteInternalFuture dynamicStartCache( * * @param ccfg Cache configuration. */ - @SuppressWarnings("IfMayBeConditional") public IgniteInternalFuture dynamicStartSqlCache( CacheConfiguration ccfg ) { @@ -3194,7 +3685,6 @@ public IgniteInternalFuture dynamicStartSqlCache( * @param checkThreadTx If {@code true} checks that current thread does not have active transactions. * @return Future that will be completed when cache is deployed. */ - @SuppressWarnings("IfMayBeConditional") public IgniteInternalFuture dynamicStartCache( @Nullable CacheConfiguration ccfg, String cacheName, @@ -3221,6 +3711,7 @@ public IgniteInternalFuture dynamicStartCache( sql, failIfExists, failIfNotStarted, + null, false, null, ccfg != null && ccfg.isEncryptionEnabled() ? grpKeys.iterator().next() : null); @@ -3325,14 +3816,18 @@ private IgniteInternalFuture startClientCacheChange( * @param disabledAfterStart If true, cache proxies will be only activated after {@link #restartProxies()}. * @return Future that will be completed when all caches are deployed. */ - public IgniteInternalFuture dynamicStartCaches(Collection ccfgList, boolean failIfExists, - boolean checkThreadTx, boolean disabledAfterStart) { + public IgniteInternalFuture dynamicStartCaches( + Collection ccfgList, + boolean failIfExists, + boolean checkThreadTx, + boolean disabledAfterStart + ) { return dynamicStartCachesByStoredConf( ccfgList.stream().map(StoredCacheData::new).collect(Collectors.toList()), failIfExists, checkThreadTx, - disabledAfterStart - ); + disabledAfterStart, + null); } /** @@ -3342,13 +3837,16 @@ public IgniteInternalFuture dynamicStartCaches(Collection dynamicStartCachesByStoredConf( Collection storedCacheDataList, boolean failIfExists, boolean checkThreadTx, - boolean disabledAfterStart) { + boolean disabledAfterStart, + IgniteUuid restartId + ) { if (checkThreadTx) checkEmptyTransactions(); @@ -3369,6 +3867,7 @@ public IgniteInternalFuture dynamicStartCachesByStoredConf( ccfg.sql(), failIfExists, true, + restartId, disabledAfterStart, ccfg.queryEntities(), ccfg.config().isEncryptionEnabled() ? grpKeysIter.next() : null); @@ -3439,10 +3938,16 @@ else if (DataStructuresProcessor.isDataStructureCache(ccfg.getName())) * command. * @param checkThreadTx If {@code true} checks that current thread does not have active transactions. * @param restart Restart flag. + * @param restartId Restart requester id (it'll allow to start this cache only him). * @return Future that will be completed when cache is destroyed. */ - public IgniteInternalFuture dynamicDestroyCache(String cacheName, boolean sql, boolean checkThreadTx, - boolean restart) { + public IgniteInternalFuture dynamicDestroyCache( + String cacheName, + boolean sql, + boolean checkThreadTx, + boolean restart, + IgniteUuid restartId + ) { assert cacheName != null; if (checkThreadTx) @@ -3453,6 +3958,7 @@ public IgniteInternalFuture dynamicDestroyCache(String cacheName, boole req.stop(true); req.destroy(true); req.restart(restart); + req.restartId(restartId); return F.first(initiateCacheChanges(F.asList(req))); } @@ -3460,30 +3966,30 @@ public IgniteInternalFuture dynamicDestroyCache(String cacheName, boole /** * @param cacheNames Collection of cache names to destroy. * @param checkThreadTx If {@code true} checks that current thread does not have active transactions. - * @param restart Restart flag. * @return Future that will be completed when cache is destroyed. */ - public IgniteInternalFuture dynamicDestroyCaches(Collection cacheNames, boolean checkThreadTx, - boolean restart) { - return dynamicDestroyCaches(cacheNames, checkThreadTx, restart, true); + public IgniteInternalFuture dynamicDestroyCaches(Collection cacheNames, boolean checkThreadTx) { + return dynamicDestroyCaches(cacheNames, checkThreadTx, true); } /** * @param cacheNames Collection of cache names to destroy. * @param checkThreadTx If {@code true} checks that current thread does not have active transactions. - * @param restart Restart flag. * @param destroy Cache data destroy flag. Setting to true will cause removing all cache data * @return Future that will be completed when cache is destroyed. */ - public IgniteInternalFuture dynamicDestroyCaches(Collection cacheNames, boolean checkThreadTx, - boolean restart, boolean destroy) { + public IgniteInternalFuture dynamicDestroyCaches( + Collection cacheNames, + boolean checkThreadTx, + boolean destroy + ) { if (checkThreadTx) checkEmptyTransactions(); List reqs = new ArrayList<>(cacheNames.size()); for (String cacheName : cacheNames) { - reqs.add(createStopRequest(cacheName, restart, destroy)); + reqs.add(createStopRequest(cacheName, false, null, destroy)); } return dynamicChangeCaches(reqs); @@ -3494,15 +4000,17 @@ public IgniteInternalFuture dynamicDestroyCaches(Collection cacheName * * @param cacheName Cache names to destroy. * @param restart Restart flag. + * @param restartId Restart requester id (it'll allow to start this cache only him). * @param destroy Cache data destroy flag. Setting to {@code true} will cause removing all cache data from store. * @return Future that will be completed when cache is destroyed. */ - @NotNull public DynamicCacheChangeRequest createStopRequest(String cacheName, boolean restart, boolean destroy) { + @NotNull public DynamicCacheChangeRequest createStopRequest(String cacheName, boolean restart, IgniteUuid restartId, boolean destroy) { DynamicCacheChangeRequest req = DynamicCacheChangeRequest.stopRequest(ctx, cacheName, false, true); req.stop(true); req.destroy(destroy); req.restart(restart); + req.restartId(restartId); return req; } @@ -3565,7 +4073,7 @@ IgniteInternalFuture dynamicCloseCache(String cacheName) { checkEmptyTransactions(); if (proxy.context().isLocal()) - return dynamicDestroyCache(cacheName, false, true, false); + return dynamicDestroyCache(cacheName, false, true, false, null); return startClientCacheChange(null, Collections.singleton(cacheName)); } @@ -3888,10 +4396,11 @@ else if (rebalanceOrder < 0) } /** - * Reset restarting caches. + * @param cacheName Cache to check. + * @return Cache is under restarting. */ - public void resetRestartingCaches() { - cachesInfo.restartingCaches().clear(); + public boolean isCacheRestarting(String cacheName) { + return cachesInfo.isRestarting(cacheName); } /** @@ -4308,8 +4817,20 @@ public CacheConfiguration cacheConfiguration(String name) { DynamicCacheDescriptor desc = cacheDescriptor(name); - if (desc == null) + if (desc == null) { + if (cachesInfo.isRestarting(name)) { + IgniteCacheProxyImpl proxy = jCacheProxies.get(name); + + assert proxy != null: name; + + proxy.internalProxy(); //should throw exception + + // we have procceed, try again + return cacheConfiguration(name); + } + throw new IllegalStateException("Cache doesn't exist: " + name); + } else return desc.cacheConfiguration(); } @@ -4331,6 +4852,26 @@ public Map cacheDescriptors() { return cachesInfo.registeredCaches(); } + /** + * @return Collection of persistent cache descriptors. + */ + public Collection persistentCaches() { + return cachesInfo.registeredCaches().values() + .stream() + .filter(desc -> isPersistentCache(desc.cacheConfiguration(), ctx.config().getDataStorageConfiguration())) + .collect(Collectors.toList()); + } + + /** + * @return Collection of persistent cache group descriptors. + */ + public Collection persistentGroups() { + return cachesInfo.registeredCacheGroups().values() + .stream() + .filter(CacheGroupDescriptor::persistenceEnabled) + .collect(Collectors.toList()); + } + /** * @return Cache group descriptors. */ @@ -4790,6 +5331,7 @@ private T withBinaryContext(IgniteOutClosureX c) throws IgniteCheckedExce * @param sql Whether the cache needs to be created as the result of SQL {@code CREATE TABLE} command. * @param failIfExists Fail if exists flag. * @param failIfNotStarted If {@code true} fails if cache is not started. + * @param restartId Restart requester id (it'll allow to start this cache only him). * @param disabledAfterStart If true, cache proxies will be only activated after {@link #restartProxies()}. * @param qryEntities Query entities. * @param encKey Encryption key. @@ -4805,6 +5347,7 @@ private DynamicCacheChangeRequest prepareCacheChangeRequest( boolean sql, boolean failIfExists, boolean failIfNotStarted, + IgniteUuid restartId, boolean disabledAfterStart, @Nullable Collection qryEntities, @Nullable byte[] encKey @@ -4821,6 +5364,8 @@ private DynamicCacheChangeRequest prepareCacheChangeRequest( req.encryptionKey(encKey); + req.restartId(restartId); + if (ccfg != null) { cloneCheckSerializable(ccfg); @@ -4834,7 +5379,7 @@ private DynamicCacheChangeRequest prepareCacheChangeRequest( // Check if we were asked to start a near cache. if (nearCfg != null) { - if (CU.affinityNode(ctx.discovery().localNode(), descCfg.getNodeFilter())) { + if (isLocalAffinity(descCfg)) { // If we are on a data node and near cache was enabled, return success, else - fail. if (descCfg.getNearConfiguration() != null) return null; @@ -4846,7 +5391,7 @@ private DynamicCacheChangeRequest prepareCacheChangeRequest( // If local node has near cache, return success. req.clientStartOnly(true); } - else if (!CU.affinityNode(ctx.discovery().localNode(), descCfg.getNodeFilter())) + else if (!isLocalAffinity(descCfg)) req.clientStartOnly(true); req.deploymentId(desc.deploymentId()); @@ -4855,17 +5400,21 @@ else if (!CU.affinityNode(ctx.discovery().localNode(), descCfg.getNodeFilter())) } } else { + CacheConfiguration cfg = new CacheConfiguration(ccfg); + req.deploymentId(IgniteUuid.randomUuid()); - CacheConfiguration cfg = new CacheConfiguration(ccfg); + req.startCacheConfiguration(cfg); CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(cfg); initialize(cfg, cacheObjCtx); - req.startCacheConfiguration(cfg); - req.schema(new QuerySchema(qryEntities != null ? QueryUtils.normalizeQueryEntities(qryEntities, cfg) - : cfg.getQueryEntities())); + if (restartId != null) + req.schema(new QuerySchema(qryEntities == null ? cfg.getQueryEntities() : qryEntities)); + else + req.schema(new QuerySchema(qryEntities != null ? QueryUtils.normalizeQueryEntities(qryEntities, cfg) + : cfg.getQueryEntities())); } } else { @@ -5014,6 +5563,108 @@ public T clone(final T obj) throws IgniteCheckedException { }); } + /** + * Get Temporary storage + */ + public MetaStorage.TmpStorage getTmpStorage() { + return tmpStorage; + } + + /** + * Set Temporary storage + */ + public void setTmpStorage(MetaStorage.TmpStorage tmpStorage) { + this.tmpStorage = tmpStorage; + } + + /** + * Recovery lifecycle for caches. + */ + private class CacheRecoveryLifecycle implements MetastorageLifecycleListener, DatabaseLifecycleListener { + /** Set of QuerySchema's saved on recovery. It's needed if cache query schema has changed after node joined to topology.*/ + private final Map querySchemas = new ConcurrentHashMap<>(); + + /** {@inheritDoc} */ + @Override public void onBaselineChange() { + onKernalStopCaches(true); + + stopCaches(true); + + sharedCtx.database().cleanupRestoredCaches(); + } + + /** {@inheritDoc} */ + @Override public void onReadyForRead(ReadOnlyMetastorage metastorage) throws IgniteCheckedException { + restoreCacheConfigurations(); + } + + /** {@inheritDoc} */ + @Override public void beforeBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException { + for (DynamicCacheDescriptor cacheDescriptor : persistentCaches()) + preparePageStore(cacheDescriptor, true); + } + + /** {@inheritDoc} */ + @Override public void afterBinaryMemoryRestore( + IgniteCacheDatabaseSharedManager mgr, + GridCacheDatabaseSharedManager.RestoreBinaryState restoreState) throws IgniteCheckedException { + for (DynamicCacheDescriptor cacheDescriptor : persistentCaches()) { + startCacheInRecoveryMode(cacheDescriptor); + + querySchemas.put(cacheDescriptor.cacheId(), cacheDescriptor.schema().copy()); + } + } + + /** {@inheritDoc} */ + @Override public void afterLogicalUpdatesApplied( + IgniteCacheDatabaseSharedManager mgr, + GridCacheDatabaseSharedManager.RestoreLogicalState restoreState) throws IgniteCheckedException { + restorePartitionStates(cacheGroups(), restoreState.partitionRecoveryStates()); + } + + /** + * @param forGroups Cache groups. + * @param partitionStates Partition states. + * @throws IgniteCheckedException If failed. + */ + private void restorePartitionStates( + Collection forGroups, + Map partitionStates + ) throws IgniteCheckedException { + long startRestorePart = U.currentTimeMillis(); + + if (log.isInfoEnabled()) + log.info("Restoring partition state for local groups."); + + long totalProcessed = 0; + + for (CacheGroupContext grp : forGroups) + totalProcessed += grp.offheap().restorePartitionStates(partitionStates); + + if (log.isInfoEnabled()) + log.info("Finished restoring partition state for local groups [" + + "groupsProcessed=" + forGroups.size() + + ", partitionsProcessed=" + totalProcessed + + ", time=" + (U.currentTimeMillis() - startRestorePart) + "ms]"); + } + } + + /** + * Handle of fail during cache start. + * + * @param Type of started data. + */ + private static interface StartCacheFailHandler { + /** + * Handle of fail. + * + * @param data Start data. + * @param startCacheOperation Operation for start cache. + * @throws IgniteCheckedException if failed. + */ + void handle(T data, IgniteThrowableConsumer startCacheOperation) throws IgniteCheckedException; + } + /** * */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index ebb8b5ea30154..fa9f3cb56f995 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -238,6 +238,42 @@ public IgniteInternalCache delegate() { } } + /** {@inheritDoc} */ + @Override public void preloadPartition(int part) throws IgniteCheckedException { + CacheOperationContext prev = gate.enter(opCtx); + + try { + delegate.preloadPartition(part); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public IgniteInternalFuture preloadPartitionAsync(int part) throws IgniteCheckedException { + CacheOperationContext prev = gate.enter(opCtx); + + try { + return delegate.preloadPartitionAsync(part); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public boolean localPreloadPartition(int part) throws IgniteCheckedException { + CacheOperationContext prev = gate.enter(opCtx); + + try { + return delegate.localPreloadPartition(part); + } + finally { + gate.leave(prev); + } + } + /** {@inheritDoc} */ @Override public GridCacheProxyImpl forSubjectId(UUID subjId) { return new GridCacheProxyImpl<>(ctx, delegate, @@ -890,13 +926,12 @@ public IgniteInternalCache delegate() { /** {@inheritDoc} */ @Nullable @Override public V localPeek(K key, - CachePeekMode[] peekModes, - @Nullable IgniteCacheExpiryPolicy plc) + CachePeekMode[] peekModes) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { - return delegate.localPeek(key, peekModes, plc); + return delegate.localPeek(key, peekModes); } finally { gate.leave(prev); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java index 431b9a9e9445e..94d8c1c6b2aaa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java @@ -175,6 +175,9 @@ public class GridCacheSharedContext { /** */ private final List stateAwareMgrs; + /** Cluster is in read-only mode. */ + private volatile boolean readOnlyMode; + /** * @param kernalCtx Context. * @param txMgr Transaction manager. @@ -1124,4 +1127,26 @@ public void finishDhtAtomicUpdate(GridCacheVersion ver) { private int dhtAtomicUpdateIndex(GridCacheVersion ver) { return U.safeAbs(ver.hashCode()) % dhtAtomicUpdCnt.length(); } + + /** + * @return {@code true} if cluster is in read-only mode. + */ + public boolean readOnlyMode() { + return readOnlyMode; + } + + /** + * @param readOnlyMode Read-only flag. + */ + public void readOnlyMode(boolean readOnlyMode) { + this.readOnlyMode = readOnlyMode; + } + + /** + * For test purposes. + * @param txMgr Tx manager. + */ + public void setTxManager(IgniteTxManager txMgr) { + this.txMgr = txMgr; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedTtlCleanupManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedTtlCleanupManager.java index 7a543546eb700..3f64f56923ab4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedTtlCleanupManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedTtlCleanupManager.java @@ -130,6 +130,17 @@ private class CleanupWorker extends GridWorker { Throwable err = null; try { + blockingSectionBegin(); + + try { + cctx.discovery().localJoin(); + } + finally { + blockingSectionEnd(); + } + + assert !cctx.kernalContext().recoveryMode(); + while (!isCancelled()) { boolean expiredRemains = false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java index 2166ce5eba935..1a887e24f55a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java @@ -71,7 +71,7 @@ public class GridCacheTtlManager extends GridCacheManagerAdapter { } if (touch) - entry.touch(null); + entry.touch(); } }; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java index ebf42fa16727a..ca60e29ab4187 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java @@ -1317,7 +1317,7 @@ public static long expireTimeInPast() { if (e instanceof CachePartialUpdateCheckedException) return new CachePartialUpdateException((CachePartialUpdateCheckedException)e); - else if (e instanceof ClusterTopologyServerNotFoundException) + else if (e.hasCause(ClusterTopologyServerNotFoundException.class)) return new CacheServerNotFoundException(e.getMessage(), e); else if (e instanceof SchemaOperationException) return new CacheException(e.getMessage(), e); @@ -1796,7 +1796,7 @@ private void process(KeyCacheObject key, CacheObject val, GridCacheVersion ver, } finally { if (entry != null) - entry.touch(topVer); + entry.touch(); cctx.shared().database().checkpointReadUnlock(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridChangeGlobalStateMessageResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridChangeGlobalStateMessageResponse.java index e49be4934eeb9..4cf9e2388229c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridChangeGlobalStateMessageResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridChangeGlobalStateMessageResponse.java @@ -116,13 +116,13 @@ public Throwable getError() { } switch (writer.state()) { - case 2: + case 3: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 3: + case 4: if (!writer.writeUuid("requestId", requestId)) return false; @@ -144,7 +144,7 @@ public Throwable getError() { return false; switch (reader.state()) { - case 2: + case 3: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -152,7 +152,7 @@ public Throwable getError() { reader.incrementState(); - case 3: + case 4: requestId = reader.readUuid("requestId"); if (!reader.isLastRead()) @@ -172,7 +172,7 @@ public Throwable getError() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 4; + return 5; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java index 1128ae2be4c23..7f0fc3096d9a0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java @@ -31,6 +31,8 @@ import org.apache.ignite.internal.processors.cache.persistence.CacheSearchRow; import org.apache.ignite.internal.processors.cache.persistence.RootPage; import org.apache.ignite.internal.processors.cache.persistence.RowStore; +import org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId; +import org.apache.ignite.internal.processors.cache.persistence.partstate.PartitionRecoverState; import org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseList; import org.apache.ignite.internal.processors.cache.tree.PendingEntriesTree; import org.apache.ignite.internal.processors.cache.tree.mvcc.data.MvccUpdateResult; @@ -81,6 +83,15 @@ public interface IgniteCacheOffheapManager { */ public void stop(); + /** + * Pre-create partitions that resides in page memory or WAL and restores their state. + * + * @param partitionRecoveryStates Partition recovery states. + * @return Number of processed partitions. + * @throws IgniteCheckedException If failed. + */ + long restorePartitionStates(Map partitionRecoveryStates) throws IgniteCheckedException; + /** * Partition counter update callback. May be overridden by plugin-provided subclasses. * @@ -180,10 +191,11 @@ public void invoke(GridCacheContext cctx, KeyCacheObject key, GridDhtLocalPartit /** * @param cctx Cache context. * @param key Key. + * @param mvccSnapshot MVCC snapshot. * @return Cached row, if available, null otherwise. * @throws IgniteCheckedException If failed. */ - @Nullable public CacheDataRow mvccRead(GridCacheContext cctx, KeyCacheObject key, MvccSnapshot ver) + @Nullable public CacheDataRow mvccRead(GridCacheContext cctx, KeyCacheObject key, MvccSnapshot mvccSnapshot) throws IgniteCheckedException; /** @@ -449,11 +461,11 @@ public void remove( public int onUndeploy(ClassLoader ldr); /** - * * @param cacheId Cache ID. * @param primary Primary entries flag. * @param backup Backup entries flag. * @param topVer Topology version. + * @param mvccSnapshot MVCC snapshot. * @return Rows iterator. * @throws IgniteCheckedException If failed. */ @@ -512,20 +524,21 @@ public IgniteRebalanceIterator rebalanceIterator(IgniteDhtDemandedPartitionsMap /** * @param cctx Cache context. - * @param primary Primary entries flag. - * @param backup Backup entries flag. + * @param primary {@code True} if need to return primary entries. + * @param backup {@code True} if need to return backup entries. * @param topVer Topology version. * @param keepBinary Keep binary flag. + * @param mvccSnapshot MVCC snapshot. * @return Entries iterator. * @throws IgniteCheckedException If failed. */ - // TODO: MVCC> public GridCloseableIterator> cacheEntriesIterator( GridCacheContext cctx, final boolean primary, final boolean backup, final AffinityTopologyVersion topVer, - final boolean keepBinary) throws IgniteCheckedException; + final boolean keepBinary, + @Nullable final MvccSnapshot mvccSnapshot) throws IgniteCheckedException; /** * @param cacheId Cache ID. @@ -577,17 +590,18 @@ public long cacheEntriesCount(int cacheId, boolean primary, boolean backup, Affi /** * @param cacheId Cache ID. * @param idxName Index name. + * @param segment Segment. * @return Root page for index tree. * @throws IgniteCheckedException If failed. */ - public RootPage rootPageForIndex(int cacheId, String idxName) throws IgniteCheckedException; + public RootPage rootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException; /** * @param cacheId Cache ID. * @param idxName Index name. * @throws IgniteCheckedException If failed. */ - public void dropRootPageForIndex(int cacheId, String idxName) throws IgniteCheckedException; + public void dropRootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException; /** * @param idxName Index name. @@ -608,6 +622,14 @@ public long cacheEntriesCount(int cacheId, boolean primary, boolean backup, Affi */ public long totalPartitionEntriesCount(int part); + /** + * Preload a partition. Must be called under partition reservation for DHT caches. + * + * @param part Partition. + * @throws IgniteCheckedException If failed. + */ + public void preloadPartition(int part) throws IgniteCheckedException; + /** * */ @@ -655,6 +677,11 @@ interface CacheDataStore { */ long fullSize(); + /** + * @return {@code True} if there are no items in the store. + */ + boolean isEmpty(); + /** * Updates size metric for particular cache. * @@ -1091,7 +1118,7 @@ public GridCursor cursor(int cacheId, KeyCacheObject low /** * @param cntr Counter. */ - void updateInitialCounter(long cntr); + public void updateInitialCounter(long cntr); /** * Inject rows cache cleaner. @@ -1105,11 +1132,19 @@ public GridCursor cursor(int cacheId, KeyCacheObject low * * @return PendingTree instance. */ - PendingEntriesTree pendingTree(); + public PendingEntriesTree pendingTree(); /** * Flushes pending update counters closing all possible gaps. + * + * @return Even-length array of pairs [start, end] for each gap. + */ + GridLongList finalizeUpdateCounters(); + + /** + * Preload a store into page memory. + * @throws IgniteCheckedException If failed. */ - void finalizeUpdateCountres(); + public void preload() throws IgniteCheckedException; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index 5ce40b0d859ae..6df2f8af54771 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -60,6 +60,8 @@ import org.apache.ignite.internal.processors.cache.persistence.CacheSearchRow; import org.apache.ignite.internal.processors.cache.persistence.RootPage; import org.apache.ignite.internal.processors.cache.persistence.RowStore; +import org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId; +import org.apache.ignite.internal.processors.cache.persistence.partstate.PartitionRecoverState; import org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree; import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO; import org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO; @@ -258,6 +260,11 @@ protected void initDataStructures() throws IgniteCheckedException { } } + /** {@inheritDoc} */ + @Override public long restorePartitionStates(Map partitionRecoveryStates) throws IgniteCheckedException { + return 0; // No-op. + } + /** {@inheritDoc} */ @Override public void onKernalStop() { busyLock.block(); @@ -338,6 +345,11 @@ public CacheDataStore dataStore(int part) { } } + /** {@inheritDoc} */ + @Override public void preloadPartition(int p) throws IgniteCheckedException { + throw new IgniteCheckedException("Operation only applicable to caches with enabled persistence"); + } + /** * @param p Partition. * @return Partition data. @@ -675,13 +687,13 @@ private Iterator cacheData(boolean primary, boolean backup, Affi } /** {@inheritDoc} */ - @Nullable @Override public CacheDataRow mvccRead(GridCacheContext cctx, KeyCacheObject key, MvccSnapshot ver) + @Nullable @Override public CacheDataRow mvccRead(GridCacheContext cctx, KeyCacheObject key, MvccSnapshot mvccSnapshot) throws IgniteCheckedException { - assert ver != null; + assert mvccSnapshot != null; CacheDataStore dataStore = dataStore(cctx, key); - CacheDataRow row = dataStore != null ? dataStore.mvccFind(cctx, key, ver) : null; + CacheDataRow row = dataStore != null ? dataStore.mvccFind(cctx, key, mvccSnapshot) : null; assert row == null || row.value() != null : row; @@ -800,21 +812,16 @@ private Iterator cacheData(boolean primary, boolean backup, Affi return 0; } - /** - * @param primary {@code True} if need return primary entries. - * @param backup {@code True} if need return backup entries. - * @param topVer Topology version to use. - * @return Entries iterator. - * @throws IgniteCheckedException If failed. - */ + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public GridCloseableIterator> cacheEntriesIterator( final GridCacheContext cctx, final boolean primary, final boolean backup, final AffinityTopologyVersion topVer, - final boolean keepBinary) throws IgniteCheckedException { - final Iterator it = cacheIterator(cctx.cacheId(), primary, backup, topVer, null); + final boolean keepBinary, + @Nullable final MvccSnapshot mvccSnapshot) throws IgniteCheckedException { + final Iterator it = cacheIterator(cctx.cacheId(), primary, backup, topVer, mvccSnapshot); return new GridCloseableIteratorAdapter>() { /** */ @@ -1131,14 +1138,14 @@ private long allocateForTree() throws IgniteCheckedException { } /** {@inheritDoc} */ - @Override public RootPage rootPageForIndex(int cacheId, String idxName) throws IgniteCheckedException { + @Override public RootPage rootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException { long pageId = allocateForTree(); return new RootPage(new FullPageId(pageId, grp.groupId()), true); } /** {@inheritDoc} */ - @Override public void dropRootPageForIndex(int cacheId, String idxName) throws IgniteCheckedException { + @Override public void dropRootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException { // No-op. } @@ -1522,6 +1529,24 @@ void decrementSize(int cacheId) { return storageSize.get(); } + /** + * @return {@code True} if there are no items in the store. + */ + @Override public boolean isEmpty() { + try { + /* + * TODO https://issues.apache.org/jira/browse/IGNITE-10082 + * Using of counters is cheaper than tree operations. Return size checking after the ticked is resolved. + */ + return grp.mvccEnabled() ? dataTree.isEmpty() : storageSize.get() == 0; + } + catch (IgniteCheckedException e) { + U.error(log, "Failed to perform operation.", e); + + return false; + } + } + /** {@inheritDoc} */ @Override public void updateSize(int cacheId, long delta) { storageSize.addAndGet(delta); @@ -1576,8 +1601,8 @@ void decrementSize(int cacheId) { } /** {@inheritDoc} */ - @Override public void finalizeUpdateCountres() { - pCntr.finalizeUpdateCountres(); + @Override public GridLongList finalizeUpdateCounters() { + return pCntr.finalizeUpdateCounters(); } /** {@inheritDoc} */ @@ -1966,6 +1991,8 @@ else if (res == ResultType.VERSION_FOUND || // exceptional case assert res == ResultType.PREV_NULL; if (entryProc != null) { + entryProc = EntryProcessorResourceInjectorProxy.wrap(cctx.kernalContext(), entryProc); + CacheInvokeEntry.Operation op = applyEntryProcessor(cctx, key, ver, entryProc, invokeArgs, updateRow, oldRow); if (op == CacheInvokeEntry.Operation.NONE) { @@ -3012,6 +3039,11 @@ private void afterRowFound(@Nullable CacheDataRow row, KeyCacheObject key) throw return pendingEntries; } + /** {@inheritDoc} */ + @Override public void preload() throws IgniteCheckedException { + // No-op. + } + /** * @param cctx Cache context. * @param key Key. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java index 776e1cbeb65de..f421c1dbbed4f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java @@ -31,6 +31,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.Lock; import javax.cache.Cache; @@ -100,7 +101,6 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.mxbean.CacheMetricsMXBean; import org.apache.ignite.plugin.security.SecurityPermission; @@ -122,9 +122,15 @@ public class IgniteCacheProxyImpl extends AsyncSupportAdapter ctx; + /** Old context. */ + private transient volatile GridCacheContext oldContext; + /** Delegate. */ @GridToStringInclude private volatile IgniteInternalCache delegate; @@ -185,6 +191,10 @@ private IgniteCacheProxyImpl( assert ctx != null; assert delegate != null; + cacheName = ctx.name(); + + assert cacheName.equals(delegate.name()) : "ctx.name=" + cacheName + ", delegate.name=" + delegate.name(); + this.ctx = ctx; this.delegate = delegate; @@ -203,6 +213,65 @@ public CountDownLatch getInitLatch(){ * @return Context. */ @Override public GridCacheContext context() { + return getContextSafe(); + } + + /** + * @return Context or throw restart exception. + */ + private GridCacheContext getContextSafe() { + while (true) { + GridCacheContext ctx = this.ctx; + + if (ctx == null) { + checkRestart(); + + if (Thread.currentThread().isInterrupted()) + throw new IgniteException(new InterruptedException()); + } + else + return ctx; + } + } + + /** + * @return Delegate or throw restart exception. + */ + private IgniteInternalCache getDelegateSafe() { + while (true) { + IgniteInternalCache delegate = this.delegate; + + if (delegate == null) { + checkRestart(); + + if (Thread.currentThread().isInterrupted()) + throw new IgniteException(new InterruptedException()); + } + else + return delegate; + } + } + + /** + * @return Context. + */ + public GridCacheContext context0() { + GridCacheContext ctx = this.ctx; + + if (ctx == null) { + synchronized (this) { + ctx = this.ctx; + + if (ctx == null) { + GridCacheContext context = oldContext; + + assert context != null; + + return context; + } + } + } + return ctx; } @@ -219,36 +288,49 @@ public IgniteCacheProxy gatewayWrapper() { return cachedProxy; cachedProxy = new GatewayProtectedCacheProxy<>(this, new CacheOperationContext(), true); + return cachedProxy; } /** {@inheritDoc} */ @Override public CacheMetrics metrics() { + GridCacheContext ctx = getContextSafe(); + return ctx.cache().clusterMetrics(); } /** {@inheritDoc} */ @Override public CacheMetrics metrics(ClusterGroup grp) { + GridCacheContext ctx = getContextSafe(); + return ctx.cache().clusterMetrics(grp); } /** {@inheritDoc} */ @Override public CacheMetrics localMetrics() { + GridCacheContext ctx = getContextSafe(); + return ctx.cache().localMetrics(); } /** {@inheritDoc} */ @Override public CacheMetricsMXBean mxBean() { + GridCacheContext ctx = getContextSafe(); + return ctx.cache().clusterMxBean(); } /** {@inheritDoc} */ @Override public CacheMetricsMXBean localMxBean() { + GridCacheContext ctx = getContextSafe(); + return ctx.cache().localMxBean(); } /** {@inheritDoc} */ @Override public > C getConfiguration(Class clazz) { + GridCacheContext ctx = getContextSafe(); + CacheConfiguration cfg = ctx.config(); if (!clazz.isAssignableFrom(cfg.getClass())) @@ -284,6 +366,8 @@ public IgniteCacheProxy gatewayWrapper() { /** {@inheritDoc} */ @Override public void loadCache(@Nullable IgniteBiPredicate p, @Nullable Object... args) { + GridCacheContext ctx = getContextSafe(); + try { if (isAsync()) { if (ctx.cache().isLocal()) @@ -306,6 +390,8 @@ public IgniteCacheProxy gatewayWrapper() { /** {@inheritDoc} */ @Override public IgniteFuture loadCacheAsync(@Nullable IgniteBiPredicate p, @Nullable Object... args) throws CacheException { + GridCacheContext ctx = getContextSafe(); + try { if (ctx.cache().isLocal()) return (IgniteFuture)createFuture(ctx.cache().localLoadCacheAsync(p, args)); @@ -319,6 +405,8 @@ public IgniteCacheProxy gatewayWrapper() { /** {@inheritDoc} */ @Override public void localLoadCache(@Nullable IgniteBiPredicate p, @Nullable Object... args) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) setFuture(delegate.localLoadCacheAsync(p, args)); @@ -333,11 +421,15 @@ public IgniteCacheProxy gatewayWrapper() { /** {@inheritDoc} */ @Override public IgniteFuture localLoadCacheAsync(@Nullable IgniteBiPredicate p, @Nullable Object... args) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + return (IgniteFuture)createFuture(delegate.localLoadCacheAsync(p, args)); } /** {@inheritDoc} */ @Nullable @Override public V getAndPutIfAbsent(K key, V val) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getAndPutIfAbsentAsync(key, val)); @@ -354,6 +446,8 @@ public IgniteCacheProxy gatewayWrapper() { /** {@inheritDoc} */ @Override public IgniteFuture getAndPutIfAbsentAsync(K key, V val) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.getAndPutIfAbsentAsync(key, val)); } @@ -364,6 +458,9 @@ public IgniteCacheProxy gatewayWrapper() { /** {@inheritDoc} */ @Override public Lock lockAll(final Collection keys) { + IgniteInternalCache delegate = getDelegateSafe(); + GridCacheContext ctx = getContextSafe(); + //TODO: IGNITE-9324: add explicit locks support. MvccUtils.verifyMvccOperationSupport(ctx, "Lock"); @@ -372,6 +469,8 @@ public IgniteCacheProxy gatewayWrapper() { /** {@inheritDoc} */ @Override public boolean isLocalLocked(K key, boolean byCurrThread) { + IgniteInternalCache delegate = getDelegateSafe(); + return byCurrThread ? delegate.isLockedByThread(key) : delegate.isLocked(key); } @@ -386,8 +485,9 @@ public IgniteCacheProxy gatewayWrapper() { private QueryCursor query( final ScanQuery scanQry, @Nullable final IgniteClosure transformer, - @Nullable ClusterGroup grp) - throws IgniteCheckedException { + @Nullable ClusterGroup grp + ) throws IgniteCheckedException { + GridCacheContext ctx = getContextSafe(); CacheOperationContext opCtxCall = ctx.operationContextPerCall(); @@ -405,7 +505,7 @@ private QueryCursor query( qry.projection(grp); final GridCloseableIterator iter = ctx.kernalContext().query().executeQuery(GridCacheQueryType.SCAN, - ctx.name(), ctx, new IgniteOutClosureX>() { + cacheName, ctx, new IgniteOutClosureX>() { @Override public GridCloseableIterator applyx() throws IgniteCheckedException { return qry.executeScanQuery(); } @@ -423,6 +523,8 @@ private QueryCursor query( @SuppressWarnings("unchecked") private QueryCursor> query(final Query filter, @Nullable ClusterGroup grp) throws IgniteCheckedException { + GridCacheContext ctx = getContextSafe(); + final CacheQuery qry; CacheOperationContext opCtxCall = ctx.operationContextPerCall(); @@ -515,11 +617,13 @@ else if (filter instanceof SpiQuery) { * @return Local node cluster group. */ private ClusterGroup projection(boolean loc) { + GridCacheContext ctx = getContextSafe(); + if (loc || ctx.isLocal() || ctx.isReplicatedAffinityNode()) return ctx.kernalContext().grid().cluster().forLocal(); if (ctx.isReplicated()) - return ctx.kernalContext().grid().cluster().forDataNodes(ctx.name()).forRandom(); + return ctx.kernalContext().grid().cluster().forDataNodes(cacheName).forRandom(); return null; } @@ -534,6 +638,8 @@ private ClusterGroup projection(boolean loc) { */ @SuppressWarnings("unchecked") private QueryCursor> queryContinuous(AbstractContinuousQuery qry, boolean loc, boolean keepBinary) { + GridCacheContext ctx = getContextSafe(); + assert qry instanceof ContinuousQuery || qry instanceof ContinuousQueryWithTransformer; if (qry.getInitialQuery() instanceof ContinuousQuery || @@ -638,6 +744,8 @@ private QueryCursor> queryContinuous(AbstractContinuousQuery q /** {@inheritDoc} */ @Override public List>> queryMultipleStatements(SqlFieldsQuery qry) { + GridCacheContext ctx = getContextSafe(); + A.notNull(qry, "qry"); try { ctx.checkSecurity(SecurityPermission.CACHE_READ); @@ -663,6 +771,8 @@ private QueryCursor> queryContinuous(AbstractContinuousQuery q /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public QueryCursor query(Query qry) { + GridCacheContext ctx = getContextSafe(); + A.notNull(qry, "qry"); try { ctx.checkSecurity(SecurityPermission.CACHE_READ); @@ -700,6 +810,8 @@ private QueryCursor> queryContinuous(AbstractContinuousQuery q /** {@inheritDoc} */ @Override public QueryCursor query(Query qry, IgniteClosure transformer) { + GridCacheContext ctx = getContextSafe(); + A.notNull(qry, "qry"); A.notNull(transformer, "transformer"); @@ -727,6 +839,8 @@ private QueryCursor> queryContinuous(AbstractContinuousQuery q * @param qry Query. */ private void convertToBinary(final Query qry) { + GridCacheContext ctx = getContextSafe(); + if (ctx.binaryMarshaller()) { if (qry instanceof SqlQuery) { final SqlQuery sqlQry = (SqlQuery) qry; @@ -755,6 +869,8 @@ private void convertToBinary(final Object[] args) { if (args == null) return; + GridCacheContext ctx = getContextSafe(); + for (int i = 0; i < args.length; i++) args[i] = ctx.cacheObjects().binary().toBinary(args[i]); } @@ -766,10 +882,12 @@ private void convertToBinary(final Object[] args) { * @throws CacheException If query indexing disabled for sql query. */ private void validate(Query qry) { + GridCacheContext ctx = getContextSafe(); + if (!QueryUtils.isEnabled(ctx.config()) && !(qry instanceof ScanQuery) && !(qry instanceof ContinuousQuery) && !(qry instanceof ContinuousQueryWithTransformer) && !(qry instanceof SpiQuery) && !(qry instanceof SqlQuery) && !(qry instanceof SqlFieldsQuery)) - throw new CacheException("Indexing is disabled for cache: " + ctx.cache().name() + + throw new CacheException("Indexing is disabled for cache: " + cacheName + ". Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable."); if (!ctx.kernalContext().query().moduleEnabled() && @@ -780,6 +898,8 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public Iterable> localEntries(CachePeekMode... peekModes) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + try { return delegate.localEntries(peekModes); } @@ -790,33 +910,45 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public QueryMetrics queryMetrics() { + IgniteInternalCache delegate = getDelegateSafe(); + return delegate.context().queries().metrics(); } /** {@inheritDoc} */ @Override public void resetQueryMetrics() { + IgniteInternalCache delegate = getDelegateSafe(); + delegate.context().queries().resetMetrics(); } /** {@inheritDoc} */ @Override public Collection queryDetailMetrics() { + IgniteInternalCache delegate = getDelegateSafe(); + return delegate.context().queries().detailMetrics(); } /** {@inheritDoc} */ @Override public void resetQueryDetailMetrics() { + IgniteInternalCache delegate = getDelegateSafe(); + delegate.context().queries().resetDetailMetrics(); } /** {@inheritDoc} */ @Override public void localEvict(Collection keys) { + IgniteInternalCache delegate = getDelegateSafe(); + delegate.evictAll(keys); } /** {@inheritDoc} */ @Nullable @Override public V localPeek(K key, CachePeekMode... peekModes) { + IgniteInternalCache delegate = getDelegateSafe(); + try { - return delegate.localPeek(key, peekModes, null); + return delegate.localPeek(key, peekModes); } catch (IgniteException | IgniteCheckedException e) { throw cacheException(e); @@ -825,6 +957,8 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public int size(CachePeekMode... peekModes) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.sizeAsync(peekModes)); @@ -841,11 +975,15 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public IgniteFuture sizeAsync(CachePeekMode... peekModes) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.sizeAsync(peekModes)); } /** {@inheritDoc} */ @Override public long sizeLong(CachePeekMode... peekModes) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.sizeLongAsync(peekModes)); @@ -862,11 +1000,15 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public IgniteFuture sizeLongAsync(CachePeekMode... peekModes) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.sizeLongAsync(peekModes)); } /** {@inheritDoc} */ @Override public long sizeLong(int part, CachePeekMode... peekModes) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.sizeLongAsync(part, peekModes)); @@ -883,11 +1025,15 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public IgniteFuture sizeLongAsync(int part, CachePeekMode... peekModes) throws CacheException { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.sizeLongAsync(part, peekModes)); } /** {@inheritDoc} */ @Override public int localSize(CachePeekMode... peekModes) { + IgniteInternalCache delegate = getDelegateSafe(); + try { return delegate.localSize(peekModes); } @@ -898,6 +1044,8 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public long localSizeLong(CachePeekMode... peekModes) { + IgniteInternalCache delegate = getDelegateSafe(); + try { return delegate.localSizeLong(peekModes); } @@ -908,6 +1056,8 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public long localSizeLong(int part, CachePeekMode... peekModes) { + IgniteInternalCache delegate = getDelegateSafe(); + try { return delegate.localSizeLong(part, peekModes); } @@ -918,6 +1068,8 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public V get(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getAsync(key)); @@ -934,11 +1086,15 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public IgniteFuture getAsync(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.getAsync(key)); } /** {@inheritDoc} */ @Override public CacheEntry getEntry(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getEntryAsync(key)); @@ -955,11 +1111,15 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public IgniteFuture> getEntryAsync(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.getEntryAsync(key)); } /** {@inheritDoc} */ @Override public Map getAll(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getAllAsync(keys)); @@ -976,11 +1136,15 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public IgniteFuture> getAllAsync(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.getAllAsync(keys)); } /** {@inheritDoc} */ @Override public Collection> getEntries(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getEntriesAsync(keys)); @@ -997,11 +1161,15 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public IgniteFuture>> getEntriesAsync(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.getEntriesAsync(keys)); } /** {@inheritDoc} */ @Override public Map getAllOutTx(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getAllOutTxAsync(keys)); @@ -1018,6 +1186,8 @@ private void validate(Query qry) { /** {@inheritDoc} */ @Override public IgniteFuture> getAllOutTxAsync(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.getAllOutTxAsync(keys)); } @@ -1026,6 +1196,8 @@ private void validate(Query qry) { * @return Values map. */ public Map getAll(Collection keys) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getAllAsync(keys)); @@ -1042,6 +1214,8 @@ public Map getAll(Collection keys) { /** {@inheritDoc} */ @Override public boolean containsKey(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + if (isAsync()) { setFuture(delegate.containsKeyAsync(key)); @@ -1053,11 +1227,15 @@ public Map getAll(Collection keys) { /** {@inheritDoc} */ @Override public IgniteFuture containsKeyAsync(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.containsKeyAsync(key)); } /** {@inheritDoc} */ @Override public boolean containsKeys(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + if (isAsync()) { setFuture(delegate.containsKeysAsync(keys)); @@ -1069,6 +1247,8 @@ public Map getAll(Collection keys) { /** {@inheritDoc} */ @Override public IgniteFuture containsKeysAsync(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.containsKeysAsync(keys)); } @@ -1078,6 +1258,8 @@ public Map getAll(Collection keys) { boolean replaceExisting, @Nullable final CompletionListener completionLsnr ) { + GridCacheContext ctx = getContextSafe(); + IgniteInternalFuture fut = ctx.cache().loadAll(keys, replaceExisting); if (completionLsnr != null) { @@ -1098,6 +1280,8 @@ public Map getAll(Collection keys) { /** {@inheritDoc} */ @Override public void put(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) setFuture(putAsync0(key, val)); @@ -1122,6 +1306,8 @@ public Map getAll(Collection keys) { * @return Internal future. */ private IgniteInternalFuture putAsync0(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + IgniteInternalFuture fut = delegate.putAsync(key, val); return fut.chain(new CX1, Void>() { @@ -1140,6 +1326,8 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public V getAndPut(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getAndPutAsync(key, val)); @@ -1156,11 +1344,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture getAndPutAsync(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.getAndPutAsync(key, val)); } /** {@inheritDoc} */ @Override public void putAll(Map map) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) setFuture(delegate.putAllAsync(map)); @@ -1174,11 +1366,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture putAllAsync(Map map) { + IgniteInternalCache delegate = getDelegateSafe(); + return (IgniteFuture)createFuture(delegate.putAllAsync(map)); } /** {@inheritDoc} */ @Override public boolean putIfAbsent(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.putIfAbsentAsync(key, val)); @@ -1195,11 +1391,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture putIfAbsentAsync(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.putIfAbsentAsync(key, val)); } /** {@inheritDoc} */ @Override public boolean remove(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.removeAsync(key)); @@ -1216,11 +1416,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture removeAsync(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.removeAsync(key)); } /** {@inheritDoc} */ @Override public boolean remove(K key, V oldVal) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.removeAsync(key, oldVal)); @@ -1237,11 +1441,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture removeAsync(K key, V oldVal) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.removeAsync(key, oldVal)); } /** {@inheritDoc} */ @Override public V getAndRemove(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getAndRemoveAsync(key)); @@ -1258,11 +1466,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture getAndRemoveAsync(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.getAndRemoveAsync(key)); } /** {@inheritDoc} */ @Override public boolean replace(K key, V oldVal, V newVal) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.replaceAsync(key, oldVal, newVal)); @@ -1279,11 +1491,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture replaceAsync(K key, V oldVal, V newVal) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.replaceAsync(key, oldVal, newVal)); } /** {@inheritDoc} */ @Override public boolean replace(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.replaceAsync(key, val)); @@ -1300,11 +1516,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture replaceAsync(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.replaceAsync(key, val)); } /** {@inheritDoc} */ @Override public V getAndReplace(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.getAndReplaceAsync(key, val)); @@ -1321,11 +1541,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture getAndReplaceAsync(K key, V val) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.getAndReplaceAsync(key, val)); } /** {@inheritDoc} */ @Override public void removeAll(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) setFuture(delegate.removeAllAsync(keys)); @@ -1339,11 +1563,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture removeAllAsync(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + return (IgniteFuture)createFuture(delegate.removeAllAsync(keys)); } /** {@inheritDoc} */ @Override public void removeAll() { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) setFuture(delegate.removeAllAsync()); @@ -1357,11 +1585,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture removeAllAsync() { + IgniteInternalCache delegate = getDelegateSafe(); + return (IgniteFuture)createFuture(delegate.removeAllAsync()); } /** {@inheritDoc} */ @Override public void clear(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) setFuture(delegate.clearAsync(key)); @@ -1375,11 +1607,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture clearAsync(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + return (IgniteFuture)createFuture(delegate.clearAsync(key)); } /** {@inheritDoc} */ @Override public void clearAll(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) setFuture(delegate.clearAllAsync(keys)); @@ -1393,11 +1629,15 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture clearAllAsync(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + return (IgniteFuture)createFuture(delegate.clearAllAsync(keys)); } /** {@inheritDoc} */ @Override public void clear() { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) setFuture(delegate.clearAsync()); @@ -1411,16 +1651,22 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public IgniteFuture clearAsync() { + IgniteInternalCache delegate = getDelegateSafe(); + return (IgniteFuture)createFuture(delegate.clearAsync()); } /** {@inheritDoc} */ @Override public void localClear(K key) { + IgniteInternalCache delegate = getDelegateSafe(); + delegate.clearLocally(key); } /** {@inheritDoc} */ @Override public void localClearAll(Set keys) { + IgniteInternalCache delegate = getDelegateSafe(); + for (K key : keys) delegate.clearLocally(key); } @@ -1428,6 +1674,8 @@ private IgniteInternalFuture putAsync0(K key, V val) { /** {@inheritDoc} */ @Override public T invoke(K key, EntryProcessor entryProcessor, Object... args) throws EntryProcessorException { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(invokeAsync0(key, entryProcessor, args)); @@ -1460,6 +1708,8 @@ private IgniteInternalFuture putAsync0(K key, V val) { * @return Internal future. */ private IgniteInternalFuture invokeAsync0(K key, EntryProcessor entryProcessor, Object[] args) { + IgniteInternalCache delegate = getDelegateSafe(); + IgniteInternalFuture> fut = delegate.invokeAsync(key, entryProcessor, args); return fut.chain(new CX1>, T>() { @@ -1498,7 +1748,10 @@ private IgniteInternalFuture invokeAsync0(K key, EntryProcessor public T invoke(@Nullable AffinityTopologyVersion topVer, K key, EntryProcessor entryProcessor, - Object... args) { + Object... args + ) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) throw new UnsupportedOperationException(); @@ -1516,7 +1769,10 @@ public T invoke(@Nullable AffinityTopologyVersion topVer, /** {@inheritDoc} */ @Override public Map> invokeAll(Set keys, EntryProcessor entryProcessor, - Object... args) { + Object... args + ) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.invokeAllAsync(keys, entryProcessor, args)); @@ -1534,13 +1790,19 @@ public T invoke(@Nullable AffinityTopologyVersion topVer, /** {@inheritDoc} */ @Override public IgniteFuture>> invokeAllAsync(Set keys, EntryProcessor entryProcessor, Object... args) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.invokeAllAsync(keys, entryProcessor, args)); } /** {@inheritDoc} */ - @Override public Map> invokeAll(Set keys, + @Override public Map> invokeAll( + Set keys, CacheEntryProcessor entryProcessor, - Object... args) { + Object... args + ) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.invokeAllAsync(keys, entryProcessor, args)); @@ -1558,6 +1820,8 @@ public T invoke(@Nullable AffinityTopologyVersion topVer, /** {@inheritDoc} */ @Override public IgniteFuture>> invokeAllAsync(Set keys, CacheEntryProcessor entryProcessor, Object... args) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.invokeAllAsync(keys, entryProcessor, args)); } @@ -1565,6 +1829,8 @@ public T invoke(@Nullable AffinityTopologyVersion topVer, @Override public Map> invokeAll( Map> map, Object... args) { + IgniteInternalCache delegate = getDelegateSafe(); + try { if (isAsync()) { setFuture(delegate.invokeAllAsync(map, args)); @@ -1582,12 +1848,14 @@ public T invoke(@Nullable AffinityTopologyVersion topVer, /** {@inheritDoc} */ @Override public IgniteFuture>> invokeAllAsync( Map> map, Object... args) { + IgniteInternalCache delegate = getDelegateSafe(); + return createFuture(delegate.invokeAllAsync(map, args)); } /** {@inheritDoc} */ @Override public String getName() { - return delegate.name(); + return cacheName; } /** {@inheritDoc} */ @@ -1609,7 +1877,9 @@ public void setCacheManager(CacheManager cacheMgr) { /** {@inheritDoc} */ @Override public IgniteFuture destroyAsync() { - return new IgniteFutureImpl<>(ctx.kernalContext().cache().dynamicDestroyCache(ctx.name(), false, true, false)); + GridCacheContext ctx = getContextSafe(); + + return new IgniteFutureImpl<>(ctx.kernalContext().cache().dynamicDestroyCache(cacheName, false, true, false, null)); } /** {@inheritDoc} */ @@ -1619,11 +1889,15 @@ public void setCacheManager(CacheManager cacheMgr) { /** {@inheritDoc} */ @Override public IgniteFuture closeAsync() { - return new IgniteFutureImpl<>(ctx.kernalContext().cache().dynamicCloseCache(ctx.name())); + GridCacheContext ctx = getContextSafe(); + + return new IgniteFutureImpl<>(ctx.kernalContext().cache().dynamicCloseCache(cacheName)); } /** {@inheritDoc} */ @Override public boolean isClosed() { + GridCacheContext ctx = getContextSafe(); + return ctx.kernalContext().cache().context().closed(ctx); } @@ -1632,14 +1906,19 @@ public void setCacheManager(CacheManager cacheMgr) { @Override public T unwrap(Class clazz) { if (clazz.isAssignableFrom(getClass())) return (T)this; - else if (clazz.isAssignableFrom(IgniteEx.class)) + else if (clazz.isAssignableFrom(IgniteEx.class)) { + GridCacheContext ctx = getContextSafe(); + return (T)ctx.grid(); + } throw new IllegalArgumentException("Unwrapping to class is not supported: " + clazz); } /** {@inheritDoc} */ @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration lsnrCfg) { + GridCacheContext ctx = getContextSafe(); + try { CacheOperationContext opCtx = ctx.operationContextPerCall(); @@ -1652,6 +1931,8 @@ else if (clazz.isAssignableFrom(IgniteEx.class)) /** {@inheritDoc} */ @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration lsnrCfg) { + GridCacheContext ctx = getContextSafe(); + try { ctx.continuousQueries().cancelJCacheQuery(lsnrCfg); } @@ -1662,6 +1943,8 @@ else if (clazz.isAssignableFrom(IgniteEx.class)) /** {@inheritDoc} */ @Override public Iterator> iterator() { + GridCacheContext ctx = getContextSafe(); + try { return ctx.cache().igniteIterator(); } @@ -1672,6 +1955,9 @@ else if (clazz.isAssignableFrom(IgniteEx.class)) /** {@inheritDoc} */ @Override protected IgniteCache createAsyncInstance() { + GridCacheContext ctx = getContextSafe(); + IgniteInternalCache delegate = getDelegateSafe(); + return new IgniteCacheProxyImpl( ctx, delegate, @@ -1745,10 +2031,25 @@ else if (clazz.isAssignableFrom(IgniteEx.class)) private RuntimeException cacheException(Exception e) { GridFutureAdapter restartFut = this.restartFut.get(); + if (X.hasCause(e, IgniteCacheRestartingException.class)) { + IgniteCacheRestartingException restartingException = X.cause(e, IgniteCacheRestartingException.class); + + if (restartingException.restartFuture() == null) { + if (restartFut == null) + restartFut = suspend(); + + assert restartFut != null; + + throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(restartFut), cacheName); + } + else + throw restartingException; + } + if (restartFut != null) { if (X.hasCause(e, CacheStoppedException.class) || X.hasSuppressed(e, CacheStoppedException.class)) throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(restartFut), "Cache is restarting: " + - ctx.name(), e); + cacheName, e); } if (e instanceof IgniteException && X.hasCause(e, CacheException.class)) @@ -1782,7 +2083,8 @@ private void setFuture(IgniteInternalFuture fut) { * @return Internal proxy. */ @Override public GridCacheProxyImpl internalProxy() { - checkRestart(); + GridCacheContext ctx = getContextSafe(); + IgniteInternalCache delegate = getDelegateSafe(); return new GridCacheProxyImpl<>(ctx, delegate, ctx.operationContextPerCall()); } @@ -1803,11 +2105,15 @@ private void setFuture(IgniteInternalFuture fut) { /** {@inheritDoc} */ @Override public Collection lostPartitions() { + IgniteInternalCache delegate = getDelegateSafe(); + return delegate.lostPartitions(); } /** {@inheritDoc} */ @Override public void enableStatistics(boolean enabled) { + GridCacheContext ctx = getContextSafe(); + try { ctx.kernalContext().cache().enableStatistics(Collections.singleton(getName()), enabled); } @@ -1818,6 +2124,8 @@ private void setFuture(IgniteInternalFuture fut) { /** {@inheritDoc} */ @Override public void clearStatistics() { + GridCacheContext ctx = getContextSafe(); + try { ctx.kernalContext().cache().clearStatistics(Collections.singleton(getName())); } @@ -1826,6 +2134,42 @@ private void setFuture(IgniteInternalFuture fut) { } } + /** {@inheritDoc} */ + @Override public void preloadPartition(int part) { + IgniteInternalCache delegate = getDelegateSafe(); + + try { + delegate.preloadPartition(part); + } + catch (IgniteCheckedException e) { + throw cacheException(e); + } + } + + /** {@inheritDoc} */ + @Override public IgniteFuture preloadPartitionAsync(int part) { + IgniteInternalCache delegate = getDelegateSafe(); + + try { + return (IgniteFuture)createFuture(delegate.preloadPartitionAsync(part)); + } + catch (IgniteCheckedException e) { + throw cacheException(e); + } + } + + /** {@inheritDoc} */ + @Override public boolean localPreloadPartition(int part) { + IgniteInternalCache delegate = getDelegateSafe(); + + try { + return delegate.localPreloadPartition(part); + } + catch (IgniteCheckedException e) { + throw cacheException(e); + } + } + /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(ctx); @@ -1839,15 +2183,23 @@ private void setFuture(IgniteInternalFuture fut) { ctx = (GridCacheContext)in.readObject(); delegate = (IgniteInternalCache)in.readObject(); + + cacheName = ctx.name(); + + assert cacheName.equals(delegate.name()) : "ctx.name=" + cacheName + ", delegate.name=" + delegate.name(); } /** {@inheritDoc} */ @Override public IgniteFuture rebalance() { + GridCacheContext ctx = getContextSafe(); + return new IgniteFutureImpl<>(ctx.preloader().forceRebalance()); } /** {@inheritDoc} */ @Override public IgniteFuture indexReadyFuture() { + GridCacheContext ctx = getContextSafe(); + IgniteInternalFuture fut = ctx.shared().database().indexRebuildFuture(ctx.cacheId()); if (fut == null) @@ -1860,10 +2212,29 @@ private void setFuture(IgniteInternalFuture fut) { * Throws {@code IgniteCacheRestartingException} if proxy is restarting. */ public void checkRestart() { + checkRestart(false); + } + + /** + * Throws {@code IgniteCacheRestartingException} if proxy is restarting. + */ + public void checkRestart(boolean noWait) { RestartFuture currentFut = restartFut.get(); - if (currentFut != null) - currentFut.checkRestartOrAwait(); + if (currentFut != null) { + try { + if (!noWait) { + currentFut.get(1, TimeUnit.SECONDS); + + return; + } + } + catch (IgniteCheckedException ignore) { + //do nothing + } + + throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(currentFut), cacheName); + } } /** @@ -1874,26 +2245,33 @@ public boolean isRestarting() { } /** - * Restarts this cache proxy. + * Suspend this cache proxy. + * To make cache proxy active again, it's needed to restart it. */ - public boolean restart() { - RestartFuture restartFut = new RestartFuture(ctx.name()); - - RestartFuture curFut = this.restartFut.get(); - - boolean changed = this.restartFut.compareAndSet(curFut, restartFut); + public RestartFuture suspend() { + while (true) { + RestartFuture curFut = this.restartFut.get(); + + if (curFut == null) { + RestartFuture restartFut = new RestartFuture(cacheName); + + if (this.restartFut.compareAndSet(null, restartFut)) { + synchronized (this) { + if (!restartFut.isDone()) { + if (oldContext == null) { + oldContext = ctx; + delegate = null; + ctx = null; + } + } + } - if (changed && curFut != null) - restartFut.listen(new IgniteInClosure>() { - @Override public void apply(IgniteInternalFuture fut) { - if (fut.error() != null) - curFut.onDone(fut.error()); - else - curFut.onDone(); + return restartFut; } - }); - - return changed; + } + else + return curFut; + } } /** @@ -1909,19 +2287,30 @@ public void registrateFutureRestart(GridFutureAdapter fut){ /** * If proxy is already being restarted, returns future to wait on, else restarts this cache proxy. * - * @return Future to wait on, or null. + * @param cache To use for restart proxy. */ - public GridFutureAdapter opportunisticRestart() { - RestartFuture restartFut = new RestartFuture(ctx.name()); + public void opportunisticRestart(IgniteInternalCache cache) { + RestartFuture restartFut = new RestartFuture(cacheName); while (true) { - if (this.restartFut.compareAndSet(null, restartFut)) - return null; + if (this.restartFut.compareAndSet(null, restartFut)) { + onRestarted(cache.context(), cache.context().cache()); + + return; + } GridFutureAdapter curFut = this.restartFut.get(); - if (curFut != null) - return curFut; + if (curFut != null) { + try { + curFut.get(); + } + catch (IgniteCheckedException ignore) { + // Do notrhing. + } + + return; + } } } @@ -1936,12 +2325,18 @@ public void onRestarted(GridCacheContext ctx, IgniteInternalCache delegate) { assert restartFut != null; - this.ctx = ctx; - this.delegate = delegate; + synchronized (this) { + this.restartFut.compareAndSet(restartFut, null); + + this.ctx = ctx; + oldContext = null; + this.delegate = delegate; - this.restartFut.compareAndSet(restartFut, null); + restartFut.onDone(); + } - restartFut.onDone(); + assert delegate == null || cacheName.equals(delegate.name()) && cacheName.equals(ctx.name()) : + "ctx.name=" + ctx.name() + ", delegate.name=" + delegate.name() + ", cacheName=" + cacheName; } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java index cba2228f0323e..64e21e3fe5f32 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java @@ -302,11 +302,10 @@ public interface IgniteInternalCache extends Iterable> { /** * @param key Key. * @param peekModes Peek modes. - * @param plc Expiry policy if TTL should be updated. * @return Value. * @throws IgniteCheckedException If failed. */ - @Nullable public V localPeek(K key, CachePeekMode[] peekModes, @Nullable IgniteCacheExpiryPolicy plc) + @Nullable public V localPeek(K key, CachePeekMode[] peekModes) throws IgniteCheckedException; /** @@ -1818,4 +1817,27 @@ public void localLoadCache(@Nullable IgniteBiPredicate p, @Nullable Object * @return A collection of lost partitions if a cache is in recovery state. */ public Collection lostPartitions(); + + /** + * Preload cache partition. + * @param part Partition. + * @throws IgniteCheckedException If failed. + */ + public void preloadPartition(int part) throws IgniteCheckedException; + + /** + * Preload cache partition. + * @param part Partition. + * @return Future to be completed whenever preloading completes. + * @throws IgniteCheckedException If failed. + */ + public IgniteInternalFuture preloadPartitionAsync(int part) throws IgniteCheckedException; + + /** + * Preloads cache partition if it exists on local node. + * @param part Partition. + * @return {@code True} if partition was preloaded, {@code false} if it doesn't belong to local node. + * @throws IgniteCheckedException If failed. + */ + public boolean localPreloadPartition(int part) throws IgniteCheckedException; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObject.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObject.java index 8f8ceb6d256f1..9c4eeee6cceda 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObject.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObject.java @@ -48,4 +48,4 @@ public interface KeyCacheObject extends CacheObject { * @return Copy of this object with given partition set. */ public KeyCacheObject copy(int part); -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PartitionUpdateCounter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PartitionUpdateCounter.java index fe4470875b7e6..39d8d5fcc1c21 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PartitionUpdateCounter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PartitionUpdateCounter.java @@ -20,6 +20,7 @@ import java.util.TreeSet; import java.util.concurrent.atomic.AtomicLong; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.internal.util.GridLongList; import org.jetbrains.annotations.NotNull; /** @@ -180,14 +181,31 @@ private void offer(Item item) { /** * Flushes pending update counters closing all possible gaps. + * + * @return Even-length array of pairs [start, end] for each gap. */ - public synchronized void finalizeUpdateCountres() { - Item last = queue.pollLast(); + public synchronized GridLongList finalizeUpdateCounters() { + Item item = poll(); + + GridLongList gaps = null; + + while (item != null) { + if (gaps == null) + gaps = new GridLongList((queue.size() + 1) * 2); + + long start = cntr.get() + 1; + long end = item.start; - if (last != null) - update(last.start + last.delta); + gaps.add(start); + gaps.add(end); + + // Close pending ranges. + update(item.start + item.delta); + + item = poll(); + } - queue.clear(); + return gaps; } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StartCacheInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StartCacheInfo.java new file mode 100644 index 0000000000000..a5aea26453ff6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StartCacheInfo.java @@ -0,0 +1,113 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.jetbrains.annotations.Nullable; + +/** + * Specific cache information for start. + */ +public class StartCacheInfo { + /** Cache configuration for start. */ + private final CacheConfiguration startedConf; + + /** Cache descriptor for start. */ + private final DynamicCacheDescriptor desc; + + /** Near cache configuration for start. */ + private final @Nullable NearCacheConfiguration reqNearCfg; + + /** Exchange topology version in which starting happened. */ + private final AffinityTopologyVersion exchTopVer; + + /** Disable started cache after start or not. */ + private final boolean disabledAfterStart; + + /** + * @param desc Cache configuration for start. + * @param reqNearCfg Near cache configuration for start. + * @param exchTopVer Exchange topology version in which starting happened. + * @param disabledAfterStart Disable started cache after start or not. + */ + public StartCacheInfo(DynamicCacheDescriptor desc, + NearCacheConfiguration reqNearCfg, + AffinityTopologyVersion exchTopVer, boolean disabledAfterStart) { + this(desc.cacheConfiguration(), desc, reqNearCfg, exchTopVer, disabledAfterStart); + } + + /** + * @param conf Cache configuration for start. + * @param desc Cache descriptor for start. + * @param reqNearCfg Near cache configuration for start. + * @param exchTopVer Exchange topology version in which starting happened. + * @param disabledAfterStart Disable started cache after start or not. + */ + public StartCacheInfo(CacheConfiguration conf, DynamicCacheDescriptor desc, + NearCacheConfiguration reqNearCfg, + AffinityTopologyVersion exchTopVer, boolean disabledAfterStart) { + startedConf = conf; + this.desc = desc; + this.reqNearCfg = reqNearCfg; + this.exchTopVer = exchTopVer; + this.disabledAfterStart = disabledAfterStart; + } + + /** + * @return Cache configuration for start. + */ + public CacheConfiguration getStartedConfiguration() { + return startedConf; + } + + /** + * @return Cache descriptor for start. + */ + public DynamicCacheDescriptor getCacheDescriptor() { + return desc; + } + + /** + * @return Near cache configuration for start. + */ + @Nullable public NearCacheConfiguration getReqNearCfg() { + return reqNearCfg; + } + + /** + * @return Exchange topology version in which starting happened. + */ + public AffinityTopologyVersion getExchangeTopVer() { + return exchTopVer; + } + + /** + * @return Disable started cache after start or not. + */ + public boolean isDisabledAfterStart() { + return disabledAfterStart; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(StartCacheInfo.class, this); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateAckMessage.java index 7c241068231bb..f8012a7de733e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateAckMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateAckMessage.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.internal.GridDirectTransient; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.processors.query.schema.message.SchemaOperationStatusMessage; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.Message; @@ -31,6 +32,7 @@ /** * WAL state ack message (sent from participant node to coordinator). */ +@IgniteCodeGeneratingFail public class WalStateAckMessage implements Message { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateManager.java index a01e813cbcc4c..b380d97950051 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateManager.java @@ -122,6 +122,9 @@ public class WalStateManager extends GridCacheSharedManagerAdapter { /** */ private volatile WALDisableContext walDisableContext; + /** Denies or allows WAL disabling. */ + private volatile boolean prohibitDisabling; + /** * Constructor. * @@ -265,6 +268,24 @@ public void onKernalStart() { } } + /** + * Denies or allows WAL disabling with subsequent {@link #init(Collection, boolean)} call. + * + * @param val denial status. + */ + public void prohibitWALDisabling(boolean val) { + prohibitDisabling = val; + } + + /** + * Reports whether WAL disabling with subsequent {@link #init(Collection, boolean)} is denied. + * + * @return denial status. + */ + public boolean prohibitWALDisabling() { + return prohibitDisabling; + } + /** * Initiate WAL mode change operation. * @@ -273,6 +294,9 @@ public void onKernalStart() { * @return Future completed when operation finished. */ public IgniteInternalFuture init(Collection cacheNames, boolean enabled) { + if (!enabled && prohibitDisabling) + return errorFuture("WAL disabling is prohibited."); + if (F.isEmpty(cacheNames)) return errorFuture("Cache names cannot be empty."); @@ -363,9 +387,12 @@ else if (!F.eq(grpDesc.deploymentId(), curGrpDesc.deploymentId())) { * in OWNING state if such feature is enabled. * * @param topVer Topology version. + * @param changedBaseline The exchange is caused by Baseline Topology change. */ - public void changeLocalStatesOnExchangeDone(AffinityTopologyVersion topVer) { - if (!IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING, false)) + public void changeLocalStatesOnExchangeDone(AffinityTopologyVersion topVer, boolean changedBaseline) { + if (changedBaseline + && IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_PENDING_TX_TRACKER_ENABLED) + || !IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING, false)) return; Set grpsToEnableWal = new HashSet<>(); @@ -449,7 +476,7 @@ else if (!grp.localWalEnabled()) public void onGroupRebalanceFinished(int grpId, AffinityTopologyVersion topVer) { TemporaryDisabledWal session0 = tmpDisabledWal; - if (session0 == null || !session0.topVer.equals(topVer)) + if (session0 == null || session0.topVer.compareTo(topVer) > 0) return; session0.remainingGrps.remove(grpId); @@ -480,9 +507,11 @@ public void onGroupRebalanceFinished(int grpId, AffinityTopologyVersion topVer) for (Integer grpId0 : session0.disabledGrps) { CacheGroupContext grp = cctx.cache().cacheGroup(grpId0); - assert grp != null; + if (grp != null) + grp.topology().ownMoving(topVer); + else if (log.isDebugEnabled()) + log.debug("Cache group was destroyed before checkpoint finished, [grpId=" + grpId0 + ']'); - grp.topology().ownMoving(session0.topVer); } cctx.exchange().refreshPartitions(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataFileStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataFileStore.java index 662839c6f99f1..bee40994bc63b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataFileStore.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataFileStore.java @@ -18,13 +18,17 @@ import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.util.concurrent.ConcurrentMap; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.binary.BinaryMetadata; import org.apache.ignite.internal.binary.BinaryUtils; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.jetbrains.annotations.Nullable; @@ -45,6 +49,9 @@ class BinaryMetadataFileStore { /** */ private final GridKernalContext ctx; + /** */ + private FileIOFactory fileIOFactory; + /** */ private final IgniteLogger log; @@ -67,6 +74,8 @@ class BinaryMetadataFileStore { if (!CU.isPersistenceEnabled(ctx.config())) return; + fileIOFactory = ctx.config().getDataStorageConfiguration().getFileIOFactory(); + if (binaryMetadataFileStoreDir != null) workDir = binaryMetadataFileStoreDir; else { @@ -91,17 +100,27 @@ void writeMetadata(BinaryMetadata binMeta) { return; try { - File file = new File(workDir, Integer.toString(binMeta.typeId()) + ".bin"); + File file = new File(workDir, binMeta.typeId() + ".bin"); + + byte[] marshalled = U.marshal(ctx, binMeta); - try(FileOutputStream out = new FileOutputStream(file, false)) { - byte[] marshalled = U.marshal(ctx, binMeta); + try (final FileIO out = fileIOFactory.create(file)) { + int left = marshalled.length; + while ((left -= out.writeFully(marshalled, 0, Math.min(marshalled.length, left))) > 0) + ; - out.write(marshalled); + out.force(); } } catch (Exception e) { - U.warn(log, "Failed to save metadata for typeId: " + binMeta.typeId() + - "; exception was thrown: " + e.getMessage()); + final String msg = "Failed to save metadata for typeId: " + binMeta.typeId() + + "; exception was thrown: " + e.getMessage(); + + U.error(log, msg); + + ctx.failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); + + throw new IgniteException(msg, e); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataKey.java index 32ab2a09ecbb4..352754069927b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataKey.java @@ -25,7 +25,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; /** - * Key for binary meta data. + * Key for binary metadata. */ public class BinaryMetadataKey extends GridCacheUtilityKey implements Externalizable { /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java index 38450dfec5c78..1c2f6f0e77f84 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java @@ -16,8 +16,12 @@ */ package org.apache.ignite.internal.processors.cache.binary; +import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Queue; +import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; @@ -42,6 +46,7 @@ import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; import org.jetbrains.annotations.Nullable; @@ -86,6 +91,9 @@ final class BinaryMetadataTransport { /** */ private final ConcurrentMap clientReqSyncMap = new ConcurrentHashMap<>(); + /** */ + private final ConcurrentMap> schemaWaitFuts = new ConcurrentHashMap<>(); + /** */ private volatile boolean stopping; @@ -206,6 +214,21 @@ GridFutureAdapter awaitMetadataUpdate(int typeId, int ver) return resFut; } + /** + * Await specific schema update. + * @param typeId Type id. + * @param schemaId Schema id. + * @return Future which will be completed when schema is received. + */ + GridFutureAdapter awaitSchemaUpdate(int typeId, int schemaId) { + GridFutureAdapter fut = new GridFutureAdapter<>(); + + // Use version for schemaId. + GridFutureAdapter oldFut = schemaWaitFuts.putIfAbsent(new SyncKey(typeId, schemaId), fut); + + return oldFut == null ? fut : oldFut; + } + /** * Allows client node to request latest version of binary metadata for a given typeId from the cluster * in case client is able to detect that it has obsolete metadata in its local cache. @@ -259,6 +282,13 @@ private final class MetadataUpdateProposedListener implements CustomEventListene /** {@inheritDoc} */ @Override public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, MetadataUpdateProposedMessage msg) { + if (log.isDebugEnabled()) + log.debug("Received MetadataUpdateProposedListener [typeId=" + msg.typeId() + + ", typeName=" + msg.metadata().typeName() + + ", pendingVer=" + msg.pendingVersion() + + ", acceptedVer=" + msg.acceptedVersion() + + ", schemasCnt=" + msg.metadata().schemas().size() + ']'); + int typeId = msg.typeId(); BinaryMetadataHolder holder = metaLocCache.get(typeId); @@ -277,20 +307,23 @@ private final class MetadataUpdateProposedListener implements CustomEventListene acceptedVer = 0; } - if (log.isDebugEnabled()) - log.debug("Versions are stamped on coordinator" + - " [typeId=" + typeId + - ", pendingVer=" + pendingVer + - ", acceptedVer=" + acceptedVer + "]" - ); - msg.pendingVersion(pendingVer); msg.acceptedVersion(acceptedVer); BinaryMetadata locMeta = holder != null ? holder.metadata() : null; try { - BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(locMeta, msg.metadata()); + Set changedSchemas = new LinkedHashSet<>(); + + BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(locMeta, msg.metadata(), changedSchemas); + + if (log.isDebugEnabled()) + log.debug("Versions are stamped on coordinator" + + " [typeId=" + typeId + + ", changedSchemas=" + changedSchemas + + ", pendingVer=" + pendingVer + + ", acceptedVer=" + acceptedVer + "]" + ); msg.metadata(mergedMeta); } @@ -358,8 +391,10 @@ private final class MetadataUpdateProposedListener implements CustomEventListene if (!msg.rejected()) { BinaryMetadata locMeta = holder != null ? holder.metadata() : null; + Set changedSchemas = new LinkedHashSet<>(); + try { - BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(locMeta, msg.metadata()); + BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(locMeta, msg.metadata(), changedSchemas); BinaryMetadataHolder newHolder = new BinaryMetadataHolder(mergedMeta, pendingVer, acceptedVer); @@ -382,7 +417,8 @@ private final class MetadataUpdateProposedListener implements CustomEventListene } else { if (log.isDebugEnabled()) - log.debug("Updated metadata on server node: " + newHolder); + log.debug("Updated metadata on server node [holder=" + newHolder + + ", changedSchemas=" + changedSchemas + ']'); metaLocCache.put(typeId, newHolder); } @@ -463,7 +499,7 @@ private final class MetadataUpdateAcceptedListener implements CustomEventListene if (oldAcceptedVer >= newAcceptedVer) { if (log.isDebugEnabled()) log.debug("Marking ack as duplicate [holder=" + holder + - ", newAcceptedVer: " + newAcceptedVer + ']'); + ", newAcceptedVer=" + newAcceptedVer + ']'); //this is duplicate ack msg.duplicated(true); @@ -481,8 +517,26 @@ private final class MetadataUpdateAcceptedListener implements CustomEventListene GridFutureAdapter fut = syncMap.get(new SyncKey(typeId, newAcceptedVer)); + holder = metaLocCache.get(typeId); + if (log.isDebugEnabled()) - log.debug("Completing future " + fut + " for " + metaLocCache.get(typeId)); + log.debug("Completing future " + fut + " for " + holder); + + if (!schemaWaitFuts.isEmpty()) { + Iterator>> iter = schemaWaitFuts.entrySet().iterator(); + + while (iter.hasNext()) { + Map.Entry> entry = iter.next(); + + SyncKey key = entry.getKey(); + + if (key.typeId() == typeId && holder.metadata().hasSchema(key.version())) { + entry.getValue().onDone(); + + iter.remove(); + } + } + } if (fut != null) fut.onDone(MetadataUpdateResult.createSuccessfulResult()); @@ -527,6 +581,11 @@ private final class MetadataUpdateResultFuture extends GridFutureAdapter reconnectFut) throws IgniteCheckedException { + this.reconnectFut = reconnectFut; + if (transport != null) transport.onDisconnected(); + + binaryContext().unregisterUserTypeDescriptors(); + binaryContext().unregisterBinarySchemas(); + + metadataLocCache.clear(); + } + + /** {@inheritDoc} */ + @Override public IgniteInternalFuture onReconnected(boolean clusterRestarted) throws IgniteCheckedException { + this.reconnectFut = null; + + return super.onReconnected(clusterRestarted); } /** {@inheritDoc} */ @@ -452,11 +475,20 @@ public GridBinaryMarshaller marshaller() { BinaryMetadata oldMeta = metaHolder != null ? metaHolder.metadata() : null; - BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0); + Set changedSchemas = new LinkedHashSet<>(); + + BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0, changedSchemas); - //metadata requested to be added is exactly the same as already presented in the cache - if (mergedMeta == oldMeta) + if (mergedMeta == oldMeta) { + // Metadata locally is up-to-date. Waiting for updating metadata in an entire cluster, if necessary. + if (metaHolder.pendingVersion() != metaHolder.acceptedVersion()) { + GridFutureAdapter fut = + transport.awaitMetadataUpdate(typeId, metaHolder.pendingVersion()); + + fut.get(); + } return; + } if (failIfUnregistered) throw new UnregisteredBinaryTypeException( @@ -466,7 +498,24 @@ public GridBinaryMarshaller marshaller() { "dev-list.", typeId, mergedMeta); - MetadataUpdateResult res = transport.requestMetadataUpdate(mergedMeta).get(); + long t0 = System.nanoTime(); + + GridFutureAdapter fut = transport.requestMetadataUpdate(mergedMeta); + + MetadataUpdateResult res = fut.get(); + + if (log.isDebugEnabled()) { + IgniteInternalTx tx = ctx.cache().context().tm().tx(); + + log.debug("Completed metadata update [typeId=" + typeId + + ", typeName=" + newMeta.typeName() + + ", changedSchemas=" + changedSchemas + + ", waitTime=" + MILLISECONDS.convert(System.nanoTime() - t0, NANOSECONDS) + "ms" + + ", holder=" + metaHolder + + ", fut=" + fut + + ", tx=" + CU.txString(tx) + + ']'); + } assert res != null; @@ -474,7 +523,7 @@ public GridBinaryMarshaller marshaller() { throw res.error(); } catch (IgniteCheckedException e) { - throw new BinaryObjectException("Failed to update meta data for type: " + newMeta.typeName(), e); + throw new BinaryObjectException("Failed to update metadata for type: " + newMeta.typeName(), e); } } @@ -513,13 +562,15 @@ public GridBinaryMarshaller marshaller() { /** * @param typeId Type ID. - * @return Meta data. + * @return Metadata. * @throws IgniteException In case of error. */ @Nullable public BinaryMetadata metadata0(final int typeId) { BinaryMetadataHolder holder = metadataLocCache.get(typeId); - if (holder == null) { + IgniteThread curThread = IgniteThread.current(); + + if (holder == null && (curThread == null || !curThread.isForbiddenToRequestBinaryMetadata())) { if (ctx.clientNode()) { try { transport.requestUpToDateMetadata(typeId).get(); @@ -533,7 +584,7 @@ public GridBinaryMarshaller marshaller() { } if (holder != null) { - if (IgniteThread.current() instanceof IgniteDiscoveryThread) + if (curThread instanceof IgniteDiscoveryThread || (curThread != null && curThread.isForbiddenToRequestBinaryMetadata())) return holder.metadata(); if (holder.pendingVersion() - holder.acceptedVersion() > 0) { @@ -541,9 +592,9 @@ public GridBinaryMarshaller marshaller() { if (log.isDebugEnabled() && !fut.isDone()) log.debug("Waiting for update for" + - " [typeId=" + typeId + - ", pendingVer=" + holder.pendingVersion() + - ", acceptedVer=" + holder.acceptedVersion() + "]"); + " [typeId=" + typeId + + ", pendingVer=" + holder.pendingVersion() + + ", acceptedVer=" + holder.acceptedVersion() + "]"); try { fut.get(); @@ -565,40 +616,104 @@ public GridBinaryMarshaller marshaller() { if (ctx.clientNode()) { if (holder == null || !holder.metadata().hasSchema(schemaId)) { + if (log.isDebugEnabled()) + log.debug("Waiting for client metadata update" + + " [typeId=" + typeId + + ", schemaId=" + schemaId + + ", pendingVer=" + (holder == null ? "NA" : holder.pendingVersion()) + + ", acceptedVer=" + (holder == null ? "NA" :holder.acceptedVersion()) + ']'); + try { transport.requestUpToDateMetadata(typeId).get(); - - holder = metadataLocCache.get(typeId); } catch (IgniteCheckedException ignored) { // No-op. } + + holder = metadataLocCache.get(typeId); + + IgniteFuture reconnectFut0 = reconnectFut; + + if (holder == null && reconnectFut0 != null) + throw new IgniteClientDisconnectedException(reconnectFut0, "Client node disconnected."); + + if (log.isDebugEnabled()) + log.debug("Finished waiting for client metadata update" + + " [typeId=" + typeId + + ", schemaId=" + schemaId + + ", pendingVer=" + (holder == null ? "NA" : holder.pendingVersion()) + + ", acceptedVer=" + (holder == null ? "NA" :holder.acceptedVersion()) + ']'); } } - else if (holder != null) { - if (IgniteThread.current() instanceof IgniteDiscoveryThread) + else { + if (holder != null && IgniteThread.current() instanceof IgniteDiscoveryThread) return holder.metadata().wrap(binaryCtx); + else if (holder != null && (holder.pendingVersion() - holder.acceptedVersion() > 0)) { + if (log.isDebugEnabled()) + log.debug("Waiting for metadata update" + + " [typeId=" + typeId + + ", schemaId=" + schemaId + + ", pendingVer=" + holder.pendingVersion() + + ", acceptedVer=" + holder.acceptedVersion() + ']'); - if (holder.pendingVersion() - holder.acceptedVersion() > 0) { - GridFutureAdapter fut = transport.awaitMetadataUpdate( - typeId, - holder.pendingVersion()); + long t0 = System.nanoTime(); - if (log.isDebugEnabled() && !fut.isDone()) - log.debug("Waiting for update for" + - " [typeId=" + typeId - + ", schemaId=" + schemaId - + ", pendingVer=" + holder.pendingVersion() - + ", acceptedVer=" + holder.acceptedVersion() + "]"); + GridFutureAdapter fut = transport.awaitMetadataUpdate( + typeId, + holder.pendingVersion()); try { fut.get(); } + catch (IgniteCheckedException e) { + log.error("Failed to wait for metadata update [typeId=" + typeId + ", schemaId=" + schemaId + ']', e); + } + + if (log.isDebugEnabled()) + log.debug("Finished waiting for metadata update" + + " [typeId=" + typeId + + ", waitTime=" + NANOSECONDS.convert(System.nanoTime() - t0, MILLISECONDS) + "ms" + + ", schemaId=" + schemaId + + ", pendingVer=" + holder.pendingVersion() + + ", acceptedVer=" + holder.acceptedVersion() + ']'); + + holder = metadataLocCache.get(typeId); + } + else if (holder == null || !holder.metadata().hasSchema(schemaId)) { + // Last resort waiting. + U.warn(log, + "Schema is missing while no metadata updates are in progress " + + "(will wait for schema update within timeout defined by IGNITE_BINARY_META_UPDATE_TIMEOUT system property)" + + " [typeId=" + typeId + + ", missingSchemaId=" + schemaId + + ", pendingVer=" + (holder == null ? "NA" : holder.pendingVersion()) + + ", acceptedVer=" + (holder == null ? "NA" : holder.acceptedVersion()) + + ", binMetaUpdateTimeout=" + waitSchemaTimeout +']'); + + long t0 = System.nanoTime(); + + GridFutureAdapter fut = transport.awaitSchemaUpdate(typeId, schemaId); + + try { + fut.get(waitSchemaTimeout); + } + catch (IgniteFutureTimeoutCheckedException e) { + log.error("Timed out while waiting for schema update [typeId=" + typeId + ", schemaId=" + + schemaId + ']'); + } catch (IgniteCheckedException ignored) { // No-op. } holder = metadataLocCache.get(typeId); + + if (log.isDebugEnabled() && holder != null && holder.metadata().hasSchema(schemaId)) + log.debug("Found the schema after wait" + + " [typeId=" + typeId + + ", waitTime=" + NANOSECONDS.convert(System.nanoTime() - t0, MILLISECONDS) + "ms" + + ", schemaId=" + schemaId + + ", pendingVer=" + holder.pendingVersion() + + ", acceptedVer=" + holder.acceptedVersion() + ']'); } } @@ -903,7 +1018,7 @@ else if (type == BinaryObjectImpl.TYPE_BINARY_ENUM) if ((res = validateBinaryConfiguration(rmtNode)) != null) return res; - return validateBinaryMetadata(rmtNode.id(), (Map) discoData.joiningNodeData()); + return validateBinaryMetadata(rmtNode.id(), (Map)discoData.joiningNodeData()); } /** */ @@ -1070,4 +1185,75 @@ private IgniteNodeValidationResult validateBinaryMetadata(UUID rmtNodeId, Map listeners; + + /** + * @param metaHnd Meta handler. + * @param igniteCfg Ignite config. + * @param log Logger. + */ + public TestBinaryContext(BinaryMetadataHandler metaHnd, IgniteConfiguration igniteCfg, + IgniteLogger log) { + super(metaHnd, igniteCfg, log); + } + + /** {@inheritDoc} */ + @Nullable @Override public BinaryType metadata(int typeId) throws BinaryObjectException { + BinaryType metadata = super.metadata(typeId); + + if (listeners != null) { + for (TestBinaryContextListener listener : listeners) + listener.onAfterMetadataRequest(typeId, metadata); + } + + return metadata; + } + + /** {@inheritDoc} */ + @Override public void updateMetadata(int typeId, BinaryMetadata meta, + boolean failIfUnregistered) throws BinaryObjectException { + if (listeners != null) { + for (TestBinaryContextListener listener : listeners) + listener.onBeforeMetadataUpdate(typeId, meta); + } + + super.updateMetadata(typeId, meta, failIfUnregistered); + } + + /** */ + public interface TestBinaryContextListener { + /** + * @param typeId Type id. + * @param type Type. + */ + void onAfterMetadataRequest(int typeId, BinaryType type); + + /** + * @param typeId Type id. + * @param metadata Metadata. + */ + void onBeforeMetadataUpdate(int typeId, BinaryMetadata metadata); + } + + /** + * @param lsnr Listener. + */ + public void addListener(TestBinaryContextListener lsnr) { + if (listeners == null) + listeners = new ArrayList<>(); + + if (!listeners.contains(lsnr)) + listeners.add(lsnr); + } + + /** */ + public void clearAllListener() { + if (listeners != null) + listeners.clear(); + } + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java index 84e32e1b3d7cc..c465314c9170b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataUpdateProposedMessage.java @@ -77,22 +77,22 @@ public final class MetadataUpdateProposedMessage implements DiscoveryCustomMessa /** */ private final IgniteUuid id = IgniteUuid.randomUuid(); - /** */ + /** Node UUID which initiated metadata update. */ private final UUID origNodeId; /** */ private BinaryMetadata metadata; - /** */ + /** Metadata type id. */ private final int typeId; - /** */ + /** Metadata version which is pending for update. */ private int pendingVer; - /** */ + /** Metadata version which is already accepted by entire cluster. */ private int acceptedVer; - /** */ + /** Message acceptance status. */ private ProposalStatus status = ProposalStatus.SUCCESSFUL; /** */ @@ -222,7 +222,7 @@ public int typeId() { return typeId; } - /** */ + /** Message acceptance status. */ private enum ProposalStatus { /** */ SUCCESSFUL, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index c092132192c74..c420aeb4f0491 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -213,37 +213,37 @@ public List nearVersions() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeCollection("nearKeys", nearKeys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeCollection("nearVers", nearVers, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 6: - if (!writer.writeMessage("topVer", topVer)) + case 7: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeLong("ttl", ttl)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeCollection("vers", vers, MessageCollectionItemType.MSG)) return false; @@ -265,7 +265,7 @@ public List nearVersions() { return false; switch (reader.state()) { - case 3: + case 4: keys = reader.readCollection("keys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -273,7 +273,7 @@ public List nearVersions() { reader.incrementState(); - case 4: + case 5: nearKeys = reader.readCollection("nearKeys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -281,7 +281,7 @@ public List nearVersions() { reader.incrementState(); - case 5: + case 6: nearVers = reader.readCollection("nearVers", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -289,15 +289,15 @@ public List nearVersions() { reader.incrementState(); - case 6: - topVer = reader.readMessage("topVer"); + case 7: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 7: + case 8: ttl = reader.readLong("ttl"); if (!reader.isLastRead()) @@ -305,7 +305,7 @@ public List nearVersions() { reader.incrementState(); - case 8: + case 9: vers = reader.readCollection("vers", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -325,7 +325,7 @@ public List nearVersions() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 9; + return 10; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryRequest.java index 45d1f1a31bf5a..90ce2344d77ab 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryRequest.java @@ -148,37 +148,37 @@ public boolean system() { } switch (writer.state()) { - case 7: + case 8: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeIgniteUuid("miniId", miniId)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeBoolean("nearTxCheck", nearTxCheck)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeMessage("nearXidVer", nearXidVer)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeBoolean("sys", sys)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeInt("txNum", txNum)) return false; @@ -200,7 +200,7 @@ public boolean system() { return false; switch (reader.state()) { - case 7: + case 8: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -208,7 +208,7 @@ public boolean system() { reader.incrementState(); - case 8: + case 9: miniId = reader.readIgniteUuid("miniId"); if (!reader.isLastRead()) @@ -216,7 +216,7 @@ public boolean system() { reader.incrementState(); - case 9: + case 10: nearTxCheck = reader.readBoolean("nearTxCheck"); if (!reader.isLastRead()) @@ -224,7 +224,7 @@ public boolean system() { reader.incrementState(); - case 10: + case 11: nearXidVer = reader.readMessage("nearXidVer"); if (!reader.isLastRead()) @@ -232,7 +232,7 @@ public boolean system() { reader.incrementState(); - case 11: + case 12: sys = reader.readBoolean("sys"); if (!reader.isLastRead()) @@ -240,7 +240,7 @@ public boolean system() { reader.incrementState(); - case 12: + case 13: txNum = reader.readInt("txNum"); if (!reader.isLastRead()) @@ -260,7 +260,7 @@ public boolean system() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 13; + return 14; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryResponse.java index a9ac26ba4b49c..1ef44a8f21f6b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryResponse.java @@ -129,19 +129,19 @@ public boolean success() { } switch (writer.state()) { - case 7: + case 8: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeIgniteUuid("miniId", miniId)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeBoolean("success", success)) return false; @@ -163,7 +163,7 @@ public boolean success() { return false; switch (reader.state()) { - case 7: + case 8: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -171,7 +171,7 @@ public boolean success() { reader.incrementState(); - case 8: + case 9: miniId = reader.readIgniteUuid("miniId"); if (!reader.isLastRead()) @@ -179,7 +179,7 @@ public boolean success() { reader.incrementState(); - case 9: + case 10: success = reader.readBoolean("success"); if (!reader.isLastRead()) @@ -199,7 +199,7 @@ public boolean success() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 10; + return 11; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java index fc209aaa956f0..8536e480489b5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java @@ -161,25 +161,25 @@ int keysCount() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeByteArray("candsByIdxBytes", candsByIdxBytes)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeCollection("committedVers", committedVers, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeCollection("rolledbackVers", rolledbackVers, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeMessage("ver", ver)) return false; @@ -201,7 +201,7 @@ int keysCount() { return false; switch (reader.state()) { - case 3: + case 4: candsByIdxBytes = reader.readByteArray("candsByIdxBytes"); if (!reader.isLastRead()) @@ -209,7 +209,7 @@ int keysCount() { reader.incrementState(); - case 4: + case 5: committedVers = reader.readCollection("committedVers", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -217,7 +217,7 @@ int keysCount() { reader.incrementState(); - case 5: + case 6: rolledbackVers = reader.readCollection("rolledbackVers", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -225,7 +225,7 @@ int keysCount() { reader.incrementState(); - case 6: + case 7: ver = reader.readMessage("ver"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java index ff636c7c9a9a2..b07451a6a2091 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java @@ -368,6 +368,8 @@ public void removeExplicitNodeLocks(UUID nodeId) throws GridCacheEntryRemovedExc GridCacheMvccCandidate doomed; + GridCacheVersion deferredDelVer; + CacheObject val; lockEntry(); @@ -406,11 +408,22 @@ public void removeExplicitNodeLocks(UUID nodeId) throws GridCacheEntryRemovedExc } val = this.val; + + deferredDelVer = this.ver; } finally { unlockEntry(); } + if (val == null) { + boolean deferred = cctx.deferredDelete() && !detached() && !isInternal(); + + if (deferred) { + if (deferredDelVer != null) + cctx.onDeferredDelete(this, deferredDelVer); + } + } + if (log.isDebugEnabled()) log.debug("Removed lock candidate from entry [doomed=" + doomed + ", owner=" + owner + ", prev=" + prev + ", entry=" + this + ']'); @@ -705,11 +718,6 @@ public void recheck() { } } - /** {@inheritDoc} */ - @Override public final void txUnlock(IgniteInternalTx tx) throws GridCacheEntryRemovedException { - removeLock(tx.xidVersion()); - } - /** * @param emptyBefore Empty flag before operation. * @param emptyAfter Empty flag after operation. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index 25a557c324817..ca78763fc2148 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -366,79 +366,79 @@ public long timeout() { } switch (writer.state()) { - case 7: + case 8: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeBoolean("isInTx", isInTx)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeBoolean("isInvalidate", isInvalidate)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeBoolean("isRead", isRead)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeMessage("nearXidVer", nearXidVer)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeUuid("nodeId", nodeId)) return false; writer.incrementState(); - case 16: + case 17: if (!writer.writeBooleanArray("retVals", retVals)) return false; writer.incrementState(); - case 17: + case 18: if (!writer.writeLong("threadId", threadId)) return false; writer.incrementState(); - case 18: + case 19: if (!writer.writeLong("timeout", timeout)) return false; writer.incrementState(); - case 19: + case 20: if (!writer.writeInt("txSize", txSize)) return false; @@ -460,7 +460,7 @@ public long timeout() { return false; switch (reader.state()) { - case 7: + case 8: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -468,7 +468,7 @@ public long timeout() { reader.incrementState(); - case 8: + case 9: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -476,7 +476,7 @@ public long timeout() { reader.incrementState(); - case 9: + case 10: isInTx = reader.readBoolean("isInTx"); if (!reader.isLastRead()) @@ -484,7 +484,7 @@ public long timeout() { reader.incrementState(); - case 10: + case 11: isInvalidate = reader.readBoolean("isInvalidate"); if (!reader.isLastRead()) @@ -492,7 +492,7 @@ public long timeout() { reader.incrementState(); - case 11: + case 12: isRead = reader.readBoolean("isRead"); if (!reader.isLastRead()) @@ -500,7 +500,7 @@ public long timeout() { reader.incrementState(); - case 12: + case 13: byte isolationOrd; isolationOrd = reader.readByte("isolation"); @@ -512,7 +512,7 @@ public long timeout() { reader.incrementState(); - case 13: + case 14: keys = reader.readCollection("keys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -520,7 +520,7 @@ public long timeout() { reader.incrementState(); - case 14: + case 15: nearXidVer = reader.readMessage("nearXidVer"); if (!reader.isLastRead()) @@ -528,7 +528,7 @@ public long timeout() { reader.incrementState(); - case 15: + case 16: nodeId = reader.readUuid("nodeId"); if (!reader.isLastRead()) @@ -536,7 +536,7 @@ public long timeout() { reader.incrementState(); - case 16: + case 17: retVals = reader.readBooleanArray("retVals"); if (!reader.isLastRead()) @@ -544,7 +544,7 @@ public long timeout() { reader.incrementState(); - case 17: + case 18: threadId = reader.readLong("threadId"); if (!reader.isLastRead()) @@ -552,7 +552,7 @@ public long timeout() { reader.incrementState(); - case 18: + case 19: timeout = reader.readLong("timeout"); if (!reader.isLastRead()) @@ -560,7 +560,7 @@ public long timeout() { reader.incrementState(); - case 19: + case 20: txSize = reader.readInt("txSize"); if (!reader.isLastRead()) @@ -580,7 +580,7 @@ public long timeout() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 20; + return 21; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index 4b21896b1c051..2d4de9c8156eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -221,19 +221,19 @@ protected int valuesSize() { } switch (writer.state()) { - case 7: + case 8: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeCollection("vals", vals, MessageCollectionItemType.MSG)) return false; @@ -255,7 +255,7 @@ protected int valuesSize() { return false; switch (reader.state()) { - case 7: + case 8: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -263,7 +263,7 @@ protected int valuesSize() { reader.incrementState(); - case 8: + case 9: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -271,7 +271,7 @@ protected int valuesSize() { reader.incrementState(); - case 9: + case 10: vals = reader.readCollection("vals", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -291,7 +291,7 @@ protected int valuesSize() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 10; + return 11; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java index ea9336b2a55e3..a1af470c56deb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java @@ -325,85 +325,85 @@ public boolean replyRequired() { } switch (writer.state()) { - case 7: + case 8: if (!writer.writeMessage("baseVer", baseVer)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeBoolean("commit", commit)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeMessage("commitVer", commitVer)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeBoolean("invalidate", invalidate)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeByte("plc", plc)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeByte("syncMode", syncMode != null ? (byte)syncMode.ordinal() : -1)) return false; writer.incrementState(); - case 16: + case 17: if (!writer.writeBoolean("sys", sys)) return false; writer.incrementState(); - case 17: + case 18: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 18: + case 19: if (!writer.writeLong("threadId", threadId)) return false; writer.incrementState(); - case 19: - if (!writer.writeMessage("topVer", topVer)) + case 20: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 20: + case 21: if (!writer.writeInt("txSize", txSize)) return false; @@ -425,7 +425,7 @@ public boolean replyRequired() { return false; switch (reader.state()) { - case 7: + case 8: baseVer = reader.readMessage("baseVer"); if (!reader.isLastRead()) @@ -433,7 +433,7 @@ public boolean replyRequired() { reader.incrementState(); - case 8: + case 9: commit = reader.readBoolean("commit"); if (!reader.isLastRead()) @@ -441,7 +441,7 @@ public boolean replyRequired() { reader.incrementState(); - case 9: + case 10: commitVer = reader.readMessage("commitVer"); if (!reader.isLastRead()) @@ -449,7 +449,7 @@ public boolean replyRequired() { reader.incrementState(); - case 10: + case 11: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -457,7 +457,7 @@ public boolean replyRequired() { reader.incrementState(); - case 11: + case 12: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -465,7 +465,7 @@ public boolean replyRequired() { reader.incrementState(); - case 12: + case 13: invalidate = reader.readBoolean("invalidate"); if (!reader.isLastRead()) @@ -473,7 +473,7 @@ public boolean replyRequired() { reader.incrementState(); - case 13: + case 14: plc = reader.readByte("plc"); if (!reader.isLastRead()) @@ -481,7 +481,7 @@ public boolean replyRequired() { reader.incrementState(); - case 14: + case 15: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -489,7 +489,7 @@ public boolean replyRequired() { reader.incrementState(); - case 15: + case 16: byte syncModeOrd; syncModeOrd = reader.readByte("syncMode"); @@ -501,7 +501,7 @@ public boolean replyRequired() { reader.incrementState(); - case 16: + case 17: sys = reader.readBoolean("sys"); if (!reader.isLastRead()) @@ -509,7 +509,7 @@ public boolean replyRequired() { reader.incrementState(); - case 17: + case 18: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -517,7 +517,7 @@ public boolean replyRequired() { reader.incrementState(); - case 18: + case 19: threadId = reader.readLong("threadId"); if (!reader.isLastRead()) @@ -525,15 +525,15 @@ public boolean replyRequired() { reader.incrementState(); - case 19: - topVer = reader.readMessage("topVer"); + case 20: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 20: + case 21: txSize = reader.readInt("txSize"); if (!reader.isLastRead()) @@ -553,7 +553,7 @@ public boolean replyRequired() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 21; + return 22; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java index c36e6336d4f7c..5fdf970bc0f8d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java @@ -145,25 +145,25 @@ public IgniteUuid futureId() { } switch (writer.state()) { - case 2: + case 3: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 3: + case 4: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeInt("part", part)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeMessage("txId", txId)) return false; @@ -185,7 +185,7 @@ public IgniteUuid futureId() { return false; switch (reader.state()) { - case 2: + case 3: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -193,7 +193,7 @@ public IgniteUuid futureId() { reader.incrementState(); - case 3: + case 4: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -201,7 +201,7 @@ public IgniteUuid futureId() { reader.incrementState(); - case 4: + case 5: part = reader.readInt("part"); if (!reader.isLastRead()) @@ -209,7 +209,7 @@ public IgniteUuid futureId() { reader.incrementState(); - case 5: + case 6: txId = reader.readMessage("txId"); if (!reader.isLastRead()) @@ -229,7 +229,7 @@ public IgniteUuid futureId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 6; + return 7; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index a5aa0d838935a..96eeee20b4b71 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -505,79 +505,79 @@ private boolean isFlag(int mask) { } switch (writer.state()) { - case 7: + case 8: if (!writer.writeByte("concurrency", concurrency != null ? (byte)concurrency.ordinal() : -1)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeCollection("dhtVerKeys", dhtVerKeys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeCollection("dhtVerVals", dhtVerVals, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeByte("plc", plc)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeCollection("reads", reads, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeLong("threadId", threadId)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeLong("timeout", timeout)) return false; writer.incrementState(); - case 16: + case 17: if (!writer.writeMap("txNodesMsg", txNodesMsg, MessageCollectionItemType.UUID, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 17: + case 18: if (!writer.writeInt("txSize", txSize)) return false; writer.incrementState(); - case 18: + case 19: if (!writer.writeMessage("writeVer", writeVer)) return false; writer.incrementState(); - case 19: + case 20: if (!writer.writeCollection("writes", writes, MessageCollectionItemType.MSG)) return false; @@ -599,7 +599,7 @@ private boolean isFlag(int mask) { return false; switch (reader.state()) { - case 7: + case 8: byte concurrencyOrd; concurrencyOrd = reader.readByte("concurrency"); @@ -611,7 +611,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 8: + case 9: dhtVerKeys = reader.readCollection("dhtVerKeys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -619,7 +619,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 9: + case 10: dhtVerVals = reader.readCollection("dhtVerVals", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -627,7 +627,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 10: + case 11: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -635,7 +635,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 11: + case 12: byte isolationOrd; isolationOrd = reader.readByte("isolation"); @@ -647,7 +647,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 12: + case 13: plc = reader.readByte("plc"); if (!reader.isLastRead()) @@ -655,7 +655,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 13: + case 14: reads = reader.readCollection("reads", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -663,7 +663,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 14: + case 15: threadId = reader.readLong("threadId"); if (!reader.isLastRead()) @@ -671,7 +671,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 15: + case 16: timeout = reader.readLong("timeout"); if (!reader.isLastRead()) @@ -679,7 +679,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 16: + case 17: txNodesMsg = reader.readMap("txNodesMsg", MessageCollectionItemType.UUID, MessageCollectionItemType.MSG, false); if (!reader.isLastRead()) @@ -687,7 +687,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 17: + case 18: txSize = reader.readInt("txSize"); if (!reader.isLastRead()) @@ -695,7 +695,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 18: + case 19: writeVer = reader.readMessage("writeVer"); if (!reader.isLastRead()) @@ -703,7 +703,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 19: + case 20: writes = reader.readCollection("writes", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -723,7 +723,7 @@ private boolean isFlag(int mask) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 20; + return 21; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java index 58e94926ca9e8..c26880e10fed4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java @@ -178,19 +178,19 @@ public boolean isRollback() { } switch (writer.state()) { - case 7: + case 8: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeInt("part", part)) return false; @@ -212,7 +212,7 @@ public boolean isRollback() { return false; switch (reader.state()) { - case 7: + case 8: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -220,7 +220,7 @@ public boolean isRollback() { reader.incrementState(); - case 8: + case 9: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -228,7 +228,7 @@ public boolean isRollback() { reader.incrementState(); - case 9: + case 10: part = reader.readInt("part"); if (!reader.isLastRead()) @@ -248,7 +248,7 @@ public boolean isRollback() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 10; + return 11; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java index e095c08087067..0db9b4e79a4df 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java @@ -52,7 +52,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheUpdateTxResult; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry; -import org.apache.ignite.internal.processors.cache.persistence.StorageException; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; @@ -509,333 +508,302 @@ private void commitIfLocked() throws IgniteCheckedException { batchStoreCommit(writeMap().values()); - try { - // Node that for near transactions we grab all entries. - for (IgniteTxEntry txEntry : entries) { - GridCacheContext cacheCtx = txEntry.context(); + // Node that for near transactions we grab all entries. + for (IgniteTxEntry txEntry : entries) { + GridCacheContext cacheCtx = txEntry.context(); - boolean replicate = cacheCtx.isDrEnabled(); + boolean replicate = cacheCtx.isDrEnabled(); + while (true) { try { - while (true) { - try { - GridCacheEntryEx cached = txEntry.cached(); + GridCacheEntryEx cached = txEntry.cached(); - if (cached == null) - txEntry.cached(cached = cacheCtx.cache().entryEx(txEntry.key(), topologyVersion())); + if (cached == null) + txEntry.cached(cached = cacheCtx.cache().entryEx(txEntry.key(), topologyVersion())); - if (near() && cacheCtx.dr().receiveEnabled()) { - cached.markObsolete(xidVer); + if (near() && cacheCtx.dr().receiveEnabled()) { + cached.markObsolete(xidVer); - break; - } + break; + } - GridNearCacheEntry nearCached = null; + GridNearCacheEntry nearCached = null; - if (updateNearCache(cacheCtx, txEntry.key(), topVer)) - nearCached = cacheCtx.dht().near().peekExx(txEntry.key()); + if (updateNearCache(cacheCtx, txEntry.key(), topVer)) + nearCached = cacheCtx.dht().near().peekExx(txEntry.key()); - if (!F.isEmpty(txEntry.entryProcessors())) - txEntry.cached().unswap(false); + if (!F.isEmpty(txEntry.entryProcessors())) + txEntry.cached().unswap(false); - IgniteBiTuple res = - applyTransformClosures(txEntry, false, ret); + IgniteBiTuple res = + applyTransformClosures(txEntry, false, ret); - GridCacheOperation op = res.get1(); - CacheObject val = res.get2(); + GridCacheOperation op = res.get1(); + CacheObject val = res.get2(); - GridCacheVersion explicitVer = txEntry.conflictVersion(); + GridCacheVersion explicitVer = txEntry.conflictVersion(); - if (explicitVer == null) - explicitVer = writeVersion(); + if (explicitVer == null) + explicitVer = writeVersion(); - if (txEntry.ttl() == CU.TTL_ZERO) - op = DELETE; + if (txEntry.ttl() == CU.TTL_ZERO) + op = DELETE; - boolean conflictNeedResolve = cacheCtx.conflictNeedResolve(); + boolean conflictNeedResolve = cacheCtx.conflictNeedResolve(); - GridCacheVersionConflictContext conflictCtx = null; + GridCacheVersionConflictContext conflictCtx = null; - if (conflictNeedResolve) { - IgniteBiTuple - drRes = conflictResolve(op, txEntry, val, explicitVer, cached); + if (conflictNeedResolve) { + IgniteBiTuple + drRes = conflictResolve(op, txEntry, val, explicitVer, cached); - assert drRes != null; + assert drRes != null; - conflictCtx = drRes.get2(); + conflictCtx = drRes.get2(); - if (conflictCtx.isUseOld()) - op = NOOP; - else if (conflictCtx.isUseNew()) { - txEntry.ttl(conflictCtx.ttl()); - txEntry.conflictExpireTime(conflictCtx.expireTime()); - } - else if (conflictCtx.isMerge()) { - op = drRes.get1(); - val = txEntry.context().toCacheObject(conflictCtx.mergeValue()); - explicitVer = writeVersion(); + if (conflictCtx.isUseOld()) + op = NOOP; + else if (conflictCtx.isUseNew()) { + txEntry.ttl(conflictCtx.ttl()); + txEntry.conflictExpireTime(conflictCtx.expireTime()); + } + else if (conflictCtx.isMerge()) { + op = drRes.get1(); + val = txEntry.context().toCacheObject(conflictCtx.mergeValue()); + explicitVer = writeVersion(); - txEntry.ttl(conflictCtx.ttl()); - txEntry.conflictExpireTime(conflictCtx.expireTime()); - } - } - else - // Nullify explicit version so that innerSet/innerRemove will work as usual. - explicitVer = null; - - GridCacheVersion dhtVer = cached.isNear() ? writeVersion() : null; - - if (!near() && cacheCtx.group().persistenceEnabled() && cacheCtx.group().walEnabled() && - op != NOOP && op != RELOAD && (op != READ || cctx.snapshot().needTxReadLogging())) { - if (dataEntries == null) - dataEntries = new ArrayList<>(entries.size()); - - dataEntries.add( - new T2<>( - new DataEntry( - cacheCtx.cacheId(), - txEntry.key(), - val, - op, - nearXidVersion(), - writeVersion(), - 0, - txEntry.key().partition(), - txEntry.updateCounter() - ), - txEntry - ) - ); - } + txEntry.ttl(conflictCtx.ttl()); + txEntry.conflictExpireTime(conflictCtx.expireTime()); + } + } + else + // Nullify explicit version so that innerSet/innerRemove will work as usual. + explicitVer = null; + + GridCacheVersion dhtVer = cached.isNear() ? writeVersion() : null; + + if (!near() && cacheCtx.group().persistenceEnabled() && cacheCtx.group().walEnabled() && + op != NOOP && op != RELOAD && (op != READ || cctx.snapshot().needTxReadLogging())) { + if (dataEntries == null) + dataEntries = new ArrayList<>(entries.size()); + + dataEntries.add( + new T2<>( + new DataEntry( + cacheCtx.cacheId(), + txEntry.key(), + val, + op, + nearXidVersion(), + writeVersion(), + 0, + txEntry.key().partition(), + txEntry.updateCounter() + ), + txEntry + ) + ); + } - if (op == CREATE || op == UPDATE) { - // Invalidate only for near nodes (backups cannot be invalidated). - if (isSystemInvalidate() || (isInvalidate() && cacheCtx.isNear())) - cached.innerRemove(this, - eventNodeId(), - nodeId, - false, - true, - true, - txEntry.keepBinary(), - txEntry.hasOldValue(), - txEntry.oldValue(), - topVer, - null, - replicate ? DR_BACKUP : DR_NONE, - near() ? null : explicitVer, - CU.subjectId(this, cctx), - resolveTaskName(), - dhtVer, - txEntry.updateCounter(), - mvccSnapshot()); - else { - assert val != null : txEntry; - - GridCacheUpdateTxResult updRes = cached.innerSet(this, - eventNodeId(), - nodeId, - val, - false, - false, - txEntry.ttl(), - true, - true, - txEntry.keepBinary(), - txEntry.hasOldValue(), - txEntry.oldValue(), - topVer, - null, - replicate ? DR_BACKUP : DR_NONE, - txEntry.conflictExpireTime(), - near() ? null : explicitVer, - CU.subjectId(this, cctx), - resolveTaskName(), - dhtVer, - txEntry.updateCounter(), - mvccSnapshot()); - - txEntry.updateCounter(updRes.updateCounter()); - - if (updRes.loggedPointer() != null) - ptr = updRes.loggedPointer(); - - // Keep near entry up to date. - if (nearCached != null) { - CacheObject val0 = cached.valueBytes(); - - nearCached.updateOrEvict(xidVer, - val0, - cached.expireTime(), - cached.ttl(), - nodeId, - topVer); - } - } - } - else if (op == DELETE) { - GridCacheUpdateTxResult updRes = cached.innerRemove(this, - eventNodeId(), + if (op == CREATE || op == UPDATE) { + // Invalidate only for near nodes (backups cannot be invalidated). + if (isSystemInvalidate() || (isInvalidate() && cacheCtx.isNear())) + cached.innerRemove(this, + eventNodeId(), + nodeId, + false, + true, + true, + txEntry.keepBinary(), + txEntry.hasOldValue(), + txEntry.oldValue(), + topVer, + null, + replicate ? DR_BACKUP : DR_NONE, + near() ? null : explicitVer, + CU.subjectId(this, cctx), + resolveTaskName(), + dhtVer, + txEntry.updateCounter(), + mvccSnapshot()); + else { + assert val != null : txEntry; + + GridCacheUpdateTxResult updRes = cached.innerSet(this, + eventNodeId(), + nodeId, + val, + false, + false, + txEntry.ttl(), + true, + true, + txEntry.keepBinary(), + txEntry.hasOldValue(), + txEntry.oldValue(), + topVer, + null, + replicate ? DR_BACKUP : DR_NONE, + txEntry.conflictExpireTime(), + near() ? null : explicitVer, + CU.subjectId(this, cctx), + resolveTaskName(), + dhtVer, + txEntry.updateCounter(), + mvccSnapshot()); + + txEntry.updateCounter(updRes.updateCounter()); + + if (updRes.loggedPointer() != null) + ptr = updRes.loggedPointer(); + + // Keep near entry up to date. + if (nearCached != null) { + CacheObject val0 = cached.valueBytes(); + + nearCached.updateOrEvict(xidVer, + val0, + cached.expireTime(), + cached.ttl(), nodeId, - false, - true, - true, - txEntry.keepBinary(), - txEntry.hasOldValue(), - txEntry.oldValue(), - topVer, - null, - replicate ? DR_BACKUP : DR_NONE, - near() ? null : explicitVer, - CU.subjectId(this, cctx), - resolveTaskName(), - dhtVer, - txEntry.updateCounter(), - mvccSnapshot()); - - txEntry.updateCounter(updRes.updateCounter()); - - if (updRes.loggedPointer() != null) - ptr = updRes.loggedPointer(); - - // Keep near entry up to date. - if (nearCached != null) - nearCached.updateOrEvict(xidVer, null, 0, 0, nodeId, topVer); - } - else if (op == RELOAD) { - CacheObject reloaded = cached.innerReload(); - - if (nearCached != null) { - nearCached.innerReload(); - - nearCached.updateOrEvict(cached.version(), - reloaded, - cached.expireTime(), - cached.ttl(), - nodeId, - topVer); - } + topVer); } - else if (op == READ) { - assert near(); - - if (log.isDebugEnabled()) - log.debug("Ignoring READ entry when committing: " + txEntry); - } - // No-op. - else { - if (conflictCtx == null || !conflictCtx.isUseOld()) { - if (txEntry.ttl() != CU.TTL_NOT_CHANGED) - cached.updateTtl(null, txEntry.ttl()); - - if (nearCached != null) { - CacheObject val0 = cached.valueBytes(); - - nearCached.updateOrEvict(xidVer, - val0, - cached.expireTime(), - cached.ttl(), - nodeId, - topVer); - } - } - } - - // Assert after setting values as we want to make sure - // that if we replaced removed entries. - assert - txEntry.op() == READ || onePhaseCommit() || - // If candidate is not there, then lock was explicit - // and we simply allow the commit to proceed. - !cached.hasLockCandidateUnsafe(xidVer) || cached.lockedByUnsafe(xidVer) : - "Transaction does not own lock for commit [entry=" + cached + - ", tx=" + this + ']'; - - // Break out of while loop. - break; - } - catch (GridCacheEntryRemovedException ignored) { - if (log.isDebugEnabled()) - log.debug("Attempting to commit a removed entry (will retry): " + txEntry); - - // Renew cached entry. - txEntry.cached(cacheCtx.cache().entryEx(txEntry.key(), topologyVersion())); } } - } - catch (Throwable ex) { - boolean isNodeStopping = X.hasCause(ex, NodeStoppingException.class); - boolean hasInvalidEnvironmentIssue = X.hasCause(ex, InvalidEnvironmentException.class); - - // In case of error, we still make the best effort to commit, - // as there is no way to rollback at this point. - err = new IgniteTxHeuristicCheckedException("Commit produced a runtime exception " + - "(all transaction entries will be invalidated): " + CU.txString(this), ex); - - if (isNodeStopping) { - U.warn(log, "Failed to commit transaction, node is stopping [tx=" + this + - ", err=" + ex + ']'); - } - else if (hasInvalidEnvironmentIssue) { - U.warn(log, "Failed to commit transaction, node is in invalid state and will be stopped [tx=" + this + - ", err=" + ex + ']'); + else if (op == DELETE) { + GridCacheUpdateTxResult updRes = cached.innerRemove(this, + eventNodeId(), + nodeId, + false, + true, + true, + txEntry.keepBinary(), + txEntry.hasOldValue(), + txEntry.oldValue(), + topVer, + null, + replicate ? DR_BACKUP : DR_NONE, + near() ? null : explicitVer, + CU.subjectId(this, cctx), + resolveTaskName(), + dhtVer, + txEntry.updateCounter(), + mvccSnapshot()); + + txEntry.updateCounter(updRes.updateCounter()); + + if (updRes.loggedPointer() != null) + ptr = updRes.loggedPointer(); + + // Keep near entry up to date. + if (nearCached != null) + nearCached.updateOrEvict(xidVer, null, 0, 0, nodeId, topVer); } - else - U.error(log, "Commit failed.", err); - - state(UNKNOWN); - - if (hasInvalidEnvironmentIssue) - cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, ex)); - else if (!isNodeStopping) { // Skip fair uncommit in case of node stopping or invalidation. - try { - // Courtesy to minimize damage. - uncommit(); + else if (op == RELOAD) { + CacheObject reloaded = cached.innerReload(); + + if (nearCached != null) { + nearCached.innerReload(); + + nearCached.updateOrEvict(cached.version(), + reloaded, + cached.expireTime(), + cached.ttl(), + nodeId, + topVer); } - catch (Throwable ex1) { - U.error(log, "Failed to uncommit transaction: " + this, ex1); + } + else if (op == READ) { + assert near(); - if (ex1 instanceof Error) - throw ex1; + if (log.isDebugEnabled()) + log.debug("Ignoring READ entry when committing: " + txEntry); + } + // No-op. + else { + if (conflictCtx == null || !conflictCtx.isUseOld()) { + if (txEntry.ttl() != CU.TTL_NOT_CHANGED) + cached.updateTtl(null, txEntry.ttl()); + + if (nearCached != null) { + CacheObject val0 = cached.valueBytes(); + + nearCached.updateOrEvict(xidVer, + val0, + cached.expireTime(), + cached.ttl(), + nodeId, + topVer); + } } } - if (ex instanceof Error) - throw (Error) ex; + // Assert after setting values as we want to make sure + // that if we replaced removed entries. + assert + txEntry.op() == READ || onePhaseCommit() || + // If candidate is not there, then lock was explicit + // and we simply allow the commit to proceed. + !cached.hasLockCandidateUnsafe(xidVer) || cached.lockedByUnsafe(xidVer) : + "Transaction does not own lock for commit [entry=" + cached + + ", tx=" + this + ']'; + + // Break out of while loop. + break; + } + catch (GridCacheEntryRemovedException ignored) { + if (log.isDebugEnabled()) + log.debug("Attempting to commit a removed entry (will retry): " + txEntry); - throw err; + // Renew cached entry. + txEntry.cached(cacheCtx.cache().entryEx(txEntry.key(), topologyVersion())); } } + } - // Apply cache size deltas. - applyTxSizes(); + // Apply cache size deltas. + applyTxSizes(); - TxCounters txCntrs = txCounters(false); + TxCounters txCntrs = txCounters(false); - // Apply update counters. - if (txCntrs != null) - cctx.tm().txHandler().applyPartitionsUpdatesCounters(txCntrs.updateCounters()); + // Apply update counters. + if (txCntrs != null) + cctx.tm().txHandler().applyPartitionsUpdatesCounters(txCntrs.updateCounters()); - cctx.mvccCaching().onTxFinished(this, true); + cctx.mvccCaching().onTxFinished(this, true); - if (!near() && !F.isEmpty(dataEntries) && cctx.wal() != null) { - // Set new update counters for data entries received from persisted tx entries. - List entriesWithCounters = dataEntries.stream() - .map(tuple -> tuple.get1().partitionCounter(tuple.get2().updateCounter())) - .collect(Collectors.toList()); + if (!near() && !F.isEmpty(dataEntries) && cctx.wal() != null) { + // Set new update counters for data entries received from persisted tx entries. + List entriesWithCounters = dataEntries.stream() + .map(tuple -> tuple.get1().partitionCounter(tuple.get2().updateCounter())) + .collect(Collectors.toList()); - cctx.wal().log(new DataRecord(entriesWithCounters)); - } + cctx.wal().log(new DataRecord(entriesWithCounters)); + } + + if (ptr != null && !cctx.tm().logTxRecords()) + cctx.wal().flush(ptr, false); + } + catch (Throwable ex) { + state(UNKNOWN); - if (ptr != null && !cctx.tm().logTxRecords()) - cctx.wal().flush(ptr, false); + if (X.hasCause(ex, NodeStoppingException.class)) { + U.warn(log, "Failed to commit transaction, node is stopping [tx=" + CU.txString(this) + + ", err=" + ex + ']'); + + return; } - catch (StorageException e) { - err = e; - throw new IgniteCheckedException("Failed to log transaction record " + - "(transaction will be rolled back): " + this, e); + err = heuristicException(ex); + + try { + uncommit(); + } + catch (Throwable e) { + err.addSuppressed(e); } + + throw err; } finally { cctx.database().checkpointReadUnlock(); @@ -875,9 +843,19 @@ else if (!isNodeStopping) { // Skip fair uncommit in case of node stopping or in throw new IgniteCheckedException("Invalid transaction state for commit [state=" + state + ", tx=" + this + ']'); rollbackRemoteTx(); + + return; } - commitIfLocked(); + try { + commitIfLocked(); + } + catch (IgniteTxHeuristicCheckedException e) { + // Treat heuristic exception as critical. + cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); + + throw e; + } } /** @@ -953,6 +931,8 @@ public void forceCommit() throws IgniteCheckedException { catch (IgniteCheckedException | RuntimeException | Error e) { state(UNKNOWN); + U.error(log, "Error during tx rollback.", e); + if (e instanceof IgniteCheckedException) throw new IgniteException(e); else if (e instanceof RuntimeException) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java index ca2bdab156bf7..001eb61589569 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java @@ -122,7 +122,7 @@ public void addKey(KeyCacheObject key, GridCacheContext ctx) throws IgniteChecke } switch (writer.state()) { - case 7: + case 8: if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG)) return false; @@ -144,7 +144,7 @@ public void addKey(KeyCacheObject key, GridCacheContext ctx) throws IgniteChecke return false; switch (reader.state()) { - case 7: + case 8: keys = reader.readCollection("keys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -164,7 +164,7 @@ public void addKey(KeyCacheObject key, GridCacheContext ctx) throws IgniteChecke /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 8; + return 9; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java index 62b5fe9879c58..d0228159a8721 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java @@ -18,18 +18,40 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; import java.util.UUID; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheCompoundIdentityFuture; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.GridCacheFuture; import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy; import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse; +import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; +import org.apache.ignite.internal.util.typedef.C1; +import org.apache.ignite.internal.util.typedef.CIX1; import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.internal.util.typedef.internal.CU; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; @@ -40,8 +62,14 @@ /** * */ -public abstract class CacheDistributedGetFutureAdapter extends GridCacheCompoundIdentityFuture> - implements GridCacheFuture>, CacheGetFuture { +public abstract class CacheDistributedGetFutureAdapter + extends GridCacheCompoundIdentityFuture> implements CacheGetFuture { + /** Logger reference. */ + protected static final AtomicReference logRef = new AtomicReference<>(); + + /** Logger. */ + protected static IgniteLogger log; + /** Default max remap count value. */ public static final int DFLT_MAX_REMAP_CNT = 3; @@ -101,6 +129,10 @@ public abstract class CacheDistributedGetFutureAdapter extends GridCacheCo /** */ protected final boolean recovery; + /** */ + protected Map>> invalidNodes = Collections.emptyMap(); + + /** * @param cctx Context. * @param keys Keys. @@ -149,6 +181,29 @@ protected CacheDistributedGetFutureAdapter( futId = IgniteUuid.randomUuid(); } + /** + * @param aclass Class. + */ + protected void initLogger(Class aclass){ + if (log == null) + log = U.logger(cctx.kernalContext(), logRef, aclass); + } + + /** {@inheritDoc} */ + @Override public boolean trackable() { + return trackable; + } + + /** {@inheritDoc} */ + @Override public void markNotTrackable() { + // Should not flip trackable flag from true to false since get future can be remapped. + } + + /** {@inheritDoc} */ + @Override public IgniteUuid futureId() { + return futId; + } + /** * @param part Partition. * @return {@code True} if partition is in owned state. @@ -158,11 +213,384 @@ protected final boolean partitionOwned(int part) { } /** + * @param fut Future. + */ + protected void registrateFutureInMvccManager(GridCacheFuture fut) { + if (!trackable) { + trackable = true; + + cctx.mvcc().addFuture(fut, futId); + } + } + + /** + * @param node Cluster node. + * @param part Invalid partition. + * @param topVer Topology version. + */ + protected synchronized void addNodeAsInvalid(ClusterNode node, int part, AffinityTopologyVersion topVer) { + if (invalidNodes == Collections.>>emptyMap()) { + invalidNodes = new HashMap<>(); + } + + Map> invalidNodeMap = invalidNodes.get(topVer); + + if (invalidNodeMap == null) + invalidNodes.put(topVer, invalidNodeMap = new HashMap<>()); + + Set invalidNodeSet = invalidNodeMap.get(part); + + if (invalidNodeSet == null) + invalidNodeMap.put(part, invalidNodeSet = new HashSet<>()); + + invalidNodeSet.add(node); + } + + /** + * @param part Partition. + * @param topVer Topology version. + * @return Set of invalid cluster nodes. + */ + protected synchronized Set getInvalidNodes(int part, AffinityTopologyVersion topVer) { + Set invalidNodeSet = Collections.emptySet(); + + Map> invalidNodesMap = invalidNodes.get(topVer); + + if (invalidNodesMap != null) { + Set nodes = invalidNodesMap.get(part); + + if (nodes != null) + invalidNodeSet = nodes; + } + + return invalidNodeSet; + } + + /** + * + * @param key Key. + * @param node Mapped node. + * @param missedNodesToKeysMapping Full node mapping. + */ + protected boolean checkRetryPermits( + KeyCacheObject key, + ClusterNode node, + Map> missedNodesToKeysMapping + ) { + LinkedHashMap keys = missedNodesToKeysMapping.get(node); + + if (keys != null && keys.containsKey(key)) { + if (REMAP_CNT_UPD.incrementAndGet(this) > MAX_REMAP_CNT) { + onDone(new ClusterTopologyCheckedException("Failed to remap key to a new node after " + + MAX_REMAP_CNT + " attempts (key got remapped to the same node) [key=" + key + ", node=" + + U.toShortString(node) + ", mappings=" + missedNodesToKeysMapping + ']')); + + return false; + } + } + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean onNodeLeft(UUID nodeId) { + boolean found = false; + + for (IgniteInternalFuture> fut : futures()) + if (isMini(fut)) { + AbstractMiniFuture f = (AbstractMiniFuture)fut; + + if (f.node().id().equals(nodeId)) { + found = true; + + f.onNodeLeft(new ClusterTopologyCheckedException("Remote node left grid (will retry): " + nodeId)); + } + } + + return found; + } + + /** {@inheritDoc} */ + @Override public void onResult(UUID nodeId, GridNearGetResponse res) { + for (IgniteInternalFuture> fut : futures()) + if (isMini(fut)) { + AbstractMiniFuture f = (AbstractMiniFuture)fut; + + if (f.futureId().equals(res.miniId())) { + assert f.node().id().equals(nodeId); + + f.onResult(res); + } + } + } + + /** + * @param part Partition. * @param topVer Topology version. * @return Exception. */ - protected final ClusterTopologyServerNotFoundException serverNotFoundError(AffinityTopologyVersion topVer) { + protected final ClusterTopologyServerNotFoundException serverNotFoundError(int part, AffinityTopologyVersion topVer) { return new ClusterTopologyServerNotFoundException("Failed to map keys for cache " + - "(all partition nodes left the grid) [topVer=" + topVer + ", cache=" + cctx.name() + ']'); + "(all partition nodes left the grid) [topVer=" + topVer + + ", part" + part + ", cache=" + cctx.name() + ", localNodeId=" + cctx.localNodeId() + ']'); + } + + /** + * @param f Future. + * @return {@code True} if mini-future. + */ + protected abstract boolean isMini(IgniteInternalFuture f); + + /** + * @param keys Collection of mapping keys. + * @param mapped Previous mapping. + * @param topVer Topology version. + */ + protected abstract void map( + Collection keys, + Map> mapped, + AffinityTopologyVersion topVer + ); + + /** {@inheritDoc} */ + @Override public String toString() { + Collection futuresStrings = F.viewReadOnly(futures(), new C1, String>() { + @SuppressWarnings("unchecked") + @Override public String apply(IgniteInternalFuture f) { + if (isMini(f)) { + AbstractMiniFuture mini = (AbstractMiniFuture)f; + + return "miniFuture([futId=" + mini.futureId() + ", node=" + mini.node().id() + + ", loc=" + mini.node().isLocal() + + ", done=" + f.isDone() + "])"; + } + else + return f.getClass().getSimpleName() + " [loc=true, done=" + f.isDone() + "]"; + } + }); + + return S.toString(CacheDistributedGetFutureAdapter.class, this, + "innerFuts", futuresStrings, + "super", super.toString()); + } + + /** + * Mini-future for get operations. Mini-futures are only waiting on a single + * node as opposed to multiple nodes. + */ + protected abstract class AbstractMiniFuture extends GridFutureAdapter> { + /** Mini-future id. */ + private final IgniteUuid futId = IgniteUuid.randomUuid(); + + /** Mapped node. */ + protected final ClusterNode node; + + /** Mapped keys. */ + @GridToStringInclude + protected final LinkedHashMap keys; + + /** Topology version on which this future was mapped. */ + protected final AffinityTopologyVersion topVer; + + /** Post processing closure. */ + private final IgniteInClosure> postProcessingClos; + + /** {@code True} if remapped after node left. */ + private boolean remapped; + + /** + * @param node Node. + * @param keys Keys. + * @param topVer Topology version. + */ + protected AbstractMiniFuture( + ClusterNode node, + LinkedHashMap keys, + AffinityTopologyVersion topVer + ) { + this.node = node; + this.keys = keys; + this.topVer = topVer; + this.postProcessingClos = CU.createBackupPostProcessingClosure( + topVer, log, cctx, null, expiryPlc, readThrough, skipVals); + } + + /** + * @return Future ID. + */ + public IgniteUuid futureId() { + return futId; + } + + /** + * @return Node ID. + */ + public ClusterNode node() { + return node; + } + + /** + * @return Keys. + */ + public Collection keys() { + return keys.keySet(); + } + + /** + * Factory methond for generate request associated with this miniFuture. + * + * @param rootFutId Root future id. + * @return Near get request. + */ + public GridNearGetRequest createGetRequest(IgniteUuid rootFutId) { + return createGetRequest0(rootFutId, futureId()); + } + + /** + * @param rootFutId Root future id. + * @param futId Mini future id. + * @return Near get request. + */ + protected abstract GridNearGetRequest createGetRequest0(IgniteUuid rootFutId, IgniteUuid futId); + + /** + * @param entries Collection of entries. + * @return Map with key value results. + */ + protected abstract Map createResultMap(Collection entries); + + /** + * @param e Error. + */ + public void onResult(Throwable e) { + if (log.isDebugEnabled()) + log.debug("Failed to get future result [fut=" + this + ", err=" + e + ']'); + + // Fail. + onDone(e); + } + + /** + * @param e Failure exception. + */ + public synchronized void onNodeLeft(ClusterTopologyCheckedException e) { + if (remapped) + return; + + remapped = true; + + if (log.isDebugEnabled()) + log.debug("Remote node left grid while sending or waiting for reply (will retry): " + this); + + // Try getting from existing nodes. + if (!canRemap) { + map(keys.keySet(), F.t(node, keys), topVer); + + onDone(Collections.emptyMap()); + } + else { + long maxTopVer = Math.max(topVer.topologyVersion() + 1, cctx.discovery().topologyVersion()); + + AffinityTopologyVersion awaitTopVer = new AffinityTopologyVersion(maxTopVer); + + cctx.shared().exchange() + .affinityReadyFuture(awaitTopVer) + .listen((f) -> { + try { + // Remap. + map(keys.keySet(), F.t(node, keys), f.get()); + + onDone(Collections.emptyMap()); + } + catch (IgniteCheckedException ex) { + CacheDistributedGetFutureAdapter.this.onDone(ex); + } + } + ); + } + } + + /** + * @param res Result callback. + */ + public void onResult(GridNearGetResponse res) { + // If error happened on remote node, fail the whole future. + if (res.error() != null) { + onDone(res.error()); + + return; + } + + Collection invalidParts = res.invalidPartitions(); + + // Remap invalid partitions. + if (!F.isEmpty(invalidParts)) { + AffinityTopologyVersion rmtTopVer = res.topologyVersion(); + + for (Integer part : invalidParts) + addNodeAsInvalid(node, part, topVer); + + if (log.isDebugEnabled()) + log.debug("Remapping mini get future [invalidParts=" + invalidParts + ", fut=" + this + ']'); + + if (!canRemap) { + map(F.view(keys.keySet(), new P1() { + @Override public boolean apply(KeyCacheObject key) { + return invalidParts.contains(cctx.affinity().partition(key)); + } + }), F.t(node, keys), topVer); + + postProcessResult(res); + + onDone(createResultMap(res.entries())); + + return; + } + + // Remap after remote version will be finished localy. + cctx.shared().exchange().affinityReadyFuture(rmtTopVer) + .listen(new CIX1>() { + @Override public void applyx( + IgniteInternalFuture fut + ) throws IgniteCheckedException { + AffinityTopologyVersion topVer = fut.get(); + + // This will append new futures to compound list. + map(F.view(keys.keySet(), new P1() { + @Override public boolean apply(KeyCacheObject key) { + return invalidParts.contains(cctx.affinity().partition(key)); + } + }), F.t(node, keys), topVer); + + postProcessResult(res); + + onDone(createResultMap(res.entries())); + } + }); + } + else { + try { + postProcessResult(res); + + onDone(createResultMap(res.entries())); + } + catch (Exception e) { + onDone(e); + } + } + } + + /** + * @param res Response. + */ + protected void postProcessResult(final GridNearGetResponse res) { + if (postProcessingClos != null) + postProcessingClos.apply(res.entries()); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(AbstractMiniFuture.class, this); + } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/ClientCacheDhtTopologyFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/ClientCacheDhtTopologyFuture.java index 4b48f5a59e9ff..f468590a2c198 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/ClientCacheDhtTopologyFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/ClientCacheDhtTopologyFuture.java @@ -80,6 +80,11 @@ public void validate(CacheGroupContext grp, Collection topNodes) { return topVer; } + /** {@inheritDoc} */ + @Override public boolean changedAffinity() { + return true; + } + /** {@inheritDoc} */ @Override public String toString() { return "ClientCacheDhtTopologyFuture [topVer=" + topVer + ']'; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java index 44c7b88c029f3..cf7018a15c895 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java @@ -109,7 +109,7 @@ public long futureId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 6; + return 7; } /** {@inheritDoc} */ @@ -127,20 +127,20 @@ public long futureId() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 5: - if (!writer.writeMessage("topVer", topVer)) + case 6: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -161,7 +161,7 @@ public long futureId() { return false; switch (reader.state()) { - case 3: + case 4: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -169,7 +169,7 @@ public long futureId() { reader.incrementState(); - case 4: + case 5: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -177,8 +177,8 @@ public long futureId() { reader.incrementState(); - case 5: - topVer = reader.readMessage("topVer"); + case 6: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java index 5b0de08a2ce97..e8b40e9cd8c15 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java @@ -215,7 +215,7 @@ private List> ids(List> assignments) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 8; + return 9; } /** @@ -272,32 +272,32 @@ private List> ids(List> assignments) { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeByteArray("affAssignmentIdsBytes", affAssignmentIdsBytes)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeByteArray("idealAffAssignmentBytes", idealAffAssignmentBytes)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeByteArray("partBytes", partBytes)) return false; writer.incrementState(); - case 7: - if (!writer.writeMessage("topVer", topVer)) + case 8: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -318,7 +318,7 @@ private List> ids(List> assignments) { return false; switch (reader.state()) { - case 3: + case 4: affAssignmentIdsBytes = reader.readByteArray("affAssignmentIdsBytes"); if (!reader.isLastRead()) @@ -326,7 +326,7 @@ private List> ids(List> assignments) { reader.incrementState(); - case 4: + case 5: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -334,7 +334,7 @@ private List> ids(List> assignments) { reader.incrementState(); - case 5: + case 6: idealAffAssignmentBytes = reader.readByteArray("idealAffAssignmentBytes"); if (!reader.isLastRead()) @@ -342,7 +342,7 @@ private List> ids(List> assignments) { reader.incrementState(); - case 6: + case 7: partBytes = reader.readByteArray("partBytes"); if (!reader.isLastRead()) @@ -350,8 +350,8 @@ private List> ids(List> assignments) { reader.incrementState(); - case 7: - topVer = reader.readMessage("topVer"); + case 8: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java index 71ddf3ce189bc..c24d48f9029c6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java @@ -260,7 +260,7 @@ private void processForceKeysRequest0(ClusterNode node, GridDhtForceKeysRequest res.addInfo(info); } - entry.touch(msg.topologyVersion()); + entry.touch(); break; } @@ -699,7 +699,7 @@ private void loadEntry(KeyCacheObject key, } finally { if (entry != null) - entry.touch(topVer); + entry.touch(); part.release(); @@ -959,12 +959,14 @@ else if (req.needVersion()) res0 = info.value(); } - res = new GridNearSingleGetResponse(ctx.cacheId(), + res = new GridNearSingleGetResponse( + ctx.cacheId(), req.futureId(), null, res0, false, - req.addDeploymentInfo()); + req.addDeploymentInfo() + ); if (info != null && req.skipValues()) res.setContainsValue(); @@ -972,15 +974,14 @@ else if (req.needVersion()) else { AffinityTopologyVersion topVer = ctx.shared().exchange().lastTopologyFuture().initialVersion(); - assert topVer.compareTo(req.topologyVersion()) > 0 : "Wrong ready topology version for " + - "invalid partitions response [topVer=" + topVer + ", req=" + req + ']'; - - res = new GridNearSingleGetResponse(ctx.cacheId(), + res = new GridNearSingleGetResponse( + ctx.cacheId(), req.futureId(), topVer, null, true, - req.addDeploymentInfo()); + req.addDeploymentInfo() + ); } } catch (NodeStoppingException ignored) { @@ -1064,8 +1065,11 @@ protected void processNearGetRequest(final UUID nodeId, final GridNearGetRequest res.error(e); } - if (!F.isEmpty(fut.invalidPartitions())) - res.invalidPartitions(fut.invalidPartitions(), ctx.shared().exchange().lastTopologyFuture().initialVersion()); + if (!F.isEmpty(fut.invalidPartitions())){ + AffinityTopologyVersion topVer = ctx.shared().exchange().lastTopologyFuture().initialVersion(); + + res.invalidPartitions(fut.invalidPartitions(), topVer); + } try { ctx.io().send(nodeId, res, ctx.ioPolicy()); @@ -1217,7 +1221,7 @@ private void updateTtl(GridCacheAdapter cache, } finally { if (entry != null) - entry.touch(AffinityTopologyVersion.NONE); + entry.touch(); } } catch (IgniteCheckedException e) { @@ -1263,6 +1267,11 @@ protected final boolean needRemap(AffinityTopologyVersion expVer, AffinityTopolo if (expVer.equals(curVer)) return false; + AffinityTopologyVersion lastAffChangedTopVer = ctx.shared().exchange().lastAffinityChangedTopologyVersion(expVer); + + if (curVer.compareTo(lastAffChangedTopVer) >= 0 && curVer.compareTo(expVer) <= 0) + return false; + // TODO IGNITE-7164 check mvcc crd for mvcc enabled txs. Collection cacheNodes0 = ctx.discovery().cacheGroupAffinityNodes(ctx.groupId(), expVer); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java index 8d029b20beadb..90841523cabb6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java @@ -649,10 +649,10 @@ public boolean clearInternal( ']'); } - if (cctx.mvccEnabled()) - cctx.offheap().mvccRemoveAll(this); - else - removeValue(); + if (cctx.mvccEnabled()) + cctx.offheap().mvccRemoveAll(this); + else + removeValue(); // Give to GC. update(null, 0L, 0L, ver, true); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java index 24fd621c8878a..b37a57dc9cd71 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java @@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.ReaderArguments; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter.LostPolicyValidator; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; @@ -55,6 +56,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static java.util.Collections.singleton; +import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter.OperationType.READ; +import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.LOST; +import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING; + /** * */ @@ -179,6 +185,7 @@ public GridDhtGetFuture( * Initializes future. */ void init() { + // TODO get rid of force keys request https://issues.apache.org/jira/browse/IGNITE-10251 GridDhtFuture fut = cctx.group().preloader().request(cctx, keys.keySet(), topVer); if (fut != null) { @@ -203,14 +210,14 @@ void init() { return; } - map0(keys); + map0(keys, true); markInitialized(); } }); } else { - map0(keys); + map0(keys, false); markInitialized(); } @@ -251,7 +258,7 @@ public GridCacheVersion version() { /** * @param keys Keys to map. */ - private void map0(Map keys) { + private void map0(Map keys, boolean forceKeys) { Map mappedKeys = null; // Assign keys to primary nodes. @@ -259,7 +266,7 @@ private void map0(Map keys) { int part = cctx.affinity().partition(key.getKey()); if (retries == null || !retries.contains(part)) { - if (!map(key.getKey())) { + if (!map(key.getKey(), forceKeys)) { if (retries == null) retries = new HashSet<>(); @@ -303,7 +310,7 @@ else if (mappedKeys != null) * @param key Key. * @return {@code True} if mapped. */ - private boolean map(KeyCacheObject key) { + private boolean map(KeyCacheObject key, boolean forceKeys) { try { int keyPart = cctx.affinity().partition(key); @@ -314,14 +321,31 @@ private boolean map(KeyCacheObject key) { if (part == null) return false; + if (!forceKeys && part.state() == LOST && !recovery) { + Throwable error = LostPolicyValidator.validate(cctx, key, READ, singleton(part.id())); + + if (error != null) { + onDone(null, error); + + return false; + } + } + if (parts == null || !F.contains(parts, part.id())) { // By reserving, we make sure that partition won't be unloaded while processed. if (part.reserve()) { - parts = parts == null ? new int[1] : Arrays.copyOf(parts, parts.length + 1); + if (forceKeys || (part.state() == OWNING || part.state() == LOST)) { + parts = parts == null ? new int[1] : Arrays.copyOf(parts, parts.length + 1); - parts[parts.length - 1] = part.id(); + parts[parts.length - 1] = part.id(); - return true; + return true; + } + else { + part.release(); + + return false; + } } else return false; @@ -411,7 +435,7 @@ private IgniteInternalFuture> getAsync( log.debug("Got removed entry when getting a DHT value: " + e); } finally { - e.touch(topVer); + e.touch(); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java index d722397442999..955c8836edbd2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java @@ -35,6 +35,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.ReaderArguments; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter.LostPolicyValidator; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; @@ -47,6 +48,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static java.util.Collections.singleton; +import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter.OperationType.READ; +import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.LOST; +import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING; + /** * */ @@ -201,6 +207,7 @@ public GridCacheVersion version() { * */ private void map() { + // TODO Get rid of force keys request https://issues.apache.org/jira/browse/IGNITE-10251. if (cctx.group().preloader().needForceKeys()) { GridDhtFuture fut = cctx.group().preloader().request( cctx, @@ -234,7 +241,7 @@ private void map() { onDone(e); } else - map0(); + map0(true); } } ); @@ -243,19 +250,20 @@ private void map() { } } - map0(); + map0(false); } /** * */ - private void map0() { + private void map0(boolean forceKeys) { assert retry == null : retry; - if (!map(key)) { + if (!map(key, forceKeys)) { retry = cctx.affinity().partition(key); - onDone((GridCacheEntryInfo)null); + if (!isDone()) + onDone((GridCacheEntryInfo)null); return; } @@ -272,7 +280,7 @@ private void map0() { * @param key Key. * @return {@code True} if mapped. */ - private boolean map(KeyCacheObject key) { + private boolean map(KeyCacheObject key, boolean forceKeys) { try { int keyPart = cctx.affinity().partition(key); @@ -285,11 +293,28 @@ private boolean map(KeyCacheObject key) { assert this.part == -1; + if (!forceKeys && part.state() == LOST && !recovery) { + Throwable error = LostPolicyValidator.validate(cctx, key, READ, singleton(part.id())); + + if (error != null) { + onDone(null, error); + + return false; + } + } + // By reserving, we make sure that partition won't be unloaded while processed. if (part.reserve()) { - this.part = part.id(); + if (forceKeys || (part.state() == OWNING || part.state() == LOST)) { + this.part = part.id(); + + return true; + } + else { + part.release(); - return true; + return false; + } } else return false; @@ -358,7 +383,7 @@ private void getAsync() { log.debug("Got removed entry when getting a DHT value: " + e); } finally { - e.touch(topVer); + e.touch(); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 1ac58182ddc57..76c3b163d577a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -363,62 +363,62 @@ public long accessTtl() { } switch (writer.state()) { - case 20: + case 21: if (!writer.writeLong("accessTtl", accessTtl)) return false; writer.incrementState(); - case 21: + case 22: if (!writer.writeBitSet("invalidateEntries", invalidateEntries)) return false; writer.incrementState(); - case 22: + case 23: if (!writer.writeIgniteUuid("miniId", miniId)) return false; writer.incrementState(); - case 23: + case 24: if (!writer.writeCollection("nearKeys", nearKeys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 24: + case 25: if (!writer.writeObjectArray("ownedKeys", ownedKeys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 25: + case 26: if (!writer.writeObjectArray("ownedValues", ownedValues, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 26: + case 27: if (!writer.writeBitSet("preloadKeys", preloadKeys)) return false; writer.incrementState(); - case 27: + case 28: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 28: + case 29: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 29: - if (!writer.writeMessage("topVer", topVer)) + case 30: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -439,7 +439,7 @@ public long accessTtl() { return false; switch (reader.state()) { - case 20: + case 21: accessTtl = reader.readLong("accessTtl"); if (!reader.isLastRead()) @@ -447,7 +447,7 @@ public long accessTtl() { reader.incrementState(); - case 21: + case 22: invalidateEntries = reader.readBitSet("invalidateEntries"); if (!reader.isLastRead()) @@ -455,7 +455,7 @@ public long accessTtl() { reader.incrementState(); - case 22: + case 23: miniId = reader.readIgniteUuid("miniId"); if (!reader.isLastRead()) @@ -463,7 +463,7 @@ public long accessTtl() { reader.incrementState(); - case 23: + case 24: nearKeys = reader.readCollection("nearKeys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -471,7 +471,7 @@ public long accessTtl() { reader.incrementState(); - case 24: + case 25: ownedKeys = reader.readObjectArray("ownedKeys", MessageCollectionItemType.MSG, KeyCacheObject.class); if (!reader.isLastRead()) @@ -479,7 +479,7 @@ public long accessTtl() { reader.incrementState(); - case 25: + case 26: ownedValues = reader.readObjectArray("ownedValues", MessageCollectionItemType.MSG, GridCacheVersion.class); if (!reader.isLastRead()) @@ -487,7 +487,7 @@ public long accessTtl() { reader.incrementState(); - case 26: + case 27: preloadKeys = reader.readBitSet("preloadKeys"); if (!reader.isLastRead()) @@ -495,7 +495,7 @@ public long accessTtl() { reader.incrementState(); - case 27: + case 28: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -503,7 +503,7 @@ public long accessTtl() { reader.incrementState(); - case 28: + case 29: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -511,8 +511,8 @@ public long accessTtl() { reader.incrementState(); - case 29: - topVer = reader.readMessage("topVer"); + case 30: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; @@ -531,7 +531,7 @@ public long accessTtl() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 30; + return 31; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index 87abd6c2ce994..63c07e82906f4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -207,25 +207,25 @@ public Collection preloadEntries() { } switch (writer.state()) { - case 10: + case 11: if (!writer.writeCollection("invalidParts", invalidParts, MessageCollectionItemType.INT)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeIgniteUuid("miniId", miniId)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeCollection("nearEvicted", nearEvicted, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeCollection("preloadEntries", preloadEntries, MessageCollectionItemType.MSG)) return false; @@ -247,7 +247,7 @@ public Collection preloadEntries() { return false; switch (reader.state()) { - case 10: + case 11: invalidParts = reader.readCollection("invalidParts", MessageCollectionItemType.INT); if (!reader.isLastRead()) @@ -255,7 +255,7 @@ public Collection preloadEntries() { reader.incrementState(); - case 11: + case 12: miniId = reader.readIgniteUuid("miniId"); if (!reader.isLastRead()) @@ -263,7 +263,7 @@ public Collection preloadEntries() { reader.incrementState(); - case 12: + case 13: nearEvicted = reader.readCollection("nearEvicted", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -271,7 +271,7 @@ public Collection preloadEntries() { reader.incrementState(); - case 13: + case 14: preloadEntries = reader.readCollection("preloadEntries", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -291,7 +291,7 @@ public Collection preloadEntries() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 14; + return 15; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java index 489fb63309ea5..3cae875f5d9c7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java @@ -86,4 +86,10 @@ public interface GridDhtTopologyFuture extends IgniteInternalFuture keys); + + /** + * + * @return {@code True} if this exchange changed affinity. + */ + public boolean changedAffinity(); } \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java index 539fef48bda46..8a6a5ee0a5a89 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java @@ -29,12 +29,13 @@ import org.apache.ignite.internal.processors.cache.CacheInvalidStateException; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.apache.ignite.internal.util.typedef.F; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.cache.PartitionLossPolicy.READ_ONLY_ALL; import static org.apache.ignite.cache.PartitionLossPolicy.READ_ONLY_SAFE; -import static org.apache.ignite.cache.PartitionLossPolicy.READ_WRITE_ALL; import static org.apache.ignite.cache.PartitionLossPolicy.READ_WRITE_SAFE; +import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter.OperationType.WRITE; /** * @@ -42,7 +43,7 @@ public abstract class GridDhtTopologyFutureAdapter extends GridFutureAdapter implements GridDhtTopologyFuture { /** Cache groups validation results. */ - protected volatile Map grpValidRes; + protected volatile Map grpValidRes = Collections.emptyMap(); /** Whether or not cluster is active. */ protected volatile boolean clusterIsActive = true; @@ -52,7 +53,7 @@ public abstract class GridDhtTopologyFutureAdapter extends GridFutureAdapter topNodes) { + protected final CacheGroupValidation validateCacheGroup(CacheGroupContext grp, Collection topNodes) { Collection lostParts = grp.isLocal() ? Collections.emptyList() : grp.topology().lostPartitions(); @@ -65,11 +66,11 @@ protected final CacheValidation validateCacheGroup(CacheGroupContext grp, Collec valid = validator.validate(topNodes); } - return new CacheValidation(valid, lostParts); + return new CacheGroupValidation(valid, lostParts); } /** {@inheritDoc} */ - @Nullable @Override public final Throwable validateCache( + @Override public final @Nullable Throwable validateCache( GridCacheContext cctx, boolean recovery, boolean read, @@ -87,112 +88,181 @@ protected final CacheValidation validateCacheGroup(CacheGroupContext grp, Collec return new CacheInvalidStateException( "Failed to perform cache operation (cluster is not activated): " + cctx.name()); + OperationType opType = read ? OperationType.READ : WRITE; + CacheGroupContext grp = cctx.group(); - PartitionLossPolicy partLossPlc = grp.config().getPartitionLossPolicy(); + PartitionLossPolicy lossPlc = grp.config().getPartitionLossPolicy(); + + if (cctx.shared().readOnlyMode() && opType == WRITE) + return new IgniteCheckedException("Failed to perform cache operation (cluster is in read only mode)"); if (grp.needsRecovery() && !recovery) { - if (!read && (partLossPlc == READ_ONLY_SAFE || partLossPlc == READ_ONLY_ALL)) - return new IgniteCheckedException("Failed to write to cache (cache is moved to a read-only state): " + - cctx.name()); + if (opType == WRITE && (lossPlc == READ_ONLY_SAFE || lossPlc == READ_ONLY_ALL)) + return new IgniteCheckedException( + "Failed to write to cache (cache is moved to a read-only state): " + cctx.name()); } - if (grp.needsRecovery() || grp.topologyValidator() != null) { - CacheValidation validation = grpValidRes.get(grp.groupId()); - - if (validation == null) - return null; - - if (!validation.valid && !read) - return new IgniteCheckedException("Failed to perform cache operation " + - "(cache topology is not valid): " + cctx.name()); - - if (recovery || !grp.needsRecovery()) - return null; - - if (key != null) { - int p = cctx.affinity().partition(key); - - CacheInvalidStateException ex = validatePartitionOperation(cctx.name(), read, key, p, - validation.lostParts, partLossPlc); - - if (ex != null) - return ex; - } - - if (keys != null) { - for (Object k : keys) { - int p = cctx.affinity().partition(k); + CacheGroupValidation validation = grpValidRes.get(grp.groupId()); - CacheInvalidStateException ex = validatePartitionOperation(cctx.name(), read, k, p, - validation.lostParts, partLossPlc); + if (validation == null) + return null; - if (ex != null) - return ex; - } - } + if (opType == WRITE && !validation.isValid()) { + return new IgniteCheckedException("Failed to perform cache operation " + + "(cache topology is not valid): " + cctx.name()); } - return null; - } + if (recovery) + return null; - /** - * @param cacheName Cache name. - * @param read Read flag. - * @param key Key to check. - * @param part Partition this key belongs to. - * @param lostParts Collection of lost partitions. - * @param plc Partition loss policy. - * @return Invalid state exception if this operation is disallowed. - */ - private CacheInvalidStateException validatePartitionOperation( - String cacheName, - boolean read, - Object key, - int part, - Collection lostParts, - PartitionLossPolicy plc - ) { - if (lostParts.contains(part)) { - if (!read) { - assert plc == READ_WRITE_ALL || plc == READ_WRITE_SAFE; + if (validation.hasLostPartitions()) { + if (key != null) + return LostPolicyValidator.validate(cctx, key, opType, validation.lostPartitions()); - if (plc == READ_WRITE_SAFE) { - return new CacheInvalidStateException("Failed to execute cache operation " + - "(all partition owners have left the grid, partition data has been lost) [" + - "cacheName=" + cacheName + ", part=" + part + ", key=" + key + ']'); - } - } - else { - // Read. - if (plc == READ_ONLY_SAFE || plc == READ_WRITE_SAFE) - return new CacheInvalidStateException("Failed to execute cache operation " + - "(all partition owners have left the grid, partition data has been lost) [" + - "cacheName=" + cacheName + ", part=" + part + ", key=" + key + ']'); - } + if (keys != null) + return LostPolicyValidator.validate(cctx, keys, opType, validation.lostPartitions()); } return null; } /** - * Cache validation result. + * Cache group validation result. */ - protected static class CacheValidation { + protected static class CacheGroupValidation { /** Topology validation result. */ - private boolean valid; + private final boolean valid; /** Lost partitions on this topology version. */ - private Collection lostParts; + private final Collection lostParts; /** * @param valid Valid flag. * @param lostParts Lost partitions. */ - private CacheValidation(boolean valid, Collection lostParts) { + private CacheGroupValidation(boolean valid, Collection lostParts) { this.valid = valid; this.lostParts = lostParts; } + + /** + * @return True if valid, False if invalide. + */ + public boolean isValid() { + return valid; + } + + /** + * @return True if lost partition is present, False if not. + */ + public boolean hasLostPartitions() { + return !F.isEmpty(lostParts); + } + + /** + * @return Lost patition ID collection. + */ + public Collection lostPartitions() { + return lostParts; + } } + /** + * + */ + public enum OperationType { + /** + * Read operation. + */ + READ, + /** + * Write operation. + */ + WRITE + } + + /** + * Lost policy validator. + */ + public static class LostPolicyValidator { + /** + * + */ + public static Throwable validate( + GridCacheContext cctx, + Object key, + OperationType opType, + Collection lostParts + ) { + CacheGroupContext grp = cctx.group(); + + PartitionLossPolicy lostPlc = grp.config().getPartitionLossPolicy(); + + int partition = cctx.affinity().partition(key); + + return validate(cctx, key, partition, opType, lostPlc, lostParts); + } + + /** + * + */ + public static Throwable validate( + GridCacheContext cctx, + Collection keys, + OperationType opType, + Collection lostParts + ) { + CacheGroupContext grp = cctx.group(); + + PartitionLossPolicy lostPlc = grp.config().getPartitionLossPolicy(); + + for (Object key : keys) { + int partition = cctx.affinity().partition(key); + + Throwable res = validate(cctx, key, partition, opType, lostPlc, lostParts); + + if (res != null) + return res; + } + + return null; + } + + /** + * + */ + private static Throwable validate( + GridCacheContext cctx, + Object key, + int partition, + OperationType opType, + PartitionLossPolicy lostPlc, + Collection lostParts + ) { + if (opType == WRITE) { + if (lostPlc == READ_ONLY_SAFE || lostPlc == READ_ONLY_ALL) { + return new IgniteCheckedException( + "Failed to write to cache (cache is moved to a read-only state): " + cctx.name() + ); + } + + if (lostParts.contains(partition) && lostPlc == READ_WRITE_SAFE) { + return new CacheInvalidStateException("Failed to execute cache operation " + + "(all partition owners have left the grid, partition data has been lost) [" + + "cacheName=" + cctx.name() + ", part=" + partition + ", key=" + key + ']'); + } + } + + if (opType == OperationType.READ) { + if (lostParts.contains(partition) && (lostPlc == READ_ONLY_SAFE || lostPlc == READ_WRITE_SAFE)) + return new CacheInvalidStateException("Failed to execute cache operation " + + "(all partition owners have left the grid, partition data has been lost) [" + + "cacheName=" + cctx.name() + ", part=" + partition + ", key=" + key + ']' + ); + } + + return null; + } + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java index edd28b44a47bc..295eabf371c27 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java @@ -1121,7 +1121,8 @@ public IgniteInternalFuture lockAllAsync( req.txSize(), null, req.subjectId(), - req.taskNameHash()); + req.taskNameHash(), + null); if (req.syncCommit()) tx.syncMode(FULL_SYNC); @@ -1646,7 +1647,7 @@ private void clearLocks(UUID nodeId, GridDistributedUnlockRequest req) { "(added to cancelled locks set): " + req); } - entry.touch(ctx.affinity().affinityTopologyVersion()); + entry.touch(); break; } @@ -1834,7 +1835,7 @@ else if (log.isDebugEnabled()) if (created && entry.markObsolete(dhtVer)) removeEntry(entry); - entry.touch(topVer); + entry.touch(); break; } @@ -1962,23 +1963,24 @@ private void processNearTxQueryResultsEnlistRequest(UUID nodeId, final GridNearT req.subjectId(), req.taskNameHash()); } - catch (IgniteCheckedException | IgniteException ex) { + catch (Throwable e) { GridNearTxQueryResultsEnlistResponse res = new GridNearTxQueryResultsEnlistResponse(req.cacheId(), req.futureId(), req.miniId(), req.version(), - ex); + e); try { ctx.io().send(nearNode, res, ctx.ioPolicy()); } - catch (IgniteCheckedException e) { - U.error(log, "Failed to send near enlist response [" + - "txId=" + req.version() + - ", node=" + nodeId + - ", res=" + res + ']', e); + catch (IgniteCheckedException ioEx) { + U.error(log, "Failed to send near enlist response " + + "[txId=" + req.version() + ", node=" + nodeId + ", res=" + res + ']', ioEx); } + if (e instanceof Error) + throw (Error) e; + return; } @@ -2124,7 +2126,8 @@ public GridDhtTxLocal initTxTopologyVersion(UUID nodeId, GridDhtTopologyFuture topFut = top.topologyVersionFuture(); - if (!topFut.isDone() || !topFut.topologyVersion().equals(topVer)) { + if (!topFut.isDone() || !(topFut.topologyVersion().compareTo(topVer) >= 0 + && ctx.shared().exchange().lastAffinityChangedTopologyVersion(topFut.initialVersion()).compareTo(topVer) <= 0)) { // TODO IGNITE-7164 Wait for topology change, remap client TX in case affinity was changed. top.readUnlock(); @@ -2155,7 +2158,8 @@ public GridDhtTxLocal initTxTopologyVersion(UUID nodeId, -1, null, txSubjectId, - txTaskNameHash); + txTaskNameHash, + null); // if (req.syncCommit()) tx.syncMode(FULL_SYNC); @@ -2227,26 +2231,6 @@ private void processNearTxQueryResultsEnlistResponse(UUID nodeId, final GridNear fut.onResult(nodeId, res); } - /** - * @param primary Primary node. - * @param req Request. - * @param e Error. - */ - private void onError(UUID primary, GridDhtTxQueryEnlistRequest req, Throwable e) { - GridDhtTxQueryEnlistResponse res = new GridDhtTxQueryEnlistResponse(ctx.cacheId(), - req.dhtFutureId(), - req.batchId(), - e); - - try { - ctx.io().send(primary, res, ctx.ioPolicy()); - } - catch (IgniteCheckedException ioEx) { - U.error(log, "Failed to send DHT enlist reply to primary node [node: " + primary + ", req=" + req + - ']', ioEx); - } - } - /** * @param primary Primary node. * @param req Message. @@ -2318,8 +2302,22 @@ private void processDhtTxQueryEnlistRequest(UUID primary, GridDhtTxQueryEnlistRe req + ']', ioEx); } } - catch (IgniteCheckedException e) { - onError(primary, req, e); + catch (Throwable e) { + GridDhtTxQueryEnlistResponse res = new GridDhtTxQueryEnlistResponse(ctx.cacheId(), + req.dhtFutureId(), + req.batchId(), + e); + + try { + ctx.io().send(primary, res, ctx.ioPolicy()); + } + catch (IgniteCheckedException ioEx) { + U.error(log, "Failed to send DHT enlist reply to primary node " + + "[node: " + primary + ", req=" + req + ']', ioEx); + } + + if (e instanceof Error) + throw (Error) e; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxAbstractEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxAbstractEnlistFuture.java index cfa8eb770168e..0a355a49c5417 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxAbstractEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxAbstractEnlistFuture.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -386,12 +385,20 @@ private void continueLoop(boolean ignoreCntr) { try { while (true) { + int curPart = -1; + List backups = null; + while (hasNext0()) { Object cur = next0(); - KeyCacheObject key = cctx.toCacheKeyObject(op.isDeleteOrLock() ? cur : ((IgniteBiTuple)cur).getKey()); + KeyCacheObject key = toKey(op, cur); + + if (curPart != key.partition()) + backups = backupNodes(curPart = key.partition()); - if (!ensureFreeSlot(key)) { + assert backups != null; + + if (!ensureFreeSlot(key, backups)) { // Can't advance further at the moment. peek = cur; @@ -442,7 +449,7 @@ private void continueLoop(boolean ignoreCntr) { cctx.localNodeId(), topVer, mvccSnapshot, - isMoving(key.partition()), + isMoving(key.partition(), backups), needOldVal, filter, needResult()); @@ -463,7 +470,7 @@ private void continueLoop(boolean ignoreCntr) { topVer, mvccSnapshot, op.cacheOperation(), - isMoving(key.partition()), + isMoving(key.partition(), backups), op.noCreate(), needOldVal, filter, @@ -502,13 +509,14 @@ private void continueLoop(boolean ignoreCntr) { res = updateFut.get(); else { GridDhtCacheEntry entry0 = entry; + List backups0 = backups; it.beforeDetach(); updateFut.listen(new CI1>() { @Override public void apply(IgniteInternalFuture fut) { try { - processEntry(entry0, op, fut.get(), val0); + processEntry(entry0, op, fut.get(), val0, backups0); continueLoop(true); } @@ -523,7 +531,7 @@ private void continueLoop(boolean ignoreCntr) { } } - processEntry(entry, op, res, val0); + processEntry(entry, op, res, val0, backups); } if (!hasNext0()) { @@ -591,6 +599,16 @@ private boolean hasNext0() { return peek != FINISHED; } + /** */ + private KeyCacheObject toKey(EnlistOperation op, Object cur) { + KeyCacheObject key = cctx.toCacheKeyObject(op.isDeleteOrLock() ? cur : ((IgniteBiTuple)cur).getKey()); + + if (key.partition() == -1) + key.partition(cctx.affinity().partition(key)); + + return key; + } + /** * @return {@code True} if in-flight batches map is empty. */ @@ -611,41 +629,40 @@ private boolean noPendingRequests() { * @param op Operation. * @param updRes Update result. * @param val New value. + * @param backups Backup nodes * @throws IgniteCheckedException If failed. */ private void processEntry(GridDhtCacheEntry entry, EnlistOperation op, - GridCacheUpdateTxResult updRes, Message val) throws IgniteCheckedException { + GridCacheUpdateTxResult updRes, Message val, List backups) throws IgniteCheckedException { checkCompleted(); assert updRes != null && updRes.updateFuture() == null; onEntryProcessed(entry.key(), updRes); - if (!updRes.success()) + if (!updRes.success() + || updRes.filtered() + || op == EnlistOperation.LOCK) return; - if (!updRes.filtered()) - cctx.shared().mvccCaching().addEnlisted(entry.key(), updRes.newValue(), 0, 0, lockVer, - updRes.oldValue(), tx.local(), tx.topologyVersion(), mvccSnapshot, cctx.cacheId(), tx, null, -1); + cctx.shared().mvccCaching().addEnlisted(entry.key(), updRes.newValue(), 0, 0, lockVer, + updRes.oldValue(), tx.local(), tx.topologyVersion(), mvccSnapshot, cctx.cacheId(), tx, null, -1); - if (op != EnlistOperation.LOCK) - addToBatch(entry.key(), val, updRes.mvccHistory(), entry.context().cacheId()); + addToBatch(entry.key(), val, updRes.mvccHistory(), entry.context().cacheId(), backups); } /** * Adds row to batch. * IMPORTANT: This method should be called from the critical section in {@link this.sendNextBatches()} - * * @param key Key. * @param val Value. * @param hist History rows. * @param cacheId Cache Id. + * @param backups Backup nodes */ private void addToBatch(KeyCacheObject key, Message val, List hist, - int cacheId) throws IgniteCheckedException { - List backups = backupNodes(key); - - int part = cctx.affinity().partition(key); + int cacheId, List backups) throws IgniteCheckedException { + int part = key.partition(); tx.touchPartition(cacheId, part); @@ -659,7 +676,7 @@ private void addToBatch(KeyCacheObject key, Message val, List backups) { if (F.isEmpty(batches) || F.isEmpty(pending)) return true; + int part = key.partition(); + // Check possibility of adding to batch and sending. - for (ClusterNode node : backupNodes(key)) { - if (skipNearNodeUpdates && node.id().equals(nearNodeId) && !isMoving(node, key.partition())) + for (ClusterNode node : backups) { + if (skipNearLocalUpdate(node, isMoving(node, part))) continue; Batch batch = batches.get(node.id()); @@ -814,16 +834,14 @@ private void sendBatch(Batch batch) throws IgniteCheckedException { if (newRemoteTx(node)) addNewRemoteTxNode(node); - if (!firstReqSent.contains(node)) { - firstReqSent.add(node); - + if (firstReqSent.add(node)) { // If this is a first request to this node, send full info. req = new GridDhtTxQueryFirstEnlistRequest(cctx.cacheId(), futId, cctx.localNodeId(), tx.topologyVersionSnapshot(), lockVer, - mvccSnapshot, + mvccSnapshot.withoutActiveTransactions(), tx.remainingTime(), tx.taskNameHash(), nearNodeId, @@ -861,7 +879,13 @@ private void sendBatch(Batch batch) throws IgniteCheckedException { assert prev == null; - cctx.io().send(node, req, cctx.ioPolicy()); + try { + cctx.io().send(node, req, cctx.ioPolicy()); + } + catch (ClusterTopologyCheckedException e) { + // backup node left the grid, will continue. + onNodeLeft(node.id()); + } } /** */ @@ -878,20 +902,21 @@ private synchronized void updateMappings(ClusterNode node) throws IgniteCheckedE mapping.markQueryUpdate(); } + /** */ + private boolean skipNearLocalUpdate(ClusterNode node, boolean moving) { + return skipNearNodeUpdates && node.id().equals(nearNodeId) && !moving; + } + /** - * @param key Key. - * @return Backup nodes for the given key. + * @param part Partition. + * @return Backup nodes for the given partition. */ - @NotNull private List backupNodes(KeyCacheObject key) { - List dhtNodes = cctx.affinity().nodesByKey(key, tx.topologyVersion()); - - assert !dhtNodes.isEmpty() && dhtNodes.get(0).id().equals(cctx.localNodeId()) : - "localNode = " + cctx.localNodeId() + ", dhtNodes = " + dhtNodes; + @NotNull private List backupNodes(int part) { + List nodes = cctx.topology().nodes(part, tx.topologyVersion()); - if (dhtNodes.size() == 1) - return Collections.emptyList(); + assert nodes.size() > 0 && nodes.get(0).isLocal(); - return dhtNodes.subList(1, dhtNodes.size()); + return nodes.subList(1, nodes.size()); } /** @@ -931,31 +956,33 @@ private void checkPartitions(@Nullable int[] parts) throws ClusterTopologyChecke /** * @param part Partition. + * @param backups Backup nodes. * @return {@code true} if the given partition is rebalancing to any backup node. */ - private boolean isMoving(int part) { + private boolean isMoving(int part, List backups) { + Boolean res; + if (movingParts == null) movingParts = new HashMap<>(); - Boolean res = movingParts.get(part); + if ((res = movingParts.get(part)) == null) + movingParts.put(part, res = isMoving0(part, backups)); - if (res != null) - return res; - - List dhtNodes = cctx.affinity().nodesByPartition(part, tx.topologyVersion()); - - for (int i = 1; i < dhtNodes.size(); i++) { - ClusterNode node = dhtNodes.get(i); - if (isMoving(node, part)) { - movingParts.put(part, Boolean.TRUE); + return res == Boolean.TRUE; + } - return true; - } + /** + * @param part Partition. + * @param backups Backup nodes. + * @return {@code true} if the given partition is rebalancing to any backup node. + */ + private Boolean isMoving0(int part, List backups) { + for (ClusterNode node : backups) { + if (isMoving(node, part)) + return Boolean.TRUE; } - movingParts.put(part, Boolean.FALSE); - - return false; + return Boolean.FALSE; } /** @@ -964,9 +991,7 @@ private boolean isMoving(int part) { * @return {@code true} if the given partition is rebalancing to the given node. */ private boolean isMoving(ClusterNode node, int part) { - GridDhtPartitionState partState = cctx.topology().partitionState(node.id(), part); - - return partState != GridDhtPartitionState.OWNING && partState != GridDhtPartitionState.EVICTED; + return cctx.topology().partitionState(node.id(), part) == GridDhtPartitionState.MOVING; } /** */ @@ -1019,23 +1044,17 @@ public void onResult(UUID nodeId, GridDhtTxQueryEnlistResponse res) { /** {@inheritDoc} */ @Override public boolean onNodeLeft(UUID nodeId) { - boolean backupLeft = false; - - Set nodes = tx.lockTransactionNodes(); - - if (!F.isEmpty(nodes)) { - for (ClusterNode node : nodes) { - if (node.id().equals(nodeId)) { - backupLeft = true; - - break; - } - } + try { + if (nearNodeId.equals(nodeId)) + onDone(new ClusterTopologyCheckedException("Requesting node left the grid [nodeId=" + nodeId + ']')); + else if (pending != null && pending.remove(nodeId) != null) + cctx.kernalContext().closure().runLocalSafe(() -> continueLoop(false)); + } + catch (Exception e) { + onDone(e); } - return (backupLeft || nearNodeId.equals(nodeId)) && onDone( - new ClusterTopologyCheckedException((backupLeft ? "Backup" : "Requesting") + - " node left the grid [nodeId=" + nodeId + ']')); + return false; } /** {@inheritDoc} */ @@ -1127,16 +1146,17 @@ public void add(KeyCacheObject key, Message val) { if (keys == null) keys = new ArrayList<>(); - keys.add(key); - - if (val != null) { - if (vals == null) - vals = new ArrayList<>(); + if (vals == null && val != null) { + vals = new ArrayList<>(U.ceilPow2(keys.size() + 1)); - vals.add(val); + while (vals.size() != keys.size()) + vals.add(null); // Init vals with missed 'nulls'. } - assert (vals == null) || keys.size() == vals.size(); + keys.add(key); + + if (vals != null) + vals.add(val); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxEnlistFuture.java index 7719638a89a78..60644cd8e351a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxEnlistFuture.java @@ -119,19 +119,16 @@ public GridDhtTxEnlistFuture(UUID nearNodeId, res.success(txRes.success()); - if(txRes.invokeResult() != null) + if(txRes.invokeResult() != null) { res.invokeResult(true); - if (needRes && txRes.success()) { CacheInvokeResult invokeRes = txRes.invokeResult(); - if (invokeRes != null) { - if(invokeRes.result() != null || invokeRes.error() != null) - res.addEntryProcessResult(cctx, key, null, invokeRes.result(), invokeRes.error(), cctx.keepBinary()); - } - else - res.set(cctx, txRes.prevValue(), txRes.success(), true); + if (invokeRes.result() != null || invokeRes.error() != null) + res.addEntryProcessResult(cctx, key, null, invokeRes.result(), invokeRes.error(), cctx.keepBinary()); } + else if (needRes) + res.set(cctx, txRes.prevValue(), txRes.success(), true); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java index 472aafd724d16..d0fbd90bf03eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java @@ -173,10 +173,13 @@ public void rollbackOnError(Throwable e) { if (ERR_UPD.compareAndSet(this, null, e)) { tx.setRollbackOnly(); - if (X.hasCause(e, InvalidEnvironmentException.class, NodeStoppingException.class)) + if (X.hasCause(e, NodeStoppingException.class) || cctx.kernalContext().failure().nodeStopping()) onComplete(); - else + else { + // Rolling back a remote transaction may result in partial commit. + // This is only acceptable in tests with no-op failure handler. finish(false); + } } } @@ -230,9 +233,9 @@ public void onResult(UUID nodeId, GridDhtTxFinishResponse res) { if (this.tx.onePhaseCommit() && (this.tx.state() == COMMITTING)) { try { - boolean hasInvalidEnvironmentIssue = X.hasCause(err, InvalidEnvironmentException.class, NodeStoppingException.class); + boolean nodeStopping = X.hasCause(err, NodeStoppingException.class); - this.tx.tmFinish(err == null, hasInvalidEnvironmentIssue, false); + this.tx.tmFinish(err == null, nodeStopping || cctx.kernalContext().failure().nodeStopping(), false); } catch (IgniteCheckedException finishErr) { U.error(log, "Failed to finish tx: " + tx, e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index 61896b59a3d15..04f411d8e3b23 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -393,44 +393,38 @@ public Collection updateCounters() { } switch (writer.state()) { - case 21: - if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1)) - return false; - - writer.incrementState(); - case 22: - if (!writer.writeInt("miniId", miniId)) + if (!writer.writeByte("isolation", isolation != null ? (byte)isolation.ordinal() : -1)) return false; writer.incrementState(); case 23: - if (!writer.writeUuid("nearNodeId", nearNodeId)) + if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); case 24: - if (!writer.writeMessage("partUpdateCnt", partUpdateCnt)) + if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) return false; writer.incrementState(); case 25: - if (!writer.writeCollection("pendingVers", pendingVers, MessageCollectionItemType.MSG)) + if (!writer.writeUuid("nearNodeId", nearNodeId)) return false; writer.incrementState(); case 26: - if (!writer.writeMessage("writeVer", writeVer)) + if (!writer.writeMessage("partUpdateCnt", partUpdateCnt)) return false; writer.incrementState(); case 27: - if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) + if (!writer.writeCollection("pendingVers", pendingVers, MessageCollectionItemType.MSG)) return false; writer.incrementState(); @@ -441,6 +435,12 @@ public Collection updateCounters() { writer.incrementState(); + case 29: + if (!writer.writeMessage("writeVer", writeVer)) + return false; + + writer.incrementState(); + } return true; @@ -457,7 +457,7 @@ public Collection updateCounters() { return false; switch (reader.state()) { - case 21: + case 22: byte isolationOrd; isolationOrd = reader.readByte("isolation"); @@ -469,16 +469,8 @@ public Collection updateCounters() { reader.incrementState(); - case 22: - miniId = reader.readInt("miniId"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - case 23: - nearNodeId = reader.readUuid("nearNodeId"); + miniId = reader.readInt("miniId"); if (!reader.isLastRead()) return false; @@ -486,7 +478,7 @@ public Collection updateCounters() { reader.incrementState(); case 24: - partUpdateCnt = reader.readMessage("partUpdateCnt"); + mvccSnapshot = reader.readMessage("mvccSnapshot"); if (!reader.isLastRead()) return false; @@ -494,7 +486,7 @@ public Collection updateCounters() { reader.incrementState(); case 25: - pendingVers = reader.readCollection("pendingVers", MessageCollectionItemType.MSG); + nearNodeId = reader.readUuid("nearNodeId"); if (!reader.isLastRead()) return false; @@ -502,7 +494,7 @@ public Collection updateCounters() { reader.incrementState(); case 26: - writeVer = reader.readMessage("writeVer"); + partUpdateCnt = reader.readMessage("partUpdateCnt"); if (!reader.isLastRead()) return false; @@ -510,7 +502,7 @@ public Collection updateCounters() { reader.incrementState(); case 27: - mvccSnapshot = reader.readMessage("mvccSnapshot"); + pendingVers = reader.readCollection("pendingVers", MessageCollectionItemType.MSG); if (!reader.isLastRead()) return false; @@ -525,6 +517,14 @@ public Collection updateCounters() { reader.incrementState(); + case 29: + writeVer = reader.readMessage("writeVer"); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + } return reader.afterMessageRead(GridDhtTxFinishRequest.class); @@ -537,7 +537,7 @@ public Collection updateCounters() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 29; + return 30; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java index 6d717ebf904e6..d777a2201a149 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java @@ -173,19 +173,19 @@ public GridCacheReturn returnValue() { } switch (writer.state()) { - case 6: + case 7: if (!writer.writeByteArray("checkCommittedErrBytes", checkCommittedErrBytes)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeMessage("retVal", retVal)) return false; @@ -207,7 +207,7 @@ public GridCacheReturn returnValue() { return false; switch (reader.state()) { - case 6: + case 7: checkCommittedErrBytes = reader.readByteArray("checkCommittedErrBytes"); if (!reader.isLastRead()) @@ -215,7 +215,7 @@ public GridCacheReturn returnValue() { reader.incrementState(); - case 7: + case 8: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -223,7 +223,7 @@ public GridCacheReturn returnValue() { reader.incrementState(); - case 8: + case 9: retVal = reader.readMessage("retVal"); if (!reader.isLastRead()) @@ -243,7 +243,7 @@ public GridCacheReturn returnValue() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 9; + return 10; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java index a091d44ac423f..ec92c402a288b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java @@ -24,6 +24,8 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -34,11 +36,13 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.GridCacheMappedVersion; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishResponse; +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException; import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException; import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException; import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; @@ -46,6 +50,7 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.CI1; import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; @@ -115,6 +120,7 @@ public GridDhtTxLocal() { * @param storeEnabled Store enabled flag. * @param txSize Expected transaction size. * @param txNodes Transaction nodes mapping. + * @param parentTx Transaction from which this transaction was copied by(if it was). */ public GridDhtTxLocal( GridCacheSharedContext cctx, @@ -138,7 +144,8 @@ public GridDhtTxLocal( int txSize, Map> txNodes, UUID subjId, - int taskNameHash + int taskNameHash, + GridNearTxLocal parentTx ) { super( cctx, @@ -170,6 +177,8 @@ public GridDhtTxLocal( threadId = nearThreadId; + setParentTx(parentTx); + assert !F.eq(xidVer, nearXidVer); initResult(); @@ -467,7 +476,11 @@ else if (!lockFut.isDone()) { ", tx=" + CU.txString(this) + ']'); } catch (IgniteCheckedException e) { - U.error(log, "Failed to finish transaction [commit=" + commit + ", tx=" + this + ']', e); + logTxFinishErrorSafe(log, commit, e); + + // Treat heuristic exception as critical. + if (X.hasCause(e, IgniteTxHeuristicCheckedException.class)) + cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); err = e; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java index 29169162caa28..86f9c3c0d0cb8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java @@ -29,6 +29,8 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -41,6 +43,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; +import org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxOnePhaseCommitAckRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxOnePhaseCommitAckRequest.java index 67eacd3f8c5f8..50f2e7947b1c4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxOnePhaseCommitAckRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxOnePhaseCommitAckRequest.java @@ -97,7 +97,7 @@ public Collection versions() { } switch (writer.state()) { - case 2: + case 3: if (!writer.writeCollection("vers", vers, MessageCollectionItemType.MSG)) return false; @@ -119,7 +119,7 @@ public Collection versions() { return false; switch (reader.state()) { - case 2: + case 3: vers = reader.readCollection("vers", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -139,6 +139,6 @@ public Collection versions() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 3; + return 4; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java index 57280788bc16f..a7816c5eebdba 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; @@ -36,6 +37,8 @@ import org.apache.ignite.IgniteInterruptedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.IgniteDiagnosticAware; import org.apache.ignite.internal.IgniteDiagnosticPrepareContext; import org.apache.ignite.internal.IgniteInternalFuture; @@ -96,12 +99,14 @@ import org.jetbrains.annotations.Nullable; import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_LOADED; +import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_VALIDATE_CACHE_REQUESTS; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.CREATE; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.DELETE; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.NOOP; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.READ; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.UPDATE; +import static org.apache.ignite.internal.util.lang.GridFunc.isEmpty; import static org.apache.ignite.transactions.TransactionState.PREPARED; /** @@ -215,6 +220,9 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture 0 ? new PrepareTimeoutObject(timeout) : null; + + if (tx.onePhaseCommit()) + timeoutAddedLatch = new CountDownLatch(1); } /** {@inheritDoc} */ @@ -690,6 +701,14 @@ private boolean mapIfLocked() { if (!MAPPED_UPD.compareAndSet(this, 0, 1)) return false; + if (timeoutObj != null && tx.onePhaseCommit()) { + U.awaitQuiet(timeoutAddedLatch); + + // Disable timeouts after all locks are acquired for one-phase commit or partition desync will occur. + if (!cctx.time().removeTimeoutObject(timeoutObj)) + return true; // Should not proceed with prepare if tx is already timed out. + } + if (forceKeysFut == null || (forceKeysFut.isDone() && forceKeysFut.error() == null)) prepare0(); else { @@ -728,7 +747,7 @@ private boolean mapIfLocked() { tx.clearPrepareFuture(this); // Do not commit one-phase commit transaction if originating node has near cache enabled. - if (tx.onePhaseCommit() && tx.commitOnPrepare()) { + if (tx.commitOnPrepare()) { assert last; Throwable prepErr = this.err; @@ -738,37 +757,30 @@ private boolean mapIfLocked() { onComplete(res); - if (tx.commitOnPrepare()) { - if (tx.markFinalizing(IgniteInternalTx.FinalizationStatus.USER_FINISH)) { - IgniteInternalFuture fut = null; - - CIX1> resClo = - new CIX1>() { - @Override public void applyx(IgniteInternalFuture fut) { - if(res.error() == null && fut.error() != null) - res.error(fut.error()); + if (tx.markFinalizing(IgniteInternalTx.FinalizationStatus.USER_FINISH)) { + CIX1> resClo = + new CIX1>() { + @Override public void applyx(IgniteInternalFuture fut) { + if (res.error() == null && fut.error() != null) + res.error(fut.error()); - if (REPLIED_UPD.compareAndSet(GridDhtTxPrepareFuture.this, 0, 1)) - sendPrepareResponse(res); - } - }; + if (REPLIED_UPD.compareAndSet(GridDhtTxPrepareFuture.this, 0, 1)) + sendPrepareResponse(res); + } + }; + try { if (prepErr == null) { try { - fut = tx.commitAsync(); + tx.commitAsync().listen(resClo); } - catch (RuntimeException | Error e) { - Exception hEx = new IgniteTxHeuristicCheckedException("Commit produced a runtime " + - "exception: " + CU.txString(tx), e); - - res.error(hEx); + catch (Throwable e) { + res.error(e); tx.systemInvalidate(true); try { - fut = tx.rollbackAsync(); - - fut.listen(resClo); + tx.rollbackAsync().listen(resClo); } catch (Throwable e1) { e.addSuppressed(e1); @@ -776,25 +788,25 @@ private boolean mapIfLocked() { throw e; } - } - else if (!cctx.kernalContext().isStopping()) + else if (!cctx.kernalContext().isStopping()) { try { - fut = tx.rollbackAsync(); + tx.rollbackAsync().listen(resClo); } catch (Throwable e) { - err.addSuppressed(e); - fut = null; + if (err != null) + err.addSuppressed(e); + + throw err; } + } + } + catch (Throwable e) { + tx.logTxFinishErrorSafe(log, true, e); - if (fut != null) - fut.listen(resClo); + cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } } - else { - if (REPLIED_UPD.compareAndSet(this, 0, 1)) - sendPrepareResponse(res); - } return true; } @@ -895,8 +907,6 @@ private GridNearTxPrepareResponse createPrepareResponse(@Nullable Throwable prep tx.onePhaseCommit(), tx.activeCachesDeploymentEnabled()); - res.mvccSnapshot(tx.mvccSnapshot()); - if (prepErr == null) { if (tx.needReturnValue() || tx.nearOnOriginatingNode() || tx.hasInterceptor()) addDhtValues(res); @@ -1000,7 +1010,7 @@ private boolean isMini(IgniteInternalFuture f) { * @return {@code True} if {@code done} flag was changed as a result of this call. */ private boolean onComplete(@Nullable GridNearTxPrepareResponse res) { - if ((last || tx.isSystemInvalidate()) && !(tx.near() && tx.local())) + if (!tx.onePhaseCommit() && ((last || tx.isSystemInvalidate()) && !(tx.near() && tx.local()))) tx.state(PREPARED); if (super.onDone(res, res == null ? err : null)) { @@ -1044,6 +1054,24 @@ public void prepare(GridNearTxPrepareRequest req) { this.req = req; + ClusterNode node = cctx.discovery().node(tx.topologyVersion(), tx.nearNodeId()); + + boolean validateCache = needCacheValidation(node); + + if (validateCache) { + GridDhtTopologyFuture topFut = cctx.exchange().lastFinishedFuture(); + + if (topFut != null && !isEmpty(req.writes())) { + // All caches either read only or not. So validation of one cache context is enough. + GridCacheContext ctx = F.first(req.writes()).context(); + + Throwable err = topFut.validateCache(ctx, req.recovery(), isEmpty(req.writes()), null, null); + + if (err != null) + onDone(null, new IgniteCheckedException(err)); + } + } + boolean ser = tx.serializable() && tx.optimistic(); if (!F.isEmpty(req.writes()) || (ser && !F.isEmpty(req.reads()))) { @@ -1062,14 +1090,35 @@ public void prepare(GridNearTxPrepareRequest req) { readyLocks(); - if (timeoutObj != null && !isDone()) { - // Start timeout tracking after 'readyLocks' to avoid race with timeout processing. + // Start timeout tracking after 'readyLocks' to avoid race with timeout processing. + if (timeoutObj != null) { cctx.time().addTimeoutObject(timeoutObj); + + // Fix race with add/remove timeout object if locks are mapped from another + // thread before timeout object is enqueued. + if (tx.onePhaseCommit()) + timeoutAddedLatch.countDown(); } mapIfLocked(); } + /** + * Returns {@code true} if cache validation needed. + * + * @param node Originating node. + * @return {@code True} if cache should be validated, {@code false} - otherwise. + */ + private boolean needCacheValidation(ClusterNode node) { + if (node == null) { + // The originating (aka near) node has left the topology + // and therefore the cache validation doesn't make sense. + return false; + } + + return Boolean.TRUE.equals(node.attribute(ATTR_VALIDATE_CACHE_REQUESTS)); + } + /** * Checks if this transaction needs previous value for the given tx entry. Will use passed in map to store * required key or will create new map if passed in map is {@code null}. @@ -1216,8 +1265,6 @@ private IgniteTxOptimisticCheckedException versionCheckError(IgniteTxEntry entry * */ private void prepare0() { - boolean skipInit = false; - try { if (tx.serializable() && tx.optimistic()) { IgniteCheckedException err0; @@ -1252,29 +1299,6 @@ private void prepare0() { } } - IgniteInternalFuture waitCrdCntrFut = null; - - if (req.requestMvccCounter()) { - assert last; - - assert tx.txState().mvccEnabled(); - - try { - // Request snapshot locally only because - // Mvcc Coordinator is expected to be local. - MvccSnapshot snapshot = cctx.coordinators().tryRequestSnapshotLocal(tx); - - assert snapshot != null : tx.topologyVersion(); - - tx.mvccSnapshot(snapshot); - } - catch (ClusterTopologyCheckedException e) { - onDone(e); - - return; - } - } - onEntriesLocked(); // We are holding transaction-level locks for entries here, so we can get next write version. @@ -1295,43 +1319,23 @@ private void prepare0() { return; if (last) { - if (waitCrdCntrFut != null) { - skipInit = true; - - waitCrdCntrFut.listen(new IgniteInClosure>() { - @Override public void apply(IgniteInternalFuture fut) { - try { - fut.get(); - - sendPrepareRequests(); + recheckOnePhaseCommit(); - markInitialized(); - } - catch (Throwable e) { - U.error(log, "Failed to get mvcc version for tx [txId=" + tx.nearXidVersion() + - ", err=" + e + ']', e); - - GridNearTxPrepareResponse res = createPrepareResponse(e); + if (tx.onePhaseCommit()) + tx.chainState(PREPARED); - onDone(res, res.error()); - } - } - }); - } - else - sendPrepareRequests(); + sendPrepareRequests(); } } finally { - if (!skipInit) - markInitialized(); + markInitialized(); } } /** - * + * Checking that one phase commit for transaction still actual. */ - private void sendPrepareRequests() { + private void recheckOnePhaseCommit() { if (tx.onePhaseCommit() && !tx.nearMap().isEmpty()) { for (GridDistributedTxMapping nearMapping : tx.nearMap().values()) { if (!tx.dhtMap().containsKey(nearMapping.primary().id())) { @@ -1341,7 +1345,12 @@ private void sendPrepareRequests() { } } } + } + /** + * + */ + private void sendPrepareRequests() { assert !tx.txState().mvccEnabled() || !tx.onePhaseCommit() || tx.mvccSnapshot() != null; int miniId = 0; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 30e8cebbd3638..46a06d781b576 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -90,7 +90,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest { /** */ @GridDirectCollection(PartitionUpdateCountersMessage.class) - private Collection counters; + private Collection updCntrs; /** Near transaction ID. */ private GridCacheVersion nearXidVer; @@ -136,7 +136,7 @@ public GridDhtTxPrepareRequest() { * @param storeWriteThrough Cache store write through flag. * @param retVal Need return value flag * @param mvccSnapshot Mvcc snapshot. - * @param counters Update counters for mvcc Tx. + * @param updCntrs Update counters for mvcc Tx. */ public GridDhtTxPrepareRequest( IgniteUuid futId, @@ -156,7 +156,7 @@ public GridDhtTxPrepareRequest( boolean storeWriteThrough, boolean retVal, MvccSnapshot mvccSnapshot, - Collection counters) { + Collection updCntrs) { super(tx, timeout, null, @@ -178,7 +178,7 @@ public GridDhtTxPrepareRequest( this.subjId = subjId; this.taskNameHash = taskNameHash; this.mvccSnapshot = mvccSnapshot; - this.counters = counters; + this.updCntrs = updCntrs; storeWriteThrough(storeWriteThrough); needReturnValue(retVal); @@ -201,7 +201,7 @@ public MvccSnapshot mvccSnapshot() { * @return Update counters list. */ public Collection updateCounters() { - return counters; + return updCntrs; } /** @@ -423,92 +423,92 @@ public boolean skipCompletedVersion() { } switch (writer.state()) { - case 20: - if (!writer.writeIgniteUuid("futId", futId)) - return false; - - writer.incrementState(); - case 21: - if (!writer.writeBitSet("invalidateNearEntries", invalidateNearEntries)) + if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); case 22: - if (!writer.writeInt("miniId", miniId)) + if (!writer.writeBitSet("invalidateNearEntries", invalidateNearEntries)) return false; writer.incrementState(); case 23: - if (!writer.writeUuid("nearNodeId", nearNodeId)) + if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); case 24: - if (!writer.writeCollection("nearWrites", nearWrites, MessageCollectionItemType.MSG)) + if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) return false; writer.incrementState(); case 25: - if (!writer.writeMessage("nearXidVer", nearXidVer)) + if (!writer.writeUuid("nearNodeId", nearNodeId)) return false; writer.incrementState(); case 26: - if (!writer.writeCollection("ownedKeys", ownedKeys, MessageCollectionItemType.MSG)) + if (!writer.writeCollection("nearWrites", nearWrites, MessageCollectionItemType.MSG)) return false; writer.incrementState(); case 27: - if (!writer.writeCollection("ownedVals", ownedVals, MessageCollectionItemType.MSG)) + if (!writer.writeMessage("nearXidVer", nearXidVer)) return false; writer.incrementState(); case 28: - if (!writer.writeBitSet("preloadKeys", preloadKeys)) + if (!writer.writeCollection("ownedKeys", ownedKeys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); case 29: - if (!writer.writeBoolean("skipCompletedVers", skipCompletedVers)) + if (!writer.writeCollection("ownedVals", ownedVals, MessageCollectionItemType.MSG)) return false; writer.incrementState(); case 30: - if (!writer.writeUuid("subjId", subjId)) + if (!writer.writeBitSet("preloadKeys", preloadKeys)) return false; writer.incrementState(); case 31: - if (!writer.writeInt("taskNameHash", taskNameHash)) + if (!writer.writeBoolean("skipCompletedVers", skipCompletedVers)) return false; writer.incrementState(); case 32: - if (!writer.writeMessage("topVer", topVer)) + if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); case 33: - if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) + if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); case 34: - if (!writer.writeCollection("counters", counters, MessageCollectionItemType.MSG)) + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) + return false; + + writer.incrementState(); + + case 35: + if (!writer.writeCollection("updCntrs", updCntrs, MessageCollectionItemType.MSG)) return false; writer.incrementState(); @@ -529,16 +529,8 @@ public boolean skipCompletedVersion() { return false; switch (reader.state()) { - case 20: - futId = reader.readIgniteUuid("futId"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - case 21: - invalidateNearEntries = reader.readBitSet("invalidateNearEntries"); + futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) return false; @@ -546,7 +538,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 22: - miniId = reader.readInt("miniId"); + invalidateNearEntries = reader.readBitSet("invalidateNearEntries"); if (!reader.isLastRead()) return false; @@ -554,7 +546,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 23: - nearNodeId = reader.readUuid("nearNodeId"); + miniId = reader.readInt("miniId"); if (!reader.isLastRead()) return false; @@ -562,7 +554,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 24: - nearWrites = reader.readCollection("nearWrites", MessageCollectionItemType.MSG); + mvccSnapshot = reader.readMessage("mvccSnapshot"); if (!reader.isLastRead()) return false; @@ -570,7 +562,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 25: - nearXidVer = reader.readMessage("nearXidVer"); + nearNodeId = reader.readUuid("nearNodeId"); if (!reader.isLastRead()) return false; @@ -578,7 +570,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 26: - ownedKeys = reader.readCollection("ownedKeys", MessageCollectionItemType.MSG); + nearWrites = reader.readCollection("nearWrites", MessageCollectionItemType.MSG); if (!reader.isLastRead()) return false; @@ -586,7 +578,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 27: - ownedVals = reader.readCollection("ownedVals", MessageCollectionItemType.MSG); + nearXidVer = reader.readMessage("nearXidVer"); if (!reader.isLastRead()) return false; @@ -594,7 +586,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 28: - preloadKeys = reader.readBitSet("preloadKeys"); + ownedKeys = reader.readCollection("ownedKeys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) return false; @@ -602,7 +594,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 29: - skipCompletedVers = reader.readBoolean("skipCompletedVers"); + ownedVals = reader.readCollection("ownedVals", MessageCollectionItemType.MSG); if (!reader.isLastRead()) return false; @@ -610,7 +602,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 30: - subjId = reader.readUuid("subjId"); + preloadKeys = reader.readBitSet("preloadKeys"); if (!reader.isLastRead()) return false; @@ -618,7 +610,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 31: - taskNameHash = reader.readInt("taskNameHash"); + skipCompletedVers = reader.readBoolean("skipCompletedVers"); if (!reader.isLastRead()) return false; @@ -626,7 +618,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 32: - topVer = reader.readMessage("topVer"); + subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) return false; @@ -634,7 +626,7 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 33: - mvccSnapshot = reader.readMessage("mvccSnapshot"); + taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) return false; @@ -642,7 +634,15 @@ public boolean skipCompletedVersion() { reader.incrementState(); case 34: - counters = reader.readCollection("counters", MessageCollectionItemType.MSG); + topVer = reader.readAffinityTopologyVersion("topVer"); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + + case 35: + updCntrs = reader.readCollection("updCntrs", MessageCollectionItemType.MSG); if (!reader.isLastRead()) return false; @@ -661,7 +661,7 @@ public boolean skipCompletedVersion() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 35; + return 36; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index 0c2bf8198bac6..fcb14a34c58e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -245,31 +245,31 @@ public void addPreloadEntry(GridCacheEntryInfo info) { } switch (writer.state()) { - case 10: + case 11: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeMap("invalidParts", invalidParts, MessageCollectionItemType.INT, MessageCollectionItemType.INT_ARR)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeCollection("nearEvicted", nearEvicted, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeCollection("preloadEntries", preloadEntries, MessageCollectionItemType.MSG)) return false; @@ -291,7 +291,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { return false; switch (reader.state()) { - case 10: + case 11: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -299,7 +299,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { reader.incrementState(); - case 11: + case 12: invalidParts = reader.readMap("invalidParts", MessageCollectionItemType.INT, MessageCollectionItemType.INT_ARR, false); if (!reader.isLastRead()) @@ -307,7 +307,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { reader.incrementState(); - case 12: + case 13: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -315,7 +315,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { reader.incrementState(); - case 13: + case 14: nearEvicted = reader.readCollection("nearEvicted", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -323,7 +323,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { reader.incrementState(); - case 14: + case 15: preloadEntries = reader.readCollection("preloadEntries", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -343,7 +343,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 15; + return 16; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryEnlistRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryEnlistRequest.java index b3aa56ddf3cc5..27b7c81aa1479 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryEnlistRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryEnlistRequest.java @@ -247,43 +247,43 @@ else if (val instanceof GridInvokeValue) } switch (writer.state()) { - case 3: + case 4: if (!writer.writeInt("batchId", batchId)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeIgniteUuid("dhtFutId", dhtFutId)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeMessage("lockVer", lockVer)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeInt("mvccOpCnt", mvccOpCnt)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeByte("op", op != null ? (byte)op.ordinal() : -1)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeCollection("vals", vals, MessageCollectionItemType.MSG)) return false; @@ -305,7 +305,7 @@ else if (val instanceof GridInvokeValue) return false; switch (reader.state()) { - case 3: + case 4: batchId = reader.readInt("batchId"); if (!reader.isLastRead()) @@ -313,7 +313,7 @@ else if (val instanceof GridInvokeValue) reader.incrementState(); - case 4: + case 5: dhtFutId = reader.readIgniteUuid("dhtFutId"); if (!reader.isLastRead()) @@ -321,7 +321,7 @@ else if (val instanceof GridInvokeValue) reader.incrementState(); - case 5: + case 6: keys = reader.readCollection("keys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -329,7 +329,7 @@ else if (val instanceof GridInvokeValue) reader.incrementState(); - case 6: + case 7: lockVer = reader.readMessage("lockVer"); if (!reader.isLastRead()) @@ -337,7 +337,7 @@ else if (val instanceof GridInvokeValue) reader.incrementState(); - case 7: + case 8: mvccOpCnt = reader.readInt("mvccOpCnt"); if (!reader.isLastRead()) @@ -345,7 +345,7 @@ else if (val instanceof GridInvokeValue) reader.incrementState(); - case 8: + case 9: byte opOrd; opOrd = reader.readByte("op"); @@ -357,7 +357,7 @@ else if (val instanceof GridInvokeValue) reader.incrementState(); - case 9: + case 10: vals = reader.readCollection("vals", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -372,7 +372,7 @@ else if (val instanceof GridInvokeValue) /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 10; + return 11; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryEnlistResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryEnlistResponse.java index f3b4aa7c95824..42554362199aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryEnlistResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryEnlistResponse.java @@ -60,7 +60,7 @@ public GridDhtTxQueryEnlistResponse() { * @param batchId Batch id. * @param err Error. */ - GridDhtTxQueryEnlistResponse(int cacheId, IgniteUuid futId, int batchId, + public GridDhtTxQueryEnlistResponse(int cacheId, IgniteUuid futId, int batchId, Throwable err) { this.cacheId = cacheId; this.futId = futId; @@ -117,7 +117,7 @@ public int batchId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 6; + return 7; } /** {@inheritDoc} */ @@ -135,19 +135,19 @@ public int batchId() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeInt("batchId", batchId)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeIgniteUuid("futId", futId)) return false; @@ -169,7 +169,7 @@ public int batchId() { return false; switch (reader.state()) { - case 3: + case 4: batchId = reader.readInt("batchId"); if (!reader.isLastRead()) @@ -177,7 +177,7 @@ public int batchId() { reader.incrementState(); - case 4: + case 5: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -185,7 +185,7 @@ public int batchId() { reader.incrementState(); - case 5: + case 6: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryFirstEnlistRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryFirstEnlistRequest.java index 5c1bf6cb3e61f..2220b29720f8a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryFirstEnlistRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxQueryFirstEnlistRequest.java @@ -208,56 +208,56 @@ public long cleanupVersion() { } switch (writer.state()) { - case 10: + case 11: if (!writer.writeLong("cleanupVer", cleanupVer)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeLong("cntr", cntr)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeLong("crdVer", crdVer)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeUuid("nearNodeId", nearNodeId)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeMessage("nearXidVer", nearXidVer)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 16: + case 17: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 17: + case 18: if (!writer.writeLong("timeout", timeout)) return false; writer.incrementState(); - case 18: - if (!writer.writeMessage("topVer", topVer)) + case 19: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -278,7 +278,7 @@ public long cleanupVersion() { return false; switch (reader.state()) { - case 10: + case 11: cleanupVer = reader.readLong("cleanupVer"); if (!reader.isLastRead()) @@ -286,7 +286,7 @@ public long cleanupVersion() { reader.incrementState(); - case 11: + case 12: cntr = reader.readLong("cntr"); if (!reader.isLastRead()) @@ -294,7 +294,7 @@ public long cleanupVersion() { reader.incrementState(); - case 12: + case 13: crdVer = reader.readLong("crdVer"); if (!reader.isLastRead()) @@ -302,7 +302,7 @@ public long cleanupVersion() { reader.incrementState(); - case 13: + case 14: nearNodeId = reader.readUuid("nearNodeId"); if (!reader.isLastRead()) @@ -310,7 +310,7 @@ public long cleanupVersion() { reader.incrementState(); - case 14: + case 15: nearXidVer = reader.readMessage("nearXidVer"); if (!reader.isLastRead()) @@ -318,7 +318,7 @@ public long cleanupVersion() { reader.incrementState(); - case 15: + case 16: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -326,7 +326,7 @@ public long cleanupVersion() { reader.incrementState(); - case 16: + case 17: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -334,7 +334,7 @@ public long cleanupVersion() { reader.incrementState(); - case 17: + case 18: timeout = reader.readLong("timeout"); if (!reader.isLastRead()) @@ -342,8 +342,8 @@ public long cleanupVersion() { reader.incrementState(); - case 18: - topVer = reader.readMessage("topVer"); + case 19: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; @@ -357,7 +357,7 @@ public long cleanupVersion() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 19; + return 20; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 5671d7fd0f044..3bc4de01f6b17 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -113,7 +113,7 @@ public void addNearKey(KeyCacheObject key) } switch (writer.state()) { - case 8: + case 9: if (!writer.writeCollection("nearKeys", nearKeys, MessageCollectionItemType.MSG)) return false; @@ -135,7 +135,7 @@ public void addNearKey(KeyCacheObject key) return false; switch (reader.state()) { - case 8: + case 9: nearKeys = reader.readCollection("nearKeys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -155,6 +155,6 @@ public void addNearKey(KeyCacheObject key) /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 9; + return 10; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java index e09a599246081..52658f0045945 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java @@ -23,10 +23,9 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; -import java.util.concurrent.atomic.AtomicReference; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; @@ -43,7 +42,6 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest; -import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse; import org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker; import org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTrackerImpl; import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; @@ -52,17 +50,10 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.GridLeanMap; import org.apache.ignite.internal.util.future.GridFinishedFuture; -import org.apache.ignite.internal.util.future.GridFutureAdapter; -import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.C1; -import org.apache.ignite.internal.util.typedef.CI1; -import org.apache.ignite.internal.util.typedef.CIX1; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; @@ -71,14 +62,6 @@ */ public class GridPartitionedGetFuture extends CacheDistributedGetFutureAdapter implements MvccSnapshotResponseListener { - /** */ - private static final long serialVersionUID = 0L; - - /** Logger reference. */ - private static final AtomicReference logRef = new AtomicReference<>(); - - /** Logger. */ - private static IgniteLogger log; /** */ protected final MvccSnapshot mvccSnapshot; @@ -117,7 +100,8 @@ public GridPartitionedGetFuture( boolean keepCacheObjects, @Nullable MvccSnapshot mvccSnapshot ) { - super(cctx, + super( + cctx, keys, readThrough, forcePrimary, @@ -128,13 +112,14 @@ public GridPartitionedGetFuture( skipVals, needVer, keepCacheObjects, - recovery); + recovery + ); + assert mvccSnapshot == null || cctx.mvccEnabled(); this.mvccSnapshot = mvccSnapshot; - if (log == null) - log = U.logger(cctx.kernalContext(), logRef, GridPartitionedGetFuture.class); + initLogger(GridPartitionedGetFuture.class); } /** @@ -162,14 +147,15 @@ public GridPartitionedGetFuture( public void init(AffinityTopologyVersion topVer) { AffinityTopologyVersion lockedTopVer = cctx.shared().lockedTopologyVersion(null); + // Can not remap if we in transaction and locked on some topology. if (lockedTopVer != null) { topVer = lockedTopVer; canRemap = false; } - else { - topVer = topVer.topologyVersion() > 0 ? topVer : - canRemap ? cctx.affinity().affinityTopologyVersion() : cctx.shared().exchange().readyAffinityVersion(); + else{ + // Use affinity topology version if constructor version is not specify. + topVer = topVer.topologyVersion() > 0 ? topVer : cctx.affinity().affinityTopologyVersion(); } if (!cctx.mvccEnabled() || mvccSnapshot != null) @@ -177,84 +163,33 @@ public void init(AffinityTopologyVersion topVer) { else { mvccTracker = new MvccQueryTrackerImpl(cctx, canRemap); - trackable = true; - - cctx.mvcc().addFuture(this, futId); + registrateFutureInMvccManager(this); mvccTracker.requestSnapshot(topVer, this); } } - @Override public void onResponse(MvccSnapshot res) { - AffinityTopologyVersion topVer = mvccTracker.topologyVersion(); - - assert topVer != null; - - initialMap(topVer); - } - - @Override public void onError(IgniteCheckedException e) { - onDone(e); - } - /** * @param topVer Topology version. */ private void initialMap(AffinityTopologyVersion topVer) { - map(keys, Collections.>emptyMap(), topVer); + map(keys, Collections.emptyMap(), topVer); markInitialized(); } /** {@inheritDoc} */ - @Override public boolean trackable() { - return trackable; - } + @Override public void onResponse(MvccSnapshot res) { + AffinityTopologyVersion topVer = mvccTracker.topologyVersion(); - /** {@inheritDoc} */ - @Override public void markNotTrackable() { - // Should not flip trackable flag from true to false since get future can be remapped. - } + assert topVer != null; - /** {@inheritDoc} */ - @Override public IgniteUuid futureId() { - return futId; + initialMap(topVer); } /** {@inheritDoc} */ - @Override public boolean onNodeLeft(UUID nodeId) { - boolean found = false; - - for (IgniteInternalFuture> fut : futures()) - if (isMini(fut)) { - MiniFuture f = (MiniFuture)fut; - - if (f.node().id().equals(nodeId)) { - found = true; - - f.onNodeLeft(new ClusterTopologyCheckedException("Remote node left grid (will retry): " + nodeId)); - } - } - - return found; - } - - /** - * @param nodeId Sender. - * @param res Result. - */ - @Override public void onResult(UUID nodeId, GridNearGetResponse res) { - for (IgniteInternalFuture> fut : futures()) { - if (isMini(fut)) { - MiniFuture f = (MiniFuture)fut; - - if (f.futureId().equals(res.miniId())) { - assert f.node().id().equals(nodeId); - - f.onResult(res); - } - } - } + @Override public void onError(IgniteCheckedException e) { + onDone(e); } /** {@inheritDoc} */ @@ -263,6 +198,8 @@ private void initialMap(AffinityTopologyVersion topVer) { if (trackable) cctx.mvcc().removeFuture(futId); + MvccQueryTracker mvccTracker = this.mvccTracker; + if (mvccTracker != null) mvccTracker.onDone(); @@ -274,11 +211,8 @@ private void initialMap(AffinityTopologyVersion topVer) { return false; } - /** - * @param f Future. - * @return {@code True} if mini-future. - */ - private boolean isMini(IgniteInternalFuture f) { + /** {@inheritDoc} */ + @Override protected boolean isMini(IgniteInternalFuture f) { return f.getClass().equals(MiniFuture.class); } @@ -287,68 +221,60 @@ private boolean isMini(IgniteInternalFuture f) { * @param mapped Mappings to check for duplicates. * @param topVer Topology version on which keys should be mapped. */ - private void map( + @Override protected void map( Collection keys, Map> mapped, - final AffinityTopologyVersion topVer + AffinityTopologyVersion topVer ) { Collection cacheNodes = CU.affinityNodes(cctx, topVer); - if (cacheNodes.isEmpty()) { - onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for cache " + - "(all partition nodes left the grid) [topVer=" + topVer + ", cache=" + cctx.name() + ']')); - - return; - } - - GridDhtTopologyFuture topFut = cctx.shared().exchange().lastFinishedFuture(); - - Throwable err = topFut != null ? topFut.validateCache(cctx, recovery, true, null, keys) : null; - - if (err != null) { - onDone(err); + validate(cacheNodes, topVer); + // Future can be already done with some exception. + if (isDone()) return; - } Map> mappings = U.newHashMap(cacheNodes.size()); - final int keysSize = keys.size(); + int keysSize = keys.size(); + // Map for local (key,value) pairs. Map locVals = U.newHashMap(keysSize); + // True if we have remote nodes after key mapping complete. boolean hasRmtNodes = false; - // Assign keys to primary nodes. + // Assign keys to nodes. for (KeyCacheObject key : keys) - hasRmtNodes |= map(key, mappings, locVals, topVer, mapped); + hasRmtNodes |= map(key, topVer, mappings, mapped, locVals); + // Future can be alredy done with some exception. if (isDone()) return; + // Add local read (key,value) in result. if (!locVals.isEmpty()) add(new GridFinishedFuture<>(locVals)); - if (hasRmtNodes) { - if (!trackable) { - trackable = true; - - cctx.mvcc().addFuture(this, futId); - } - } + // If we have remote nodes in mapping we should registrate future in mvcc manager. + if (hasRmtNodes) + registrateFutureInMvccManager(this); - // Create mini futures. + // Create mini futures after mapping to remote nodes. for (Map.Entry> entry : mappings.entrySet()) { - final ClusterNode n = entry.getKey(); + // Node for request. + ClusterNode n = entry.getKey(); - final LinkedHashMap mappedKeys = entry.getValue(); + // Keys for request. + LinkedHashMap mappedKeys = entry.getValue(); assert !mappedKeys.isEmpty(); // If this is the primary or backup node for the keys. if (n.isLocal()) { - final GridDhtFuture> fut = - cache().getDhtAsync(n.id(), + GridDhtFuture> fut = cache() + .getDhtAsync( + n.id(), -1, mappedKeys, false, @@ -359,67 +285,50 @@ private void map( expiryPlc, skipVals, recovery, - mvccSnapshot()); + mvccSnapshot() + ); - final Collection invalidParts = fut.invalidPartitions(); + Collection invalidParts = fut.invalidPartitions(); if (!F.isEmpty(invalidParts)) { Collection remapKeys = new ArrayList<>(keysSize); for (KeyCacheObject key : keys) { - if (key != null && invalidParts.contains(cctx.affinity().partition(key))) + int part = cctx.affinity().partition(key); + + if (key != null && invalidParts.contains(part)) { + addNodeAsInvalid(n, part, topVer); + remapKeys.add(key); + } } AffinityTopologyVersion updTopVer = cctx.shared().exchange().readyAffinityVersion(); - assert updTopVer.compareTo(topVer) > 0 : "Got invalid partitions for local node but topology version did " + - "not change [topVer=" + topVer + ", updTopVer=" + updTopVer + - ", invalidParts=" + invalidParts + ']'; - // Remap recursively. map(remapKeys, mappings, updTopVer); } // Add new future. - add(fut.chain(new C1>, Map>() { - @Override public Map apply(IgniteInternalFuture> fut) { - try { - return createResultMap(fut.get()); - } - catch (Exception e) { - U.error(log, "Failed to get values from dht cache [fut=" + fut + "]", e); + add(fut.chain(f -> { + try { + return createResultMap(f.get()); + } + catch (Exception e) { + U.error(log, "Failed to get values from dht cache [fut=" + fut + "]", e); - onDone(e); + onDone(e); - return Collections.emptyMap(); - } + return Collections.emptyMap(); } })); } else { - MiniFuture fut = new MiniFuture(n, mappedKeys, topVer, - CU.createBackupPostProcessingClosure(topVer, log, cctx, null, expiryPlc, readThrough, skipVals)); - - GridCacheMessage req = new GridNearGetRequest( - cctx.cacheId(), - futId, - fut.futureId(), - null, - mappedKeys, - readThrough, - topVer, - subjId, - taskName == null ? 0 : taskName.hashCode(), - expiryPlc != null ? expiryPlc.forCreate() : -1L, - expiryPlc != null ? expiryPlc.forAccess() : -1L, - false, - skipVals, - cctx.deploymentEnabled(), - recovery, - mvccSnapshot()); + MiniFuture miniFut = new MiniFuture(n, mappedKeys, topVer); - add(fut); // Append new future. + GridCacheMessage req = miniFut.createGetRequest(futId); + + add(miniFut); // Append new future. try { cctx.io().send(n, req, cctx.ioPolicy()); @@ -427,84 +336,119 @@ private void map( catch (IgniteCheckedException e) { // Fail the whole thing. if (e instanceof ClusterTopologyCheckedException) - fut.onNodeLeft((ClusterTopologyCheckedException)e); + miniFut.onNodeLeft((ClusterTopologyCheckedException)e); else - fut.onResult(e); + miniFut.onResult(e); } } } } /** - * @param mappings Mappings. + * @param nodesToKeysMapping Mappings. * @param key Key to map. * @param locVals Local values. * @param topVer Topology version. - * @param mapped Previously mapped. + * @param missedNodesToKeysMapping Previously mapped. * @return {@code True} if has remote nodes. */ @SuppressWarnings("ConstantConditions") private boolean map( KeyCacheObject key, - Map> mappings, - Map locVals, AffinityTopologyVersion topVer, - Map> mapped + Map> nodesToKeysMapping, + Map> missedNodesToKeysMapping, + Map locVals ) { int part = cctx.affinity().partition(key); List affNodes = cctx.affinity().nodesByPartition(part, topVer); + // Failed if none affinity node found. if (affNodes.isEmpty()) { - onDone(serverNotFoundError(topVer)); + onDone(serverNotFoundError(part, topVer)); return false; } - // Local get cannot be used with MVCC as local node can contain some visible version which is not latest. - boolean fastLocGet = !cctx.mvccEnabled() && (!forcePrimary || affNodes.get(0).isLocal()) && - cctx.reserveForFastLocalGet(part, topVer); + // Try to read key localy if we can. + if (tryLocalGet(key, part, topVer, affNodes, locVals)) + return false; - if (fastLocGet) { - try { - if (localGet(topVer, key, part, locVals)) - return false; - } - finally { - cctx.releaseForFastLocalGet(part, topVer); - } - } + Set invalidNodeSet = getInvalidNodes(part, topVer); - ClusterNode node = cctx.selectAffinityNodeBalanced(affNodes, canRemap); + // Get remote node for request for this key. + ClusterNode node = cctx.selectAffinityNodeBalanced(affNodes, invalidNodeSet, part, canRemap); + // Failed if none remote node found. if (node == null) { - onDone(serverNotFoundError(topVer)); + onDone(serverNotFoundError(part, topVer)); return false; } + // The node still can be local, see details implementation of #tryLocalGet(). boolean remote = !node.isLocal(); - LinkedHashMap keys = mapped.get(node); + // Check retry counter, bound for avoid inifinit remap. + if (!checkRetryPermits(key, node, missedNodesToKeysMapping)) + return false; - if (keys != null && keys.containsKey(key)) { - if (REMAP_CNT_UPD.incrementAndGet(this) > MAX_REMAP_CNT) { - onDone(new ClusterTopologyCheckedException("Failed to remap key to a new node after " + - MAX_REMAP_CNT + " attempts (key got remapped to the same node) [key=" + key + ", node=" + - U.toShortString(node) + ", mappings=" + mapped + ']')); + addNodeMapping(key, node, nodesToKeysMapping); - return false; - } - } + return remote; + } + /** + * + * @param key Key. + * @param node Mapped node. + * @param mappings Full node mapping. + */ + private void addNodeMapping( + KeyCacheObject key, + ClusterNode node, + Map> mappings + ) { LinkedHashMap old = mappings.get(node); if (old == null) mappings.put(node, old = new LinkedHashMap<>(3, 1f)); old.put(key, false); + } - return remote; + /** + * + * @param key Key. + * @param part Partition. + * @param topVer Topology version. + * @param affNodes Affynity nodes. + * @param locVals Map for local (key,value) pairs. + */ + private boolean tryLocalGet( + KeyCacheObject key, + int part, + AffinityTopologyVersion topVer, + List affNodes, + Map locVals + ) { + // Local get cannot be used with MVCC as local node can contain some visible version which is not latest. + boolean fastLocGet = !cctx.mvccEnabled() && + (!forcePrimary || affNodes.get(0).isLocal()) && + cctx.reserveForFastLocalGet(part, topVer); + + if (fastLocGet) { + try { + if (localGet(topVer, key, part, locVals)) + return true; + } + finally { + cctx.releaseForFastLocalGet(part, topVer); + } + } + + return false; } /** @@ -599,7 +543,7 @@ private boolean localGet(AffinityTopologyVersion topVer, KeyCacheObject key, int mvccSnapshot()); } - entry.touch(topVer); + entry.touch(); // Entry was not in memory or in swap, so we remove it from cache. if (v == null) { @@ -652,6 +596,27 @@ private boolean localGet(AffinityTopologyVersion topVer, KeyCacheObject key, int } } + /** + * + * @param cacheNodes Cache affynity nodes. + * @param topVer Topology version. + */ + private void validate(Collection cacheNodes, AffinityTopologyVersion topVer) { + if (cacheNodes.isEmpty()) { + onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for cache " + + "(all partition nodes left the grid) [topVer=" + topVer + ", cache=" + cctx.name() + ']')); + + return; + } + + GridDhtTopologyFuture topFut = cctx.shared().exchange().lastFinishedFuture(); + + Throwable err = topFut != null ? topFut.validateCache(cctx, recovery, true, null, keys) : null; + + if (err != null) + onDone(err); + } + /** * @return Near cache. */ @@ -692,21 +657,7 @@ private Map createResultMap(Collection infos) { /** {@inheritDoc} */ @Override public String toString() { - Collection futs = F.viewReadOnly(futures(), new C1, String>() { - @SuppressWarnings("unchecked") - @Override public String apply(IgniteInternalFuture f) { - if (isMini(f)) { - return "[node=" + ((MiniFuture)f).node().id() + - ", loc=" + ((MiniFuture)f).node().isLocal() + - ", done=" + f.isDone() + "]"; - } - else - return "[loc=true, done=" + f.isDone() + "]"; - } - }); - return S.toString(GridPartitionedGetFuture.class, this, - "innerFuts", futs, "super", super.toString()); } @@ -714,200 +665,45 @@ private Map createResultMap(Collection infos) { * Mini-future for get operations. Mini-futures are only waiting on a single * node as opposed to multiple nodes. */ - private class MiniFuture extends GridFutureAdapter> { - /** */ - private final IgniteUuid futId = IgniteUuid.randomUuid(); - - /** Node ID. */ - private final ClusterNode node; - - /** Keys. */ - @GridToStringInclude - private final LinkedHashMap keys; - - /** Topology version on which this future was mapped. */ - private final AffinityTopologyVersion topVer; - - /** Post processing closure. */ - private final IgniteInClosure> postProcessingClos; - - /** {@code True} if remapped after node left. */ - private boolean remapped; - + private class MiniFuture extends AbstractMiniFuture { /** * @param node Node. * @param keys Keys. * @param topVer Topology version. - * @param postProcessingClos Post processing closure. */ - MiniFuture(ClusterNode node, LinkedHashMap keys, AffinityTopologyVersion topVer, - @Nullable IgniteInClosure> postProcessingClos) { - this.node = node; - this.keys = keys; - this.topVer = topVer; - this.postProcessingClos = postProcessingClos; + public MiniFuture( + ClusterNode node, + LinkedHashMap keys, + AffinityTopologyVersion topVer + ) { + super(node, keys, topVer); } - /** - * @return Future ID. - */ - IgniteUuid futureId() { - return futId; - } - - /** - * @return Node ID. - */ - public ClusterNode node() { - return node; - } - - /** - * @return Keys. - */ - public Collection keys() { - return keys.keySet(); - } - - /** - * @param e Error. - */ - void onResult(Throwable e) { - if (log.isDebugEnabled()) - log.debug("Failed to get future result [fut=" + this + ", err=" + e + ']'); - - // Fail. - onDone(e); - } - - /** - * @param e Failure exception. - */ - @SuppressWarnings("UnusedParameters") - synchronized void onNodeLeft(ClusterTopologyCheckedException e) { - if (remapped) - return; - - remapped = true; - - if (log.isDebugEnabled()) - log.debug("Remote node left grid while sending or waiting for reply (will retry): " + this); - - // Try getting from existing nodes. - if (!canRemap) { - map(keys.keySet(), F.t(node, keys), topVer); - - onDone(Collections.emptyMap()); - } - else { - AffinityTopologyVersion updTopVer = - new AffinityTopologyVersion(Math.max(topVer.topologyVersion() + 1, cctx.discovery().topologyVersion())); - - cctx.shared().exchange().affinityReadyFuture(updTopVer).listen( - new CI1>() { - @Override public void apply(IgniteInternalFuture fut) { - try { - // Remap. - map(keys.keySet(), F.t(node, keys), fut.get()); - - onDone(Collections.emptyMap()); - } - catch (IgniteCheckedException e) { - GridPartitionedGetFuture.this.onDone(e); - } - } - } - ); - } - } - - /** - * @param res Result callback. - */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") - void onResult(final GridNearGetResponse res) { - final Collection invalidParts = res.invalidPartitions(); - - // If error happened on remote node, fail the whole future. - if (res.error() != null) { - onDone(res.error()); - - return; - } - - // Remap invalid partitions. - if (!F.isEmpty(invalidParts)) { - AffinityTopologyVersion rmtTopVer = res.topologyVersion(); - - assert !rmtTopVer.equals(AffinityTopologyVersion.ZERO); - - if (rmtTopVer.compareTo(topVer) <= 0) { - // Fail the whole get future. - onDone(new IgniteCheckedException("Failed to process invalid partitions response (remote node reported " + - "invalid partitions but remote topology version does not differ from local) " + - "[topVer=" + topVer + ", rmtTopVer=" + rmtTopVer + ", invalidParts=" + invalidParts + - ", nodeId=" + node.id() + ']')); - - return; - } - - if (log.isDebugEnabled()) - log.debug("Remapping mini get future [invalidParts=" + invalidParts + ", fut=" + this + ']'); - - if (!canRemap) { - map(F.view(keys.keySet(), new P1() { - @Override public boolean apply(KeyCacheObject key) { - return invalidParts.contains(cctx.affinity().partition(key)); - } - }), F.t(node, keys), topVer); - - postProcessResult(res); - - onDone(createResultMap(res.entries())); - - return; - } - - // Need to wait for next topology version to remap. - IgniteInternalFuture topFut = cctx.shared().exchange().affinityReadyFuture(rmtTopVer); - - topFut.listen(new CIX1>() { - @SuppressWarnings("unchecked") - @Override public void applyx( - IgniteInternalFuture fut) throws IgniteCheckedException { - AffinityTopologyVersion topVer = fut.get(); - - // This will append new futures to compound list. - map(F.view(keys.keySet(), new P1() { - @Override public boolean apply(KeyCacheObject key) { - return invalidParts.contains(cctx.affinity().partition(key)); - } - }), F.t(node, keys), topVer); - - postProcessResult(res); - - onDone(createResultMap(res.entries())); - } - }); - } - else { - try { - postProcessResult(res); - - onDone(createResultMap(res.entries())); - } - catch (Exception e) { - onDone(e); - } - } + /** {@inheritDoc} */ + @Override protected GridNearGetRequest createGetRequest0(IgniteUuid rootFutId, IgniteUuid futId) { + return new GridNearGetRequest( + cctx.cacheId(), + rootFutId, + futId, + null, + keys, + readThrough, + topVer, + subjId, + taskName == null ? 0 : taskName.hashCode(), + expiryPlc != null ? expiryPlc.forCreate() : -1L, + expiryPlc != null ? expiryPlc.forAccess() : -1L, + false, + skipVals, + cctx.deploymentEnabled(), + recovery, + mvccSnapshot() + ); } - /** - * @param res Response. - */ - private void postProcessResult(final GridNearGetResponse res) { - if (postProcessingClos != null) - postProcessingClos.apply(res.entries()); + /** {@inheritDoc} */ + @Override protected Map createResultMap(Collection entries) { + return GridPartitionedGetFuture.this.createResultMap(entries); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java index 4dc72b2a0dd6e..58dd56d355a66 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java @@ -18,8 +18,12 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.UUID; +import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReference; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; @@ -27,6 +31,7 @@ import org.apache.ignite.internal.IgniteDiagnosticAware; import org.apache.ignite.internal.IgniteDiagnosticPrepareContext; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.NodeStoppingException; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -51,8 +56,6 @@ import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.CI1; -import org.apache.ignite.internal.util.typedef.CIX1; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; @@ -61,13 +64,25 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.jetbrains.annotations.Nullable; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_NEAR_GET_MAX_REMAPS; +import static org.apache.ignite.IgniteSystemProperties.getInteger; import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING; /** * */ -public class GridPartitionedSingleGetFuture extends GridCacheFutureAdapter implements GridCacheFuture, - CacheGetFuture, IgniteDiagnosticAware { +public class GridPartitionedSingleGetFuture extends GridCacheFutureAdapter + implements CacheGetFuture, IgniteDiagnosticAware { + /** Default max remap count value. */ + public static final int DFLT_MAX_REMAP_CNT = 3; + + /** Maximum number of attempts to remap key to the same primary node. */ + protected static final int MAX_REMAP_CNT = getInteger(IGNITE_NEAR_GET_MAX_REMAPS, DFLT_MAX_REMAP_CNT); + + /** Remap count updater. */ + protected static final AtomicIntegerFieldUpdater REMAP_CNT_UPD = + AtomicIntegerFieldUpdater.newUpdater(GridPartitionedSingleGetFuture.class, "remapCnt"); + /** Logger reference. */ private static final AtomicReference logRef = new AtomicReference<>(); @@ -132,6 +147,12 @@ public class GridPartitionedSingleGetFuture extends GridCacheFutureAdapter invalidNodes = Collections.emptySet(); + + /** Remap count. */ + protected volatile int remapCnt; + /** * @param cctx Context. * @param key Key. @@ -197,30 +218,30 @@ public GridPartitionedSingleGetFuture( } /** - * + * Initialize future. */ public void init() { - AffinityTopologyVersion topVer = this.topVer.topologyVersion() > 0 ? this.topVer : - canRemap ? cctx.affinity().affinityTopologyVersion() : cctx.shared().exchange().readyAffinityVersion(); - - GridDhtTopologyFuture topFut = cctx.shared().exchange().lastFinishedFuture(); - - Throwable err = topFut != null ? topFut.validateCache(cctx, recovery, true, key, null) : null; - - if (err != null) { - onDone(err); + AffinityTopologyVersion mappingtopVermappingtopVer; - return; + if (topVer.topologyVersion() > 0) + mappingtopVermappingtopVer = topVer; + else { + mappingtopVermappingtopVer = canRemap ? + cctx.affinity().affinityTopologyVersion() : + cctx.shared().exchange().readyAffinityVersion(); } - map(topVer); + map(mappingtopVermappingtopVer); } /** * @param topVer Topology version. */ @SuppressWarnings("unchecked") - private void map(final AffinityTopologyVersion topVer) { + private void map(AffinityTopologyVersion topVer) { + if (!validate(topVer)) + return; + ClusterNode node = mapKeyToNode(topVer); if (node == null) { @@ -232,45 +253,45 @@ private void map(final AffinityTopologyVersion topVer) { if (isDone()) return; + // Read value if node is localNode. if (node.isLocal()) { - final GridDhtFuture fut = cctx.dht().getDhtSingleAsync(node.id(), - -1, - key, - false, - readThrough, - topVer, - subjId, - taskName == null ? 0 : taskName.hashCode(), - expiryPlc, - skipVals, - recovery, - mvccSnapshot); - - final Collection invalidParts = fut.invalidPartitions(); + GridDhtFuture fut = cctx.dht() + .getDhtSingleAsync( + node.id(), + -1, + key, + false, + readThrough, + topVer, + subjId, + taskName == null ? 0 : taskName.hashCode(), + expiryPlc, + skipVals, + recovery, + mvccSnapshot + ); + + Collection invalidParts = fut.invalidPartitions(); if (!F.isEmpty(invalidParts)) { - AffinityTopologyVersion updTopVer = cctx.shared().exchange().readyAffinityVersion(); + addNodeAsInvalid(node); - assert updTopVer.compareTo(topVer) > 0 : "Got invalid partitions for local node but topology " + - "version did not change [topVer=" + topVer + ", updTopVer=" + updTopVer + - ", invalidParts=" + invalidParts + ']'; + AffinityTopologyVersion updTopVer = cctx.shared().exchange().readyAffinityVersion(); // Remap recursively. map(updTopVer); } else { - fut.listen(new CI1>() { - @Override public void apply(IgniteInternalFuture fut) { - try { - GridCacheEntryInfo info = fut.get(); + fut.listen(f -> { + try { + GridCacheEntryInfo info = f.get(); - setResult(info); - } - catch (Exception e) { - U.error(log, "Failed to get values from dht cache [fut=" + fut + "]", e); + setResult(info); + } + catch (Exception e) { + U.error(log, "Failed to get values from dht cache [fut=" + fut + "]", e); - onDone(e); - } + onDone(e); } }); } @@ -283,15 +304,11 @@ private void map(final AffinityTopologyVersion topVer) { this.node = node; } - if (!trackable) { - trackable = true; - - cctx.mvcc().addFuture(this, futId); - } + registrateFutureInMvccManager(this); boolean needVer = this.needVer; - final BackupPostProcessingClosure postClos = CU.createBackupPostProcessingClosure(topVer, log, + BackupPostProcessingClosure postClos = CU.createBackupPostProcessingClosure(topVer, log, cctx, key, expiryPlc, readThrough, skipVals); if (postClos != null) { @@ -301,7 +318,8 @@ private void map(final AffinityTopologyVersion topVer) { postProcessingClos = postClos; } - GridCacheMessage req = new GridNearSingleGetRequest(cctx.cacheId(), + GridCacheMessage req = new GridNearSingleGetRequest( + cctx.cacheId(), futId.localId(), key, readThrough, @@ -315,7 +333,8 @@ private void map(final AffinityTopologyVersion topVer) { needVer, cctx.deploymentEnabled(), recovery, - mvccSnapshot); + mvccSnapshot + ); try { cctx.io().send(node, req, cctx.ioPolicy()); @@ -338,35 +357,58 @@ private void map(final AffinityTopologyVersion topVer) { List affNodes = cctx.affinity().nodesByPartition(part, topVer); + // Failed if none affinity node found by assigment. if (affNodes.isEmpty()) { - onDone(serverNotFoundError(topVer)); + onDone(serverNotFoundError(part, topVer)); + + return null; + } + + // Try to read key localy if we can. + if (tryLocalGet(key, part, topVer, affNodes)) + return null; + + ClusterNode affNode = cctx.selectAffinityNodeBalanced(affNodes, getInvalidNodes(), part, canRemap); + + // Failed if none balanced node found. + if (affNode == null) { + onDone(serverNotFoundError(part, topVer)); return null; } + return affNode; + } + + /** + * + * @param key Key. + * @param part Partition. + * @param topVer Topology version. + * @param affNodes Affynity nodes. + */ + private boolean tryLocalGet( + KeyCacheObject key, + int part, + AffinityTopologyVersion topVer, + List affNodes + ) { // Local get cannot be used with MVCC as local node can contain some visible version which is not latest. - boolean fastLocGet = !cctx.mvccEnabled() && (!forcePrimary || affNodes.get(0).isLocal()) && + boolean fastLocGet = !cctx.mvccEnabled() && + (!forcePrimary || affNodes.get(0).isLocal()) && cctx.reserveForFastLocalGet(part, topVer); if (fastLocGet) { try { - if (localGet(topVer, part)) - return null; + if (localGet(topVer, key, part)) + return true; } finally { cctx.releaseForFastLocalGet(part, topVer); } } - ClusterNode affNode = cctx.selectAffinityNodeBalanced(affNodes, canRemap); - - if (affNode == null) { - onDone(serverNotFoundError(topVer)); - - return null; - } - - return affNode; + return false; } /** @@ -374,7 +416,7 @@ private void map(final AffinityTopologyVersion topVer) { * @param part Partition. * @return {@code True} if future completed. */ - private boolean localGet(AffinityTopologyVersion topVer, int part) { + private boolean localGet(AffinityTopologyVersion topVer, KeyCacheObject key, int part) { assert cctx.affinityNode() : this; GridDhtCacheAdapter colocated = cctx.dht(); @@ -458,7 +500,7 @@ private boolean localGet(AffinityTopologyVersion topVer, int part) { mvccSnapshot); } - entry.touch(topVer); + entry.touch(); // Entry was not in memory or in swap, so we remove it from cache. if (v == null) { @@ -511,13 +553,29 @@ private boolean localGet(AffinityTopologyVersion topVer, int part) { } } + /** + * @param fut Future. + */ + private void registrateFutureInMvccManager(GridCacheFuture fut) { + if (!trackable) { + trackable = true; + + cctx.mvcc().addFuture(fut, futId); + } + } + /** * @param nodeId Node ID. * @param res Result. */ public void onResult(UUID nodeId, GridNearSingleGetResponse res) { - if (!processResponse(nodeId) || - !checkError(res.error(), res.invalidPartitions(), res.topologyVersion(), nodeId)) + // Brake here if response from unexpected node. + if (!processResponse(nodeId)) + return; + + // Brake here if exception was throws on remote node or + // parition on remote node is invalid. + if (!checkError(nodeId, res.invalidPartitions(), res.topologyVersion(), res.error())) return; Message res0 = res.result(); @@ -552,13 +610,15 @@ else if (readThrough && res0 instanceof CacheVersionedValue) { } } - /** - * @param nodeId Node ID. - * @param res Result. - */ + /** {@inheritDoc} */ @Override public void onResult(UUID nodeId, GridNearGetResponse res) { - if (!processResponse(nodeId) || - !checkError(res.error(), !F.isEmpty(res.invalidPartitions()), res.topologyVersion(), nodeId)) + // Brake here if response from unexpected node. + if (!processResponse(nodeId)) + return; + + // Brake here if exception was throws on remote node or + // parition on remote node is invalid. + if (!checkError(nodeId, !F.isEmpty(res.invalidPartitions()), res.topologyVersion(), res.error())) return; Collection infos = res.entries(); @@ -591,10 +651,12 @@ private boolean processResponse(UUID nodeId) { * @param nodeId Node ID. * @return {@code True} if should process received response. */ - private boolean checkError(@Nullable IgniteCheckedException err, + private boolean checkError( + UUID nodeId, boolean invalidParts, AffinityTopologyVersion rmtTopVer, - UUID nodeId) { + @Nullable IgniteCheckedException err + ) { if (err != null) { onDone(err); @@ -602,34 +664,10 @@ private boolean checkError(@Nullable IgniteCheckedException err, } if (invalidParts) { - assert !rmtTopVer.equals(AffinityTopologyVersion.ZERO); - - if (rmtTopVer.compareTo(topVer) <= 0) { - // Fail the whole get future. - onDone(new IgniteCheckedException("Failed to process invalid partitions response (remote node reported " + - "invalid partitions but remote topology version does not differ from local) " + - "[topVer=" + topVer + ", rmtTopVer=" + rmtTopVer + ", part=" + cctx.affinity().partition(key) + - ", nodeId=" + nodeId + ']')); - - return false; - } + addNodeAsInvalid(cctx.node(nodeId)); if (canRemap) { - IgniteInternalFuture topFut = cctx.shared().exchange().affinityReadyFuture(rmtTopVer); - - topFut.listen(new CIX1>() { - @Override public void applyx(IgniteInternalFuture fut) { - try { - AffinityTopologyVersion topVer = fut.get(); - - remap(topVer); - } - catch (IgniteCheckedException e) { - onDone(e); - } - } - }); - + awaitVersionAndRemap(rmtTopVer); } else map(topVer); @@ -718,12 +756,71 @@ private boolean partitionOwned(int part) { } /** + * @param node Invalid node. + */ + private synchronized void addNodeAsInvalid(ClusterNode node) { + if (invalidNodes == Collections.emptySet()) + invalidNodes = new HashSet<>(); + + invalidNodes.add(node); + } + + /** + * @return Set of invalid cluster nodes. + */ + protected synchronized Set getInvalidNodes() { + return invalidNodes; + } + + /** + * @param topVer Topology version. + */ + private boolean checkRetryPermits(AffinityTopologyVersion topVer) { + if (topVer.equals(this.topVer)) + return true; + + if (REMAP_CNT_UPD.incrementAndGet(this) > MAX_REMAP_CNT) { + ClusterNode node0 = node; + + onDone(new ClusterTopologyCheckedException("Failed to remap key to a new node after " + + MAX_REMAP_CNT + " attempts (key got remapped to the same node) [key=" + key + ", node=" + + (node0 != null ? U.toShortString(node0) : node0) + ", invalidNodes=" + invalidNodes + ']')); + + return false; + } + + return true; + } + + /** + * @param part Partition. * @param topVer Topology version. * @return Exception. */ - private ClusterTopologyServerNotFoundException serverNotFoundError(AffinityTopologyVersion topVer) { + private ClusterTopologyServerNotFoundException serverNotFoundError(int part, AffinityTopologyVersion topVer) { return new ClusterTopologyServerNotFoundException("Failed to map keys for cache " + - "(all partition nodes left the grid) [topVer=" + topVer + ", cache=" + cctx.name() + ']'); + "(all partition nodes left the grid) [topVer=" + topVer + ", part=" + part + ", cache=" + cctx.name() + ']'); + } + + /** + * @param topVer Topology version. + * @return True if validate success, False is not. + */ + private boolean validate(AffinityTopologyVersion topVer) { + if (!checkRetryPermits(topVer)) + return false; + + GridDhtTopologyFuture lastFut = cctx.shared().exchange().lastFinishedFuture(); + + Throwable error = lastFut.validateCache(cctx, recovery, true, key, null); + + if (error != null) { + onDone(error); + + return false; + } + else + return true; } /** {@inheritDoc} */ @@ -737,20 +834,9 @@ private ClusterTopologyServerNotFoundException serverNotFoundError(AffinityTopol return false; if (canRemap) { - AffinityTopologyVersion updTopVer = new AffinityTopologyVersion( - Math.max(topVer.topologyVersion() + 1, cctx.discovery().topologyVersion())); - - cctx.shared().exchange().affinityReadyFuture(updTopVer).listen( - new CI1>() { - @Override public void apply(IgniteInternalFuture fut) { - try { - remap(fut.get()); - } - catch (IgniteCheckedException e) { - onDone(e); - } - } - }); + long maxTopVer = Math.max(topVer.topologyVersion() + 1, cctx.discovery().topologyVersion()); + + awaitVersionAndRemap(new AffinityTopologyVersion(maxTopVer)); } else remap(topVer); @@ -758,12 +844,34 @@ private ClusterTopologyServerNotFoundException serverNotFoundError(AffinityTopol return true; } + /** + * @param topVer Topology version. + */ + private void awaitVersionAndRemap(AffinityTopologyVersion topVer){ + IgniteInternalFuture awaitTopologyVersionFuture = + cctx.shared().exchange().affinityReadyFuture(topVer); + + awaitTopologyVersionFuture.listen(f -> { + try { + remap(f.get()); + } + catch (IgniteCheckedException e) { + onDone(e); + } + }); + } + /** * @param topVer Topology version. */ private void remap(final AffinityTopologyVersion topVer) { cctx.closures().runLocalSafe(new Runnable() { @Override public void run() { + // If topology changed reset collection of invalid nodes. + synchronized (this) { + invalidNodes = Collections.emptySet(); + } + map(topVer); } }); @@ -776,7 +884,8 @@ private void remap(final AffinityTopologyVersion topVer) { if (trackable) cctx.mvcc().removeFuture(futId); - cctx.dht().sendTtlUpdateRequest(expiryPlc); + if (!(err instanceof NodeStoppingException)) + cctx.dht().sendTtlUpdateRequest(expiryPlc); return true; } @@ -816,6 +925,6 @@ private void remap(final AffinityTopologyVersion topVer) { /** {@inheritDoc} */ @Override public String toString() { - return S.toString(GridPartitionedSingleGetFuture.class, this); + return S.toString(GridPartitionedSingleGetFuture.class, this, "super", super.toString()); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/PartitionUpdateCountersMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/PartitionUpdateCountersMessage.java index 3e5953fcb7ca6..f30d51d9016d6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/PartitionUpdateCountersMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/PartitionUpdateCountersMessage.java @@ -20,6 +20,7 @@ import java.nio.ByteBuffer; import java.util.Arrays; import org.apache.ignite.internal.GridDirectTransient; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageReader; @@ -28,6 +29,7 @@ /** * Partition update counters message. */ +@IgniteCodeGeneratingFail public class PartitionUpdateCountersMessage implements Message { /** */ private static final int ITEM_SIZE = 4 /* partition */ + 8 /* initial counter */ + 8 /* updates count */; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateRequest.java index a5e9feb1255a4..0096f012d0fe5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateRequest.java @@ -484,7 +484,7 @@ final boolean isFlag(int mask) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 12; + return 13; } /** {@inheritDoc} */ @@ -502,55 +502,55 @@ final boolean isFlag(int mask) { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeLong("nearFutId", nearFutId)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeUuid("nearNodeId", nearNodeId)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeByte("syncMode", syncMode != null ? (byte)syncMode.ordinal() : -1)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 10: - if (!writer.writeMessage("topVer", topVer)) + case 11: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeMessage("writeVer", writeVer)) return false; @@ -572,7 +572,7 @@ final boolean isFlag(int mask) { return false; switch (reader.state()) { - case 3: + case 4: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -580,7 +580,7 @@ final boolean isFlag(int mask) { reader.incrementState(); - case 4: + case 5: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -588,7 +588,7 @@ final boolean isFlag(int mask) { reader.incrementState(); - case 5: + case 6: nearFutId = reader.readLong("nearFutId"); if (!reader.isLastRead()) @@ -596,7 +596,7 @@ final boolean isFlag(int mask) { reader.incrementState(); - case 6: + case 7: nearNodeId = reader.readUuid("nearNodeId"); if (!reader.isLastRead()) @@ -604,7 +604,7 @@ final boolean isFlag(int mask) { reader.incrementState(); - case 7: + case 8: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -612,7 +612,7 @@ final boolean isFlag(int mask) { reader.incrementState(); - case 8: + case 9: byte syncModeOrd; syncModeOrd = reader.readByte("syncMode"); @@ -624,7 +624,7 @@ final boolean isFlag(int mask) { reader.incrementState(); - case 9: + case 10: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -632,15 +632,15 @@ final boolean isFlag(int mask) { reader.incrementState(); - case 10: - topVer = reader.readMessage("topVer"); + case 11: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 11: + case 12: writeVer = reader.readMessage("writeVer"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index c7b6677ebdbdc..3700a6f865f2f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -31,9 +31,11 @@ import javax.cache.expiry.ExpiryPolicy; import javax.cache.processor.EntryProcessor; import javax.cache.processor.EntryProcessorResult; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.binary.BinaryInvalidTypeException; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.NodeStoppingException; @@ -41,7 +43,6 @@ import org.apache.ignite.internal.UnregisteredClassException; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.mem.IgniteOutOfMemoryException; -import org.apache.ignite.internal.processors.cache.persistence.StorageException; import org.apache.ignite.internal.processors.affinity.AffinityAssignment; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; @@ -68,12 +69,14 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtFuture; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysRequest; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysResponse; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearAtomicCache; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest; @@ -83,6 +86,7 @@ import org.apache.ignite.internal.processors.cache.dr.GridCacheDrExpirationInfo; import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext; @@ -119,6 +123,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_ATOMIC_DEFERRED_ACK_TIMEOUT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; +import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_VALIDATE_CACHE_REQUESTS; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.DELETE; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.UPDATE; @@ -1592,7 +1597,7 @@ private IgniteInternalFuture> getAllAsync0(@Nullable Collection affFut = + ctx.shared().exchange().affinityReadyFuture(req.topologyVersion()); + + if (affFut.isDone()) { + List futs = + ctx.shared().exchange().exchangeFutures(); + + boolean found = false; + + for (int i = 0; i < futs.size(); ++i) { + GridDhtPartitionsExchangeFuture fut = futs.get(i); + + // We have to check fut.exchangeDone() here - + // otherwise attempt to get topVer will throw error. + // We won't skip needed future as per affinity ready future is done. + if (fut.exchangeDone() && + fut.topologyVersion().equals(req.topologyVersion())) { + topFut = fut; + + found = true; + + break; + } + } + + assert found: "The requested topology future cannot be found [topVer=" + + req.topologyVersion() + ']'; + } + else { + affFut.listen(f -> updateAllAsyncInternal0(node, req, completionCb)); + + return; + } + + assert req.topologyVersion().equals(topFut.topologyVersion()) : + "The requested topology version cannot be found [" + + "reqTopFut=" + req.topologyVersion() + + ", topFut=" + topFut + ']'; + } + + assert topFut.isDone() : topFut; + + Throwable err = topFut.validateCache(ctx, req.recovery(), false, null, null); + + if (err != null) { + IgniteCheckedException e = new IgniteCheckedException(err); + + res.error(e); + + completionCb.apply(req, res); + + return; + } + } + update(node, locked, req, res, updDhtRes); dhtFut = updDhtRes.dhtFuture(); @@ -2725,6 +2798,8 @@ else if (GridDhtCacheEntry.ReaderId.contains(readers, nearNode.id())) { final GridDhtAtomicAbstractUpdateFuture dhtFut = dhtUpdRes.dhtFuture(); + Collection failedToUnwrapKeys = null; + // Avoid iterator creation. for (int i = 0; i < entries.size(); i++) { GridDhtCacheEntry entry = entries.get(i); @@ -2737,9 +2812,26 @@ else if (GridDhtCacheEntry.ReaderId.contains(readers, nearNode.id())) { continue; } - if (storeErr != null && - storeErr.failedKeys().contains(entry.key().value(ctx.cacheObjectContext(), false))) - continue; + if (storeErr != null) { + Object key = entry.key(); + + try { + key = entry.key().value(ctx.cacheObjectContext(), false); + } + catch (BinaryInvalidTypeException e) { + if (log.isDebugEnabled()) { + if (failedToUnwrapKeys == null) + failedToUnwrapKeys = new ArrayList<>(); + + // To limit keys count in log message. + if (failedToUnwrapKeys.size() < 5) + failedToUnwrapKeys.add(key); + } + } + + if (storeErr.failedKeys().contains(key)) + continue; + } try { // We are holding java-level locks on entries at this point. @@ -2868,6 +2960,10 @@ else if (GridDhtCacheEntry.ReaderId.contains(readers, nearNode.id())) { dhtUpdRes.processedEntriesCount(firstEntryIdx + i + 1); } + if (failedToUnwrapKeys != null) { + log.warning("Failed to get values of keys: " + failedToUnwrapKeys + + " (the binary objects will be used instead)."); + } } catch (IgniteCheckedException e) { res.addFailedKeys(putMap != null ? putMap.keySet() : rmvKeys, e); @@ -3006,7 +3102,7 @@ private void unlockEntries(List locked, AffinityTopologyVersi for (int i = 0; i < size; i++) { GridCacheMapEntry entry = locked.get(i); if (entry != null && (skip == null || !skip.contains(entry.key()))) - entry.touch(topVer); + entry.touch(); } } @@ -3286,7 +3382,7 @@ && writeThrough() && !req.skipStore(), } finally { if (entry != null) - entry.touch(req.topologyVersion()); + entry.touch(); } } } @@ -3614,6 +3710,17 @@ private void sendNearUpdateReply(UUID nodeId, GridNearAtomicUpdateResponse res) } } + /** + * Returns {@code true} if cache validation needed. + * + * @return {@code True} if cache should be validated, {@code false} - otherwise. + */ + private boolean needCacheValidation(ClusterNode node) { + assert node != null: "The near node must not be null. This is guaranteed by processNearAtomicUpdateRequest()"; + + return Boolean.TRUE.equals(node.attribute(ATTR_VALIDATE_CACHE_REQUESTS)); + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtAtomicCache.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java index 0c069da80082e..ee5eac15a6c45 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java @@ -119,7 +119,7 @@ GridLongList futureIds() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeMessage("futIds", futIds)) return false; @@ -141,7 +141,7 @@ GridLongList futureIds() { return false; switch (reader.state()) { - case 3: + case 4: futIds = reader.readMessage("futIds"); if (!reader.isLastRead()) @@ -161,7 +161,7 @@ GridLongList futureIds() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 4; + return 5; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java index 71d23216f0e2b..8f11ead53adff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicNearResponse.java @@ -171,7 +171,7 @@ public long futureId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 8; + return 9; } /** {@inheritDoc} */ @@ -210,31 +210,31 @@ public long futureId() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeMessage("errs", errs)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeInt("partId", partId)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeUuid("primaryId", primaryId)) return false; @@ -256,7 +256,7 @@ public long futureId() { return false; switch (reader.state()) { - case 3: + case 4: errs = reader.readMessage("errs"); if (!reader.isLastRead()) @@ -264,7 +264,7 @@ public long futureId() { reader.incrementState(); - case 4: + case 5: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -272,7 +272,7 @@ public long futureId() { reader.incrementState(); - case 5: + case 6: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -280,7 +280,7 @@ public long futureId() { reader.incrementState(); - case 6: + case 7: partId = reader.readInt("partId"); if (!reader.isLastRead()) @@ -288,7 +288,7 @@ public long futureId() { reader.incrementState(); - case 7: + case 8: primaryId = reader.readUuid("primaryId"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java index 19b24b052d795..16be80e2e5a71 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicSingleUpdateRequest.java @@ -373,25 +373,25 @@ private void near(boolean near) { } switch (writer.state()) { - case 12: + case 13: if (!writer.writeMessage("key", key)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeMessage("prevVal", prevVal)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeLong("updateCntr", updateCntr)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeMessage("val", val)) return false; @@ -413,7 +413,7 @@ private void near(boolean near) { return false; switch (reader.state()) { - case 12: + case 13: key = reader.readMessage("key"); if (!reader.isLastRead()) @@ -421,7 +421,7 @@ private void near(boolean near) { reader.incrementState(); - case 13: + case 14: prevVal = reader.readMessage("prevVal"); if (!reader.isLastRead()) @@ -429,7 +429,7 @@ private void near(boolean near) { reader.incrementState(); - case 14: + case 15: updateCntr = reader.readLong("updateCntr"); if (!reader.isLastRead()) @@ -437,7 +437,7 @@ private void near(boolean near) { reader.incrementState(); - case 15: + case 16: val = reader.readMessage("val"); if (!reader.isLastRead()) @@ -487,7 +487,7 @@ private void finishUnmarshalObject(@Nullable CacheObject obj, GridCacheContext c /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 16; + return 17; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 30be9dcc30c22..67281f756267a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -558,97 +558,97 @@ else if (conflictVers != null) } switch (writer.state()) { - case 12: + case 13: if (!writer.writeMessage("conflictExpireTimes", conflictExpireTimes)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeCollection("conflictVers", conflictVers, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeCollection("entryProcessorsBytes", entryProcessorsBytes, MessageCollectionItemType.BYTE_ARR)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeBoolean("forceTransformBackups", forceTransformBackups)) return false; writer.incrementState(); - case 16: + case 17: if (!writer.writeObjectArray("invokeArgsBytes", invokeArgsBytes, MessageCollectionItemType.BYTE_ARR)) return false; writer.incrementState(); - case 17: + case 18: if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 18: + case 19: if (!writer.writeCollection("nearEntryProcessorsBytes", nearEntryProcessorsBytes, MessageCollectionItemType.BYTE_ARR)) return false; writer.incrementState(); - case 19: + case 20: if (!writer.writeMessage("nearExpireTimes", nearExpireTimes)) return false; writer.incrementState(); - case 20: + case 21: if (!writer.writeCollection("nearKeys", nearKeys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 21: + case 22: if (!writer.writeMessage("nearTtls", nearTtls)) return false; writer.incrementState(); - case 22: + case 23: if (!writer.writeCollection("nearVals", nearVals, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 23: + case 24: if (!writer.writeMessage("obsoleteIndexes", obsoleteIndexes)) return false; writer.incrementState(); - case 24: + case 25: if (!writer.writeCollection("prevVals", prevVals, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 25: + case 26: if (!writer.writeMessage("ttls", ttls)) return false; writer.incrementState(); - case 26: + case 27: if (!writer.writeMessage("updateCntrs", updateCntrs)) return false; writer.incrementState(); - case 27: + case 28: if (!writer.writeCollection("vals", vals, MessageCollectionItemType.MSG)) return false; @@ -670,7 +670,7 @@ else if (conflictVers != null) return false; switch (reader.state()) { - case 12: + case 13: conflictExpireTimes = reader.readMessage("conflictExpireTimes"); if (!reader.isLastRead()) @@ -678,7 +678,7 @@ else if (conflictVers != null) reader.incrementState(); - case 13: + case 14: conflictVers = reader.readCollection("conflictVers", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -686,7 +686,7 @@ else if (conflictVers != null) reader.incrementState(); - case 14: + case 15: entryProcessorsBytes = reader.readCollection("entryProcessorsBytes", MessageCollectionItemType.BYTE_ARR); if (!reader.isLastRead()) @@ -694,7 +694,7 @@ else if (conflictVers != null) reader.incrementState(); - case 15: + case 16: forceTransformBackups = reader.readBoolean("forceTransformBackups"); if (!reader.isLastRead()) @@ -702,7 +702,7 @@ else if (conflictVers != null) reader.incrementState(); - case 16: + case 17: invokeArgsBytes = reader.readObjectArray("invokeArgsBytes", MessageCollectionItemType.BYTE_ARR, byte[].class); if (!reader.isLastRead()) @@ -710,7 +710,7 @@ else if (conflictVers != null) reader.incrementState(); - case 17: + case 18: keys = reader.readCollection("keys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -718,7 +718,7 @@ else if (conflictVers != null) reader.incrementState(); - case 18: + case 19: nearEntryProcessorsBytes = reader.readCollection("nearEntryProcessorsBytes", MessageCollectionItemType.BYTE_ARR); if (!reader.isLastRead()) @@ -726,7 +726,7 @@ else if (conflictVers != null) reader.incrementState(); - case 19: + case 20: nearExpireTimes = reader.readMessage("nearExpireTimes"); if (!reader.isLastRead()) @@ -734,7 +734,7 @@ else if (conflictVers != null) reader.incrementState(); - case 20: + case 21: nearKeys = reader.readCollection("nearKeys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -742,7 +742,7 @@ else if (conflictVers != null) reader.incrementState(); - case 21: + case 22: nearTtls = reader.readMessage("nearTtls"); if (!reader.isLastRead()) @@ -750,7 +750,7 @@ else if (conflictVers != null) reader.incrementState(); - case 22: + case 23: nearVals = reader.readCollection("nearVals", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -758,7 +758,7 @@ else if (conflictVers != null) reader.incrementState(); - case 23: + case 24: obsoleteIndexes = reader.readMessage("obsoleteIndexes"); if (!reader.isLastRead()) @@ -766,7 +766,7 @@ else if (conflictVers != null) reader.incrementState(); - case 24: + case 25: prevVals = reader.readCollection("prevVals", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -774,7 +774,7 @@ else if (conflictVers != null) reader.incrementState(); - case 25: + case 26: ttls = reader.readMessage("ttls"); if (!reader.isLastRead()) @@ -782,7 +782,7 @@ else if (conflictVers != null) reader.incrementState(); - case 26: + case 27: updateCntrs = reader.readMessage("updateCntrs"); if (!reader.isLastRead()) @@ -790,7 +790,7 @@ else if (conflictVers != null) reader.incrementState(); - case 27: + case 28: vals = reader.readCollection("vals", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -816,7 +816,7 @@ else if (conflictVers != null) /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 28; + return 29; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 70bf6f5648b41..21efbb1350b3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -179,25 +179,25 @@ public void nearEvicted(List nearEvicted) { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeMessage("errs", errs)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeCollection("nearEvicted", nearEvicted, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeInt("partId", partId)) return false; @@ -219,7 +219,7 @@ public void nearEvicted(List nearEvicted) { return false; switch (reader.state()) { - case 3: + case 4: errs = reader.readMessage("errs"); if (!reader.isLastRead()) @@ -227,7 +227,7 @@ public void nearEvicted(List nearEvicted) { reader.incrementState(); - case 4: + case 5: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -235,7 +235,7 @@ public void nearEvicted(List nearEvicted) { reader.incrementState(); - case 5: + case 6: nearEvicted = reader.readCollection("nearEvicted", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -243,7 +243,7 @@ public void nearEvicted(List nearEvicted) { reader.incrementState(); - case 6: + case 7: partId = reader.readInt("partId"); if (!reader.isLastRead()) @@ -263,7 +263,7 @@ public void nearEvicted(List nearEvicted) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 7; + return 8; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java index 983b18ac38ba0..f4c9b5cf22645 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java @@ -30,6 +30,7 @@ import javax.cache.expiry.ExpiryPolicy; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.binary.BinaryInvalidTypeException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; @@ -400,10 +401,46 @@ final void onPrimaryError(GridNearAtomicAbstractUpdateRequest req, GridNearAtomi Collection keys = new ArrayList<>(keys0.size()); - for (KeyCacheObject key : keys0) - keys.add(cctx.cacheObjectContext().unwrapBinaryIfNeeded(key, keepBinary, false)); + Collection failedToUnwrapKeys = null; - err.add(keys, res.error(), req.topologyVersion()); + Exception suppressedErr = null; + + for (KeyCacheObject key : keys0) { + try { + keys.add(cctx.cacheObjectContext().unwrapBinaryIfNeeded(key, keepBinary, false)); + } + catch (BinaryInvalidTypeException e) { + keys.add(cctx.toCacheKeyObject(key)); + + if (log.isDebugEnabled()) { + if (failedToUnwrapKeys == null) + failedToUnwrapKeys = new ArrayList<>(); + + // To limit keys count in log message. + if (failedToUnwrapKeys.size() < 5) + failedToUnwrapKeys.add(key); + } + + suppressedErr = e; + } + catch (Exception e) { + keys.add(cctx.toCacheKeyObject(key)); + + suppressedErr = e; + } + } + + if (failedToUnwrapKeys != null) { + log.warning("Failed to unwrap keys: " + failedToUnwrapKeys + + " (the binary objects will be used instead)."); + } + + IgniteCheckedException error = res.error(); + + if (suppressedErr != null) + error.addSuppressed(suppressedErr); + + err.add(keys, error, req.topologyVersion()); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java index 62618f81e6af5..f0d89bf952a09 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java @@ -396,14 +396,14 @@ public void keepBinary(boolean val) { } /** - * @return Keep binary flag. + * @return Recovery flag. */ public final boolean recovery() { return isFlag(RECOVERY_FLAG_MASK); } /** - * @param val Keep binary flag. + * @param val Recovery flag. */ public void recovery(boolean val) { setFlag(val, RECOVERY_FLAG_MASK); @@ -528,7 +528,7 @@ abstract void addUpdateEntry(KeyCacheObject key, /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 10; + return 11; } /** {@inheritDoc} */ @@ -546,44 +546,44 @@ abstract void addUpdateEntry(KeyCacheObject key, } switch (writer.state()) { - case 3: + case 4: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeByte("op", op != null ? (byte)op.ordinal() : -1)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeByte("syncMode", syncMode != null ? (byte)syncMode.ordinal() : -1)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 9: - if (!writer.writeMessage("topVer", topVer)) + case 10: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -604,7 +604,7 @@ abstract void addUpdateEntry(KeyCacheObject key, return false; switch (reader.state()) { - case 3: + case 4: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -612,7 +612,7 @@ abstract void addUpdateEntry(KeyCacheObject key, reader.incrementState(); - case 4: + case 5: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -620,7 +620,7 @@ abstract void addUpdateEntry(KeyCacheObject key, reader.incrementState(); - case 5: + case 6: byte opOrd; opOrd = reader.readByte("op"); @@ -632,7 +632,7 @@ abstract void addUpdateEntry(KeyCacheObject key, reader.incrementState(); - case 6: + case 7: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -640,7 +640,7 @@ abstract void addUpdateEntry(KeyCacheObject key, reader.incrementState(); - case 7: + case 8: byte syncModeOrd; syncModeOrd = reader.readByte("syncMode"); @@ -652,7 +652,7 @@ abstract void addUpdateEntry(KeyCacheObject key, reader.incrementState(); - case 8: + case 9: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -660,8 +660,8 @@ abstract void addUpdateEntry(KeyCacheObject key, reader.incrementState(); - case 9: - topVer = reader.readMessage("topVer"); + case 10: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicCheckUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicCheckUpdateRequest.java index 96be0233c308a..a19e28029b89f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicCheckUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicCheckUpdateRequest.java @@ -101,7 +101,7 @@ GridNearAtomicAbstractUpdateRequest updateRequest() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 5; + return 6; } /** {@inheritDoc} */ @@ -119,13 +119,13 @@ GridNearAtomicAbstractUpdateRequest updateRequest() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeInt("partId", partId)) return false; @@ -147,7 +147,7 @@ GridNearAtomicAbstractUpdateRequest updateRequest() { return false; switch (reader.state()) { - case 3: + case 4: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -155,7 +155,7 @@ GridNearAtomicAbstractUpdateRequest updateRequest() { reader.incrementState(); - case 4: + case 5: partId = reader.readInt("partId"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java index d6956a64dae69..170586b22d589 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicFullUpdateRequest.java @@ -435,55 +435,55 @@ else if (conflictVers != null) } switch (writer.state()) { - case 10: + case 11: if (!writer.writeMessage("conflictExpireTimes", conflictExpireTimes)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeMessage("conflictTtls", conflictTtls)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeCollection("conflictVers", conflictVers, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeCollection("entryProcessorsBytes", entryProcessorsBytes, MessageCollectionItemType.BYTE_ARR)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeByteArray("expiryPlcBytes", expiryPlcBytes)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeObjectArray("filter", filter, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 16: + case 17: if (!writer.writeObjectArray("invokeArgsBytes", invokeArgsBytes, MessageCollectionItemType.BYTE_ARR)) return false; writer.incrementState(); - case 17: + case 18: if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 18: + case 19: if (!writer.writeCollection("vals", vals, MessageCollectionItemType.MSG)) return false; @@ -505,7 +505,7 @@ else if (conflictVers != null) return false; switch (reader.state()) { - case 10: + case 11: conflictExpireTimes = reader.readMessage("conflictExpireTimes"); if (!reader.isLastRead()) @@ -513,7 +513,7 @@ else if (conflictVers != null) reader.incrementState(); - case 11: + case 12: conflictTtls = reader.readMessage("conflictTtls"); if (!reader.isLastRead()) @@ -521,7 +521,7 @@ else if (conflictVers != null) reader.incrementState(); - case 12: + case 13: conflictVers = reader.readCollection("conflictVers", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -529,7 +529,7 @@ else if (conflictVers != null) reader.incrementState(); - case 13: + case 14: entryProcessorsBytes = reader.readCollection("entryProcessorsBytes", MessageCollectionItemType.BYTE_ARR); if (!reader.isLastRead()) @@ -537,7 +537,7 @@ else if (conflictVers != null) reader.incrementState(); - case 14: + case 15: expiryPlcBytes = reader.readByteArray("expiryPlcBytes"); if (!reader.isLastRead()) @@ -545,7 +545,7 @@ else if (conflictVers != null) reader.incrementState(); - case 15: + case 16: filter = reader.readObjectArray("filter", MessageCollectionItemType.MSG, CacheEntryPredicate.class); if (!reader.isLastRead()) @@ -553,7 +553,7 @@ else if (conflictVers != null) reader.incrementState(); - case 16: + case 17: invokeArgsBytes = reader.readObjectArray("invokeArgsBytes", MessageCollectionItemType.BYTE_ARR, byte[].class); if (!reader.isLastRead()) @@ -561,7 +561,7 @@ else if (conflictVers != null) reader.incrementState(); - case 17: + case 18: keys = reader.readCollection("keys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -569,7 +569,7 @@ else if (conflictVers != null) reader.incrementState(); - case 18: + case 19: vals = reader.readCollection("vals", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -601,7 +601,7 @@ else if (conflictVers != null) /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 19; + return 20; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java index 5c66bc46894b2..c7076988a659f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFilterRequest.java @@ -155,7 +155,7 @@ public GridNearAtomicSingleUpdateFilterRequest() { } switch (writer.state()) { - case 12: + case 13: if (!writer.writeObjectArray("filter", filter, MessageCollectionItemType.MSG)) return false; @@ -177,7 +177,7 @@ public GridNearAtomicSingleUpdateFilterRequest() { return false; switch (reader.state()) { - case 12: + case 13: filter = reader.readObjectArray("filter", MessageCollectionItemType.MSG, CacheEntryPredicate.class); if (!reader.isLastRead()) @@ -197,7 +197,7 @@ public GridNearAtomicSingleUpdateFilterRequest() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 13; + return 14; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java index 4c0d2dbc01ebe..4e87df50921f4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java @@ -23,6 +23,7 @@ import java.util.UUID; import javax.cache.expiry.ExpiryPolicy; import javax.cache.processor.EntryProcessor; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; @@ -404,8 +405,11 @@ private void updateNear(GridNearAtomicAbstractUpdateRequest req, GridNearAtomicU AffinityTopologyVersion topVer; if (cache.topology().stopping()) { - completeFuture(null,new CacheStoppedException( - cache.name()), + completeFuture( + null, + cctx.shared().cache().isCacheRestarting(cache.name())? + new IgniteCacheRestartingException(cache.name()): + new CacheStoppedException(cache.name()), null); return; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java index 865d6f8664e9e..ee3d2a4fe036a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java @@ -225,13 +225,13 @@ public GridNearAtomicSingleUpdateInvokeRequest() { } switch (writer.state()) { - case 12: + case 13: if (!writer.writeByteArray("entryProcessorBytes", entryProcessorBytes)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeObjectArray("invokeArgsBytes", invokeArgsBytes, MessageCollectionItemType.BYTE_ARR)) return false; @@ -253,7 +253,7 @@ public GridNearAtomicSingleUpdateInvokeRequest() { return false; switch (reader.state()) { - case 12: + case 13: entryProcessorBytes = reader.readByteArray("entryProcessorBytes"); if (!reader.isLastRead()) @@ -261,7 +261,7 @@ public GridNearAtomicSingleUpdateInvokeRequest() { reader.incrementState(); - case 13: + case 14: invokeArgsBytes = reader.readObjectArray("invokeArgsBytes", MessageCollectionItemType.BYTE_ARR, byte[].class); if (!reader.isLastRead()) @@ -276,7 +276,7 @@ public GridNearAtomicSingleUpdateInvokeRequest() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 14; + return 15; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java index dd3a7bedb7de9..83ec4565f49ce 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java @@ -247,13 +247,13 @@ public GridNearAtomicSingleUpdateRequest() { } switch (writer.state()) { - case 10: + case 11: if (!writer.writeMessage("key", key)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeMessage("val", val)) return false; @@ -275,7 +275,7 @@ public GridNearAtomicSingleUpdateRequest() { return false; switch (reader.state()) { - case 10: + case 11: key = reader.readMessage("key"); if (!reader.isLastRead()) @@ -283,7 +283,7 @@ public GridNearAtomicSingleUpdateRequest() { reader.incrementState(); - case 11: + case 12: val = reader.readMessage("val"); if (!reader.isLastRead()) @@ -311,7 +311,7 @@ public GridNearAtomicSingleUpdateRequest() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 12; + return 13; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java index 28ebfb13ef72b..4ccea7bfb66e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java @@ -26,6 +26,7 @@ import java.util.UUID; import javax.cache.expiry.ExpiryPolicy; import javax.cache.processor.EntryProcessor; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cluster.ClusterNode; @@ -627,7 +628,12 @@ private void updateNear(GridNearAtomicAbstractUpdateRequest req, GridNearAtomicU AffinityTopologyVersion topVer; if (cache.topology().stopping()) { - completeFuture(null,new CacheStoppedException(cache.name()), null); + completeFuture( + null, + cctx.shared().cache().isCacheRestarting(cache.name())? + new IgniteCacheRestartingException(cache.name()): + new CacheStoppedException(cache.name()), + null); return; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 37fe824a39f99..6dccd8b9cdc9b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -405,43 +405,43 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeMessage("errs", errs)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeCollection("mapping", mapping, MessageCollectionItemType.UUID)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeMessage("nearUpdates", nearUpdates)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeInt("partId", partId)) return false; writer.incrementState(); - case 8: - if (!writer.writeMessage("remapTopVer", remapTopVer)) + case 9: + if (!writer.writeAffinityTopologyVersion("remapTopVer", remapTopVer)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeMessage("ret", ret)) return false; @@ -463,7 +463,7 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { return false; switch (reader.state()) { - case 3: + case 4: errs = reader.readMessage("errs"); if (!reader.isLastRead()) @@ -471,7 +471,7 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { reader.incrementState(); - case 4: + case 5: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -479,7 +479,7 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { reader.incrementState(); - case 5: + case 6: mapping = reader.readCollection("mapping", MessageCollectionItemType.UUID); if (!reader.isLastRead()) @@ -487,7 +487,7 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { reader.incrementState(); - case 6: + case 7: nearUpdates = reader.readMessage("nearUpdates"); if (!reader.isLastRead()) @@ -495,7 +495,7 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { reader.incrementState(); - case 7: + case 8: partId = reader.readInt("partId"); if (!reader.isLastRead()) @@ -503,15 +503,15 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { reader.incrementState(); - case 8: - remapTopVer = reader.readMessage("remapTopVer"); + case 9: + remapTopVer = reader.readAffinityTopologyVersion("remapTopVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 9: + case 10: ret = reader.readMessage("ret"); if (!reader.isLastRead()) @@ -531,7 +531,7 @@ synchronized void addFailedKeys(Collection keys, Throwable e) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 10; + return 11; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java index bbfb502c37521..987c38e50f19a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java @@ -189,7 +189,7 @@ public GridDistributedCacheEntry entryExx( if (keyCheck) validateCacheKey(key); - GridNearTxLocal tx = ctx.mvccEnabled() ? MvccUtils.tx(ctx.kernalContext()) : ctx.tm().threadLocalTx(ctx); + GridNearTxLocal tx = checkCurrentTx(); final CacheOperationContext opCtx = ctx.operationContextPerCall(); @@ -305,7 +305,7 @@ public GridDistributedCacheEntry entryExx( if (keyCheck) validateCacheKeys(keys); - GridNearTxLocal tx = (ctx.mvccEnabled()) ? MvccUtils.tx(ctx.kernalContext()) : ctx.tm().threadLocalTx(ctx); + GridNearTxLocal tx = checkCurrentTx(); final CacheOperationContext opCtx = ctx.operationContextPerCall(); @@ -345,7 +345,7 @@ public GridDistributedCacheEntry entryExx( assert mvccSnapshot != null; } catch (IgniteCheckedException ex) { - return new GridFinishedFuture(ex); + return new GridFinishedFuture<>(ex); } } @@ -610,7 +610,7 @@ public final IgniteInternalFuture> loadAsync( } finally { if (entry != null) - entry.touch(topVer); + entry.touch(); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java index 9dbb8be974433..da5ad43a3d3ba 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java @@ -29,6 +29,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReference; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; @@ -778,7 +779,18 @@ void map() { if (topVer != null) { for (GridDhtTopologyFuture fut : cctx.shared().exchange().exchangeFutures()) { if (fut.exchangeDone() && fut.topologyVersion().equals(topVer)) { - Throwable err = fut.validateCache(cctx, recovery, read, null, keys); + Throwable err = null; + + // Before cache validation, make sure that this topology future is already completed. + try { + fut.get(); + } + catch (IgniteCheckedException e) { + err = fut.error(); + } + + if (err == null) + err = fut.validateCache(cctx, recovery, read, null, keys); if (err != null) { onDone(err); @@ -820,7 +832,10 @@ private void mapOnTopology(final boolean remap, @Nullable final Runnable c) { try { if (cctx.topology().stopping()) { - onDone(new CacheStoppedException(cctx.name())); + onDone( + cctx.shared().cache().isCacheRestarting(cctx.name())? + new IgniteCacheRestartingException(cctx.name()): + new CacheStoppedException(cctx.name())); return; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CacheGroupAffinityMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CacheGroupAffinityMessage.java index 7da4051e27929..695eadca581a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CacheGroupAffinityMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CacheGroupAffinityMessage.java @@ -192,16 +192,10 @@ public static List toNodes(GridLongList assign, Map discoCache.serverNodeByOrder(order)); - if (affNode == null) { - affNode = discoCache.serverNodeByOrder(order); - - assert affNode != null : "Failed to find node by order [order=" + order + - ", topVer=" + discoCache.version() + ']'; - - nodesByOrder.put(order, affNode); - } + assert affNode != null : "Failed to find node by order [order=" + order + + ", topVer=" + discoCache.version() + ']'; assign0.add(affNode); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionFullCountersMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionFullCountersMap.java index 2d5eec3878cf5..008c2766e4a47 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionFullCountersMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionFullCountersMap.java @@ -93,27 +93,6 @@ public void updateCounter(int p, long updCntr) { updCntrs[p] = updCntr; } - /** - * Creates submap for provided partition IDs. - * - * @param parts Partition IDs. - * @return Partial counters map. - */ - public CachePartitionPartialCountersMap subMap(Set parts) { - CachePartitionPartialCountersMap res = new CachePartitionPartialCountersMap(parts.size()); - - for (int p = 0; p < updCntrs.length; p++) { - if (!parts.contains(p)) - continue; - - res.add(p, initialUpdCntrs[p], updCntrs[p]); - } - - assert res.size() == parts.size(); - - return res; - } - /** * Clears full counters map. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionPartialCountersMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionPartialCountersMap.java index 9fc7f941a2188..986a100222ac6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionPartialCountersMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionPartialCountersMap.java @@ -34,7 +34,7 @@ public class CachePartitionPartialCountersMap implements Serializable { private static final long serialVersionUID = 0L; /** */ - static final IgniteProductVersion PARTIAL_COUNTERS_MAP_SINCE = IgniteProductVersion.fromString("2.1.4"); + public static final IgniteProductVersion PARTIAL_COUNTERS_MAP_SINCE = IgniteProductVersion.fromString("2.1.4"); /** */ public static final CachePartitionPartialCountersMap EMPTY = new CachePartitionPartialCountersMap(); @@ -53,7 +53,7 @@ public class CachePartitionPartialCountersMap implements Serializable { /** */ private CachePartitionPartialCountersMap() { - // Empty map. + this(0); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 124ae44ca5b30..80c45efc76805 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -167,26 +167,26 @@ private int keyCount() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeIgniteUuid("miniId", miniId)) return false; writer.incrementState(); - case 6: - if (!writer.writeMessage("topVer", topVer)) + case 7: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -207,7 +207,7 @@ private int keyCount() { return false; switch (reader.state()) { - case 3: + case 4: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -215,7 +215,7 @@ private int keyCount() { reader.incrementState(); - case 4: + case 5: keys = reader.readCollection("keys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -223,7 +223,7 @@ private int keyCount() { reader.incrementState(); - case 5: + case 6: miniId = reader.readIgniteUuid("miniId"); if (!reader.isLastRead()) @@ -231,8 +231,8 @@ private int keyCount() { reader.incrementState(); - case 6: - topVer = reader.readMessage("topVer"); + case 7: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; @@ -251,7 +251,7 @@ private int keyCount() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 7; + return 8; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index 977e9ba41eef2..ab85df3e94622 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -213,31 +213,31 @@ public void addInfo(GridCacheEntryInfo info) { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeCollection("infos", infos, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeIgniteUuid("miniId", miniId)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeCollection("missedKeys", missedKeys, MessageCollectionItemType.MSG)) return false; @@ -259,7 +259,7 @@ public void addInfo(GridCacheEntryInfo info) { return false; switch (reader.state()) { - case 3: + case 4: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -267,7 +267,7 @@ public void addInfo(GridCacheEntryInfo info) { reader.incrementState(); - case 4: + case 5: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -275,7 +275,7 @@ public void addInfo(GridCacheEntryInfo info) { reader.incrementState(); - case 5: + case 6: infos = reader.readCollection("infos", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -283,7 +283,7 @@ public void addInfo(GridCacheEntryInfo info) { reader.incrementState(); - case 6: + case 7: miniId = reader.readIgniteUuid("miniId"); if (!reader.isLastRead()) @@ -291,7 +291,7 @@ public void addInfo(GridCacheEntryInfo info) { reader.incrementState(); - case 7: + case 8: missedKeys = reader.readCollection("missedKeys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -311,7 +311,7 @@ public void addInfo(GridCacheEntryInfo info) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 8; + return 9; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandLegacyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandLegacyMessage.java index 46e9ceb004830..cd7741b554fa7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandLegacyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandLegacyMessage.java @@ -285,49 +285,49 @@ Long partitionCounter(int part) { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeCollection("historicalParts", historicalParts, MessageCollectionItemType.INT)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeCollection("parts", parts, MessageCollectionItemType.INT)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeMap("partsCntrs", partsCntrs, MessageCollectionItemType.INT, MessageCollectionItemType.LONG)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeLong("timeout", timeout)) return false; writer.incrementState(); - case 7: - if (!writer.writeMessage("topVer", topVer)) + case 8: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeByteArray("topicBytes", topicBytes)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeLong("updateSeq", updateSeq)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeInt("workerId", workerId)) return false; @@ -349,7 +349,7 @@ Long partitionCounter(int part) { return false; switch (reader.state()) { - case 3: + case 4: historicalParts = reader.readCollection("historicalParts", MessageCollectionItemType.INT); if (!reader.isLastRead()) @@ -357,7 +357,7 @@ Long partitionCounter(int part) { reader.incrementState(); - case 4: + case 5: parts = reader.readCollection("parts", MessageCollectionItemType.INT); if (!reader.isLastRead()) @@ -365,7 +365,7 @@ Long partitionCounter(int part) { reader.incrementState(); - case 5: + case 6: partsCntrs = reader.readMap("partsCntrs", MessageCollectionItemType.INT, MessageCollectionItemType.LONG, false); if (!reader.isLastRead()) @@ -373,7 +373,7 @@ Long partitionCounter(int part) { reader.incrementState(); - case 6: + case 7: timeout = reader.readLong("timeout"); if (!reader.isLastRead()) @@ -381,15 +381,15 @@ Long partitionCounter(int part) { reader.incrementState(); - case 7: - topVer = reader.readMessage("topVer"); + case 8: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 8: + case 9: topicBytes = reader.readByteArray("topicBytes"); if (!reader.isLastRead()) @@ -397,7 +397,7 @@ Long partitionCounter(int part) { reader.incrementState(); - case 9: + case 10: updateSeq = reader.readLong("updateSeq"); if (!reader.isLastRead()) @@ -405,7 +405,7 @@ Long partitionCounter(int part) { reader.incrementState(); - case 10: + case 11: workerId = reader.readInt("workerId"); if (!reader.isLastRead()) @@ -415,7 +415,7 @@ Long partitionCounter(int part) { } - return reader.afterMessageRead(GridDhtPartitionDemandMessage.class); + return reader.afterMessageRead(GridDhtPartitionDemandLegacyMessage.class); } /** {@inheritDoc} */ @@ -425,7 +425,7 @@ Long partitionCounter(int part) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 11; + return 12; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java index dc6162bc321f2..bae326424d0fb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java @@ -21,6 +21,7 @@ import java.nio.ByteBuffer; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridDirectTransient; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage; import org.apache.ignite.internal.processors.cache.GridCacheMessage; @@ -35,6 +36,7 @@ /** * Partition demand request. */ +@IgniteCodeGeneratingFail public class GridDhtPartitionDemandMessage extends GridCacheGroupIdMessage { /** */ private static final long serialVersionUID = 0L; @@ -259,37 +261,37 @@ public GridCacheMessage convertIfNeeded(IgniteProductVersion target) { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeByteArray("partsBytes", partsBytes)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeLong("timeout", timeout)) return false; writer.incrementState(); - case 5: - if (!writer.writeMessage("topVer", topVer)) + case 6: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeByteArray("topicBytes", topicBytes)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeLong("rebalanceId", rebalanceId)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeInt("workerId", workerId)) return false; @@ -311,7 +313,7 @@ public GridCacheMessage convertIfNeeded(IgniteProductVersion target) { return false; switch (reader.state()) { - case 3: + case 4: partsBytes = reader.readByteArray("partsBytes"); if (!reader.isLastRead()) @@ -319,7 +321,7 @@ public GridCacheMessage convertIfNeeded(IgniteProductVersion target) { reader.incrementState(); - case 4: + case 5: timeout = reader.readLong("timeout"); if (!reader.isLastRead()) @@ -327,15 +329,15 @@ public GridCacheMessage convertIfNeeded(IgniteProductVersion target) { reader.incrementState(); - case 5: - topVer = reader.readMessage("topVer"); + case 6: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 6: + case 7: topicBytes = reader.readByteArray("topicBytes"); if (!reader.isLastRead()) @@ -343,7 +345,7 @@ public GridCacheMessage convertIfNeeded(IgniteProductVersion target) { reader.incrementState(); - case 7: + case 8: rebalanceId = reader.readLong("rebalanceId"); if (!reader.isLastRead()) @@ -351,7 +353,7 @@ public GridCacheMessage convertIfNeeded(IgniteProductVersion target) { reader.incrementState(); - case 8: + case 9: workerId = reader.readInt("workerId"); if (!reader.isLastRead()) @@ -371,7 +373,7 @@ public GridCacheMessage convertIfNeeded(IgniteProductVersion target) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 9; + return 10; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java index 40defa14b41e4..40d5a2803ef3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java @@ -741,7 +741,25 @@ public void handleSupplyMessage( int p = e.getKey(); if (aff.get(p).contains(ctx.localNode())) { - GridDhtLocalPartition part = top.localPartition(p, topVer, true); + GridDhtLocalPartition part; + + try { + part = top.localPartition(p, topVer, true); + } + catch (GridDhtInvalidPartitionException err) { + assert !topVer.equals(top.lastTopologyChangeVersion()); + + if (log.isDebugEnabled()) { + log.debug("Failed to get partition for rebalancing [" + + "grp=" + grp.cacheOrGroupName() + + ", err=" + err + + ", p=" + p + + ", topVer=" + topVer + + ", lastTopVer=" + top.lastTopologyChangeVersion() + ']'); + } + + continue; + } assert part != null; @@ -890,6 +908,9 @@ private boolean preloadEntry( try { GridCacheContext cctx = grp.sharedGroup() ? ctx.cacheContext(entry.cacheId()) : grp.singleCacheContext(); + if (cctx == null) + return true; + if (cctx.isNear()) cctx = cctx.dhtCache().context(); @@ -913,7 +934,7 @@ private boolean preloadEntry( cctx.isDrEnabled() ? DR_PRELOAD : DR_NONE, false )) { - cached.touch(topVer); // Start tracking. + cached.touch(); // Start tracking. if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_OBJECT_LOADED) && !cached.isInternal()) cctx.events().addEvent(cached.partition(), cached.key(), cctx.localNodeId(), @@ -921,7 +942,7 @@ private boolean preloadEntry( false, null, null, null, true); } else { - cached.touch(topVer); // Start tracking. + cached.touch(); // Start tracking. if (log.isTraceEnabled()) log.trace("Rebalancing entry is already in cache (will ignore) [key=" + cached.key() + diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java index 741386b40707b..2206f2e372fad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java @@ -248,7 +248,7 @@ public boolean isLeft() { writer.incrementState(); case 2: - if (!writer.writeMessage("topVer", topVer)) + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -283,7 +283,7 @@ public boolean isLeft() { reader.incrementState(); case 2: - topVer = reader.readMessage("topVer"); + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; @@ -311,4 +311,4 @@ public boolean isLeft() { "nodeId", U.id8(nodeId), "evt", U.gridEventName(evt)); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java index 835910e36387c..92547667ca39e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java @@ -27,6 +27,7 @@ import java.util.stream.Collectors; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; @@ -45,6 +46,7 @@ import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.T3; +import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; @@ -71,6 +73,10 @@ class GridDhtPartitionSupplier { /** Supply context map. T3: nodeId, topicId, topVer. */ private final Map, SupplyContext> scMap = new HashMap<>(); + /** Override for rebalance throttle. */ + private long rebalanceThrottleOverride = + IgniteSystemProperties.getLong(IgniteSystemProperties.IGNITE_REBALANCE_THROTTLE_OVERRIDE, 0); + /** * @param grp Cache group. */ @@ -82,6 +88,9 @@ class GridDhtPartitionSupplier { log = grp.shared().logger(getClass()); top = grp.topology(); + + if (rebalanceThrottleOverride > 0) + LT.info(log, "Using rebalance throttle override: " + rebalanceThrottleOverride); } /** @@ -511,7 +520,9 @@ private boolean reply( grp.shared().io().sendOrderedMessage(demander, demandMsg.topic(), supplyMsg, grp.ioPolicy(), demandMsg.timeout()); // Throttle preloading. - if (grp.config().getRebalanceThrottle() > 0) + if (rebalanceThrottleOverride > 0) + U.sleep(rebalanceThrottleOverride); + else if (grp.config().getRebalanceThrottle() > 0) U.sleep(grp.config().getRebalanceThrottle()); return true; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 284700ad3a44f..7e281e59a7e1e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -28,6 +28,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridDirectCollection; import org.apache.ignite.internal.GridDirectMap; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection; import org.apache.ignite.internal.processors.cache.CacheGroupContext; @@ -45,6 +46,7 @@ /** * Partition supply message. */ +@IgniteCodeGeneratingFail public class GridDhtPartitionSupplyMessage extends GridCacheGroupIdMessage implements GridCacheDeployable { /** */ private static final long serialVersionUID = 0L; @@ -247,6 +249,9 @@ void addEntry0(int p, boolean historical, GridCacheEntryInfo info, GridCacheShar CacheGroupContext grp = ctx.cache().cacheGroup(grpId); + if (grp == null) + return; + for (CacheEntryInfoCollection col : infos().values()) { List entries = col.infos(); @@ -282,55 +287,55 @@ public int size() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeCollection("clean", clean, MessageCollectionItemType.INT)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeLong("estimatedKeysCnt", estimatedKeysCnt)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeMap("infos", infos, MessageCollectionItemType.INT, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeMap("keysPerCache", keysPerCache, MessageCollectionItemType.INT, MessageCollectionItemType.LONG)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeMap("last", last, MessageCollectionItemType.INT, MessageCollectionItemType.LONG)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeCollection("missed", missed, MessageCollectionItemType.INT)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeInt("msgSize", msgSize)) return false; writer.incrementState(); - case 10: - if (!writer.writeMessage("topVer", topVer)) + case 11: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 11: + case 12: // Keep 'updateSeq' name for compatibility. if (!writer.writeLong("updateSeq", rebalanceId)) return false; @@ -353,7 +358,7 @@ public int size() { return false; switch (reader.state()) { - case 3: + case 4: clean = reader.readCollection("clean", MessageCollectionItemType.INT); if (!reader.isLastRead()) @@ -361,7 +366,7 @@ public int size() { reader.incrementState(); - case 4: + case 5: estimatedKeysCnt = reader.readLong("estimatedKeysCnt"); if (!reader.isLastRead()) @@ -369,7 +374,7 @@ public int size() { reader.incrementState(); - case 5: + case 6: infos = reader.readMap("infos", MessageCollectionItemType.INT, MessageCollectionItemType.MSG, false); if (!reader.isLastRead()) @@ -377,7 +382,7 @@ public int size() { reader.incrementState(); - case 6: + case 7: keysPerCache = reader.readMap("keysPerCache", MessageCollectionItemType.INT, MessageCollectionItemType.LONG, false); if (!reader.isLastRead()) @@ -385,7 +390,7 @@ public int size() { reader.incrementState(); - case 7: + case 8: last = reader.readMap("last", MessageCollectionItemType.INT, MessageCollectionItemType.LONG, false); if (!reader.isLastRead()) @@ -393,7 +398,7 @@ public int size() { reader.incrementState(); - case 8: + case 9: missed = reader.readCollection("missed", MessageCollectionItemType.INT); if (!reader.isLastRead()) @@ -401,7 +406,7 @@ public int size() { reader.incrementState(); - case 9: + case 10: msgSize = reader.readInt("msgSize"); if (!reader.isLastRead()) @@ -409,15 +414,15 @@ public int size() { reader.incrementState(); - case 10: - topVer = reader.readMessage("topVer"); + case 11: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 11: + case 12: // Keep 'updateSeq' name for compatibility. rebalanceId = reader.readLong("updateSeq"); @@ -438,7 +443,7 @@ public int size() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 12; + return 13; } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java index b6bff0e823506..154d9fb4a6136 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java @@ -36,7 +36,7 @@ public class GridDhtPartitionSupplyMessageV2 extends GridDhtPartitionSupplyMessa private static final long serialVersionUID = 0L; /** Available since. */ - public static final IgniteProductVersion AVAILABLE_SINCE = IgniteProductVersion.fromString("2.7.0"); + public static final IgniteProductVersion AVAILABLE_SINCE = IgniteProductVersion.fromString("2.5.3"); /** Supplying process error. */ @GridDirectTransient @@ -101,7 +101,7 @@ public GridDhtPartitionSupplyMessageV2( } switch (writer.state()) { - case 12: + case 13: if (!writer.writeByteArray("errBytes", errBytes)) return false; @@ -123,7 +123,7 @@ public GridDhtPartitionSupplyMessageV2( return false; switch (reader.state()) { - case 12: + case 13: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -148,6 +148,6 @@ public GridDhtPartitionSupplyMessageV2( /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 13; + return 14; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java index 84cc792fe22ea..e2884e1751508 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java @@ -145,7 +145,7 @@ public boolean restoreState() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 5; + return 6; } /** {@inheritDoc} */ @@ -163,19 +163,19 @@ public boolean restoreState() { } switch (writer.state()) { - case 2: + case 3: if (!writer.writeMessage("exchId", exchId)) return false; writer.incrementState(); - case 3: + case 4: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeMessage("lastVer", lastVer)) return false; @@ -197,7 +197,7 @@ public boolean restoreState() { return false; switch (reader.state()) { - case 2: + case 3: exchId = reader.readMessage("exchId"); if (!reader.isLastRead()) @@ -205,7 +205,7 @@ public boolean restoreState() { reader.incrementState(); - case 3: + case 4: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -213,7 +213,7 @@ public boolean restoreState() { reader.incrementState(); - case 4: + case 5: lastVer = reader.readMessage("lastVer"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java index 6f38757300f0f..c4162fb8bc528 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java @@ -36,12 +36,14 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cache.CacheMode; @@ -49,8 +51,9 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.events.DiscoveryEvent; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException; import org.apache.ignite.internal.IgniteDiagnosticAware; import org.apache.ignite.internal.IgniteDiagnosticPrepareContext; @@ -82,7 +85,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.GridCacheUtils; -import org.apache.ignite.internal.processors.cache.LocalJoinCachesContext; import org.apache.ignite.internal.processors.cache.StateChangeRequest; import org.apache.ignite.internal.processors.cache.WalStateAbstractMessage; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter; @@ -92,7 +94,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionsStateValidator; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; +import org.apache.ignite.internal.processors.cache.persistence.DatabaseLifecycleListener; import org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotDiscoveryMessage; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -100,8 +102,8 @@ import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage; import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage; import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState; -import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.internal.util.IgniteUtils; +import org.apache.ignite.internal.util.TimeBag; import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -131,6 +133,7 @@ import static org.apache.ignite.internal.processors.cache.ExchangeDiscoveryEvents.serverJoinEvent; import static org.apache.ignite.internal.processors.cache.ExchangeDiscoveryEvents.serverLeftEvent; import static org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap.PARTIAL_COUNTERS_MAP_SINCE; +import static org.apache.ignite.internal.util.IgniteUtils.doInParallel; /** * Future for exchanging partition maps. @@ -190,7 +193,10 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte /** Cache context. */ private final GridCacheSharedContext cctx; - /** Busy lock to prevent activities from accessing exchanger while it's stopping. */ + /** + * Busy lock to prevent activities from accessing exchanger while it's stopping. Stopping uses write lock, so every + * {@link #enterBusy()} will be failed as false. But regular operation uses read lock acquired multiple times. + */ private ReadWriteLock busyLock; /** */ @@ -337,6 +343,15 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte /** Future for wait all exchange listeners comepleted. */ private final GridFutureAdapter afterLsnrCompleteFut = new GridFutureAdapter<>(); + /** Time bag to measure and store exchange stages times. */ + private final TimeBag timeBag; + + /** Start time of exchange. */ + private long startTime = System.nanoTime(); + + /** Discovery lag / Clocks discrepancy, calculated on coordinator when all single messages are received. */ + private T2 discoveryLag; + /** * @param cctx Cache context. * @param busyLock Busy lock. @@ -368,6 +383,8 @@ public GridDhtPartitionsExchangeFuture( log = cctx.logger(getClass()); exchLog = cctx.logger(EXCHANGE_LOG); + timeBag = new TimeBag(); + initFut = new GridFutureAdapter() { @Override public IgniteLogger logger() { return log; @@ -548,6 +565,14 @@ private boolean dynamicCacheStartExchange() { && exchActions.cacheStopRequests().isEmpty(); } + /** + * @param cacheOrGroupName Group or cache name for reset lost partitions. + * @return {@code True} if reset lost partition exchange. + */ + public boolean resetLostPartitionFor(String cacheOrGroupName) { + return exchActions != null && exchActions.cachesToResetLostPartitions().contains(cacheOrGroupName); + } + /** * @return {@code True} if activate cluster exchange. */ @@ -567,6 +592,16 @@ public boolean changedBaseline() { return exchActions != null && exchActions.changedBaseline(); } + /** {@inheritDoc} */ + @Override public boolean changedAffinity() { + DiscoveryEvent firstDiscoEvt0 = firstDiscoEvt; + + assert firstDiscoEvt0 != null; + + return firstDiscoEvt0.type() == DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT + || !firstDiscoEvt0.eventNode().isClient() || firstDiscoEvt0.eventNode().isLocal(); + } + /** * @return {@code True} if there are caches to start. */ @@ -604,7 +639,7 @@ public GridDhtPartitionExchangeId exchangeId() { } /** - * @return {@code true} if entered to busy state. + * @return {@code true} if entered to busy state. {@code false} for stop node. */ private boolean enterBusy() { if (busyLock.readLock().tryLock()) @@ -643,6 +678,13 @@ private void initCoordinatorCaches(boolean newCrd) throws IgniteCheckedException } } + /** + * @return Object to collect exchange timings. + */ + public TimeBag timeBag() { + return timeBag; + } + /** * Starts activity. * @@ -680,25 +722,10 @@ public void init(boolean newCrd) throws IgniteInterruptedCheckedException { boolean crdNode = crd != null && crd.isLocal(); - MvccCoordinator mvccCrd = firstEvtDiscoCache.mvccCoordinator(); - - boolean mvccCrdChange = mvccCrd != null && - (initialVersion().equals(mvccCrd.topologyVersion()) || activateCluster()); - - // Mvcc coordinator should has been initialized before exchange context is created. - cctx.kernalContext().coordinators().updateCoordinator(mvccCrd); - - exchCtx = new ExchangeContext(crdNode, mvccCrdChange, this); + exchCtx = new ExchangeContext(crdNode, this); cctx.exchange().exchangerBlockingSectionBegin(); - try { - cctx.kernalContext().coordinators().onExchangeStart(mvccCrd, exchCtx, crd); - } - finally { - cctx.exchange().exchangerBlockingSectionEnd(); - } - assert state == null : state; if (crdNode) @@ -708,8 +735,6 @@ public void init(boolean newCrd) throws IgniteInterruptedCheckedException { if (exchLog.isInfoEnabled()) { exchLog.info("Started exchange init [topVer=" + topVer + - ", mvccCrd=" + mvccCrd + - ", mvccCrdChange=" + mvccCrdChange + ", crd=" + crdNode + ", evt=" + IgniteUtils.gridEventName(firstDiscoEvt.type()) + ", evtNode=" + firstDiscoEvt.eventNode().id() + @@ -717,6 +742,8 @@ public void init(boolean newCrd) throws IgniteInterruptedCheckedException { ", allowMerge=" + exchCtx.mergeExchanges() + ']'); } + timeBag.finishGlobalStage("Exchange parameters initialization"); + ExchangeType exchange; if (firstDiscoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT) { @@ -799,7 +826,9 @@ else if (msg instanceof WalStateAbstractMessage) cctx.cache().registrateProxyRestart(resolveCacheRequests(exchActions), afterLsnrCompleteFut); - updateTopologies(crdNode, cctx.coordinators().currentCoordinator()); + updateTopologies(crdNode); + + timeBag.finishGlobalStage("Determine exchange type"); switch (exchange) { case ALL: { @@ -844,7 +873,9 @@ else if (msg instanceof WalStateAbstractMessage) exchLog.info("Finished exchange init [topVer=" + topVer + ", crd=" + crdNode + ']'); } catch (IgniteInterruptedCheckedException e) { - onDone(e); + assert cctx.kernalContext().isStopping(); + + onDone(new IgniteCheckedException("Node stopped")); throw e; } @@ -869,20 +900,21 @@ else if (msg instanceof WalStateAbstractMessage) * @throws IgniteCheckedException If failed. */ private IgniteInternalFuture initCachesOnLocalJoin() throws IgniteCheckedException { - if (isLocalNodeNotInBaseline()) { + if (!cctx.kernalContext().clientNode() && !isLocalNodeInBaseline()) { cctx.exchange().exchangerBlockingSectionBegin(); try { - cctx.cache().cleanupCachesDirectories(); + List listeners = cctx.kernalContext().internalSubscriptionProcessor() + .getDatabaseListeners(); - cctx.database().cleanupCheckpointDirectory(); - - if (cctx.wal() != null) - cctx.wal().cleanupWalDirectories(); + for (DatabaseLifecycleListener lsnr : listeners) + lsnr.onBaselineChange(); } finally { cctx.exchange().exchangerBlockingSectionEnd(); } + + timeBag.finishGlobalStage("Baseline change callback"); } cctx.exchange().exchangerBlockingSectionBegin(); @@ -894,34 +926,13 @@ private IgniteInternalFuture initCachesOnLocalJoin() throws IgniteCheckedExce cctx.exchange().exchangerBlockingSectionEnd(); } - LocalJoinCachesContext locJoinCtx = exchActions == null ? null : exchActions.localJoinContext(); - - List> caches = locJoinCtx == null ? null : - locJoinCtx.caches(); - - if (!cctx.kernalContext().clientNode()) { - List startDescs = new ArrayList<>(); + timeBag.finishGlobalStage("Components activation"); - if (caches != null) { - for (T2 c : caches) { - DynamicCacheDescriptor startDesc = c.get1(); + IgniteInternalFuture cachesRegistrationFut = cctx.cache().startCachesOnLocalJoin(initialVersion(), + exchActions == null ? null : exchActions.localJoinContext()); - if (CU.isPersistentCache(startDesc.cacheConfiguration(), cctx.gridConfig().getDataStorageConfiguration())) - startDescs.add(startDesc); - } - } - - cctx.exchange().exchangerBlockingSectionBegin(); - - try { - cctx.database().readCheckpointAndRestoreMemory(startDescs); - } - finally { - cctx.exchange().exchangerBlockingSectionEnd(); - } - } - - IgniteInternalFuture cachesRegistrationFut = cctx.cache().startCachesOnLocalJoin(initialVersion(), locJoinCtx); + if (!cctx.kernalContext().clientNode()) + cctx.cache().shutdownNotFinishedRecoveryCaches(); ensureClientCachesStarted(); @@ -948,12 +959,12 @@ private void ensureClientCachesStarted() { } /** - * @return {@code true} if local node is not in baseline and {@code false} otherwise. + * @return {@code true} if local node is in baseline and {@code false} otherwise. */ - private boolean isLocalNodeNotInBaseline() { + private boolean isLocalNodeInBaseline() { BaselineTopology topology = cctx.discovery().discoCache().state().baselineTopology(); - return topology!= null && !topology.consistentIds().contains(cctx.localNode().consistentId()); + return topology != null && topology.consistentIds().contains(cctx.localNode().consistentId()); } /** @@ -983,10 +994,9 @@ private void initTopologies() throws IgniteCheckedException { * Updates topology versions and discovery caches on all topologies. * * @param crd Coordinator flag. - * @param mvccCrd Mvcc coordinator. * @throws IgniteCheckedException If failed. */ - private void updateTopologies(boolean crd, MvccCoordinator mvccCrd) throws IgniteCheckedException { + private void updateTopologies(boolean crd) throws IgniteCheckedException { for (CacheGroupContext grp : cctx.cache().cacheGroups()) { if (grp.isLocal()) continue; @@ -1023,7 +1033,6 @@ private void updateTopologies(boolean crd, MvccCoordinator mvccCrd) throws Ignit top.updateTopologyVersion( this, events().discoveryCache(), - mvccCrd, updSeq, cacheGroupStopping(grp.groupId())); } @@ -1038,7 +1047,6 @@ private void updateTopologies(boolean crd, MvccCoordinator mvccCrd) throws Ignit for (GridClientPartitionTopology top : cctx.exchange().clientTopologies()) { top.updateTopologyVersion(this, events().discoveryCache(), - mvccCrd, -1, cacheGroupStopping(top.groupId())); } @@ -1082,33 +1090,15 @@ private ExchangeType onClusterStateChangeRequest(boolean crd) { cctx.exchange().exchangerBlockingSectionEnd(); } - if (!cctx.kernalContext().clientNode()) { - List startDescs = new ArrayList<>(); - - for (ExchangeActions.CacheActionData startReq : exchActions.cacheStartRequests()) { - DynamicCacheDescriptor desc = startReq.descriptor(); - - if (CU.isPersistentCache(desc.cacheConfiguration(), - cctx.gridConfig().getDataStorageConfiguration())) - startDescs.add(desc); - } - - cctx.exchange().exchangerBlockingSectionBegin(); - - try { - cctx.database().readCheckpointAndRestoreMemory(startDescs); - } - finally { - cctx.exchange().exchangerBlockingSectionEnd(); - } - } - assert registerCachesFuture == null : "No caches registration should be scheduled before new caches have started."; cctx.exchange().exchangerBlockingSectionBegin(); try { registerCachesFuture = cctx.affinity().onCacheChangeRequest(this, crd, exchActions); + + if (!cctx.kernalContext().clientNode()) + cctx.cache().shutdownNotFinishedRecoveryCaches(); } finally { cctx.exchange().exchangerBlockingSectionEnd(); @@ -1235,7 +1225,8 @@ private ExchangeType onCacheChangeRequest(boolean crd) throws IgniteCheckedExcep // This exception will be handled by init() method. throw e; - U.error(log, "Failed to initialize cache(s) (will try to rollback). " + exchId, e); + U.error(log, "Failed to initialize cache(s) (will try to rollback) [exchId=" + exchId + + ", caches=" + exchActions.cacheGroupsToStart() + ']', e); exchangeLocE = new IgniteCheckedException( "Failed to initialize exchange locally [locNodeId=" + cctx.localNodeId() + "]", e); @@ -1385,6 +1376,8 @@ private void distributedExchange() throws IgniteCheckedException { } } + timeBag.finishGlobalStage("Preloading notification"); + cctx.exchange().exchangerBlockingSectionBegin(); try { @@ -1397,6 +1390,8 @@ private void distributedExchange() throws IgniteCheckedException { cctx.exchange().exchangerBlockingSectionEnd(); } + timeBag.finishGlobalStage("WAL history reservation"); + // Skipping wait on local join is available when all cluster nodes have the same protocol. boolean skipWaitOnLocalJoin = cctx.exchange().latch().canSkipJoiningNodes(initialVersion()) && localJoinExchange(); @@ -1441,16 +1436,15 @@ private void distributedExchange() throws IgniteCheckedException { } } - /* It is necessary to run database callback before all topology callbacks. - In case of persistent store is enabled we first restore partitions presented on disk. - We need to guarantee that there are no partition state changes logged to WAL before this callback - to make sure that we correctly restored last actual states. */ - boolean restored; - cctx.exchange().exchangerBlockingSectionBegin(); try { - restored = cctx.database().beforeExchange(this); + /* It is necessary to run database callback before all topology callbacks. + In case of persistent store is enabled we first restore partitions presented on disk. + We need to guarantee that there are no partition state changes logged to WAL before this callback + to make sure that we correctly restored last actual states. */ + + cctx.database().beforeExchange(this); } finally { cctx.exchange().exchangerBlockingSectionEnd(); @@ -1477,25 +1471,33 @@ private void distributedExchange() throws IgniteCheckedException { } // After all partitions have been restored and pre-created it's safe to make first checkpoint. - if (restored) { + if (localJoinExchange() || activateCluster()) { cctx.exchange().exchangerBlockingSectionBegin(); try { - cctx.database().onStateRestored(); + cctx.database().onStateRestored(initialVersion()); } finally { cctx.exchange().exchangerBlockingSectionEnd(); } } + timeBag.finishGlobalStage("After states restored callback"); + changeWalModeIfNeeded(); + if (events().hasServerLeft()) + finalizePartitionCounters(); + cctx.exchange().exchangerBlockingSectionBegin(); try { if (crd.isLocal()) { - if (remaining.isEmpty()) + if (remaining.isEmpty()) { + initFut.onDone(true); + onAllReceived(null); + } } else sendPartitions(crd); @@ -1599,9 +1601,6 @@ private void waitPartitionRelease(boolean distributed, boolean doRollback) throw // Assign to class variable so it will be included into toString() method. this.partReleaseFut = partReleaseFut; - - if (exchId.isLeft()) - cctx.mvcc().removeExplicitNodeLocks(exchId.nodeId(), exchId.topologyVersion()); } finally { cctx.exchange().exchangerBlockingSectionEnd(); @@ -1717,6 +1716,8 @@ private void waitPartitionRelease(boolean distributed, boolean doRollback) throw } } + timeBag.finishGlobalStage("Wait partitions release"); + if (releaseLatch == null) { assert !distributed : "Partitions release latch must be initialized in distributed mode."; @@ -1757,6 +1758,8 @@ private void waitPartitionRelease(boolean distributed, boolean doRollback) throw catch (IgniteCheckedException e) { U.warn(log, "Stop waiting for partitions release latch: " + e.getMessage()); } + + timeBag.finishGlobalStage("Wait partitions release latch"); } /** @@ -1771,8 +1774,6 @@ private void onLeft() { cctx.exchange().exchangerUpdateHeartbeat(); } - - cctx.mvcc().removeExplicitNodeLocks(exchId.nodeId(), exchId.topologyVersion()); } /** @@ -1831,8 +1832,6 @@ public boolean localJoinExchange() { private void sendLocalPartitions(ClusterNode node) throws IgniteCheckedException { assert node != null; - long time = System.currentTimeMillis(); - GridDhtPartitionsSingleMessage msg; // Reset lost partitions before sending local partitions to coordinator. @@ -1862,17 +1861,13 @@ private void sendLocalPartitions(ClusterNode node) throws IgniteCheckedException msg.partitionHistoryCounters(partHistReserved0); } - if (exchCtx.newMvccCoordinator() && cctx.coordinators().currentCoordinatorId().equals(node.id())) { - Map activeQueries = exchCtx.activeQueries(); - - msg.activeQueries(activeQueries != null ? activeQueries.get(cctx.localNodeId()) : null); - } - if ((stateChangeExchange() || dynamicCacheStartExchange()) && exchangeLocE != null) msg.setError(exchangeLocE); else if (localJoinExchange()) msg.cacheGroupsAffinityRequest(exchCtx.groupsAffinityRequestOnJoin()); + msg.exchangeStartTime(startTime); + if (log.isTraceEnabled()) log.trace("Sending local partitions [nodeId=" + node.id() + ", exchId=" + exchId + ", msg=" + msg + ']'); @@ -1883,9 +1878,6 @@ else if (localJoinExchange()) if (log.isDebugEnabled()) log.debug("Node left during partition exchange [nodeId=" + node.id() + ", exchId=" + exchId + ']'); } - - if (log.isInfoEnabled()) - log.info("Sending Single Message performed in " + (System.currentTimeMillis() - time) + " ms."); } /** @@ -1944,8 +1936,6 @@ private void sendAllPartitions( .map(singleMessage -> fullMsg.copy().joinedNodeAffinity(affinityForJoinedNodes)) .orElse(null); - long time = System.currentTimeMillis(); - // Prepare and send full messages for given nodes. nodes.stream() .map(node -> { @@ -1998,9 +1988,6 @@ private void sendAllPartitions( U.error(log, "Failed to send partitions [node=" + node + ']', e); } }); - - if (log.isInfoEnabled()) - log.info("Sending Full Message performed in " + (System.currentTimeMillis() - time) + " ms."); } /** @@ -2042,8 +2029,45 @@ public boolean serverNodeDiscoveryEvent() { /** * Finish merged future to allow GridCachePartitionExchangeManager.ExchangeFutureSet cleanup. */ - public void finishMerged() { - super.onDone(null, null); + public void finishMerged(AffinityTopologyVersion resVer) { + synchronized (mux) { + if (state == null) state = ExchangeLocalState.MERGED; + } + + done.set(true); + + super.onDone(resVer, null); + } + + /** + * @return {@code True} if future was merged. + */ + public boolean isMerged() { + synchronized (mux) { + return state == ExchangeLocalState.MERGED; + } + } + + /** + * Make a log message that contains given exchange timings. + * + * @param header Header of log message. + * @param timings Exchange stages timings. + * @return Log message with exchange timings and exchange version. + */ + private String exchangeTimingsLogMessage(String header, List timings) { + StringBuilder timingsToLog = new StringBuilder(); + + timingsToLog.append(header).append(" ["); + timingsToLog.append("startVer=").append(initialVersion()); + timingsToLog.append(", resVer=").append(topologyVersion()); + + for (String stageTiming : timings) + timingsToLog.append(", ").append(stageTiming); + + timingsToLog.append(']'); + + return timingsToLog.toString(); } /** {@inheritDoc} */ @@ -2078,22 +2102,24 @@ public void finishMerged() { if (centralizedAff || forceAffReassignment) { assert !exchCtx.mergeExchanges(); + Collection grpToRefresh = U.newHashSet(cctx.cache().cacheGroups().size()); + for (CacheGroupContext grp : cctx.cache().cacheGroups()) { if (grp.isLocal()) continue; - boolean needRefresh = false; - try { - needRefresh = grp.topology().initPartitionsWhenAffinityReady(res, this); + if (grp.topology().initPartitionsWhenAffinityReady(res, this)) + grpToRefresh.add(grp); } catch (IgniteInterruptedCheckedException e) { U.error(log, "Failed to initialize partitions.", e); } - if (needRefresh) - cctx.exchange().refreshPartitions(); } + + if (!grpToRefresh.isEmpty()) + cctx.exchange().refreshPartitions(grpToRefresh); } for (GridCacheContext cacheCtx : cctx.cacheContexts()) { @@ -2101,7 +2127,7 @@ public void finishMerged() { if (drCacheCtx.isDrEnabled()) { try { - drCacheCtx.dr().onExchange(res, exchId.isLeft()); + drCacheCtx.dr().onExchange(res, exchId.isLeft(), activateCluster()); } catch (IgniteCheckedException e) { U.error(log, "Failed to notify DR: " + e, e); @@ -2109,10 +2135,10 @@ public void finishMerged() { } } - if (serverNodeDiscoveryEvent()) + if (serverNodeDiscoveryEvent() || localJoinExchange()) detectLostPartitions(res); - Map m = U.newHashMap(cctx.cache().cacheGroups().size()); + Map m = U.newHashMap(cctx.cache().cacheGroups().size()); for (CacheGroupContext grp : cctx.cache().cacheGroups()) m.put(grp.groupId(), validateCacheGroup(grp, events().lastEvent().topologyNodes())); @@ -2124,8 +2150,7 @@ public void finishMerged() { tryToPerformLocalSnapshotOperation(); if (err == null) - cctx.coordinators().onExchangeDone(exchCtx.newMvccCoordinator(), exchCtx.events().discoveryCache(), - exchCtx.activeQueries()); + cctx.coordinators().onExchangeDone(events().discoveryCache()); // Create and destory caches and cache proxies. cctx.cache().onExchangeDone(initialVersion(), exchActions, err); @@ -2148,15 +2173,16 @@ public void finishMerged() { cctx.database().releaseHistoryForExchange(); - cctx.database().rebuildIndexesIfNeeded(this); - if (err == null) { + cctx.database().rebuildIndexesIfNeeded(this); + for (CacheGroupContext grp : cctx.cache().cacheGroups()) { if (!grp.isLocal()) grp.topology().onExchangeDone(this, grp.affinity().readyAffinity(res), false); } - cctx.walState().changeLocalStatesOnExchangeDone(res); + if (changedAffinity()) + cctx.walState().changeLocalStatesOnExchangeDone(res, changedBaseline()); } final Throwable err0 = err; @@ -2182,14 +2208,26 @@ public void finishMerged() { if (super.onDone(res, err)) { afterLsnrCompleteFut.onDone(); - if (log.isDebugEnabled()) { - log.debug("Completed partition exchange [localNode=" + cctx.localNodeId() + ", exchange= " + this + - ", durationFromInit=" + (U.currentTimeMillis() - initTs) + ']'); - } - else if (log.isInfoEnabled()) { + if (log.isInfoEnabled()) { log.info("Completed partition exchange [localNode=" + cctx.localNodeId() + - ", exchange=" + shortInfo() + ", topVer=" + topologyVersion() + - ", durationFromInit=" + (U.currentTimeMillis() - initTs) + ']'); + ", exchange=" + (log.isDebugEnabled() ? this : shortInfo()) + ", topVer=" + topologyVersion() + "]"); + + if (err == null) { + timeBag.finishGlobalStage("Exchange done"); + + // Collect all stages timings. + List timings = timeBag.stagesTimings(); + + if (discoveryLag != null && discoveryLag.get1() != 0) + timings.add("Discovery lag=" + discoveryLag.get1() + + " ms, Latest started node id=" + discoveryLag.get2()); + + log.info(exchangeTimingsLogMessage("Exchange timings", timings)); + + List localTimings = timeBag.longestLocalStagesTimings(3); + + log.info(exchangeTimingsLogMessage("Exchange longest local stages", localTimings)); + } } initFut.onDone(err == null); @@ -2205,8 +2243,6 @@ else if (log.isInfoEnabled()) { } } - exchActions = null; - if (firstDiscoEvt instanceof DiscoveryCustomEvent) ((DiscoveryCustomEvent)firstDiscoEvt).customMessage(null); @@ -2228,6 +2264,42 @@ else if (log.isInfoEnabled()) { return false; } + /** + * Calculates discovery lag (Maximal difference between exchange start times across all nodes). + * + * @param declared Single messages that were expected to be received during exchange. + * @param merged Single messages from nodes that were merged during exchange. + * + * @return Pair with discovery lag and node id which started exchange later than others. + */ + private T2 calculateDiscoveryLag( + Map declared, + Map merged + ) { + Map msgs = new HashMap<>(declared); + + msgs.putAll(merged); + + long minStartTime = startTime; + long maxStartTime = startTime; + UUID latestStartedNode = cctx.localNodeId(); + + for (Map.Entry msg : msgs.entrySet()) { + UUID nodeId = msg.getKey(); + long exchangeTime = msg.getValue().exchangeStartTime(); + + if (exchangeTime != 0) { + minStartTime = Math.min(minStartTime, exchangeTime); + maxStartTime = Math.max(maxStartTime, exchangeTime); + } + + if (maxStartTime == exchangeTime) + latestStartedNode = nodeId; + } + + return new T2<>(TimeUnit.NANOSECONDS.toMillis(maxStartTime - minStartTime), latestStartedNode); + } + /** * @param exchangeActions Exchange actions. * @return Map of cache names and start descriptors. @@ -2702,9 +2774,6 @@ public void waitAndReplyToNode(final UUID nodeId, final GridDhtPartitionsSingleM */ private void processSingleMessage(UUID nodeId, GridDhtPartitionsSingleMessage msg) { if (msg.client()) { - if (msg.activeQueries() != null) - cctx.coordinators().processClientActiveQueries(nodeId, msg.activeQueries()); - waitAndReplyToNode(nodeId, msg); return; @@ -2800,6 +2869,7 @@ else if (log.isDebugEnabled()) } } } + if (allReceived) { if (!awaitSingleMapUpdates()) return; @@ -3032,24 +3102,31 @@ else if (cntr == maxCntr.cnt) * @param resTopVer Result topology version. */ private void detectLostPartitions(AffinityTopologyVersion resTopVer) { - boolean detected = false; - - long time = System.currentTimeMillis(); - - synchronized (cctx.exchange().interruptLock()) { - if (Thread.currentThread().isInterrupted()) - return; + AtomicInteger detected = new AtomicInteger(); - for (CacheGroupContext grp : cctx.cache().cacheGroups()) { - if (!grp.isLocal()) { - boolean detectedOnGrp = grp.topology().detectLostPartitions(resTopVer, events().lastEvent()); + try { + // Reserve at least 2 threads for system operations. + doInParallel( + U.availableThreadCount(cctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2), + cctx.kernalContext().getSystemExecutorService(), + cctx.cache().cacheGroups(), + grp -> { + if (!grp.isLocal()) { + // Do not trigger lost partition events on start. + boolean evt = !localJoinExchange() && !activateCluster(); + + if (grp.topology().detectLostPartitions(resTopVer, evt ? events().lastEvent() : null)) + detected.incrementAndGet(); + } - detected |= detectedOnGrp; - } - } + return null; + }); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); } - if (detected) { + if (detected.get() > 0) { if (log.isDebugEnabled()) log.debug("Partitions have been scheduled to resend [reason=" + "Lost partitions detect on " + resTopVer + "]"); @@ -3057,8 +3134,7 @@ private void detectLostPartitions(AffinityTopologyVersion resTopVer) { cctx.exchange().scheduleResendPartitions(); } - if (log.isInfoEnabled()) - log.info("Detecting lost partitions performed in " + (System.currentTimeMillis() - time) + " ms."); + timeBag.finishGlobalStage("Detect lost partitions"); } /** @@ -3067,22 +3143,29 @@ private void detectLostPartitions(AffinityTopologyVersion resTopVer) { private void resetLostPartitions(Collection cacheNames) { assert !exchCtx.mergeExchanges(); - synchronized (cctx.exchange().interruptLock()) { - if (Thread.currentThread().isInterrupted()) - return; - - for (CacheGroupContext grp : cctx.cache().cacheGroups()) { - if (grp.isLocal()) - continue; + try { + // Reserve at least 2 threads for system operations. + U.doInParallel( + U.availableThreadCount(cctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2), + cctx.kernalContext().getSystemExecutorService(), + cctx.cache().cacheGroups(), + grp -> { + if (grp.isLocal()) + return null; - for (String cacheName : cacheNames) { - if (grp.hasCache(cacheName)) { - grp.topology().resetLostPartitions(initialVersion()); + for (String cacheName : cacheNames) { + if (grp.hasCache(cacheName)) { + grp.topology().resetLostPartitions(initialVersion()); - break; + break; + } } - } - } + + return null; + }); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); } } @@ -3154,6 +3237,10 @@ private void sendExchangeFailureMessage() { */ private void onAllReceived(@Nullable Collection sndResNodes) { try { + initFut.get(); + + timeBag.finishGlobalStage("Waiting for all single messages"); + assert crd.isLocal(); assert partHistSuppliers.isEmpty() : partHistSuppliers; @@ -3177,12 +3264,9 @@ private void onAllReceived(@Nullable Collection sndResNodes) { if (log.isInfoEnabled()) log.info("Coordinator received all messages, try merge [ver=" + initialVersion() + ']'); - long time = System.currentTimeMillis(); - boolean finish = cctx.exchange().mergeExchangesOnCoordinator(this); - if (log.isInfoEnabled()) - log.info("Exchanges merging performed in " + (System.currentTimeMillis() - time) + " ms."); + timeBag.finishGlobalStage("Exchanges merge"); if (!finish) return; @@ -3202,6 +3286,9 @@ private void onAllReceived(@Nullable Collection sndResNodes) { * @param sndResNodes Additional nodes to send finish message to. */ private void finishExchangeOnCoordinator(@Nullable Collection sndResNodes) { + if (isDone() || !enterBusy()) + return; + try { if (!F.isEmpty(exchangeGlobalExceptions) && dynamicCacheStartExchange() && isRollbackSupported()) { sendExchangeFailureMessage(); @@ -3218,7 +3305,8 @@ private void finishExchangeOnCoordinator(@Nullable Collection sndRe Map idealAffDiff = null; - long time = System.currentTimeMillis(); + // Reserve at least 2 threads for system operations. + int parallelismLvl = U.availableThreadCount(cctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2); if (exchCtx.mergeExchanges()) { synchronized (mux) { @@ -3240,55 +3328,42 @@ private void finishExchangeOnCoordinator(@Nullable Collection sndRe else cctx.affinity().onServerJoinWithExchangeMergeProtocol(this, true); - for (CacheGroupDescriptor desc : cctx.affinity().cacheGroups().values()) { - if (desc.config().getCacheMode() == CacheMode.LOCAL) - continue; - - CacheGroupContext grp = cctx.cache().cacheGroup(desc.groupId()); - - GridDhtPartitionTopology top = grp != null ? grp.topology() : - cctx.exchange().clientTopology(desc.groupId(), events().discoveryCache()); - - top.beforeExchange(this, true, true); - } - } - if (log.isInfoEnabled()) - log.info("Affinity changes (coordinator) applied in " + (System.currentTimeMillis() - time) + " ms."); + doInParallel( + parallelismLvl, + cctx.kernalContext().getSystemExecutorService(), + cctx.affinity().cacheGroups().values(), + desc -> { + if (desc.config().getCacheMode() == CacheMode.LOCAL) + return null; - Map joinedNodeAff = null; + CacheGroupContext grp = cctx.cache().cacheGroup(desc.groupId()); - for (Map.Entry e : msgs.entrySet()) { - GridDhtPartitionsSingleMessage msg = e.getValue(); + GridDhtPartitionTopology top = grp != null ? grp.topology() : + cctx.exchange().clientTopology(desc.groupId(), events().discoveryCache()); - if (exchCtx.newMvccCoordinator()) - exchCtx.addActiveQueries(e.getKey(), msg.activeQueries()); + top.beforeExchange(this, true, true); - // Apply update counters after all single messages are received. - for (Map.Entry entry : msg.partitions().entrySet()) { - Integer grpId = entry.getKey(); + return null; + }); + } - CacheGroupContext grp = cctx.cache().cacheGroup(grpId); + timeBag.finishGlobalStage("Affinity recalculation (crd)"); - GridDhtPartitionTopology top = grp != null ? grp.topology() : - cctx.exchange().clientTopology(grpId, events().discoveryCache()); + Map joinedNodeAff = new ConcurrentHashMap<>(cctx.cache().cacheGroups().size()); - CachePartitionPartialCountersMap cntrs = msg.partitionUpdateCounters(grpId, - top.partitions()); + doInParallel( + parallelismLvl, + cctx.kernalContext().getSystemExecutorService(), + msgs.values(), + msg -> { + processSingleMessageOnCrdFinish(msg, joinedNodeAff); - if (cntrs != null) - top.collectUpdateCounters(cntrs); + return null; } + ); - Collection affReq = msg.cacheGroupsAffinityRequest(); - - if (affReq != null) { - joinedNodeAff = CacheGroupAffinityMessage.createAffinityMessages(cctx, - resTopVer, - affReq, - joinedNodeAff); - } - } + timeBag.finishGlobalStage("Collect update counters and create affinity messages"); validatePartitionsState(); @@ -3323,22 +3398,25 @@ else if (discoveryCustomMessage instanceof SnapshotDiscoveryMessage } // Recalculate new affinity based on partitions availability. - if (!exchCtx.mergeExchanges() && forceAffReassignment) + if (!exchCtx.mergeExchanges() && forceAffReassignment) { idealAffDiff = cctx.affinity().onCustomEventWithEnforcedAffinityReassignment(this); + timeBag.finishGlobalStage("Ideal affinity diff calculation (enforced)"); + } + for (CacheGroupContext grpCtx : cctx.cache().cacheGroups()) { if (!grpCtx.isLocal()) grpCtx.topology().applyUpdateCounters(); } + timeBag.finishGlobalStage("Apply update counters"); + updateLastVersion(cctx.versions().last()); cctx.versions().onExchange(lastVer.get().order()); IgniteProductVersion minVer = exchCtx.events().discoveryCache().minimumNodeVersion(); - time = System.currentTimeMillis(); - GridDhtPartitionsFullMessage msg = createPartitionsMessage(true, minVer.compareToIgnoreTimestamp(PARTIAL_COUNTERS_MAP_SINCE) >= 0); @@ -3355,8 +3433,7 @@ else if (forceAffReassignment) msg.prepareMarshal(cctx); - if (log.isInfoEnabled()) - log.info("Preparing Full Message performed in " + (System.currentTimeMillis() - time) + " ms."); + timeBag.finishGlobalStage("Full message preparing"); synchronized (mux) { finishState = new FinishState(crd.id(), resTopVer, msg); @@ -3367,8 +3444,6 @@ else if (forceAffReassignment) if (centralizedAff) { assert !exchCtx.mergeExchanges(); - time = System.currentTimeMillis(); - IgniteInternalFuture>>> fut = cctx.affinity().initAffinityOnNodeLeft(this); if (!fut.isDone()) { @@ -3380,9 +3455,6 @@ else if (forceAffReassignment) } else onAffinityInitialized(fut); - - if (log.isInfoEnabled()) - log.info("Centralized affinity changes are performed in " + (System.currentTimeMillis() - time) + " ms."); } else { Set nodes; @@ -3406,20 +3478,24 @@ else if (forceAffReassignment) } } } + else + mergedJoinExchMsgs0 = Collections.emptyMap(); if (!F.isEmpty(sndResNodes)) nodes.addAll(sndResNodes); } - time = System.currentTimeMillis(); - if (!nodes.isEmpty()) sendAllPartitions(msg, nodes, mergedJoinExchMsgs0, joinedNodeAff); - partitionsSent = true; + timeBag.finishGlobalStage("Full message sending"); - if (log.isInfoEnabled()) - log.info("Sending Full Message to all nodes performed in " + (System.currentTimeMillis() - time) + " ms."); + discoveryLag = calculateDiscoveryLag( + msgs, + mergedJoinExchMsgs0 + ); + + partitionsSent = true; if (!stateChangeExchange()) onDone(exchCtx.events().topologyVersion(), null); @@ -3436,8 +3512,6 @@ else if (forceAffReassignment) } if (stateChangeExchange()) { - IgniteCheckedException err = null; - StateChangeRequest req = exchActions.stateChangeRequest(); assert req != null : exchActions; @@ -3447,8 +3521,6 @@ else if (forceAffReassignment) if (!F.isEmpty(exchangeGlobalExceptions)) { stateChangeErr = true; - err = new IgniteCheckedException("Cluster state change failed."); - cctx.kernalContext().state().onStateChangeError(exchangeGlobalExceptions, req); } else { @@ -3479,8 +3551,10 @@ else if (forceAffReassignment) cctx.discovery().sendCustomEvent(stateFinishMsg); + timeBag.finishGlobalStage("State finish message sending"); + if (!centralizedAff) - onDone(exchCtx.events().topologyVersion(), err); + onDone(exchCtx.events().topologyVersion(), null); } } catch (IgniteCheckedException e) { @@ -3489,77 +3563,169 @@ else if (forceAffReassignment) else onDone(e); } + finally { + leaveBusy(); + } } /** - * Validates that partition update counters and cache sizes for all caches are consistent. + * @param msg Single message to process. + * @param messageAccumulator Message to store message which need to be sent after. */ - private void validatePartitionsState() { - long time = System.currentTimeMillis(); + private void processSingleMessageOnCrdFinish( + GridDhtPartitionsSingleMessage msg, + Map messageAccumulator + ) { + for (Map.Entry e : msg.partitions().entrySet()) { + Integer grpId = e.getKey(); - for (Map.Entry e : cctx.affinity().cacheGroups().entrySet()) { - CacheGroupDescriptor grpDesc = e.getValue(); - if (grpDesc.config().getCacheMode() == CacheMode.LOCAL) - continue; + CacheGroupContext grp = cctx.cache().cacheGroup(grpId); - int grpId = e.getKey(); + GridDhtPartitionTopology top = grp != null + ? grp.topology() + : cctx.exchange().clientTopology(grpId, events().discoveryCache()); - CacheGroupContext grpCtx = cctx.cache().cacheGroup(grpId); + CachePartitionPartialCountersMap cntrs = msg.partitionUpdateCounters(grpId, top.partitions()); - GridDhtPartitionTopology top = grpCtx != null ? - grpCtx.topology() : - cctx.exchange().clientTopology(grpId, events().discoveryCache()); + if (cntrs != null) + top.collectUpdateCounters(cntrs); + } - // Do not validate read or write through caches or caches with disabled rebalance - // or ExpiryPolicy is set or validation is disabled. - if (grpCtx == null - || grpCtx.config().isReadThrough() - || grpCtx.config().isWriteThrough() - || grpCtx.config().getCacheStoreFactory() != null - || grpCtx.config().getRebalanceDelay() == -1 - || grpCtx.config().getRebalanceMode() == CacheRebalanceMode.NONE - || grpCtx.config().getExpiryPolicyFactory() == null - || SKIP_PARTITION_SIZE_VALIDATION) - continue; + Collection affReq = msg.cacheGroupsAffinityRequest(); - try { - validator.validatePartitionCountersAndSizes(this, top, msgs); - } - catch (IgniteCheckedException ex) { - log.warning("Partition states validation has failed for group: " + grpDesc.cacheOrGroupName() + ". " + ex.getMessage()); - // TODO: Handle such errors https://issues.apache.org/jira/browse/IGNITE-7833 - } + if (affReq != null) + CacheGroupAffinityMessage.createAffinityMessages( + cctx, + exchCtx.events().topologyVersion(), + affReq, + messageAccumulator + ); + } + + /** + * Collects non local cache group descriptors. + * + * @return Collection of non local cache group descriptors. + */ + private List nonLocalCacheGroupDescriptors() { + return cctx.affinity().cacheGroups().values().stream() + .filter(grpDesc -> grpDesc.config().getCacheMode() != CacheMode.LOCAL) + .collect(Collectors.toList()); + } + + /** + * Collects non local cache groups. + * + * @return Collection of non local cache groups. + */ + private List nonLocalCacheGroups() { + return cctx.cache().cacheGroups().stream() + .filter(grp -> !grp.isLocal() && !cacheGroupStopping(grp.groupId())) + .collect(Collectors.toList()); + } + + /** + * Validates that partition update counters and cache sizes for all caches are consistent. + */ + private void validatePartitionsState() { + try { + U.doInParallel( + cctx.kernalContext().getSystemExecutorService(), + nonLocalCacheGroupDescriptors(), + grpDesc -> { + CacheGroupContext grpCtx = cctx.cache().cacheGroup(grpDesc.groupId()); + + GridDhtPartitionTopology top = grpCtx != null + ? grpCtx.topology() + : cctx.exchange().clientTopology(grpDesc.groupId(), events().discoveryCache()); + + // Do not validate read or write through caches or caches with disabled rebalance + // or ExpiryPolicy is set or validation is disabled. + if (grpCtx == null + || grpCtx.config().isReadThrough() + || grpCtx.config().isWriteThrough() + || grpCtx.config().getCacheStoreFactory() != null + || grpCtx.config().getRebalanceDelay() == -1 + || grpCtx.config().getRebalanceMode() == CacheRebalanceMode.NONE + || grpCtx.config().getExpiryPolicyFactory() == null + || SKIP_PARTITION_SIZE_VALIDATION) + return null; + + try { + validator.validatePartitionCountersAndSizes(GridDhtPartitionsExchangeFuture.this, top, msgs); + } + catch (IgniteCheckedException ex) { + log.warning("Partition states validation has failed for group: " + grpCtx.cacheOrGroupName() + ". " + ex.getMessage()); + // TODO: Handle such errors https://issues.apache.org/jira/browse/IGNITE-7833 + } + + return null; + } + ); + } + catch (IgniteCheckedException e) { + throw new IgniteException("Failed to validate partitions state", e); } - if (log.isInfoEnabled()) - log.info("Partitions validation performed in " + (System.currentTimeMillis() - time) + " ms."); + timeBag.finishGlobalStage("Validate partitions states"); } /** * */ private void assignPartitionsStates() { - long time = System.currentTimeMillis(); + try { + U.doInParallel( + cctx.kernalContext().getSystemExecutorService(), + nonLocalCacheGroupDescriptors(), + grpDesc -> { + CacheGroupContext grpCtx = cctx.cache().cacheGroup(grpDesc.groupId()); + + GridDhtPartitionTopology top = grpCtx != null + ? grpCtx.topology() + : cctx.exchange().clientTopology(grpDesc.groupId(), events().discoveryCache()); + + if (!CU.isPersistentCache(grpDesc.config(), cctx.gridConfig().getDataStorageConfiguration())) + assignPartitionSizes(top); + else + assignPartitionStates(top); - for (Map.Entry e : cctx.affinity().cacheGroups().entrySet()) { - CacheGroupDescriptor grpDesc = e.getValue(); - if (grpDesc.config().getCacheMode() == CacheMode.LOCAL) - continue; + return null; + } + ); + } + catch (IgniteCheckedException e) { + throw new IgniteException("Failed to assign partition states", e); + } - CacheGroupContext grpCtx = cctx.cache().cacheGroup(e.getKey()); + timeBag.finishGlobalStage("Assign partitions states"); + } - GridDhtPartitionTopology top = grpCtx != null ? - grpCtx.topology() : - cctx.exchange().clientTopology(e.getKey(), events().discoveryCache()); + /** + * Removes gaps in the local update counters. Gaps in update counters are possible on backup node when primary + * failed to send update counter deltas to backup. + */ + private void finalizePartitionCounters() { + // Reserve at least 2 threads for system operations. + int parallelismLvl = U.availableThreadCount(cctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2); - if (!CU.isPersistentCache(grpDesc.config(), cctx.gridConfig().getDataStorageConfiguration())) - assignPartitionSizes(top); - else - assignPartitionStates(top); + try { + U.doInParallel( + parallelismLvl, + cctx.kernalContext().getSystemExecutorService(), + nonLocalCacheGroups(), + grp -> { + grp.topology().finalizeUpdateCounters(); + + return null; + } + ); + } + catch (IgniteCheckedException e) { + throw new IgniteException("Failed to finalize partition counters", e); } - if (log.isInfoEnabled()) - log.info("Partitions assignment performed in " + (System.currentTimeMillis() - time) + " ms."); + timeBag.finishGlobalStage("Finalize update counters"); } /** @@ -3802,6 +3968,8 @@ private void processFullMessage(boolean checkCrd, ClusterNode node, GridDhtParti assert exchId.equals(msg.exchangeId()) : msg; assert msg.lastVersion() != null : msg; + timeBag.finishGlobalStage("Waiting for Full message"); + if (checkCrd) { assert node != null; @@ -3877,8 +4045,6 @@ private void processFullMessage(boolean checkCrd, ClusterNode node, GridDhtParti AffinityTopologyVersion resTopVer = initialVersion(); - long time = System.currentTimeMillis(); - if (exchCtx.mergeExchanges()) { if (msg.resultTopologyVersion() != null && !initialVersion().equals(msg.resultTopologyVersion())) { if (log.isInfoEnabled()) { @@ -3922,8 +4088,7 @@ else if (localJoinExchange() && !exchCtx.fetchAffinityOnJoin()) else if (forceAffReassignment) cctx.affinity().applyAffinityFromFullMessage(this, msg); - if (log.isInfoEnabled()) - log.info("Affinity changes applied in " + (System.currentTimeMillis() - time) + " ms."); + timeBag.finishGlobalStage("Affinity recalculation"); if (dynamicCacheStartExchange() && !F.isEmpty(exchangeGlobalExceptions)) { assert cctx.localNode().isClient(); @@ -3942,15 +4107,10 @@ else if (forceAffReassignment) updatePartitionFullMap(resTopVer, msg); - IgniteCheckedException err = null; - - if (stateChangeExchange() && !F.isEmpty(msg.getErrorsMap())) { - err = new IgniteCheckedException("Cluster state change failed"); - + if (stateChangeExchange() && !F.isEmpty(msg.getErrorsMap())) cctx.kernalContext().state().onStateChangeError(msg.getErrorsMap(), exchActions.stateChangeRequest()); - } - onDone(resTopVer, err); + onDone(resTopVer, null); } catch (IgniteCheckedException e) { onDone(e); @@ -3970,48 +4130,55 @@ private void updatePartitionFullMap(AffinityTopologyVersion resTopVer, GridDhtPa partHistSuppliers.putAll(msg.partitionHistorySuppliers()); - long time = System.currentTimeMillis(); + // Reserve at least 2 threads for system operations. + int parallelismLvl = U.availableThreadCount(cctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2); - for (Map.Entry entry : msg.partitions().entrySet()) { - Integer grpId = entry.getKey(); + try { + doInParallel( + parallelismLvl, + cctx.kernalContext().getSystemExecutorService(), + msg.partitions().keySet(), grpId -> { + CacheGroupContext grp = cctx.cache().cacheGroup(grpId); - CacheGroupContext grp = cctx.cache().cacheGroup(grpId); + if (grp != null) { + CachePartitionFullCountersMap cntrMap = msg.partitionUpdateCounters(grpId, + grp.topology().partitions()); - if (grp != null) { - CachePartitionFullCountersMap cntrMap = msg.partitionUpdateCounters(grpId, - grp.topology().partitions()); + grp.topology().update(resTopVer, + msg.partitions().get(grpId), + cntrMap, + msg.partsToReload(cctx.localNodeId(), grpId), + msg.partitionSizes(grpId), + null); + } + else { + ClusterNode oldest = cctx.discovery().oldestAliveServerNode(AffinityTopologyVersion.NONE); - grp.topology().update(resTopVer, - entry.getValue(), - cntrMap, - msg.partsToReload(cctx.localNodeId(), grpId), - msg.partitionSizes(grpId), - null); - } - else { - ClusterNode oldest = cctx.discovery().oldestAliveServerNode(AffinityTopologyVersion.NONE); + if (oldest != null && oldest.isLocal()) { + GridDhtPartitionTopology top = cctx.exchange().clientTopology(grpId, events().discoveryCache()); - if (oldest != null && oldest.isLocal()) { - GridDhtPartitionTopology top = cctx.exchange().clientTopology(grpId, events().discoveryCache()); + CachePartitionFullCountersMap cntrMap = msg.partitionUpdateCounters(grpId, + top.partitions()); - CachePartitionFullCountersMap cntrMap = msg.partitionUpdateCounters(grpId, - top.partitions()); + top.update(resTopVer, + msg.partitions().get(grpId), + cntrMap, + Collections.emptySet(), + null, + null); + } + } - top.update(resTopVer, - entry.getValue(), - cntrMap, - Collections.emptySet(), - null, - null); - } - } + return null; + }); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); } partitionsReceived = true; - if (log.isInfoEnabled()) - log.info("Full map updating for " + msg.partitions().size() - + " groups performed in " + (System.currentTimeMillis() - time) + " ms."); + timeBag.finishGlobalStage("Full map updating"); } /** @@ -4219,8 +4386,6 @@ public void onNodeLeft(final ClusterNode node) { if (isDone() || !enterBusy()) return; - cctx.mvcc().removeExplicitNodeLocks(node.id(), initialVersion()); - try { onDiscoveryEvent(new IgniteRunnable() { @Override public void run() { @@ -4315,7 +4480,16 @@ public void onNodeLeft(final ClusterNode node) { cctx.kernalContext().closure().callLocal(new Callable() { @Override public Void call() throws Exception { - newCrdFut.init(GridDhtPartitionsExchangeFuture.this); + try { + newCrdFut.init(GridDhtPartitionsExchangeFuture.this); + } + catch (Throwable t) { + U.error(log, "Failed to initialize new coordinator future [topVer=" + initialVersion() + "]", t); + + cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, t)); + + throw t; + } newCrdFut.listen(new CI1() { @Override public void apply(IgniteInternalFuture fut) { @@ -4437,21 +4611,38 @@ private void onBecomeCoordinator(InitNewCoordinatorFuture newCrdFut) { Map msgs = newCrdFut.messages(); if (!F.isEmpty(msgs)) { - Map joinedNodeAff = null; - - for (Map.Entry e : msgs.entrySet()) { - this.msgs.put(e.getKey().id(), e.getValue()); + Map joinedNodeAff = new ConcurrentHashMap<>(); - GridDhtPartitionsSingleMessage msg = e.getValue(); + // Reserve at least 2 threads for system operations. + int parallelismLvl = U.availableThreadCount(cctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2); - Collection affReq = msg.cacheGroupsAffinityRequest(); + try { + U.doInParallel( + parallelismLvl, + cctx.kernalContext().getSystemExecutorService(), + msgs.entrySet(), + entry -> { + this.msgs.put(entry.getKey().id(), entry.getValue()); + + GridDhtPartitionsSingleMessage msg = entry.getValue(); + + Collection affReq = msg.cacheGroupsAffinityRequest(); + + if (!F.isEmpty(affReq)) { + CacheGroupAffinityMessage.createAffinityMessages( + cctx, + fullMsg.resultTopologyVersion(), + affReq, + joinedNodeAff + ); + } - if (!F.isEmpty(affReq)) { - joinedNodeAff = CacheGroupAffinityMessage.createAffinityMessages(cctx, - fullMsg.resultTopologyVersion(), - affReq, - joinedNodeAff); - } + return null; + } + ); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); } Map mergedJoins = newCrdFut.mergedJoinExchangeMessages(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index a63ab70e28d53..a2cecb8ba527c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -19,8 +19,11 @@ import java.io.Externalizable; import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -28,11 +31,13 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.GridDirectMap; import org.apache.ignite.internal.GridDirectTransient; +import org.apache.ignite.internal.managers.communication.GridIoPolicy; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.lang.IgniteThrowableConsumer; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; @@ -410,69 +415,75 @@ void setErrorsMap(Map errs) { (!F.isEmpty(errs) && errsBytes == null); if (marshal) { - byte[] partsBytes0 = null; - byte[] partCntrsBytes0 = null; - byte[] partCntrsBytes20 = null; - byte[] partHistSuppliersBytes0 = null; - byte[] partsToReloadBytes0 = null; - byte[] partsSizesBytes0 = null; - byte[] errsBytes0 = null; + // Reserve at least 2 threads for system operations. + int parallelismLvl = U.availableThreadCount(ctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2); + + Collection objectsToMarshall = new ArrayList<>(); if (!F.isEmpty(parts) && partsBytes == null) - partsBytes0 = U.marshal(ctx, parts); + objectsToMarshall.add(parts); if (partCntrs != null && !partCntrs.empty() && partCntrsBytes == null) - partCntrsBytes0 = U.marshal(ctx, partCntrs); + objectsToMarshall.add(partCntrs); if (partCntrs2 != null && !partCntrs2.empty() && partCntrsBytes2 == null) - partCntrsBytes20 = U.marshal(ctx, partCntrs2); + objectsToMarshall.add(partCntrs2); if (partHistSuppliers != null && partHistSuppliersBytes == null) - partHistSuppliersBytes0 = U.marshal(ctx, partHistSuppliers); + objectsToMarshall.add(partHistSuppliers); if (partsToReload != null && partsToReloadBytes == null) - partsToReloadBytes0 = U.marshal(ctx, partsToReload); + objectsToMarshall.add(partsToReload); if (partsSizes != null && partsSizesBytes == null) - partsSizesBytes0 = U.marshal(ctx, partsSizes); + objectsToMarshall.add(partsSizes); if (!F.isEmpty(errs) && errsBytes == null) - errsBytes0 = U.marshal(ctx, errs); + objectsToMarshall.add(errs); + + Collection marshalled = U.doInParallel( + parallelismLvl, + ctx.kernalContext().getSystemExecutorService(), + objectsToMarshall, + new IgniteThrowableConsumer() { + @Override public byte[] accept(Object payload) throws IgniteCheckedException { + byte[] marshalled = U.marshal(ctx, payload); + + if(compress) + marshalled = U.zip(marshalled, ctx.gridConfig().getNetworkCompressionLevel()); + + return marshalled; + } + }); + + Iterator iterator = marshalled.iterator(); + + if (!F.isEmpty(parts) && partsBytes == null) + partsBytes = iterator.next(); + + if (partCntrs != null && !partCntrs.empty() && partCntrsBytes == null) + partCntrsBytes = iterator.next(); + + if (partCntrs2 != null && !partCntrs2.empty() && partCntrsBytes2 == null) + partCntrsBytes2 = iterator.next(); + + if (partHistSuppliers != null && partHistSuppliersBytes == null) + partHistSuppliersBytes = iterator.next(); + + if (partsToReload != null && partsToReloadBytes == null) + partsToReloadBytes = iterator.next(); + + if (partsSizes != null && partsSizesBytes == null) + partsSizesBytes = iterator.next(); + + if (!F.isEmpty(errs) && errsBytes == null) + errsBytes = iterator.next(); if (compress) { - assert !compressed(); - - try { - byte[] partsBytesZip = U.zip(partsBytes0); - byte[] partCntrsBytesZip = U.zip(partCntrsBytes0); - byte[] partCntrsBytes2Zip = U.zip(partCntrsBytes20); - byte[] partHistSuppliersBytesZip = U.zip(partHistSuppliersBytes0); - byte[] partsToReloadBytesZip = U.zip(partsToReloadBytes0); - byte[] partsSizesBytesZip = U.zip(partsSizesBytes0); - byte[] exsBytesZip = U.zip(errsBytes0); - - partsBytes0 = partsBytesZip; - partCntrsBytes0 = partCntrsBytesZip; - partCntrsBytes20 = partCntrsBytes2Zip; - partHistSuppliersBytes0 = partHistSuppliersBytesZip; - partsToReloadBytes0 = partsToReloadBytesZip; - partsSizesBytes0 = partsSizesBytesZip; - errsBytes0 = exsBytesZip; - - compressed(true); - } - catch (IgniteCheckedException e) { - U.error(ctx.logger(getClass()), "Failed to compress partitions data: " + e, e); - } - } + assert !compressed() : "Unexpected compressed state"; - partsBytes = partsBytes0; - partCntrsBytes = partCntrsBytes0; - partCntrsBytes2 = partCntrsBytes20; - partHistSuppliersBytes = partHistSuppliersBytes0; - partsToReloadBytes = partsToReloadBytes0; - partsSizesBytes = partsSizesBytes0; - errsBytes = errsBytes0; + compressed(true); + } } } @@ -494,11 +505,51 @@ public void topologyVersion(AffinityTopologyVersion topVer) { @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { super.finishUnmarshal(ctx, ldr); + ClassLoader classLoader = U.resolveClassLoader(ldr, ctx.gridConfig()); + + Collection objectsToUnmarshall = new ArrayList<>(); + + // Reserve at least 2 threads for system operations. + int parallelismLvl = U.availableThreadCount(ctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2); + + if (partsBytes != null && parts == null) + objectsToUnmarshall.add(partsBytes); + + if (partCntrsBytes != null && partCntrs == null) + objectsToUnmarshall.add(partCntrsBytes); + + if (partCntrsBytes2 != null && partCntrs2 == null) + objectsToUnmarshall.add(partCntrsBytes2); + + if (partHistSuppliersBytes != null && partHistSuppliers == null) + objectsToUnmarshall.add(partHistSuppliersBytes); + + if (partsToReloadBytes != null && partsToReload == null) + objectsToUnmarshall.add(partsToReloadBytes); + + if (partsSizesBytes != null && partsSizes == null) + objectsToUnmarshall.add(partsSizesBytes); + + if (errsBytes != null && errs == null) + objectsToUnmarshall.add(errsBytes); + + Collection unmarshalled = U.doInParallel( + parallelismLvl, + ctx.kernalContext().getSystemExecutorService(), + objectsToUnmarshall, + new IgniteThrowableConsumer() { + @Override public Object accept(byte[] binary) throws IgniteCheckedException { + return compressed() + ? U.unmarshalZip(ctx.marshaller(), binary, classLoader) + : U.unmarshal(ctx, binary, classLoader); + } + } + ); + + Iterator iterator = unmarshalled.iterator(); + if (partsBytes != null && parts == null) { - if (compressed()) - parts = U.unmarshalZip(ctx.marshaller(), partsBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - else - parts = U.unmarshal(ctx, partsBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); + parts = (Map)iterator.next(); if (dupPartsData != null) { assert parts != null; @@ -528,53 +579,41 @@ public void topologyVersion(AffinityTopologyVersion topVer) { } } - if (parts == null) - parts = new HashMap<>(); + if (partCntrsBytes != null && partCntrs == null) + partCntrs = (IgniteDhtPartitionCountersMap)iterator.next(); - if (partCntrsBytes != null && partCntrs == null) { - if (compressed()) - partCntrs = U.unmarshalZip(ctx.marshaller(), partCntrsBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - else - partCntrs = U.unmarshal(ctx, partCntrsBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - } + if (partCntrsBytes2 != null && partCntrs2 == null) + partCntrs2 = (IgniteDhtPartitionCountersMap2)iterator.next(); - if (partCntrsBytes2 != null && partCntrs2 == null) { - if (compressed()) - partCntrs2 = U.unmarshalZip(ctx.marshaller(), partCntrsBytes2, U.resolveClassLoader(ldr, ctx.gridConfig())); - else - partCntrs2 = U.unmarshal(ctx, partCntrsBytes2, U.resolveClassLoader(ldr, ctx.gridConfig())); - } + if (partHistSuppliersBytes != null && partHistSuppliers == null) + partHistSuppliers = (IgniteDhtPartitionHistorySuppliersMap)iterator.next(); - if (partHistSuppliersBytes != null && partHistSuppliers == null) { - if (compressed()) - partHistSuppliers = U.unmarshalZip(ctx.marshaller(), partHistSuppliersBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - else - partHistSuppliers = U.unmarshal(ctx, partHistSuppliersBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - } + if (partsToReloadBytes != null && partsToReload == null) + partsToReload = (IgniteDhtPartitionsToReloadMap)iterator.next(); - if (partsToReloadBytes != null && partsToReload == null) { - if (compressed()) - partsToReload = U.unmarshalZip(ctx.marshaller(), partsToReloadBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - else - partsToReload = U.unmarshal(ctx, partsToReloadBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - } + if (partsSizesBytes != null && partsSizes == null) + partsSizes = (Map>)iterator.next(); - if (partsSizesBytes != null && partsSizes == null) { - if (compressed()) - partsSizes = U.unmarshalZip(ctx.marshaller(), partsSizesBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - else - partsSizes = U.unmarshal(ctx, partsSizesBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - } + if (errsBytes != null && errs == null) + errs = (Map)iterator.next(); + + if (parts == null) + parts = new HashMap<>(); if (partCntrs == null) partCntrs = new IgniteDhtPartitionCountersMap(); - if (errsBytes != null && errs == null) { - if (compressed()) - errs = U.unmarshalZip(ctx.marshaller(), errsBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - else - errs = U.unmarshal(ctx, errsBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); - } + if (partCntrs2 == null) + partCntrs2 = new IgniteDhtPartitionCountersMap2(); + + if(partHistSuppliers == null) + partHistSuppliers = new IgniteDhtPartitionHistorySuppliersMap(); + + if(partsToReload == null) + partsToReload = new IgniteDhtPartitionsToReloadMap(); + + if(partsSizes == null) + partsSizes = new HashMap<>(); if (errs == null) errs = new HashMap<>(); @@ -595,74 +634,74 @@ public void topologyVersion(AffinityTopologyVersion topVer) { } switch (writer.state()) { - case 5: + case 6: if (!writer.writeMap("dupPartsData", dupPartsData, MessageCollectionItemType.INT, MessageCollectionItemType.INT)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeByteArray("errsBytes", errsBytes)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeMap("idealAffDiff", idealAffDiff, MessageCollectionItemType.INT, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeMap("joinedNodeAff", joinedNodeAff, MessageCollectionItemType.INT, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeByteArray("partCntrsBytes", partCntrsBytes)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeByteArray("partCntrsBytes2", partCntrsBytes2)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeByteArray("partHistSuppliersBytes", partHistSuppliersBytes)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeByteArray("partsBytes", partsBytes)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeByteArray("partsSizesBytes", partsSizesBytes)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeByteArray("partsToReloadBytes", partsToReloadBytes)) return false; writer.incrementState(); - case 15: - if (!writer.writeMessage("resTopVer", resTopVer)) + case 16: + if (!writer.writeAffinityTopologyVersion("resTopVer", resTopVer)) return false; writer.incrementState(); - case 16: - if (!writer.writeMessage("topVer", topVer)) + case 17: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -683,7 +722,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { return false; switch (reader.state()) { - case 5: + case 6: dupPartsData = reader.readMap("dupPartsData", MessageCollectionItemType.INT, MessageCollectionItemType.INT, false); if (!reader.isLastRead()) @@ -691,7 +730,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 6: + case 7: errsBytes = reader.readByteArray("errsBytes"); if (!reader.isLastRead()) @@ -699,7 +738,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 7: + case 8: idealAffDiff = reader.readMap("idealAffDiff", MessageCollectionItemType.INT, MessageCollectionItemType.MSG, false); if (!reader.isLastRead()) @@ -707,7 +746,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 8: + case 9: joinedNodeAff = reader.readMap("joinedNodeAff", MessageCollectionItemType.INT, MessageCollectionItemType.MSG, false); if (!reader.isLastRead()) @@ -715,7 +754,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 9: + case 10: partCntrsBytes = reader.readByteArray("partCntrsBytes"); if (!reader.isLastRead()) @@ -723,7 +762,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 10: + case 11: partCntrsBytes2 = reader.readByteArray("partCntrsBytes2"); if (!reader.isLastRead()) @@ -731,7 +770,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 11: + case 12: partHistSuppliersBytes = reader.readByteArray("partHistSuppliersBytes"); if (!reader.isLastRead()) @@ -739,7 +778,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 12: + case 13: partsBytes = reader.readByteArray("partsBytes"); if (!reader.isLastRead()) @@ -747,7 +786,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 13: + case 14: partsSizesBytes = reader.readByteArray("partsSizesBytes"); if (!reader.isLastRead()) @@ -755,7 +794,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 14: + case 15: partsToReloadBytes = reader.readByteArray("partsToReloadBytes"); if (!reader.isLastRead()) @@ -763,16 +802,16 @@ public void topologyVersion(AffinityTopologyVersion topVer) { reader.incrementState(); - case 15: - resTopVer = reader.readMessage("resTopVer"); + case 16: + resTopVer = reader.readAffinityTopologyVersion("resTopVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 16: - topVer = reader.readMessage("topVer"); + case 17: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; @@ -791,7 +830,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 17; + return 18; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 088fb31d7f715..3316e3ec432ee 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -30,7 +30,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; @@ -103,15 +102,15 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes @GridDirectCollection(Integer.class) private Collection grpsAffRequest; + /** Start time of exchange on node which sent this message in nanoseconds. */ + private long exchangeStartTime; + /** * Exchange finish message, sent to new coordinator when it tries to * restore state after previous coordinator failed during exchange. */ private GridDhtPartitionsFullMessage finishMsg; - /** */ - private GridLongList activeQryTrackers; - /** * Required by {@link Externalizable}. */ @@ -135,20 +134,6 @@ public GridDhtPartitionsSingleMessage(GridDhtPartitionExchangeId exchId, this.compress = compress; } - /** - * @return Active queries started with previous coordinator. - */ - GridLongList activeQueries() { - return activeQryTrackers; - } - - /** - * @param activeQrys Active queries started with previous coordinator. - */ - void activeQueries(GridLongList activeQrys) { - this.activeQryTrackers = activeQrys; - } - /** * @param finishMsg Exchange finish message (used to restore exchange state on new coordinator). */ @@ -334,6 +319,20 @@ public void setError(Exception ex) { return err; } + /** + * Start time of exchange on node which sent this message. + */ + public long exchangeStartTime() { + return exchangeStartTime; + } + + /** + * @param exchangeStartTime Start time of exchange. + */ + public void exchangeStartTime(long exchangeStartTime) { + this.exchangeStartTime = exchangeStartTime; + } + /** {@inheritDoc} * @param ctx*/ @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { @@ -473,65 +472,66 @@ public void setError(Exception ex) { } switch (writer.state()) { - case 5: + case 6: if (!writer.writeBoolean("client", client)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeMap("dupPartsData", dupPartsData, MessageCollectionItemType.INT, MessageCollectionItemType.INT)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 8: + case 9: + if (!writer.writeLong("exchangeStartTime", exchangeStartTime)) + return false; + + writer.incrementState(); + + case 10: if (!writer.writeMessage("finishMsg", finishMsg)) return false; writer.incrementState(); - case 9: + case 11: if (!writer.writeCollection("grpsAffRequest", grpsAffRequest, MessageCollectionItemType.INT)) return false; writer.incrementState(); - case 10: + case 12: if (!writer.writeByteArray("partCntrsBytes", partCntrsBytes)) return false; writer.incrementState(); - case 11: + case 13: if (!writer.writeByteArray("partHistCntrsBytes", partHistCntrsBytes)) return false; writer.incrementState(); - case 12: + case 14: if (!writer.writeByteArray("partsBytes", partsBytes)) return false; writer.incrementState(); - case 13: + case 15: if (!writer.writeByteArray("partsSizesBytes", partsSizesBytes)) return false; writer.incrementState(); - case 14: - if (!writer.writeMessage("activeQryTrackers", activeQryTrackers)) - return false; - - writer.incrementState(); } return true; @@ -548,7 +548,7 @@ public void setError(Exception ex) { return false; switch (reader.state()) { - case 5: + case 6: client = reader.readBoolean("client"); if (!reader.isLastRead()) @@ -556,7 +556,7 @@ public void setError(Exception ex) { reader.incrementState(); - case 6: + case 7: dupPartsData = reader.readMap("dupPartsData", MessageCollectionItemType.INT, MessageCollectionItemType.INT, false); if (!reader.isLastRead()) @@ -564,7 +564,7 @@ public void setError(Exception ex) { reader.incrementState(); - case 7: + case 8: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -572,7 +572,15 @@ public void setError(Exception ex) { reader.incrementState(); - case 8: + case 9: + exchangeStartTime = reader.readLong("exchangeStartTime"); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + + case 10: finishMsg = reader.readMessage("finishMsg"); if (!reader.isLastRead()) @@ -580,7 +588,7 @@ public void setError(Exception ex) { reader.incrementState(); - case 9: + case 11: grpsAffRequest = reader.readCollection("grpsAffRequest", MessageCollectionItemType.INT); if (!reader.isLastRead()) @@ -588,7 +596,7 @@ public void setError(Exception ex) { reader.incrementState(); - case 10: + case 12: partCntrsBytes = reader.readByteArray("partCntrsBytes"); if (!reader.isLastRead()) @@ -596,7 +604,7 @@ public void setError(Exception ex) { reader.incrementState(); - case 11: + case 13: partHistCntrsBytes = reader.readByteArray("partHistCntrsBytes"); if (!reader.isLastRead()) @@ -604,7 +612,7 @@ public void setError(Exception ex) { reader.incrementState(); - case 12: + case 14: partsBytes = reader.readByteArray("partsBytes"); if (!reader.isLastRead()) @@ -612,7 +620,7 @@ public void setError(Exception ex) { reader.incrementState(); - case 13: + case 15: partsSizesBytes = reader.readByteArray("partsSizesBytes"); if (!reader.isLastRead()) @@ -620,13 +628,6 @@ public void setError(Exception ex) { reader.incrementState(); - case 14: - activeQryTrackers = reader.readMessage("activeQryTrackers"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); } return reader.afterMessageRead(GridDhtPartitionsSingleMessage.class); @@ -639,7 +640,7 @@ public void setError(Exception ex) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 15; + return 16; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java index 0be0f37aa22ac..26d3cdeffd684 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java @@ -89,7 +89,7 @@ GridDhtPartitionExchangeId restoreExchangeId() { } switch (writer.state()) { - case 5: + case 6: if (!writer.writeMessage("restoreExchId", restoreExchId)) return false; @@ -111,7 +111,7 @@ GridDhtPartitionExchangeId restoreExchangeId() { return false; switch (reader.state()) { - case 5: + case 6: restoreExchId = reader.readMessage("restoreExchId"); if (!reader.isLastRead()) @@ -131,7 +131,7 @@ GridDhtPartitionExchangeId restoreExchangeId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 6; + return 7; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java index 034bf72cecf4e..b3f597cd5d5ca 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java @@ -20,14 +20,16 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Queue; import java.util.UUID; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.stream.Collectors; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.NodeStoppingException; +import org.apache.ignite.internal.managers.communication.GridIoPolicy; import org.apache.ignite.internal.processors.affinity.AffinityAssignment; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheGroupContext; @@ -43,7 +45,9 @@ import org.apache.ignite.internal.util.future.GridFinishedFuture; import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.lang.GridPlainRunnable; +import org.apache.ignite.internal.util.lang.GridTuple3; import org.apache.ignite.internal.util.typedef.CI1; +import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; import org.jetbrains.annotations.Nullable; @@ -80,6 +84,12 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter { /** Demand lock. */ private final ReadWriteLock demandLock = new ReentrantReadWriteLock(); + /** */ + private boolean paused; + + /** */ + private Queue> pausedDemanderQueue = new ConcurrentLinkedQueue<>(); + /** */ private boolean stopped; @@ -168,6 +178,9 @@ private IgniteCheckedException stopError() { if (ctx.kernalContext().clientNode() || rebTopVer.equals(AffinityTopologyVersion.NONE)) return false; // No-op. + if (exchFut.resetLostPartitionFor(grp.cacheOrGroupName())) + return true; + if (exchFut.localJoinExchange()) return true; // Required, can have outdated updSeq partition counter if node reconnects. @@ -184,38 +197,10 @@ private IgniteCheckedException stopError() { if (rebFut.isDone() && !rebFut.result()) return true; // Required, previous rebalance cancelled. - final AffinityTopologyVersion exchTopVer = exchFut.context().events().topologyVersion(); - - Collection aliveNodes = ctx.discovery().aliveServerNodes().stream() - .map(ClusterNode::id) - .collect(Collectors.toList()); - - return assignmentsChanged(rebTopVer, exchTopVer) || - !aliveNodes.containsAll(demander.remainingNodes()); // Some of nodes left before rabalance compelete. - } - - /** - * @param oldTopVer Previous topology version. - * @param newTopVer New topology version to check result. - * @return {@code True} if affinity assignments changed between two versions for local node. - */ - private boolean assignmentsChanged(AffinityTopologyVersion oldTopVer, AffinityTopologyVersion newTopVer) { - final AffinityAssignment aff = grp.affinity().readyAffinity(newTopVer); - - // We should get affinity assignments based on previous rebalance to calculate difference. - // Whole history size described by IGNITE_AFFINITY_HISTORY_SIZE constant. - final AffinityAssignment prevAff = grp.affinity().cachedVersions().contains(oldTopVer) ? - grp.affinity().cachedAffinity(oldTopVer) : null; - - if (prevAff == null) - return false; - - boolean assignsChanged = false; + AffinityTopologyVersion lastAffChangeTopVer = + ctx.exchange().lastAffinityChangedTopologyVersion(exchFut.topologyVersion()); - for (int p = 0; !assignsChanged && p < grp.affinity().partitions(); p++) - assignsChanged |= aff.get(p).contains(ctx.localNode()) != prevAff.get(p).contains(ctx.localNode()); - - return assignsChanged; + return lastAffChangeTopVer.compareTo(rebTopVer) > 0; } /** {@inheritDoc} */ @@ -384,7 +369,10 @@ private List remoteOwners(int p, AffinityTopologyVersion topVer) { demandLock.readLock().lock(); try { - demander.handleSupplyMessage(idx, id, s); + if (paused) + pausedDemanderQueue.add(F.t(idx, id, s)); + else + demander.handleSupplyMessage(idx, id, s); } finally { demandLock.readLock().unlock(); @@ -589,6 +577,41 @@ private GridDhtFuture request0(GridCacheContext cctx, Collection> msgToProc = + new ArrayList<>(pausedDemanderQueue); + + pausedDemanderQueue.clear(); + + final GridDhtPreloader preloader = this; + + ctx.kernalContext().closure().runLocalSafe(() -> msgToProc.forEach( + m -> preloader.handleSupplyMessage(m.get1(), m.get2(), m.get3()) + ), GridIoPolicy.SYSTEM_POOL); + + paused = false; + } + finally { + demandLock.writeLock().unlock(); + } + } + /** {@inheritDoc} */ @Override public void dumpDebugInfo() { // No-op diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/ExchangeLatchManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/ExchangeLatchManager.java index 35c04fb7d7902..0308ff4198d95 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/ExchangeLatchManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/ExchangeLatchManager.java @@ -64,7 +64,7 @@ public class ExchangeLatchManager { * Exchange latch V2 protocol introduces following optimization: * Joining nodes are explicitly excluded from possible latch participants. */ - public static final IgniteProductVersion PROTOCOL_V2_VERSION_SINCE = IgniteProductVersion.fromString("2.7.0"); + public static final IgniteProductVersion PROTOCOL_V2_VERSION_SINCE = IgniteProductVersion.fromString("2.5.3"); /** Logger. */ private final IgniteLogger log; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/LatchAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/LatchAckMessage.java index bad1b6137bac5..9c69fdf581856 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/LatchAckMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/latch/LatchAckMessage.java @@ -103,10 +103,11 @@ public boolean isFinal() { writer.incrementState(); case 2: - if (!writer.writeMessage("topVer", topVer)) + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); + } return true; @@ -137,12 +138,13 @@ public boolean isFinal() { reader.incrementState(); case 2: - topVer = reader.readMessage("topVer"); + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); + } return reader.afterMessageRead(LatchAckMessage.class); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridClientPartitionTopology.java index cd6e254efcf50..0a50b94e20b17 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridClientPartitionTopology.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridClientPartitionTopology.java @@ -48,7 +48,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; import org.apache.ignite.internal.util.F0; import org.apache.ignite.internal.util.GridAtomicLong; import org.apache.ignite.internal.util.GridPartitionStateMap; @@ -201,11 +200,6 @@ private String mapString(GridDhtPartitionMap map) { lock.readLock().unlock(); } - /** {@inheritDoc} */ - @Override public MvccCoordinator mvccCoordinator() { - throw new UnsupportedOperationException(); - } - /** {@inheritDoc} */ @Override public boolean holdsLock() { return lock.isWriteLockedByCurrentThread() || lock.getReadHoldCount() > 0; @@ -215,7 +209,6 @@ private String mapString(GridDhtPartitionMap map) { @Override public void updateTopologyVersion( GridDhtTopologyFuture exchFut, DiscoCache discoCache, - MvccCoordinator mvccCrd, long updSeq, boolean stopping ) throws IgniteInterruptedCheckedException { @@ -1119,7 +1112,7 @@ private void removeNode(UUID nodeId) { } /** {@inheritDoc} */ - @Override public void ownMoving(AffinityTopologyVersion topVer) { + @Override public void ownMoving(AffinityTopologyVersion rebFinishedTopVer) { // No-op } @@ -1234,11 +1227,15 @@ private void removeNode(UUID nodeId) { } /** {@inheritDoc} */ - @Override public CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros, - boolean finalizeCntrsBeforeCollecting) { + @Override public CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros) { return CachePartitionPartialCountersMap.EMPTY; } + /** {@inheritDoc} */ + @Override public void finalizeUpdateCounters() { + // No-op. + } + /** {@inheritDoc} */ @Override public Map partitionSizes() { return Collections.emptyMap(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java index 2ddc0d447ceba..ca3a154c782c8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java @@ -32,6 +32,8 @@ import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.NodeStoppingException; @@ -53,6 +55,7 @@ import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.GridQueryRowCacheCleaner; +import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.lang.GridIterator; import org.apache.ignite.internal.util.tostring.GridToStringExclude; @@ -79,15 +82,7 @@ */ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements Comparable, GridReservable { /** */ - private static final GridCacheMapEntryFactory ENTRY_FACTORY = new GridCacheMapEntryFactory() { - @Override public GridCacheMapEntry create( - GridCacheContext ctx, - AffinityTopologyVersion topVer, - KeyCacheObject key - ) { - return new GridDhtCacheEntry(ctx, topVer, key); - } - }; + private static final GridCacheMapEntryFactory ENTRY_FACTORY = GridDhtCacheEntry::new; /** Maximum size for delete queue. */ public static final int MAX_DELETE_QUEUE_SIZE = Integer.getInteger(IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE, 200_000); @@ -179,11 +174,15 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements * @param ctx Context. * @param grp Cache group. * @param id Partition ID. + * @param recovery Flag indicates that partition is created during recovery phase. */ @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor") - public GridDhtLocalPartition(GridCacheSharedContext ctx, - CacheGroupContext grp, - int id) { + public GridDhtLocalPartition( + GridCacheSharedContext ctx, + CacheGroupContext grp, + int id, + boolean recovery + ) { super(ENTRY_FACTORY); this.id = id; @@ -220,7 +219,7 @@ public GridDhtLocalPartition(GridCacheSharedContext ctx, store = grp.offheap().createCacheDataStore(id); // Log partition creation for further crash recovery purposes. - if (grp.walEnabled()) + if (grp.walEnabled() && !recovery) ctx.wal().log(new PartitionMetaStateRecord(grp.groupId(), id, state(), updateCounter())); // Inject row cache cleaner on store creation @@ -359,7 +358,7 @@ public int reservations() { * @return {@code True} if partition is empty. */ public boolean isEmpty() { - return store.fullSize() == 0 && internalSize() == 0; + return store.isEmpty() && internalSize() == 0; } /** @@ -567,6 +566,8 @@ private boolean casState(long state, GridDhtPartitionState toState) { } catch (IgniteCheckedException e) { U.error(log, "Failed to log partition state change to WAL.", e); + + ctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } if (log.isDebugEnabled()) @@ -981,6 +982,19 @@ public long nextUpdateCounter(int cacheId, AffinityTopologyVersion topVer, boole if (grp.sharedGroup()) grp.onPartitionCounterUpdate(cacheId, id, primaryCntr != null ? primaryCntr : nextCntr, topVer, primary); + // This is first update in partition, we should log partition state information for further crash recovery. + if (nextCntr == 1) { + if (grp.persistenceEnabled() && grp.walEnabled()) + try { + ctx.wal().log(new PartitionMetaStateRecord(grp.groupId(), id, state(), 0)); + } + catch (IgniteCheckedException e) { + U.error(log, "Failed to log partition state snapshot to WAL.", e); + + ctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); + } + } + return nextCntr; } @@ -1372,9 +1386,11 @@ private static long setSize(long state, int size) { /** * Flushes pending update counters closing all possible gaps. + * + * @return Even-length array of pairs [start, end] for each gap. */ - public void finalizeUpdateCountres() { - store.finalizeUpdateCountres(); + public GridLongList finalizeUpdateCounters() { + return store.finalizeUpdateCounters(); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopology.java index 25b284ed29f46..4b1e5a6ada99d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopology.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopology.java @@ -25,6 +25,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.events.DiscoveryEvent; +import org.apache.ignite.events.EventType; import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.managers.discovery.DiscoCache; import org.apache.ignite.internal.processors.affinity.AffinityAssignment; @@ -37,7 +38,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.jetbrains.annotations.Nullable; @@ -77,7 +77,6 @@ public interface GridDhtPartitionTopology { public void updateTopologyVersion( GridDhtTopologyFuture exchFut, DiscoCache discoCache, - MvccCoordinator mvccCrd, long updateSeq, boolean stopping ) throws IgniteInterruptedCheckedException; @@ -327,10 +326,10 @@ public boolean update(@Nullable GridDhtPartitionExchangeId exchId, * This method should be called on topology coordinator after all partition messages are received. * * @param resTopVer Exchange result version. - * @param discoEvt Discovery event for which we detect lost partitions. + * @param discoEvt Discovery event for which we detect lost partitions if {@link EventType#EVT_CACHE_REBALANCE_PART_DATA_LOST} event should be fired. * @return {@code True} if partitions state got updated. */ - public boolean detectLostPartitions(AffinityTopologyVersion resTopVer, DiscoveryEvent discoEvt); + public boolean detectLostPartitions(AffinityTopologyVersion resTopVer, @Nullable DiscoveryEvent discoEvt); /** * Resets the state of all LOST partitions to OWNING. @@ -344,6 +343,11 @@ public boolean update(@Nullable GridDhtPartitionExchangeId exchId, */ public Collection lostPartitions(); + /** + * Pre-processes partition update counters before exchange. + */ + void finalizeUpdateCounters(); + /** * @return Partition update counters. */ @@ -351,11 +355,9 @@ public boolean update(@Nullable GridDhtPartitionExchangeId exchId, /** * @param skipZeros {@code True} for adding zero counter to map. - * @param finalizeCntrsBeforeCollecting {@code True} indicates that partition counters should be finalized. * @return Partition update counters. */ - public CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros, - boolean finalizeCntrsBeforeCollecting); + public CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros); /** * @return Partition cache sizes. @@ -371,9 +373,9 @@ public CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros, /** * Owns all moving partitions for the given topology version. * - * @param topVer Topology version. + * @param rebFinishedTopVer Topology version when rebalancing finished. */ - public void ownMoving(AffinityTopologyVersion topVer); + public void ownMoving(AffinityTopologyVersion rebFinishedTopVer); /** * @param part Evicted partition. @@ -428,6 +430,4 @@ public CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros, * @param updateRebalanceVer {@code True} if need check rebalance state. */ public void onExchangeDone(GridDhtPartitionsExchangeFuture fut, AffinityAssignment assignment, boolean updateRebalanceVer); - - public MvccCoordinator mvccCoordinator(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java index 683a140c5d978..39484d4b0b38e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; +import java.util.TreeSet; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReferenceArray; @@ -45,6 +46,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.ExchangeDiscoveryEvents; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; @@ -54,9 +56,9 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; import org.apache.ignite.internal.util.F0; import org.apache.ignite.internal.util.GridAtomicLong; +import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.internal.util.GridPartitionStateMap; import org.apache.ignite.internal.util.StripedCompositeReadWriteLock; import org.apache.ignite.internal.util.tostring.GridToStringExclude; @@ -110,8 +112,8 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology { /** Node to partition map. */ private GridDhtPartitionFullMap node2part; - /** Partitions map for left nodes. */ - private GridDhtPartitionFullMap leftNode2Part = new GridDhtPartitionFullMap(); + /** */ + private Set lostParts; /** */ private final Map> diffFromAffinity = new HashMap<>(); @@ -149,9 +151,6 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology { /** */ private volatile AffinityTopologyVersion rebalancedTopVer = AffinityTopologyVersion.NONE; - /** */ - private volatile MvccCoordinator mvccCrd; - /** * @param ctx Cache shared context. * @param grp Cache group. @@ -243,11 +242,6 @@ private String mapString(GridDhtPartitionMap map) { lock.readLock().unlock(); } - /** {@inheritDoc} */ - @Override public MvccCoordinator mvccCoordinator() { - return mvccCrd; - } - /** {@inheritDoc} */ @Override public boolean holdsLock() { return lock.isWriteLockedByCurrentThread() || lock.getReadHoldCount() > 0; @@ -257,7 +251,6 @@ private String mapString(GridDhtPartitionMap map) { @Override public void updateTopologyVersion( GridDhtTopologyFuture exchFut, @NotNull DiscoCache discoCache, - MvccCoordinator mvccCrd, long updSeq, boolean stopping ) throws IgniteInterruptedCheckedException { @@ -284,7 +277,6 @@ private String mapString(GridDhtPartitionMap map) { lastTopChangeVer = exchTopVer; this.discoCache = discoCache; - this.mvccCrd = mvccCrd; } finally { lock.writeLock().unlock(); @@ -313,9 +305,18 @@ private String mapString(GridDhtPartitionMap map) { /** {@inheritDoc} */ @Override public GridDhtTopologyFuture topologyVersionFuture() { - assert topReadyFut != null; + GridDhtTopologyFuture topReadyFut0 = topReadyFut; - return topReadyFut; + assert topReadyFut0 != null; + + if (!topReadyFut0.changedAffinity()) { + GridDhtTopologyFuture lastFut = ctx.exchange().lastFinishedFuture(); + + if (lastFut != null) + return lastFut; + } + + return topReadyFut0; } /** {@inheritDoc} */ @@ -748,45 +749,47 @@ private boolean partitionLocalNode(int p, AffinityTopologyVersion topVer) { long updateSeq = this.updateSeq.incrementAndGet(); - for (int p = 0; p < partitions; p++) { - GridDhtLocalPartition locPart = localPartition0(p, topVer, false, true); - - if (partitionLocalNode(p, topVer)) { - // Prepare partition to rebalance if it's not happened on full map update phase. - if (locPart == null || locPart.state() == RENTING || locPart.state() == EVICTED) - locPart = rebalancePartition(p, false); + if (!ctx.localNode().isClient()) { + for (int p = 0; p < partitions; p++) { + GridDhtLocalPartition locPart = localPartition0(p, topVer, false, true); - GridDhtPartitionState state = locPart.state(); + if (partitionLocalNode(p, topVer)) { + // Prepare partition to rebalance if it's not happened on full map update phase. + if (locPart == null || locPart.state() == RENTING || locPart.state() == EVICTED) + locPart = rebalancePartition(p, false); - if (state == MOVING) { - if (grp.rebalanceEnabled()) { - Collection owners = owners(p); + GridDhtPartitionState state = locPart.state(); - // If an owner node left during exchange, then new exchange should be started with detecting lost partitions. - if (!F.isEmpty(owners)) { - if (log.isDebugEnabled()) - log.debug("Will not own partition (there are owners to rebalance from) " + - "[grp=" + grp.cacheOrGroupName() + ", p=" + p + ", owners = " + owners + ']'); + if (state == MOVING) { + if (grp.rebalanceEnabled()) { + Collection owners = owners(p); + + // If an owner node left during exchange, then new exchange should be started with detecting lost partitions. + if (!F.isEmpty(owners)) { + if (log.isDebugEnabled()) + log.debug("Will not own partition (there are owners to rebalance from) " + + "[grp=" + grp.cacheOrGroupName() + ", p=" + p + ", owners = " + owners + ']'); + } } + else + updateSeq = updateLocal(p, locPart.state(), updateSeq, topVer); } - else - updateSeq = updateLocal(p, locPart.state(), updateSeq, topVer); } - } - else { - if (locPart != null) { - GridDhtPartitionState state = locPart.state(); + else { + if (locPart != null) { + GridDhtPartitionState state = locPart.state(); - if (state == MOVING) { - locPart.rent(false); + if (state == MOVING) { + locPart.rent(false); - updateSeq = updateLocal(p, locPart.state(), updateSeq, topVer); + updateSeq = updateLocal(p, locPart.state(), updateSeq, topVer); - changed = true; + changed = true; - if (log.isDebugEnabled()) { - log.debug("Evicting " + state + " partition (it does not belong to affinity) [" + - "grp=" + grp.cacheOrGroupName() + ", p=" + locPart.id() + ']'); + if (log.isDebugEnabled()) { + log.debug("Evicting " + state + " partition (it does not belong to affinity) [" + + "grp=" + grp.cacheOrGroupName() + ", p=" + locPart.id() + ']'); + } } } } @@ -850,7 +853,7 @@ private GridDhtLocalPartition getOrCreatePartition(int p) { if (loc != null) loc.awaitDestroy(); - locParts.set(p, loc = new GridDhtLocalPartition(ctx, grp, p)); + locParts.set(p, loc = new GridDhtLocalPartition(ctx, grp, p, false)); long updCntr = cntrMap.updateCounter(p); @@ -881,12 +884,10 @@ private GridDhtLocalPartition getOrCreatePartition(int p) { if (part != null && part.state() != EVICTED) return part; - part = new GridDhtLocalPartition(ctx, grp, p); + part = new GridDhtLocalPartition(ctx, grp, p, true); locParts.set(p, part); - ctx.pageStore().onPartitionCreated(grp.groupId(), p); - return part; } finally { @@ -946,8 +947,10 @@ private GridDhtLocalPartition localPartition0(int p, } } else if (loc != null && state == RENTING && !showRenting) { + boolean belongsNow = topVer.equals(this.readyTopVer) ? belongs : partitionLocalNode(p, this.readyTopVer); + throw new GridDhtInvalidPartitionException(p, "Adding entry to partition that is concurrently " + - "evicted [grp=" + grp.cacheOrGroupName() + ", part=" + p + ", shouldBeMoving=" + "evicted [grp=" + grp.cacheOrGroupName() + ", part=" + p + ", belongsNow=" + belongsNow + ", belongs=" + belongs + ", topVer=" + topVer + ", curTopVer=" + this.readyTopVer + "]"); } @@ -958,7 +961,7 @@ else if (loc != null && state == RENTING && !showRenting) { "[grp=" + grp.cacheOrGroupName() + ", part=" + p + ", topVer=" + topVer + ", this.topVer=" + this.readyTopVer + ']'); - locParts.set(p, loc = new GridDhtLocalPartition(ctx, grp, p)); + locParts.set(p, loc = new GridDhtLocalPartition(ctx, grp, p, false)); this.updateSeq.incrementAndGet(); @@ -1131,25 +1134,38 @@ else if (loc != null && state == RENTING && !showRenting) { List nodes = null; - if (!topVer.equals(diffFromAffinityVer)) { - LT.warn(log, "Requested topology version does not match calculated diff, will require full iteration to" + - "calculate mapping [grp=" + grp.cacheOrGroupName() + ", topVer=" + topVer + - ", diffVer=" + diffFromAffinityVer + "]"); + AffinityTopologyVersion diffVer = diffFromAffinityVer; - nodes = new ArrayList<>(); + if (!diffVer.equals(topVer)) { + LT.warn(log, "Requested topology version does not match calculated diff, need to check if " + + "affinity has changed [grp=" + grp.cacheOrGroupName() + ", topVer=" + topVer + + ", diffVer=" + diffVer + "]"); - nodes.addAll(affNodes); + boolean affChanged; - for (Map.Entry entry : node2part.entrySet()) { - GridDhtPartitionState state = entry.getValue().get(p); + if (diffVer.compareTo(topVer) < 0) + affChanged = ctx.exchange().affinityChanged(diffVer, topVer); + else + affChanged = ctx.exchange().affinityChanged(topVer, diffVer); - ClusterNode n = ctx.discovery().node(entry.getKey()); + if (affChanged) { + LT.warn(log, "Requested topology version does not match calculated diff, will require full iteration to" + + "calculate mapping [grp=" + grp.cacheOrGroupName() + ", topVer=" + topVer + + ", diffVer=" + diffVer + "]"); - if (n != null && state != null && (state == MOVING || state == OWNING || state == RENTING) - && !nodes.contains(n) && (topVer.topologyVersion() < 0 || n.order() <= topVer.topologyVersion())) { - nodes.add(n); - } + nodes = new ArrayList<>(); + nodes.addAll(affNodes); + + for (Map.Entry entry : node2part.entrySet()) { + GridDhtPartitionState state = entry.getValue().get(p); + + ClusterNode n = ctx.discovery().node(entry.getKey()); + + if (n != null && state != null && (state == MOVING || state == OWNING || state == RENTING) + && !nodes.contains(n) && (topVer.topologyVersion() < 0 || n.order() <= topVer.topologyVersion())) + nodes.add(n); + } } return nodes; @@ -1468,13 +1484,6 @@ private boolean shouldOverridePartitionMap(GridDhtPartitionMap currentMap, GridD log.trace("Removing left node from full map update [grp=" + grp.cacheOrGroupName() + ", nodeId=" + nodeId + ", partMap=" + partMap + ']'); - if (node2part.containsKey(nodeId)) { - GridDhtPartitionMap map = partMap.get(nodeId); - - if (map != null) - leftNode2Part.put(nodeId, map); - } - it.remove(); } } @@ -2005,7 +2014,7 @@ private void rebuildDiff(AffinityAssignment affAssignment) { } /** {@inheritDoc} */ - @Override public boolean detectLostPartitions(AffinityTopologyVersion resTopVer, DiscoveryEvent discoEvt) { + @Override public boolean detectLostPartitions(AffinityTopologyVersion resTopVer, @Nullable DiscoveryEvent discoEvt) { ctx.database().checkpointReadLock(); try { @@ -2015,42 +2024,55 @@ private void rebuildDiff(AffinityAssignment affAssignment) { if (node2part == null) return false; + PartitionLossPolicy plc = grp.config().getPartitionLossPolicy(); + + assert plc != null; + int parts = grp.affinity().partitions(); - Set lost = new HashSet<>(parts); + Set recentlyLost = null; - for (int p = 0; p < parts; p++) - lost.add(p); + boolean changed = false; - for (GridDhtPartitionMap partMap : node2part.values()) { - for (Map.Entry e : partMap.entrySet()) { - if (e.getValue() == OWNING) { - lost.remove(e.getKey()); + for (int part = 0; part < parts; part++) { + boolean lost = F.contains(lostParts, part); + + if (!lost) { + boolean hasOwner = false; - if (lost.isEmpty()) + for (GridDhtPartitionMap partMap : node2part.values()) { + if (partMap.get(part) == OWNING) { + hasOwner = true; break; + } } - } - } - boolean changed = false; + if (!hasOwner) { + lost = true; + + if (lostParts == null) + lostParts = new TreeSet<>(); - if (!F.isEmpty(lost)) { - PartitionLossPolicy plc = grp.config().getPartitionLossPolicy(); + lostParts.add(part); - assert plc != null; + if (discoEvt != null) { + if (recentlyLost == null) + recentlyLost = new HashSet<>(); - Set recentlyLost = new HashSet<>(); + recentlyLost.add(part); - for (Map.Entry leftEntry : leftNode2Part.entrySet()) { - for (Map.Entry entry : leftEntry.getValue().entrySet()) { - if (entry.getValue() == OWNING) - recentlyLost.add(entry.getKey()); + if (grp.eventRecordable(EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST)) { + grp.addRebalanceEvent(part, + EVT_CACHE_REBALANCE_PART_DATA_LOST, + discoEvt.eventNode(), + discoEvt.type(), + discoEvt.timestamp()); + } + } } } - // Update partition state on all nodes. - for (Integer part : lost) { + if (lost) { long updSeq = updateSeq.incrementAndGet(); GridDhtLocalPartition locPart = localPartition(part, resTopVer, false, true); @@ -2076,21 +2098,17 @@ else if (plc != PartitionLossPolicy.IGNORE) { e.getValue().put(part, LOST); } } - - if (recentlyLost.contains(part) && grp.eventRecordable(EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST)) { - grp.addRebalanceEvent(part, - EVT_CACHE_REBALANCE_PART_DATA_LOST, - discoEvt.eventNode(), - discoEvt.type(), - discoEvt.timestamp()); - } } + } - if (plc != PartitionLossPolicy.IGNORE) - grp.needsRecovery(true); + if (recentlyLost != null) { + U.warn(log, "Detected lost partitions [grp=" + grp.cacheOrGroupName() + + ", parts=" + S.compact(recentlyLost) + + ", plc=" + plc + "]"); } - leftNode2Part.clear(); + if (lostParts != null && plc != PartitionLossPolicy.IGNORE) + grp.needsRecovery(true); return changed; } @@ -2125,14 +2143,23 @@ else if (plc != PartitionLossPolicy.IGNORE) { if (locPart != null && locPart.state() == LOST) { boolean marked = locPart.own(); - if (marked) + if (marked) { updateLocal(locPart.id(), locPart.state(), updSeq, resTopVer); + + long updateCntr = locPart.updateCounter(); + + //Set update counters to 0, for full rebalance. + locPart.updateCounter(updateCntr, -updateCntr); + locPart.initialUpdateCounter(0); + } } } } checkEvictions(updSeq, grp.affinity().readyAffinity(resTopVer)); + lostParts = null; + grp.needsRecovery(false); } finally { @@ -2152,22 +2179,7 @@ else if (plc != PartitionLossPolicy.IGNORE) { lock.readLock().lock(); try { - Set res = null; - - int parts = grp.affinity().partitions(); - - for (GridDhtPartitionMap partMap : node2part.values()) { - for (Map.Entry e : partMap.entrySet()) { - if (e.getValue() == LOST) { - if (res == null) - res = new HashSet<>(parts); - - res.add(e.getKey()); - } - } - } - - return res == null ? Collections.emptySet() : res; + return lostParts == null ? Collections.emptySet() : new HashSet<>(lostParts); } finally { lock.readLock().unlock(); @@ -2523,9 +2535,6 @@ private void removeNode(UUID nodeId) { GridDhtPartitionMap parts = node2part.remove(nodeId); - if (parts != null) - leftNode2Part.put(nodeId, parts); - if (!grp.isReplicated()) { if (parts != null) { for (Integer p : parts.keySet()) { @@ -2568,19 +2577,26 @@ private void removeNode(UUID nodeId) { } /** {@inheritDoc} */ - @Override public void ownMoving(AffinityTopologyVersion topVer) { + @Override public void ownMoving(AffinityTopologyVersion rebFinishedTopVer) { lock.writeLock().lock(); + AffinityTopologyVersion lastAffChangeVer = ctx.exchange().lastAffinityChangedTopologyVersion(lastTopChangeVer); + + if (lastAffChangeVer.compareTo(rebFinishedTopVer) > 0) + log.info("Affinity topology changed, no MOVING partitions will be owned " + + "[rebFinishedTopVer=" + rebFinishedTopVer + + ", lastAffChangeVer=" + lastAffChangeVer + "]"); + try { for (GridDhtLocalPartition locPart : grp.topology().currentLocalPartitions()) { if (locPart.state() == MOVING) { boolean reserved = locPart.reserve(); try { - if (reserved && locPart.state() == MOVING && lastTopChangeVer.equals(topVer)) - grp.topology().own(locPart); - else // topology changed, rebalancing must be restarted - return; + if (reserved && locPart.state() == MOVING && + lastAffChangeVer.compareTo(rebFinishedTopVer) <= 0 && + rebFinishedTopVer.compareTo(lastTopChangeVer) <= 0) + grp.topology().own(locPart); } finally { if (reserved) @@ -2636,6 +2652,49 @@ private void removeNode(UUID nodeId) { } } + /** + * Pre-processes partition update counters before exchange. + */ + @Override public void finalizeUpdateCounters() { + if (!grp.mvccEnabled()) + return; + + // It is need to acquire checkpoint lock before topology lock acquiring. + ctx.database().checkpointReadLock(); + + try { + lock.readLock().lock(); + + try { + for (int i = 0; i < locParts.length(); i++) { + GridDhtLocalPartition part = locParts.get(i); + + if (part != null && part.state().active()) { + // We need to close all gaps in partition update counters sequence. We assume this finalizing is + // happened on exchange and hence all txs are completed. Therefore each gap in update counters + // sequence is a result of undelivered DhtTxFinishMessage on backup (sequences on primary nodes + // do not have gaps). Here we close these gaps and asynchronously notify continuous query engine + // about the skipped events. + AffinityTopologyVersion topVer = ctx.exchange().readyAffinityVersion(); + + GridLongList gaps = part.finalizeUpdateCounters(); + + if (gaps != null) { + for (GridCacheContext ctx0 : grp.caches()) + ctx0.continuousQueries().closeBackupUpdateCountersGaps(ctx0, part.id(), topVer, gaps); + } + } + } + } + finally { + lock.readLock().unlock(); + } + } + finally { + ctx.database().checkpointReadUnlock(); + } + } + /** {@inheritDoc} */ @Override public CachePartitionFullCountersMap fullUpdateCounters() { lock.readLock().lock(); @@ -2649,8 +2708,7 @@ private void removeNode(UUID nodeId) { } /** {@inheritDoc} */ - @Override public CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros, - boolean finalizeCntrsBeforeCollecting) { + @Override public CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros) { lock.readLock().lock(); try { @@ -2671,9 +2729,6 @@ private void removeNode(UUID nodeId) { if (part == null) continue; - if (finalizeCntrsBeforeCollecting) - part.finalizeUpdateCountres(); - long updCntr = part.updateCounter(); long initCntr = part.initialUpdateCounter(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionsReservation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionsReservation.java index 2682a896e7476..501748628661b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionsReservation.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionsReservation.java @@ -179,7 +179,7 @@ public void onPublish(CI1 unpublish) { */ private static void tryEvict(GridDhtLocalPartition[] parts) { if (parts == null) // Can be not initialized yet. - return ; + return; for (GridDhtLocalPartition part : parts) tryEvict(part); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionsStateValidator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionsStateValidator.java index d131d56375e4a..4a0e21832764f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionsStateValidator.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionsStateValidator.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache.distributed.dht.topology; +import java.util.AbstractMap; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -33,7 +34,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage; import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils; -import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.lang.IgniteProductVersion; import org.jetbrains.annotations.Nullable; @@ -78,14 +78,16 @@ public void validatePartitionCountersAndSizes( final Set ignoringNodes = new HashSet<>(); // Ignore just joined nodes. - for (DiscoveryEvent evt : fut.events().events()) + for (DiscoveryEvent evt : fut.events().events()) { if (evt.type() == EVT_NODE_JOINED) ignoringNodes.add(evt.eventNode().id()); + } AffinityTopologyVersion topVer = fut.context().events().topologyVersion(); // Validate update counters. Map> result = validatePartitionsUpdateCounters(top, messages, ignoringNodes); + if (!result.isEmpty()) throw new IgniteCheckedException("Partitions update counters are inconsistent for " + fold(topVer, result)); @@ -110,16 +112,21 @@ public void validatePartitionCountersAndSizes( * * @param top Topology to validate. * @param nodeId Node which sent single message. - * @param singleMsg Single message. + * @param countersMap Counters map. + * @param sizesMap Sizes map. * @return Set of partition ids should be excluded from validation. */ - @Nullable private Set shouldIgnore(GridDhtPartitionTopology top, UUID nodeId, GridDhtPartitionsSingleMessage singleMsg) { - CachePartitionPartialCountersMap countersMap = singleMsg.partitionUpdateCounters(top.groupId(), top.partitions()); - Map sizesMap = singleMsg.partitionSizes(top.groupId()); - + @Nullable private Set shouldIgnore( + GridDhtPartitionTopology top, + UUID nodeId, + CachePartitionPartialCountersMap countersMap, + Map sizesMap + ) { Set ignore = null; - for (int p = 0; p < top.partitions(); p++) { + for (int i = 0; i < countersMap.size(); i++) { + int p = countersMap.partitionAt(i); + if (top.partitionState(nodeId, p) != GridDhtPartitionState.OWNING) { if (ignore == null) ignore = new HashSet<>(); @@ -129,9 +136,8 @@ public void validatePartitionCountersAndSizes( continue; } - int partIdx = countersMap.partitionIndex(p); - long updateCounter = partIdx >= 0 ? countersMap.updateCounterAt(partIdx) : 0; - long size = sizesMap.containsKey(p) ? sizesMap.get(p) : 0; + long updateCounter = countersMap.updateCounterAt(i); + long size = sizesMap.getOrDefault(p, 0L); // Do not validate partitions with zero update counter and size. if (updateCounter == 0 && size == 0) { @@ -154,14 +160,14 @@ public void validatePartitionCountersAndSizes( * @return Invalid partitions map with following structure: (partId, (nodeId, updateCounter)). * If map is empty validation is successful. */ - public Map> validatePartitionsUpdateCounters( - GridDhtPartitionTopology top, - Map messages, - Set ignoringNodes - ) { + public Map> validatePartitionsUpdateCounters( + GridDhtPartitionTopology top, + Map messages, + Set ignoringNodes + ) { Map> invalidPartitions = new HashMap<>(); - Map> updateCountersAndNodesByPartitions = new HashMap<>(); + Map> updateCountersAndNodesByPartitions = new HashMap<>(); // Populate counters statistics from local node partitions. for (GridDhtLocalPartition part : top.currentLocalPartitions()) { @@ -171,7 +177,7 @@ public Map> validatePartitionsUpdateCounters( if (part.updateCounter() == 0 && part.fullSize() == 0) continue; - updateCountersAndNodesByPartitions.put(part.id(), new T2<>(cctx.localNodeId(), part.updateCounter())); + updateCountersAndNodesByPartitions.put(part.id(), new AbstractMap.SimpleEntry<>(cctx.localNodeId(), part.updateCounter())); } int partitions = top.partitions(); @@ -182,18 +188,23 @@ public Map> validatePartitionsUpdateCounters( if (ignoringNodes.contains(nodeId)) continue; - CachePartitionPartialCountersMap countersMap = e.getValue().partitionUpdateCounters(top.groupId(), partitions); + final GridDhtPartitionsSingleMessage message = e.getValue(); + + CachePartitionPartialCountersMap countersMap = message.partitionUpdateCounters(top.groupId(), partitions); - Set ignorePartitions = shouldIgnore(top, nodeId, e.getValue()); + Map sizesMap = message.partitionSizes(top.groupId()); - for (int part = 0; part < partitions; part++) { - if (ignorePartitions != null && ignorePartitions.contains(part)) + Set ignorePartitions = shouldIgnore(top, nodeId, countersMap, sizesMap); + + for (int i = 0; i < countersMap.size(); i++) { + int p = countersMap.partitionAt(i); + + if (ignorePartitions != null && ignorePartitions.contains(p)) continue; - int partIdx = countersMap.partitionIndex(part); - long currentCounter = partIdx >= 0 ? countersMap.updateCounterAt(partIdx) : 0; + long currentCounter = countersMap.updateCounterAt(i); - process(invalidPartitions, updateCountersAndNodesByPartitions, part, nodeId, currentCounter); + process(invalidPartitions, updateCountersAndNodesByPartitions, p, nodeId, currentCounter); } } @@ -209,14 +220,14 @@ public Map> validatePartitionsUpdateCounters( * @return Invalid partitions map with following structure: (partId, (nodeId, cacheSize)). * If map is empty validation is successful. */ - public Map> validatePartitionsSizes( - GridDhtPartitionTopology top, - Map messages, - Set ignoringNodes - ) { + public Map> validatePartitionsSizes( + GridDhtPartitionTopology top, + Map messages, + Set ignoringNodes + ) { Map> invalidPartitions = new HashMap<>(); - Map> sizesAndNodesByPartitions = new HashMap<>(); + Map> sizesAndNodesByPartitions = new HashMap<>(); // Populate sizes statistics from local node partitions. for (GridDhtLocalPartition part : top.currentLocalPartitions()) { @@ -226,7 +237,7 @@ public Map> validatePartitionsSizes( if (part.updateCounter() == 0 && part.fullSize() == 0) continue; - sizesAndNodesByPartitions.put(part.id(), new T2<>(cctx.localNodeId(), part.fullSize())); + sizesAndNodesByPartitions.put(part.id(), new AbstractMap.SimpleEntry<>(cctx.localNodeId(), part.fullSize())); } int partitions = top.partitions(); @@ -237,17 +248,23 @@ public Map> validatePartitionsSizes( if (ignoringNodes.contains(nodeId)) continue; - Map sizesMap = e.getValue().partitionSizes(top.groupId()); + final GridDhtPartitionsSingleMessage message = e.getValue(); + + CachePartitionPartialCountersMap countersMap = message.partitionUpdateCounters(top.groupId(), partitions); + + Map sizesMap = message.partitionSizes(top.groupId()); + + Set ignorePartitions = shouldIgnore(top, nodeId, countersMap, sizesMap); - Set ignorePartitions = shouldIgnore(top, nodeId, e.getValue()); + for (int i = 0; i < countersMap.size(); i++) { + int p = countersMap.partitionAt(i); - for (int part = 0; part < partitions; part++) { - if (ignorePartitions != null && ignorePartitions.contains(part)) + if (ignorePartitions != null && ignorePartitions.contains(p)) continue; - long currentSize = sizesMap.containsKey(part) ? sizesMap.get(part) : 0L; + long currentSize = sizesMap.getOrDefault(p, 0L); - process(invalidPartitions, sizesAndNodesByPartitions, part, nodeId, currentSize); + process(invalidPartitions, sizesAndNodesByPartitions, p, nodeId, currentSize); } } @@ -264,20 +281,22 @@ public Map> validatePartitionsSizes( * @param node Node id. * @param counter Counter value reported by {@code node}. */ - private void process(Map> invalidPartitions, - Map> countersAndNodes, - int part, - UUID node, - long counter) { - T2 existingData = countersAndNodes.get(part); + private void process( + Map> invalidPartitions, + Map> countersAndNodes, + int part, + UUID node, + long counter + ) { + AbstractMap.Entry existingData = countersAndNodes.get(part); if (existingData == null) - countersAndNodes.put(part, new T2<>(node, counter)); + countersAndNodes.put(part, new AbstractMap.SimpleEntry<>(node, counter)); - if (existingData != null && counter != existingData.get2()) { + if (existingData != null && counter != existingData.getValue()) { if (!invalidPartitions.containsKey(part)) { Map map = new HashMap<>(); - map.put(existingData.get1(), existingData.get2()); + map.put(existingData.getKey(), existingData.getValue()); invalidPartitions.put(part, map); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/PartitionsEvictManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/PartitionsEvictManager.java index cd010fa89d32d..404e194a9615a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/PartitionsEvictManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/PartitionsEvictManager.java @@ -19,6 +19,7 @@ import java.util.Collection; import java.util.Comparator; +import java.util.HashSet; import java.util.Map; import java.util.Queue; import java.util.Set; @@ -31,7 +32,6 @@ import org.apache.ignite.internal.managers.communication.GridIoPolicy; import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter; -import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.internal.util.typedef.internal.U; @@ -63,6 +63,7 @@ public class PartitionsEvictManager extends GridCacheSharedManagerAdapter { /** Next time of show eviction progress. */ private long nextShowProgressTime; + /** */ private final Map evictionGroupsMap = new ConcurrentHashMap<>(); /** Flag indicates that eviction process has stopped. */ @@ -110,28 +111,28 @@ public void onCacheGroupStopped(CacheGroupContext grp){ * @param part Partition to evict. */ public void evictPartitionAsync(CacheGroupContext grp, GridDhtLocalPartition part) { - // Check node stop. - if (sharedEvictionContext.shouldStop()) - return; - GroupEvictionContext groupEvictionContext = evictionGroupsMap.computeIfAbsent( grp.groupId(), (k) -> new GroupEvictionContext(grp)); - PartitionEvictionTask evictionTask = groupEvictionContext.createEvictPartitionTask(part); - - if (evictionTask == null) + // Check node stop. + if (groupEvictionContext.shouldStop()) return; - if (log.isDebugEnabled()) - log.debug("Partition has been scheduled for eviction [grp=" + grp.cacheOrGroupName() - + ", p=" + part.id() + ", state=" + part.state() + "]"); - int bucket; synchronized (mux) { - bucket = evictionQueue.offer(evictionTask); + if (!groupEvictionContext.partIds.add(part.id())) + return; + + bucket = evictionQueue.offer(new PartitionEvictionTask(part, groupEvictionContext)); } + groupEvictionContext.totalTasks.incrementAndGet(); + + if (log.isDebugEnabled()) + log.debug("Partition has been scheduled for eviction [grp=" + grp.cacheOrGroupName() + + ", p=" + part.id() + ", state=" + part.state() + "]"); + scheduleNextPartitionEviction(bucket); } @@ -177,7 +178,7 @@ private void scheduleNextPartitionEviction(int bucket) { // Print current eviction progress. showProgress(); - GroupEvictionContext groupEvictionContext = evictionTask.groupEvictionContext; + GroupEvictionContext groupEvictionContext = evictionTask.groupEvictionCtx; // Check that group or node stopping. if (groupEvictionContext.shouldStop()) @@ -270,7 +271,7 @@ private class GroupEvictionContext implements EvictionContext { private final CacheGroupContext grp; /** Deduplicate set partition ids. */ - private final Set partIds = new GridConcurrentHashSet<>(); + private final Set partIds = new HashSet<>(); /** Future for currently running partition eviction task. */ private final Map> partsEvictFutures = new ConcurrentHashMap<>(); @@ -296,19 +297,6 @@ private GroupEvictionContext(CacheGroupContext grp) { return stop || sharedEvictionContext.shouldStop(); } - /** - * - * @param part Grid local partition. - */ - private PartitionEvictionTask createEvictPartitionTask(GridDhtLocalPartition part){ - if (shouldStop() || !partIds.add(part.id())) - return null; - - totalTasks.incrementAndGet(); - - return new PartitionEvictionTask(part, this); - } - /** * * @param task Partition eviction task. @@ -323,6 +311,8 @@ private synchronized void taskScheduled(PartitionEvictionTask task) { int partId = task.part.id(); + partIds.remove(partId); + partsEvictFutures.put(partId, fut); fut.listen(f -> { @@ -390,48 +380,52 @@ private class PartitionEvictionTask implements Runnable { /** Partition to evict. */ private final GridDhtLocalPartition part; + /** */ private final long size; /** Eviction context. */ - private final GroupEvictionContext groupEvictionContext; + private final GroupEvictionContext groupEvictionCtx; /** */ private final GridFutureAdapter finishFut = new GridFutureAdapter<>(); /** * @param part Partition. + * @param groupEvictionCtx Eviction context. */ private PartitionEvictionTask( GridDhtLocalPartition part, - GroupEvictionContext groupEvictionContext + GroupEvictionContext groupEvictionCtx ) { this.part = part; - this.groupEvictionContext = groupEvictionContext; + this.groupEvictionCtx = groupEvictionCtx; size = part.fullSize(); } /** {@inheritDoc} */ @Override public void run() { - if (groupEvictionContext.shouldStop()) { + if (groupEvictionCtx.shouldStop()) { finishFut.onDone(); return; } try { - boolean success = part.tryClear(groupEvictionContext); + boolean success = part.tryClear(groupEvictionCtx); if (success) { if (part.state() == GridDhtPartitionState.EVICTED && part.markForDestroy()) part.destroy(); } - else // Re-offer partition if clear was unsuccessful due to partition reservation. - evictionQueue.offer(this); // Complete eviction future before schedule new to prevent deadlock with // simultaneous eviction stopping and scheduling new eviction. finishFut.onDone(); + + // Re-offer partition if clear was unsuccessful due to partition reservation. + if (!success) + evictPartitionAsync(groupEvictionCtx.grp, part); } catch (Throwable ex) { finishFut.onDone(ex); @@ -502,6 +496,7 @@ PartitionEvictionTask pollAny() { /** * Offer task to queue. * + * @param task Eviction task. * @return Bucket index. */ int offer(PartitionEvictionTask task) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java index 9670f8a4ea5cf..c19d486a489b4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/CacheVersionedValue.java @@ -174,4 +174,4 @@ public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws Ignite @Override public String toString() { return S.toString(CacheVersionedValue.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java index 503c324de3390..21f409a401779 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java @@ -284,7 +284,7 @@ private void processNearAtomicUpdateResponse( } finally { if (entry != null) - entry.touch(topVer); + entry.touch(); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java index 39047813e85e5..086247c519d15 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java @@ -444,7 +444,7 @@ private EntrySet(Set> nearSet, Set> dhtSet) F.iterator0(dhtSet, false, new P1>() { @Override public boolean apply(Cache.Entry e) { try { - return GridNearCacheAdapter.super.localPeek(e.getKey(), NEAR_PEEK_MODE, null) == null; + return GridNearCacheAdapter.super.localPeek(e.getKey(), NEAR_PEEK_MODE) == null; } catch (IgniteCheckedException ex) { throw new IgniteException(ex); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java index d7800ed61c758..97041846272bc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java @@ -23,10 +23,9 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; -import java.util.concurrent.atomic.AtomicReference; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; @@ -38,8 +37,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException; -import org.apache.ignite.internal.processors.cache.GridCacheMessage; -import org.apache.ignite.internal.processors.cache.GridCacheUtils.BackupPostProcessingClosure; import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.CacheDistributedGetFutureAdapter; @@ -50,13 +47,7 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.GridLeanMap; import org.apache.ignite.internal.util.future.GridFinishedFuture; -import org.apache.ignite.internal.util.future.GridFutureAdapter; -import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.C1; -import org.apache.ignite.internal.util.typedef.CI1; -import org.apache.ignite.internal.util.typedef.CIX1; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; @@ -67,17 +58,8 @@ * */ public final class GridNearGetFuture extends CacheDistributedGetFutureAdapter { - /** */ - private static final long serialVersionUID = 0L; - - /** Logger reference. */ - private static final AtomicReference logRef = new AtomicReference<>(); - - /** Logger. */ - private static IgniteLogger log; - /** Transaction. */ - private IgniteTxLocalEx tx; + private final IgniteTxLocalEx tx; /** */ private GridCacheVersion ver; @@ -112,7 +94,8 @@ public GridNearGetFuture( boolean keepCacheObjects, boolean recovery ) { - super(cctx, + super( + cctx, keys, readThrough, forcePrimary, @@ -123,18 +106,16 @@ public GridNearGetFuture( skipVals, needVer, keepCacheObjects, - recovery); + recovery + ); assert !F.isEmpty(keys); this.tx = tx; - futId = IgniteUuid.randomUuid(); - ver = tx == null ? cctx.versions().next() : tx.xidVersion(); - if (log == null) - log = U.logger(cctx.kernalContext(), logRef, GridNearGetFuture.class); + initLogger(GridNearGetFuture.class); } /** @@ -148,73 +129,21 @@ public void init(@Nullable AffinityTopologyVersion topVer) { if (lockedTopVer != null) { canRemap = false; - map(keys, Collections.>emptyMap(), lockedTopVer); + map(keys, Collections.emptyMap(), lockedTopVer); } else { AffinityTopologyVersion mapTopVer = topVer; if (mapTopVer == null) { - mapTopVer = tx == null ? - (canRemap ? cctx.affinity().affinityTopologyVersion() : cctx.shared().exchange().readyAffinityVersion()) : - tx.topologyVersion(); + mapTopVer = tx == null ? cctx.affinity().affinityTopologyVersion() : tx.topologyVersion(); } - map(keys, Collections.>emptyMap(), mapTopVer); + map(keys, Collections.emptyMap(), mapTopVer); } markInitialized(); } - /** {@inheritDoc} */ - @Override public boolean trackable() { - return trackable; - } - - /** {@inheritDoc} */ - @Override public void markNotTrackable() { - // Should not flip trackable flag from true to false since get future can be remapped. - } - - /** {@inheritDoc} */ - @Override public IgniteUuid futureId() { - return futId; - } - - /** {@inheritDoc} */ - @Override public boolean onNodeLeft(UUID nodeId) { - boolean found = false; - - for (IgniteInternalFuture> fut : futures()) - if (isMini(fut)) { - MiniFuture f = (MiniFuture)fut; - - if (f.node().id().equals(nodeId)) { - found = true; - - f.onNodeLeft(); - } - } - - return found; - } - - /** - * @param nodeId Sender. - * @param res Result. - */ - @Override public void onResult(UUID nodeId, GridNearGetResponse res) { - for (IgniteInternalFuture> fut : futures()) - if (isMini(fut)) { - MiniFuture f = (MiniFuture)fut; - - if (f.futureId().equals(res.miniId())) { - assert f.node().id().equals(nodeId); - - f.onResult(res); - } - } - } - /** {@inheritDoc} */ @Override public boolean onDone(Map res, Throwable err) { if (super.onDone(res, err)) { @@ -230,11 +159,8 @@ public void init(@Nullable AffinityTopologyVersion topVer) { return false; } - /** - * @param f Future. - * @return {@code True} if mini-future. - */ - private boolean isMini(IgniteInternalFuture f) { + /** {@inheritDoc} */ + @Override protected boolean isMini(IgniteInternalFuture f) { return f.getClass().equals(MiniFuture.class); } @@ -243,10 +169,10 @@ private boolean isMini(IgniteInternalFuture f) { * @param mapped Mappings to check for duplicates. * @param topVer Topology version to map on. */ - private void map( + @Override protected void map( Collection keys, Map> mapped, - final AffinityTopologyVersion topVer + AffinityTopologyVersion topVer ) { Collection affNodes = CU.affinityNodes(cctx, topVer); @@ -269,7 +195,7 @@ private void map( try { // Assign keys to primary nodes. for (KeyCacheObject key : keys) - savedEntries = map(key, mappings, topVer, mapped, savedEntries); + savedEntries = map(key, topVer, mappings, mapped, savedEntries); success = true; } @@ -293,23 +219,24 @@ private void map( if (isDone()) return; - final Map saved = savedEntries != null ? savedEntries : - Collections.emptyMap(); + Map saved = + savedEntries != null ? savedEntries : Collections.emptyMap(); - final int keysSize = keys.size(); + int keysSize = keys.size(); // Create mini futures. for (Map.Entry> entry : mappings.entrySet()) { - final ClusterNode n = entry.getKey(); + ClusterNode n = entry.getKey(); - final LinkedHashMap mappedKeys = entry.getValue(); + LinkedHashMap mappedKeys = entry.getValue(); assert !mappedKeys.isEmpty(); // If this is the primary or backup node for the keys. if (n.isLocal()) { - final GridDhtFuture> fut = - dht().getDhtAsync(n.id(), + GridDhtFuture> fut = dht() + .getDhtAsync( + n.id(), -1, mappedKeys, false, @@ -320,73 +247,52 @@ private void map( expiryPlc, skipVals, recovery, - null); // TODO IGNITE-7371 + null + ); // TODO IGNITE-7371 - final Collection invalidParts = fut.invalidPartitions(); + Collection invalidParts = fut.invalidPartitions(); if (!F.isEmpty(invalidParts)) { Collection remapKeys = new ArrayList<>(keysSize); for (KeyCacheObject key : keys) { - if (key != null && invalidParts.contains(cctx.affinity().partition(key))) + int part = cctx.affinity().partition(key); + + if (key != null && invalidParts.contains(part)) { + addNodeAsInvalid(n, part, topVer); + remapKeys.add(key); + } } AffinityTopologyVersion updTopVer = cctx.shared().exchange().readyAffinityVersion(); - assert updTopVer.compareTo(topVer) > 0 : "Got invalid partitions for local node but topology version did " + - "not change [topVer=" + topVer + ", updTopVer=" + updTopVer + - ", invalidParts=" + invalidParts + ']'; - // Remap recursively. map(remapKeys, mappings, updTopVer); } // Add new future. - add(fut.chain(new C1>, Map>() { - @Override public Map apply(IgniteInternalFuture> fut) { - try { - return loadEntries(n.id(), mappedKeys.keySet(), fut.get(), saved, topVer); - } - catch (Exception e) { - U.error(log, "Failed to get values from dht cache [fut=" + fut + "]", e); + add(fut.chain(f -> { + try { + return loadEntries(n.id(), mappedKeys.keySet(), f.get(), saved, topVer); + } + catch (Exception e) { + U.error(log, "Failed to get values from dht cache [fut=" + fut + "]", e); - onDone(e); + onDone(e); - return Collections.emptyMap(); - } + return Collections.emptyMap(); } })); } else { - if (!trackable) { - trackable = true; + registrateFutureInMvccManager(this); - cctx.mvcc().addFuture(this, futId); - } + MiniFuture miniFuture = new MiniFuture(n, mappedKeys, saved, topVer); - MiniFuture fut = new MiniFuture(n, mappedKeys, saved, topVer, - CU.createBackupPostProcessingClosure(topVer, log, cctx, null, expiryPlc, readThrough, skipVals)); - - GridCacheMessage req = new GridNearGetRequest( - cctx.cacheId(), - futId, - fut.futureId(), - ver, - mappedKeys, - readThrough, - topVer, - subjId, - taskName == null ? 0 : taskName.hashCode(), - expiryPlc != null ? expiryPlc.forCreate() : -1L, - expiryPlc != null ? expiryPlc.forAccess() : -1L, - true, - skipVals, - cctx.deploymentEnabled(), - recovery, - null); // TODO IGNITE-7371 - - add(fut); // Append new future. + GridNearGetRequest req = miniFuture.createGetRequest(futId); + + add(miniFuture); // Append new future. try { cctx.io().send(n, req, cctx.ioPolicy()); @@ -394,16 +300,14 @@ private void map( catch (IgniteCheckedException e) { // Fail the whole thing. if (e instanceof ClusterTopologyCheckedException) - fut.onNodeLeft(); + miniFuture.onNodeLeft((ClusterTopologyCheckedException)e); else - fut.onResult(e); + miniFuture.onResult(e); } } } } - - /** * @param mappings Mappings. * @param key Key to map. @@ -415,8 +319,8 @@ private void map( @SuppressWarnings("unchecked") private Map map( KeyCacheObject key, - Map> mappings, AffinityTopologyVersion topVer, + Map> mappings, Map> mapped, Map saved ) { @@ -425,7 +329,7 @@ private Map map( List affNodes = cctx.affinity().nodesByPartition(part, topVer); if (affNodes.isEmpty()) { - onDone(serverNotFoundError(topVer)); + onDone(serverNotFoundError(part, topVer)); return null; } @@ -494,10 +398,12 @@ private Map map( } } - ClusterNode affNode = cctx.selectAffinityNodeBalanced(affNodes, canRemap); + Set invalidNodesSet = getInvalidNodes(part, topVer); + + ClusterNode affNode = cctx.selectAffinityNodeBalanced(affNodes, invalidNodesSet, part, canRemap); if (affNode == null) { - onDone(serverNotFoundError(topVer)); + onDone(serverNotFoundError(part, topVer)); return saved; } @@ -505,17 +411,8 @@ private Map map( if (cctx.statisticsEnabled() && !skipVals && !affNode.isLocal() && !isNear) cache().metrics0().onRead(false); - LinkedHashMap keys = mapped.get(affNode); - - if (keys != null && keys.containsKey(key)) { - if (REMAP_CNT_UPD.incrementAndGet(this) > MAX_REMAP_CNT) { - onDone(new ClusterTopologyCheckedException("Failed to remap key to a new node after " + - MAX_REMAP_CNT + " attempts (key got remapped to the same node) " + - "[key=" + key + ", node=" + U.toShortString(affNode) + ", mappings=" + mapped + ']')); - - return saved; - } - } + if (!checkRetryPermits(key,affNode,mapped)) + return saved; if (!affNodes.contains(cctx.localNode())) { GridNearCacheEntry nearEntry = entry != null ? entry : near.entryExx(key, topVer); @@ -558,7 +455,7 @@ private Map map( } finally { if (entry != null && tx == null) - entry.touch(topVer); + entry.touch(); } } @@ -572,10 +469,12 @@ private Map map( * @param nearRead {@code True} if already tried to read from near cache. * @return {@code True} if there is no need to further search value. */ - private boolean localDhtGet(KeyCacheObject key, + private boolean localDhtGet( + KeyCacheObject key, int part, AffinityTopologyVersion topVer, - boolean nearRead) { + boolean nearRead + ) { GridDhtCacheAdapter dht = cache().dht(); assert dht.context().affinityNode() : this; @@ -661,7 +560,7 @@ private boolean localDhtGet(KeyCacheObject key, if (dhtEntry != null) // Near cache is enabled, so near entry will be enlisted in the transaction. // Always touch DHT entry in this case. - dhtEntry.touch(topVer); + dhtEntry.touch(); } } } @@ -795,9 +694,11 @@ private Map loadEntries( * @param saved Saved entries. * @param topVer Topology version. */ - private void releaseEvictions(Collection keys, + private void releaseEvictions( + Collection keys, Map saved, - AffinityTopologyVersion topVer) { + AffinityTopologyVersion topVer + ) { for (KeyCacheObject key : keys) { GridNearCacheEntry entry = saved.get(key); @@ -805,108 +706,65 @@ private void releaseEvictions(Collection keys, entry.releaseEviction(); if (tx == null) - entry.touch(topVer); + entry.touch(); } } } /** {@inheritDoc} */ @Override public String toString() { - Collection futs = F.viewReadOnly(futures(), new C1, String>() { - @SuppressWarnings("unchecked") - @Override public String apply(IgniteInternalFuture f) { - if (isMini(f)) { - return "[node=" + ((MiniFuture)f).node().id() + - ", loc=" + ((MiniFuture)f).node().isLocal() + - ", done=" + f.isDone() + "]"; - } - else - return "[loc=true, done=" + f.isDone() + "]"; - } - }); - return S.toString(GridNearGetFuture.class, this, - "innerFuts", futs, "super", super.toString()); } /** - * Mini-future for get operations. Mini-futures are only waiting on a single - * node as opposed to multiple nodes. + * Mini-future for get operations. Mini-futures are only waiting on a single node as opposed to multiple nodes. */ - private class MiniFuture extends GridFutureAdapter> { - /** */ - private final IgniteUuid futId = IgniteUuid.randomUuid(); - - /** Node ID. */ - private ClusterNode node; - - /** Keys. */ - @GridToStringInclude - private LinkedHashMap keys; - + private class MiniFuture extends AbstractMiniFuture { /** Saved entry versions. */ - private Map savedEntries; - - /** Topology version on which this future was mapped. */ - private AffinityTopologyVersion topVer; - - /** Post processing closure. */ - private final BackupPostProcessingClosure postProcessingClos; - - /** {@code True} if remapped after node left. */ - private boolean remapped; + private final Map savedEntries; /** * @param node Node. * @param keys Keys. * @param savedEntries Saved entries. * @param topVer Topology version. - * @param postProcessingClos Post processing closure. */ MiniFuture( ClusterNode node, LinkedHashMap keys, Map savedEntries, - AffinityTopologyVersion topVer, - BackupPostProcessingClosure postProcessingClos) { - this.node = node; - this.keys = keys; + AffinityTopologyVersion topVer + ) { + super(node, keys, topVer); this.savedEntries = savedEntries; - this.topVer = topVer; - this.postProcessingClos = postProcessingClos; } - /** - * @return Future ID. - */ - IgniteUuid futureId() { - return futId; - } - - /** - * @return Node ID. - */ - public ClusterNode node() { - return node; - } - - /** - * @return Keys. - */ - public Collection keys() { - return keys.keySet(); + /** {@inheritDoc} */ + @Override protected GridNearGetRequest createGetRequest0(IgniteUuid rootFutId, IgniteUuid futId) { + return new GridNearGetRequest( + cctx.cacheId(), + rootFutId, + futId, + ver, + keys, + readThrough, + topVer, + subjId, + taskName == null ? 0 : taskName.hashCode(), + expiryPlc != null ? expiryPlc.forCreate() : -1L, + expiryPlc != null ? expiryPlc.forAccess() : -1L, + true, + skipVals, + cctx.deploymentEnabled(), + recovery, + null + ); // TODO IGNITE-7371 } - /** - * @param e Error. - */ - void onResult(Throwable e) { - if (log.isDebugEnabled()) - log.debug("Failed to get future result [fut=" + this + ", err=" + e + ']'); - - // Fail. - onDone(e); + /** {@inheritDoc} */ + @Override protected Map createResultMap(Collection entries) { + return loadEntries(node.id(), keys.keySet(), entries, savedEntries, topVer); } /** {@inheritDoc} */ @@ -920,136 +778,6 @@ void onResult(Throwable e) { return false; } - /** - */ - synchronized void onNodeLeft() { - if (remapped) - return; - - remapped = true; - - if (log.isDebugEnabled()) - log.debug("Remote node left grid while sending or waiting for reply (will retry): " + this); - - // Try getting value from alive nodes. - if (!canRemap) { - // Remap - map(keys.keySet(), F.t(node, keys), topVer); - - onDone(Collections.emptyMap()); - } - else { - AffinityTopologyVersion updTopVer = - new AffinityTopologyVersion(Math.max(topVer.topologyVersion() + 1, cctx.discovery().topologyVersion())); - - cctx.shared().exchange().affinityReadyFuture(updTopVer).listen(f -> { - try { - // Remap. - map(keys.keySet(), F.t(node, keys), f.get()); - - onDone(Collections.emptyMap()); - - } - catch (IgniteCheckedException e) { - GridNearGetFuture.this.onDone(e); - } - }); - } - } - - /** - * @param res Result callback. - */ - void onResult(final GridNearGetResponse res) { - final Collection invalidParts = res.invalidPartitions(); - - // If error happened on remote node, fail the whole future. - if (res.error() != null) { - onDone(res.error()); - - return; - } - - // Remap invalid partitions. - if (!F.isEmpty(invalidParts)) { - AffinityTopologyVersion rmtTopVer = res.topologyVersion(); - - assert rmtTopVer.topologyVersion() != 0; - - if (rmtTopVer.compareTo(topVer) <= 0) { - // Fail the whole get future. - onDone(new IgniteCheckedException("Failed to process invalid partitions response (remote node reported " + - "invalid partitions but remote topology version does not differ from local) " + - "[topVer=" + topVer + ", rmtTopVer=" + rmtTopVer + ", invalidParts=" + invalidParts + - ", nodeId=" + node.id() + ']')); - - return; - } - - if (log.isDebugEnabled()) - log.debug("Remapping mini get future [invalidParts=" + invalidParts + ", fut=" + this + ']'); - - if (!canRemap) { - map(F.view(keys.keySet(), new P1() { - @Override public boolean apply(KeyCacheObject key) { - return invalidParts.contains(cctx.affinity().partition(key)); - } - }), F.t(node, keys), topVer); - - postProcessResultAndDone(res); - - return; - } - - // Need to wait for next topology version to remap. - IgniteInternalFuture topFut = cctx.shared().exchange().affinityReadyFuture(rmtTopVer); - - topFut.listen(new CIX1>() { - @Override public void applyx( - IgniteInternalFuture fut) throws IgniteCheckedException { - AffinityTopologyVersion readyTopVer = fut.get(); - - // This will append new futures to compound list. - map(F.view(keys.keySet(), new P1() { - @Override public boolean apply(KeyCacheObject key) { - return invalidParts.contains(cctx.affinity().partition(key)); - } - }), F.t(node, keys), readyTopVer); - - postProcessResultAndDone(res); - } - }); - } - else - postProcessResultAndDone(res); - - } - - /** - * Post processes result and done future. - * - * @param res Response. - */ - private void postProcessResultAndDone(final GridNearGetResponse res){ - try { - postProcessResult(res); - - // It is critical to call onDone after adding futures to compound list. - onDone(loadEntries(node.id(), keys.keySet(), res.entries(), savedEntries, topVer)); - } - catch (Exception ex) { - onDone(ex); - } - } - - /** - * @param res Response. - */ - private void postProcessResult(final GridNearGetResponse res) { - if (postProcessingClos != null) - postProcessingClos.apply(res.entries()); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(MiniFuture.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index f594e2bd353f6..a607a9afafbc6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -360,74 +360,74 @@ public long accessTtl() { } switch (writer.state()) { - case 3: - if (!writer.writeLong("accessTtl", accessTtl)) - return false; - - writer.incrementState(); - case 4: - if (!writer.writeLong("createTtl", createTtl)) + if (!writer.writeLong("accessTtl", accessTtl)) return false; writer.incrementState(); case 5: - if (!writer.writeByte("flags", flags)) + if (!writer.writeLong("createTtl", createTtl)) return false; writer.incrementState(); case 6: - if (!writer.writeIgniteUuid("futId", futId)) + if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); case 7: - if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG)) + if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); case 8: - if (!writer.writeIgniteUuid("miniId", miniId)) + if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); case 9: - if (!writer.writeCollection("readersFlags", readersFlags, MessageCollectionItemType.BOOLEAN)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; writer.incrementState(); case 10: - if (!writer.writeUuid("subjId", subjId)) + if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) return false; writer.incrementState(); case 11: - if (!writer.writeInt("taskNameHash", taskNameHash)) + if (!writer.writeCollection("readersFlags", readersFlags, MessageCollectionItemType.BOOLEAN)) return false; writer.incrementState(); case 12: - if (!writer.writeMessage("topVer", topVer)) + if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); case 13: - if (!writer.writeMessage("ver", ver)) + if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); case 14: - if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) + return false; + + writer.incrementState(); + + case 15: + if (!writer.writeMessage("ver", ver)) return false; writer.incrementState(); @@ -448,7 +448,7 @@ public long accessTtl() { return false; switch (reader.state()) { - case 3: + case 4: accessTtl = reader.readLong("accessTtl"); if (!reader.isLastRead()) @@ -456,7 +456,7 @@ public long accessTtl() { reader.incrementState(); - case 4: + case 5: createTtl = reader.readLong("createTtl"); if (!reader.isLastRead()) @@ -464,7 +464,7 @@ public long accessTtl() { reader.incrementState(); - case 5: + case 6: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -472,7 +472,7 @@ public long accessTtl() { reader.incrementState(); - case 6: + case 7: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -480,7 +480,7 @@ public long accessTtl() { reader.incrementState(); - case 7: + case 8: keys = reader.readCollection("keys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -488,7 +488,7 @@ public long accessTtl() { reader.incrementState(); - case 8: + case 9: miniId = reader.readIgniteUuid("miniId"); if (!reader.isLastRead()) @@ -496,48 +496,48 @@ public long accessTtl() { reader.incrementState(); - case 9: - readersFlags = reader.readCollection("readersFlags", MessageCollectionItemType.BOOLEAN); + case 10: + mvccSnapshot = reader.readMessage("mvccSnapshot"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 10: - subjId = reader.readUuid("subjId"); + case 11: + readersFlags = reader.readCollection("readersFlags", MessageCollectionItemType.BOOLEAN); if (!reader.isLastRead()) return false; reader.incrementState(); - case 11: - taskNameHash = reader.readInt("taskNameHash"); + case 12: + subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 12: - topVer = reader.readMessage("topVer"); + case 13: + taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 13: - ver = reader.readMessage("ver"); + case 14: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 14: - mvccSnapshot = reader.readMessage("mvccSnapshot"); + case 15: + ver = reader.readMessage("ver"); if (!reader.isLastRead()) return false; @@ -556,7 +556,7 @@ public long accessTtl() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 15; + return 16; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java index b4e4424862c54..578c46b6ac34a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java @@ -228,43 +228,43 @@ public void error(IgniteCheckedException err) { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeCollection("entries", entries, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeCollection("invalidParts", invalidParts, MessageCollectionItemType.INT)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeIgniteUuid("miniId", miniId)) return false; writer.incrementState(); - case 8: - if (!writer.writeMessage("topVer", topVer)) + case 9: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeMessage("ver", ver)) return false; @@ -286,7 +286,7 @@ public void error(IgniteCheckedException err) { return false; switch (reader.state()) { - case 3: + case 4: entries = reader.readCollection("entries", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -294,7 +294,7 @@ public void error(IgniteCheckedException err) { reader.incrementState(); - case 4: + case 5: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -302,7 +302,7 @@ public void error(IgniteCheckedException err) { reader.incrementState(); - case 5: + case 6: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -310,7 +310,7 @@ public void error(IgniteCheckedException err) { reader.incrementState(); - case 6: + case 7: invalidParts = reader.readCollection("invalidParts", MessageCollectionItemType.INT); if (!reader.isLastRead()) @@ -318,7 +318,7 @@ public void error(IgniteCheckedException err) { reader.incrementState(); - case 7: + case 8: miniId = reader.readIgniteUuid("miniId"); if (!reader.isLastRead()) @@ -326,15 +326,15 @@ public void error(IgniteCheckedException err) { reader.incrementState(); - case 8: - topVer = reader.readMessage("topVer"); + case 9: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 9: + case 10: ver = reader.readMessage("ver"); if (!reader.isLastRead()) @@ -354,7 +354,7 @@ public void error(IgniteCheckedException err) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 10; + return 11; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java index 6cd45148f95b1..a6b11c093e72f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java @@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReference; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; @@ -847,7 +848,17 @@ void map() { if (topVer != null) { for (GridDhtTopologyFuture fut : cctx.shared().exchange().exchangeFutures()) { if (fut.exchangeDone() && fut.topologyVersion().equals(topVer)){ - Throwable err = fut.validateCache(cctx, recovery, read, null, keys); + Throwable err = null; + + // Before cache validation, make sure that this topology future is already completed. + try { + fut.get(); + } + catch (IgniteCheckedException e) { + err = fut.error(); + } + + err = (err == null)? fut.validateCache(cctx, recovery, read, null, keys): err; if (err != null) { onDone(err); @@ -886,7 +897,10 @@ synchronized void mapOnTopology(final boolean remap) { try { if (cctx.topology().stopping()) { - onDone(new CacheStoppedException(cctx.name())); + onDone( + cctx.shared().cache().isCacheRestarting(cctx.name())? + new IgniteCacheRestartingException(cctx.name()): + new CacheStoppedException(cctx.name())); return; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java index f736cae61848c..0712e2234f6cf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java @@ -363,56 +363,56 @@ public long accessTtl() { } switch (writer.state()) { - case 20: + case 21: if (!writer.writeLong("accessTtl", accessTtl)) return false; writer.incrementState(); - case 21: + case 22: if (!writer.writeLong("createTtl", createTtl)) return false; writer.incrementState(); - case 22: + case 23: if (!writer.writeObjectArray("dhtVers", dhtVers, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 23: + case 24: if (!writer.writeObjectArray("filter", filter, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 24: + case 25: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 25: + case 26: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 26: + case 27: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 27: + case 28: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 28: - if (!writer.writeMessage("topVer", topVer)) + case 29: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -433,7 +433,7 @@ public long accessTtl() { return false; switch (reader.state()) { - case 20: + case 21: accessTtl = reader.readLong("accessTtl"); if (!reader.isLastRead()) @@ -441,7 +441,7 @@ public long accessTtl() { reader.incrementState(); - case 21: + case 22: createTtl = reader.readLong("createTtl"); if (!reader.isLastRead()) @@ -449,7 +449,7 @@ public long accessTtl() { reader.incrementState(); - case 22: + case 23: dhtVers = reader.readObjectArray("dhtVers", MessageCollectionItemType.MSG, GridCacheVersion.class); if (!reader.isLastRead()) @@ -457,7 +457,7 @@ public long accessTtl() { reader.incrementState(); - case 23: + case 24: filter = reader.readObjectArray("filter", MessageCollectionItemType.MSG, CacheEntryPredicate.class); if (!reader.isLastRead()) @@ -465,7 +465,7 @@ public long accessTtl() { reader.incrementState(); - case 24: + case 25: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -473,7 +473,7 @@ public long accessTtl() { reader.incrementState(); - case 25: + case 26: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -481,7 +481,7 @@ public long accessTtl() { reader.incrementState(); - case 26: + case 27: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -489,7 +489,7 @@ public long accessTtl() { reader.incrementState(); - case 27: + case 28: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -497,8 +497,8 @@ public long accessTtl() { reader.incrementState(); - case 28: - topVer = reader.readMessage("topVer"); + case 29: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; @@ -517,7 +517,7 @@ public long accessTtl() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 29; + return 30; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java index e88f0a07e0755..b6c6d8c903c49 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java @@ -208,37 +208,37 @@ public void addValueBytes( } switch (writer.state()) { - case 10: - if (!writer.writeMessage("clientRemapVer", clientRemapVer)) + case 11: + if (!writer.writeAffinityTopologyVersion("clientRemapVer", clientRemapVer)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeObjectArray("dhtVers", dhtVers, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeBooleanArray("filterRes", filterRes)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeObjectArray("mappedVers", mappedVers, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeCollection("pending", pending, MessageCollectionItemType.MSG)) return false; @@ -260,15 +260,15 @@ public void addValueBytes( return false; switch (reader.state()) { - case 10: - clientRemapVer = reader.readMessage("clientRemapVer"); + case 11: + clientRemapVer = reader.readAffinityTopologyVersion("clientRemapVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 11: + case 12: dhtVers = reader.readObjectArray("dhtVers", MessageCollectionItemType.MSG, GridCacheVersion.class); if (!reader.isLastRead()) @@ -276,7 +276,7 @@ public void addValueBytes( reader.incrementState(); - case 12: + case 13: filterRes = reader.readBooleanArray("filterRes"); if (!reader.isLastRead()) @@ -284,7 +284,7 @@ public void addValueBytes( reader.incrementState(); - case 13: + case 14: mappedVers = reader.readObjectArray("mappedVers", MessageCollectionItemType.MSG, GridCacheVersion.class); if (!reader.isLastRead()) @@ -292,7 +292,7 @@ public void addValueBytes( reader.incrementState(); - case 14: + case 15: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -300,7 +300,7 @@ public void addValueBytes( reader.incrementState(); - case 15: + case 16: pending = reader.readCollection("pending", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -320,7 +320,7 @@ public void addValueBytes( /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 16; + return 17; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java index 2c8fe219cb52f..762e244d323b1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java @@ -38,7 +38,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxMapping; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -59,7 +58,6 @@ import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM; -import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.noCoordinatorError; import static org.apache.ignite.transactions.TransactionState.PREPARED; import static org.apache.ignite.transactions.TransactionState.PREPARING; @@ -196,9 +194,6 @@ private void prepareError(Throwable e) { if (keyLockFut != null) keyLockFut.onDone(e); - - if (mvccVerFut != null) - mvccVerFut.onDone(); } /** {@inheritDoc} */ @@ -275,7 +270,8 @@ private boolean isMini(IgniteInternalFuture f) { private boolean onComplete() { Throwable err0 = err; - if (err0 == null || tx.needCheckBackup()) + if ((!tx.onePhaseCommit() || tx.mappings().get(cctx.localNodeId()) == null) && + (err0 == null || tx.needCheckBackup())) tx.state(PREPARED); if (super.onDone(tx, err0)) { @@ -349,30 +345,20 @@ private void prepare( boolean hasNearCache = false; - MvccCoordinator mvccCrd = null; - for (IgniteTxEntry write : writes) { map(write, topVer, mappings, txMapping, remap, topLocked); - GridCacheContext cctx = write.context(); - - if (cctx.isNear()) + if (write.context().isNear()) hasNearCache = true; - - if (cctx.mvccEnabled() && mvccCrd == null) { - mvccCrd = cctx.affinity().mvccCoordinator(topVer); - - if (mvccCrd == null) { - onDone(noCoordinatorError(topVer)); - - return; - } - } } - for (IgniteTxEntry read : reads) + for (IgniteTxEntry read : reads) { map(read, topVer, mappings, txMapping, remap, topLocked); + if (read.context().isNear()) + hasNearCache = true; + } + if (keyLockFut != null) keyLockFut.onAllKeysAdded(); @@ -383,8 +369,6 @@ private void prepare( return; } - assert !tx.txState().mvccEnabled() || mvccCrd != null || F.isEmpty(writes); - tx.addEntryMapping(mappings.values()); cctx.mvcc().recheckPendingLocks(); @@ -396,16 +380,12 @@ private void prepare( MiniFuture locNearEntriesFut = null; - int lockCnt = keyLockFut != null ? 1 : 0; - // Create futures in advance to have all futures when process {@link GridNearTxPrepareResponse#clientRemapVersion}. for (GridDistributedTxMapping m : mappings.values()) { assert !m.empty(); MiniFuture fut = new MiniFuture(this, m, ++miniId); - lockCnt++; - add((IgniteInternalFuture)fut); if (m.primary().isLocal() && m.hasNearCacheEntries() && m.hasColocatedCacheEntries()) { @@ -414,14 +394,9 @@ private void prepare( locNearEntriesFut = fut; add((IgniteInternalFuture)new MiniFuture(this, m, ++miniId)); - - lockCnt++; } } - if (mvccCrd != null) - initMvccVersionFuture(lockCnt, remap); - Collection> futs = (Collection)futures(); Iterator> it = futs.iterator(); @@ -584,7 +559,8 @@ private GridNearTxPrepareRequest createRequest( tx.taskNameHash(), m.clientFirst(), txNodes.size() == 1, - tx.activeCachesDeploymentEnabled()); + tx.activeCachesDeploymentEnabled(), + tx.txState().recovery()); for (IgniteTxEntry txEntry : writes) { if (txEntry.op() == TRANSFORM) @@ -605,7 +581,7 @@ private void prepareLocal(GridNearTxPrepareRequest req, final MiniFuture fut, final boolean nearEntries) { IgniteInternalFuture prepFut = nearEntries ? - cctx.tm().txHandler().prepareNearTxLocal(req) : + cctx.tm().txHandler().prepareNearTxLocal(tx, req) : cctx.tm().txHandler().prepareColocatedTx(tx, req); prepFut.listen(new CI1>() { @@ -986,9 +962,6 @@ void onResult(final GridNearTxPrepareResponse res, boolean updateMapping) { // Finish this mini future (need result only on client node). onDone(parent.cctx.kernalContext().clientNode() ? res : null); - - if (parent.mvccVerFut != null) - parent.mvccVerFut.onLockReceived(); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java index e1bfa90b69a02..7e8c6888c899f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java @@ -43,7 +43,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxMapping; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; @@ -69,7 +68,6 @@ import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM; -import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.noCoordinatorError; import static org.apache.ignite.transactions.TransactionState.PREPARED; import static org.apache.ignite.transactions.TransactionState.PREPARING; @@ -301,7 +299,8 @@ private boolean isMini(IgniteInternalFuture f) { private boolean onComplete() { Throwable err0 = err; - if (err0 == null || tx.needCheckBackup()) + if ((!tx.onePhaseCommit() || tx.mappings().get(cctx.localNodeId()) == null) && + (err0 == null || tx.needCheckBackup())) tx.state(PREPARED); if (super.onDone(tx, err0)) { @@ -382,18 +381,6 @@ else if (write.context().isColocated()) tx.colocatedLocallyMapped(true); } - if (write.context().mvccEnabled()) { - MvccCoordinator mvccCrd = write.context().affinity().mvccCoordinator(topVer); - - if (mvccCrd == null) { - onDone(noCoordinatorError(topVer)); - - return; - } - - initMvccVersionFuture(keyLockFut != null ? 2 : 1, remap); - } - if (keyLockFut != null) keyLockFut.onAllKeysAdded(); @@ -438,8 +425,6 @@ private void prepare( boolean hasNearCache = false; - MvccCoordinator mvccCrd = null; - for (IgniteTxEntry write : writes) { write.clearEntryReadVersion(); @@ -449,16 +434,6 @@ private void prepare( // an exception occurred while transaction mapping, stop further processing break; - if (write.context().mvccEnabled() && mvccCrd == null) { - mvccCrd = write.context().affinity().mvccCoordinator(topVer); - - if (mvccCrd == null) { - onDone(noCoordinatorError(topVer)); - - break; - } - } - if (write.context().isNear()) hasNearCache = true; @@ -498,11 +473,6 @@ else if (write.context().isColocated()) return; } - assert !tx.txState().mvccEnabled() || mvccCrd != null; - - if (mvccCrd != null) - initMvccVersionFuture(keyLockFut != null ? 2 : 1, remap); - if (keyLockFut != null) keyLockFut.onAllKeysAdded(); @@ -526,12 +496,8 @@ else if (write.context().isColocated()) private void proceedPrepare(final Queue mappings) { final GridDistributedTxMapping m = mappings.poll(); - if (m == null) { - if (mvccVerFut != null) - mvccVerFut.onLockReceived(); - + if (m == null) return; - } proceedPrepare(m, mappings); } @@ -574,7 +540,8 @@ private void proceedPrepare(GridDistributedTxMapping m, @Nullable final Queue prepFut = - m.hasNearCacheEntries() ? cctx.tm().txHandler().prepareNearTxLocal(req) + m.hasNearCacheEntries() ? cctx.tm().txHandler().prepareNearTxLocal(tx, req) : cctx.tm().txHandler().prepareColocatedTx(tx, req); prepFut.listen(new CI1>() { @@ -1039,8 +1006,6 @@ void onResult(final GridNearTxPrepareResponse res) { // Proceed prepare before finishing mini future. if (mappings != null) parent.proceedPrepare(mappings); - else if (parent.mvccVerFut != null) - parent.mvccVerFut.onLockReceived(); // Finish this mini future. onDone((GridNearTxPrepareResponse)null); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java index 6f541d330b5a1..913e9bc4c92eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java @@ -18,15 +18,11 @@ package org.apache.ignite.internal.processors.cache.distributed.near; import java.util.Collection; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotResponseListener; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; @@ -35,7 +31,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.lang.IgniteInClosure; import org.jetbrains.annotations.Nullable; /** @@ -45,18 +40,10 @@ public abstract class GridNearOptimisticTxPrepareFutureAdapter extends GridNearT /** */ private static final long serialVersionUID = 7460376140787916619L; - /** */ - private static final AtomicIntegerFieldUpdater LOCK_CNT_UPD = - AtomicIntegerFieldUpdater.newUpdater(MvccSnapshotFutureExt.class, "lockCnt"); - /** */ @GridToStringExclude protected KeyLockFuture keyLockFut; - /** */ - @GridToStringExclude - protected MvccSnapshotFutureExt mvccVerFut; - /** * @param cctx Context. * @param tx Transaction. @@ -213,29 +200,6 @@ protected final void prepareOnTopology(final boolean remap, @Nullable final Runn */ protected abstract void prepare0(boolean remap, boolean topLocked); - /** - * @param lockCnt Expected number of lock responses. - * @param remap Remap flag. - */ - @SuppressWarnings("unchecked") - final void initMvccVersionFuture(int lockCnt, boolean remap) { - if (!remap) { - mvccVerFut = new MvccSnapshotFutureExt(); - - mvccVerFut.init(lockCnt); - - if (keyLockFut != null) - keyLockFut.listen(mvccVerFut); - - add((IgniteInternalFuture)mvccVerFut); - } - else { - assert mvccVerFut != null; - - mvccVerFut.init(lockCnt); - } - } - /** * @param e Exception. * @param timedOut {@code True} if timed out. @@ -314,82 +278,4 @@ private void checkLocks() { return S.toString(KeyLockFuture.class, this, super.toString()); } } - - /** - * - */ - class MvccSnapshotFutureExt extends GridFutureAdapter implements MvccSnapshotResponseListener, IgniteInClosure> { - /** */ - private static final long serialVersionUID = 5883078648683911226L; - - /** */ - volatile int lockCnt; - - /** {@inheritDoc} */ - @Override public void apply(IgniteInternalFuture keyLockFut) { - try { - keyLockFut.get(); - - onLockReceived(); - } - catch (IgniteCheckedException e) { - if (log.isDebugEnabled()) - log.debug("MvccSnapshotFutureExt ignores key lock future failure: " + e); - } - } - - /** - * @param lockCnt Expected number of lock responses. - */ - void init(int lockCnt) { - assert lockCnt > 0; - - this.lockCnt = lockCnt; - - assert !isDone(); - } - - /** */ - void onLockReceived() { - int remaining = LOCK_CNT_UPD.decrementAndGet(this); - - assert remaining >= 0 : remaining; - - if (remaining == 0) { - try { - MvccSnapshot snapshot = cctx.coordinators().tryRequestSnapshotLocal(tx); - - if (snapshot != null) - onResponse(snapshot); - else - cctx.coordinators().requestSnapshotAsync(tx, this); - } - catch (ClusterTopologyCheckedException e) { - onError(e); - } - } - } - - /** {@inheritDoc} */ - @Override public void onResponse(MvccSnapshot res) { - tx.mvccSnapshot(res); - - onDone(); - } - - /** {@inheritDoc} */ - @Override public void onError(IgniteCheckedException e) { - if (e instanceof ClusterTopologyCheckedException) - ((ClusterTopologyCheckedException)e).retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion())); - - ERR_UPD.compareAndSet(GridNearOptimisticTxPrepareFutureAdapter.this, null, e); - - onDone(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(MvccSnapshotFutureExt.class, this, super.toString()); - } - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java index beff162fb444c..e5095fd92b54c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java @@ -34,11 +34,8 @@ import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxMapping; -import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinator; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshotResponseListener; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; @@ -52,7 +49,6 @@ import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM; -import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.noCoordinatorError; import static org.apache.ignite.transactions.TransactionState.PREPARED; import static org.apache.ignite.transactions.TransactionState.PREPARING; @@ -229,7 +225,8 @@ private GridNearTxPrepareRequest createRequest(Map> txNod tx.taskNameHash(), false, true, - tx.activeCachesDeploymentEnabled()); + tx.activeCachesDeploymentEnabled(), + tx.txState().recovery()); req.queryUpdate(m.queryUpdate()); @@ -259,7 +256,7 @@ private void prepareLocal(GridNearTxPrepareRequest req, add((IgniteInternalFuture)fut); IgniteInternalFuture prepFut = nearEntries ? - cctx.tm().txHandler().prepareNearTxLocal(req) : + cctx.tm().txHandler().prepareNearTxLocal(tx, req) : cctx.tm().txHandler().prepareColocatedTx(tx, req); prepFut.listen(new CI1>() { @@ -285,8 +282,6 @@ private void preparePessimistic() { AffinityTopologyVersion topVer = tx.topologyVersion(); - MvccCoordinator mvccCrd = null; - boolean hasNearCache = false; Map> txNodes; @@ -324,16 +319,6 @@ private void preparePessimistic() { else nodes = cacheCtx.affinity().nodesByKey(txEntry.key(), topVer); - if (tx.mvccSnapshot() == null && mvccCrd == null && cacheCtx.mvccEnabled()) { - mvccCrd = cacheCtx.affinity().mvccCoordinator(topVer); - - if (mvccCrd == null) { - onDone(noCoordinatorError(topVer)); - - return; - } - } - if (F.isEmpty(nodes)) { onDone(new ClusterTopologyServerNotFoundException("Failed to map keys to nodes (partition " + "is not mapped to any node) [key=" + txEntry.key() + @@ -359,8 +344,6 @@ private void preparePessimistic() { txNodes = txMapping.transactionNodes(); } - assert !tx.txState().mvccEnabled() || tx.mvccSnapshot() != null || mvccCrd != null; - tx.transactionNodes(txNodes); if (!hasNearCache) @@ -379,16 +362,6 @@ private void preparePessimistic() { for (final GridDistributedTxMapping m : mappings.values()) { final ClusterNode primary = m.primary(); - boolean needCntr = false; - - if (mvccCrd != null) { - if (tx.onePhaseCommit() || mvccCrd.nodeId().equals(primary.id())) { - needCntr = true; - - mvccCrd = null; - } - } - if (primary.isLocal()) { if (m.hasNearCacheEntries() && m.hasColocatedCacheEntries()) { GridNearTxPrepareRequest nearReq = createRequest(txNodes, @@ -397,8 +370,6 @@ private void preparePessimistic() { m.nearEntriesReads(), m.nearEntriesWrites()); - nearReq.requestMvccCounter(needCntr); - prepareLocal(nearReq, m, ++miniId, true); GridNearTxPrepareRequest colocatedReq = createRequest(txNodes, @@ -412,8 +383,6 @@ private void preparePessimistic() { else { GridNearTxPrepareRequest req = createRequest(txNodes, m, timeout, m.reads(), m.writes()); - req.requestMvccCounter(needCntr); - prepareLocal(req, m, ++miniId, m.hasNearCacheEntries()); } } @@ -424,8 +393,6 @@ private void preparePessimistic() { m.reads(), m.writes()); - req.requestMvccCounter(needCntr); - final MiniFuture fut = new MiniFuture(m, ++miniId); req.miniId(fut.futureId()); @@ -458,16 +425,6 @@ private void preparePessimistic() { } } - if (mvccCrd != null) { - assert !tx.onePhaseCommit(); - - MvccSnapshotFutureExt fut = new MvccSnapshotFutureExt(); - - cctx.coordinators().requestSnapshotAsync(tx, fut); - - add((IgniteInternalFuture)fut); - } - markInitialized(); } @@ -483,7 +440,8 @@ private void preparePessimistic() { err = this.err; - if (err == null || tx.needCheckBackup()) + if ((!tx.onePhaseCommit() || tx.mappings().get(cctx.localNodeId()) == null) && + (err == null || tx.needCheckBackup())) tx.state(PREPARED); if (super.onDone(tx, err)) { @@ -515,35 +473,6 @@ private void preparePessimistic() { "super", super.toString()); } - /** - * - */ - private class MvccSnapshotFutureExt extends GridFutureAdapter implements MvccSnapshotResponseListener { - /** {@inheritDoc} */ - @Override public void onResponse(MvccSnapshot res) { - tx.mvccSnapshot(res); - - onDone(); - } - - /** {@inheritDoc} */ - @Override public void onError(IgniteCheckedException e) { - if (log.isDebugEnabled()) - log.debug("Error on tx prepare [fut=" + this + ", err=" + e + ", tx=" + tx + ']'); - - if (ERR_UPD.compareAndSet(GridNearPessimisticTxPrepareFuture.this, null, e)) - tx.setRollbackOnly(); - - onDone(e); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(MvccSnapshotFutureExt.class, this, super.toString()); - } - } - - /** */ private class MiniFuture extends GridFutureAdapter { /** */ @@ -583,9 +512,6 @@ void onResult(GridNearTxPrepareResponse res, boolean updateMapping) { if (res.error() != null) onError(res.error()); else { - if (res.mvccSnapshot() != null) - tx.mvccSnapshot(res.mvccSnapshot()); - onPrepareResponse(m, res, updateMapping); onDone(res); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java index cf885e27111e3..44addb053243c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java @@ -296,7 +296,7 @@ public boolean recovery() { return false; switch (reader.state()) { - case 3: + case 4: accessTtl = reader.readLong("accessTtl"); if (!reader.isLastRead()) @@ -304,7 +304,7 @@ public boolean recovery() { reader.incrementState(); - case 4: + case 5: createTtl = reader.readLong("createTtl"); if (!reader.isLastRead()) @@ -312,7 +312,7 @@ public boolean recovery() { reader.incrementState(); - case 5: + case 6: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -320,7 +320,7 @@ public boolean recovery() { reader.incrementState(); - case 6: + case 7: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -328,7 +328,7 @@ public boolean recovery() { reader.incrementState(); - case 7: + case 8: key = reader.readMessage("key"); if (!reader.isLastRead()) @@ -336,32 +336,32 @@ public boolean recovery() { reader.incrementState(); - case 8: - subjId = reader.readUuid("subjId"); + case 9: + mvccSnapshot = reader.readMessage("mvccSnapshot"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 9: - taskNameHash = reader.readInt("taskNameHash"); + case 10: + subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 10: - topVer = reader.readMessage("topVer"); + case 11: + taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 11: - mvccSnapshot = reader.readMessage("mvccSnapshot"); + case 12: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; @@ -388,56 +388,56 @@ public boolean recovery() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeLong("accessTtl", accessTtl)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeLong("createTtl", createTtl)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeMessage("key", key)) return false; writer.incrementState(); - case 8: - if (!writer.writeUuid("subjId", subjId)) + case 9: + if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) return false; writer.incrementState(); - case 9: - if (!writer.writeInt("taskNameHash", taskNameHash)) + case 10: + if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 10: - if (!writer.writeMessage("topVer", topVer)) + case 11: + if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 11: - if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) + case 12: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -459,7 +459,7 @@ public boolean recovery() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 12; + return 13; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java index 2cb75c253e290..584cec2eb1cb1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetResponse.java @@ -206,32 +206,32 @@ else if (res instanceof GridCacheEntryInfo) } switch (writer.state()) { - case 3: + case 4: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeMessage("res", res)) return false; writer.incrementState(); - case 7: - if (!writer.writeMessage("topVer", topVer)) + case 8: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -252,7 +252,7 @@ else if (res instanceof GridCacheEntryInfo) return false; switch (reader.state()) { - case 3: + case 4: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -260,7 +260,7 @@ else if (res instanceof GridCacheEntryInfo) reader.incrementState(); - case 4: + case 5: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -268,7 +268,7 @@ else if (res instanceof GridCacheEntryInfo) reader.incrementState(); - case 5: + case 6: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -276,7 +276,7 @@ else if (res instanceof GridCacheEntryInfo) reader.incrementState(); - case 6: + case 7: res = reader.readMessage("res"); if (!reader.isLastRead()) @@ -284,8 +284,8 @@ else if (res instanceof GridCacheEntryInfo) reader.incrementState(); - case 7: - topVer = reader.readMessage("topVer"); + case 8: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; @@ -309,7 +309,7 @@ else if (res instanceof GridCacheEntryInfo) /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 8; + return 9; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java index 494f388fb84e1..a5fff90930225 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java @@ -255,7 +255,7 @@ public void clearLocks(UUID nodeId, GridDhtUnlockRequest req) { "(added to cancelled locks set): " + req); } - entry.touch(topVer); + entry.touch(); } else if (log.isDebugEnabled()) log.debug("Received unlock request for entry that could not be found: " + req); @@ -363,7 +363,7 @@ else if (log.isDebugEnabled()) ); if (!req.inTx()) - entry.touch(req.topologyVersion()); + entry.touch(); } else { if (evicted == null) @@ -596,7 +596,7 @@ else if (log.isDebugEnabled()) if (topVer.equals(AffinityTopologyVersion.NONE)) topVer = ctx.affinity().affinityTopologyVersion(); - entry.touch(topVer); + entry.touch(); break; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxAbstractEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxAbstractEnlistFuture.java index bd094242a5f46..3f82144fac052 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxAbstractEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxAbstractEnlistFuture.java @@ -19,6 +19,7 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; @@ -223,7 +224,18 @@ else if (tx.updateLockFuture(null, this)) if (topVer != null) { for (GridDhtTopologyFuture fut : cctx.shared().exchange().exchangeFutures()) { if (fut.exchangeDone() && fut.topologyVersion().equals(topVer)) { - Throwable err = fut.validateCache(cctx, false, false, null, null); + Throwable err = null; + + // Before cache validation, make sure that this topology future is already completed. + try { + fut.get(); + } + catch (IgniteCheckedException e) { + err = fut.error(); + } + + if (err == null) + err = fut.validateCache(cctx, false, false, null, null); if (err != null) { onDone(err); @@ -304,7 +316,10 @@ private void mapOnTopology() { try { if (cctx.topology().stopping()) { - onDone(new CacheStoppedException(cctx.name())); + onDone( + cctx.shared().cache().isCacheRestarting(cctx.name())? + new IgniteCacheRestartingException(cctx.name()): + new CacheStoppedException(cctx.name())); return; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistFuture.java index 3ddedd04b653b..1044df5de51ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistFuture.java @@ -26,10 +26,12 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; +import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheMessage; @@ -70,6 +72,10 @@ public class GridNearTxEnlistFuture extends GridNearTxAbstractEnlistFuture SKIP_UPD = AtomicIntegerFieldUpdater.newUpdater(GridNearTxEnlistFuture.class, "skipCntr"); + /** Res field updater. */ + private static final AtomicReferenceFieldUpdater RES_UPD = + AtomicReferenceFieldUpdater.newUpdater(GridNearTxEnlistFuture.class, GridCacheReturn.class, "res"); + /** Marker object. */ private static final Object FINISHED = new Object(); @@ -210,12 +216,10 @@ private Collection continueLoop(@Nullable UUID nodeId) throws IgniteCheck KeyCacheObject key = cctx.toCacheKeyObject(op.isDeleteOrLock() ? cur : ((IgniteBiTuple)cur).getKey()); - List nodes = cctx.affinity().nodesByKey(key, topVer); - - ClusterNode node; + ClusterNode node = cctx.affinity().primaryByKey(key, topVer); - if (F.isEmpty(nodes) || ((node = nodes.get(0)) == null)) - throw new ClusterTopologyCheckedException("Failed to get primary node " + + if (node == null) + throw new ClusterTopologyServerNotFoundException("Failed to get primary node " + "[topVer=" + topVer + ", key=" + key + ']'); tx.markQueryEnlisted(null); @@ -241,8 +245,7 @@ else if (batch != null && !batch.node().equals(node)) break; } - batch.add(op.isDeleteOrLock() ? key : cur, - op != EnlistOperation.LOCK && cctx.affinityNode() && (cctx.isReplicated() || nodes.indexOf(cctx.localNode()) > 0)); + batch.add(op.isDeleteOrLock() ? key : cur, !node.isLocal() && isLocalBackup(op, key)); if (batch.size() == batchSize) res = markReady(res, batch); @@ -298,6 +301,16 @@ private boolean hasNext0() { return peek != FINISHED; } + /** */ + private boolean isLocalBackup(EnlistOperation op, KeyCacheObject key) { + if (!cctx.affinityNode() || op == EnlistOperation.LOCK) + return false; + else if (cctx.isReplicated()) + return true; + + return cctx.topology().nodes(key.partition(), tx.topologyVersion()).indexOf(cctx.localNode()) > 0; + } + /** * Add batch to batch collection if it is ready. * @@ -592,19 +605,19 @@ public boolean checkResponse(UUID nodeId, GridNearTxEnlistResponse res, Throwabl assert res != null; - if (res.result().invokeResult()) { - if(this.res == null) - this.res = new GridCacheReturn(true, true); - - this.res.success(this.res.success() && err == null && res.result().success()); + if (this.res != null || !RES_UPD.compareAndSet(this, null, res.result())) { + GridCacheReturn res0 = this.res; - this.res.mergeEntryProcessResults(res.result()); + if (res.result().invokeResult()) + res0.mergeEntryProcessResults(res.result()); + else if (res0.success() && !res.result().success()) + res0.success(false); } - else - this.res = res.result(); assert this.res != null && (this.res.emptyResult() || needRes || this.res.invokeResult() || !this.res.success()); + tx.hasRemoteLocks(true); + return true; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistRequest.java index e71de896a185b..dd868618c005e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistRequest.java @@ -388,97 +388,97 @@ public CacheEntryPredicate filter() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeBoolean("clientFirst", clientFirst)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeMessage("filter", filter)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeObjectArray("keys", keys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeMessage("lockVer", lockVer)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeBoolean("needRes", needRes)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeByte("op", op != null ? (byte)op.ordinal() : -1)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeLong("threadId", threadId)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeLong("timeout", timeout)) return false; writer.incrementState(); - case 16: - if (!writer.writeMessage("topVer", topVer)) + case 17: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 17: + case 18: if (!writer.writeLong("txTimeout", txTimeout)) return false; writer.incrementState(); - case 18: + case 19: if (!writer.writeObjectArray("values", values, MessageCollectionItemType.MSG)) return false; @@ -500,7 +500,7 @@ public CacheEntryPredicate filter() { return false; switch (reader.state()) { - case 3: + case 4: clientFirst = reader.readBoolean("clientFirst"); if (!reader.isLastRead()) @@ -508,7 +508,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 4: + case 5: filter = reader.readMessage("filter"); if (!reader.isLastRead()) @@ -516,7 +516,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 5: + case 6: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -524,7 +524,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 6: + case 7: keys = reader.readObjectArray("keys", MessageCollectionItemType.MSG, KeyCacheObject.class); if (!reader.isLastRead()) @@ -532,7 +532,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 7: + case 8: lockVer = reader.readMessage("lockVer"); if (!reader.isLastRead()) @@ -540,7 +540,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 8: + case 9: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -548,7 +548,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 9: + case 10: mvccSnapshot = reader.readMessage("mvccSnapshot"); if (!reader.isLastRead()) @@ -556,7 +556,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 10: + case 11: needRes = reader.readBoolean("needRes"); if (!reader.isLastRead()) @@ -564,7 +564,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 11: + case 12: byte opOrd; opOrd = reader.readByte("op"); @@ -576,7 +576,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 12: + case 13: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -584,7 +584,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 13: + case 14: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -592,7 +592,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 14: + case 15: threadId = reader.readLong("threadId"); if (!reader.isLastRead()) @@ -600,7 +600,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 15: + case 16: timeout = reader.readLong("timeout"); if (!reader.isLastRead()) @@ -608,15 +608,15 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 16: - topVer = reader.readMessage("topVer"); + case 17: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 17: + case 18: txTimeout = reader.readLong("txTimeout"); if (!reader.isLastRead()) @@ -624,7 +624,7 @@ public CacheEntryPredicate filter() { reader.incrementState(); - case 18: + case 19: values = reader.readObjectArray("values", MessageCollectionItemType.MSG, Message.class); if (!reader.isLastRead()) @@ -639,7 +639,7 @@ public CacheEntryPredicate filter() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 19; + return 20; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistResponse.java index 78333a4e65ae7..93df0c2d78fea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxEnlistResponse.java @@ -158,7 +158,7 @@ public GridCacheReturn result() { } /** {@inheritDoc} */ - @Nullable @Override public Throwable error() { + @Override public @Nullable Throwable error() { return err; } @@ -190,7 +190,7 @@ public Collection newDhtNodes() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 11; + return 12; } /** {@inheritDoc} */ @@ -208,49 +208,49 @@ public Collection newDhtNodes() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeIgniteUuid("dhtFutId", dhtFutId)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeMessage("dhtVer", dhtVer)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeMessage("lockVer", lockVer)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeCollection("newDhtNodes", newDhtNodes, MessageCollectionItemType.UUID)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeMessage("res", res)) return false; @@ -272,7 +272,7 @@ public Collection newDhtNodes() { return false; switch (reader.state()) { - case 3: + case 4: dhtFutId = reader.readIgniteUuid("dhtFutId"); if (!reader.isLastRead()) @@ -280,7 +280,7 @@ public Collection newDhtNodes() { reader.incrementState(); - case 4: + case 5: dhtVer = reader.readMessage("dhtVer"); if (!reader.isLastRead()) @@ -288,7 +288,7 @@ public Collection newDhtNodes() { reader.incrementState(); - case 5: + case 6: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -296,7 +296,7 @@ public Collection newDhtNodes() { reader.incrementState(); - case 6: + case 7: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -304,7 +304,7 @@ public Collection newDhtNodes() { reader.incrementState(); - case 7: + case 8: lockVer = reader.readMessage("lockVer"); if (!reader.isLastRead()) @@ -312,7 +312,7 @@ public Collection newDhtNodes() { reader.incrementState(); - case 8: + case 9: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -320,7 +320,7 @@ public Collection newDhtNodes() { reader.incrementState(); - case 9: + case 10: newDhtNodes = reader.readCollection("newDhtNodes", MessageCollectionItemType.UUID); if (!reader.isLastRead()) @@ -328,7 +328,7 @@ public Collection newDhtNodes() { reader.incrementState(); - case 10: + case 11: res = reader.readMessage("res"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java index 4a4d8e3524932..befa3053fe605 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java @@ -311,7 +311,7 @@ void forceFinish() { if (err != null) { tx.setRollbackOnly(); - nodeStop = err instanceof NodeStoppingException; + nodeStop = err instanceof NodeStoppingException || cctx.kernalContext().failure().nodeStopping(); } if (commit) { @@ -357,29 +357,6 @@ else if (err != null) } if (super.onDone(tx0, err)) { - if (error() instanceof IgniteTxHeuristicCheckedException && !nodeStop) { - AffinityTopologyVersion topVer = tx.topologyVersion(); - - for (IgniteTxEntry e : tx.writeMap().values()) { - GridCacheContext cacheCtx = e.context(); - - try { - if (e.op() != NOOP && !cacheCtx.affinity().keyLocalNode(e.key(), topVer)) { - GridCacheEntryEx entry = cacheCtx.cache().peekEx(e.key()); - - if (entry != null) - entry.invalidate(tx.xidVersion()); - } - } - catch (Throwable t) { - U.error(log, "Failed to invalidate entry.", t); - - if (t instanceof Error) - throw (Error)t; - } - } - } - // Don't forget to clean up. cctx.mvcc().removeFuture(futId); @@ -402,8 +379,7 @@ private boolean isMini(IgniteInternalFuture fut) { } /** {@inheritDoc} */ - @Override @SuppressWarnings("ForLoopReplaceableByForEach") - public void finish(final boolean commit, final boolean clearThreadMap, final boolean onTimeout) { + @Override public void finish(final boolean commit, final boolean clearThreadMap, final boolean onTimeout) { if (!cctx.mvcc().addFuture(this, futureId())) return; @@ -490,18 +466,22 @@ private void doFinish(boolean commit, boolean clearThreadMap) { } } + // Cleanup transaction if heuristic failure. + if (tx.state() == UNKNOWN) + cctx.tm().rollbackTx(tx, clearThreadMap, false); + if ((tx.onePhaseCommit() && needFinishOnePhase(commit)) || (!tx.onePhaseCommit() && mappings != null)) { if (mappings.single()) { GridDistributedTxMapping mapping = mappings.singleMapping(); if (mapping != null) { - assert !hasFutures() || waitTxs != null : futures(); + assert !hasFutures() || isDone() || waitTxs != null : futures(); finish(1, mapping, commit, !clearThreadMap); } } else { - assert !hasFutures() || waitTxs != null : futures(); + assert !hasFutures() || isDone() || waitTxs != null : futures(); finish(mappings.mappings(), commit, !clearThreadMap); } @@ -762,7 +742,7 @@ private void readyNearMappingFromBackup(GridDistributedTxMapping mapping) { /** * @param mappings Mappings. * @param commit Commit flag. - * @param {@code true} If need to add completed version on finish. + * @param useCompletedVer {@code True} if need to add completed version on finish. */ private void finish(Iterable mappings, boolean commit, boolean useCompletedVer) { int miniId = 0; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java index 6b5aa90e3f5f3..91079dff6c13f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java @@ -186,13 +186,13 @@ public void miniId(int miniId) { } switch (writer.state()) { - case 21: + case 22: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 22: + case 23: if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) return false; @@ -214,7 +214,7 @@ public void miniId(int miniId) { return false; switch (reader.state()) { - case 21: + case 22: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -222,7 +222,7 @@ public void miniId(int miniId) { reader.incrementState(); - case 22: + case 23: mvccSnapshot = reader.readMessage("mvccSnapshot"); if (!reader.isLastRead()) @@ -242,7 +242,7 @@ public void miniId(int miniId) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 23; + return 24; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java index a1a2b5712fcdd..e3dcbf832bd14 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java @@ -133,19 +133,19 @@ public long threadId() { } switch (writer.state()) { - case 6: + case 7: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeLong("nearThreadId", nearThreadId)) return false; @@ -167,7 +167,7 @@ public long threadId() { return false; switch (reader.state()) { - case 6: + case 7: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -175,7 +175,7 @@ public long threadId() { reader.incrementState(); - case 7: + case 8: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -183,7 +183,7 @@ public long threadId() { reader.incrementState(); - case 8: + case 9: nearThreadId = reader.readLong("nearThreadId"); if (!reader.isLastRead()) @@ -203,7 +203,7 @@ public long threadId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 9; + return 10; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java index 68aa5c05faf97..d628939661776 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java @@ -703,19 +703,6 @@ private IgniteInternalFuture putAsync0( } } - /** - * Validate Tx mode. - * - * @param ctx Cache context. - * @throws IgniteCheckedException If tx mode is not supported. - */ - protected void validateTxMode(GridCacheContext ctx) throws IgniteCheckedException { - if(!ctx.mvccEnabled() || pessimistic() && repeatableRead()) - return; - - throw new IgniteCheckedException("Only pessimistic repeatable read transactions are supported at the moment."); - } - /** * Internal method for put and transform operations in Mvcc mode. * Note: Only one of {@code map}, {@code transformMap} maps must be non-null. @@ -737,8 +724,6 @@ private IgniteInternalFuture mvccPutAllAsync0( @Nullable final CacheEntryPredicate filter ) { try { - validateTxMode(cacheCtx); - MvccUtils.requestSnapshot(cacheCtx, this); beforePut(cacheCtx, retval, true); @@ -1437,7 +1422,7 @@ private boolean enlistWriteEntry(GridCacheContext cacheCtx, } } catch (ClusterTopologyCheckedException e) { - entry.touch(topologyVersion()); + entry.touch(); throw e; } @@ -1495,7 +1480,7 @@ private boolean enlistWriteEntry(GridCacheContext cacheCtx, } if (readCommitted()) - entry.touch(topologyVersion()); + entry.touch(); break; // While. } @@ -1921,13 +1906,7 @@ private IgniteInternalFuture mvccRemoveAllAsync0( @Nullable final CacheEntryPredicate filter ) { try { - validateTxMode(cacheCtx); - - if (mvccSnapshot == null) { - MvccUtils.mvccTracker(cacheCtx, this); - - assert mvccSnapshot != null; - } + MvccUtils.requestSnapshot(cacheCtx, this); beforeRemove(cacheCtx, retval, true); } @@ -2114,7 +2093,7 @@ private IgniteInternalFuture updateAsync(GridCacheContext cache Object val = futRes.value(); - if (futRes.invokeResult()) { + if (futRes.invokeResult() && val != null) { assert val instanceof Map; val = cacheCtx.unwrapInvokeResult((Map)val, keepBinary); @@ -2188,13 +2167,6 @@ public IgniteInternalFuture> getAllAsync( if (F.isEmpty(keys)) return new GridFinishedFuture<>(Collections.emptyMap()); - try { - validateTxMode(cacheCtx); - } - catch (IgniteCheckedException e) { - return new GridFinishedFuture(e); - } - if (cacheCtx.mvccEnabled() && !isOperationAllowed(true)) return txTypeMismatchFinishFuture(); @@ -2422,16 +2394,16 @@ public IgniteInternalFuture> getAllAsync( try { IgniteInternalFuture> fut1 = plc2.apply(fut.get(), null); - return fut1.isDone() ? + return nonInterruptable(fut1.isDone() ? new GridFinishedFuture<>(finClos.apply(fut1.get(), null)) : - new GridEmbeddedFuture<>(finClos, fut1); + new GridEmbeddedFuture<>(finClos, fut1)); } catch (GridClosureException e) { return new GridFinishedFuture<>(e.unwrap()); } catch (IgniteCheckedException e) { try { - return plc2.apply(false, e); + return nonInterruptable(plc2.apply(false, e)); } catch (Exception e1) { return new GridFinishedFuture<>(e1); @@ -2439,10 +2411,10 @@ public IgniteInternalFuture> getAllAsync( } } else { - return new GridEmbeddedFuture<>( + return nonInterruptable(new GridEmbeddedFuture<>( fut, plc2, - finClos); + finClos)); } } else { @@ -2798,7 +2770,7 @@ private Collection enlistRead( } } else - entry.touch(topVer); + entry.touch(); } } } @@ -2987,7 +2959,7 @@ private void onException() { GridCacheEntryEx cached0 = txEntry.cached(); if (cached0 != null) - cached0.touch(topologyVersion()); + cached0.touch(); } } @@ -3947,16 +3919,23 @@ private IgniteInternalFuture chainFinishFuture(final NearTxFin fut.listen(new IgniteInClosure>() { @Override public void apply(IgniteInternalFuture fut0) { if (FINISH_FUT_UPD.compareAndSet(tx, fut, rollbackFut)) { - if (tx.state() == COMMITTED) { - if (log.isDebugEnabled()) - log.debug("Failed to rollback, transaction is already committed: " + tx); + switch (tx.state()) { + case COMMITTED: + if (log.isDebugEnabled()) + log.debug("Failed to rollback, transaction is already committed: " + tx); + + // Fall-through. + + case ROLLED_BACK: + rollbackFut.forceFinish(); - rollbackFut.forceFinish(); + assert rollbackFut.isDone() : rollbackFut; - assert rollbackFut.isDone() : rollbackFut; + break; + + default: // First finish attempt was unsuccessful. Try again. + rollbackFut.finish(false, clearThreadMap, onTimeout); } - else - rollbackFut.finish(false, clearThreadMap, onTimeout); } else { finishFut.listen(new IgniteInClosure>() { @@ -4583,7 +4562,7 @@ private IgniteInternalFuture> checkMissed( GridCacheEntryEx e = txEntry == null ? entryEx(cacheCtx, txKey, topVer) : txEntry.cached(); if (readCommitted() || skipVals) { - e.touch(topologyVersion()); + e.touch(); if (visibleVal != null) { cacheCtx.addResult(map, @@ -4739,7 +4718,7 @@ private void checkUpdatesAllowed(GridCacheContext cacheCtx) throws IgniteChecked * @param fut Future. * @return Future ignoring interrupts on {@code get()}. */ - private IgniteInternalFuture nonInterruptable(IgniteInternalFuture fut) { + private static IgniteInternalFuture nonInterruptable(IgniteInternalFuture fut) { // Safety. if (fut instanceof GridFutureAdapter) ((GridFutureAdapter)fut).ignoreInterrupts(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 55c809d6f189f..00d969705011f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -58,8 +58,8 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest { /** */ private static final int ALLOW_WAIT_TOP_FUT_FLAG_MASK = 0x10; - /** */ - private static final int REQUEST_MVCC_CNTR_FLAG_MASK = 0x20; + /** Recovery value flag. */ + private static final int RECOVERY_FLAG_MASK = 0x40; /** Future ID. */ private IgniteUuid futId; @@ -125,7 +125,8 @@ public GridNearTxPrepareRequest( int taskNameHash, boolean firstClientReq, boolean allowWaitTopFut, - boolean addDepInfo + boolean addDepInfo, + boolean recovery ) { super(tx, timeout, @@ -150,28 +151,29 @@ public GridNearTxPrepareRequest( setFlag(explicitLock, EXPLICIT_LOCK_FLAG_MASK); setFlag(firstClientReq, FIRST_CLIENT_REQ_FLAG_MASK); setFlag(allowWaitTopFut, ALLOW_WAIT_TOP_FUT_FLAG_MASK); + setFlag(recovery, RECOVERY_FLAG_MASK); } /** - * @return {@code True} if need request MVCC counter on primary node on prepare step. + * @return {@code True} if it is safe for first client request to wait for topology future + * completion. */ - public boolean requestMvccCounter() { - return isFlag(REQUEST_MVCC_CNTR_FLAG_MASK); + public boolean allowWaitTopologyFuture() { + return isFlag(ALLOW_WAIT_TOP_FUT_FLAG_MASK); } /** - * @param val {@code True} if need request MVCC counter on primary node on prepare step. + * @return Recovery flag. */ - public void requestMvccCounter(boolean val) { - setFlag(val, REQUEST_MVCC_CNTR_FLAG_MASK); + public final boolean recovery() { + return isFlag(RECOVERY_FLAG_MASK); } /** - * @return {@code True} if it is safe for first client request to wait for topology future - * completion. + * @param val Recovery flag. */ - public boolean allowWaitTopologyFuture() { - return isFlag(ALLOW_WAIT_TOP_FUT_FLAG_MASK); + public void recovery(boolean val) { + setFlag(val, RECOVERY_FLAG_MASK); } /** @@ -318,38 +320,38 @@ private boolean isFlag(int mask) { } switch (writer.state()) { - case 20: + case 21: if (!writer.writeByte("flags", flags)) return false; writer.incrementState(); - case 21: + case 22: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 22: + case 23: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 23: + case 24: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 24: + case 25: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 25: - if (!writer.writeMessage("topVer", topVer)) + case 26: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -370,7 +372,7 @@ private boolean isFlag(int mask) { return false; switch (reader.state()) { - case 20: + case 21: flags = reader.readByte("flags"); if (!reader.isLastRead()) @@ -378,7 +380,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 21: + case 22: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -386,7 +388,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 22: + case 23: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -394,7 +396,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 23: + case 24: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -402,7 +404,7 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 24: + case 25: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -410,8 +412,8 @@ private boolean isFlag(int mask) { reader.incrementState(); - case 25: - topVer = reader.readMessage("topVer"); + case 26: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; @@ -430,7 +432,7 @@ private boolean isFlag(int mask) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 26; + return 27; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index e9865df5e3e3b..ef547ccaed0a6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -33,7 +33,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheReturn; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareResponse; -import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.tostring.GridToStringExclude; @@ -98,9 +97,6 @@ public class GridNearTxPrepareResponse extends GridDistributedTxPrepareResponse /** Not {@code null} if client node should remap transaction. */ private AffinityTopologyVersion clientRemapVer; - /** */ - private MvccSnapshot mvccSnapshot; - /** * Empty constructor required by {@link Externalizable}. */ @@ -149,20 +145,6 @@ public GridNearTxPrepareResponse( flags |= NEAR_PREPARE_ONE_PHASE_COMMIT_FLAG_MASK; } - /** - * @param mvccSnapshot Mvcc info. - */ - public void mvccSnapshot(MvccSnapshot mvccSnapshot) { - this.mvccSnapshot = mvccSnapshot; - } - - /** - * @return Mvcc info. - */ - @Nullable public MvccSnapshot mvccSnapshot() { - return mvccSnapshot; - } - /** * @return One-phase commit state on primary node. */ @@ -376,72 +358,65 @@ public boolean hasOwnedValue(IgniteTxKey key) { } switch (writer.state()) { - case 10: - if (!writer.writeMessage("clientRemapVer", clientRemapVer)) - return false; - - writer.incrementState(); - case 11: - if (!writer.writeMessage("dhtVer", dhtVer)) + if (!writer.writeAffinityTopologyVersion("clientRemapVer", clientRemapVer)) return false; writer.incrementState(); case 12: - if (!writer.writeCollection("filterFailedKeys", filterFailedKeys, MessageCollectionItemType.MSG)) + if (!writer.writeMessage("dhtVer", dhtVer)) return false; writer.incrementState(); case 13: - if (!writer.writeIgniteUuid("futId", futId)) + if (!writer.writeCollection("filterFailedKeys", filterFailedKeys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); case 14: - if (!writer.writeInt("miniId", miniId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); case 15: - if (!writer.writeCollection("ownedValKeys", ownedValKeys, MessageCollectionItemType.MSG)) + if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); case 16: - if (!writer.writeCollection("ownedValVals", ownedValVals, MessageCollectionItemType.MSG)) + if (!writer.writeCollection("ownedValKeys", ownedValKeys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); case 17: - if (!writer.writeCollection("pending", pending, MessageCollectionItemType.MSG)) + if (!writer.writeCollection("ownedValVals", ownedValVals, MessageCollectionItemType.MSG)) return false; writer.incrementState(); case 18: - if (!writer.writeMessage("retVal", retVal)) + if (!writer.writeCollection("pending", pending, MessageCollectionItemType.MSG)) return false; writer.incrementState(); case 19: - if (!writer.writeMessage("writeVer", writeVer)) + if (!writer.writeMessage("retVal", retVal)) return false; writer.incrementState(); case 20: - if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) + if (!writer.writeMessage("writeVer", writeVer)) return false; writer.incrementState(); - } return true; @@ -458,16 +433,8 @@ public boolean hasOwnedValue(IgniteTxKey key) { return false; switch (reader.state()) { - case 10: - clientRemapVer = reader.readMessage("clientRemapVer"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - case 11: - dhtVer = reader.readMessage("dhtVer"); + clientRemapVer = reader.readAffinityTopologyVersion("clientRemapVer"); if (!reader.isLastRead()) return false; @@ -475,7 +442,7 @@ public boolean hasOwnedValue(IgniteTxKey key) { reader.incrementState(); case 12: - filterFailedKeys = reader.readCollection("filterFailedKeys", MessageCollectionItemType.MSG); + dhtVer = reader.readMessage("dhtVer"); if (!reader.isLastRead()) return false; @@ -483,7 +450,7 @@ public boolean hasOwnedValue(IgniteTxKey key) { reader.incrementState(); case 13: - futId = reader.readIgniteUuid("futId"); + filterFailedKeys = reader.readCollection("filterFailedKeys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) return false; @@ -491,7 +458,7 @@ public boolean hasOwnedValue(IgniteTxKey key) { reader.incrementState(); case 14: - miniId = reader.readInt("miniId"); + futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) return false; @@ -499,7 +466,7 @@ public boolean hasOwnedValue(IgniteTxKey key) { reader.incrementState(); case 15: - ownedValKeys = reader.readCollection("ownedValKeys", MessageCollectionItemType.MSG); + miniId = reader.readInt("miniId"); if (!reader.isLastRead()) return false; @@ -507,7 +474,7 @@ public boolean hasOwnedValue(IgniteTxKey key) { reader.incrementState(); case 16: - ownedValVals = reader.readCollection("ownedValVals", MessageCollectionItemType.MSG); + ownedValKeys = reader.readCollection("ownedValKeys", MessageCollectionItemType.MSG); if (!reader.isLastRead()) return false; @@ -515,7 +482,7 @@ public boolean hasOwnedValue(IgniteTxKey key) { reader.incrementState(); case 17: - pending = reader.readCollection("pending", MessageCollectionItemType.MSG); + ownedValVals = reader.readCollection("ownedValVals", MessageCollectionItemType.MSG); if (!reader.isLastRead()) return false; @@ -523,7 +490,7 @@ public boolean hasOwnedValue(IgniteTxKey key) { reader.incrementState(); case 18: - retVal = reader.readMessage("retVal"); + pending = reader.readCollection("pending", MessageCollectionItemType.MSG); if (!reader.isLastRead()) return false; @@ -531,7 +498,7 @@ public boolean hasOwnedValue(IgniteTxKey key) { reader.incrementState(); case 19: - writeVer = reader.readMessage("writeVer"); + retVal = reader.readMessage("retVal"); if (!reader.isLastRead()) return false; @@ -539,13 +506,12 @@ public boolean hasOwnedValue(IgniteTxKey key) { reader.incrementState(); case 20: - mvccSnapshot = reader.readMessage("mvccSnapshot"); + writeVer = reader.readMessage("writeVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - } return reader.afterMessageRead(GridNearTxPrepareResponse.class); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistFuture.java index 70fbd1fce793b..faf84ef96d44f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistFuture.java @@ -23,6 +23,7 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; +import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; import org.apache.ignite.internal.processors.affinity.AffinityAssignment; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheMessage; @@ -120,6 +121,10 @@ protected GridNearTxQueryEnlistFuture( updateMappings(pNode); } + if (primary.isEmpty()) + throw new ClusterTopologyServerNotFoundException("Failed to find data nodes for cache (all partition " + + "nodes left the grid)."); + boolean locallyMapped = primary.contains(cctx.localNode()); if (locallyMapped) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistRequest.java index 472937be41569..3b22afb7734b7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistRequest.java @@ -297,7 +297,7 @@ public boolean firstClientRequest() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 21; + return 22; } /** {@inheritDoc} */ @@ -331,109 +331,109 @@ public boolean firstClientRequest() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeIntArray("cacheIds", cacheIds)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeBoolean("clientFirst", clientFirst)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeInt("flags", flags)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeMessage("lockVer", lockVer)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeInt("pageSize", pageSize)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeByteArray("paramsBytes", paramsBytes)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeIntArray("parts", parts)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeString("qry", qry)) return false; writer.incrementState(); - case 14: + case 15: if (!writer.writeString("schema", schema)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 16: + case 17: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 17: + case 18: if (!writer.writeLong("threadId", threadId)) return false; writer.incrementState(); - case 18: + case 19: if (!writer.writeLong("timeout", timeout)) return false; writer.incrementState(); - case 19: - if (!writer.writeMessage("topVer", topVer)) + case 20: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 20: + case 21: if (!writer.writeLong("txTimeout", txTimeout)) return false; @@ -455,7 +455,7 @@ public boolean firstClientRequest() { return false; switch (reader.state()) { - case 3: + case 4: cacheIds = reader.readIntArray("cacheIds"); if (!reader.isLastRead()) @@ -463,7 +463,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 4: + case 5: clientFirst = reader.readBoolean("clientFirst"); if (!reader.isLastRead()) @@ -471,7 +471,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 5: + case 6: flags = reader.readInt("flags"); if (!reader.isLastRead()) @@ -479,7 +479,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 6: + case 7: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -487,7 +487,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 7: + case 8: lockVer = reader.readMessage("lockVer"); if (!reader.isLastRead()) @@ -495,7 +495,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 8: + case 9: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -503,7 +503,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 9: + case 10: mvccSnapshot = reader.readMessage("mvccSnapshot"); if (!reader.isLastRead()) @@ -511,7 +511,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 10: + case 11: pageSize = reader.readInt("pageSize"); if (!reader.isLastRead()) @@ -519,7 +519,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 11: + case 12: paramsBytes = reader.readByteArray("paramsBytes"); if (!reader.isLastRead()) @@ -527,7 +527,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 12: + case 13: parts = reader.readIntArray("parts"); if (!reader.isLastRead()) @@ -535,7 +535,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 13: + case 14: qry = reader.readString("qry"); if (!reader.isLastRead()) @@ -543,7 +543,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 14: + case 15: schema = reader.readString("schema"); if (!reader.isLastRead()) @@ -551,7 +551,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 15: + case 16: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -559,7 +559,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 16: + case 17: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -567,7 +567,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 17: + case 18: threadId = reader.readLong("threadId"); if (!reader.isLastRead()) @@ -575,7 +575,7 @@ public boolean firstClientRequest() { reader.incrementState(); - case 18: + case 19: timeout = reader.readLong("timeout"); if (!reader.isLastRead()) @@ -583,15 +583,15 @@ public boolean firstClientRequest() { reader.incrementState(); - case 19: - topVer = reader.readMessage("topVer"); + case 20: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 20: + case 21: txTimeout = reader.readLong("txTimeout"); if (!reader.isLastRead()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistResponse.java index d628de1d56311..2715f89b408f3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryEnlistResponse.java @@ -166,7 +166,7 @@ public boolean removeMapping() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 10; + return 11; } /** {@inheritDoc} */ @@ -184,47 +184,48 @@ public boolean removeMapping() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeMessage("lockVer", lockVer)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 7: - if (!writer.writeBoolean("removeMapping", removeMapping)) + case 8: + if (!writer.writeCollection("newDhtNodes", newDhtNodes, MessageCollectionItemType.UUID)) return false; writer.incrementState(); - case 8: - if (!writer.writeLong("res", res)) + case 9: + if (!writer.writeBoolean("removeMapping", removeMapping)) return false; writer.incrementState(); - case 9: - if (!writer.writeCollection("newDhtNodes", newDhtNodes, MessageCollectionItemType.UUID)) + case 10: + if (!writer.writeLong("res", res)) return false; writer.incrementState(); + } return true; @@ -241,7 +242,7 @@ public boolean removeMapping() { return false; switch (reader.state()) { - case 3: + case 4: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -249,7 +250,7 @@ public boolean removeMapping() { reader.incrementState(); - case 4: + case 5: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -257,7 +258,7 @@ public boolean removeMapping() { reader.incrementState(); - case 5: + case 6: lockVer = reader.readMessage("lockVer"); if (!reader.isLastRead()) @@ -265,7 +266,7 @@ public boolean removeMapping() { reader.incrementState(); - case 6: + case 7: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -273,29 +274,30 @@ public boolean removeMapping() { reader.incrementState(); - case 7: - removeMapping = reader.readBoolean("removeMapping"); + case 8: + newDhtNodes = reader.readCollection("newDhtNodes", MessageCollectionItemType.UUID); if (!reader.isLastRead()) return false; reader.incrementState(); - case 8: - res = reader.readLong("res"); + case 9: + removeMapping = reader.readBoolean("removeMapping"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 9: - newDhtNodes = reader.readCollection("newDhtNodes", MessageCollectionItemType.UUID); + case 10: + res = reader.readLong("res"); if (!reader.isLastRead()) return false; reader.incrementState(); + } return reader.afterMessageRead(GridNearTxQueryEnlistResponse.class); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistFuture.java index 9783582c41d46..07987ddea90ef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistFuture.java @@ -31,6 +31,7 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; +import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheMessage; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -201,12 +202,10 @@ private Collection continueLoop(@Nullable UUID nodeId) throws IgniteCheck KeyCacheObject key = cctx.toCacheKeyObject(op.isDeleteOrLock() ? cur : ((IgniteBiTuple)cur).getKey()); - List nodes = cctx.affinity().nodesByKey(key, topVer); + ClusterNode node = cctx.affinity().primaryByPartition(key.partition(), topVer); - ClusterNode node; - - if (F.isEmpty(nodes) || ((node = nodes.get(0)) == null)) - throw new ClusterTopologyCheckedException("Failed to get primary node " + + if (node == null) + throw new ClusterTopologyServerNotFoundException("Failed to get primary node " + "[topVer=" + topVer + ", key=" + key + ']'); if (!sequential) @@ -230,8 +229,7 @@ else if (batch != null && !batch.node().equals(node)) break; } - batch.add(op.isDeleteOrLock() ? key : cur, - op != EnlistOperation.LOCK && cctx.affinityNode() && (cctx.isReplicated() || nodes.indexOf(cctx.localNode()) > 0)); + batch.add(op.isDeleteOrLock() ? key : cur, !node.isLocal() && isLocalBackup(op, key)); if (batch.size() == batchSize) res = markReady(res, batch); @@ -287,6 +285,16 @@ private boolean hasNext0() { return peek != FINISHED; } + /** */ + private boolean isLocalBackup(EnlistOperation op, KeyCacheObject key) { + if (!cctx.affinityNode() || op == EnlistOperation.LOCK) + return false; + else if (cctx.isReplicated()) + return true; + + return cctx.topology().nodes(key.partition(), tx.topologyVersion()).contains(cctx.localNode()); + } + /** */ private ArrayList markReady(ArrayList batches, Batch batch) { if (!batch.ready()) { @@ -571,6 +579,8 @@ public boolean checkResponse(UUID nodeId, GridNearTxQueryResultsEnlistResponse r RES_UPD.getAndAdd(this, res.result()); + tx.hasRemoteLocks(true); + return true; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistRequest.java index f350d502b9b7d..8e10a7edb3494 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistRequest.java @@ -335,85 +335,85 @@ public EnlistOperation operation() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeBoolean("clientFirst", clientFirst)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeObjectArray("keys", keys, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeMessage("lockVer", lockVer)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeInt("miniId", miniId)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) return false; writer.incrementState(); - case 9: + case 10: if (!writer.writeByte("op", op != null ? (byte)op.ordinal() : -1)) return false; writer.incrementState(); - case 10: + case 11: if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeInt("taskNameHash", taskNameHash)) return false; writer.incrementState(); - case 12: + case 13: if (!writer.writeLong("threadId", threadId)) return false; writer.incrementState(); - case 13: + case 14: if (!writer.writeLong("timeout", timeout)) return false; writer.incrementState(); - case 14: - if (!writer.writeMessage("topVer", topVer)) + case 15: + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); - case 15: + case 16: if (!writer.writeLong("txTimeout", txTimeout)) return false; writer.incrementState(); - case 16: + case 17: if (!writer.writeObjectArray("values", values, MessageCollectionItemType.MSG)) return false; @@ -435,7 +435,7 @@ public EnlistOperation operation() { return false; switch (reader.state()) { - case 3: + case 4: clientFirst = reader.readBoolean("clientFirst"); if (!reader.isLastRead()) @@ -443,7 +443,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 4: + case 5: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -451,7 +451,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 5: + case 6: keys = reader.readObjectArray("keys", MessageCollectionItemType.MSG, KeyCacheObject.class); if (!reader.isLastRead()) @@ -459,7 +459,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 6: + case 7: lockVer = reader.readMessage("lockVer"); if (!reader.isLastRead()) @@ -467,7 +467,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 7: + case 8: miniId = reader.readInt("miniId"); if (!reader.isLastRead()) @@ -475,7 +475,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 8: + case 9: mvccSnapshot = reader.readMessage("mvccSnapshot"); if (!reader.isLastRead()) @@ -483,7 +483,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 9: + case 10: byte opOrd; opOrd = reader.readByte("op"); @@ -495,7 +495,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 10: + case 11: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -503,7 +503,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 11: + case 12: taskNameHash = reader.readInt("taskNameHash"); if (!reader.isLastRead()) @@ -511,7 +511,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 12: + case 13: threadId = reader.readLong("threadId"); if (!reader.isLastRead()) @@ -519,7 +519,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 13: + case 14: timeout = reader.readLong("timeout"); if (!reader.isLastRead()) @@ -527,15 +527,15 @@ public EnlistOperation operation() { reader.incrementState(); - case 14: - topVer = reader.readMessage("topVer"); + case 15: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 15: + case 16: txTimeout = reader.readLong("txTimeout"); if (!reader.isLastRead()) @@ -543,7 +543,7 @@ public EnlistOperation operation() { reader.incrementState(); - case 16: + case 17: values = reader.readObjectArray("values", MessageCollectionItemType.MSG, CacheObject.class); if (!reader.isLastRead()) @@ -558,7 +558,7 @@ public EnlistOperation operation() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 17; + return 18; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistResponse.java index 48c63bc3c942c..2a0c63242f867 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxQueryResultsEnlistResponse.java @@ -102,7 +102,7 @@ public IgniteUuid dhtFutureId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 12; + return 13; } /** {@inheritDoc} */ @@ -120,17 +120,18 @@ public IgniteUuid dhtFutureId() { } switch (writer.state()) { - case 10: + case 11: if (!writer.writeIgniteUuid("dhtFutId", dhtFutId)) return false; writer.incrementState(); - case 11: + case 12: if (!writer.writeMessage("dhtVer", dhtVer)) return false; writer.incrementState(); + } return true; @@ -147,7 +148,7 @@ public IgniteUuid dhtFutureId() { return false; switch (reader.state()) { - case 10: + case 11: dhtFutId = reader.readIgniteUuid("dhtFutId"); if (!reader.isLastRead()) @@ -155,13 +156,14 @@ public IgniteUuid dhtFutureId() { reader.incrementState(); - case 11: + case 12: dhtVer = reader.readMessage("dhtVer"); if (!reader.isLastRead()) return false; reader.incrementState(); + } return reader.afterMessageRead(GridNearTxQueryResultsEnlistResponse.class); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java index 879bf26fb7273..cd0ee6c2f6e81 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java @@ -340,7 +340,7 @@ private boolean addEntry(IgniteTxEntry entry) throws IgniteCheckedException { try { cached.unswap(); - CacheObject val = cached.peek(null); + CacheObject val = cached.peek(); if (val == null && cached.evictInternal(xidVer, null, false)) { evicted.add(entry.txKey()); @@ -401,7 +401,7 @@ public boolean addEntry( else { cached.unswap(); - CacheObject peek = cached.peek(null); + CacheObject peek = cached.peek(); if (peek == null && cached.evictInternal(xidVer, null, false)) { cached.context().cache().removeIfObsolete(key.key()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java index 2b49889cadc27..b2ed241e91fd2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java @@ -85,7 +85,7 @@ public GridNearUnlockRequest(int cacheId, int keyCnt, boolean addDepInfo) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 8; + return 9; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/TxTopologyVersionFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/TxTopologyVersionFuture.java index b5e38839b75b4..7f8a121b8b806 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/TxTopologyVersionFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/TxTopologyVersionFuture.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache.distributed.near; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -70,7 +71,18 @@ private void init() { if (topVer != null) { for (GridDhtTopologyFuture fut : cctx.shared().exchange().exchangeFutures()) { if (fut.exchangeDone() && fut.topologyVersion().equals(topVer)) { - Throwable err = fut.validateCache(cctx, false, false, null, null); + Throwable err = null; + + // Before cache validation, make sure that this topology future is already completed. + try { + fut.get(); + } + catch (IgniteCheckedException e) { + err = fut.error(); + } + + if (err == null) + err = fut.validateCache(cctx, false, false, null, null); if (err != null) { onDone(err); @@ -100,7 +112,10 @@ private void acquireTopologyVersion() { try { if (cctx.topology().stopping()) { - onDone(new CacheStoppedException(cctx.name())); + onDone( + cctx.shared().cache().isCacheRestarting(cctx.name())? + new IgniteCacheRestartingException(cctx.name()): + new CacheStoppedException(cctx.name())); return; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridCacheDrManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridCacheDrManager.java index f2a4b30c4af82..33a52a11a03d1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridCacheDrManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridCacheDrManager.java @@ -60,9 +60,10 @@ public void replicate(KeyCacheObject key, * * @param topVer Topology version. * @param left {@code True} if exchange has been caused by node leave. + * @param activate {@code True} if exchange has been caused by cluster activation. * @throws IgniteCheckedException If failed. */ - public void onExchange(AffinityTopologyVersion topVer, boolean left) throws IgniteCheckedException; + public void onExchange(AffinityTopologyVersion topVer, boolean left, boolean activate) throws IgniteCheckedException; /** * @return {@code True} is DR is enabled. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridOsCacheDrManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridOsCacheDrManager.java index f3c1b23f7c7d6..425e79c536344 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridOsCacheDrManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridOsCacheDrManager.java @@ -78,7 +78,7 @@ public class GridOsCacheDrManager implements GridCacheDrManager { } /** {@inheritDoc} */ - @Override public void onExchange(AffinityTopologyVersion topVer, boolean left) throws IgniteCheckedException { + @Override public void onExchange(AffinityTopologyVersion topVer, boolean left, boolean activate) throws IgniteCheckedException { // No-op. } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java index 7b7ac66c0cc31..3bdb44e72aa55 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java @@ -182,7 +182,7 @@ public IgniteInternalFuture lockAllAsync(Collection key if (entry != null && ctx.isAll(entry, CU.empty0())) { entry.releaseLocal(); - entry.touch(topVer); + entry.touch(); } } } @@ -232,4 +232,27 @@ else if (modes.heap) @Override public long localSizeLong(int part, CachePeekMode[] peekModes) throws IgniteCheckedException { return localSizeLong(peekModes); } + + /** {@inheritDoc} */ + @Override public void preloadPartition(int part) throws IgniteCheckedException { + ctx.offheap().preloadPartition(part); + } + + /** {@inheritDoc} */ + @Override public IgniteInternalFuture preloadPartitionAsync(int part) throws IgniteCheckedException { + return ctx.closures().callLocalSafe(new Callable() { + @Override public Void call() throws Exception { + preloadPartition(part); + + return null; + } + }); + } + + /** {@inheritDoc} */ + @Override public boolean localPreloadPartition(int part) throws IgniteCheckedException { + ctx.offheap().preloadPartition(part); + + return true; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java index 412d4d30e4e76..e26174a2adef5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java @@ -257,15 +257,6 @@ public void recheck() { } } - /** - * Unlocks lock if it is currently owned. - * - * @param tx Transaction to unlock. - */ - @Override public void txUnlock(IgniteInternalTx tx) throws GridCacheEntryRemovedException { - removeLock(tx.xidVersion()); - } - /** * Releases local lock. */ @@ -327,6 +318,8 @@ private void releaseLocal(long threadId) { GridCacheMvccCandidate doomed; + GridCacheVersion deferredDelVer; + lockEntry(); try { @@ -351,11 +344,22 @@ private void releaseLocal(long threadId) { } val = this.val; + + deferredDelVer = this.ver; } finally { unlockEntry(); } + if (val == null) { + boolean deferred = cctx.deferredDelete() && !detached() && !isInternal(); + + if (deferred) { + if (deferredDelVer != null) + cctx.onDeferredDelete(this, deferredDelVer); + } + } + if (doomed != null) checkThreadChain(doomed); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java index b615952f785cd..9376768db89a7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java @@ -516,7 +516,7 @@ private Map getAllInternal(@Nullable Collection keys, } finally { if (entry != null) - entry.touch(ctx.affinity().affinityTopologyVersion()); + entry.touch(); } if (!success && storeEnabled) @@ -982,7 +982,7 @@ else if (res == null) } finally { if (entry != null) - entry.touch(ctx.affinity().affinityTopologyVersion()); + entry.touch(); } } } @@ -1513,7 +1513,7 @@ private List lockEntries(Collection keys) { AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); for (GridCacheEntryEx entry : locked) - entry.touch(topVer); + entry.touch(); throw new NullPointerException("Null key."); } @@ -1530,7 +1530,7 @@ private void unlockEntries(Iterable locked) { AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); for (GridCacheEntryEx entry : locked) - entry.touch(topVer); + entry.touch(); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCachingManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCachingManager.java index 259f69b3c706c..8f83b6e5b3e1d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCachingManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCachingManager.java @@ -40,8 +40,10 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.TxCounters; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; +import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; @@ -146,16 +148,23 @@ public void onTxFinished(IgniteInternalTx tx, boolean commit) throws IgniteCheck Map cached = buf.getCached(); - if (F.isEmpty(cached) || !commit) + if (F.isEmpty(cached)) return; TxCounters txCntrs = tx.txCounters(false); - assert txCntrs != null; + assert txCntrs != null || !commit; - Collection cntrsColl = txCntrs.updateCounters(); + if (txCntrs == null) + return; + + Collection cntrsColl = txCntrs.updateCounters(); - assert !F.isEmpty(cntrsColl) : cntrsColl; + if (F.isEmpty(cntrsColl)) { + assert !commit; + + return; + } // cacheId -> partId -> initCntr -> cntr + delta. Map>> cntrsMap = new HashMap<>(); @@ -219,8 +228,8 @@ public void onTxFinished(IgniteInternalTx tx, boolean commit) throws IgniteCheck contQryMgr.onEntryUpdated( lsnrCol, e.key(), - e.value(), - e.oldValue(), + commit ? e.value() : null, // Force skip update counter if rolled back. + commit ? e.oldValue() : null, // Force skip update counter if rolled back. false, e.key().partition(), tx.local(), @@ -253,7 +262,7 @@ public boolean needDrReplicate(GridCacheContext ctx0, KeyCacheObject key) { * @return Map of listeners to be notified by this update. */ public Map continuousQueryListeners(GridCacheContext ctx0, @Nullable IgniteInternalTx tx, KeyCacheObject key) { - boolean internal = key.internal() || !ctx0.userCache(); + boolean internal = key != null && key.internal() || !ctx0.userCache(); return ctx0.continuousQueries().notifyContinuousQueries(tx) ? ctx0.continuousQueries().updateListeners(internal, false) : null; @@ -268,9 +277,11 @@ private static class EnlistBuffer { private IgniteUuid lastFutId; /** Main buffer for entries. */ + @GridToStringInclude private Map cached = new LinkedHashMap<>(); /** Pending entries. */ + @GridToStringInclude private SortedMap> pending; /** @@ -337,5 +348,10 @@ private void flushPending() { pending.clear(); } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(EnlistBuffer.class, this); + } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccPreviousCoordinatorQueries.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccPreviousCoordinatorQueries.java index cd7560f40a205..6218bc026fa50 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccPreviousCoordinatorQueries.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccPreviousCoordinatorQueries.java @@ -19,7 +19,6 @@ import java.util.Collection; import java.util.HashSet; -import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -58,7 +57,7 @@ class MvccPreviousCoordinatorQueries { * @param nodes Cluster nodes. * @param mgr Discovery manager. */ - void init(Map nodeQueries, Collection nodes, GridDiscoveryManager mgr) { + void init(GridLongList nodeQueries, Collection nodes, GridDiscoveryManager mgr) { synchronized (this) { assert !initDone; assert waitNodes == null; @@ -66,18 +65,14 @@ void init(Map nodeQueries, Collection nodes, Gr waitNodes = new HashSet<>(); for (ClusterNode node : nodes) { - if ((nodeQueries == null || !nodeQueries.containsKey(node.id())) && - mgr.alive(node) && - !F.contains(rcvd, node.id())) + if (!node.isLocal() && mgr.alive(node) && !F.contains(rcvd, node.id())) waitNodes.add(node.id()); } initDone = waitNodes.isEmpty(); - if (nodeQueries != null) { - for (Map.Entry e : nodeQueries.entrySet()) - mergeToActiveQueries(e.getKey(), e.getValue()); - } + if (nodeQueries != null) + mergeToActiveQueries(mgr.localNode().id(), nodeQueries); if (initDone && !prevQueriesDone) prevQueriesDone = activeQueries.isEmpty() && rcvdAcks.isEmpty(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccProcessor.java index a926acf032735..fd45c7a053585 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccProcessor.java @@ -17,21 +17,16 @@ package org.apache.ignite.internal.processors.cache.mvcc; -import java.util.Collection; -import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; -import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.events.DiscoveryEvent; import org.apache.ignite.internal.IgniteDiagnosticPrepareContext; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.managers.discovery.DiscoCache; -import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; import org.apache.ignite.internal.processors.GridProcessor; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.ExchangeContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.util.GridLongList; @@ -42,31 +37,18 @@ */ public interface MvccProcessor extends GridProcessor { /** - * @param evtType Event type. - * @param nodes Current nodes. - * @param topVer Topology version. - * @param customMsg Message - */ - void onDiscoveryEvent(int evtType, Collection nodes, long topVer, - @Nullable DiscoveryCustomMessage customMsg); - - /** - * Exchange start callback. + * Local join callback. * - * @param mvccCrd Mvcc coordinator. - * @param exchCtx Exchange context. - * @param exchCrd Exchange coordinator. + * @param evt Discovery event. */ - void onExchangeStart(MvccCoordinator mvccCrd, ExchangeContext exchCtx, ClusterNode exchCrd); + void onLocalJoin(DiscoveryEvent evt); /** * Exchange done callback. * - * @param newCoord New coordinator flag. * @param discoCache Disco cache. - * @param activeQueries Active queries. */ - void onExchangeDone(boolean newCoord, DiscoCache discoCache, Map activeQueries); + void onExchangeDone(DiscoCache discoCache); /** * @param nodeId Node ID @@ -74,33 +56,16 @@ void onDiscoveryEvent(int evtType, Collection nodes, long topVer, */ void processClientActiveQueries(UUID nodeId, @Nullable GridLongList activeQueries); - /** - * @return Mvcc coordinator received from discovery event. - */ - @Nullable MvccCoordinator assignedCoordinator(); - /** * @return Coordinator. */ @Nullable MvccCoordinator currentCoordinator(); - /** - * Check that the given topology is greater or equals to coordinator's one and returns current coordinator. - * @param topVer Topology version. - * @return Mvcc coordinator. - */ - @Nullable MvccCoordinator currentCoordinator(AffinityTopologyVersion topVer); - /** * @return Current coordinator node ID. */ UUID currentCoordinatorId(); - /** - * @param curCrd Coordinator. - */ - void updateCoordinator(MvccCoordinator curCrd); - /** * @param crdVer Mvcc coordinator version. * @param cntr Mvcc counter. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccProcessorImpl.java index 4651bcd767f53..c367e2b2a7044 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccProcessorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccProcessorImpl.java @@ -34,6 +34,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; @@ -48,15 +49,14 @@ import org.apache.ignite.internal.NodeStoppingException; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.managers.communication.GridMessageListener; +import org.apache.ignite.internal.managers.discovery.CustomEventListener; import org.apache.ignite.internal.managers.discovery.DiscoCache; -import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener; import org.apache.ignite.internal.processors.GridProcessorAdapter; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch; import org.apache.ignite.internal.processors.cache.DynamicCacheChangeRequest; -import org.apache.ignite.internal.processors.cache.ExchangeContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.KeyCacheObject; @@ -80,6 +80,7 @@ import org.apache.ignite.internal.processors.cache.mvcc.txlog.TxState; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.persistence.DatabaseLifecycleListener; +import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.tree.mvcc.data.MvccDataRow; @@ -107,14 +108,12 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; -import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; +import static org.apache.ignite.events.EventType.EVT_NODE_JOINED; import static org.apache.ignite.events.EventType.EVT_NODE_LEFT; -import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED; -import static org.apache.ignite.events.EventType.EVT_NODE_SEGMENTED; import static org.apache.ignite.internal.GridTopic.TOPIC_CACHE_COORDINATOR; -import static org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT; import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL; import static org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker.MVCC_TRACKER_ID_NA; import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.MVCC_COUNTER_NA; @@ -137,6 +136,10 @@ */ @SuppressWarnings("serial") public class MvccProcessorImpl extends GridProcessorAdapter implements MvccProcessor, DatabaseLifecycleListener { + /** */ + private static final boolean FORCE_MVCC = + IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, false); + /** */ private static final IgniteProductVersion MVCC_SUPPORTED_SINCE = IgniteProductVersion.fromString("2.7.0"); @@ -159,14 +162,11 @@ static void coordinatorAssignClosure(IgniteClosure, Clus } /** Topology version when local node was assigned as coordinator. */ - private long crdVer; + private volatile long crdVer; /** */ private volatile MvccCoordinator curCrd; - /** */ - private volatile MvccCoordinator assignedCrd; - /** */ private TxLog txLog; @@ -226,6 +226,9 @@ static void coordinatorAssignClosure(IgniteClosure, Clus /** Flag whether all nodes in cluster support MVCC. */ private volatile boolean mvccSupported = true; + /** Flag whether coordinator was changed by the last discovery event. */ + private volatile boolean crdChanged; + /** * Maps failed node id to votes accumulator for that node. */ @@ -242,10 +245,21 @@ public MvccProcessorImpl(GridKernalContext ctx) { /** {@inheritDoc} */ @Override public void start() throws IgniteCheckedException { - ctx.event().addLocalEventListener(new CacheCoordinatorNodeFailListener(), - EVT_NODE_FAILED, EVT_NODE_LEFT); + ctx.event().addLocalEventListener(new GridLocalEventListener() { + @Override public void onEvent(Event evt) { + onDiscovery((DiscoveryEvent)evt); + } + }, + EVT_NODE_FAILED, EVT_NODE_LEFT, EVT_NODE_JOINED); ctx.io().addMessageListener(TOPIC_CACHE_COORDINATOR, new CoordinatorMessageListener()); + + ctx.discovery().setCustomEventListener(DynamicCacheChangeBatch.class, + new CustomEventListener() { + @Override public void onCustomEvent(AffinityTopologyVersion topVer, ClusterNode snd, DynamicCacheChangeBatch msg) { + checkMvccCacheStarted(msg); + } + }); } /** {@inheritDoc} */ @@ -255,6 +269,11 @@ public MvccProcessorImpl(GridKernalContext ctx) { /** {@inheritDoc} */ @Override public void preProcessCacheConfiguration(CacheConfiguration ccfg) { + if (FORCE_MVCC && ccfg.getAtomicityMode() == TRANSACTIONAL && !CU.isSystemCache(ccfg.getName())) { + ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + ccfg.setNearConfiguration(null); + } + if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) { if (!mvccSupported) throw new IgniteException("Cannot start MVCC transactional cache. " + @@ -321,21 +340,22 @@ public MvccProcessorImpl(GridKernalContext ctx) { } /** {@inheritDoc} */ - @Override public void afterInitialise(IgniteCacheDatabaseSharedManager mgr) { - // No-op. + @Override public void beforeResumeWalLogging(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException { + // In case of blt changed we should re-init TX_LOG cache. + txLogPageStoreInit(mgr); } /** {@inheritDoc} */ - @SuppressWarnings("ConstantConditions") - @Override public void beforeMemoryRestore(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException { - assert CU.isPersistenceEnabled(ctx.config()); - assert txLog == null; + @Override public void beforeBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException { + txLogPageStoreInit(mgr); + } - ctx.cache().context().pageStore().initialize(TX_LOG_CACHE_ID, 1, - TX_LOG_CACHE_NAME, mgr.dataRegion(TX_LOG_CACHE_NAME).memoryMetrics()); + /** {@inheritDoc} */ + @Override public void afterBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr, + GridCacheDatabaseSharedManager.RestoreBinaryState restoreState) throws IgniteCheckedException { - boolean hasMvccCaches = ctx.cache().cacheGroups().stream().filter(CacheGroupContext::persistenceEnabled) - .anyMatch(g -> g.config().getAtomicityMode() == TRANSACTIONAL_SNAPSHOT); + boolean hasMvccCaches = ctx.cache().persistentCaches().stream() + .anyMatch(c -> c.cacheConfiguration().getAtomicityMode() == TRANSACTIONAL_SNAPSHOT); if (hasMvccCaches) { txLog = new TxLog(ctx, mgr); @@ -344,78 +364,183 @@ public MvccProcessorImpl(GridKernalContext ctx) { } } - /** {@inheritDoc} */ - @Override public void afterMemoryRestore(IgniteCacheDatabaseSharedManager mgr) { - // No-op. + /** + * @param mgr Database shared manager. + * @throws IgniteCheckedException If failed. + */ + private void txLogPageStoreInit(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException { + assert CU.isPersistenceEnabled(ctx.config()); + + ctx.cache().context().pageStore().initialize(TX_LOG_CACHE_ID, 1, + TX_LOG_CACHE_NAME, mgr.dataRegion(TX_LOG_CACHE_NAME).memoryMetrics()); } /** {@inheritDoc} */ - @Override public void onDiscoveryEvent(int evtType, Collection nodes, long topVer, - @Nullable DiscoveryCustomMessage customMsg) { - if (evtType == EVT_NODE_METRICS_UPDATED) - return; + @Override public void onExchangeDone(DiscoCache discoCache) { + MvccCoordinator curCrd0 = curCrd; - if (evtType == EVT_DISCOVERY_CUSTOM_EVT) - checkMvccCacheStarted(customMsg); - else - assignMvccCoordinator(evtType, nodes, topVer); + if (crdChanged) { + // Rollback all transactions with old snapshots. + ctx.cache().context().tm().rollbackMvccTxOnCoordinatorChange(); + + // Complete init future if local node is a new coordinator. All previous txs are already completed here. + if (crdVer != 0 && !initFut.isDone()) { + assert curCrd0 != null && curCrd0.nodeId().equals(ctx.localNodeId()); + + initFut.onDone(); + } + + crdChanged = false; + } + else { + if (curCrd0 != null && ctx.localNodeId().equals(curCrd0.nodeId()) && discoCache != null) + cleanupOrphanedServerTransactions(discoCache.serverNodes()); + } } /** {@inheritDoc} */ - @Override public void onExchangeStart(MvccCoordinator mvccCrd, ExchangeContext exchCtx, ClusterNode exchCrd) { - if (!exchCtx.newMvccCoordinator()) + @Override public void onLocalJoin(DiscoveryEvent evt) { + assert evt.type() == EVT_NODE_JOINED && ctx.localNodeId().equals(evt.eventNode().id()); + + onCoordinatorChanged(evt.topologyNodes(), evt.topologyVersion(), false); + } + + /** + * Discovery listener. Note: initial join event is handled by {@link MvccProcessorImpl#onLocalJoin(DiscoveryEvent)} + * method. + * + * @param evt Discovery event. + */ + private void onDiscovery(DiscoveryEvent evt) { + assert evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_JOINED; + + UUID nodeId = evt.eventNode().id(); + + MvccCoordinator curCrd0 = curCrd; + + if (evt.type() == EVT_NODE_JOINED) { + if (curCrd0 == null) // Handle join event only if coordinator has not been elected yet. + onCoordinatorChanged(evt.topologyNodes(), evt.topologyVersion(), false); + return; + } - GridLongList activeQryTrackers = collectActiveQueryTrackers(); + // Process mvcc coordinator left event on the rest nodes. + if (nodeId.equals(curCrd0.nodeId())) { + // 1. Notify all listeners waiting for a snapshot. + Map map = snapLsnrs.remove(nodeId); - exchCtx.addActiveQueries(ctx.localNodeId(), activeQryTrackers); + if (map != null) { + ClusterTopologyCheckedException ex = new ClusterTopologyCheckedException("Failed to request mvcc " + + "version, coordinator failed: " + nodeId); - if (exchCrd == null || !mvccCrd.nodeId().equals(exchCrd.id())) { - try { - sendMessage(mvccCrd.nodeId(), new MvccActiveQueriesMessage(activeQryTrackers)); + MvccSnapshotResponseListener lsnr; + + for (Long id : map.keySet()) { + if ((lsnr = map.remove(id)) != null) + lsnr.onError(ex); + } } - catch (IgniteCheckedException e) { - U.error(log, "Failed to send active queries to mvcc coordinator: " + e); + + // 2. Notify acknowledge futures. + for (WaitAckFuture fut : ackFuts.values()) + fut.onNodeLeft(nodeId); + + // 3. Process coordinator change. + onCoordinatorChanged(evt.topologyNodes(), evt.topologyVersion(), true); + } + // Process node left event on the current mvcc coordinator. + else if (curCrd0.nodeId().equals(ctx.localNodeId())) { + // 1. Notify active queries. + activeQueries.onNodeFailed(nodeId); + + // 2. Notify previous queries. + prevCrdQueries.onNodeFailed(nodeId); + + // 3. Recover transactions started by the failed node. + recoveryBallotBoxes.forEach((nearNodeId, ballotBox) -> { + // Put synthetic vote from another failed node + ballotBox.vote(nodeId); + + tryFinishRecoveryVoting(nearNodeId, ballotBox); + }); + + if (evt.eventNode().isClient()) { + RecoveryBallotBox ballotBox = recoveryBallotBoxes + .computeIfAbsent(nodeId, uuid -> new RecoveryBallotBox()); + + ballotBox + .voters(evt.topologyNodes().stream().map(ClusterNode::id).collect(Collectors.toList())); + + tryFinishRecoveryVoting(nodeId, ballotBox); } } } - /** {@inheritDoc} */ - @Override public void onExchangeDone(boolean newCrd, DiscoCache discoCache, Map activeQueries) { - if (!newCrd) { - if (curCrd != null && ctx.localNodeId().equals(curCrd.nodeId()) && discoCache != null) - cleanupOrphanedServerTransactions(discoCache.serverNodes()); + /** + * Coordinator change callback. Performs all needed actions for handling new coordinator assignment. + * + * @param nodes Cluster topology snapshot. + * @param topVer Topology version. + * @param sndQrys {@code True} if it is need to send an active queries list to the new coordinator. + */ + private void onCoordinatorChanged(Collection nodes, long topVer, boolean sndQrys) { + MvccCoordinator newCrd = pickMvccCoordinator(nodes, topVer); + if (newCrd == null) return; - } - ctx.cache().context().tm().rollbackMvccTxOnCoordinatorChange(); + // Update current coordinator, collect active queries and send it to the new coordinator if needed. + GridLongList activeQryTrackers = null; - if (ctx.localNodeId().equals(curCrd.nodeId())) { - assert ctx.localNodeId().equals(curCrd.nodeId()); + synchronized (activeTrackers) { + assert curCrd == null || newCrd.topologyVersion().compareTo(curCrd.topologyVersion()) > 0; - MvccCoordinator crd = discoCache.mvccCoordinator(); + if (sndQrys) { + activeQryTrackers = new GridLongList(); - assert crd != null; + for (MvccQueryTracker tracker : activeTrackers.values()) { + long trackerId = tracker.onMvccCoordinatorChange(newCrd); - // No need to re-initialize if coordinator version hasn't changed (e.g. it was cluster activation). - if (crdVer == crd.coordinatorVersion()) - return; + if (trackerId != MVCC_TRACKER_ID_NA) + activeQryTrackers.add(trackerId); + } + } + + curCrd = newCrd; + } + + // Send local active queries to remote coordinator, if needed. + if (!newCrd.nodeId().equals(ctx.localNodeId())) { + try { + if (sndQrys) + sendMessage(newCrd.nodeId(), new MvccActiveQueriesMessage(activeQryTrackers)); + } + catch (IgniteCheckedException e) { + U.error(log, "Failed to send active queries to mvcc coordinator: " + e); + } + } + // If a current node was elected as a new mvcc coordinator, we need to pre-initialize it. + else { + assert crdVer == 0 : crdVer; - crdVer = crd.coordinatorVersion(); + crdVer = newCrd.coordinatorVersion(); if (log.isInfoEnabled()) log.info("Initialize local node as mvcc coordinator [node=" + ctx.localNodeId() + ", crdVer=" + crdVer + ']'); - prevCrdQueries.init(activeQueries, F.view(discoCache.allNodes(), this::supportsMvcc), ctx.discovery()); + prevCrdQueries.init(activeQryTrackers, F.view(nodes, this::supportsMvcc), ctx.discovery()); - initFut.onDone(); + // Do not complete init future here, because we should wait until all old transactions become terminated. } + + crdChanged = true; } /** - * Cleans up active transacitons lost near node which is server. Executed on coordinator. + * Cleans up active transactions lost near node which is server. Executed on coordinator. + * * @param liveSrvs Live server nodes at the moment of cleanup. */ private void cleanupOrphanedServerTransactions(Collection liveSrvs) { @@ -448,24 +573,7 @@ private void cleanupOrphanedServerTransactions(Collection liveSrvs) /** {@inheritDoc} */ @Override @Nullable public MvccCoordinator currentCoordinator() { - return currentCoordinator(AffinityTopologyVersion.NONE); - } - - /** {@inheritDoc} */ - @Override @Nullable public MvccCoordinator currentCoordinator(AffinityTopologyVersion topVer) { - MvccCoordinator crd = curCrd; - - // Assert coordinator did not already change. - assert crd == null - || topVer == AffinityTopologyVersion.NONE - || crd.topologyVersion().compareTo(topVer) <= 0 : "Invalid coordinator [crd=" + crd + ", topVer=" + topVer + ']'; - - return crd; - } - - /** {@inheritDoc} */ - @Override @Nullable public MvccCoordinator assignedCoordinator() { - return assignedCrd; + return curCrd; } /** {@inheritDoc} */ @@ -475,11 +583,6 @@ private void cleanupOrphanedServerTransactions(Collection liveSrvs) return curCrd != null ? curCrd.nodeId() : null; } - /** {@inheritDoc} */ - @Override public void updateCoordinator(MvccCoordinator curCrd) { - this.curCrd = curCrd; - } - /** {@inheritDoc} */ @Override public byte state(MvccVersion ver) throws IgniteCheckedException { return state(ver.coordinatorVersion(), ver.counter()); @@ -835,51 +938,47 @@ private DataStorageConfiguration dataStorageConfiguration() { return ctx.config().getDataStorageConfiguration(); } - /** */ - private void assignMvccCoordinator(int evtType, Collection nodes, long topVer) { + /** + * Picks mvcc coordinator from the given list of nodes. + * + * @param nodes List of nodes. + * @param topVer Topology version. + * @return Chosen mvcc coordinator. + */ + private MvccCoordinator pickMvccCoordinator(Collection nodes, long topVer) { checkMvccSupported(nodes); - MvccCoordinator crd; - - if (evtType == EVT_NODE_SEGMENTED || evtType == EVT_CLIENT_NODE_DISCONNECTED) - crd = null; - else { - crd = assignedCrd; - - if (crd == null || - ((evtType == EVT_NODE_FAILED || evtType == EVT_NODE_LEFT) && !F.nodeIds(nodes).contains(crd.nodeId()))) { - ClusterNode crdNode = null; + ClusterNode crdNode = null; - if (crdC != null) { - crdNode = crdC.apply(nodes); + if (crdC != null) { + crdNode = crdC.apply(nodes); - if (log.isInfoEnabled()) - log.info("Assigned coordinator using test closure: " + crd); - } - else { - // Expect nodes are sorted by order. - for (ClusterNode node : nodes) { - if (!node.isClient() && supportsMvcc(node)) { - crdNode = node; + if (crdNode != null && log.isInfoEnabled()) + log.info("Assigned coordinator using test closure: " + crdNode.id()); + } + else { + // Expect nodes are sorted by order. + for (ClusterNode node : nodes) { + if (!node.isClient() && supportsMvcc(node)) { + crdNode = node; - break; - } - } + break; } - - crd = crdNode != null ? new MvccCoordinator(crdNode.id(), coordinatorVersion(crdNode), - new AffinityTopologyVersion(topVer, 0)) : null; - - if (log.isInfoEnabled() && crd != null) - log.info("Assigned mvcc coordinator [crd=" + crd + ", crdNode=" + crdNode + ']'); - else if (crd == null) - U.warn(log, "New mvcc coordinator was not assigned [topVer=" + topVer + ']'); } } - assignedCrd = crd; + MvccCoordinator crd = crdNode != null ? new MvccCoordinator(crdNode.id(), coordinatorVersion(crdNode), + new AffinityTopologyVersion(topVer, 0)) : null; + + if (log.isInfoEnabled() && crd != null) + log.info("Assigned mvcc coordinator [crd=" + crd + ", crdNode=" + crdNode + ']'); + else if (crd == null) + U.warn(log, "New mvcc coordinator was not assigned [topVer=" + topVer + ']'); + + return crd; } + /** * @param crdNode Assigned coordinator node. * @return Coordinator version. @@ -916,11 +1015,9 @@ private boolean supportsMvcc(ClusterNode node) { } /** */ - private void checkMvccCacheStarted(@Nullable DiscoveryCustomMessage customMsg) { - assert customMsg != null; - - if (!mvccEnabled && customMsg instanceof DynamicCacheChangeBatch) { - for (DynamicCacheChangeRequest req : ((DynamicCacheChangeBatch)customMsg).requests()) { + private void checkMvccCacheStarted(DynamicCacheChangeBatch cacheMsg) { + if (!mvccEnabled) { + for (DynamicCacheChangeRequest req : cacheMsg.requests()) { CacheConfiguration ccfg = req.startCacheConfiguration(); if (ccfg == null) @@ -935,24 +1032,6 @@ private void checkMvccCacheStarted(@Nullable DiscoveryCustomMessage customMsg) { } } - /** - * @return Active queries list. - */ - private GridLongList collectActiveQueryTrackers() { - assert curCrd != null; - - GridLongList activeQryTrackers = new GridLongList(); - - for (MvccQueryTracker tracker : activeTrackers.values()) { - long trackerId = tracker.onMvccCoordinatorChange(curCrd); - - if (trackerId != MVCC_TRACKER_ID_NA) - activeQryTrackers.add(trackerId); - } - - return activeQryTrackers; - } - /** */ private MvccSnapshotResponse assignTxSnapshot(long futId, UUID nearId, boolean client) { assert initFut.isDone(); @@ -1340,7 +1419,6 @@ private void sendFutureResponse(UUID nodeId, MvccWaitTxsRequest msg) { fut.onDone(); // No need to ack, finish without error. } else - fut.onDone(e); } } @@ -1738,63 +1816,6 @@ void onNodeLeft(UUID nodeId) { } } - /** - * - */ - private class CacheCoordinatorNodeFailListener implements GridLocalEventListener { - /** {@inheritDoc} */ - @Override public void onEvent(Event evt) { - assert evt instanceof DiscoveryEvent : evt; - - DiscoveryEvent discoEvt = (DiscoveryEvent)evt; - - UUID nodeId = discoEvt.eventNode().id(); - - Map map = snapLsnrs.remove(nodeId); - - if (map != null) { - ClusterTopologyCheckedException ex = new ClusterTopologyCheckedException("Failed to request mvcc " + - "version, coordinator failed: " + nodeId); - - MvccSnapshotResponseListener lsnr; - - for (Long id : map.keySet()) { - if ((lsnr = map.remove(id)) != null) - lsnr.onError(ex); - } - } - - for (WaitAckFuture fut : ackFuts.values()) - fut.onNodeLeft(nodeId); - - activeQueries.onNodeFailed(nodeId); - - prevCrdQueries.onNodeFailed(nodeId); - - recoveryBallotBoxes.forEach((nearNodeId, ballotBox) -> { - // Put synthetic vote from another failed node - ballotBox.vote(nodeId); - - tryFinishRecoveryVoting(nearNodeId, ballotBox); - }); - - if (discoEvt.eventNode().isClient()) { - RecoveryBallotBox ballotBox = recoveryBallotBoxes - .computeIfAbsent(nodeId, uuid -> new RecoveryBallotBox()); - - ballotBox - .voters(discoEvt.topologyNodes().stream().map(ClusterNode::id).collect(Collectors.toList())); - - tryFinishRecoveryVoting(nodeId, ballotBox); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "CacheCoordinatorDiscoveryListener[]"; - } - } - /** * */ @@ -2159,7 +2180,8 @@ private static class VacuumScheduler extends GridWorker { if (e instanceof Error) throw (Error) e; - U.error(log, "Vacuum error.", e); + if (log.isDebugEnabled()) + U.warn(log, "Failed to perform vacuum.", e); } long delay = nextScheduledTime - U.currentTimeMillis(); @@ -2418,18 +2440,21 @@ private void cleanup(GridDhtLocalPartition part, KeyCacheObject key, List) rest)) { + for (MvccDataRow row : ((List) rest)) part.dataStore().updateTxState(cctx, row); - } - } else + } + else part.dataStore().updateTxState(cctx, (MvccDataRow) rest); } - } finally { + } + finally { cctx.shared().database().checkpointReadUnlock(); } - } finally { + } + finally { entry.unlockEntry(); - cctx.evicts().touch(entry, AffinityTopologyVersion.NONE); + + cctx.evicts().touch(entry); metrics.addCleanupNanoTime(System.nanoTime() - cleanupStartNanoTime); metrics.addCleanupRowsCnt(cleaned); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccQueryTrackerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccQueryTrackerImpl.java index 7296d66817b9c..d86f5ecd64f80 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccQueryTrackerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccQueryTrackerImpl.java @@ -227,7 +227,7 @@ private MvccSnapshotResponseListener decorate(MvccSnapshotResponseListener lsnr) * @return {@code True} if topology is valid. */ private boolean checkTopology(AffinityTopologyVersion topVer, MvccSnapshotResponseListener lsnr) { - MvccCoordinator crd = cctx.affinity().mvccCoordinator(topVer); + MvccCoordinator crd = cctx.shared().coordinators().currentCoordinator(); if (crd == null) { lsnr.onError(noCoordinatorError(topVer)); @@ -241,16 +241,6 @@ private boolean checkTopology(AffinityTopologyVersion topVer, MvccSnapshotRespon crdVer = crd.coordinatorVersion(); } - MvccCoordinator curCrd = cctx.topology().mvccCoordinator(); - - if (!crd.equals(curCrd)) { - assert cctx.topology().topologyVersionFuture().initialVersion().compareTo(topVer) > 0; - - tryRemap(lsnr); - - return false; - } - return true; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java index f29e23f9036e9..c6848d35ef1aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java @@ -100,13 +100,13 @@ public class MvccUtils { /** */ public static final int MVCC_VISIBLE = 2; - /** */ + /** A special version visible by everyone */ public static final MvccVersion INITIAL_VERSION = mvccVersion(MVCC_CRD_START_CNTR, MVCC_INITIAL_CNTR, MVCC_START_OP_CNTR); - /** */ - public static final MvccVersion MVCC_VERSION_NA = - mvccVersion(MVCC_CRD_COUNTER_NA, MVCC_COUNTER_NA, MVCC_OP_COUNTER_NA); + /** A special snapshot for which all committed versions are visible */ + public static final MvccSnapshot MVCC_MAX_SNAPSHOT = + new MvccSnapshotWithoutTxs(Long.MAX_VALUE, Long.MAX_VALUE, MVCC_READ_OP_CNTR, MVCC_COUNTER_NA); /** */ private static final MvccClosure getVisibleState = new GetVisibleState(); @@ -677,6 +677,26 @@ public static GridNearTxLocal checkActive(GridNearTxLocal tx) { * @return Currently started user transaction, or {@code null} if none started. */ @Nullable public static GridNearTxLocal tx(GridKernalContext ctx, @Nullable GridCacheVersion txId) { + try { + return currentTx(ctx, txId); + } + catch (UnsupportedTxModeException e) { + throw new IgniteSQLException(e.getMessage(), IgniteQueryErrorCode.UNSUPPORTED_OPERATION); + } + catch (NonMvccTransactionException e) { + throw new IgniteSQLException(e.getMessage(), IgniteQueryErrorCode.TRANSACTION_TYPE_MISMATCH); + } + } + + /** + * @param ctx Grid kernal context. + * @param txId Transaction ID. + * @return Currently started user transaction, or {@code null} if none started. + * @throws UnsupportedTxModeException If transaction mode is not supported when MVCC is enabled. + * @throws NonMvccTransactionException If started transaction spans non MVCC caches. + */ + @Nullable public static GridNearTxLocal currentTx(GridKernalContext ctx, + @Nullable GridCacheVersion txId) throws UnsupportedTxModeException, NonMvccTransactionException { IgniteTxManager tm = ctx.cache().context().tm(); IgniteInternalTx tx0 = txId == null ? tm.tx() : tm.tx(txId); @@ -684,26 +704,22 @@ public static GridNearTxLocal checkActive(GridNearTxLocal tx) { GridNearTxLocal tx = tx0 != null && tx0.user() ? (GridNearTxLocal)tx0 : null; if (tx != null) { - if (!tx.pessimistic() || !tx.repeatableRead()) { + if (!tx.pessimistic()) { tx.setRollbackOnly(); - throw new IgniteSQLException("Only pessimistic repeatable read transactions are supported at the moment.", - IgniteQueryErrorCode.UNSUPPORTED_OPERATION); - + throw new UnsupportedTxModeException(); } if (!tx.isOperationAllowed(true)) { tx.setRollbackOnly(); - throw new IgniteSQLException("SQL queries and cache operations " + - "may not be used in the same transaction.", IgniteQueryErrorCode.TRANSACTION_TYPE_MISMATCH); + throw new NonMvccTransactionException(); } } return tx; } - /** * @param ctx Grid kernal context. * @param timeout Transaction timeout. @@ -925,4 +941,24 @@ private static class GetNewVersion implements MvccClosure { return newMvccCrd == MVCC_CRD_COUNTER_NA ? null : mvccVersion(newMvccCrd, newMvccCntr, newMvccOpCntr); } } + + /** */ + public static class UnsupportedTxModeException extends IgniteCheckedException { + /** */ + private static final long serialVersionUID = 0L; + /** */ + private UnsupportedTxModeException() { + super("Only pessimistic transactions are supported when MVCC is enabled."); + } + } + + /** */ + public static class NonMvccTransactionException extends IgniteCheckedException { + /** */ + private static final long serialVersionUID = 0L; + /** */ + private NonMvccTransactionException() { + super("Operations on MVCC caches are not permitted in transactions spanning non MVCC caches."); + } + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccAckRequestTxAndQueryId.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccAckRequestTxAndQueryId.java index 89f09db5d0b2f..f3b3150480af1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccAckRequestTxAndQueryId.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccAckRequestTxAndQueryId.java @@ -76,6 +76,7 @@ public MvccAckRequestTxAndQueryId(long futId, long txCntr, long qryTrackerId) { return false; writer.incrementState(); + } return true; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccSnapshotResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccSnapshotResponse.java index c5a849499e0df..73d3f9483981a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccSnapshotResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccSnapshotResponse.java @@ -20,6 +20,7 @@ import java.nio.ByteBuffer; import java.util.Arrays; import org.apache.ignite.internal.GridDirectTransient; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.managers.communication.GridIoMessageFactory; import org.apache.ignite.internal.processors.cache.mvcc.MvccLongList; import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; @@ -33,6 +34,7 @@ /** * */ +@IgniteCodeGeneratingFail public class MvccSnapshotResponse implements MvccMessage, MvccSnapshot, MvccLongList { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccTxSnapshotRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccTxSnapshotRequest.java index cd30eb85b88af..4cf6f65a44de4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccTxSnapshotRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/MvccTxSnapshotRequest.java @@ -81,6 +81,7 @@ public long futureId() { return false; writer.incrementState(); + } return true; @@ -101,6 +102,7 @@ public long futureId() { return false; reader.incrementState(); + } return reader.afterMessageRead(MvccTxSnapshotRequest.class); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/PartitionCountersNeighborcastRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/PartitionCountersNeighborcastRequest.java index ffd9a67edb6d1..5c46ca66a280a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/PartitionCountersNeighborcastRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/PartitionCountersNeighborcastRequest.java @@ -79,13 +79,13 @@ public IgniteUuid futId() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeIgniteUuid("futId", futId)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeCollection("updCntrs", updCntrs, MessageCollectionItemType.MSG)) return false; @@ -107,7 +107,7 @@ public IgniteUuid futId() { return false; switch (reader.state()) { - case 3: + case 4: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -115,7 +115,7 @@ public IgniteUuid futId() { reader.incrementState(); - case 4: + case 5: updCntrs = reader.readCollection("updCntrs", MessageCollectionItemType.MSG); if (!reader.isLastRead()) @@ -135,7 +135,7 @@ public IgniteUuid futId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 5; + return 6; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/PartitionCountersNeighborcastResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/PartitionCountersNeighborcastResponse.java index 547539db69ba3..2f88cde5a6fbb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/PartitionCountersNeighborcastResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/msg/PartitionCountersNeighborcastResponse.java @@ -62,7 +62,7 @@ public IgniteUuid futId() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeIgniteUuid("futId", futId)) return false; @@ -84,7 +84,7 @@ public IgniteUuid futId() { return false; switch (reader.state()) { - case 3: + case 4: futId = reader.readIgniteUuid("futId"); if (!reader.isLastRead()) @@ -104,7 +104,7 @@ public IgniteUuid futId() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 4; + return 5; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CheckpointFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CheckpointFuture.java index 1c77013d63333..767173812ba8f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CheckpointFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CheckpointFuture.java @@ -31,5 +31,5 @@ public interface CheckpointFuture { /** * @return Finish future. */ - public GridFutureAdapter finishFuture(); + public GridFutureAdapter finishFuture(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsImpl.java index 2408660d17fe9..420af3d389722 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsImpl.java @@ -481,4 +481,23 @@ public void subIntervals(int subInts) { pageReplaceRate = new HitRateMetrics((int)rateTimeInterval, subInts); pageReplaceAge = new HitRateMetrics((int)rateTimeInterval, subInts); } + + /** + * Clear metrics. + */ + public void clear() { + totalAllocatedPages.reset(); + grpAllocationTrackers.values().forEach(GroupAllocationTracker::reset); + largeEntriesPages.reset(); + dirtyPages.reset(); + readPages.reset(); + writtenPages.reset(); + replacedPages.reset(); + offHeapSize.set(0); + checkpointBufferSize.set(0); + allocRate.clear(); + evictRate.clear(); + pageReplaceRate.clear(); + pageReplaceAge.clear(); + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataStructure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataStructure.java index c23a9700046c6..610f6e638d0db 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataStructure.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataStructure.java @@ -360,7 +360,7 @@ protected final long recyclePage( boolean needWalDeltaRecord = needWalDeltaRecord(pageId, page, walPlc); - if (PageIdUtils.tag(pageId) == FLAG_DATA) { + if (PageIdUtils.flag(pageId) == FLAG_DATA) { int rotatedIdPart = PageIO.getRotatedIdPart(pageAddr); if (rotatedIdPart != 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DatabaseLifecycleListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DatabaseLifecycleListener.java index f96cdd91a7e8f..269dbd318f520 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DatabaseLifecycleListener.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DatabaseLifecycleListener.java @@ -22,33 +22,74 @@ /** * */ +@SuppressWarnings("RedundantThrows") public interface DatabaseLifecycleListener { - /** + * Callback executed when data regions become to start-up. + * * @param mgr Database shared manager. + * @throws IgniteCheckedException If failed. + */ + public default void onInitDataRegions(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException {} + + /** + * Callback executed when node detected that baseline topology is changed and node is not in that baseline. + * It's useful to cleanup and invalidate all available data restored at that moment. * + * @throws IgniteCheckedException If failed. + */ + public default void onBaselineChange() throws IgniteCheckedException {} + + /** + * Callback executed right before node become perform binary recovery. + * + * @param mgr Database shared manager. + * @throws IgniteCheckedException If failed. */ - void onInitDataRegions(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException; + public default void beforeBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException {} /** - * @param mgr Page store manager. + * Callback executed when binary memory has fully restored and WAL logging is resumed. * + * + * @param mgr Database shared manager. + * @param restoreState Result of binary recovery. + * @throws IgniteCheckedException If failed. */ - void beforeMemoryRestore(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException; + public default void afterBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr, + GridCacheDatabaseSharedManager.RestoreBinaryState restoreState) throws IgniteCheckedException {} /** + * Callback executed when all logical updates were applied and page memory become to fully consistent state. + * + * * @param mgr Database shared manager. + * @param restoreState Result of logical recovery. + * @throws IgniteCheckedException If failed. + */ + public default void afterLogicalUpdatesApplied(IgniteCacheDatabaseSharedManager mgr, + GridCacheDatabaseSharedManager.RestoreLogicalState restoreState) throws IgniteCheckedException {} + + /** + * Callback executed when all physical updates are applied and we are ready to write new physical records + * during logical recovery. * + * @param mgr Database shared manager. + * @throws IgniteCheckedException If failed. */ - void afterMemoryRestore(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException; + public default void beforeResumeWalLogging(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException {} /** + * Callback executed after all data regions are initialized. + * * @param mgr Database shared manager. */ - void afterInitialise(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException; + public default void afterInitialise(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException {} /** + * Callback executed before shared manager will be stopped. + * * @param mgr Database shared manager. */ - void beforeStop(IgniteCacheDatabaseSharedManager mgr); + public default void beforeStop(IgniteCacheDatabaseSharedManager mgr) {} } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java index da965f8ee2d8b..6199896389c9a 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java @@ -40,6 +40,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -53,10 +54,10 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import javax.management.ObjectName; import org.apache.ignite.DataStorageMetrics; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; @@ -70,8 +71,6 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.events.DiscoveryEvent; -import org.apache.ignite.events.EventType; import org.apache.ignite.failure.FailureContext; import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.GridKernalContext; @@ -82,9 +81,8 @@ import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; import org.apache.ignite.internal.mem.DirectMemoryProvider; import org.apache.ignite.internal.mem.DirectMemoryRegion; -import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider; -import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider; import org.apache.ignite.internal.pagemem.FullPageId; +import org.apache.ignite.internal.pagemem.PageIdAllocator; import org.apache.ignite.internal.pagemem.PageIdUtils; import org.apache.ignite.internal.pagemem.PageMemory; import org.apache.ignite.internal.pagemem.PageUtils; @@ -102,16 +100,17 @@ import org.apache.ignite.internal.pagemem.wal.record.MvccTxRecord; import org.apache.ignite.internal.pagemem.wal.record.PageSnapshot; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; +import org.apache.ignite.internal.pagemem.wal.record.WalRecordCacheGroupAware; import org.apache.ignite.internal.pagemem.wal.record.delta.PageDeltaRecord; import org.apache.ignite.internal.pagemem.wal.record.delta.PartitionDestroyRecord; import org.apache.ignite.internal.pagemem.wal.record.delta.PartitionMetaStateRecord; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor; import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; import org.apache.ignite.internal.processors.cache.ExchangeActions; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.StoredCacheData; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; @@ -129,17 +128,18 @@ import org.apache.ignite.internal.processors.cache.persistence.pagemem.CheckpointMetricsTracker; import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx; import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl; +import org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId; import org.apache.ignite.internal.processors.cache.persistence.partstate.PartitionAllocationMap; +import org.apache.ignite.internal.processors.cache.persistence.partstate.PartitionRecoverState; import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteCacheSnapshotManager; import org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotOperation; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO; import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer; import org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException; -import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; import org.apache.ignite.internal.processors.port.GridPortRecord; +import org.apache.ignite.internal.processors.query.GridQueryProcessor; import org.apache.ignite.internal.util.GridMultiCollectionWrapper; -import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.future.CountDownFuture; import org.apache.ignite.internal.util.future.GridCompoundFuture; @@ -156,6 +156,7 @@ import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.util.worker.GridWorker; +import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteOutClosure; @@ -170,12 +171,12 @@ import static java.nio.file.StandardOpenOption.READ; import static org.apache.ignite.IgniteSystemProperties.IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_SKIP_CRC; import static org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_WAL_REBALANCE_THRESHOLD; import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR; +import static org.apache.ignite.failure.FailureType.SYSTEM_CRITICAL_OPERATION_TIMEOUT; import static org.apache.ignite.failure.FailureType.SYSTEM_WORKER_TERMINATION; import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.CHECKPOINT_RECORD; -import static org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_ID; +import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.METASTORE_DATA_RECORD; import static org.apache.ignite.internal.util.IgniteUtils.checkpointBufferSize; /** @@ -186,15 +187,15 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan /** */ public static final String IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC = "IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC"; + /** */ + public static final String IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP = "IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP"; + /** MemoryPolicyConfiguration name reserved for meta store. */ public static final String METASTORE_DATA_REGION_NAME = "metastoreMemPlc"; /** Skip sync. */ private final boolean skipSync = IgniteSystemProperties.getBoolean(IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC); - /** */ - private boolean skipCrc = IgniteSystemProperties.getBoolean(IGNITE_PDS_SKIP_CRC, false); - /** */ private final int walRebalanceThreshold = IgniteSystemProperties.getInteger( IGNITE_PDS_WAL_REBALANCE_THRESHOLD, 500_000); @@ -203,6 +204,9 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan private final String throttlingPolicyOverride = IgniteSystemProperties.getString( IgniteSystemProperties.IGNITE_OVERRIDE_WRITE_THROTTLING_ENABLED); + /** */ + private final boolean skipCheckpointOnNodeStop = IgniteSystemProperties.getBoolean(IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP, false); + /** Checkpoint lock hold count. */ private static final ThreadLocal CHECKPOINT_LOCK_HOLD_COUNT = new ThreadLocal() { @Override protected Integer initialValue() { @@ -216,9 +220,6 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan /** Checkpoint file name pattern. */ public static final Pattern CP_FILE_NAME_PATTERN = Pattern.compile("(\\d+)-(.*)-(START|END)\\.bin"); - /** Node started file suffix. */ - public static final String NODE_STARTED_FILE_NAME_SUFFIX = "-node-started.bin"; - /** */ private static final String MBEAN_NAME = "DataStorageMetrics"; @@ -253,6 +254,9 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan /** Checkpoint thread. Needs to be volatile because it is created in exchange worker. */ private volatile Checkpointer checkpointer; + /** Checkpointer thread instance. */ + private volatile IgniteThread checkpointerThread; + /** For testing only. */ private volatile boolean checkpointsEnabled = true; @@ -260,7 +264,7 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan private volatile GridFutureAdapter enableChangeApplied; /** */ - private ReentrantReadWriteLock checkpointLock = new ReentrantReadWriteLock(); + ReentrantReadWriteLock checkpointLock = new ReentrantReadWriteLock(); /** */ private long checkpointFreq; @@ -286,6 +290,14 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan /** */ private boolean stopping; + /** + * The position of last seen WAL pointer. Used for resumming logging from this pointer. + * + * If binary memory recovery pefrormed on node start, the checkpoint END pointer will store + * not the last WAL pointer and can't be used for resumming logging. + */ + private volatile WALPointer walTail; + /** Checkpoint runner thread pool. If null tasks are to be run in single thread */ @Nullable private IgniteThreadPoolExecutor asyncRunner; @@ -319,9 +331,6 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan /** */ private DataStorageMetricsImpl persStoreMetrics; - /** */ - private ObjectName persistenceMetricsMbeanName; - /** Counter for written checkpoint pages. Not null only if checkpoint is running. */ private volatile AtomicInteger writtenPagesCntr = null; @@ -334,7 +343,10 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan /** Number of pages in current checkpoint at the beginning of checkpoint. */ private volatile int currCheckpointPagesCnt; - /** */ + /** + * MetaStorage instance. Value {@code null} means storage not initialized yet. + * Guarded by {@link GridCacheDatabaseSharedManager#checkpointReadLock()} + */ private MetaStorage metaStorage; /** */ @@ -352,6 +364,13 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan /** Timeout for checkpoint read lock acquisition in milliseconds. */ private volatile long checkpointReadLockTimeout; + /** Flag allows to log additional information about partitions during recovery phases. */ + private final boolean recoveryVerboseLogging = IgniteSystemProperties.getBoolean( + IgniteSystemProperties.IGNITE_RECOVERY_VERBOSE_LOGGING, true); + + /** Pointer to a memory recovery record that should be included into the next checkpoint record. */ + private volatile WALPointer memoryRecoveryRecordPtr; + /** * @param ctx Kernal context. */ @@ -409,6 +428,15 @@ public Checkpointer getCheckpointer() { return checkpointer; } + /** + * For test use only. + * + * @return Checkpointer thread instance. + */ + public IgniteThread checkpointerThread() { + return checkpointerThread; + } + /** * For test use only. */ @@ -430,7 +458,7 @@ public IgniteInternalFuture enableCheckpoints(boolean enable) { addDataRegion( memCfg, - createDataRegionConfiguration(memCfg), + createMetastoreDataRegionConfig(memCfg), false ); @@ -438,16 +466,19 @@ public IgniteInternalFuture enableCheckpoints(boolean enable) { } /** + * Create metastorage data region configuration with enabled persistence by default. + * * @param storageCfg Data storage configuration. * @return Data region configuration. */ - private DataRegionConfiguration createDataRegionConfiguration(DataStorageConfiguration storageCfg) { + private DataRegionConfiguration createMetastoreDataRegionConfig(DataStorageConfiguration storageCfg) { DataRegionConfiguration cfg = new DataRegionConfiguration(); cfg.setName(METASTORE_DATA_REGION_NAME); cfg.setInitialSize(storageCfg.getSystemRegionInitialSize()); cfg.setMaxSize(storageCfg.getSystemRegionMaxSize()); cfg.setPersistenceEnabled(true); + return cfg; } @@ -471,6 +502,8 @@ private DataRegionConfiguration createDataRegionConfiguration(DataStorageConfigu final GridKernalContext kernalCtx = cctx.kernalContext(); if (!kernalCtx.clientNode()) { + kernalCtx.internalSubscriptionProcessor().registerDatabaseListener(new MetastorageRecoveryLifecycle()); + checkpointer = new Checkpointer(cctx.igniteInstanceName(), "db-checkpoint-thread", log); cpHistory = new CheckpointHistory(kernalCtx); @@ -490,15 +523,7 @@ private DataRegionConfiguration createDataRegionConfiguration(DataStorageConfigu .resolveFolders() .getLockedFileLockHolder(); - fileLockHolder = preLocked == null ? - new FileLockHolder(storeMgr.workDir().getPath(), kernalCtx, log) : preLocked; - - if (log.isDebugEnabled()) - log.debug("Try to capture file lock [nodeId=" + - cctx.localNodeId() + " path=" + fileLockHolder.lockPath() + "]"); - - if (!fileLockHolder.isLocked()) - fileLockHolder.tryLock(lockWaitTime); + acquireFileLock(preLocked); cleanupTempCheckpointDirectory(); @@ -524,10 +549,48 @@ private DataRegionConfiguration createDataRegionConfiguration(DataStorageConfigu } } - /** - * Cleanup checkpoint directory. - */ + /** {@inheritDoc} */ + @Override public void cleanupRestoredCaches() { + if (dataRegionMap.isEmpty()) + return; + + for (CacheGroupDescriptor grpDesc : cctx.cache().cacheGroupDescriptors().values()) { + String regionName = grpDesc.config().getDataRegionName(); + + DataRegion region = regionName != null ? dataRegionMap.get(regionName) : dfltDataRegion; + + if (region == null) + continue; + + if (log.isInfoEnabled()) + log.info("Page memory " + region.config().getName() + " for " + grpDesc + " has invalidated."); + + int partitions = grpDesc.config().getAffinity().partitions(); + + if (region.pageMemory() instanceof PageMemoryEx) { + PageMemoryEx memEx = (PageMemoryEx)region.pageMemory(); + + for (int partId = 0; partId < partitions; partId++) + memEx.invalidate(grpDesc.groupId(), partId); + + memEx.invalidate(grpDesc.groupId(), PageIdAllocator.INDEX_PARTITION); + } + } + + storeMgr.cleanupPageStoreIfMatch( + new Predicate() { + @Override public boolean test(Integer grpId) { + return MetaStorage.METASTORAGE_CACHE_ID != grpId; + } + }, + true); + } + + /** {@inheritDoc} */ @Override public void cleanupCheckpointDirectory() throws IgniteCheckedException { + if (cpHistory != null) + cpHistory = new CheckpointHistory(cctx.kernalContext()); + try { try (DirectoryStream files = Files.newDirectoryStream(cpDir.toPath())) { for (Path path : files) @@ -539,6 +602,39 @@ private DataRegionConfiguration createDataRegionConfiguration(DataStorageConfigu } } + /** + * @param preLocked Pre-locked file lock holder. + */ + private void acquireFileLock(FileLockHolder preLocked) throws IgniteCheckedException { + if (cctx.kernalContext().clientNode()) + return; + + fileLockHolder = preLocked == null ? + new FileLockHolder(storeMgr.workDir().getPath(), cctx.kernalContext(), log) : preLocked; + + if (!fileLockHolder.isLocked()) { + if (log.isDebugEnabled()) + log.debug("Try to capture file lock [nodeId=" + + cctx.localNodeId() + " path=" + fileLockHolder.lockPath() + "]"); + + fileLockHolder.tryLock(lockWaitTime); + } + } + + /** + * + */ + private void releaseFileLock() { + if (cctx.kernalContext().clientNode() || fileLockHolder == null) + return; + + if (log.isDebugEnabled()) + log.debug("Release file lock [nodeId=" + + cctx.localNodeId() + " path=" + fileLockHolder.lockPath() + "]"); + + fileLockHolder.close(); + } + /** * Retreives checkpoint history form specified {@code dir}. * @@ -622,52 +718,36 @@ private void removeCheckpointFiles(CheckpointEntry cpEntry) throws IgniteChecked /** */ private void readMetastore() throws IgniteCheckedException { try { - DataStorageConfiguration memCfg = cctx.kernalContext().config().getDataStorageConfiguration(); - - DataRegionConfiguration plcCfg = createDataRegionConfiguration(memCfg); - - File allocPath = buildAllocPath(plcCfg); - - DirectMemoryProvider memProvider = allocPath == null ? - new UnsafeMemoryProvider(log) : - new MappedFileMemoryProvider( - log, - allocPath); - - DataRegionMetricsImpl memMetrics = new DataRegionMetricsImpl(plcCfg); - - PageMemoryEx storePageMem = (PageMemoryEx)createPageMemory(memProvider, memCfg, plcCfg, memMetrics, false); - - DataRegion regCfg = new DataRegion(storePageMem, plcCfg, memMetrics, createPageEvictionTracker(plcCfg, storePageMem)); - CheckpointStatus status = readCheckpointStatus(); - cctx.pageStore().initializeForMetastorage(); - - storePageMem.start(); - checkpointReadLock(); try { - restoreMemory(status, true, storePageMem); + dataRegion(METASTORE_DATA_REGION_NAME).pageMemory().start(); - metaStorage = new MetaStorage(cctx, regCfg, memMetrics, true); + performBinaryMemoryRestore(status, onlyMetastorageGroup(), physicalRecords(), false); - metaStorage.init(this); + metaStorage = createMetastorage(true); - applyLastUpdates(status, true); + applyLogicalUpdates(status, onlyMetastorageGroup(), onlyMetastorageRecords(), false); fillWalDisabledGroups(); notifyMetastorageReadyForRead(); } finally { - checkpointReadUnlock(); - } + metaStorage = null; + + dataRegion(METASTORE_DATA_REGION_NAME).pageMemory().stop(false); - metaStorage = null; + cctx.pageStore().cleanupPageStoreIfMatch(new Predicate() { + @Override public boolean test(Integer grpId) { + return MetaStorage.METASTORAGE_CACHE_ID == grpId; + } + }, false); - storePageMem.stop(true); + checkpointReadUnlock(); + } } catch (StorageException e) { cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); @@ -684,16 +764,16 @@ private void readMetastore() throws IgniteCheckedException { snapshotMgr = cctx.snapshot(); - if (!cctx.localNode().isClient()) { - initDataBase(); - - registrateMetricsMBean(); - } - - if (checkpointer == null) + if (!cctx.kernalContext().clientNode() && checkpointer == null) checkpointer = new Checkpointer(cctx.igniteInstanceName(), "db-checkpoint-thread", log); super.onActivate(ctx); + + if (!cctx.kernalContext().clientNode()) { + initializeCheckpointPool(); + + finishRecovery(); + } } /** {@inheritDoc} */ @@ -713,7 +793,7 @@ private void readMetastore() throws IgniteCheckedException { /** * */ - private void initDataBase() { + private void initializeCheckpointPool() { if (persistenceCfg.getCheckpointThreads() > 1) asyncRunner = new IgniteThreadPoolExecutor( CHECKPOINT_RUNNER_THREAD_PREFIX, @@ -725,46 +805,17 @@ private void initDataBase() { ); } - /** - * Try to register Metrics MBean. - * - * @throws IgniteCheckedException If failed. - */ - private void registrateMetricsMBean() throws IgniteCheckedException { - if (U.IGNITE_MBEANS_DISABLED) - return; - - try { - persistenceMetricsMbeanName = U.registerMBean( - cctx.kernalContext().config().getMBeanServer(), - cctx.kernalContext().igniteInstanceName(), - MBEAN_GROUP, - MBEAN_NAME, - persStoreMetrics, - DataStorageMetricsMXBean.class); - } - catch (Throwable e) { - throw new IgniteCheckedException("Failed to register " + MBEAN_NAME + " MBean.", e); - } - } - - /** - * Unregister metrics MBean. - */ - private void unRegistrateMetricsMBean() { - if (persistenceMetricsMbeanName == null) - return; - - assert !U.IGNITE_MBEANS_DISABLED; - - try { - cctx.kernalContext().config().getMBeanServer().unregisterMBean(persistenceMetricsMbeanName); - - persistenceMetricsMbeanName = null; - } - catch (Throwable e) { - U.error(log, "Failed to unregister " + MBEAN_NAME + " MBean.", e); - } + /** {@inheritDoc} */ + @Override protected void registerMetricsMBeans(IgniteConfiguration cfg) { + super.registerMetricsMBeans(cfg); + + registerMetricsMBean( + cctx.kernalContext().config(), + MBEAN_GROUP, + MBEAN_NAME, + persStoreMetrics, + DataStorageMetricsMXBean.class + ); } /** {@inheritDoc} */ @@ -792,11 +843,14 @@ private void unRegistrateMetricsMBean() { }; } - /** {@inheritDoc} */ - @Override public void readCheckpointAndRestoreMemory( - List cachesToStart - ) throws IgniteCheckedException { - assert !cctx.localNode().isClient(); + /** + * Restores last valid WAL pointer and resumes logging from that pointer. + * Re-creates metastorage if needed. + * + * @throws IgniteCheckedException If failed. + */ + private void finishRecovery() throws IgniteCheckedException { + assert !cctx.kernalContext().clientNode(); long time = System.currentTimeMillis(); @@ -804,50 +858,26 @@ private void unRegistrateMetricsMBean() { try { for (DatabaseLifecycleListener lsnr : getDatabaseListeners(cctx.kernalContext())) - lsnr.beforeMemoryRestore(this); - - if (!F.isEmpty(cachesToStart)) { - for (DynamicCacheDescriptor desc : cachesToStart) { - if (CU.affinityNode(cctx.localNode(), desc.cacheConfiguration().getNodeFilter())) - storeMgr.initializeForCache(desc.groupDescriptor(), new StoredCacheData(desc.cacheConfiguration())); - } - } - - CheckpointStatus status = readCheckpointStatus(); - - cctx.pageStore().initializeForMetastorage(); + lsnr.beforeResumeWalLogging(this); - metaStorage = new MetaStorage( - cctx, - dataRegionMap.get(METASTORE_DATA_REGION_NAME), - (DataRegionMetricsImpl)memMetricsMap.get(METASTORE_DATA_REGION_NAME) - ); + // Try to resume logging since last finished checkpoint if possible. + if (walTail == null) { + CheckpointStatus status = readCheckpointStatus(); - WALPointer restore = restoreMemory(status); - - if (restore == null && !status.endPtr.equals(CheckpointStatus.NULL_PTR)) { - throw new StorageException("Restore wal pointer = " + restore + ", while status.endPtr = " + - status.endPtr + ". Can't restore memory - critical part of WAL archive is missing."); + walTail = CheckpointStatus.NULL_PTR.equals(status.endPtr) ? null : status.endPtr; } - // First, bring memory to the last consistent checkpoint state if needed. - // This method should return a pointer to the last valid record in the WAL. - cctx.wal().resumeLogging(restore); + cctx.wal().resumeLogging(walTail); - WALPointer ptr = cctx.wal().log(new MemoryRecoveryRecord(U.currentTimeMillis())); + walTail = null; - if (ptr != null) { - cctx.wal().flush(ptr, true); - - nodeStart(ptr); - } - - metaStorage.init(this); + // Recreate metastorage to refresh page memory state after deactivation. + if (metaStorage == null) + metaStorage = createMetastorage(false); notifyMetastorageReadyForReadWrite(); - for (DatabaseLifecycleListener lsnr : getDatabaseListeners(cctx.kernalContext())) - lsnr.afterMemoryRestore(this); + U.log(log, "Finish recovery performed in " + (System.currentTimeMillis() - time) + " ms."); } catch (IgniteCheckedException e) { if (X.hasCause(e, StorageException.class, IOException.class)) @@ -857,103 +887,88 @@ private void unRegistrateMetricsMBean() { } finally { checkpointReadUnlock(); - - if (log.isInfoEnabled()) - log.info("Binary recovery performed in " + (System.currentTimeMillis() - time) + " ms."); } } /** - * Creates file with current timestamp and specific "node-started.bin" suffix - * and writes into memory recovery pointer. - * - * @param ptr Memory recovery wal pointer. + * @param readOnly Metastorage read-only mode. + * @return Instance of Metastorage. + * @throws IgniteCheckedException If failed to create metastorage. */ - private void nodeStart(WALPointer ptr) throws IgniteCheckedException { - FileWALPointer p = (FileWALPointer)ptr; - - String fileName = U.currentTimeMillis() + NODE_STARTED_FILE_NAME_SUFFIX; - String tmpFileName = fileName + FilePageStoreManager.TMP_SUFFIX; - - ByteBuffer buf = ByteBuffer.allocate(FileWALPointer.POINTER_SIZE); - buf.order(ByteOrder.nativeOrder()); - - try { - try (FileIO io = ioFactory.create(Paths.get(cpDir.getAbsolutePath(), tmpFileName).toFile(), - StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE)) { - buf.putLong(p.index()); - - buf.putInt(p.fileOffset()); - - buf.putInt(p.length()); - - buf.flip(); - - io.writeFully(buf); + private MetaStorage createMetastorage(boolean readOnly) throws IgniteCheckedException { + cctx.pageStore().initializeForMetastorage(); - buf.clear(); + MetaStorage storage = new MetaStorage( + cctx, + dataRegion(METASTORE_DATA_REGION_NAME), + (DataRegionMetricsImpl) memMetricsMap.get(METASTORE_DATA_REGION_NAME), + readOnly + ); - io.force(true); - } + storage.init(this); - Files.move(Paths.get(cpDir.getAbsolutePath(), tmpFileName), Paths.get(cpDir.getAbsolutePath(), fileName)); - } - catch (IOException e) { - throw new StorageException("Failed to write node start marker: " + ptr, e); - } + return storage; } /** - * Collects memory recovery pointers from node started files. See {@link #nodeStart(WALPointer)}. - * Each pointer associated with timestamp extracted from file. - * Tuples are sorted by timestamp. - * - * @return Sorted list of tuples (node started timestamp, memory recovery pointer). - * + * @param cacheGroupsPredicate Cache groups to restore. + * @param recordTypePredicate Filter records by type. + * @return Last seen WAL pointer during binary memory recovery. * @throws IgniteCheckedException If failed. */ - public List> nodeStartedPointers() throws IgniteCheckedException { - List> res = new ArrayList<>(); + private RestoreBinaryState restoreBinaryMemory( + IgnitePredicate cacheGroupsPredicate, + IgniteBiPredicate recordTypePredicate + ) throws IgniteCheckedException { + long time = System.currentTimeMillis(); - try (DirectoryStream nodeStartedFiles = Files.newDirectoryStream( - cpDir.toPath(), - path -> path.toFile().getName().endsWith(NODE_STARTED_FILE_NAME_SUFFIX)) - ) { - ByteBuffer buf = ByteBuffer.allocate(FileWALPointer.POINTER_SIZE); - buf.order(ByteOrder.nativeOrder()); + try { + log.info("Starting binary memory restore for: " + cctx.cache().cacheGroupDescriptors().keySet()); - for (Path path : nodeStartedFiles) { - File f = path.toFile(); + for (DatabaseLifecycleListener lsnr : getDatabaseListeners(cctx.kernalContext())) + lsnr.beforeBinaryMemoryRestore(this); - String name = f.getName(); + CheckpointStatus status = readCheckpointStatus(); - Long ts = Long.valueOf(name.substring(0, name.length() - NODE_STARTED_FILE_NAME_SUFFIX.length())); + // First, bring memory to the last consistent checkpoint state if needed. + // This method should return a pointer to the last valid record in the WAL. + RestoreBinaryState binaryState = performBinaryMemoryRestore( + status, + cacheGroupsPredicate, + recordTypePredicate, + true + ); - try (FileIO io = ioFactory.create(f, READ)) { - io.readFully(buf); + WALPointer restored = binaryState.lastReadRecordPointer().map(FileWALPointer::next).orElse(null); - buf.flip(); + if (restored == null && !status.endPtr.equals(CheckpointStatus.NULL_PTR)) { + throw new StorageException("The memory cannot be restored. The critical part of WAL archive is missing " + + "[tailWalPtr=" + restored + ", endPtr=" + status.endPtr + ']'); + } + else if (restored != null) + U.log(log, "Binary memory state restored at node startup [restoredPtr=" + restored + ']'); - FileWALPointer ptr = new FileWALPointer( - buf.getLong(), buf.getInt(), buf.getInt()); + // Wal logging is now available. + cctx.wal().resumeLogging(restored); - res.add(new T2<>(ts, ptr)); + // Log MemoryRecoveryRecord to make sure that old physical records are not replayed during + // next physical recovery. + memoryRecoveryRecordPtr = cctx.wal().log(new MemoryRecoveryRecord(U.currentTimeMillis())); - buf.clear(); - } - catch (IOException e) { - throw new StorageException("Failed to read node started marker file: " + f.getAbsolutePath(), e); - } - } - } - catch (IOException e) { - throw new StorageException("Failed to retreive node started files.", e); - } + for (DatabaseLifecycleListener lsnr : getDatabaseListeners(cctx.kernalContext())) + lsnr.afterBinaryMemoryRestore(this, binaryState); - // Sort start markers by file timestamp. - res.sort(Comparator.comparingLong(IgniteBiTuple::get1)); + if (log.isInfoEnabled()) + log.info("Binary recovery performed in " + (System.currentTimeMillis() - time) + " ms."); - return res; + return binaryState; + } + catch (IgniteCheckedException e) { + if (X.hasCause(e, StorageException.class, IOException.class)) + cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); + + throw e; + } } /** {@inheritDoc} */ @@ -973,22 +988,20 @@ public List> nodeStartedPointers() throws IgniteCheckedExce super.onKernalStop0(cancel); - unRegistrateMetricsMBean(); + unregisterMetricsMBean( + cctx.gridConfig(), + MBEAN_GROUP, + MBEAN_NAME + ); + + metaStorage = null; } /** {@inheritDoc} */ @Override protected void stop0(boolean cancel) { super.stop0(cancel); - if (!cctx.kernalContext().clientNode()) { - if (fileLockHolder != null) { - if (log.isDebugEnabled()) - log.debug("Release file lock [nodeId=" + - cctx.localNodeId() + " path=" + fileLockHolder.lockPath() + "]"); - - fileLockHolder.close(); - } - } + releaseFileLock(); } /** */ @@ -1065,13 +1078,11 @@ private long[] calculateFragmentSizes(int concLvl, long cacheSize, long chpBufSi (fullId, pageBuf, tag) -> { memMetrics.onPageWritten(); - // First of all, write page to disk. - storeMgr.write(fullId.groupId(), fullId.pageId(), pageBuf, tag); - - pageBuf.rewind(); + // We can write only page from disk into snapshot. + snapshotMgr.beforePageWrite(fullId); - // Only after write we can write page into snapshot. - snapshotMgr.flushDirtyPageHandler(fullId, pageBuf, tag); + // Write page to disk. + storeMgr.write(fullId.groupId(), fullId.pageId(), pageBuf, tag); AtomicInteger cntr = evictedPagesCntr; @@ -1148,8 +1159,9 @@ private long[] calculateFragmentSizes(int concLvl, long cacheSize, long chpBufSi plc = PageMemoryImpl.ThrottlingPolicy.valueOf(throttlingPolicyOverride.toUpperCase()); } catch (IllegalArgumentException e) { - log.error("Incorrect value of IGNITE_OVERRIDE_WRITE_THROTTLING_ENABLED property: " + - throttlingPolicyOverride + ". Default throttling policy " + plc + " will be used."); + log.error("Incorrect value of IGNITE_OVERRIDE_WRITE_THROTTLING_ENABLED property. " + + "The default throttling policy will be used [plc=" + throttlingPolicyOverride + + ", defaultPlc=" + plc + ']'); } } return plc; @@ -1161,8 +1173,8 @@ private long[] calculateFragmentSizes(int concLvl, long cacheSize, long chpBufSi if (!regCfg.isPersistenceEnabled()) super.checkRegionEvictionProperties(regCfg, dbCfg); else if (regCfg.getPageEvictionMode() != DataPageEvictionMode.DISABLED) { - U.warn(log, "Page eviction mode set for [" + regCfg.getName() + "] data will have no effect" + - " because the oldest pages are evicted automatically if Ignite persistence is enabled."); + U.warn(log, "Page eviction mode will have no effect because the oldest pages are evicted automatically " + + "if Ignite persistence is enabled: " + regCfg.getName()); } } @@ -1282,34 +1294,37 @@ private void shutdownCheckpointer(boolean cancel) { } /** {@inheritDoc} */ - @Override public boolean beforeExchange(GridDhtPartitionsExchangeFuture fut) throws IgniteCheckedException { - DiscoveryEvent discoEvt = fut.firstEvent(); - - boolean joinEvt = discoEvt.type() == EventType.EVT_NODE_JOINED; - - boolean locNode = discoEvt.eventNode().isLocal(); - - boolean isSrvNode = !cctx.kernalContext().clientNode(); + @Override public void beforeExchange(GridDhtPartitionsExchangeFuture fut) throws IgniteCheckedException { + // Try to restore partition states. + if (fut.localJoinExchange() || fut.activateCluster() + || (fut.exchangeActions() != null && !F.isEmpty(fut.exchangeActions().cacheGroupsToStart()))) { + U.doInParallel( + cctx.kernalContext().getSystemExecutorService(), + cctx.cache().cacheGroups(), + cacheGroup -> { + if (cacheGroup.isLocal()) + return null; - boolean clusterInTransitionStateToActive = fut.activateCluster(); + cctx.database().checkpointReadLock(); - boolean restored = false; + try { + cacheGroup.offheap().restorePartitionStates(Collections.emptyMap()); - long time = System.currentTimeMillis(); + if (cacheGroup.localStartVersion().equals(fut.initialVersion())) + cacheGroup.topology().afterStateRestored(fut.initialVersion()); - // In case of cluster activation or local join restore, restore whole manager state. - if (clusterInTransitionStateToActive || (joinEvt && locNode && isSrvNode)) { - restoreState(); + fut.timeBag().finishLocalStage("Restore partition states " + + "[grp=" + cacheGroup.cacheOrGroupName() + "]"); + } + finally { + cctx.database().checkpointReadUnlock(); + } - restored = true; - } - // In case of starting groups, restore partition states only for these groups. - else if (fut.exchangeActions() != null && !F.isEmpty(fut.exchangeActions().cacheGroupsToStart())) { - Set restoreGroups = fut.exchangeActions().cacheGroupsToStart().stream() - .map(actionData -> actionData.descriptor().groupId()) - .collect(Collectors.toSet()); + return null; + } + ); - restorePartitionStates(Collections.emptyMap(), restoreGroups); + fut.timeBag().finishGlobalStage("Restore partition states"); } if (cctx.kernalContext().query().moduleEnabled()) { @@ -1326,11 +1341,6 @@ else if (acts.localJoinContext() != null && !F.isEmpty(acts.localJoinContext().c } } } - - if (log.isInfoEnabled()) - log.info("Logical recovery performed in " + (System.currentTimeMillis() - time) + " ms."); - - return restored; } /** @@ -1350,16 +1360,19 @@ private void prepareIndexRebuildFuture(int cacheId) { /** {@inheritDoc} */ @Override public void rebuildIndexesIfNeeded(GridDhtPartitionsExchangeFuture fut) { - if (cctx.kernalContext().query().moduleEnabled()) { + GridQueryProcessor qryProc = cctx.kernalContext().query(); + + if (qryProc.moduleEnabled()) { for (final GridCacheContext cacheCtx : (Collection)cctx.cacheContexts()) { if (cacheCtx.startTopologyVersion().equals(fut.initialVersion())) { final int cacheId = cacheCtx.cacheId(); final GridFutureAdapter usrFut = idxRebuildFuts.get(cacheId); - if (!cctx.pageStore().hasIndexStore(cacheCtx.groupId()) && cacheCtx.affinityNode() - && cacheCtx.group().persistenceEnabled()) { - IgniteInternalFuture rebuildFut = cctx.kernalContext().query() - .rebuildIndexesFromHash(Collections.singleton(cacheCtx.cacheId())); + IgniteInternalFuture rebuildFut = qryProc.rebuildIndexesFromHash(cacheCtx); + + if (rebuildFut != null) { + log().info("Started indexes rebuilding for cache [name=" + cacheCtx.name() + + ", grpName=" + cacheCtx.group().name() + ']'); assert usrFut != null : "Missing user future for cache: " + cacheCtx.name(); @@ -1442,14 +1455,12 @@ private void prepareIndexRebuildFuture(int cacheId) { for (IgniteBiTuple tup : stoppedGrps) { CacheGroupContext grp = tup.get1(); - if (grp.affinityNode()) { - try { - cctx.pageStore().shutdownForCacheGroup(grp, tup.get2()); - } - catch (IgniteCheckedException e) { - U.error(log, "Failed to gracefully clean page store resources for destroyed cache " + - "[cache=" + grp.cacheOrGroupName() + "]", e); - } + try { + cctx.pageStore().shutdownForCacheGroup(grp, tup.get2()); + } + catch (IgniteCheckedException e) { + U.error(log, "Failed to gracefully clean page store resources for destroyed cache " + + "[cache=" + grp.cacheOrGroupName() + "]", e); } } } @@ -1545,7 +1556,7 @@ private void failCheckpointReadLock() throws CheckpointReadLockTimeoutException, IgniteException e = new IgniteException(msg); - if (cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, e))) + if (cctx.kernalContext().failure().process(new FailureContext(SYSTEM_CRITICAL_OPERATION_TIMEOUT, e))) throw e; throw new CheckpointReadLockTimeoutException(msg); @@ -1613,52 +1624,6 @@ private boolean safeToUpdatePageMemories() { CHECKPOINT_LOCK_HOLD_COUNT.set(CHECKPOINT_LOCK_HOLD_COUNT.get() - 1); } - /** - * Restores from last checkpoint and applies WAL changes since this checkpoint. - * - * @throws IgniteCheckedException If failed to restore database status from WAL. - */ - private void restoreState() throws IgniteCheckedException { - try { - CheckpointStatus status = readCheckpointStatus(); - - checkpointReadLock(); - - try { - applyLastUpdates(status, false); - } - finally { - checkpointReadUnlock(); - } - - snapshotMgr.restoreState(); - } - catch (StorageException e) { - throw new IgniteCheckedException(e); - } - } - - /** - * Called when all partitions have been fully restored and pre-created on node start. - * - * Starts checkpointing process and initiates first checkpoint. - * - * @throws IgniteCheckedException If first checkpoint has failed. - */ - @Override public void onStateRestored() throws IgniteCheckedException { - long time = System.currentTimeMillis(); - - new IgniteThread(cctx.igniteInstanceName(), "db-checkpoint-thread", checkpointer).start(); - - CheckpointProgressSnapshot chp = checkpointer.wakeupForCheckpoint(0, "node started"); - - if (chp != null) - chp.cpBeginFut.get(); - - if (log.isInfoEnabled()) - log.info("Checkpointer initilialzation performed in " + (System.currentTimeMillis() - time) + " ms."); - } - /** {@inheritDoc} */ @Override public synchronized Map> reserveHistoryForExchange() { assert reservedForExchange == null : reservedForExchange; @@ -1768,16 +1733,7 @@ private Map> partitionsApplicableForWalRebalance() { if (ptr == null) return false; - boolean reserved; - - try { - reserved = cctx.wal().reserve(ptr); - } - catch (IgniteCheckedException e) { - U.error(log, "Error while trying to reserve history", e); - - reserved = false; - } + boolean reserved = cctx.wal().reserve(ptr); if (reserved) reservedForPreloading.put(new T2<>(grpId, partId), new T2<>(cntr, ptr)); @@ -1961,40 +1917,144 @@ private WALPointer readPointer(File cpMarkerFile, ByteBuffer buf) throws IgniteC } } + /** {@inheritDoc} */ + @Override public void startMemoryRestore(GridKernalContext kctx) throws IgniteCheckedException { + if (kctx.clientNode()) + return; + + checkpointReadLock(); + + try { + // Preform early regions startup before restoring state. + initAndStartRegions(kctx.config().getDataStorageConfiguration()); + + // Restore binary memory for all not WAL disabled cache groups. + restoreBinaryMemory( + groupsWithEnabledWal(), + physicalRecords() + ); + + if (recoveryVerboseLogging && log.isInfoEnabled()) { + log.info("Partition states information after BINARY RECOVERY phase:"); + + dumpPartitionsInfo(cctx, log); + } + + CheckpointStatus status = readCheckpointStatus(); + + RestoreLogicalState logicalState = applyLogicalUpdates( + status, + groupsWithEnabledWal(), + logicalRecords(), + true + ); + + if (recoveryVerboseLogging && log.isInfoEnabled()) { + log.info("Partition states information after LOGICAL RECOVERY phase:"); + + dumpPartitionsInfo(cctx, log); + } + + walTail = tailPointer(logicalState.lastReadRecordPointer().orElse(null)); + + cctx.wal().onDeActivate(kctx); + } + catch (IgniteCheckedException e) { + releaseFileLock(); + + throw e; + } + finally { + checkpointReadUnlock(); + } + } + /** - * @param status Checkpoint status. + * Calculates tail pointer for WAL at the end of logical recovery. + * + * @param from Start replay WAL from. + * @return Tail pointer. * @throws IgniteCheckedException If failed. - * @throws StorageException In case I/O error occurred during operations with storage. */ - @Nullable private WALPointer restoreMemory(CheckpointStatus status) throws IgniteCheckedException { - return restoreMemory(status, false, (PageMemoryEx)metaStorage.pageMemory()); + private WALPointer tailPointer(WALPointer from) throws IgniteCheckedException { + WALIterator it = cctx.wal().replay(from); + + try { + while (it.hasNextX()) { + IgniteBiTuple rec = it.nextX(); + + if (rec == null) + break; + } + } + finally { + it.close(); + } + + return it.lastRead().map(WALPointer::next).orElse(null); + } + + /** + * Called when all partitions have been fully restored and pre-created on node start. + * + * Starts checkpointing process and initiates first checkpoint. + * + * @throws IgniteCheckedException If first checkpoint has failed. + */ + @Override public void onStateRestored(AffinityTopologyVersion topVer) throws IgniteCheckedException { + IgniteThread cpThread = new IgniteThread(cctx.igniteInstanceName(), "db-checkpoint-thread", checkpointer); + + cpThread.start(); + + checkpointerThread = cpThread; + + CheckpointProgressSnapshot chp = checkpointer.wakeupForCheckpoint(0, "node started"); + + if (chp != null) + chp.cpBeginFut.get(); } /** * @param status Checkpoint status. - * @param metastoreOnly If {@code True} restores Metastorage only. - * @param storePageMem Metastore page memory. + * @param cacheGroupsPredicate Cache groups to restore. * @throws IgniteCheckedException If failed. * @throws StorageException In case I/O error occurred during operations with storage. */ - @Nullable private WALPointer restoreMemory( + private RestoreBinaryState performBinaryMemoryRestore( CheckpointStatus status, - boolean metastoreOnly, - PageMemoryEx storePageMem + IgnitePredicate cacheGroupsPredicate, + IgniteBiPredicate recordTypePredicate, + boolean finalizeState ) throws IgniteCheckedException { - assert !metastoreOnly || storePageMem != null; - if (log.isInfoEnabled()) log.info("Checking memory state [lastValidPos=" + status.endPtr + ", lastMarked=" + status.startPtr + ", lastCheckpointId=" + status.cpStartId + ']'); + WALPointer recPtr = status.endPtr; + boolean apply = status.needRestoreMemory(); if (apply) { - U.quietAndWarn(log, "Ignite node stopped in the middle of checkpoint. Will restore memory state and " + - "finish checkpoint on node start."); + if (finalizeState) + U.quietAndWarn(log, "Ignite node stopped in the middle of checkpoint. Will restore memory state and " + + "finish checkpoint on node start."); cctx.pageStore().beginRecover(); + + WALRecord rec = cctx.wal().read(status.startPtr); + + if (!(rec instanceof CheckpointRecord)) + throw new StorageException("Checkpoint marker doesn't point to checkpoint record " + + "[ptr=" + status.startPtr + ", rec=" + rec + "]"); + + WALPointer cpMark = ((CheckpointRecord)rec).checkpointMark(); + + if (cpMark != null) { + log.info("Restoring checkpoint after logical recovery, will start physical recovery from " + + "back pointer: " + cpMark); + + recPtr = cpMark; + } } else cctx.wal().notchLastCheckpointPtr(status.startPtr); @@ -2003,16 +2063,15 @@ private WALPointer readPointer(File cpMarkerFile, ByteBuffer buf) throws IgniteC long lastArchivedSegment = cctx.wal().lastArchivedSegment(); - RestoreBinaryState restoreBinaryState = new RestoreBinaryState(status, lastArchivedSegment, log); + WALIterator it = cctx.wal().replay(recPtr, recordTypePredicate); - Collection ignoreGrps = metastoreOnly ? Collections.emptySet() : - F.concat(false, initiallyGlobalWalDisabledGrps, initiallyLocalWalDisabledGrps); + RestoreBinaryState restoreBinaryState = new RestoreBinaryState(status, it, lastArchivedSegment, cacheGroupsPredicate); int applied = 0; - try (WALIterator it = cctx.wal().replay(status.endPtr)) { + try { while (it.hasNextX()) { - WALRecord rec = restoreBinaryState.next(it); + WALRecord rec = restoreBinaryState.next(); if (rec == null) break; @@ -2026,32 +2085,30 @@ private WALPointer readPointer(File cpMarkerFile, ByteBuffer buf) throws IgniteC // several repetitive restarts and the same pages may have changed several times. int grpId = pageRec.fullPageId().groupId(); - if (metastoreOnly && grpId != METASTORAGE_CACHE_ID) - continue; + long pageId = pageRec.fullPageId().pageId(); - if (!ignoreGrps.contains(grpId)) { - long pageId = pageRec.fullPageId().pageId(); + PageMemoryEx pageMem = getPageMemoryForCacheGroup(grpId); - PageMemoryEx pageMem = grpId == METASTORAGE_CACHE_ID ? storePageMem : getPageMemoryForCacheGroup(grpId); + if (pageMem == null) + break; - long page = pageMem.acquirePage(grpId, pageId, true); + long page = pageMem.acquirePage(grpId, pageId, true); - try { - long pageAddr = pageMem.writeLock(grpId, pageId, page); + try { + long pageAddr = pageMem.writeLock(grpId, pageId, page, true); - try { - PageUtils.putBytes(pageAddr, 0, pageRec.pageData()); - } - finally { - pageMem.writeUnlock(grpId, pageId, page, null, true, true); - } + try { + PageUtils.putBytes(pageAddr, 0, pageRec.pageData()); } finally { - pageMem.releasePage(grpId, pageId, page); + pageMem.writeUnlock(grpId, pageId, page, null, true, true); } - - applied++; } + finally { + pageMem.releasePage(grpId, pageId, page); + } + + applied++; } break; @@ -2062,12 +2119,6 @@ private WALPointer readPointer(File cpMarkerFile, ByteBuffer buf) throws IgniteC { int grpId = metaStateRecord.groupId(); - if (metastoreOnly && grpId != METASTORAGE_CACHE_ID) - continue; - - if (ignoreGrps.contains(grpId)) - continue; - int partId = metaStateRecord.partitionId(); GridDhtPartitionState state = GridDhtPartitionState.fromOrdinal(metaStateRecord.state()); @@ -2086,13 +2137,10 @@ private WALPointer readPointer(File cpMarkerFile, ByteBuffer buf) throws IgniteC { int grpId = destroyRecord.groupId(); - if (metastoreOnly && grpId != METASTORAGE_CACHE_ID) - continue; - - if (ignoreGrps.contains(grpId)) - continue; + PageMemoryEx pageMem = getPageMemoryForCacheGroup(grpId); - PageMemoryEx pageMem = grpId == METASTORAGE_CACHE_ID ? storePageMem : getPageMemoryForCacheGroup(grpId); + if (pageMem == null) + break; pageMem.invalidate(grpId, destroyRecord.partitionId()); @@ -2107,43 +2155,44 @@ private WALPointer readPointer(File cpMarkerFile, ByteBuffer buf) throws IgniteC int grpId = r.groupId(); - if (metastoreOnly && grpId != METASTORAGE_CACHE_ID) - continue; + long pageId = r.pageId(); - if (!ignoreGrps.contains(grpId)) { - long pageId = r.pageId(); + PageMemoryEx pageMem = getPageMemoryForCacheGroup(grpId); - PageMemoryEx pageMem = grpId == METASTORAGE_CACHE_ID ? storePageMem : getPageMemoryForCacheGroup(grpId); + if (pageMem == null) + break; - // Here we do not require tag check because we may be applying memory changes after - // several repetitive restarts and the same pages may have changed several times. - long page = pageMem.acquirePage(grpId, pageId, true); + // Here we do not require tag check because we may be applying memory changes after + // several repetitive restarts and the same pages may have changed several times. + long page = pageMem.acquirePage(grpId, pageId, true); - try { - long pageAddr = pageMem.writeLock(grpId, pageId, page); + try { + long pageAddr = pageMem.writeLock(grpId, pageId, page, true); - try { - r.applyDelta(pageMem, pageAddr); - } - finally { - pageMem.writeUnlock(grpId, pageId, page, null, true, true); - } + try { + r.applyDelta(pageMem, pageAddr); } finally { - pageMem.releasePage(grpId, pageId, page); + pageMem.writeUnlock(grpId, pageId, page, null, true, true); } - - applied++; } + finally { + pageMem.releasePage(grpId, pageId, page); + } + + applied++; } } } } + finally { + it.close(); + } - if (metastoreOnly) + if (!finalizeState) return null; - WALPointer lastReadPtr = restoreBinaryState.lastReadRecordPointer(); + FileWALPointer lastReadPtr = restoreBinaryState.lastReadRecordPointer().orElse(null); if (status.needRestoreMemory()) { if (restoreBinaryState.needApplyBinaryUpdate()) @@ -2152,7 +2201,7 @@ private WALPointer readPointer(File cpMarkerFile, ByteBuffer buf) throws IgniteC "[cpStatus=" + status + ", lastRead=" + lastReadPtr + "]"); log.info("Finished applying memory changes [changesApplied=" + applied + - ", time=" + (U.currentTimeMillis() - start) + "ms]"); + ", time=" + (U.currentTimeMillis() - start) + " ms]"); if (applied > 0) finalizeCheckpointOnRecovery(status.cpStartTs, status.cpStartId, status.startPtr); @@ -2160,7 +2209,7 @@ private WALPointer readPointer(File cpMarkerFile, ByteBuffer buf) throws IgniteC cpHistory.initialize(retreiveHistory()); - return lastReadPtr == null ? null : lastReadPtr.next(); + return restoreBinaryState; } /** @@ -2171,6 +2220,9 @@ private WALPointer readPointer(File cpMarkerFile, ByteBuffer buf) throws IgniteC * @throws IgniteCheckedException if no DataRegion is configured for a name obtained from cache descriptor. */ private PageMemoryEx getPageMemoryForCacheGroup(int grpId) throws IgniteCheckedException { + if (grpId == MetaStorage.METASTORAGE_CACHE_ID) + return (PageMemoryEx)dataRegion(METASTORE_DATA_REGION_NAME).pageMemory(); + // TODO IGNITE-7792 add generic mapping. if (grpId == TxLog.TX_LOG_CACHE_ID) return (PageMemoryEx)dataRegion(TxLog.TX_LOG_CACHE_NAME).pageMemory(); @@ -2181,7 +2233,7 @@ private PageMemoryEx getPageMemoryForCacheGroup(int grpId) throws IgniteCheckedE CacheGroupDescriptor desc = sharedCtx.cache().cacheGroupDescriptors().get(grpId); if (desc == null) - throw new IgniteCheckedException("Failed to find cache group descriptor [grpId=" + grpId + ']'); + return null; String memPlcName = desc.config().getDataRegionName(); @@ -2194,97 +2246,85 @@ private PageMemoryEx getPageMemoryForCacheGroup(int grpId) throws IgniteCheckedE * @param it WalIterator. * @param recPredicate Wal record filter. * @param entryPredicate Entry filter. - * @param partStates Partition to restore state. */ public void applyUpdatesOnRecovery( @Nullable WALIterator it, - IgnitePredicate> recPredicate, - IgnitePredicate entryPredicate, - Map, T2> partStates + IgniteBiPredicate recPredicate, + IgnitePredicate entryPredicate ) throws IgniteCheckedException { + if (it == null) + return; + cctx.walState().runWithOutWAL(() -> { - if (it != null) { - while (it.hasNext()) { - IgniteBiTuple next = it.next(); + while (it.hasNext()) { + IgniteBiTuple next = it.next(); - WALRecord rec = next.get2(); + WALRecord rec = next.get2(); - if (!recPredicate.apply(next)) - break; + if (!recPredicate.apply(next.get1(), rec)) + break; - switch (rec.type()) { - case MVCC_DATA_RECORD: - case DATA_RECORD: - checkpointReadLock(); + switch (rec.type()) { + case MVCC_DATA_RECORD: + case DATA_RECORD: + checkpointReadLock(); - try { - DataRecord dataRec = (DataRecord)rec; + try { + DataRecord dataRec = (DataRecord)rec; - for (DataEntry dataEntry : dataRec.writeEntries()) { - if (entryPredicate.apply(dataEntry)) { - checkpointReadLock(); + for (DataEntry dataEntry : dataRec.writeEntries()) { + if (entryPredicate.apply(dataEntry)) { + checkpointReadLock(); - try { - int cacheId = dataEntry.cacheId(); + try { + int cacheId = dataEntry.cacheId(); - GridCacheContext cacheCtx = cctx.cacheContext(cacheId); + GridCacheContext cacheCtx = cctx.cacheContext(cacheId); - if (cacheCtx != null) - applyUpdate(cacheCtx, dataEntry); - else if (log != null) - log.warning("Cache (cacheId=" + cacheId + ") is not started, can't apply updates."); - } - finally { - checkpointReadUnlock(); - } + if (cacheCtx != null) + applyUpdate(cacheCtx, dataEntry); + else if (log != null) + log.warning("Cache is not started. Updates cannot be applied " + + "[cacheId=" + cacheId + ']'); + } + finally { + checkpointReadUnlock(); } } } - catch (IgniteCheckedException e) { - throw new IgniteException(e); - } - finally { - checkpointReadUnlock(); - } + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + finally { + checkpointReadUnlock(); + } - break; + break; - case MVCC_TX_RECORD: - checkpointReadLock(); + case MVCC_TX_RECORD: + checkpointReadLock(); - try { - MvccTxRecord txRecord = (MvccTxRecord)rec; + try { + MvccTxRecord txRecord = (MvccTxRecord)rec; - byte txState = convertToTxState(txRecord.state()); + byte txState = convertToTxState(txRecord.state()); - cctx.coordinators().updateState(txRecord.mvccVersion(), txState, false); - } - catch (IgniteCheckedException e) { - throw new IgniteException(e); - } - finally { - checkpointReadUnlock(); - } + cctx.coordinators().updateState(txRecord.mvccVersion(), txState, false); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + finally { + checkpointReadUnlock(); + } - break; + break; - default: - // Skip other records. - } + default: + // Skip other records. } } - - checkpointReadLock(); - - try { - restorePartitionStates(partStates, null); - } - catch (IgniteCheckedException e) { - throw new IgniteException(e); - } - finally { - checkpointReadUnlock(); - } }); } @@ -2293,29 +2333,32 @@ else if (log != null) * @throws IgniteCheckedException If failed to apply updates. * @throws StorageException If IO exception occurred while reading write-ahead log. */ - private void applyLastUpdates(CheckpointStatus status, boolean metastoreOnly) throws IgniteCheckedException { + private RestoreLogicalState applyLogicalUpdates( + CheckpointStatus status, + IgnitePredicate cacheGroupsPredicate, + IgniteBiPredicate recordTypePredicate, + boolean skipFieldLookup + ) throws IgniteCheckedException { if (log.isInfoEnabled()) log.info("Applying lost cache updates since last checkpoint record [lastMarked=" + status.startPtr + ", lastCheckpointId=" + status.cpStartId + ']'); - if (!metastoreOnly) + if (skipFieldLookup) cctx.kernalContext().query().skipFieldLookup(true); - long lastArchivedSegment = cctx.wal().lastArchivedSegment(); - - RestoreLogicalState restoreLogicalState = new RestoreLogicalState(lastArchivedSegment, log); - long start = U.currentTimeMillis(); + int applied = 0; - Collection ignoreGrps = metastoreOnly ? Collections.emptySet() : - F.concat(false, initiallyGlobalWalDisabledGrps, initiallyLocalWalDisabledGrps); + long lastArchivedSegment = cctx.wal().lastArchivedSegment(); + + WALIterator it = cctx.wal().replay(status.startPtr, recordTypePredicate); - try (WALIterator it = cctx.wal().replay(status.startPtr)) { - Map, T2> partStates = new HashMap<>(); + RestoreLogicalState restoreLogicalState = new RestoreLogicalState(it, lastArchivedSegment, cacheGroupsPredicate); + try { while (it.hasNextX()) { - WALRecord rec = restoreLogicalState.next(it); + WALRecord rec = restoreLogicalState.next(); if (rec == null) break; @@ -2323,37 +2366,48 @@ private void applyLastUpdates(CheckpointStatus status, boolean metastoreOnly) th switch (rec.type()) { case MVCC_DATA_RECORD: case DATA_RECORD: - if (metastoreOnly) - continue; - + case ENCRYPTED_DATA_RECORD: DataRecord dataRec = (DataRecord)rec; for (DataEntry dataEntry : dataRec.writeEntries()) { int cacheId = dataEntry.cacheId(); - int grpId = cctx.cache().cacheDescriptor(cacheId).groupId(); + DynamicCacheDescriptor cacheDesc = cctx.cache().cacheDescriptor(cacheId); - if (!ignoreGrps.contains(grpId)) { - GridCacheContext cacheCtx = cctx.cacheContext(cacheId); + // Can empty in case recovery node on blt changed. + if (cacheDesc == null) + continue; - applyUpdate(cacheCtx, dataEntry); + GridCacheContext cacheCtx = cctx.cacheContext(cacheId); - applied++; - } + applyUpdate(cacheCtx, dataEntry); + + applied++; } break; - case PART_META_UPDATE_STATE: - if (metastoreOnly) - continue; + case MVCC_TX_RECORD: + MvccTxRecord txRecord = (MvccTxRecord)rec; + + byte txState = convertToTxState(txRecord.state()); + + cctx.coordinators().updateState(txRecord.mvccVersion(), txState, false); + + break; + case PART_META_UPDATE_STATE: PartitionMetaStateRecord metaStateRecord = (PartitionMetaStateRecord)rec; - if (!ignoreGrps.contains(metaStateRecord.groupId())) { - partStates.put(new T2<>(metaStateRecord.groupId(), metaStateRecord.partitionId()), - new T2<>((int)metaStateRecord.state(), metaStateRecord.updateCounter())); - } + GroupPartitionId groupPartitionId = new GroupPartitionId( + metaStateRecord.groupId(), metaStateRecord.partitionId() + ); + + PartitionRecoverState state = new PartitionRecoverState( + (int)metaStateRecord.state(), metaStateRecord.updateCounter() + ); + + restoreLogicalState.partitionRecoveryStates.put(groupPartitionId, state); break; @@ -2367,13 +2421,14 @@ private void applyLastUpdates(CheckpointStatus status, boolean metastoreOnly) th case META_PAGE_UPDATE_NEXT_SNAPSHOT_ID: case META_PAGE_UPDATE_LAST_SUCCESSFUL_SNAPSHOT_ID: case META_PAGE_UPDATE_LAST_SUCCESSFUL_FULL_SNAPSHOT_ID: - if (metastoreOnly) - continue; - + case META_PAGE_UPDATE_LAST_ALLOCATED_INDEX: PageDeltaRecord rec0 = (PageDeltaRecord) rec; PageMemoryEx pageMem = getPageMemoryForCacheGroup(rec0.groupId()); + if (pageMem == null) + break; + long page = pageMem.acquirePage(rec0.groupId(), rec0.pageId(), true); try { @@ -2392,182 +2447,26 @@ private void applyLastUpdates(CheckpointStatus status, boolean metastoreOnly) th break; - case MVCC_TX_RECORD: - if (metastoreOnly) - continue; - - MvccTxRecord txRecord = (MvccTxRecord)rec; - - byte txState = convertToTxState(txRecord.state()); - - cctx.coordinators().updateState(txRecord.mvccVersion(), txState, false); - - break; - default: // Skip other records. } } - - if (!metastoreOnly) { - long startRestorePart = U.currentTimeMillis(); - - if (log.isInfoEnabled()) - log.info("Restoring partition state for local groups [cntPartStateWal=" - + partStates.size() + ", lastCheckpointId=" + status.cpStartId + ']'); - - long proc = restorePartitionStates(partStates, null); - - if (log.isInfoEnabled()) - log.info("Finished restoring partition state for local groups [cntProcessed=" + proc + - ", cntPartStateWal=" + partStates.size() + - ", time=" + (U.currentTimeMillis() - startRestorePart) + "ms]"); - } } finally { - if (!metastoreOnly) + it.close(); + + if (skipFieldLookup) cctx.kernalContext().query().skipFieldLookup(false); } if (log.isInfoEnabled()) log.info("Finished applying WAL changes [updatesApplied=" + applied + - ", time=" + (U.currentTimeMillis() - start) + "ms]"); - } - - /** - * Initializes not empty partitions and restores their state from page memory or WAL. - * Partition states presented in page memory may be overriden by states restored from WAL {@code partStates}. - * - * @param partStates Partition states restored from WAL. - * @param onlyForGroups If not {@code null} restore states only for specified cache groups. - * @return cntParts Count of partitions processed. - * @throws IgniteCheckedException If failed to restore partition states. - */ - private long restorePartitionStates( - Map, T2> partStates, - @Nullable Set onlyForGroups - ) throws IgniteCheckedException { - long cntParts = 0; - - for (CacheGroupContext grp : cctx.cache().cacheGroups()) { - if (grp.isLocal() || !grp.affinityNode()) { - // Local cache has no partitions and its states. - continue; - } - - if (!grp.dataRegion().config().isPersistenceEnabled()) - continue; - - if (onlyForGroups != null && !onlyForGroups.contains(grp.groupId())) - continue; - - int grpId = grp.groupId(); - - PageMemoryEx pageMem = (PageMemoryEx)grp.dataRegion().pageMemory(); - - for (int i = 0; i < grp.affinity().partitions(); i++) { - T2 restore = partStates.get(new T2<>(grpId, i)); - - if (storeMgr.exists(grpId, i)) { - storeMgr.ensure(grpId, i); - - if (storeMgr.pages(grpId, i) <= 1) - continue; - - if (log.isDebugEnabled()) - log.debug("Creating partition on recovery (exists in page store) " + - "[grp=" + grp.cacheOrGroupName() + ", p=" + i + "]"); - - GridDhtLocalPartition part = grp.topology().forceCreatePartition(i); - - assert part != null; - - // TODO: https://issues.apache.org/jira/browse/IGNITE-6097 - grp.offheap().onPartitionInitialCounterUpdated(i, 0); - - checkpointReadLock(); - - try { - long partMetaId = pageMem.partitionMetaPageId(grpId, i); - long partMetaPage = pageMem.acquirePage(grpId, partMetaId); - - try { - long pageAddr = pageMem.writeLock(grpId, partMetaId, partMetaPage); - - boolean changed = false; - - try { - PagePartitionMetaIO io = PagePartitionMetaIO.VERSIONS.forPage(pageAddr); - - if (restore != null) { - int stateId = restore.get1(); - - io.setPartitionState(pageAddr, (byte)stateId); - - changed = updateState(part, stateId); - - if (stateId == GridDhtPartitionState.OWNING.ordinal() - || (stateId == GridDhtPartitionState.MOVING.ordinal() - && part.initialUpdateCounter() < restore.get2())) { - part.initialUpdateCounter(restore.get2()); - - changed = true; - } - - if (log.isDebugEnabled()) - log.debug("Restored partition state (from WAL) " + - "[grp=" + grp.cacheOrGroupName() + ", p=" + i + ", state=" + part.state() + - "updCntr=" + part.initialUpdateCounter() + "]"); - } - else { - changed = updateState(part, (int) io.getPartitionState(pageAddr)); - - if (log.isDebugEnabled()) - log.debug("Restored partition state (from page memory) " + - "[grp=" + grp.cacheOrGroupName() + ", p=" + i + ", state=" + part.state() + - "updCntr=" + part.initialUpdateCounter() + "]"); - } - } - finally { - pageMem.writeUnlock(grpId, partMetaId, partMetaPage, null, changed); - } - } - finally { - pageMem.releasePage(grpId, partMetaId, partMetaPage); - } - } - finally { - checkpointReadUnlock(); - } - } - else if (restore != null) { - if (log.isDebugEnabled()) - log.debug("Creating partition on recovery (exists in WAL) " + - "[grp=" + grp.cacheOrGroupName() + ", p=" + i + "]"); - - GridDhtLocalPartition part = grp.topology().forceCreatePartition(i); - - assert part != null; - - // TODO: https://issues.apache.org/jira/browse/IGNITE-6097 - grp.offheap().onPartitionInitialCounterUpdated(i, 0); - - updateState(part, restore.get1()); - - if (log.isDebugEnabled()) - log.debug("Restored partition state (from WAL) " + - "[grp=" + grp.cacheOrGroupName() + ", p=" + i + ", state=" + part.state() + - "updCntr=" + part.initialUpdateCounter() + "]"); - } + ", time=" + (U.currentTimeMillis() - start) + " ms]"); - cntParts++; - } - - // After partition states are restored, it is necessary to update internal data structures in topology. - grp.topology().afterStateRestored(grp.topology().lastTopologyChangeVersion()); - } + for (DatabaseLifecycleListener lsnr : getDatabaseListeners(cctx.kernalContext())) + lsnr.afterLogicalUpdatesApplied(this, restoreLogicalState); - return cntParts; + return restoreLogicalState; } /** @@ -2604,25 +2503,6 @@ public void onWalTruncated(WALPointer highBound) throws IgniteCheckedException { removeCheckpointFiles(cp); } - /** - * @param part Partition to restore state for. - * @param stateId State enum ordinal. - * @return Updated flag. - */ - private boolean updateState(GridDhtLocalPartition part, int stateId) { - if (stateId != -1) { - GridDhtPartitionState state = GridDhtPartitionState.fromOrdinal(stateId); - - assert state != null; - - part.restoreState(state == GridDhtPartitionState.EVICTED ? GridDhtPartitionState.RENTING : state); - - return true; - } - - return false; - } - /** * @param cacheCtx Cache context to apply an update. * @param dataEntry Data entry to apply. @@ -2888,8 +2768,9 @@ private static String checkpointFileName(long cpTs, UUID cpId, CheckpointEntryTy /** * @param cp Checkpoint entry. * @param type Checkpoint type. + * @return Checkpoint file name. */ - private static String checkpointFileName(CheckpointEntry cp, CheckpointEntryType type) { + public static String checkpointFileName(CheckpointEntry cp, CheckpointEntryType type) { return checkpointFileName(cp.timestamp(), cp.checkpointId(), type); } @@ -3166,6 +3047,13 @@ protected Checkpointer(@Nullable String gridName, String name, IgniteLogger log) while (!isCancelled()) { waitCheckpointEvent(); + if (skipCheckpointOnNodeStop && (isCancelled() || shutdownNow)) { + if (log.isInfoEnabled()) + log.warning("Skipping last checkpoint because node is stopping."); + + return; + } + GridFutureAdapter enableChangeApplied = GridCacheDatabaseSharedManager.this.enableChangeApplied; if (enableChangeApplied != null) { @@ -3192,7 +3080,7 @@ protected Checkpointer(@Nullable String gridName, String name, IgniteLogger log) } finally { if (err == null && !(stopping && isCancelled)) - err = new IllegalStateException("Thread " + name() + " is terminated unexpectedly"); + err = new IllegalStateException("Thread is terminated unexpectedly: " + name()); if (err instanceof OutOfMemoryError) cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, err)); @@ -3597,7 +3485,7 @@ private void cancelOrWaitPartitionDestroy(int grpId, int partId) throws IgniteCh if (req != null) req.waitCompleted(); - if (log.isDebugEnabled()) + if (req != null && log.isDebugEnabled()) log.debug("Partition file destroy has cancelled [grpId=" + grpId + ", partId=" + partId + "]"); } @@ -3639,7 +3527,9 @@ private void waitCheckpointEvent() { */ @SuppressWarnings("TooBroadScope") private Checkpoint markCheckpointBegin(CheckpointMetricsTracker tracker) throws IgniteCheckedException { - CheckpointRecord cpRec = new CheckpointRecord(null); + CheckpointRecord cpRec = new CheckpointRecord(memoryRecoveryRecordPtr); + + memoryRecoveryRecordPtr = null; WALPointer cpPtr = null; @@ -3823,7 +3713,7 @@ private Checkpoint markCheckpointBegin(CheckpointMetricsTracker tracker) throws } catch (IgniteException e) { U.error(log, "Failed to wait for snapshot operation initialization: " + - curr.snapshotOperation + "]", e); + curr.snapshotOperation, e); } } @@ -4136,8 +4026,6 @@ private WriteCheckpointPages( private List writePages(Collection writePageIds) throws IgniteCheckedException { ByteBuffer tmpWriteBuf = threadBuf.get(); - long writeAddr = GridUnsafe.bufferAddress(tmpWriteBuf); - List pagesToRetry = new ArrayList<>(); for (FullPageId fullId : writePageIds) { @@ -4162,7 +4050,7 @@ else if (grpId == TxLog.TX_LOG_CACHE_ID) else { CacheGroupContext grp = context().cache().cacheGroup(grpId); - DataRegion region = grp != null ?grp .dataRegion() : null; + DataRegion region = grp != null ? grp.dataRegion() : null; if (region == null || !region.config().isPersistenceEnabled()) continue; @@ -4192,19 +4080,9 @@ else if (grpId == TxLog.TX_LOG_CACHE_ID) tracker.onDataPageWritten(); } - if (!skipCrc) { - PageIO.setCrc(writeAddr, PureJavaCrc32.calcCrc32(tmpWriteBuf, pageSize())); - - tmpWriteBuf.rewind(); - } - - int curWrittenPages = writtenPagesCntr.incrementAndGet(); - - snapshotMgr.onPageWrite(fullId, tmpWriteBuf, curWrittenPages, totalPagesToWrite); + writtenPagesCntr.incrementAndGet(); - tmpWriteBuf.rewind(); - - PageStore store = storeMgr.writeInternal(grpId, fullId.pageId(), tmpWriteBuf, tag, false); + PageStore store = storeMgr.writeInternal(grpId, fullId.pageId(), tmpWriteBuf, tag, true); updStores.computeIfAbsent(store, k -> new LongAdder()).increment(); } @@ -4278,12 +4156,12 @@ public void walSegsCoveredRange(final IgniteBiTuple walSegsCoveredRa /** * */ - private static class CheckpointStatus { + public static class CheckpointStatus { /** Null checkpoint UUID. */ private static final UUID NULL_UUID = new UUID(0L, 0L); /** Null WAL pointer. */ - private static final WALPointer NULL_PTR = new FileWALPointer(0, 0, 0); + public static final WALPointer NULL_PTR = new FileWALPointer(0, 0, 0); /** */ private long cpStartTs; @@ -4317,7 +4195,8 @@ private CheckpointStatus(long cpStartTs, UUID cpStartId, WALPointer startPtr, UU } /** - * @return {@code True} if need to apply page log to restore tree structure. + * @return {@code True} if need perform binary memory recovery. Only records {@link PageDeltaRecord} + * and {@link PageSnapshot} needs to be applyed from {@link #cpStartId}. */ public boolean needRestoreMemory() { return !F.eq(cpStartId, cpEndId) && !F.eq(NULL_UUID, cpStartId); @@ -4398,7 +4277,7 @@ private static class CheckpointProgressSnapshot implements CheckpointFuture { } /** {@inheritDoc} */ - @Override public GridFutureAdapter finishFuture() { + @Override public GridFutureAdapter finishFuture() { return cpFinishFut; } } @@ -4501,9 +4380,9 @@ public void tryLock(long lockWaitTimeMillis) throws IgniteCheckedException { if (content == null) content = readContent(); - log.warning("Failed to acquire file lock (local nodeId:" + ctx.localNodeId() - + ", already locked by " + content + "), will try again in 1s: " - + file.getAbsolutePath()); + log.warning("Failed to acquire file lock. Will try again in 1s " + + "[nodeId=" + ctx.localNodeId() + ", holder=" + content + + ", path=" + file.getAbsolutePath() + ']'); } U.sleep(1000); @@ -4512,8 +4391,8 @@ public void tryLock(long lockWaitTimeMillis) throws IgniteCheckedException { if (content == null) content = readContent(); - failMsg = "Failed to acquire file lock during " + (lockWaitTimeMillis / 1000) + - " sec, (locked by " + content + "): " + file.getAbsolutePath(); + failMsg = "Failed to acquire file lock [holder=" + content + ", time=" + (lockWaitTimeMillis / 1000) + + " sec, path=" + file.getAbsolutePath() + ']'; } catch (Exception e) { throw new IgniteCheckedException(e); @@ -4604,7 +4483,7 @@ public DataStorageMetricsImpl persistentStoreMetricsImpl() { } /** {@inheritDoc} */ - public void notifyMetaStorageSubscribersOnReadyForRead() throws IgniteCheckedException { + @Override public void notifyMetaStorageSubscribersOnReadyForRead() throws IgniteCheckedException { metastorageLifecycleLsnrs = cctx.kernalContext().internalSubscriptionProcessor().getMetastorageSubscribers(); readMetastore(); @@ -4681,10 +4560,10 @@ public boolean isCheckpointInapplicableForWalRebalance(Long cpTs, int grpId) thr * */ private void fillWalDisabledGroups() { - MetaStorage meta = cctx.database().metaStorage(); + assert metaStorage != null; try { - Set keys = meta.readForPredicate(WAL_KEY_PREFIX_PRED).keySet(); + Set keys = metaStorage.readForPredicate(WAL_KEY_PREFIX_PRED).keySet(); if (keys.isEmpty()) return; @@ -4747,47 +4626,216 @@ else if (key.startsWith(WAL_GLOBAL_KEY_PREFIX)) } /** - * Abstract class for create restore context. + * Method dumps partitions info see {@link #dumpPartitionsInfo(CacheGroupContext, IgniteLogger)} + * for all persistent cache groups. + * + * @param cctx Shared context. + * @param log Logger. + * @throws IgniteCheckedException If failed. */ - public abstract static class RestoreStateContext { - /** */ - protected final IgniteLogger log; + private static void dumpPartitionsInfo(GridCacheSharedContext cctx, IgniteLogger log) throws IgniteCheckedException { + for (CacheGroupContext grp : cctx.cache().cacheGroups()) { + if (grp.isLocal() || !grp.persistenceEnabled()) + continue; + + dumpPartitionsInfo(grp, log); + } + } + + /** + * Retrieves from page memory meta information about given {@code grp} group partitions + * and dumps this information to log INFO level. + * + * @param grp Cache group. + * @param log Logger. + * @throws IgniteCheckedException If failed. + */ + private static void dumpPartitionsInfo(CacheGroupContext grp, IgniteLogger log) throws IgniteCheckedException { + PageMemoryEx pageMem = (PageMemoryEx)grp.dataRegion().pageMemory(); + + IgnitePageStoreManager pageStore = grp.shared().pageStore(); + + assert pageStore != null : "Persistent cache should have initialize page store manager."; + + for (int p = 0; p < grp.affinity().partitions(); p++) { + if (grp.topology().localPartition(p) != null) { + GridDhtLocalPartition part = grp.topology().localPartition(p); + + log.info("Partition [grp=" + grp.cacheOrGroupName() + + ", id=" + p + + ", state=" + part.state() + + ", counter=" + part.updateCounter() + + ", size=" + part.fullSize() + "]"); + + continue; + } + + if (!pageStore.exists(grp.groupId(), p)) + continue; + + pageStore.ensure(grp.groupId(), p); + + if (pageStore.pages(grp.groupId(), p) <= 1) { + log.info("Partition [grp=" + grp.cacheOrGroupName() + ", id=" + p + ", state=N/A (only file header) ]"); + + continue; + } + + long partMetaId = pageMem.partitionMetaPageId(grp.groupId(), p); + long partMetaPage = pageMem.acquirePage(grp.groupId(), partMetaId); + + try { + long pageAddr = pageMem.readLock(grp.groupId(), partMetaId, partMetaPage); + + try { + PagePartitionMetaIO io = PagePartitionMetaIO.VERSIONS.forPage(pageAddr); + + GridDhtPartitionState partitionState = GridDhtPartitionState.fromOrdinal(io.getPartitionState(pageAddr)); + + String state = partitionState != null ? partitionState.toString() : "N/A"; + + long updateCounter = io.getUpdateCounter(pageAddr); + long size = io.getSize(pageAddr); + + log.info("Partition [grp=" + grp.cacheOrGroupName() + + ", id=" + p + + ", state=" + state + + ", counter=" + updateCounter + + ", size=" + size + "]"); + } + finally { + pageMem.readUnlock(grp.groupId(), partMetaId, partMetaPage); + } + } + finally { + pageMem.releasePage(grp.groupId(), partMetaId, partMetaPage); + } + } + } + + /** + * Recovery lifecycle for read-write metastorage. + */ + private class MetastorageRecoveryLifecycle implements DatabaseLifecycleListener { + /** {@inheritDoc} */ + @Override public void beforeBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException { + cctx.pageStore().initializeForMetastorage(); + } + + /** {@inheritDoc} */ + @Override public void afterBinaryMemoryRestore( + IgniteCacheDatabaseSharedManager mgr, + RestoreBinaryState restoreState + ) throws IgniteCheckedException { + assert metaStorage == null; + + metaStorage = createMetastorage(false); + } + } + + /** + * @return Cache group predicate that passes only Metastorage cache group id. + */ + private IgnitePredicate onlyMetastorageGroup() { + return groupId -> MetaStorage.METASTORAGE_CACHE_ID == groupId; + } + + /** + * @return Cache group predicate that passes only cache groups with enabled WAL. + */ + private IgnitePredicate groupsWithEnabledWal() { + return groupId -> !initiallyGlobalWalDisabledGrps.contains(groupId) + && !initiallyLocalWalDisabledGrps.contains(groupId); + } + + /** + * @return WAL records predicate that passes only Metastorage data records. + */ + private IgniteBiPredicate onlyMetastorageRecords() { + return (type, ptr) -> type == METASTORE_DATA_RECORD; + } + + /** + * @return WAL records predicate that passes only physical and mixed WAL records. + */ + private IgniteBiPredicate physicalRecords() { + return (type, ptr) -> type.purpose() == WALRecord.RecordPurpose.PHYSICAL + || type.purpose() == WALRecord.RecordPurpose.MIXED; + } + + /** + * @return WAL records predicate that passes only logical and mixed WAL records. + */ + private IgniteBiPredicate logicalRecords() { + return (type, ptr) -> type.purpose() == WALRecord.RecordPurpose.LOGICAL + || type.purpose() == WALRecord.RecordPurpose.MIXED; + } + /** + * Abstract class to create restore context. + */ + private abstract class RestoreStateContext { /** Last archived segment. */ protected final long lastArchivedSegment; - /** Last read record WAL pointer. */ - protected FileWALPointer lastRead; + /** WAL iterator. */ + private final WALIterator iterator; + + /** Only {@link WalRecordCacheGroupAware} records satisfied this predicate will be applied. */ + private final IgnitePredicate cacheGroupPredicate; /** + * @param iterator WAL iterator. * @param lastArchivedSegment Last archived segment index. - * @param log Ignite logger. + * @param cacheGroupPredicate Cache groups predicate. */ - public RestoreStateContext(long lastArchivedSegment, IgniteLogger log) { + protected RestoreStateContext( + WALIterator iterator, + long lastArchivedSegment, + IgnitePredicate cacheGroupPredicate + ) { + this.iterator = iterator; this.lastArchivedSegment = lastArchivedSegment; - this.log = log; + this.cacheGroupPredicate = cacheGroupPredicate; } /** * Advance iterator to the next record. * - * @param it WAL iterator. * @return WALRecord entry. * @throws IgniteCheckedException If CRC check fail during binary recovery state or another exception occurring. */ - public WALRecord next(WALIterator it) throws IgniteCheckedException { + public WALRecord next() throws IgniteCheckedException { try { - IgniteBiTuple tup = it.nextX(); + for (;;) { + if (!iterator.hasNextX()) + return null; + + IgniteBiTuple tup = iterator.nextX(); + + if (tup == null) + return null; + + WALRecord rec = tup.get2(); - WALRecord rec = tup.get2(); + WALPointer ptr = tup.get1(); - WALPointer ptr = tup.get1(); + rec.position(ptr); - lastRead = (FileWALPointer)ptr; + // Filter out records by group id. + if (rec instanceof WalRecordCacheGroupAware) { + WalRecordCacheGroupAware grpAwareRecord = (WalRecordCacheGroupAware) rec; + + if (!cacheGroupPredicate.apply(grpAwareRecord.groupId())) + continue; + } - rec.position(ptr); + // Filter out data entries by group id. + if (rec instanceof DataRecord) + rec = filterEntriesByGroupId((DataRecord) rec); - return rec; + return rec; + } } catch (IgniteCheckedException e) { boolean throwsCRCError = throwsCRCError(); @@ -4799,35 +4847,51 @@ public WALRecord next(WALIterator it) throws IgniteCheckedException { return null; } - log.error("Catch error during restore state, throwsCRCError=" + throwsCRCError, e); + log.error("There is an error during restore state [throwsCRCError=" + throwsCRCError + ']', e); throw e; } } + /** + * Filter outs data entries from given data record that not satisfy {@link #cacheGroupPredicate}. + * + * @param record Original data record. + * @return Data record with filtered data entries. + */ + private DataRecord filterEntriesByGroupId(DataRecord record) { + List filteredEntries = record.writeEntries().stream() + .filter(entry -> { + int cacheId = entry.cacheId(); + + return cctx.cacheContext(cacheId) != null && cacheGroupPredicate.apply(cctx.cacheContext(cacheId).groupId()); + }) + .collect(Collectors.toList()); + + return record.setWriteEntries(filteredEntries); + } + /** * * @return Last read WAL record pointer. */ - public WALPointer lastReadRecordPointer() { - return lastRead; + public Optional lastReadRecordPointer() { + return iterator.lastRead().map(ptr -> (FileWALPointer)ptr); } /** * * @return Flag indicates need throws CRC exception or not. */ - public boolean throwsCRCError(){ - FileWALPointer lastReadPtr = lastRead; - - return lastReadPtr != null && lastReadPtr.index() <= lastArchivedSegment; + public boolean throwsCRCError() { + return lastReadRecordPointer().filter(ptr -> ptr.index() <= lastArchivedSegment).isPresent(); } } /** * Restore memory context. Tracks the safety of binary recovery. */ - public static class RestoreBinaryState extends RestoreStateContext { + public class RestoreBinaryState extends RestoreStateContext { /** Checkpoint status. */ private final CheckpointStatus status; @@ -4836,25 +4900,30 @@ public static class RestoreBinaryState extends RestoreStateContext { /** * @param status Checkpoint status. + * @param iterator WAL iterator. * @param lastArchivedSegment Last archived segment index. - * @param log Ignite logger. + * @param cacheGroupsPredicate Cache groups predicate. */ - public RestoreBinaryState(CheckpointStatus status, long lastArchivedSegment, IgniteLogger log) { - super(lastArchivedSegment, log); + public RestoreBinaryState( + CheckpointStatus status, + WALIterator iterator, + long lastArchivedSegment, + IgnitePredicate cacheGroupsPredicate + ) { + super(iterator, lastArchivedSegment, cacheGroupsPredicate); this.status = status; - needApplyBinaryUpdates = status.needRestoreMemory(); + this.needApplyBinaryUpdates = status.needRestoreMemory(); } /** * Advance iterator to the next record. * - * @param it WAL iterator. * @return WALRecord entry. * @throws IgniteCheckedException If CRC check fail during binary recovery state or another exception occurring. */ - @Override public WALRecord next(WALIterator it) throws IgniteCheckedException { - WALRecord rec = super.next(it); + @Override public WALRecord next() throws IgniteCheckedException { + WALRecord rec = super.next(); if (rec == null) return null; @@ -4890,8 +4959,8 @@ public boolean needApplyBinaryUpdate() { * @return Flag indicates need throws CRC exception or not. */ @Override public boolean throwsCRCError() { - log.info("Throws CRC error check, needApplyBinaryUpdates=" + needApplyBinaryUpdates + - ", lastArchivedSegment=" + lastArchivedSegment + ", lastRead=" + lastRead); + log.info("Throws CRC error check [needApplyBinaryUpdates=" + needApplyBinaryUpdates + + ", lastArchivedSegment=" + lastArchivedSegment + ", lastRead=" + lastReadRecordPointer() + ']'); if (needApplyBinaryUpdates) return true; @@ -4903,13 +4972,22 @@ public boolean needApplyBinaryUpdate() { /** * Restore logical state context. Tracks the safety of logical recovery. */ - public static class RestoreLogicalState extends RestoreStateContext { + public class RestoreLogicalState extends RestoreStateContext { + /** States of partitions recovered during applying logical updates. */ + private final Map partitionRecoveryStates = new HashMap<>(); + /** * @param lastArchivedSegment Last archived segment index. - * @param log Ignite logger. */ - public RestoreLogicalState(long lastArchivedSegment, IgniteLogger log) { - super(lastArchivedSegment, log); + public RestoreLogicalState(WALIterator iterator, long lastArchivedSegment, IgnitePredicate cacheGroupsPredicate) { + super(iterator, lastArchivedSegment, cacheGroupsPredicate); + } + + /** + * @return Map of restored partition states for cache groups. + */ + public Map partitionRecoveryStates() { + return Collections.unmodifiableMap(partitionRecoveryStates); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java index 9366e29469333..f78428d055e52 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java @@ -38,6 +38,7 @@ import org.apache.ignite.internal.pagemem.PageIdUtils; import org.apache.ignite.internal.pagemem.PageMemory; import org.apache.ignite.internal.pagemem.PageSupport; +import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager; import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; import org.apache.ignite.internal.pagemem.wal.WALIterator; import org.apache.ignite.internal.pagemem.wal.WALPointer; @@ -70,6 +71,7 @@ import org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId; import org.apache.ignite.internal.processors.cache.persistence.partstate.PagesAllocationRange; import org.apache.ignite.internal.processors.cache.persistence.partstate.PartitionAllocationMap; +import org.apache.ignite.internal.processors.cache.persistence.partstate.PartitionRecoverState; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionCountersIO; @@ -111,6 +113,9 @@ public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl imple /** */ private ReuseListImpl reuseList; + /** Flag indicates that all group partitions have restored their state from page memory / disk. */ + private volatile boolean partitionStatesRestored; + /** {@inheritDoc} */ @Override protected void initPendingTree(GridCacheContext cctx) throws IgniteCheckedException { // No-op. Per-partition PendingTree should be used. @@ -137,6 +142,7 @@ public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl imple ctx.wal(), globalRemoveId(), grp.groupId(), + grp.sharedGroup(), PageIdAllocator.INDEX_PARTITION, PageIdAllocator.FLAG_IDX, reuseList, @@ -173,17 +179,7 @@ public IndexStorage getIndexStorage() { boolean needSnapshot = ctx.nextSnapshot() && ctx.needToSnapshot(grp.cacheOrGroupName()); - boolean hasNonEmptyGroups = false; - - for (CacheDataStore store : partDataStores.values()) { - if (notEmpty(store)) { - hasNonEmptyGroups = true; - - break; - } - } - - if (needSnapshot && hasNonEmptyGroups) { + if (needSnapshot) { if (execSvc == null) updateSnapshotTag(ctx); else { @@ -198,6 +194,17 @@ public IndexStorage getIndexStorage() { } } + syncMetadata(execSvc, ctx, needSnapshot); + } + + /** + * Syncs and saves meta-information of all data structures to page memory. + * + * @param execSvc Executor service to run save process + * @param ctx Checkpoint listener context. + * @throws IgniteCheckedException If failed. + */ + private void syncMetadata(Executor execSvc, Context ctx, boolean needSnapshot) throws IgniteCheckedException { if (execSvc == null) { reuseList.saveMetadata(); @@ -395,6 +402,142 @@ else if (needSnapshot) tryAddEmptyPartitionToSnapshot(store, ctx); } + /** {@inheritDoc} */ + @Override public long restorePartitionStates(Map partitionRecoveryStates) throws IgniteCheckedException { + if (grp.isLocal() || !grp.affinityNode() || !grp.dataRegion().config().isPersistenceEnabled()) + return 0; + + if (partitionStatesRestored) + return 0; + + long processed = 0; + + PageMemoryEx pageMem = (PageMemoryEx)grp.dataRegion().pageMemory(); + + for (int p = 0; p < grp.affinity().partitions(); p++) { + PartitionRecoverState recoverState = partitionRecoveryStates.get(new GroupPartitionId(grp.groupId(), p)); + + if (ctx.pageStore().exists(grp.groupId(), p)) { + ctx.pageStore().ensure(grp.groupId(), p); + + if (ctx.pageStore().pages(grp.groupId(), p) <= 1) { + if (log.isDebugEnabled()) + log.debug("Skipping partition on recovery (pages less than 1) " + + "[grp=" + grp.cacheOrGroupName() + ", p=" + p + "]"); + + continue; + } + + if (log.isDebugEnabled()) + log.debug("Creating partition on recovery (exists in page store) " + + "[grp=" + grp.cacheOrGroupName() + ", p=" + p + "]"); + + processed++; + + GridDhtLocalPartition part = grp.topology().forceCreatePartition(p); + + onPartitionInitialCounterUpdated(p, 0); + + ctx.database().checkpointReadLock(); + + try { + long partMetaId = pageMem.partitionMetaPageId(grp.groupId(), p); + long partMetaPage = pageMem.acquirePage(grp.groupId(), partMetaId); + + try { + long pageAddr = pageMem.writeLock(grp.groupId(), partMetaId, partMetaPage); + + boolean changed = false; + + try { + PagePartitionMetaIO io = PagePartitionMetaIO.VERSIONS.forPage(pageAddr); + + if (recoverState != null) { + io.setPartitionState(pageAddr, (byte) recoverState.stateId()); + + changed = updateState(part, recoverState.stateId()); + + if (recoverState.stateId() == GridDhtPartitionState.OWNING.ordinal() + || (recoverState.stateId() == GridDhtPartitionState.MOVING.ordinal() + && part.initialUpdateCounter() < recoverState.updateCounter())) { + part.initialUpdateCounter(recoverState.updateCounter()); + + changed = true; + } + + if (log.isDebugEnabled()) + log.debug("Restored partition state (from WAL) " + + "[grp=" + grp.cacheOrGroupName() + ", p=" + p + ", state=" + part.state() + + ", updCntr=" + part.initialUpdateCounter() + "]"); + } + else { + int stateId = (int) io.getPartitionState(pageAddr); + + changed = updateState(part, stateId); + + if (log.isDebugEnabled()) + log.debug("Restored partition state (from page memory) " + + "[grp=" + grp.cacheOrGroupName() + ", p=" + p + ", state=" + part.state() + + ", updCntr=" + part.initialUpdateCounter() + ", stateId=" + stateId + "]"); + } + } + finally { + pageMem.writeUnlock(grp.groupId(), partMetaId, partMetaPage, null, changed); + } + } + finally { + pageMem.releasePage(grp.groupId(), partMetaId, partMetaPage); + } + } + finally { + ctx.database().checkpointReadUnlock(); + } + } + else if (recoverState != null) { + GridDhtLocalPartition part = grp.topology().forceCreatePartition(p); + + onPartitionInitialCounterUpdated(p, recoverState.updateCounter()); + + updateState(part, recoverState.stateId()); + + processed++; + + if (log.isDebugEnabled()) + log.debug("Restored partition state (from WAL) " + + "[grp=" + grp.cacheOrGroupName() + ", p=" + p + ", state=" + part.state() + + ", updCntr=" + part.initialUpdateCounter() + "]"); + } + else { + if (log.isDebugEnabled()) + log.debug("Skipping partition on recovery (no page store OR wal state) " + + "[grp=" + grp.cacheOrGroupName() + ", p=" + p + "]"); + } + } + + partitionStatesRestored = true; + + return processed; + } + + /** + * @param part Partition to restore state for. + * @param stateId State enum ordinal. + * @return Updated flag. + */ + private boolean updateState(GridDhtLocalPartition part, int stateId) { + if (stateId != -1) { + GridDhtPartitionState state = GridDhtPartitionState.fromOrdinal(stateId); + + assert state != null; + + part.restoreState(state == GridDhtPartitionState.EVICTED ? GridDhtPartitionState.RENTING : state); + + return true; + } + + return false; + } + /** * Check that we need to snapshot this partition and add it to map. * @@ -561,10 +704,8 @@ private void updateSnapshotTag(Context ctx) throws IgniteCheckedException { log.debug("Save next snapshot before checkpoint start for grId = " + grpId + ", nextSnapshotTag = " + nextSnapshotTag); - if (PageHandler.isWalDeltaRecordNeeded(pageMem, grpId, metaPageId, - metaPage, wal, null)) - wal.log(new MetaPageUpdateNextSnapshotId(grpId, metaPageId, - nextSnapshotTag + 1)); + if (!wal.disabled(grpId)) + wal.log(new MetaPageUpdateNextSnapshotId(grpId, metaPageId, nextSnapshotTag + 1)); addPartition( null, @@ -694,19 +835,13 @@ public void destroyPartitionStore(int grpId, int partId) throws IgniteCheckedExc } /** {@inheritDoc} */ - @Override public RootPage rootPageForIndex(int cacheId, String idxName) throws IgniteCheckedException { - if (grp.sharedGroup()) - idxName = Integer.toString(cacheId) + "_" + idxName; - - return indexStorage.getOrAllocateForTree(idxName); + @Override public RootPage rootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException { + return indexStorage.allocateCacheIndex(cacheId, idxName, segment); } /** {@inheritDoc} */ - @Override public void dropRootPageForIndex(int cacheId, String idxName) throws IgniteCheckedException { - if (grp.sharedGroup()) - idxName = Integer.toString(cacheId) + "_" + idxName; - - indexStorage.dropRootPage(idxName); + @Override public void dropRootPageForIndex(int cacheId, String idxName, int segment) throws IgniteCheckedException { + indexStorage.dropCacheIndex(cacheId, idxName, segment); } /** {@inheritDoc} */ @@ -869,6 +1004,21 @@ private Metas getOrAllocateCacheMetas() throws IgniteCheckedException { return size; } + /** {@inheritDoc} */ + @Override public void preloadPartition(int part) throws IgniteCheckedException { + if (grp.isLocal()) { + dataStore(part).preload(); + + return; + } + + GridDhtLocalPartition locPart = grp.topology().localPartition(part, AffinityTopologyVersion.NONE, false, false); + + assert locPart != null && locPart.reservations() > 0; + + locPart.dataStore().preload(); + } + /** * Calculates free space of all partition data stores - number of bytes available for use in allocated pages. * @@ -1388,11 +1538,36 @@ private CacheDataStore init0(boolean checkExists) throws IgniteCheckedException @Override public PendingEntriesTree pendingTree() { return pendingTree0; } + + /** {@inheritDoc} */ + @Override public void preload() throws IgniteCheckedException { + IgnitePageStoreManager pageStoreMgr = ctx.pageStore(); + + if (pageStoreMgr == null) + return; + + final int pages = pageStoreMgr.pages(grp.groupId(), partId); + + long pageId = pageMem.partitionMetaPageId(grp.groupId(), partId); + + // For each page sequentially pin/unpin. + for (int pageNo = 0; pageNo < pages; pageId++, pageNo++) { + long pagePointer = -1; + + try { + pagePointer = pageMem.acquirePage(grp.groupId(), pageId); + } + finally { + if (pagePointer != -1) + pageMem.releasePage(grp.groupId(), pageId, pagePointer); + } + } + } }; pendingTree = pendingTree0; - if (!hasPendingEntries && pendingTree0.size() > 0) + if (!hasPendingEntries && !pendingTree0.isEmpty()) hasPendingEntries = true; int grpId = grp.groupId(); @@ -1588,6 +1763,18 @@ private Metas getOrAllocatePartitionMetas() throws IgniteCheckedException { } } + /** {@inheritDoc} */ + @Override public boolean isEmpty() { + try { + CacheDataStore delegate0 = init0(true); + + return delegate0 == null || delegate0.isEmpty(); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + } + /** {@inheritDoc} */ @Override public long cacheSize(int cacheId) { try { @@ -1681,12 +1868,11 @@ private Metas getOrAllocatePartitionMetas() throws IgniteCheckedException { } /** {@inheritDoc} */ - @Override public void finalizeUpdateCountres() { + @Override public GridLongList finalizeUpdateCounters() { try { CacheDataStore delegate0 = init0(true); - if (delegate0 != null) - delegate0.finalizeUpdateCountres(); + return delegate0 != null ? delegate0.finalizeUpdateCounters() : null; } catch (IgniteCheckedException e) { throw new IgniteException(e); @@ -2253,6 +2439,14 @@ private int purgeExpiredInternal(GridCacheContext cctx, throw new IgniteException(e); } } + + /** {@inheritDoc} */ + @Override public void preload() throws IgniteCheckedException { + CacheDataStore delegate0 = init0(true); + + if (delegate0 != null) + delegate0.preload(); + } } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java index 28ce085608d7c..7fc70d0b8923d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import javax.management.InstanceNotFoundException; import org.apache.ignite.DataRegionMetrics; import org.apache.ignite.DataStorageMetrics; @@ -37,6 +38,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; import org.apache.ignite.internal.mem.DirectMemoryProvider; import org.apache.ignite.internal.mem.DirectMemoryRegion; import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider; @@ -44,8 +46,8 @@ import org.apache.ignite.internal.pagemem.PageMemory; import org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl; import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheGroupContext; -import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; @@ -91,16 +93,25 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap private static final long MAX_PAGE_MEMORY_INIT_SIZE_32_BIT = 2L * 1024 * 1024 * 1024; /** {@code True} to reuse memory on deactive. */ - private final boolean reuseMemory = IgniteSystemProperties.getBoolean(IGNITE_REUSE_MEMORY_ON_DEACTIVATE); + protected final boolean reuseMemory = IgniteSystemProperties.getBoolean(IGNITE_REUSE_MEMORY_ON_DEACTIVATE); /** */ - protected volatile Map dataRegionMap; + protected final Map dataRegionMap = new ConcurrentHashMap<>(); + + /** Stores memory providers eligible for reuse. */ + private final Map memProviderMap = new ConcurrentHashMap<>(); + + /** */ + private static final String MBEAN_GROUP_NAME = "DataRegionMetrics"; + + /** */ + protected final Map memMetricsMap = new ConcurrentHashMap<>(); /** */ private volatile boolean dataRegionsInitialized; /** */ - protected Map memMetricsMap; + private volatile boolean dataRegionsStarted; /** */ protected DataRegion dfltDataRegion; @@ -117,8 +128,6 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap /** First eviction was warned flag. */ private volatile boolean firstEvictWarn; - /** Stores memory providers eligible for reuse. */ - private Map memProviderMap; /** {@inheritDoc} */ @Override protected void start0() throws IgniteCheckedException { @@ -137,44 +146,88 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap } /** - * Registers MBeans for all DataRegionMetrics configured in this instance. - */ - private void registerMetricsMBeans() { - if(U.IGNITE_MBEANS_DISABLED) + * @param cfg Ignite configuration. + * @param groupName Name of group. + * @param dataRegionName Metrics MBean name. + * @param impl Metrics implementation. + * @param clazz Metrics class type. + */ + protected void registerMetricsMBean( + IgniteConfiguration cfg, + String groupName, + String dataRegionName, + T impl, + Class clazz + ) { + if (U.IGNITE_MBEANS_DISABLED) return; - IgniteConfiguration cfg = cctx.gridConfig(); - - for (DataRegionMetrics memMetrics : memMetricsMap.values()) { - DataRegionConfiguration memPlcCfg = dataRegionMap.get(memMetrics.getName()).config(); - - registerMetricsMBean((DataRegionMetricsImpl)memMetrics, memPlcCfg, cfg); + try { + U.registerMBean( + cfg.getMBeanServer(), + cfg.getIgniteInstanceName(), + groupName, + dataRegionName, + impl, + clazz); + } + catch (Throwable e) { + U.error(log, "Failed to register MBean with name: " + dataRegionName, e); } } /** - * @param memMetrics Memory metrics. - * @param dataRegionCfg Data region configuration. * @param cfg Ignite configuration. + * @param groupName Name of group. + * @param name Name of MBean. */ - private void registerMetricsMBean( - DataRegionMetricsImpl memMetrics, - DataRegionConfiguration dataRegionCfg, - IgniteConfiguration cfg + protected void unregisterMetricsMBean( + IgniteConfiguration cfg, + String groupName, + String name ) { - assert !U.IGNITE_MBEANS_DISABLED; + if (U.IGNITE_MBEANS_DISABLED) + return; + + assert cfg != null; try { - U.registerMBean( - cfg.getMBeanServer(), - cfg.getIgniteInstanceName(), - "DataRegionMetrics", - dataRegionCfg.getName(), - new DataRegionMetricsMXBeanImpl(memMetrics, dataRegionCfg), - DataRegionMetricsMXBean.class); + cfg.getMBeanServer().unregisterMBean( + U.makeMBeanName( + cfg.getIgniteInstanceName(), + groupName, + name + )); + } + catch (InstanceNotFoundException ignored) { + // We tried to unregister a non-existing MBean, not a big deal. } catch (Throwable e) { - U.error(log, "Failed to register MBean for DataRegionMetrics with name: '" + memMetrics.getName() + "'", e); + U.error(log, "Failed to unregister MBean for memory metrics: " + name, e); + } + } + + /** + * Registers MBeans for all DataRegionMetrics configured in this instance. + * + * @param cfg Ignite configuration. + */ + protected void registerMetricsMBeans(IgniteConfiguration cfg) { + if (U.IGNITE_MBEANS_DISABLED) + return; + + assert cfg != null; + + for (DataRegionMetrics memMetrics : memMetricsMap.values()) { + DataRegionConfiguration memPlcCfg = dataRegionMap.get(memMetrics.getName()).config(); + + registerMetricsMBean( + cfg, + MBEAN_GROUP_NAME, + memPlcCfg.getName(), + new DataRegionMetricsMXBeanImpl((DataRegionMetricsImpl)memMetrics, memPlcCfg), + DataRegionMetricsMXBean.class + ); } } @@ -219,11 +272,11 @@ public int pageSize() { /** * */ - private void startMemoryPolicies() { - for (DataRegion memPlc : dataRegionMap.values()) { - memPlc.pageMemory().start(); + private void startDataRegions() { + for (DataRegion region : dataRegionMap.values()) { + region.pageMemory().start(); - memPlc.evictionTracker().start(); + region.evictionTracker().start(); } } @@ -238,6 +291,8 @@ protected void initDataRegions(DataStorageConfiguration memCfg) throws IgniteChe initDataRegions0(memCfg); dataRegionsInitialized = true; + + U.log(log, "Configured data regions initialized successfully [total=" + dataRegionMap.size() + ']'); } /** @@ -247,12 +302,6 @@ protected void initDataRegions(DataStorageConfiguration memCfg) throws IgniteChe protected void initDataRegions0(DataStorageConfiguration memCfg) throws IgniteCheckedException { DataRegionConfiguration[] dataRegionCfgs = memCfg.getDataRegionConfigurations(); - int dataRegions = dataRegionCfgs == null ? 0 : dataRegionCfgs.length; - - dataRegionMap = U.newHashMap(3 + dataRegions); - memMetricsMap = U.newHashMap(3 + dataRegions); - memProviderMap = reuseMemory ? U.newHashMap(3 + dataRegions) : null; - if (dataRegionCfgs != null) { for (DataRegionConfiguration dataRegionCfg : dataRegionCfgs) addDataRegion(memCfg, dataRegionCfg, dataRegionCfg.isPersistenceEnabled()); @@ -305,17 +354,17 @@ public void addDataRegion( DataRegionMetricsImpl memMetrics = new DataRegionMetricsImpl(dataRegionCfg, freeSpaceProvider(dataRegionCfg)); - DataRegion memPlc = initMemory(dataStorageCfg, dataRegionCfg, memMetrics, trackable); + DataRegion region = initMemory(dataStorageCfg, dataRegionCfg, memMetrics, trackable); - dataRegionMap.put(dataRegionName, memPlc); + dataRegionMap.put(dataRegionName, region); memMetricsMap.put(dataRegionName, memMetrics); if (dataRegionName.equals(dfltMemPlcName)) - dfltDataRegion = memPlc; + dfltDataRegion = region; else if (dataRegionName.equals(DFLT_DATA_REG_DEFAULT_NAME)) U.warn(log, "Data Region with name 'default' isn't used as a default. " + - "Please check Memory Policies configuration."); + "Please, check Data Region configuration."); } /** @@ -647,20 +696,12 @@ public DataStorageMetrics persistentStoreMetrics() { return null; } - /** - * @param cachesToStart Started caches. - * @throws IgniteCheckedException If failed. - */ - public void readCheckpointAndRestoreMemory(List cachesToStart) throws IgniteCheckedException { - // No-op. - } - /** * @param memPlcName Name of {@link DataRegion} to obtain {@link DataRegionMetrics} for. * @return {@link DataRegionMetrics} snapshot for specified {@link DataRegion} or {@code null} if * no {@link DataRegion} is configured for specified name. */ - @Nullable public DataRegionMetrics memoryMetrics(String memPlcName) { + public @Nullable DataRegionMetrics memoryMetrics(String memPlcName) { if (!F.isEmpty(memMetricsMap)) { DataRegionMetrics memMetrics = memMetricsMap.get(memPlcName); @@ -679,7 +720,7 @@ public DataRegion dataRegion(String memPlcName) throws IgniteCheckedException { if (memPlcName == null) return dfltDataRegion; - if (dataRegionMap == null) + if (dataRegionMap.isEmpty()) return null; DataRegion plc; @@ -717,32 +758,6 @@ public ReuseList reuseList(String memPlcName) { onDeActivate(true); } - /** - * Unregister MBean. - * @param name Name of mbean. - */ - private void unregisterMBean(String name) { - if(U.IGNITE_MBEANS_DISABLED) - return; - - IgniteConfiguration cfg = cctx.gridConfig(); - - try { - cfg.getMBeanServer().unregisterMBean( - U.makeMBeanName( - cfg.getIgniteInstanceName(), - "DataRegionMetrics", name - )); - } - catch (InstanceNotFoundException ignored) { - // We tried to unregister a non-existing MBean, not a big deal. - } - catch (Throwable e) { - U.error(log, "Failed to unregister MBean for memory metrics: " + - name, e); - } - } - /** {@inheritDoc} */ @Override public boolean checkpointLockIsHeldByThread() { return true; @@ -777,7 +792,15 @@ public void checkpointReadLockTimeout(long val) { } /** - * No-op for non-persistent storage. + * Method will perform cleanup cache page memory and each cache partition store. + */ + public void cleanupRestoredCaches() { + // No-op. + } + + /** + * Clean checkpoint directory {@link GridCacheDatabaseSharedManager#cpDir}. The operation + * is necessary when local node joined to baseline topology with different consistentId. */ public void cleanupCheckpointDirectory() throws IgniteCheckedException { // No-op. @@ -824,11 +847,19 @@ public void waitForCheckpoint(String reason) throws IgniteCheckedException { /** * @param discoEvt Before exchange for the given discovery event. + */ + public void beforeExchange(GridDhtPartitionsExchangeFuture discoEvt) throws IgniteCheckedException { + + } + + /** + * Perform memory restore before {@link GridDiscoveryManager} start. * - * @return {@code True} if partitions have been restored from persistent storage. + * @param kctx Current kernal context. + * @throws IgniteCheckedException If fails. */ - public boolean beforeExchange(GridDhtPartitionsExchangeFuture discoEvt) throws IgniteCheckedException { - return false; + public void startMemoryRestore(GridKernalContext kctx) throws IgniteCheckedException { + // No-op. } /** @@ -836,7 +867,7 @@ public boolean beforeExchange(GridDhtPartitionsExchangeFuture discoEvt) throws I * * @throws IgniteCheckedException If failed. */ - public void onStateRestored() throws IgniteCheckedException { + public void onStateRestored(AffinityTopologyVersion topVer) throws IgniteCheckedException { // No-op. } @@ -984,7 +1015,7 @@ private DirectMemoryProvider createOrReuseMemoryProvider(DataRegionConfiguration * * @return {@code True} if policy supports memory reuse. */ - private boolean supportsMemoryReuse(DataRegionConfiguration plcCfg) { + public boolean supportsMemoryReuse(DataRegionConfiguration plcCfg) { return reuseMemory && plcCfg.getSwapPath() == null; } @@ -1134,23 +1165,46 @@ protected File buildPath(String path, String consId) throws IgniteCheckedExcepti /** {@inheritDoc} */ @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException { - if (cctx.kernalContext().clientNode() && cctx.kernalContext().config().getDataStorageConfiguration() == null) + if (kctx.clientNode() && kctx.config().getDataStorageConfiguration() == null) return; - DataStorageConfiguration memCfg = cctx.kernalContext().config().getDataStorageConfiguration(); + initAndStartRegions(kctx.config().getDataStorageConfiguration()); - assert memCfg != null; + for (DatabaseLifecycleListener lsnr : getDatabaseListeners(kctx)) + lsnr.afterInitialise(this); + } - initDataRegions(memCfg); + /** + * @param cfg Current data storage configuration. + * @throws IgniteCheckedException If fails. + */ + protected void initAndStartRegions(DataStorageConfiguration cfg) throws IgniteCheckedException { + assert cfg != null; + + initDataRegions(cfg); - registerMetricsMBeans(); + startDataRegions(cfg); + } - startMemoryPolicies(); + /** + * @param cfg Regions configuration. + * @throws IgniteCheckedException If fails. + */ + private void startDataRegions(DataStorageConfiguration cfg) throws IgniteCheckedException { + if (dataRegionsStarted) + return; - initPageMemoryDataStructures(memCfg); + assert cfg != null; - for (DatabaseLifecycleListener lsnr : getDatabaseListeners(kctx)) - lsnr.afterInitialise(this); + registerMetricsMBeans(cctx.gridConfig()); + + startDataRegions(); + + initPageMemoryDataStructures(cfg); + + dataRegionsStarted = true; + + U.log(log, "Configured data regions started successfully [total=" + dataRegionMap.size() + ']'); } /** {@inheritDoc} */ @@ -1159,33 +1213,32 @@ protected File buildPath(String path, String consId) throws IgniteCheckedExcepti } /** - * @param shutdown Shutdown. + * @param shutdown {@code True} to force memory regions shutdown. */ private void onDeActivate(boolean shutdown) { for (DatabaseLifecycleListener lsnr : getDatabaseListeners(cctx.kernalContext())) lsnr.beforeStop(this); - if (dataRegionMap != null) { - for (DataRegion memPlc : dataRegionMap.values()) { - memPlc.pageMemory().stop(shutdown); + for (DataRegion region : dataRegionMap.values()) { + region.pageMemory().stop(shutdown); - memPlc.evictionTracker().stop(); + region.evictionTracker().stop(); - unregisterMBean(memPlc.memoryMetrics().getName()); + unregisterMetricsMBean( + cctx.gridConfig(), + MBEAN_GROUP_NAME, + region.memoryMetrics().getName() + ); } - dataRegionMap.clear(); + dataRegionMap.clear(); - dataRegionMap = null; + if (shutdown && memProviderMap != null) + memProviderMap.clear(); - if (shutdown && memProviderMap != null) { - memProviderMap.clear(); + dataRegionsInitialized = false; - memProviderMap = null; - } - - dataRegionsInitialized = false; - } + dataRegionsStarted = false; } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IndexStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IndexStorage.java index 5141b04868f7c..295ff00f26311 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IndexStorage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IndexStorage.java @@ -23,6 +23,17 @@ * Meta store. */ public interface IndexStorage { + /** + * Allocate page for cache index. Index name will be masked if needed. + * + * @param cacheId Cache ID. + * @param idxName Index name. + * @param segment Segment. + * @return Root page. + * @throws IgniteCheckedException If failed. + */ + public RootPage allocateCacheIndex(Integer cacheId, String idxName, int segment) throws IgniteCheckedException; + /** * Get or allocate initial page for an index. * @@ -31,7 +42,18 @@ public interface IndexStorage { * was newly allocated, and rootId that is counter which increments each time new page allocated. * @throws IgniteCheckedException If failed. */ - public RootPage getOrAllocateForTree(String idxName) throws IgniteCheckedException; + public RootPage allocateIndex(String idxName) throws IgniteCheckedException; + + /** + * Deallocate index page and remove from tree. + * + * @param cacheId Cache ID. + * @param idxName Index name. + * @param segment Segment. + * @return Root ID or -1 if no page was removed. + * @throws IgniteCheckedException If failed. + */ + public RootPage dropCacheIndex(Integer cacheId, String idxName, int segment) throws IgniteCheckedException; /** * Deallocate index page and remove from tree. @@ -40,7 +62,7 @@ public interface IndexStorage { * @return Root ID or -1 if no page was removed. * @throws IgniteCheckedException If failed. */ - public RootPage dropRootPage(String idxName) throws IgniteCheckedException; + public RootPage dropIndex(String idxName) throws IgniteCheckedException; /** * Destroy this meta store. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IndexStorageImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IndexStorageImpl.java index 6248765525866..b29553c6b8e2a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IndexStorageImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IndexStorageImpl.java @@ -61,6 +61,9 @@ public class IndexStorageImpl implements IndexStorage { /** Cache group ID. */ private final int grpId; + /** Whether group is shared. */ + private final boolean grpShared; + /** */ private final int allocPartId; @@ -76,6 +79,7 @@ public IndexStorageImpl( final IgniteWriteAheadLogManager wal, final AtomicLong globalRmvId, final int grpId, + boolean grpShared, final int allocPartId, final byte allocSpace, final ReuseList reuseList, @@ -86,6 +90,7 @@ public IndexStorageImpl( try { this.pageMem = pageMem; this.grpId = grpId; + this.grpShared = grpShared; this.allocPartId = allocPartId; this.allocSpace = allocSpace; this.reuseList = reuseList; @@ -99,7 +104,15 @@ public IndexStorageImpl( } /** {@inheritDoc} */ - @Override public RootPage getOrAllocateForTree(final String idxName) throws IgniteCheckedException { + @Override public RootPage allocateCacheIndex(Integer cacheId, String idxName, int segment) + throws IgniteCheckedException { + String maskedIdxName = maskCacheIndexName(cacheId, idxName, segment); + + return allocateIndex(maskedIdxName); + } + + /** {@inheritDoc} */ + @Override public RootPage allocateIndex(String idxName) throws IgniteCheckedException { final MetaTree tree = metaTree; synchronized (this) { @@ -132,8 +145,15 @@ public IndexStorageImpl( } /** {@inheritDoc} */ - @Override public RootPage dropRootPage(final String idxName) + @Override public RootPage dropCacheIndex(Integer cacheId, String idxName, int segment) throws IgniteCheckedException { + String maskedIdxName = maskCacheIndexName(cacheId, idxName, segment); + + return dropIndex(maskedIdxName); + } + + /** {@inheritDoc} */ + @Override public RootPage dropIndex(final String idxName) throws IgniteCheckedException { byte[] idxNameBytes = idxName.getBytes(StandardCharsets.UTF_8); final IndexItem row = metaTree.remove(new IndexItem(idxNameBytes, 0)); @@ -151,6 +171,19 @@ public IndexStorageImpl( metaTree.destroy(); } + /** + * Mask cache index name. + * + * @param idxName Index name. + * @return Masked name. + */ + private String maskCacheIndexName(Integer cacheId, String idxName, int segment) { + if (grpShared) + idxName = Integer.toString(cacheId) + "_" + idxName; + + return idxName + "%" + segment; + } + /** * */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AsyncFileIOFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AsyncFileIOFactory.java index 104697e810e58..e0c545b8a87c0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AsyncFileIOFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AsyncFileIOFactory.java @@ -22,10 +22,6 @@ import java.nio.channels.AsynchronousFileChannel; import java.nio.file.OpenOption; -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; - /** * File I/O factory which uses {@link AsynchronousFileChannel} based implementation of FileIO. */ @@ -36,11 +32,6 @@ public class AsyncFileIOFactory implements FileIOFactory { /** Thread local channel future holder. */ private transient volatile ThreadLocal holder = initHolder(); - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, READ, WRITE); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { if (holder == null) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/EncryptedFileIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/EncryptedFileIO.java index 008a72830899b..86d9bbc5b56e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/EncryptedFileIO.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/EncryptedFileIO.java @@ -21,10 +21,11 @@ import java.io.Serializable; import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; + +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc; import org.apache.ignite.spi.encryption.EncryptionSpi; import org.apache.ignite.internal.managers.encryption.GridEncryptionManager; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO; -import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; import org.apache.ignite.internal.util.typedef.internal.CU; /** @@ -260,7 +261,7 @@ private void decrypt(ByteBuffer encrypted, ByteBuffer destBuf) throws IOExceptio * @param res Destination buffer. */ private void storeCRC(ByteBuffer res) { - int crc = PureJavaCrc32.calcCrc32(res, encryptedDataSize()); + int crc = FastCrc.calcCrc(res, encryptedDataSize()); res.put((byte) (crc >> 24)); res.put((byte) (crc >> 16)); @@ -274,7 +275,7 @@ private void storeCRC(ByteBuffer res) { * @param encrypted Encrypted data buffer. */ private void checkCRC(ByteBuffer encrypted) throws IOException { - int crc = PureJavaCrc32.calcCrc32(encrypted, encryptedDataSize()); + int crc = FastCrc.calcCrc(encrypted, encryptedDataSize()); int storedCrc = 0; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/EncryptedFileIOFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/EncryptedFileIOFactory.java index 336aab6fa85dd..b4b0389ef2c39 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/EncryptedFileIOFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/EncryptedFileIOFactory.java @@ -75,13 +75,6 @@ public class EncryptedFileIOFactory implements FileIOFactory { this.encSpi = encSpi; } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - FileIO io = plainIOFactory.create(file); - - return new EncryptedFileIO(io, groupId, pageSize, headerSize, encMgr, encSpi); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { FileIO io = plainIOFactory.create(file, modes); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FileIOFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FileIOFactory.java index 27351853269db..b236000d07c72 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FileIOFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FileIOFactory.java @@ -22,6 +22,10 @@ import java.io.Serializable; import java.nio.file.OpenOption; +import static java.nio.file.StandardOpenOption.CREATE; +import static java.nio.file.StandardOpenOption.READ; +import static java.nio.file.StandardOpenOption.WRITE; + /** * {@link FileIO} factory definition. */ @@ -33,7 +37,9 @@ public interface FileIOFactory extends Serializable { * @return File I/O interface. * @throws IOException If I/O interface creation was failed. */ - public FileIO create(File file) throws IOException; + default FileIO create(File file) throws IOException{ + return create(file, CREATE, READ, WRITE); + }; /** * Creates I/O interface for file with specified mode. @@ -43,5 +49,5 @@ public interface FileIOFactory extends Serializable { * @return File I/O interface. * @throws IOException If I/O interface creation was failed. */ - public FileIO create(File file, OpenOption... modes) throws IOException; + FileIO create(File file, OpenOption... modes) throws IOException; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStore.java index 2e0786798078b..16d74c33c66e6 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStore.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStore.java @@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; + import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.configuration.DataStorageConfiguration; @@ -35,8 +36,8 @@ import org.apache.ignite.internal.processors.cache.persistence.AllocatedPageTracker; import org.apache.ignite.internal.processors.cache.persistence.StorageException; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO; +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc; import org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException; -import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; import org.apache.ignite.internal.util.typedef.internal.U; import static java.nio.file.StandardOpenOption.CREATE; @@ -257,6 +258,10 @@ private long checkFile(FileIO fileIO) throws IOException { + ", delete=" + delete + "]", e); } finally { + allocatedTracker.updateTotalAllocatedPages(-1L * allocated.getAndSet(0) / pageSize); + + inited = false; + lock.writeLock().unlock(); } } @@ -358,7 +363,7 @@ private long checkFile(FileIO fileIO) throws IOException { pageBuf.position(0); if (!skipCrc) { - int curCrc32 = PureJavaCrc32.calcCrc32(pageBuf, pageSize); + int curCrc32 = FastCrc.calcCrc(pageBuf, pageSize); if ((savedCrc32 ^ curCrc32) != 0) throw new IgniteDataIntegrityViolationException("Failed to read page (CRC validation failed) " + @@ -541,7 +546,8 @@ private void reinit(FileIO fileIO) throws IOException { long off = pageOffset(pageId); assert (off >= 0 && off <= allocated.get()) || recover : - "off=" + U.hexLong(off) + ", allocated=" + U.hexLong(allocated.get()) + ", pageId=" + U.hexLong(pageId); + "off=" + U.hexLong(off) + ", allocated=" + U.hexLong(allocated.get()) + + ", pageId=" + U.hexLong(pageId) + ", file=" + cfgFile.getPath(); assert pageBuf.capacity() == pageSize; assert pageBuf.position() == 0; @@ -613,7 +619,7 @@ private static int calcCrc32(ByteBuffer pageBuf, int pageSize) { try { pageBuf.position(0); - return PureJavaCrc32.calcCrc32(pageBuf, pageSize); + return FastCrc.calcCrc(pageBuf, pageSize); } finally { pageBuf.position(0); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java index c6cd9e502c2c2..c293e692b50f8 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java @@ -22,7 +22,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -32,12 +31,17 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.function.Predicate; +import java.util.stream.Collectors; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; @@ -54,12 +58,16 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter; import org.apache.ignite.internal.processors.cache.StoredCacheData; import org.apache.ignite.internal.processors.cache.persistence.AllocatedPageTracker; +import org.apache.ignite.internal.processors.cache.persistence.DataRegion; import org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl; +import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.StorageException; import org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings; import org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage; import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteCacheSnapshotManager; +import org.apache.ignite.internal.util.GridStripedReadWriteLock; import org.apache.ignite.internal.util.IgniteUtils; +import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; @@ -143,6 +151,10 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen /** */ private final Set grpsWithoutIdx = Collections.newSetFromMap(new ConcurrentHashMap()); + /** */ + private final GridStripedReadWriteLock initDirLock = + new GridStripedReadWriteLock(Math.max(Runtime.getRuntime().availableProcessors(), 8)); + /** * @param ctx Kernal context. */ @@ -181,6 +193,22 @@ public FilePageStoreManager(GridKernalContext ctx) { "DataStorageConfiguration#storagePath properties). " + "Current persistence store directory is: [" + tmpDir + "]"); } + + File[] files = storeWorkDir.listFiles(); + + for (File file : files) { + if (file.isDirectory()) { + File[] tmpFiles = file.listFiles((k, v) -> v.endsWith(CACHE_DATA_TMP_FILENAME)); + + if (tmpFiles != null) { + for (File tmpFile : tmpFiles) { + if (!tmpFile.delete()) + log.warning("Failed to delete temporary cache config file" + + "(make sure Ignite process has enough rights):" + file.getName()); + } + } + } + } } /** {@inheritDoc} */ @@ -226,15 +254,29 @@ public FilePageStoreManager(GridKernalContext ctx) { } } + /** {@inheritDoc} */ + @Override public void cleanupPageStoreIfMatch(Predicate cacheGrpPred, boolean cleanFiles) { + Map filteredStores = idxCacheStores.entrySet().stream() + .filter(e -> cacheGrpPred.test(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + IgniteCheckedException ex = shutdown(filteredStores.values(), cleanFiles); + + if (ex != null) + U.error(log, "Failed to gracefully stop page store managers", ex); + + idxCacheStores.entrySet().removeIf(e -> cacheGrpPred.test(e.getKey())); + + U.log(log, "Cleanup cache stores [total=" + filteredStores.keySet().size() + + ", left=" + idxCacheStores.size() + ", cleanFiles=" + cleanFiles + ']'); + } + /** {@inheritDoc} */ @Override public void stop0(boolean cancel) { if (log.isDebugEnabled()) log.debug("Stopping page store manager."); - IgniteCheckedException ex = shutdown(false); - - if (ex != null) - U.error(log, "Failed to gracefully stop page store manager", ex); + cleanupPageStoreIfMatch(p -> true, false); } /** {@inheritDoc} */ @@ -253,8 +295,6 @@ public FilePageStoreManager(GridKernalContext ctx) { " topVer=" + cctx.discovery().topologyVersionEx() + " ]"); stop0(true); - - idxCacheStores.clear(); } /** {@inheritDoc} */ @@ -287,6 +327,8 @@ public FilePageStoreManager(GridKernalContext ctx) { /** {@inheritDoc} */ @Override public void initialize(int cacheId, int partitions, String workingDir, AllocatedPageTracker tracker) throws IgniteCheckedException { + assert storeWorkDir != null; + if (!idxCacheStores.containsKey(cacheId)) { CacheStoreHolder holder = initDir( new File(storeWorkDir, workingDir), @@ -304,6 +346,8 @@ public FilePageStoreManager(GridKernalContext ctx) { /** {@inheritDoc} */ @Override public void initializeForCache(CacheGroupDescriptor grpDesc, StoredCacheData cacheData) throws IgniteCheckedException { + assert storeWorkDir != null; + int grpId = grpDesc.groupId(); if (!idxCacheStores.containsKey(grpId)) { @@ -317,14 +361,18 @@ public FilePageStoreManager(GridKernalContext ctx) { /** {@inheritDoc} */ @Override public void initializeForMetastorage() throws IgniteCheckedException { + assert storeWorkDir != null; + int grpId = MetaStorage.METASTORAGE_CACHE_ID; if (!idxCacheStores.containsKey(grpId)) { + DataRegion dataRegion = cctx.database().dataRegion(GridCacheDatabaseSharedManager.METASTORE_DATA_REGION_NAME); + CacheStoreHolder holder = initDir( new File(storeWorkDir, META_STORAGE_NAME), grpId, - 1, - AllocatedPageTracker.NO_OP, + PageIdAllocator.METASTORE_PARTITION + 1, + dataRegion.memoryMetrics(), false); CacheStoreHolder old = idxCacheStores.put(grpId, holder); @@ -353,17 +401,17 @@ public FilePageStoreManager(GridKernalContext ctx) { if (overwrite || !Files.exists(filePath) || Files.size(filePath) == 0) { File tmp = new File(file.getParent(), file.getName() + TMP_SUFFIX); - tmp.createNewFile(); + if (tmp.exists() && !tmp.delete()) { + log.warning("Failed to delete temporary cache config file" + + "(make sure Ignite process has enough rights):" + file.getName()); + } // Pre-existing file will be truncated upon stream open. try (OutputStream stream = new BufferedOutputStream(new FileOutputStream(tmp))) { marshaller.marshal(cacheData, stream); } - if (file.exists()) - file.delete(); - - Files.move(tmp.toPath(), file.toPath()); + Files.move(tmp.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING); } } catch (IOException ex) { @@ -379,16 +427,15 @@ public FilePageStoreManager(GridKernalContext ctx) { CacheStoreHolder old = idxCacheStores.remove(grp.groupId()); - assert old != null : "Missing cache store holder [cache=" + grp.cacheOrGroupName() + - ", locNodeId=" + cctx.localNodeId() + ", gridName=" + cctx.igniteInstanceName() + ']'; + if (old != null) { + IgniteCheckedException ex = shutdown(old, /*clean files if destroy*/destroy, null); - IgniteCheckedException ex = shutdown(old, /*clean files if destroy*/destroy, null); + if (destroy) + removeCacheGroupConfigurationData(grp); - if (destroy) - removeCacheGroupConfigurationData(grp); - - if (ex != null) - throw ex; + if (ex != null) + throw ex; + } } /** {@inheritDoc} */ @@ -600,8 +647,9 @@ private CacheStoreHolder initDir(File cacheWorkDir, return new CacheStoreHolder(idxStore, partStores); } - catch (StorageException e) { - cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); + catch (IgniteCheckedException e) { + if (X.hasCause(e, StorageException.class, IOException.class)) + cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); throw e; } @@ -626,69 +674,78 @@ private CacheStoreHolder initDir(File cacheWorkDir, private boolean checkAndInitCacheWorkDir(File cacheWorkDir) throws IgniteCheckedException { boolean dirExisted = false; - if (!Files.exists(cacheWorkDir.toPath())) { - try { - Files.createDirectory(cacheWorkDir.toPath()); - } - catch (IOException e) { - throw new IgniteCheckedException("Failed to initialize cache working directory " + - "(failed to create, make sure the work folder has correct permissions): " + - cacheWorkDir.getAbsolutePath(), e); + ReadWriteLock lock = initDirLock.getLock(cacheWorkDir.getName().hashCode()); + + lock.writeLock().lock(); + + try { + if (!Files.exists(cacheWorkDir.toPath())) { + try { + Files.createDirectory(cacheWorkDir.toPath()); + } + catch (IOException e) { + throw new IgniteCheckedException("Failed to initialize cache working directory " + + "(failed to create, make sure the work folder has correct permissions): " + + cacheWorkDir.getAbsolutePath(), e); + } } - } - else { - if (cacheWorkDir.isFile()) - throw new IgniteCheckedException("Failed to initialize cache working directory " + - "(a file with the same name already exists): " + cacheWorkDir.getAbsolutePath()); + else { + if (cacheWorkDir.isFile()) + throw new IgniteCheckedException("Failed to initialize cache working directory " + + "(a file with the same name already exists): " + cacheWorkDir.getAbsolutePath()); - File lockF = new File(cacheWorkDir, IgniteCacheSnapshotManager.SNAPSHOT_RESTORE_STARTED_LOCK_FILENAME); + File lockF = new File(cacheWorkDir, IgniteCacheSnapshotManager.SNAPSHOT_RESTORE_STARTED_LOCK_FILENAME); - Path cacheWorkDirPath = cacheWorkDir.toPath(); + Path cacheWorkDirPath = cacheWorkDir.toPath(); - Path tmp = cacheWorkDirPath.getParent().resolve(cacheWorkDir.getName() + TMP_SUFFIX); + Path tmp = cacheWorkDirPath.getParent().resolve(cacheWorkDir.getName() + TMP_SUFFIX); - if (Files.exists(tmp) && Files.isDirectory(tmp) && + if (Files.exists(tmp) && Files.isDirectory(tmp) && Files.exists(tmp.resolve(IgniteCacheSnapshotManager.TEMP_FILES_COMPLETENESS_MARKER))) { - U.warn(log, "Ignite node crashed during the snapshot restore process " + - "(there is a snapshot restore lock file left for cache). But old version of cache was saved. " + - "Trying to restore it. Cache - [" + cacheWorkDir.getAbsolutePath() + ']'); + U.warn(log, "Ignite node crashed during the snapshot restore process " + + "(there is a snapshot restore lock file left for cache). But old version of cache was saved. " + + "Trying to restore it. Cache - [" + cacheWorkDir.getAbsolutePath() + ']'); - U.delete(cacheWorkDir); + U.delete(cacheWorkDir); - try { - Files.move(tmp, cacheWorkDirPath, StandardCopyOption.ATOMIC_MOVE); + try { + Files.move(tmp, cacheWorkDirPath, StandardCopyOption.ATOMIC_MOVE); - cacheWorkDirPath.resolve(IgniteCacheSnapshotManager.TEMP_FILES_COMPLETENESS_MARKER).toFile().delete(); - } - catch (IOException e) { - throw new IgniteCheckedException(e); + cacheWorkDirPath.resolve(IgniteCacheSnapshotManager.TEMP_FILES_COMPLETENESS_MARKER).toFile().delete(); + } + catch (IOException e) { + throw new IgniteCheckedException(e); + } } - } - else if (lockF.exists()) { - U.warn(log, "Ignite node crashed during the snapshot restore process " + - "(there is a snapshot restore lock file left for cache). Will remove both the lock file and " + - "incomplete cache directory [cacheDir=" + cacheWorkDir.getAbsolutePath() + ']'); + else if (lockF.exists()) { + U.warn(log, "Ignite node crashed during the snapshot restore process " + + "(there is a snapshot restore lock file left for cache). Will remove both the lock file and " + + "incomplete cache directory [cacheDir=" + cacheWorkDir.getAbsolutePath() + ']'); - boolean deleted = U.delete(cacheWorkDir); + boolean deleted = U.delete(cacheWorkDir); - if (!deleted) - throw new IgniteCheckedException("Failed to remove obsolete cache working directory " + - "(remove the directory manually and make sure the work folder has correct permissions): " + - cacheWorkDir.getAbsolutePath()); + if (!deleted) + throw new IgniteCheckedException("Failed to remove obsolete cache working directory " + + "(remove the directory manually and make sure the work folder has correct permissions): " + + cacheWorkDir.getAbsolutePath()); - cacheWorkDir.mkdirs(); - } - else - dirExisted = true; + cacheWorkDir.mkdirs(); + } + else + dirExisted = true; - if (!cacheWorkDir.exists()) - throw new IgniteCheckedException("Failed to initialize cache working directory " + - "(failed to create, make sure the work folder has correct permissions): " + - cacheWorkDir.getAbsolutePath()); + if (!cacheWorkDir.exists()) + throw new IgniteCheckedException("Failed to initialize cache working directory " + + "(failed to create, make sure the work folder has correct permissions): " + + cacheWorkDir.getAbsolutePath()); - if (Files.exists(tmp)) - U.delete(tmp); + if (Files.exists(tmp)) + U.delete(tmp); + } + } + finally { + lock.writeLock().unlock(); } return dirExisted; @@ -764,20 +821,6 @@ else if (lockF.exists()) { for (File file : files) { if (file.isDirectory()) { - File[] tmpFiles = file.listFiles(new FilenameFilter() { - @Override public boolean accept(File dir, String name) { - return name.endsWith(CACHE_DATA_TMP_FILENAME); - } - }); - - if (tmpFiles != null) { - for (File tmpFile: tmpFiles) { - if (!tmpFile.delete()) - log.warning("Failed to delete temporary cache config file" + - "(make sure Ignite process has enough rights):" + file.getName()); - } - } - if (file.getName().startsWith(CACHE_DIR_PREFIX)) { File conf = new File(file, CACHE_DATA_FILENAME); @@ -898,10 +941,10 @@ public File cacheWorkDir(boolean isSharedGroup, String cacheOrGroupName) { /** * @param cleanFiles {@code True} if the stores should delete it's files upon close. */ - private IgniteCheckedException shutdown(boolean cleanFiles) { + private IgniteCheckedException shutdown(Collection holders, boolean cleanFiles) { IgniteCheckedException ex = null; - for (CacheStoreHolder holder : idxCacheStores.values()) + for (CacheStoreHolder holder : holders) ex = shutdown(holder, cleanFiles, ex); return ex; @@ -989,6 +1032,39 @@ private IgniteCheckedException shutdown(PageStore store, boolean cleanFile, Igni return aggr; } + /** + * Return cache store holedr. + * + * @param grpId Cache group ID. + * @return Cache store holder. + */ + private CacheStoreHolder getHolder(int grpId) throws IgniteCheckedException { + try { + return idxCacheStores.computeIfAbsent(grpId, (key) -> { + CacheGroupDescriptor gDesc = cctx.cache().cacheGroupDescriptors().get(grpId); + + CacheStoreHolder holder0 = null; + + if (gDesc != null) { + if (CU.isPersistentCache(gDesc.config(), cctx.gridConfig().getDataStorageConfiguration())) { + try { + holder0 = initForCache(gDesc, gDesc.config()); + } catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + } + } + + return holder0; + }); + } catch (IgniteException ex) { + if (X.hasCause(ex, IgniteCheckedException.class)) + throw ex.getCause(IgniteCheckedException.class); + else + throw ex; + } + } + /** * @param grpId Cache group ID. * @param partId Partition ID. @@ -998,7 +1074,7 @@ private IgniteCheckedException shutdown(PageStore store, boolean cleanFile, Igni * Note: visible for testing. */ public PageStore getStore(int grpId, int partId) throws IgniteCheckedException { - CacheStoreHolder holder = idxCacheStores.get(grpId); + CacheStoreHolder holder = getHolder(grpId); if (holder == null) throw new IgniteCheckedException("Failed to get page store for the given cache ID " + diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/RandomAccessFileIOFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/RandomAccessFileIOFactory.java index 856ba1c749b45..3fa3e2dded52d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/RandomAccessFileIOFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/RandomAccessFileIOFactory.java @@ -21,10 +21,6 @@ import java.io.IOException; import java.nio.file.OpenOption; -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; - /** * File I/O factory which provides RandomAccessFileIO implementation of FileIO. */ @@ -32,11 +28,6 @@ public class RandomAccessFileIOFactory implements FileIOFactory { /** */ private static final long serialVersionUID = 0L; - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, READ, WRITE); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { return new RandomAccessFileIO(file, modes); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetaStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetaStorage.java index 3981d4d906d11..6559b07157271 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetaStorage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetaStorage.java @@ -17,24 +17,37 @@ package org.apache.ignite.internal.processors.cache.persistence.metastorage; +import java.io.Closeable; +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; import java.io.Serializable; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Stream; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.pagemem.FullPageId; +import org.apache.ignite.internal.pagemem.PageIdAllocator; import org.apache.ignite.internal.pagemem.PageIdUtils; import org.apache.ignite.internal.pagemem.PageMemory; import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; -import org.apache.ignite.internal.processors.cache.persistence.StorageException; import org.apache.ignite.internal.pagemem.wal.WALPointer; import org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord; import org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRecord; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; +import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.IncompleteObject; import org.apache.ignite.internal.processors.cache.persistence.DataRegion; @@ -43,6 +56,7 @@ import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.RootPage; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; import org.apache.ignite.internal.processors.cache.persistence.freelist.AbstractFreeList; import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx; import org.apache.ignite.internal.processors.cache.persistence.tree.io.AbstractDataPageIO; @@ -57,11 +71,14 @@ import org.apache.ignite.internal.util.lang.GridCursor; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.jetbrains.annotations.NotNull; +import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA; +import static org.apache.ignite.internal.pagemem.PageIdAllocator.OLD_METASTORE_PARTITION; import static org.apache.ignite.internal.pagemem.PageIdUtils.itemId; import static org.apache.ignite.internal.pagemem.PageIdUtils.pageId; @@ -75,9 +92,19 @@ public class MetaStorage implements DbCheckpointListener, ReadOnlyMetastorage, R /** */ public static final int METASTORAGE_CACHE_ID = CU.cacheId(METASTORAGE_CACHE_NAME); + /** This flag is used ONLY FOR TESTING the migration of a metastorage from Part 0 to Part 1. */ + public static boolean PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = false; + /** Marker for removed entry. */ private static final byte[] TOMBSTONE = new byte[0]; + /** Temporary metastorage memory size. */ + private static final int TEMPORARY_METASTORAGE_IN_MEMORY_SIZE = 128 * 1024 * 1024; + + /** Temporary metastorage buffer size (file). */ + private static final int TEMPORARY_METASTORAGE_BUFFER_SIZE = 1024 * 1024; + + /** */ private final IgniteWriteAheadLogManager wal; @@ -97,7 +124,7 @@ public class MetaStorage implements DbCheckpointListener, ReadOnlyMetastorage, R private DataRegionMetricsImpl regionMetrics; /** */ - private boolean readOnly; + private final boolean readOnly; /** */ private boolean empty; @@ -120,6 +147,12 @@ public class MetaStorage implements DbCheckpointListener, ReadOnlyMetastorage, R /** */ private final FailureProcessor failureProcessor; + /** Partition id. */ + private int partId; + + /** Cctx. */ + private final GridCacheSharedContext cctx; + /** */ public MetaStorage( GridCacheSharedContext cctx, @@ -127,6 +160,7 @@ public MetaStorage( DataRegionMetricsImpl regionMetrics, boolean readOnly ) { + this.cctx = cctx; wal = cctx.wal(); this.dataRegion = dataRegion; this.regionMetrics = regionMetrics; @@ -136,13 +170,80 @@ public MetaStorage( } /** */ - public MetaStorage(GridCacheSharedContext cctx, DataRegion memPlc, DataRegionMetricsImpl memMetrics) { - this(cctx, memPlc, memMetrics, false); + public void init(GridCacheDatabaseSharedManager db) throws IgniteCheckedException { + regionMetrics.clear(); + + initInternal(db); + + if (!PRESERVE_LEGACY_METASTORAGE_PARTITION_ID) { + GridCacheProcessor gcProcessor = cctx.kernalContext().cache(); + + if (partId == OLD_METASTORE_PARTITION) + gcProcessor.setTmpStorage(copyDataToTmpStorage()); + else if (gcProcessor.getTmpStorage() != null) { + restoreDataFromTmpStorage(gcProcessor.getTmpStorage()); + + gcProcessor.setTmpStorage(null); + + // remove old partitions + CacheGroupContext cgc = cctx.cache().cacheGroup(METASTORAGE_CACHE_ID); + + if (cgc != null) { + db.schedulePartitionDestroy(METASTORAGE_CACHE_ID, OLD_METASTORE_PARTITION); + + db.schedulePartitionDestroy(METASTORAGE_CACHE_ID, PageIdAllocator.INDEX_PARTITION); + } + } + } } - /** */ - public void init(IgniteCacheDatabaseSharedManager db) throws IgniteCheckedException { - getOrAllocateMetas(); + /** + * Copying all data from the 'meta' to temporary storage. + * + * @return Target temporary storage + */ + private TmpStorage copyDataToTmpStorage() throws IgniteCheckedException { + TmpStorage tmpStorage = new TmpStorage(TEMPORARY_METASTORAGE_IN_MEMORY_SIZE, log); + + GridCursor cur = tree.find(null, null); + + while (cur.next()) { + MetastorageDataRow row = cur.get(); + + tmpStorage.add(row.key(), row.value()); + } + + return tmpStorage; + } + + /** + * Data recovery from temporary storage + * + * @param tmpStorage temporary storage. + */ + private void restoreDataFromTmpStorage(TmpStorage tmpStorage) throws IgniteCheckedException { + for (Iterator> it = tmpStorage.stream().iterator(); it.hasNext(); ) { + IgniteBiTuple t = it.next(); + + putData(t.get1(), t.get2()); + } + + try { + tmpStorage.close(); + } + catch (IOException e) { + log.error(e.getMessage(), e); + } + } + + /** + * @param db Database. + */ + private void initInternal(IgniteCacheDatabaseSharedManager db) throws IgniteCheckedException { + if (PRESERVE_LEGACY_METASTORAGE_PARTITION_ID) + getOrAllocateMetas(partId = PageIdAllocator.OLD_METASTORE_PARTITION); + else if (!readOnly || getOrAllocateMetas(partId = PageIdAllocator.OLD_METASTORE_PARTITION)) + getOrAllocateMetas(partId = PageIdAllocator.METASTORE_PARTITION); if (!empty) { freeList = new FreeListImpl(METASTORAGE_CACHE_ID, "metastorage", @@ -152,7 +253,7 @@ public void init(IgniteCacheDatabaseSharedManager db) throws IgniteCheckedExcept MetastorageRowStore rowStore = new MetastorageRowStore(freeList, db); tree = new MetastorageTree(METASTORAGE_CACHE_ID, dataRegion.pageMemory(), wal, rmvId, - freeList, rowStore, treeRoot.pageId().pageId(), treeRoot.isAllocated(), failureProcessor); + freeList, rowStore, treeRoot.pageId().pageId(), treeRoot.isAllocated(), failureProcessor, partId); if (!readOnly) ((GridCacheDatabaseSharedManager)db).addCheckpointListener(this); @@ -227,6 +328,23 @@ public void init(IgniteCacheDatabaseSharedManager db) throws IgniteCheckedExcept return res; } + /** + * Read all items from metastore. + */ + public Collection> readAll() throws IgniteCheckedException { + ArrayList> res = new ArrayList<>(); + + GridCursor cur = tree.find(null, null); + + while (cur.next()) { + MetastorageDataRow row = cur.get(); + + res.add(new IgniteBiTuple<>(row.key(), row.value())); + } + + return res; + } + /** {@inheritDoc} */ @Override public void write(@NotNull String key, @NotNull Serializable val) throws IgniteCheckedException { assert val != null; @@ -315,11 +433,16 @@ private void checkRootsPageIdFlag(long treeRoot, long reuseListRoot) throws Stor + U.hexLong(reuseListRoot) + ", METASTORAGE_CACHE_ID=" + METASTORAGE_CACHE_ID); } - /** */ - private void getOrAllocateMetas() throws IgniteCheckedException { - PageMemoryEx pageMem = (PageMemoryEx)dataRegion.pageMemory(); + /** + * Initializing the selected partition for use as MetaStorage + * + * @param partId Partition id. + * @return true if the partion is empty + */ + private boolean getOrAllocateMetas(int partId) throws IgniteCheckedException { + empty = false; - int partId = 0; + PageMemoryEx pageMem = (PageMemoryEx)dataRegion.pageMemory(); long partMetaId = pageMem.partitionMetaPageId(METASTORAGE_CACHE_ID, partId); long partMetaPage = pageMem.acquirePage(METASTORAGE_CACHE_ID, partMetaId); @@ -331,7 +454,7 @@ private void getOrAllocateMetas() throws IgniteCheckedException { if (PageIO.getType(pageAddr) != PageIO.T_PART_META) { empty = true; - return; + return true; } PagePartitionMetaIO io = PageIO.getPageIO(pageAddr); @@ -407,6 +530,8 @@ private void getOrAllocateMetas() throws IgniteCheckedException { finally { pageMem.releasePage(METASTORAGE_CACHE_ID, partMetaId, partMetaPage); } + + return false; } /** @@ -452,8 +577,6 @@ public PageMemory pageMemory() { private void saveStoreMetadata() throws IgniteCheckedException { PageMemoryEx pageMem = (PageMemoryEx) pageMemory(); - int partId = 0; - long partMetaId = pageMem.partitionMetaPageId(METASTORAGE_CACHE_ID, partId); long partMetaPage = pageMem.acquirePage(METASTORAGE_CACHE_ID, partMetaId); @@ -499,7 +622,7 @@ public void applyUpdate(String key, byte[] value) throws IgniteCheckedException } /** */ - public static class FreeListImpl extends AbstractFreeList { + public class FreeListImpl extends AbstractFreeList { /** {@inheritDoc} */ FreeListImpl(int cacheId, String name, DataRegionMetricsImpl regionMetrics, DataRegion dataRegion, ReuseList reuseList, @@ -512,6 +635,11 @@ public static class FreeListImpl extends AbstractFreeList { return SimpleDataPageIO.VERSIONS; } + /** {@inheritDoc} */ + @Override protected long allocatePageNoReuse() throws IgniteCheckedException { + return pageMem.allocatePage(grpId, partId, FLAG_DATA); + } + /** * Read row from data pages. */ @@ -594,4 +722,259 @@ final MetastorageDataRow readRow(String key, long link) return new MetastorageDataRow(link, key, incomplete.data()); } } + + /** + * Temporary storage internal + */ + private interface TmpStorageInternal extends Closeable { + /** + * Put data + * + * @param key Key. + * @param val Value. + */ + boolean add(String key, byte[] val) throws IOException; + + /** + * Read data from storage + */ + Stream> stream() throws IOException; + } + + /** + * Temporary storage (memory) + */ + private static class MemoryTmpStorage implements TmpStorageInternal { + /** Buffer. */ + final ByteBuffer buf; + + /** Size. */ + int size; + + /** + * @param size Size. + */ + MemoryTmpStorage(int size) { + buf = ByteBuffer.allocateDirect(size); + } + + /** {@inheritDoc} */ + @Override public boolean add(String key, byte[] val) { + byte[] keyData = key.getBytes(StandardCharsets.UTF_8); + + if (val.length + keyData.length + 8 > buf.remaining()) + return false; + + buf.putInt(keyData.length).putInt(val.length).put(keyData).put(val); + + size++; + + return true; + } + + /** {@inheritDoc} */ + @Override public Stream> stream() { + buf.flip(); + + return Stream.generate(() -> { + int keyLen = buf.getInt(); + int dataLen = buf.getInt(); + + byte[] tmpBuf = new byte[Math.max(keyLen, dataLen)]; + + buf.get(tmpBuf, 0, keyLen); + + String key = new String(tmpBuf, 0, keyLen, StandardCharsets.UTF_8); + + buf.get(tmpBuf, 0, dataLen); + + return new IgniteBiTuple<>(key, tmpBuf.length > dataLen ? Arrays.copyOf(tmpBuf, dataLen) : tmpBuf); + }).limit(size); + } + + /** {@inheritDoc} */ + @Override public void close() throws IOException { + } + } + + /** + * Temporary storage (file) + */ + private static class FileTmpStorage implements TmpStorageInternal { + /** Cache. */ + final ByteBuffer cache = ByteBuffer.allocateDirect(TEMPORARY_METASTORAGE_BUFFER_SIZE); + + /** File. */ + RandomAccessFile file; + + /** Size. */ + long size; + + /** {@inheritDoc} */ + @Override public boolean add(String key, byte[] val) throws IOException { + if (file == null) + file = new RandomAccessFile(File.createTempFile("m_storage", "bin"), "rw"); + + byte[] keyData = key.getBytes(StandardCharsets.UTF_8); + + if (val.length + keyData.length + 8 > cache.remaining()) + flushCache(false); + + cache.putInt(keyData.length).putInt(val.length).put(keyData).put(val); + + size++; + + return true; + } + + /** {@inheritDoc} */ + @Override public Stream> stream() throws IOException { + if (file == null) + return Stream.empty(); + + flushCache(true); + + file.getChannel().position(0); + + readToCache(); + + return Stream.generate(() -> { + if (cache.remaining() <= 8) { + cache.compact(); + + try { + readToCache(); + } + catch (IOException e) { + throw new IgniteException(e); + } + } + + int keyLen = cache.getInt(); + int dataLen = cache.getInt(); + + if (cache.remaining() < keyLen + dataLen) { + cache.compact(); + + try { + readToCache(); + } + catch (IOException e) { + throw new IgniteException(e); + } + } + + byte[] tmpBuf = new byte[Math.max(keyLen, dataLen)]; + + cache.get(tmpBuf, 0, keyLen); + + String key = new String(tmpBuf, 0, keyLen, StandardCharsets.UTF_8); + + cache.get(tmpBuf, 0, dataLen); + + return new IgniteBiTuple<>(key, tmpBuf.length > dataLen ? Arrays.copyOf(tmpBuf, dataLen) : tmpBuf); + }).limit(size); + } + + /** {@inheritDoc} */ + @Override public void close() throws IOException { + file.close(); + } + + /** + * Read data to cache + */ + private void readToCache() throws IOException { + int len = (int)Math.min(file.length() - file.getChannel().position(), cache.remaining()); + + while (len > 0) + len -= file.getChannel().read(cache); + + cache.flip(); + } + + /** + * Write cache to file. + * + * @param force force metadata. + */ + private void flushCache(boolean force) throws IOException { + if (cache.position() > 0) { + cache.flip(); + + while (cache.remaining() > 0) + file.getChannel().write(cache); + + cache.clear(); + } + + file.getChannel().force(force); + } + } + + /** + * Temporary storage + */ + public static class TmpStorage implements Closeable { + /** Chain of internal storages. */ + final List chain = new ArrayList<>(2); + + /** Current internal storage. */ + TmpStorageInternal current; + + /** Logger. */ + final IgniteLogger log; + + /** + * @param memBufSize Memory buffer size. + * @param log Logger. + */ + TmpStorage(int memBufSize, IgniteLogger log) { + this.log = log; + + chain.add(current = new MemoryTmpStorage(memBufSize)); + } + + /** + * Put data + * + * @param key Key. + * @param val Value. + */ + public void add(String key, byte[] val) throws IgniteCheckedException { + try { + while (!current.add(key, val)) + chain.add(current = new FileTmpStorage()); + } + catch (IOException e) { + throw new IgniteCheckedException(e); + } + } + + /** + * Read data from storage + */ + public Stream> stream() { + return chain.stream().flatMap(storage -> { + try { + return storage.stream(); + } + catch (IOException e) { + throw new IgniteException(e); + } + }); + } + + /** {@inheritDoc} */ + @Override public void close() throws IOException { + for (TmpStorageInternal storage : chain) { + try { + storage.close(); + } + catch (IOException ex) { + log.error(ex.getMessage(), ex); + } + } + } + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageDataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageDataRow.java index 5e2660bc3aa97..2d7b0a66e47a4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageDataRow.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageDataRow.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.persistence.metastorage; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.pagemem.PageIdAllocator; import org.apache.ignite.internal.processors.cache.persistence.Storable; /** @@ -62,7 +63,7 @@ public int hash() { /** {@inheritDoc} */ @Override public int partition() { - return 0; + return MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID ? PageIdAllocator.OLD_METASTORE_PARTITION: PageIdAllocator.METASTORE_PARTITION; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageLifecycleListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageLifecycleListener.java index 8ab418c4f4d5e..12cc4468fc010 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageLifecycleListener.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageLifecycleListener.java @@ -33,7 +33,7 @@ public interface MetastorageLifecycleListener { * * @param metastorage Read-only meta storage. */ - public void onReadyForRead(ReadOnlyMetastorage metastorage) throws IgniteCheckedException; + default void onReadyForRead(ReadOnlyMetastorage metastorage) throws IgniteCheckedException { }; /** * Fully functional metastore capable of performing reading and writing operations. @@ -43,5 +43,5 @@ public interface MetastorageLifecycleListener { * * @param metastorage Fully functional meta storage. */ - public void onReadyForReadWrite(ReadWriteMetastorage metastorage) throws IgniteCheckedException; + default void onReadyForReadWrite(ReadWriteMetastorage metastorage) throws IgniteCheckedException { }; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java index 00db5cd791163..72e7f510c9f9c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java @@ -31,6 +31,9 @@ import org.apache.ignite.internal.processors.failure.FailureProcessor; import org.jetbrains.annotations.Nullable; +import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA; +import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX; + /** * */ @@ -41,6 +44,9 @@ public class MetastorageTree extends BPlusTree io = io(rootAddr); + + return io.getCount(rootAddr) == 0; + } + finally { + readUnlock(rootId, rootPage, rootAddr); + } + } + finally { + releasePage(rootId, rootPage); + } + } + } + /** * Returns number of elements in the tree by scanning pages of the bottom (leaf) level. * Since a concurrent access is permitted, there is no guarantee about diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java index 3cbe577c24c59..f37b154c60507 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalRecordsIterator.java @@ -22,6 +22,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.nio.ByteOrder; +import java.util.Optional; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.pagemem.wal.WALIterator; @@ -92,6 +93,9 @@ public abstract class AbstractWalRecordsIterator /** Factory to provide I/O interfaces for read primitives with files. */ private final SegmentFileInputFactory segmentFileInputFactory; + /** Position of last read valid record. */ + private WALPointer lastRead; + /** * @param log Logger. * @param sharedCtx Shared context. @@ -154,6 +158,8 @@ protected void advance() throws IgniteCheckedException { curRec = advanceRecord(currWalSegment); if (curRec != null) { + lastRead = curRec.get1(); + if (curRec.get2().type() == null) continue; // Record was skipped by filter of current serializer, should read next record. @@ -183,6 +189,11 @@ protected void advance() throws IgniteCheckedException { } } + /** {@inheritDoc} */ + @Override public Optional lastRead() { + return Optional.ofNullable(lastRead); + } + /** * @param tailReachedException Tail reached exception. * @param currWalSegment Current WAL segment read handler. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWALPointer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWALPointer.java index 6ea7e002b6e6d..5e5917871983f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWALPointer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWALPointer.java @@ -80,7 +80,7 @@ public void length(int len) { } /** {@inheritDoc} */ - @Override public WALPointer next() { + @Override public FileWALPointer next() { if (len == 0) throw new IllegalStateException("Failed to calculate next WAL pointer " + "(this pointer is a terminal): " + this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java index e958db74cbd97..dcc761d579ee0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java @@ -26,17 +26,11 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.MappedByteBuffer; import java.nio.channels.ClosedByInterruptException; -import java.nio.file.DirectoryStream; import java.nio.file.FileAlreadyExistsException; import java.nio.file.Files; -import java.nio.file.Path; import java.sql.Time; import java.util.ArrayList; import java.util.Arrays; @@ -45,19 +39,12 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.TreeSet; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.PriorityBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.LockSupport; -import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Pattern; import java.util.stream.Stream; import java.util.zip.ZipEntry; @@ -80,10 +67,13 @@ import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; import org.apache.ignite.internal.pagemem.wal.WALIterator; import org.apache.ignite.internal.pagemem.wal.WALPointer; -import org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord; import org.apache.ignite.internal.pagemem.wal.record.MarshalledRecord; +import org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord; +import org.apache.ignite.internal.pagemem.wal.record.PageSnapshot; +import org.apache.ignite.internal.pagemem.wal.record.RolloverType; import org.apache.ignite.internal.pagemem.wal.record.SwitchSegmentRecord; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; +import org.apache.ignite.internal.pagemem.wal.record.delta.PageDeltaRecord; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter; import org.apache.ignite.internal.processors.cache.WalStateManager.WALDisableContext; @@ -95,15 +85,19 @@ import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; import org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings; +import org.apache.ignite.internal.processors.cache.persistence.wal.aware.SegmentAware; +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc; import org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException; -import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; +import org.apache.ignite.internal.processors.cache.persistence.wal.filehandle.AbstractFileHandle; +import org.apache.ignite.internal.processors.cache.persistence.wal.filehandle.FileHandleManagerFactory; +import org.apache.ignite.internal.processors.cache.persistence.wal.filehandle.FileHandleManager; +import org.apache.ignite.internal.processors.cache.persistence.wal.filehandle.FileWriteHandle; import org.apache.ignite.internal.processors.cache.persistence.wal.io.FileInput; -import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentFileInputFactory; import org.apache.ignite.internal.processors.cache.persistence.wal.io.LockedSegmentFileInputFactory; +import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentFileInputFactory; import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentIO; import org.apache.ignite.internal.processors.cache.persistence.wal.io.SimpleSegmentFileInputFactory; import org.apache.ignite.internal.processors.cache.persistence.wal.record.HeaderRecord; -import org.apache.ignite.internal.processors.cache.persistence.wal.aware.SegmentAware; import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer; import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactory; import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl; @@ -111,7 +105,6 @@ import org.apache.ignite.internal.processors.failure.FailureProcessor; import org.apache.ignite.internal.processors.timeout.GridTimeoutObject; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; -import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.future.GridFinishedFuture; import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.typedef.CI1; @@ -121,6 +114,7 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.util.worker.GridWorker; +import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgnitePredicate; @@ -134,59 +128,32 @@ import static java.nio.file.StandardOpenOption.WRITE; import static org.apache.ignite.IgniteSystemProperties.IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE; import static org.apache.ignite.IgniteSystemProperties.IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_COMPRESSOR_WORKER_THREAD_CNT; import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_MMAP; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SEGMENT_SYNC_TIMEOUT; import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SERIALIZER_VERSION; -import static org.apache.ignite.configuration.WALMode.LOG_ONLY; import static org.apache.ignite.events.EventType.EVT_WAL_SEGMENT_ARCHIVED; import static org.apache.ignite.events.EventType.EVT_WAL_SEGMENT_COMPACTED; import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR; import static org.apache.ignite.failure.FailureType.SYSTEM_WORKER_TERMINATION; -import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.SWITCH_SEGMENT_RECORD; -import static org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer.BufferMode.DIRECT; +import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactory.LATEST_SERIALIZER_VERSION; import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.HEADER_RECORD_SIZE; import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.readSegmentHeader; -import static org.apache.ignite.internal.util.IgniteUtils.findField; -import static org.apache.ignite.internal.util.IgniteUtils.findNonPublicMethod; -import static org.apache.ignite.internal.util.IgniteUtils.sleep; /** * File WAL manager. */ @SuppressWarnings("IfMayBeConditional") public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter implements IgniteWriteAheadLogManager { - /** Dfault wal segment sync timeout. */ - public static final long DFLT_WAL_SEGMENT_SYNC_TIMEOUT = 500L; - /** {@link MappedByteBuffer#force0(java.io.FileDescriptor, long, long)}. */ - private static final Method force0 = findNonPublicMethod( - MappedByteBuffer.class, "force0", - java.io.FileDescriptor.class, long.class, long.class - ); - - /** {@link MappedByteBuffer#mappingOffset()}. */ - private static final Method mappingOffset = findNonPublicMethod(MappedByteBuffer.class, "mappingOffset"); - - /** {@link MappedByteBuffer#mappingAddress(long)}. */ - private static final Method mappingAddress = findNonPublicMethod( - MappedByteBuffer.class, "mappingAddress", long.class - ); - - /** {@link MappedByteBuffer#fd} */ - private static final Field fd = findField(MappedByteBuffer.class, "fd"); - - /** Page size. */ - private static final int PAGE_SIZE = GridUnsafe.pageSize(); - /** */ private static final FileDescriptor[] EMPTY_DESCRIPTORS = new FileDescriptor[0]; - /** */ + /** Zero-filled buffer for file formatting. */ private static final byte[] FILL_BUF = new byte[1024 * 1024]; - /** Pattern for segment file names */ + /** Pattern for segment file names. */ public static final Pattern WAL_NAME_PATTERN = Pattern.compile("\\d{16}\\.wal"); - /** */ + /** Pattern for WAL temp files - these files will be cleared at startup. */ public static final Pattern WAL_TEMP_NAME_PATTERN = Pattern.compile("\\d{16}\\.wal\\.tmp"); /** WAL segment file filter, see {@link #WAL_NAME_PATTERN} */ @@ -196,7 +163,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl } }; - /** */ + /** WAL segment temporary file filter, see {@link #WAL_TEMP_NAME_PATTERN} */ private static final FileFilter WAL_SEGMENT_TEMP_FILE_FILTER = new FileFilter() { @Override public boolean accept(File file) { return !file.isDirectory() && WAL_TEMP_NAME_PATTERN.matcher(file.getName()).matches(); @@ -231,19 +198,12 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl } }; - /** Latest serializer version to use. */ - private static final int LATEST_SERIALIZER_VERSION = 2; - /** Buffer size. */ private static final int BUF_SIZE = 1024 * 1024; /** Use mapped byte buffer. */ private final boolean mmap = IgniteSystemProperties.getBoolean(IGNITE_WAL_MMAP, true); - /** {@link FileWriteHandle#written} atomic field updater. */ - private static final AtomicLongFieldUpdater WRITTEN_UPD = - AtomicLongFieldUpdater.newUpdater(FileWriteHandle.class, "written"); - /** * Percentage of archive size for checkpoint trigger. Need for calculate max size of WAL after last checkpoint. * Checkpoint should be triggered when max size of WAL after last checkpoint more than maxWallArchiveSize * thisValue @@ -257,6 +217,12 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl private static final double THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE = IgniteSystemProperties.getDouble(IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE, 0.5); + /** + * Number of WAL compressor worker threads. + */ + private final int WAL_COMPRESSOR_WORKER_THREAD_CNT = + IgniteSystemProperties.getInteger(IGNITE_WAL_COMPRESSOR_WORKER_THREAD_CNT, 4); + /** */ private final boolean alwaysWriteFullPages; @@ -267,7 +233,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl * Maximum number of allowed segments without checkpoint. If we have their more checkpoint should be triggered. * It is simple way to calculate WAL size without checkpoint instead fair WAL size calculating. */ - private long maxSegCountWithoutCheckpoint; + private final long maxSegCountWithoutCheckpoint; /** Size of wal archive since which removing of old archive should be started */ private final long allowedThresholdWalArchiveSize; @@ -278,9 +244,6 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl /** WAL flush frequency. Makes sense only for {@link WALMode#BACKGROUND} log WALMode. */ private final long flushFreq; - /** Fsync delay. */ - private final long fsyncDelay; - /** */ private final DataStorageConfiguration dsCfg; @@ -337,9 +300,12 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl /** */ private final ThreadLocal lastWALPtr = new ThreadLocal<>(); - /** Current log segment handle */ + /** Current log segment handle. */ private volatile FileWriteHandle currHnd; + /** File handle manager. */ + private volatile FileHandleManager fileHandleManager; + /** */ private volatile WALDisableContext walDisableContext; @@ -354,7 +320,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl * segment, skip possible archiving for this case
Value is filled only for case {@link * #walAutoArchiveAfterInactivity} > 0
*/ - private AtomicLong lastRecordLoggedMs = new AtomicLong(); + private final AtomicLong lastRecordLoggedMs = new AtomicLong(); /** * Cancellable task for {@link WALMode#BACKGROUND}, should be cancelled at shutdown. @@ -368,24 +334,21 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl */ @Nullable private volatile GridTimeoutObject nextAutoArchiveTimeoutObj; - /** WAL writer worker. */ - private WALWriter walWriter; - /** * Listener invoked for each segment file IO initializer. */ @Nullable private volatile IgniteInClosure createWalFileListener; - /** Wal segment sync worker. */ - private WalSegmentSyncer walSegmentSyncWorker; - /** * Manage of segment location. */ private SegmentRouter segmentRouter; /** Segment factory with ability locked segment during reading. */ - private SegmentFileInputFactory lockedSegmentFileInputFactory; + private volatile SegmentFileInputFactory lockedSegmentFileInputFactory; + + /** FileHandleManagerFactory. */ + private final FileHandleManagerFactory fileHandleManagerFactory; /** * @param ctx Kernal context. @@ -402,9 +365,8 @@ public FileWriteAheadLogManager(@NotNull final GridKernalContext ctx) { maxWalSegmentSize = dsCfg.getWalSegmentSize(); mode = dsCfg.getWalMode(); flushFreq = dsCfg.getWalFlushFrequency(); - fsyncDelay = dsCfg.getWalFsyncDelayNanos(); alwaysWriteFullPages = dsCfg.isAlwaysWriteFullPages(); - ioFactory = new RandomAccessFileIOFactory(); + ioFactory = mode == WALMode.FSYNC ? dsCfg.getFileIOFactory() : new RandomAccessFileIOFactory(); segmentFileInputFactory = new SimpleSegmentFileInputFactory(); walAutoArchiveAfterInactivity = dsCfg.getWalAutoArchiveAfterInactivity(); @@ -412,6 +374,12 @@ public FileWriteAheadLogManager(@NotNull final GridKernalContext ctx) { evt = ctx.event(); failureProcessor = ctx.failure(); + + fileHandleManagerFactory = new FileHandleManagerFactory(dsCfg); + + maxSegCountWithoutCheckpoint = + (long)((U.adjustedWalHistorySize(dsCfg, log) * CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE) + / dsCfg.getWalSegmentSize()); } /** @@ -425,98 +393,111 @@ public void setFileIOFactory(FileIOFactory ioFactory) { /** {@inheritDoc} */ @Override public void start0() throws IgniteCheckedException { - if (!cctx.kernalContext().clientNode()) { - maxSegCountWithoutCheckpoint = - (long)((U.adjustedWalHistorySize(dsCfg, log) * CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE) - / dsCfg.getWalSegmentSize()); + if(cctx.kernalContext().clientNode()) + return; - final PdsFolderSettings resolveFolders = cctx.kernalContext().pdsFolderResolver().resolveFolders(); + final PdsFolderSettings resolveFolders = cctx.kernalContext().pdsFolderResolver().resolveFolders(); - checkWalConfiguration(); + checkWalConfiguration(); - final File walWorkDir0 = walWorkDir = initDirectory( + final File walWorkDir0 = walWorkDir = initDirectory( dsCfg.getWalPath(), DataStorageConfiguration.DFLT_WAL_PATH, resolveFolders.folderName(), "write ahead log work directory" - ); + ); - final File walArchiveDir0 = walArchiveDir = initDirectory( + final File walArchiveDir0 = walArchiveDir = initDirectory( dsCfg.getWalArchivePath(), DataStorageConfiguration.DFLT_WAL_ARCHIVE_PATH, resolveFolders.folderName(), "write ahead log archive directory" - ); + ); - serializer = new RecordSerializerFactoryImpl(cctx).createSerializer(serializerVer); + serializer = new RecordSerializerFactoryImpl(cctx).createSerializer(serializerVer); - GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)cctx.database(); + GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)cctx.database(); - metrics = dbMgr.persistentStoreMetricsImpl(); + metrics = dbMgr.persistentStoreMetricsImpl(); - checkOrPrepareFiles(); + checkOrPrepareFiles(); - if (metrics != null) - metrics.setWalSizeProvider(new CO() { - @Override public Long apply() { - long size = 0; + if (metrics != null) + metrics.setWalSizeProvider(new CO() { + @Override public Long apply() { + long size = 0; - for (File f : walWorkDir0.listFiles()) - size += f.length(); + for (File f : walWorkDir0.listFiles()) + size += f.length(); - for (File f : walArchiveDir0.listFiles()) - size += f.length(); + for (File f : walArchiveDir0.listFiles()) + size += f.length(); - return size; - } - }); + return size; + } + }); - IgniteBiTuple tup = scanMinMaxArchiveIndices(); + IgniteBiTuple tup = scanMinMaxArchiveIndices(); - segmentAware = new SegmentAware(dsCfg.getWalSegments()); + segmentAware = new SegmentAware(dsCfg.getWalSegments(), dsCfg.isWalCompactionEnabled()); - segmentAware.lastTruncatedArchiveIdx(tup == null ? -1 : tup.get1() - 1); + segmentAware.lastTruncatedArchiveIdx(tup == null ? -1 : tup.get1() - 1); - long lastAbsArchivedIdx = tup == null ? -1 : tup.get2(); + long lastAbsArchivedIdx = tup == null ? -1 : tup.get2(); - if (isArchiverEnabled()) - archiver = new FileArchiver(lastAbsArchivedIdx, log); - else - archiver = null; + if (isArchiverEnabled()) + archiver = new FileArchiver(lastAbsArchivedIdx, log); + else + archiver = null; - if (lastAbsArchivedIdx > 0) - segmentAware.setLastArchivedAbsoluteIndex(lastAbsArchivedIdx); + if (lastAbsArchivedIdx > 0) + segmentAware.setLastArchivedAbsoluteIndex(lastAbsArchivedIdx); - if (dsCfg.isWalCompactionEnabled()) { - compressor = new FileCompressor(); + if (dsCfg.isWalCompactionEnabled()) { + compressor = new FileCompressor(log); - if (decompressor == null) { // Preventing of two file-decompressor thread instantiations. - decompressor = new FileDecompressor(log); + decompressor = new FileDecompressor(log); + } - new IgniteThread(decompressor).start(); - } - } + segmentRouter = new SegmentRouter(walWorkDir, walArchiveDir, segmentAware, dsCfg); - segmentRouter = new SegmentRouter(walWorkDir, walArchiveDir, segmentAware, dsCfg); + walDisableContext = cctx.walState().walDisableContext(); - walDisableContext = cctx.walState().walDisableContext(); + fileHandleManager = fileHandleManagerFactory.build( + cctx, metrics, mmap, lastWALPtr::get, serializer, this::currentHandle + ); - if (mode != WALMode.NONE && mode != WALMode.FSYNC) { - walSegmentSyncWorker = new WalSegmentSyncer(igCfg.getIgniteInstanceName(), - cctx.kernalContext().log(WalSegmentSyncer.class)); + fileHandleManager.start(); - if (log.isInfoEnabled()) - log.info("Started write-ahead log manager [mode=" + mode + ']'); - } - else - U.quietAndWarn(log, "Started write-ahead log manager in NONE mode, persisted data may be lost in " + - "a case of unexpected node failure. Make sure to deactivate the cluster before shutdown."); + lockedSegmentFileInputFactory = new LockedSegmentFileInputFactory( + segmentAware, + segmentRouter, + ioFactory + ); + } - lockedSegmentFileInputFactory = new LockedSegmentFileInputFactory( - segmentAware, - segmentRouter, - ioFactory - ); + /** + * + */ + private void startArchiverAndCompressor() { + segmentAware.reset(); + + if (isArchiverEnabled()) { + assert archiver != null : "FileArchiver should be initialized."; + + archiver.restart(); + } + + fileHandleManager.onActivate(); + + if (dsCfg.isWalCompactionEnabled()) { + assert compressor != null : "Compressor should be initialized."; + + compressor.restart(); + + assert decompressor != null : "Compressor should be initialized."; + + decompressor.restart(); } } @@ -585,7 +566,10 @@ private void checkWalConfiguration() throws IgniteCheckedException { } } - /** {@inheritDoc} */ + /** + * Method is called twice on deactivate and stop. + * It shutdown workers but do not deallocate them to avoid duplication. + * */ @Override protected void stop0(boolean cancel) { final GridTimeoutProcessor.CancelableTask schedule = backgroundFlushSchedule; @@ -597,22 +581,8 @@ private void checkWalConfiguration() throws IgniteCheckedException { if (timeoutObj != null) cctx.time().removeTimeoutObject(timeoutObj); - final FileWriteHandle currHnd = currentHandle(); - try { - if (mode == WALMode.BACKGROUND) { - if (currHnd != null) - currHnd.flush(null); - } - - if (currHnd != null) - currHnd.close(false); - - if (walSegmentSyncWorker != null) - walSegmentSyncWorker.shutdown(); - - if (walWriter != null) - walWriter.shutdown(); + fileHandleManager.onDeactivate(); segmentAware.interrupt(); @@ -626,7 +596,7 @@ private void checkWalConfiguration() throws IgniteCheckedException { decompressor.shutdown(); } catch (Exception e) { - U.error(log, "Failed to gracefully close WAL segment: " + this.currHnd.fileIO, e); + U.error(log, "Failed to gracefully close WAL segment: " + this.currHnd, e); } } @@ -635,22 +605,7 @@ private void checkWalConfiguration() throws IgniteCheckedException { if (log.isDebugEnabled()) log.debug("Activated file write ahead log manager [nodeId=" + cctx.localNodeId() + " topVer=" + cctx.discovery().topologyVersionEx() + " ]"); - - start0(); - - if (!cctx.kernalContext().clientNode()) { - if (isArchiverEnabled()) { - assert archiver != null; - - new IgniteThread(archiver).start(); - } - - if (walSegmentSyncWorker != null) - new IgniteThread(walSegmentSyncWorker).start(); - - if (compressor != null) - compressor.start(); - } + //NOOP implementation, we need to override it. } /** {@inheritDoc} */ @@ -676,15 +631,26 @@ private void checkWalConfiguration() throws IgniteCheckedException { /** {@inheritDoc} */ @Override public void resumeLogging(WALPointer lastPtr) throws IgniteCheckedException { + if (log.isDebugEnabled()) + log.debug("File write ahead log manager resuming logging [nodeId=" + cctx.localNodeId() + + " topVer=" + cctx.discovery().topologyVersionEx() + " ]"); + + /* + walDisableContext is started after FileWriteAheadLogManager, so we obtain actual walDisableContext ref here. + */ + walDisableContext = cctx.walState().walDisableContext(); + assert currHnd == null; assert lastPtr == null || lastPtr instanceof FileWALPointer; - FileWALPointer filePtr = (FileWALPointer)lastPtr; + startArchiverAndCompressor(); + + assert (isArchiverEnabled() && archiver != null) || (!isArchiverEnabled() && archiver == null) : + "Trying to restore FileWriteHandle on deactivated write ahead log manager"; - walWriter = new WALWriter(log); + FileWALPointer filePtr = (FileWALPointer)lastPtr; - if (!mmap) - new IgniteThread(walWriter).start(); + fileHandleManager.resumeLogging(); currHnd = restoreWriteHandle(filePtr); @@ -692,24 +658,19 @@ private void checkWalConfiguration() throws IgniteCheckedException { if (filePtr == null) currHnd.writeHeader(); - if (currHnd.serializer.version() != serializer.version()) { + if (currHnd.serializerVersion() != serializer.version()) { if (log.isInfoEnabled()) log.info("Record serializer version change detected, will start logging with a new WAL record " + "serializer to a new WAL segment [curFile=" + currHnd + ", newVer=" + serializer.version() + - ", oldVer=" + currHnd.serializer.version() + ']'); + ", oldVer=" + currHnd.serializerVersion() + ']'); - rollOver(currHnd); + rollOver(currHnd, null); } - currHnd.resume = false; + currHnd.finishResumeLogging(); - if (mode == WALMode.BACKGROUND) { - backgroundFlushSchedule = cctx.time().schedule(new Runnable() { - @Override public void run() { - doFlush(); - } - }, flushFreq, flushFreq); - } + if (mode == WALMode.BACKGROUND) + backgroundFlushSchedule = cctx.time().schedule(this::doFlush, flushFreq, flushFreq); if (walAutoArchiveAfterInactivity > 0) scheduleNextInactivityPeriodElapsedCheck(); @@ -778,9 +739,7 @@ private void checkWalRolloverRequiredDuringInactivityPeriod() { final FileWriteHandle handle = currentHandle(); try { - handle.buf.close(); - - rollOver(handle); + closeBufAndRollover(handle, null, RolloverType.NONE); } catch (IgniteCheckedException e) { U.error(log, "Unable to perform segment rollover: " + e.getMessage(), e); @@ -790,11 +749,20 @@ private void checkWalRolloverRequiredDuringInactivityPeriod() { } /** {@inheritDoc} */ - @SuppressWarnings("TooBroadScope") - @Override public WALPointer log(WALRecord rec) throws IgniteCheckedException, StorageException { + @Override public WALPointer log(WALRecord rec) throws IgniteCheckedException { + return log(rec, RolloverType.NONE); + } + + /** {@inheritDoc} */ + @Override public WALPointer log(WALRecord rec, RolloverType rolloverType) throws IgniteCheckedException { if (serializer == null || mode == WALMode.NONE) return null; + // Only delta-records, page snapshots and memory recovery are allowed to write in recovery mode. + if (cctx.kernalContext().recoveryMode() && + !(rec instanceof PageDeltaRecord || rec instanceof PageSnapshot || rec instanceof MemoryRecoveryRecord)) + return null; + FileWriteHandle currWrHandle = currentHandle(); WALDisableContext isDisable = walDisableContext; @@ -807,21 +775,32 @@ private void checkWalRolloverRequiredDuringInactivityPeriod() { rec.size(serializer.size(rec)); while (true) { - if (rec.rollOver()) { - assert cctx.database().checkpointLockIsHeldByThread(); + WALPointer ptr; - long idx = currWrHandle.getSegmentId(); + if (rolloverType == RolloverType.NONE) + ptr = currWrHandle.addRecord(rec); + else { + assert cctx.database().checkpointLockIsHeldByThread(); - currWrHandle.buf.close(); + if (rolloverType == RolloverType.NEXT_SEGMENT) { + WALPointer pos = rec.position(); - currWrHandle = rollOver(currWrHandle); + do { + // This will change rec.position() unless concurrent rollover happened. + currWrHandle = closeBufAndRollover(currWrHandle, rec, rolloverType); + } + while (Objects.equals(pos, rec.position())); - if (log != null && log.isInfoEnabled()) - log.info("Rollover segment [" + idx + " to " + currWrHandle.getSegmentId() + "], recordType=" + rec.type()); + ptr = rec.position(); + } + else if (rolloverType == RolloverType.CURRENT_SEGMENT) { + if ((ptr = currWrHandle.addRecord(rec)) != null) + currWrHandle = closeBufAndRollover(currWrHandle, rec, rolloverType); + } + else + throw new IgniteCheckedException("Unknown rollover type: " + rolloverType); } - WALPointer ptr = currWrHandle.addRecord(rec); - if (ptr != null) { metrics.onWalRecordLogged(); @@ -833,7 +812,7 @@ private void checkWalRolloverRequiredDuringInactivityPeriod() { return ptr; } else - currWrHandle = rollOver(currWrHandle); + currWrHandle = rollOver(currWrHandle, null); checkNode(); @@ -842,34 +821,51 @@ private void checkWalRolloverRequiredDuringInactivityPeriod() { } } - /** {@inheritDoc} */ - @Override public void flush(WALPointer ptr, boolean explicitFsync) throws IgniteCheckedException, StorageException { - if (serializer == null || mode == WALMode.NONE) - return; + /** */ + private FileWriteHandle closeBufAndRollover( + FileWriteHandle currWriteHandle, + WALRecord rec, + RolloverType rolloverType + ) throws IgniteCheckedException { + long idx = currWriteHandle.getSegmentId(); - FileWriteHandle cur = currentHandle(); + currWriteHandle.closeBuffer(); - // WAL manager was not started (client node). - if (cur == null) - return; + FileWriteHandle res = rollOver(currWriteHandle, rolloverType == RolloverType.NEXT_SEGMENT ? rec : null); - FileWALPointer filePtr = (FileWALPointer)(ptr == null ? lastWALPtr.get() : ptr); + if (log != null && log.isInfoEnabled()) + log.info("Rollover segment [" + idx + " to " + res.getSegmentId() + "], recordType=" + rec.type()); - if (mode == LOG_ONLY) - cur.flushOrWait(filePtr); + return res; + } - if (!explicitFsync && mode != WALMode.FSYNC) - return; // No need to sync in LOG_ONLY or BACKGROUND unless explicit fsync is required. + /** {@inheritDoc} */ + @Override public void flush(WALPointer ptr, boolean explicitFsync) throws IgniteCheckedException, StorageException { + fileHandleManager.flush(ptr, explicitFsync); + } - // No need to sync if was rolled over. - if (filePtr != null && !cur.needFsync(filePtr)) - return; + /** {@inheritDoc} */ + @Override public WALRecord read(WALPointer ptr) throws IgniteCheckedException, StorageException { + try (WALIterator it = replay(ptr)) { + IgniteBiTuple rec = it.next(); - cur.fsync(filePtr); + if (rec.get1().equals(ptr)) + return rec.get2(); + else + throw new StorageException("Failed to read record by pointer [ptr=" + ptr + ", rec=" + rec + "]"); + } } /** {@inheritDoc} */ @Override public WALIterator replay(WALPointer start) throws IgniteCheckedException, StorageException { + return replay(start, null); + } + + /** {@inheritDoc} */ + @Override public WALIterator replay( + WALPointer start, + @Nullable IgniteBiPredicate recordDeserializeFilter + ) throws IgniteCheckedException, StorageException { assert start == null || start instanceof FileWALPointer : "Invalid start pointer: " + start; FileWriteHandle hnd = currentHandle(); @@ -886,7 +882,7 @@ private void checkWalRolloverRequiredDuringInactivityPeriod() { (FileWALPointer)start, end, dsCfg, - new RecordSerializerFactoryImpl(cctx), + new RecordSerializerFactoryImpl(cctx).recordDeserializeFilter(recordDeserializeFilter), ioFactory, archiver, decompressor, @@ -897,7 +893,7 @@ private void checkWalRolloverRequiredDuringInactivityPeriod() { } /** {@inheritDoc} */ - @Override public boolean reserve(WALPointer start) throws IgniteCheckedException { + @Override public boolean reserve(WALPointer start) { assert start != null && start instanceof FileWALPointer : "Invalid start pointer: " + start; if (mode == WALMode.NONE) @@ -1007,7 +1003,7 @@ private boolean segmentReservedOrLocked(long absIdx) { /** {@inheritDoc} */ @Override public void notchLastCheckpointPtr(WALPointer ptr) { if (compressor != null) - compressor.keepUncompressedIdxFrom(((FileWALPointer)ptr).index()); + segmentAware.keepUncompressedIdxFrom(((FileWALPointer)ptr).index()); } /** {@inheritDoc} */ @@ -1172,9 +1168,10 @@ private FileWriteHandle currentHandle() { /** * @param cur Handle that failed to fit the given entry. + * @param rec Optional record to be added right after header. * @return Handle that will fit the entry. */ - private FileWriteHandle rollOver(FileWriteHandle cur) throws StorageException, IgniteCheckedException { + private FileWriteHandle rollOver(FileWriteHandle cur, @Nullable WALRecord rec) throws IgniteCheckedException { FileWriteHandle hnd = currentHandle(); if (hnd != cur) @@ -1188,6 +1185,12 @@ private FileWriteHandle rollOver(FileWriteHandle cur) throws StorageException, I next.writeHeader(); + if (rec != null) { + WALPointer ptr = next.addRecord(rec); + + assert ptr != null; + } + if (next.getSegmentId() - lashCheckpointFileIdx() >= maxSegCountWithoutCheckpoint) cctx.database().forceCheckpoint("too big size of WAL without checkpoint"); @@ -1260,25 +1263,7 @@ private FileWriteHandle restoreWriteHandle(FileWALPointer lastReadPtr) throws St log.info("Resuming logging to WAL segment [file=" + curFile.getAbsolutePath() + ", offset=" + off + ", ver=" + serVer + ']'); - SegmentedRingByteBuffer rbuf; - - if (mmap) { - MappedByteBuffer buf = fileIO.map((int)maxWalSegmentSize); - - rbuf = new SegmentedRingByteBuffer(buf, metrics); - } - else - rbuf = new SegmentedRingByteBuffer(dsCfg.getWalBufferSize(), maxWalSegmentSize, DIRECT, metrics); - - if (lastReadPtr != null) - rbuf.init(lastReadPtr.fileOffset() + lastReadPtr.length()); - - FileWriteHandle hnd = new FileWriteHandle( - fileIO, - off + len, - true, - ser, - rbuf); + FileWriteHandle hnd = fileHandleManager.initHandle(fileIO, off + len, ser); if (archiver0 != null) segmentAware.curAbsWalIdx(absIdx); @@ -1323,8 +1308,6 @@ private FileWriteHandle initNextWriteHandle(FileWriteHandle cur) throws IgniteCh if (log.isDebugEnabled()) log.debug("Switching to a new WAL segment: " + nextFile.getAbsolutePath()); - SegmentedRingByteBuffer rbuf = null; - SegmentIO fileIO = null; FileWriteHandle hnd; @@ -1339,20 +1322,8 @@ private FileWriteHandle initNextWriteHandle(FileWriteHandle cur) throws IgniteCh if (lsnr != null) lsnr.apply(fileIO); - if (mmap) { - MappedByteBuffer buf = fileIO.map((int)maxWalSegmentSize); - - rbuf = new SegmentedRingByteBuffer(buf, metrics); - } - else - rbuf = cur.buf.reset(); - hnd = new FileWriteHandle( - fileIO, - 0, - false, - serializer, - rbuf); + hnd = fileHandleManager.nextHandle(fileIO, serializer); if (interrupted) Thread.currentThread().interrupt(); @@ -1374,12 +1345,6 @@ private FileWriteHandle initNextWriteHandle(FileWriteHandle cur) throws IgniteCh fileIO = null; } - - if (rbuf != null) { - rbuf.free(); - - rbuf = null; - } } } @@ -1435,29 +1400,6 @@ private void checkOrPrepareFiles() throws StorageException { checkFiles(0, false, null, null); } - /** {@inheritDoc} */ - @Override public void cleanupWalDirectories() throws IgniteCheckedException { - try { - try (DirectoryStream files = Files.newDirectoryStream(walWorkDir.toPath())) { - for (Path path : files) - Files.delete(path); - } - } - catch (IOException e) { - throw new IgniteCheckedException("Failed to cleanup wal work directory: " + walWorkDir, e); - } - - try { - try (DirectoryStream files = Files.newDirectoryStream(walArchiveDir.toPath())) { - for (Path path : files) - Files.delete(path); - } - } - catch (IOException e) { - throw new IgniteCheckedException("Failed to cleanup wal archive directory: " + walArchiveDir, e); - } - } - /** * Clears whole the file, fills with zeros for Default mode. * @@ -1745,7 +1687,7 @@ private void shutdown() throws IgniteInterruptedCheckedException { blockingSectionEnd(); } - if (evt.isRecordable(EVT_WAL_SEGMENT_ARCHIVED)) { + if (evt.isRecordable(EVT_WAL_SEGMENT_ARCHIVED) && !cctx.kernalContext().recoveryMode()) { evt.record(new WalSegmentArchivedEvent( cctx.discovery().localNode(), res.getAbsIdx(), @@ -1908,22 +1850,30 @@ private void allocateRemainingFiles() throws StorageException { } ); } + + /** + * Restart worker in IgniteThread. + */ + public void restart() { + assert runner() == null : "FileArchiver is still running"; + + isCancelled = false; + + new IgniteThread(archiver).start(); + } } /** * Responsible for compressing WAL archive segments. * Also responsible for deleting raw copies of already compressed WAL archive segments if they are not reserved. */ - private class FileCompressor extends Thread { - /** Current thread stopping advice. */ - private volatile boolean stopped; - - /** All segments prior to this (inclusive) can be compressed. */ - private volatile long minUncompressedIdxToKeep = -1L; + private class FileCompressor extends FileCompressorWorker { + /** Workers queue. */ + private final List workers = new ArrayList<>(); /** */ - FileCompressor() { - super("wal-file-compressor%" + cctx.igniteInstanceName()); + FileCompressor(IgniteLogger log) { + super(0, log); } /** */ @@ -1931,7 +1881,7 @@ private void init() { File[] toDel = walArchiveDir.listFiles(WAL_SEGMENT_TEMP_FILE_COMPACTED_FILTER); for (File f : toDel) { - if (stopped) + if (isCancelled()) return; f.delete(); @@ -1940,113 +1890,154 @@ private void init() { FileDescriptor[] alreadyCompressed = scan(walArchiveDir.listFiles(WAL_SEGMENT_FILE_COMPACTED_FILTER)); if (alreadyCompressed.length > 0) - segmentAware.lastCompressedIdx(alreadyCompressed[alreadyCompressed.length - 1].idx()); + segmentAware.onSegmentCompressed(alreadyCompressed[alreadyCompressed.length - 1].idx()); + + for (int i = 1; i < calculateThreadCount(); i++) { + FileCompressorWorker worker = new FileCompressorWorker(i, log); + + worker.restart(); + + synchronized (this) { + workers.add(worker); + } + } } /** - * @param idx Minimum raw segment index that should be preserved from deletion. + * Calculate optimal additional compressor worker threads count. If quarter of proc threads greater + * than WAL_COMPRESSOR_WORKER_THREAD_CNT, use this value. Otherwise, reduce number of threads. + * + * @return Optimal number of compressor threads. */ - void keepUncompressedIdxFrom(long idx) { - minUncompressedIdxToKeep = idx; + private int calculateThreadCount() { + int procNum = Runtime.getRuntime().availableProcessors(); + + // If quarter of proc threads greater than WAL_COMPRESSOR_WORKER_THREAD_CNT, + // use this value. Otherwise, reduce number of threads. + if (procNum >> 2 >= WAL_COMPRESSOR_WORKER_THREAD_CNT) + return WAL_COMPRESSOR_WORKER_THREAD_CNT; + else + return procNum >> 2; } - /** - * Pessimistically tries to reserve segment for compression in order to avoid concurrent truncation. - * Waits if there's no segment to archive right now. - */ - private long tryReserveNextSegmentOrWait() throws IgniteCheckedException { - long segmentToCompress = segmentAware.waitNextSegmentToCompress(); - boolean reserved = reserve(new FileWALPointer(segmentToCompress, 0, 0)); + /** {@inheritDoc} */ + @Override public void body() throws InterruptedException, IgniteInterruptedCheckedException{ + init(); - return reserved ? segmentToCompress : -1; + super.body0(); } /** - * Deletes raw WAL segments if they aren't locked and already have compressed copies of themselves. + * @throws IgniteInterruptedCheckedException If failed to wait for thread shutdown. */ - private void deleteObsoleteRawSegments() { - FileDescriptor[] descs = scan(walArchiveDir.listFiles(WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER)); + private void shutdown() throws IgniteInterruptedCheckedException { + synchronized (this) { + for (FileCompressorWorker worker: workers) + U.cancel(worker); - Set indices = new HashSet<>(); - Set duplicateIndices = new HashSet<>(); + for (FileCompressorWorker worker: workers) + U.join(worker); - for (FileDescriptor desc : descs) { - if (!indices.add(desc.idx)) - duplicateIndices.add(desc.idx); + workers.clear(); + + U.cancel(this); } - for (FileDescriptor desc : descs) { - if (desc.isCompressed()) - continue; + U.join(this); + } + } - // Do not delete reserved or locked segment and any segment after it. - if (segmentReservedOrLocked(desc.idx)) - return; + /** */ + private class FileCompressorWorker extends GridWorker { + /** */ + FileCompressorWorker(int idx, IgniteLogger log) { + super(cctx.igniteInstanceName(), "wal-file-compressor-%" + cctx.igniteInstanceName() + "%-" + idx, log); + } - if (desc.idx < minUncompressedIdxToKeep && duplicateIndices.contains(desc.idx)) { - if (!desc.file.delete()) - U.warn(log, "Failed to remove obsolete WAL segment (make sure the process has enough rights): " + - desc.file.getAbsolutePath() + ", exists: " + desc.file.exists()); - } + /** */ + void restart() { + assert runner() == null : "FileCompressorWorker is still running."; + + isCancelled = false; + + new IgniteThread(this).start(); + } + + /** + * Pessimistically tries to reserve segment for compression in order to avoid concurrent truncation. + * Waits if there's no segment to archive right now. + */ + private long tryReserveNextSegmentOrWait() throws IgniteInterruptedCheckedException{ + long segmentToCompress = segmentAware.waitNextSegmentToCompress(); + + boolean reserved = reserve(new FileWALPointer(segmentToCompress, 0, 0)); + + if (reserved) + return segmentToCompress; + else { + segmentAware.onSegmentCompressed(segmentToCompress); + + return -1; } } /** {@inheritDoc} */ - @Override public void run() { - init(); + @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException { + body0(); + } - while (!Thread.currentThread().isInterrupted() && !stopped) { - long currReservedSegment = -1; + /** */ + private void body0() { + while (!isCancelled()) { + long segIdx = -1L; try { + if ((segIdx = tryReserveNextSegmentOrWait()) == -1) + continue; + deleteObsoleteRawSegments(); - currReservedSegment = tryReserveNextSegmentOrWait(); - if (currReservedSegment == -1) - continue; + File tmpZip = new File(walArchiveDir, FileDescriptor.fileName(segIdx) + + FilePageStoreManager.ZIP_SUFFIX + FilePageStoreManager.TMP_SUFFIX); - File tmpZip = new File(walArchiveDir, FileDescriptor.fileName(currReservedSegment) - + FilePageStoreManager.ZIP_SUFFIX + FilePageStoreManager.TMP_SUFFIX); + File zip = new File(walArchiveDir, FileDescriptor.fileName(segIdx) + FilePageStoreManager.ZIP_SUFFIX); - File zip = new File(walArchiveDir, FileDescriptor.fileName(currReservedSegment) + FilePageStoreManager.ZIP_SUFFIX); + File raw = new File(walArchiveDir, FileDescriptor.fileName(segIdx)); - File raw = new File(walArchiveDir, FileDescriptor.fileName(currReservedSegment)); if (!Files.exists(raw.toPath())) throw new IgniteCheckedException("WAL archive segment is missing: " + raw); - compressSegmentToFile(currReservedSegment, raw, tmpZip); + compressSegmentToFile(segIdx, raw, tmpZip); Files.move(tmpZip.toPath(), zip.toPath()); - if (mode != WALMode.NONE) { - try (FileIO f0 = ioFactory.create(zip, CREATE, READ, WRITE)) { - f0.force(); - } + try (FileIO f0 = ioFactory.create(zip, CREATE, READ, WRITE)) { + f0.force(); + } + + segmentAware.onSegmentCompressed(segIdx); - if (evt.isRecordable(EVT_WAL_SEGMENT_COMPACTED)) { - evt.record(new WalSegmentCompactedEvent( - cctx.discovery().localNode(), - currReservedSegment, + if (evt.isRecordable(EVT_WAL_SEGMENT_COMPACTED) && !cctx.kernalContext().recoveryMode()) { + evt.record(new WalSegmentCompactedEvent( + cctx.localNode(), + segIdx, zip.getAbsoluteFile()) - ); - } + ); } - - segmentAware.lastCompressedIdx(currReservedSegment); } catch (IgniteInterruptedCheckedException ignore) { Thread.currentThread().interrupt(); } catch (IgniteCheckedException | IOException e) { - U.error(log, "Compression of WAL segment [idx=" + currReservedSegment + - "] was skipped due to unexpected error", e); + U.error(log, "Compression of WAL segment [idx=" + segIdx + + "] was skipped due to unexpected error", e); - segmentAware.lastCompressedIdx(currReservedSegment); + segmentAware.onSegmentCompressed(segIdx); } finally { - if (currReservedSegment != -1) - release(new FileWALPointer(currReservedSegment, 0, 0)); + if (segIdx != -1L) + release(new FileWALPointer(segIdx, 0, 0)); } } } @@ -2057,7 +2048,7 @@ private void deleteObsoleteRawSegments() { * @param zip Zip file. */ private void compressSegmentToFile(long nextSegment, File raw, File zip) - throws IOException, IgniteCheckedException { + throws IOException, IgniteCheckedException { int segmentSerializerVer; try (FileIO fileIO = ioFactory.create(raw)) { @@ -2066,7 +2057,7 @@ private void compressSegmentToFile(long nextSegment, File raw, File zip) try (ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zip)))) { zos.setLevel(dsCfg.getWalCompactionLevel()); - zos.putNextEntry(new ZipEntry("")); + zos.putNextEntry(new ZipEntry(nextSegment + ".wal")); ByteBuffer buf = ByteBuffer.allocate(HEADER_RECORD_SIZE); buf.order(ByteOrder.nativeOrder()); @@ -2087,7 +2078,7 @@ private void compressSegmentToFile(long nextSegment, File raw, File zip) }; try (SingleSegmentLogicalRecordsIterator iter = new SingleSegmentLogicalRecordsIterator( - log, cctx, ioFactory, BUF_SIZE, nextSegment, walArchiveDir, appendToZipC)) { + log, cctx, ioFactory, BUF_SIZE, nextSegment, walArchiveDir, appendToZipC)) { while (iter.hasNextX()) iter.nextX(); @@ -2106,7 +2097,7 @@ private void compressSegmentToFile(long nextSegment, File raw, File zip) * @param ser Record Serializer. */ @NotNull private ByteBuffer prepareSwitchSegmentRecordBuffer(long nextSegment, RecordSerializer ser) - throws IgniteCheckedException { + throws IgniteCheckedException { SwitchSegmentRecord switchRecord = new SwitchSegmentRecord(); int switchRecordSize = ser.size(switchRecord); @@ -2121,16 +2112,33 @@ private void compressSegmentToFile(long nextSegment, File raw, File zip) } /** - * @throws IgniteInterruptedCheckedException If failed to wait for thread shutdown. + * Deletes raw WAL segments if they aren't locked and already have compressed copies of themselves. */ - private void shutdown() throws IgniteInterruptedCheckedException { - synchronized (this) { - stopped = true; + private void deleteObsoleteRawSegments() { + FileDescriptor[] descs = scan(walArchiveDir.listFiles(WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER)); - notifyAll(); + Set indices = new HashSet<>(); + Set duplicateIndices = new HashSet<>(); + + for (FileDescriptor desc : descs) { + if (!indices.add(desc.idx)) + duplicateIndices.add(desc.idx); } - U.join(this); + for (FileDescriptor desc : descs) { + if (desc.isCompressed()) + continue; + + // Do not delete reserved or locked segment and any segment after it. + if (segmentReservedOrLocked(desc.idx)) + return; + + if (desc.idx < segmentAware.keepUncompressedIdxFrom() && duplicateIndices.contains(desc.idx)) { + if (desc.file.exists() && !desc.file.delete()) + U.warn(log, "Failed to remove obsolete WAL segment (make sure the process has enough rights): " + + desc.file.getAbsolutePath() + ", exists: " + desc.file.exists()); + } + } } } @@ -2273,6 +2281,15 @@ private void shutdown() { U.join(this, log); } + + /** Restart worker. */ + void restart() { + assert runner() == null : "FileDecompressor is still running."; + + isCancelled = false; + + new IgniteThread(this).start(); + } } /** @@ -2319,7 +2336,7 @@ else if (create) * @param ver Version. * @param compacted Compacted flag. */ - @NotNull private static ByteBuffer prepareSerializerVersionBuffer(long idx, int ver, boolean compacted, ByteBuffer buf) { + @NotNull public static ByteBuffer prepareSerializerVersionBuffer(long idx, int ver, boolean compacted, ByteBuffer buf) { // Write record type. buf.put((byte) (WALRecord.RecordType.HEADER_RECORD.ordinal() + 1)); @@ -2339,7 +2356,7 @@ else if (create) buf.position(0); // This call will move buffer position to the end of the record again. - int crcVal = PureJavaCrc32.calcCrc32(buf, curPos); + int crcVal = FastCrc.calcCrc(buf, curPos); buf.putInt(crcVal); } @@ -2355,44 +2372,18 @@ else if (create) /** * */ - private abstract static class FileHandle { - /** I/O interface for read/write operations with file */ - SegmentIO fileIO; + public static class ReadFileHandle extends AbstractFileHandle implements AbstractWalRecordsIterator.AbstractReadFileHandle { + /** Entry serializer. */ + RecordSerializer ser; - /** Segment idx corresponded to fileIo*/ - final long segmentIdx; - - /** - * @param fileIO I/O interface for read/write operations of FileHandle. - */ - private FileHandle(@NotNull SegmentIO fileIO) { - this.fileIO = fileIO; - segmentIdx = fileIO.getSegmentId(); - } - - /** - * @return Absolute WAL segment file index (incremental counter). - */ - public long getSegmentId(){ - return segmentIdx; - } - } - - /** - * - */ - public static class ReadFileHandle extends FileHandle implements AbstractWalRecordsIterator.AbstractReadFileHandle { - /** Entry serializer. */ - RecordSerializer ser; - - /** */ - FileInput in; + /** */ + FileInput in; /** Holder of actual information of latest manipulation on WAL segments. */ private final SegmentAware segmentAware; /** - * @param fileIO I/O interface for read/write operations of FileHandle. + * @param fileIO I/O interface for read/write operations of AbstractFileHandle. * @param ser Entry serializer. * @param in File input. * @param aware Segment aware. @@ -2444,459 +2435,6 @@ public ReadFileHandle( } } - /** - * File handle for one log segment. - */ - @SuppressWarnings("SignalWithoutCorrespondingAwait") - private class FileWriteHandle extends FileHandle { - /** */ - private final RecordSerializer serializer; - - /** Created on resume logging. */ - private volatile boolean resume; - - /** - * Position in current file after the end of last written record (incremented after file channel write - * operation) - */ - volatile long written; - - /** */ - private volatile long lastFsyncPos; - - /** Stop guard to provide warranty that only one thread will be successful in calling {@link #close(boolean)} */ - private final AtomicBoolean stop = new AtomicBoolean(false); - - /** */ - private final Lock lock = new ReentrantLock(); - - /** Condition for timed wait of several threads, see {@link DataStorageConfiguration#getWalFsyncDelayNanos()} */ - private final Condition fsync = lock.newCondition(); - - /** - * Next segment available condition. Protection from "spurious wakeup" is provided by predicate {@link - * #fileIO}=null - */ - private final Condition nextSegment = lock.newCondition(); - - /** Buffer. */ - private final SegmentedRingByteBuffer buf; - - /** - * @param fileIO I/O file interface to use - * @param pos Position. - * @param resume Created on resume logging flag. - * @param serializer Serializer. - * @param buf Buffer. - * @throws IOException If failed. - */ - private FileWriteHandle( - SegmentIO fileIO, - long pos, - boolean resume, - RecordSerializer serializer, - SegmentedRingByteBuffer buf - ) throws IOException { - super(fileIO); - - assert serializer != null; - - if (!mmap) - fileIO.position(pos); - - this.serializer = serializer; - - written = pos; - lastFsyncPos = pos; - this.resume = resume; - this.buf = buf; - } - - /** - * Write serializer version to current handle. - */ - public void writeHeader() { - SegmentedRingByteBuffer.WriteSegment seg = buf.offer(HEADER_RECORD_SIZE); - - assert seg != null && seg.position() > 0; - - prepareSerializerVersionBuffer(getSegmentId(), serializerVersion(), false, seg.buffer()); - - seg.release(); - } - - /** - * @param rec Record to be added to write queue. - * @return Pointer or null if roll over to next segment is required or already started by other thread. - * @throws StorageException If failed. - * @throws IgniteCheckedException If failed. - */ - @Nullable private WALPointer addRecord(WALRecord rec) throws StorageException, IgniteCheckedException { - assert rec.size() > 0 : rec; - - for (;;) { - checkNode(); - - SegmentedRingByteBuffer.WriteSegment seg; - - // Buffer can be in open state in case of resuming with different serializer version. - if (rec.type() == SWITCH_SEGMENT_RECORD && !currHnd.resume) - seg = buf.offerSafe(rec.size()); - else - seg = buf.offer(rec.size()); - - FileWALPointer ptr = null; - - if (seg != null) { - try { - int pos = (int)(seg.position() - rec.size()); - - ByteBuffer buf = seg.buffer(); - - if (buf == null) - return null; // Can not write to this segment, need to switch to the next one. - - ptr = new FileWALPointer(getSegmentId(), pos, rec.size()); - - rec.position(ptr); - - fillBuffer(buf, rec); - - if (mmap) { - // written field must grow only, but segment with greater position can be serialized - // earlier than segment with smaller position. - while (true) { - long written0 = written; - - if (seg.position() > written0) { - if (WRITTEN_UPD.compareAndSet(this, written0, seg.position())) - break; - } - else - break; - } - } - - return ptr; - } - finally { - seg.release(); - - if (mode == WALMode.BACKGROUND && rec instanceof CheckpointRecord) - flushOrWait(ptr); - } - } - else - walWriter.flushAll(); - } - } - - /** - * Flush or wait for concurrent flush completion. - * - * @param ptr Pointer. - */ - private void flushOrWait(FileWALPointer ptr) throws IgniteCheckedException { - if (ptr != null) { - // If requested obsolete file index, it must be already flushed by close. - if (ptr.index() != getSegmentId()) - return; - } - - flush(ptr); - } - - /** - * @param ptr Pointer. - */ - private void flush(FileWALPointer ptr) throws IgniteCheckedException { - if (ptr == null) { // Unconditional flush. - walWriter.flushAll(); - - return; - } - - assert ptr.index() == getSegmentId(); - - walWriter.flushBuffer(ptr.fileOffset()); - } - - /** - * @param buf Buffer. - * @param rec WAL record. - * @throws IgniteCheckedException If failed. - */ - private void fillBuffer(ByteBuffer buf, WALRecord rec) throws IgniteCheckedException { - try { - serializer.writeRecord(rec, buf); - } - catch (RuntimeException e) { - throw new IllegalStateException("Failed to write record: " + rec, e); - } - } - - /** - * Non-blocking check if this pointer needs to be sync'ed. - * - * @param ptr WAL pointer to check. - * @return {@code False} if this pointer has been already sync'ed. - */ - private boolean needFsync(FileWALPointer ptr) { - // If index has changed, it means that the log was rolled over and already sync'ed. - // If requested position is smaller than last sync'ed, it also means all is good. - // If position is equal, then our record is the last not synced. - return getSegmentId() == ptr.index() && lastFsyncPos <= ptr.fileOffset(); - } - - /** - * @return Pointer to the end of the last written record (probably not fsync-ed). - */ - private FileWALPointer position() { - lock.lock(); - - try { - return new FileWALPointer(getSegmentId(), (int)written, 0); - } - finally { - lock.unlock(); - } - } - - /** - * @param ptr Pointer to sync. - * @throws StorageException If failed. - */ - private void fsync(FileWALPointer ptr) throws StorageException, IgniteCheckedException { - lock.lock(); - - try { - if (ptr != null) { - if (!needFsync(ptr)) - return; - - if (fsyncDelay > 0 && !stop.get()) { - // Delay fsync to collect as many updates as possible: trade latency for throughput. - U.await(fsync, fsyncDelay, TimeUnit.NANOSECONDS); - - if (!needFsync(ptr)) - return; - } - } - - flushOrWait(ptr); - - if (stop.get()) - return; - - long lastFsyncPos0 = lastFsyncPos; - long written0 = written; - - if (lastFsyncPos0 != written0) { - // Fsync position must be behind. - assert lastFsyncPos0 < written0 : "lastFsyncPos=" + lastFsyncPos0 + ", written=" + written0; - - boolean metricsEnabled = metrics.metricsEnabled(); - - long start = metricsEnabled ? System.nanoTime() : 0; - - if (mmap) { - long pos = ptr == null ? -1 : ptr.fileOffset(); - - List segs = buf.poll(pos); - - if (segs != null) { - assert segs.size() == 1; - - SegmentedRingByteBuffer.ReadSegment seg = segs.get(0); - - int off = seg.buffer().position(); - int len = seg.buffer().limit() - off; - - fsync((MappedByteBuffer)buf.buf, off, len); - - seg.release(); - } - } - else - walWriter.force(); - - lastFsyncPos = written; - - if (fsyncDelay > 0) - fsync.signalAll(); - - long end = metricsEnabled ? System.nanoTime() : 0; - - if (metricsEnabled) - metrics.onFsync(end - start); - } - } - finally { - lock.unlock(); - } - } - - /** - * @param buf Mapped byte buffer.. - * @param off Offset. - * @param len Length. - */ - private void fsync(MappedByteBuffer buf, int off, int len) throws IgniteCheckedException { - try { - long mappedOff = (Long)mappingOffset.invoke(buf); - - assert mappedOff == 0 : mappedOff; - - long addr = (Long)mappingAddress.invoke(buf, mappedOff); - - long delta = (addr + off) % PAGE_SIZE; - - long alignedAddr = (addr + off) - delta; - - force0.invoke(buf, fd.get(buf), alignedAddr, len + delta); - } - catch (IllegalAccessException | InvocationTargetException e) { - throw new IgniteCheckedException(e); - } - } - - /** - * @return {@code true} If this thread actually closed the segment. - * @throws IgniteCheckedException If failed. - * @throws StorageException If failed. - */ - private boolean close(boolean rollOver) throws IgniteCheckedException, StorageException { - if (stop.compareAndSet(false, true)) { - lock.lock(); - - try { - flushOrWait(null); - - try { - RecordSerializer backwardSerializer = new RecordSerializerFactoryImpl(cctx) - .createSerializer(serializerVer); - - SwitchSegmentRecord segmentRecord = new SwitchSegmentRecord(); - - int switchSegmentRecSize = backwardSerializer.size(segmentRecord); - - if (rollOver && written < (maxWalSegmentSize - switchSegmentRecSize)) { - segmentRecord.size(switchSegmentRecSize); - - WALPointer segRecPtr = addRecord(segmentRecord); - - if (segRecPtr != null) - fsync((FileWALPointer)segRecPtr); - } - - if (mmap) { - List segs = buf.poll(maxWalSegmentSize); - - if (segs != null) { - assert segs.size() == 1; - - segs.get(0).release(); - } - } - - // Do the final fsync. - if (mode != WALMode.NONE) { - if (mmap) - ((MappedByteBuffer)buf.buf).force(); - else - fileIO.force(); - - lastFsyncPos = written; - } - - if (mmap) { - try { - fileIO.close(); - } - catch (IOException ignore) { - // No-op. - } - } - else { - walWriter.close(); - - if (!rollOver) - buf.free(); - } - } - catch (IOException e) { - throw new StorageException("Failed to close WAL write handle [idx=" + getSegmentId() + "]", e); - } - - if (log.isDebugEnabled()) - log.debug("Closed WAL write handle [idx=" + getSegmentId() + "]"); - - return true; - } - finally { - if (mmap) - buf.free(); - - lock.unlock(); - } - } - else - return false; - } - - /** - * Signals next segment available to wake up other worker threads waiting for WAL to write - */ - private void signalNextAvailable() { - lock.lock(); - - try { - assert cctx.kernalContext().invalid() || - written == lastFsyncPos || mode != WALMode.FSYNC : - "fsync [written=" + written + ", lastFsync=" + lastFsyncPos + ", idx=" + getSegmentId() + ']'; - - fileIO = null; - - nextSegment.signalAll(); - } - finally { - lock.unlock(); - } - } - - /** - * - */ - private void awaitNext() { - lock.lock(); - - try { - while (fileIO != null) - U.awaitQuiet(nextSegment); - } - finally { - lock.unlock(); - } - } - - /** - * @return Safely reads current position of the file channel as String. Will return "null" if channel is null. - */ - private String safePosition() { - FileIO io = fileIO; - - if (io == null) - return "null"; - - try { - return String.valueOf(io.position()); - } - catch (IOException e) { - return "{Failed to read channel position: " + e.getMessage() + '}'; - } - } - } - /** * Iterator over WAL-log. */ @@ -3185,353 +2723,13 @@ private void doFlush() { FileWriteHandle hnd = currentHandle(); try { - hnd.flush(null); + hnd.flushAll(); } catch (Exception e) { U.warn(log, "Failed to flush WAL record queue", e); } } - /** - * WAL writer worker. - */ - @SuppressWarnings("ForLoopReplaceableByForEach") - private class WALWriter extends GridWorker { - /** Unconditional flush. */ - private static final long UNCONDITIONAL_FLUSH = -1L; - - /** File close. */ - private static final long FILE_CLOSE = -2L; - - /** File force. */ - private static final long FILE_FORCE = -3L; - - /** Err. */ - private volatile Throwable err; - - //TODO: replace with GC free data structure. - /** Parked threads. */ - final Map waiters = new ConcurrentHashMap<>(); - - /** - * Default constructor. - * - * @param log Logger. - */ - WALWriter(IgniteLogger log) { - super(cctx.igniteInstanceName(), "wal-write-worker%" + cctx.igniteInstanceName(), log, - cctx.kernalContext().workersRegistry()); - } - - /** {@inheritDoc} */ - @Override protected void body() { - Throwable err = null; - - try { - while (!isCancelled()) { - onIdle(); - - while (waiters.isEmpty()) { - if (!isCancelled()) { - blockingSectionBegin(); - - try { - LockSupport.park(); - } - finally { - blockingSectionEnd(); - } - } - else { - unparkWaiters(Long.MAX_VALUE); - - return; - } - } - - Long pos = null; - - for (Long val : waiters.values()) { - if (val > Long.MIN_VALUE) - pos = val; - } - - updateHeartbeat(); - - if (pos == null) - continue; - else if (pos < UNCONDITIONAL_FLUSH) { - try { - assert pos == FILE_CLOSE || pos == FILE_FORCE : pos; - - if (pos == FILE_CLOSE) - currHnd.fileIO.close(); - else if (pos == FILE_FORCE) - currHnd.fileIO.force(); - } - catch (IOException e) { - log.error("Exception in WAL writer thread: ", e); - - err = e; - - unparkWaiters(Long.MAX_VALUE); - - return; - } - - unparkWaiters(pos); - } - - updateHeartbeat(); - - List segs = currentHandle().buf.poll(pos); - - if (segs == null) { - unparkWaiters(pos); - - continue; - } - - for (int i = 0; i < segs.size(); i++) { - SegmentedRingByteBuffer.ReadSegment seg = segs.get(i); - - updateHeartbeat(); - - try { - writeBuffer(seg.position(), seg.buffer()); - } - catch (Throwable e) { - log.error("Exception in WAL writer thread:", e); - - err = e; - } - finally { - seg.release(); - - long p = pos <= UNCONDITIONAL_FLUSH || err != null ? Long.MAX_VALUE : currentHandle().written; - - unparkWaiters(p); - } - } - } - } - catch (Throwable t) { - err = t; - } - finally { - unparkWaiters(Long.MAX_VALUE); - - if (err == null && !isCancelled) - err = new IllegalStateException("Worker " + name() + " is terminated unexpectedly"); - - if (err instanceof OutOfMemoryError) - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, err)); - else if (err != null) - cctx.kernalContext().failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, err)); - } - } - - /** - * Shutdowns thread. - */ - public void shutdown() throws IgniteInterruptedCheckedException { - U.cancel(this); - - LockSupport.unpark(runner()); - - U.join(runner()); - } - - /** - * Unparks waiting threads. - * - * @param pos Pos. - */ - private void unparkWaiters(long pos) { - assert pos > Long.MIN_VALUE : pos; - - for (Map.Entry e : waiters.entrySet()) { - Long val = e.getValue(); - - if (val <= pos) { - if (val != Long.MIN_VALUE) - waiters.put(e.getKey(), Long.MIN_VALUE); - - LockSupport.unpark(e.getKey()); - } - } - } - - /** - * Forces all made changes to the file. - */ - void force() throws IgniteCheckedException { - flushBuffer(FILE_FORCE); - } - - /** - * Closes file. - */ - void close() throws IgniteCheckedException { - flushBuffer(FILE_CLOSE); - } - - /** - * Flushes all data from the buffer. - */ - void flushAll() throws IgniteCheckedException { - flushBuffer(UNCONDITIONAL_FLUSH); - } - - /** - * @param expPos Expected position. - */ - @SuppressWarnings("ForLoopReplaceableByForEach") - void flushBuffer(long expPos) throws IgniteCheckedException { - if (mmap) - return; - - Throwable err = walWriter.err; - - if (err != null) - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, err)); - - if (expPos == UNCONDITIONAL_FLUSH) - expPos = (currentHandle().buf.tail()); - - Thread t = Thread.currentThread(); - - waiters.put(t, expPos); - - LockSupport.unpark(walWriter.runner()); - - while (true) { - Long val = waiters.get(t); - - assert val != null : "Only this thread can remove thread from waiters"; - - if (val == Long.MIN_VALUE) { - waiters.remove(t); - - Throwable walWriterError = walWriter.err; - - if (walWriterError != null) - throw new IgniteCheckedException("Flush buffer failed.", walWriterError); - - return; - } - else - LockSupport.park(); - } - } - - /** - * @param pos Position in file to start write from. May be checked against actual position to wait previous - * writes to complete - * @param buf Buffer to write to file - * @throws StorageException If failed. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("TooBroadScope") - private void writeBuffer(long pos, ByteBuffer buf) throws StorageException, IgniteCheckedException { - FileWriteHandle hdl = currentHandle(); - - assert hdl.fileIO != null : "Writing to a closed segment."; - - checkNode(); - - long lastLogged = U.currentTimeMillis(); - - long logBackoff = 2_000; - - // If we were too fast, need to wait previous writes to complete. - while (hdl.written != pos) { - assert hdl.written < pos : "written = " + hdl.written + ", pos = " + pos; // No one can write further than we are now. - - // Permutation occurred between blocks write operations. - // Order of acquiring lock is not the same as order of write. - long now = U.currentTimeMillis(); - - if (now - lastLogged >= logBackoff) { - if (logBackoff < 60 * 60_000) - logBackoff *= 2; - - U.warn(log, "Still waiting for a concurrent write to complete [written=" + hdl.written + - ", pos=" + pos + ", lastFsyncPos=" + hdl.lastFsyncPos + ", stop=" + hdl.stop.get() + - ", actualPos=" + hdl.safePosition() + ']'); - - lastLogged = now; - } - - checkNode(); - } - - // Do the write. - int size = buf.remaining(); - - assert size > 0 : size; - - try { - assert hdl.written == hdl.fileIO.position(); - - hdl.written += hdl.fileIO.writeFully(buf); - - metrics.onWalBytesWritten(size); - - assert hdl.written == hdl.fileIO.position(); - } - catch (IOException e) { - StorageException se = new StorageException("Failed to write buffer.", e); - - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, se)); - - throw se; - } - } - } - - /** - * Syncs WAL segment file. - */ - private class WalSegmentSyncer extends GridWorker { - /** Sync timeout. */ - long syncTimeout; - - /** - * @param igniteInstanceName Ignite instance name. - * @param log Logger. - */ - public WalSegmentSyncer(String igniteInstanceName, IgniteLogger log) { - super(igniteInstanceName, "wal-segment-syncer", log); - - syncTimeout = Math.max(IgniteSystemProperties.getLong(IGNITE_WAL_SEGMENT_SYNC_TIMEOUT, - DFLT_WAL_SEGMENT_SYNC_TIMEOUT), 100L); - } - - /** {@inheritDoc} */ - @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException { - while (!isCancelled()) { - sleep(syncTimeout); - - try { - flush(null, true); - } - catch (IgniteCheckedException e) { - U.error(log, "Exception when flushing WAL.", e); - } - } - } - - /** Shutted down the worker. */ - private void shutdown() { - synchronized (this) { - U.cancel(this); - } - - U.join(this, log); - } - } - /** * Scans provided folder for a WAL segment files * @param walFilesDir directory to scan diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java deleted file mode 100644 index 12d0c51814bea..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FsyncModeFileWriteAheadLogManager.java +++ /dev/null @@ -1,3457 +0,0 @@ -/* - * 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. - */ - -package org.apache.ignite.internal.processors.cache.persistence.wal; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.EOFException; -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.file.DirectoryStream; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.sql.Time; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.NavigableMap; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.concurrent.PriorityBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.LockSupport; -import java.util.concurrent.locks.ReentrantLock; -import java.util.regex.Pattern; -import java.util.stream.Stream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.IgniteSystemProperties; -import org.apache.ignite.configuration.DataStorageConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.events.EventType; -import org.apache.ignite.events.WalSegmentArchivedEvent; -import org.apache.ignite.events.WalSegmentCompactedEvent; -import org.apache.ignite.failure.FailureContext; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.IgniteInterruptedCheckedException; -import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager; -import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; -import org.apache.ignite.internal.pagemem.wal.WALIterator; -import org.apache.ignite.internal.pagemem.wal.WALPointer; -import org.apache.ignite.internal.pagemem.wal.record.MarshalledRecord; -import org.apache.ignite.internal.pagemem.wal.record.SwitchSegmentRecord; -import org.apache.ignite.internal.pagemem.wal.record.WALRecord; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter; -import org.apache.ignite.internal.processors.cache.WalStateManager.WALDisableContext; -import org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl; -import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; -import org.apache.ignite.internal.processors.cache.persistence.StorageException; -import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; -import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; -import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; -import org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings; -import org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException; -import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; -import org.apache.ignite.internal.processors.cache.persistence.wal.io.FileInput; -import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentFileInputFactory; -import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentIO; -import org.apache.ignite.internal.processors.cache.persistence.wal.io.SimpleSegmentFileInputFactory; -import org.apache.ignite.internal.processors.cache.persistence.wal.record.HeaderRecord; -import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer; -import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactory; -import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl; -import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer; -import org.apache.ignite.internal.processors.timeout.GridTimeoutObject; -import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; -import org.apache.ignite.internal.util.GridUnsafe; -import org.apache.ignite.internal.util.future.GridFinishedFuture; -import org.apache.ignite.internal.util.future.GridFutureAdapter; -import org.apache.ignite.internal.util.typedef.CI1; -import org.apache.ignite.internal.util.typedef.CIX1; -import org.apache.ignite.internal.util.typedef.CO; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.util.worker.GridWorker; -import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.thread.IgniteThread; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SERIALIZER_VERSION; -import static org.apache.ignite.events.EventType.EVT_WAL_SEGMENT_COMPACTED; -import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR; -import static org.apache.ignite.failure.FailureType.SYSTEM_WORKER_TERMINATION; -import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.readSegmentHeader; - -/** - * File WAL manager. - */ -public class FsyncModeFileWriteAheadLogManager extends GridCacheSharedManagerAdapter implements IgniteWriteAheadLogManager { - /** */ - public static final FileDescriptor[] EMPTY_DESCRIPTORS = new FileDescriptor[0]; - - /** */ - private static final byte[] FILL_BUF = new byte[1024 * 1024]; - - /** Pattern for segment file names */ - private static final Pattern WAL_NAME_PATTERN = Pattern.compile("\\d{16}\\.wal"); - - /** */ - private static final Pattern WAL_TEMP_NAME_PATTERN = Pattern.compile("\\d{16}\\.wal\\.tmp"); - - /** WAL segment file filter, see {@link #WAL_NAME_PATTERN} */ - public static final FileFilter WAL_SEGMENT_FILE_FILTER = new FileFilter() { - @Override public boolean accept(File file) { - return !file.isDirectory() && WAL_NAME_PATTERN.matcher(file.getName()).matches(); - } - }; - - /** */ - private static final FileFilter WAL_SEGMENT_TEMP_FILE_FILTER = new FileFilter() { - @Override public boolean accept(File file) { - return !file.isDirectory() && WAL_TEMP_NAME_PATTERN.matcher(file.getName()).matches(); - } - }; - - /** */ - private static final Pattern WAL_SEGMENT_FILE_COMPACTED_PATTERN = Pattern.compile("\\d{16}\\.wal\\.zip"); - - /** WAL segment file filter, see {@link #WAL_NAME_PATTERN} */ - public static final FileFilter WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER = new FileFilter() { - @Override public boolean accept(File file) { - return !file.isDirectory() && (WAL_NAME_PATTERN.matcher(file.getName()).matches() || - WAL_SEGMENT_FILE_COMPACTED_PATTERN.matcher(file.getName()).matches()); - } - }; - - /** */ - private static final Pattern WAL_SEGMENT_TEMP_FILE_COMPACTED_PATTERN = Pattern.compile("\\d{16}\\.wal\\.zip\\.tmp"); - - /** */ - private static final FileFilter WAL_SEGMENT_FILE_COMPACTED_FILTER = new FileFilter() { - @Override public boolean accept(File file) { - return !file.isDirectory() && WAL_SEGMENT_FILE_COMPACTED_PATTERN.matcher(file.getName()).matches(); - } - }; - - /** */ - private static final FileFilter WAL_SEGMENT_TEMP_FILE_COMPACTED_FILTER = new FileFilter() { - @Override public boolean accept(File file) { - return !file.isDirectory() && WAL_SEGMENT_TEMP_FILE_COMPACTED_PATTERN.matcher(file.getName()).matches(); - } - }; - - /** Latest serializer version to use. */ - private static final int LATEST_SERIALIZER_VERSION = 2; - - /** - * Percentage of archive size for checkpoint trigger. Need for calculate max size of WAL after last checkpoint. - * Checkpoint should be triggered when max size of WAL after last checkpoint more than maxWallArchiveSize * thisValue - */ - private static final double CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE = - IgniteSystemProperties.getDouble(IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE, 0.25); - - /** - * Percentage of WAL archive size to calculate threshold since which removing of old archive should be started. - */ - private static final double THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE = - IgniteSystemProperties.getDouble(IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE, 0.5); - - /** */ - private final boolean alwaysWriteFullPages; - - /** WAL segment size in bytes */ - private final long maxWalSegmentSize; - - /** - * Maximum number of allowed segments without checkpoint. If we have their more checkpoint should be triggered. - * It is simple way to calculate wal size without checkpoint instead fair wal size calculating. - */ - private long maxSegCountWithoutCheckpoint; - - /** Size of wal archive since which removing of old archive should be started */ - private final long allowedThresholdWalArchiveSize; - - /** */ - private final WALMode mode; - - /** Thread local byte buffer size, see {@link #tlb} */ - private final int tlbSize; - - /** WAL flush frequency. Makes sense only for {@link WALMode#BACKGROUND} log WALMode. */ - private final long flushFreq; - - /** Fsync delay. */ - private final long fsyncDelay; - - /** */ - private final DataStorageConfiguration dsCfg; - - /** Events service */ - private final GridEventStorageManager evt; - - /** */ - private IgniteConfiguration igCfg; - - /** Persistence metrics tracker. */ - private DataStorageMetricsImpl metrics; - - /** */ - private File walWorkDir; - - /** WAL archive directory (including consistent ID as subfolder) */ - private File walArchiveDir; - - /** Serializer of latest version, used to read header record and for write records */ - private RecordSerializer serializer; - - /** Serializer latest version to use. */ - private final int serializerVersion = - IgniteSystemProperties.getInteger(IGNITE_WAL_SERIALIZER_VERSION, LATEST_SERIALIZER_VERSION); - - /** Latest segment cleared by {@link #truncate(WALPointer, WALPointer)}. */ - private volatile long lastTruncatedArchiveIdx = -1L; - - /** Factory to provide I/O interfaces for read/write operations with files */ - private volatile FileIOFactory ioFactory; - - /** Factory to provide I/O interfaces for read primitives with files */ - private final SegmentFileInputFactory segmentFileInputFactory; - - /** Updater for {@link #currentHnd}, used for verify there are no concurrent update for current log segment handle */ - private static final AtomicReferenceFieldUpdater currentHndUpd = - AtomicReferenceFieldUpdater.newUpdater(FsyncModeFileWriteAheadLogManager.class, FileWriteHandle.class, "currentHnd"); - - /** - * Thread local byte buffer for saving serialized WAL records chain, see {@link FileWriteHandle#head}. - * Introduced to decrease number of buffers allocation. - * Used only for record itself is shorter than {@link #tlbSize}. - */ - private final ThreadLocal tlb = new ThreadLocal() { - @Override protected ByteBuffer initialValue() { - ByteBuffer buf = ByteBuffer.allocateDirect(tlbSize); - - buf.order(GridUnsafe.NATIVE_BYTE_ORDER); - - return buf; - } - }; - - /** */ - private volatile FileArchiver archiver; - - /** Compressor. */ - private volatile FileCompressor compressor; - - /** Decompressor. */ - private volatile FileDecompressor decompressor; - - /** */ - private final ThreadLocal lastWALPtr = new ThreadLocal<>(); - - /** Current log segment handle */ - private volatile FileWriteHandle currentHnd; - - /** */ - private volatile WALDisableContext walDisableContext; - - /** - * Positive (non-0) value indicates WAL can be archived even if not complete
- * See {@link DataStorageConfiguration#setWalAutoArchiveAfterInactivity(long)}
- */ - private final long walAutoArchiveAfterInactivity; - - /** - * Container with last WAL record logged timestamp.
- * Zero value means there was no records logged to current segment, skip possible archiving for this case
- * Value is filled only for case {@link #walAutoArchiveAfterInactivity} > 0
- */ - private AtomicLong lastRecordLoggedMs = new AtomicLong(); - - /** - * Cancellable task for {@link WALMode#BACKGROUND}, should be cancelled at shutdown - * Null for non background modes - */ - @Nullable private volatile GridTimeoutProcessor.CancelableTask backgroundFlushSchedule; - - /** - * Reference to the last added next archive timeout check object. - * Null if mode is not enabled. - * Should be cancelled at shutdown - */ - @Nullable private volatile GridTimeoutObject nextAutoArchiveTimeoutObj; - - /** - * @param ctx Kernal context. - */ - public FsyncModeFileWriteAheadLogManager(@NotNull final GridKernalContext ctx) { - igCfg = ctx.config(); - - DataStorageConfiguration dsCfg = igCfg.getDataStorageConfiguration(); - - assert dsCfg != null; - - this.dsCfg = dsCfg; - - maxWalSegmentSize = dsCfg.getWalSegmentSize(); - mode = dsCfg.getWalMode(); - tlbSize = dsCfg.getWalThreadLocalBufferSize(); - flushFreq = dsCfg.getWalFlushFrequency(); - fsyncDelay = dsCfg.getWalFsyncDelayNanos(); - alwaysWriteFullPages = dsCfg.isAlwaysWriteFullPages(); - ioFactory = dsCfg.getFileIOFactory(); - segmentFileInputFactory = new SimpleSegmentFileInputFactory(); - walAutoArchiveAfterInactivity = dsCfg.getWalAutoArchiveAfterInactivity(); - evt = ctx.event(); - - allowedThresholdWalArchiveSize = (long)(dsCfg.getMaxWalArchiveSize() * THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE); - - assert mode == WALMode.FSYNC : dsCfg; - } - - /** - * For test purposes only. - * - * @param ioFactory IO factory. - */ - public void setFileIOFactory(FileIOFactory ioFactory) { - this.ioFactory = ioFactory; - } - - /** {@inheritDoc} */ - @Override public void start0() throws IgniteCheckedException { - if (!cctx.kernalContext().clientNode()) { - maxSegCountWithoutCheckpoint = - (long)((U.adjustedWalHistorySize(dsCfg, log) * CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE) - / dsCfg.getWalSegmentSize()); - - final PdsFolderSettings resolveFolders = cctx.kernalContext().pdsFolderResolver().resolveFolders(); - - checkWalConfiguration(); - - final File walWorkDir0 = walWorkDir = initDirectory( - dsCfg.getWalPath(), - DataStorageConfiguration.DFLT_WAL_PATH, - resolveFolders.folderName(), - "write ahead log work directory" - ); - - final File walArchiveDir0 = walArchiveDir = initDirectory( - dsCfg.getWalArchivePath(), - DataStorageConfiguration.DFLT_WAL_ARCHIVE_PATH, - resolveFolders.folderName(), - "write ahead log archive directory" - ); - - serializer = new RecordSerializerFactoryImpl(cctx).createSerializer(serializerVersion); - - GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)cctx.database(); - - metrics = dbMgr.persistentStoreMetricsImpl(); - - checkOrPrepareFiles(); - - metrics.setWalSizeProvider(new CO() { - @Override public Long apply() { - long size = 0; - - for (File f : walWorkDir0.listFiles()) - size += f.length(); - - for (File f : walArchiveDir0.listFiles()) - size += f.length(); - - return size; - } - }); - - IgniteBiTuple tup = scanMinMaxArchiveIndices(); - - lastTruncatedArchiveIdx = tup == null ? -1 : tup.get1() - 1; - - archiver = isArchiverEnabled() ? new FileArchiver(tup == null ? -1 : tup.get2(), log) : null; - - if (archiver != null && dsCfg.isWalCompactionEnabled()) { - compressor = new FileCompressor(); - - if (decompressor == null) { // Preventing of two file-decompressor thread instantiations. - decompressor = new FileDecompressor(log); - - new IgniteThread(decompressor).start(); - } - } - - walDisableContext = cctx.walState().walDisableContext(); - - if (mode != WALMode.NONE) { - if (log.isInfoEnabled()) - log.info("Started write-ahead log manager [mode=" + mode + ']'); - } - else - U.quietAndWarn(log, "Started write-ahead log manager in NONE mode, persisted data may be lost in " + - "a case of unexpected node failure. Make sure to deactivate the cluster before shutdown."); - } - } - - /** - * @throws IgniteCheckedException if WAL store path is configured and archive path isn't (or vice versa) - */ - private void checkWalConfiguration() throws IgniteCheckedException { - if (dsCfg.getWalPath() == null ^ dsCfg.getWalArchivePath() == null) { - throw new IgniteCheckedException( - "Properties should be either both specified or both null " + - "[walStorePath = " + dsCfg.getWalPath() + - ", walArchivePath = " + dsCfg.getWalArchivePath() + "]" - ); - } - } - - /** {@inheritDoc} */ - @Override protected void stop0(boolean cancel) { - final GridTimeoutProcessor.CancelableTask schedule = backgroundFlushSchedule; - - if (schedule != null) - schedule.close(); - - final GridTimeoutObject timeoutObj = nextAutoArchiveTimeoutObj; - - if (timeoutObj != null) - cctx.time().removeTimeoutObject(timeoutObj); - - final FileWriteHandle currHnd = currentHandle(); - - try { - if (mode == WALMode.BACKGROUND) { - if (currHnd != null) - currHnd.flush((FileWALPointer)null, true); - } - - if (currHnd != null) - currHnd.close(false); - - if (archiver != null) - archiver.shutdown(); - - if (compressor != null) - compressor.shutdown(); - - if (decompressor != null) - decompressor.shutdown(); - } - catch (Exception e) { - U.error(log, "Failed to gracefully close WAL segment: " + currentHnd.fileIO, e); - } - } - - /** {@inheritDoc} */ - @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException { - if (log.isDebugEnabled()) - log.debug("Activated file write ahead log manager [nodeId=" + cctx.localNodeId() + - " topVer=" + cctx.discovery().topologyVersionEx() + " ]"); - - start0(); - - if (!cctx.kernalContext().clientNode()) { - if (isArchiverEnabled()) { - assert archiver != null; - - new IgniteThread(archiver).start(); - } - - if (compressor != null) - compressor.start(); - } - } - - /** {@inheritDoc} */ - @Override public void onDeActivate(GridKernalContext kctx) { - if (log.isDebugEnabled()) - log.debug("DeActivate file write ahead log [nodeId=" + cctx.localNodeId() + - " topVer=" + cctx.discovery().topologyVersionEx() + " ]"); - - stop0(true); - - currentHnd = null; - } - - /** {@inheritDoc} */ - @Override public boolean isAlwaysWriteFullPages() { - return alwaysWriteFullPages; - } - - /** {@inheritDoc} */ - @Override public boolean isFullSync() { - return mode == WALMode.FSYNC; - } - - /** {@inheritDoc} */ - @Override public void resumeLogging(WALPointer lastPtr) throws IgniteCheckedException { - assert currentHnd == null; - assert lastPtr == null || lastPtr instanceof FileWALPointer; - - FileWALPointer filePtr = (FileWALPointer)lastPtr; - - currentHnd = restoreWriteHandle(filePtr); - - if (currentHnd.serializer.version() != serializer.version()) { - if (log.isInfoEnabled()) - log.info("Record serializer version change detected, will start logging with a new WAL record " + - "serializer to a new WAL segment [curFile=" + currentHnd + ", newVer=" + serializer.version() + - ", oldVer=" + currentHnd.serializer.version() + ']'); - - rollOver(currentHnd); - } - - if (mode == WALMode.BACKGROUND) { - backgroundFlushSchedule = cctx.time().schedule(new Runnable() { - @Override public void run() { - doFlush(); - } - }, flushFreq, flushFreq); - } - - if (walAutoArchiveAfterInactivity > 0) - scheduleNextInactivityPeriodElapsedCheck(); - } - - /** - * Schedules next check of inactivity period expired. Based on current record update timestamp. - * At timeout method does check of inactivity period and schedules new launch. - */ - private void scheduleNextInactivityPeriodElapsedCheck() { - final long lastRecMs = lastRecordLoggedMs.get(); - final long nextPossibleAutoArchive = (lastRecMs <= 0 ? U.currentTimeMillis() : lastRecMs) + walAutoArchiveAfterInactivity; - - if (log.isDebugEnabled()) - log.debug("Schedule WAL rollover check at " + new Time(nextPossibleAutoArchive).toString()); - - nextAutoArchiveTimeoutObj = new GridTimeoutObject() { - private final IgniteUuid id = IgniteUuid.randomUuid(); - - @Override public IgniteUuid timeoutId() { - return id; - } - - @Override public long endTime() { - return nextPossibleAutoArchive; - } - - @Override public void onTimeout() { - if (log.isDebugEnabled()) - log.debug("Checking if WAL rollover required (" + new Time(U.currentTimeMillis()).toString() + ")"); - - checkWalRolloverRequiredDuringInactivityPeriod(); - - scheduleNextInactivityPeriodElapsedCheck(); - } - }; - cctx.time().addTimeoutObject(nextAutoArchiveTimeoutObj); - } - - /** - * Archiver can be not created, all files will be written to WAL folder, using absolute segment index. - * - * @return flag indicating if archiver is disabled. - */ - private boolean isArchiverEnabled() { - if (walArchiveDir != null && walWorkDir != null) - return !walArchiveDir.equals(walWorkDir); - - return !new File(dsCfg.getWalArchivePath()).equals(new File(dsCfg.getWalPath())); - } - - /** - * Collect wal segment files from low pointer (include) to high pointer (not include) and reserve low pointer. - * - * @param low Low bound. - * @param high High bound. - */ - public Collection getAndReserveWalFiles(FileWALPointer low, FileWALPointer high) throws IgniteCheckedException { - final long awaitIdx = high.index() - 1; - - while (archiver != null && archiver.lastArchivedAbsoluteIndex() < awaitIdx) - LockSupport.parkNanos(Thread.currentThread(), 1_000_000); - - if (!reserve(low)) - throw new IgniteCheckedException("WAL archive segment has been deleted [idx=" + low.index() + "]"); - - List res = new ArrayList<>(); - - for (long i = low.index(); i < high.index(); i++) { - String segmentName = FileDescriptor.fileName(i); - - File file = new File(walArchiveDir, segmentName); - File fileZip = new File(walArchiveDir, segmentName + FilePageStoreManager.ZIP_SUFFIX); - - if (file.exists()) - res.add(file); - else if (fileZip.exists()) - res.add(fileZip); - else { - if (log.isInfoEnabled()) { - log.info("Segment not found: " + file.getName() + "/" + fileZip.getName()); - - log.info("Stopped iteration on idx: " + i); - } - - break; - } - } - - return res; - } - - /** {@inheritDoc}*/ - @Override public int serializerVersion() { - return serializerVersion; - } - - /** - * Checks if there was elapsed significant period of inactivity. - * If WAL auto-archive is enabled using {@link #walAutoArchiveAfterInactivity} > 0 this method will activate - * roll over by timeout
- */ - private void checkWalRolloverRequiredDuringInactivityPeriod() { - if (walAutoArchiveAfterInactivity <= 0) - return; // feature not configured, nothing to do - - final long lastRecMs = lastRecordLoggedMs.get(); - - if (lastRecMs == 0) - return; //no records were logged to current segment, does not consider inactivity - - final long elapsedMs = U.currentTimeMillis() - lastRecMs; - - if (elapsedMs <= walAutoArchiveAfterInactivity) - return; // not enough time elapsed since last write - - if (!lastRecordLoggedMs.compareAndSet(lastRecMs, 0)) - return; // record write occurred concurrently - - final FileWriteHandle handle = currentHandle(); - - try { - rollOver(handle); - } - catch (IgniteCheckedException e) { - U.error(log, "Unable to perform segment rollover: " + e.getMessage(), e); - - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, e)); - } - } - - /** {@inheritDoc} */ - @SuppressWarnings("TooBroadScope") - @Override public WALPointer log(WALRecord record) throws IgniteCheckedException, StorageException { - if (serializer == null || mode == WALMode.NONE) - return null; - - FileWriteHandle currWrHandle = currentHandle(); - - WALDisableContext isDisable = walDisableContext; - - // Logging was not resumed yet. - if (currWrHandle == null || (isDisable != null && isDisable.check())) - return null; - - // Need to calculate record size first. - record.size(serializer.size(record)); - - while (true) { - if (record.rollOver()){ - assert cctx.database().checkpointLockIsHeldByThread(); - - currWrHandle = rollOver(currWrHandle); - } - - WALPointer ptr = currWrHandle.addRecord(record); - - if (ptr != null) { - metrics.onWalRecordLogged(); - - lastWALPtr.set(ptr); - - if (walAutoArchiveAfterInactivity > 0) - lastRecordLoggedMs.set(U.currentTimeMillis()); - - return ptr; - } - else - currWrHandle = rollOver(currWrHandle); - - checkNode(); - - if (isStopping()) - throw new IgniteCheckedException("Stopping."); - } - } - - /** {@inheritDoc} */ - @Override public void flush(WALPointer ptr, boolean explicitFsync) throws IgniteCheckedException, StorageException { - if (serializer == null || mode == WALMode.NONE) - return; - - FileWriteHandle cur = currentHandle(); - - // WAL manager was not started (client node). - if (cur == null) - return; - - FileWALPointer filePtr = (FileWALPointer)(ptr == null ? lastWALPtr.get() : ptr); - - // No need to sync if was rolled over. - if (filePtr != null && !cur.needFsync(filePtr)) - return; - - cur.fsync(filePtr, false); - } - - /** {@inheritDoc} */ - @Override public WALIterator replay(WALPointer start) - throws IgniteCheckedException, StorageException { - assert start == null || start instanceof FileWALPointer : "Invalid start pointer: " + start; - - FileWriteHandle hnd = currentHandle(); - - FileWALPointer end = null; - - if (hnd != null) - end = hnd.position(); - - return new RecordsIterator( - cctx, - walWorkDir, - walArchiveDir, - (FileWALPointer)start, - end, - dsCfg, - new RecordSerializerFactoryImpl(cctx), - ioFactory, - archiver, - decompressor, - log, - segmentFileInputFactory - ); - } - - /** {@inheritDoc} */ - @Override public boolean reserve(WALPointer start) throws IgniteCheckedException { - assert start != null && start instanceof FileWALPointer : "Invalid start pointer: " + start; - - if (mode == WALMode.NONE) - return false; - - FileArchiver archiver0 = archiver; - - if (archiver0 == null) - throw new IgniteCheckedException("Could not reserve WAL segment: archiver == null"); - - archiver0.reserve(((FileWALPointer)start).index()); - - if (!hasIndex(((FileWALPointer)start).index())) { - archiver0.release(((FileWALPointer)start).index()); - - return false; - } - - return true; - } - - /** {@inheritDoc} */ - @Override public void release(WALPointer start) throws IgniteCheckedException { - assert start != null && start instanceof FileWALPointer : "Invalid start pointer: " + start; - - if (mode == WALMode.NONE) - return; - - FileArchiver archiver0 = archiver; - - if (archiver0 == null) - throw new IgniteCheckedException("Could not release WAL segment: archiver == null"); - - archiver0.release(((FileWALPointer)start).index()); - } - - /** - * @param absIdx Absolulte index to check. - * @return {@code true} if has this index. - */ - private boolean hasIndex(long absIdx) { - String segmentName = FileDescriptor.fileName(absIdx); - - String zipSegmentName = FileDescriptor.fileName(absIdx) + FilePageStoreManager.ZIP_SUFFIX; - - boolean inArchive = new File(walArchiveDir, segmentName).exists() || - new File(walArchiveDir, zipSegmentName).exists(); - - if (inArchive) - return true; - - if (absIdx <= lastArchivedIndex()) - return false; - - FileWriteHandle cur = currentHnd; - - return cur != null && cur.getSegmentId() >= absIdx; - } - - /** {@inheritDoc} */ - @Override public int truncate(WALPointer low, WALPointer high) { - if (high == null) - return 0; - - assert high instanceof FileWALPointer : high; - - // File pointer bound: older entries will be deleted from archive - FileWALPointer lowPtr = (FileWALPointer)low; - FileWALPointer highPtr = (FileWALPointer)high; - - FileDescriptor[] descs = scan(walArchiveDir.listFiles(WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER)); - - int deleted = 0; - - FileArchiver archiver0 = archiver; - - for (FileDescriptor desc : descs) { - if (lowPtr != null && desc.idx < lowPtr.index()) - continue; - - // Do not delete reserved or locked segment and any segment after it. - if (archiver0 != null && archiver0.reserved(desc.idx)) - return deleted; - - long lastArchived = archiver0 != null ? archiver0.lastArchivedAbsoluteIndex() : lastArchivedIndex(); - - // We need to leave at least one archived segment to correctly determine the archive index. - if (desc.idx < highPtr.index() && desc.idx < lastArchived) { - if (!desc.file.delete()) - U.warn(log, "Failed to remove obsolete WAL segment (make sure the process has enough rights): " + - desc.file.getAbsolutePath()); - else - deleted++; - - // Bump up the oldest archive segment index. - if (lastTruncatedArchiveIdx < desc.idx) - lastTruncatedArchiveIdx = desc.idx; - } - } - - return deleted; - } - - /** {@inheritDoc} */ - @Override public void notchLastCheckpointPtr(WALPointer ptr) { - if (compressor != null) - compressor.keepUncompressedIdxFrom(((FileWALPointer)ptr).index()); - } - - /** {@inheritDoc} */ - @Override public int walArchiveSegments() { - if (archiver == null) - return 0; - - long lastTruncated = lastTruncatedArchiveIdx; - - long lastArchived = archiver.lastArchivedAbsoluteIndex(); - - if (lastArchived == -1) - return 0; - - int res = (int)(lastArchived - lastTruncated); - - return res >= 0 ? res : 0; - } - - /** - * Files from archive WAL directory. - */ - private FileDescriptor[] walArchiveFiles() { - return scan(walArchiveDir.listFiles(WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER)); - } - - /** {@inheritDoc} */ - @Override public long maxArchivedSegmentToDelete() { - //When maxWalArchiveSize==MAX_VALUE deleting files is not permit. - if (dsCfg.getMaxWalArchiveSize() == Long.MAX_VALUE) - return -1; - - FileDescriptor[] archivedFiles = walArchiveFiles(); - - Long totalArchiveSize = Stream.of(archivedFiles) - .map(desc -> desc.file().length()) - .reduce(0L, Long::sum); - - if (archivedFiles.length == 0 || totalArchiveSize < allowedThresholdWalArchiveSize) - return -1; - - long sizeOfOldestArchivedFiles = 0; - - for (FileDescriptor desc : archivedFiles) { - sizeOfOldestArchivedFiles += desc.file().length(); - - if (totalArchiveSize - sizeOfOldestArchivedFiles < allowedThresholdWalArchiveSize) - return desc.getIdx(); - } - - return archivedFiles[archivedFiles.length - 1].getIdx(); - } - - /** {@inheritDoc} */ - @Override public long lastArchivedSegment() { - return archiver != null ? archiver.lastArchivedAbsoluteIndex() : -1L; - } - - /** {@inheritDoc} */ - @Override public long lastCompactedSegment() { - return compressor != null ? compressor.lastCompressedIdx : -1L; - } - - /** {@inheritDoc} */ - @Override public boolean reserved(WALPointer ptr) { - FileWALPointer fPtr = (FileWALPointer)ptr; - - FileArchiver archiver0 = archiver; - - return archiver0 != null && archiver0.reserved(fPtr.index()); - } - - /** {@inheritDoc} */ - @Override public int reserved(WALPointer low, WALPointer high) { - // It is not clear now how to get the highest WAL pointer. So when high is null method returns 0. - if (high == null) - return 0; - - assert high instanceof FileWALPointer : high; - - assert low == null || low instanceof FileWALPointer : low; - - FileWALPointer lowPtr = (FileWALPointer)low; - - FileWALPointer highPtr = (FileWALPointer)high; - - FileArchiver archiver0 = archiver; - - long lowIdx = lowPtr != null ? lowPtr.index() : 0; - - long highIdx = highPtr.index(); - - while (lowIdx < highIdx) { - if(archiver0 != null && archiver0.reserved(lowIdx)) - break; - - lowIdx++; - } - - return (int)(highIdx - lowIdx + 1); - } - - /** {@inheritDoc} */ - @Override public boolean disabled(int grpId) { - return cctx.walState().isDisabled(grpId); - } - - /** {@inheritDoc} */ - @Override public void cleanupWalDirectories() throws IgniteCheckedException { - try { - try (DirectoryStream files = Files.newDirectoryStream(walWorkDir.toPath())) { - for (Path path : files) - Files.delete(path); - } - } - catch (IOException e) { - throw new IgniteCheckedException("Failed to cleanup wal work directory: " + walWorkDir, e); - } - - try { - try (DirectoryStream files = Files.newDirectoryStream(walArchiveDir.toPath())) { - for (Path path : files) - Files.delete(path); - } - } - catch (IOException e) { - throw new IgniteCheckedException("Failed to cleanup wal archive directory: " + walArchiveDir, e); - } - } - - /** - * Lists files in archive directory and returns the index of last archived file. - * - * @return The absolute index of last archived file. - */ - private long lastArchivedIndex() { - long lastIdx = -1; - - for (File file : walArchiveDir.listFiles(WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER)) { - try { - long idx = Long.parseLong(file.getName().substring(0, 16)); - - lastIdx = Math.max(lastIdx, idx); - } - catch (NumberFormatException | IndexOutOfBoundsException ignore) { - - } - } - - return lastIdx; - } - - /** - * Lists files in archive directory and returns the indices of least and last archived files. - * In case of holes, first segment after last "hole" is considered as minimum. - * Example: minimum(0, 1, 10, 11, 20, 21, 22) should be 20 - * - * @return The absolute indices of min and max archived files. - */ - private IgniteBiTuple scanMinMaxArchiveIndices() { - TreeSet archiveIndices = new TreeSet<>(); - - for (File file : walArchiveDir.listFiles(WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER)) { - try { - long idx = Long.parseLong(file.getName().substring(0, 16)); - - archiveIndices.add(idx); - } - catch (NumberFormatException | IndexOutOfBoundsException ignore) { - // No-op. - } - } - - if (archiveIndices.isEmpty()) - return null; - else { - Long min = archiveIndices.first(); - Long max = archiveIndices.last(); - - if (max - min == archiveIndices.size() - 1) - return F.t(min, max); // Short path. - - for (Long idx : archiveIndices.descendingSet()) { - if (!archiveIndices.contains(idx - 1)) - return F.t(idx, max); - } - - throw new IllegalStateException("Should never happen if TreeSet is valid."); - } - } - - /** - * Creates a directory specified by the given arguments. - * - * @param cfg Configured directory path, may be {@code null}. - * @param defDir Default directory path, will be used if cfg is {@code null}. - * @param consId Local node consistent ID. - * @param msg File description to print out on successful initialization. - * @return Initialized directory. - * @throws IgniteCheckedException If failed to initialize directory. - */ - private File initDirectory(String cfg, String defDir, String consId, String msg) throws IgniteCheckedException { - File dir; - - if (cfg != null) { - File workDir0 = new File(cfg); - - dir = workDir0.isAbsolute() ? - new File(workDir0, consId) : - new File(U.resolveWorkDirectory(igCfg.getWorkDirectory(), cfg, false), consId); - } - else - dir = new File(U.resolveWorkDirectory(igCfg.getWorkDirectory(), defDir, false), consId); - - U.ensureDirectory(dir, msg, log); - - return dir; - } - - /** - * @return Current log segment handle. - */ - private FileWriteHandle currentHandle() { - return currentHnd; - } - - /** - * @param cur Handle that failed to fit the given entry. - * @return Handle that will fit the entry. - */ - private FileWriteHandle rollOver(FileWriteHandle cur) throws IgniteCheckedException { - FileWriteHandle hnd = currentHandle(); - - if (hnd != cur) - return hnd; - - if (hnd.close(true)) { - if (metrics.metricsEnabled()) - metrics.onWallRollOver(); - - FileWriteHandle next = initNextWriteHandle(cur.getSegmentId()); - - if (next.getSegmentId() - lashCheckpointFileIdx() >= maxSegCountWithoutCheckpoint) - cctx.database().forceCheckpoint("too big size of WAL without checkpoint"); - - boolean swapped = currentHndUpd.compareAndSet(this, hnd, next); - - assert swapped : "Concurrent updates on rollover are not allowed"; - - if (walAutoArchiveAfterInactivity > 0) - lastRecordLoggedMs.set(0); - - // Let other threads to proceed with new segment. - hnd.signalNextAvailable(); - } - else - hnd.awaitNext(); - - return currentHandle(); - } - - /** - * Give last checkpoint file idx - */ - private long lashCheckpointFileIdx() { - WALPointer lastCheckpointMark = cctx.database().lastCheckpointMarkWalPointer(); - - return lastCheckpointMark == null ? 0 : ((FileWALPointer)lastCheckpointMark).index(); - } - - /** - * @param lastReadPtr Last read WAL file pointer. - * @return Initialized file write handle. - * @throws StorageException If failed to initialize WAL write handle. - */ - private FileWriteHandle restoreWriteHandle(FileWALPointer lastReadPtr) throws StorageException { - long absIdx = lastReadPtr == null ? 0 : lastReadPtr.index(); - - long segNo = absIdx % dsCfg.getWalSegments(); - - File curFile = new File(walWorkDir, FileDescriptor.fileName(segNo)); - - int offset = lastReadPtr == null ? 0 : lastReadPtr.fileOffset(); - int len = lastReadPtr == null ? 0 : lastReadPtr.length(); - - try { - SegmentIO fileIO = new SegmentIO(absIdx, ioFactory.create(curFile)); - - try { - int serVer = serializerVersion; - - // If we have existing segment, try to read version from it. - if (lastReadPtr != null) { - try { - serVer = readSegmentHeader(fileIO, segmentFileInputFactory).getSerializerVersion(); - } - catch (SegmentEofException | EOFException ignore) { - serVer = serializerVersion; - } - } - - RecordSerializer ser = new RecordSerializerFactoryImpl(cctx).createSerializer(serVer); - - if (log.isInfoEnabled()) - log.info("Resuming logging to WAL segment [file=" + curFile.getAbsolutePath() + - ", offset=" + offset + ", ver=" + serVer + ']'); - - FileWriteHandle hnd = new FileWriteHandle( - fileIO, - offset + len, - maxWalSegmentSize, - ser); - - // For new handle write serializer version to it. - if (lastReadPtr == null) - hnd.writeSerializerVersion(); - - if (archiver != null) - archiver.currentWalIndex(absIdx); - - return hnd; - } - catch (IgniteCheckedException | IOException e) { - try { - fileIO.close(); - } - catch (IOException suppressed) { - e.addSuppressed(suppressed); - } - - if (e instanceof StorageException) - throw (StorageException) e; - - throw e instanceof IOException ? (IOException) e : new IOException(e); - } - } - catch (IOException e) { - throw new StorageException("Failed to restore WAL write handle: " + curFile.getAbsolutePath(), e); - } - } - - /** - * Fills the file header for a new segment. - * Calling this method signals we are done with the segment and it can be archived. - * If we don't have prepared file yet and achiever is busy this method blocks - * - * @param curIdx current absolute segment released by WAL writer - * @return Initialized file handle. - * @throws IgniteCheckedException If exception occurred. - */ - private FileWriteHandle initNextWriteHandle(long curIdx) throws IgniteCheckedException { - IgniteCheckedException error = null; - - try { - File nextFile = pollNextFile(curIdx); - - if (log.isDebugEnabled()) - log.debug("Switching to a new WAL segment: " + nextFile.getAbsolutePath()); - - SegmentIO fileIO = new SegmentIO(curIdx + 1, ioFactory.create(nextFile)); - - FileWriteHandle hnd = new FileWriteHandle( - fileIO, - 0, - maxWalSegmentSize, - serializer); - - hnd.writeSerializerVersion(); - - return hnd; - } - catch (IgniteCheckedException e) { - throw error = e; - } - catch (IOException e) { - throw error = new StorageException("Unable to initialize WAL segment", e); - } - finally { - if (error != null) - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, error)); - } - } - - /** - * Deletes temp files, creates and prepares new; Creates first segment if necessary. - * - * @throws StorageException If failed. - */ - private void checkOrPrepareFiles() throws StorageException { - // Clean temp files. - { - File[] tmpFiles = walWorkDir.listFiles(WAL_SEGMENT_TEMP_FILE_FILTER); - - if (!F.isEmpty(tmpFiles)) { - for (File tmp : tmpFiles) { - boolean deleted = tmp.delete(); - - if (!deleted) - throw new StorageException("Failed to delete previously created temp file " + - "(make sure Ignite process has enough rights): " + tmp.getAbsolutePath()); - } - } - } - - File[] allFiles = walWorkDir.listFiles(WAL_SEGMENT_FILE_FILTER); - - if (allFiles.length != 0 && allFiles.length > dsCfg.getWalSegments()) - throw new StorageException("Failed to initialize wal (work directory contains " + - "incorrect number of segments) [cur=" + allFiles.length + ", expected=" + dsCfg.getWalSegments() + ']'); - - // Allocate the first segment synchronously. All other segments will be allocated by archiver in background. - if (allFiles.length == 0) { - File first = new File(walWorkDir, FileDescriptor.fileName(0)); - - createFile(first); - } - else - checkFiles(0, false, null, null); - } - - /** - * Clears whole the file, fills with zeros for Default mode. - * - * @param file File to format. - * @throws StorageException if formatting failed. - */ - private void formatFile(File file) throws StorageException { - formatFile(file, dsCfg.getWalSegmentSize()); - } - - /** - * Clears the file, fills with zeros for Default mode. - * - * @param file File to format. - * @param bytesCntToFormat Count of first bytes to format. - * @throws StorageException If formatting failed. - */ - private void formatFile(File file, int bytesCntToFormat) throws StorageException { - if (log.isDebugEnabled()) - log.debug("Formatting file [exists=" + file.exists() + ", file=" + file.getAbsolutePath() + ']'); - - try (FileIO fileIO = ioFactory.create(file, CREATE, READ, WRITE)) { - int left = bytesCntToFormat; - - if (mode == WALMode.FSYNC) { - while ((left -= fileIO.writeFully(FILL_BUF, 0, Math.min(FILL_BUF.length, left))) > 0) - ; - - fileIO.force(); - } - else - fileIO.clear(); - } - catch (IOException e) { - throw new StorageException("Failed to format WAL segment file: " + file.getAbsolutePath(), e); - } - } - - /** - * Creates a file atomically with temp file. - * - * @param file File to create. - * @throws StorageException If failed. - */ - private void createFile(File file) throws StorageException { - if (log.isDebugEnabled()) - log.debug("Creating new file [exists=" + file.exists() + ", file=" + file.getAbsolutePath() + ']'); - - File tmp = new File(file.getParent(), file.getName() + FilePageStoreManager.TMP_SUFFIX); - - formatFile(tmp); - - try { - Files.move(tmp.toPath(), file.toPath()); - } - catch (IOException e) { - throw new StorageException("Failed to move temp file to a regular WAL segment file: " + - file.getAbsolutePath(), e); - } - - if (log.isDebugEnabled()) - log.debug("Created WAL segment [file=" + file.getAbsolutePath() + ", size=" + file.length() + ']'); - } - - /** - * Retrieves next available file to write WAL data, waiting - * if necessary for a segment to become available. - * - * @param curIdx Current absolute WAL segment index. - * @return File ready for use as new WAL segment. - * @throws StorageException If exception occurred in the archiver thread. - * @throws IgniteInterruptedCheckedException If interrupted. - */ - private File pollNextFile(long curIdx) throws StorageException, IgniteInterruptedCheckedException { - FileArchiver archiver0 = archiver; - - if (archiver0 == null) - return new File(walWorkDir, FileDescriptor.fileName(curIdx + 1)); - - // Signal to archiver that we are done with the segment and it can be archived. - long absNextIdx = archiver0.nextAbsoluteSegmentIndex(curIdx); - - long segmentIdx = absNextIdx % dsCfg.getWalSegments(); - - return new File(walWorkDir, FileDescriptor.fileName(segmentIdx)); - } - - - /** - * @return Sorted WAL files descriptors. - */ - public static FileDescriptor[] scan(File[] allFiles) { - if (allFiles == null) - return EMPTY_DESCRIPTORS; - - FileDescriptor[] descs = new FileDescriptor[allFiles.length]; - - for (int i = 0; i < allFiles.length; i++) { - File f = allFiles[i]; - - descs[i] = new FileDescriptor(f); - } - - Arrays.sort(descs); - - return descs; - } - - /** - * @throws StorageException If node is no longer valid and we missed a WAL operation. - */ - private void checkNode() throws StorageException { - if (cctx.kernalContext().invalid()) - throw new StorageException("Failed to perform WAL operation (environment was invalidated by a " + - "previous error)"); - } - - /** - * File archiver operates on absolute segment indexes. For any given absolute segment index N we can calculate - * the work WAL segment: S(N) = N % dsCfg.walSegments. - * When a work segment is finished, it is given to the archiver. If the absolute index of last archived segment - * is denoted by A and the absolute index of next segment we want to write is denoted by W, then we can allow - * write to S(W) if W - A <= walSegments.
- * - * Monitor of current object is used for notify on: - *
    - *
  • exception occurred ({@link FileArchiver#cleanException}!=null)
  • - *
  • stopping thread ({@link FileArchiver#isCancelled}==true)
  • - *
  • current file index changed ({@link FileArchiver#curAbsWalIdx})
  • - *
  • last archived file index was changed ({@link FileArchiver#lastAbsArchivedIdx})
  • - *
  • some WAL index was removed from {@link FileArchiver#locked} map
  • - *
- */ - private class FileArchiver extends GridWorker { - /** Exception which occurred during initial creation of files or during archiving WAL segment */ - private StorageException cleanException; - - /** - * Absolute current segment index WAL Manager writes to. Guarded by this. - * Incremented during rollover. Also may be directly set if WAL is resuming logging after start. - */ - private long curAbsWalIdx = -1; - - /** Last archived file index (absolute, 0-based). Guarded by this. */ - private volatile long lastAbsArchivedIdx = -1; - - /** */ - private NavigableMap reserved = new TreeMap<>(); - - /** - * Maps absolute segment index to locks counter. Lock on segment protects from archiving segment and may - * come from {@link RecordsIterator} during WAL replay. Map itself is guarded by this. - */ - private Map locked = new HashMap<>(); - - /** Formatted index. */ - private int formatted; - - /** - * - */ - private FileArchiver(long lastAbsArchivedIdx, IgniteLogger log) { - super(cctx.igniteInstanceName(), "wal-file-archiver%" + cctx.igniteInstanceName(), log, - cctx.kernalContext().workersRegistry()); - - this.lastAbsArchivedIdx = lastAbsArchivedIdx; - } - - /** - * @return Last archived segment absolute index. - */ - private long lastArchivedAbsoluteIndex() { - return lastAbsArchivedIdx; - } - - /** - * @throws IgniteInterruptedCheckedException If failed to wait for thread shutdown. - */ - private void shutdown() throws IgniteInterruptedCheckedException { - synchronized (this) { - isCancelled = true; - - notifyAll(); - } - - U.join(runner()); - } - - /** - * @param curAbsWalIdx Current absolute WAL segment index. - */ - private void currentWalIndex(long curAbsWalIdx) { - synchronized (this) { - this.curAbsWalIdx = curAbsWalIdx; - - notifyAll(); - } - } - - /** - * @param absIdx Index for reservation. - */ - private synchronized void reserve(long absIdx) { - Integer cur = reserved.get(absIdx); - - if (cur == null) - reserved.put(absIdx, 1); - else - reserved.put(absIdx, cur + 1); - } - - /** - * Check if WAL segment locked or reserved - * - * @param absIdx Index for check reservation. - * @return {@code True} if index is reserved. - */ - private synchronized boolean reserved(long absIdx) { - return locked.containsKey(absIdx) || reserved.floorKey(absIdx) != null; - } - - /** - * @param absIdx Reserved index. - */ - private synchronized void release(long absIdx) { - Integer cur = reserved.get(absIdx); - - assert cur != null && cur >= 1 : cur; - - if (cur == 1) - reserved.remove(absIdx); - else - reserved.put(absIdx, cur - 1); - } - - /** {@inheritDoc} */ - @Override protected void body() { - blockingSectionBegin(); - - try { - allocateRemainingFiles(); - } - catch (StorageException e) { - synchronized (this) { - // Stop the thread and report to starter. - cleanException = e; - - notifyAll(); - } - - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, e)); - - return; - } - finally { - blockingSectionEnd(); - } - - Throwable err = null; - - try { - synchronized (this) { - while (curAbsWalIdx == -1 && !isCancelled()) { - blockingSectionBegin(); - - try { - wait(); - } - finally { - blockingSectionEnd(); - } - } - - // If the archive directory is empty, we can be sure that there were no WAL segments archived. - // This is ensured by the check in truncate() which will leave at least one file there - // once it was archived. - } - - while (!Thread.currentThread().isInterrupted() && !isCancelled()) { - long toArchive; - - synchronized (this) { - assert lastAbsArchivedIdx <= curAbsWalIdx : "lastArchived=" + lastAbsArchivedIdx + - ", current=" + curAbsWalIdx; - - while (lastAbsArchivedIdx >= curAbsWalIdx - 1 && !isCancelled()) { - blockingSectionBegin(); - - try { - wait(); - } - finally { - blockingSectionEnd(); - } - } - - toArchive = lastAbsArchivedIdx + 1; - } - - if (isCancelled()) - break; - - SegmentArchiveResult res; - - blockingSectionBegin(); - - try { - res = archiveSegment(toArchive); - } - finally { - blockingSectionEnd(); - } - - synchronized (this) { - while (locked.containsKey(toArchive) && !isCancelled()) { - blockingSectionBegin(); - - try { - wait(); - } - finally { - blockingSectionEnd(); - } - } - - changeLastArchivedIndexAndWakeupCompressor(toArchive); - - notifyAll(); - } - - if (evt.isRecordable(EventType.EVT_WAL_SEGMENT_ARCHIVED)) { - evt.record(new WalSegmentArchivedEvent(cctx.discovery().localNode(), - res.getAbsIdx(), res.getDstArchiveFile())); - } - - onIdle(); - } - } - catch (InterruptedException t) { - Thread.currentThread().interrupt(); - - if (!isCancelled()) - err = t; - } - catch (Throwable t) { - err = t; - } - finally { - if (err == null && !isCancelled()) - err = new IllegalStateException("Worker " + name() + " is terminated unexpectedly"); - - if (err instanceof OutOfMemoryError) - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, err)); - else if (err != null) - cctx.kernalContext().failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, err)); - } - } - - /** - * @param idx Index. - */ - private void changeLastArchivedIndexAndWakeupCompressor(long idx) { - lastAbsArchivedIdx = idx; - - if (compressor != null) - compressor.onNextSegmentArchived(); - } - - /** - * Gets the absolute index of the next WAL segment available to write. - * Blocks till there are available file to write - * - * @param curIdx Current absolute index that we want to increment. - * @return Next index (curWalSegmIdx+1) when it is ready to be written. - * @throws StorageException If exception occurred in the archiver thread. - * @throws IgniteInterruptedCheckedException If interrupted. - */ - private long nextAbsoluteSegmentIndex(long curIdx) throws StorageException, IgniteInterruptedCheckedException { - try { - synchronized (this) { - if (cleanException != null) - throw cleanException; - - assert curIdx == curAbsWalIdx; - - curAbsWalIdx++; - - // Notify archiver thread. - notifyAll(); - - int segments = dsCfg.getWalSegments(); - - if (isArchiverEnabled()) { - while ((curAbsWalIdx - lastAbsArchivedIdx > segments && cleanException == null)) - wait(); - } - - if (cleanException != null) - throw cleanException; - - // Wait for formatter so that we do not open an empty file in DEFAULT mode. - while (curAbsWalIdx % dsCfg.getWalSegments() > formatted && cleanException == null) - wait(); - - if (cleanException != null) - throw cleanException; - - return curAbsWalIdx; - } - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - - throw new IgniteInterruptedCheckedException(e); - } - } - - /** - * @param absIdx Segment absolute index. - * @return
  • {@code True} if can read, no lock is held,
  • {@code false} if work segment, need - * release segment later, use {@link #releaseWorkSegment} for unlock
- */ - @SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext") - private boolean checkCanReadArchiveOrReserveWorkSegment(long absIdx) { - synchronized (this) { - if (lastAbsArchivedIdx >= absIdx) { - if (log.isDebugEnabled()) - log.debug("Not needed to reserve WAL segment: absIdx=" + absIdx + ";" + - " lastAbsArchivedIdx=" + lastAbsArchivedIdx); - - return true; - } - - Integer cur = locked.get(absIdx); - - cur = cur == null ? 1 : cur + 1; - - locked.put(absIdx, cur); - - if (log.isDebugEnabled()) - log.debug("Reserved work segment [absIdx=" + absIdx + ", pins=" + cur + ']'); - - return false; - } - } - - /** - * @param absIdx Segment absolute index. - */ - @SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext") - private void releaseWorkSegment(long absIdx) { - synchronized (this) { - Integer cur = locked.get(absIdx); - - assert cur != null && cur > 0 : "WAL Segment with Index " + absIdx + " is not locked;" + - " lastAbsArchivedIdx = " + lastAbsArchivedIdx; - - if (cur == 1) { - locked.remove(absIdx); - - if (log.isDebugEnabled()) - log.debug("Fully released work segment (ready to archive) [absIdx=" + absIdx + ']'); - } - else { - locked.put(absIdx, cur - 1); - - if (log.isDebugEnabled()) - log.debug("Partially released work segment [absIdx=" + absIdx + ", pins=" + (cur - 1) + ']'); - } - - notifyAll(); - } - } - - /** - * Moves WAL segment from work folder to archive folder. - * Temp file is used to do movement - * - * @param absIdx Absolute index to archive. - */ - private SegmentArchiveResult archiveSegment(long absIdx) throws IgniteCheckedException { - long segIdx = absIdx % dsCfg.getWalSegments(); - - File origFile = new File(walWorkDir, FileDescriptor.fileName(segIdx)); - - String name = FileDescriptor.fileName(absIdx); - - File dstTmpFile = new File(walArchiveDir, name + FilePageStoreManager.TMP_SUFFIX); - - File dstFile = new File(walArchiveDir, name); - - if (log.isInfoEnabled()) - log.info("Starting to copy WAL segment [absIdx=" + absIdx + ", segIdx=" + segIdx + - ", origFile=" + origFile.getAbsolutePath() + ", dstFile=" + dstFile.getAbsolutePath() + ']'); - - try { - Files.deleteIfExists(dstTmpFile.toPath()); - - Files.copy(origFile.toPath(), dstTmpFile.toPath()); - - Files.move(dstTmpFile.toPath(), dstFile.toPath()); - - if (mode == WALMode.FSYNC) { - try (FileIO f0 = ioFactory.create(dstFile, CREATE, READ, WRITE)) { - f0.force(); - } - } - } - catch (IOException e) { - throw new IgniteCheckedException("Failed to archive WAL segment [" + - "srcFile=" + origFile.getAbsolutePath() + - ", dstFile=" + dstTmpFile.getAbsolutePath() + ']', e); - } - - if (log.isInfoEnabled()) - log.info("Copied file [src=" + origFile.getAbsolutePath() + - ", dst=" + dstFile.getAbsolutePath() + ']'); - - return new SegmentArchiveResult(absIdx, origFile, dstFile); - } - - /** - * - */ - private boolean checkStop() { - return isCancelled(); - } - - /** - * Background creation of all segments except first. First segment was created in main thread by - * {@link FsyncModeFileWriteAheadLogManager#checkOrPrepareFiles()} - */ - private void allocateRemainingFiles() throws StorageException { - final FileArchiver archiver = this; - - checkFiles(1, - true, - new IgnitePredicate() { - @Override public boolean apply(Integer integer) { - return !checkStop(); - } - }, new CI1() { - @Override public void apply(Integer idx) { - synchronized (archiver) { - formatted = idx; - - archiver.notifyAll(); - } - } - }); - } - } - - /** - * Responsible for compressing WAL archive segments. - * Also responsible for deleting raw copies of already compressed WAL archive segments if they are not reserved. - */ - private class FileCompressor extends Thread { - /** Current thread stopping advice. */ - private volatile boolean stopped; - - /** Last successfully compressed segment. */ - private volatile long lastCompressedIdx = -1L; - - /** All segments prior to this (inclusive) can be compressed. */ - private volatile long minUncompressedIdxToKeep = -1L; - - /** */ - FileCompressor() { - super("wal-file-compressor%" + cctx.igniteInstanceName()); - } - - /** */ - private void init() { - File[] toDel = walArchiveDir.listFiles(WAL_SEGMENT_TEMP_FILE_COMPACTED_FILTER); - - for (File f : toDel) { - if (stopped) - return; - - f.delete(); - } - - FileDescriptor[] alreadyCompressed = scan(walArchiveDir.listFiles(WAL_SEGMENT_FILE_COMPACTED_FILTER)); - - if (alreadyCompressed.length > 0) - lastCompressedIdx = alreadyCompressed[alreadyCompressed.length - 1].idx(); - } - - /** - * @param idx Minimum raw segment index that should be preserved from deletion. - */ - synchronized void keepUncompressedIdxFrom(long idx) { - minUncompressedIdxToKeep = idx; - - notify(); - } - - /** - * Callback for waking up compressor when new segment is archived. - */ - synchronized void onNextSegmentArchived() { - notify(); - } - - /** - * Pessimistically tries to reserve segment for compression in order to avoid concurrent truncation. - * Waits if there's no segment to archive right now. - */ - private long tryReserveNextSegmentOrWait() throws InterruptedException, IgniteCheckedException { - long segmentToCompress = lastCompressedIdx + 1; - - synchronized (this) { - if (stopped) - return -1; - - while (segmentToCompress > archiver.lastArchivedAbsoluteIndex()) { - wait(); - - if (stopped) - return -1; - } - } - - segmentToCompress = Math.max(segmentToCompress, lastTruncatedArchiveIdx + 1); - - boolean reserved = reserve(new FileWALPointer(segmentToCompress, 0, 0)); - - return reserved ? segmentToCompress : -1; - } - - /** - * Deletes raw WAL segments if they aren't locked and already have compressed copies of themselves. - */ - private void deleteObsoleteRawSegments() { - FileDescriptor[] descs = scan(walArchiveDir.listFiles(WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER)); - - Set indices = new HashSet<>(); - Set duplicateIndices = new HashSet<>(); - - for (FileDescriptor desc : descs) { - if (!indices.add(desc.idx)) - duplicateIndices.add(desc.idx); - } - - FileArchiver archiver0 = archiver; - - for (FileDescriptor desc : descs) { - if (desc.isCompressed()) - continue; - - // Do not delete reserved or locked segment and any segment after it. - if (archiver0 != null && archiver0.reserved(desc.idx)) - return; - - if (desc.idx < minUncompressedIdxToKeep && duplicateIndices.contains(desc.idx)) { - if (!desc.file.delete()) - U.warn(log, "Failed to remove obsolete WAL segment (make sure the process has enough rights): " + - desc.file.getAbsolutePath() + ", exists: " + desc.file.exists()); - } - } - } - - /** {@inheritDoc} */ - @Override public void run() { - init(); - - while (!Thread.currentThread().isInterrupted() && !stopped) { - long currReservedSegment = -1; - - try { - deleteObsoleteRawSegments(); - - currReservedSegment = tryReserveNextSegmentOrWait(); - if (currReservedSegment == -1) - continue; - - File tmpZip = new File(walArchiveDir, FileDescriptor.fileName(currReservedSegment) - + FilePageStoreManager.ZIP_SUFFIX + FilePageStoreManager.TMP_SUFFIX); - - File zip = new File(walArchiveDir, FileDescriptor.fileName(currReservedSegment) - + FilePageStoreManager.ZIP_SUFFIX); - - File raw = new File(walArchiveDir, FileDescriptor.fileName(currReservedSegment)); - if (!Files.exists(raw.toPath())) - throw new IgniteCheckedException("WAL archive segment is missing: " + raw); - - compressSegmentToFile(currReservedSegment, raw, tmpZip); - - Files.move(tmpZip.toPath(), zip.toPath()); - - if (mode != WALMode.NONE) { - try (FileIO f0 = ioFactory.create(zip, CREATE, READ, WRITE)) { - f0.force(); - } - - if (evt.isRecordable(EVT_WAL_SEGMENT_COMPACTED)) { - evt.record(new WalSegmentCompactedEvent( - cctx.discovery().localNode(), - currReservedSegment, - zip.getAbsoluteFile()) - ); - } - } - - lastCompressedIdx = currReservedSegment; - } - catch (IgniteCheckedException | IOException e) { - U.error(log, "Compression of WAL segment [idx=" + currReservedSegment + - "] was skipped due to unexpected error", e); - - lastCompressedIdx++; - } - catch (InterruptedException ignore) { - Thread.currentThread().interrupt(); - } - finally { - try { - if (currReservedSegment != -1) - release(new FileWALPointer(currReservedSegment, 0, 0)); - } - catch (IgniteCheckedException e) { - U.error(log, "Can't release raw WAL segment [idx=" + currReservedSegment + - "] after compression", e); - } - } - } - } - - /** - * @param nextSegment Next segment absolute idx. - * @param raw Raw file. - * @param zip Zip file. - */ - private void compressSegmentToFile(long nextSegment, File raw, File zip) - throws IOException, IgniteCheckedException { - int segmentSerializerVer; - - try (FileIO fileIO = ioFactory.create(raw)) { - segmentSerializerVer = readSegmentHeader(new SegmentIO(nextSegment, fileIO), segmentFileInputFactory).getSerializerVersion(); - } - - try (ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zip)))) { - zos.setLevel(dsCfg.getWalCompactionLevel()); - zos.putNextEntry(new ZipEntry("")); - - zos.write(prepareSerializerVersionBuffer(nextSegment, segmentSerializerVer, true).array()); - - final CIX1 appendToZipC = new CIX1() { - @Override public void applyx(WALRecord record) throws IgniteCheckedException { - final MarshalledRecord marshRec = (MarshalledRecord)record; - - try { - zos.write(marshRec.buffer().array(), 0, marshRec.buffer().remaining()); - } - catch (IOException e) { - throw new IgniteCheckedException(e); - } - } - }; - - try (SingleSegmentLogicalRecordsIterator iter = new SingleSegmentLogicalRecordsIterator( - log, cctx, ioFactory, tlbSize, nextSegment, walArchiveDir, appendToZipC)) { - - while (iter.hasNextX()) - iter.nextX(); - } - } - } - - /** - * @throws IgniteInterruptedCheckedException If failed to wait for thread shutdown. - */ - private void shutdown() throws IgniteInterruptedCheckedException { - synchronized (this) { - stopped = true; - - notifyAll(); - } - - U.join(this); - } - } - - /** - * Responsible for decompressing previously compressed segments of WAL archive if they are needed for replay. - */ - private class FileDecompressor extends GridWorker { - /** Decompression futures. */ - private Map> decompressionFutures = new HashMap<>(); - - /** Segments queue. */ - private PriorityBlockingQueue segmentsQueue = new PriorityBlockingQueue<>(); - - /** Byte array for draining data. */ - private byte[] arr = new byte[tlbSize]; - - /** - * @param log Logger. - */ - FileDecompressor(IgniteLogger log) { - super(cctx.igniteInstanceName(), "wal-file-decompressor%" + cctx.igniteInstanceName(), log, - cctx.kernalContext().workersRegistry()); - } - - /** {@inheritDoc} */ - @Override protected void body() { - Throwable err = null; - - try { - while (!isCancelled()) { - long segmentToDecompress = -1L; - - try { - blockingSectionBegin(); - - try { - segmentToDecompress = segmentsQueue.take(); - } - finally { - blockingSectionEnd(); - } - - if (isCancelled()) - break; - - File zip = new File(walArchiveDir, FileDescriptor.fileName(segmentToDecompress) - + FilePageStoreManager.ZIP_SUFFIX); - File unzipTmp = new File(walArchiveDir, FileDescriptor.fileName(segmentToDecompress) - + FilePageStoreManager.TMP_SUFFIX); - File unzip = new File(walArchiveDir, FileDescriptor.fileName(segmentToDecompress)); - - try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(zip))); - FileIO io = ioFactory.create(unzipTmp)) { - zis.getNextEntry(); - - while (io.writeFully(arr, 0, zis.read(arr)) > 0) - updateHeartbeat(); - } - - try { - Files.move(unzipTmp.toPath(), unzip.toPath()); - } - catch (FileAlreadyExistsException e) { - U.error(log, "Can't rename temporary unzipped segment: raw segment is already present " + - "[tmp=" + unzipTmp + ", raw=" + unzip + ']', e); - - if (!unzipTmp.delete()) - U.error(log, "Can't delete temporary unzipped segment [tmp=" + unzipTmp + ']'); - } - - updateHeartbeat(); - - synchronized (this) { - decompressionFutures.remove(segmentToDecompress).onDone(); - } - } - catch (IOException ex) { - if (!isCancelled && segmentToDecompress != -1L) { - IgniteCheckedException e = new IgniteCheckedException("Error during WAL segment " + - "decompression [segmentIdx=" + segmentToDecompress + ']', ex); - - synchronized (this) { - decompressionFutures.remove(segmentToDecompress).onDone(e); - } - } - } - } - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - - if (!isCancelled) - err = e; - } - catch (Throwable t) { - err = t; - } - finally { - if (err == null && !isCancelled) - err = new IllegalStateException("Worker " + name() + " is terminated unexpectedly"); - - if (err instanceof OutOfMemoryError) - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, err)); - else if (err != null) - cctx.kernalContext().failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, err)); - } - } - - /** - * Asynchronously decompresses WAL segment which is present only in .zip file. - * - * @return Future which is completed once file is decompressed. - */ - synchronized IgniteInternalFuture decompressFile(long idx) { - if (decompressionFutures.containsKey(idx)) - return decompressionFutures.get(idx); - - File f = new File(walArchiveDir, FileDescriptor.fileName(idx)); - - if (f.exists()) - return new GridFinishedFuture<>(); - - segmentsQueue.put(idx); - - GridFutureAdapter res = new GridFutureAdapter<>(); - - decompressionFutures.put(idx, res); - - return res; - } - - /** */ - private void shutdown() { - synchronized (this) { - U.cancel(this); - - // Put fake -1 to wake thread from queue.take() - segmentsQueue.put(-1L); - } - - U.join(this, log); - } - } - - /** - * Validate files depending on {@link DataStorageConfiguration#getWalSegments()} and create if need. - * Check end when exit condition return false or all files are passed. - * - * @param startWith Start with. - * @param create Flag create file. - * @param p Predicate Exit condition. - * @throws StorageException if validation or create file fail. - */ - private void checkFiles( - int startWith, - boolean create, - @Nullable IgnitePredicate p, - @Nullable IgniteInClosure completionCallback - ) throws StorageException { - for (int i = startWith; i < dsCfg.getWalSegments() && (p == null || (p != null && p.apply(i))); i++) { - File checkFile = new File(walWorkDir, FileDescriptor.fileName(i)); - - if (checkFile.exists()) { - if (checkFile.isDirectory()) - throw new StorageException("Failed to initialize WAL log segment (a directory with " + - "the same name already exists): " + checkFile.getAbsolutePath()); - else if (checkFile.length() != dsCfg.getWalSegmentSize() && mode == WALMode.FSYNC) - throw new StorageException("Failed to initialize WAL log segment " + - "(WAL segment size change is not supported):" + checkFile.getAbsolutePath()); - } - else if (create) - createFile(checkFile); - - if (completionCallback != null) - completionCallback.apply(i); - } - } - - /** - * Writes record serializer version to provided {@code io}. - * NOTE: Method mutates position of {@code io}. - * - * @param io I/O interface for file. - * @param idx Segment index. - * @param version Serializer version. - * @return I/O position after write version. - * @throws IOException If failed to write serializer version. - */ - public static long writeSerializerVersion(FileIO io, long idx, int version, WALMode mode) throws IOException { - ByteBuffer buffer = prepareSerializerVersionBuffer(idx, version, false); - - io.writeFully(buffer); - - // Flush - if (mode == WALMode.FSYNC) - io.force(); - - return io.position(); - } - - /** - * @param idx Index. - * @param ver Version. - * @param compacted Compacted flag. - */ - @NotNull private static ByteBuffer prepareSerializerVersionBuffer(long idx, int ver, boolean compacted) { - ByteBuffer buf = ByteBuffer.allocate(RecordV1Serializer.HEADER_RECORD_SIZE); - buf.order(ByteOrder.nativeOrder()); - - // Write record type. - buf.put((byte) (WALRecord.RecordType.HEADER_RECORD.ordinal() + 1)); - - // Write position. - RecordV1Serializer.putPosition(buf, new FileWALPointer(idx, 0, 0)); - - // Place magic number. - buf.putLong(compacted ? HeaderRecord.COMPACTED_MAGIC : HeaderRecord.REGULAR_MAGIC); - - // Place serializer version. - buf.putInt(ver); - - // Place CRC if needed. - if (!RecordV1Serializer.skipCrc) { - int curPos = buf.position(); - - buf.position(0); - - // This call will move buffer position to the end of the record again. - int crcVal = PureJavaCrc32.calcCrc32(buf, curPos); - - buf.putInt(crcVal); - } - else - buf.putInt(0); - - // Write header record through io. - buf.position(0); - - return buf; - } - - /** - * - */ - private abstract static class FileHandle { - /** I/O interface for read/write operations with file */ - protected SegmentIO fileIO; - /** Segment idx corresponded to fileIo*/ - final long segmentIdx; - - /** - * @param fileIO I/O interface for read/write operations of FileHandle. - */ - private FileHandle(@NotNull SegmentIO fileIO) { - this.fileIO = fileIO; - this.segmentIdx = fileIO.getSegmentId(); - } - - /** - * @return Current segment id. - */ - public long getSegmentId(){ - return segmentIdx; - } - } - - /** - * - */ - public static class ReadFileHandle extends FileHandle implements AbstractWalRecordsIterator.AbstractReadFileHandle { - /** Entry serializer. */ - RecordSerializer ser; - - /** */ - FileInput in; - - /** - * true if this file handle came from work directory. - * false if this file handle came from archive directory. - */ - private boolean workDir; - - /** - * @param fileIO I/O interface for read/write operations of FileHandle. - * @param ser Entry serializer. - * @param in File input. - */ - ReadFileHandle( - SegmentIO fileIO, - RecordSerializer ser, - FileInput in - ) { - super(fileIO); - - this.ser = ser; - this.in = in; - } - - /** - * @throws IgniteCheckedException If failed to close the WAL segment file. - */ - @Override public void close() throws IgniteCheckedException { - try { - fileIO.close(); - } - catch (IOException e) { - throw new IgniteCheckedException(e); - } - } - - /** {@inheritDoc} */ - @Override public long idx() { - return getSegmentId(); - } - - /** {@inheritDoc} */ - @Override public FileInput in() { - return in; - } - - /** {@inheritDoc} */ - @Override public RecordSerializer ser() { - return ser; - } - - /** {@inheritDoc} */ - @Override public boolean workDir() { - return workDir; - } - } - - /** - * File handle for one log segment. - */ - @SuppressWarnings("SignalWithoutCorrespondingAwait") - private class FileWriteHandle extends FileHandle { - /** */ - private final RecordSerializer serializer; - - /** See {@link FsyncModeFileWriteAheadLogManager#maxWalSegmentSize} */ - private final long maxSegmentSize; - - /** - * Accumulated WAL records chain. - * This reference points to latest WAL record. - * When writing records chain is iterated from latest to oldest (see {@link WALRecord#previous()}) - * Records from chain are saved into buffer in reverse order - */ - private final AtomicReference head = new AtomicReference<>(); - - /** - * Position in current file after the end of last written record (incremented after file channel write - * operation) - */ - private volatile long written; - - /** */ - private volatile long lastFsyncPos; - - /** Stop guard to provide warranty that only one thread will be successful in calling {@link #close(boolean)}*/ - private final AtomicBoolean stop = new AtomicBoolean(false); - - /** */ - private final Lock lock = new ReentrantLock(); - - /** Condition activated each time writeBuffer() completes. Used to wait previously flushed write to complete */ - private final Condition writeComplete = lock.newCondition(); - - /** Condition for timed wait of several threads, see {@link DataStorageConfiguration#getWalFsyncDelayNanos()} */ - private final Condition fsync = lock.newCondition(); - - /** - * Next segment available condition. - * Protection from "spurious wakeup" is provided by predicate {@link #fileIO}=null - */ - private final Condition nextSegment = lock.newCondition(); - - /** - * @param fileIO I/O file interface to use - * @param pos Position. - * @param maxSegmentSize Max segment size. - * @param serializer Serializer. - * @throws IOException If failed. - */ - private FileWriteHandle( - SegmentIO fileIO, - long pos, - long maxSegmentSize, - RecordSerializer serializer - ) throws IOException { - super(fileIO); - - assert serializer != null; - - fileIO.position(pos); - - this.maxSegmentSize = maxSegmentSize; - this.serializer = serializer; - - head.set(new FakeRecord(new FileWALPointer(fileIO.getSegmentId(), (int)pos, 0), false)); - written = pos; - lastFsyncPos = pos; - } - - /** - * Write serializer version to current handle. - * NOTE: Method mutates {@code fileIO} position, written and lastFsyncPos fields. - * - * @throws IOException If fail to write serializer version. - */ - private void writeSerializerVersion() throws IOException { - try { - assert fileIO.position() == 0 : "Serializer version can be written only at the begin of file " + - fileIO.position(); - - long updatedPosition = FsyncModeFileWriteAheadLogManager.writeSerializerVersion(fileIO, getSegmentId(), - serializer.version(), mode); - - written = updatedPosition; - lastFsyncPos = updatedPosition; - head.set(new FakeRecord(new FileWALPointer(getSegmentId(), (int)updatedPosition, 0), false)); - } - catch (IOException e) { - throw new IOException("Unable to write serializer version for segment " + getSegmentId(), e); - } - } - - /** - * Checks if current head is a close fake record and returns {@code true} if so. - * - * @return {@code true} if current head is close record. - */ - private boolean stopped() { - return stopped(head.get()); - } - - /** - * @param record Record to check. - * @return {@code true} if the record is fake close record. - */ - private boolean stopped(WALRecord record) { - return record instanceof FakeRecord && ((FakeRecord)record).stop; - } - - /** - * @param rec Record to be added to record chain as new {@link #head} - * @return Pointer or null if roll over to next segment is required or already started by other thread. - * @throws StorageException If failed. - */ - @Nullable private WALPointer addRecord(WALRecord rec) throws StorageException { - assert rec.size() > 0 || rec.getClass() == FakeRecord.class; - - boolean flushed = false; - - for (; ; ) { - WALRecord h = head.get(); - - long nextPos = nextPosition(h); - - if (nextPos + rec.size() >= maxSegmentSize || stopped(h)) { - // Can not write to this segment, need to switch to the next one. - return null; - } - - int newChainSize = h.chainSize() + rec.size(); - - if (newChainSize > tlbSize && !flushed) { - boolean res = h.previous() == null || flush(h, false); - - if (rec.size() > tlbSize) - flushed = res; - - continue; - } - - rec.chainSize(newChainSize); - rec.previous(h); - - FileWALPointer ptr = new FileWALPointer( - getSegmentId(), - (int)nextPos, - rec.size()); - - rec.position(ptr); - - if (head.compareAndSet(h, rec)) - return ptr; - } - } - - /** - * @param rec Record. - * @return Position for the next record. - */ - private long nextPosition(WALRecord rec) { - return recordOffset(rec) + rec.size(); - } - - /** - * Flush or wait for concurrent flush completion. - * - * @param ptr Pointer. - * @throws StorageException If failed. - */ - private void flushOrWait(FileWALPointer ptr, boolean stop) throws StorageException { - long expWritten; - - if (ptr != null) { - // If requested obsolete file index, it must be already flushed by close. - if (ptr.index() != getSegmentId()) - return; - - expWritten = ptr.fileOffset(); - } - else // We read head position before the flush because otherwise we can get wrong position. - expWritten = recordOffset(head.get()); - - if (flush(ptr, stop)) - return; - else if (stop) { - FakeRecord fr = (FakeRecord)head.get(); - - assert fr.stop : "Invalid fake record on top of the queue: " + fr; - - expWritten = recordOffset(fr); - } - - // Spin-wait for a while before acquiring the lock. - for (int i = 0; i < 64; i++) { - if (written >= expWritten) - return; - } - - // If we did not flush ourselves then await for concurrent flush to complete. - lock.lock(); - - try { - while (written < expWritten && !cctx.kernalContext().invalid()) - U.awaitQuiet(writeComplete); - } - finally { - lock.unlock(); - } - } - - /** - * @param ptr Pointer. - * @return {@code true} If the flush really happened. - * @throws StorageException If failed. - */ - private boolean flush(FileWALPointer ptr, boolean stop) throws StorageException { - if (ptr == null) { // Unconditional flush. - for (; ; ) { - WALRecord expHead = head.get(); - - if (expHead.previous() == null) { - FakeRecord frHead = (FakeRecord)expHead; - - if (frHead.stop == stop || frHead.stop || - head.compareAndSet(expHead, new FakeRecord(frHead.position(), stop))) - return false; - } - - if (flush(expHead, stop)) - return true; - } - } - - assert ptr.index() == getSegmentId(); - - for (; ; ) { - WALRecord h = head.get(); - - // If current chain begin position is greater than requested, then someone else flushed our changes. - if (chainBeginPosition(h) > ptr.fileOffset()) - return false; - - if (flush(h, stop)) - return true; // We are lucky. - } - } - - /** - * @param h Head of the chain. - * @return Chain begin position. - */ - private long chainBeginPosition(WALRecord h) { - return recordOffset(h) + h.size() - h.chainSize(); - } - - /** - * @param expHead Expected head of chain. If head was changed, flush is not performed in this thread - * @throws StorageException If failed. - */ - private boolean flush(WALRecord expHead, boolean stop) throws StorageException { - if (expHead.previous() == null) { - FakeRecord frHead = (FakeRecord)expHead; - - if (!stop || frHead.stop) // Protects from CASing terminal FakeRecord(true) to FakeRecord(false) - return false; - } - - // Fail-fast before CAS. - checkNode(); - - if (!head.compareAndSet(expHead, new FakeRecord(new FileWALPointer(getSegmentId(), (int)nextPosition(expHead), 0), stop))) - return false; - - if (expHead.chainSize() == 0) - return false; - - // At this point we grabbed the piece of WAL chain. - // Any failure in this code must invalidate the environment. - try { - // We can safely allow other threads to start building next chains while we are doing flush here. - ByteBuffer buf; - - boolean tmpBuf = false; - - if (expHead.chainSize() > tlbSize) { - buf = GridUnsafe.allocateBuffer(expHead.chainSize()); - - tmpBuf = true; // We need to manually release this temporary direct buffer. - } - else - buf = tlb.get(); - - try { - long pos = fillBuffer(buf, expHead); - - writeBuffer(pos, buf); - } - finally { - if (tmpBuf) - GridUnsafe.freeBuffer(buf); - } - - return true; - } - catch (Throwable e) { - StorageException se = e instanceof StorageException ? (StorageException) e : - new StorageException("Unable to write", new IOException(e)); - - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, se)); - - // All workers waiting for a next segment must be woken up and stopped - signalNextAvailable(); - - throw se; - } - } - - /** - * Serializes WAL records chain to provided byte buffer - * - * @param buf Buffer, will be filled with records chain from end to beginning - * @param head Head of the chain to write to the buffer. - * @return Position in file for this buffer. - * @throws IgniteCheckedException If failed. - */ - private long fillBuffer(ByteBuffer buf, WALRecord head) throws IgniteCheckedException { - final int limit = head.chainSize(); - - assert limit <= buf.capacity(); - - buf.rewind(); - buf.limit(limit); - - do { - buf.position(head.chainSize() - head.size()); - buf.limit(head.chainSize()); // Just to make sure that serializer works in bounds. - - try { - serializer.writeRecord(head, buf); - } - catch (RuntimeException e) { - throw new IllegalStateException("Failed to write record: " + head, e); - } - - assert !buf.hasRemaining() : "Reported record size is greater than actual: " + head; - - head = head.previous(); - } - while (head.previous() != null); - - assert head instanceof FakeRecord : head.getClass(); - - buf.rewind(); - buf.limit(limit); - - return recordOffset(head); - } - - /** - * Non-blocking check if this pointer needs to be sync'ed. - * - * @param ptr WAL pointer to check. - * @return {@code False} if this pointer has been already sync'ed. - */ - private boolean needFsync(FileWALPointer ptr) { - // If index has changed, it means that the log was rolled over and already sync'ed. - // If requested position is smaller than last sync'ed, it also means all is good. - // If position is equal, then our record is the last not synced. - return getSegmentId() == ptr.index() && lastFsyncPos <= ptr.fileOffset(); - } - - /** - * @return Pointer to the end of the last written record (probably not fsync-ed). - */ - private FileWALPointer position() { - lock.lock(); - - try { - return new FileWALPointer(getSegmentId(), (int)written, 0); - } - finally { - lock.unlock(); - } - } - - /** - * @param ptr Pointer to sync. - * @throws StorageException If failed. - * @throws IgniteInterruptedCheckedException If interrupted. - */ - private void fsync(FileWALPointer ptr, boolean stop) throws StorageException, IgniteInterruptedCheckedException { - lock.lock(); - - try { - if (ptr != null) { - if (!needFsync(ptr)) - return; - - if (fsyncDelay > 0 && !stopped()) { - // Delay fsync to collect as many updates as possible: trade latency for throughput. - U.await(fsync, fsyncDelay, TimeUnit.NANOSECONDS); - - if (!needFsync(ptr)) - return; - } - } - - flushOrWait(ptr, stop); - - if (stopped()) - return; - - if (lastFsyncPos != written) { - assert lastFsyncPos < written; // Fsync position must be behind. - - boolean metricsEnabled = metrics.metricsEnabled(); - - long start = metricsEnabled ? System.nanoTime() : 0; - - try { - fileIO.force(); - } - catch (IOException e) { - throw new StorageException(e); - } - - lastFsyncPos = written; - - if (fsyncDelay > 0) - fsync.signalAll(); - - long end = metricsEnabled ? System.nanoTime() : 0; - - if (metricsEnabled) - metrics.onFsync(end - start); - } - } - finally { - lock.unlock(); - } - } - - /** - * @return {@code true} If this thread actually closed the segment. - * @throws StorageException If failed. - */ - private boolean close(boolean rollOver) throws StorageException { - if (stop.compareAndSet(false, true)) { - lock.lock(); - - try { - flushOrWait(null, true); - - assert stopped() : "Segment is not closed after close flush: " + head.get(); - - try { - try { - RecordSerializer backwardSerializer = new RecordSerializerFactoryImpl(cctx) - .createSerializer(serializerVersion); - - SwitchSegmentRecord segmentRecord = new SwitchSegmentRecord(); - - int switchSegmentRecSize = backwardSerializer.size(segmentRecord); - - if (rollOver && written < (maxSegmentSize - switchSegmentRecSize)) { - final ByteBuffer buf = ByteBuffer.allocate(switchSegmentRecSize); - - segmentRecord.position(new FileWALPointer(getSegmentId(), (int)written, switchSegmentRecSize)); - backwardSerializer.writeRecord(segmentRecord, buf); - - buf.rewind(); - - written += fileIO.writeFully(buf, written); - } - } - catch (IgniteCheckedException e) { - throw new IOException(e); - } - finally { - assert mode == WALMode.FSYNC; - - // Do the final fsync. - fileIO.force(); - - lastFsyncPos = written; - - fileIO.close(); - } - } - catch (IOException e) { - throw new StorageException("Failed to close WAL write handle [idx=" + getSegmentId() + "]", e); - } - - if (log.isDebugEnabled()) - log.debug("Closed WAL write handle [idx=" + getSegmentId() + "]"); - - return true; - } - finally { - lock.unlock(); - } - } - else - return false; - } - - /** - * Signals next segment available to wake up other worker threads waiting for WAL to write - */ - private void signalNextAvailable() { - lock.lock(); - - try { - WALRecord rec = head.get(); - - if (!cctx.kernalContext().invalid()) { - assert rec instanceof FakeRecord : "Expected head FakeRecord, actual head " - + (rec != null ? rec.getClass().getSimpleName() : "null"); - - assert written == lastFsyncPos || mode != WALMode.FSYNC : - "fsync [written=" + written + ", lastFsync=" + lastFsyncPos + ']'; - - fileIO = null; - } - else { - try { - fileIO.close(); - } - catch (IOException e) { - U.error(log, "Failed to close WAL file [idx=" + getSegmentId() + ", fileIO=" + fileIO + "]", e); - } - } - - nextSegment.signalAll(); - } - finally { - lock.unlock(); - } - } - - /** - * - */ - private void awaitNext() { - lock.lock(); - - try { - while (fileIO != null && !cctx.kernalContext().invalid()) - U.awaitQuiet(nextSegment); - } - finally { - lock.unlock(); - } - } - - /** - * @param pos Position in file to start write from. May be checked against actual position to wait previous - * writes to complete - * @param buf Buffer to write to file - * @throws StorageException If failed. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("TooBroadScope") - private void writeBuffer(long pos, ByteBuffer buf) throws StorageException { - boolean interrupted = false; - - lock.lock(); - - try { - assert fileIO != null : "Writing to a closed segment."; - - checkNode(); - - long lastLogged = U.currentTimeMillis(); - - long logBackoff = 2_000; - - // If we were too fast, need to wait previous writes to complete. - while (written != pos) { - assert written < pos : "written = " + written + ", pos = " + pos; // No one can write further than we are now. - - // Permutation occurred between blocks write operations. - // Order of acquiring lock is not the same as order of write. - long now = U.currentTimeMillis(); - - if (now - lastLogged >= logBackoff) { - if (logBackoff < 60 * 60_000) - logBackoff *= 2; - - U.warn(log, "Still waiting for a concurrent write to complete [written=" + written + - ", pos=" + pos + ", lastFsyncPos=" + lastFsyncPos + ", stop=" + stop.get() + - ", actualPos=" + safePosition() + ']'); - - lastLogged = now; - } - - try { - writeComplete.await(2, TimeUnit.SECONDS); - } - catch (InterruptedException ignore) { - interrupted = true; - } - - checkNode(); - } - - // Do the write. - int size = buf.remaining(); - - assert size > 0 : size; - - try { - assert written == fileIO.position(); - - fileIO.writeFully(buf); - - written += size; - - metrics.onWalBytesWritten(size); - - assert written == fileIO.position(); - } - catch (IOException e) { - StorageException se = new StorageException("Unable to write", e); - - cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, se)); - - throw se; - } - } - finally { - writeComplete.signalAll(); - - lock.unlock(); - - if (interrupted) - Thread.currentThread().interrupt(); - } - } - - /** - * @return Safely reads current position of the file channel as String. Will return "null" if channel is null. - */ - private String safePosition() { - FileIO io = this.fileIO; - - if (io == null) - return "null"; - - try { - return String.valueOf(io.position()); - } - catch (IOException e) { - return "{Failed to read channel position: " + e.getMessage() + "}"; - } - } - } - - /** - * Gets WAL record offset relative to the WAL segment file beginning. - * - * @param rec WAL record. - * @return File offset. - */ - private static int recordOffset(WALRecord rec) { - FileWALPointer ptr = (FileWALPointer)rec.position(); - - assert ptr != null; - - return ptr.fileOffset(); - } - - /** - * Fake record is zero-sized record, which is not stored into file. - * Fake record is used for storing position in file {@link WALRecord#position()}. - * Fake record is allowed to have no previous record. - */ - private static final class FakeRecord extends WALRecord { - /** */ - private final boolean stop; - - /** - * @param pos Position. - */ - FakeRecord(FileWALPointer pos, boolean stop) { - position(pos); - - this.stop = stop; - } - - /** {@inheritDoc} */ - @Override public RecordType type() { - return null; - } - - /** {@inheritDoc} */ - @Override public FileWALPointer position() { - return (FileWALPointer) super.position(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(FakeRecord.class, this, "super", super.toString()); - } - } - - /** - * Iterator over WAL-log. - */ - private class RecordsIterator extends AbstractWalRecordsIterator { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private final File walWorkDir; - - /** */ - private final File walArchiveDir; - - /** */ - private final FileArchiver archiver; - - /** */ - private final FileDecompressor decompressor; - - /** */ - private final DataStorageConfiguration psCfg; - - /** Optional start pointer. */ - @Nullable - private FileWALPointer start; - - /** Optional end pointer. */ - @Nullable - private FileWALPointer end; - - /** - * @param cctx Shared context. - * @param walWorkDir WAL work dir. - * @param walArchiveDir WAL archive dir. - * @param start Optional start pointer. - * @param end Optional end pointer. - * @param psCfg Database configuration. - * @param serializerFactory Serializer factory. - * @param archiver Archiver. - * @param decompressor Decompressor. - * @param log Logger @throws IgniteCheckedException If failed to initialize WAL segment. - * @param segmentFileInputFactory Segment file input factory. - */ - private RecordsIterator( - GridCacheSharedContext cctx, - File walWorkDir, - File walArchiveDir, - @Nullable FileWALPointer start, - @Nullable FileWALPointer end, - DataStorageConfiguration psCfg, - @NotNull RecordSerializerFactory serializerFactory, - FileIOFactory ioFactory, - FileArchiver archiver, - FileDecompressor decompressor, - IgniteLogger log, - SegmentFileInputFactory segmentFileInputFactory - ) throws IgniteCheckedException { - super( - log, - cctx, - serializerFactory, - ioFactory, - psCfg.getWalRecordIteratorBufferSize(), - segmentFileInputFactory - ); - this.walWorkDir = walWorkDir; - this.walArchiveDir = walArchiveDir; - this.psCfg = psCfg; - this.archiver = archiver; - this.start = start; - this.end = end; - this.decompressor = decompressor; - - init(); - - advance(); - } - - /** {@inheritDoc} */ - @Override protected ReadFileHandle initReadHandle( - @NotNull AbstractFileDescriptor desc, - @Nullable FileWALPointer start - ) throws IgniteCheckedException, FileNotFoundException { - AbstractFileDescriptor currDesc = desc; - - if (!desc.file().exists()) { - FileDescriptor zipFile = new FileDescriptor( - new File(walArchiveDir, FileDescriptor.fileName(desc.idx()) - + FilePageStoreManager.ZIP_SUFFIX)); - - if (!zipFile.file.exists()) { - throw new FileNotFoundException("Both compressed and raw segment files are missing in archive " + - "[segmentIdx=" + desc.idx() + "]"); - } - - if (decompressor != null) - decompressor.decompressFile(desc.idx()).get(); - else - currDesc = zipFile; - } - - return (ReadFileHandle) super.initReadHandle(currDesc, start); - } - - /** {@inheritDoc} */ - @Override protected void onClose() throws IgniteCheckedException { - super.onClose(); - - curRec = null; - - final AbstractReadFileHandle handle = closeCurrentWalSegment(); - - if (handle != null && handle.workDir()) - releaseWorkSegment(curWalSegmIdx); - - curWalSegmIdx = Integer.MAX_VALUE; - } - - /** - * @throws IgniteCheckedException If failed to initialize first file handle. - */ - private void init() throws IgniteCheckedException { - AbstractFileDescriptor[] descs = loadFileDescriptors(walArchiveDir); - - if (start != null) { - if (!F.isEmpty(descs)) { - if (descs[0].idx() > start.index()) - throw new IgniteCheckedException("WAL history is too short " + - "[descs=" + Arrays.asList(descs) + ", start=" + start + ']'); - - for (AbstractFileDescriptor desc : descs) { - if (desc.idx() == start.index()) { - curWalSegmIdx = start.index(); - - break; - } - } - - if (curWalSegmIdx == -1) { - long lastArchived = descs[descs.length - 1].idx(); - - if (lastArchived > start.index()) - throw new IgniteCheckedException("WAL history is corrupted (segment is missing): " + start); - - // This pointer may be in work files because archiver did not - // copy the file yet, check that it is not too far forward. - curWalSegmIdx = start.index(); - } - } - else { - // This means that whole checkpoint history fits in one segment in WAL work directory. - // Will start from this index right away. - curWalSegmIdx = start.index(); - } - } - else - curWalSegmIdx = !F.isEmpty(descs) ? descs[0].idx() : 0; - - curWalSegmIdx--; - - if (log.isDebugEnabled()) - log.debug("Initialized WAL cursor [start=" + start + ", end=" + end + ", curWalSegmIdx=" + curWalSegmIdx + ']'); - } - - /** {@inheritDoc} */ - @Override protected AbstractReadFileHandle advanceSegment( - @Nullable final AbstractReadFileHandle curWalSegment - ) throws IgniteCheckedException { - if (curWalSegment != null) { - curWalSegment.close(); - - if (curWalSegment.workDir()) - releaseWorkSegment(curWalSegment.idx()); - - } - - // We are past the end marker. - if (end != null && curWalSegmIdx + 1 > end.index()) - return null; //stop iteration - - curWalSegmIdx++; - - FileDescriptor fd; - - boolean readArchive = canReadArchiveOrReserveWork(curWalSegmIdx); - - if (readArchive) - fd = new FileDescriptor(new File(walArchiveDir, FileDescriptor.fileName(curWalSegmIdx))); - else { - long workIdx = curWalSegmIdx % psCfg.getWalSegments(); - - fd = new FileDescriptor( - new File(walWorkDir, FileDescriptor.fileName(workIdx)), - curWalSegmIdx); - } - - if (log.isDebugEnabled()) - log.debug("Reading next file [absIdx=" + curWalSegmIdx + ", file=" + fd.file().getAbsolutePath() + ']'); - - ReadFileHandle nextHandle; - - try { - nextHandle = initReadHandle(fd, start != null && curWalSegmIdx == start.index() ? start : null); - } - catch (FileNotFoundException e) { - if (readArchive) - throw new IgniteCheckedException("Missing WAL segment in the archive", e); - else - nextHandle = null; - } - - if (nextHandle == null) { - if (!readArchive) - releaseWorkSegment(curWalSegmIdx); - } - else - nextHandle.workDir = !readArchive; - - curRec = null; - - return nextHandle; - } - - /** {@inheritDoc} */ - @Override protected IgniteCheckedException handleRecordException( - @NotNull Exception e, - @Nullable FileWALPointer ptr) { - - if (e instanceof IgniteCheckedException) - if (X.hasCause(e, IgniteDataIntegrityViolationException.class)) - // This means that there is no explicit last sengment, so we iterate unil the very end. - if (end == null) { - long nextWalSegmentIdx = curWalSegmIdx + 1; - - // Check that we should not look this segment up in archive directory. - // Basically the same check as in "advanceSegment" method. - if (archiver != null) - if (!canReadArchiveOrReserveWork(nextWalSegmentIdx)) - try { - long workIdx = nextWalSegmentIdx % dsCfg.getWalSegments(); - - FileDescriptor fd = new FileDescriptor( - new File(walWorkDir, FileDescriptor.fileName(workIdx)), - nextWalSegmentIdx - ); - - try { - ReadFileHandle nextHandle = initReadHandle(fd, null); - - // "nextHandle == null" is true only if current segment is the last one in the - // whole history. Only in such case we ignore crc validation error and just stop - // as if we reached the end of the WAL. - if (nextHandle == null) - return null; - } - catch (IgniteCheckedException | FileNotFoundException initReadHandleException) { - e.addSuppressed(initReadHandleException); - } - } - finally { - releaseWorkSegment(nextWalSegmentIdx); - } - } - - return super.handleRecordException(e, ptr); - } - - /** - * @param absIdx Absolute index to check. - * @return
  • {@code True} if we can safely read the archive,
  • {@code false} if the segment has - * not been archived yet. In this case the corresponding work segment is reserved (will not be deleted until - * release). Use {@link #releaseWorkSegment} for unlock
- */ - private boolean canReadArchiveOrReserveWork(long absIdx) { - return archiver != null && archiver.checkCanReadArchiveOrReserveWorkSegment(absIdx); - } - - /** - * @param absIdx Absolute index to release. - */ - private void releaseWorkSegment(long absIdx) { - if (archiver != null) - archiver.releaseWorkSegment(absIdx); - } - - /** {@inheritDoc} */ - @Override protected AbstractReadFileHandle createReadFileHandle(SegmentIO fileIO, - RecordSerializer ser, FileInput in) { - return new ReadFileHandle(fileIO, ser, in); - } - } - - /** - * Flushes current file handle for {@link WALMode#BACKGROUND} WALMode. - * Called periodically from scheduler. - */ - private void doFlush() { - final FileWriteHandle hnd = currentHandle(); - try { - hnd.flush(hnd.head.get(), false); - } - catch (Exception e) { - U.warn(log, "Failed to flush WAL record queue", e); - } - } - - /** - * Scans provided folder for a WAL segment files - * @param walFilesDir directory to scan - * @return found WAL file descriptors - */ - private static FileDescriptor[] loadFileDescriptors(@NotNull final File walFilesDir) throws IgniteCheckedException { - final File[] files = walFilesDir.listFiles(WAL_SEGMENT_COMPACTED_OR_RAW_FILE_FILTER); - - if (files == null) { - throw new IgniteCheckedException("WAL files directory does not not denote a " + - "directory, or if an I/O error occurs: [" + walFilesDir.getAbsolutePath() + "]"); - } - return scan(files); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentArchivedStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentArchivedStorage.java index c526ae11e6feb..57ac848fc8295 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentArchivedStorage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentArchivedStorage.java @@ -34,6 +34,8 @@ class SegmentArchivedStorage extends SegmentObservable { * no segments archived. */ private volatile long lastAbsArchivedIdx = -1; + /** Latest truncated segment. */ + private volatile long lastTruncatedArchiveIdx = -1; /** * @param segmentLockStorage Protects WAL work segments from moving. @@ -122,6 +124,13 @@ synchronized void interrupt() { notifyAll(); } + /** + * Resets interrupted flag. + */ + void reset() { + interrupted = false; + } + /** * Check for interrupt flag was set. */ @@ -136,4 +145,18 @@ private void checkInterrupted() throws IgniteInterruptedCheckedException { private synchronized void onSegmentUnlocked(long segmentId) { notifyAll(); } + + /** + * @param lastTruncatedArchiveIdx Last truncated segment. + */ + void lastTruncatedArchiveIdx(long lastTruncatedArchiveIdx) { + this.lastTruncatedArchiveIdx = lastTruncatedArchiveIdx; + } + + /** + * @return Last truncated segment. + */ + long lastTruncatedArchiveIdx() { + return lastTruncatedArchiveIdx; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAware.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAware.java index 6172a75ab0cfe..b564aec868bb0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAware.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAware.java @@ -27,8 +27,6 @@ * Holder of actual information of latest manipulation on WAL segments. */ public class SegmentAware { - /** Latest truncated segment. */ - private volatile long lastTruncatedArchiveIdx = -1L; /** Segment reservations storage: Protects WAL segments from deletion during WAL log cleanup. */ private final SegmentReservationStorage reservationStorage = new SegmentReservationStorage(); /** Lock on segment protects from archiving segment. */ @@ -36,15 +34,17 @@ public class SegmentAware { /** Manages last archived index, emulates archivation in no-archiver mode. */ private final SegmentArchivedStorage segmentArchivedStorage = buildArchivedStorage(segmentLockStorage); /** Storage of actual information about current index of compressed segments. */ - private final SegmentCompressStorage segmentCompressStorage = buildCompressStorage(segmentArchivedStorage); + private final SegmentCompressStorage segmentCompressStorage; /** Storage of absolute current segment index. */ private final SegmentCurrentStateStorage segmentCurrStateStorage; /** * @param walSegmentsCnt Total WAL segments count. + * @param compactionEnabled Is wal compaction enabled. */ - public SegmentAware(int walSegmentsCnt) { + public SegmentAware(int walSegmentsCnt, boolean compactionEnabled) { segmentCurrStateStorage = buildCurrentStateStorage(walSegmentsCnt, segmentArchivedStorage); + segmentCompressStorage = buildCompressStorage(segmentArchivedStorage, compactionEnabled); } /** @@ -104,16 +104,21 @@ public void awaitSegmentArchived(long awaitIdx) throws IgniteInterruptedCheckedE * there's no segment to archive right now. */ public long waitNextSegmentToCompress() throws IgniteInterruptedCheckedException { - return Math.max(segmentCompressStorage.nextSegmentToCompressOrWait(), lastTruncatedArchiveIdx + 1); + long idx; + + while ((idx = segmentCompressStorage.nextSegmentToCompressOrWait()) <= lastTruncatedArchiveIdx()) + onSegmentCompressed(idx); + + return idx; } /** - * Force set last compressed segment. + * Callback after segment compression finish. * - * @param lastCompressedIdx Segment which was last compressed. + * @param compressedIdx Index of compressed segment. */ - public void lastCompressedIdx(long lastCompressedIdx) { - segmentCompressStorage.lastCompressedIdx(lastCompressedIdx); + public void onSegmentCompressed(long compressedIdx) { + segmentCompressStorage.onSegmentCompressed(compressedIdx); } /** @@ -123,6 +128,20 @@ public long lastCompressedIdx() { return segmentCompressStorage.lastCompressedIdx(); } + /** + * @param idx Minimum raw segment index that should be preserved from deletion. + */ + public void keepUncompressedIdxFrom(long idx) { + segmentCompressStorage.keepUncompressedIdxFrom(idx); + } + + /** + * @return Minimum raw segment index that should be preserved from deletion. + */ + public long keepUncompressedIdxFrom() { + return segmentCompressStorage.keepUncompressedIdxFrom(); + } + /** * Update current WAL index. * @@ -136,14 +155,14 @@ public void curAbsWalIdx(long curAbsWalIdx) { * @param lastTruncatedArchiveIdx Last truncated segment; */ public void lastTruncatedArchiveIdx(long lastTruncatedArchiveIdx) { - this.lastTruncatedArchiveIdx = lastTruncatedArchiveIdx; + segmentArchivedStorage.lastTruncatedArchiveIdx(lastTruncatedArchiveIdx); } /** * @return Last truncated segment. */ public long lastTruncatedArchiveIdx() { - return lastTruncatedArchiveIdx; + return segmentArchivedStorage.lastTruncatedArchiveIdx(); } /** @@ -219,6 +238,17 @@ public void releaseWorkSegment(long absIdx) { segmentLockStorage.releaseWorkSegment(absIdx); } + /** + * Reset interrupted flag. + */ + public void reset() { + segmentArchivedStorage.reset(); + + segmentCompressStorage.reset(); + + segmentCurrStateStorage.reset(); + } + /** * Interrupt waiting on related objects. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentCompressStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentCompressStorage.java index 30c9a2d50d363..d93bb8423acc4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentCompressStorage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentCompressStorage.java @@ -18,6 +18,10 @@ package org.apache.ignite.internal.processors.cache.persistence.wal.aware; import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.List; +import java.util.Queue; /** * Storage of actual information about current index of compressed segments. @@ -25,25 +29,50 @@ public class SegmentCompressStorage { /** Flag of interrupt waiting on this object. */ private volatile boolean interrupted; + /** Manages last archived index, emulates archivation in no-archiver mode. */ private final SegmentArchivedStorage segmentArchivedStorage; + + /** If WAL compaction enabled. */ + private final boolean compactionEnabled; + /** Last successfully compressed segment. */ private volatile long lastCompressedIdx = -1L; + /** Last enqueued to compress segment. */ + private long lastEnqueuedToCompressIdx = -1L; + + /** Segments to compress queue. */ + private final Queue segmentsToCompress = new ArrayDeque<>(); + + /** List of currently compressing segments. */ + private final List compressingSegments = new ArrayList<>(); + + /** Compressed segment with maximal index. */ + private long lastMaxCompressedIdx = -1L; + + /** Min uncompressed index to keep. */ + private volatile long minUncompressedIdxToKeep = -1L; + /** * @param segmentArchivedStorage Storage of last archived segment. + * @param compactionEnabled If WAL compaction enabled. */ - private SegmentCompressStorage(SegmentArchivedStorage segmentArchivedStorage) { + private SegmentCompressStorage(SegmentArchivedStorage segmentArchivedStorage, boolean compactionEnabled) { this.segmentArchivedStorage = segmentArchivedStorage; + this.compactionEnabled = compactionEnabled; + this.segmentArchivedStorage.addObserver(this::onSegmentArchived); } /** * @param segmentArchivedStorage Storage of last archived segment. + * @param compactionEnabled If WAL compaction enabled. */ - static SegmentCompressStorage buildCompressStorage(SegmentArchivedStorage segmentArchivedStorage) { - SegmentCompressStorage storage = new SegmentCompressStorage(segmentArchivedStorage); + static SegmentCompressStorage buildCompressStorage(SegmentArchivedStorage segmentArchivedStorage, + boolean compactionEnabled) { + SegmentCompressStorage storage = new SegmentCompressStorage(segmentArchivedStorage, compactionEnabled); segmentArchivedStorage.addObserver(storage::onSegmentArchived); @@ -51,12 +80,23 @@ static SegmentCompressStorage buildCompressStorage(SegmentArchivedStorage segmen } /** - * Force set last compressed segment. + * Callback after segment compression finish. * - * @param lastCompressedIdx Segment which was last compressed. + * @param compressedIdx Index of compressed segment. */ - void lastCompressedIdx(long lastCompressedIdx) { - this.lastCompressedIdx = lastCompressedIdx; + synchronized void onSegmentCompressed(long compressedIdx) { + if (compressedIdx > lastMaxCompressedIdx) + lastMaxCompressedIdx = compressedIdx; + + compressingSegments.remove(compressedIdx); + + if (!compressingSegments.isEmpty()) + this.lastCompressedIdx = Math.min(lastMaxCompressedIdx, compressingSegments.get(0) - 1); + else + this.lastCompressedIdx = lastMaxCompressedIdx; + + if (compressedIdx > lastEnqueuedToCompressIdx) + lastEnqueuedToCompressIdx = compressedIdx; } /** @@ -71,13 +111,8 @@ long lastCompressedIdx() { * there's no segment to archive right now. */ synchronized long nextSegmentToCompressOrWait() throws IgniteInterruptedCheckedException { - long segmentToCompress = lastCompressedIdx + 1; - try { - while ( - segmentToCompress > segmentArchivedStorage.lastArchivedAbsoluteIndex() - && !interrupted - ) + while (segmentsToCompress.peek() == null && !interrupted) wait(); } catch (InterruptedException e) { @@ -86,7 +121,13 @@ synchronized long nextSegmentToCompressOrWait() throws IgniteInterruptedCheckedE checkInterrupted(); - return segmentToCompress; + Long idx = segmentsToCompress.poll(); + + assert idx != null; + + compressingSegments.add(idx); + + return idx; } /** @@ -110,7 +151,30 @@ private void checkInterrupted() throws IgniteInterruptedCheckedException { * Callback for waking up compressor when new segment is archived. */ private synchronized void onSegmentArchived(long lastAbsArchivedIdx) { + while (lastEnqueuedToCompressIdx < lastAbsArchivedIdx && compactionEnabled) + segmentsToCompress.add(++lastEnqueuedToCompressIdx); + notifyAll(); } + /** + * @param idx Minimum raw segment index that should be preserved from deletion. + */ + void keepUncompressedIdxFrom(long idx) { + minUncompressedIdxToKeep = idx; + } + + /** + * @return Minimum raw segment index that should be preserved from deletion. + */ + long keepUncompressedIdxFrom() { + return minUncompressedIdxToKeep; + } + + /** + * Reset interrupted flag. + */ + public void reset() { + interrupted = false; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentCurrentStateStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentCurrentStateStorage.java index 5761ef9fcbb46..d08a9b8bdeaae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentCurrentStateStorage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentCurrentStateStorage.java @@ -168,4 +168,13 @@ private void checkInterrupted() throws IgniteInterruptedCheckedException { if (interrupted) throw new IgniteInterruptedCheckedException("Interrupt waiting of change current idx"); } + + /** + * Reset interrupted flag. + */ + public void reset() { + interrupted = false; + + forceInterrupted = false; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/crc/FastCrc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/crc/FastCrc.java new file mode 100644 index 0000000000000..0dcbafdb9c978 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/crc/FastCrc.java @@ -0,0 +1,101 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.crc; + +import java.nio.ByteBuffer; +import java.util.zip.CRC32; + +/** + * This CRC calculation implementation workf much faster then {@link PureJavaCrc32} + */ +public final class FastCrc { + /** CRC algo. */ + private static final ThreadLocal CRC = ThreadLocal.withInitial(CRC32::new); + + /** */ + private final CRC32 crc = new CRC32(); + + /** + * Current value. + */ + private int val; + + /** */ + public FastCrc() { + reset(); + } + + /** + * Preparation for further calculations. + */ + public void reset() { + val = 0xffffffff; + + crc.reset(); + } + + /** + * @return crc value. + */ + public int getValue() { + return val; + } + + /** + * @param buf Input buffer. + * @param len Data length. + */ + public void update(final ByteBuffer buf, final int len) { + val = calcCrc(crc, buf, len); + } + + /** + * @param buf Input buffer. + * @param len Data length. + * + * @return Crc checksum. + */ + public static int calcCrc(ByteBuffer buf, int len) { + CRC32 crcAlgo = CRC.get(); + + int res = calcCrc(crcAlgo, buf, len); + + crcAlgo.reset(); + + return res; + } + + /** + * @param crcAlgo CRC algorithm. + * @param buf Input buffer. + * @param len Buffer length. + * + * @return Crc checksum. + */ + private static int calcCrc(CRC32 crcAlgo, ByteBuffer buf, int len) { + int initLimit = buf.limit(); + + buf.limit(buf.position() + len); + + crcAlgo.update(buf); + + buf.limit(initLimit); + + return (int)crcAlgo.getValue() ^ 0xFFFFFFFF; + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/crc/PureJavaCrc32.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/crc/PureJavaCrc32.java index 6bd4a35b2fdf8..b011f783be005 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/crc/PureJavaCrc32.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/crc/PureJavaCrc32.java @@ -29,7 +29,9 @@ * succession. * * The current version is ~10x to 1.8x as fast as Sun's native java.util.zip.CRC32 in Java 1.6 + * @deprecated Use {@link FastCrc} instead. */ +@Deprecated public class PureJavaCrc32 { /** * the current CRC value diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/AbstractFileHandle.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/AbstractFileHandle.java new file mode 100644 index 0000000000000..127d73787d3fc --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/AbstractFileHandle.java @@ -0,0 +1,47 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.filehandle; + +import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentIO; +import org.jetbrains.annotations.NotNull; + +/** + * + */ +public abstract class AbstractFileHandle { + /** I/O interface for read/write operations with file. */ + protected SegmentIO fileIO; + + /** Segment idx corresponded to fileIo. */ + private final long segmentIdx; + + /** + * @param fileIO I/O interface for read/write operations of AbstractFileHandle. + */ + public AbstractFileHandle(@NotNull SegmentIO fileIO) { + this.fileIO = fileIO; + segmentIdx = fileIO.getSegmentId(); + } + + /** + * @return Absolute WAL segment file index (incremental counter). + */ + public long getSegmentId(){ + return segmentIdx; + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileHandleManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileHandleManager.java new file mode 100644 index 0000000000000..6597e4615394f --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileHandleManager.java @@ -0,0 +1,81 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.filehandle; + +import java.io.IOException; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; +import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentIO; +import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer; + +/** + * Manager of {@link FileWriteHandle}. + */ +public interface FileHandleManager { + /** + * Initialize {@link FileWriteHandle} for first time. + * + * @param fileIO FileIO. + * @param position Init position. + * @param serializer Serializer for file handle. + * @return Created file handle. + * @throws IOException if creation was not success. + */ + FileWriteHandle initHandle(SegmentIO fileIO, long position, RecordSerializer serializer) throws IOException; + + /** + * Create next file handle. + * + * @param fileIO FileIO. + * @param serializer Serializer for file handle. + * @return Created file handle. + * @throws IOException if creation was not success. + */ + FileWriteHandle nextHandle(SegmentIO fileIO, RecordSerializer serializer) throws IOException; + + /** + * Start manager. + */ + void start(); + + /** + * On activate. + */ + void onActivate(); + + /** + * On deactivate. + * + * @throws IgniteCheckedException if fail. + */ + void onDeactivate() throws IgniteCheckedException; + + /** + * Resume logging. + */ + void resumeLogging(); + + /** + * @param ptr Pointer until need to flush. + * @param explicitFsync {@code true} if fsync required. + * @throws IgniteCheckedException if fail. + * @throws StorageException if storage was fail. + */ + void flush(WALPointer ptr, boolean explicitFsync) throws IgniteCheckedException, StorageException; +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileHandleManagerFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileHandleManagerFactory.java new file mode 100644 index 0000000000000..b0c456e42dd1b --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileHandleManagerFactory.java @@ -0,0 +1,90 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.filehandle; + +import java.util.function.Supplier; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl; +import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer; + +/** + * Factory of {@link FileHandleManager}. + */ +public class FileHandleManagerFactory { + /** */ + private final boolean walFsyncWithDedicatedWorker = + IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_WAL_FSYNC_WITH_DEDICATED_WORKER, false); + + /** Data storage configuration. */ + private final DataStorageConfiguration dsConf; + + /** + * @param conf Data storage configuration. + */ + public FileHandleManagerFactory(DataStorageConfiguration conf) { + dsConf = conf; + } + + /** + * @param cctx Cache context. + * @param metrics Data storage metrics. + * @param mmap Using mmap. + * @param lastWALPtr Last WAL pointer. + * @param serializer Serializer. + * @param currHandleSupplier Supplier of current handle. + * @return One of implementation of {@link FileHandleManager}. + */ + public FileHandleManager build( + GridCacheSharedContext cctx, + DataStorageMetricsImpl metrics, + boolean mmap, + Supplier lastWALPtr, + RecordSerializer serializer, + Supplier currHandleSupplier + ) { + if (dsConf.getWalMode() == WALMode.FSYNC && !walFsyncWithDedicatedWorker) + return new FsyncFileHandleManagerImpl( + cctx, + metrics, + lastWALPtr, + serializer, + currHandleSupplier, + dsConf.getWalMode(), + dsConf.getWalSegmentSize(), + dsConf.getWalFsyncDelayNanos(), + dsConf.getWalThreadLocalBufferSize() + ); + else + return new FileHandleManagerImpl( + cctx, + metrics, + mmap, + lastWALPtr, + serializer, + currHandleSupplier, + dsConf.getWalMode(), + dsConf.getWalBufferSize(), + dsConf.getWalSegmentSize(), + dsConf.getWalFsyncDelayNanos() + ); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileHandleManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileHandleManagerImpl.java new file mode 100644 index 0000000000000..1daac31cafc60 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileHandleManagerImpl.java @@ -0,0 +1,603 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.filehandle; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.MappedByteBuffer; +import java.nio.channels.ClosedByInterruptException; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.locks.LockSupport; +import java.util.function.Supplier; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer; +import org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer; +import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentIO; +import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.util.worker.GridWorker; +import org.apache.ignite.thread.IgniteThread; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SEGMENT_SYNC_TIMEOUT; +import static org.apache.ignite.configuration.WALMode.LOG_ONLY; +import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR; +import static org.apache.ignite.failure.FailureType.SYSTEM_WORKER_TERMINATION; +import static org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer.BufferMode.DIRECT; +import static org.apache.ignite.internal.util.IgniteUtils.sleep; + +/** + * Manager for {@link FileWriteHandleImpl}. + */ +public class FileHandleManagerImpl implements FileHandleManager { + /** Default wal segment sync timeout. */ + private static final long DFLT_WAL_SEGMENT_SYNC_TIMEOUT = 500L; + + /** WAL writer worker. */ + private WALWriter walWriter; + /** Wal segment sync worker. */ + private WalSegmentSyncer walSegmentSyncWorker; + /** Context. */ + protected final GridCacheSharedContext cctx; + /** Logger. */ + private final IgniteLogger log; + /** */ + private final WALMode mode; + /** Persistence metrics tracker. */ + private final DataStorageMetricsImpl metrics; + /** Use mapped byte buffer. */ + private final boolean mmap; + /** Last WAL pointer. */ + private final Supplier lastWALPtr; + /** */ + private final RecordSerializer serializer; + /** Current handle supplier. */ + private final Supplier currentHandleSupplier; + /** WAL buffer size. */ + private final int walBufferSize; + /** WAL segment size in bytes. . This is maximum value, actual segments may be shorter. */ + private final long maxWalSegmentSize; + /** Fsync delay. */ + private final long fsyncDelay; + + /** + * @param cctx Context. + * @param metrics Data storage metrics. + * @param mmap Mmap. + * @param lastWALPtr Last WAL pointer. + * @param serializer Serializer. + * @param currentHandleSupplier Current handle supplier. + * @param mode WAL mode. + * @param walBufferSize WAL buffer size. + * @param maxWalSegmentSize Max WAL segment size. + * @param fsyncDelay Fsync delay. + */ + public FileHandleManagerImpl( + GridCacheSharedContext cctx, + DataStorageMetricsImpl metrics, + boolean mmap, + Supplier lastWALPtr, + RecordSerializer serializer, + Supplier currentHandleSupplier, + WALMode mode, + int walBufferSize, + long maxWalSegmentSize, + long fsyncDelay) { + this.cctx = cctx; + this.log = cctx.logger(FileHandleManagerImpl.class); + this.mode = mode; + this.metrics = metrics; + this.mmap = mmap; + this.lastWALPtr = lastWALPtr; + this.serializer = serializer; + this.currentHandleSupplier = currentHandleSupplier; + this.walBufferSize = walBufferSize; + this.maxWalSegmentSize = maxWalSegmentSize; + this.fsyncDelay = fsyncDelay; + } + + /** {@inheritDoc} */ + @Override public FileWriteHandle initHandle( + SegmentIO fileIO, + long position, + RecordSerializer serializer + ) throws IOException { + SegmentedRingByteBuffer rbuf; + + if (mmap) { + MappedByteBuffer buf = fileIO.map((int)maxWalSegmentSize); + + rbuf = new SegmentedRingByteBuffer(buf, metrics); + } + else + rbuf = new SegmentedRingByteBuffer(walBufferSize, maxWalSegmentSize, DIRECT, metrics); + + rbuf.init(position); + + return new FileWriteHandleImpl( + cctx, fileIO, rbuf, serializer, metrics, walWriter, position, + mode, mmap, true, fsyncDelay, maxWalSegmentSize + ); + } + + /** {@inheritDoc} */ + @Override public FileWriteHandle nextHandle(SegmentIO fileIO, RecordSerializer serializer) throws IOException { + SegmentedRingByteBuffer rbuf; + + if (mmap) { + MappedByteBuffer buf = fileIO.map((int)maxWalSegmentSize); + + rbuf = new SegmentedRingByteBuffer(buf, metrics); + } + else + rbuf = currentHandle().buf.reset(); + + try { + return new FileWriteHandleImpl( + cctx, fileIO, rbuf, serializer, metrics, walWriter, 0, + mode, mmap, false, fsyncDelay, maxWalSegmentSize + ); + } + catch (ClosedByInterruptException e) { + if (rbuf != null) + rbuf.free(); + } + + return null; + } + + /** + * @return Current handle. + */ + private FileWriteHandleImpl currentHandle() { + return (FileWriteHandleImpl)currentHandleSupplier.get(); + } + + /** {@inheritDoc} */ + @Override public void start() { + if (mode != WALMode.NONE && mode != WALMode.FSYNC) { + walSegmentSyncWorker = new WalSegmentSyncer(cctx.igniteInstanceName(), + cctx.kernalContext().log(WalSegmentSyncer.class)); + + if (log.isInfoEnabled()) + log.info("Started write-ahead log manager [mode=" + mode + ']'); + } + else + U.quietAndWarn(log, "Started write-ahead log manager in NONE mode, persisted data may be lost in " + + "a case of unexpected node failure. Make sure to deactivate the cluster before shutdown."); + + } + + /** {@inheritDoc} */ + @Override public void onActivate() { + if (!cctx.kernalContext().clientNode()) { + if (walSegmentSyncWorker != null) + new IgniteThread(walSegmentSyncWorker).start(); + } + } + + /** {@inheritDoc} */ + @Override public void onDeactivate() throws IgniteCheckedException { + FileWriteHandleImpl currHnd = currentHandle(); + + if (mode == WALMode.BACKGROUND) { + if (currHnd != null) + currHnd.flush(null); + } + + if (currHnd != null) + currHnd.close(false); + + if (walSegmentSyncWorker != null) + walSegmentSyncWorker.shutdown(); + + if (walWriter != null) + walWriter.shutdown(); + } + + /** {@inheritDoc} */ + @Override public void resumeLogging() { + walWriter = new WALWriter(log); + + if (!mmap) + new IgniteThread(walWriter).start(); + } + + /** {@inheritDoc} */ + @Override public void flush(WALPointer ptr, boolean explicitFsync) throws IgniteCheckedException, StorageException { + if (serializer == null || mode == WALMode.NONE) + return; + + FileWriteHandleImpl cur = currentHandle(); + + // WAL manager was not started (client node). + if (cur == null) + return; + + FileWALPointer filePtr = (FileWALPointer)(ptr == null ? lastWALPtr.get() : ptr); + + if (mode == LOG_ONLY) + cur.flushOrWait(filePtr); + + if (!explicitFsync && mode != WALMode.FSYNC) + return; // No need to sync in LOG_ONLY or BACKGROUND unless explicit fsync is required. + + // No need to sync if was rolled over. + if (filePtr != null && !cur.needFsync(filePtr)) + return; + + cur.fsync(filePtr); + } + + /** + * @throws StorageException If node is no longer valid and we missed a WAL operation. + */ + private void checkNode() throws StorageException { + if (cctx.kernalContext().invalid()) + throw new StorageException("Failed to perform WAL operation (environment was invalidated by a " + + "previous error)"); + } + + /** + * WAL writer worker. + */ + public class WALWriter extends GridWorker { + /** Unconditional flush. */ + private static final long UNCONDITIONAL_FLUSH = -1L; + + /** File close. */ + private static final long FILE_CLOSE = -2L; + + /** File force. */ + private static final long FILE_FORCE = -3L; + + /** Err. */ + private volatile Throwable err; + + //TODO: replace with GC free data structure. + /** Parked threads. */ + final Map waiters = new ConcurrentHashMap<>(); + + /** + * Default constructor. + * + * @param log Logger. + */ + WALWriter(IgniteLogger log) { + super(cctx.igniteInstanceName(), "wal-write-worker%" + cctx.igniteInstanceName(), log, + cctx.kernalContext().workersRegistry()); + } + + /** {@inheritDoc} */ + @Override protected void body() { + Throwable err = null; + + try { + while (!isCancelled()) { + onIdle(); + + while (waiters.isEmpty()) { + if (!isCancelled()) { + blockingSectionBegin(); + + try { + LockSupport.park(); + } + finally { + blockingSectionEnd(); + } + } + else { + unparkWaiters(Long.MAX_VALUE); + + return; + } + } + + Long pos = null; + + for (Long val : waiters.values()) { + if (val > Long.MIN_VALUE) + pos = val; + } + + updateHeartbeat(); + + if (pos == null) + continue; + else if (pos < UNCONDITIONAL_FLUSH) { + try { + assert pos == FILE_CLOSE || pos == FILE_FORCE : pos; + + if (pos == FILE_CLOSE) + currentHandle().fileIO.close(); + else if (pos == FILE_FORCE) + currentHandle().fileIO.force(); + } + catch (IOException e) { + log.error("Exception in WAL writer thread: ", e); + + err = e; + + unparkWaiters(Long.MAX_VALUE); + + return; + } + + unparkWaiters(pos); + } + + updateHeartbeat(); + + List segs = currentHandle().buf.poll(pos); + + if (segs == null) { + unparkWaiters(pos); + + continue; + } + + for (int i = 0; i < segs.size(); i++) { + SegmentedRingByteBuffer.ReadSegment seg = segs.get(i); + + updateHeartbeat(); + + try { + writeBuffer(seg.position(), seg.buffer()); + } + catch (Throwable e) { + log.error("Exception in WAL writer thread:", e); + + err = e; + } + finally { + seg.release(); + + long p = pos <= UNCONDITIONAL_FLUSH || err != null ? Long.MAX_VALUE : currentHandle().written; + + unparkWaiters(p); + } + } + } + } + catch (Throwable t) { + err = t; + } + finally { + unparkWaiters(Long.MAX_VALUE); + + if (err == null && !isCancelled) + err = new IllegalStateException("Worker " + name() + " is terminated unexpectedly"); + + if (err instanceof OutOfMemoryError) + cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, err)); + else if (err != null) + cctx.kernalContext().failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, err)); + } + } + + /** + * Shutdowns thread. + */ + private void shutdown() throws IgniteInterruptedCheckedException { + U.cancel(this); + + LockSupport.unpark(runner()); + + U.join(runner()); + } + + /** + * Unparks waiting threads. + * + * @param pos Pos. + */ + private void unparkWaiters(long pos) { + assert pos > Long.MIN_VALUE : pos; + + for (Map.Entry e : waiters.entrySet()) { + Long val = e.getValue(); + + if (val <= pos) { + if (val != Long.MIN_VALUE) + waiters.put(e.getKey(), Long.MIN_VALUE); + + LockSupport.unpark(e.getKey()); + } + } + } + + /** + * Forces all made changes to the file. + */ + void force() throws IgniteCheckedException { + flushBuffer(FILE_FORCE); + } + + /** + * Closes file. + */ + void close() throws IgniteCheckedException { + flushBuffer(FILE_CLOSE); + } + + /** + * Flushes all data from the buffer. + */ + void flushAll() throws IgniteCheckedException { + flushBuffer(UNCONDITIONAL_FLUSH); + } + + /** + * @param expPos Expected position. + */ + void flushBuffer(long expPos) throws IgniteCheckedException { + if (mmap) + return; + + Throwable err = walWriter.err; + + if (err != null) + cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, err)); + + if (expPos == UNCONDITIONAL_FLUSH) + expPos = (currentHandle().buf.tail()); + + Thread t = Thread.currentThread(); + + waiters.put(t, expPos); + + LockSupport.unpark(walWriter.runner()); + + while (true) { + Long val = waiters.get(t); + + assert val != null : "Only this thread can remove thread from waiters"; + + if (val == Long.MIN_VALUE) { + waiters.remove(t); + + Throwable walWriterError = walWriter.err; + + if (walWriterError != null) + throw new IgniteCheckedException("Flush buffer failed.", walWriterError); + + return; + } + else + LockSupport.park(); + } + } + + /** + * @param pos Position in file to start write from. May be checked against actual position to wait previous + * writes to complete. + * @param buf Buffer to write to file. + * @throws StorageException If failed. + * @throws IgniteCheckedException If failed. + */ + private void writeBuffer(long pos, ByteBuffer buf) throws StorageException, IgniteCheckedException { + FileWriteHandleImpl hdl = currentHandle(); + + assert hdl.fileIO != null : "Writing to a closed segment."; + + checkNode(); + + long lastLogged = U.currentTimeMillis(); + + long logBackoff = 2_000; + + // If we were too fast, need to wait previous writes to complete. + while (hdl.written != pos) { + assert hdl.written < pos : "written = " + hdl.written + ", pos = " + pos; // No one can write further than we are now. + + // Permutation occurred between blocks write operations. + // Order of acquiring lock is not the same as order of write. + long now = U.currentTimeMillis(); + + if (now - lastLogged >= logBackoff) { + if (logBackoff < 60 * 60_000) + logBackoff *= 2; + + U.warn(log, "Still waiting for a concurrent write to complete [written=" + hdl.written + + ", pos=" + pos + ", lastFsyncPos=" + hdl.lastFsyncPos + ", stop=" + hdl.stop.get() + + ", actualPos=" + hdl.safePosition() + ']'); + + lastLogged = now; + } + + checkNode(); + } + + // Do the write. + int size = buf.remaining(); + + assert size > 0 : size; + + try { + assert hdl.written == hdl.fileIO.position(); + + hdl.written += hdl.fileIO.writeFully(buf); + + metrics.onWalBytesWritten(size); + + assert hdl.written == hdl.fileIO.position(); + } + catch (IOException e) { + StorageException se = new StorageException("Failed to write buffer.", e); + + cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, se)); + + throw se; + } + } + } + + /** + * Syncs WAL segment file. + */ + public class WalSegmentSyncer extends GridWorker { + /** Sync timeout. */ + long syncTimeout; + + /** + * @param igniteInstanceName Ignite instance name. + * @param log Logger. + */ + private WalSegmentSyncer(String igniteInstanceName, IgniteLogger log) { + super(igniteInstanceName, "wal-segment-syncer", log); + + syncTimeout = Math.max(IgniteSystemProperties.getLong(IGNITE_WAL_SEGMENT_SYNC_TIMEOUT, + DFLT_WAL_SEGMENT_SYNC_TIMEOUT), 100L); + } + + /** {@inheritDoc} */ + @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException { + while (!isCancelled()) { + sleep(syncTimeout); + + try { + flush(null, true); + } + catch (IgniteCheckedException e) { + U.error(log, "Exception when flushing WAL.", e); + } + } + } + + /** Shutted down the worker. */ + private void shutdown() { + synchronized (this) { + U.cancel(this); + } + + U.join(this, log); + } + } + +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileWriteHandle.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileWriteHandle.java new file mode 100644 index 0000000000000..410cd56046dcb --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileWriteHandle.java @@ -0,0 +1,113 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.filehandle; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.pagemem.wal.record.WALRecord; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer; +import org.jetbrains.annotations.Nullable; + +/** + * File write handle. + */ +public interface FileWriteHandle { + + /** + * @return Version of serializer. + */ + int serializerVersion(); + + /** + * Do action after finish resume logging. + */ + void finishResumeLogging(); + + /** + * Write header to segment. + * + * @throws IgniteCheckedException if fail. + */ + void writeHeader() throws IgniteCheckedException; + + /** + * @param rec Record to be added. + * @return Pointer or null if roll over to next segment is required or already started by other thread. + * @throws StorageException if storage was failed. + * @throws IgniteCheckedException if fail. + */ + @Nullable WALPointer addRecord(WALRecord rec) throws StorageException, IgniteCheckedException; + + /** + * Flush all records. + * + * @throws IgniteCheckedException if fail. + */ + void flushAll() throws IgniteCheckedException; + + /** + * @param ptr Pointer. + * @return {@code true} if fsync needed. + */ + boolean needFsync(FileWALPointer ptr); + + /** + * @return Pointer to the end of the last written record (probably not fsync-ed). + */ + FileWALPointer position(); + + /** + * Do fsync. + * + * @param ptr Pointer to which fsync required. + * @throws StorageException if storage fail. + * @throws IgniteCheckedException if fail. + */ + void fsync(FileWALPointer ptr) throws StorageException, IgniteCheckedException; + + /** + * Close buffer. + */ + void closeBuffer(); + + /** + * Close segment. + * + * @param rollOver Close for rollover. + * @return {@code true} if close was success. + * @throws IgniteCheckedException if fail. + * @throws StorageException if storage was fail. + */ + boolean close(boolean rollOver) throws IgniteCheckedException, StorageException; + + /** + * Signals next segment available to wake up other worker threads waiting for WAL to write. + */ + void signalNextAvailable(); + + /** + * Awaiting when next segment would be initialized. + */ + void awaitNext(); + + /** + * @return Absolute WAL segment file index (incremental counter). + */ + long getSegmentId(); +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileWriteHandleImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileWriteHandleImpl.java new file mode 100644 index 0000000000000..f582dbd496ae8 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FileWriteHandleImpl.java @@ -0,0 +1,601 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.filehandle; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.nio.ByteBuffer; +import java.nio.MappedByteBuffer; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLongFieldUpdater; +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord; +import org.apache.ignite.internal.pagemem.wal.record.SwitchSegmentRecord; +import org.apache.ignite.internal.pagemem.wal.record.WALRecord; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; +import org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer; +import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentIO; +import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer; +import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl; +import org.apache.ignite.internal.util.GridUnsafe; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SERIALIZER_VERSION; +import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.SWITCH_SEGMENT_RECORD; +import static org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager.prepareSerializerVersionBuffer; +import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactory.LATEST_SERIALIZER_VERSION; +import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.HEADER_RECORD_SIZE; +import static org.apache.ignite.internal.util.IgniteUtils.findField; +import static org.apache.ignite.internal.util.IgniteUtils.findNonPublicMethod; + +/** + * File handle for one log segment. + */ +@SuppressWarnings("SignalWithoutCorrespondingAwait") +class FileWriteHandleImpl extends AbstractFileHandle implements FileWriteHandle { + /** {@link MappedByteBuffer#force0(java.io.FileDescriptor, long, long)}. */ + private static final Method force0 = findNonPublicMethod( + MappedByteBuffer.class, "force0", + java.io.FileDescriptor.class, long.class, long.class + ); + /** {@link FileWriteHandleImpl#written} atomic field updater. */ + private static final AtomicLongFieldUpdater WRITTEN_UPD = + AtomicLongFieldUpdater.newUpdater(FileWriteHandleImpl.class, "written"); + + /** {@link MappedByteBuffer#mappingOffset()}. */ + private static final Method mappingOffset = findNonPublicMethod(MappedByteBuffer.class, "mappingOffset"); + + /** {@link MappedByteBuffer#mappingAddress(long)}. */ + private static final Method mappingAddress = findNonPublicMethod( + MappedByteBuffer.class, "mappingAddress", long.class + ); + + /** {@link MappedByteBuffer#fd} */ + private static final Field fd = findField(MappedByteBuffer.class, "fd"); + + /** Page size. */ + private static final int PAGE_SIZE = GridUnsafe.pageSize(); + + /** Serializer latest version to use. */ + private final int serializerVer = + IgniteSystemProperties.getInteger(IGNITE_WAL_SERIALIZER_VERSION, LATEST_SERIALIZER_VERSION); + + /** Use mapped byte buffer. */ + private final boolean mmap; + + /** Created on resume logging. */ + private volatile boolean resume; + + /** + * Position in current file after the end of last written record (incremented after file channel write operation) + */ + volatile long written; + + /** */ + protected volatile long lastFsyncPos; + + /** Stop guard to provide warranty that only one thread will be successful in calling {@link #close(boolean)}. */ + protected final AtomicBoolean stop = new AtomicBoolean(false); + + /** */ + private final Lock lock = new ReentrantLock(); + + /** Condition for timed wait of several threads, see {@link DataStorageConfiguration#getWalFsyncDelayNanos()}. */ + private final Condition fsync = lock.newCondition(); + + /** + * Next segment available condition. Protection from "spurious wakeup" is provided by predicate {@link + * #fileIO}=null. + */ + private final Condition nextSegment = lock.newCondition(); + + /** Buffer. */ + protected final SegmentedRingByteBuffer buf; + + /** */ + private final WALMode mode; + + /** Fsync delay. */ + private final long fsyncDelay; + + /** Persistence metrics tracker. */ + private final DataStorageMetricsImpl metrics; + + /** WAL segment size in bytes. This is maximum value, actual segments may be shorter. */ + private final long maxWalSegmentSize; + + /** Logger. */ + protected final IgniteLogger log; + + /** */ + private final RecordSerializer serializer; + + /** Context. */ + protected final GridCacheSharedContext cctx; + + /** WAL writer worker. */ + private final FileHandleManagerImpl.WALWriter walWriter; + + /** + * @param cctx Context. + * @param fileIO I/O file interface to use + * @param serializer Serializer. + * @param metrics Data storage metrics. + * @param writer WAL writer. + * @param pos Initial position. + * @param mode WAL mode. + * @param mmap Mmap. + * @param resume Created on resume logging flag. + * @param fsyncDelay Fsync delay. + * @param maxWalSegmentSize Max WAL segment size. + * @throws IOException If failed. + */ + FileWriteHandleImpl( + GridCacheSharedContext cctx, SegmentIO fileIO, SegmentedRingByteBuffer rbuf, RecordSerializer serializer, + DataStorageMetricsImpl metrics, FileHandleManagerImpl.WALWriter writer, long pos, WALMode mode, boolean mmap, + boolean resume, long fsyncDelay, long maxWalSegmentSize) throws IOException { + super(fileIO); + assert serializer != null; + + this.mmap = mmap; + this.mode = mode; + this.fsyncDelay = fsyncDelay; + this.metrics = metrics; + this.maxWalSegmentSize = maxWalSegmentSize; + this.log = cctx.logger(FileWriteHandleImpl.class); + this.cctx = cctx; + this.walWriter = writer; + this.serializer = serializer; + this.written = pos; + this.lastFsyncPos = pos; + this.resume = resume; + this.buf = rbuf; + + if (!mmap) + fileIO.position(pos); + } + + /** {@inheritDoc} */ + @Override public int serializerVersion() { + return serializer.version(); + } + + /** {@inheritDoc} */ + @Override public void finishResumeLogging() { + resume = false; + } + + /** + * @throws StorageException If node is no longer valid and we missed a WAL operation. + */ + private void checkNode() throws StorageException { + if (cctx.kernalContext().invalid()) + throw new StorageException("Failed to perform WAL operation (environment was invalidated by a " + + "previous error)"); + } + + /** + * Write serializer version to current handle. + */ + @Override public void writeHeader() { + SegmentedRingByteBuffer.WriteSegment seg = buf.offer(HEADER_RECORD_SIZE); + + assert seg != null && seg.position() > 0; + + prepareSerializerVersionBuffer(getSegmentId(), serializerVer, false, seg.buffer()); + + seg.release(); + } + + /** + * @param rec Record to be added to write queue. + * @return Pointer or null if roll over to next segment is required or already started by other thread. + * @throws StorageException If failed. + * @throws IgniteCheckedException If failed. + */ + @Override @Nullable public WALPointer addRecord(WALRecord rec) throws StorageException, IgniteCheckedException { + assert rec.size() > 0 : rec; + + for (; ; ) { + checkNode(); + + SegmentedRingByteBuffer.WriteSegment seg; + + // Buffer can be in open state in case of resuming with different serializer version. + if (rec.type() == SWITCH_SEGMENT_RECORD && !resume) + seg = buf.offerSafe(rec.size()); + else + seg = buf.offer(rec.size()); + + FileWALPointer ptr = null; + + if (seg != null) { + try { + int pos = (int)(seg.position() - rec.size()); + + ByteBuffer buf = seg.buffer(); + + if (buf == null) + return null; // Can not write to this segment, need to switch to the next one. + + ptr = new FileWALPointer(getSegmentId(), pos, rec.size()); + + rec.position(ptr); + + fillBuffer(buf, rec); + + if (mmap) { + // written field must grow only, but segment with greater position can be serialized + // earlier than segment with smaller position. + while (true) { + long written0 = written; + + if (seg.position() > written0) { + if (WRITTEN_UPD.compareAndSet(this, written0, seg.position())) + break; + } + else + break; + } + } + + return ptr; + } + finally { + seg.release(); + + if (mode == WALMode.BACKGROUND && rec instanceof CheckpointRecord) + flushOrWait(ptr); + } + } + else + walWriter.flushAll(); + } + } + + /** + * Flush or wait for concurrent flush completion. + * + * @param ptr Pointer. + */ + public void flushOrWait(FileWALPointer ptr) throws IgniteCheckedException { + if (ptr != null) { + // If requested obsolete file index, it must be already flushed by close. + if (ptr.index() != getSegmentId()) + return; + } + + flush(ptr); + } + + /** {@inheritDoc} */ + @Override public void flushAll() throws IgniteCheckedException { + flush(null); + } + + /** + * @param ptr Pointer. + */ + public void flush(FileWALPointer ptr) throws IgniteCheckedException { + if (ptr == null) { // Unconditional flush. + walWriter.flushAll(); + + return; + } + + assert ptr.index() == getSegmentId(); + + walWriter.flushBuffer(ptr.fileOffset()); + } + + /** + * @param buf Buffer. + * @param rec WAL record. + * @throws IgniteCheckedException If failed. + */ + private void fillBuffer(ByteBuffer buf, WALRecord rec) throws IgniteCheckedException { + try { + serializer.writeRecord(rec, buf); + } + catch (RuntimeException e) { + throw new IllegalStateException("Failed to write record: " + rec, e); + } + } + + /** + * Non-blocking check if this pointer needs to be sync'ed. + * + * @param ptr WAL pointer to check. + * @return {@code False} if this pointer has been already sync'ed. + */ + @Override public boolean needFsync(FileWALPointer ptr) { + // If index has changed, it means that the log was rolled over and already sync'ed. + // If requested position is smaller than last sync'ed, it also means all is good. + // If position is equal, then our record is the last not synced. + return getSegmentId() == ptr.index() && lastFsyncPos <= ptr.fileOffset(); + } + + /** + * @return Pointer to the end of the last written record (probably not fsync-ed). + */ + @Override public FileWALPointer position() { + lock.lock(); + + try { + return new FileWALPointer(getSegmentId(), (int)written, 0); + } + finally { + lock.unlock(); + } + } + + /** + * @param ptr Pointer to sync. + * @throws StorageException If failed. + */ + @Override public void fsync(FileWALPointer ptr) throws StorageException, IgniteCheckedException { + lock.lock(); + + try { + if (ptr != null) { + if (!needFsync(ptr)) + return; + + if (fsyncDelay > 0 && !stop.get()) { + // Delay fsync to collect as many updates as possible: trade latency for throughput. + U.await(fsync, fsyncDelay, TimeUnit.NANOSECONDS); + + if (!needFsync(ptr)) + return; + } + } + + flushOrWait(ptr); + + if (stop.get()) + return; + + long lastFsyncPos0 = lastFsyncPos; + long written0 = written; + + if (lastFsyncPos0 != written0) { + // Fsync position must be behind. + assert lastFsyncPos0 < written0 : "lastFsyncPos=" + lastFsyncPos0 + ", written=" + written0; + + boolean metricsEnabled = metrics.metricsEnabled(); + + long start = metricsEnabled ? System.nanoTime() : 0; + + if (mmap) { + long pos = ptr == null ? -1 : ptr.fileOffset(); + + List segs = buf.poll(pos); + + if (segs != null) { + assert segs.size() == 1; + + SegmentedRingByteBuffer.ReadSegment seg = segs.get(0); + + int off = seg.buffer().position(); + int len = seg.buffer().limit() - off; + + fsync((MappedByteBuffer)buf.buf, off, len); + + seg.release(); + } + } + else + walWriter.force(); + + lastFsyncPos = written; + + if (fsyncDelay > 0) + fsync.signalAll(); + + long end = metricsEnabled ? System.nanoTime() : 0; + + if (metricsEnabled) + metrics.onFsync(end - start); + } + } + finally { + lock.unlock(); + } + } + + /** + * @param buf Mapped byte buffer. + * @param off Offset. + * @param len Length. + */ + private void fsync(MappedByteBuffer buf, int off, int len) throws IgniteCheckedException { + try { + long mappedOff = (Long)mappingOffset.invoke(buf); + + assert mappedOff == 0 : mappedOff; + + long addr = (Long)mappingAddress.invoke(buf, mappedOff); + + long delta = (addr + off) % PAGE_SIZE; + + long alignedAddr = (addr + off) - delta; + + force0.invoke(buf, fd.get(buf), alignedAddr, len + delta); + } + catch (IllegalAccessException | InvocationTargetException e) { + throw new IgniteCheckedException(e); + } + } + + /** {@inheritDoc} */ + @Override public void closeBuffer() { + buf.close(); + } + + /** + * @return {@code true} If this thread actually closed the segment. + * @throws IgniteCheckedException If failed. + * @throws StorageException If failed. + */ + @Override public boolean close(boolean rollOver) throws IgniteCheckedException, StorageException { + if (stop.compareAndSet(false, true)) { + lock.lock(); + + try { + flushOrWait(null); + + try { + RecordSerializer backwardSerializer = new RecordSerializerFactoryImpl(cctx) + .createSerializer(serializerVer); + + SwitchSegmentRecord segmentRecord = new SwitchSegmentRecord(); + + int switchSegmentRecSize = backwardSerializer.size(segmentRecord); + + if (rollOver && written < (maxWalSegmentSize - switchSegmentRecSize)) { + segmentRecord.size(switchSegmentRecSize); + + WALPointer segRecPtr = addRecord(segmentRecord); + + if (segRecPtr != null) + fsync((FileWALPointer)segRecPtr); + } + + if (mmap) { + List segs = buf.poll(maxWalSegmentSize); + + if (segs != null) { + assert segs.size() == 1; + + segs.get(0).release(); + } + } + + // Do the final fsync. + if (mode != WALMode.NONE) { + if (mmap) + ((MappedByteBuffer)buf.buf).force(); + else + fileIO.force(); + + lastFsyncPos = written; + } + + if (mmap) { + try { + fileIO.close(); + } + catch (IOException ignore) { + // No-op. + } + } + else { + walWriter.close(); + + if (!rollOver) + buf.free(); + } + } + catch (IOException e) { + throw new StorageException("Failed to close WAL write handle [idx=" + getSegmentId() + "]", e); + } + + if (log.isDebugEnabled()) + log.debug("Closed WAL write handle [idx=" + getSegmentId() + "]"); + + return true; + } + finally { + if (mmap) + buf.free(); + + lock.unlock(); + } + } + else + return false; + } + + /** + * Signals next segment available to wake up other worker threads waiting for WAL to write. + */ + @Override public void signalNextAvailable() { + lock.lock(); + + try { + assert cctx.kernalContext().invalid() || + written == lastFsyncPos || mode != WALMode.FSYNC : + "fsync [written=" + written + ", lastFsync=" + lastFsyncPos + ", idx=" + getSegmentId() + ']'; + + fileIO = null; + + nextSegment.signalAll(); + } + finally { + lock.unlock(); + } + } + + /** {@inheritDoc} */ + @Override public void awaitNext() { + lock.lock(); + + try { + while (fileIO != null) + U.awaitQuiet(nextSegment); + } + finally { + lock.unlock(); + } + } + + /** + * @return Safely reads current position of the file channel as String. Will return "null" if channel is null. + */ + public String safePosition() { + FileIO io = fileIO; + + if (io == null) + return "null"; + + try { + return String.valueOf(io.position()); + } + catch (IOException e) { + return "{Failed to read channel position: " + e.getMessage() + '}'; + } + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FsyncFileHandleManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FsyncFileHandleManagerImpl.java new file mode 100644 index 0000000000000..e456f04c1711d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FsyncFileHandleManagerImpl.java @@ -0,0 +1,157 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.filehandle; + +import java.io.IOException; +import java.util.function.Supplier; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer; +import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentIO; +import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer; + +/** + * Implementation of {@link FileWriteHandle} for FSYNC mode. + */ +public class FsyncFileHandleManagerImpl implements FileHandleManager { + /** Context. */ + protected final GridCacheSharedContext cctx; + /** Logger. */ + protected final IgniteLogger log; + /** */ + private final WALMode mode; + /** Persistence metrics tracker. */ + private final DataStorageMetricsImpl metrics; + /** Last WAL pointer. */ + private final Supplier lastWALPtr; + /** */ + protected final RecordSerializer serializer; + /** Current handle supplier. */ + private final Supplier currentHandleSupplier; + /** WAL segment size in bytes. This is maximum value, actual segments may be shorter. */ + private final long maxWalSegmentSize; + /** Fsync delay. */ + private final long fsyncDelay; + /** Thread local byte buffer size. */ + private final int tlbSize; + + /** + * @param cctx Context. + * @param metrics Data storage metrics. + * @param ptr Last WAL pointer. + * @param serializer Serializer. + * @param handle Current handle supplier. + * @param mode WAL mode. + * @param maxWalSegmentSize Max WAL segment size. + * @param fsyncDelay Fsync delay. + * @param tlbSize Thread local byte buffer size. + */ + public FsyncFileHandleManagerImpl(GridCacheSharedContext cctx, + DataStorageMetricsImpl metrics, Supplier ptr, RecordSerializer serializer, + Supplier handle, WALMode mode, + long maxWalSegmentSize, long fsyncDelay, int tlbSize) { + this.cctx = cctx; + this.log = cctx.logger(FsyncFileHandleManagerImpl.class); + this.mode = mode; + this.metrics = metrics; + lastWALPtr = ptr; + this.serializer = serializer; + currentHandleSupplier = handle; + this.maxWalSegmentSize = maxWalSegmentSize; + this.fsyncDelay = fsyncDelay; + this.tlbSize = tlbSize; + } + + /** {@inheritDoc} */ + @Override public FileWriteHandle initHandle(SegmentIO fileIO, long position, + RecordSerializer serializer) throws IOException { + return new FsyncFileWriteHandle( + cctx, fileIO, metrics, serializer, position, + mode, maxWalSegmentSize, tlbSize, fsyncDelay + ); + } + + /** {@inheritDoc} */ + @Override public FileWriteHandle nextHandle(SegmentIO fileIO, + RecordSerializer serializer) throws IOException { + return new FsyncFileWriteHandle( + cctx, fileIO, metrics, serializer, 0, + mode, maxWalSegmentSize, tlbSize, fsyncDelay + ); + } + + /** + * @return Current handle. + */ + private FsyncFileWriteHandle currentHandle() { + return (FsyncFileWriteHandle)currentHandleSupplier.get(); + } + + /** {@inheritDoc} */ + @Override public void start() { + //NOOP. + } + + /** {@inheritDoc} */ + @Override public void onActivate() { + //NOOP. + } + + /** {@inheritDoc} */ + @Override public void onDeactivate() throws IgniteCheckedException { + FsyncFileWriteHandle currHnd = currentHandle(); + + if (mode == WALMode.BACKGROUND) { + if (currHnd != null) + currHnd.flushAllOnStop(); + } + + if (currHnd != null) + currHnd.close(false); + } + + /** {@inheritDoc} */ + @Override public void resumeLogging() { + //NOOP. + } + + /** {@inheritDoc} */ + @Override public void flush(WALPointer ptr, boolean explicitFsync) throws IgniteCheckedException, StorageException { + if (serializer == null || mode == WALMode.NONE) + return; + + FsyncFileWriteHandle cur = currentHandle(); + + // WAL manager was not started (client node). + if (cur == null) + return; + + FileWALPointer filePtr = (FileWALPointer)(ptr == null ? lastWALPtr.get() : ptr); + + // No need to sync if was rolled over. + if (filePtr != null && !cur.needFsync(filePtr)) + return; + + cur.fsync(filePtr, false); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FsyncFileWriteHandle.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FsyncFileWriteHandle.java new file mode 100644 index 0000000000000..2acc3a7994263 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/filehandle/FsyncFileWriteHandle.java @@ -0,0 +1,845 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.filehandle; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.pagemem.wal.record.SwitchSegmentRecord; +import org.apache.ignite.internal.pagemem.wal.record.WALRecord; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; +import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentIO; +import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer; +import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl; +import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer; +import org.apache.ignite.internal.util.GridUnsafe; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SERIALIZER_VERSION; +import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR; +import static org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager.prepareSerializerVersionBuffer; +import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactory.LATEST_SERIALIZER_VERSION; + +/** + * File handle for one log segment. + */ +@SuppressWarnings("SignalWithoutCorrespondingAwait") +class FsyncFileWriteHandle extends AbstractFileHandle implements FileWriteHandle { + /** */ + private final RecordSerializer serializer; + /** Max segment size. */ + private final long maxSegmentSize; + /** Serializer latest version to use. */ + private final int serializerVersion = + IgniteSystemProperties.getInteger(IGNITE_WAL_SERIALIZER_VERSION, LATEST_SERIALIZER_VERSION); + /** + * Accumulated WAL records chain. This reference points to latest WAL record. When writing records chain is iterated + * from latest to oldest (see {@link WALRecord#previous()}) Records from chain are saved into buffer in reverse + * order + */ + private final AtomicReference head = new AtomicReference<>(); + /** + * Position in current file after the end of last written record (incremented after file channel write operation) + */ + private volatile long written; + /** */ + private volatile long lastFsyncPos; + /** Stop guard to provide warranty that only one thread will be successful in calling {@link #close(boolean)} */ + private final AtomicBoolean stop = new AtomicBoolean(false); + /** */ + private final Lock lock = new ReentrantLock(); + /** Condition activated each time writeBuffer() completes. Used to wait previously flushed write to complete */ + private final Condition writeComplete = lock.newCondition(); + /** Condition for timed wait of several threads, see {@link DataStorageConfiguration#getWalFsyncDelayNanos()} */ + private final Condition fsync = lock.newCondition(); + /** + * Next segment available condition. Protection from "spurious wakeup" is provided by predicate {@link + * #fileIO}=null + */ + private final Condition nextSegment = lock.newCondition(); + /** */ + private final WALMode mode; + /** Thread local byte buffer size, see {@link #tlb} */ + private final int tlbSize; + /** Context. */ + protected final GridCacheSharedContext cctx; + /** Persistence metrics tracker. */ + private final DataStorageMetricsImpl metrics; + /** Logger. */ + protected final IgniteLogger log; + /** Fsync delay. */ + private final long fsyncDelay; + + /** + * Thread local byte buffer for saving serialized WAL records chain, see {@link FsyncFileWriteHandle#head}. + * Introduced to decrease number of buffers allocation. Used only for record itself is shorter than {@link + * #tlbSize}. + */ + private final ThreadLocal tlb = new ThreadLocal() { + @Override protected ByteBuffer initialValue() { + ByteBuffer buf = ByteBuffer.allocateDirect(tlbSize); + + buf.order(GridUnsafe.NATIVE_BYTE_ORDER); + + return buf; + } + }; + + /** + * @param cctx Context. + * @param fileIO I/O file interface to use. + * @param metrics Data storage metrics. + * @param serializer Serializer. + * @param pos Position. + * @param mode WAL mode. + * @param maxSegmentSize Max segment size. + * @param size Thread local byte buffer size. + * @param fsyncDelay Fsync delay. + * @throws IOException If failed. + */ + FsyncFileWriteHandle( + GridCacheSharedContext cctx, SegmentIO fileIO, + DataStorageMetricsImpl metrics, RecordSerializer serializer, long pos, + WALMode mode, long maxSegmentSize, int size, long fsyncDelay) throws IOException { + super(fileIO); + assert serializer != null; + + this.mode = mode; + tlbSize = size; + this.cctx = cctx; + this.metrics = metrics; + this.log = cctx.logger(FsyncFileWriteHandle.class); + this.fsyncDelay = fsyncDelay; + this.maxSegmentSize = maxSegmentSize; + this.serializer = serializer; + this.written = pos; + this.lastFsyncPos = pos; + + head.set(new FakeRecord(new FileWALPointer(fileIO.getSegmentId(), (int)pos, 0), false)); + + fileIO.position(pos); + } + + /** {@inheritDoc} */ + @Override public int serializerVersion() { + return serializer.version(); + } + + /** {@inheritDoc} */ + @Override public void finishResumeLogging() { + // NOOP. + } + + /** + * Write serializer version to current handle. NOTE: Method mutates {@code fileIO} position, written and + * lastFsyncPos fields. + * + * @throws IgniteCheckedException If fail to write serializer version. + */ + @Override public void writeHeader() throws IgniteCheckedException { + try { + assert fileIO.position() == 0 : "Serializer version can be written only at the begin of file " + + fileIO.position(); + + long updatedPosition = writeSerializerVersion(fileIO, getSegmentId(), + serializer.version(), mode); + + written = updatedPosition; + lastFsyncPos = updatedPosition; + head.set(new FakeRecord(new FileWALPointer(getSegmentId(), (int)updatedPosition, 0), false)); + } + catch (IOException e) { + throw new IgniteCheckedException("Unable to write serializer version for segment " + getSegmentId(), e); + } + } + + /** + * Writes record serializer version to provided {@code io}. NOTE: Method mutates position of {@code io}. + * + * @param io I/O interface for file. + * @param idx Segment index. + * @param version Serializer version. + * @return I/O position after write version. + * @throws IOException If failed to write serializer version. + */ + private static long writeSerializerVersion(FileIO io, long idx, int version, WALMode mode) throws IOException { + ByteBuffer buf = ByteBuffer.allocate(RecordV1Serializer.HEADER_RECORD_SIZE); + buf.order(ByteOrder.nativeOrder()); + + io.writeFully(prepareSerializerVersionBuffer(idx, version, false, buf)); + + // Flush + if (mode == WALMode.FSYNC) + io.force(); + + return io.position(); + } + + /** + * Checks if current head is a close fake record and returns {@code true} if so. + * + * @return {@code true} if current head is close record. + */ + private boolean stopped() { + return stopped(head.get()); + } + + /** + * @param record Record to check. + * @return {@code true} if the record is fake close record. + */ + private boolean stopped(WALRecord record) { + return record instanceof FakeRecord && ((FakeRecord)record).stop; + } + + /** {@inheritDoc} */ + @Nullable @Override public WALPointer addRecord(WALRecord rec) throws StorageException { + assert rec.size() > 0 || rec.getClass() == FakeRecord.class; + + boolean flushed = false; + + for (; ; ) { + WALRecord h = head.get(); + + long nextPos = nextPosition(h); + + if (nextPos + rec.size() >= maxSegmentSize || stopped(h)) { + // Can not write to this segment, need to switch to the next one. + return null; + } + + int newChainSize = h.chainSize() + rec.size(); + + if (newChainSize > tlbSize && !flushed) { + boolean res = h.previous() == null || flush(h, false); + + if (rec.size() > tlbSize) + flushed = res; + + continue; + } + + rec.chainSize(newChainSize); + rec.previous(h); + + FileWALPointer ptr = new FileWALPointer( + getSegmentId(), + (int)nextPos, + rec.size()); + + rec.position(ptr); + + if (head.compareAndSet(h, rec)) + return ptr; + } + } + + /** {@inheritDoc} */ + @Override public void flushAll() throws IgniteCheckedException { + flush(head.get(), false); + } + + /** + * @throws IgniteCheckedException if failed. + */ + public void flushAllOnStop() throws IgniteCheckedException { + flush(head.get(), true); + } + + /** + * @param rec Record. + * @return Position for the next record. + */ + private long nextPosition(WALRecord rec) { + return recordOffset(rec) + rec.size(); + } + + /** + * Gets WAL record offset relative to the WAL segment file beginning. + * + * @param rec WAL record. + * @return File offset. + */ + private static int recordOffset(WALRecord rec) { + FileWALPointer ptr = (FileWALPointer)rec.position(); + + assert ptr != null; + + return ptr.fileOffset(); + } + + /** + * Flush or wait for concurrent flush completion. + * + * @param ptr Pointer. + * @throws StorageException If failed. + */ + private void flushOrWait(FileWALPointer ptr, boolean stop) throws StorageException { + long expWritten; + + if (ptr != null) { + // If requested obsolete file index, it must be already flushed by close. + if (ptr.index() != getSegmentId()) + return; + + expWritten = ptr.fileOffset(); + } + else // We read head position before the flush because otherwise we can get wrong position. + expWritten = recordOffset(head.get()); + + if (flush(ptr, stop)) + return; + else if (stop) { + FakeRecord fr = (FakeRecord)head.get(); + + assert fr.stop : "Invalid fake record on top of the queue: " + fr; + + expWritten = recordOffset(fr); + } + + // Spin-wait for a while before acquiring the lock. + for (int i = 0; i < 64; i++) { + if (written >= expWritten) + return; + } + + // If we did not flush ourselves then await for concurrent flush to complete. + lock.lock(); + + try { + while (written < expWritten && !cctx.kernalContext().invalid()) + U.awaitQuiet(writeComplete); + } + finally { + lock.unlock(); + } + } + + /** + * @param ptr Pointer. + * @return {@code true} If the flush really happened. + * @throws StorageException If failed. + */ + private boolean flush(FileWALPointer ptr, boolean stop) throws StorageException { + if (ptr == null) { // Unconditional flush. + for (; ; ) { + WALRecord expHead = head.get(); + + if (expHead.previous() == null) { + FakeRecord frHead = (FakeRecord)expHead; + + if (frHead.stop == stop || frHead.stop || + head.compareAndSet(expHead, new FakeRecord(frHead.position(), stop))) + return false; + } + + if (flush(expHead, stop)) + return true; + } + } + + assert ptr.index() == getSegmentId(); + + for (; ; ) { + WALRecord h = head.get(); + + // If current chain begin position is greater than requested, then someone else flushed our changes. + if (chainBeginPosition(h) > ptr.fileOffset()) + return false; + + if (flush(h, stop)) + return true; // We are lucky. + } + } + + /** + * @param h Head of the chain. + * @return Chain begin position. + */ + private long chainBeginPosition(WALRecord h) { + return recordOffset(h) + h.size() - h.chainSize(); + } + + /** + * @throws StorageException If node is no longer valid and we missed a WAL operation. + */ + private void checkNode() throws StorageException { + if (cctx.kernalContext().invalid()) + throw new StorageException("Failed to perform WAL operation (environment was invalidated by a " + + "previous error)"); + } + + /** + * @param expHead Expected head of chain. If head was changed, flush is not performed in this thread + * @throws StorageException If failed. + */ + private boolean flush(WALRecord expHead, boolean stop) throws StorageException { + if (expHead.previous() == null) { + FakeRecord frHead = (FakeRecord)expHead; + + if (!stop || frHead.stop) // Protects from CASing terminal FakeRecord(true) to FakeRecord(false) + return false; + } + + // Fail-fast before CAS. + checkNode(); + + if (!head.compareAndSet(expHead, new FakeRecord(new FileWALPointer(getSegmentId(), (int)nextPosition(expHead), 0), stop))) + return false; + + if (expHead.chainSize() == 0) + return false; + + // At this point we grabbed the piece of WAL chain. + // Any failure in this code must invalidate the environment. + try { + // We can safely allow other threads to start building next chains while we are doing flush here. + ByteBuffer buf; + + boolean tmpBuf = false; + + if (expHead.chainSize() > tlbSize) { + buf = GridUnsafe.allocateBuffer(expHead.chainSize()); + + tmpBuf = true; // We need to manually release this temporary direct buffer. + } + else + buf = tlb.get(); + + try { + long pos = fillBuffer(buf, expHead); + + writeBuffer(pos, buf); + } + finally { + if (tmpBuf) + GridUnsafe.freeBuffer(buf); + } + + return true; + } + catch (Throwable e) { + StorageException se = e instanceof StorageException ? (StorageException)e : + new StorageException("Unable to write", new IOException(e)); + + cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, se)); + + // All workers waiting for a next segment must be woken up and stopped + signalNextAvailable(); + + throw se; + } + } + + /** + * Serializes WAL records chain to provided byte buffer. + * + * @param buf Buffer, will be filled with records chain from end to beginning. + * @param head Head of the chain to write to the buffer. + * @return Position in file for this buffer. + * @throws IgniteCheckedException If failed. + */ + private long fillBuffer(ByteBuffer buf, WALRecord head) throws IgniteCheckedException { + final int limit = head.chainSize(); + + assert limit <= buf.capacity(); + + buf.rewind(); + buf.limit(limit); + + do { + buf.position(head.chainSize() - head.size()); + buf.limit(head.chainSize()); // Just to make sure that serializer works in bounds. + + try { + serializer.writeRecord(head, buf); + } + catch (RuntimeException e) { + throw new IllegalStateException("Failed to write record: " + head, e); + } + + assert !buf.hasRemaining() : "Reported record size is greater than actual: " + head; + + head = head.previous(); + } + while (head.previous() != null); + + assert head instanceof FakeRecord : head.getClass(); + + buf.rewind(); + buf.limit(limit); + + return recordOffset(head); + } + + /** + * Non-blocking check if this pointer needs to be sync'ed. + * + * @param ptr WAL pointer to check. + * @return {@code False} if this pointer has been already sync'ed. + */ + @Override public boolean needFsync(FileWALPointer ptr) { + // If index has changed, it means that the log was rolled over and already sync'ed. + // If requested position is smaller than last sync'ed, it also means all is good. + // If position is equal, then our record is the last not synced. + return getSegmentId() == ptr.index() && lastFsyncPos <= ptr.fileOffset(); + } + + /** {@inheritDoc} */ + @Override public FileWALPointer position() { + lock.lock(); + + try { + return new FileWALPointer(getSegmentId(), (int)written, 0); + } + finally { + lock.unlock(); + } + } + + /** {@inheritDoc} */ + @Override public void fsync(FileWALPointer ptr) throws StorageException, IgniteCheckedException { + fsync(ptr, false); + } + + /** {@inheritDoc} */ + @Override public void closeBuffer() { + //NOOP. + } + + /** + * @param ptr Pointer to sync. + * @throws StorageException If failed. + * @throws IgniteInterruptedCheckedException If interrupted. + */ + protected void fsync(FileWALPointer ptr, boolean stop) throws StorageException, IgniteInterruptedCheckedException { + lock.lock(); + + try { + if (ptr != null) { + if (!needFsync(ptr)) + return; + + if (fsyncDelay > 0 && !stopped()) { + // Delay fsync to collect as many updates as possible: trade latency for throughput. + U.await(fsync, fsyncDelay, TimeUnit.NANOSECONDS); + + if (!needFsync(ptr)) + return; + } + } + + flushOrWait(ptr, stop); + + if (stopped()) + return; + + if (lastFsyncPos != written) { + assert lastFsyncPos < written; // Fsync position must be behind. + + boolean metricsEnabled = metrics.metricsEnabled(); + + long start = metricsEnabled ? System.nanoTime() : 0; + + try { + fileIO.force(); + } + catch (IOException e) { + throw new StorageException(e); + } + + lastFsyncPos = written; + + if (fsyncDelay > 0) + fsync.signalAll(); + + long end = metricsEnabled ? System.nanoTime() : 0; + + if (metricsEnabled) + metrics.onFsync(end - start); + } + } + finally { + lock.unlock(); + } + } + + /** + * @return {@code true} If this thread actually closed the segment. + * @throws StorageException If failed. + */ + @Override public boolean close(boolean rollOver) throws StorageException { + if (stop.compareAndSet(false, true)) { + lock.lock(); + + try { + flushOrWait(null, true); + + assert stopped() : "Segment is not closed after close flush: " + head.get(); + + try { + try { + RecordSerializer backwardSerializer = new RecordSerializerFactoryImpl(cctx) + .createSerializer(serializerVersion); + + SwitchSegmentRecord segmentRecord = new SwitchSegmentRecord(); + + int switchSegmentRecSize = backwardSerializer.size(segmentRecord); + + if (rollOver && written < (maxSegmentSize - switchSegmentRecSize)) { + final ByteBuffer buf = ByteBuffer.allocate(switchSegmentRecSize); + + segmentRecord.position(new FileWALPointer(getSegmentId(), (int)written, switchSegmentRecSize)); + backwardSerializer.writeRecord(segmentRecord, buf); + + buf.rewind(); + + written += fileIO.writeFully(buf, written); + } + } + catch (IgniteCheckedException e) { + throw new IOException(e); + } + finally { + assert mode == WALMode.FSYNC; + + // Do the final fsync. + fileIO.force(); + + lastFsyncPos = written; + + fileIO.close(); + } + } + catch (IOException e) { + throw new StorageException("Failed to close WAL write handle [idx=" + getSegmentId() + "]", e); + } + + if (log.isDebugEnabled()) + log.debug("Closed WAL write handle [idx=" + getSegmentId() + "]"); + + return true; + } + finally { + lock.unlock(); + } + } + else + return false; + } + + /** {@inheritDoc} */ + @Override public void signalNextAvailable() { + lock.lock(); + + try { + WALRecord rec = head.get(); + + if (!cctx.kernalContext().invalid()) { + assert rec instanceof FakeRecord : "Expected head FakeRecord, actual head " + + (rec != null ? rec.getClass().getSimpleName() : "null"); + + assert written == lastFsyncPos || mode != WALMode.FSYNC : + "fsync [written=" + written + ", lastFsync=" + lastFsyncPos + ']'; + + fileIO = null; + } + else { + try { + fileIO.close(); + } + catch (IOException e) { + U.error(log, "Failed to close WAL file [idx=" + getSegmentId() + ", fileIO=" + fileIO + "]", e); + } + } + + nextSegment.signalAll(); + } + finally { + lock.unlock(); + } + } + + /** {@inheritDoc} */ + @Override public void awaitNext() { + lock.lock(); + + try { + while (fileIO != null && !cctx.kernalContext().invalid()) + U.awaitQuiet(nextSegment); + } + finally { + lock.unlock(); + } + } + + /** + * @param pos Position in file to start write from. May be checked against actual position to wait previous writes + * to complete. + * @param buf Buffer to write to file. + * @throws StorageException If failed. + */ + @SuppressWarnings("TooBroadScope") + private void writeBuffer(long pos, ByteBuffer buf) throws StorageException { + boolean interrupted = false; + + lock.lock(); + + try { + assert fileIO != null : "Writing to a closed segment."; + + checkNode(); + + long lastLogged = U.currentTimeMillis(); + + long logBackoff = 2_000; + + // If we were too fast, need to wait previous writes to complete. + while (written != pos) { + assert written < pos : "written = " + written + ", pos = " + pos; // No one can write further than we are now. + + // Permutation occurred between blocks write operations. + // Order of acquiring lock is not the same as order of write. + long now = U.currentTimeMillis(); + + if (now - lastLogged >= logBackoff) { + if (logBackoff < 60 * 60_000) + logBackoff *= 2; + + U.warn(log, "Still waiting for a concurrent write to complete [written=" + written + + ", pos=" + pos + ", lastFsyncPos=" + lastFsyncPos + ", stop=" + stop.get() + + ", actualPos=" + safePosition() + ']'); + + lastLogged = now; + } + + try { + writeComplete.await(2, TimeUnit.SECONDS); + } + catch (InterruptedException ignore) { + interrupted = true; + } + + checkNode(); + } + + // Do the write. + int size = buf.remaining(); + + assert size > 0 : size; + + try { + assert written == fileIO.position(); + + fileIO.writeFully(buf); + + written += size; + + metrics.onWalBytesWritten(size); + + assert written == fileIO.position(); + } + catch (IOException e) { + StorageException se = new StorageException("Unable to write", e); + + cctx.kernalContext().failure().process(new FailureContext(CRITICAL_ERROR, se)); + + throw se; + } + } + finally { + writeComplete.signalAll(); + + lock.unlock(); + + if (interrupted) + Thread.currentThread().interrupt(); + } + } + + /** + * @return Safely reads current position of the file channel as String. Will return "null" if channel is null. + */ + public String safePosition() { + FileIO io = this.fileIO; + + if (io == null) + return "null"; + + try { + return String.valueOf(io.position()); + } + catch (IOException e) { + return "{Failed to read channel position: " + e.getMessage() + "}"; + } + } + + /** + * Fake record is zero-sized record, which is not stored into file. Fake record is used for storing position in file + * {@link WALRecord#position()}. Fake record is allowed to have no previous record. + */ + private static final class FakeRecord extends WALRecord { + /** */ + private final boolean stop; + + /** + * @param pos Position. + */ + FakeRecord(FileWALPointer pos, boolean stop) { + position(pos); + + this.stop = stop; + } + + /** {@inheritDoc} */ + @Override public RecordType type() { + return null; + } + + /** {@inheritDoc} */ + @Override public FileWALPointer position() { + return (FileWALPointer)super.position(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(FakeRecord.class, this, "super", super.toString()); + } + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/io/FileInput.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/io/FileInput.java index d19d17b3c7d7f..c9615f597e0f7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/io/FileInput.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/io/FileInput.java @@ -19,10 +19,12 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.util.zip.CRC32; + import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; import org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferBackedDataInput; +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc; import org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException; -import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; import org.jetbrains.annotations.NotNull; /** @@ -56,7 +58,7 @@ public interface FileInput extends ByteBufferBackedDataInput { */ public class Crc32CheckingFileInput implements ByteBufferBackedDataInput, AutoCloseable { /** */ - private final PureJavaCrc32 crc32 = new PureJavaCrc32(); + private final FastCrc crc = new FastCrc(); /** Last calc position. */ private int lastCalcPosition; @@ -93,7 +95,7 @@ public Crc32CheckingFileInput(FileInput delegate, boolean skipCheck) { @Override public void close() throws Exception { updateCrc(); - int val = crc32.getValue(); + int val = crc.getValue(); int writtenCrc = this.readInt(); @@ -118,7 +120,7 @@ private void updateCrc() { buffer().position(lastCalcPosition); - crc32.update(delegate.buffer(), oldPos - lastCalcPosition); + crc.update(delegate.buffer(), oldPos - lastCalcPosition); lastCalcPosition = oldPos; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/io/SimpleFileInput.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/io/SimpleFileInput.java index 5918b0b34e93e..1a1562e0909e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/io/SimpleFileInput.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/io/SimpleFileInput.java @@ -20,6 +20,7 @@ import java.io.EOFException; import java.io.IOException; import java.nio.ByteBuffer; + import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; import org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferExpander; import org.jetbrains.annotations.NotNull; @@ -264,7 +265,7 @@ private void clearBuffer() { /** * @param skipCheck If CRC check should be skipped. - * @return autoclosable fileInput, after its closing crc32 will be calculated and compared with saved one + * @return autoclosable fileInput, after its closing crc will be calculated and compared with saved one */ public Crc32CheckingFileInput startRead(boolean skipCheck) { return new Crc32CheckingFileInput(this, skipCheck); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java index 4ea1828e6c189..6e5759dd88f5e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java @@ -174,14 +174,16 @@ public WALIterator iterator( iteratorParametersBuilder.validate(); return new StandaloneWalRecordsIterator(log, - prepareSharedCtx(iteratorParametersBuilder), + iteratorParametersBuilder.sharedCtx == null ? prepareSharedCtx(iteratorParametersBuilder) : + iteratorParametersBuilder.sharedCtx, iteratorParametersBuilder.ioFactory, resolveWalFiles(iteratorParametersBuilder), iteratorParametersBuilder.filter, iteratorParametersBuilder.lowBound, iteratorParametersBuilder.highBound, iteratorParametersBuilder.keepBinary, - iteratorParametersBuilder.bufferSize + iteratorParametersBuilder.bufferSize, + iteratorParametersBuilder.strictBoundsCheck ); } @@ -409,6 +411,14 @@ public static class IteratorParametersBuilder { */ @Nullable private File marshallerMappingFileStoreDir; + /** + * Cache shared context. In case context is specified binary objects converting and unmarshalling will be + * performed using processors of this shared context. + *
This field can't be specified together with {@link #binaryMetadataFileStoreDir} or + * {@link #marshallerMappingFileStoreDir} fields. + * */ + @Nullable private GridCacheSharedContext sharedCtx; + /** */ @Nullable private IgniteBiPredicate filter; @@ -418,6 +428,9 @@ public static class IteratorParametersBuilder { /** */ private FileWALPointer highBound = DFLT_HIGH_BOUND; + /** Use strict bounds check for WAL segments. */ + private boolean strictBoundsCheck; + /** * @param filesOrDirs Paths to files or directories. * @return IteratorParametersBuilder Self reference. @@ -504,6 +517,16 @@ public IteratorParametersBuilder marshallerMappingFileStoreDir(File marshallerMa return this; } + /** + * @param sharedCtx Cache shared context. + * @return IteratorParametersBuilder Self reference. + */ + public IteratorParametersBuilder sharedContext(GridCacheSharedContext sharedCtx) { + this.sharedCtx = sharedCtx; + + return this; + } + /** * @param filter Record filter for skip records during iteration. * @return IteratorParametersBuilder Self reference. @@ -534,6 +557,16 @@ public IteratorParametersBuilder to(FileWALPointer highBound) { return this; } + /** + * @param flag Use strict check. + * @return IteratorParametersBuilder Self reference. + */ + public IteratorParametersBuilder strictBoundsCheck(boolean flag) { + this.strictBoundsCheck = flag; + + return this; + } + /** * Copy current state of builder to new instance. * @@ -548,9 +581,11 @@ public IteratorParametersBuilder copy() { .ioFactory(ioFactory) .binaryMetadataFileStoreDir(binaryMetadataFileStoreDir) .marshallerMappingFileStoreDir(marshallerMappingFileStoreDir) + .sharedContext(sharedCtx) .from(lowBound) .to(highBound) - .filter(filter); + .filter(filter) + .strictBoundsCheck(strictBoundsCheck); } /** @@ -561,6 +596,10 @@ public void validate() throws IllegalArgumentException { A.ensure(U.isPow2(pageSize), "Page size must be a power of 2."); A.ensure(bufferSize >= pageSize * 2, "Buffer to small."); + + A.ensure(sharedCtx == null || (binaryMetadataFileStoreDir == null && + marshallerMappingFileStoreDir == null), "GridCacheSharedContext and binaryMetadataFileStoreDir/" + + "marshallerMappingFileStoreDir can't be specified in the same time"); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java index 6d379a9381b15..e70a02709f4f8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneGridKernalContext.java @@ -652,6 +652,11 @@ protected IgniteConfiguration prepareIgniteConfiguration() { return null; } + /** {@inheritDoc} */ + @Override public boolean recoveryMode() { + return false; + } + /** {@inheritDoc} */ @Override public PdsFoldersResolver pdsFolderResolver() { return new PdsFoldersResolver() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java index 21383b39e6557..56a44cd8ad4e3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java @@ -17,11 +17,11 @@ package org.apache.ignite.internal.processors.cache.persistence.wal.reader; -import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.GridKernalContext; @@ -29,7 +29,7 @@ import org.apache.ignite.internal.pagemem.wal.record.DataEntry; import org.apache.ignite.internal.pagemem.wal.record.DataRecord; import org.apache.ignite.internal.pagemem.wal.record.FilteredRecord; -import org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry; +import org.apache.ignite.internal.pagemem.wal.record.MarshalledDataEntry; import org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry; import org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord; import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry; @@ -119,7 +119,8 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator { FileWALPointer lowBound, FileWALPointer highBound, boolean keepBinary, - int initialReadBufferSize + int initialReadBufferSize, + boolean strictBoundsCheck ) throws IgniteCheckedException { super( log, @@ -130,6 +131,9 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator { FILE_INPUT_FACTORY ); + if (strictBoundsCheck) + strictCheck(walFiles, lowBound, highBound); + this.lowBound = lowBound; this.highBound = highBound; @@ -142,6 +146,55 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator { advance(); } + /** + * @param walFiles Wal files. + * @return printable indexes of segment files. + */ + private static String printIndexes(List walFiles) { + return "[" + String.join(",", walFiles.stream().map(f -> Long.toString(f.idx())).collect(Collectors.toList())) + "]"; + } + + /** + * @param walFiles Wal files. + * @param lowBound Low bound. + * @param highBound High bound. + * + * @throws IgniteCheckedException if failed + */ + private static void strictCheck(List walFiles, FileWALPointer lowBound, FileWALPointer highBound) throws IgniteCheckedException { + int idx = 0; + + if (lowBound.index() > Long.MIN_VALUE) { + for (; idx < walFiles.size(); idx++) { + FileDescriptor desc = walFiles.get(idx); + + assert desc != null; + + if (desc.idx() == lowBound.index()) + break; + } + } + + if (idx == walFiles.size()) + throw new StrictBoundsCheckException("Wal segments not in bounds. loBoundIndex=" + lowBound.index() + + ", indexes=" + printIndexes(walFiles)); + + long curWalSegmIdx = walFiles.get(idx).idx(); + + for (; idx < walFiles.size() && curWalSegmIdx <= highBound.index(); idx++, curWalSegmIdx++) { + FileDescriptor desc = walFiles.get(idx); + + assert desc != null; + + if (curWalSegmIdx != desc.idx()) + throw new StrictBoundsCheckException("Wal segment " + curWalSegmIdx + " not found in files " + printIndexes(walFiles)); + } + + if (highBound.index() < Long.MAX_VALUE && curWalSegmIdx <= highBound.index()) + throw new StrictBoundsCheckException("Wal segments not in bounds. hiBoundIndex=" + highBound.index() + + ", indexes=" + printIndexes(walFiles)); + } + /** * For directory mode sets oldest file as initial segment, for file by file mode, converts all files to descriptors * and gets oldest as initial. @@ -381,16 +434,15 @@ private boolean checkBounds(long idx) { final IgniteCacheObjectProcessor processor, final CacheObjectContext fakeCacheObjCtx, final DataEntry dataEntry) throws IgniteCheckedException { - if(dataEntry instanceof EncryptedDataEntry) + if (dataEntry instanceof EncryptedDataEntry) return dataEntry; final KeyCacheObject key; final CacheObject val; - final File marshallerMappingFileStoreDir = - fakeCacheObjCtx.kernalContext().marshallerContext().getMarshallerMappingFileStoreDir(); + boolean keepBinary = this.keepBinary || !fakeCacheObjCtx.kernalContext().marshallerContext().initialized(); - if (dataEntry instanceof LazyDataEntry) { - final LazyDataEntry lazyDataEntry = (LazyDataEntry)dataEntry; + if (dataEntry instanceof MarshalledDataEntry) { + final MarshalledDataEntry lazyDataEntry = (MarshalledDataEntry)dataEntry; key = processor.toKeyCacheObject(fakeCacheObjCtx, lazyDataEntry.getKeyType(), @@ -408,7 +460,7 @@ private boolean checkBounds(long idx) { val = dataEntry.value(); } - return unwrapDataEntry(fakeCacheObjCtx, dataEntry, key, val, marshallerMappingFileStoreDir); + return unwrapDataEntry(fakeCacheObjCtx, dataEntry, key, val, keepBinary); } /** @@ -417,11 +469,11 @@ private boolean checkBounds(long idx) { * @param dataEntry Data entry. * @param key Entry key. * @param val Entry value. - * @param marshallerMappingFileStoreDir Marshaller directory. + * @param keepBinary Don't convert non primitive types. * @return Unwrapped entry. */ - private @NotNull DataEntry unwrapDataEntry(CacheObjectContext coCtx, DataEntry dataEntry, - KeyCacheObject key, CacheObject val, File marshallerMappingFileStoreDir) { + private DataEntry unwrapDataEntry(CacheObjectContext coCtx, DataEntry dataEntry, + KeyCacheObject key, CacheObject val, boolean keepBinary) { if (dataEntry instanceof MvccDataEntry) return new UnwrapMvccDataEntry( dataEntry.cacheId(), @@ -435,7 +487,7 @@ private boolean checkBounds(long idx) { dataEntry.partitionCounter(), ((MvccDataEntry)dataEntry).mvccVer(), coCtx, - keepBinary || marshallerMappingFileStoreDir == null); + keepBinary); else return new UnwrapDataEntry( dataEntry.cacheId(), @@ -448,7 +500,7 @@ private boolean checkBounds(long idx) { dataEntry.partitionId(), dataEntry.partitionCounter(), coCtx, - keepBinary || marshallerMappingFileStoreDir == null); + keepBinary); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java new file mode 100644 index 0000000000000..89d54eb1a2e28 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java @@ -0,0 +1,35 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.wal.reader; + +import org.apache.ignite.IgniteCheckedException; + +/** + * This exception is used in checking boundaries (StandaloneWalRecordsIterator). + */ +public class StrictBoundsCheckException extends IgniteCheckedException { + /** */ + private static final long serialVersionUID = 0L; + + /** + * @param mesg Message. + */ + public StrictBoundsCheckException(String mesg) { + super(mesg); + } +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordDataV1Serializer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordDataV1Serializer.java index a80266587f344..604b643e7c5d0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordDataV1Serializer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordDataV1Serializer.java @@ -145,6 +145,9 @@ public class RecordDataV1Serializer implements RecordDataSerializer { /** Encryption manager. */ private final GridEncryptionManager encMgr; + /** */ + private final boolean encryptionDisabled; + /** */ private static final byte ENCRYPTED = 1; @@ -162,6 +165,8 @@ public RecordDataV1Serializer(GridCacheSharedContext cctx) { this.encSpi = cctx.gridConfig().getEncryptionSpi(); this.encMgr = cctx.kernalContext().encryption(); + encryptionDisabled = encSpi instanceof NoopEncryptionSpi; + //This happen on offline WAL iteration(we don't have encryption keys available). if (encSpi != null) this.realPageSize = CU.encryptedPageSize(pageSize, encSpi); @@ -227,7 +232,7 @@ public RecordDataV1Serializer(GridCacheSharedContext cctx) { * @return {@code True} if this record should be encrypted. */ private boolean needEncryption(WALRecord rec) { - if (encSpi instanceof NoopEncryptionSpi) + if (encryptionDisabled) return false; if (!(rec instanceof WalRecordCacheGroupAware)) @@ -241,10 +246,10 @@ private boolean needEncryption(WALRecord rec) { * @return {@code True} if this record should be encrypted. */ private boolean needEncryption(int grpId) { - if (encSpi instanceof NoopEncryptionSpi) + if (encryptionDisabled) return false; - return encMgr.groupKey(grpId) != null; + return encMgr != null && encMgr.groupKey(grpId) != null; } /** @@ -551,7 +556,7 @@ WALRecord readPlainRecord(RecordType type, ByteBufferBackedDataInput in, long msb = in.readLong(); long lsb = in.readLong(); boolean hasPtr = in.readByte() != 0; - int idx = hasPtr ? in.readInt() : 0; + long idx = hasPtr ? in.readLong() : 0; int off = hasPtr ? in.readInt() : 0; int len = hasPtr ? in.readInt() : 0; @@ -1922,6 +1927,9 @@ DataEntry readPlainDataEntry(ByteBufferBackedDataInput in) throws IOException, I * @return Real record type. */ RecordType recordType(WALRecord rec) { + if (encryptionDisabled) + return rec.type(); + if (needEncryption(rec)) return ENCRYPTED_RECORD; @@ -1936,8 +1944,11 @@ RecordType recordType(WALRecord rec) { * @return {@code True} if this data record should be encrypted. */ boolean isDataRecordEncrypted(DataRecord rec) { + if (encryptionDisabled) + return false; + for (DataEntry e : rec.writeEntries()) { - if(needEncryption(cctx.cacheContext(e.cacheId()).groupId())) + if (cctx.cacheContext(e.cacheId()) != null && needEncryption(cctx.cacheContext(e.cacheId()).groupId())) return true; } @@ -2013,7 +2024,7 @@ protected int dataSize(DataRecord dataRec) throws IgniteCheckedException { for (DataEntry entry : dataRec.writeEntries()) { int clSz = entrySize(entry); - if (needEncryption(cctx.cacheContext(entry.cacheId()).groupId())) + if (!encryptionDisabled && needEncryption(cctx.cacheContext(entry.cacheId()).groupId())) sz += encSpi.encryptedSize(clSz) + 1 /* encrypted flag */ + 4 /* groupId */ + 4 /* data size */; else { sz += clSz; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordDataV2Serializer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordDataV2Serializer.java index dd25b8cca4049..aaf3cb77720e9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordDataV2Serializer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordDataV2Serializer.java @@ -55,7 +55,7 @@ /** * Record data V2 serializer. */ -public class RecordDataV2Serializer extends RecordDataV1Serializer implements RecordDataSerializer { +public class RecordDataV2Serializer extends RecordDataV1Serializer { /** Length of HEADER record data. */ private static final int HEADER_RECORD_DATA_SIZE = /*Magic*/8 + /*Version*/4; @@ -125,7 +125,7 @@ public RecordDataV2Serializer(GridCacheSharedContext cctx) { long msb = in.readLong(); long lsb = in.readLong(); boolean hasPtr = in.readByte() != 0; - int idx0 = hasPtr ? in.readInt() : 0; + long idx0 = hasPtr ? in.readLong() : 0; int off = hasPtr ? in.readInt() : 0; int len = hasPtr ? in.readInt() : 0; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordSerializerFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordSerializerFactory.java index f46c315426516..afc4e9462219c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordSerializerFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordSerializerFactory.java @@ -28,6 +28,8 @@ * Factory for creating {@link RecordSerializer}. */ public interface RecordSerializerFactory { + /** Latest serializer version to use. */ + static final int LATEST_SERIALIZER_VERSION = 2; /** * Factory method for creation {@link RecordSerializer}. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordSerializerFactoryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordSerializerFactoryImpl.java index c149817299f25..96b78e664cc83 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordSerializerFactoryImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordSerializerFactoryImpl.java @@ -22,6 +22,7 @@ import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.lang.IgniteBiPredicate; +import org.jetbrains.annotations.Nullable; /** * @@ -34,7 +35,7 @@ public class RecordSerializerFactoryImpl implements RecordSerializerFactory { private boolean needWritePointer; /** Read record filter. */ - private IgniteBiPredicate recordDeserializeFilter; + private @Nullable IgniteBiPredicate recordDeserializeFilter; /** * Marshalled mode flag. @@ -56,7 +57,7 @@ public RecordSerializerFactoryImpl(GridCacheSharedContext cctx) { */ public RecordSerializerFactoryImpl( GridCacheSharedContext cctx, - IgniteBiPredicate readTypeFilter + @Nullable IgniteBiPredicate readTypeFilter ) { this.cctx = cctx; this.recordDeserializeFilter = readTypeFilter; @@ -114,7 +115,7 @@ public IgniteBiPredicate recordDeserializeFilt /** {@inheritDoc} */ @Override public RecordSerializerFactoryImpl recordDeserializeFilter( - IgniteBiPredicate readTypeFilter + @Nullable IgniteBiPredicate readTypeFilter ) { this.recordDeserializeFilter = readTypeFilter; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java index c65f37cc8d648..fa32c87709ee7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV1Serializer.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; + import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.internal.pagemem.wal.WALPointer; @@ -32,6 +33,7 @@ import org.apache.ignite.internal.processors.cache.persistence.tree.io.CacheVersionIO; import org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferBackedDataInput; import org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferExpander; +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc; import org.apache.ignite.internal.processors.cache.persistence.wal.io.FileInput; import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentFileInputFactory; import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer; @@ -39,7 +41,6 @@ import org.apache.ignite.internal.processors.cache.persistence.wal.io.SegmentIO; import org.apache.ignite.internal.processors.cache.persistence.wal.io.SimpleFileInput; import org.apache.ignite.internal.processors.cache.persistence.wal.WalSegmentTailReachedException; -import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; import org.apache.ignite.internal.processors.cache.persistence.wal.record.HeaderRecord; import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.io.RecordIO; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; @@ -143,7 +144,8 @@ public class RecordV1Serializer implements RecordSerializer { rec.position(ptr); - if (recordFilter != null && !recordFilter.apply(rec.type(), ptr)) + if (recType.purpose() != WALRecord.RecordPurpose.INTERNAL + && recordFilter != null && !recordFilter.apply(rec.type(), ptr)) return FilteredRecord.INSTANCE; else if (marshalledMode) { ByteBuffer buf = heapTlb.get(); @@ -421,7 +423,7 @@ static void writeWithCrc(WALRecord rec, ByteBuffer buf, RecordIO writer) throws buf.position(startPos); // This call will move buffer position to the end of the record again. - int crcVal = PureJavaCrc32.calcCrc32(buf, curPos - startPos); + int crcVal = FastCrc.calcCrc(buf, curPos - startPos); buf.putInt(crcVal); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV2Serializer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV2Serializer.java index d27a331141e32..0d78d08291bc7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV2Serializer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/serializer/RecordV2Serializer.java @@ -122,7 +122,8 @@ public class RecordV2Serializer implements RecordSerializer { ", expected pointer [idx=" + exp.index() + ", offset=" + exp.fileOffset() + "]"); } - if (recordFilter != null && !recordFilter.apply(recType, ptr)) { + if (recType.purpose() != WALRecord.RecordPurpose.INTERNAL + && recordFilter != null && !recordFilter.apply(recType, ptr)) { int toSkip = ptr.length() - REC_TYPE_SIZE - FILE_WAL_POINTER_SIZE - CRC_SIZE; assert toSkip >= 0 : "Too small saved record length: " + ptr; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java index 6134bd47546e5..e723bdcba5c46 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java @@ -172,7 +172,7 @@ public abstract class GridCacheQueryManager extends GridCacheManagerAdapte GridCacheQueryDetailMetricsAdapter> QRY_DETAIL_METRICS_MERGE_FX = GridCacheQueryDetailMetricsAdapter::aggregate; - /** Default is @{code true} */ + /** */ private final boolean isIndexingSpiAllowsBinary = !IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_UNWRAP_BINARY_FOR_INDEXING_SPI); /** */ @@ -3011,7 +3011,7 @@ private void advance() { val = entry.peek(true, true, topVer, expiryPlc); - entry.touch(topVer); + entry.touch(); break; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index b7205b6e17bbb..21c636334e121 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -513,128 +513,128 @@ public int taskHash() { } switch (writer.state()) { - case 3: - if (!writer.writeBoolean("all", all)) - return false; - - writer.incrementState(); - case 4: - if (!writer.writeByteArray("argsBytes", argsBytes)) + if (!writer.writeBoolean("all", all)) return false; writer.incrementState(); case 5: - if (!writer.writeString("cacheName", cacheName)) + if (!writer.writeByteArray("argsBytes", argsBytes)) return false; writer.incrementState(); case 6: - if (!writer.writeBoolean("cancel", cancel)) + if (!writer.writeString("cacheName", cacheName)) return false; writer.incrementState(); case 7: - if (!writer.writeString("clause", clause)) + if (!writer.writeBoolean("cancel", cancel)) return false; writer.incrementState(); case 8: - if (!writer.writeString("clsName", clsName)) + if (!writer.writeString("clause", clause)) return false; writer.incrementState(); case 9: - if (!writer.writeBoolean("fields", fields)) + if (!writer.writeString("clsName", clsName)) return false; writer.incrementState(); case 10: - if (!writer.writeLong("id", id)) + if (!writer.writeBoolean("fields", fields)) return false; writer.incrementState(); case 11: - if (!writer.writeBoolean("incBackups", incBackups)) + if (!writer.writeLong("id", id)) return false; writer.incrementState(); case 12: - if (!writer.writeBoolean("incMeta", incMeta)) + if (!writer.writeBoolean("incBackups", incBackups)) return false; writer.incrementState(); case 13: - if (!writer.writeBoolean("keepBinary", keepBinary)) + if (!writer.writeBoolean("incMeta", incMeta)) return false; writer.incrementState(); case 14: - if (!writer.writeByteArray("keyValFilterBytes", keyValFilterBytes)) + if (!writer.writeBoolean("keepBinary", keepBinary)) return false; writer.incrementState(); case 15: - if (!writer.writeInt("pageSize", pageSize)) + if (!writer.writeByteArray("keyValFilterBytes", keyValFilterBytes)) return false; writer.incrementState(); case 16: - if (!writer.writeInt("part", part)) + if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) return false; writer.incrementState(); case 17: - if (!writer.writeByteArray("rdcBytes", rdcBytes)) + if (!writer.writeInt("pageSize", pageSize)) return false; writer.incrementState(); case 18: - if (!writer.writeUuid("subjId", subjId)) + if (!writer.writeInt("part", part)) return false; writer.incrementState(); case 19: - if (!writer.writeInt("taskHash", taskHash)) + if (!writer.writeByteArray("rdcBytes", rdcBytes)) return false; writer.incrementState(); case 20: - if (!writer.writeMessage("topVer", topVer)) + if (!writer.writeUuid("subjId", subjId)) return false; writer.incrementState(); case 21: - if (!writer.writeByteArray("transBytes", transBytes)) + if (!writer.writeInt("taskHash", taskHash)) return false; writer.incrementState(); case 22: - if (!writer.writeByte("type", type != null ? (byte)type.ordinal() : -1)) + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); case 23: - if (!writer.writeMessage("mvccSnapshot", mvccSnapshot)) + if (!writer.writeByteArray("transBytes", transBytes)) + return false; + + writer.incrementState(); + + case 24: + if (!writer.writeByte("type", type != null ? (byte)type.ordinal() : -1)) return false; writer.incrementState(); @@ -655,7 +655,7 @@ public int taskHash() { return false; switch (reader.state()) { - case 3: + case 4: all = reader.readBoolean("all"); if (!reader.isLastRead()) @@ -663,7 +663,7 @@ public int taskHash() { reader.incrementState(); - case 4: + case 5: argsBytes = reader.readByteArray("argsBytes"); if (!reader.isLastRead()) @@ -671,7 +671,7 @@ public int taskHash() { reader.incrementState(); - case 5: + case 6: cacheName = reader.readString("cacheName"); if (!reader.isLastRead()) @@ -679,7 +679,7 @@ public int taskHash() { reader.incrementState(); - case 6: + case 7: cancel = reader.readBoolean("cancel"); if (!reader.isLastRead()) @@ -687,7 +687,7 @@ public int taskHash() { reader.incrementState(); - case 7: + case 8: clause = reader.readString("clause"); if (!reader.isLastRead()) @@ -695,7 +695,7 @@ public int taskHash() { reader.incrementState(); - case 8: + case 9: clsName = reader.readString("clsName"); if (!reader.isLastRead()) @@ -703,7 +703,7 @@ public int taskHash() { reader.incrementState(); - case 9: + case 10: fields = reader.readBoolean("fields"); if (!reader.isLastRead()) @@ -711,7 +711,7 @@ public int taskHash() { reader.incrementState(); - case 10: + case 11: id = reader.readLong("id"); if (!reader.isLastRead()) @@ -719,7 +719,7 @@ public int taskHash() { reader.incrementState(); - case 11: + case 12: incBackups = reader.readBoolean("incBackups"); if (!reader.isLastRead()) @@ -727,7 +727,7 @@ public int taskHash() { reader.incrementState(); - case 12: + case 13: incMeta = reader.readBoolean("incMeta"); if (!reader.isLastRead()) @@ -735,7 +735,7 @@ public int taskHash() { reader.incrementState(); - case 13: + case 14: keepBinary = reader.readBoolean("keepBinary"); if (!reader.isLastRead()) @@ -743,7 +743,7 @@ public int taskHash() { reader.incrementState(); - case 14: + case 15: keyValFilterBytes = reader.readByteArray("keyValFilterBytes"); if (!reader.isLastRead()) @@ -751,7 +751,15 @@ public int taskHash() { reader.incrementState(); - case 15: + case 16: + mvccSnapshot = reader.readMessage("mvccSnapshot"); + + if (!reader.isLastRead()) + return false; + + reader.incrementState(); + + case 17: pageSize = reader.readInt("pageSize"); if (!reader.isLastRead()) @@ -759,7 +767,7 @@ public int taskHash() { reader.incrementState(); - case 16: + case 18: part = reader.readInt("part"); if (!reader.isLastRead()) @@ -767,7 +775,7 @@ public int taskHash() { reader.incrementState(); - case 17: + case 19: rdcBytes = reader.readByteArray("rdcBytes"); if (!reader.isLastRead()) @@ -775,7 +783,7 @@ public int taskHash() { reader.incrementState(); - case 18: + case 20: subjId = reader.readUuid("subjId"); if (!reader.isLastRead()) @@ -783,7 +791,7 @@ public int taskHash() { reader.incrementState(); - case 19: + case 21: taskHash = reader.readInt("taskHash"); if (!reader.isLastRead()) @@ -791,15 +799,15 @@ public int taskHash() { reader.incrementState(); - case 20: - topVer = reader.readMessage("topVer"); + case 22: + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; reader.incrementState(); - case 21: + case 23: transBytes = reader.readByteArray("transBytes"); if (!reader.isLastRead()) @@ -807,7 +815,7 @@ public int taskHash() { reader.incrementState(); - case 22: + case 24: byte typeOrd; typeOrd = reader.readByte("type"); @@ -819,14 +827,6 @@ public int taskHash() { reader.incrementState(); - case 23: - mvccSnapshot = reader.readMessage("mvccSnapshot"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - } return reader.afterMessageRead(GridCacheQueryRequest.class); @@ -839,7 +839,7 @@ public int taskHash() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 24; + return 25; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 13e0915875b92..a1650be162c46 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -287,37 +287,37 @@ public boolean fields() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeCollection("dataBytes", dataBytes, MessageCollectionItemType.BYTE_ARR)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeByteArray("errBytes", errBytes)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeBoolean("fields", fields)) return false; writer.incrementState(); - case 6: + case 7: if (!writer.writeBoolean("finished", finished)) return false; writer.incrementState(); - case 7: + case 8: if (!writer.writeCollection("metaDataBytes", metaDataBytes, MessageCollectionItemType.BYTE_ARR)) return false; writer.incrementState(); - case 8: + case 9: if (!writer.writeLong("reqId", reqId)) return false; @@ -339,7 +339,7 @@ public boolean fields() { return false; switch (reader.state()) { - case 3: + case 4: dataBytes = reader.readCollection("dataBytes", MessageCollectionItemType.BYTE_ARR); if (!reader.isLastRead()) @@ -347,7 +347,7 @@ public boolean fields() { reader.incrementState(); - case 4: + case 5: errBytes = reader.readByteArray("errBytes"); if (!reader.isLastRead()) @@ -355,7 +355,7 @@ public boolean fields() { reader.incrementState(); - case 5: + case 6: fields = reader.readBoolean("fields"); if (!reader.isLastRead()) @@ -363,7 +363,7 @@ public boolean fields() { reader.incrementState(); - case 6: + case 7: finished = reader.readBoolean("finished"); if (!reader.isLastRead()) @@ -371,7 +371,7 @@ public boolean fields() { reader.incrementState(); - case 7: + case 8: metaDataBytes = reader.readCollection("metaDataBytes", MessageCollectionItemType.BYTE_ARR); if (!reader.isLastRead()) @@ -379,7 +379,7 @@ public boolean fields() { reader.incrementState(); - case 8: + case 9: reqId = reader.readLong("reqId"); if (!reader.isLastRead()) @@ -399,7 +399,7 @@ public boolean fields() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 9; + return 10; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java index f1a23552b3957..692ffabe88d97 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java @@ -106,6 +106,12 @@ public final class IgniteQueryErrorCode { /** Attempt to INSERT, UPDATE or MERGE value that exceed maximum column length. */ public final static int TOO_LONG_VALUE = 4008; + /** Attempt to INSERT, UPDATE or MERGE value which scale exceed maximum DECIMAL column scale. */ + public static final int VALUE_SCALE_OUT_OF_RANGE = 4009; + + /** Attempt to INSERT, UPDATE or MERGE value which scale exceed maximum DECIMAL column scale. */ + public static final int KEY_SCALE_OUT_OF_RANGE = 4010; + /* 5xxx - transactions related runtime errors. */ /** Transaction is already open. */ @@ -151,6 +157,8 @@ public static String codeToSqlState(int statusCode) { case DUPLICATE_KEY: case TOO_LONG_KEY: case TOO_LONG_VALUE: + case KEY_SCALE_OUT_OF_RANGE: + case VALUE_SCALE_OUT_OF_RANGE: return SqlStateCode.CONSTRAINT_VIOLATION; case NULL_KEY: diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryBatchAck.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryBatchAck.java index ef0157ee70caa..9ba9ad2d1cd28 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryBatchAck.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryBatchAck.java @@ -90,15 +90,14 @@ Map updateCntrs() { } switch (writer.state()) { - case 3: + case 4: if (!writer.writeUuid("routineId", routineId)) return false; writer.incrementState(); - case 4: - if (!writer.writeMap("updateCntrs", updateCntrs, MessageCollectionItemType.INT, - MessageCollectionItemType.LONG)) + case 5: + if (!writer.writeMap("updateCntrs", updateCntrs, MessageCollectionItemType.INT, MessageCollectionItemType.LONG)) return false; writer.incrementState(); @@ -119,7 +118,7 @@ Map updateCntrs() { return false; switch (reader.state()) { - case 3: + case 4: routineId = reader.readUuid("routineId"); if (!reader.isLastRead()) @@ -127,9 +126,8 @@ Map updateCntrs() { reader.incrementState(); - case 4: - updateCntrs = reader.readMap("updateCntrs", MessageCollectionItemType.INT, - MessageCollectionItemType.LONG, false); + case 5: + updateCntrs = reader.readMap("updateCntrs", MessageCollectionItemType.INT, MessageCollectionItemType.LONG, false); if (!reader.isLastRead()) return false; @@ -153,7 +151,7 @@ Map updateCntrs() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 5; + return 6; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java index 88005d047933f..b05c275451ffe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEntry.java @@ -411,7 +411,7 @@ CacheObject oldValue() { writer.incrementState(); case 8: - if (!writer.writeMessage("topVer", topVer)) + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -500,7 +500,7 @@ CacheObject oldValue() { reader.incrementState(); case 8: - topVer = reader.readMessage("topVer"); + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index d1640c64e82d1..ade360a1d60d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -144,7 +144,7 @@ public class CacheContinuousQueryHandler implements GridContinuousHandler private transient boolean skipPrimaryCheck; /** */ - private boolean locCache; + private transient boolean locOnly; /** */ private boolean keepBinary; @@ -247,10 +247,10 @@ public void notifyExisting(boolean notifyExisting) { } /** - * @param locCache Local cache. + * @param locOnly Local only. */ - public void localCache(boolean locCache) { - this.locCache = locCache; + public void localOnly(boolean locOnly) { + this.locOnly = locOnly; } /** @@ -514,7 +514,7 @@ public void keepBinary(boolean keepBinary) { skipCtx = new CounterSkipContext(part, cntr, topVer); if (loc) { - assert !locCache; + assert !locOnly; final Collection> evts = handleEvent(ctx, skipCtx.entry()); @@ -583,6 +583,10 @@ public void keepBinary(boolean keepBinary) { private String taskName() { return ctx.security().enabled() ? ctx.task().resolveTaskName(taskHash) : null; } + + @Override public boolean isPrimaryOnly() { + return locOnly && !skipPrimaryCheck; + } }; CacheContinuousQueryManager mgr = manager(ctx); @@ -860,7 +864,7 @@ private void onEntryUpdate(CacheContinuousQueryEvent evt, boolean notify, boolea IgniteClosure, ?> trans = getTransformer(); if (loc) { - if (!locCache) { + if (!locOnly) { Collection> evts = handleEvent(ctx, entry); notifyLocalListener(evts, trans); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java index 7da657fe399dd..029b6d8dca73b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.query.continuous; import java.util.Map; +import org.apache.ignite.cache.query.ContinuousQuery; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; @@ -114,4 +115,9 @@ public void onEntryUpdated(CacheContinuousQueryEvent evt, boolean primary, * @return Whether to notify on existing entries. */ public boolean notifyExisting(); -} \ No newline at end of file + + /** + * @return {@code True} if this listener should be called on events on primary partitions only. + */ + public boolean isPrimaryOnly(); +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java index c41e1a3108508..4c399bf8cb3f8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java @@ -58,6 +58,7 @@ import org.apache.ignite.internal.NodeStoppingException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; @@ -67,6 +68,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.continuous.GridContinuousHandler; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.util.GridLongList; import org.apache.ignite.internal.util.StripedCompositeReadWriteLock; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.CI2; @@ -274,6 +276,37 @@ private void skipUpdateEvent(Map lsnrs, return skipCtx; } + /** + * For cache updates in shared cache group need notify others caches CQ listeners + * that generated counter should be skipped. + * + * @param cctx Cache context. + * @param part Partition. + * @param topVer Topology version. + * @param gaps Even-length array of pairs [start, end] for each gap. + */ + @Nullable public void closeBackupUpdateCountersGaps(GridCacheContext cctx, + int part, + AffinityTopologyVersion topVer, + GridLongList gaps) { + assert gaps != null && gaps.size() % 2 == 0; + + for (int i = 0; i < gaps.size() / 2; i++) { + long gapStart = gaps.get(i * 2); + long gapStop = gaps.get(i * 2 + 1); + + /* + * No user listeners should be called by this invocation. In the common case of partitioned cache or + * replicated cache with non-local-only listener gaps (dummy filtered CQ events) will be added to the + * backup queue without passing it to any listener. In the special case of local-only listener on + * replicated cache there is no backup queues used at all and therefore no gaps occur - all unfiltered + * events are passed to listeners upon arrive. + */ + for (long cntr = gapStart; cntr <= gapStop; cntr++) + skipUpdateEvent(lsnrs, null, part, cntr, false, topVer); + } + } + /** * @param internal Internal entry flag (internal key or not user cache). * @param preload Whether update happened during preloading. @@ -385,7 +418,7 @@ public void onEntryUpdated( boolean recordIgniteEvt = primary && !internal && cctx.events().isRecordable(EVT_CACHE_QUERY_OBJECT_READ); for (CacheContinuousQueryListener lsnr : lsnrCol.values()) { - if (preload && !lsnr.notifyExisting()) + if (preload && !lsnr.notifyExisting() || lsnr.isPrimaryOnly() && !primary) continue; if (!initialized) { @@ -722,12 +755,14 @@ private UUID executeQuery0(CacheEntryUpdatedListener locLsnr, final CacheContinuousQueryHandler hnd = clsr.apply(); + boolean locOnly = cctx.isLocal() || loc; + hnd.taskNameHash(taskNameHash); hnd.skipPrimaryCheck(skipPrimaryCheck); hnd.notifyExisting(notifyExisting); hnd.internal(internal); hnd.keepBinary(keepBinary); - hnd.localCache(cctx.isLocal()); + hnd.localOnly(locOnly); IgnitePredicate pred = (loc || cctx.config().getCacheMode() == CacheMode.LOCAL) ? F.nodeForNodeId(cctx.localNodeId()) : cctx.group().nodeFilter(); @@ -739,13 +774,13 @@ private UUID executeQuery0(CacheEntryUpdatedListener locLsnr, try { id = cctx.kernalContext().continuous().startRoutine( hnd, - internal && loc, + locOnly, bufSize, timeInterval, autoUnsubscribe, pred).get(); - if (hnd.isQuery() && cctx.userCache() && !onStart) + if (hnd.isQuery() && cctx.userCache() && !locOnly && !onStart) hnd.waitTopologyFuture(cctx.kernalContext()); } catch (NodeStoppingException e) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java index 901924ae4d6c2..f747161c043aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java @@ -17,6 +17,8 @@ package org.apache.ignite.internal.processors.cache.transactions; +import javax.cache.expiry.ExpiryPolicy; +import javax.cache.processor.EntryProcessor; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; @@ -37,8 +39,6 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import javax.cache.expiry.ExpiryPolicy; -import javax.cache.processor.EntryProcessor; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; @@ -62,7 +62,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheReturn; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; @@ -73,6 +75,8 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionedEntryEx; +import org.apache.ignite.internal.processors.cluster.BaselineTopology; +import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException; import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException; import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; import org.apache.ignite.internal.util.GridSetWrapper; @@ -272,6 +276,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement protected ConsistentIdMapper consistentIdMapper; /** Mvcc tx update snapshot. */ + @GridToStringInclude protected volatile MvccSnapshot mvccSnapshot; /** Rollback finish future. */ @@ -279,8 +284,13 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement private volatile IgniteInternalFuture rollbackFut; /** */ + @SuppressWarnings("unused") + @GridToStringExclude private volatile TxCounters txCounters; + /** Transaction from which this transaction was copied by(if it was). */ + private GridNearTxLocal parentTx; + /** * Empty constructor required for {@link Externalizable}. */ @@ -399,6 +409,13 @@ protected IgniteTxAdapter( consistentIdMapper = new ConsistentIdMapper(cctx.discovery()); } + /** + * @param parentTx Transaction from which this transaction was copied by. + */ + public void setParentTx(GridNearTxLocal parentTx) { + this.parentTx = parentTx; + } + /** * @return Mvcc info. */ @@ -761,6 +778,36 @@ public final IgniteCheckedException rollbackException() { "[timeout=" + timeout() + ", tx=" + CU.txString(this) + ']'); } + /** + * @param ex Root cause. + */ + public final IgniteCheckedException heuristicException(Throwable ex) { + return new IgniteTxHeuristicCheckedException("Committing a transaction has produced runtime exception", ex); + } + + /** + * @param log Log. + * @param commit Commit. + * @param e Exception. + */ + public void logTxFinishErrorSafe(@Nullable IgniteLogger log, boolean commit, Throwable e) { + assert e != null : "Exception is expected"; + + final String fmt = "Failed completing the transaction: [commit=%s, tx=%s, plc=%s]"; + + try { + // First try printing a full transaction. This is error prone. + U.error(log, String.format(fmt, commit, this, + cctx.gridConfig().getFailureHandler().getClass().getSimpleName()), e); + } + catch (Throwable e0) { + e.addSuppressed(e0); + + U.error(log, String.format(fmt, commit, CU.txString(this), + cctx.gridConfig().getFailureHandler().getClass().getSimpleName()), e); + } + } + /** {@inheritDoc} */ @Override public GridCacheVersion xidVersion() { return xidVer; @@ -1011,6 +1058,19 @@ public void onePhaseCommit(boolean onePhaseCommit) { return state(state, false); } + /** + * Changing state for this transaction as well as chained(parent) transactions. + * + * @param state Transaction state. + * @return {@code True} if transition was valid, {@code false} otherwise. + */ + public boolean chainState(TransactionState state) { + if (parentTx != null) + parentTx.state(state); + + return state(state); + } + /** {@inheritDoc} */ @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor") @Override public IgniteInternalFuture finishFuture() { @@ -1954,21 +2014,51 @@ protected void applyTxSizes() { for (Map.Entry> entry : sizeDeltas.entrySet()) { Integer cacheId = entry.getKey(); - Map partDeltas = entry.getValue(); + Map deltas = entry.getValue(); - assert !F.isEmpty(partDeltas); + assert !F.isEmpty(deltas); GridDhtPartitionTopology top = cctx.cacheContext(cacheId).topology(); - for (Map.Entry e : partDeltas.entrySet()) { - Integer p = e.getKey(); + // Need to reserve on backups only + boolean reserve = dht() && remote(); + + for (Map.Entry e : deltas.entrySet()) { + boolean invalid = false; + int p = e.getKey(); long delta = e.getValue().get(); - GridDhtLocalPartition dhtPart = top.localPartition(p); + try { + GridDhtLocalPartition part = top.localPartition(p); - assert dhtPart != null; + if (!reserve || part != null && part.reserve()) { + assert part != null; - dhtPart.dataStore().updateSize(cacheId, delta); + try { + if (part.state() != GridDhtPartitionState.RENTING) + part.dataStore().updateSize(cacheId, delta); + else + invalid = true; + } + finally { + if (reserve) + part.release(); + } + } + else + invalid = true; + } + catch (GridDhtInvalidPartitionException e1) { + invalid = true; + } + + if (invalid) { + assert reserve; + + if (log.isDebugEnabled()) + log.debug("Trying to apply size delta for invalid partition: " + + "[cacheId=" + cacheId + ", part=" + p + "]"); + } } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java index 09a3be4ab1359..b80422c87a23a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java @@ -25,7 +25,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.cluster.ClusterTopologyException; import org.apache.ignite.failure.FailureContext; import org.apache.ignite.failure.FailureType; import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; @@ -34,7 +33,6 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection; import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.GridCacheAffinityManager; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; @@ -64,6 +62,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.PartitionUpdateCountersMessage; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishFuture; @@ -343,14 +342,17 @@ private IgniteTxEntry unmarshal(@Nullable Collection entries) thr } /** + * @param originTx Transaction for copy. * @param req Request. * @return Prepare future. */ - public IgniteInternalFuture prepareNearTxLocal(final GridNearTxPrepareRequest req) { + public IgniteInternalFuture prepareNearTxLocal( + final GridNearTxLocal originTx, + final GridNearTxPrepareRequest req) { // Make sure not to provide Near entries to DHT cache. req.cloneEntries(); - return prepareNearTx(ctx.localNode(), req); + return prepareNearTx(originTx, ctx.localNode(), req); } /** @@ -361,6 +363,20 @@ public IgniteInternalFuture prepareNearTxLocal(final @Nullable private IgniteInternalFuture prepareNearTx( final ClusterNode nearNode, final GridNearTxPrepareRequest req + ) { + return prepareNearTx(null, nearNode, req); + } + + /** + * @param originTx Transaction for copy. + * @param nearNode Node that initiated transaction. + * @param req Near prepare request. + * @return Prepare future or {@code null} if need retry operation. + */ + @Nullable private IgniteInternalFuture prepareNearTx( + final GridNearTxLocal originTx, + final ClusterNode nearNode, + final GridNearTxPrepareRequest req ) { IgniteTxEntry firstEntry; @@ -509,7 +525,8 @@ public IgniteInternalFuture prepareNearTxLocal(final req.txSize(), req.transactionNodes(), req.subjectId(), - req.taskNameHash() + req.taskNameHash(), + originTx ); tx = ctx.tm().onCreated(null, tx); @@ -690,6 +707,11 @@ private boolean needRemap(AffinityTopologyVersion expVer, if (expVer.equals(curVer)) return false; + AffinityTopologyVersion lastAffChangedTopVer = ctx.exchange().lastAffinityChangedTopologyVersion(expVer); + + if (curVer.compareTo(expVer) <= 0 && curVer.compareTo(lastAffChangedTopVer) >= 0) + return false; + // TODO IGNITE-6754 check mvcc crd for mvcc enabled txs. for (IgniteTxEntry e : F.concat(false, req.reads(), req.writes())) { @@ -1048,45 +1070,34 @@ private IgniteInternalFuture finishDhtLocal(UUID nodeId, } catch (Throwable e) { try { - U.error(log, "Failed completing transaction [commit=" + req.commit() + ", tx=" + tx + ']', e); - } - catch (Throwable e0) { - ClusterNode node0 = ctx.discovery().node(nodeId); - - U.error(log, "Failed completing transaction [commit=" + req.commit() + ", tx=" + - CU.txString(tx) + ']', e); - - U.error(log, "Failed to log message due to an error: ", e0); - - if (node0 != null && (!node0.isClient() || node0.isLocal())) { - ctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); - - throw e; - } - } + if (tx != null) { + tx.commitError(e); - if (tx != null) { - tx.commitError(e); + tx.systemInvalidate(true); - tx.systemInvalidate(true); + try { + IgniteInternalFuture res = tx.rollbackDhtLocalAsync(); - try { - IgniteInternalFuture res = tx.rollbackDhtLocalAsync(); + // Only for error logging. + res.listen(CU.errorLogger(log)); - // Only for error logging. - res.listen(CU.errorLogger(log)); + return res; + } + catch (Throwable e1) { + e.addSuppressed(e1); + } - return res; - } - catch (Throwable e1) { - e.addSuppressed(e1); + tx.logTxFinishErrorSafe(log, req.commit(), e); } - } - if (e instanceof Error) - throw (Error)e; + if (e instanceof Error) + throw (Error)e; - return new GridFinishedFuture<>(e); + return new GridFinishedFuture<>(e); + } + finally { + ctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); + } } } @@ -1111,20 +1122,26 @@ public IgniteInternalFuture finishColocatedLocal(boolean commi return tx.rollbackAsyncLocal(); } catch (Throwable e) { - U.error(log, "Failed completing transaction [commit=" + commit + ", tx=" + tx + ']', e); - - if (e instanceof Error) - throw e; + try { + if (tx != null) { + try { + return tx.rollbackNearTxLocalAsync(); + } + catch (Throwable e1) { + e.addSuppressed(e1); + } - if (tx != null) - try { - return tx.rollbackNearTxLocalAsync(); - } - catch (Throwable e1) { - e.addSuppressed(e1); + tx.logTxFinishErrorSafe(log, commit, e); } - return new GridFinishedFuture<>(e); + if (e instanceof Error) + throw e; + + return new GridFinishedFuture<>(e); + } + finally { + ctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); + } } } @@ -1211,10 +1228,6 @@ else if (e instanceof IgniteTxOptimisticCheckedException) { if (log.isDebugEnabled()) log.debug("Optimistic failure for remote transaction (will rollback): " + req); } - else if (e instanceof IgniteTxHeuristicCheckedException) { - U.warn(log, "Failed to commit transaction (all transaction entries were invalidated): " + - CU.txString(dhtTx)); - } else U.error(log, "Failed to process prepare request: " + req, e); @@ -1439,9 +1452,10 @@ protected void finish( tx.rollbackRemoteTx(); } } + catch (IgniteTxHeuristicCheckedException e) { + // Already uncommitted. + } catch (Throwable e) { - U.error(log, "Failed completing transaction [commit=" + req.commit() + ", tx=" + tx + ']', e); - // Mark transaction for invalidate. tx.invalidate(true); tx.systemInvalidate(true); @@ -1459,6 +1473,8 @@ protected void finish( } /** + * Finish for one-phase distributed tx. + * * @param tx Transaction. * @param req Request. */ @@ -1482,22 +1498,27 @@ protected void finish( throw e; } catch (Throwable e) { - U.error(log, "Failed committing transaction [tx=" + tx + ']', e); + try { + // Mark transaction for invalidate. + tx.invalidate(true); - // Mark transaction for invalidate. - tx.invalidate(true); - tx.systemInvalidate(true); + tx.systemInvalidate(true); - try { - tx.rollbackRemoteTx(); + try { + tx.rollbackRemoteTx(); + } + catch (Throwable e1) { + e.addSuppressed(e1); + } + + tx.logTxFinishErrorSafe(log, true, e); + + if (e instanceof Error) + throw (Error)e; } - catch (Throwable e1) { - e.addSuppressed(e1); - U.error(log, "Failed to automatically rollback transaction: " + tx, e1); + finally { + ctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e)); } - - if (e instanceof Error) - throw (Error)e; } } @@ -1659,8 +1680,6 @@ private void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committe GridDhtTxRemote tx = ctx.tm().tx(req.version()); if (tx == null) { - assert !req.queryUpdate(); - boolean single = req.last() && req.writes().size() == 1; tx = new GridDhtTxRemote( @@ -1685,6 +1704,7 @@ private void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committe single, req.storeWriteThrough()); + tx.onePhaseCommit(req.onePhaseCommit()); tx.writeVersion(req.writeVersion()); tx = ctx.tm().onCreated(null, tx); @@ -1859,117 +1879,131 @@ public void mvccEnlistBatch(GridDhtTxRemote tx, GridCacheContext ctx, EnlistOper int part = ctx.affinity().partition(key); - GridDhtLocalPartition locPart = ctx.topology().localPartition(part, tx.topologyVersion(), false); + try { + GridDhtLocalPartition locPart = ctx.topology().localPartition(part, tx.topologyVersion(), false); - if (locPart == null || !locPart.reserve()) - throw new ClusterTopologyException("Can not reserve partition. Please retry on stable topology."); + if (locPart != null && locPart.reserve()) { + try { + // do not process renting partitions. + if (locPart.state() == GridDhtPartitionState.RENTING) { + tx.addInvalidPartition(ctx, part); - try { - CacheObject val = null; - EntryProcessor entryProc = null; - Object[] invokeArgs = null; + continue; + } - boolean needOldVal = ctx.shared().mvccCaching().continuousQueryListeners(ctx, tx, key) != null; + CacheObject val = null; + EntryProcessor entryProc = null; + Object[] invokeArgs = null; - Message val0 = vals != null ? vals.get(i) : null; + boolean needOldVal = ctx.shared().mvccCaching().continuousQueryListeners(ctx, tx, key) != null; - CacheEntryInfoCollection entries = - val0 instanceof CacheEntryInfoCollection ? (CacheEntryInfoCollection)val0 : null; + Message val0 = vals != null ? vals.get(i) : null; - if (entries == null && !op.isDeleteOrLock() && !op.isInvoke()) - val = (val0 instanceof CacheObject) ? (CacheObject)val0 : null; + CacheEntryInfoCollection entries = + val0 instanceof CacheEntryInfoCollection ? (CacheEntryInfoCollection)val0 : null; - if(entries == null && op.isInvoke()) { - assert val0 instanceof GridInvokeValue; + if (entries == null && !op.isDeleteOrLock() && !op.isInvoke()) + val = (val0 instanceof CacheObject) ? (CacheObject)val0 : null; - GridInvokeValue invokeVal = (GridInvokeValue)val0; + if (entries == null && op.isInvoke()) { + assert val0 instanceof GridInvokeValue; - entryProc = invokeVal.entryProcessor(); - invokeArgs = invokeVal.invokeArgs(); - } + GridInvokeValue invokeVal = (GridInvokeValue)val0; - assert entryProc != null || !op.isInvoke(); + entryProc = invokeVal.entryProcessor(); + invokeArgs = invokeVal.invokeArgs(); + } - GridDhtCacheEntry entry = dht.entryExx(key, tx.topologyVersion()); + assert entries != null || entryProc != null || !op.isInvoke() : "entryProc=" + entryProc + ", op=" + op; - GridCacheUpdateTxResult updRes; + GridDhtCacheEntry entry = dht.entryExx(key, tx.topologyVersion()); - while (true) { - ctx.shared().database().checkpointReadLock(); + GridCacheUpdateTxResult updRes; - try { - if (entries == null) { - switch (op) { - case DELETE: - updRes = entry.mvccRemove( - tx, - ctx.localNodeId(), - tx.topologyVersion(), - snapshot, - false, - needOldVal, - null, - false); - - break; - - case INSERT: - case TRANSFORM: - case UPSERT: - case UPDATE: - updRes = entry.mvccSet( - tx, + while (true) { + ctx.shared().database().checkpointReadLock(); + + try { + if (entries == null) { + switch (op) { + case DELETE: + updRes = entry.mvccRemove( + tx, + ctx.localNodeId(), + tx.topologyVersion(), + snapshot, + false, + needOldVal, + null, + false); + + break; + + case INSERT: + case TRANSFORM: + case UPSERT: + case UPDATE: + updRes = entry.mvccSet( + tx, + ctx.localNodeId(), + val, + entryProc, + invokeArgs, + 0, + tx.topologyVersion(), + snapshot, + op.cacheOperation(), + false, + false, + needOldVal, + null, + false); + + break; + + default: + throw new IgniteSQLException("Cannot acquire lock for operation [op= " + + op + "]" + "Operation is unsupported at the moment ", + IgniteQueryErrorCode.UNSUPPORTED_OPERATION); + } + } + else { + updRes = entry.mvccUpdateRowsWithPreloadInfo(tx, ctx.localNodeId(), - val, - entryProc, - invokeArgs, - 0, tx.topologyVersion(), - snapshot, + entries.infos(), op.cacheOperation(), - false, - false, - needOldVal, - null, - false); - - break; - - default: - throw new IgniteSQLException("Cannot acquire lock for operation [op= " - + op + "]" + "Operation is unsupported at the moment ", - IgniteQueryErrorCode.UNSUPPORTED_OPERATION); + snapshot, + futId, + batchNum); + } + + break; + } + catch (GridCacheEntryRemovedException ignore) { + entry = dht.entryExx(key); + } + finally { + ctx.shared().database().checkpointReadUnlock(); } - } - else { - updRes = entry.mvccUpdateRowsWithPreloadInfo(tx, - ctx.localNodeId(), - tx.topologyVersion(), - entries.infos(), - op.cacheOperation(), - snapshot, - futId, - batchNum); } - break; - } - catch (GridCacheEntryRemovedException ignore) { - entry = dht.entryExx(key); + if (!updRes.filtered()) + ctx.shared().mvccCaching().addEnlisted(key, updRes.newValue(), 0, 0, tx.xidVersion(), + updRes.oldValue(), tx.local(), tx.topologyVersion(), snapshot, ctx.cacheId(), tx, futId, batchNum); + + assert updRes.updateFuture() == null : "Entry should not be locked on the backup"; } + finally { - ctx.shared().database().checkpointReadUnlock(); + locPart.release(); } } - - if (!updRes.filtered()) - ctx.shared().mvccCaching().addEnlisted(key, updRes.newValue(), 0, 0, tx.xidVersion(), - updRes.oldValue(), tx.local(), tx.topologyVersion(), snapshot, ctx.cacheId(), tx, futId, batchNum); - - assert updRes.updateFuture() == null : "Entry should not be locked on the backup"; + else + tx.addInvalidPartition(ctx, part); } - finally { - locPart.release(); + catch (GridDhtInvalidPartitionException e) { + tx.addInvalidPartition(ctx, e.partition()); } } } @@ -2210,26 +2244,42 @@ public void applyPartitionsUpdatesCounters(Iterable filterUpdateCountersForBackupNode( IgniteInternalTx tx, ClusterNode node) { TxCounters txCntrs = tx.txCounters(false); + Collection updCntrs; - if (txCntrs == null || F.isEmpty(txCntrs.updateCounters())) + if (txCntrs == null || F.isEmpty(updCntrs = txCntrs.updateCounters())) return null; - Collection updCntrs = txCntrs.updateCounters(); - List res = new ArrayList<>(updCntrs.size()); AffinityTopologyVersion top = tx.topologyVersionSnapshot(); for (PartitionUpdateCountersMessage partCntrs : updCntrs) { - GridCacheAffinityManager affinity = ctx.cacheContext(partCntrs.cacheId()).affinity(); + GridDhtPartitionTopology topology = ctx.cacheContext(partCntrs.cacheId()).topology(); PartitionUpdateCountersMessage resCntrs = new PartitionUpdateCountersMessage(partCntrs.cacheId(), partCntrs.size()); for (int i = 0; i < partCntrs.size(); i++) { int part = partCntrs.partition(i); - if (affinity.backupByPartition(node, part, top)) + if (topology.nodes(part, top).indexOf(node) > 0) resCntrs.add(part, partCntrs.initialCounter(i), partCntrs.updatesCount(i)); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java index 2b76772b7708a..b1e1b022ef636 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; @@ -148,7 +149,10 @@ public class IgniteTxImplicitSingleStateImpl extends IgniteTxLocalStateAdapter { cacheCtx.topology().readLock(); if (cacheCtx.topology().stopping()) { - fut.onDone(new CacheStoppedException(cacheCtx.name())); + fut.onDone( + cctx.cache().isCacheRestarting(cacheCtx.name())? + new IgniteCacheRestartingException(cacheCtx.name()): + new CacheStoppedException(cacheCtx.name())); return null; } @@ -302,6 +306,11 @@ public class IgniteTxImplicitSingleStateImpl extends IgniteTxLocalStateAdapter { return ctx0 != null && ctx0.mvccEnabled(); } + /** {@inheritDoc} */ + @Override public boolean recovery() { + return recovery; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(IgniteTxImplicitSingleStateImpl.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java index efcb48b4714c3..2c3892f564dde 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxKey.java @@ -191,4 +191,4 @@ public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws Ignite @Override public String toString() { return S.toString(IgniteTxKey.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java index 775b61c0eeffe..7e042923ad48b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java @@ -558,7 +558,7 @@ protected GridCacheEntryEx entryEx(GridCacheContext cacheCtx, IgniteTxKey key, A /** {@inheritDoc} */ @SuppressWarnings({"CatchGenericClass"}) - @Override public final void userCommit() throws IgniteCheckedException { + @Override public void userCommit() throws IgniteCheckedException { TransactionState state = state(); if (state != COMMITTING) { @@ -590,7 +590,7 @@ protected GridCacheEntryEx entryEx(GridCacheContext cacheCtx, IgniteTxKey key, A WALPointer ptr = null; - Exception err = null; + IgniteCheckedException err = null; cctx.database().checkpointReadLock(); @@ -609,176 +609,175 @@ protected GridCacheEntryEx entryEx(GridCacheContext cacheCtx, IgniteTxKey key, A UUID nodeId = txEntry.nodeId() == null ? this.nodeId : txEntry.nodeId(); - try { - while (true) { - try { - GridCacheEntryEx cached = txEntry.cached(); + while (true) { + try { + GridCacheEntryEx cached = txEntry.cached(); - // Must try to evict near entries before committing from - // transaction manager to make sure locks are held. - if (!evictNearEntry(txEntry, false)) { - if (cacheCtx.isNear() && cacheCtx.dr().receiveEnabled()) { - cached.markObsolete(xidVer); + // Must try to evict near entries before committing from + // transaction manager to make sure locks are held. + if (!evictNearEntry(txEntry, false)) { + if (cacheCtx.isNear() && cacheCtx.dr().receiveEnabled()) { + cached.markObsolete(xidVer); - break; - } + break; + } - if (cached.detached()) - break; + if (cached.detached()) + break; - boolean updateNearCache = updateNearCache(cacheCtx, txEntry.key(), topVer); + boolean updateNearCache = updateNearCache(cacheCtx, txEntry.key(), topVer); - boolean metrics = true; + boolean metrics = true; - if (!updateNearCache && cacheCtx.isNear() && txEntry.locallyMapped()) - metrics = false; + if (!updateNearCache && cacheCtx.isNear() && txEntry.locallyMapped()) + metrics = false; - boolean evt = !isNearLocallyMapped(txEntry, false); + boolean evt = !isNearLocallyMapped(txEntry, false); - if (!F.isEmpty(txEntry.entryProcessors()) || !F.isEmpty(txEntry.filters())) - txEntry.cached().unswap(false); + if (!F.isEmpty(txEntry.entryProcessors()) || !F.isEmpty(txEntry.filters())) + txEntry.cached().unswap(false); - IgniteBiTuple res = applyTransformClosures(txEntry, - true, null); + IgniteBiTuple res = applyTransformClosures(txEntry, + true, null); - GridCacheVersion dhtVer = null; + GridCacheVersion dhtVer = null; - // For near local transactions we must record DHT version - // in order to keep near entries on backup nodes until - // backup remote transaction completes. - if (cacheCtx.isNear()) { - if (txEntry.op() == CREATE || txEntry.op() == UPDATE || - txEntry.op() == DELETE || txEntry.op() == TRANSFORM) - dhtVer = txEntry.dhtVersion(); + // For near local transactions we must record DHT version + // in order to keep near entries on backup nodes until + // backup remote transaction completes. + if (cacheCtx.isNear()) { + if (txEntry.op() == CREATE || txEntry.op() == UPDATE || + txEntry.op() == DELETE || txEntry.op() == TRANSFORM) + dhtVer = txEntry.dhtVersion(); - if ((txEntry.op() == CREATE || txEntry.op() == UPDATE) && - txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE) { - ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry); + if ((txEntry.op() == CREATE || txEntry.op() == UPDATE) && + txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE) { + ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry); - if (expiry != null) { - txEntry.cached().unswap(false); + if (expiry != null) { + txEntry.cached().unswap(false); - Duration duration = cached.hasValue() ? - expiry.getExpiryForUpdate() : expiry.getExpiryForCreation(); + Duration duration = cached.hasValue() ? + expiry.getExpiryForUpdate() : expiry.getExpiryForCreation(); - txEntry.ttl(CU.toTtl(duration)); - } + txEntry.ttl(CU.toTtl(duration)); } } + } - GridCacheOperation op = res.get1(); - CacheObject val = res.get2(); + GridCacheOperation op = res.get1(); + CacheObject val = res.get2(); - // Deal with conflicts. - GridCacheVersion explicitVer = txEntry.conflictVersion() != null ? - txEntry.conflictVersion() : writeVersion(); + // Deal with conflicts. + GridCacheVersion explicitVer = txEntry.conflictVersion() != null ? + txEntry.conflictVersion() : writeVersion(); - if ((op == CREATE || op == UPDATE) && - txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE) { - ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry); + if ((op == CREATE || op == UPDATE) && + txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE) { + ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry); - if (expiry != null) { - Duration duration = cached.hasValue() ? - expiry.getExpiryForUpdate() : expiry.getExpiryForCreation(); + if (expiry != null) { + Duration duration = cached.hasValue() ? + expiry.getExpiryForUpdate() : expiry.getExpiryForCreation(); - long ttl = CU.toTtl(duration); + long ttl = CU.toTtl(duration); - txEntry.ttl(ttl); + txEntry.ttl(ttl); - if (ttl == CU.TTL_ZERO) - op = DELETE; - } + if (ttl == CU.TTL_ZERO) + op = DELETE; } + } - boolean conflictNeedResolve = cacheCtx.conflictNeedResolve(); - - GridCacheVersionConflictContext conflictCtx = null; - - if (conflictNeedResolve) { - IgniteBiTuple conflictRes = - conflictResolve(op, txEntry, val, explicitVer, cached); + boolean conflictNeedResolve = cacheCtx.conflictNeedResolve(); - assert conflictRes != null; + GridCacheVersionConflictContext conflictCtx = null; - conflictCtx = conflictRes.get2(); + if (conflictNeedResolve) { + IgniteBiTuple conflictRes = + conflictResolve(op, txEntry, val, explicitVer, cached); - if (conflictCtx.isUseOld()) - op = NOOP; - else if (conflictCtx.isUseNew()) { - txEntry.ttl(conflictCtx.ttl()); - txEntry.conflictExpireTime(conflictCtx.expireTime()); - } - else { - assert conflictCtx.isMerge(); + assert conflictRes != null; - op = conflictRes.get1(); - val = txEntry.context().toCacheObject(conflictCtx.mergeValue()); - explicitVer = writeVersion(); + conflictCtx = conflictRes.get2(); - txEntry.ttl(conflictCtx.ttl()); - txEntry.conflictExpireTime(conflictCtx.expireTime()); - } + if (conflictCtx.isUseOld()) + op = NOOP; + else if (conflictCtx.isUseNew()) { + txEntry.ttl(conflictCtx.ttl()); + txEntry.conflictExpireTime(conflictCtx.expireTime()); } - else - // Nullify explicit version so that innerSet/innerRemove will work as usual. - explicitVer = null; + else { + assert conflictCtx.isMerge(); - if (sndTransformedVals || conflictNeedResolve) { - assert sndTransformedVals && cacheCtx.isReplicated() || conflictNeedResolve; + op = conflictRes.get1(); + val = txEntry.context().toCacheObject(conflictCtx.mergeValue()); + explicitVer = writeVersion(); - txEntry.value(val, true, false); - txEntry.op(op); - txEntry.entryProcessors(null); - txEntry.conflictVersion(explicitVer); + txEntry.ttl(conflictCtx.ttl()); + txEntry.conflictExpireTime(conflictCtx.expireTime()); } + } + else + // Nullify explicit version so that innerSet/innerRemove will work as usual. + explicitVer = null; - if (dhtVer == null) - dhtVer = explicitVer != null ? explicitVer : writeVersion(); + if (sndTransformedVals || conflictNeedResolve) { + assert sndTransformedVals && cacheCtx.isReplicated() || conflictNeedResolve; - if (op == CREATE || op == UPDATE) { - assert val != null : txEntry; + txEntry.value(val, true, false); + txEntry.op(op); + txEntry.entryProcessors(null); + txEntry.conflictVersion(explicitVer); + } - GridCacheUpdateTxResult updRes = cached.innerSet( - this, - eventNodeId(), - txEntry.nodeId(), - val, - false, - false, - txEntry.ttl(), - evt, - metrics, - txEntry.keepBinary(), - txEntry.hasOldValue(), - txEntry.oldValue(), - topVer, - null, - cached.detached() ? DR_NONE : drType, - txEntry.conflictExpireTime(), - cached.isNear() ? null : explicitVer, - CU.subjectId(this, cctx), - resolveTaskName(), - dhtVer, - null, - mvccSnapshot()); - - if (updRes.success()) { - txEntry.updateCounter(updRes.updateCounter()); - - GridLongList waitTxs = updRes.mvccWaitTransactions(); - - updateWaitTxs(waitTxs); - } + if (dhtVer == null) + dhtVer = explicitVer != null ? explicitVer : writeVersion(); + + if (op == CREATE || op == UPDATE) { + assert val != null : txEntry; + + GridCacheUpdateTxResult updRes = cached.innerSet( + this, + eventNodeId(), + txEntry.nodeId(), + val, + false, + false, + txEntry.ttl(), + evt, + metrics, + txEntry.keepBinary(), + txEntry.hasOldValue(), + txEntry.oldValue(), + topVer, + null, + cached.detached() ? DR_NONE : drType, + txEntry.conflictExpireTime(), + cached.isNear() ? null : explicitVer, + CU.subjectId(this, cctx), + resolveTaskName(), + dhtVer, + null, + mvccSnapshot()); + + if (updRes.success()) { + txEntry.updateCounter(updRes.updateCounter()); + + GridLongList waitTxs = updRes.mvccWaitTransactions(); + + updateWaitTxs(waitTxs); + } - if (updRes.loggedPointer() != null) - ptr = updRes.loggedPointer(); + if (updRes.loggedPointer() != null) + ptr = updRes.loggedPointer(); - if (updRes.success() && updateNearCache) { - final CacheObject val0 = val; - final boolean metrics0 = metrics; - final GridCacheVersion dhtVer0 = dhtVer; + if (updRes.success() && updateNearCache) { + final CacheObject val0 = val; + final boolean metrics0 = metrics; + final GridCacheVersion dhtVer0 = dhtVer; - updateNearEntrySafely(cacheCtx, txEntry.key(), entry -> entry.innerSet( + updateNearEntrySafely(cacheCtx, txEntry.key(), entry -> entry.innerSet( null, eventNodeId(), nodeId, @@ -801,46 +800,46 @@ else if (conflictCtx.isUseNew()) { dhtVer0, null, mvccSnapshot()) - ); - } + ); + } + } + else if (op == DELETE) { + GridCacheUpdateTxResult updRes = cached.innerRemove( + this, + eventNodeId(), + txEntry.nodeId(), + false, + evt, + metrics, + txEntry.keepBinary(), + txEntry.hasOldValue(), + txEntry.oldValue(), + topVer, + null, + cached.detached() ? DR_NONE : drType, + cached.isNear() ? null : explicitVer, + CU.subjectId(this, cctx), + resolveTaskName(), + dhtVer, + null, + mvccSnapshot()); + + if (updRes.success()) { + txEntry.updateCounter(updRes.updateCounter()); + + GridLongList waitTxs = updRes.mvccWaitTransactions(); + + updateWaitTxs(waitTxs); } - else if (op == DELETE) { - GridCacheUpdateTxResult updRes = cached.innerRemove( - this, - eventNodeId(), - txEntry.nodeId(), - false, - evt, - metrics, - txEntry.keepBinary(), - txEntry.hasOldValue(), - txEntry.oldValue(), - topVer, - null, - cached.detached() ? DR_NONE : drType, - cached.isNear() ? null : explicitVer, - CU.subjectId(this, cctx), - resolveTaskName(), - dhtVer, - null, - mvccSnapshot()); - - if (updRes.success()) { - txEntry.updateCounter(updRes.updateCounter()); - - GridLongList waitTxs = updRes.mvccWaitTransactions(); - - updateWaitTxs(waitTxs); - } - if (updRes.loggedPointer() != null) - ptr = updRes.loggedPointer(); + if (updRes.loggedPointer() != null) + ptr = updRes.loggedPointer(); - if (updRes.success() && updateNearCache) { - final boolean metrics0 = metrics; - final GridCacheVersion dhtVer0 = dhtVer; + if (updRes.success() && updateNearCache) { + final boolean metrics0 = metrics; + final GridCacheVersion dhtVer0 = dhtVer; - updateNearEntrySafely(cacheCtx, txEntry.key(), entry -> entry.innerRemove( + updateNearEntrySafely(cacheCtx, txEntry.key(), entry -> entry.innerRemove( null, eventNodeId(), nodeId, @@ -859,125 +858,78 @@ else if (op == DELETE) { dhtVer0, null, mvccSnapshot()) - ); - } + ); } - else if (op == RELOAD) { - cached.innerReload(); + } + else if (op == RELOAD) { + cached.innerReload(); - if (updateNearCache) - updateNearEntrySafely(cacheCtx, txEntry.key(), entry -> entry.innerReload()); + if (updateNearCache) + updateNearEntrySafely(cacheCtx, txEntry.key(), entry -> entry.innerReload()); + } + else if (op == READ) { + CacheGroupContext grp = cacheCtx.group(); + + if (grp.persistenceEnabled() && grp.walEnabled() && + cctx.snapshot().needTxReadLogging()) { + ptr = cctx.wal().log(new DataRecord(new DataEntry( + cacheCtx.cacheId(), + txEntry.key(), + val, + op, + nearXidVersion(), + writeVersion(), + 0, + txEntry.key().partition(), + txEntry.updateCounter()))); } - else if (op == READ) { - CacheGroupContext grp = cacheCtx.group(); - - if (grp.persistenceEnabled() && grp.walEnabled() && - cctx.snapshot().needTxReadLogging()) { - ptr = cctx.wal().log(new DataRecord(new DataEntry( - cacheCtx.cacheId(), - txEntry.key(), - val, - op, - nearXidVersion(), - writeVersion(), - 0, - txEntry.key().partition(), - txEntry.updateCounter()))); - } - ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry); + ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry); - if (expiry != null) { - Duration duration = expiry.getExpiryForAccess(); + if (expiry != null) { + Duration duration = expiry.getExpiryForAccess(); - if (duration != null) - cached.updateTtl(null, CU.toTtl(duration)); - } - - if (log.isDebugEnabled()) - log.debug("Ignoring READ entry when committing: " + txEntry); + if (duration != null) + cached.updateTtl(null, CU.toTtl(duration)); } - else { - assert ownsLock(txEntry.cached()) : - "Transaction does not own lock for group lock entry during commit [tx=" + - this + ", txEntry=" + txEntry + ']'; - if (conflictCtx == null || !conflictCtx.isUseOld()) { - if (txEntry.ttl() != CU.TTL_NOT_CHANGED) - cached.updateTtl(null, txEntry.ttl()); - } - - if (log.isDebugEnabled()) - log.debug("Ignoring NOOP entry when committing: " + txEntry); - } + if (log.isDebugEnabled()) + log.debug("Ignoring READ entry when committing: " + txEntry); } + else { + assert ownsLock(txEntry.cached()) : + "Transaction does not own lock for group lock entry during commit [tx=" + + this + ", txEntry=" + txEntry + ']'; + + if (conflictCtx == null || !conflictCtx.isUseOld()) { + if (txEntry.ttl() != CU.TTL_NOT_CHANGED) + cached.updateTtl(null, txEntry.ttl()); + } - // Check commit locks after set, to make sure that - // we are not changing obsolete entries. - // (innerSet and innerRemove will throw an exception - // if an entry is obsolete). - if (txEntry.op() != READ) - checkCommitLocks(cached); - - // Break out of while loop. - break; - } - // If entry cached within transaction got removed. - catch (GridCacheEntryRemovedException ignored) { - if (log.isDebugEnabled()) - log.debug("Got removed entry during transaction commit (will retry): " + txEntry); - - txEntry.cached(entryEx(cacheCtx, txEntry.txKey(), topologyVersion())); + if (log.isDebugEnabled()) + log.debug("Ignoring NOOP entry when committing: " + txEntry); + } } - } - } - catch (Throwable ex) { - // We are about to initiate transaction rollback when tx has started to committing. - // Need to remove version from committed list. - cctx.tm().removeCommittedTx(this); - boolean isNodeStopping = X.hasCause(ex, NodeStoppingException.class); - boolean hasInvalidEnvironmentIssue = X.hasCause(ex, InvalidEnvironmentException.class); + // Check commit locks after set, to make sure that + // we are not changing obsolete entries. + // (innerSet and innerRemove will throw an exception + // if an entry is obsolete). + if (txEntry.op() != READ) + checkCommitLocks(cached); - IgniteCheckedException err0 = new IgniteTxHeuristicCheckedException("Failed to locally write to cache " + - "(all transaction entries will be invalidated, however there was a window when " + - "entries for this transaction were visible to others): " + this, ex); - - if (isNodeStopping) { - U.warn(log, "Failed to commit transaction, node is stopping [tx=" + this + - ", err=" + ex + ']'); - } - else if (hasInvalidEnvironmentIssue) { - U.warn(log, "Failed to commit transaction, node is in invalid state and will be stopped [tx=" + this + - ", err=" + ex + ']'); + // Break out of while loop. + break; } - else - U.error(log, "Commit failed.", err0); - - COMMIT_ERR_UPD.compareAndSet(this, null, err0); + // If entry cached within transaction got removed. + catch (GridCacheEntryRemovedException ignored) { + if (log.isDebugEnabled()) + log.debug("Got removed entry during transaction commit (will retry): " + txEntry); - state(UNKNOWN); - - if (hasInvalidEnvironmentIssue) - cctx.kernalContext().failure().process(new FailureContext(FailureType.CRITICAL_ERROR, ex)); - else if (!isNodeStopping) { // Skip fair uncommit in case of node stopping or invalidation. - try { - // Courtesy to minimize damage. - uncommit(); - } - catch (Throwable ex1) { - U.error(log, "Failed to uncommit transaction: " + this, ex1); - - if (ex1 instanceof Error) - throw ex1; - } + txEntry.cached(entryEx(cacheCtx, txEntry.txKey(), topologyVersion())); } - - if (ex instanceof Error) - throw ex; - - throw err0; } + } // Apply cache sizes only for primary nodes. Update counters were applied on prepare state. @@ -988,11 +940,32 @@ else if (!isNodeStopping) { // Skip fair uncommit in case of node stopping or in if (ptr != null && !cctx.tm().logTxRecords()) cctx.wal().flush(ptr, false); } - catch (StorageException e) { - err = e; + catch (Throwable ex) { + // We are about to initiate transaction rollback when tx has started to committing. + // Need to remove version from committed list. + cctx.tm().removeCommittedTx(this); + + if (X.hasCause(ex, NodeStoppingException.class)) { + U.warn(log, "Failed to commit transaction, node is stopping [tx=" + CU.txString(this) + + ", err=" + ex + ']'); + + return; + } + + err = heuristicException(ex); + + COMMIT_ERR_UPD.compareAndSet(this, null, err); + + state(UNKNOWN); + + try { + uncommit(); + } + catch (Throwable e) { + err.addSuppressed(e); + } - throw new IgniteCheckedException("Failed to log transaction record " + - "(transaction will be rolled back): " + this, e); + throw err; } finally { cctx.database().checkpointReadUnlock(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalState.java index 01eb4f4417877..e007f903b03ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalState.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalState.java @@ -57,4 +57,9 @@ public interface IgniteTxLocalState extends IgniteTxState { * @param partId Partition id. */ public void touchPartition(int cacheId, int partId); + + /** + * @return Recovery mode flag. + */ + public boolean recovery(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 9336bca0d9e82..10b3b48bd0bd3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -267,7 +267,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter { // Wait some time in case there are some unprocessed messages from failed node. cctx.time().addTimeoutObject( - new NodeFailureTimeoutObject(evt.eventNode(), discoCache.mvccCoordinator())); + new NodeFailureTimeoutObject(evt.eventNode(), cctx.coordinators().currentCoordinator())); if (txFinishSync != null) txFinishSync.onNodeLeft(nodeId); @@ -323,7 +323,7 @@ public void rollbackOnTopologyChange(AffinityTopologyVersion topVer) { */ public void rollbackMvccTxOnCoordinatorChange() { for (IgniteInternalTx tx : activeTransactions()) { - if (tx.mvccSnapshot() != null) + if (tx.mvccSnapshot() != null && tx instanceof GridNearTxLocal) ((GridNearTxLocal)tx).rollbackNearTxLocalAsync(false, false); } } @@ -895,7 +895,8 @@ public void prepareTx(IgniteInternalTx tx, @Nullable Collection e throw new IgniteCheckedException("Transaction is marked for rollback: " + tx); } - if (tx.remainingTime() == -1) { + // One-phase commit tx cannot timeout on prepare because it is expected to be committed. + if (tx.remainingTime() == -1 && !tx.onePhaseCommit()) { tx.setRollbackOnly(); throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java index cd8c6e9a87a2e..9cbea0ff1b383 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java @@ -24,6 +24,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.apache.ignite.IgniteCacheRestartingException; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheInterceptor; import org.apache.ignite.cache.CacheWriteSynchronizationMode; @@ -149,7 +150,7 @@ public class IgniteTxStateImpl extends IgniteTxLocalStateAdapter { assert ctx != null : cacheId; - Throwable err = topFut.validateCache(ctx, recovery != null && recovery, read, null, e.getValue()); + Throwable err = topFut.validateCache(ctx, recovery(), read, null, e.getValue()); if (err != null) { if (invalidCaches != null) @@ -180,6 +181,11 @@ public class IgniteTxStateImpl extends IgniteTxLocalStateAdapter { return null; } + /** {@inheritDoc} */ + @Override public boolean recovery() { + return recovery != null && recovery; + } + /** {@inheritDoc} */ @Override public CacheWriteSynchronizationMode syncMode(GridCacheSharedContext cctx) { CacheWriteSynchronizationMode syncMode = CacheWriteSynchronizationMode.FULL_ASYNC; @@ -288,7 +294,10 @@ public class IgniteTxStateImpl extends IgniteTxLocalStateAdapter { nonLocCtx.topology().readLock(); if (nonLocCtx.topology().stopping()) { - fut.onDone(new CacheStoppedException(nonLocCtx.name())); + fut.onDone( + cctx.cache().isCacheRestarting(nonLocCtx.name())? + new IgniteCacheRestartingException(nonLocCtx.name()): + new CacheStoppedException(nonLocCtx.name())); return null; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java index 94fe00527a488..86109c8f323a9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksRequest.java @@ -149,13 +149,13 @@ public Collection txKeys() { } switch (writer.state()) { - case 2: + case 3: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 3: + case 4: if (!writer.writeObjectArray("txKeysArr", txKeysArr, MessageCollectionItemType.MSG)) return false; @@ -177,7 +177,7 @@ public Collection txKeys() { return false; switch (reader.state()) { - case 2: + case 3: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -185,7 +185,7 @@ public Collection txKeys() { reader.incrementState(); - case 3: + case 4: txKeysArr = reader.readObjectArray("txKeysArr", MessageCollectionItemType.MSG, IgniteTxKey.class); if (!reader.isLastRead()) @@ -205,7 +205,7 @@ public Collection txKeys() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 4; + return 5; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java index a5c8f0917da8c..df5caa978b609 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxLocksResponse.java @@ -239,25 +239,25 @@ public void addKey(IgniteTxKey key) { } switch (writer.state()) { - case 2: + case 3: if (!writer.writeLong("futId", futId)) return false; writer.incrementState(); - case 3: + case 4: if (!writer.writeObjectArray("locksArr", locksArr, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 4: + case 5: if (!writer.writeObjectArray("nearTxKeysArr", nearTxKeysArr, MessageCollectionItemType.MSG)) return false; writer.incrementState(); - case 5: + case 6: if (!writer.writeObjectArray("txKeysArr", txKeysArr, MessageCollectionItemType.MSG)) return false; @@ -279,7 +279,7 @@ public void addKey(IgniteTxKey key) { return false; switch (reader.state()) { - case 2: + case 3: futId = reader.readLong("futId"); if (!reader.isLastRead()) @@ -287,7 +287,7 @@ public void addKey(IgniteTxKey key) { reader.incrementState(); - case 3: + case 4: locksArr = reader.readObjectArray("locksArr", MessageCollectionItemType.MSG, TxLockList.class); if (!reader.isLastRead()) @@ -295,7 +295,7 @@ public void addKey(IgniteTxKey key) { reader.incrementState(); - case 4: + case 5: nearTxKeysArr = reader.readObjectArray("nearTxKeysArr", MessageCollectionItemType.MSG, IgniteTxKey.class); if (!reader.isLastRead()) @@ -303,7 +303,7 @@ public void addKey(IgniteTxKey key) { reader.incrementState(); - case 5: + case 6: txKeysArr = reader.readObjectArray("txKeysArr", MessageCollectionItemType.MSG, IgniteTxKey.class); if (!reader.isLastRead()) @@ -323,7 +323,7 @@ public void addKey(IgniteTxKey key) { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 6; + return 7; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/mvcc/data/MvccUpdateDataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/mvcc/data/MvccUpdateDataRow.java index 0464e45bb5858..75c510b3d67a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/mvcc/data/MvccUpdateDataRow.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/mvcc/data/MvccUpdateDataRow.java @@ -273,8 +273,11 @@ && isActive(cctx, lockCrd, lockCntr, mvccSnapshot)) { else { // Actually, full row can be omitted for replace(k,newval) and putIfAbsent, but // operation context is not available here and full row required if filter is set. - if (res == ResultType.PREV_NOT_NULL && (isFlagsSet(NEED_PREV_VALUE) || filter != null)) - oldRow = tree.getRow(io, pageAddr, idx, RowData.FULL); + if (res == ResultType.PREV_NOT_NULL && (isFlagsSet(NEED_PREV_VALUE) || filter != null)) { + oldRow = tree.getRow(io, pageAddr, idx, RowData.NO_KEY); + + oldRow.key(key); + } else oldRow = row; } @@ -398,7 +401,7 @@ && isVisible(cctx, mvccSnapshot, rowCrd, rowCntr, rowOpCntr, false))) { rowIo.setMvccLockCoordinatorVersion(pageAddr, idx, mvccCoordinatorVersion()); rowIo.setMvccLockCounter(pageAddr, idx, mvccCounter()); - // TODO Delta record IGNITE-7991 + // Actually, there is no need to log lock delta record into WAL. setFlags(DIRTY); } @@ -581,9 +584,7 @@ public List cleanupRows() { /** {@inheritDoc} */ @Override public CacheObject oldValue() { - assert oldRow != null; - - return oldRow.value(); + return oldRow == null ? null : oldRow.value(); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/CacheInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/CacheInfo.java index 31c0b3fcbe2d0..01231990050bd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/CacheInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/CacheInfo.java @@ -20,7 +20,8 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; - +import java.util.LinkedHashMap; +import java.util.Map; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -238,7 +239,7 @@ public CacheAtomicityMode getAtomicityMode() { } /** - * @param atomicityMode + * @param atomicityMode Atomicity mode. */ public void setAtomicityMode(CacheAtomicityMode atomicityMode) { this.atomicityMode = atomicityMode; @@ -272,32 +273,74 @@ public void setAffinityClsName(String affinityClsName) { this.affinityClsName = affinityClsName; } + /** + * Gets name of info for multi line output depending on cache command. + * + * @param cmd Cache command. + * @return Header. + */ + public Object name(VisorViewCacheCmd cmd) { + switch (cmd) { + case CACHES: + return getCacheName(); + + case GROUPS: + return getGrpName(); + + case SEQ: + return getSeqName(); + + default: + throw new IllegalArgumentException("Unknown cache subcommand " + cmd); + } + } + /** * @param cmd Command. */ - public void print(VisorViewCacheCmd cmd) { - if (cmd == null) - cmd = VisorViewCacheCmd.CACHES; + public Map toMap(VisorViewCacheCmd cmd) { + Map map; switch (cmd) { case SEQ: - System.out.println("[seqName=" + getSeqName() + ", curVal=" + seqVal + ']'); + map = new LinkedHashMap<>(2); + + map.put("seqName", getSeqName()); + map.put("curVal", seqVal); break; case GROUPS: - System.out.println("[grpName=" + getGrpName() + ", grpId=" + getGrpId() + ", cachesCnt=" + getCachesCnt() + - ", prim=" + getPartitions() + ", mapped=" + getMapped() + ", mode=" + getMode() + - ", atomicity=" + getAtomicityMode() + ", backups=" + getBackupsCnt() + ", affCls=" + getAffinityClsName() + ']'); + map = new LinkedHashMap<>(10); + + map.put("grpName", getGrpName()); + map.put("grpId", getGrpId()); + map.put("cachesCnt", getCachesCnt()); + map.put("prim", getPartitions()); + map.put("mapped", getMapped()); + map.put("mode", getMode()); + map.put("atomicity", getAtomicityMode()); + map.put("backups", getBackupsCnt()); + map.put("affCls", getAffinityClsName()); break; default: - System.out.println("[cacheName=" + getCacheName() + ", cacheId=" + getCacheId() + - ", grpName=" + getGrpName() + ", grpId=" + getGrpId() + ", prim=" + getPartitions() + - ", mapped=" + getMapped() + ", mode=" + getMode() + ", atomicity=" + getAtomicityMode() + - ", backups=" + getBackupsCnt() + ", affCls=" + getAffinityClsName() + ']'); + map = new LinkedHashMap<>(10); + + map.put("cacheName", getCacheName()); + map.put("cacheId", getCacheId()); + map.put("grpName", getGrpName()); + map.put("grpId", getGrpId()); + map.put("prim", getPartitions()); + map.put("mapped", getMapped()); + map.put("mode", getMode()); + map.put("atomicity", getAtomicityMode()); + map.put("backups", getBackupsCnt()); + map.put("affCls", getAffinityClsName()); } + + return map; } /** {@inheritDoc} */ @@ -345,4 +388,4 @@ public void print(VisorViewCacheCmd cmd) { @Override public String toString() { return S.toString(CacheInfo.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/IdleVerifyResultV2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/IdleVerifyResultV2.java index c31d6627ed94a..a153063d8998a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/IdleVerifyResultV2.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/IdleVerifyResultV2.java @@ -21,6 +21,7 @@ import java.io.ObjectOutput; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.function.Consumer; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; @@ -43,6 +44,9 @@ public class IdleVerifyResultV2 extends VisorDataTransferObject { /** Moving partitions. */ private Map> movingPartitions; + /** Exceptions. */ + private Map exceptions; + /** * @param cntrConflicts Counter conflicts. * @param hashConflicts Hash conflicts. @@ -51,11 +55,13 @@ public class IdleVerifyResultV2 extends VisorDataTransferObject { public IdleVerifyResultV2( Map> cntrConflicts, Map> hashConflicts, - Map> movingPartitions + Map> movingPartitions, + Map exceptions ) { this.cntrConflicts = cntrConflicts; this.hashConflicts = hashConflicts; this.movingPartitions = movingPartitions; + this.exceptions = exceptions; } /** @@ -64,11 +70,17 @@ public IdleVerifyResultV2( public IdleVerifyResultV2() { } + /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return V2; + } + /** {@inheritDoc} */ @Override protected void writeExternalData(ObjectOutput out) throws IOException { U.writeMap(out, cntrConflicts); U.writeMap(out, hashConflicts); U.writeMap(out, movingPartitions); + U.writeMap(out, exceptions); } /** {@inheritDoc} */ @@ -77,6 +89,9 @@ public IdleVerifyResultV2() { cntrConflicts = U.readMap(in); hashConflicts = U.readMap(in); movingPartitions = U.readMap(in); + + if (protoVer >= V2) + exceptions = U.readMap(in); } /** @@ -107,6 +122,13 @@ public boolean hasConflicts() { return !F.isEmpty(hashConflicts()) || !F.isEmpty(counterConflicts()); } + /** + * @return Exceptions on nodes. + */ + public Map exceptions() { + return exceptions; + } + /** * Print formatted result to given printer. * @@ -159,6 +181,16 @@ public void print(Consumer printer) { printer.accept("\n"); } + + if (!F.isEmpty(exceptions())) { + printer.accept("Idle verify failed on nodes:\n"); + + for (Map.Entry e : exceptions().entrySet()) { + printer.accept("Node ID: " + e.getKey() + "\n"); + printer.accept("Exception message:" + "\n"); + printer.accept(e.getValue().getMessage() + "\n"); + } + } } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/VerifyBackupPartitionsDumpTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/VerifyBackupPartitionsDumpTask.java index 7bbd9f19b9b15..c0fd36ae5a6b0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/VerifyBackupPartitionsDumpTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/VerifyBackupPartitionsDumpTask.java @@ -30,15 +30,18 @@ import java.util.TreeMap; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteException; +import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.compute.ComputeJob; import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeJobResultPolicy; import org.apache.ignite.compute.ComputeTaskAdapter; import org.apache.ignite.internal.processors.task.GridInternal; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.visor.verify.VisorIdleVerifyDumpTaskArg; import org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg; import org.apache.ignite.resources.IgniteInstanceResource; +import org.apache.ignite.resources.LoggerResource; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -57,7 +60,7 @@ public class VerifyBackupPartitionsDumpTask extends ComputeTaskAdapter map( List subgrid, VisorIdleVerifyTaskArg arg) throws IgniteException { @@ -83,6 +91,9 @@ public class VerifyBackupPartitionsDumpTask extends ComputeTaskAdapter> clusterHashes = new TreeMap<>(buildPartitionKeyComparator()); for (ComputeJobResult res : results) { + if (res.getException() != null) + continue; + Map nodeHashes = res.getData(); for (Map.Entry e : nodeHashes.entrySet()) { @@ -111,6 +122,22 @@ public class VerifyBackupPartitionsDumpTask extends ComputeTaskAdapter rcvd) throws + IgniteException { + ComputeJobResultPolicy superRes = super.result(res, rcvd); + + // Deny failover. + if (superRes == ComputeJobResultPolicy.FAILOVER) { + superRes = ComputeJobResultPolicy.WAIT; + + log.warning("VerifyBackupPartitionsJobV2 failed on node " + + "[consistentId=" + res.getNode().consistentId() + "]", res.getException()); + } + + return superRes; + } + /** * Checking conditions for adding given record to result. * @@ -140,6 +167,8 @@ record = records.get(i); /** * @param partitions Dump result. + * @param conflictRes Conflict results. + * @param skippedRecords Number of empty partitions. * @return Path where results are written. * @throws IgniteException If failed to write the file. */ @@ -152,7 +181,7 @@ private String writeHashes( ? new File("/tmp") : new File(ignite.configuration().getWorkDirectory()); - File out = new File(workDir, IDLE_DUMP_FILE_PREMIX + LocalDateTime.now().format(TIME_FORMATTER) + ".txt"); + File out = new File(workDir, IDLE_DUMP_FILE_PREFIX + LocalDateTime.now().format(TIME_FORMATTER) + ".txt"); ignite.log().info("IdleVerifyDumpTask will write output to " + out.getAbsolutePath()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/VerifyBackupPartitionsTaskV2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/VerifyBackupPartitionsTaskV2.java index e698e3a2e6bc4..c30d37bdfea11 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/VerifyBackupPartitionsTaskV2.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/VerifyBackupPartitionsTaskV2.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; @@ -36,20 +37,28 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteInterruptedException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.compute.ComputeJob; import org.apache.ignite.compute.ComputeJobAdapter; import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeJobResultPolicy; import org.apache.ignite.compute.ComputeTaskAdapter; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; +import org.apache.ignite.internal.processors.cache.GridCacheUtils; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.task.GridInternal; import org.apache.ignite.internal.util.lang.GridIterator; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.verify.CacheFilterEnum; +import org.apache.ignite.internal.visor.verify.VisorIdleVerifyDumpTaskArg; import org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg; import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.resources.IgniteInstanceResource; @@ -71,6 +80,10 @@ public class VerifyBackupPartitionsTaskV2 extends ComputeTaskAdapter results) throws IgniteException { Map> clusterHashes = new HashMap<>(); + Map exceptions = new HashMap<>(); for (ComputeJobResult res : results) { + if (res.getException() != null) { + exceptions.put(res.getNode().id(), res.getException()); + + continue; + } + Map nodeHashes = res.getData(); for (Map.Entry e : nodeHashes.entrySet()) { @@ -135,7 +155,23 @@ public class VerifyBackupPartitionsTaskV2 extends ComputeTaskAdapter rcvd) throws + IgniteException { + ComputeJobResultPolicy superRes = super.result(res, rcvd); + + // Deny failover. + if (superRes == ComputeJobResultPolicy.FAILOVER) { + superRes = ComputeJobResultPolicy.WAIT; + + log.warning("VerifyBackupPartitionsJobV2 failed on node " + + "[consistentId=" + res.getNode().consistentId() + "]", res.getException()); + } + + return superRes; } /** @@ -170,13 +206,13 @@ public VerifyBackupPartitionsJobV2(VisorIdleVerifyTaskArg arg) { @Override public Map execute() throws IgniteException { Set grpIds = new HashSet<>(); - Set missingCaches = new HashSet<>(); + if (arg.getCaches() != null && !arg.getCaches().isEmpty()) { + Set missingCaches = new HashSet<>(); - if (arg.getCaches() != null) { for (String cacheName : arg.getCaches()) { DynamicCacheDescriptor desc = ignite.context().cache().cacheDescriptor(cacheName); - if (desc == null) { + if (desc == null || !isCacheMatchFilter(cacheName)) { missingCaches.add(cacheName); continue; @@ -185,25 +221,17 @@ public VerifyBackupPartitionsJobV2(VisorIdleVerifyTaskArg arg) { grpIds.add(desc.groupId()); } - if (!missingCaches.isEmpty()) { - StringBuilder strBuilder = new StringBuilder("The following caches do not exist: "); - - for (String name : missingCaches) - strBuilder.append(name).append(", "); - - strBuilder.delete(strBuilder.length() - 2, strBuilder.length()); - - throw new IgniteException(strBuilder.toString()); - } + handlingMissedCaches(missingCaches); } - else { - Collection groups = ignite.context().cache().cacheGroups(); - - for (CacheGroupContext grp : groups) { - if (!grp.systemCache() && !grp.isLocal()) - grpIds.add(grp.groupId()); + else if (onlySpecificCaches()) { + for (DynamicCacheDescriptor desc : ignite.context().cache().cacheDescriptors().values()) { + if (desc.cacheConfiguration().getCacheMode() != CacheMode.LOCAL + && isCacheMatchFilter(desc.cacheName())) + grpIds.add(desc.groupId()); } } + else + grpIds = getCacheGroupIds(); List>> partHashCalcFutures = new ArrayList<>(); @@ -259,6 +287,118 @@ else if (e.getCause() instanceof IgniteException) return res; } + /** + * Gets filtered group ids. + */ + private Set getCacheGroupIds() { + Collection groups = ignite.context().cache().cacheGroups(); + + Set grpIds = new HashSet<>(); + + if (arg.excludeCaches() == null || arg.excludeCaches().isEmpty()) { + for (CacheGroupContext grp : groups) { + if (!grp.systemCache() && !grp.isLocal()) + grpIds.add(grp.groupId()); + } + return grpIds; + } + + for (CacheGroupContext grp : groups) { + if (!grp.systemCache() && !grp.isLocal() && !isGrpExcluded(grp)) + grpIds.add(grp.groupId()); + } + + return grpIds; + } + + /** + * @param grp Group. + */ + private boolean isGrpExcluded(CacheGroupContext grp) { + if (arg.excludeCaches().contains(grp.name())) + return true; + + for (GridCacheContext cacheCtx : grp.caches()) { + if (arg.excludeCaches().contains(cacheCtx.name())) + return true; + } + + return false; + } + + /** + * Checks and throw exception if caches was missed. + * + * @param missingCaches Missing caches. + */ + private void handlingMissedCaches(Set missingCaches) { + if (missingCaches.isEmpty()) + return; + + StringBuilder strBuilder = new StringBuilder("The following caches do not exist"); + + if (onlySpecificCaches()) { + VisorIdleVerifyDumpTaskArg vdta = (VisorIdleVerifyDumpTaskArg)arg; + + strBuilder.append(" or do not match to the given filter [") + .append(vdta.getCacheFilterEnum()) + .append("]: "); + } + else + strBuilder.append(": "); + + for (String name : missingCaches) + strBuilder.append(name).append(", "); + + strBuilder.delete(strBuilder.length() - 2, strBuilder.length()); + + throw new IgniteException(strBuilder.toString()); + } + + /** + * @return True if validates only specific caches, else false. + */ + private boolean onlySpecificCaches() { + if (arg instanceof VisorIdleVerifyDumpTaskArg) { + VisorIdleVerifyDumpTaskArg vdta = (VisorIdleVerifyDumpTaskArg)arg; + + return vdta.getCacheFilterEnum() != CacheFilterEnum.ALL; + } + + return false; + } + + /** + * @param cacheName Cache name. + */ + private boolean isCacheMatchFilter(String cacheName) { + if (arg instanceof VisorIdleVerifyDumpTaskArg) { + DataStorageConfiguration dsc = ignite.context().config().getDataStorageConfiguration(); + DynamicCacheDescriptor desc = ignite.context().cache().cacheDescriptor(cacheName); + CacheConfiguration cc = desc.cacheConfiguration(); + VisorIdleVerifyDumpTaskArg vdta = (VisorIdleVerifyDumpTaskArg)arg; + + switch (vdta.getCacheFilterEnum()) { + case SYSTEM: + return !desc.cacheType().userCache(); + + case NOT_PERSISTENT: + return desc.cacheType().userCache() && !GridCacheUtils.isPersistentCache(cc, dsc); + + case PERSISTENT: + return desc.cacheType().userCache() && GridCacheUtils.isPersistentCache(cc, dsc); + + case ALL: + break; + + default: + assert false: "Illegal cache filter: " + vdta.getCacheFilterEnum(); + } + } + + return true; + } + /** * @param grpCtx Group context. * @param part Local partition. @@ -274,7 +414,6 @@ private Future> calculatePartitionHas }); } - /** * @param grpCtx Group context. * @param part Local partition. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java index 586a043cc8d22..ceea0a2d9a5cd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheRawVersionedEntry.java @@ -24,6 +24,7 @@ import java.nio.ByteBuffer; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridDirectTransient; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; @@ -39,6 +40,7 @@ /** * Raw versioned entry. */ +@IgniteCodeGeneratingFail public class GridCacheRawVersionedEntry extends DataStreamerEntry implements GridCacheVersionedEntry, GridCacheVersionable, Externalizable { /** */ @@ -381,4 +383,4 @@ public void prepareDirectMarshal(CacheObjectContext ctx) throws IgniteCheckedExc "valBytesLen", valBytes != null ? valBytes.length : "n/a", "super", super.toString()); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java index df8af4811b7b3..2a6526aa2a377 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java @@ -41,9 +41,6 @@ public class GridCacheVersionManager extends GridCacheSharedManagerAdapter { /** */ public static final GridCacheVersion EVICT_VER = new GridCacheVersion(Integer.MAX_VALUE, 0, 0, 0); - /** */ - public static final GridCacheVersion START_VER = new GridCacheVersion(0, 0, 0, 0); - /** Timestamp used as base time for cache topology version (January 1, 2014). */ public static final long TOP_VER_BASE_TIME = 1388520000000L; @@ -56,6 +53,9 @@ public class GridCacheVersionManager extends GridCacheSharedManagerAdapter { /** Current order for store operations. */ private final AtomicLong loadOrder = new AtomicLong(0); + /** Entry start version. */ + private GridCacheVersion startVer; + /** Last version. */ private volatile GridCacheVersion last; @@ -87,6 +87,8 @@ public class GridCacheVersionManager extends GridCacheSharedManagerAdapter { @Override public void start0() throws IgniteCheckedException { last = new GridCacheVersion(0, order.get(), 0, dataCenterId); + startVer = new GridCacheVersion(0, 0, 0, dataCenterId); + cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_METRICS_UPDATED); } @@ -104,6 +106,8 @@ public void dataCenterId(byte dataCenterId) { this.dataCenterId = dataCenterId; last = new GridCacheVersion(0, order.get(), 0, dataCenterId); + + startVer = new GridCacheVersion(0, 0, 0, dataCenterId); } /** @@ -301,4 +305,25 @@ private GridCacheVersion next(long topVer, boolean addTime, boolean forLoad, byt public GridCacheVersion last() { return last; } + + /** + * Gets start version. + * + * @return Start version. + */ + public GridCacheVersion startVersion() { + assert startVer != null; + + return startVer; + } + + /** + * Check if given version is start version. + * + * @param ver Version. + * @return {@code True} if given version is start version. + */ + public boolean isStartVersion(GridCacheVersion ver) { + return startVer.equals(ver); + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java index defb3ccb2ad31..4c56ea7c28865 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java @@ -215,5 +215,5 @@ public IncompleteCacheObject toKeyCacheObject(CacheObjectContext ctx, ByteBuffer /** * @return Ignite binary interface. */ - public IgniteBinary binary(); + public IgniteBinary binary() ; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/BaselineTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/BaselineTopology.java index fcb7a397e8936..5a7e66aefc7bb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/BaselineTopology.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/BaselineTopology.java @@ -298,13 +298,15 @@ public ClusterNode baselineNode(Object consId) { * @return Sorted list of baseline topology nodes. */ public List createBaselineView( - List aliveNodes, - @Nullable IgnitePredicate nodeFilter) - { + Collection aliveNodes, + @Nullable IgnitePredicate nodeFilter + ) { List res = new ArrayList<>(nodeMap.size()); + boolean nullNodeFilter = nodeFilter == null; + for (ClusterNode node : aliveNodes) { - if (nodeMap.containsKey(node.consistentId()) && (nodeFilter == null || CU.affinityNode(node, nodeFilter))) + if (nodeMap.containsKey(node.consistentId()) && (nullNodeFilter || CU.affinityNode(node, nodeFilter))) res.add(node); } @@ -316,7 +318,7 @@ public List createBaselineView( Map consIdMap = new HashMap<>(); for (ClusterNode node : aliveNodes) { - if (nodeMap.containsKey(node.consistentId()) && (nodeFilter == null || CU.affinityNode(node, nodeFilter))) + if (nodeMap.containsKey(node.consistentId()) && (nullNodeFilter || CU.affinityNode(node, nodeFilter))) consIdMap.put(node.consistentId(), node); } @@ -326,7 +328,7 @@ public List createBaselineView( if (!consIdMap.containsKey(consId)) { DetachedClusterNode node = new DetachedClusterNode(consId, e.getValue()); - if (nodeFilter == null || CU.affinityNode(node, nodeFilter)) + if (nullNodeFilter || CU.affinityNode(node, nodeFilter)) consIdMap.put(consId, node); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java index d4928469d088c..778d9f24e8631 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java @@ -17,18 +17,6 @@ package org.apache.ignite.internal.processors.cluster; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicReference; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteCompute; @@ -59,8 +47,11 @@ import org.apache.ignite.internal.processors.task.GridInternal; import org.apache.ignite.internal.util.future.GridFinishedFuture; import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl; +import org.apache.ignite.internal.util.future.IgniteFutureImpl; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.tostring.GridToStringInclude; +import org.apache.ignite.internal.util.typedef.C1; import org.apache.ignite.internal.util.typedef.CI1; import org.apache.ignite.internal.util.typedef.CI2; import org.apache.ignite.internal.util.typedef.F; @@ -79,6 +70,19 @@ import org.apache.ignite.spi.discovery.DiscoveryDataBag; import org.jetbrains.annotations.Nullable; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicReference; + import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; import static org.apache.ignite.events.EventType.EVT_NODE_LEFT; import static org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.STATE_PROC; @@ -173,6 +177,11 @@ public boolean compatibilityMode() { /** {@inheritDoc} */ @Override public boolean publicApiActiveState(boolean waitForTransition) { + return publicApiActiveStateAsync(waitForTransition).get(); + } + + /** {@inheritDoc} */ + @Override public IgniteFuture publicApiActiveStateAsync(boolean asyncWaitForTransition) { if (ctx.isDaemon()) return sendComputeCheckGlobalState(); @@ -184,32 +193,34 @@ public boolean compatibilityMode() { Boolean transitionRes = globalState.transitionResult(); if (transitionRes != null) - return transitionRes; + return new IgniteFinishedFutureImpl<>(transitionRes); else { - if (waitForTransition) { - GridFutureAdapter fut = transitionFuts.get(globalState.transitionRequestId()); + GridFutureAdapter fut = transitionFuts.get(globalState.transitionRequestId()); + if (fut != null) { + if (asyncWaitForTransition) { + return new IgniteFutureImpl<>(fut.chain(new C1, Boolean>() { + @Override public Boolean apply(IgniteInternalFuture fut) { + Boolean res = globalState.transitionResult(); - if (fut != null) { - try { - fut.get(); - } - catch (IgniteCheckedException ex) { - throw new IgniteException(ex); - } + assert res != null; + + return res; + } + })); } + else + return new IgniteFinishedFutureImpl<>(globalState.baselineChanged()); + } - transitionRes = globalState.transitionResult(); + transitionRes = globalState.transitionResult(); - assert transitionRes != null; + assert transitionRes != null; - return transitionRes; - } - else - return globalState.baselineChanged(); + return new IgniteFinishedFutureImpl<>(transitionRes); } } else - return globalState.active(); + return new IgniteFinishedFutureImpl<>(globalState.active()); } /** {@inheritDoc} */ @@ -404,7 +415,7 @@ private boolean isBaselineSatisfied(BaselineTopology blt, List serv if (msg.requestId().equals(state.transitionRequestId())) { log.info("Received state change finish message: " + msg.clusterActive()); - globalState = globalState.finish(msg.success()); + globalState = state.finish(msg.success()); afterStateChangeFinished(msg.id(), msg.success()); @@ -839,7 +850,8 @@ private IgniteInternalFuture changeGlobalState0(final boolean activate, DiscoveryDataClusterState curState = globalState; - if (!curState.transition() && curState.active() == activate && BaselineTopology.equals(curState.baselineTopology(), blt)) + if (!curState.transition() && curState.active() == activate + && (!activate || BaselineTopology.equals(curState.baselineTopology(), blt))) return new GridFinishedFuture<>(); GridChangeGlobalStateFuture startedFut = null; @@ -893,15 +905,19 @@ private IgniteInternalFuture changeGlobalState0(final boolean activate, forceChangeBaselineTopology, System.currentTimeMillis()); + IgniteInternalFuture resFut = wrapStateChangeFuture(startedFut, msg); + try { if (log.isInfoEnabled()) U.log(log, "Sending " + prettyStr(activate) + " request with BaselineTopology " + blt); ctx.discovery().sendCustomEvent(msg); - if (ctx.isStopping()) - startedFut.onDone(new IgniteCheckedException("Failed to execute " + prettyStr(activate) + " request, " + - "node is stopping.")); + if (ctx.isStopping()) { + String errMsg = "Failed to execute " + prettyStr(activate) + " request, node is stopping."; + + startedFut.onDone(new IgniteCheckedException(errMsg)); + } } catch (IgniteCheckedException e) { U.error(log, "Failed to send global state change request: " + activate, e); @@ -909,7 +925,7 @@ private IgniteInternalFuture changeGlobalState0(final boolean activate, startedFut.onDone(e); } - return wrapStateChangeFuture(startedFut, msg); + return resFut; } /** {@inheritDoc} */ @@ -1066,7 +1082,7 @@ private void sendComputeChangeGlobalState( * * @return Cluster state, {@code True} if cluster active, {@code False} if inactive. */ - private boolean sendComputeCheckGlobalState() { + private IgniteFuture sendComputeCheckGlobalState() { AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx(); if (log.isInfoEnabled()) { @@ -1079,11 +1095,11 @@ private boolean sendComputeCheckGlobalState() { ClusterGroupAdapter clusterGroupAdapter = (ClusterGroupAdapter)ctx.cluster().get().forServers(); if (F.isEmpty(clusterGroupAdapter.nodes())) - return false; + return new IgniteFinishedFutureImpl<>(false); IgniteCompute comp = clusterGroupAdapter.compute(); - return comp.call(new IgniteCallable() { + return comp.callAsync(new IgniteCallable() { @IgniteInstanceResource private Ignite ig; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/IGridClusterStateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/IGridClusterStateProcessor.java index bc72a516b860a..1f677ed0cdef3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/IGridClusterStateProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/IGridClusterStateProcessor.java @@ -18,9 +18,6 @@ package org.apache.ignite.internal.processors.cluster; -import java.util.Collection; -import java.util.Map; -import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cluster.BaselineNode; import org.apache.ignite.cluster.ClusterNode; @@ -29,8 +26,13 @@ import org.apache.ignite.internal.processors.GridProcessor; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.StateChangeRequest; +import org.apache.ignite.lang.IgniteFuture; import org.jetbrains.annotations.Nullable; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; + /** * */ @@ -40,6 +42,11 @@ public interface IGridClusterStateProcessor extends GridProcessor { */ boolean publicApiActiveState(boolean waitForTransition); + /** + * @return Cluster state to be used on public API. + */ + IgniteFuture publicApiActiveStateAsync(boolean waitForTransition); + /** * @param discoCache Discovery data cache. * @return If transition is in progress returns future which is completed when transition finishes. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java index ec04ac355e5a6..5e7cc9d3a4576 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java @@ -274,4 +274,4 @@ public void dataBytes(byte[] dataBytes) { @Override public String toString() { return S.toString(GridContinuousMessage.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java index 88bfbf4e15a50..f95740efdd077 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java @@ -1423,7 +1423,7 @@ private void processStartRequest(ClusterNode node, StartRoutineDiscoveryMessage if (cache != null && !cache.isLocal() && cache.context().userCache()) req.addUpdateCounters(ctx.localNodeId(), - toCountersMap(cache.context().topology().localUpdateCounters(false, false))); + toCountersMap(cache.context().topology().localUpdateCounters(false))); } } @@ -1564,7 +1564,7 @@ private void processStartRequestV2(final AffinityTopologyVersion topVer, if (cache != null && !cache.isLocal() && cache.context().userCache()) { CachePartitionPartialCountersMap cntrsMap = - cache.context().topology().localUpdateCounters(false, false); + cache.context().topology().localUpdateCounters(false); cntrs = U.marshal(marsh, cntrsMap); } @@ -2504,7 +2504,7 @@ private void onAllRemoteRegistered( if (cctx != null && cntrsPerNode != null && !cctx.isLocal() && cctx.affinityNode()) cntrsPerNode.put(ctx.localNodeId(), - toCountersMap(cctx.topology().localUpdateCounters(false, false))); + toCountersMap(cctx.topology().localUpdateCounters(false))); routine.handler().updateCounters(topVer, cntrsPerNode, cntrs); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java index bf1e13db1d377..e3ea0be2a32e4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java @@ -85,10 +85,10 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheFutureImpl; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor; import org.apache.ignite.internal.processors.dr.GridDrType; @@ -725,7 +725,7 @@ private void loadData(Collection entries, GridFutur keys.add(new KeyCacheObjectWrapper(e.getKey())); } - load0(entries, fut, keys, 0); + load0(entries, fut, keys, 0, null, null); } /** {@inheritDoc} */ @@ -798,13 +798,18 @@ private void acquireRemapSemaphore() throws IgniteInterruptedCheckedException { * @param resFut Result future. * @param activeKeys Active keys. * @param remaps Remaps count. + * @param remapNode Node for remap. In case update with {@code allowOverride() == false} fails on one node, + * we don't need to send update request to all affinity nodes again, if topology version does not changed. + * @param remapTopVer Topology version. */ private void load0( Collection entries, final GridFutureAdapter resFut, @Nullable final Collection activeKeys, - final int remaps - ) { + final int remaps, + ClusterNode remapNode, + AffinityTopologyVersion remapTopVer + ) { try { assert entries != null; @@ -876,7 +881,10 @@ else if (rcvr != null) if (key.partition() == -1) key.partition(cctx.affinity().partition(key, false)); - nodes = nodes(key, topVer, cctx); + if (!allowOverwrite() && remapNode != null && F.eq(topVer, remapTopVer)) + nodes = Collections.singletonList(remapNode); + else + nodes = nodes(key, topVer, cctx); } catch (IgniteCheckedException e) { resFut.onDone(e); @@ -903,6 +911,7 @@ else if (rcvr != null) } for (final Map.Entry> e : mappings.entrySet()) { + final ClusterNode node = e.getKey(); final UUID nodeId = e.getKey().id(); Buffer buf = bufMappings.get(nodeId); @@ -964,7 +973,7 @@ else if (remaps + 1 > maxRemapCnt) { if (cancelled) closedException(); - load0(entriesForNode, resFut, activeKeys, remaps + 1); + load0(entriesForNode, resFut, activeKeys, remaps + 1, node, topVer); } catch (Throwable ex) { resFut.onDone( @@ -2195,11 +2204,11 @@ protected static class IsolatedUpdater implements StreamReceiver cctx = internalCache.context(); - AffinityTopologyVersion topVer = cctx.isLocal() ? - cctx.affinity().affinityTopologyVersion() : - cctx.shared().exchange().readyAffinityVersion(); + GridDhtTopologyFuture topFut = cctx.shared().exchange().lastFinishedFuture(); + + AffinityTopologyVersion topVer = topFut.topologyVersion(); GridCacheVersion ver = cctx.versions().isolatedStreamerVersion(); @@ -2260,6 +2269,13 @@ else if (ttl == CU.TTL_NOT_CHANGED) expiryTime = CU.toExpireTime(ttl); } + if (topFut != null) { + Throwable err = topFut.validateCache(cctx, false, false, entry.key(), null); + + if (err != null) + throw new IgniteCheckedException(err); + } + boolean primary = cctx.affinity().primaryByKey(cctx.localNode(), entry.key(), topVer); entry.initialValue(e.getValue(), @@ -2271,7 +2287,7 @@ else if (ttl == CU.TTL_NOT_CHANGED) primary ? GridDrType.DR_LOAD : GridDrType.DR_PRELOAD, false); - entry.touch(topVer); + entry.touch(); CU.unwindEvicts(cctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java index f70ee9c486fa0..87313de15ebd2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerRequest.java @@ -369,7 +369,7 @@ public int partition() { writer.incrementState(); case 13: - if (!writer.writeMessage("topVer", topVer)) + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -508,7 +508,7 @@ public int partition() { reader.incrementState(); case 13: - topVer = reader.readMessage("topVer"); + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerResponse.java index 4cb46e1582022..56f37c2cf0b98 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerResponse.java @@ -169,4 +169,4 @@ public boolean forceLocalDeployment() { @Override public byte fieldsCount() { return 3; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/AtomicDataStructureProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/AtomicDataStructureProxy.java index 2c336a052e648..17672341b2118 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/AtomicDataStructureProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/AtomicDataStructureProxy.java @@ -149,7 +149,7 @@ private IllegalStateException removedError() { * @return Error. */ private IllegalStateException suspendedError() { - throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(suspendFut), "Underlying cache is restarting: " + ctx.name()); + throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(suspendFut), ctx.name()); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java index 92671e00d2e6f..18b21211c2e2c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java @@ -705,6 +705,10 @@ private void removeDataStructure( }); } + /** + * Would suspend calls for this cache if it is atomics cache. + * @param cacheName To suspend. + */ public void suspend(String cacheName) { for (Map.Entry e : dsMap.entrySet()) { String cacheName0 = ATOMICS_CACHE_NAME + "@" + e.getKey().groupName(); @@ -714,12 +718,24 @@ public void suspend(String cacheName) { } } - public void restart(IgniteInternalCache cache) { + + /** + * Would return this cache to normal work if it was suspened (and if it is atomics cache). + * @param cacheName To restart. + */ + public void restart(String cacheName, IgniteInternalCache cache) { for (Map.Entry e : dsMap.entrySet()) { String cacheName0 = ATOMICS_CACHE_NAME + "@" + e.getKey().groupName(); - if (cacheName0.equals(cache.name())) - e.getValue().restart(cache); + if (cacheName0.equals(cacheName)) { + if (cache != null) + e.getValue().restart(cache); + else { + e.getValue().onRemoved(); + + dsMap.remove(e.getKey(), e.getValue()); + } + } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheRemovable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheRemovable.java index d26a153f0289d..aa66ae01fe614 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheRemovable.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheRemovable.java @@ -35,7 +35,14 @@ public interface GridCacheRemovable { */ public void needCheckNotRemoved(); + /** + * Would suspend calls for this object. + */ public void suspend(); + /** + * Would return this object work to normal. + * @param cache To update with. + */ public void restart(IgniteInternalCache cache); } \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetProxy.java index 729f6ebdb6c4e..541ca3026ac89 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetProxy.java @@ -365,7 +365,7 @@ public void blockOnRemove() { if (delegate.separated()) { IgniteInternalFuture fut = cctx.kernalContext().cache().dynamicDestroyCache( - cctx.cache().name(), false, true, false); + cctx.cache().name(), false, true, false, null); ((GridFutureAdapter)fut).ignoreInterrupts(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/failure/FailureProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/failure/FailureProcessor.java index 319b4d6647857..e47115a103c88 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/failure/FailureProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/failure/FailureProcessor.java @@ -24,6 +24,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.failure.FailureContext; import org.apache.ignite.failure.FailureHandler; +import org.apache.ignite.failure.NoOpFailureHandler; import org.apache.ignite.failure.StopNodeOrHaltFailureHandler; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.GridProcessorAdapter; @@ -78,6 +79,13 @@ public FailureProcessor(GridKernalContext ctx) { U.quietAndInfo(log, "Configured failure handler: [hnd=" + hnd + ']'); } + /** + * @return @{code True} if a node will be stopped by current handler in near time. + */ + public boolean nodeStopping() { + return failureCtx != null && !(hnd instanceof NoOpFailureHandler); + } + /** * This method is used to initialize local failure handler if {@link IgniteConfiguration} don't contain configured one. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopDirectShuffleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopDirectShuffleMessage.java index f6bddb64fa366..e990cb3cd7303 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopDirectShuffleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopDirectShuffleMessage.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.hadoop.shuffle; import org.apache.ignite.internal.GridDirectTransient; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.processors.hadoop.HadoopJobId; import org.apache.ignite.internal.processors.hadoop.message.HadoopMessage; import org.apache.ignite.internal.util.tostring.GridToStringInclude; @@ -35,6 +36,7 @@ /** * Direct shuffle message. */ +@IgniteCodeGeneratingFail public class HadoopDirectShuffleMessage implements Message, HadoopMessage { /** */ private static final long serialVersionUID = 0L; @@ -268,4 +270,4 @@ public int dataLength() { @Override public String toString() { return S.toString(HadoopDirectShuffleMessage.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java index 07b8c2fd1635a..2660e281f20de 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java @@ -23,6 +23,7 @@ import java.nio.ByteBuffer; import java.util.concurrent.atomic.AtomicLong; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.processors.hadoop.HadoopJobId; import org.apache.ignite.internal.processors.hadoop.message.HadoopMessage; import org.apache.ignite.internal.util.GridUnsafe; @@ -36,6 +37,7 @@ /** * Shuffle message. */ +@IgniteCodeGeneratingFail public class HadoopShuffleMessage implements Message, HadoopMessage { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java index 5ae3fed3e47e0..76a08f9877aab 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAckMessage.java @@ -195,4 +195,4 @@ public IgniteCheckedException error() { @Override public byte fieldsCount() { return 3; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java index 736525de1489a..98bf306a479df 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java @@ -297,4 +297,4 @@ public boolean evictExclude() { @Override public String toString() { return S.toString(IgfsBlockKey.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlocksMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlocksMessage.java index 2ec54b2ed0663..5448c50b9352d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlocksMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlocksMessage.java @@ -176,4 +176,4 @@ public Map blocks() { @Override public byte fieldsCount() { return 3; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java index 412c45baf6daf..7f5daa617bdb7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsCommunicationMessage.java @@ -77,4 +77,4 @@ public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws @Override public byte fieldsCount() { return 0; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java index b5e96664b4634..2c2c98c82f18b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteMessage.java @@ -190,4 +190,4 @@ public IgniteCheckedException error() { @Override public String toString() { return S.toString(IgfsDeleteMessage.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerRequest.java index bb605b857641c..c64b627dac641 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerRequest.java @@ -157,4 +157,4 @@ public Collection fragmentRanges() { @Override public byte fieldsCount() { return 2; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerResponse.java index 76793bfeb6d0e..f7857dcfad154 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerResponse.java @@ -118,4 +118,4 @@ public IgniteUuid fileId() { @Override public byte fieldsCount() { return 1; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSyncMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSyncMessage.java index 2b32084b7f3e6..2707de543002e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSyncMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSyncMessage.java @@ -149,4 +149,4 @@ public boolean response() { @Override public byte fieldsCount() { return 2; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerAbstractConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerAbstractConnectionContext.java index 1c19d5599cd20..14fcf9d9f631d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerAbstractConnectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerAbstractConnectionContext.java @@ -65,10 +65,8 @@ public GridKernalContext kernalContext() { return ctx; } - /** - * @return Security context. - */ - @Nullable public SecurityContext securityContext() { + /** {@inheritDoc} */ + @Nullable @Override public SecurityContext securityContext() { return secCtx; } @@ -128,4 +126,10 @@ private AuthenticationContext authenticateExternal(String user, String pwd) thro return authCtx; } + + /** {@inheritDoc} */ + @Override public void onDisconnected() { + if (ctx.security().enabled()) + ctx.security().onSessionExpired(secCtx.subject().id()); + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerConnectionContext.java index b693cb6f6ef38..c39bfe20a443a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerConnectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerConnectionContext.java @@ -20,6 +20,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.binary.BinaryReaderExImpl; import org.apache.ignite.internal.processors.authentication.AuthorizationContext; +import org.apache.ignite.internal.processors.security.SecurityContext; import org.jetbrains.annotations.Nullable; /** @@ -76,4 +77,9 @@ void initializeFromHandshake(ClientListenerProtocolVersion ver, BinaryReaderExIm * @return authorization context. */ @Nullable AuthorizationContext authorizationContext(); + + /** + * @return Security context. + */ + @Nullable SecurityContext securityContext(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java index 0eb6ac4d480e3..debef427d3f8b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java @@ -27,11 +27,14 @@ import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream; import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream; import org.apache.ignite.internal.binary.streams.BinaryInputStream; +import org.apache.ignite.internal.processors.authentication.AuthorizationContext; import org.apache.ignite.internal.processors.authentication.IgniteAccessControlException; import org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext; import org.apache.ignite.internal.processors.odbc.odbc.OdbcConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientStatus; +import org.apache.ignite.internal.processors.security.SecurityContext; +import org.apache.ignite.internal.processors.security.SecurityContextHolder; import org.apache.ignite.internal.util.GridSpinBusyLock; import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter; import org.apache.ignite.internal.util.nio.GridNioSession; @@ -159,7 +162,23 @@ public ClientListenerNioListener(GridKernalContext ctx, GridSpinBusyLock busyLoc ses.remoteAddress() + ", req=" + req + ']'); } - ClientListenerResponse resp = handler.handle(req); + ClientListenerResponse resp; + + AuthorizationContext authCtx = connCtx.authorizationContext(); + SecurityContext oldSecCtx = SecurityContextHolder.push(connCtx.securityContext()); + + if (authCtx != null) + AuthorizationContext.context(authCtx); + + try { + resp = handler.handle(req); + } + finally { + SecurityContextHolder.pop(oldSecCtx); + + if (authCtx != null) + AuthorizationContext.clear(); + } if (resp != null) { if (log.isDebugEnabled()) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java index c80136d140c9b..8ba07903cbd9d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java @@ -207,5 +207,7 @@ public JdbcConnectionContext(GridKernalContext ctx, GridNioSession ses, GridSpin /** {@inheritDoc} */ @Override public void onDisconnected() { handler.onDisconnect(); + + super.onDisconnected(); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java index d59788c3d6d9b..e58b7efab214c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java @@ -404,41 +404,32 @@ private ClientListenerResponse processBulkLoadFileBatch(JdbcBulkLoadBatchRequest * or due to {@code IOException} during network operations. */ public void onDisconnect() { - if (busyLock.enterBusy()) - { - if (worker != null) { - worker.cancel(); + if (worker != null) { + worker.cancel(); - try { - worker.join(); - } - catch (InterruptedException e) { - // No-op. - } + try { + worker.join(); } + catch (InterruptedException e) { + // No-op. + } + } - try - { - for (JdbcQueryCursor cursor : qryCursors.values()) - cursor.close(); - - for (JdbcBulkLoadProcessor processor : bulkLoadRequests.values()) { - try { - processor.close(); - } - catch (Exception e) { - U.error(null, "Error closing JDBC bulk load processor.", e); - } - } - - bulkLoadRequests.clear(); + for (JdbcQueryCursor cursor : qryCursors.values()) + cursor.close(); - U.close(cliCtx, log); + for (JdbcBulkLoadProcessor processor : bulkLoadRequests.values()) { + try { + processor.close(); } - finally { - busyLock.leaveBusy(); + catch (Exception e) { + U.error(null, "Error closing JDBC bulk load processor.", e); } } + + bulkLoadRequests.clear(); + + U.close(cliCtx, log); } /** @@ -1013,8 +1004,11 @@ private ClientListenerResponse getPrimaryKeys(JdbcMetaPrimaryKeysRequest req) { table.keyFieldName(); if (fields.isEmpty()) { + String keyColName = + table.keyFieldName() == null ? QueryUtils.KEY_FIELD_NAME : table.keyFieldName(); + meta.add(new JdbcPrimaryKeyMeta(table.schemaName(), table.tableName(), keyName, - Collections.singletonList("_KEY"))); + Collections.singletonList(keyColName))); } else meta.add(new JdbcPrimaryKeyMeta(table.schemaName(), table.tableName(), keyName, fields)); @@ -1079,7 +1073,7 @@ private JdbcResponse exceptionToResult(Exception e) { if (e instanceof IgniteSQLException) return new JdbcResponse(((IgniteSQLException) e).statusCode(), e.getMessage()); else - return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN, e.toString()); + return new JdbcResponse(IgniteQueryErrorCode.UNKNOWN, e.getMessage()); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java index 5592aabe0ce35..bf5d2132d1b76 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java @@ -146,7 +146,9 @@ public OdbcConnectionContext(GridKernalContext ctx, GridNioSession ses, GridSpin if (ver.compareTo(VER_2_5_0) >= 0) { user = reader.readString(); passwd = reader.readString(); + } + if (ver.compareTo(VER_2_7_0) >= 0) { byte nestedTxModeVal = reader.readByte(); nestedTxMode = NestedTxMode.fromByte(nestedTxModeVal); @@ -188,5 +190,7 @@ public OdbcConnectionContext(GridKernalContext ctx, GridNioSession ses, GridSpin /** {@inheritDoc} */ @Override public void onDisconnected() { handler.onDisconnect(); + + super.onDisconnected(); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java index 723ce5c56cc05..10cfd6dbc2f18 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java @@ -868,15 +868,12 @@ private static boolean matchesTableType(String str, String ptrn) { if (str == null) return false; - String pattern = ptrn.toUpperCase().replace("%", ".*").replace("_", "."); + String pattern = OdbcUtils.preprocessPattern(ptrn); String[] types = pattern.split(","); for (String type0 : types) { - String type = type0.trim(); - - if (type.length() >= 2 && type.matches("['\"].*['\"]")) - type = type.substring(1, type.length() - 1); + String type = OdbcUtils.removeQuotationMarksIfNeeded(type0.trim()); if (str.toUpperCase().matches(type)) return true; @@ -899,10 +896,7 @@ private static boolean matches(String str, String ptrn) { if (str == null) return false; - String pattern = ptrn.toUpperCase().replace("%", ".*").replace("_", "."); - - if (pattern.length() >= 2 && pattern.matches("['\"].*['\"]")) - pattern = pattern.substring(1, pattern.length() - 1); + String pattern = OdbcUtils.preprocessPattern(ptrn); return str.toUpperCase().matches(pattern); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java index a1c67aad62f3d..d294ac25c583f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java @@ -25,6 +25,7 @@ import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.processors.odbc.SqlListenerDataTypes; import org.apache.ignite.internal.processors.query.IgniteSQLException; +import org.apache.ignite.internal.util.typedef.F; /** * Various ODBC utility methods. @@ -56,6 +57,27 @@ public static String removeQuotationMarksIfNeeded(String str) { return str; } + /** + * Pre-process table or column pattern. + * + * @param ptrn Pattern to pre-process. + * @return Processed pattern. + */ + public static String preprocessPattern(String ptrn) { + if (F.isEmpty(ptrn)) + return ptrn; + + String ptrn0 = ' ' + removeQuotationMarksIfNeeded(ptrn.toUpperCase()); + + ptrn0 = ptrn0.replaceAll("([^\\\\])%", "$1.*"); + + ptrn0 = ptrn0.replaceAll("([^\\\\])_", "$1."); + + ptrn0 = ptrn0.replaceAll("\\\\(.)", "$1"); + + return ptrn0.substring(1); + } + /** * Private constructor. */ @@ -173,6 +195,7 @@ public static String tryRetrieveH2ErrorMessage(Throwable err) { String msg = err.getMessage(); Throwable e = err.getCause(); + while (e != null) { if (e.getClass().getCanonicalName().equals("org.h2.jdbc.JdbcSQLException")) { msg = e.getMessage(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java index ffe38ca68870f..5e68c34ec56ef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java @@ -143,6 +143,8 @@ public ClientResourceRegistry resources() { /** {@inheritDoc} */ @Override public void onDisconnected() { resReg.clean(); + + super.onDisconnected(); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java index 799b3e733f410..76823b592ce32 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequest.java @@ -19,9 +19,6 @@ import org.apache.ignite.binary.BinaryRawReader; import org.apache.ignite.internal.processors.odbc.ClientListenerRequest; -import org.apache.ignite.internal.processors.security.SecurityContext; -import org.apache.ignite.plugin.security.SecurityException; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Thin client request. @@ -61,30 +58,4 @@ public ClientRequest(long reqId) { public ClientResponse process(ClientConnectionContext ctx) { return new ClientResponse(reqId); } - - /** - * Run the code with converting {@link SecurityException} to {@link IgniteClientException}. - */ - protected static void runWithSecurityExceptionHandler(Runnable runnable) { - try { - runnable.run(); - } - catch (SecurityException ex) { - throw new IgniteClientException( - ClientStatus.SECURITY_VIOLATION, - "Client is not authorized to perform this operation", - ex - ); - } - } - - /** - * Authorize for specified permission. - */ - protected void authorize(ClientConnectionContext ctx, SecurityPermission perm) { - SecurityContext secCtx = ctx.securityContext(); - - if (secCtx != null) - runWithSecurityExceptionHandler(() -> ctx.kernalContext().security().authorize(null, perm, secCtx)); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java index 5ed0d38d8eac5..8fe4e5df12df7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java @@ -22,7 +22,7 @@ import org.apache.ignite.internal.processors.odbc.ClientListenerRequest; import org.apache.ignite.internal.processors.odbc.ClientListenerRequestHandler; import org.apache.ignite.internal.processors.odbc.ClientListenerResponse; -import org.apache.ignite.internal.processors.security.SecurityContextHolder; +import org.apache.ignite.plugin.security.SecurityException; /** * Thin client request handler. @@ -48,19 +48,15 @@ public class ClientRequestHandler implements ClientListenerRequestHandler { /** {@inheritDoc} */ @Override public ClientListenerResponse handle(ClientListenerRequest req) { - if (authCtx != null) { - AuthorizationContext.context(authCtx); - SecurityContextHolder.set(ctx.securityContext()); - } - try { return ((ClientRequest)req).process(ctx); } - finally { - if (authCtx != null) - AuthorizationContext.clear(); - - SecurityContextHolder.clear(); + catch (SecurityException ex) { + throw new IgniteClientException( + ClientStatus.SECURITY_VIOLATION, + "Client is not authorized to perform this operation", + ex + ); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java index 5f8e952234bf8..6bcbbe89b2636 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java @@ -20,7 +20,6 @@ import org.apache.ignite.internal.binary.BinaryRawReaderEx; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Clear key request. @@ -38,8 +37,6 @@ public ClientCacheClearKeyRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_REMOVE); - cache(ctx).clear(key()); return super.process(ctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java index d803f697420f3..04eb7f60c9502 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java @@ -20,7 +20,6 @@ import org.apache.ignite.internal.binary.BinaryRawReaderEx; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Clear keys request. @@ -38,8 +37,6 @@ public ClientCacheClearKeysRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_REMOVE); - cache(ctx).clearAll(keys()); return super.process(ctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java index 7b84522921c7c..0e5f20de1eb1b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java @@ -20,7 +20,6 @@ import org.apache.ignite.binary.BinaryRawReader; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache clear request. @@ -38,8 +37,6 @@ public ClientCacheClearRequest(BinaryRawReader reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_REMOVE); - cache(ctx).clear(); return super.process(ctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java index 386f448bb4b53..8470828e424a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * ContainsKey request. @@ -39,8 +38,6 @@ public ClientCacheContainsKeyRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ); - boolean val = cache(ctx).containsKey(key()); return new ClientBooleanResponse(requestId(), val); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java index b5184bfc1afc9..41e13068db1f5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * ContainsKeys request. @@ -39,8 +38,6 @@ public ClientCacheContainsKeysRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ); - boolean val = cache(ctx).containsKeys(keys()); return new ClientBooleanResponse(requestId(), val); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheCreateWithConfigurationRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheCreateWithConfigurationRequest.java index 9f1d63fccabc2..93a18edc77e9d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheCreateWithConfigurationRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheCreateWithConfigurationRequest.java @@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse; import org.apache.ignite.internal.processors.platform.client.ClientStatus; import org.apache.ignite.internal.processors.platform.client.IgniteClientException; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache create with configuration request. @@ -50,12 +49,10 @@ public ClientCacheCreateWithConfigurationRequest(BinaryRawReader reader, ClientL /** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_CREATE); - try { - // Use security exception handler since the code authorizes "enable on-heap cache" permission - runWithSecurityExceptionHandler(() -> ctx.kernalContext().grid().createCache(cacheCfg)); - } catch (CacheExistsException e) { + ctx.kernalContext().grid().createCache(cacheCfg); + } + catch (CacheExistsException e) { throw new IgniteClientException(ClientStatus.CACHE_EXISTS, e.getMessage()); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheCreateWithNameRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheCreateWithNameRequest.java index cacf099b4f81f..526eb6cdeb01a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheCreateWithNameRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheCreateWithNameRequest.java @@ -24,7 +24,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse; import org.apache.ignite.internal.processors.platform.client.ClientStatus; import org.apache.ignite.internal.processors.platform.client.IgniteClientException; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache create with name request. @@ -46,11 +45,10 @@ public ClientCacheCreateWithNameRequest(BinaryRawReader reader) { /** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_CREATE); - try { ctx.kernalContext().grid().createCache(cacheName); - } catch (CacheExistsException e) { + } + catch (CacheExistsException e) { throw new IgniteClientException(ClientStatus.CACHE_EXISTS, e.getMessage()); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheDestroyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheDestroyRequest.java index b6f85eec3d9fc..6645a03a06b4f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheDestroyRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheDestroyRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientRequest; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache destroy request. @@ -43,8 +42,6 @@ public ClientCacheDestroyRequest(BinaryRawReader reader) { /** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_DESTROY); - String cacheName = ClientCacheRequest.cacheDescriptor(ctx, cacheId).cacheName(); ctx.kernalContext().grid().destroyCache(cacheName); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java index a07305c4ce14b..d07da1cf46cb4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java @@ -22,7 +22,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse; import java.util.Map; -import org.apache.ignite.plugin.security.SecurityPermission; /** * GetAll request. @@ -40,9 +39,7 @@ public ClientCacheGetAllRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ); - - Map val = cache(ctx).getAll(keys()); + Map val = cache(ctx).getAll(keys()); return new ClientCacheGetAllResponse(requestId(), val); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java index 8713a211bb4eb..836021313c5fc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache get and put if absent request. @@ -39,8 +38,6 @@ public ClientCacheGetAndPutIfAbsentRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ, SecurityPermission.CACHE_PUT); - Object res = cache(ctx).getAndPutIfAbsent(key(), val()); return new ClientObjectResponse(requestId(), res); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java index dde5181303cef..7a540e8473ac9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache get and put request. @@ -39,8 +38,6 @@ public ClientCacheGetAndPutRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ, SecurityPermission.CACHE_PUT); - Object res = cache(ctx).getAndPut(key(), val()); return new ClientObjectResponse(requestId(), res); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java index 3b9dd4bab88c3..e4fd735b186ac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache get and remove request. @@ -39,8 +38,6 @@ public ClientCacheGetAndRemoveRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ, SecurityPermission.CACHE_REMOVE); - Object val = cache(ctx).getAndRemove(key()); return new ClientObjectResponse(requestId(), val); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java index 8ba157a762c9c..dba8639e4c07a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache get and replace request. @@ -39,8 +38,6 @@ public ClientCacheGetAndReplaceRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ, SecurityPermission.CACHE_PUT); - Object res = cache(ctx).getAndReplace(key(), val()); return new ClientObjectResponse(requestId(), res); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetOrCreateWithConfigurationRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetOrCreateWithConfigurationRequest.java index b005fb235cf9f..77368beed7695 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetOrCreateWithConfigurationRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetOrCreateWithConfigurationRequest.java @@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse; import org.apache.ignite.internal.processors.platform.client.ClientStatus; import org.apache.ignite.internal.processors.platform.client.IgniteClientException; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache get or create with configuration request. @@ -50,12 +49,10 @@ public ClientCacheGetOrCreateWithConfigurationRequest(BinaryRawReader reader, Cl /** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_CREATE); - try { - // Use security exception handler since the code authorizes "enable on-heap cache" permission - runWithSecurityExceptionHandler(() -> ctx.kernalContext().grid().getOrCreateCache(cacheCfg)); - } catch (CacheExistsException e) { + ctx.kernalContext().grid().getOrCreateCache(cacheCfg); + } + catch (CacheExistsException e) { throw new IgniteClientException(ClientStatus.CACHE_EXISTS, e.getMessage()); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetOrCreateWithNameRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetOrCreateWithNameRequest.java index 3c4ce7b06a694..94dd115d6075f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetOrCreateWithNameRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetOrCreateWithNameRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientRequest; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache create with name request. @@ -43,8 +42,6 @@ public ClientCacheGetOrCreateWithNameRequest(BinaryRawReader reader) { /** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_CREATE); - ctx.kernalContext().grid().getOrCreateCache(cacheName); return super.process(ctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java index dc17cbfbce548..41558c2863d03 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache get request. @@ -39,8 +38,6 @@ public ClientCacheGetRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ); - Object val = cache(ctx).get(key()); return new ClientObjectResponse(requestId(), val); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java index 474c206b8cae3..ba185bf7415d8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java @@ -22,7 +22,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientLongResponse; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache size request. @@ -51,8 +50,6 @@ public ClientCacheGetSizeRequest(BinaryRawReader reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ); - long res = cache(ctx).sizeLong(modes); return new ClientLongResponse(requestId(), res); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheLocalPeekRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheLocalPeekRequest.java index 068bbc9792c18..2002664d00714 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheLocalPeekRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheLocalPeekRequest.java @@ -22,7 +22,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache local peek request. @@ -41,8 +40,6 @@ public ClientCacheLocalPeekRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ); - Object val = cache(ctx).localPeek(key(), CachePeekMode.ALL); return new ClientObjectResponse(requestId(), val); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java index b9bf80e60608f..abc9acf646ba1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java @@ -29,7 +29,6 @@ import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cluster node list request. @@ -46,12 +45,10 @@ public ClientCacheNodePartitionsRequest(BinaryRawReader reader) { /** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ); IgniteCache cache = cache(ctx); GridDiscoveryManager discovery = ctx.kernalContext().discovery(); - Collection nodes = discovery.cacheNodes(cache.getName(), - new AffinityTopologyVersion(discovery.topologyVersion())); + Collection nodes = discovery.discoCache().cacheNodes(cache.getName()); Affinity aff = ctx.kernalContext().affinity().affinityProxy(cache.getName()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java index 57e31443b474a..28a7fa57e3ee5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java @@ -23,7 +23,6 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.apache.ignite.plugin.security.SecurityPermission; /** * PutAll request. @@ -51,8 +50,6 @@ public ClientCachePutAllRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_PUT); - cache(ctx).putAll(map); return super.process(ctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java index ec81bc0c0fe48..4dd2cde58ce06 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache put if absent request. @@ -39,8 +38,6 @@ public ClientCachePutIfAbsentRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ, SecurityPermission.CACHE_PUT); - boolean res = cache(ctx).putIfAbsent(key(), val()); return new ClientBooleanResponse(requestId(), res); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java index 116460eece965..2c396b7ede87a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java @@ -20,7 +20,6 @@ import org.apache.ignite.internal.binary.BinaryRawReaderEx; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache put request. @@ -38,8 +37,6 @@ public ClientCachePutRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_PUT); - cache(ctx).put(key(), val()); return super.process(ctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java index d90d873968105..f5adc6378912e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java @@ -20,7 +20,6 @@ import org.apache.ignite.binary.BinaryRawReader; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache removeAll request. @@ -38,8 +37,6 @@ public ClientCacheRemoveAllRequest(BinaryRawReader reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_REMOVE); - cache(ctx).removeAll(); return super.process(ctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java index 26c191f5b5553..b86f2f8895d64 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache remove request with value. @@ -39,8 +38,6 @@ public ClientCacheRemoveIfEqualsRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ, SecurityPermission.CACHE_REMOVE); - boolean res = cache(ctx).remove(key(), val()); return new ClientBooleanResponse(requestId(), res); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java index 5af9743b3cac3..a68c32730f4fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Remove request. @@ -39,8 +38,6 @@ public ClientCacheRemoveKeyRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_REMOVE); - boolean val = cache(ctx).remove(key()); return new ClientBooleanResponse(requestId(), val); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java index 62dea00201af8..043b5688a3f43 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java @@ -20,7 +20,6 @@ import org.apache.ignite.internal.binary.BinaryRawReaderEx; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Remove keys request. @@ -38,8 +37,6 @@ public ClientCacheRemoveKeysRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_REMOVE); - cache(ctx).removeAll(keys()); return super.process(ctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java index 056367d71d2a9..8645fbb817322 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache replace request. @@ -44,8 +43,6 @@ public ClientCacheReplaceIfEqualsRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ, SecurityPermission.CACHE_PUT); - boolean res = cache(ctx).replace(key(), val(), newVal); return new ClientBooleanResponse(requestId(), res); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java index ea04593e7cf15..bd7a642bb39e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; import org.apache.ignite.internal.processors.platform.client.ClientResponse; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache replace request. @@ -39,8 +38,6 @@ public ClientCacheReplaceRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ, SecurityPermission.CACHE_PUT); - boolean res = cache(ctx).replace(key(), val()); return new ClientBooleanResponse(requestId(), res); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java index 9e39b5618c686..52b799f345120 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java @@ -24,8 +24,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientRequest; import org.apache.ignite.internal.processors.platform.client.ClientStatus; import org.apache.ignite.internal.processors.platform.client.IgniteClientException; -import org.apache.ignite.internal.processors.security.SecurityContext; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Cache get request. @@ -121,34 +119,4 @@ public static DynamicCacheDescriptor cacheDescriptor(ClientConnectionContext ctx protected int cacheId() { return cacheId; } - - /** {@inheritDoc} */ - @Override protected void authorize(ClientConnectionContext ctx, SecurityPermission perm) { - SecurityContext secCtx = ctx.securityContext(); - - if (secCtx != null) { - DynamicCacheDescriptor cacheDesc = cacheDescriptor(ctx, cacheId); - - runWithSecurityExceptionHandler(() -> { - ctx.kernalContext().security().authorize(cacheDesc.cacheName(), perm, secCtx); - }); - } - } - - /** - * Authorize for multiple permissions. - */ - protected void authorize(ClientConnectionContext ctx, SecurityPermission... perm) - throws IgniteClientException { - SecurityContext secCtx = ctx.securityContext(); - - if (secCtx != null) { - DynamicCacheDescriptor cacheDesc = cacheDescriptor(ctx, cacheId); - - runWithSecurityExceptionHandler(() -> { - for (SecurityPermission p : perm) - ctx.kernalContext().security().authorize(cacheDesc.cacheName(), p, secCtx); - }); - } - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheScanQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheScanQueryRequest.java index 70b6966e999c4..26ab236e8be1e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheScanQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheScanQueryRequest.java @@ -28,7 +28,6 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse; import org.apache.ignite.internal.processors.platform.utils.PlatformUtils; import org.apache.ignite.lang.IgniteBiPredicate; -import org.apache.ignite.plugin.security.SecurityPermission; /** * Scan query request. @@ -81,8 +80,6 @@ public ClientCacheScanQueryRequest(BinaryRawReaderEx reader) { /** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { - authorize(ctx, SecurityPermission.CACHE_READ); - IgniteCache cache = filterPlatform == FILTER_PLATFORM_JAVA && !isKeepBinary() ? rawCache(ctx) : cache(ctx); ScanQuery qry = new ScanQuery() diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java index 915075afe7a34..8338a3b9849cd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java @@ -713,9 +713,11 @@ public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfigura TcpCommunicationSpi comm = new TcpCommunicationSpi(); comm.setAckSendThreshold(in.readInt()); + comm.setConnectionsPerNode(in.readInt()); comm.setConnectTimeout(in.readLong()); comm.setDirectBuffer(in.readBoolean()); comm.setDirectSendBuffer(in.readBoolean()); + comm.setFilterReachableAddresses(in.readBoolean()); comm.setIdleConnectionTimeout(in.readLong()); comm.setLocalAddress(in.readString()); comm.setLocalPort(in.readInt()); @@ -724,11 +726,15 @@ public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfigura comm.setMessageQueueLimit(in.readInt()); comm.setReconnectCount(in.readInt()); comm.setSelectorsCount(in.readInt()); + comm.setSelectorSpins(in.readLong()); + comm.setSharedMemoryPort(in.readInt()); comm.setSlowClientQueueLimit(in.readInt()); comm.setSocketReceiveBuffer(in.readInt()); comm.setSocketSendBuffer(in.readInt()); + comm.setSocketWriteTimeout(in.readLong()); comm.setTcpNoDelay(in.readBoolean()); comm.setUnacknowledgedMessagesBufferSize(in.readInt()); + comm.setUsePairedConnections(in.readBoolean()); cfg.setCommunicationSpi(comm); } @@ -1299,9 +1305,11 @@ public static void writeIgniteConfiguration(BinaryRawWriter w, IgniteConfigurati TcpCommunicationSpi tcp = (TcpCommunicationSpi) comm; w.writeInt(tcp.getAckSendThreshold()); + w.writeInt(tcp.getConnectionsPerNode()); w.writeLong(tcp.getConnectTimeout()); w.writeBoolean(tcp.isDirectBuffer()); w.writeBoolean(tcp.isDirectSendBuffer()); + w.writeBoolean(tcp.isFilterReachableAddresses()); w.writeLong(tcp.getIdleConnectionTimeout()); w.writeString(tcp.getLocalAddress()); w.writeInt(tcp.getLocalPort()); @@ -1310,11 +1318,15 @@ public static void writeIgniteConfiguration(BinaryRawWriter w, IgniteConfigurati w.writeInt(tcp.getMessageQueueLimit()); w.writeInt(tcp.getReconnectCount()); w.writeInt(tcp.getSelectorsCount()); + w.writeLong(tcp.getSelectorSpins()); + w.writeInt(tcp.getSharedMemoryPort()); w.writeInt(tcp.getSlowClientQueueLimit()); w.writeInt(tcp.getSocketReceiveBuffer()); w.writeInt(tcp.getSocketSendBuffer()); + w.writeLong(tcp.getSocketWriteTimeout()); w.writeBoolean(tcp.isTcpNoDelay()); w.writeInt(tcp.getUnacknowledgedMessagesBufferSize()); + w.writeBoolean(tcp.isUsePairedConnections()); } else w.writeBoolean(false); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java index 7aa4021d7b5a0..c048d011d9691 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java @@ -29,6 +29,7 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker; @@ -293,19 +294,12 @@ public void remove(GridCacheContext cctx, GridQueryTypeDescriptor type, CacheDat throws IgniteCheckedException; /** - * Rebuilds all indexes of given type from hash index. + * Rebuild indexes for the given cache if necessary. * - * @param cacheName Cache name. - * @throws IgniteCheckedException If failed. - */ - public void rebuildIndexesFromHash(String cacheName) throws IgniteCheckedException; - - /** - * Marks all indexes of given type for rebuild from hash index, making them unusable until rebuild finishes. - * - * @param cacheName Cache name. + * @param cctx Cache context. + * @return Future completed when index rebuild finished. */ - public void markForRebuildFromHash(String cacheName); + public IgniteInternalFuture rebuildIndexesFromHash(GridCacheContext cctx); /** * Returns backup filter. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java index accccbb123924..0e381fdfbc754 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java @@ -65,6 +65,7 @@ import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; @@ -93,8 +94,6 @@ import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashSet; import org.apache.ignite.internal.util.GridSpinBusyLock; -import org.apache.ignite.internal.util.future.GridCompoundFuture; -import org.apache.ignite.internal.util.future.GridFinishedFuture; import org.apache.ignite.internal.util.lang.GridCloseableIterator; import org.apache.ignite.internal.util.lang.GridClosureException; import org.apache.ignite.internal.util.lang.IgniteOutClosureX; @@ -106,8 +105,6 @@ import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.util.worker.GridWorker; -import org.apache.ignite.internal.util.worker.GridWorkerFuture; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteInClosure; @@ -152,7 +149,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { private final ConcurrentMap typesByName = new ConcurrentHashMap<>(); /** */ - private final GridQueryIndexing idx; + private final @Nullable GridQueryIndexing idx; /** Value object context. */ private final CacheQueryObjectValueContext valCtx; @@ -1540,6 +1537,9 @@ else if (QueryUtils.TEMPLATE_REPLICATED.equalsIgnoreCase(templateName)) ccfg.setSqlEscapeAll(true); ccfg.setQueryEntities(Collections.singleton(entity)); + if (!QueryUtils.isCustomAffinityMapper(ccfg.getAffinityMapper())) + ccfg.setAffinityMapper(null); + if (affinityKey != null) ccfg.setKeyConfiguration(new CacheKeyConfiguration(entity.getKeyType(), affinityKey)); @@ -1752,78 +1752,45 @@ public boolean belongsToTable(GridCacheContext cctx, String expCacheName, String /** * Rebuilds indexes for provided caches from corresponding hash indexes. * - * @param cacheIds Cache IDs. + * @param cctx Cache context. * @return Future that will be completed when rebuilding is finished. */ - public IgniteInternalFuture rebuildIndexesFromHash(Set cacheIds) { - if (!busyLock.enterBusy()) - throw new IllegalStateException("Failed to rebuild indexes from hash (grid is stopping)."); - - // Because of alt type ids, there can be few entries in 'types' for a single cache. - // In order to avoid processing a cache more than once, let's track processed names. - Set processedCacheNames = new HashSet<>(); - - try { - GridCompoundFuture fut = new GridCompoundFuture(); - - for (Map.Entry e : types.entrySet()) { - if (cacheIds.contains(CU.cacheId(e.getKey().cacheName())) && - processedCacheNames.add(e.getKey().cacheName())) - fut.add(rebuildIndexesFromHash(e.getKey().cacheName(), e.getValue())); - } - - fut.markInitialized(); - - return fut; - } - finally { - busyLock.leaveBusy(); - } - } - - /** - * @param cacheName Cache name. - * @param desc Type descriptor. - * @return Future that will be completed when rebuilding of all indexes is finished. - */ - private IgniteInternalFuture rebuildIndexesFromHash(@Nullable final String cacheName, - @Nullable final QueryTypeDescriptorImpl desc) { + public IgniteInternalFuture rebuildIndexesFromHash(GridCacheContext cctx) { + // Indexing module is disabled, nothing to rebuild. if (idx == null) - return new GridFinishedFuture<>(new IgniteCheckedException("Indexing is disabled.")); - - if (desc == null) - return new GridFinishedFuture<>(); - - final GridWorkerFuture fut = new GridWorkerFuture<>(); + return null; - idx.markForRebuildFromHash(cacheName); + // No data on non-affinity nodes. + if (!cctx.affinityNode()) + return null; - GridWorker w = new GridWorker(ctx.igniteInstanceName(), "index-rebuild-worker", log) { - @Override protected void body() { - try { - idx.rebuildIndexesFromHash(cacheName); + // No indexes to rebuild when there are no QueryEntities. + if (!cctx.isQueryEnabled()) + return null; - fut.onDone(); - } - catch (Exception e) { - fut.onDone(e); - } - catch (Throwable e) { - U.error(log, "Failed to rebuild indexes for type [cache=" + cacheName + - ", name=" + desc.name() + ']', e); + // No need to rebuild if cache has no data. + boolean empty = true; - fut.onDone(e); + for (IgniteCacheOffheapManager.CacheDataStore store : cctx.offheap().cacheDataStores()) { + if (!store.isEmpty()) { + empty = false; - throw e; - } + break; } - }; + } - fut.setWorker(w); + if (empty) + return null; - ctx.getExecutorService().execute(w); + if (!busyLock.enterBusy()) + throw new IllegalStateException("Failed to rebuild indexes from hash (grid is stopping)."); - return fut; + try { + return idx.rebuildIndexesFromHash(cctx); + } + finally { + busyLock.leaveBusy(); + } } /** @@ -2162,9 +2129,6 @@ public List>> querySqlFields(@Nullable final GridCache */ private static void validateSqlFieldsQuery(SqlFieldsQuery qry, GridKernalContext ctx, @Nullable GridCacheContext cctx) { - if (qry.isReplicatedOnly() && qry.getPartitions() != null) - throw new CacheException("Partitions are not supported in replicated only mode."); - if (qry.isDistributedJoins() && qry.getPartitions() != null) throw new CacheException("Using both partitions and distributed JOINs is not supported for the same query"); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java index 2eaeb1feadb32..e02b7dfd859e5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryTypeDescriptorImpl.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.query; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -36,10 +37,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.jetbrains.annotations.Nullable; +import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.KEY_SCALE_OUT_OF_RANGE; import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.NULL_KEY; import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.NULL_VALUE; import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.TOO_LONG_KEY; import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.TOO_LONG_VALUE; +import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.VALUE_SCALE_OUT_OF_RANGE; import static org.apache.ignite.internal.processors.query.QueryUtils.KEY_FIELD_NAME; import static org.apache.ignite.internal.processors.query.QueryUtils.VAL_FIELD_NAME; @@ -580,14 +583,30 @@ else if (F.eq(prop.name(), valFieldName) || (valFieldName == null && F.eq(prop.n isKey ? NULL_KEY : NULL_VALUE); } - if (prop.precision() != -1 && - propVal != null && - String.class == propVal.getClass() && + if (propVal == null || prop.precision() == -1) + continue; + + if (String.class == propVal.getClass() && ((String)propVal).length() > prop.precision()) { throw new IgniteSQLException("Value for a column '" + prop.name() + "' is too long. " + "Maximum length: " + prop.precision() + ", actual length: " + ((CharSequence)propVal).length(), isKey ? TOO_LONG_KEY : TOO_LONG_VALUE); } + else if (BigDecimal.class == propVal.getClass()) { + BigDecimal dec = (BigDecimal)propVal; + + if (dec.precision() > prop.precision()) { + throw new IgniteSQLException("Value for a column '" + prop.name() + "' is out of range. " + + "Maximum precision: " + prop.precision() + ", actual precision: " + dec.precision(), + isKey ? TOO_LONG_KEY : TOO_LONG_VALUE); + } + else if (prop.scale() != -1 && + dec.scale() > prop.scale()) { + throw new IgniteSQLException("Value for a column '" + prop.name() + "' is out of range. " + + "Maximum scale : " + prop.scale() + ", actual scale: " + dec.scale(), + isKey ? KEY_SCALE_OUT_OF_RANGE : VALUE_SCALE_OUT_OF_RANGE); + } + } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java index d977a49006648..e19247c0ffafa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java @@ -67,6 +67,8 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_INDEXING_DISCOVERY_HISTORY_SIZE; import static org.apache.ignite.IgniteSystemProperties.getInteger; +import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.TOO_LONG_VALUE; +import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.VALUE_SCALE_OUT_OF_RANGE; /** * Utility methods for queries. @@ -825,17 +827,10 @@ public static QueryBinaryProperty buildBinaryProperty(GridKernalContext ctx, Str public static QueryClassProperty buildClassProperty(Class keyCls, Class valCls, String pathStr, Class resType, Map aliases, boolean notNull, CacheObjectContext coCtx) throws IgniteCheckedException { - QueryClassProperty res = buildClassProperty( - true, - keyCls, - pathStr, - resType, - aliases, - notNull, - coCtx); - - if (res == null) // We check key before value consistently with BinaryProperty. - res = buildClassProperty(false, valCls, pathStr, resType, aliases, notNull, coCtx); + QueryClassProperty res = buildClassProperty(false, valCls, pathStr, resType, aliases, notNull, coCtx); + + if (res == null) // We check value before key consistently with BinaryProperty. + res = buildClassProperty(true, keyCls, pathStr, resType, aliases, notNull, coCtx); if (res == null) throw new IgniteCheckedException(propertyInitializationExceptionMessage(keyCls, valCls, pathStr, resType)); @@ -1271,6 +1266,7 @@ private static void validateQueryEntity(QueryEntity entity) { Map dfltVals = entity.getDefaultFieldValues(); Map precision = entity.getFieldsPrecision(); + Map scale = entity.getFieldsScale(); if (!F.isEmpty(precision)) { for (String fld : precision.keySet()) { @@ -1282,9 +1278,23 @@ private static void validateQueryEntity(QueryEntity entity) { if (dfltVal == null) continue; - if (dfltVal.toString().length() > precision.get(fld)) { + if (dfltVal.getClass() == String.class && dfltVal.toString().length() > precision.get(fld)) { throw new IgniteSQLException("Default value '" + dfltVal + - "' is longer than maximum length " + precision.get(fld)); + "' is longer than maximum length " + precision.get(fld), TOO_LONG_VALUE); + } + else if (dfltVal.getClass() == BigDecimal.class) { + BigDecimal dec = (BigDecimal)dfltVal; + + if (dec.precision() > precision.get(fld)) { + throw new IgniteSQLException("Default value: '" + dfltVal + "' for a column " + fld + + " is out of range. Maximum precision: " + precision.get(fld) + + ", actual precision: " + dec.precision(), TOO_LONG_VALUE); + } + else if (!F.isEmpty(scale) && scale.containsKey(fld) && dec.scale() > scale.get(fld)) { + throw new IgniteSQLException("Default value:: '" + dfltVal + "' for a column " + fld + + " is out of range. Maximum scale: " + scale.get(fld) + + ", actual scale: " + dec.scale(), VALUE_SCALE_OUT_OF_RANGE); + } } } } @@ -1355,6 +1365,18 @@ public static void checkNotNullAllowed(CacheConfiguration cfg) { "is set.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION); } + /** + * Checks whether affinity key mapper is custom or default. + * + * @param affinityKeyMapper Affinity key mapper. + * @return {@code true} if affinity key mapper is custom. + */ + public static boolean isCustomAffinityMapper(AffinityKeyMapper affinityKeyMapper) { + return affinityKeyMapper != null && + !(affinityKeyMapper instanceof CacheDefaultBinaryAffinityKeyMapper) && + !(affinityKeyMapper instanceof GridCacheDefaultAffinityKeyMapper); + } + /** * Checks if given column can be removed from table using its {@link QueryEntity}. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java index 6b976c24179cf..7fdd5d6a57ceb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java @@ -220,7 +220,7 @@ public Collection plainRows() { writer.incrementState(); case 6: - if (!writer.writeMessage("retry", retry)) + if (!writer.writeAffinityTopologyVersion("retry", retry)) return false; writer.incrementState(); @@ -310,7 +310,7 @@ public Collection plainRows() { reader.incrementState(); case 6: - retry = reader.readMessage("retry"); + retry = reader.readAffinityTopologyVersion("retry"); if (!reader.isLastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/property/QueryBinaryProperty.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/property/QueryBinaryProperty.java index 7a47c2fb3f1a3..3f2d233a75cfe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/property/QueryBinaryProperty.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/property/QueryBinaryProperty.java @@ -131,11 +131,11 @@ public QueryBinaryProperty(GridKernalContext ctx, String propName, QueryBinaryPr if (isKeyProp0 == 0) { // Key is allowed to be a non-binary object here. - // We check key before value consistently with ClassProperty. - if (key instanceof BinaryObject && ((BinaryObject)key).hasField(propName)) - isKeyProp = isKeyProp0 = 1; - else if (val instanceof BinaryObject && ((BinaryObject)val).hasField(propName)) + // We check value before key consistently with ClassProperty. + if (val instanceof BinaryObject && ((BinaryObject)val).hasField(propName)) isKeyProp = isKeyProp0 = -1; + else if (key instanceof BinaryObject && ((BinaryObject)key).hasField(propName)) + isKeyProp = isKeyProp0 = 1; else { if (!warned) { U.warn(log, "Neither key nor value have property \"" + propName + "\" " + diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java index 57a1a49de7cb5..7c40cd12cb848 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java @@ -19,7 +19,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.IgniteInterruptedCheckedException; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException; @@ -244,7 +243,7 @@ private void processKey(KeyCacheObject key, SchemaIndexCacheVisitorClosure clo) entry.updateIndex(rowFilter, clo); } finally { - entry.touch(AffinityTopologyVersion.NONE); + entry.touch(); } break; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/message/SchemaOperationStatusMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/message/SchemaOperationStatusMessage.java index 5f75e607d4173..9e81d5a84b432 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/message/SchemaOperationStatusMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/message/SchemaOperationStatusMessage.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.query.schema.message; import org.apache.ignite.internal.GridDirectTransient; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageReader; @@ -30,6 +31,7 @@ /** * Schema operation status message. */ +@IgniteCodeGeneratingFail public class SchemaOperationStatusMessage implements Message { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java index 587ed2ee8c1de..4046b1572a213 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java @@ -176,6 +176,18 @@ public enum GridRestCommand { /** */ CLUSTER_CURRENT_STATE("currentstate"), + /** */ + BASELINE_CURRENT_STATE("baseline"), + + /** */ + BASELINE_SET("setbaseline"), + + /** */ + BASELINE_ADD("addbaseline"), + + /** */ + BASELINE_REMOVE("removebaseline"), + /** */ AUTHENTICATE("authenticate"), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java index 30d2f0a1328d2..f24c4d33a88ad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java @@ -49,6 +49,7 @@ import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandler; import org.apache.ignite.internal.processors.rest.handlers.auth.AuthenticationCommandHandler; import org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler; +import org.apache.ignite.internal.processors.rest.handlers.cluster.GridBaselineCommandHandler; import org.apache.ignite.internal.processors.rest.handlers.cluster.GridChangeStateCommandHandler; import org.apache.ignite.internal.processors.rest.handlers.datastructures.DataStructuresCommandHandler; import org.apache.ignite.internal.processors.rest.handlers.log.GridLogCommandHandler; @@ -500,6 +501,9 @@ public GridRestProcessor(GridKernalContext ctx) { if (ses.isTimedOut(sesTtl)) { clientId2SesId.remove(ses.clientId, ses.sesId); sesId2Ses.remove(ses.sesId, ses); + + if (ctx.security().enabled() && ses.secCtx != null && ses.secCtx.subject() != null) + ctx.security().onSessionExpired(ses.secCtx.subject().id()); } } } @@ -528,6 +532,7 @@ public GridRestProcessor(GridKernalContext ctx) { addHandler(new GridChangeStateCommandHandler(ctx)); addHandler(new AuthenticationCommandHandler(ctx)); addHandler(new UserActionCommandHandler(ctx)); + addHandler(new GridBaselineCommandHandler(ctx)); // Start protocols. startTcpProtocol(); @@ -892,6 +897,9 @@ private void authorize(GridRestRequest req, SecurityContext sCtx) throws Securit case CLUSTER_INACTIVE: case CLUSTER_ACTIVATE: case CLUSTER_DEACTIVATE: + case BASELINE_SET: + case BASELINE_ADD: + case BASELINE_REMOVE: perm = SecurityPermission.ADMIN_OPS; break; @@ -909,6 +917,7 @@ private void authorize(GridRestRequest req, SecurityContext sCtx) throws Securit case NAME: case LOG: case CLUSTER_CURRENT_STATE: + case BASELINE_CURRENT_STATE: case AUTHENTICATE: case ADD_USER: case REMOVE_USER: diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridBaselineCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridBaselineCommandHandler.java new file mode 100644 index 0000000000000..88fde87464647 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridBaselineCommandHandler.java @@ -0,0 +1,205 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.rest.handlers.cluster; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cluster.BaselineNode; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.cluster.IgniteClusterEx; +import org.apache.ignite.internal.processors.rest.GridRestCommand; +import org.apache.ignite.internal.processors.rest.GridRestResponse; +import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandlerAdapter; +import org.apache.ignite.internal.processors.rest.request.GridRestBaselineRequest; +import org.apache.ignite.internal.processors.rest.request.GridRestRequest; +import org.apache.ignite.internal.util.future.GridFinishedFuture; +import org.apache.ignite.internal.util.typedef.internal.U; + +import static java.util.function.Function.identity; +import static java.util.stream.Collectors.toMap; +import static org.apache.ignite.internal.processors.rest.GridRestCommand.BASELINE_ADD; +import static org.apache.ignite.internal.processors.rest.GridRestCommand.BASELINE_CURRENT_STATE; +import static org.apache.ignite.internal.processors.rest.GridRestCommand.BASELINE_REMOVE; +import static org.apache.ignite.internal.processors.rest.GridRestCommand.BASELINE_SET; + +/** + * + */ +public class GridBaselineCommandHandler extends GridRestCommandHandlerAdapter { + /** Supported commands. */ + private static final Collection SUPPORTED_COMMANDS = U.sealList(BASELINE_CURRENT_STATE, + BASELINE_SET, BASELINE_ADD, BASELINE_REMOVE); + + /** + * @param ctx Context. + */ + public GridBaselineCommandHandler(GridKernalContext ctx) { + super(ctx); + } + + /** {@inheritDoc} */ + @Override public Collection supportedCommands() { + return SUPPORTED_COMMANDS; + } + + /** {@inheritDoc} */ + @Override public IgniteInternalFuture handleAsync(GridRestRequest req) { + assert req != null; + + assert SUPPORTED_COMMANDS.contains(req.command()); + assert req instanceof GridRestBaselineRequest : "Invalid type of baseline request."; + + + if (log.isDebugEnabled()) + log.debug("Handling baseline REST request: " + req); + + GridRestBaselineRequest req0 = (GridRestBaselineRequest)req; + + try { + IgniteClusterEx cluster = ctx.grid().cluster(); + + List consistentIds = req0.consistentIds(); + + switch (req0.command()) { + case BASELINE_CURRENT_STATE: { + // No-op. + + break; + } + + case BASELINE_SET: { + Long topVer = req0.topologyVersion(); + + if (topVer == null && consistentIds == null) + throw new IgniteCheckedException("Failed to handle request (either topVer or consistentIds should be specified)."); + + if (topVer != null) + cluster.setBaselineTopology(topVer); + else + cluster.setBaselineTopology(filterServerNodesByConsId(consistentIds)); + + break; + } + + case BASELINE_ADD: { + if (consistentIds == null) + throw new IgniteCheckedException(missingParameter("consistentIds")); + + Set baselineTop = new HashSet<>(currentBaseLine()); + + baselineTop.addAll(filterServerNodesByConsId(consistentIds)); + + cluster.setBaselineTopology(baselineTop); + + break; + } + + case BASELINE_REMOVE: { + if (consistentIds == null) + throw new IgniteCheckedException(missingParameter("consistentIds")); + + Collection baseline = currentBaseLine(); + + Set baselineTop = new HashSet<>(baseline); + + baselineTop.removeAll(filterNodesByConsId(baseline, consistentIds)); + + cluster.setBaselineTopology(baselineTop); + + break; + } + + default: + assert false : "Invalid command for baseline handler: " + req; + } + + return new GridFinishedFuture<>(new GridRestResponse(currentState())); + } + catch (IgniteCheckedException e) { + return new GridFinishedFuture<>(e); + } + finally { + if (log.isDebugEnabled()) + log.debug("Handled baseline REST request: " + req); + } + } + + /** + * @return Current baseline. + */ + private Collection currentBaseLine() { + Collection baselineNodes = ctx.grid().cluster().currentBaselineTopology(); + + return baselineNodes != null ? baselineNodes : Collections.emptyList(); + } + + /** + * Collect baseline topology command result. + * + * @return Baseline descriptor. + */ + private GridBaselineCommandResponse currentState() { + IgniteClusterEx cluster = ctx.grid().cluster(); + + Collection srvrs = cluster.forServers().nodes(); + + return new GridBaselineCommandResponse(cluster.active(), cluster.topologyVersion(), currentBaseLine(), srvrs); + } + + /** + * Filter passed nodes by consistent IDs. + * + * @param nodes Collection of nodes. + * @param consistentIds Collection of consistent IDs. + * @throws IllegalStateException In case of some consistent ID not found in nodes collection. + */ + private Collection filterNodesByConsId(Collection nodes, List consistentIds) { + Map nodeMap = + nodes.stream().collect(toMap(n -> n.consistentId().toString(), identity())); + + Collection filtered = new ArrayList<>(consistentIds.size()); + + for (Object consistentId : consistentIds) { + BaselineNode node = nodeMap.get(consistentId); + + if (node == null) + throw new IllegalStateException("Node not found for consistent ID: " + consistentId); + + filtered.add(node); + } + + return filtered; + } + + /** + * Filter server nodes by consistent IDs. + * + * @param consistentIds Collection of consistent IDs to add. + * @throws IllegalStateException In case of some consistent ID not found in nodes collection. + */ + private Collection filterServerNodesByConsId(List consistentIds) { + return filterNodesByConsId(ctx.grid().cluster().forServers().nodes(), consistentIds); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridBaselineCommandResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridBaselineCommandResponse.java new file mode 100644 index 0000000000000..aae16c0ec1ad9 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridBaselineCommandResponse.java @@ -0,0 +1,161 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.rest.handlers.cluster; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Collection; +import org.apache.ignite.cluster.BaselineNode; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +import static java.util.stream.Collectors.toList; + +/** + * Result for baseline command. + */ +public class GridBaselineCommandResponse implements Externalizable { + /** */ + private static final long serialVersionUID = 0L; + + /** Cluster state. */ + private boolean active; + + /** Current topology version. */ + private long topVer; + + /** Current baseline nodes. */ + private Collection baseline; + + /** Current server nodes. */ + private Collection srvs; + + /** + * @param nodes Nodes to process. + * @return Collection of consistentIds. + */ + private static Collection consistentIds(Collection nodes) { + return nodes.stream().map(n -> String.valueOf(n.consistentId())).collect(toList()); + } + + /** + * Default constructor. + */ + public GridBaselineCommandResponse() { + // No-op. + } + + /** + * Constructor. + * + * @param active Cluster state. + * @param topVer Current topology version. + * @param baseline Current baseline nodes. + * @param srvs Current server nodes. + */ + GridBaselineCommandResponse( + boolean active, + long topVer, + Collection baseline, + Collection srvs + ) { + this.active = active; + this.topVer = topVer; + this.baseline = consistentIds(baseline); + this.srvs = consistentIds(srvs); + } + + /** + * @return Cluster state. + */ + public boolean isActive() { + return active; + } + + /** + * @param active Cluster active. + */ + public void setActive(boolean active) { + this.active = active; + } + + /** + * @return Current topology version. + */ + public long getTopologyVersion() { + return topVer; + } + + /** + * @param topVer Current topology version. + */ + public void setTopologyVersion(long topVer) { + this.topVer = topVer; + } + + /** + * @return Baseline nodes. + */ + public Collection getBaseline() { + return baseline; + } + + /** + * @param baseline Baseline nodes. + */ + public void setBaseline(Collection baseline) { + this.baseline = baseline; + } + + /** + * @return Server nodes. + */ + public Collection getServers() { + return srvs; + } + + /** + * @param srvs Server nodes. + */ + public void setServers(Collection srvs) { + this.srvs = srvs; + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeBoolean(active); + out.writeLong(topVer); + U.writeCollection(out, baseline); + U.writeCollection(out, srvs); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + active = in.readBoolean(); + topVer = in.readLong(); + baseline = U.readCollection(in); + srvs = U.readCollection(in); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridBaselineCommandResponse.class, this); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java index b8b4edbf01bb7..f3ec0e8afacaf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java @@ -171,4 +171,4 @@ public void topic(String topic) { @Override public byte fieldsCount() { return 2; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index b9bb27c067182..88b42f5e80a5c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -217,4 +217,4 @@ public void error(String err) { @Override public byte fieldsCount() { return 4; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java index 0390936e77395..edcb3741bc331 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java @@ -97,6 +97,7 @@ public GridTopologyCommandHandler(GridKernalContext ctx) { boolean mtr = req0.includeMetrics(); boolean attr = req0.includeAttributes(); + boolean caches = req0.includeCaches(); switch (req.command()) { case TOPOLOGY: { @@ -107,7 +108,7 @@ public GridTopologyCommandHandler(GridKernalContext ctx) { new ArrayList<>(allNodes.size()); for (ClusterNode node : allNodes) - top.add(createNodeBean(node, mtr, attr)); + top.add(createNodeBean(node, mtr, attr, caches)); res.setResponse(top); @@ -143,7 +144,7 @@ public boolean apply(ClusterNode n) { }); if (node != null) - res.setResponse(createNodeBean(node, mtr, attr)); + res.setResponse(createNodeBean(node, mtr, attr, caches)); else res.setResponse(null); @@ -196,14 +197,15 @@ public GridClientCacheBean createCacheBean(CacheConfiguration ccfg) { } /** - * Creates node bean out of grid node. Notice that cache attribute is handled separately. + * Creates node bean out of cluster node. Notice that cache attribute is handled separately. * - * @param node Grid node. - * @param mtr {@code true} to add metrics. - * @param attr {@code true} to add attributes. + * @param node Cluster node. + * @param mtr Whether to include node metrics. + * @param attr Whether to include node attributes. + * @param caches Whether to include node caches. * @return Grid Node bean. */ - private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr) { + private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr, boolean caches) { assert node != null; GridClientNodeBean nodeBean = new GridClientNodeBean(); @@ -216,14 +218,16 @@ private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean nodeBean.setTcpAddresses(nonEmptyList(node.>attribute(ATTR_REST_TCP_ADDRS))); nodeBean.setTcpHostNames(nonEmptyList(node.>attribute(ATTR_REST_TCP_HOST_NAMES))); - Map nodeCaches = ctx.discovery().nodePublicCaches(node); + if (caches) { + Map nodeCaches = ctx.discovery().nodePublicCaches(node); - Collection caches = new ArrayList<>(nodeCaches.size()); + Collection cacheBeans = new ArrayList<>(nodeCaches.size()); - for (CacheConfiguration ccfg : nodeCaches.values()) - caches.add(createCacheBean(ccfg)); + for (CacheConfiguration ccfg : nodeCaches.values()) + cacheBeans.add(createCacheBean(ccfg)); - nodeBean.setCaches(caches); + nodeBean.setCaches(cacheBeans); + } if (mtr) { ClusterMetrics metrics = node.metrics(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestBaselineRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestBaselineRequest.java new file mode 100644 index 0000000000000..a3aa042e5d0db --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestBaselineRequest.java @@ -0,0 +1,65 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.rest.request; + +import java.util.List; +import org.apache.ignite.internal.util.typedef.internal.S; + +/** + * Grid command topology request. + */ +public class GridRestBaselineRequest extends GridRestRequest { + /** Topology version to set. */ + private Long topVer; + + /** Collection of consistent IDs to set. */ + private List consistentIds; + + /** + * @return Topology version to set. + */ + public Long topologyVersion() { + return topVer; + } + + /** + * @param topVer New topology version to set. + */ + public void topologyVersion(Long topVer) { + this.topVer = topVer; + } + + /** + * @return Collection of consistent IDs to set. + */ + public List consistentIds() { + return consistentIds; + } + + /** + * @param consistentIds New collection of consistent IDs to set. + */ + public void consistentIds(List consistentIds) { + this.consistentIds = consistentIds; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridRestBaselineRequest.class, this, super.toString()); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTopologyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTopologyRequest.java index b02836743f67b..fadd178945e2b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTopologyRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTopologyRequest.java @@ -36,6 +36,9 @@ public class GridRestTopologyRequest extends GridRestRequest { /** Include node attributes flag. */ private boolean includeAttrs; + /** Include caches flag. With default value for compatibility. */ + private boolean includeCaches = true; + /** * @return Include metrics flag. */ @@ -64,6 +67,20 @@ public void includeAttributes(boolean includeAttrs) { this.includeAttrs = includeAttrs; } + /** + * @return Include caches flag. + */ + public boolean includeCaches() { + return includeCaches; + } + + /** + * @param includeCaches Include caches flag. + */ + public void includeCaches(boolean includeCaches) { + this.includeCaches = includeCaches; + } + /** * @return Node identifier, if specified, {@code null} otherwise. */ @@ -96,4 +113,4 @@ public void nodeIp(String nodeIp) { @Override public String toString() { return S.toString(GridRestTopologyRequest.class, this, super.toString()); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/security/SecurityContextHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/security/SecurityContextHolder.java index 14d70c97cbfdb..d01071166ea73 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/security/SecurityContextHolder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/security/SecurityContextHolder.java @@ -39,15 +39,22 @@ public class SecurityContextHolder { * Set security context. * * @param ctx Context. + * @return Old context. */ - public static void set(@Nullable SecurityContext ctx) { + public static SecurityContext push(@Nullable SecurityContext ctx) { + SecurityContext oldCtx = CTX.get(); + CTX.set(ctx); + + return oldCtx; } /** - * Clear security context. + * Pop security context. + * + * @param oldCtx Old context. */ - public static void clear() { - set(null); + public static void pop(@Nullable SecurityContext oldCtx) { + CTX.set(oldCtx); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java index 9007472b034f5..b81665e32002f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java @@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.LongAdder; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; @@ -54,6 +55,7 @@ import org.apache.ignite.internal.GridTaskSessionRequest; import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException; import org.apache.ignite.internal.IgniteDeploymentCheckedException; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.compute.ComputeTaskCancelledCheckedException; import org.apache.ignite.internal.managers.communication.GridIoManager; @@ -69,7 +71,9 @@ import org.apache.ignite.internal.util.typedef.C1; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorTaskArgument; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteUuid; @@ -77,6 +81,7 @@ import org.apache.ignite.plugin.security.SecurityPermission; import org.jetbrains.annotations.Nullable; +import static org.apache.ignite.events.EventType.EVT_MANAGEMENT_TASK_STARTED; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; import static org.apache.ignite.events.EventType.EVT_NODE_LEFT; import static org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET; @@ -187,7 +192,24 @@ private IgniteClientDisconnectedCheckedException disconnectedError(@Nullable Ign /** {@inheritDoc} */ @SuppressWarnings("TooBroadScope") @Override public void onKernalStop(boolean cancel) { - lock.writeLock(); + boolean interrupted = false; + + while (true) { + try { + if (lock.tryWriteLock(1, TimeUnit.SECONDS)) + break; + else { + LT.warn(log, "Still waiting to acquire write lock on stop"); + + U.sleep(50); + } + } + catch (IgniteInterruptedCheckedException | InterruptedException e) { + LT.warn(log, "Stopping thread was interrupted while waiting for write lock (will wait anyway)"); + + interrupted = true; + } + } try { stopping = true; @@ -196,6 +218,9 @@ private IgniteClientDisconnectedCheckedException disconnectedError(@Nullable Ign } finally { lock.writeUnlock(); + + if (interrupted) + Thread.currentThread().interrupt(); } startLatch.countDown(); @@ -471,7 +496,7 @@ public String resolveTaskName(int taskNameHash) { try { return taskMetaCache().localPeek( - new GridTaskNameHashKey(taskNameHash), null, null); + new GridTaskNameHashKey(taskNameHash), null); } catch (IgniteCheckedException e) { throw new IgniteException(e); @@ -679,7 +704,10 @@ else if (task != null) { top = nodes != null ? F.nodeIds(nodes) : null; } - UUID subjId = getThreadContext(TC_SUBJ_ID); + UUID subjId = (UUID)map.get(TC_SUBJ_ID); + + if (subjId == null) + subjId = getThreadContext(TC_SUBJ_ID); if (subjId == null) subjId = ctx.localNodeId(); @@ -742,6 +770,24 @@ else if (task != null) { assert taskWorker0 == null : "Session ID is not unique: " + sesId; + if (ctx.event().isRecordable(EVT_MANAGEMENT_TASK_STARTED) && dep.visorManagementTask(task, taskCls)) { + VisorTaskArgument visorTaskArgument = (VisorTaskArgument)arg; + + Event evt = new TaskEvent( + ctx.discovery().localNode(), + visorTaskArgument != null && visorTaskArgument.getArgument() != null + ? visorTaskArgument.getArgument().toString() : "[]", + EVT_MANAGEMENT_TASK_STARTED, + ses.getId(), + taskCls == null ? null : taskCls.getSimpleName(), + "VisorManagementTask", + false, + subjId + ); + + ctx.event().record(evt); + } + if (!ctx.clientDisconnected()) { if (dep.annotation(taskCls, ComputeTaskMapAsync.class) != null) { try { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridVisorManagementTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridVisorManagementTask.java new file mode 100644 index 0000000000000..09c87bf017964 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridVisorManagementTask.java @@ -0,0 +1,38 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.task; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Indicates that annotated task is a visor task that was invoked by user. They can be handled by event listeners. + * + * This annotation intended for internal use only. + */ +@Documented +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface GridVisorManagementTask { + // No-op. +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java index 0200d7747002e..e9c7d016bdb4c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java @@ -491,4 +491,4 @@ public InputStream inputStream() { @Override public String toString() { return S.toString(GridByteArrayList.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java index ebe2e0765c787..c54584a78c4f1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java @@ -600,4 +600,4 @@ public GridIntIterator iterator() { } }; } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java index d1f20e634a03c..1c022b0a4ce5c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java @@ -26,6 +26,7 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.NoSuchElementException; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.SB; @@ -38,10 +39,14 @@ * Minimal list API to work with primitive longs. This list exists * to avoid boxing/unboxing when using standard list from Java. */ +@IgniteCodeGeneratingFail public class GridLongList implements Message, Externalizable { /** */ private static final long serialVersionUID = 0L; + /** Empty array. */ + public static final long[] EMPTY_ARRAY = new long[0]; + /** */ private long[] arr; @@ -390,6 +395,9 @@ public int replaceValue(int startIdx, long oldVal, long newVal) { * @return Array copy. */ public long[] array() { + if (arr == null) + return EMPTY_ARRAY; + long[] res = new long[idx]; System.arraycopy(arr, 0, res, 0, idx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteStopwatch.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteStopwatch.java new file mode 100644 index 0000000000000..83cd7bc8d3ba6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteStopwatch.java @@ -0,0 +1,230 @@ +/* + * 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. + */ + +/* + * Copyright (C) 2008 The Guava Authors + */ + +package org.apache.ignite.internal.util; + +import java.time.Duration; +import java.util.concurrent.TimeUnit; +import org.jetbrains.annotations.NotNull; + +import static java.util.concurrent.TimeUnit.DAYS; +import static java.util.concurrent.TimeUnit.HOURS; +import static java.util.concurrent.TimeUnit.MICROSECONDS; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.MINUTES; +import static java.util.concurrent.TimeUnit.NANOSECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; + +/** + * An object that measures elapsed time in nanoseconds. It is useful to measure elapsed time using + * this class instead of direct calls to {@link System#nanoTime} for a few reasons: + * + *
    + *
  • An alternate time source can be substituted, for testing or performance reasons. + *
  • As documented by {@code nanoTime}, the value returned has no absolute meaning, and can only + * be interpreted as relative to another timestamp returned by {@code nanoTime} at a different + * time. {@code Stopwatch} is a more effective abstraction because it exposes only these + * relative values, not the absolute ones. + *
+ * + *

Basic usage: + * + *

{@code
+ * Stopwatch stopwatch = Stopwatch.createStarted();
+ * doSomething();
+ * stopwatch.stop(); // optional
+ *
+ * Duration duration = stopwatch.elapsed();
+ *
+ * log.info("time: " + stopwatch); // formatted string like "12.3 ms"
+ * }
+ * + *

Stopwatch methods are not idempotent; it is an error to start or stop a stopwatch that is + * already in the desired state. + * + *

When testing code that uses this class, use {@link #createUnstarted(IgniteTicker)} or {@link + * #createStarted(IgniteTicker)} to supply a fake or mock ticker. This allows you to simulate any valid + * behavior of the stopwatch. + * + *

Note: This class is not thread-safe. + * + *

Warning for Android users: a stopwatch with default behavior may not continue to keep + * time while the device is asleep. Instead, create one like this: + * + *

{@code
+ * Stopwatch.createStarted(
+ *      new Ticker() {
+ *        public long read() {
+ *          return android.os.SystemClock.elapsedRealtimeNanos();
+ *        }
+ *      });
+ * }
+ */ +@SuppressWarnings("GoodTime") // lots of violations +public final class IgniteStopwatch { + /** Ticker. */ + private final IgniteTicker ticker; + /** Is running. */ + private boolean isRunning; + /** Elapsed nanos. */ + private long elapsedNanos; + /** Start tick. */ + private long startTick; + + /** + * Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source. + */ + public static IgniteStopwatch createUnstarted() { + return new IgniteStopwatch(); + } + + /** + * Creates (but does not start) a new stopwatch, using the specified time source. + */ + public static IgniteStopwatch createUnstarted(IgniteTicker ticker) { + return new IgniteStopwatch(ticker); + } + + /** + * Creates (and starts) a new stopwatch using {@link System#nanoTime} as its time source. + */ + public static IgniteStopwatch createStarted() { + return new IgniteStopwatch().start(); + } + + /** + * Creates (and starts) a new stopwatch, using the specified time source. + */ + public static IgniteStopwatch createStarted(IgniteTicker ticker) { + return new IgniteStopwatch(ticker).start(); + } + + /** + * Default constructor. + */ + IgniteStopwatch() { + this.ticker = IgniteTicker.systemTicker(); + } + + /** + * @param ticker Ticker. + */ + IgniteStopwatch(@NotNull IgniteTicker ticker) { + this.ticker = ticker; + } + + /** + * Returns {@code true} if {@link #start()} has been called on this stopwatch, and {@link #stop()} + * has not been called since the last call to {@code start()}. + */ + public boolean isRunning() { + return isRunning; + } + + /** + * Starts the stopwatch. + * + * @return this {@code Stopwatch} instance + * @throws IllegalStateException if the stopwatch is already running. + */ + public IgniteStopwatch start() { + assert !isRunning : "This stopwatch is already running."; + + isRunning = true; + + startTick = ticker.read(); + + return this; + } + + /** + * Stops the stopwatch. Future reads will return the fixed duration that had elapsed up to this + * point. + * + * @return this {@code Stopwatch} instance + * @throws IllegalStateException if the stopwatch is already stopped. + */ + public IgniteStopwatch stop() { + long tick = ticker.read(); + + assert !isRunning : "This stopwatch is already running."; + + isRunning = false; + elapsedNanos += tick - startTick; + return this; + } + + /** + * Sets the elapsed time for this stopwatch to zero, and places it in a stopped state. + * + * @return this {@code Stopwatch} instance + */ + public IgniteStopwatch reset() { + elapsedNanos = 0; + + isRunning = false; + + return this; + } + + /** + * + */ + private long elapsedNanos() { + return isRunning ? ticker.read() - startTick + elapsedNanos : elapsedNanos; + } + + /** + * Returns the current elapsed time shown on this stopwatch, expressed in the desired time unit, + * with any fraction rounded down. + * + *

Note: the overhead of measurement can be more than a microsecond, so it is generally + * not useful to specify {@link TimeUnit#NANOSECONDS} precision here. + * + *

It is generally not a good idea to use an ambiguous, unitless {@code long} to represent + * elapsed time. Therefore, we recommend using {@link #elapsed()} instead, which returns a + * strongly-typed {@link Duration} instance. + */ + public long elapsed(TimeUnit desiredUnit) { + return desiredUnit.convert(elapsedNanos(), NANOSECONDS); + } + + /** + * Returns the current elapsed time shown on this stopwatch as a {@link Duration}. Unlike {@link + * #elapsed(TimeUnit)}, this method does not lose any precision due to rounding. + */ + public Duration elapsed() { + return Duration.ofNanos(elapsedNanos()); + } + + /** + * @param nanos Nanos. + */ + private static TimeUnit chooseUnit(long nanos) { + if (DAYS.convert(nanos, NANOSECONDS) > 0) return DAYS; + if (HOURS.convert(nanos, NANOSECONDS) > 0) return HOURS; + if (MINUTES.convert(nanos, NANOSECONDS) > 0) return MINUTES; + if (SECONDS.convert(nanos, NANOSECONDS) > 0) return SECONDS; + if (MILLISECONDS.convert(nanos, NANOSECONDS) > 0) return MILLISECONDS; + if (MICROSECONDS.convert(nanos, NANOSECONDS) > 0) return MICROSECONDS; + return NANOSECONDS; + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteTicker.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteTicker.java new file mode 100644 index 0000000000000..1f7f41d9a8d76 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteTicker.java @@ -0,0 +1,52 @@ +/* + * 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. + */ + +/* + * Copyright (C) 2011 The Guava Authors + */ + +package org.apache.ignite.internal.util; + +/** + * A time source; returns a time value representing the number of nanoseconds elapsed since some + * fixed but arbitrary point in time. Note that most users should use {@link IgniteStopwatch} instead of + * interacting with this class directly. + * + *

Warning: this interface can only be used to measure elapsed time, not wall time. + */ +public abstract class IgniteTicker { + /** Constructor for use by subclasses. */ + protected IgniteTicker() {} + + /** Returns the number of nanoseconds elapsed since this ticker's fixed point of reference. */ + public abstract long read(); + + /** + * A ticker that reads the current time using {@link System#nanoTime}. + */ + public static IgniteTicker systemTicker() { + return SYSTEM_TICKER; + } + + /** System ticker. */ + private static final IgniteTicker SYSTEM_TICKER = + new IgniteTicker() { + @Override public long read() { + return System.nanoTime(); + } + }; +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index aa106f8837e30..e01f89960cc88 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -17,6 +17,114 @@ package org.apache.ignite.internal.util; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteClientDisconnectedException; +import org.apache.ignite.IgniteDeploymentException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.IgniteIllegalStateException; +import org.apache.ignite.IgniteInterruptedException; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.binary.BinaryRawReader; +import org.apache.ignite.binary.BinaryRawWriter; +import org.apache.ignite.cluster.ClusterGroupEmptyException; +import org.apache.ignite.cluster.ClusterMetrics; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.cluster.ClusterTopologyException; +import org.apache.ignite.compute.ComputeTask; +import org.apache.ignite.compute.ComputeTaskCancelledException; +import org.apache.ignite.compute.ComputeTaskName; +import org.apache.ignite.compute.ComputeTaskTimeoutException; +import org.apache.ignite.configuration.AddressResolver; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.events.EventType; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException; +import org.apache.ignite.internal.IgniteDeploymentCheckedException; +import org.apache.ignite.internal.IgniteFutureCancelledCheckedException; +import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.IgniteNodeAttributes; +import org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException; +import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; +import org.apache.ignite.internal.compute.ComputeTaskCancelledCheckedException; +import org.apache.ignite.internal.compute.ComputeTaskTimeoutCheckedException; +import org.apache.ignite.internal.events.DiscoveryCustomEvent; +import org.apache.ignite.internal.managers.communication.GridIoManager; +import org.apache.ignite.internal.managers.communication.GridIoPolicy; +import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo; +import org.apache.ignite.internal.mxbean.IgniteStandardMXBean; +import org.apache.ignite.internal.processors.cache.CacheClassLoaderMarker; +import org.apache.ignite.internal.processors.cache.GridCacheAttributes; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cluster.BaselineTopology; +import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException; +import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException; +import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException; +import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; +import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.apache.ignite.internal.util.future.IgniteFutureImpl; +import org.apache.ignite.internal.util.io.GridFilenameUtils; +import org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryNativeLoader; +import org.apache.ignite.internal.util.lang.GridClosureException; +import org.apache.ignite.internal.util.lang.GridPeerDeployAware; +import org.apache.ignite.internal.util.lang.GridTuple; +import org.apache.ignite.internal.util.lang.IgniteThrowableConsumer; +import org.apache.ignite.internal.util.typedef.C1; +import org.apache.ignite.internal.util.typedef.CI1; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.P1; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.A; +import org.apache.ignite.internal.util.typedef.internal.SB; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.util.worker.GridWorker; +import org.apache.ignite.lang.IgniteBiTuple; +import org.apache.ignite.lang.IgniteClosure; +import org.apache.ignite.lang.IgniteFutureCancelledException; +import org.apache.ignite.lang.IgniteFutureTimeoutException; +import org.apache.ignite.lang.IgniteOutClosure; +import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.lang.IgniteProductVersion; +import org.apache.ignite.lang.IgniteUuid; +import org.apache.ignite.lifecycle.LifecycleAware; +import org.apache.ignite.marshaller.Marshaller; +import org.apache.ignite.plugin.PluginProvider; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.extensions.communication.MessageWriter; +import org.apache.ignite.spi.IgniteSpi; +import org.apache.ignite.spi.IgniteSpiException; +import org.apache.ignite.spi.discovery.DiscoverySpi; +import org.apache.ignite.spi.discovery.DiscoverySpiOrderSupport; +import org.apache.ignite.transactions.TransactionDeadlockException; +import org.apache.ignite.transactions.TransactionHeuristicException; +import org.apache.ignite.transactions.TransactionOptimisticException; +import org.apache.ignite.transactions.TransactionRollbackException; +import org.apache.ignite.transactions.TransactionTimeoutException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import sun.misc.Unsafe; + +import javax.management.DynamicMBean; +import javax.management.JMException; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; +import javax.naming.Context; +import javax.naming.NamingException; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; @@ -95,7 +203,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; -import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -114,7 +221,6 @@ import java.util.ServiceLoader; import java.util.Set; import java.util.StringTokenizer; -import java.util.TimeZone; import java.util.TreeMap; import java.util.UUID; import java.util.concurrent.BrokenBarrierException; @@ -141,115 +247,12 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.zip.Deflater; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; -import javax.management.DynamicMBean; -import javax.management.JMException; -import javax.management.MBeanRegistrationException; -import javax.management.MBeanServer; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import javax.naming.Context; -import javax.naming.NamingException; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteClientDisconnectedException; -import org.apache.ignite.IgniteDeploymentException; -import org.apache.ignite.IgniteException; -import org.apache.ignite.IgniteIllegalStateException; -import org.apache.ignite.IgniteInterruptedException; -import org.apache.ignite.IgniteLogger; -import org.apache.ignite.IgniteSystemProperties; -import org.apache.ignite.binary.BinaryRawReader; -import org.apache.ignite.binary.BinaryRawWriter; -import org.apache.ignite.cluster.ClusterGroupEmptyException; -import org.apache.ignite.cluster.ClusterMetrics; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.cluster.ClusterTopologyException; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.compute.ComputeTaskCancelledException; -import org.apache.ignite.compute.ComputeTaskName; -import org.apache.ignite.compute.ComputeTaskTimeoutException; -import org.apache.ignite.configuration.AddressResolver; -import org.apache.ignite.configuration.DataRegionConfiguration; -import org.apache.ignite.configuration.DataStorageConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.events.EventType; -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException; -import org.apache.ignite.internal.IgniteDeploymentCheckedException; -import org.apache.ignite.internal.IgniteFutureCancelledCheckedException; -import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.IgniteInterruptedCheckedException; -import org.apache.ignite.internal.IgniteNodeAttributes; -import org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException; -import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; -import org.apache.ignite.internal.compute.ComputeTaskCancelledCheckedException; -import org.apache.ignite.internal.compute.ComputeTaskTimeoutCheckedException; -import org.apache.ignite.internal.events.DiscoveryCustomEvent; -import org.apache.ignite.internal.managers.communication.GridIoManager; -import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo; -import org.apache.ignite.internal.mxbean.IgniteStandardMXBean; -import org.apache.ignite.internal.processors.cache.CacheClassLoaderMarker; -import org.apache.ignite.internal.processors.cache.GridCacheAttributes; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cluster.BaselineTopology; -import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException; -import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException; -import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException; -import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; -import org.apache.ignite.internal.util.future.GridFutureAdapter; -import org.apache.ignite.internal.util.future.IgniteFutureImpl; -import org.apache.ignite.internal.util.io.GridFilenameUtils; -import org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryNativeLoader; -import org.apache.ignite.internal.util.lang.GridClosureException; -import org.apache.ignite.internal.util.lang.GridPeerDeployAware; -import org.apache.ignite.internal.util.lang.GridTuple; -import org.apache.ignite.internal.util.typedef.C1; -import org.apache.ignite.internal.util.typedef.CI1; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.internal.util.typedef.P1; -import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.internal.util.typedef.internal.A; -import org.apache.ignite.internal.util.typedef.internal.SB; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.util.worker.GridWorker; -import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.lang.IgniteClosure; -import org.apache.ignite.lang.IgniteFutureCancelledException; -import org.apache.ignite.lang.IgniteFutureTimeoutException; -import org.apache.ignite.lang.IgniteOutClosure; -import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.lang.IgniteProductVersion; -import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.lifecycle.LifecycleAware; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.plugin.PluginProvider; -import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; -import org.apache.ignite.spi.IgniteSpi; -import org.apache.ignite.spi.IgniteSpiException; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.DiscoverySpiOrderSupport; -import org.apache.ignite.transactions.TransactionDeadlockException; -import org.apache.ignite.transactions.TransactionHeuristicException; -import org.apache.ignite.transactions.TransactionOptimisticException; -import org.apache.ignite.transactions.TransactionRollbackException; -import org.apache.ignite.transactions.TransactionTimeoutException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import sun.misc.Unsafe; import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISABLE_HOSTNAME_VERIFIER; import static org.apache.ignite.IgniteSystemProperties.IGNITE_HOME; @@ -7194,137 +7197,6 @@ private static boolean checkNextToken(StringTokenizer t, String str, String date } } - /** - * - * @param str ISO date. - * @return Calendar instance. - * @throws IgniteCheckedException Thrown in case of any errors. - */ - public static Calendar parseIsoDate(String str) throws IgniteCheckedException { - StringTokenizer t = new StringTokenizer(str, "+-:.TZ", true); - - Calendar cal = Calendar.getInstance(); - cal.clear(); - - try { - if (t.hasMoreTokens()) - cal.set(Calendar.YEAR, Integer.parseInt(t.nextToken())); - else - return cal; - - if (checkNextToken(t, "-", str) && t.hasMoreTokens()) - cal.set(Calendar.MONTH, Integer.parseInt(t.nextToken()) - 1); - else - return cal; - - if (checkNextToken(t, "-", str) && t.hasMoreTokens()) - cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(t.nextToken())); - else - return cal; - - if (checkNextToken(t, "T", str) && t.hasMoreTokens()) - cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(t.nextToken())); - else { - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - - return cal; - } - - if (checkNextToken(t, ":", str) && t.hasMoreTokens()) - cal.set(Calendar.MINUTE, Integer.parseInt(t.nextToken())); - else { - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - - return cal; - } - - if (!t.hasMoreTokens()) - return cal; - - String tok = t.nextToken(); - - if (":".equals(tok)) { // Seconds. - if (t.hasMoreTokens()) { - cal.set(Calendar.SECOND, Integer.parseInt(t.nextToken())); - - if (!t.hasMoreTokens()) - return cal; - - tok = t.nextToken(); - - if (".".equals(tok)) { - String nt = t.nextToken(); - - while (nt.length() < 3) - nt += "0"; - - nt = nt.substring(0, 3); // Cut trailing chars. - - cal.set(Calendar.MILLISECOND, Integer.parseInt(nt)); - - if (!t.hasMoreTokens()) - return cal; - - tok = t.nextToken(); - } - else - cal.set(Calendar.MILLISECOND, 0); - } - else - throw new IgniteCheckedException("Invalid date format: " + str); - } - else { - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - } - - if (!"Z".equals(tok)) { - if (!"+".equals(tok) && !"-".equals(tok)) - throw new IgniteCheckedException("Invalid date format: " + str); - - boolean plus = "+".equals(tok); - - if (!t.hasMoreTokens()) - throw new IgniteCheckedException("Invalid date format: " + str); - - tok = t.nextToken(); - - int tzHour; - int tzMin; - - if (tok.length() == 4) { - tzHour = Integer.parseInt(tok.substring(0, 2)); - tzMin = Integer.parseInt(tok.substring(2, 4)); - } - else { - tzHour = Integer.parseInt(tok); - - if (checkNextToken(t, ":", str) && t.hasMoreTokens()) - tzMin = Integer.parseInt(t.nextToken()); - else - throw new IgniteCheckedException("Invalid date format: " + str); - } - - if (plus) - cal.set(Calendar.ZONE_OFFSET, (tzHour * 60 + tzMin) * 60 * 1000); - else - cal.set(Calendar.ZONE_OFFSET, -(tzHour * 60 + tzMin) * 60 * 1000); - } - else - cal.setTimeZone(TimeZone.getTimeZone("GMT")); - } - catch (NumberFormatException ex) { - throw new IgniteCheckedException("Invalid date format: " + str, ex); - } - - return cal; - } - /** * Adds values to collection and returns the same collection to allow chaining. * @@ -7430,20 +7302,6 @@ public static IgniteCheckedException cast(Throwable t) { : new IgniteCheckedException(t); } - /** - * Parses passed string with specified date. - * - * @param src String to parse. - * @param ptrn Pattern. - * @return Parsed date. - * @throws java.text.ParseException If exception occurs while parsing. - */ - public static Date parse(String src, String ptrn) throws java.text.ParseException { - java.text.DateFormat format = new java.text.SimpleDateFormat(ptrn); - - return format.parse(src); - } - /** * Checks if class loader is an internal P2P class loader. * @@ -10335,11 +10193,23 @@ public static void restoreOldIgniteName(@Nullable String oldName, @Nullable Stri } /** + * Zip binary payload using default compression. + * * @param bytes Byte array to compress. * @return Compressed bytes. * @throws IgniteCheckedException If failed. */ public static byte[] zip(@Nullable byte[] bytes) throws IgniteCheckedException { + return zip(bytes, Deflater.DEFAULT_COMPRESSION); + } + + /** + * @param bytes Byte array to compress. + * @param compressionLevel Level of compression to encode. + * @return Compressed bytes. + * @throws IgniteCheckedException If failed. + */ + public static byte[] zip(@Nullable byte[] bytes, int compressionLevel) throws IgniteCheckedException { try { if (bytes == null) return null; @@ -10347,6 +10217,8 @@ public static byte[] zip(@Nullable byte[] bytes) throws IgniteCheckedException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (ZipOutputStream zos = new ZipOutputStream(bos)) { + zos.setLevel(compressionLevel); + ZipEntry entry = new ZipEntry(""); try { @@ -10377,7 +10249,7 @@ public static byte[] zip(@Nullable byte[] bytes) throws IgniteCheckedException { public static byte[] toBytes(Serializable obj) { try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos)) { - + oos.writeObject(obj); oos.flush(); @@ -10742,6 +10614,336 @@ public static ClusterNode randomServerNode(GridKernalContext ctx) { return rndNode; } + /** + * @param ctx Kernal context. + * @param plc IO Policy. + * @param reserved Thread to reserve. + * @return Number of available threads in executor service for {@code plc}. If {@code plc} + * is invalid, return {@code 1}. + */ + public static int availableThreadCount(GridKernalContext ctx, byte plc, int reserved) { + IgniteConfiguration cfg = ctx.config(); + + int parallelismLvl; + + switch (plc) { + case GridIoPolicy.P2P_POOL: + parallelismLvl = cfg.getPeerClassLoadingThreadPoolSize(); + + break; + + case GridIoPolicy.SYSTEM_POOL: + parallelismLvl = cfg.getSystemThreadPoolSize(); + + break; + + case GridIoPolicy.PUBLIC_POOL: + parallelismLvl = cfg.getPublicThreadPoolSize(); + + break; + + case GridIoPolicy.MANAGEMENT_POOL: + parallelismLvl = cfg.getManagementThreadPoolSize(); + + break; + + case GridIoPolicy.UTILITY_CACHE_POOL: + parallelismLvl = cfg.getUtilityCacheThreadPoolSize(); + + break; + + case GridIoPolicy.IGFS_POOL: + parallelismLvl = cfg.getIgfsThreadPoolSize(); + + break; + + case GridIoPolicy.SERVICE_POOL: + parallelismLvl = cfg.getServiceThreadPoolSize(); + + break; + + case GridIoPolicy.DATA_STREAMER_POOL: + parallelismLvl = cfg.getDataStreamerThreadPoolSize(); + + break; + + case GridIoPolicy.QUERY_POOL: + parallelismLvl = cfg.getQueryThreadPoolSize(); + + break; + + default: + parallelismLvl = -1; + } + + return Math.max(1, parallelismLvl - reserved); + } + + /** + * Execute operation on data in parallel. + * + * @param executorSvc Service for parallel execution. + * @param srcDatas List of data for parallelization. + * @param operation Logic for execution of on each item of data. + * @param Type of data. + * @throws IgniteCheckedException if parallel execution was failed. + */ + public static Collection doInParallel( + ExecutorService executorSvc, + Collection srcDatas, + IgniteThrowableConsumer operation + ) throws IgniteCheckedException, IgniteInterruptedCheckedException { + return doInParallel(srcDatas.size(), executorSvc, srcDatas, operation); + } + + /** + * Execute operation on data in parallel. + * + * @param parallelismLvl Number of threads on which it should be executed. + * @param executorSvc Service for parallel execution. + * @param srcDatas List of data for parallelization. + * @param operation Logic for execution of on each item of data. + * @param Type of data. + * @param Type of return value. + * @throws IgniteCheckedException if parallel execution was failed. + */ + public static Collection doInParallel( + int parallelismLvl, + ExecutorService executorSvc, + Collection srcDatas, + IgniteThrowableConsumer operation + ) throws IgniteCheckedException, IgniteInterruptedCheckedException { + if(srcDatas.isEmpty()) + return Collections.emptyList(); + + int[] batchSizes = calculateOptimalBatchSizes(parallelismLvl, srcDatas.size()); + + List> batches = new ArrayList<>(batchSizes.length); + + // Set for sharing batches between executor and current thread. + // If executor cannot perform immediately, we will execute task in the current thread. + Set> sharedBatchesSet = new GridConcurrentHashSet<>(batchSizes.length); + + Iterator iterator = srcDatas.iterator(); + + for (int idx = 0; idx < batchSizes.length; idx++) { + int batchSize = batchSizes[idx]; + + Batch batch = new Batch<>(batchSize); + + for (int i = 0; i < batchSize; i++) + batch.addTask(iterator.next()); + + batches.add(batch); + } + + batches = batches.stream() + .filter(batch -> !batch.tasks.isEmpty()) + // Add to set only after check that batch is not empty. + .peek(sharedBatchesSet::add) + // Setup future in batch for waiting result. + .peek(batch -> batch.future = executorSvc.submit(() -> { + // Batch was stolen by the main stream. + if (!sharedBatchesSet.remove(batch)) { + return null; + } + + Collection results = new ArrayList<>(batch.tasks.size()); + + for (T item : batch.tasks) + results.add(operation.accept(item)); + + return results; + })) + .collect(Collectors.toList()); + + Throwable error = null; + + // Stealing jobs if executor is busy and cannot process task immediately. + // Perform batches in a current thread. + for (Batch batch : sharedBatchesSet) { + // Executor steal task. + if (!sharedBatchesSet.remove(batch)) + continue; + + Collection res = new ArrayList<>(batch.tasks.size()); + + try { + for (T item : batch.tasks) + res.add(operation.accept(item)); + + batch.result(res); + } + catch (Throwable e) { + batch.result(e); + } + } + + // Final result collection. + Collection results = new ArrayList<>(srcDatas.size()); + + for (Batch batch: batches) { + try { + Throwable err = batch.error; + + if (err != null) { + error = addSuppressed(error, err); + + continue; + } + + Collection res = batch.result(); + + if (res != null) + results.addAll(res); + else + assert error != null; + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + + throw new IgniteInterruptedCheckedException(e); + } + catch (ExecutionException e) { + error = addSuppressed(error, e.getCause()); + } + catch (CancellationException e) { + error = addSuppressed(error, e); + } + } + + if (error != null) { + if (error instanceof IgniteCheckedException) + throw (IgniteCheckedException)error; + + if (error instanceof RuntimeException) + throw (RuntimeException)error; + + if (error instanceof Error) + throw (Error)error; + + throw new IgniteCheckedException(error); + } + + return results; + } + + /** + * Utility method to add the given throwable error to the given throwable root error. If the given + * suppressed throwable is an {@code Error}, but the root error is not, will change the root to the {@code Error}. + * + * @param root Root error to add suppressed error to. + * @param err Error to add. + * @return New root error. + */ + private static Throwable addSuppressed(Throwable root, Throwable err) { + assert err != null; + + if (root == null) + return err; + + if (err instanceof Error && !(root instanceof Error)) { + err.addSuppressed(root); + + root = err; + } + else + root.addSuppressed(err); + + return root; + } + + /** + * The batch of tasks with a batch index in global array. + */ + private static class Batch { + /** List tasks. */ + private final List tasks; + + /** */ + private Collection result; + + /** */ + private Throwable error; + + /** */ + private Future> future; + + /** + * @param batchSize Batch size. + */ + private Batch(int batchSize) { + this.tasks = new ArrayList<>(batchSize); + } + + /** + * @param task Add task. + */ + public void addTask(T task){ + tasks.add(task); + } + + /** + * @param res Setup results for tasks. + */ + public void result(Collection res) { + this.result = res; + } + + /** + * @param e Throwable if task was completed with error. + */ + public void result(Throwable e) { + this.error = e; + } + + /** + * Get tasks results. + */ + public Collection result() throws ExecutionException, InterruptedException { + assert future != null; + + return result != null ? result : future.get(); + } + } + + /** + * Split number of tasks into optimized batches. + * @param parallelismLvl Level of parallelism. + * @param size number of tasks to split. + * @return array of batch sizes. + */ + public static int[] calculateOptimalBatchSizes(int parallelismLvl, int size) { + int[] batcheSizes = new int[Math.min(parallelismLvl, size)]; + + for (int i = 0; i < size; i++) + batcheSizes[i % batcheSizes.length]++; + + return batcheSizes; + } + + /** + * @param fut Future to wait for completion. + * @throws ExecutionException If the future + */ + private static void getUninterruptibly(Future fut) throws ExecutionException { + boolean interrupted = false; + + while (true) { + try { + fut.get(); + + break; + } + catch (InterruptedException e) { + interrupted = true; + } + } + + if (interrupted) + Thread.currentThread().interrupt(); + } + /** * * @param r Runnable. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/InitializationProtector.java b/modules/core/src/main/java/org/apache/ignite/internal/util/InitializationProtector.java new file mode 100644 index 0000000000000..7c501c42486c9 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/InitializationProtector.java @@ -0,0 +1,79 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.util; + +import java.util.concurrent.locks.Lock; +import java.util.function.Supplier; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.util.lang.IgniteThrowableRunner; + +/** + * Class for avoid multiple initialization of specific value from various threads. + */ +public class InitializationProtector { + /** Default striped lock concurrency level. */ + private static final int DEFAULT_CONCURRENCY_LEVEL = Runtime.getRuntime().availableProcessors(); + + /** Striped lock. */ + private GridStripedLock stripedLock = new GridStripedLock(DEFAULT_CONCURRENCY_LEVEL); + + /** + * @param protectedKey Unique value by which initialization code should be run only one time. + * @param initializedVal Supplier for given already initialized value if it exist or null as sign that + * initialization required. + * @param initializationCode Code for initialization value corresponding protectedKey. Should be idempotent. + * @param Type of initialization value. + * @return Initialized value. + * @throws IgniteCheckedException if initialization was failed. + */ + public T protect(Object protectedKey, Supplier initializedVal, + IgniteThrowableRunner initializationCode) throws IgniteCheckedException { + T value = initializedVal.get(); + + if (value != null) + return value; + + Lock lock = stripedLock.getLock(protectedKey.hashCode() % stripedLock.concurrencyLevel()); + + lock.lock(); + try { + value = initializedVal.get(); + + if (value != null) + return value; + + initializationCode.run(); + + return initializedVal.get(); + } + finally { + lock.unlock(); + } + } + + /** + * It method allows to avoid simultaneous initialization from various threads. + * + * @param protectedKey Unique value by which initialization code should be run only from one thread in one time. + * @param initializationCode Code for initialization value corresponding protectedKey. Should be idempotent. + * @throws IgniteCheckedException if initialization was failed. + */ + public void protect(Object protectedKey, IgniteThrowableRunner initializationCode) throws IgniteCheckedException { + protect(protectedKey, () -> null, initializationCode); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/OffheapReadWriteLock.java b/modules/core/src/main/java/org/apache/ignite/internal/util/OffheapReadWriteLock.java index b119960cfc822..95c007be7ad96 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/OffheapReadWriteLock.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/OffheapReadWriteLock.java @@ -263,7 +263,7 @@ public void writeUnlock(long lock, int tag) { if (lockCount(state) != -1) throw new IllegalMonitorStateException("Attempted to release write lock while not holding it " + - "[lock=" + U.hexLong(lock) + ", state=" + U.hexLong(state)); + "[lock=" + U.hexLong(lock) + ", state=" + U.hexLong(state) + ']'); updated = releaseWithTag(state, tag); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/TimeBag.java b/modules/core/src/main/java/org/apache/ignite/internal/util/TimeBag.java new file mode 100644 index 0000000000000..156d826e9935c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/TimeBag.java @@ -0,0 +1,312 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.PriorityQueue; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import org.jetbrains.annotations.NotNull; + +/** + * Utility class to measure and collect timings of some execution workflow. + */ +public class TimeBag { + /** Initial global stage. */ + private final CompositeStage INITIAL_STAGE = new CompositeStage("", 0, new HashMap<>()); + + /** Lock. */ + private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); + + /** Global stopwatch. */ + private final IgniteStopwatch globalStopwatch = IgniteStopwatch.createStarted(); + + /** Measurement unit. */ + private final TimeUnit measurementUnit; + + /** List of global stages (guarded by {@code lock}). */ + private final List stages; + + /** List of current local stages separated by threads (guarded by {@code lock}). */ + private Map> localStages; + + /** Last seen global stage by thread. */ + private final ThreadLocal tlLastSeenStage = ThreadLocal.withInitial(() -> INITIAL_STAGE); + + /** Thread-local stopwatch. */ + private final ThreadLocal tlStopwatch = ThreadLocal.withInitial(IgniteStopwatch::createUnstarted); + + + /** + * Default constructor. + */ + public TimeBag() { + this(TimeUnit.MILLISECONDS); + } + + /** + * @param measurementUnit Measurement unit. + */ + public TimeBag(TimeUnit measurementUnit) { + this.stages = new ArrayList<>(); + this.localStages = new ConcurrentHashMap<>(); + this.measurementUnit = measurementUnit; + + this.stages.add(INITIAL_STAGE); + } + + /** + * + */ + private CompositeStage lastCompletedGlobalStage() { + assert !stages.isEmpty() : "No stages :("; + + return stages.get(stages.size() - 1); + } + + /** + * @param description Description. + */ + public void finishGlobalStage(String description) { + lock.writeLock().lock(); + + try { + stages.add( + new CompositeStage(description, globalStopwatch.elapsed(measurementUnit), Collections.unmodifiableMap(localStages)) + ); + + localStages = new ConcurrentHashMap<>(); + + globalStopwatch.reset().start(); + } + finally { + lock.writeLock().unlock(); + } + } + + /** + * @param description Description. + */ + public void finishLocalStage(String description) { + lock.readLock().lock(); + + try { + CompositeStage lastSeen = tlLastSeenStage.get(); + CompositeStage lastCompleted = lastCompletedGlobalStage(); + IgniteStopwatch localStopWatch = tlStopwatch.get(); + + Stage stage; + + // We see this stage first time, get elapsed time from last completed global stage and start tracking local. + if (lastSeen != lastCompleted) { + stage = new Stage(description, globalStopwatch.elapsed(measurementUnit)); + + tlLastSeenStage.set(lastCompleted); + } + else + stage = new Stage(description, localStopWatch.elapsed(measurementUnit)); + + localStopWatch.reset().start(); + + // Associate local stage with current thread name. + String threadName = Thread.currentThread().getName(); + + localStages.computeIfAbsent(threadName, t -> new ArrayList<>()).add(stage); + } + finally { + lock.readLock().unlock(); + } + } + + /** + * @return Short name of desired measurement unit. + */ + private String measurementUnitShort() { + switch (measurementUnit) { + case MILLISECONDS: + return "ms"; + case SECONDS: + return "s"; + case NANOSECONDS: + return "ns"; + case MICROSECONDS: + return "mcs"; + case HOURS: + return "h"; + case MINUTES: + return "min"; + case DAYS: + return "days"; + default: + return ""; + } + } + + /** + * @return List of string representation of all stage timings. + */ + public List stagesTimings() { + lock.readLock().lock(); + + try { + List timings = new ArrayList<>(); + + long totalTime = 0; + + // Skip initial stage. + for (int i = 1; i < stages.size(); i++) { + CompositeStage stage = stages.get(i); + + totalTime += stage.time(); + + timings.add(stage.toString()); + } + + // Add last stage with summary time of all global stages. + timings.add(new Stage("Total time", totalTime).toString()); + + return timings; + } + finally { + lock.readLock().unlock(); + } + } + + /** + * @param maxPerCompositeStage Max count of local stages to collect per composite stage. + * @return List of string represenation of longest local stages per each composite stage. + */ + public List longestLocalStagesTimings(int maxPerCompositeStage) { + lock.readLock().lock(); + + try { + List timings = new ArrayList<>(); + + for (int i = 1; i < stages.size(); i++) { + CompositeStage stage = stages.get(i); + + if (!stage.localStages.isEmpty()) { + PriorityQueue stagesByTime = new PriorityQueue<>(); + + for (Map.Entry> threadAndStages : stage.localStages.entrySet()) { + for (Stage locStage : threadAndStages.getValue()) + stagesByTime.add(locStage); + } + + int stageCount = 0; + while (!stagesByTime.isEmpty() && stageCount < maxPerCompositeStage) { + stageCount++; + + Stage locStage = stagesByTime.poll(); + + timings.add(locStage.toString() + " (parent=" + stage.description() + ")"); + } + } + } + + return timings; + } + finally { + lock.readLock().unlock(); + } + } + + /** + * + */ + private class CompositeStage extends Stage { + /** Local stages. */ + private final Map> localStages; + + /** + * @param description Description. + * @param time Time. + * @param localStages Local stages. + */ + public CompositeStage(String description, long time, Map> localStages) { + super(description, time); + + this.localStages = localStages; + } + + /** + * + */ + public Map> localStages() { + return localStages; + } + } + + /** + * + */ + private class Stage implements Comparable { + /** Description. */ + private final String description; + + /** Time. */ + private final long time; + + /** + * @param description Description. + * @param time Time. + */ + public Stage(String description, long time) { + this.description = description; + this.time = time; + } + + /** + * + */ + public String description() { + return description; + } + + /** + * + */ + public long time() { + return time; + } + + /** {@inheritDoc} */ + @Override public String toString() { + StringBuilder sb = new StringBuilder(); + + sb.append("stage=").append('"').append(description()).append('"'); + sb.append(' ').append('(').append(time()).append(' ').append(measurementUnitShort()).append(')'); + + return sb.toString(); + } + + /** {@inheritDoc} */ + @Override public int compareTo(@NotNull TimeBag.Stage o) { + if (o.time < time) + return -1; + if (o.time > time) + return 1; + return o.description.compareTo(description); + } + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java index 8302504dd90de..a191f30f130eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java @@ -357,13 +357,23 @@ private void unblock(Object waiter) { /** {@inheritDoc} */ @Override public IgniteInternalFuture chain(final IgniteClosure, T> doneCb) { - return new ChainFuture<>(this, doneCb, null); + ChainFuture fut = new ChainFuture<>(this, doneCb, null); + + if (ignoreInterrupts) + fut.ignoreInterrupts(); + + return fut; } /** {@inheritDoc} */ @Override public IgniteInternalFuture chain(final IgniteClosure, T> doneCb, Executor exec) { - return new ChainFuture<>(this, doneCb, exec); + ChainFuture fut = new ChainFuture<>(this, doneCb, exec); + + if (ignoreInterrupts) + fut.ignoreInterrupts(); + + return fut; } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/IgniteThrowableConsumer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/IgniteThrowableConsumer.java new file mode 100644 index 0000000000000..55feed8cc2d33 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/IgniteThrowableConsumer.java @@ -0,0 +1,39 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.util.lang; + +import java.io.Serializable; +import org.apache.ignite.IgniteCheckedException; + +/** + * Represents an operation that accepts a single input argument and returns no result. Unlike most other functional + * interfaces, {@code IgniteThrowableConsumer} is expected to operate via side-effects. + * + * @param Type of closure parameter. + * @param Type of result value. + */ +public interface IgniteThrowableConsumer extends Serializable { + /** + * Consumer body. + * + * @param e Consumer parameter. + * @return Result of consumer operation. + * @throws IgniteCheckedException if body execution was failed. + */ + public R accept(E e) throws IgniteCheckedException; +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/IgniteThrowableRunner.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/IgniteThrowableRunner.java new file mode 100644 index 0000000000000..a5c95e1a3e575 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/IgniteThrowableRunner.java @@ -0,0 +1,30 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.util.lang; + +import org.apache.ignite.IgniteCheckedException; + +/** + * Represents a throwable runner. + */ +public interface IgniteThrowableRunner { + /** + * Execute a body. + */ + void run() throws IgniteCheckedException; +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java index 329682f462525..77c333daa774c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java @@ -21,7 +21,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.Serializable; -import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -29,16 +28,19 @@ import java.util.Collection; import java.util.Collections; import java.util.EventListener; -import java.util.IdentityHashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Queue; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.SB; +import org.apache.ignite.internal.util.typedef.internal.U; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,9 +50,6 @@ /** * Provides auto-generation framework for {@code toString()} output. *

- * In case of recursion, repeatable objects will be shown as "ClassName@hash". - * But fields will be printed only for the first entry to prevent recursion. - *

* Default exclusion policy (can be overridden with {@link GridToStringInclude} * annotation): *

    @@ -84,9 +83,6 @@ *
*/ public class GridToStringBuilder { - /** */ - private static final Object[] EMPTY_ARRAY = new Object[0]; - /** */ private static final Map classCache = new ConcurrentHashMap<>(); @@ -98,30 +94,25 @@ public class GridToStringBuilder { private static final int COLLECTION_LIMIT = IgniteSystemProperties.getInteger(IGNITE_TO_STRING_COLLECTION_LIMIT, 100); - /** Every thread has its own string builder. */ - private static ThreadLocal threadLocSB = new ThreadLocal() { - @Override protected SBLimitedLength initialValue() { - SBLimitedLength sb = new SBLimitedLength(256); + /** */ + private static ThreadLocal> threadCache = new ThreadLocal>() { + @Override protected Queue initialValue() { + Queue queue = new LinkedList<>(); - sb.initLimit(new SBLengthLimit()); + queue.offer(new GridToStringThreadLocal()); - return sb; + return queue; } }; - /** - * Contains objects currently printing in the string builder. - *

- * Since {@code toString()} methods can be chain-called from the same thread we - * have to keep a map of this objects pointed to the position of previous occurrence - * and remove/add them in each {@code toString()} apply. - */ - private static ThreadLocal> savedObjects = new ThreadLocal>() { - @Override protected IdentityHashMap initialValue() { - return new IdentityHashMap<>(); + /** */ + private static ThreadLocal threadCurLen = new ThreadLocal() { + @Override protected SBLengthLimit initialValue() { + return new SBLengthLimit(); } }; + /** * Produces auto-generated output of string presentation for given object and its declaration class. * @@ -270,9 +261,18 @@ public static String toString(Class cls, T obj, assert name3 != null; assert name4 != null; - Object[] addNames = new Object[5]; - Object[] addVals = new Object[5]; - boolean[] addSens = new boolean[5]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] addNames = tmp.getAdditionalNames(); + Object[] addVals = tmp.getAdditionalValues(); + boolean[] addSens = tmp.getAdditionalSensitives(); addNames[0] = name0; addVals[0] = val0; @@ -290,16 +290,20 @@ public static String toString(Class cls, T obj, addVals[4] = val4; addSens[4] = sens4; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(cls, sb, obj, addNames, addVals, addSens, 5); + newStr = lenLim.length() == 0; + + return toStringImpl(cls, tmp.getStringBuilder(lenLim), obj, addNames, addVals, addSens, 5); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -345,9 +349,18 @@ public static String toString(Class cls, T obj, assert name4 != null; assert name5 != null; - Object[] addNames = new Object[6]; - Object[] addVals = new Object[6]; - boolean[] addSens = new boolean[6]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] addNames = tmp.getAdditionalNames(); + Object[] addVals = tmp.getAdditionalValues(); + boolean[] addSens = tmp.getAdditionalSensitives(); addNames[0] = name0; addVals[0] = val0; @@ -368,16 +381,20 @@ public static String toString(Class cls, T obj, addVals[5] = val5; addSens[5] = sens5; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(cls, sb, obj, addNames, addVals, addSens, 6); + newStr = lenLim.length() == 0; + + return toStringImpl(cls, tmp.getStringBuilder(lenLim), obj, addNames, addVals, addSens, 6); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -428,9 +445,18 @@ public static String toString(Class cls, T obj, assert name5 != null; assert name6 != null; - Object[] addNames = new Object[7]; - Object[] addVals = new Object[7]; - boolean[] addSens = new boolean[7]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] addNames = tmp.getAdditionalNames(); + Object[] addVals = tmp.getAdditionalValues(); + boolean[] addSens = tmp.getAdditionalSensitives(); addNames[0] = name0; addVals[0] = val0; @@ -454,16 +480,20 @@ public static String toString(Class cls, T obj, addVals[6] = val6; addSens[6] = sens6; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(cls, sb, obj, addNames, addVals, addSens, 7); + newStr = lenLim.length() == 0; + + return toStringImpl(cls, tmp.getStringBuilder(lenLim), obj, addNames, addVals, addSens, 7); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -527,9 +557,18 @@ public static String toString(Class cls, T obj, assert name2 != null; assert name3 != null; - Object[] addNames = new Object[4]; - Object[] addVals = new Object[4]; - boolean[] addSens = new boolean[4]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] addNames = tmp.getAdditionalNames(); + Object[] addVals = tmp.getAdditionalValues(); + boolean[] addSens = tmp.getAdditionalSensitives(); addNames[0] = name0; addVals[0] = val0; @@ -544,16 +583,20 @@ public static String toString(Class cls, T obj, addVals[3] = val3; addSens[3] = sens3; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(cls, sb, obj, addNames, addVals, addSens, 4); + newStr = lenLim.length() == 0; + + return toStringImpl(cls, tmp.getStringBuilder(lenLim), obj, addNames, addVals, addSens, 4); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -609,9 +652,18 @@ public static String toString(Class cls, T obj, assert name1 != null; assert name2 != null; - Object[] addNames = new Object[3]; - Object[] addVals = new Object[3]; - boolean[] addSens = new boolean[3]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] addNames = tmp.getAdditionalNames(); + Object[] addVals = tmp.getAdditionalValues(); + boolean[] addSens = tmp.getAdditionalSensitives(); addNames[0] = name0; addVals[0] = val0; @@ -623,16 +675,20 @@ public static String toString(Class cls, T obj, addVals[2] = val2; addSens[2] = sens2; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(cls, sb, obj, addNames, addVals, addSens, 3); + newStr = lenLim.length() == 0; + + return toStringImpl(cls, tmp.getStringBuilder(lenLim), obj, addNames, addVals, addSens, 3); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -676,9 +732,18 @@ public static String toString(Class cls, T obj, assert name0 != null; assert name1 != null; - Object[] addNames = new Object[2]; - Object[] addVals = new Object[2]; - boolean[] addSens = new boolean[2]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] addNames = tmp.getAdditionalNames(); + Object[] addVals = tmp.getAdditionalValues(); + boolean[] addSens = tmp.getAdditionalSensitives(); addNames[0] = name0; addVals[0] = val0; @@ -687,16 +752,20 @@ public static String toString(Class cls, T obj, addVals[1] = val1; addSens[1] = sens1; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(cls, sb, obj, addNames, addVals, addSens, 2); + newStr = lenLim.length() == 0; + + return toStringImpl(cls, tmp.getStringBuilder(lenLim), obj, addNames, addVals, addSens, 2); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -730,24 +799,37 @@ public static String toString(Class cls, T obj, String name, @Nullable Ob assert obj != null; assert name != null; - Object[] addNames = new Object[1]; - Object[] addVals = new Object[1]; - boolean[] addSens = new boolean[1]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] addNames = tmp.getAdditionalNames(); + Object[] addVals = tmp.getAdditionalValues(); + boolean[] addSens = tmp.getAdditionalSensitives(); addNames[0] = name; addVals[0] = val; addSens[0] = sens; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(cls, sb, obj, addNames, addVals, addSens, 1); + newStr = lenLim.length() == 0; + + return toStringImpl(cls, tmp.getStringBuilder(lenLim), obj, addNames, addVals, addSens, 1); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -763,16 +845,30 @@ public static String toString(Class cls, T obj) { assert cls != null; assert obj != null; - SBLimitedLength sb = threadLocSB.get(); + Queue queue = threadCache.get(); + + assert queue != null; - boolean newStr = sb.length() == 0; + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + SBLengthLimit lenLim = threadCurLen.get(); + + boolean newStr = false; try { - return toStringImpl(cls, sb, obj, EMPTY_ARRAY, EMPTY_ARRAY, null, 0); + newStr = lenLim.length() == 0; + + return toStringImpl(cls, tmp.getStringBuilder(lenLim), obj, tmp.getAdditionalNames(), + tmp.getAdditionalValues(), null, 0); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -790,164 +886,68 @@ public static String toString(Class cls, T obj, String parent) { } /** - * Print value with length limitation. - * + * Print value with length limitation * @param buf buffer to print to. * @param val value to print, can be {@code null}. */ private static void toString(SBLimitedLength buf, Object val) { - toString(buf, null, val); - } - - /** - * Print value with length limitation. - * - * @param buf buffer to print to. - * @param cls value class. - * @param val value to print. - */ - @SuppressWarnings({"unchecked"}) - private static void toString(SBLimitedLength buf, Class cls, Object val) { - if (val == null) { + if (val == null) buf.a("null"); - - return; - } - - if (cls == null) - cls = val.getClass(); - - if (cls.isPrimitive()) { - buf.a(val); - - return; - } - - IdentityHashMap svdObjs = savedObjects.get(); - - if (handleRecursion(buf, val, svdObjs)) - return; - - svdObjs.put(val, buf.length()); - - try { - if (cls.isArray()) - addArray(buf, cls, val); - else if (val instanceof Collection) - addCollection(buf, (Collection) val); - else if (val instanceof Map) - addMap(buf, (Map) val); - else - buf.a(val); - } - finally { - svdObjs.remove(val); - } - } - - /** - * Writes array to buffer. - * - * @param buf String builder buffer. - * @param arrType Type of the array. - * @param obj Array object. - */ - private static void addArray(SBLimitedLength buf, Class arrType, Object obj) { - if (arrType.getComponentType().isPrimitive()) { - buf.a(arrayToString(obj)); - - return; - } - - Object[] arr = (Object[]) obj; - - buf.a(arrType.getSimpleName()).a(" ["); - - for (int i = 0; i < arr.length; i++) { - toString(buf, arr[i]); - - if (i == COLLECTION_LIMIT - 1 || i == arr.length - 1) - break; - - buf.a(", "); - } - - handleOverflow(buf, arr.length); - - buf.a(']'); + else + toString(buf, val.getClass(), val); } /** - * Writes collection to buffer. - * - * @param buf String builder buffer. - * @param col Collection object. + * Print value with length limitation + * @param buf buffer to print to. + * @param valClass value class. + * @param val value to print */ - private static void addCollection(SBLimitedLength buf, Collection col) { - buf.a(col.getClass().getSimpleName()).a(" ["); - - int cnt = 0; - - for (Object obj : col) { - toString(buf, obj); - - if (++cnt == COLLECTION_LIMIT || cnt == col.size()) - break; - - buf.a(", "); - } + private static void toString(SBLimitedLength buf, Class valClass, Object val) { + if (valClass.isArray()) + buf.a(arrayToString(valClass, val)); + else { + int overflow = 0; + char bracket = ' '; + + if (val instanceof Collection && ((Collection)val).size() > COLLECTION_LIMIT) { + overflow = ((Collection)val).size() - COLLECTION_LIMIT; + bracket = ']'; + val = F.retain((Collection) val, true, COLLECTION_LIMIT); + } + else if (val instanceof Map && ((Map)val).size() > COLLECTION_LIMIT) { + Map tmp = U.newHashMap(COLLECTION_LIMIT); - handleOverflow(buf, col.size()); + overflow = ((Map)val).size() - COLLECTION_LIMIT; - buf.a(']'); - } + bracket= '}'; - /** - * Writes map to buffer. - * - * @param buf String builder buffer. - * @param map Map object. - */ - private static void addMap(SBLimitedLength buf, Map map) { - buf.a(map.getClass().getSimpleName()).a(" {"); + int cntr = 0; - int cnt = 0; + for (Object o : ((Map)val).entrySet()) { + Map.Entry e = (Map.Entry)o; - for (Map.Entry e : map.entrySet()) { - toString(buf, e.getKey()); + tmp.put(e.getKey(), e.getValue()); - buf.a('='); + if (++cntr >= COLLECTION_LIMIT) + break; + } - toString(buf, e.getValue()); + val = tmp; + } - if (++cnt == COLLECTION_LIMIT || cnt == map.size()) - break; + buf.a(val); - buf.a(", "); + if (overflow > 0) { + buf.d(buf.length() - 1); + buf.a("... and ").a(overflow).a(" more").a(bracket); + } } - - handleOverflow(buf, map.size()); - - buf.a('}'); - } - - /** - * Writes overflow message to buffer if needed. - * - * @param buf String builder buffer. - * @param size Size to compare with limit. - */ - private static void handleOverflow(SBLimitedLength buf, int size) { - int overflow = size - COLLECTION_LIMIT; - - if (overflow > 0) - buf.a("... and ").a(overflow).a(" more"); } /** * Creates an uniformed string presentation for the given object. * - * @param Type of object. * @param cls Class of the object. * @param buf String builder buffer. * @param obj Object for which to get string presentation. @@ -956,7 +956,9 @@ private static void handleOverflow(SBLimitedLength buf, int size) { * @param addSens Sensitive flag of values or {@code null} if all values are not sensitive. * @param addLen How many additional values will be included. * @return String presentation of the given object. + * @param Type of object. */ + @SuppressWarnings({"unchecked"}) private static String toStringImpl( Class cls, SBLimitedLength buf, @@ -973,56 +975,13 @@ private static String toStringImpl( assert addNames.length == addVals.length; assert addLen <= addNames.length; - boolean newStr = buf.length() == 0; - - IdentityHashMap svdObjs = savedObjects.get(); - - if (newStr) - svdObjs.put(obj, buf.length()); - - try { - String s = toStringImpl0(cls, buf, obj, addNames, addVals, addSens, addLen); - - if (newStr) - return s; - - // Called from another GTSB.toString(), so this string is already in the buffer and shouldn't be returned. - return ""; - } - finally { - if (newStr) - svdObjs.remove(obj); - } - } - - /** - * Creates an uniformed string presentation for the given object. - * - * @param cls Class of the object. - * @param buf String builder buffer. - * @param obj Object for which to get string presentation. - * @param addNames Names of additional values to be included. - * @param addVals Additional values to be included. - * @param addSens Sensitive flag of values or {@code null} if all values are not sensitive. - * @param addLen How many additional values will be included. - * @return String presentation of the given object. - * @param Type of object. - */ - @SuppressWarnings({"unchecked"}) - private static String toStringImpl0( - Class cls, - SBLimitedLength buf, - T obj, - Object[] addNames, - Object[] addVals, - @Nullable boolean[] addSens, - int addLen - ) { try { GridToStringClassDescriptor cd = getClassDescriptor(cls); assert cd != null; + buf.setLength(0); + buf.a(cd.getSimpleClassName()).a(" ["); boolean first = true; @@ -1054,6 +1013,7 @@ private static String toStringImpl0( } // Specifically catching all exceptions. catch (Exception e) { + // Remove entry from cache to avoid potential memory leak // in case new class loader got loaded under the same identity hash. classCache.remove(cls.getName() + System.identityHashCode(cls.getClassLoader())); @@ -1076,40 +1036,95 @@ public static String toString(String str, String name, @Nullable Object val) { } /** - * Returns limited string representation of array. - * - * @param arr Array object. Each value is automatically wrapped if it has a primitive type. + * @param arrType Type of the array. + * @param arr Array object. * @return String representation of an array. */ - public static String arrayToString(Object arr) { + @SuppressWarnings({"ConstantConditions", "unchecked"}) + public static String arrayToString(Class arrType, Object arr) { if (arr == null) return "null"; String res; + int more = 0; - int arrLen; - - if (arr instanceof Object[]) { + if (arrType.equals(byte[].class)) { + byte[] byteArr = (byte[])arr; + if (byteArr.length > COLLECTION_LIMIT) { + more = byteArr.length - COLLECTION_LIMIT; + byteArr = Arrays.copyOf(byteArr, COLLECTION_LIMIT); + } + res = Arrays.toString(byteArr); + } + else if (arrType.equals(boolean[].class)) { + boolean[] boolArr = (boolean[])arr; + if (boolArr.length > COLLECTION_LIMIT) { + more = boolArr.length - COLLECTION_LIMIT; + boolArr = Arrays.copyOf(boolArr, COLLECTION_LIMIT); + } + res = Arrays.toString(boolArr); + } + else if (arrType.equals(short[].class)) { + short[] shortArr = (short[])arr; + if (shortArr.length > COLLECTION_LIMIT) { + more = shortArr.length - COLLECTION_LIMIT; + shortArr = Arrays.copyOf(shortArr, COLLECTION_LIMIT); + } + res = Arrays.toString(shortArr); + } + else if (arrType.equals(int[].class)) { + int[] intArr = (int[])arr; + if (intArr.length > COLLECTION_LIMIT) { + more = intArr.length - COLLECTION_LIMIT; + intArr = Arrays.copyOf(intArr, COLLECTION_LIMIT); + } + res = Arrays.toString(intArr); + } + else if (arrType.equals(long[].class)) { + long[] longArr = (long[])arr; + if (longArr.length > COLLECTION_LIMIT) { + more = longArr.length - COLLECTION_LIMIT; + longArr = Arrays.copyOf(longArr, COLLECTION_LIMIT); + } + res = Arrays.toString(longArr); + } + else if (arrType.equals(float[].class)) { + float[] floatArr = (float[])arr; + if (floatArr.length > COLLECTION_LIMIT) { + more = floatArr.length - COLLECTION_LIMIT; + floatArr = Arrays.copyOf(floatArr, COLLECTION_LIMIT); + } + res = Arrays.toString(floatArr); + } + else if (arrType.equals(double[].class)) { + double[] doubleArr = (double[])arr; + if (doubleArr.length > COLLECTION_LIMIT) { + more = doubleArr.length - COLLECTION_LIMIT; + doubleArr = Arrays.copyOf(doubleArr, COLLECTION_LIMIT); + } + res = Arrays.toString(doubleArr); + } + else if (arrType.equals(char[].class)) { + char[] charArr = (char[])arr; + if (charArr.length > COLLECTION_LIMIT) { + more = charArr.length - COLLECTION_LIMIT; + charArr = Arrays.copyOf(charArr, COLLECTION_LIMIT); + } + res = Arrays.toString(charArr); + } + else { Object[] objArr = (Object[])arr; - - arrLen = objArr.length; - - if (arrLen > COLLECTION_LIMIT) + if (objArr.length > COLLECTION_LIMIT) { + more = objArr.length - COLLECTION_LIMIT; objArr = Arrays.copyOf(objArr, COLLECTION_LIMIT); - + } res = Arrays.toString(objArr); - } else { - res = toStringWithLimit(arr, COLLECTION_LIMIT); - - arrLen = Array.getLength(arr); } - - if (arrLen > COLLECTION_LIMIT) { + if (more > 0) { StringBuilder resSB = new StringBuilder(res); resSB.deleteCharAt(resSB.length() - 1); - - resSB.append("... and ").append(arrLen - COLLECTION_LIMIT).append(" more]"); + resSB.append("... and ").append(more).append(" more]"); res = resSB.toString(); } @@ -1117,37 +1132,6 @@ public static String arrayToString(Object arr) { return res; } - /** - * Returns limited string representation of array. - * - * @param arr Input array. Each value is automatically wrapped if it has a primitive type. - * @param limit max array items to string limit. - * @return String representation of an array. - */ - private static String toStringWithLimit(Object arr, int limit) { - int arrIdxMax = Array.getLength(arr) - 1; - - if (arrIdxMax == -1) - return "[]"; - - int idxMax = Math.min(arrIdxMax, limit); - - StringBuilder b = new StringBuilder(); - - b.append('['); - - for (int i = 0; i <= idxMax; ++i) { - b.append(Array.get(arr, i)); - - if (i == idxMax) - return b.append(']').toString(); - - b.append(", "); - } - - return b.toString(); - } - /** * Produces uniformed output of string with context properties * @@ -1160,24 +1144,37 @@ private static String toStringWithLimit(Object arr, int limit) { public static String toString(String str, String name, @Nullable Object val, boolean sens) { assert name != null; - Object[] propNames = new Object[1]; - Object[] propVals = new Object[1]; - boolean[] propSens = new boolean[1]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] propNames = tmp.getAdditionalNames(); + Object[] propVals = tmp.getAdditionalValues(); + boolean[] propSens = tmp.getAdditionalSensitives(); propNames[0] = name; propVals[0] = val; propSens[0] = sens; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(str, sb, propNames, propVals, propSens, 1); + newStr = lenLim.length() == 0; + + return toStringImpl(str, tmp.getStringBuilder(lenLim), propNames, propVals, propSens, 1); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -1214,9 +1211,18 @@ public static String toString(String str, assert name0 != null; assert name1 != null; - Object[] propNames = new Object[2]; - Object[] propVals = new Object[2]; - boolean[] propSens = new boolean[2]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] propNames = tmp.getAdditionalNames(); + Object[] propVals = tmp.getAdditionalValues(); + boolean[] propSens = tmp.getAdditionalSensitives(); propNames[0] = name0; propVals[0] = val0; @@ -1225,16 +1231,20 @@ public static String toString(String str, propVals[1] = val1; propSens[1] = sens1; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(str, sb, propNames, propVals, propSens, 2); + newStr = lenLim.length() == 0; + + return toStringImpl(str, tmp.getStringBuilder(lenLim), propNames, propVals, propSens, 2); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -1261,9 +1271,18 @@ public static String toString(String str, assert name1 != null; assert name2 != null; - Object[] propNames = new Object[3]; - Object[] propVals = new Object[3]; - boolean[] propSens = new boolean[3]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] propNames = tmp.getAdditionalNames(); + Object[] propVals = tmp.getAdditionalValues(); + boolean[] propSens = tmp.getAdditionalSensitives(); propNames[0] = name0; propVals[0] = val0; @@ -1275,16 +1294,20 @@ public static String toString(String str, propVals[2] = val2; propSens[2] = sens2; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(str, sb, propNames, propVals, propSens, 3); + newStr = lenLim.length() == 0; + + return toStringImpl(str, tmp.getStringBuilder(lenLim), propNames, propVals, propSens, 3); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -1316,9 +1339,18 @@ public static String toString(String str, assert name2 != null; assert name3 != null; - Object[] propNames = new Object[4]; - Object[] propVals = new Object[4]; - boolean[] propSens = new boolean[4]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] propNames = tmp.getAdditionalNames(); + Object[] propVals = tmp.getAdditionalValues(); + boolean[] propSens = tmp.getAdditionalSensitives(); propNames[0] = name0; propVals[0] = val0; @@ -1333,16 +1365,20 @@ public static String toString(String str, propVals[3] = val3; propSens[3] = sens3; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(str, sb, propNames, propVals, propSens, 4); + newStr = lenLim.length() == 0; + + return toStringImpl(str, tmp.getStringBuilder(lenLim), propNames, propVals, propSens, 4); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -1379,9 +1415,18 @@ public static String toString(String str, assert name3 != null; assert name4 != null; - Object[] propNames = new Object[5]; - Object[] propVals = new Object[5]; - boolean[] propSens = new boolean[5]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] propNames = tmp.getAdditionalNames(); + Object[] propVals = tmp.getAdditionalValues(); + boolean[] propSens = tmp.getAdditionalSensitives(); propNames[0] = name0; propVals[0] = val0; @@ -1399,16 +1444,20 @@ public static String toString(String str, propVals[4] = val4; propSens[4] = sens4; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(str, sb, propNames, propVals, propSens, 5); + newStr = lenLim.length() == 0; + + return toStringImpl(str, tmp.getStringBuilder(lenLim), propNames, propVals, propSens, 5); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -1450,9 +1499,18 @@ public static String toString(String str, assert name4 != null; assert name5 != null; - Object[] propNames = new Object[6]; - Object[] propVals = new Object[6]; - boolean[] propSens = new boolean[6]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] propNames = tmp.getAdditionalNames(); + Object[] propVals = tmp.getAdditionalValues(); + boolean[] propSens = tmp.getAdditionalSensitives(); propNames[0] = name0; propVals[0] = val0; @@ -1473,16 +1531,20 @@ public static String toString(String str, propVals[5] = val5; propSens[5] = sens5; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(str, sb, propNames, propVals, propSens, 6); + newStr = lenLim.length() == 0; + + return toStringImpl(str, tmp.getStringBuilder(lenLim), propNames, propVals, propSens, 6); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -1529,9 +1591,18 @@ public static String toString(String str, assert name5 != null; assert name6 != null; - Object[] propNames = new Object[7]; - Object[] propVals = new Object[7]; - boolean[] propSens = new boolean[7]; + Queue queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] propNames = tmp.getAdditionalNames(); + Object[] propVals = tmp.getAdditionalValues(); + boolean[] propSens = tmp.getAdditionalSensitives(); propNames[0] = name0; propVals[0] = val0; @@ -1555,16 +1626,20 @@ public static String toString(String str, propVals[6] = val6; propSens[6] = sens6; - SBLimitedLength sb = threadLocSB.get(); + SBLengthLimit lenLim = threadCurLen.get(); - boolean newStr = sb.length() == 0; + boolean newStr = false; try { - return toStringImpl(str, sb, propNames, propVals, propSens, 7); + newStr = lenLim.length() == 0; + + return toStringImpl(str, tmp.getStringBuilder(lenLim), propNames, propVals, propSens, 7); } finally { + queue.offer(tmp); + if (newStr) - sb.reset(); + lenLim.reset(); } } @@ -1582,7 +1657,7 @@ public static String toString(String str, private static String toStringImpl(String str, SBLimitedLength buf, Object[] propNames, Object[] propVals, boolean[] propSens, int propCnt) { - boolean newStr = buf.length() == 0; + buf.setLength(0); if (str != null) buf.a(str).a(" "); @@ -1593,11 +1668,7 @@ private static String toStringImpl(String str, SBLimitedLength buf, Object[] pro buf.a(']'); - if (newStr) - return buf.toString(); - - // Called from another GTSB.toString(), so this string is already in the buffer and shouldn't be returned. - return ""; + return buf.toString(); } /** @@ -1770,54 +1841,4 @@ public static String compact(@NotNull Collection col) { return sb.toString(); } - - /** - * Checks that object is already saved. - * In positive case this method inserts hash to the saved object entry (if needed) and name@hash for current entry. - * Further toString operations are not needed for current object. - * - * @param buf String builder buffer. - * @param obj Object. - * @param svdObjs Map with saved objects to handle recursion. - * @return {@code True} if object is already saved and name@hash was added to buffer. - * {@code False} if it wasn't saved previously and it should be saved. - */ - private static boolean handleRecursion(SBLimitedLength buf, Object obj, IdentityHashMap svdObjs) { - Integer pos = svdObjs.get(obj); - - if (pos == null) - return false; - - String name = obj.getClass().getSimpleName(); - String hash = '@' + Integer.toHexString(System.identityHashCode(obj)); - String savedName = name + hash; - - if (!buf.isOverflowed() && buf.impl().indexOf(savedName, pos) != pos) { - buf.i(pos + name.length(), hash); - - incValues(svdObjs, obj, hash.length()); - } - - buf.a(savedName); - - return true; - } - - /** - * Increment positions of already presented objects afterward given object. - * - * @param svdObjs Map with objects already presented in the buffer. - * @param obj Object. - * @param hashLen Length of the object's hash. - */ - private static void incValues(IdentityHashMap svdObjs, Object obj, int hashLen) { - Integer baseline = svdObjs.get(obj); - - for (IdentityHashMap.Entry entry : svdObjs.entrySet()) { - Integer pos = entry.getValue(); - - if (pos > baseline) - entry.setValue(pos + hashLen); - } - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringThreadLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringThreadLocal.java new file mode 100644 index 0000000000000..2f62727b17802 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringThreadLocal.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.util.tostring; + +/** + * Helper wrapper containing StringBuilder and additional values. Stored as a thread-local variable. + */ +class GridToStringThreadLocal { + /** */ + private SBLimitedLength sb = new SBLimitedLength(256); + + /** */ + private Object[] addNames = new Object[7]; + + /** */ + private Object[] addVals = new Object[7]; + + /** */ + private boolean[] addSens = new boolean[7]; + + /** + * @param len Length limit. + * @return String builder. + */ + SBLimitedLength getStringBuilder(SBLengthLimit len) { + sb.initLimit(len); + + return sb; + } + + /** + * @return Additional names. + */ + Object[] getAdditionalNames() { + return addNames; + } + + /** + * @return Additional values. + */ + Object[] getAdditionalValues() { + return addVals; + } + + /** + * @return Additional values. + */ + boolean[] getAdditionalSensitives() { + return addSens; + } +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/SBLimitedLength.java b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/SBLimitedLength.java index b524b3d9ad39c..c47cf40c26ef7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/SBLimitedLength.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/SBLimitedLength.java @@ -50,19 +50,6 @@ void initLimit(SBLengthLimit lenLimit) { tail.reset(); } - /** - * Resets buffer. - */ - public void reset() { - super.setLength(0); - - lenLimit.reset(); - - if (tail != null) - tail.reset(); - } - - /** * @return tail string builder. */ @@ -305,11 +292,4 @@ private GridStringBuilder onWrite(int lenBeforeWrite) { return res.toString(); } } - - /** - * @return {@code True} - if buffer limit is reached. - */ - public boolean isOverflowed() { - return lenLimit.overflowed(this); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java index 6ba3aa7d5aed5..6fd51cdd3d55c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java @@ -50,6 +50,9 @@ public abstract class VisorDataTransferObject implements Externalizable { /** Version 3. */ protected static final byte V3 = 3; + /** Version 4. */ + protected static final byte V4 = 4; + /** * @param col Source collection. * @param Collection type. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorMultiNodeTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorMultiNodeTask.java index 29ad5195c59e1..dbf1c6630905d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorMultiNodeTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorMultiNodeTask.java @@ -105,7 +105,7 @@ protected Map map0(List subgrid, map.put(job(taskArg), node); if (map.isEmpty()) - ignite.log().error("No mapped jobs: [task=" + getClass().getName() + + ignite.log().warning("No mapped jobs: [task=" + getClass().getName() + ", topVer=" + ignite.cluster().topologyVersion() + ", jobNids=" + nodeIds + ", subGrid=" + U.toShortString(subgrid) + "]"); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/baseline/VisorBaselineTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/baseline/VisorBaselineTask.java index 3c00452c83a48..be5fcca5e85b5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/baseline/VisorBaselineTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/baseline/VisorBaselineTask.java @@ -27,6 +27,7 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.cluster.IgniteClusterEx; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; @@ -37,6 +38,7 @@ * Task that will collect information about baseline topology and can change its state. */ @GridInternal +@GridVisorManagementTask public class VisorBaselineTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTask.java index bf072e22485de..c62c658e529ca 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTask.java @@ -20,6 +20,7 @@ import org.apache.ignite.IgniteBinary; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -29,6 +30,7 @@ * Task that collects binary metadata. */ @GridInternal +@GridVisorManagementTask public class VisorBinaryMetadataCollectorTask extends VisorOneNodeTask { /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java index 63eb13c3cecc6..495a9cb6dbe7e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java @@ -91,6 +91,9 @@ public class VisorCache extends VisorDataTransferObject { /** Cache system state. */ private boolean sys; + /** Checks whether statistics collection is enabled in this cache. */ + private boolean statisticsEnabled; + /** * Create data transfer object for given cache. */ @@ -119,7 +122,7 @@ public VisorCache(IgniteEx ignite, GridCacheAdapter ca, boolean collectMetrics) backupSize = ca.localSizeLong(PEEK_ONHEAP_BACKUP); nearSize = ca.nearSize(); size = primarySize + backupSize + nearSize; - + partitions = ca.affinity().partitions(); near = cctx.isNear(); @@ -127,6 +130,8 @@ public VisorCache(IgniteEx ignite, GridCacheAdapter ca, boolean collectMetrics) metrics = new VisorCacheMetrics(ignite, name); sys = ignite.context().cache().systemCache(name); + + statisticsEnabled = ca.clusterMetrics().isStatisticsEnabled(); } /** @@ -278,9 +283,16 @@ public long offHeapEntriesCount() { return metrics != null ? metrics.getOffHeapEntriesCount() : 0L; } + /** + * @return Checks whether statistics collection is enabled in this cache. + */ + public boolean isStatisticsEnabled() { + return statisticsEnabled; + } + /** {@inheritDoc} */ @Override public byte getProtocolVersion() { - return V2; + return V3; } /** {@inheritDoc} */ @@ -298,6 +310,7 @@ public long offHeapEntriesCount() { out.writeBoolean(near); out.writeObject(metrics); out.writeBoolean(sys); + out.writeBoolean(statisticsEnabled); } /** {@inheritDoc} */ @@ -316,6 +329,9 @@ public long offHeapEntriesCount() { metrics = (VisorCacheMetrics)in.readObject(); sys = protoVer > V1 ? in.readBoolean() : metrics != null && metrics.isSystem(); + + if (protoVer > V2) + statisticsEnabled = in.readBoolean(); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java index 447cc11d7d387..439b8d3edcd7b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java @@ -21,6 +21,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -30,6 +31,7 @@ * Task that will find affinity node for key. */ @GridInternal +@GridVisorManagementTask public class VisorCacheAffinityNodeTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java index bdfc9eb183a1f..68142b97aad60 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java @@ -21,6 +21,7 @@ import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.compute.ComputeJobContext; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -32,6 +33,7 @@ * Task that clears specified caches on specified node. */ @GridInternal +@GridVisorManagementTask public class VisorCacheClearTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java index b0126788db819..1e9faaabaded2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java @@ -36,6 +36,7 @@ import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; + import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactIterable; @@ -489,8 +490,8 @@ public int getQueryDetailMetricsSize() { } /** - * @return {@code true} if data can be read from backup node or {@code false} if data always - * should be read from primary node and never from backup. + * @return {@code true} if data can be read from backup node or {@code false} if data always should be read from + * primary node and never from backup. */ public boolean isReadFromBackup() { return readFromBackup; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorJob.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorJob.java index f72cd7de09421..51477c96a6896 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorJob.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorJob.java @@ -19,16 +19,18 @@ import java.util.Collection; import java.util.Map; +import java.util.regex.Pattern; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.util.VisorTaskUtils; import org.apache.ignite.lang.IgniteUuid; /** - * Job that collect cache metrics from node. + * Job that collect cache configuration from node. */ public class VisorCacheConfigurationCollectorJob extends VisorJob> { @@ -38,7 +40,7 @@ public class VisorCacheConfigurationCollectorJob /** * Create job with given argument. * - * @param arg Whether to collect metrics for all caches or for specified cache name only. + * @param arg Whether to collect metrics for all caches or for specified cache name only or by regex. * @param debug Debug flag. */ public VisorCacheConfigurationCollectorJob(VisorCacheConfigurationCollectorTaskArg arg, boolean debug) { @@ -49,18 +51,24 @@ public VisorCacheConfigurationCollectorJob(VisorCacheConfigurationCollectorTaskA @Override protected Map run(VisorCacheConfigurationCollectorTaskArg arg) { Collection> caches = ignite.context().cache().jcaches(); - Collection cacheNames = arg.getCacheNames(); + Pattern ptrn = arg.getRegex() != null ? Pattern.compile(arg.getRegex()) : null; - boolean all = F.isEmpty(cacheNames); + boolean all = F.isEmpty(arg.getCacheNames()); - Map res = U.newHashMap(all ? caches.size() : cacheNames.size()); + boolean hasPtrn = ptrn != null; + + Map res = U.newHashMap(caches.size()); for (IgniteCacheProxy cache : caches) { String cacheName = cache.getName(); - if (all || cacheNames.contains(cacheName)) { - res.put(cacheName, config(cache.getConfiguration(CacheConfiguration.class), - cache.context().dynamicDeploymentId())); + boolean matched = hasPtrn ? ptrn.matcher(cacheName).find() : all || arg.getCacheNames().contains(cacheName); + + if (!VisorTaskUtils.isRestartingCache(ignite, cacheName) && matched) { + VisorCacheConfiguration cfg = + config(cache.getConfiguration(CacheConfiguration.class), cache.context().dynamicDeploymentId()); + + res.put(cacheName, cfg); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorTask.java index fd224a893eb39..418eb1b57b81b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorTask.java @@ -17,9 +17,15 @@ package org.apache.ignite.internal.visor.cache; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; +import org.apache.ignite.IgniteException; +import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.internal.processors.task.GridInternal; import org.apache.ignite.internal.visor.VisorOneNodeTask; +import org.jetbrains.annotations.Nullable; /** * Task that collect cache metrics from all nodes. @@ -34,4 +40,38 @@ public class VisorCacheConfigurationCollectorTask @Override protected VisorCacheConfigurationCollectorJob job(VisorCacheConfigurationCollectorTaskArg arg) { return new VisorCacheConfigurationCollectorJob(arg, debug); } + + /** {@inheritDoc} */ + @Override protected @Nullable Map reduce0( + List results + ) throws IgniteException { + if (results == null) + return null; + + Map map = new HashMap<>(); + + List resultsExceptions = null; + + for (ComputeJobResult res : results) { + if (res.getException() == null) + map.putAll(res.getData()); + else { + if (resultsExceptions == null) + resultsExceptions = new ArrayList<>(results.size()); + + resultsExceptions.add(new IgniteException("Job failed on node: " + res.getNode().id(), res.getException())); + } + } + + if (resultsExceptions != null) { + IgniteException e = new IgniteException("Reduce failed because of job failed on some nodes"); + + for (Exception ex : resultsExceptions) + e.addSuppressed(ex); + + throw e; + } + + return map; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorTaskArg.java index a0b43dbcf890d..b4b8143be0de0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorTaskArg.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorTaskArg.java @@ -21,6 +21,7 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.Collection; +import java.util.regex.Pattern; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorDataTransferObject; @@ -32,9 +33,12 @@ public class VisorCacheConfigurationCollectorTaskArg extends VisorDataTransferOb /** */ private static final long serialVersionUID = 0L; - /** Collection of cache deployment IDs. */ + /** Collection of cache names. */ private Collection cacheNames; + /** Cache name regexp. */ + private String regex; + /** * Default constructor. */ @@ -49,6 +53,16 @@ public VisorCacheConfigurationCollectorTaskArg(Collection cacheNames) { this.cacheNames = cacheNames; } + /** + * @param regex Cache name regexp. + */ + public VisorCacheConfigurationCollectorTaskArg(String regex) { + // Checks, that regex is correct. + Pattern.compile(regex); + + this.regex = regex; + } + /** * @return Collection of cache deployment IDs. */ @@ -56,14 +70,30 @@ public Collection getCacheNames() { return cacheNames; } + /** + * @return Cache name regexp. + */ + public String getRegex() { + return regex; + } + + /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return V2; + } + /** {@inheritDoc} */ @Override protected void writeExternalData(ObjectOutput out) throws IOException { U.writeCollection(out, cacheNames); + U.writeString(out, regex); } /** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { cacheNames = U.readCollection(in); + + if (protoVer > V1) + regex = U.readString(in); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java index 7b25ae4e84cf4..5d1bccd06f3bf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java @@ -26,6 +26,7 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorJob; @@ -35,6 +36,7 @@ * Task to loads caches. */ @GridInternal +@GridVisorManagementTask public class VisorCacheLoadTask extends VisorOneNodeTask> { /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTask.java index 9785b9cf96921..daa4af7bec8ae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTask.java @@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -32,6 +33,7 @@ * Collect list of lost partitions. */ @GridInternal +@GridVisorManagementTask public class VisorCacheLostPartitionsTask extends VisorOneNodeTask { /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskArg.java index d6404bfdeb5ec..3ccaeaa3ba179 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskArg.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskArg.java @@ -35,6 +35,9 @@ public class VisorCacheLostPartitionsTaskArg extends VisorDataTransferObject { /** List of cache names. */ private List cacheNames; + /** Created for toString method because Collection can't be printed. */ + private String modifiedCaches; + /** * Default constructor. */ @@ -47,6 +50,9 @@ public VisorCacheLostPartitionsTaskArg() { */ public VisorCacheLostPartitionsTaskArg(List cacheNames) { this.cacheNames = cacheNames; + + if (cacheNames != null) + modifiedCaches = cacheNames.toString(); } /** @@ -59,11 +65,13 @@ public List getCacheNames() { /** {@inheritDoc} */ @Override protected void writeExternalData(ObjectOutput out) throws IOException { U.writeCollection(out, cacheNames); + U.writeString(out, modifiedCaches); } /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { cacheNames = U.readList(in); + modifiedCaches = U.readString(in); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java index ab1fa8c835d41..4c18ba3c78247 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java @@ -30,6 +30,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorMultiNodeTask; +import org.apache.ignite.internal.visor.util.VisorTaskUtils; import org.jetbrains.annotations.Nullable; /** @@ -110,15 +111,17 @@ private VisorCacheMetricsCollectorJob(VisorCacheMetricsCollectorTaskArg arg, boo boolean allCaches = cacheNames.isEmpty(); for (IgniteCacheProxy ca : caches) { - GridCacheContext ctx = ca.context(); + String cacheName = ca.getName(); - if (ctx.started() && (ctx.affinityNode() || ctx.isNear())) { - String cacheName = ca.getName(); + if (!VisorTaskUtils.isRestartingCache(ignite, cacheName)) { + GridCacheContext ctx = ca.context(); - VisorCacheMetrics cm = new VisorCacheMetrics(ignite, cacheName); + if (ctx.started() && (ctx.affinityNode() || ctx.isNear())) { + VisorCacheMetrics cm = new VisorCacheMetrics(ignite, cacheName); - if ((allCaches || cacheNames.contains(cacheName)) && (showSysCaches || !cm.isSystem())) - res.add(cm); + if ((allCaches || cacheNames.contains(cacheName)) && (showSysCaches || !cm.isSystem())) + res.add(cm); + } } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTask.java index 62e7ac6449cf3..f68efa8622e1b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTask.java @@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -31,6 +32,7 @@ * Task that modify value in specified cache. */ @GridInternal +@GridVisorManagementTask public class VisorCacheModifyTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskArg.java index bef73ed5fa508..3948a2f086672 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskArg.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskArg.java @@ -43,6 +43,9 @@ public class VisorCacheModifyTaskArg extends VisorDataTransferObject { /** Specified value. */ private Object val; + /** Created for toString method because Object can't be printed. */ + private String modifiedValues; + /** * Default constructor. */ @@ -61,6 +64,7 @@ public VisorCacheModifyTaskArg(String cacheName, VisorModifyCacheMode mode, Obje this.mode = mode; this.key = key; this.val = val; + this.modifiedValues = "[Key=" + key + ", Value=" + val + "]"; } /** @@ -97,6 +101,7 @@ public Object getValue() { U.writeEnum(out, mode); out.writeObject(key); out.writeObject(val); + U.writeString(out, modifiedValues); } /** {@inheritDoc} */ @@ -105,6 +110,7 @@ public Object getValue() { mode = VisorModifyCacheMode.fromOrdinal(in.readByte()); key = in.readObject(); val = in.readObject(); + modifiedValues = U.readString(in); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java index 93c9c60c571d8..11ae18de754f8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java @@ -36,10 +36,11 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorMultiNodeTask; +import org.apache.ignite.internal.visor.util.VisorTaskUtils; import org.jetbrains.annotations.Nullable; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; import static org.apache.ignite.internal.visor.util.VisorTaskUtils.escapeName; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; /** * Task that collect keys distribution in partitions. @@ -98,7 +99,7 @@ private VisorCachePartitionsJob(VisorCachePartitionsTaskArg arg, boolean debug) GridCacheAdapter ca = ignite.context().cache().internalCache(cacheName); // Cache was not started. - if (ca == null || !ca.context().started()) + if (ca == null || !ca.context().started() || VisorTaskUtils.isRestartingCache(ignite, cacheName)) return parts; CacheConfiguration cfg = ca.configuration(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTask.java index 87a2ce6713c22..9c3fd37e32bb6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTask.java @@ -23,6 +23,7 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorJob; @@ -32,6 +33,7 @@ * Pre-loads caches. Made callable just to conform common pattern. */ @GridInternal +@GridVisorManagementTask public class VisorCacheRebalanceTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTask.java index 2ad88ee75b7b6..aa90d3e52a77d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTask.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.visor.cache; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -26,6 +27,7 @@ * Reset lost partitions for caches. */ @GridInternal +@GridVisorManagementTask public class VisorCacheResetLostPartitionsTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTaskArg.java index 2f365c82d6fba..5f607304cb8d8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTaskArg.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTaskArg.java @@ -35,6 +35,9 @@ public class VisorCacheResetLostPartitionsTaskArg extends VisorDataTransferObjec /** List of cache names. */ private List cacheNames; + /** Created for toString method because Collection can't be printed. */ + private String modifiedCaches; + /** * Default constructor. */ @@ -47,6 +50,9 @@ public VisorCacheResetLostPartitionsTaskArg() { */ public VisorCacheResetLostPartitionsTaskArg(List cacheNames) { this.cacheNames = cacheNames; + + if(cacheNames != null) + modifiedCaches = cacheNames.toString(); } /** @@ -59,11 +65,13 @@ public List getCacheNames() { /** {@inheritDoc} */ @Override protected void writeExternalData(ObjectOutput out) throws IOException { U.writeCollection(out, cacheNames); + U.writeString(out, modifiedCaches); } /** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { cacheNames = U.readList(in); + modifiedCaches = U.readString(in); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java index 5f6337be0147e..7663827b53e6b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java @@ -29,6 +29,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; @@ -40,6 +41,7 @@ * Task that start cache or near cache with specified configuration. */ @GridInternal +@GridVisorManagementTask public class VisorCacheStartTask extends VisorMultiNodeTask, Void> { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTask.java index df95c5ea73488..b76fc3df40315 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTask.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.HashSet; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; @@ -29,6 +30,7 @@ * Task that stop specified caches on specified node. */ @GridInternal +@GridVisorManagementTask public class VisorCacheStopTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTask.java new file mode 100644 index 0000000000000..aebed810d2cc0 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTask.java @@ -0,0 +1,72 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.cache; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorOneNodeTask; + +/** + * Switch statisticsEnabled flag for specified caches to specified state. + */ +@GridInternal +public class VisorCacheToggleStatisticsTask extends VisorOneNodeTask { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorCachesToggleStatisticsJob job(VisorCacheToggleStatisticsTaskArg arg) { + return new VisorCachesToggleStatisticsJob(arg, debug); + } + + /** + * Job that switch statisticsEnabled flag for specified caches to specified state. + */ + private static class VisorCachesToggleStatisticsJob extends VisorJob { + /** */ + private static final long serialVersionUID = 0L; + + /** + * @param arg Job argument object. + * @param debug Debug flag. + */ + private VisorCachesToggleStatisticsJob(VisorCacheToggleStatisticsTaskArg arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected Void run(VisorCacheToggleStatisticsTaskArg arg) { + try { + ignite.context().cache().enableStatistics(arg.getCacheNames(), arg.getState()); + } + catch (IgniteCheckedException e) { + throw U.convertException(e); + } + + return null; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorCachesToggleStatisticsJob.class, this); + } + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTaskArg.java new file mode 100644 index 0000000000000..34359daeacf6c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTaskArg.java @@ -0,0 +1,87 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.cache; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Set; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObject; + +/** + * Argument for {@link VisorCacheToggleStatisticsTask}. + */ +public class VisorCacheToggleStatisticsTaskArg extends VisorDataTransferObject { + /** */ + private static final long serialVersionUID = 0L; + + /** State to set to statisticsEnabled flag. */ + private boolean state; + + /** Cache names to toggle statisticsEnabled flag. */ + private Set cacheNames; + + /** + * Default constructor. + */ + public VisorCacheToggleStatisticsTaskArg() { + // No-op. + } + + /** + * @param state State to set to statisticsEnabled flag. + * @param cacheNames Collection of cache names to toggle statisticsEnabled flag. + */ + public VisorCacheToggleStatisticsTaskArg(boolean state, Set cacheNames) { + this.state = state; + this.cacheNames = cacheNames; + } + + /** + * @return State to set to statisticsEnabled flag. + */ + public boolean getState() { + return state; + } + + /** + * @return Cache names to toggle statisticsEnabled flag. + */ + public Set getCacheNames() { + return cacheNames; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + out.writeBoolean(state); + U.writeCollection(out, cacheNames); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + state = in.readBoolean(); + cacheNames = U.readSet(in); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorCacheToggleStatisticsTaskArg.class, this); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeCancelSessionsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeCancelSessionsTask.java index 6cd683ca42318..8b29a400e19da 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeCancelSessionsTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeCancelSessionsTask.java @@ -24,6 +24,7 @@ import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.compute.ComputeTaskFuture; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -34,6 +35,7 @@ * Cancels given tasks sessions. */ @GridInternal +@GridVisorManagementTask public class VisorComputeCancelSessionsTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeResetMetricsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeResetMetricsTask.java index eefeb746240d8..ac3e18b4a0d93 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeResetMetricsTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeResetMetricsTask.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.visor.compute; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -26,6 +27,7 @@ * Reset compute grid metrics task. */ @GridInternal +@GridVisorManagementTask public class VisorComputeResetMetricsTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTask.java index 9c6aa603a10b5..f064028abcf29 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTask.java @@ -20,6 +20,7 @@ import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorJob; @@ -29,6 +30,7 @@ * Creates thread dump. */ @GridInternal +@GridVisorManagementTask public class VisorThreadDumpTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTask.java index e4685b73bcf6d..340abea3b0505 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTask.java @@ -19,6 +19,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -27,6 +28,7 @@ * Format IGFS instance. */ @GridInternal +@GridVisorManagementTask public class VisorIgfsFormatTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTask.java index c730840ab621b..dc1a30ada5060 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTask.java @@ -28,6 +28,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteFileSystem; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorJob; @@ -39,6 +40,7 @@ * Remove all IGFS profiler logs. */ @GridInternal +@GridVisorManagementTask public class VisorIgfsProfilerClearTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTask.java index ee90edf3bc78e..b1eaddad9d683 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTask.java @@ -19,6 +19,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -27,6 +28,7 @@ * Resets IGFS metrics. */ @GridInternal +@GridVisorManagementTask public class VisorIgfsResetMetricsTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTask.java index e4d2882568d1a..04ee29cda70bc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTask.java @@ -30,6 +30,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.io.GridReversedLinesFileReader; import org.apache.ignite.internal.util.lang.GridTuple3; import org.apache.ignite.internal.util.typedef.internal.S; @@ -48,6 +49,7 @@ * Search text matching in logs */ @GridInternal +@GridVisorManagementTask public class VisorLogSearchTask extends VisorMultiNodeTask> { /** */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTask.java index bde4d6ccfc806..86aee0343202b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTask.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.visor.misc; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -26,6 +27,7 @@ * Task for changing grid active state. */ @GridInternal +@GridVisorManagementTask public class VisorChangeGridActiveStateTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorJobResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorJobResult.java new file mode 100644 index 0000000000000..5bd818d424848 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorJobResult.java @@ -0,0 +1,91 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.node; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.apache.ignite.internal.dto.IgniteDataTransferObject; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +/** + * Result object for cache rebalance job. + */ +public class VisorCacheRebalanceCollectorJobResult extends IgniteDataTransferObject { + /** */ + private static final long serialVersionUID = 0L; + + /** Rebalance percent. */ + private double rebalance; + + /** Node baseline state. */ + private VisorNodeBaselineStatus baseline; + + /** + * Default constructor. + */ + public VisorCacheRebalanceCollectorJobResult() { + // No-op. + } + + /** + * @return Rebalance progress. + */ + public double getRebalance() { + return rebalance; + } + + /** + * @param rebalance Rebalance progress. + */ + public void setRebalance(double rebalance) { + this.rebalance = rebalance; + } + + /** + * @return Node baseline status. + */ + public VisorNodeBaselineStatus getBaseline() { + return baseline; + } + + /** + * @param baseline Node baseline status. + */ + public void setBaseline(VisorNodeBaselineStatus baseline) { + this.baseline = baseline; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + out.writeDouble(rebalance); + U.writeEnum(out, baseline); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + rebalance = in.readDouble(); + baseline = VisorNodeBaselineStatus.fromOrdinal(in.readByte()); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorCacheRebalanceCollectorJobResult.class, this); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTask.java new file mode 100644 index 0000000000000..9d0e04144ea58 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTask.java @@ -0,0 +1,194 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.node; + +import java.util.Collection; +import java.util.List; +import org.apache.ignite.cache.CacheMetrics; +import org.apache.ignite.cluster.BaselineNode; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.internal.cluster.IgniteClusterEx; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; +import org.apache.ignite.internal.processors.cache.GridCacheAdapter; +import org.apache.ignite.internal.processors.cache.GridCacheProcessor; +import org.apache.ignite.internal.processors.cache.GridCacheUtils; +import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorMultiNodeTask; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.visor.node.VisorNodeBaselineStatus.BASELINE_NOT_AVAILABLE; +import static org.apache.ignite.internal.visor.node.VisorNodeBaselineStatus.NODE_IN_BASELINE; +import static org.apache.ignite.internal.visor.node.VisorNodeBaselineStatus.NODE_NOT_IN_BASELINE; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.MINIMAL_REBALANCE; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.NOTHING_TO_REBALANCE; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.REBALANCE_COMPLETE; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.REBALANCE_NOT_AVAILABLE; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.isProxyCache; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.isRestartingCache; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; + +/** + * Collects topology rebalance metrics. + */ +@GridInternal +public class VisorCacheRebalanceCollectorTask extends VisorMultiNodeTask { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorCacheRebalanceCollectorJob job(VisorCacheRebalanceCollectorTaskArg arg) { + return new VisorCacheRebalanceCollectorJob(arg, debug); + } + + /** {@inheritDoc} */ + @Nullable @Override protected VisorCacheRebalanceCollectorTaskResult reduce0(List results) { + return reduce(new VisorCacheRebalanceCollectorTaskResult(), results); + } + + /** + * @param taskRes Task result. + * @param results Results. + * @return Topology rebalance metrics collector task result. + */ + protected VisorCacheRebalanceCollectorTaskResult reduce( + VisorCacheRebalanceCollectorTaskResult taskRes, + List results + ) { + for (ComputeJobResult res : results) { + VisorCacheRebalanceCollectorJobResult jobRes = res.getData(); + + if (jobRes != null) { + if (res.getException() == null) + taskRes.getRebalance().put(res.getNode().id(), jobRes.getRebalance()); + + taskRes.getBaseline().put(res.getNode().id(), jobRes.getBaseline()); + } + } + + return taskRes; + } + + /** + * Job that collects rebalance metrics. + */ + private static class VisorCacheRebalanceCollectorJob extends VisorJob { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Create job with given argument. + * + * @param arg Job argument. + * @param debug Debug flag. + */ + private VisorCacheRebalanceCollectorJob(VisorCacheRebalanceCollectorTaskArg arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected VisorCacheRebalanceCollectorJobResult run(VisorCacheRebalanceCollectorTaskArg arg) { + VisorCacheRebalanceCollectorJobResult res = new VisorCacheRebalanceCollectorJobResult(); + + long start0 = U.currentTimeMillis(); + + try { + int partitions = 0; + double total = 0; + double ready = 0; + + GridCacheProcessor cacheProc = ignite.context().cache(); + + boolean rebalanceInProgress = false; + + for (CacheGroupContext grp: cacheProc.cacheGroups()) { + String cacheName = grp.config().getName(); + + if (isProxyCache(ignite, cacheName) || isRestartingCache(ignite, cacheName)) + continue; + + try { + GridCacheAdapter ca = cacheProc.internalCache(cacheName); + + if (ca == null || !ca.context().started()) + continue; + + CacheMetrics cm = ca.localMetrics(); + + partitions += cm.getTotalPartitionsCount(); + + long keysTotal = cm.getEstimatedRebalancingKeys(); + long keysReady = cm.getRebalancedKeys(); + + if (keysReady >= keysTotal) + keysReady = Math.max(keysTotal - 1, 0); + + total += keysTotal; + ready += keysReady; + + if (cm.getRebalancingPartitionsCount() > 0) + rebalanceInProgress = true; + } + catch(IllegalStateException | IllegalArgumentException e) { + if (debug && ignite.log() != null) + ignite.log().error("Ignored cache group: " + grp.cacheOrGroupName(), e); + } + } + + if (partitions == 0) + res.setRebalance(NOTHING_TO_REBALANCE); + else if (total == 0 && rebalanceInProgress) + res.setRebalance(MINIMAL_REBALANCE); + else + res.setRebalance(total > 0 && rebalanceInProgress ? Math.max(ready / total, MINIMAL_REBALANCE) : REBALANCE_COMPLETE); + } + catch (Exception e) { + res.setRebalance(REBALANCE_NOT_AVAILABLE); + + ignite.log().error("Failed to collect rebalance metrics", e); + } + + if (GridCacheUtils.isPersistenceEnabled(ignite.configuration())) { + IgniteClusterEx cluster = ignite.cluster(); + + Object consistentId = ignite.localNode().consistentId(); + + Collection baseline = cluster.currentBaselineTopology(); + + boolean inBaseline = baseline.stream().anyMatch(n -> consistentId.equals(n.consistentId())); + + res.setBaseline(inBaseline ? NODE_IN_BASELINE : NODE_NOT_IN_BASELINE); + } + else + res.setBaseline(BASELINE_NOT_AVAILABLE); + + if (debug) + log(ignite.log(), "Collected rebalance metrics", getClass(), start0); + + return res; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorCacheRebalanceCollectorJob.class, this); + } + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskArg.java new file mode 100644 index 0000000000000..d97fd50192572 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskArg.java @@ -0,0 +1,54 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.node; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.visor.VisorDataTransferObject; + +/** + * Argument for {@link VisorCacheRebalanceCollectorTask} task. + */ +public class VisorCacheRebalanceCollectorTaskArg extends VisorDataTransferObject { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Default constructor. + */ + public VisorCacheRebalanceCollectorTaskArg() { + // No-op. + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + // No-op. + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorCacheRebalanceCollectorTaskArg.class, this); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskResult.java new file mode 100644 index 0000000000000..1305cd2df87eb --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskResult.java @@ -0,0 +1,92 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.node; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import org.apache.ignite.internal.dto.IgniteDataTransferObject; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +/** + * Result object for {@link VisorCacheRebalanceCollectorTask} task. + */ +public class VisorCacheRebalanceCollectorTaskResult extends IgniteDataTransferObject { + /** */ + private static final long serialVersionUID = 0L; + + /** Rebalance state on nodes. */ + private Map rebalance = new HashMap<>(); + + /** Nodes baseline status. */ + private Map baseline = new HashMap<>(); + + /** + * Default constructor. + */ + public VisorCacheRebalanceCollectorTaskResult() { + // No-op. + } + + /** + * @return Rebalance on nodes. + */ + public Map getRebalance() { + return rebalance; + } + + /** + * @return Baseline. + */ + public Map getBaseline() { + return baseline; + } + + /** + * Add specified results. + * + * @param res Results to add. + */ + public void add(VisorCacheRebalanceCollectorTaskResult res) { + assert res != null; + + rebalance.putAll(res.getRebalance()); + baseline.putAll(res.getBaseline()); + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + U.writeMap(out, rebalance); + U.writeMap(out, baseline); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + rebalance = U.readMap(in); + baseline = U.readMap(in); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorCacheRebalanceCollectorTaskResult.class, this); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java index 85849a56f907c..a9144abc5f45a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java @@ -126,6 +126,9 @@ public class VisorGridConfiguration extends VisorDataTransferObject { /** Client connector configuration */ private VisorClientConnectorConfiguration clnConnCfg; + /** MVCC configuration. */ + private VisorMvccConfiguration mvccCfg; + /** * Default constructor. */ @@ -192,6 +195,8 @@ public VisorGridConfiguration(IgniteEx ignite) { if (dsCfg != null) dataStorage = new VisorDataStorageConfiguration(dsCfg); + + mvccCfg = new VisorMvccConfiguration(c); } /** @@ -383,9 +388,16 @@ public VisorDataStorageConfiguration getDataStorageConfiguration() { return dataStorage; } + /** + * @return MVCC configuration. + */ + public VisorMvccConfiguration getMvccConfiguration() { + return mvccCfg; + } + /** {@inheritDoc} */ @Override public byte getProtocolVersion() { - return V3; + return V4; } /** {@inheritDoc} */ @@ -417,6 +429,7 @@ public VisorDataStorageConfiguration getDataStorageConfiguration() { U.writeCollection(out, srvcCfgs); out.writeObject(dataStorage); out.writeObject(clnConnCfg); + out.writeObject(mvccCfg); } /** {@inheritDoc} */ @@ -447,11 +460,14 @@ public VisorDataStorageConfiguration getDataStorageConfiguration() { sqlConnCfg = (VisorSqlConnectorConfiguration) in.readObject(); srvcCfgs = U.readList(in); - if (protoVer >= V2) + if (protoVer > V1) dataStorage = (VisorDataStorageConfiguration)in.readObject(); - if (protoVer >= V3) + if (protoVer > V2) clnConnCfg = (VisorClientConnectorConfiguration)in.readObject(); + + if (protoVer > V3) + mvccCfg = (VisorMvccConfiguration)in.readObject(); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMvccConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMvccConfiguration.java new file mode 100644 index 0000000000000..1bcaa21507818 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMvccConfiguration.java @@ -0,0 +1,94 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.node; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.visor.VisorDataTransferObject; + +/** + * Data transfer object for data store configuration. + */ +public class VisorMvccConfiguration extends VisorDataTransferObject { + /** */ + private static final long serialVersionUID = 0L; + + /** Number of MVCC vacuum cleanup threads. */ + private int mvccVacuumThreadCnt; + + /** Time interval between vacuum runs */ + private long mvccVacuumFreq; + + /** + * Default constructor. + */ + public VisorMvccConfiguration() { + // No-op. + } + + /** + * Constructor. + * + * @param cfg Ignite configuration. + */ + public VisorMvccConfiguration(IgniteConfiguration cfg) { + assert cfg != null; + + mvccVacuumThreadCnt = cfg.getMvccVacuumThreadCount(); + mvccVacuumFreq = cfg.getMvccVacuumFrequency(); + } + + /** + * @return Number of MVCC vacuum threads. + */ + public int getMvccVacuumThreadCount() { + return mvccVacuumThreadCnt; + } + + /** + * @return Time interval between MVCC vacuum runs in milliseconds. + */ + public long getMvccVacuumFrequency() { + return mvccVacuumFreq; + } + + /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return V1; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + out.writeInt(mvccVacuumThreadCnt); + out.writeLong(mvccVacuumFreq); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + mvccVacuumThreadCnt = in.readInt(); + mvccVacuumFreq = in.readLong(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorMvccConfiguration.class, this); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeBaselineStatus.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeBaselineStatus.java new file mode 100644 index 0000000000000..ea90be3a6ef2c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeBaselineStatus.java @@ -0,0 +1,45 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.node; + +import org.jetbrains.annotations.Nullable; + +/** + * Node baseline status. + */ +public enum VisorNodeBaselineStatus { + /** */ + NODE_IN_BASELINE, + /** */ + NODE_NOT_IN_BASELINE, + /** */ + BASELINE_NOT_AVAILABLE; + + /** Enumerated values. */ + private static final VisorNodeBaselineStatus[] VALS = values(); + + /** + * Efficiently gets enumerated value from its ordinal. + * + * @param ord Ordinal value. + * @return Enumerated value or {@code null} if ordinal out of range. + */ + @Nullable public static VisorNodeBaselineStatus fromOrdinal(int ord) { + return ord >= 0 && ord < VALS.length ? VALS[ord] : null; + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java index 5fab8d16d5e94..3a115dffd5a1f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java @@ -28,8 +28,9 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.FileSystemConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter; @@ -50,9 +51,15 @@ import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isSystemCache; import static org.apache.ignite.internal.visor.compute.VisorComputeMonitoringHolder.COMPUTE_MONITORING_HOLDER_KEY; import static org.apache.ignite.internal.visor.util.VisorTaskUtils.EVT_MAPPER; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.MINIMAL_REBALANCE; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.NOTHING_TO_REBALANCE; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.REBALANCE_COMPLETE; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.REBALANCE_NOT_AVAILABLE; import static org.apache.ignite.internal.visor.util.VisorTaskUtils.VISOR_TASK_EVTS; import static org.apache.ignite.internal.visor.util.VisorTaskUtils.checkExplicitTaskMonitoring; import static org.apache.ignite.internal.visor.util.VisorTaskUtils.collectEvents; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.isProxyCache; +import static org.apache.ignite.internal.visor.util.VisorTaskUtils.isRestartingCache; import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; /** @@ -140,18 +147,6 @@ protected boolean compatibleWith(IgniteProductVersion ver) { return false; } - /** - * @param cacheName Cache name to check. - * @return {@code true} if cache on local node is not a data cache or near cache disabled. - */ - private boolean proxyCache(String cacheName) { - GridDiscoveryManager discovery = ignite.context().discovery(); - - ClusterNode locNode = ignite.localNode(); - - return !(discovery.cacheAffinityNode(locNode, cacheName) || discovery.cacheNearNode(locNode, cacheName)); - } - /** * Collect memory metrics. * @@ -194,38 +189,51 @@ protected void caches(VisorNodeDataCollectorJobResult res, VisorNodeDataCollecto List resCaches = res.getCaches(); - for (String cacheName : cacheProc.cacheNames()) { - if (proxyCache(cacheName)) - continue; + boolean rebalanceInProgress = false; - boolean sysCache = isSystemCache(cacheName); + for (CacheGroupContext grp : cacheProc.cacheGroups()) { + boolean first = true; - if (arg.getSystemCaches() || !(sysCache || isIgfsCache(cfg, cacheName))) { + for (GridCacheContext cache : grp.caches()) { long start0 = U.currentTimeMillis(); + String cacheName = cache.name(); + try { + if (isProxyCache(ignite, cacheName) || isRestartingCache(ignite, cacheName)) + continue; + GridCacheAdapter ca = cacheProc.internalCache(cacheName); if (ca == null || !ca.context().started()) continue; - CacheMetrics cm = ca.localMetrics(); + if (first) { + CacheMetrics cm = ca.localMetrics(); + + partitions += cm.getTotalPartitionsCount(); + + long keysTotal = cm.getEstimatedRebalancingKeys(); + long keysReady = cm.getRebalancedKeys(); + + if (keysReady >= keysTotal) + keysReady = Math.max(keysTotal - 1, 0); - partitions += cm.getTotalPartitionsCount(); + total += keysTotal; + ready += keysReady; - long partTotal = cm.getEstimatedRebalancingKeys(); - long partReady = cm.getRebalancedKeys(); + if (!rebalanceInProgress && cm.getRebalancingPartitionsCount() > 0) + rebalanceInProgress = true; - if (partReady >= partTotal) - partReady = Math.max(partTotal - 1, 0); + first = false; + } - total += partTotal; - ready += partReady; + boolean addToRes = arg.getSystemCaches() || !(isSystemCache(cacheName) || isIgfsCache(cfg, cacheName)); - if (all || cacheGrps.contains(ca.configuration().getGroupName())) + if (addToRes && (all || cacheGrps.contains(ca.configuration().getGroupName()))) resCaches.add(new VisorCache(ignite, ca, arg.isCollectCacheMetrics())); } - catch(IllegalStateException | IllegalArgumentException e) { + catch (IllegalStateException | IllegalArgumentException e) { if (debug && ignite.log() != null) ignite.log().error("Ignored cache: " + cacheName, e); } @@ -237,11 +245,16 @@ protected void caches(VisorNodeDataCollectorJobResult res, VisorNodeDataCollecto } if (partitions == 0) - res.setRebalance(-1); + res.setRebalance(NOTHING_TO_REBALANCE); + else if (total == 0 && rebalanceInProgress) + res.setRebalance(MINIMAL_REBALANCE); else - res.setRebalance(total > 0 ? ready / total : 1); + res.setRebalance(total > 0 && rebalanceInProgress + ? Math.max(ready / total, MINIMAL_REBALANCE) + : REBALANCE_COMPLETE); } catch (Exception e) { + res.setRebalance(REBALANCE_NOT_AVAILABLE); res.setCachesEx(new VisorExceptionWrapper(e)); } } @@ -260,7 +273,8 @@ protected void igfs(VisorNodeDataCollectorJobResult res) { FileSystemConfiguration igfsCfg = igfs.configuration(); - if (proxyCache(igfsCfg.getDataCacheConfiguration().getName()) || proxyCache(igfsCfg.getMetaCacheConfiguration().getName())) + if (isProxyCache(ignite, igfsCfg.getDataCacheConfiguration().getName()) || + isProxyCache(ignite, igfsCfg.getMetaCacheConfiguration().getName())) continue; try { @@ -335,7 +349,8 @@ protected VisorNodeDataCollectorJobResult run(VisorNodeDataCollectorJobResult re if (debug) start0 = log(ignite.log(), "Collected memory metrics", getClass(), start0); - caches(res, arg); + if (ignite.cluster().active()) + caches(res, arg); if (debug) start0 = log(ignite.log(), "Collected caches", getClass(), start0); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java index eb161f82c6638..f8eb8690ce2ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java @@ -131,7 +131,8 @@ public boolean isEmpty() { readyTopVers.isEmpty() && pendingExchanges.isEmpty() && persistenceMetrics.isEmpty() && - persistenceMetricsEx.isEmpty(); + persistenceMetricsEx.isEmpty() && + rebalance.isEmpty(); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTask.java index bdc1104cc5dcf..1e0ca4717d4f7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTask.java @@ -25,6 +25,7 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorMultiNodeTask; @@ -34,6 +35,7 @@ * Task to run gc on nodes. */ @GridInternal +@GridVisorManagementTask public class VisorNodeGcTask extends VisorMultiNodeTask, VisorNodeGcTaskResult> { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTask.java index ee2e968ffb11f..656d12aee3d52 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTask.java @@ -21,6 +21,7 @@ import org.apache.ignite.cluster.ClusterTopologyException; import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -30,6 +31,7 @@ * Ping other node. */ @GridInternal +@GridVisorManagementTask public class VisorNodePingTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeRestartTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeRestartTask.java index bb293710e8051..693665a672451 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeRestartTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeRestartTask.java @@ -21,6 +21,7 @@ import org.apache.ignite.Ignition; import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorMultiNodeTask; @@ -30,6 +31,7 @@ * Restarts nodes. */ @GridInternal +@GridVisorManagementTask public class VisorNodeRestartTask extends VisorMultiNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeStopTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeStopTask.java index 16bf5d6288cd0..6581e44e352c3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeStopTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeStopTask.java @@ -21,6 +21,7 @@ import org.apache.ignite.Ignition; import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorMultiNodeTask; @@ -30,6 +31,7 @@ * Stops nodes. */ @GridInternal +@GridVisorManagementTask public class VisorNodeStopTask extends VisorMultiNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTask.java index 207b690bc9bd5..32dc93cabe3d4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTask.java @@ -22,6 +22,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; import org.jetbrains.annotations.Nullable; @@ -30,6 +31,7 @@ * Task to cancel queries. */ @GridInternal +@GridVisorManagementTask public class VisorQueryCancelTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTask.java index 1d807f1aeb6e5..a339f8d790474 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTask.java @@ -19,6 +19,7 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -27,6 +28,7 @@ * Reset compute grid query metrics. */ @GridInternal +@GridVisorManagementTask public class VisorQueryResetMetricsTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java index b5af1b04b5151..97ee83e128f7a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java @@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; @@ -44,6 +45,7 @@ * Task for execute SQL fields query and get first page of results. */ @GridInternal +@GridVisorManagementTask public class VisorQueryTask extends VisorOneNodeTask> { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorCancelServiceTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorCancelServiceTask.java index 53c3bb3fa8914..1bb7ecde4e39f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorCancelServiceTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorCancelServiceTask.java @@ -19,6 +19,7 @@ import org.apache.ignite.IgniteServices; import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; @@ -27,6 +28,7 @@ * Task for cancel services with specified name. */ @GridInternal +@GridVisorManagementTask public class VisorCancelServiceTask extends VisorOneNodeTask { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/tx/VisorTxSortOrder.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/tx/VisorTxSortOrder.java index 9a18882c24958..1b4cdff7f0e2b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/tx/VisorTxSortOrder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/tx/VisorTxSortOrder.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.visor.tx; -import org.apache.ignite.internal.commandline.CommandHandler; import org.jetbrains.annotations.Nullable; /** @@ -42,20 +41,4 @@ public enum VisorTxSortOrder { @Nullable public static VisorTxSortOrder fromOrdinal(int ord) { return ord >= 0 && ord < VALS.length ? VALS[ord] : null; } - - /** - * @param name Name. - */ - public static VisorTxSortOrder fromString(String name) { - if (DURATION.toString().equals(name)) - return DURATION; - - if (SIZE.toString().equals(name)) - return SIZE; - - if (CommandHandler.CMD_TX_ORDER_START_TIME.equals(name)) - return START_TIME; - - throw new IllegalArgumentException("Sort order is unknown: " + name); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java index fda9ba199bc0f..7ab1ffcb18b84 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java @@ -58,6 +58,10 @@ import org.apache.ignite.cache.eviction.AbstractEvictionPolicyFactory; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.events.Event; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; +import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; +import org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl; import org.apache.ignite.internal.processors.igfs.IgfsEx; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; @@ -109,6 +113,19 @@ public class VisorTaskUtils { /** Log files count limit */ public static final int LOG_FILES_COUNT_LIMIT = 5000; + /** */ + public static final int NOTHING_TO_REBALANCE = -1; + + /** */ + public static final int REBALANCE_NOT_AVAILABLE = -2; + + /** */ + public static final double MINIMAL_REBALANCE = 0.01; + + /** */ + public static final int REBALANCE_COMPLETE = 1; + + /** */ private static final int DFLT_BUFFER_SIZE = 4096; @@ -1248,4 +1265,30 @@ public static Collection splitAddresses(String s) { return Arrays.asList(addrs); } + + /** + * @param ignite Ignite. + * @param cacheName Cache name to check. + * @return {@code true} if cache on local node is not a data cache or near cache disabled. + */ + public static boolean isProxyCache(IgniteEx ignite, String cacheName) { + GridDiscoveryManager discovery = ignite.context().discovery(); + + ClusterNode locNode = ignite.localNode(); + + return !(discovery.cacheAffinityNode(locNode, cacheName) || discovery.cacheNearNode(locNode, cacheName)); + } + + /** + * Check whether cache restarting in progress. + * + * @param ignite Grid. + * @param cacheName Cache name to check. + * @return {@code true} when cache restarting in progress. + */ + public static boolean isRestartingCache(IgniteEx ignite, String cacheName) { + IgniteCacheProxy proxy = ignite.context().cache().jcache(cacheName); + + return proxy instanceof IgniteCacheProxyImpl && ((IgniteCacheProxyImpl) proxy).isRestarting(); + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/CacheFilterEnum.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/CacheFilterEnum.java new file mode 100644 index 0000000000000..4e87d5068eaa5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/CacheFilterEnum.java @@ -0,0 +1,52 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.verify; + +import org.jetbrains.annotations.Nullable; + +/** + * Represents a type of cache(s) that can be used for comparing update counters and checksums between primary and backup partitions. + *
+ * @see org.apache.ignite.internal.processors.cache.verify.VerifyBackupPartitionsTaskV2 + */ +public enum CacheFilterEnum { + /** All. */ + ALL, + + /** System. */ + SYSTEM, + + /** Persistent. */ + PERSISTENT, + + /** Not persistent. */ + NOT_PERSISTENT; + + /** Enumerated values. */ + private static final CacheFilterEnum[] VALS = values(); + + /** + * Efficiently gets enumerated value from its ordinal. + * + * @param ord Ordinal value. + * @return Enumerated value or {@code null} if ordinal out of range. + */ + public static @Nullable CacheFilterEnum fromOrdinal(int ord) { + return ord >= 0 && ord < VALS.length ? VALS[ord] : null; + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/IndexIntegrityCheckIssue.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/IndexIntegrityCheckIssue.java new file mode 100644 index 0000000000000..ec6e5b2440765 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/IndexIntegrityCheckIssue.java @@ -0,0 +1,74 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.visor.verify; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.apache.ignite.internal.util.tostring.GridToStringExclude; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObject; + +/** + * + */ +public class IndexIntegrityCheckIssue extends VisorDataTransferObject { + /** */ + private static final long serialVersionUID = 0L; + + /** Cache group name. */ + private String grpName; + + /** T. */ + @GridToStringExclude + private Throwable t; + + /** + * + */ + public IndexIntegrityCheckIssue() { + // Default constructor required for Externalizable. + } + + /** + * @param grpName Group name. + * @param t Data integrity check error. + */ + public IndexIntegrityCheckIssue(String grpName, Throwable t) { + this.grpName = grpName; + this.t = t; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + U.writeString(out, this.grpName); + out.writeObject(t); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + this.grpName = U.readString(in); + this.t = (Throwable)in.readObject(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(IndexIntegrityCheckIssue.class, this) + ", " + t.getClass() + ": " + t.getMessage(); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleVerifyDumpTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleVerifyDumpTaskArg.java index 6316c2443a73d..3c836a40cdef6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleVerifyDumpTaskArg.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleVerifyDumpTaskArg.java @@ -22,6 +22,7 @@ import java.io.ObjectOutput; import java.util.Set; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; /** * Arguments for {@link VisorIdleVerifyDumpTask}. @@ -29,9 +30,13 @@ public class VisorIdleVerifyDumpTaskArg extends VisorIdleVerifyTaskArg { /** */ private static final long serialVersionUID = 0L; + /** */ private boolean skipZeros; + /** Cache kind. */ + private CacheFilterEnum cacheFilterEnum; + /** * Default constructor. */ @@ -40,11 +45,14 @@ public VisorIdleVerifyDumpTaskArg() { /** * @param caches Caches. + * @param excludeCaches Caches to exclude. * @param skipZeros Skip zeros partitions. + * @param cacheFilterEnum Cache kind. */ - public VisorIdleVerifyDumpTaskArg(Set caches, boolean skipZeros) { - super(caches); + public VisorIdleVerifyDumpTaskArg(Set caches, Set excludeCaches, boolean skipZeros, CacheFilterEnum cacheFilterEnum) { + super(caches, excludeCaches); this.skipZeros = skipZeros; + this.cacheFilterEnum = cacheFilterEnum; } /** @@ -54,16 +62,37 @@ public boolean isSkipZeros() { return skipZeros; } + /** + * @return Kind fo cache. + */ + public CacheFilterEnum getCacheFilterEnum() { + return cacheFilterEnum; + } + /** {@inheritDoc} */ @Override protected void writeExternalData(ObjectOutput out) throws IOException { super.writeExternalData(out); + out.writeBoolean(skipZeros); + + U.writeEnum(out, cacheFilterEnum); } /** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { super.readExternalData(protoVer, in); + skipZeros = in.readBoolean(); + + if (protoVer >= V2) + cacheFilterEnum = CacheFilterEnum.fromOrdinal(in.readByte()); + else + cacheFilterEnum = CacheFilterEnum.ALL; + } + + /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return V2; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleVerifyTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleVerifyTaskArg.java index c82af5878ebb6..d645fec16f7b9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleVerifyTaskArg.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleVerifyTaskArg.java @@ -35,6 +35,9 @@ public class VisorIdleVerifyTaskArg extends VisorDataTransferObject { /** Caches. */ private Set caches; + /** Exclude caches or groups. */ + private Set excludeCaches; + /** * Default constructor. */ @@ -42,11 +45,21 @@ public VisorIdleVerifyTaskArg() { // No-op. } + /** + * @param caches Caches. + * @param excludeCaches Exclude caches or group. + */ + public VisorIdleVerifyTaskArg(Set caches, Set excludeCaches) { + this.caches = caches; + this.excludeCaches = excludeCaches; + } + /** * @param caches Caches. */ public VisorIdleVerifyTaskArg(Set caches) { this.caches = caches; + this.excludeCaches = excludeCaches; } @@ -57,14 +70,30 @@ public Set getCaches() { return caches; } + /** + * @return Exclude caches or groups. + */ + public Set excludeCaches() { + return excludeCaches; + } + + /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return V2; + } + /** {@inheritDoc} */ @Override protected void writeExternalData(ObjectOutput out) throws IOException { U.writeCollection(out, caches); + U.writeCollection(out, excludeCaches); } /** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { caches = U.readSet(in); + + if (protoVer >= V2) + excludeCaches = U.readSet(in); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesJobResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesJobResult.java index aa74323898bd8..6d7f7652518cd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesJobResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesJobResult.java @@ -20,11 +20,14 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Collection; +import java.util.Collections; import java.util.Map; import org.apache.ignite.internal.processors.cache.verify.PartitionKey; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorDataTransferObject; +import org.jetbrains.annotations.NotNull; /** * @@ -39,14 +42,22 @@ public class VisorValidateIndexesJobResult extends VisorDataTransferObject { /** Results of reverse indexes validation from node. */ private Map idxRes; + /** Integrity check issues. */ + private Collection integrityCheckFailures; + /** * @param partRes Results of indexes validation from node. * @param idxRes Results of reverse indexes validation from node. + * @param integrityCheckFailures Collection of indexes integrity check failures. */ - public VisorValidateIndexesJobResult(Map partRes, - Map idxRes) { + public VisorValidateIndexesJobResult( + @NotNull Map partRes, + @NotNull Map idxRes, + @NotNull Collection integrityCheckFailures + ) { this.partRes = partRes; this.idxRes = idxRes; + this.integrityCheckFailures = integrityCheckFailures; } /** @@ -57,7 +68,7 @@ public VisorValidateIndexesJobResult() { /** {@inheritDoc} */ @Override public byte getProtocolVersion() { - return V2; + return V3; } /** @@ -71,13 +82,30 @@ public Map partitionResult() { * @return Results of reverse indexes validation from node. */ public Map indexResult() { - return idxRes; + return idxRes == null ? Collections.emptyMap() : idxRes; + } + + /** + * @return Collection of failed integrity checks. + */ + public Collection integrityCheckFailures() { + return integrityCheckFailures == null ? Collections.emptyList() : integrityCheckFailures; + } + + /** + * @return {@code true} If any indexes issues found on node, otherwise returns {@code false}. + */ + public boolean hasIssues() { + return (integrityCheckFailures != null && !integrityCheckFailures.isEmpty()) || + (partRes != null && partRes.entrySet().stream().anyMatch(e -> !e.getValue().issues().isEmpty())) || + (idxRes != null && idxRes.entrySet().stream().anyMatch(e -> !e.getValue().issues().isEmpty())); } /** {@inheritDoc} */ @Override protected void writeExternalData(ObjectOutput out) throws IOException { U.writeMap(out, partRes); U.writeMap(out, idxRes); + U.writeCollection(out, integrityCheckFailures); } /** {@inheritDoc} */ @@ -86,6 +114,9 @@ public Map indexResult() { if (protoVer >= V2) idxRes = U.readMap(in); + + if (protoVer >= V3) + integrityCheckFailures = U.readCollection(in); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesTaskArg.java index aa49977c7a6fa..6dbd961028e69 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesTaskArg.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesTaskArg.java @@ -21,12 +21,14 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.Set; +import java.util.UUID; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorDataTransferObject; + /** - * Arguments for task {@link VisorIdleVerifyTask} + * */ public class VisorValidateIndexesTaskArg extends VisorDataTransferObject { /** */ @@ -41,6 +43,9 @@ public class VisorValidateIndexesTaskArg extends VisorDataTransferObject { /** Check through K element (skip K-1, check Kth). */ private int checkThrough; + /** Nodes on which task will run. */ + private Set nodes; + /** * Default constructor. */ @@ -51,10 +56,11 @@ public VisorValidateIndexesTaskArg() { /** * @param caches Caches. */ - public VisorValidateIndexesTaskArg(Set caches, int checkFirst, int checkThrough) { + public VisorValidateIndexesTaskArg(Set caches, Set nodes, int checkFirst, int checkThrough) { this.caches = caches; this.checkFirst = checkFirst; this.checkThrough = checkThrough; + this.nodes = nodes; } @@ -65,6 +71,13 @@ public Set getCaches() { return caches; } + /** + * @return Nodes on which task will run. If {@code null}, task will run on all server nodes. + */ + public Set getNodes() { + return nodes; + } + /** * @return checkFirst. */ @@ -84,6 +97,7 @@ public int getCheckThrough() { U.writeCollection(out, caches); out.writeInt(checkFirst); out.writeInt(checkThrough); + U.writeCollection(out, nodes); } /** {@inheritDoc} */ @@ -98,11 +112,14 @@ public int getCheckThrough() { checkFirst = -1; checkThrough = -1; } + + if (protoVer > V2) + nodes = U.readSet(in); } /** {@inheritDoc} */ @Override public byte getProtocolVersion() { - return V2; + return V3; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorViewCacheTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorViewCacheTaskArg.java index 5fcd66d18d082..6bc2369406ee9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorViewCacheTaskArg.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorViewCacheTaskArg.java @@ -1,19 +1,19 @@ /* -* 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. -*/ + * 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. + */ package org.apache.ignite.internal.visor.verify; @@ -23,7 +23,6 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorDataTransferObject; -import org.jetbrains.annotations.Nullable; /** * @@ -36,13 +35,13 @@ public class VisorViewCacheTaskArg extends VisorDataTransferObject { private String regex; /** Type. */ - private @Nullable VisorViewCacheCmd cmd; + private VisorViewCacheCmd cmd; /** * @param regex Regex. * @param cmd Command. */ - public VisorViewCacheTaskArg(String regex, @Nullable VisorViewCacheCmd cmd) { + public VisorViewCacheTaskArg(String regex, VisorViewCacheCmd cmd) { this.regex = regex; this.cmd = cmd; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/worker/WorkersRegistry.java b/modules/core/src/main/java/org/apache/ignite/internal/worker/WorkersRegistry.java index 153b289951f0d..3d45f3fc5c404 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/worker/WorkersRegistry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/worker/WorkersRegistry.java @@ -212,7 +212,7 @@ public void setSystemWorkerBlockedTimeout(long val) { // That is, if worker is dead, but still resides in registeredWorkers // then something went wrong, the only extra thing is to test // whether the iterator refers to actual state of registeredWorkers. - GridWorker worker0 = registeredWorkers.get(worker.runner().getName()); + GridWorker worker0 = registeredWorkers.get(runner.getName()); if (worker0 != null && worker0 == worker) workerFailedHnd.apply(worker, SYSTEM_WORKER_TERMINATION); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageCollectionItemType.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageCollectionItemType.java index 2134912e5a500..2340dd9d6afe6 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageCollectionItemType.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageCollectionItemType.java @@ -84,7 +84,10 @@ public enum MessageCollectionItemType { IGNITE_UUID, /** Message. */ - MSG; + MSG, + + /** Topology version. */ + AFFINITY_TOPOLOGY_VERSION; /** Enum values. */ private static final MessageCollectionItemType[] VALS = values(); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java index 050204288927d..6feee1a21eab4 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java @@ -23,6 +23,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.UUID; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.lang.IgniteUuid; /** @@ -229,6 +230,14 @@ public interface MessageReader { */ public IgniteUuid readIgniteUuid(String name); + /** + * Reads {@link AffinityTopologyVersion}. + * + * @param name Field name. + * @return {@link AffinityTopologyVersion}. + */ + public AffinityTopologyVersion readAffinityTopologyVersion(String name); + /** * Reads nested message. * diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java index 692955f39cf15..14d4417be3ee2 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.Map; import java.util.UUID; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.lang.IgniteUuid; /** @@ -254,6 +255,15 @@ public interface MessageWriter { */ public boolean writeIgniteUuid(String name, IgniteUuid val); + /** + * Writes {@link AffinityTopologyVersion}. + * + * @param name Field name. + * @param val {@link AffinityTopologyVersion}. + * @return Whether value was fully written. + */ + public boolean writeAffinityTopologyVersion(String name, AffinityTopologyVersion val); + /** * Writes nested message. * diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermissionSetBuilder.java b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermissionSetBuilder.java index abac541ffdb68..659613aa0e8c5 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermissionSetBuilder.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermissionSetBuilder.java @@ -126,6 +126,11 @@ public SecurityPermissionSetBuilder appendServicePermissions(String name, Securi * @return {@link SecurityPermissionSetBuilder} refer to same permission builder. */ public SecurityPermissionSetBuilder appendCachePermissions(String name, SecurityPermission... perms) { + for (SecurityPermission perm : perms) { + if (perm == SecurityPermission.CACHE_CREATE || perm == SecurityPermission.CACHE_DESTROY) + throw new IgniteException(perm + " should be assigned as system permission, not cache permission"); + } + validate(toCollection("CACHE_"), perms); append(cachePerms, name, toCollection(perms)); @@ -140,7 +145,7 @@ public SecurityPermissionSetBuilder appendCachePermissions(String name, Security * @return {@link SecurityPermissionSetBuilder} refer to same permission builder. */ public SecurityPermissionSetBuilder appendSystemPermissions(SecurityPermission... perms) { - validate(toCollection("EVENTS_", "ADMIN_"), perms); + validate(toCollection("EVENTS_", "ADMIN_", "CACHE_CREATE", "CACHE_DESTROY", "JOIN_AS_SERVER"), perms); sysPerms.addAll(toCollection(perms)); @@ -194,7 +199,7 @@ private void validate(Collection ptrns, SecurityPermission perm) { private final Collection toCollection(T... perms) { assert perms != null; - Collection col = U.newHashSet(perms.length); + Collection col = U.newLinkedHashSet(perms.length); Collections.addAll(col, perms); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java index a7e6e8c72de42..f68ecd68e2591 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java @@ -41,7 +41,6 @@ import org.apache.ignite.internal.processors.timeout.GridSpiTimeoutObject; import org.apache.ignite.internal.util.IgniteExceptionRegistry; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index 6ecb14572ee2b..5f028047981e8 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -118,4 +118,4 @@ int delta() { @Override public String toString() { return S.toString(JobStealingRequest.class, this); } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java index 877d2be0f2fc8..4bd872ab39e68 100755 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java @@ -269,6 +269,9 @@ @IgniteSpiMultipleInstancesSupport(true) @IgniteSpiConsistencyChecked(optional = false) public class TcpCommunicationSpi extends IgniteSpiAdapter implements CommunicationSpi { + /** Time threshold to log too long connection establish. */ + private static final int CONNECTION_ESTABLISH_THRESHOLD_MS = 100; + /** IPC error message. */ public static final String OUT_OF_RESOURCES_TCP_MSG = "Failed to allocate shared memory segment " + "(switching to TCP, may be slower)."; @@ -2984,10 +2987,18 @@ else if (log.isDebugEnabled()) connectGate.enter(); try { + final long start = System.currentTimeMillis(); + GridCommunicationClient client = createTcpClient(node, connIdx); - if (log.isDebugEnabled()) - log.debug("TCP client created: " + client); + final long time = System.currentTimeMillis() - start; + + if (time > CONNECTION_ESTABLISH_THRESHOLD_MS) { + if (log.isInfoEnabled()) + log.info("TCP client created [client=" + client + ", duration=" + time + "ms]"); + } + else if (log.isDebugEnabled()) + log.debug("TCP client created [client=" + client + ", duration=" + time + "ms]"); return client; } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/HandshakeMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/HandshakeMessage.java index e3be9c99c7ed0..f845b0b5bbc19 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/HandshakeMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/HandshakeMessage.java @@ -19,6 +19,7 @@ import java.nio.ByteBuffer; import java.util.UUID; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; @@ -29,6 +30,7 @@ /** * Handshake message. */ +@IgniteCodeGeneratingFail public class HandshakeMessage implements Message { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/HandshakeMessage2.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/HandshakeMessage2.java index f27a825740cae..220781371a69f 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/HandshakeMessage2.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/HandshakeMessage2.java @@ -19,6 +19,7 @@ import java.nio.ByteBuffer; import java.util.UUID; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -26,6 +27,7 @@ /** * Updated handshake message. */ +@IgniteCodeGeneratingFail public class HandshakeMessage2 extends HandshakeMessage { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/NodeIdMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/NodeIdMessage.java index 2c6aa300bd8be..12e2522ce4f05 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/NodeIdMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/NodeIdMessage.java @@ -19,6 +19,7 @@ import java.nio.ByteBuffer; import java.util.UUID; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; @@ -29,6 +30,7 @@ /** * Node ID message. */ +@IgniteCodeGeneratingFail public class NodeIdMessage implements Message { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/RecoveryLastReceivedMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/RecoveryLastReceivedMessage.java index eef2655a3eafa..95d43f6b868c5 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/RecoveryLastReceivedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/messages/RecoveryLastReceivedMessage.java @@ -18,6 +18,7 @@ package org.apache.ignite.spi.communication.tcp.messages; import java.nio.ByteBuffer; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageReader; @@ -27,6 +28,7 @@ /** * Recovery acknowledgment message. */ +@IgniteCodeGeneratingFail public class RecoveryLastReceivedMessage implements Message { /** */ private static final long serialVersionUID = 0L; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryDataBag.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryDataBag.java index b8d8908215130..2b6bbca0c5358 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryDataBag.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryDataBag.java @@ -23,6 +23,7 @@ import java.util.Set; import java.util.UUID; import org.apache.ignite.internal.GridComponent; +import org.apache.ignite.internal.util.typedef.internal.S; import org.jetbrains.annotations.Nullable; /** @@ -312,4 +313,9 @@ public Map commonData() { @Nullable public Map localNodeSpecificData() { return nodeSpecificData.get(DEFAULT_KEY); } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(DiscoveryDataBag.class, this); + } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java index 3b57457b8e644..b0969dd3eb5b5 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java @@ -305,6 +305,11 @@ class ClientImpl extends TcpDiscoveryImpl { } }.start(); + timer.schedule( + new MetricsSender(), + spi.metricsUpdateFreq, + spi.metricsUpdateFreq); + try { joinLatch.await(); @@ -317,11 +322,6 @@ class ClientImpl extends TcpDiscoveryImpl { throw new IgniteSpiException("Thread has been interrupted.", e); } - timer.schedule( - new MetricsSender(), - spi.metricsUpdateFreq, - spi.metricsUpdateFreq); - spi.printStartInfo(); } @@ -1884,6 +1884,7 @@ else if (log.isInfoEnabled()) { err = spi.duplicateIdError((TcpDiscoveryDuplicateIdMessage)msg); else if (discoMsg instanceof TcpDiscoveryAuthFailedMessage) err = spi.authenticationFailedError((TcpDiscoveryAuthFailedMessage)msg); + //TODO: https://issues.apache.org/jira/browse/IGNITE-9829 else if (discoMsg instanceof TcpDiscoveryCheckFailedMessage) err = spi.checkFailedError((TcpDiscoveryCheckFailedMessage)msg); @@ -1898,6 +1899,7 @@ else if (discoMsg instanceof TcpDiscoveryCheckFailedMessage) else joinError(err); + cancel(); break; } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java index 7b0ad53e1e972..141e2256ad89d 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java @@ -263,6 +263,9 @@ class ServerImpl extends TcpDiscoveryImpl { private final ConcurrentMap>> pingMap = new ConcurrentHashMap<>(); + /** Last listener future. */ + private IgniteFuture lastCustomEvtLsnrFut; + /** * @param adapter Adapter. */ @@ -952,10 +955,10 @@ private void joinTopology() throws IgniteSpiException { timeout = threshold - U.currentTimeMillis(); } - catch (InterruptedException ignored) { + catch (InterruptedException e) { Thread.currentThread().interrupt(); - throw new IgniteSpiException("Thread has been interrupted."); + throw new IgniteSpiException("Thread has been interrupted.", e); } } @@ -1959,9 +1962,6 @@ private IpFinderCleaner() { while (!isInterrupted()) { Thread.sleep(spi.ipFinderCleanFreq); - if (!isLocalNodeCoordinator()) - continue; - if (spiStateCopy() != CONNECTED) { if (log.isDebugEnabled()) log.debug("Stopping IP finder cleaner (SPI is not connected to topology)."); @@ -1969,6 +1969,9 @@ private IpFinderCleaner() { return; } + if (!isLocalNodeCoordinator()) + continue; + if (spi.ipFinder.isShared()) cleanIpFinder(); } @@ -2159,6 +2162,20 @@ private static WorkersRegistry getWorkerRegistry(TcpDiscoverySpi spi) { return spi.ignite() instanceof IgniteEx ? ((IgniteEx)spi.ignite()).context().workersRegistry() : null; } + /** + * Wait for all the listeners from previous discovery message to be completed. + */ + private void waitForLastCustomEventListenerFuture() { + if (lastCustomEvtLsnrFut != null) { + try { + lastCustomEvtLsnrFut.get(); + } + finally { + lastCustomEvtLsnrFut = null; + } + } + } + /** * Discovery messages history used for client reconnect. */ @@ -3210,7 +3227,7 @@ else if (!spi.failureDetectionTimeoutEnabled() && (e instanceof assert !forceSndPending || msg instanceof TcpDiscoveryNodeLeftMessage; - if (failure || forceSndPending) { + if (failure || forceSndPending || newNextNode) { if (log.isDebugEnabled()) log.debug("Pending messages will be sent [failure=" + failure + ", newNextNode=" + newNextNode + @@ -4202,6 +4219,15 @@ private void trySendMessageDirectly(TcpDiscoveryNode node, TcpDiscoveryAbstractM private void processNodeAddedMessage(TcpDiscoveryNodeAddedMessage msg) { assert msg != null; + blockingSectionBegin(); + + try { + waitForLastCustomEventListenerFuture(); + } + finally { + blockingSectionEnd(); + } + TcpDiscoveryNode node = msg.node(); assert node != null; @@ -5274,6 +5300,9 @@ private void processMetricsUpdateMessage(TcpDiscoveryMetricsUpdateMessage msg) { if (clientNodeIds.contains(clientNode.id())) clientNode.clientAliveTime(spi.clientFailureDetectionTimeout()); else { + if (clientNode.clientAliveTime() == 0L) + clientNode.clientAliveTime(spi.clientFailureDetectionTimeout()); + boolean aliveCheck = clientNode.isClientAlive(); if (!aliveCheck && isLocalNodeCoordinator()) { @@ -5646,8 +5675,19 @@ private void notifyDiscoveryListener(TcpDiscoveryCustomEventMessage msg, boolean hist, msgObj); - if (waitForNotification || msgObj.isMutable()) - fut.get(); + if (waitForNotification || msgObj.isMutable()) { + blockingSectionBegin(); + + try { + fut.get(); + } + finally { + blockingSectionEnd(); + } + } + else { + lastCustomEvtLsnrFut = fut; + } if (msgObj.isMutable()) { try { diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java index 048abf62953ee..55462ff1edf81 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java @@ -423,6 +423,9 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery /** */ private IgniteDiscoverySpiInternalListener internalLsnr; + /** For test purposes. */ + private boolean skipAddrsRandomization = false; + /** * Gets current SPI state. * @@ -1881,7 +1884,7 @@ protected Collection resolvedAddresses() throws IgniteSpiExce } } - if (!res.isEmpty()) + if (!res.isEmpty() && !skipAddrsRandomization) Collections.shuffle(res); return res; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java index 13d100652d3c0..763a678b9ade1 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java @@ -124,7 +124,7 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Ignite /** Alive check time (used by clients). */ @GridToStringExclude - private transient long aliveCheckTime; + private transient volatile long aliveCheckTime; /** Client router node ID. */ @GridToStringExclude @@ -499,6 +499,13 @@ public void clientAliveTime(long aliveTime) { this.aliveCheckTime = U.currentTimeMillis() + aliveTime; } + /** + * @return Client alive check time. + */ + public long clientAliveTime() { + return aliveCheckTime; + } + /** * @return Client router node ID. */ diff --git a/modules/core/src/main/java/org/apache/ignite/ssl/DelegatingSSLContextSpi.java b/modules/core/src/main/java/org/apache/ignite/ssl/DelegatingSSLContextSpi.java index d8621f2cefd9a..360e92239c6bb 100644 --- a/modules/core/src/main/java/org/apache/ignite/ssl/DelegatingSSLContextSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/ssl/DelegatingSSLContextSpi.java @@ -31,7 +31,6 @@ /** */ class DelegatingSSLContextSpi extends SSLContextSpi { - /** */ private final SSLContext delegate; @@ -57,8 +56,7 @@ class DelegatingSSLContextSpi extends SSLContextSpi { /** {@inheritDoc} */ @Override protected SSLServerSocketFactory engineGetServerSocketFactory() { - return new SSLServerSocketFactoryWrapper(delegate.getServerSocketFactory(), - parameters); + return new SSLServerSocketFactoryWrapper(delegate.getServerSocketFactory(), parameters); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/ssl/SSLContextWrapper.java b/modules/core/src/main/java/org/apache/ignite/ssl/SSLContextWrapper.java index 901d42b1f4ba9..67bc834d0886c 100644 --- a/modules/core/src/main/java/org/apache/ignite/ssl/SSLContextWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/ssl/SSLContextWrapper.java @@ -20,10 +20,15 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; -/** */ -class SSLContextWrapper extends SSLContext { - /** */ - SSLContextWrapper(SSLContext delegate, SSLParameters sslParameters) { +/** + * Wrapper for {@link SSLContext} that extend source context with custom SSL parameters. + */ +public class SSLContextWrapper extends SSLContext { + /** + * @param delegate Wrapped SSL context. + * @param sslParameters Extended SSL parameters. + */ + public SSLContextWrapper(SSLContext delegate, SSLParameters sslParameters) { super(new DelegatingSSLContextSpi(delegate, sslParameters), delegate.getProvider(), delegate.getProtocol()); diff --git a/modules/core/src/main/java/org/apache/ignite/ssl/SSLSocketFactoryWrapper.java b/modules/core/src/main/java/org/apache/ignite/ssl/SSLSocketFactoryWrapper.java index bfe6d0d6f4bca..992f836702d62 100644 --- a/modules/core/src/main/java/org/apache/ignite/ssl/SSLSocketFactoryWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/ssl/SSLSocketFactoryWrapper.java @@ -24,9 +24,10 @@ import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; -/** */ +/** + * SSL socket factory that configure additional SSL params for socket. + */ class SSLSocketFactoryWrapper extends SSLSocketFactory { - /** */ private final SSLSocketFactory delegate; @@ -49,65 +50,46 @@ class SSLSocketFactoryWrapper extends SSLSocketFactory { return delegate.getSupportedCipherSuites(); } - /** {@inheritDoc} */ - @Override public Socket createSocket() throws IOException { - SSLSocket sock = (SSLSocket)delegate.createSocket(); - + /** + * Configure socket with SSL parameters. + * + * @param socket Socket to configure. + * @return Configured socket. + */ + private Socket configureSocket(Socket socket) { if (parameters != null) - sock.setSSLParameters(parameters); + ((SSLSocket)socket).setSSLParameters(parameters); - return sock; + return socket; } /** {@inheritDoc} */ - @Override public Socket createSocket(Socket sock, String host, int port, boolean autoClose) throws IOException { - SSLSocket sslSock = (SSLSocket)delegate.createSocket(sock, host, port, autoClose); - - if (parameters != null) - sslSock.setSSLParameters(parameters); + @Override public Socket createSocket() throws IOException { + return configureSocket(delegate.createSocket()); + } - return sock; + /** {@inheritDoc} */ + @Override public Socket createSocket(Socket sock, String host, int port, boolean autoClose) throws IOException { + return configureSocket(delegate.createSocket(sock, host, port, autoClose)); } /** {@inheritDoc} */ @Override public Socket createSocket(String host, int port) throws IOException { - SSLSocket sock = (SSLSocket)delegate.createSocket(host, port); - - if (parameters != null) - sock.setSSLParameters(parameters); - - return sock; + return configureSocket(delegate.createSocket(host, port)); } /** {@inheritDoc} */ @Override public Socket createSocket(String host, int port, InetAddress locAddr, int locPort) throws IOException { - SSLSocket sock = (SSLSocket)delegate.createSocket(host, port, locAddr, locPort); - - if (parameters != null) - sock.setSSLParameters(parameters); - - return sock; + return configureSocket(delegate.createSocket(host, port, locAddr, locPort)); } /** {@inheritDoc} */ @Override public Socket createSocket(InetAddress addr, int port) throws IOException { - SSLSocket sock = (SSLSocket)delegate.createSocket(addr, port); - - if (parameters != null) - sock.setSSLParameters(parameters); - - return sock; + return configureSocket(delegate.createSocket(addr, port)); } /** {@inheritDoc} */ - @Override public Socket createSocket(InetAddress addr, int port, InetAddress locAddr, - int locPort) throws IOException { - SSLSocket sock = (SSLSocket)delegate.createSocket(addr, port, locAddr, locPort); - - if (parameters != null) - sock.setSSLParameters(parameters); - - return sock; + @Override public Socket createSocket(InetAddress addr, int port, InetAddress locAddr, int locPort) throws IOException { + return configureSocket(delegate.createSocket(addr, port, locAddr, locPort)); } - } diff --git a/modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java b/modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java index edff5c9990373..fb370a57babce 100644 --- a/modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java @@ -93,7 +93,7 @@ public class SslContextFactory implements Factory { /** Enabled cipher suites. */ private String[] cipherSuites; - /** Enabled cipher suites. */ + /** Enabled protocols. */ private String[] protocols; /** @@ -289,6 +289,7 @@ public static TrustManager getDisabledTrustManager() { /** * Sets enabled cipher suites. + * * @param cipherSuites enabled cipher suites. */ public void setCipherSuites(String... cipherSuites) { @@ -296,7 +297,8 @@ public void setCipherSuites(String... cipherSuites) { } /** - * Gets enabled cipher suites + * Gets enabled cipher suites. + * * @return enabled cipher suites */ public String[] getCipherSuites() { @@ -304,8 +306,9 @@ public String[] getCipherSuites() { } /** - * Gets enabled cipher suites - * @return enabled cipher suites + * Gets enabled protocols. + * + * @return Enabled protocols. */ public String[] getProtocols() { return protocols; @@ -313,7 +316,8 @@ public String[] getProtocols() { /** * Sets enabled protocols. - * @param protocols enabled protocols. + * + * @param protocols Enabled protocols. */ public void setProtocols(String... protocols) { this.protocols = protocols; @@ -515,4 +519,4 @@ private static class DisabledX509TrustManager implements X509TrustManager { throw new IgniteException(e); } } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/thread/IgniteThread.java b/modules/core/src/main/java/org/apache/ignite/thread/IgniteThread.java index 6f65e0e34d39b..e37e6a749bc7c 100644 --- a/modules/core/src/main/java/org/apache/ignite/thread/IgniteThread.java +++ b/modules/core/src/main/java/org/apache/ignite/thread/IgniteThread.java @@ -57,10 +57,10 @@ public class IgniteThread extends Thread { private final byte plc; /** */ - private boolean executingEntryProcessor; + private boolean holdsTopLock; /** */ - private boolean holdsTopLock; + private boolean forbiddenToRequestBinaryMetadata; /** * Creates thread with given worker. @@ -164,17 +164,10 @@ public void compositeRwLockIndex(int compositeRwLockIdx) { } /** - * @return {@code True} if thread is currently executing entry processor. - */ - public boolean executingEntryProcessor() { - return executingEntryProcessor; - } - - /** - * @return {@code True} if thread is currently holds topology lock. + * @return {@code True} if thread is not allowed to request binary metadata to avoid potential deadlock. */ - public boolean holdsTopLock() { - return holdsTopLock; + public boolean isForbiddenToRequestBinaryMetadata() { + return holdsTopLock || forbiddenToRequestBinaryMetadata; } /** @@ -183,11 +176,8 @@ public boolean holdsTopLock() { public static void onEntryProcessorEntered(boolean holdsTopLock) { Thread curThread = Thread.currentThread(); - if (curThread instanceof IgniteThread) { - ((IgniteThread)curThread).executingEntryProcessor = true; - + if (curThread instanceof IgniteThread) ((IgniteThread)curThread).holdsTopLock = holdsTopLock; - } } /** @@ -197,7 +187,27 @@ public static void onEntryProcessorLeft() { Thread curThread = Thread.currentThread(); if (curThread instanceof IgniteThread) - ((IgniteThread)curThread).executingEntryProcessor = false; + ((IgniteThread)curThread).holdsTopLock = false; + } + + /** + * Callback on entering critical section where binary metadata requests are forbidden. + */ + public static void onForbidBinaryMetadataRequestSectionEntered() { + Thread curThread = Thread.currentThread(); + + if (curThread instanceof IgniteThread) + ((IgniteThread)curThread).forbiddenToRequestBinaryMetadata = true; + } + + /** + * Callback on leaving critical section where binary metadata requests are forbidden. + */ + public static void onForbidBinaryMetadataRequestSectionLeft() { + Thread curThread = Thread.currentThread(); + + if (curThread instanceof IgniteThread) + ((IgniteThread)curThread).forbiddenToRequestBinaryMetadata = false; } /** diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index a0e2ba79eba8b..1b65642f77160 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -1021,11 +1021,6 @@ org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogMan org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager$FileArchiver$2 org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager$FileCompressor$1 org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager$RecordsIterator -org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager$7 -org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager$FileArchiver$1 -org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager$FileArchiver$2 -org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager$FileCompressor$1 -org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager$RecordsIterator org.apache.ignite.internal.processors.cache.persistence.wal.SegmentEofException org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer$BufferMode org.apache.ignite.internal.processors.cache.persistence.wal.SingleSegmentLogicalRecordsIterator @@ -2206,6 +2201,7 @@ org.apache.ignite.internal.visor.util.VisorEventMapper org.apache.ignite.internal.visor.util.VisorExceptionWrapper org.apache.ignite.internal.visor.util.VisorTaskUtils$4 org.apache.ignite.internal.visor.verify.IndexValidationIssue +org.apache.ignite.internal.visor.verify.IndexIntegrityCheckIssue org.apache.ignite.internal.visor.verify.ValidateIndexesPartitionResult org.apache.ignite.internal.visor.verify.VisorContentionJobResult org.apache.ignite.internal.visor.verify.VisorContentionTask diff --git a/modules/core/src/test/java/org/apache/ignite/GridCacheAffinityBackupsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/GridCacheAffinityBackupsSelfTest.java index 5e7b4e26b2bcf..5e6bc25250e98 100644 --- a/modules/core/src/test/java/org/apache/ignite/GridCacheAffinityBackupsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/GridCacheAffinityBackupsSelfTest.java @@ -25,18 +25,16 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests affinity function with different number of backups. */ +@RunWith(JUnit4.class) public class GridCacheAffinityBackupsSelfTest extends GridCommonAbstractTest { - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Number of backups. */ private int backups; @@ -47,8 +45,6 @@ public class GridCacheAffinityBackupsSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(CacheMode.PARTITIONED); @@ -63,6 +59,7 @@ public class GridCacheAffinityBackupsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRendezvousBackups() throws Exception { for (int i = 0; i < nodesCnt; i++) checkBackups(i); @@ -97,4 +94,4 @@ private void checkBackups(int backups) throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/GridSuppressedExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/GridSuppressedExceptionSelfTest.java index 55e54fb884fac..2db1a9e205ae5 100644 --- a/modules/core/src/test/java/org/apache/ignite/GridSuppressedExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/GridSuppressedExceptionSelfTest.java @@ -19,16 +19,23 @@ import java.io.IOException; import java.util.List; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.X; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * */ -public class GridSuppressedExceptionSelfTest extends TestCase { +public class GridSuppressedExceptionSelfTest { /** * @throws Exception If failed. */ + @Test public void testHasCause() throws Exception { IgniteCheckedException me = prepareMultiException(); @@ -40,6 +47,7 @@ public void testHasCause() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetCause() throws Exception { IgniteCheckedException me = prepareMultiException(); @@ -55,6 +63,7 @@ public void testGetCause() throws Exception { /** * @throws Exception If failed. */ + @Test public void testXHasCause() throws Exception { IgniteCheckedException me = prepareMultiException(); @@ -71,6 +80,7 @@ public void testXHasCause() throws Exception { /** * @throws Exception If failed. */ + @Test public void testXGetSuppressedList() throws Exception { IgniteCheckedException me = prepareMultiException(); @@ -91,6 +101,7 @@ public void testXGetSuppressedList() throws Exception { /** * @throws Exception If failed. */ + @Test public void testXCause() throws Exception { IgniteCheckedException me = prepareMultiException(); diff --git a/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java index cf54949f7800b..001fa18365b31 100644 --- a/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java @@ -32,6 +32,9 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -39,6 +42,7 @@ /** * Tests for {@link GridAffinityProcessor.CacheAffinityProxy}. */ +@RunWith(JUnit4.class) public class IgniteCacheAffinitySelfTest extends IgniteCacheAbstractTest { /** Initial grid count. */ private int GRID_CNT = 3; @@ -87,6 +91,7 @@ public class IgniteCacheAffinitySelfTest extends IgniteCacheAbstractTest { /** * @throws Exception if failed. */ + @Test public void testAffinity() throws Exception { checkAffinity(); @@ -301,4 +306,4 @@ private static void checkEqualPartitionMaps(Map map1, Map< private Collection nodes() { return grid(0).cluster().nodes(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/IgniteCacheEntryProcessorSequentialCallTest.java b/modules/core/src/test/java/org/apache/ignite/cache/IgniteCacheEntryProcessorSequentialCallTest.java index 165bca78b2aa8..94c0bc61e862e 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/IgniteCacheEntryProcessorSequentialCallTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/IgniteCacheEntryProcessorSequentialCallTest.java @@ -19,6 +19,8 @@ import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; +import javax.cache.processor.EntryProcessorException; +import javax.cache.processor.MutableEntry; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; @@ -28,13 +30,24 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; -import javax.cache.processor.EntryProcessorException; -import javax.cache.processor.MutableEntry; import org.apache.ignite.transactions.TransactionOptimisticException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstractTest { + /** */ + private static final String CACHE = "cache"; + + /** */ + private static final String MVCC_CACHE = "mvccCache"; + + /** */ + private String cacheName; + /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrids(2); @@ -45,11 +58,34 @@ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstr stopAllGrids(); } + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + cacheName = CACHE; + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - CacheConfiguration cacheCfg = new CacheConfiguration("cache"); + CacheConfiguration ccfg = cacheConfiguration(CACHE); + + CacheConfiguration mvccCfg = cacheConfiguration(MVCC_CACHE) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + + cfg.setCacheConfiguration(ccfg, mvccCfg); + + return cfg; + } + + /** + * + * @return Cache configuration. + * @param name Cache name. + */ + private CacheConfiguration cacheConfiguration(String name) { + CacheConfiguration cacheCfg = new CacheConfiguration(name); cacheCfg.setCacheMode(CacheMode.PARTITIONED); cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); @@ -57,15 +93,13 @@ public class IgniteCacheEntryProcessorSequentialCallTest extends GridCommonAbstr cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setMaxConcurrentAsyncOperations(0); cacheCfg.setBackups(0); - - cfg.setCacheConfiguration(cacheCfg); - - return cfg; + return cacheCfg; } /** * */ + @Test public void testOptimisticSerializableTxInvokeSequentialCall() throws Exception { transactionInvokeSequentialCallOnPrimaryNode(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE); @@ -75,6 +109,7 @@ public void testOptimisticSerializableTxInvokeSequentialCall() throws Exception /** * */ + @Test public void testOptimisticRepeatableReadTxInvokeSequentialCall() throws Exception { transactionInvokeSequentialCallOnPrimaryNode(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ); @@ -84,6 +119,7 @@ public void testOptimisticRepeatableReadTxInvokeSequentialCall() throws Exceptio /** * */ + @Test public void testOptimisticReadCommittedTxInvokeSequentialCall() throws Exception { transactionInvokeSequentialCallOnPrimaryNode(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED); @@ -93,6 +129,7 @@ public void testOptimisticReadCommittedTxInvokeSequentialCall() throws Exception /** * */ + @Test public void testPessimisticSerializableTxInvokeSequentialCall() throws Exception { transactionInvokeSequentialCallOnPrimaryNode(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE); @@ -102,6 +139,7 @@ public void testPessimisticSerializableTxInvokeSequentialCall() throws Exception /** * */ + @Test public void testPessimisticRepeatableReadTxInvokeSequentialCall() throws Exception { transactionInvokeSequentialCallOnPrimaryNode(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); @@ -111,12 +149,25 @@ public void testPessimisticRepeatableReadTxInvokeSequentialCall() throws Excepti /** * */ + @Test public void testPessimisticReadCommittedTxInvokeSequentialCall() throws Exception { transactionInvokeSequentialCallOnPrimaryNode(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED); transactionInvokeSequentialCallOnNearNode(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED); } + /** + * + */ + @Test + public void testMvccTxInvokeSequentialCall() throws Exception { + cacheName = MVCC_CACHE; + + transactionInvokeSequentialCallOnPrimaryNode(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + + transactionInvokeSequentialCallOnNearNode(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + } + /** * Test for sequential entry processor invoking not null value on primary cache. * In this test entry processor gets value from local node. @@ -132,12 +183,12 @@ public void transactionInvokeSequentialCallOnPrimaryNode(TransactionConcurrency Ignite primaryIgnite; - if (ignite(0).affinity("cache").isPrimary(ignite(0).cluster().localNode(), key)) + if (ignite(0).affinity(cacheName).isPrimary(ignite(0).cluster().localNode(), key)) primaryIgnite = ignite(0); else primaryIgnite = ignite(1); - IgniteCache cache = primaryIgnite.cache("cache"); + IgniteCache cache = primaryIgnite.cache(cacheName); cache.put(key, val); @@ -171,7 +222,7 @@ public void transactionInvokeSequentialCallOnNearNode(TransactionConcurrency tra Ignite nearIgnite; Ignite primaryIgnite; - if (ignite(0).affinity("cache").isPrimary(ignite(0).cluster().localNode(), key)) { + if (ignite(0).affinity(cacheName).isPrimary(ignite(0).cluster().localNode(), key)) { primaryIgnite = ignite(0); nearIgnite = ignite(1); @@ -182,9 +233,9 @@ public void transactionInvokeSequentialCallOnNearNode(TransactionConcurrency tra nearIgnite = ignite(0); } - primaryIgnite.cache("cache").put(key, val); + primaryIgnite.cache(cacheName).put(key, val); - IgniteCache nearCache = nearIgnite.cache("cache"); + IgniteCache nearCache = nearIgnite.cache(cacheName); NotNullCacheEntryProcessor cacheEntryProcessor = new NotNullCacheEntryProcessor(); @@ -197,17 +248,19 @@ public void transactionInvokeSequentialCallOnNearNode(TransactionConcurrency tra transaction.commit(); } - primaryIgnite.cache("cache").remove(key); + primaryIgnite.cache(cacheName).remove(key); } /** * Test for sequential entry processor invocation. During transaction value is changed externally, which leads to * optimistic conflict exception. */ + @Test + @SuppressWarnings("ThrowableNotThrown") public void testTxInvokeSequentialOptimisticConflict() throws Exception { TestKey key = new TestKey(1L); - IgniteCache cache = ignite(0).cache("cache"); + IgniteCache cache = ignite(0).cache(CACHE); CountDownLatch latch = new CountDownLatch(1); @@ -308,4 +361,4 @@ public void value(String val) { this.val = val; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/IgniteWarmupClosureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/IgniteWarmupClosureSelfTest.java index 1fccb904313d6..f15d70f9b74b4 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/IgniteWarmupClosureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/IgniteWarmupClosureSelfTest.java @@ -19,19 +19,17 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.startup.BasicWarmupClosure; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteWarmupClosureSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ public IgniteWarmupClosureSelfTest(){ super(false); @@ -41,14 +39,8 @@ public IgniteWarmupClosureSelfTest(){ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - cfg.getTransactionConfiguration().setTxSerializableEnabled(true); - cfg.setDiscoverySpi(disco); - BasicWarmupClosure warmupClosure = new BasicWarmupClosure(); warmupClosure.setGridCount(2); @@ -72,7 +64,8 @@ public IgniteWarmupClosureSelfTest(){ /** * @throws Exception If failed. */ + @Test public void testWarmupClosure() throws Exception { startGrid(1); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java index 008da71b6679a..e842a10165f51 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/LargeEntryUpdateTest.java @@ -31,10 +31,14 @@ import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class LargeEntryUpdateTest extends GridCommonAbstractTest { /** */ private static final int THREAD_COUNT = 10; @@ -95,6 +99,7 @@ public class LargeEntryUpdateTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testEntryUpdate() throws Exception { try (Ignite ignite = startGrid()) { for (int i = 0; i < CACHE_COUNT; ++i) { diff --git a/modules/core/src/test/java/org/apache/ignite/cache/ResetLostPartitionTest.java b/modules/core/src/test/java/org/apache/ignite/cache/ResetLostPartitionTest.java new file mode 100644 index 0000000000000..05f6d8e2f72b2 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/cache/ResetLostPartitionTest.java @@ -0,0 +1,262 @@ +/* + * 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. + */ + +package org.apache.ignite.cache; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgnitionEx; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopologyImpl; +import org.apache.ignite.internal.util.typedef.internal.CU; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.LOST; +import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING; +import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR; + +/** + * + */ +@RunWith(JUnit4.class) +public class ResetLostPartitionTest extends GridCommonAbstractTest { + /** Cache name. */ + private static final String[] CACHE_NAMES = {"cacheOne", "cacheTwo", "cacheThree"}; + /** Cache size */ + public static final int CACHE_SIZE = 100000 / CACHE_NAMES.length; + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10560"); + + super.beforeTest(); + + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + super.afterTest(); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setConsistentId(igniteInstanceName); + + DataStorageConfiguration storageCfg = new DataStorageConfiguration(); + + storageCfg.getDefaultDataRegionConfiguration() + .setPersistenceEnabled(true) + .setMaxSize(500L * 1024 * 1024); + + cfg.setDataStorageConfiguration(storageCfg); + + CacheConfiguration[] ccfg = new CacheConfiguration[] { + cacheConfiguration(CACHE_NAMES[0], CacheAtomicityMode.ATOMIC), + cacheConfiguration(CACHE_NAMES[1], CacheAtomicityMode.ATOMIC), + cacheConfiguration(CACHE_NAMES[2], CacheAtomicityMode.TRANSACTIONAL) + }; + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** + * @param cacheName Cache name. + * @param mode Cache atomicity mode. + * @return Configured cache configuration. + */ + private CacheConfiguration cacheConfiguration(String cacheName, CacheAtomicityMode mode) { + return new CacheConfiguration<>(cacheName) + .setCacheMode(CacheMode.PARTITIONED) + .setAtomicityMode(mode) + .setBackups(1) + .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) + .setPartitionLossPolicy(PartitionLossPolicy.READ_ONLY_SAFE) + .setAffinity(new RendezvousAffinityFunction(false, 1024)) + .setIndexedTypes(String.class, String.class); + } + + /** Client configuration */ + private IgniteConfiguration getClientConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setPeerClassLoadingEnabled(true); + cfg.setClientMode(true); + + return cfg; + } + + /** + * Test to restore lost partitions after grid reactivation. + * + * @throws Exception if fail. + */ + @Test + public void testReactivateGridBeforeResetLostPartitions() throws Exception { + doRebalanceAfterPartitionsWereLost(true); + } + + /** + * Test to restore lost partitions on working grid. + * + * @throws Exception if fail. + */ + @Test + public void testResetLostPartitions() throws Exception { + doRebalanceAfterPartitionsWereLost(false); + } + + /** + * @param reactivateGridBeforeResetPart Reactive grid before try to reset lost partitions. + * @throws Exception if fail. + */ + private void doRebalanceAfterPartitionsWereLost(boolean reactivateGridBeforeResetPart) throws Exception { + startGrids(3); + + grid(0).cluster().active(true); + + Ignite igniteClient = startGrid(getClientConfiguration("client")); + + for (String cacheName : CACHE_NAMES) { + IgniteCache cache = igniteClient.cache(cacheName); + + for (int j = 0; j < CACHE_SIZE; j++) + cache.put(j, "Value" + j); + } + + stopGrid("client"); + + String dn2DirName = grid(1).name().replace(".", "_"); + + stopGrid(1); + + //Clean up the pds and WAL for second data node. + U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_STORE_DIR + "/" + dn2DirName, true)); + + U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_STORE_DIR + "/wal/" + dn2DirName, true)); + + //Here we have two from three data nodes and cache with 1 backup. So there is no data loss expected. + assertEquals(CACHE_NAMES.length * CACHE_SIZE, averageSizeAroundAllNodes()); + + //Start node 2 with empty PDS. Rebalance will be started. + startGrid(1); + + //During rebalance stop node 3. Rebalance will be stopped. + stopGrid(2); + + //Start node 3. + startGrid(2); + + //Loss data expected because rebalance to node 1 have not finished and node 2 was stopped. + assertTrue(CACHE_NAMES.length * CACHE_SIZE > averageSizeAroundAllNodes()); + + for (String cacheName : CACHE_NAMES) { + //Node 1 will have only OWNING partitions. + assertTrue(getPartitionsStates(0, cacheName).stream().allMatch(state -> state == OWNING)); + + //Node 3 will have only OWNING partitions. + assertTrue(getPartitionsStates(2, cacheName).stream().allMatch(state -> state == OWNING)); + } + + boolean hasLost = false; + for (String cacheName : CACHE_NAMES) { + //Node 2 will have OWNING and LOST partitions. + hasLost |= getPartitionsStates(1, cacheName).stream().anyMatch(state -> state == LOST); + } + + assertTrue(hasLost); + + if (reactivateGridBeforeResetPart) { + grid(0).cluster().active(false); + grid(0).cluster().active(true); + } + + //Try to reset lost partitions. + grid(2).resetLostPartitions(Arrays.asList(CACHE_NAMES)); + + awaitPartitionMapExchange(); + + for (String cacheName : CACHE_NAMES) { + //Node 2 will have only OWNING partitions. + assertTrue(getPartitionsStates(1, cacheName).stream().allMatch(state -> state == OWNING)); + } + + //All data was back. + assertEquals(CACHE_NAMES.length * CACHE_SIZE, averageSizeAroundAllNodes()); + + //Stop node 2 for checking rebalance correctness from this node. + stopGrid(2); + + //Rebalance should be successfully finished. + assertEquals(CACHE_NAMES.length * CACHE_SIZE, averageSizeAroundAllNodes()); + } + + /** + * @param gridNumber Grid number. + * @param cacheName Cache name. + * @return Partitions states for given cache name. + */ + private List getPartitionsStates(int gridNumber, String cacheName) { + CacheGroupContext cgCtx = grid(gridNumber).context().cache().cacheGroup(CU.cacheId(cacheName)); + + GridDhtPartitionTopologyImpl top = (GridDhtPartitionTopologyImpl)cgCtx.topology(); + + return top.localPartitions().stream() + .map(GridDhtLocalPartition::state) + .collect(Collectors.toList()); + } + + /** + * Checks that all nodes see the correct size. + */ + private int averageSizeAroundAllNodes() { + int totalSize = 0; + + for (Ignite ignite : IgnitionEx.allGrids()) { + for (String cacheName : CACHE_NAMES) { + totalSize += ignite.cache(cacheName).size(); + } + } + + return totalSize / IgnitionEx.allGrids().size(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AbstractAffinityFunctionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AbstractAffinityFunctionSelfTest.java index 8f8d78a96803b..d11609ee54d9f 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AbstractAffinityFunctionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AbstractAffinityFunctionSelfTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl; import org.apache.ignite.testframework.GridTestNode; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class AbstractAffinityFunctionSelfTest extends GridCommonAbstractTest { /** MAC prefix. */ private static final String MAC_PREF = "MAC"; @@ -50,6 +54,7 @@ public abstract class AbstractAffinityFunctionSelfTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testNodeRemovedNoBackups() throws Exception { checkNodeRemoved(0); } @@ -57,6 +62,7 @@ public void testNodeRemovedNoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeRemovedOneBackup() throws Exception { checkNodeRemoved(1); } @@ -64,6 +70,7 @@ public void testNodeRemovedOneBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeRemovedTwoBackups() throws Exception { checkNodeRemoved(2); } @@ -71,6 +78,7 @@ public void testNodeRemovedTwoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeRemovedThreeBackups() throws Exception { checkNodeRemoved(3); } @@ -78,6 +86,7 @@ public void testNodeRemovedThreeBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomReassignmentNoBackups() throws Exception { checkRandomReassignment(0); } @@ -85,6 +94,7 @@ public void testRandomReassignmentNoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomReassignmentOneBackup() throws Exception { checkRandomReassignment(1); } @@ -92,6 +102,7 @@ public void testRandomReassignmentOneBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomReassignmentTwoBackups() throws Exception { checkRandomReassignment(2); } @@ -99,6 +110,7 @@ public void testRandomReassignmentTwoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomReassignmentThreeBackups() throws Exception { checkRandomReassignment(3); } @@ -107,6 +119,7 @@ public void testRandomReassignmentThreeBackups() throws Exception { * @param backups Number of backups. * @throws Exception If failed. */ + @Test public void testNullKeyForPartitionCalculation() throws Exception { AffinityFunction aff = affinityFunction(); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityClientNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityClientNodeSelfTest.java index 6d1c0209d4eea..82be87b28879d 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityClientNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityClientNodeSelfTest.java @@ -27,20 +27,18 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteNodeAttributes; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * */ +@RunWith(JUnit4.class) public class AffinityClientNodeSelfTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODE_CNT = 4; @@ -60,8 +58,6 @@ public class AffinityClientNodeSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration ccfg1 = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg1.setBackups(1); @@ -109,6 +105,7 @@ public class AffinityClientNodeSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testClientNodeNotInAffinity() throws Exception { checkCache(CACHE1, 2); @@ -238,4 +235,4 @@ private static class TestNodesFilter implements IgnitePredicate { return true; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityDistributionLoggingTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityDistributionLoggingTest.java index 0168c7c483f30..60ddfd48165cf 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityDistributionLoggingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityDistributionLoggingTest.java @@ -35,6 +35,9 @@ import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME; @@ -46,6 +49,7 @@ * * @see EvenDistributionAffinityFunction */ +@RunWith(JUnit4.class) public class AffinityDistributionLoggingTest extends GridCommonAbstractTest { /** Pattern to test. */ private static final String LOG_MESSAGE_PREFIX = "Local node affinity assignment distribution is not ideal "; @@ -102,6 +106,7 @@ public class AffinityDistributionLoggingTest extends GridCommonAbstractTest { /** * @throws Exception In case of an error. */ + @Test public void test2PartitionsIdealDistributionIsNotLogged() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "0"); @@ -117,6 +122,7 @@ public void test2PartitionsIdealDistributionIsNotLogged() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void test120PartitionsIdeadDistributionIsNotLogged() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "0.0"); @@ -132,6 +138,7 @@ public void test120PartitionsIdeadDistributionIsNotLogged() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void test5PartitionsNotIdealDistributionIsLogged() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "50.0"); @@ -147,6 +154,7 @@ public void test5PartitionsNotIdealDistributionIsLogged() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void test5PartitionsNotIdealDistributionSuppressedLoggingOnClientNode() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "0.0"); @@ -162,6 +170,7 @@ public void test5PartitionsNotIdealDistributionSuppressedLoggingOnClientNode() t /** * @throws Exception In case of an error. */ + @Test public void test7PartitionsNotIdealDistributionSuppressedLogging() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "50.0"); @@ -177,6 +186,7 @@ public void test7PartitionsNotIdealDistributionSuppressedLogging() throws Except /** * @throws Exception In case of an error. */ + @Test public void test5PartitionsNotIdealDistributionSuppressedLogging() throws Exception { System.setProperty(IGNITE_PART_DISTRIBUTION_WARN_THRESHOLD, "65"); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionBackupFilterAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionBackupFilterAbstractSelfTest.java index 74add0ccb7946..c3785cd207b58 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionBackupFilterAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionBackupFilterAbstractSelfTest.java @@ -29,11 +29,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteBiPredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -42,10 +42,8 @@ /** * Base tests of {@link AffinityFunction} implementations with user provided backup filter. */ +@RunWith(JUnit4.class) public abstract class AffinityFunctionBackupFilterAbstractSelfTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Split attribute name. */ private static final String SPLIT_ATTRIBUTE_NAME = "split-attribute"; @@ -131,13 +129,9 @@ public abstract class AffinityFunctionBackupFilterAbstractSelfTest extends GridC cacheCfg.setRebalanceMode(SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - spi.setIpFinder(IP_FINDER); - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCacheConfiguration(cacheCfg); - cfg.setDiscoverySpi(spi); cfg.setUserAttributes(F.asMap(SPLIT_ATTRIBUTE_NAME, splitAttrVal)); return cfg; @@ -156,6 +150,7 @@ public abstract class AffinityFunctionBackupFilterAbstractSelfTest extends GridC /** * @throws Exception If failed. */ + @Test public void testPartitionDistribution() throws Exception { backups = 1; @@ -205,6 +200,7 @@ private void checkPartitions() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionDistributionWithAffinityBackupFilter() throws Exception { backups = 3; diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionExcludeNeighborsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionExcludeNeighborsAbstractSelfTest.java index eee47c717286b..a151504b2b9b1 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionExcludeNeighborsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityFunctionExcludeNeighborsAbstractSelfTest.java @@ -32,9 +32,10 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.NONE; @@ -42,7 +43,7 @@ /** * Partitioned affinity test. */ -@SuppressWarnings({"PointlessArithmeticExpression", "FieldCanBeLocal"}) +@RunWith(JUnit4.class) public abstract class AffinityFunctionExcludeNeighborsAbstractSelfTest extends GridCommonAbstractTest { /** Number of backups. */ private int backups = 2; @@ -50,9 +51,6 @@ public abstract class AffinityFunctionExcludeNeighborsAbstractSelfTest extends G /** Number of girds. */ private int gridInstanceNum; - /** Ip finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -72,7 +70,7 @@ public abstract class AffinityFunctionExcludeNeighborsAbstractSelfTest extends G } }; - spi.setIpFinder(ipFinder); + spi.setIpFinder(sharedStaticIpFinder); c.setDiscoverySpi(spi); @@ -108,6 +106,7 @@ private static Collection nodes(Affinity aff, Obj /** * @throws Exception If failed. */ + @Test public void testAffinityMultiNode() throws Exception { int grids = 9; @@ -159,6 +158,7 @@ public void testAffinityMultiNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinitySingleNode() throws Exception { Ignite g = startGrid(); @@ -175,4 +175,4 @@ public void testAffinitySingleNode() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java index f89d9ee7381ad..8dc9abfad8717 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java @@ -31,19 +31,17 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class AffinityHistoryCleanupTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -51,8 +49,6 @@ public class AffinityHistoryCleanupTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration[] ccfgs = new CacheConfiguration[4]; for (int i = 0; i < ccfgs.length; i++) { @@ -81,6 +77,7 @@ public class AffinityHistoryCleanupTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAffinityHistoryCleanup() throws Exception { String histProp = System.getProperty(IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/local/LocalAffinityFunctionTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/local/LocalAffinityFunctionTest.java index e08d2120cea13..b194137c11f28 100755 --- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/local/LocalAffinityFunctionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/local/LocalAffinityFunctionTest.java @@ -22,18 +22,16 @@ import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for local affinity function. */ +@RunWith(JUnit4.class) public class LocalAffinityFunctionTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODE_CNT = 1; @@ -43,8 +41,6 @@ public class LocalAffinityFunctionTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setBackups(1); @@ -61,6 +57,7 @@ public class LocalAffinityFunctionTest extends GridCommonAbstractTest { startGrids(NODE_CNT); } + @Test public void testWronglySetAffinityFunctionForLocalCache() { Ignite node = ignite(NODE_CNT - 1); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionSimpleBenchmark.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionSimpleBenchmark.java index c680a68f58c71..7dec6b299cdd5 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionSimpleBenchmark.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionSimpleBenchmark.java @@ -65,11 +65,15 @@ import java.util.concurrent.atomic.AtomicInteger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Simple benchmarks, compatibility test and distribution check utils for affinity functions. * Needs to check changes at the {@link RendezvousAffinityFunction}. */ +@RunWith(JUnit4.class) public class RendezvousAffinityFunctionSimpleBenchmark extends GridCommonAbstractTest { /** MAC prefix. */ private static final String MAC_PREF = "MAC"; @@ -346,6 +350,7 @@ private double chiSquare(List> byNodes, int parts, double goldenNo /** * @throws IOException On error. */ + @Test public void testDistribution() throws IOException { AffinityFunction aff0 = new RendezvousAffinityFunction(true, 1024); @@ -397,6 +402,7 @@ private void affinityDistribution(AffinityFunction aff0, AffinityFunction aff1) /** * */ + @Test public void testAffinityBenchmarkAdd() { mode = TopologyModificationMode.ADD; @@ -410,6 +416,7 @@ public void testAffinityBenchmarkAdd() { /** * */ + @Test public void testAffinityBenchmarkChangeLast() { mode = TopologyModificationMode.CHANGE_LAST_NODE; @@ -503,6 +510,7 @@ private int countPartitionsToMigrate(List> affOld, List nodes = createBaseNodes(nodesCnt); - List> assignment0 = assignPartitions(aff0, nodes, null, backups, 0).get2(); + List structure0 = structureOf(assignPartitions(aff0, nodes, null, backups, 0).get2()); - List> assignment1 = assignPartitions(aff1, nodes, null, backups, 0).get2(); + List structure1 = structureOf(assignPartitions(aff1, nodes, null, backups, 0).get2()); - assertEquals (assignment0, assignment1); + assertEquals (structure0, structure1); } } + /** */ + private List structureOf(List> assignment) { + List res = new ArrayList<>(); + + for (List nodes : assignment) + res.add(nodes != null && !nodes.contains(null) ? nodes.size() : null); + + return res; + } + /** * */ diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreListenerRWThroughDisabledTransactionalCacheTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreListenerRWThroughDisabledTransactionalCacheTest.java index 45038154ad60c..e2b658ca47010 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreListenerRWThroughDisabledTransactionalCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreListenerRWThroughDisabledTransactionalCacheTest.java @@ -20,9 +20,13 @@ import java.util.Random; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -35,7 +39,15 @@ * This class tests that redundant calls of {@link CacheStoreSessionListener#onSessionStart(CacheStoreSession)} * and {@link CacheStoreSessionListener#onSessionEnd(CacheStoreSession, boolean)} are not executed. */ +@RunWith(JUnit4.class) public class CacheStoreListenerRWThroughDisabledTransactionalCacheTest extends CacheStoreSessionListenerReadWriteThroughDisabledAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; @@ -44,6 +56,7 @@ public class CacheStoreListenerRWThroughDisabledTransactionalCacheTest extends C /** * Tests {@link IgniteCache#get(Object)} with disabled read-through and write-through modes. */ + @Test public void testTransactionalLookup() { testTransactionalLookup(OPTIMISTIC, READ_COMMITTED); testTransactionalLookup(OPTIMISTIC, REPEATABLE_READ); @@ -74,6 +87,7 @@ private void testTransactionalLookup(TransactionConcurrency concurrency, Transac /** * Tests {@link IgniteCache#put(Object, Object)} with disabled read-through and write-through modes. */ + @Test public void testTransactionalUpdate() { testTransactionalUpdate(OPTIMISTIC, READ_COMMITTED); testTransactionalUpdate(OPTIMISTIC, REPEATABLE_READ); @@ -104,6 +118,7 @@ private void testTransactionalUpdate(TransactionConcurrency concurrency, Transac /** * Tests {@link IgniteCache#remove(Object)} with disabled read-through and write-through modes. */ + @Test public void testTransactionalRemove() { testTransactionalRemove(OPTIMISTIC, READ_COMMITTED); testTransactionalRemove(OPTIMISTIC, REPEATABLE_READ); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreReadFromBackupTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreReadFromBackupTest.java index d8913dcf1992f..8ee347cdae687 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreReadFromBackupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreReadFromBackupTest.java @@ -33,6 +33,9 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -44,6 +47,7 @@ * Checks that once value is read from store, it will be loaded in * backups as well. */ +@RunWith(JUnit4.class) public class CacheStoreReadFromBackupTest extends GridCommonAbstractTest { /** */ public static final String CACHE_NAME = "cache"; @@ -100,6 +104,7 @@ protected CacheAtomicityMode atomicityMode() { /** * @throws Exception If failed. */ + @Test public void testReplicated() throws Exception { cacheMode = REPLICATED; backups = 0; @@ -111,6 +116,7 @@ public void testReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitioned() throws Exception { cacheMode = PARTITIONED; backups = 1; @@ -122,6 +128,7 @@ public void testPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearReplicated() throws Exception { cacheMode = REPLICATED; backups = 0; @@ -133,6 +140,7 @@ public void testNearReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearPartitioned() throws Exception { cacheMode = PARTITIONED; backups = 1; diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerAbstractSelfTest.java index 412a879e14932..9db8f4f546a8e 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerAbstractSelfTest.java @@ -29,21 +29,18 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for store session listeners. */ +@RunWith(JUnit4.class) public abstract class CacheStoreSessionListenerAbstractSelfTest extends GridCommonAbstractTest implements Serializable { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ protected static final String URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1"; @@ -68,19 +65,6 @@ public abstract class CacheStoreSessionListenerAbstractSelfTest extends GridComm /** */ protected static final AtomicBoolean fail = new AtomicBoolean(); - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(3); @@ -109,6 +93,7 @@ public abstract class CacheStoreSessionListenerAbstractSelfTest extends GridComm /** * @throws Exception If failed. */ + @Test public void testAtomicCache() throws Exception { CacheConfiguration cfg = cacheConfiguration(DEFAULT_CACHE_NAME, CacheAtomicityMode.ATOMIC); @@ -134,6 +119,7 @@ public void testAtomicCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransactionalCache() throws Exception { CacheConfiguration cfg = cacheConfiguration(DEFAULT_CACHE_NAME, CacheAtomicityMode.TRANSACTIONAL); @@ -159,6 +145,7 @@ public void testTransactionalCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExplicitTransaction() throws Exception { CacheConfiguration cfg = cacheConfiguration(DEFAULT_CACHE_NAME, CacheAtomicityMode.TRANSACTIONAL); @@ -184,6 +171,7 @@ public void testExplicitTransaction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCacheTransaction() throws Exception { CacheConfiguration cfg1 = cacheConfiguration("cache1", CacheAtomicityMode.TRANSACTIONAL); CacheConfiguration cfg2 = cacheConfiguration("cache2", CacheAtomicityMode.TRANSACTIONAL); @@ -212,6 +200,7 @@ public void testCrossCacheTransaction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommit() throws Exception { write.set(true); @@ -241,6 +230,7 @@ public void testCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollback() throws Exception { write.set(true); fail.set(true); @@ -329,4 +319,4 @@ private CacheConfiguration cacheConfiguration(String name, Cac * @return Session listener factory. */ protected abstract Factory sessionListenerFactory(); -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerLifecycleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerLifecycleSelfTest.java index ff176c5f0f7c1..ba52317e22ea5 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerLifecycleSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerLifecycleSelfTest.java @@ -31,24 +31,30 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lifecycle.LifecycleAware; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * Store session listeners test. */ +@RunWith(JUnit4.class) public class CacheStoreSessionListenerLifecycleSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final Queue evts = new ConcurrentLinkedDeque<>(); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -58,12 +64,6 @@ public class CacheStoreSessionListenerLifecycleSelfTest extends GridCommonAbstra new SessionListenerFactory("Shared 2") ); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -75,6 +75,7 @@ public class CacheStoreSessionListenerLifecycleSelfTest extends GridCommonAbstra /** * @throws Exception If failed. */ + @Test public void testNoCaches() throws Exception { try { startGrid(); @@ -90,6 +91,7 @@ public void testNoCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoOverride() throws Exception { try { Ignite ignite = startGrid(); @@ -152,6 +154,7 @@ public void testNoOverride() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartialOverride() throws Exception { try { Ignite ignite = startGrid(); @@ -227,6 +230,7 @@ public void testPartialOverride() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOverride() throws Exception { try { Ignite ignite = startGrid(); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerReadWriteThroughDisabledAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerReadWriteThroughDisabledAbstractTest.java index 774d4f7aac694..70f6a9fef301e 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerReadWriteThroughDisabledAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerReadWriteThroughDisabledAbstractTest.java @@ -39,11 +39,15 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * This class tests that redundant calls of {@link CacheStoreSessionListener#onSessionStart(CacheStoreSession)} * and {@link CacheStoreSessionListener#onSessionEnd(CacheStoreSession, boolean)} are not executed. */ +@RunWith(JUnit4.class) public abstract class CacheStoreSessionListenerReadWriteThroughDisabledAbstractTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -81,6 +85,7 @@ public abstract class CacheStoreSessionListenerReadWriteThroughDisabledAbstractT * * @throws Exception If failed. */ + @Test public void testLookup() throws Exception { IgniteCache cache = grid(0).getOrCreateCache(DEFAULT_CACHE_NAME); @@ -97,6 +102,7 @@ public void testLookup() throws Exception { * * @throws Exception If failed. */ + @Test public void testBatchLookup() throws Exception { IgniteCache cache = grid(0).getOrCreateCache(DEFAULT_CACHE_NAME); @@ -117,6 +123,7 @@ public void testBatchLookup() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdate() throws Exception { IgniteCache cache = grid(0).getOrCreateCache(DEFAULT_CACHE_NAME); @@ -133,6 +140,7 @@ public void testUpdate() throws Exception { * * @throws Exception If failed. */ + @Test public void testBatchUpdate() throws Exception { IgniteCache cache = grid(0).getOrCreateCache(DEFAULT_CACHE_NAME); @@ -153,6 +161,7 @@ public void testBatchUpdate() throws Exception { * * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { IgniteCache cache = grid(0).getOrCreateCache(DEFAULT_CACHE_NAME); @@ -174,6 +183,7 @@ public void testRemove() throws Exception { * * @throws Exception If failed. */ + @Test public void testBatchRemove() throws Exception { IgniteCache cache = grid(0).getOrCreateCache(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerWriteBehindEnabledTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerWriteBehindEnabledTest.java index c9a912ad51d57..1db21130656c5 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerWriteBehindEnabledTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerWriteBehindEnabledTest.java @@ -44,18 +44,23 @@ import org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore; import org.apache.ignite.resources.CacheStoreSessionResource; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * This class tests that calls of {@link CacheStoreSessionListener#onSessionStart(CacheStoreSession)} * and {@link CacheStoreSessionListener#onSessionEnd(CacheStoreSession, boolean)} are executed from * {@link GridCacheWriteBehindStore} only. */ +@RunWith(JUnit4.class) public class CacheStoreSessionListenerWriteBehindEnabledTest extends GridCacheAbstractSelfTest { /** */ - protected final static int CNT = 100; + protected static final int CNT = 100; /** */ - private final static int WRITE_BEHIND_FLUSH_FREQUENCY = 1000; + private static final int WRITE_BEHIND_FLUSH_FREQUENCY = 1000; /** */ private static final List operations = Collections.synchronizedList(new ArrayList()); @@ -66,6 +71,13 @@ public class CacheStoreSessionListenerWriteBehindEnabledTest extends GridCacheAb /** */ private static final AtomicInteger uninitializedListenerCnt = new AtomicInteger(); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; @@ -106,6 +118,7 @@ public class CacheStoreSessionListenerWriteBehindEnabledTest extends GridCacheAb * Tests that there are no redundant calls of {@link CacheStoreSessionListener#onSessionStart(CacheStoreSession)} * while {@link IgniteCache#get(Object)} performed. */ + @Test public void testLookup() { IgniteCache cache = grid(0).getOrCreateCache(DEFAULT_CACHE_NAME); @@ -119,6 +132,7 @@ public void testLookup() { * Tests that there are no redundant calls of {@link CacheStoreSessionListener#onSessionStart(CacheStoreSession)} * while {@link IgniteCache#put(Object, Object)} performed. */ + @Test public void testUpdate() { IgniteCache cache = grid(0).getOrCreateCache(DEFAULT_CACHE_NAME); @@ -132,6 +146,7 @@ public void testUpdate() { * Tests that there are no redundant calls of {@link CacheStoreSessionListener#onSessionStart(CacheStoreSession)} * while {@link IgniteCache#remove(Object)} performed. */ + @Test public void testRemove() { IgniteCache cache = grid(0).getOrCreateCache(DEFAULT_CACHE_NAME); @@ -145,6 +160,7 @@ public void testRemove() { /** * Tests that cache store session listeners are notified by write-behind store. */ + @Test public void testFlushSingleValue() throws Exception { CacheConfiguration cfg = cacheConfiguration(getTestIgniteInstanceName()); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreWriteErrorTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreWriteErrorTest.java new file mode 100644 index 0000000000000..ec6c72bc528f2 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreWriteErrorTest.java @@ -0,0 +1,133 @@ +/* + * 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. + */ + +package org.apache.ignite.cache.store; + +import com.google.common.base.Throwables; +import java.util.HashMap; +import java.util.concurrent.Callable; +import javax.cache.Cache; +import javax.cache.configuration.FactoryBuilder; +import javax.cache.integration.CacheLoaderException; +import javax.cache.integration.CacheWriterException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.binary.BinaryObject; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * This class tests handling exceptions from {@link CacheStore#write(Cache.Entry)}. + */ +@RunWith(JUnit4.class) +public class CacheStoreWriteErrorTest extends GridCommonAbstractTest { + /** */ + public static final String CACHE_NAME = "cache"; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + CacheConfiguration cacheCfg = new CacheConfiguration(CACHE_NAME) + .setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC) + .setCacheStoreFactory(FactoryBuilder.factoryOf(ThrowableCacheStore.class)) + .setWriteThrough(true) + .setStoreKeepBinary(true); + + return super.getConfiguration(gridName) + .setCacheConfiguration(cacheCfg); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** + * Checks primary error while saving batch with one entry. + */ + @Test + public void testPrimaryErrorForBatchSize1() { + checkPrimaryError(1); + } + + /** + * Checks primary error while saving batch with two entries. + */ + @Test + public void testPrimaryErrorForBatchSize2() { + checkPrimaryError(2); + } + + /** + * Checks that primary error ({@link CacheWriterException}) is not lost due to unwrapping a key. + * + * @param batchSize Batch size. + */ + private void checkPrimaryError(int batchSize) { + Throwable t = GridTestUtils.assertThrows(log, + new Callable() { + @Override public Object call() throws Exception { + try (Ignite grid = startGrid()) { + IgniteCache cache = grid.cache(CACHE_NAME); + + HashMap batch = new HashMap<>(); + + for (int i = 0; i < batchSize; i++) { + BinaryObject key = grid.binary().builder("KEY_TYPE_NAME").setField("id", i).build(); + + batch.put(key, "VALUE"); + } + + cache.putAllAsync(batch).get(); + } + + return null; + } + }, CacheWriterException.class, null); + + assertTrue("Stacktrace should contain the message of the original exception", + Throwables.getStackTraceAsString(t).contains(ThrowableCacheStore.EXCEPTION_MESSAGE)); + } + + /** + * {@link CacheStore} implementation which throws {@link RuntimeException} for every write operation. + */ + public static class ThrowableCacheStore extends CacheStoreAdapter { + /** */ + private static final String EXCEPTION_MESSAGE = "WRITE CACHE STORE EXCEPTION"; + + /** {@inheritDoc} */ + @Override public Object load(Object o) throws CacheLoaderException { + return null; + } + + /** {@inheritDoc} */ + @Override public void write(Cache.Entry entry) throws CacheWriterException { + throw new RuntimeException(EXCEPTION_MESSAGE); + } + + /** {@inheritDoc} */ + @Override public void delete(Object o) throws CacheWriterException { + // No-op. + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheTransactionalStoreReadFromBackupTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheTransactionalStoreReadFromBackupTest.java index 4837936621f46..f1b14aba08988 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheTransactionalStoreReadFromBackupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheTransactionalStoreReadFromBackupTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.cache.store; import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -25,6 +26,13 @@ * */ public class CacheTransactionalStoreReadFromBackupTest extends CacheStoreReadFromBackupTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheBalancingStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheBalancingStoreSelfTest.java index d1e33b60ecf31..067399e6fb5cb 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheBalancingStoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheBalancingStoreSelfTest.java @@ -43,14 +43,19 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Store test. */ +@RunWith(JUnit4.class) public class GridCacheBalancingStoreSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testLoads() throws Exception { final int range = 300; @@ -127,6 +132,7 @@ public void testLoads() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentLoad() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -138,6 +144,7 @@ public void testConcurrentLoad() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentLoadCustomThreshold() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -179,6 +186,7 @@ private void doTestConcurrentLoad(int threads, final int keys, int threshold) th /** * @throws Exception If failed. */ + @Test public void testConcurrentLoadAll() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -190,6 +198,7 @@ public void testConcurrentLoadAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentLoadAllCustomThreshold() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java index 2a1e23a8bcbd7..3d894863dda9c 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java @@ -21,51 +21,55 @@ import java.util.Iterator; import java.util.NoSuchElementException; import javax.cache.integration.CacheLoaderException; +import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.lang.IgniteBiTuple; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ -public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCacheAbstractSelfTest { +@RunWith(JUnit4.class) +public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCommonAbstractTest { /** Expected loadAll arguments, hardcoded on call site for convenience. */ private static final Integer[] EXP_ARGS = {1, 2, 3}; /** Store to use. */ private CacheLoadOnlyStoreAdapter store; - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 1; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { + super.beforeTestsStarted(); + startGrid(0); } /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); } /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { + grid(0).destroyCache(DEFAULT_CACHE_NAME); + super.afterTest(); } - /** {@inheritDoc} */ + /** + * @return Cache configuration. + */ @SuppressWarnings("unchecked") - @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { - CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName); + private CacheConfiguration cacheConfiguration() { + CacheConfiguration cfg = defaultCacheConfiguration(); assertNotNull(store); @@ -80,59 +84,38 @@ public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCacheAbstractSelf /** * @throws Exception If failed. */ + @Test public void testStore() throws Exception { - try { - int inputSize = 100; - - store = new TestStore(inputSize); - - startGrids(gridCount()); + int inputSize = 100; - awaitPartitionMapExchange(); + store = new TestStore(inputSize); - jcache().localLoadCache(null, 1, 2, 3); + IgniteCache cache = grid(0).createCache(cacheConfiguration()); - int cnt = 0; + cache.localLoadCache(null, 1, 2, 3); - for (int i = 0; i < gridCount(); i++) - cnt += jcache(i).localSize(); - - assertEquals(inputSize - (inputSize / 10), cnt); - } - finally { - stopAllGrids(); - } + assertEquals(inputSize - (inputSize / 10), cache.localSize()); } /** * @throws Exception If failed. */ + @Test public void testStoreSmallQueueSize() throws Exception { - try { - int inputSize = 1500; - - store = new ParallelTestStore(inputSize); - - store.setBatchSize(1); - store.setBatchQueueSize(1); - store.setThreadsCount(2); + int inputSize = 1500; - startGrids(gridCount()); + store = new ParallelTestStore(inputSize); - awaitPartitionMapExchange(); + store.setBatchSize(1); + store.setBatchQueueSize(1); + store.setThreadsCount(2); - jcache().localLoadCache(null, 1, 2, 3); + IgniteCache cache = grid(0).createCache(cacheConfiguration()); - int cnt = 0; + cache.localLoadCache(null, 1, 2, 3); - for (int i = 0; i < gridCount(); i++) - cnt += jcache(i).localSize(); + assertEquals(inputSize, cache.localSize()); - assertEquals(inputSize, cnt); - } - finally { - stopAllGrids(); - } } /** diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/GridStoreLoadCacheTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/GridStoreLoadCacheTest.java index d88c4318ee27e..2292d30574b7c 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/GridStoreLoadCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/GridStoreLoadCacheTest.java @@ -31,11 +31,15 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test checks that local cacheLoad task never blocks remote * cacheLoad. */ +@RunWith(JUnit4.class) public class GridStoreLoadCacheTest extends GridCommonAbstractTest { /** Barrier. */ private static final CyclicBarrier BARRIER = new CyclicBarrier(3); @@ -61,6 +65,7 @@ public class GridStoreLoadCacheTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void test() throws Exception { for (int i = 0; i < 3; i++) { IgniteEx srv1 = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java index cdc4277974bf7..22d9211bfc1f5 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java @@ -39,6 +39,9 @@ import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -46,6 +49,7 @@ /** * Test check that cache values removes from cache on expiry. */ +@RunWith(JUnit4.class) public class IgniteCacheExpiryStoreLoadSelfTest extends GridCacheAbstractSelfTest { /** Expected time to live in milliseconds. */ private static final int TIME_TO_LIVE = 1000; @@ -79,6 +83,7 @@ public class IgniteCacheExpiryStoreLoadSelfTest extends GridCacheAbstractSelfTes /** * @throws Exception If failed. */ + @Test public void testLoadCacheWithExpiry() throws Exception { checkLoad(false); } @@ -86,6 +91,7 @@ public void testLoadCacheWithExpiry() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheWithExpiryAsync() throws Exception { checkLoad(true); } @@ -119,6 +125,7 @@ private void checkLoad(boolean async) throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalLoadCacheWithExpiry() throws Exception { checkLocalLoad(false); } @@ -126,6 +133,7 @@ public void testLocalLoadCacheWithExpiry() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalLoadCacheWithExpiryAsync() throws Exception { checkLocalLoad(true); } @@ -159,6 +167,7 @@ private void checkLocalLoad(boolean async) throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadAllWithExpiry() throws Exception { IgniteCache cache = ignite(0).cache(DEFAULT_CACHE_NAME) .withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, TIME_TO_LIVE))); @@ -239,4 +248,4 @@ private static class TestStore implements CacheStore { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/StoreResourceInjectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/StoreResourceInjectionSelfTest.java index f043746893691..165a6fd218574 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/StoreResourceInjectionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/StoreResourceInjectionSelfTest.java @@ -19,20 +19,18 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.resources.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.testframework.junits.common.*; import javax.cache.configuration.*; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test resource injection. */ +@RunWith(JUnit4.class) public class StoreResourceInjectionSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private CacheConfiguration cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); @@ -45,12 +43,6 @@ public class StoreResourceInjectionSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -62,6 +54,7 @@ public class StoreResourceInjectionSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testResourcesInStoreFactory() throws Exception { cacheCfg.setCacheStoreFactory(new MyCacheStoreFactory()); @@ -71,6 +64,7 @@ public void testResourcesInStoreFactory() throws Exception { /** * */ + @Test public void testResourcesInLoaderFactory() throws Exception { cacheCfg.setCacheLoaderFactory(new MyCacheStoreFactory()); @@ -80,6 +74,7 @@ public void testResourcesInLoaderFactory() throws Exception { /** * */ + @Test public void testResourcesInWriterFactory() throws Exception { cacheCfg.setCacheWriterFactory(new MyCacheStoreFactory()); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java index 703cbe18908b9..6f1e42217ffc9 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java @@ -29,8 +29,8 @@ import javax.cache.integration.CacheLoaderException; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.store.jdbc.dialect.H2Dialect; -import org.apache.ignite.cache.store.jdbc.model.Person; import org.apache.ignite.cache.store.jdbc.model.Gender; +import org.apache.ignite.cache.store.jdbc.model.Person; import org.apache.ignite.cache.store.jdbc.model.PersonKey; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; @@ -38,10 +38,11 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -50,10 +51,8 @@ /** * Class for {@link CacheJdbcPojoStore} tests. */ +@RunWith(JUnit4.class) public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** DB connection URL. */ private static final String DFLT_CONN_URL = "jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1"; @@ -96,6 +95,13 @@ protected Connection getConnection() throws SQLException { return DriverManager.getConnection(DFLT_CONN_URL, "sa", ""); } + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { Connection conn = getConnection(); @@ -135,12 +141,6 @@ protected Connection getConnection() throws SQLException { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration()); cfg.setMarshaller(marshaller()); @@ -370,6 +370,7 @@ protected void checkCacheLoadWithStatement() throws SQLException { /** * @throws Exception If failed. */ + @Test public void testLoadCacheWithStatement() throws Exception { startTestGrid(false, false, false, false, 512); @@ -379,6 +380,7 @@ public void testLoadCacheWithStatement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheWithStatementTx() throws Exception { startTestGrid(false, false, false, true, 512); @@ -388,6 +390,7 @@ public void testLoadCacheWithStatementTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCache() throws Exception { startTestGrid(false, false, false, false, 512); @@ -397,6 +400,7 @@ public void testLoadCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheAll() throws Exception { startTestGrid(false, false, false, false, ORGANIZATION_CNT + PERSON_CNT + 1); @@ -406,6 +410,7 @@ public void testLoadCacheAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheWithSql() throws Exception { startTestGrid(false, false, false, false, 512); @@ -415,6 +420,7 @@ public void testLoadCacheWithSql() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheTx() throws Exception { startTestGrid(false, false, false, true, 512); @@ -424,6 +430,7 @@ public void testLoadCacheTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheWithSqlTx() throws Exception { startTestGrid(false, false, false, true, 512); @@ -433,6 +440,7 @@ public void testLoadCacheWithSqlTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCachePrimitiveKeys() throws Exception { startTestGrid(true, false, false, false, 512); @@ -442,6 +450,7 @@ public void testLoadCachePrimitiveKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCachePrimitiveKeysTx() throws Exception { startTestGrid(true, false, false, true, 512); @@ -532,6 +541,7 @@ private void checkPutRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemoveBuiltIn() throws Exception { startTestGrid(true, false, false, false, 512); @@ -541,6 +551,7 @@ public void testPutRemoveBuiltIn() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemove() throws Exception { startTestGrid(false, false, false, false, 512); @@ -550,6 +561,7 @@ public void testPutRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemoveTxBuiltIn() throws Exception { startTestGrid(true, false, false, true, 512); @@ -559,6 +571,7 @@ public void testPutRemoveTxBuiltIn() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemoveTx() throws Exception { startTestGrid(false, false, false, true, 512); @@ -568,6 +581,7 @@ public void testPutRemoveTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadNotRegisteredType() throws Exception { startTestGrid(false, false, false, false, 512); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java index b6d6fe13ac275..b95ed24b111f7 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java @@ -19,10 +19,14 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link CacheJdbcPojoStore} with binary marshaller. */ +@RunWith(JUnit4.class) public class CacheJdbcPojoStoreBinaryMarshallerSelfTest extends CacheJdbcPojoStoreAbstractSelfTest { /** {@inheritDoc} */ @Override protected Marshaller marshaller(){ @@ -32,6 +36,7 @@ public class CacheJdbcPojoStoreBinaryMarshallerSelfTest extends CacheJdbcPojoSto /** * @throws Exception If failed. */ + @Test public void testLoadCacheNoKeyClasses() throws Exception { startTestGrid(false, true, false, false, 512); @@ -41,6 +46,7 @@ public void testLoadCacheNoKeyClasses() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheNoKeyClassesTx() throws Exception { startTestGrid(false, true, false, true, 512); @@ -50,6 +56,7 @@ public void testLoadCacheNoKeyClassesTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheNoValueClasses() throws Exception { startTestGrid(false, false, true, false, 512); @@ -59,6 +66,7 @@ public void testLoadCacheNoValueClasses() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheNoValueClassesTx() throws Exception { startTestGrid(false, false, true, true, 512); @@ -68,6 +76,7 @@ public void testLoadCacheNoValueClassesTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheNoKeyAndValueClasses() throws Exception { startTestGrid(false, true, true, false, 512); @@ -77,6 +86,7 @@ public void testLoadCacheNoKeyAndValueClasses() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheNoKeyAndValueClassesTx() throws Exception { startTestGrid(false, true, true, true, 512); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java index ea2808fa7cd7c..f2db5dfaa5c55 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java @@ -50,10 +50,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.cache.GridAbstractCacheStoreSelfTest; import org.h2.jdbcx.JdbcConnectionPool; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Class for {@code PojoCacheStore} tests. */ +@RunWith(JUnit4.class) public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest> { /** DB connection URL. */ private static final String DFLT_CONN_URL = "jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1"; @@ -269,6 +273,7 @@ public CacheJdbcPojoStoreTest() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCache() throws Exception { Connection conn = store.openConnection(false); @@ -442,6 +447,7 @@ else if (k instanceof PersonComplexKey && v instanceof Person) { /** * @throws Exception If failed. */ + @Test public void testParallelLoad() throws Exception { Connection conn = store.openConnection(false); @@ -503,6 +509,7 @@ public void testParallelLoad() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteRetry() throws Exception { CacheJdbcPojoStore store = store(); @@ -556,6 +563,7 @@ public void testWriteRetry() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { Timestamp k = new Timestamp(System.currentTimeMillis()); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java index b1f8cd3c17746..56d990be00f77 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java @@ -42,12 +42,12 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.beans.BeansException; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.support.GenericApplicationContext; @@ -61,6 +61,7 @@ /** * */ +@RunWith(JUnit4.class) public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest extends GridCommonAbstractTest { /** Default config with mapping. */ @@ -69,9 +70,6 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest fut1 = runMultiThreadedAsync(new Callable() { private final Random rnd = new Random(); @@ -243,6 +236,7 @@ public void testMultithreadedPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedPutAll() throws Exception { multithreaded(new Callable() { private final Random rnd = new Random(); @@ -285,6 +279,7 @@ public void testMultithreadedPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedExplicitTx() throws Exception { runMultiThreaded(new Callable() { private final Random rnd = new Random(); diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListenerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListenerSelfTest.java index 237cfeb363799..968dc0837da34 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListenerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListenerSelfTest.java @@ -32,12 +32,20 @@ import org.apache.ignite.cache.store.CacheStoreSessionListenerAbstractSelfTest; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.resources.CacheStoreSessionResource; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.h2.jdbcx.JdbcConnectionPool; /** * Tests for {@link CacheJdbcStoreSessionListener}. */ public class CacheJdbcStoreSessionListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected Factory> storeFactory() { return new Factory>() { diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java index 1f6849030a664..a801f1355bdb0 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java @@ -37,11 +37,12 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -52,10 +53,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of grids to start. */ private static final int GRID_CNT = 5; @@ -65,6 +64,13 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr /** Client flag. */ private boolean client; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startGridsMultiThreaded(GRID_CNT - 2); @@ -90,12 +96,6 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr @Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - if (!client) { CacheConfiguration cc = defaultCacheConfiguration(); @@ -120,6 +120,7 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr /** * @throws Exception If failed. */ + @Test public void testMultithreadedPut() throws Exception { IgniteInternalFuture fut1 = runMultiThreadedAsync(new Callable() { private final Random rnd = new Random(); @@ -158,6 +159,7 @@ public void testMultithreadedPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedPutAll() throws Exception { runMultiThreaded(new Callable() { private final Random rnd = new Random(); @@ -184,6 +186,7 @@ public void testMultithreadedPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedExplicitTx() throws Exception { runMultiThreaded(new Callable() { private final Random rnd = new Random(); @@ -262,4 +265,4 @@ private void checkOpenedClosedCount() { assertEquals(opened, closed); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/JdbcTypesDefaultTransformerTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/JdbcTypesDefaultTransformerTest.java index 5e490f7368053..a1d5690c8c3fb 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/JdbcTypesDefaultTransformerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/JdbcTypesDefaultTransformerTest.java @@ -28,14 +28,19 @@ import java.sql.Timestamp; import java.util.UUID; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link JdbcTypesDefaultTransformer}. */ +@RunWith(JUnit4.class) public class JdbcTypesDefaultTransformerTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTransformer() throws Exception { // Connection to H2. String jdbcUrl = "jdbc:h2:mem:JdbcTypesDefaultTransformerTest"; diff --git a/modules/core/src/test/java/org/apache/ignite/client/ClientConfigurationTest.java b/modules/core/src/test/java/org/apache/ignite/client/ClientConfigurationTest.java index bcc212abbe130..287c6ec6793bc 100644 --- a/modules/core/src/test/java/org/apache/ignite/client/ClientConfigurationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/client/ClientConfigurationTest.java @@ -25,9 +25,19 @@ import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Collections; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import org.apache.ignite.Ignite; +import org.apache.ignite.Ignition; +import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.BinaryConfiguration; import org.apache.ignite.configuration.ClientConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; @@ -73,4 +83,36 @@ public void testSerialization() throws IOException, ClassNotFoundException { assertTrue(Comparers.equal(target, desTarget)); } + + /** + * Test check the case when {@link IgniteConfiguration#getRebalanceThreadPoolSize()} is equal to {@link + * IgniteConfiguration#getSystemThreadPoolSize()} + */ + @Test + public void testRebalanceThreadPoolSize() { + GridStringLogger gridStrLog = new GridStringLogger(); + gridStrLog.logLength(1024 * 100); + + IgniteConfiguration cci = Config.getServerConfiguration().setClientMode(true); + cci.setRebalanceThreadPoolSize(cci.getSystemThreadPoolSize()); + cci.setGridLogger(gridStrLog); + + try ( + Ignite si = Ignition.start(Config.getServerConfiguration()); + Ignite ci = Ignition.start(cci)) { + Set collect = si.cluster().nodes().stream() + .filter(new Predicate() { + @Override public boolean test(ClusterNode clusterNode) { + return clusterNode.isClient(); + } + }) + .collect(Collectors.toSet()); + + String log = gridStrLog.toString(); + boolean containsMsg = log.contains("Setting the rebalance pool size has no effect on the client mode"); + + Assert.assertTrue(containsMsg); + Assert.assertEquals(1, collect.size()); + } + } } diff --git a/modules/core/src/test/java/org/apache/ignite/client/SslParametersTest.java b/modules/core/src/test/java/org/apache/ignite/client/SslParametersTest.java index 7ac6108197a24..a950d6dc10126 100644 --- a/modules/core/src/test/java/org/apache/ignite/client/SslParametersTest.java +++ b/modules/core/src/test/java/org/apache/ignite/client/SslParametersTest.java @@ -18,23 +18,28 @@ package org.apache.ignite.client; import java.util.concurrent.Callable; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.Ignition; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ClientConfiguration; import org.apache.ignite.configuration.ClientConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.ssl.SslContextFactory; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests cases when node connects to cluster with different set of cipher suites. */ +@RunWith(JUnit4.class) public class SslParametersTest extends GridCommonAbstractTest { - + /** */ public static final String TEST_CACHE_NAME = "TEST"; + /** */ private volatile String[] cipherSuites; @@ -58,8 +63,10 @@ public class SslParametersTest extends GridCommonAbstractTest { return cfg; } - /** {@inheritDoc} */ - protected ClientConfiguration getClientConfiguration() throws Exception { + /** + * @return Client config. + */ + protected ClientConfiguration getClientConfiguration() { ClientConfiguration cfg = new ClientConfiguration(); cfg.setAddresses("127.0.0.1:10800"); @@ -71,9 +78,11 @@ protected ClientConfiguration getClientConfiguration() throws Exception { return cfg; } + /** + * @return SSL factory. + */ @NotNull private SslContextFactory createSslFactory() { - SslContextFactory factory = (SslContextFactory)GridTestUtils.sslTrustedFactory( - "node01", "trustone"); + SslContextFactory factory = (SslContextFactory)GridTestUtils.sslTrustedFactory("node01", "trustone"); factory.setCipherSuites(cipherSuites); factory.setProtocols(protocols); @@ -92,6 +101,7 @@ protected ClientConfiguration getClientConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSameCipherSuite() throws Exception { cipherSuites = new String[] { "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", @@ -102,12 +112,10 @@ public void testSameCipherSuite() throws Exception { startGrid(); checkSuccessfulClientStart( - new String[][] { - new String[] { - "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", - "TLS_RSA_WITH_AES_128_GCM_SHA256", - "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" - } + new String[] { + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" }, null ); @@ -116,6 +124,7 @@ public void testSameCipherSuite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOneCommonCipherSuite() throws Exception { cipherSuites = new String[] { "TLS_RSA_WITH_AES_128_GCM_SHA256", @@ -123,13 +132,11 @@ public void testOneCommonCipherSuite() throws Exception { }; startGrid(); - + checkSuccessfulClientStart( - new String[][] { - new String[] { - "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", - "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" - } + new String[] { + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" }, null ); @@ -138,19 +145,18 @@ public void testOneCommonCipherSuite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoCommonCipherSuite() throws Exception { cipherSuites = new String[] { "TLS_RSA_WITH_AES_128_GCM_SHA256" }; startGrid(); - + checkClientStartFailure( - new String[][] { - new String[] { - "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", - "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" - } + new String[] { + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" }, null ); @@ -159,19 +165,18 @@ public void testNoCommonCipherSuite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNonExistentCipherSuite() throws Exception { cipherSuites = new String[] { "TLS_RSA_WITH_AES_128_GCM_SHA256" }; startGrid(); - + checkClientStartFailure( - new String[][] { - new String[] { - "TLC_FAKE_CIPHER", - "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" - } + new String[] { + "TLC_FAKE_CIPHER", + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" }, null, IllegalArgumentException.class, @@ -182,6 +187,7 @@ public void testNonExistentCipherSuite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoCommonProtocols() throws Exception { protocols = new String[] { "TLSv1.1", @@ -192,11 +198,9 @@ public void testNoCommonProtocols() throws Exception { checkClientStartFailure( null, - new String[][] { - new String[] { - "TLSv1", - "TLSv1.2", - } + new String[] { + "TLSv1", + "TLSv1.2" } ); } @@ -204,6 +208,7 @@ public void testNoCommonProtocols() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNonExistentProtocol() throws Exception { protocols = new String[] { "SSLv3" @@ -213,11 +218,9 @@ public void testNonExistentProtocol() throws Exception { checkClientStartFailure( null, - new String[][] { - new String[] { - "SSLv3", - "SSLvDoesNotExist" - } + new String[] { + "SSLv3", + "SSLvDoesNotExist" }, IllegalArgumentException.class, "SSLvDoesNotExist" @@ -227,20 +230,19 @@ public void testNonExistentProtocol() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSameProtocols() throws Exception { protocols = new String[] { "TLSv1.1", - "TLSv1.2", + "TLSv1.2" }; startGrid(); checkSuccessfulClientStart(null, - new String[][] { - new String[] { - "TLSv1.1", - "TLSv1.2", - } + new String[] { + "TLSv1.1", + "TLSv1.2" } ); } @@ -248,6 +250,7 @@ public void testSameProtocols() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOneCommonProtocol() throws Exception { protocols = new String[] { "TLSv1", @@ -258,11 +261,9 @@ public void testOneCommonProtocol() throws Exception { startGrid(); checkSuccessfulClientStart(null, - new String[][] { - new String[] { - "TLSv1.1", - "SSLv3" - } + new String[] { + "TLSv1.1", + "SSLv3" } ); } @@ -272,30 +273,26 @@ public void testOneCommonProtocol() throws Exception { * @param protocols list of protocols * @throws Exception If failed. */ - private void checkSuccessfulClientStart(String[][] cipherSuites, String[][] protocols) throws Exception { - int n = Math.max( - cipherSuites != null ? cipherSuites.length : 0, - protocols != null ? protocols.length : 0); - - for (int i = 0; i < n; i++) { - this.cipherSuites = cipherSuites != null && i < cipherSuites.length ? cipherSuites[i] : null; - this.protocols = protocols != null && i < protocols.length ? protocols[i] : null; - - IgniteClient client = Ignition.startClient(getClientConfiguration()); + private void checkSuccessfulClientStart(String[] cipherSuites, String[] protocols) throws Exception { + this.cipherSuites = F.isEmpty(cipherSuites) ? null : cipherSuites; + this.protocols = F.isEmpty(protocols) ? null : protocols; + try (IgniteClient client = Ignition.startClient(getClientConfiguration())) { client.getOrCreateCache(TEST_CACHE_NAME); - - client.close(); } } /** * @param cipherSuites list of cipher suites * @param protocols list of protocols - * @throws Exception If failed. */ - private void checkClientStartFailure(String[][] cipherSuites, String[][] protocols) throws Exception { - checkClientStartFailure(cipherSuites, protocols, ClientConnectionException.class, "Ignite cluster is unavailable"); + private void checkClientStartFailure(String[] cipherSuites, String[] protocols) { + checkClientStartFailure( + cipherSuites, + protocols, + ClientConnectionException.class, + "Ignite cluster is unavailable" + ); } /** @@ -303,27 +300,27 @@ private void checkClientStartFailure(String[][] cipherSuites, String[][] protoco * @param protocols list of protocols * @param ex expected exception class * @param msg exception message - * @throws Exception If failed. */ - private void checkClientStartFailure(String[][] cipherSuites, String[][] protocols, Class ex, String msg) throws Exception { - int n = Math.max( - cipherSuites != null ? cipherSuites.length : 0, - protocols != null ? protocols.length : 0); - - for (int i = 0; i < n; i++) { - this.cipherSuites = cipherSuites != null && i < cipherSuites.length ? cipherSuites[i] : null; - this.protocols = protocols != null && i < protocols.length ? protocols[i] : null; - - int finalI = i; - - GridTestUtils.assertThrows(null, new Callable() { - @Override public Object call() throws Exception { + private void checkClientStartFailure( + String[] cipherSuites, + String[] protocols, + Class ex, + String msg + ) { + this.cipherSuites = F.isEmpty(cipherSuites) ? null : cipherSuites; + this.protocols = F.isEmpty(protocols) ? null : protocols; + + GridTestUtils.assertThrows( + null, + new Callable() { + @Override public Object call() { Ignition.startClient(getClientConfiguration()); return null; } - }, ex, msg); - } + }, + ex, + msg + ); } - } diff --git a/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlerTriggeredTest.java b/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlerTriggeredTest.java index 23c7e0895b4b9..79a2116b9ad0d 100644 --- a/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlerTriggeredTest.java +++ b/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlerTriggeredTest.java @@ -29,14 +29,19 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test of triggering of failure handler. */ +@RunWith(JUnit4.class) public class FailureHandlerTriggeredTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testFailureHandlerTriggeredOnExchangeWorkerTermination() throws Exception { try { CountDownLatch latch = new CountDownLatch(1); diff --git a/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlingConfigurationTest.java b/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlingConfigurationTest.java index 4e5b7535bb3a3..b7a9f1dc54263 100644 --- a/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlingConfigurationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/failure/FailureHandlingConfigurationTest.java @@ -33,6 +33,9 @@ import org.apache.ignite.internal.worker.WorkersRegistry; import org.apache.ignite.mxbean.FailureHandlingMxBean; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT; @@ -40,6 +43,7 @@ /** * Tests configuration parameters related to failure handling. */ +@RunWith(JUnit4.class) public class FailureHandlingConfigurationTest extends GridCommonAbstractTest { /** */ private Long checkpointReadLockTimeout; @@ -106,6 +110,7 @@ private class TestFailureHandler extends AbstractFailureHandler { /** * @throws Exception If failed. */ + @Test public void testCfgParamsPropagation() throws Exception { sysWorkerBlockedTimeout = 30_000L; checkpointReadLockTimeout = 20_000L; @@ -130,6 +135,7 @@ public void testCfgParamsPropagation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartialCfgParamsPropagation() throws Exception { sysWorkerBlockedTimeout = 30_000L; checkpointReadLockTimeout = null; @@ -154,6 +160,7 @@ public void testPartialCfgParamsPropagation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNegativeParamValues() throws Exception { sysWorkerBlockedTimeout = -1L; checkpointReadLockTimeout = -85L; @@ -178,6 +185,7 @@ public void testNegativeParamValues() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOverridingBySysProps() throws Exception { String prevWorkerProp = System.getProperty(IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT); String prevCheckpointProp = System.getProperty(IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT); @@ -228,6 +236,7 @@ public void testOverridingBySysProps() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMBeanParamsChanging() throws Exception { IgniteEx ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/failure/IoomFailureHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/failure/IoomFailureHandlerTest.java index 7557d34ba26b2..6c9304bac9c57 100644 --- a/modules/core/src/test/java/org/apache/ignite/failure/IoomFailureHandlerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/failure/IoomFailureHandlerTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.internal.mem.IgniteOutOfMemoryException; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * IgniteOutOfMemoryError failure handler test. */ +@RunWith(JUnit4.class) public class IoomFailureHandlerTest extends AbstractFailureHandlerTest { /** Offheap size for memory policy. */ private static final int SIZE = 10 * 1024 * 1024; @@ -96,6 +100,7 @@ public class IoomFailureHandlerTest extends AbstractFailureHandlerTest { /** * Test IgniteOutOfMemoryException handling with no store. */ + @Test public void testIoomErrorNoStoreHandling() throws Exception { testIoomErrorHandling(false, false); } @@ -103,6 +108,7 @@ public void testIoomErrorNoStoreHandling() throws Exception { /** * Test IgniteOutOfMemoryException handling with PDS. */ + @Test public void testIoomErrorPdsHandling() throws Exception { testIoomErrorHandling(true, false); } @@ -110,6 +116,7 @@ public void testIoomErrorPdsHandling() throws Exception { /** * Test IgniteOutOfMemoryException handling with no store. */ + @Test public void testIoomErrorMvccNoStoreHandling() throws Exception { testIoomErrorHandling(false, true); } @@ -117,6 +124,7 @@ public void testIoomErrorMvccNoStoreHandling() throws Exception { /** * Test IgniteOutOfMemoryException handling with PDS. */ + @Test public void testIoomErrorMvccPdsHandling() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-10185"); diff --git a/modules/core/src/test/java/org/apache/ignite/failure/OomFailureHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/failure/OomFailureHandlerTest.java index 2af94b88ee3e4..243316a887a5d 100644 --- a/modules/core/src/test/java/org/apache/ignite/failure/OomFailureHandlerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/failure/OomFailureHandlerTest.java @@ -36,10 +36,14 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Out of memory error failure handler test. */ +@RunWith(JUnit4.class) public class OomFailureHandlerTest extends AbstractFailureHandlerTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -64,6 +68,7 @@ public class OomFailureHandlerTest extends AbstractFailureHandlerTest { /** * Test OOME in IgniteCompute. */ + @Test public void testComputeOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); @@ -88,6 +93,7 @@ public void testComputeOomError() throws Exception { /** * Test OOME in EntryProcessor. */ + @Test public void testEntryProcessorOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); @@ -121,6 +127,7 @@ public void testEntryProcessorOomError() throws Exception { /** * Test OOME in service method invocation. */ + @Test public void testServiceInvokeOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); @@ -149,6 +156,7 @@ public void testServiceInvokeOomError() throws Exception { /** * Test OOME in service execute. */ + @Test public void testServiceExecuteOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); @@ -168,6 +176,7 @@ public void testServiceExecuteOomError() throws Exception { /** * Test OOME in event listener. */ + @Test public void testEventListenerOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/failure/StopNodeFailureHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/failure/StopNodeFailureHandlerTest.java index fb75aaeb40a92..c6f13f791dd10 100644 --- a/modules/core/src/test/java/org/apache/ignite/failure/StopNodeFailureHandlerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/failure/StopNodeFailureHandlerTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.internal.IgnitionEx; import org.apache.ignite.internal.util.typedef.PE; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * {@link StopNodeFailureHandler} tests. */ +@RunWith(JUnit4.class) public class StopNodeFailureHandlerTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected FailureHandler getFailureHandler(String igniteInstanceName) { @@ -43,6 +47,7 @@ public class StopNodeFailureHandlerTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testNodeStopped() throws Exception { try { IgniteEx ignite0 = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/failure/StopNodeOrHaltFailureHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/failure/StopNodeOrHaltFailureHandlerTest.java index 05e3e6e8faee1..86af2a38a0a42 100644 --- a/modules/core/src/test/java/org/apache/ignite/failure/StopNodeOrHaltFailureHandlerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/failure/StopNodeOrHaltFailureHandlerTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * {@link StopNodeOrHaltFailureHandler} tests. */ +@RunWith(JUnit4.class) public class StopNodeOrHaltFailureHandlerTest extends GridCommonAbstractTest { /** Number of grids started for tests. */ public static final int NODES_CNT = 3; @@ -56,6 +60,7 @@ public class StopNodeOrHaltFailureHandlerTest extends GridCommonAbstractTest { /** * Tests failed node's JVM is halted after triggering StopNodeOrHaltFailureHandler. */ + @Test public void testJvmHalted() throws Exception { IgniteEx g = grid(0); IgniteEx rmt1 = grid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/failure/SystemWorkersBlockingTest.java b/modules/core/src/test/java/org/apache/ignite/failure/SystemWorkersBlockingTest.java index 3ca7948a38c76..3d7e5dfbe05f7 100644 --- a/modules/core/src/test/java/org/apache/ignite/failure/SystemWorkersBlockingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/failure/SystemWorkersBlockingTest.java @@ -17,6 +17,8 @@ package org.apache.ignite.failure; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.apache.ignite.Ignite; @@ -25,10 +27,14 @@ import org.apache.ignite.internal.util.worker.GridWorker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.thread.IgniteThread; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests the handling of long blocking operations in system-critical workers. */ +@RunWith(JUnit4.class) public class SystemWorkersBlockingTest extends GridCommonAbstractTest { /** Handler latch. */ private static volatile CountDownLatch hndLatch; @@ -40,13 +46,22 @@ public class SystemWorkersBlockingTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setFailureHandler(new AbstractFailureHandler() { + AbstractFailureHandler failureHnd = new AbstractFailureHandler() { @Override protected boolean handle(Ignite ignite, FailureContext failureCtx) { - hndLatch.countDown(); + if (failureCtx.type() == FailureType.SYSTEM_WORKER_BLOCKED) + hndLatch.countDown(); return false; } - }); + }; + + Set ignoredFailureTypes = new HashSet<>(failureHnd.getIgnoredFailureTypes()); + + ignoredFailureTypes.remove(FailureType.SYSTEM_WORKER_BLOCKED); + + failureHnd.setIgnoredFailureTypes(ignoredFailureTypes); + + cfg.setFailureHandler(failureHnd); cfg.setFailureDetectionTimeout(FAILURE_DETECTION_TIMEOUT); @@ -72,6 +87,7 @@ public class SystemWorkersBlockingTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testBlockingWorker() throws Exception { IgniteEx ignite = grid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/failure/SystemWorkersTerminationTest.java b/modules/core/src/test/java/org/apache/ignite/failure/SystemWorkersTerminationTest.java index 1cebe2204ac52..9dadff6ec4fdd 100644 --- a/modules/core/src/test/java/org/apache/ignite/failure/SystemWorkersTerminationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/failure/SystemWorkersTerminationTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.thread.IgniteThread; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests system critical workers termination. */ +@RunWith(JUnit4.class) public class SystemWorkersTerminationTest extends GridCommonAbstractTest { /** */ private static volatile String failureHndThreadName; @@ -75,6 +79,7 @@ public class SystemWorkersTerminationTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSyntheticWorkerTermination() throws Exception { IgniteEx ignite = grid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java index bb84ae3ec78dd..33a610fa215f9 100644 --- a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java @@ -38,6 +38,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -63,6 +66,7 @@ /** * Tests events, generated by {@link org.apache.ignite.IgniteFileSystem} implementation. */ +@RunWith(JUnit4.class) public abstract class IgfsEventsAbstractSelfTest extends GridCommonAbstractTest { /** IGFS. */ private static IgfsImpl igfs; @@ -184,6 +188,7 @@ protected static int[] concat(@Nullable int[] arr, int... obj) { * * @throws Exception If failed. */ + @Test public void testSingleFileNestedDirs() throws Exception { final List evtList = new ArrayList<>(); @@ -265,6 +270,7 @@ public void testSingleFileNestedDirs() throws Exception { * * @throws Exception If failed. */ + @Test public void testDirWithFiles() throws Exception { final List evtList = new ArrayList<>(); @@ -346,6 +352,7 @@ public void testDirWithFiles() throws Exception { * * @throws Exception If failed. */ + @Test public void testSingleEmptyDir() throws Exception { final List evtList = new ArrayList<>(); @@ -403,6 +410,7 @@ public void testSingleEmptyDir() throws Exception { * * @throws Exception If failed. */ + @Test public void testTwoFiles() throws Exception { final List evtList = new ArrayList<>(); @@ -490,6 +498,7 @@ public void testTwoFiles() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeleteNonRecursive() throws Exception { final List evtList = new ArrayList<>(); @@ -544,6 +553,7 @@ public void testDeleteNonRecursive() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFile() throws Exception { final List evtList = new ArrayList<>(); @@ -611,6 +621,7 @@ public void testMoveFile() throws Exception { * * @throws Exception If failed. */ + @Test public void testNestedEmptyDirs() throws Exception { final List evtList = new ArrayList<>(); @@ -661,6 +672,7 @@ public void testNestedEmptyDirs() throws Exception { * * @throws Exception If failed. */ + @Test public void testSingleFileOverwrite() throws Exception { final List evtList = new ArrayList<>(); @@ -747,6 +759,7 @@ public void testSingleFileOverwrite() throws Exception { * * @throws Exception If failed. */ + @Test public void testFileDataEvents() throws Exception { final List evtList = new ArrayList<>(); @@ -836,4 +849,4 @@ private static class EventPredicate implements IgnitePredicate { return e0.type() == evt && e0.path().equals(path); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java index 0b14b1d91c01f..8ccd2b0b06412 100644 --- a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java @@ -27,9 +27,6 @@ import org.apache.ignite.internal.processors.igfs.IgfsMetaManager; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -39,9 +36,6 @@ * Fragmentizer abstract self test. */ public class IgfsFragmentizerAbstractSelfTest extends IgfsCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Test nodes count. */ protected static final int NODE_CNT = 4; @@ -55,12 +49,6 @@ public class IgfsFragmentizerAbstractSelfTest extends IgfsCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setName("igfs"); diff --git a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerSelfTest.java index b95fc9cecdac7..1d2425236f5f5 100644 --- a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerSelfTest.java @@ -28,14 +28,19 @@ import org.apache.ignite.internal.util.typedef.CA; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests fragmentizer work. */ +@RunWith(JUnit4.class) public class IgfsFragmentizerSelfTest extends IgfsFragmentizerAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testReadFragmentizing() throws Exception { IgniteFileSystem igfs = grid(0).fileSystem("igfs"); @@ -70,6 +75,7 @@ public void testReadFragmentizing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAppendFragmentizing() throws Exception { checkAppendFragmentizing(IGFS_BLOCK_SIZE / 4, false); } @@ -77,6 +83,7 @@ public void testAppendFragmentizing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAppendFragmentizingAligned() throws Exception { checkAppendFragmentizing(IGFS_BLOCK_SIZE, false); } @@ -84,6 +91,7 @@ public void testAppendFragmentizingAligned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAppendFragmentizingDifferentNodes() throws Exception { checkAppendFragmentizing(IGFS_BLOCK_SIZE / 4, true); } @@ -91,6 +99,7 @@ public void testAppendFragmentizingDifferentNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAppendFragmentizingAlignedDifferentNodes() throws Exception { checkAppendFragmentizing(IGFS_BLOCK_SIZE, true); } @@ -158,6 +167,7 @@ private void checkAppendFragmentizing(int chunkSize, boolean rotate) throws Exce /** * @throws Exception If failed. */ + @Test public void testFlushFragmentizing() throws Exception { checkFlushFragmentizing(IGFS_BLOCK_SIZE / 4); } @@ -165,6 +175,7 @@ public void testFlushFragmentizing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFlushFragmentizingAligned() throws Exception { checkFlushFragmentizing(IGFS_BLOCK_SIZE); } @@ -223,6 +234,7 @@ private void checkFlushFragmentizing(int chunkSize) throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeleteFragmentizing() throws Exception { IgfsImpl igfs = (IgfsImpl)grid(0).fileSystem("igfs"); @@ -265,4 +277,4 @@ private static void readFully(InputStream in, byte[] data) throws IOException { while(read < data.length) read += in.read(data, read, data.length - read); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerTopologySelfTest.java index 9cc500624beb6..ffed70d701c2f 100644 --- a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerTopologySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerTopologySelfTest.java @@ -18,14 +18,19 @@ package org.apache.ignite.igfs; import org.apache.ignite.IgniteFileSystem; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests coordinator transfer from one node to other. */ +@RunWith(JUnit4.class) public class IgfsFragmentizerTopologySelfTest extends IgfsFragmentizerAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testCoordinatorLeave() throws Exception { stopGrid(0); @@ -46,4 +51,4 @@ public void testCoordinatorLeave() throws Exception { startGrid(0); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsPathSelfTest.java b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsPathSelfTest.java index 465a4400905c8..0aba5435b12ea 100644 --- a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsPathSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsPathSelfTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * {@link IgfsPath} self test. */ +@RunWith(JUnit4.class) public class IgfsPathSelfTest extends GridCommonAbstractTest { /** Marshaller to test {@link Externalizable} interface. */ private final Marshaller marshaller; @@ -47,6 +51,7 @@ public IgfsPathSelfTest() throws IgniteCheckedException { * * @throws Exception In case of any exception. */ + @Test public void testMethods() throws Exception { IgfsPath path = new IgfsPath("/a/s/d/f"); @@ -97,6 +102,7 @@ private T mu(T obj) throws IgniteCheckedException { * @throws Exception In case of any exception. */ @SuppressWarnings("TooBroadScope") + @Test public void testConstructors() throws Exception { String pathStr = "///"; URI uri = URI.create(pathStr); @@ -158,4 +164,4 @@ private void expectConstructorThrows(Class cls, final Objec } }, cls, null); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClassSetTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClassSetTest.java index c51957a0e7082..38f7098b7430e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ClassSetTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ClassSetTest.java @@ -17,15 +17,19 @@ package org.apache.ignite.internal; -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * Tests for {@link ClassSet} class. */ -public class ClassSetTest extends TestCase { +public class ClassSetTest { /** * @throws Exception If failed. */ + @Test public void testAddAndContains() throws Exception { ClassSet clsSet = new ClassSet(); @@ -39,6 +43,7 @@ public void testAddAndContains() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddWithMaskAndContains() throws Exception { ClassSet clsSet = new ClassSet(); @@ -52,6 +57,7 @@ public void testAddWithMaskAndContains() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReduceOnAddWithMask() throws Exception { ClassSet clsSet = new ClassSet(); @@ -68,4 +74,4 @@ public void testReduceOnAddWithMask() throws Exception { assertTrue(clsSet.contains("org.apache.ignite.Ignition")); assertTrue(clsSet.contains("org.apache.ignite.NotIgnite")); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterBaselineNodesMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterBaselineNodesMetricsSelfTest.java index 46b09ac3b1819..911264aaa4f3c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterBaselineNodesMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterBaselineNodesMetricsSelfTest.java @@ -31,20 +31,18 @@ import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.mxbean.ClusterMetricsMXBean; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Baseline nodes metrics self test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class ClusterBaselineNodesMetricsSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -53,6 +51,7 @@ public class ClusterBaselineNodesMetricsSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testBaselineNodes() throws Exception { // Start 2 server nodes. IgniteEx ignite0 = startGrid(0); @@ -125,8 +124,6 @@ public void testBaselineNodes() throws Exception { String storePath = getClass().getSimpleName().toLowerCase() + "/" + getName(); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setWalMode(WALMode.LOG_ONLY) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupAbstractTest.java index fbf938d0ea913..23cbe2de0652d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupAbstractTest.java @@ -53,10 +53,11 @@ import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_JOB_STARTED; @@ -64,10 +65,8 @@ * Abstract test for {@link org.apache.ignite.cluster.ClusterGroup} */ @SuppressWarnings("deprecation") +@RunWith(JUnit4.class) public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest implements Externalizable { - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Waiting timeout. */ private static final int WAIT_TIMEOUT = 30000; @@ -121,7 +120,7 @@ protected ClusterGroupAbstractTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setForceServerMode(true).setIpFinder(ipFinder)); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); return cfg; } @@ -184,6 +183,7 @@ private Collection projectionNodeIds() { /** * Test for projection on not existing node IDs. */ + @Test public void testInvalidProjection() { Collection ids = new HashSet<>(); @@ -198,6 +198,7 @@ public void testInvalidProjection() { /** * @throws Exception If test failed. */ + @Test public void testProjection() throws Exception { assert prj != null; @@ -217,6 +218,7 @@ public void testProjection() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testRemoteNodes() throws Exception { Collection remoteNodeIds = remoteNodeIds(); @@ -247,6 +249,7 @@ public void testRemoteNodes() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testRemoteProjection() throws Exception { Collection remoteNodeIds = remoteNodeIds(); @@ -277,6 +280,7 @@ public void testRemoteProjection() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testExecution() throws Exception { String name = "oneMoreGrid"; @@ -757,4 +761,4 @@ public static class TestJob extends ComputeJobAdapter { @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // No-op. } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupHostsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupHostsSelfTest.java index 141f4af7f9194..8d2b43205eeb6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupHostsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupHostsSelfTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link ClusterGroup#forHost(String, String...)}. @@ -36,6 +39,7 @@ * @see ClusterGroupSelfTest */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class ClusterGroupHostsSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -60,6 +64,7 @@ public class ClusterGroupHostsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testForHosts() throws Exception { if (!tcpDiscovery()) return; @@ -89,6 +94,7 @@ public void testForHosts() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHostNames() throws Exception { Ignite ignite = grid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java index 0c4812f61a5e7..0fb9f80bd89a5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java @@ -35,11 +35,15 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link ClusterGroup}. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class ClusterGroupSelfTest extends ClusterGroupAbstractTest { /** Nodes count. */ private static final int NODES_CNT = 4; @@ -89,6 +93,7 @@ public class ClusterGroupSelfTest extends ClusterGroupAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRandom() throws Exception { assertTrue(ignite.cluster().nodes().contains(ignite.cluster().forRandom().node())); } @@ -96,6 +101,7 @@ public void testRandom() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOldest() throws Exception { ClusterGroup oldest = ignite.cluster().forOldest(); @@ -121,6 +127,7 @@ public void testOldest() throws Exception { /** * @throws Exception If failed. */ + @Test public void testYoungest() throws Exception { ClusterGroup youngest = ignite.cluster().forYoungest(); @@ -146,6 +153,7 @@ public void testYoungest() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForDaemons() throws Exception { assertEquals(4, ignite.cluster().nodes().size()); @@ -171,6 +179,7 @@ public void testForDaemons() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNewNodes() throws Exception { ClusterGroup youngest = ignite.cluster().forYoungest(); ClusterGroup oldest = ignite.cluster().forOldest(); @@ -194,6 +203,7 @@ public void testNewNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForPredicate() throws Exception { IgnitePredicate evenP = new IgnitePredicate() { @Override public boolean apply(ClusterNode node) { @@ -237,6 +247,7 @@ public void testForPredicate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAgeClusterGroupSerialization() throws Exception { Marshaller marshaller = ignite.configuration().getMarshaller(); @@ -260,6 +271,7 @@ public void testAgeClusterGroupSerialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientServer() throws Exception { ClusterGroup srv = ignite.cluster().forServers(); @@ -277,6 +289,7 @@ public void testClientServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForCacheNodesOnDynamicCacheCreateDestroy() throws Exception { Random rnd = ThreadLocalRandom.current(); @@ -294,6 +307,7 @@ public void testForCacheNodesOnDynamicCacheCreateDestroy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForClientNodesOnDynamicCacheCreateDestroy() throws Exception { Random rnd = ThreadLocalRandom.current(); @@ -370,6 +384,7 @@ private void addException(AtomicReference exHldr, Exception ex) { /** * @throws Exception If failed. */ + @Test public void testEmptyGroup() throws Exception { ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterMetricsSelfTest.java index 7168d3a2cca11..79460511b849f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterMetricsSelfTest.java @@ -34,6 +34,9 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_JOB_FINISHED; import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED; @@ -42,6 +45,7 @@ * Tests for projection metrics. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class ClusterMetricsSelfTest extends GridCommonAbstractTest { /** */ private static final int NODES_CNT = 4; @@ -69,6 +73,7 @@ public class ClusterMetricsSelfTest extends GridCommonAbstractTest { /** * @throws Exception In case of error. */ + @Test public void testEmptyProjection() throws Exception { try { grid(0).cluster().forPredicate(F.alwaysFalse()).metrics(); @@ -83,6 +88,7 @@ public void testEmptyProjection() throws Exception { /** * */ + @Test public void testTaskExecution() { for (int i = 0; i < ITER_CNT; i++) { info("Starting new iteration: " + i); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java index b77e46374d846..c44cad27a3ce9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java @@ -45,12 +45,12 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.messaging.MessagingListenActor; import org.apache.ignite.mxbean.ClusterMetricsMXBean; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_BUILD_VER; @@ -61,10 +61,8 @@ * Grid node metrics self test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Test message size. */ private static final int MSG_SIZE = 1024; @@ -94,12 +92,6 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - cfg.setCacheConfiguration(); cfg.setMetricsUpdateFrequency(500); @@ -120,6 +112,7 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAllocatedMemory() throws Exception { IgniteEx ignite = grid(); @@ -185,6 +178,7 @@ private void fillCache(final IgniteCache cache) throws Exceptio /** * @throws Exception If failed. */ + @Test public void testSingleTaskMetrics() throws Exception { Ignite ignite = grid(); @@ -243,6 +237,7 @@ public void testSingleTaskMetrics() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInternalTaskMetrics() throws Exception { Ignite ignite = grid(); @@ -300,6 +295,7 @@ public void testInternalTaskMetrics() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIoMetrics() throws Exception { Ignite ignite0 = grid(); Ignite ignite1 = startGrid(1); @@ -353,6 +349,7 @@ public void testIoMetrics() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterNodeMetrics() throws Exception { final Ignite ignite0 = grid(); final Ignite ignite1 = startGrid(1); @@ -381,6 +378,7 @@ public void testClusterNodeMetrics() throws Exception { * * @throws Exception If failed. */ + @Test public void testJmxClusterMetrics() throws Exception { Ignite node = grid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsUpdateTest.java index 6e6b4a4fd8344..f8dd4b899f8f1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsUpdateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsUpdateTest.java @@ -30,19 +30,17 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.lang.IgniteCallable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class ClusterNodeMetricsUpdateTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -50,8 +48,6 @@ public class ClusterNodeMetricsUpdateTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setMetricsUpdateFrequency(500); cfg.setClientMode(client); @@ -62,6 +58,7 @@ public class ClusterNodeMetricsUpdateTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testMetrics() throws Exception { int NODES = 6; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java index 6978ba2973ecc..7ff611b0002a2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java @@ -28,31 +28,19 @@ import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.compute.ComputeTaskFuture; import org.apache.ignite.compute.ComputeTaskSplitAdapter; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test cancellation of a job that depends on service. */ +@RunWith(JUnit4.class) public class ComputeJobCancelWithServiceSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -61,6 +49,7 @@ public class ComputeJobCancelWithServiceSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testJobCancel() throws Exception { Ignite server = startGrid("server"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java index 79c903114fcac..a37646bd1c079 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java @@ -28,20 +28,18 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Tests affinity mapping when {@link AffinityKeyMapper} is used. */ +@RunWith(JUnit4.class) public class GridAffinityMappedTest extends GridCommonAbstractTest { - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -53,12 +51,6 @@ public GridAffinityMappedTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - if (igniteInstanceName.endsWith("1")) cfg.setCacheConfiguration(); // Empty cache configuration. else { @@ -88,6 +80,7 @@ public GridAffinityMappedTest() { /** * @throws IgniteCheckedException If failed. */ + @Test public void testMappedAffinity() throws IgniteCheckedException { Ignite g1 = grid(1); Ignite g2 = grid(2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java index bdd1ce6b9a13e..24d2659673062 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests usage of affinity in case when cache doesn't exist. */ +@RunWith(JUnit4.class) public class GridAffinityNoCacheSelfTest extends GridCommonAbstractTest { /** */ public static final String EXPECTED_MSG = "Failed to find cache"; @@ -52,6 +56,7 @@ public class GridAffinityNoCacheSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAffinityProxyNoCache() throws Exception { checkAffinityProxyNoCache(new Object()); } @@ -59,6 +64,7 @@ public void testAffinityProxyNoCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityProxyNoCacheCacheObject() throws Exception { checkAffinityProxyNoCache(new TestCacheObject(new Object())); } @@ -81,6 +87,7 @@ private void checkAffinityProxyNoCache(Object key) { /** * @throws Exception If failed. */ + @Test public void testAffinityImplCacheDeleted() throws Exception { checkAffinityImplCacheDeleted(new Object()); } @@ -88,6 +95,7 @@ public void testAffinityImplCacheDeleted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityImplCacheDeletedCacheObject() throws Exception { checkAffinityImplCacheDeleted(new TestCacheObject(new Object())); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java index 7061e7520f989..db8362ed1aac1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java @@ -31,22 +31,20 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestExternalClassLoader; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Tests affinity and affinity mapper P2P loading. */ +@RunWith(JUnit4.class) public class GridAffinityP2PSelfTest extends GridCommonAbstractTest { - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String EXT_AFFINITY_MAPPER_CLS_NAME = "org.apache.ignite.tests.p2p.GridExternalAffinityMapper"; @@ -83,12 +81,6 @@ public GridAffinityP2PSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - c.setDeploymentMode(depMode); if (igniteInstanceName.endsWith("1")) @@ -119,6 +111,7 @@ public GridAffinityP2PSelfTest() { * * @throws Exception if error occur. */ + @Test public void testPrivateMode() throws Exception { depMode = DeploymentMode.PRIVATE; @@ -130,6 +123,7 @@ public void testPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testIsolatedMode() throws Exception { depMode = DeploymentMode.ISOLATED; @@ -141,6 +135,7 @@ public void testIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -152,6 +147,7 @@ public void testContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { depMode = DeploymentMode.SHARED; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java index f85b2c0f5a8ea..fb9f69c93340c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java @@ -29,30 +29,22 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Tests affinity mapping. */ +@RunWith(JUnit4.class) public class GridAffinitySelfTest extends GridCommonAbstractTest { - /** VM ip finder for TCP discovery. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - if (igniteInstanceName.endsWith("1")) cfg.setClientMode(true); else { @@ -84,6 +76,7 @@ public class GridAffinitySelfTest extends GridCommonAbstractTest { /** * @throws IgniteCheckedException If failed. */ + @Test public void testAffinity() throws Exception { Ignite g1 = grid(1); Ignite g2 = grid(2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAlwaysFailoverSpiFailSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAlwaysFailoverSpiFailSelfTest.java index c62c8406a1ead..c4cabfb769ec8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridAlwaysFailoverSpiFailSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAlwaysFailoverSpiFailSelfTest.java @@ -36,11 +36,15 @@ import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Always failover SPI test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridAlwaysFailoverSpiFailSelfTest extends GridCommonAbstractTest { /** */ private boolean isFailoverCalled; @@ -62,7 +66,7 @@ public GridAlwaysFailoverSpiFailSelfTest() { /** * @throws Exception If failed. */ - @SuppressWarnings({"UnusedCatchParameter", "ThrowableInstanceNeverThrown"}) + @Test public void testFailoverTask() throws Exception { isFailoverCalled = false; @@ -86,7 +90,7 @@ public void testFailoverTask() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"UnusedCatchParameter", "ThrowableInstanceNeverThrown"}) + @Test public void testNoneFailoverTask() throws Exception { isFailoverCalled = false; @@ -164,4 +168,4 @@ private static class GridTestFailoverJob extends ComputeJobAdapter { throw this.argument(0); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerHistSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerHistSizeTest.java index 69d7368c652c7..bbcb6cb0e31df 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerHistSizeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridCachePartitionExchangeManagerHistSizeTest.java @@ -19,20 +19,18 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_EXCHANGE_HISTORY_SIZE; /** * Test exchange history size parameter effect. */ +@RunWith(JUnit4.class) public class GridCachePartitionExchangeManagerHistSizeTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private String oldHistVal; @@ -40,8 +38,6 @@ public class GridCachePartitionExchangeManagerHistSizeTest extends GridCommonAbs @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME)); return cfg; @@ -66,6 +62,7 @@ public class GridCachePartitionExchangeManagerHistSizeTest extends GridCommonAbs /** * @throws Exception If failed. */ + @Test public void testSingleExchangeHistSize() throws Exception { System.setProperty(IGNITE_EXCHANGE_HISTORY_SIZE, "1"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridCancelOnGridStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridCancelOnGridStopSelfTest.java index 61ed2b3ecb129..e06032e09a9c0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridCancelOnGridStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridCancelOnGridStopSelfTest.java @@ -32,12 +32,16 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test task cancellation on grid stop. */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridCancelOnGridStopSelfTest extends GridCommonAbstractTest { /** */ private static CountDownLatch cnt; @@ -53,6 +57,7 @@ public GridCancelOnGridStopSelfTest() { /** * @throws Exception If failed. */ + @Test public void testCancelingJob() throws Exception { cancelCall = false; @@ -108,4 +113,4 @@ private static final class CancelledTask extends ComputeTaskAdapter empty = Collections.emptyList(); @@ -121,4 +126,4 @@ public UUID getSenderId() { return buf.toString(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridComputationBinarylizableClosuresSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridComputationBinarylizableClosuresSelfTest.java index a0e49b01ae1f0..e677d57790653 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridComputationBinarylizableClosuresSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridComputationBinarylizableClosuresSelfTest.java @@ -33,10 +33,14 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test ensuring that correct closures are serialized. */ +@RunWith(JUnit4.class) public class GridComputationBinarylizableClosuresSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -88,6 +92,7 @@ public class GridComputationBinarylizableClosuresSelfTest extends GridCommonAbst * * @throws Exception If failed. */ + @Test public void testJob() throws Exception { Ignite ignite = startGrid(1); startGrid(2); @@ -110,6 +115,7 @@ public void testJob() throws Exception { * * @throws Exception If failed. */ + @Test public void testMasterLeaveAwareJob() throws Exception { Ignite ignite = startGrid(1); startGrid(2); @@ -134,6 +140,7 @@ public void testMasterLeaveAwareJob() throws Exception { * * @throws Exception If failed. */ + @Test public void testCallable() throws Exception { Ignite ignite = startGrid(1); startGrid(2); @@ -153,6 +160,7 @@ public void testCallable() throws Exception { * * @throws Exception If failed. */ + @Test public void testMasterLeaveAwareCallable() throws Exception { Ignite ignite = startGrid(1); startGrid(2); @@ -174,6 +182,7 @@ public void testMasterLeaveAwareCallable() throws Exception { * * @throws Exception If failed. */ + @Test public void testRunnable() throws Exception { Ignite ignite = startGrid(1); startGrid(2); @@ -193,6 +202,7 @@ public void testRunnable() throws Exception { * * @throws Exception If failed. */ + @Test public void testMasterLeaveAwareRunnable() throws Exception { Ignite ignite = startGrid(1); startGrid(2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousJobAnnotationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousJobAnnotationSelfTest.java index 55ba0fe98f32b..50173605d6594 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousJobAnnotationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousJobAnnotationSelfTest.java @@ -40,11 +40,15 @@ import org.apache.ignite.resources.TaskContinuousMapperResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for various job callback annotations. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridContinuousJobAnnotationSelfTest extends GridCommonAbstractTest { /** */ private static final AtomicBoolean fail = new AtomicBoolean(); @@ -70,6 +74,7 @@ public class GridContinuousJobAnnotationSelfTest extends GridCommonAbstractTest /** * @throws Exception If test failed. */ + @Test public void testJobAnnotation() throws Exception { testContinuousJobAnnotation(TestJob.class); } @@ -77,6 +82,7 @@ public void testJobAnnotation() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testJobChildAnnotation() throws Exception { testContinuousJobAnnotation(TestJobChild.class); } @@ -224,4 +230,4 @@ private static class TestJobChild extends TestJob { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousJobSiblingsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousJobSiblingsSelfTest.java index 5bbbd855d0df7..4f37ec47a89bd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousJobSiblingsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousJobSiblingsSelfTest.java @@ -37,11 +37,15 @@ import org.apache.ignite.resources.TaskSessionResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test continuous mapper with siblings. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridContinuousJobSiblingsSelfTest extends GridCommonAbstractTest { /** */ private static final int JOB_COUNT = 10; @@ -49,6 +53,7 @@ public class GridContinuousJobSiblingsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If test failed. */ + @Test public void testContinuousJobSiblings() throws Exception { try { Ignite ignite = startGrid(0); @@ -64,6 +69,7 @@ public void testContinuousJobSiblings() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testContinuousJobSiblingsLocalNode() throws Exception { try { Ignite ignite = startGrid(0); @@ -154,4 +160,4 @@ private static class TestJob extends ComputeJobAdapter { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousTaskSelfTest.java index 6589dced7262f..cb1d4aefcebde 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousTaskSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousTaskSelfTest.java @@ -55,11 +55,15 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Continuous task test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridContinuousTaskSelfTest extends GridCommonAbstractTest { /** */ private static final int JOB_COUNT = 10; @@ -70,6 +74,7 @@ public class GridContinuousTaskSelfTest extends GridCommonAbstractTest { /** * @throws Exception If test failed. */ + @Test public void testContinuousJobsChain() throws Exception { try { Ignite ignite = startGrid(0); @@ -89,6 +94,7 @@ public void testContinuousJobsChain() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testContinuousJobsChainMultiThreaded() throws Exception { try { final Ignite ignite = startGrid(0); @@ -121,6 +127,7 @@ public void testContinuousJobsChainMultiThreaded() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testContinuousJobsSessionChain() throws Exception { try { Ignite ignite = startGrid(0); @@ -137,6 +144,7 @@ public void testContinuousJobsSessionChain() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testContinuousSlowMap() throws Exception { try { Ignite ignite = startGrid(0); @@ -154,6 +162,7 @@ public void testContinuousSlowMap() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testClearTimeouts() throws Exception { int holdccTimeout = 4000; @@ -176,6 +185,7 @@ public void testClearTimeouts() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMultipleHoldccCalls() throws Exception { try { Ignite grid = startGrid(0); @@ -190,6 +200,7 @@ public void testMultipleHoldccCalls() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testClosureWithNestedInternalTask() throws Exception { try { IgniteEx ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridDeploymentMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridDeploymentMultiThreadedSelfTest.java index cabcba16404e1..1b0f6d4de5104 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridDeploymentMultiThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridDeploymentMultiThreadedSelfTest.java @@ -31,12 +31,16 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; /** * Task deployment tests. */ +@RunWith(JUnit4.class) public class GridDeploymentMultiThreadedSelfTest extends GridCommonAbstractTest { /** */ private static final int THREAD_CNT = 20; @@ -47,6 +51,7 @@ public class GridDeploymentMultiThreadedSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testDeploy() throws Exception { try { final Ignite ignite = startGrid(0); @@ -123,4 +128,4 @@ private static class GridDeploymentTestTask extends ComputeTaskAdapter nodes = ignite.cluster().forRemotes().nodes(); @@ -112,6 +103,7 @@ public void testGetRemoteNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllNodes() throws Exception { Collection nodes = ignite.cluster().nodes(); @@ -124,7 +116,7 @@ public void testGetAllNodes() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"SuspiciousMethodCalls"}) + @Test public void testGetLocalNode() throws Exception { ClusterNode node = ignite.cluster().localNode(); @@ -139,6 +131,7 @@ public void testGetLocalNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPingNode() throws Exception { ClusterNode node = ignite.cluster().localNode(); @@ -152,6 +145,7 @@ public void testPingNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDiscoveryListener() throws Exception { ClusterNode node = ignite.cluster().localNode(); @@ -221,6 +215,7 @@ else if (EVT_NODE_LEFT == evt.type() || EVT_NODE_FAILED == evt.type()) { * * @throws Exception In case of any exception. */ + @Test public void testCacheNodes() throws Exception { // Validate only original node is available. GridDiscoveryManager discoMgr = ((IgniteKernal) ignite).context().discovery(); @@ -353,7 +348,6 @@ private static class GridDiscoveryTestNode extends GridMetadataAwareAdapter impl } /** {@inheritDoc} */ - @SuppressWarnings("unchecked") @Nullable @Override public T attribute(String name) { return null; } @@ -403,4 +397,4 @@ private static class GridDiscoveryTestNode extends GridMetadataAwareAdapter impl return id().hashCode(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageCheckAllEventsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageCheckAllEventsSelfTest.java index 91869023211fc..53a9daa7a3091 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageCheckAllEventsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageCheckAllEventsSelfTest.java @@ -53,6 +53,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.compute.ComputeJobResultPolicy.FAILOVER; import static org.apache.ignite.compute.ComputeJobResultPolicy.WAIT; @@ -80,6 +83,7 @@ * Test event storage. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridEventStorageCheckAllEventsSelfTest extends GridCommonAbstractTest { /** */ private static Ignite ignite; @@ -132,6 +136,7 @@ private void assertEvent(int evtType, int expType, List evts) { /** * @throws Exception If test failed. */ + @Test public void testCheckpointEvents() throws Exception { long tstamp = startTimestamp(); @@ -158,6 +163,7 @@ public void testCheckpointEvents() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testTaskUndeployEvents() throws Exception { final long tstamp = startTimestamp(); @@ -201,6 +207,7 @@ public void testTaskUndeployEvents() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testSuccessTask() throws Exception { generateEvents(null, new GridAllEventsSuccessTestJob()).get(); @@ -228,6 +235,7 @@ public void testSuccessTask() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testFailoverJobTask() throws Exception { startGrid(0); @@ -269,6 +277,7 @@ public void testFailoverJobTask() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testFailTask() throws Exception { long tstamp = startTimestamp(); @@ -300,6 +309,7 @@ public void testFailTask() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testTimeoutTask() throws Exception { long tstamp = startTimestamp(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageDefaultExceptionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageDefaultExceptionTest.java index 2cf727e6f1be9..8346abfc45191 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageDefaultExceptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageDefaultExceptionTest.java @@ -25,11 +25,15 @@ import org.apache.ignite.spi.eventstorage.NoopEventStorageSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Event storage tests with default no-op spi. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridEventStorageDefaultExceptionTest extends GridCommonAbstractTest { /** */ public GridEventStorageDefaultExceptionTest() { @@ -48,6 +52,7 @@ public GridEventStorageDefaultExceptionTest() { /** * @throws Exception In case of error. */ + @Test public void testLocalNodeEventStorage() throws Exception { try { grid().events().localQuery(F.alwaysTrue()); @@ -64,6 +69,7 @@ public void testLocalNodeEventStorage() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoteNodeEventStorage() throws Exception { try { grid().events().remoteQuery(F.alwaysTrue(), 0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageRuntimeConfigurationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageRuntimeConfigurationSelfTest.java index 97626c8e414e6..22f917c36825d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageRuntimeConfigurationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageRuntimeConfigurationSelfTest.java @@ -32,6 +32,9 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_ENTRY_CREATED; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; @@ -44,6 +47,7 @@ /** * Tests for runtime events configuration. */ +@RunWith(JUnit4.class) public class GridEventStorageRuntimeConfigurationSelfTest extends GridCommonAbstractTest { /** */ private int[] inclEvtTypes; @@ -61,6 +65,7 @@ public class GridEventStorageRuntimeConfigurationSelfTest extends GridCommonAbst /** * @throws Exception If failed. */ + @Test public void testEnableWithDefaults() throws Exception { inclEvtTypes = null; @@ -95,6 +100,7 @@ public void testEnableWithDefaults() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEnableWithIncludes() throws Exception { inclEvtTypes = new int[] { EVT_TASK_STARTED, EVT_TASK_FINISHED }; @@ -129,6 +135,7 @@ public void testEnableWithIncludes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDisableWithIncludes() throws Exception { inclEvtTypes = null; @@ -165,6 +172,7 @@ public void testDisableWithIncludes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEnableDisable() throws Exception { inclEvtTypes = null; @@ -188,7 +196,7 @@ public void testEnableDisable() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("UnusedDeclaration") + @Test public void testInvalidTypes() throws Exception { inclEvtTypes = new int[]{EVT_TASK_STARTED}; @@ -224,6 +232,7 @@ public void testInvalidTypes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetters() throws Exception { inclEvtTypes = new int[]{EVT_TASK_STARTED, EVT_TASK_FINISHED, 30000}; @@ -354,4 +363,4 @@ private int[] getEnabledEvents(int limit, Ignite g, int... customTypes) { return U.toIntArray(res); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageSelfTest.java index 4f98b0c271171..12185989e5e75 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageSelfTest.java @@ -39,6 +39,9 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVTS_ALL_MINUS_METRIC_UPDATE; import static org.apache.ignite.events.EventType.EVTS_JOB_EXECUTION; @@ -56,6 +59,7 @@ * serialized form. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridEventStorageSelfTest extends GridCommonAbstractTest { /** First grid. */ private static Ignite ignite1; @@ -82,6 +86,7 @@ public GridEventStorageSelfTest() { /** * @throws Exception In case of error. */ + @Test public void testAddRemoveGlobalListener() throws Exception { IgnitePredicate lsnr = new IgnitePredicate() { @Override public boolean apply(Event evt) { @@ -99,6 +104,7 @@ public void testAddRemoveGlobalListener() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testAddRemoveDiscoListener() throws Exception { IgnitePredicate lsnr = new IgnitePredicate() { @Override public boolean apply(Event evt) { @@ -117,6 +123,7 @@ public void testAddRemoveDiscoListener() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testLocalNodeEventStorage() throws Exception { TestEventListener lsnr = new TestEventListener(); @@ -164,6 +171,7 @@ public void testLocalNodeEventStorage() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoteNodeEventStorage() throws Exception { IgnitePredicate filter = new TestEventFilter(); @@ -180,6 +188,7 @@ public void testRemoteNodeEventStorage() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoteAndLocalNodeEventStorage() throws Exception { IgnitePredicate filter = new TestEventFilter(); @@ -211,6 +220,7 @@ private void checkGridInternalEvent(Event evt) { /** * @throws Exception In case of error. */ + @Test public void testGridInternalEvents() throws Exception { IgnitePredicate lsnr = new IgnitePredicate() { @Override public boolean apply(Event evt) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridFailFastNodeFailureDetectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridFailFastNodeFailureDetectionSelfTest.java index 79dc81ae84152..d4bdbda5d14a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridFailFastNodeFailureDetectionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridFailFastNodeFailureDetectionSelfTest.java @@ -28,9 +28,10 @@ import org.apache.ignite.spi.communication.CommunicationSpi; import org.apache.ignite.spi.discovery.DiscoverySpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; @@ -38,24 +39,19 @@ /** * Fail fast test. */ +@RunWith(JUnit4.class) public class GridFailFastNodeFailureDetectionSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); + TcpDiscoverySpi disco = (TcpDiscoverySpi)cfg.getDiscoverySpi(); // Set parameters for fast ping failure. disco.setSocketTimeout(100); disco.setNetworkTimeout(100); disco.setReconnectCount(2); - cfg.setDiscoverySpi(disco); cfg.setMetricsUpdateFrequency(10_000); return cfg; @@ -69,6 +65,7 @@ public class GridFailFastNodeFailureDetectionSelfTest extends GridCommonAbstract /** * @throws Exception If failed. */ + @Test public void testFailFast() throws Exception { startGridsMultiThreaded(5); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridFailedInputParametersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridFailedInputParametersSelfTest.java index 9446db68eabd9..a8437f9d1e1ef 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridFailedInputParametersSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridFailedInputParametersSelfTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVTS_ALL; @@ -30,6 +33,7 @@ * Test for invalid input parameters. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridFailedInputParametersSelfTest extends GridCommonAbstractTest { /** */ private static Ignite ignite; @@ -47,6 +51,7 @@ public GridFailedInputParametersSelfTest() { /** * @throws Exception Thrown in case of any errors. */ + @Test public void testAddEventLocalListener() throws Exception { try { ignite.events().localListen(null, EVTS_ALL); @@ -61,6 +66,7 @@ public void testAddEventLocalListener() throws Exception { /** * @throws Exception Thrown in case of any errors. */ + @Test public void testRemoveEventLocalListener() throws Exception { try { ignite.events().stopLocalListen(null); @@ -75,6 +81,7 @@ public void testRemoveEventLocalListener() throws Exception { /** * @throws Exception Thrown in case of any errors. */ + @Test public void testAddDiscoveryListener() throws Exception { try { ignite.events().localListen(null, EVTS_ALL); @@ -89,6 +96,7 @@ public void testAddDiscoveryListener() throws Exception { /** * @throws Exception Thrown in case of any errors. */ + @Test public void testRemoveDiscoveryListener() throws Exception { try { ignite.events().stopLocalListen(null); @@ -103,6 +111,7 @@ public void testRemoveDiscoveryListener() throws Exception { /** * @throws Exception Thrown in case of any errors. */ + @Test public void testGetNode() throws Exception { try { ignite.cluster().node(null); @@ -117,6 +126,7 @@ public void testGetNode() throws Exception { /** * @throws Exception Thrown in case of any errors. */ + @Test public void testPingNode() throws Exception { try { ignite.cluster().pingNode(null); @@ -131,6 +141,7 @@ public void testPingNode() throws Exception { /** * @throws Exception Thrown in case of any errors. */ + @Test public void testDeployTask() throws Exception { try { ignite.compute().localDeployTask(null, null); @@ -153,4 +164,4 @@ public void testDeployTask() throws Exception { // Check for exceptions. ignite.compute().localDeployTask(GridTestTask.class, U.detectClassLoader(GridTestTask.class)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverCustomTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverCustomTopologySelfTest.java index ea0c6eb309cf3..a0485c28d7e1a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverCustomTopologySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverCustomTopologySelfTest.java @@ -40,11 +40,15 @@ import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test failover and custom topology. Topology returns local node if remote node fails. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridFailoverCustomTopologySelfTest extends GridCommonAbstractTest { /** */ private final AtomicInteger failCnt = new AtomicInteger(0); @@ -80,7 +84,8 @@ public GridFailoverCustomTopologySelfTest() { * * @throws Exception If failed. */ - @SuppressWarnings({"WaitNotInLoop", "UnconditionalWait", "unchecked"}) + @SuppressWarnings({"WaitNotInLoop", "UnconditionalWait"}) + @Test public void testFailoverTopology() throws Exception { try { Ignite ignite1 = startGrid(1); @@ -192,4 +197,4 @@ public static class JobTask extends ComputeTaskAdapter { return results.get(0).getData(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverSelfTest.java index 5ed22459d48a0..d10e9c5f6c598 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverSelfTest.java @@ -40,11 +40,15 @@ import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Failover tests. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridFailoverSelfTest extends GridCommonAbstractTest { /** Initial node that job has been mapped to. */ private static final AtomicReference nodeRef = new AtomicReference<>(null); @@ -66,6 +70,7 @@ public GridFailoverSelfTest() { /** * @throws Exception If failed. */ + @Test public void testJobFail() throws Exception { try { Ignite ignite1 = startGrid(1); @@ -160,4 +165,4 @@ private static class JobFailTask implements ComputeTask { return results.get(0).getData(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverTaskWithPredicateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverTaskWithPredicateSelfTest.java index 84f31cb9485b0..6074efcc031be 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverTaskWithPredicateSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverTaskWithPredicateSelfTest.java @@ -43,11 +43,15 @@ import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test failover of a task with Node filter predicate. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridFailoverTaskWithPredicateSelfTest extends GridCommonAbstractTest { /** First node's name. */ private static final String NODE1 = "NODE1"; @@ -98,6 +102,7 @@ public class GridFailoverTaskWithPredicateSelfTest extends GridCommonAbstractTes * * @throws Exception If failed. */ + @Test public void testJobNotFailedOver() throws Exception { failed.set(false); routed.set(false); @@ -129,6 +134,7 @@ public void testJobNotFailedOver() throws Exception { * * @throws Exception If failed. */ + @Test public void testJobFailedOver() throws Exception { failed.set(false); routed.set(false); @@ -166,6 +172,7 @@ public void testJobFailedOver() throws Exception { * * @throws Exception If error happens. */ + @Test public void testJobNotFailedOverWithStaticProjection() throws Exception { failed.set(false); routed.set(false); @@ -255,4 +262,4 @@ private static class JobFailTask implements ComputeTask { } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverTopologySelfTest.java index 096554902646f..e3fdd1ff23a8c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverTopologySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverTopologySelfTest.java @@ -37,11 +37,15 @@ import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test failover and topology. It don't pick local node if it has been excluded from topology. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridFailoverTopologySelfTest extends GridCommonAbstractTest { /** */ private final AtomicBoolean failed = new AtomicBoolean(false); @@ -92,7 +96,7 @@ public GridFailoverTopologySelfTest() { * * @throws Exception If failed. */ - @SuppressWarnings("unchecked") + @Test public void testFailoverTopology() throws Exception { try { Ignite ignite1 = startGrid(1); @@ -165,4 +169,4 @@ private static class JobFailTask implements ComputeTask { return results.get(0).getData(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridGetOrStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridGetOrStartSelfTest.java index 74d50cfcbf8d4..402240e9991bc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridGetOrStartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridGetOrStartSelfTest.java @@ -20,12 +20,16 @@ import org.apache.ignite.*; import org.apache.ignite.configuration.*; import org.apache.ignite.testframework.junits.common.*; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * The GirdGetOrStartSelfTest tests get or start semantics. See IGNITE-2941 */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridGetOrStartSelfTest extends GridCommonAbstractTest { /** * Default constructor. @@ -37,6 +41,7 @@ public GridGetOrStartSelfTest() { /** * Tests default Ignite instance */ + @Test public void testDefaultIgniteInstanceGetOrStart() throws Exception { IgniteConfiguration cfg = getConfiguration(null); try(Ignite ignite = Ignition.getOrStart(cfg)) { @@ -54,6 +59,7 @@ public void testDefaultIgniteInstanceGetOrStart() throws Exception { /** * Tests named Ignite instance */ + @Test public void testNamedIgniteInstanceGetOrStart() throws Exception { IgniteConfiguration cfg = getConfiguration("test"); try(Ignite ignite = Ignition.getOrStart(cfg)) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridHomePathSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridHomePathSelfTest.java index 281c360d48b27..b38e5fd3c2fda 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridHomePathSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridHomePathSelfTest.java @@ -22,12 +22,16 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_HOME; /** * */ +@RunWith(JUnit4.class) public class GridHomePathSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -41,6 +45,7 @@ public class GridHomePathSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testHomeOverride() throws Exception { try { startGrid(0); @@ -73,4 +78,4 @@ public void testHomeOverride() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridJobCheckpointCleanupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridJobCheckpointCleanupSelfTest.java index eca7ebee3067c..b016a2f86fd87 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridJobCheckpointCleanupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridJobCheckpointCleanupSelfTest.java @@ -38,10 +38,14 @@ import org.apache.ignite.spi.checkpoint.CheckpointSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for checkpoint cleanup. */ +@RunWith(JUnit4.class) public class GridJobCheckpointCleanupSelfTest extends GridCommonAbstractTest { /** Number of currently alive checkpoints. */ private final AtomicInteger cntr = new AtomicInteger(); @@ -64,6 +68,7 @@ public class GridJobCheckpointCleanupSelfTest extends GridCommonAbstractTest { * * @throws Exception if failed. */ + @Test public void testCheckpointCleanup() throws Exception { try { checkpointSpi = new TestCheckpointSpi("task-checkpoints", cntr); @@ -169,4 +174,4 @@ private static class CheckpointCountingTestTask extends ComputeTaskAdapter>() { @Override public IgniteFuture applyx(ClusterGroup grid) { @@ -282,6 +280,7 @@ public void testApply1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testApply2() throws Exception { testMasterLeaveAwareCallback(2, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup grid) { @@ -293,6 +292,7 @@ public void testApply2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testApply3() throws Exception { testMasterLeaveAwareCallback(2, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup grid) { @@ -314,6 +314,7 @@ public void testApply3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRun1() throws Exception { testMasterLeaveAwareCallback(1, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -325,6 +326,7 @@ public void testRun1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRun2() throws Exception { testMasterLeaveAwareCallback(2, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -336,6 +338,7 @@ public void testRun2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCall1() throws Exception { testMasterLeaveAwareCallback(1, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -347,6 +350,7 @@ public void testCall1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCall2() throws Exception { testMasterLeaveAwareCallback(2, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -358,6 +362,7 @@ public void testCall2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCall3() throws Exception { testMasterLeaveAwareCallback(2, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -379,6 +384,7 @@ public void testCall3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBroadcast1() throws Exception { testMasterLeaveAwareCallback(1, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -390,6 +396,7 @@ public void testBroadcast1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBroadcast2() throws Exception { testMasterLeaveAwareCallback(1, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -401,6 +408,7 @@ public void testBroadcast2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBroadcast3() throws Exception { testMasterLeaveAwareCallback(1, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -412,6 +420,7 @@ public void testBroadcast3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityRun() throws Exception { testMasterLeaveAwareCallback(1, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -427,6 +436,7 @@ public void testAffinityRun() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityCall() throws Exception { testMasterLeaveAwareCallback(1, new CX1>() { @Override public IgniteFuture applyx(ClusterGroup prj) { @@ -767,4 +777,4 @@ private void awaitResponse() throws IgniteInterruptedCheckedException { U.await(respLatch); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridJobServicesAddNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridJobServicesAddNodeTest.java index aab33db8334c7..cbd338e2311e1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridJobServicesAddNodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridJobServicesAddNodeTest.java @@ -32,17 +32,18 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests multiple parallel jobs execution, accessing services(), while starting new nodes. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridJobServicesAddNodeTest extends GridCommonAbstractTest { /** */ private static final int LOG_MOD = 100; @@ -50,9 +51,6 @@ public class GridJobServicesAddNodeTest extends GridCommonAbstractTest { /** */ private static final int MAX_ADD_NODES = 64; - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrid(1); @@ -65,12 +63,6 @@ public class GridJobServicesAddNodeTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); commSpi.setSharedMemoryPort(-1); @@ -83,6 +75,7 @@ public class GridJobServicesAddNodeTest extends GridCommonAbstractTest { /** * @throws Exception If test failed. */ + @Test public void testServiceDescriptorsJob() throws Exception { final int tasks = 5000; final int threads = 10; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridJobStealingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridJobStealingSelfTest.java index 6824d51bcb17e..f2879eff76346 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridJobStealingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridJobStealingSelfTest.java @@ -50,12 +50,16 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Job stealing test. */ @SuppressWarnings("unchecked") @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridJobStealingSelfTest extends GridCommonAbstractTest { /** Task execution timeout in milliseconds. */ private static final int TASK_EXEC_TIMEOUT_MS = 50000; @@ -96,6 +100,7 @@ public GridJobStealingSelfTest() { * * @throws IgniteCheckedException If test failed. */ + @Test public void testTwoJobs() throws IgniteCheckedException { executeAsync(ignite1.compute(), new JobStealingSingleNodeTask(2), null).get(TASK_EXEC_TIMEOUT_MS); @@ -110,7 +115,7 @@ public void testTwoJobs() throws IgniteCheckedException { * * @throws IgniteCheckedException If test failed. */ - @SuppressWarnings("NullArgumentToVariableArgMethod") + @Test public void testTwoJobsNullPredicate() throws IgniteCheckedException { executeAsync(ignite1.compute(), new JobStealingSingleNodeTask(2), null).get(TASK_EXEC_TIMEOUT_MS); @@ -125,7 +130,7 @@ public void testTwoJobsNullPredicate() throws IgniteCheckedException { * * @throws IgniteCheckedException If test failed. */ - @SuppressWarnings("NullArgumentToVariableArgMethod") + @Test public void testTwoJobsTaskNameNullPredicate() throws IgniteCheckedException { executeAsync(ignite1.compute(), JobStealingSingleNodeTask.class.getName(), null).get(TASK_EXEC_TIMEOUT_MS); @@ -140,7 +145,7 @@ public void testTwoJobsTaskNameNullPredicate() throws IgniteCheckedException { * * @throws IgniteCheckedException If test failed. */ - @SuppressWarnings("unchecked") + @Test public void testTwoJobsPartiallyNullPredicate() throws IgniteCheckedException { IgnitePredicate topPred = new IgnitePredicate() { @Override public boolean apply(ClusterNode e) { @@ -161,6 +166,7 @@ public void testTwoJobsPartiallyNullPredicate() throws IgniteCheckedException { * * @throws Exception If failed. */ + @Test public void testProjectionPredicate() throws Exception { final Ignite ignite3 = startGrid(3); @@ -184,6 +190,7 @@ public void testProjectionPredicate() throws Exception { * * @throws Exception If failed. */ + @Test public void testProjectionPredicateInternalStealing() throws Exception { final Ignite ignite3 = startGrid(3); @@ -212,6 +219,7 @@ public void testProjectionPredicateInternalStealing() throws Exception { * * @throws Exception If failed. */ + @Test public void testSingleNodeTopology() throws Exception { IgnitePredicate p = new IgnitePredicate() { @Override public boolean apply(ClusterNode e) { @@ -232,6 +240,7 @@ public void testSingleNodeTopology() throws Exception { * * @throws Exception If failed. */ + @Test public void testSingleNodeProjection() throws Exception { ClusterGroup prj = ignite1.cluster().forNodeIds(Collections.singleton(ignite1.cluster().localNode().id())); @@ -247,7 +256,7 @@ public void testSingleNodeProjection() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings("NullArgumentToVariableArgMethod") + @Test public void testSingleNodeProjectionNullPredicate() throws Exception { ClusterGroup prj = ignite1.cluster().forNodeIds(Collections.singleton(ignite1.cluster().localNode().id())); @@ -264,6 +273,7 @@ public void testSingleNodeProjectionNullPredicate() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testProjectionPredicateDifferentClassLoaders() throws Exception { final Ignite ignite3 = startGrid(3); @@ -339,7 +349,6 @@ private static class JobStealingSpreadTask extends ComputeTaskAdapter map(List subgrid, @Nullable Object arg) { //assert subgrid.size() == 2 : "Invalid subgrid size: " + subgrid.size(); @@ -360,7 +369,6 @@ private static class JobStealingSpreadTask extends ComputeTaskAdapter results) { for (ComputeJobResult res : results) { log.info("Job result: " + res.getData()); @@ -389,7 +397,6 @@ private static class JobStealingSingleNodeTask extends JobStealingSpreadTask { } /** {@inheritDoc} */ - @SuppressWarnings("ForLoopReplaceableByForEach") @Override public Map map(List subgrid, @Nullable Object arg) { assert subgrid.size() > 1 : "Invalid subgrid size: " + subgrid.size(); @@ -454,4 +461,4 @@ private static final class GridJobStealingJob extends ComputeJobAdapter { return ignite.cluster().localNode().id(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridJobStealingZeroActiveJobsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridJobStealingZeroActiveJobsSelfTest.java index 31015cefe4791..aee0e4893ad86 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridJobStealingZeroActiveJobsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridJobStealingZeroActiveJobsSelfTest.java @@ -39,11 +39,15 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Job stealing test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridJobStealingZeroActiveJobsSelfTest extends GridCommonAbstractTest { /** */ private static Ignite ignite1; @@ -75,6 +79,7 @@ public GridJobStealingZeroActiveJobsSelfTest() { * * @throws IgniteCheckedException If test failed. */ + @Test public void testTwoJobs() throws IgniteCheckedException { ignite1.compute().execute(JobStealingTask.class, null); } @@ -176,4 +181,4 @@ public static final class GridJobStealingJob extends ComputeJobAdapter { return ignite.name(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridJobSubjectIdSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridJobSubjectIdSelfTest.java index 07720675d379e..354354bc7bf57 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridJobSubjectIdSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridJobSubjectIdSelfTest.java @@ -36,10 +36,16 @@ import org.apache.ignite.resources.TaskSessionResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SUBJ_ID; /** * Test job subject ID propagation. */ +@RunWith(JUnit4.class) public class GridJobSubjectIdSelfTest extends GridCommonAbstractTest { /** Job subject ID. */ private static volatile UUID taskSubjId; @@ -59,6 +65,7 @@ public class GridJobSubjectIdSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { node1 = startGrid(1); + node2 = startGrid(2); } @@ -67,7 +74,14 @@ public class GridJobSubjectIdSelfTest extends GridCommonAbstractTest { stopAllGrids(); node1 = null; + node2 = null; + + evtSubjId = null; + + taskSubjId = null; + + jobSubjId = null; } /** @@ -75,6 +89,7 @@ public class GridJobSubjectIdSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testJobSubjectId() throws Exception { node2.events().localListen(new IgnitePredicate() { @Override public boolean apply(Event evt) { @@ -91,9 +106,40 @@ public void testJobSubjectId() throws Exception { node1.compute().execute(new Task(node2.cluster().localNode().id()), null); assertEquals(taskSubjId, jobSubjId); + assertEquals(taskSubjId, evtSubjId); } + /** + * Test job subject ID propagation in case if was changed. + * + * @throws Exception If failed. + */ + @Test + public void testModifiedSubjectId() throws Exception { + node1.events().localListen(new IgnitePredicate() { + @Override public boolean apply(Event evt) { + JobEvent evt0 = (JobEvent)evt; + + assert evtSubjId == null; + + evtSubjId = evt0.taskSubjectId(); + + return false; + } + }, EventType.EVT_JOB_STARTED); + + UUID uuid = new UUID(100, 100); + + ((IgniteEx) node1).context().task().setThreadContextIfNotNull(TC_SUBJ_ID, uuid); + + ((IgniteEx) node1).context().task().execute(new Task(node1.cluster().localNode().id()), null).get(); + + assertEquals(uuid, jobSubjId); + + assertEquals(uuid, evtSubjId); + } + /** * Task class. */ @@ -157,4 +203,4 @@ public static class Job extends ComputeJobAdapter { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridKernalConcurrentAccessStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridKernalConcurrentAccessStopSelfTest.java index 2db34e0761c62..d797c1a83f177 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridKernalConcurrentAccessStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridKernalConcurrentAccessStopSelfTest.java @@ -20,6 +20,9 @@ import org.apache.ignite.events.Event; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; import static org.apache.ignite.events.EventType.EVT_NODE_JOINED; @@ -28,6 +31,7 @@ /** * Tests kernal stop while it is being accessed from asynchronous even listener. */ +@RunWith(JUnit4.class) public class GridKernalConcurrentAccessStopSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRIDS = 2; @@ -41,6 +45,7 @@ public class GridKernalConcurrentAccessStopSelfTest extends GridCommonAbstractT /** * */ + @Test public void testConcurrentAccess() { for (int i = 0; i < GRIDS; i++) { grid(i).events().localListen(new IgnitePredicate() { @@ -56,4 +61,4 @@ public void testConcurrentAccess() { }, EVT_NODE_FAILED, EVT_NODE_LEFT, EVT_NODE_JOINED); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridLifecycleBeanSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridLifecycleBeanSelfTest.java index 7fe0924d1f88d..ed14ecff7b51b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridLifecycleBeanSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridLifecycleBeanSelfTest.java @@ -35,6 +35,9 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.lifecycle.LifecycleEventType.AFTER_NODE_START; import static org.apache.ignite.lifecycle.LifecycleEventType.AFTER_NODE_STOP; @@ -45,6 +48,7 @@ * Lifecycle bean test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridLifecycleBeanSelfTest extends GridCommonAbstractTest { /** */ private LifeCycleBaseBean bean; @@ -61,6 +65,7 @@ public class GridLifecycleBeanSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testGetIgnite() throws Exception { final AtomicBoolean done = new AtomicBoolean(); @@ -96,6 +101,7 @@ public void testGetIgnite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoErrors() throws Exception { bean = new LifeCycleBaseBean(); @@ -125,6 +131,7 @@ public void testNoErrors() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGridErrorBeforeStart() throws Exception { checkBeforeStart(true); } @@ -132,6 +139,7 @@ public void testGridErrorBeforeStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOtherErrorBeforeStart() throws Exception { checkBeforeStart(false); } @@ -139,6 +147,7 @@ public void testOtherErrorBeforeStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGridErrorAfterStart() throws Exception { checkAfterStart(true); } @@ -146,6 +155,7 @@ public void testGridErrorAfterStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOtherErrorAfterStart() throws Exception { checkAfterStart(false); } @@ -207,6 +217,7 @@ private void checkAfterStart(boolean gridErr) throws Exception { /** * @throws Exception If failed. */ + @Test public void testGridErrorBeforeStop() throws Exception { checkOnStop(BEFORE_NODE_STOP, true); @@ -219,6 +230,7 @@ public void testGridErrorBeforeStop() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOtherErrorBeforeStop() throws Exception { checkOnStop(BEFORE_NODE_STOP, false); @@ -231,6 +243,7 @@ public void testOtherErrorBeforeStop() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGridErrorAfterStop() throws Exception { checkOnStop(AFTER_NODE_STOP, true); @@ -243,6 +256,7 @@ public void testGridErrorAfterStop() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOtherErrorAfterStop() throws Exception { checkOnStop(AFTER_NODE_STOP, false); @@ -356,4 +370,4 @@ private LifeCycleExceptionBean(LifecycleEventType errType, boolean gridErr) { super.onLifecycleEvent(evt); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridListenActorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridListenActorSelfTest.java index ae2a505441148..c89ad0ab60cc5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridListenActorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridListenActorSelfTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.messaging.MessagingListenActor; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link org.apache.ignite.messaging.MessagingListenActor}. */ +@RunWith(JUnit4.class) public class GridListenActorSelfTest extends GridCommonAbstractTest { /** */ private static final int MSG_QTY = 10; @@ -53,6 +57,7 @@ public class GridListenActorSelfTest extends GridCommonAbstractTest { * * @throws Exception Thrown if failed. */ + @Test public void testBasicFlow() throws Exception { final AtomicInteger cnt = new AtomicInteger(0); @@ -86,6 +91,7 @@ public void testBasicFlow() throws Exception { /** * @throws Exception If failed. */ + @Test public void testImmediateStop() throws Exception { doSendReceive(MSG_QTY, 1); } @@ -93,6 +99,7 @@ public void testImmediateStop() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReceiveAll() throws Exception { doSendReceive(MSG_QTY, MSG_QTY); } @@ -102,6 +109,7 @@ public void testReceiveAll() throws Exception { * * @throws Exception If failed. */ + @Test public void testRespondToRemote() throws Exception { startGrid(1); @@ -145,6 +153,7 @@ public void testRespondToRemote() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPingPong() throws Exception { final AtomicInteger pingCnt = new AtomicInteger(); final AtomicInteger pongCnt = new AtomicInteger(); @@ -220,4 +229,4 @@ private void doSendReceive(int snd, final int rcv) throws Exception { assert cnt.intValue() == rcv; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridLocalEventListenerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridLocalEventListenerSelfTest.java index 43371789f2914..cd1be316dd667 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridLocalEventListenerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridLocalEventListenerSelfTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.events.EventType; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test ensuring that event listeners are picked by started node. */ +@RunWith(JUnit4.class) public class GridLocalEventListenerSelfTest extends GridCommonAbstractTest { /** Whether event fired. */ private final CountDownLatch fired = new CountDownLatch(1); @@ -67,9 +71,10 @@ public class GridLocalEventListenerSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testListener() throws Exception { startGrids(2); assert fired.await(5000, TimeUnit.MILLISECONDS); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridMBeansTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridMBeansTest.java index 1c3998257e955..48c5cb04b9129 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridMBeansTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridMBeansTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import javax.management.ObjectName; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for the standard JMX beans registered by the kernal. */ +@RunWith(JUnit4.class) public class GridMBeansTest extends GridCommonAbstractTest { /** Executor name for setExecutorConfiguration */ private static final String CUSTOM_EXECUTOR_0 = "Custom executor 0"; @@ -54,6 +58,7 @@ public GridMBeansTest() { } /** Check that kernal bean is available */ + @Test public void testKernalBeans() throws Exception { checkBean("Kernal", "IgniteKernal", "InstanceName", grid().name()); checkBean("Kernal", "ClusterMetricsMXBeanImpl", "TotalServerNodes", 1); @@ -61,6 +66,7 @@ public void testKernalBeans() throws Exception { } /** Check that kernal bean is available */ + @Test public void testExecutorBeans() throws Exception { // standard executors checkBean("Thread Pools", "GridExecutionExecutor", "Terminated", false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java index b9b0925dc5f44..8654db2e22695 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java @@ -31,12 +31,12 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -44,6 +44,7 @@ * Tests multiple parallel jobs execution. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridMultipleJobsSelfTest extends GridCommonAbstractTest { /** */ private static final int LOG_MOD = 100; @@ -51,9 +52,6 @@ public class GridMultipleJobsSelfTest extends GridCommonAbstractTest { /** */ private static final int TEST_TIMEOUT = 60 * 1000; - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrid(1); @@ -71,12 +69,6 @@ public class GridMultipleJobsSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - if (getTestIgniteInstanceName(1).equals(igniteInstanceName)) c.setCacheConfiguration(/* no configured caches */); else { @@ -100,6 +92,7 @@ public class GridMultipleJobsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If test failed. */ + @Test public void testNotAffinityJobs() throws Exception { /* =========== Test properties =========== */ int jobsNum = 5000; @@ -111,6 +104,7 @@ public void testNotAffinityJobs() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testAffinityJobs() throws Exception { /* =========== Test properties =========== */ int jobsNum = 5000; @@ -224,4 +218,4 @@ public static class AffinityJob implements IgniteCallable { return true; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleSpisSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleSpisSelfTest.java index 32a7e65de0d09..d894c0e208cb5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleSpisSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleSpisSelfTest.java @@ -42,11 +42,15 @@ import org.apache.ignite.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Multiple SPIs test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridMultipleSpisSelfTest extends GridCommonAbstractTest { /** */ private boolean isTaskFailoverCalled; @@ -109,7 +113,7 @@ public GridMultipleSpisSelfTest() { /** * @throws Exception If failed. */ - @SuppressWarnings({"UnusedCatchParameter"}) + @Test public void testFailoverTask() throws Exception { // Start local and remote grids. Ignite ignite1 = startGrid(1); @@ -311,4 +315,4 @@ private static class GridTestMultipleSpisJob extends ComputeJobAdapter { return argument(0); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleVersionsDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleVersionsDeploymentSelfTest.java index dc5c16daa2def..33bfb22ba86a9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleVersionsDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleVersionsDeploymentSelfTest.java @@ -44,6 +44,9 @@ import org.apache.ignite.testframework.GridTestClassLoader; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVT_TASK_UNDEPLOYED; @@ -52,6 +55,7 @@ * */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridMultipleVersionsDeploymentSelfTest extends GridCommonAbstractTest { /** Excluded classes. */ private static final String[] EXCLUDE_CLASSES = new String[] { @@ -101,6 +105,7 @@ private boolean checkDeployed(Ignite ignite, String taskName) { * @throws Exception If test failed. */ @SuppressWarnings("unchecked") + @Test public void testMultipleVersionsLocalDeploy() throws Exception { try { Ignite ignite = startGrid(1); @@ -160,6 +165,7 @@ public void testMultipleVersionsLocalDeploy() throws Exception { * @throws Exception If test failed. */ @SuppressWarnings("unchecked") + @Test public void testMultipleVersionsP2PDeploy() throws Exception { try { Ignite g1 = startGrid(1); @@ -317,4 +323,4 @@ public static class GridDeploymentTestJob extends ComputeJobAdapter { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridMultithreadedJobStealingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridMultithreadedJobStealingSelfTest.java index 4a76c686ac7f3..5bd6f809f69b5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridMultithreadedJobStealingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridMultithreadedJobStealingSelfTest.java @@ -47,11 +47,15 @@ import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.eclipse.jetty.util.ConcurrentHashSet; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Multithreaded job stealing test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridMultithreadedJobStealingSelfTest extends GridCommonAbstractTest { /** */ private Ignite ignite; @@ -81,6 +85,7 @@ public GridMultithreadedJobStealingSelfTest() { * * @throws Exception If test failed. */ + @Test public void testTwoJobsMultithreaded() throws Exception { final AtomicReference fail = new AtomicReference<>(null); @@ -136,6 +141,7 @@ public void testTwoJobsMultithreaded() throws Exception { * * @throws Exception If test failed. */ + @Test public void testJoinedNodeCanStealJobs() throws Exception { final AtomicReference fail = new AtomicReference<>(null); @@ -342,4 +348,4 @@ public JobStealingResult(int stolen, int nonStolen, Set nodes) { '}'; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeFilterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeFilterSelfTest.java index 7a07deff3769c..c3a71f1c18d0f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeFilterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeFilterSelfTest.java @@ -23,11 +23,15 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Node filter test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridNodeFilterSelfTest extends GridCommonAbstractTest { /** Grid instance. */ private Ignite ignite; @@ -51,6 +55,7 @@ public GridNodeFilterSelfTest() { /** * @throws Exception If failed. */ + @Test public void testSynchronousExecute() throws Exception { UUID nodeId = ignite.cluster().localNode().id(); @@ -66,4 +71,4 @@ public void testSynchronousExecute() throws Exception { assert rmtNodes.size() == 1; assert rmtNodes.iterator().next().id().equals(rmtNodeId); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeLocalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeLocalSelfTest.java index 8d8b59f476041..07b4aa9125f10 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeLocalSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeLocalSelfTest.java @@ -26,11 +26,15 @@ import org.apache.ignite.mxbean.IgniteMXBean; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * This test will test node local storage. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridNodeLocalSelfTest extends GridCommonAbstractTest { /** Create test. */ public GridNodeLocalSelfTest() { @@ -42,6 +46,7 @@ public GridNodeLocalSelfTest() { * * @throws Exception If test failed. */ + @Test public void testNodeLocal() throws Exception { Ignite g = G.ignite(getTestIgniteInstanceName()); @@ -70,6 +75,7 @@ public void testNodeLocal() throws Exception { * * @throws Exception if test failed. */ + @Test public void testClearNodeLocalMap() throws Exception { final String key = "key"; final String value = "value"; @@ -86,4 +92,4 @@ public void testClearNodeLocalMap() throws Exception { igniteMXBean.clearNodeLocalMap(); assert nodeLocalMap.isEmpty() : "Not empty node local map"; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogPdsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogPdsSelfTest.java index a768a11ed0233..41c3588a78d17 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogPdsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogPdsSelfTest.java @@ -32,9 +32,6 @@ * Check logging local node metrics with PDS enabled. */ public class GridNodeMetricsLogPdsSelfTest extends GridNodeMetricsLogSelfTest { - /** */ - private static final String UNKNOWN_SIZE = "unknown"; - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -85,7 +82,7 @@ public class GridNodeMetricsLogPdsSelfTest extends GridNodeMetricsLogSelfTest { Set regions = new HashSet<>(); Pattern ptrn = Pattern.compile("(?m).{2,}( {3}(?.+) region|Ignite persistence) " + - "\\[used=(?[-.\\d]+|" + UNKNOWN_SIZE + ")?.*]"); + "\\[used=(?[-.\\d]+)?.*]"); Matcher matcher = ptrn.matcher(logOutput); @@ -96,9 +93,7 @@ public class GridNodeMetricsLogPdsSelfTest extends GridNodeMetricsLogSelfTest { String usedSize = matcher.group("used"); - // TODO https://issues.apache.org/jira/browse/IGNITE-9455 - // TODO The actual value of the metric should be printed when this issue is solved. - int used = UNKNOWN_SIZE.equals(usedSize) ? 0 : Integer.parseInt(usedSize); + int used = Integer.parseInt(usedSize); assertTrue(used + " should be non negative: " + subj, used >= 0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java index 4389338a84fb5..80c1bc6da14eb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java @@ -29,12 +29,16 @@ import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Check logging local node metrics */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "Kernal") +@RunWith(JUnit4.class) public class GridNodeMetricsLogSelfTest extends GridCommonAbstractTest { /** Executor name for setExecutorConfiguration */ private static final String CUSTOM_EXECUTOR_0 = "Custom executor 0"; @@ -77,6 +81,7 @@ public class GridNodeMetricsLogSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNodeMetricsLog() throws Exception { IgniteCache cache1 = grid(0).createCache("TestCache1"); IgniteCache cache2 = grid(1).createCache("TestCache2"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeVisorAttributesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeVisorAttributesSelfTest.java index 78385a1784bbc..cdff29a13507b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeVisorAttributesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeVisorAttributesSelfTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.Ignite; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Ensures that system properties required by Visor are always passed to node attributes. */ +@RunWith(JUnit4.class) public class GridNodeVisorAttributesSelfTest extends GridCommonAbstractTest { /** System properties required by Visor. */ private static final String[] SYSTEM_PROPS = new String[] { @@ -82,6 +86,7 @@ private void startGridAndCheck() throws Exception { * * @throws Exception If failed. */ + @Test public void testIncludeNull() throws Exception { inclProps = null; @@ -94,6 +99,7 @@ public void testIncludeNull() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ZeroLengthArrayAllocation") + @Test public void testIncludeEmpty() throws Exception { inclProps = new String[] {}; @@ -105,9 +111,10 @@ public void testIncludeEmpty() throws Exception { * * @throws Exception If failed. */ + @Test public void testIncludeNonEmpty() throws Exception { inclProps = new String[] {"prop1", "prop2"}; startGridAndCheck(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridNonHistoryMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridNonHistoryMetricsSelfTest.java index 2fcbf49d7e73d..b224c18b8e660 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridNonHistoryMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridNonHistoryMetricsSelfTest.java @@ -35,12 +35,16 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED; /** * */ +@RunWith(JUnit4.class) public class GridNonHistoryMetricsSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { @@ -66,6 +70,7 @@ public class GridNonHistoryMetricsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSingleTaskMetrics() throws Exception { final Ignite ignite = grid(); @@ -126,4 +131,4 @@ private static class TestTask extends ComputeTaskSplitAdapter { return results; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java index 3548234902b38..a5ddfff8df515 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java @@ -29,23 +29,20 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Tests for {@link ClusterGroup#forCacheNodes(String)} method. */ +@RunWith(JUnit4.class) public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE_NAME = "cache"; @@ -56,8 +53,6 @@ public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(discoverySpi()); - List ccfgs = new ArrayList<>(); if (igniteInstanceName.equals(getTestIgniteInstanceName(0))) @@ -72,17 +67,6 @@ else if (igniteInstanceName.equals(getTestIgniteInstanceName(2)) || return cfg; } - /** - * @return Discovery SPI; - */ - private DiscoverySpi discoverySpi() { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - return spi; - } - /** * @param cacheName Cache name. * @return Cache configuration. @@ -126,6 +110,7 @@ private CacheConfiguration cacheConfiguration( /** * @throws Exception If failed. */ + @Test public void testProjectionForDefaultCache() throws Exception { final ClusterGroup prj = ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME); @@ -149,6 +134,7 @@ public void testProjectionForDefaultCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testProjectionForNamedCache() throws Exception { final ClusterGroup prj = ignite.cluster().forCacheNodes(CACHE_NAME); @@ -171,6 +157,7 @@ public void testProjectionForNamedCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testProjectionForDataCaches() throws Exception { ClusterGroup prj = ignite.cluster().forDataNodes(DEFAULT_CACHE_NAME); @@ -182,6 +169,7 @@ public void testProjectionForDataCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testProjectionForClientCaches() throws Exception { ClusterGroup prj = ignite.cluster().forClientNodes(CACHE_NAME); @@ -193,6 +181,7 @@ public void testProjectionForClientCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testProjectionForWrongCacheName() throws Exception { ClusterGroup prj = ignite.cluster().forCacheNodes("wrong"); @@ -203,6 +192,7 @@ public void testProjectionForWrongCacheName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testProjections() throws Exception { ClusterNode locNode = ignite.cluster().localNode(); UUID locId = locNode.id(); @@ -320,4 +310,4 @@ private AttributeFilter(String... attrs) { return false; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionLocalJobMultipleArgumentsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionLocalJobMultipleArgumentsSelfTest.java index d9cc732985d36..f80afc96a5732 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionLocalJobMultipleArgumentsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionLocalJobMultipleArgumentsSelfTest.java @@ -28,20 +28,18 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Tests for methods that run job locally with multiple arguments. */ +@RunWith(JUnit4.class) public class GridProjectionLocalJobMultipleArgumentsSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static Collection ids; @@ -66,12 +64,6 @@ public GridProjectionLocalJobMultipleArgumentsSelfTest() { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -84,6 +76,7 @@ public GridProjectionLocalJobMultipleArgumentsSelfTest() { /** * @throws Exception If failed. */ + @Test public void testAffinityCall() throws Exception { Collection res = new ArrayList<>(); @@ -104,6 +97,7 @@ public void testAffinityCall() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityRun() throws Exception { for (int i : F.asList(1, 2, 3)) { grid().compute().affinityRun(DEFAULT_CACHE_NAME, i, new IgniteRunnable() { @@ -122,6 +116,7 @@ public void testAffinityRun() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCall() throws Exception { Collection res = grid().compute().apply(new C1() { @Override public Integer apply(Integer arg) { @@ -138,6 +133,7 @@ public void testCall() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCallWithProducer() throws Exception { Collection args = Arrays.asList(1, 2, 3); @@ -152,4 +148,4 @@ public void testCallWithProducer() throws Exception { assertEquals(36, F.sumInt(res)); assertEquals(3, ids.size()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridReduceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridReduceSelfTest.java index 827e2a2040c2f..45802619d62bd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridReduceSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridReduceSelfTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test reduce with long operations. */ +@RunWith(JUnit4.class) public class GridReduceSelfTest extends GridCommonAbstractTest { /** Number of nodes in the grid. */ private static final int GRID_CNT = 3; @@ -37,6 +41,7 @@ public class GridReduceSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testReduce() throws Exception { startGrids(GRID_CNT); @@ -79,6 +84,7 @@ public void testReduce() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReduceAsync() throws Exception { startGrids(GRID_CNT); @@ -187,4 +193,4 @@ private static class ReducerTestClosure implements IgniteCallable { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java index b3e69a070aa07..0507e0076e6b4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java @@ -24,17 +24,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test grids starting with non compatible release types. */ +@RunWith(JUnit4.class) public class GridReleaseTypeSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private String nodeVer; @@ -57,7 +56,7 @@ public class GridReleaseTypeSelfTest extends GridCommonAbstractTest { } }; - discoSpi.setIpFinder(IP_FINDER).setForceServerMode(true); + discoSpi.setIpFinder(sharedStaticIpFinder).setForceServerMode(true); cfg.setDiscoverySpi(discoSpi); @@ -74,6 +73,7 @@ public class GridReleaseTypeSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testOsEditionDoesNotSupportRollingUpdates() throws Exception { nodeVer = "1.0.0"; @@ -101,6 +101,7 @@ public void testOsEditionDoesNotSupportRollingUpdates() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOsEditionDoesNotSupportRollingUpdatesClientMode() throws Exception { nodeVer = "1.0.0"; @@ -125,4 +126,4 @@ public void testOsEditionDoesNotSupportRollingUpdatesClientMode() throws Excepti throw e; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridRuntimeExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridRuntimeExceptionSelfTest.java index a1f946b5b867f..c5ad9ad594903 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridRuntimeExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridRuntimeExceptionSelfTest.java @@ -40,6 +40,9 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_TASK_FAILED; @@ -48,6 +51,7 @@ */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridRuntimeExceptionSelfTest extends GridCommonAbstractTest { /** */ private enum FailType { @@ -77,6 +81,7 @@ public GridRuntimeExceptionSelfTest() { /** * @throws Exception If failed. */ + @Test public void testExecuteFailed() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -107,6 +112,7 @@ public void testExecuteFailed() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMapFailed() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -137,6 +143,7 @@ public void testMapFailed() throws Exception { /** * @throws Exception If failed. */ + @Test public void testResultFailed() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -167,6 +174,7 @@ public void testResultFailed() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReduceFailed() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -305,4 +313,4 @@ private static class GridTaskFailedTestJob extends ComputeJobAdapter { return true; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridSameVmStartupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridSameVmStartupSelfTest.java index a04c38e7a7590..9b7cdfcb930f7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridSameVmStartupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridSameVmStartupSelfTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVTS_DISCOVERY; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; @@ -40,6 +43,7 @@ * events while stopping one them. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridSameVmStartupSelfTest extends GridCommonAbstractTest { /** * @@ -53,6 +57,7 @@ public GridSameVmStartupSelfTest() { * * @throws Exception If failed. */ + @Test public void testSameVmStartup() throws Exception { Ignite ignite1 = startGrid(1); @@ -118,4 +123,4 @@ public void testSameVmStartup() throws Exception { assert G.allGrids().isEmpty(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridSelfTest.java index 08b5402cf940e..32b0e8a73fc47 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridSelfTest.java @@ -29,11 +29,15 @@ import org.apache.ignite.messaging.MessagingListenActor; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link org.apache.ignite.IgniteCluster}. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridSelfTest extends ClusterGroupAbstractTest { /** Nodes count. */ private static final int NODES_CNT = 4; @@ -65,6 +69,7 @@ public class GridSelfTest extends ClusterGroupAbstractTest { } /** {@inheritDoc} */ + @Test @Override public void testRemoteNodes() throws Exception { int size = remoteNodeIds().size(); @@ -85,6 +90,7 @@ public class GridSelfTest extends ClusterGroupAbstractTest { } /** {@inheritDoc} */ + @Test @Override public void testRemoteProjection() throws Exception { ClusterGroup remotePrj = projection().forRemotes(); @@ -109,7 +115,7 @@ public class GridSelfTest extends ClusterGroupAbstractTest { /** * @throws Exception If failed. */ - @SuppressWarnings({"TooBroadScope"}) + @Test public void testAsyncListen() throws Exception { final String hello = "HELLO!"; @@ -155,6 +161,7 @@ public void testAsyncListen() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForOthers() throws Exception { ClusterNode node0 = grid(0).localNode(); ClusterNode node1 = grid(1).localNode(); @@ -171,4 +178,4 @@ public void testForOthers() throws Exception { assertEquals(1, grid(0).cluster().forOthers(node1, node2, node3).nodes().size()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridSpiExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridSpiExceptionSelfTest.java index a588ce0dd2e99..beef7a0d38f6d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridSpiExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridSpiExceptionSelfTest.java @@ -36,11 +36,15 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests exceptions that are thrown by event storage and deployment spi. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridSpiExceptionSelfTest extends GridCommonAbstractTest { /** */ private static final String TEST_MSG = "Test exception message"; @@ -66,6 +70,7 @@ public GridSpiExceptionSelfTest() { /** * @throws Exception If failed. */ + @Test public void testSpiFail() throws Exception { Ignite ignite = startGrid(); @@ -182,4 +187,4 @@ private static class GridTestSpiException extends IgniteSpiException { super(msg, cause); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridStartStopSelfTest.java index 32f7a21810979..1f664f7531735 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridStartStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridStartStopSelfTest.java @@ -18,10 +18,8 @@ package org.apache.ignite.internal; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -36,7 +34,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.apache.ignite.transactions.Transaction; -import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP; @@ -47,8 +47,9 @@ /** * Checks basic node start/stop operations. */ -@SuppressWarnings({"CatchGenericClass", "InstanceofCatchParameter"}) +@SuppressWarnings({"InstanceofCatchParameter"}) @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridStartStopSelfTest extends GridCommonAbstractTest { /** */ public static final int COUNT = 1; @@ -60,6 +61,7 @@ public class GridStartStopSelfTest extends GridCommonAbstractTest { /** */ + @Test public void testStartStop() { IgniteConfiguration cfg = new IgniteConfiguration(); @@ -81,6 +83,7 @@ public void testStartStop() { /** * @throws Exception If failed. */ + @Test public void testStopWhileInUse() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); @@ -148,6 +151,7 @@ public void testStopWhileInUse() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStoppedState() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); @@ -221,4 +225,4 @@ public void testStoppedState() throws Exception { assertTrue(errs, errs == null || errs.isEmpty()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridStopWithCancelSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridStopWithCancelSelfTest.java index 5cc9e9b6728cd..e621d88acd2ef 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridStopWithCancelSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridStopWithCancelSelfTest.java @@ -33,11 +33,15 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests grid stop with jobs canceling. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridStopWithCancelSelfTest extends GridCommonAbstractTest { /** */ private static CountDownLatch cnt; @@ -60,6 +64,7 @@ public GridStopWithCancelSelfTest() { /** * @throws Exception If an error occurs. */ + @Test public void testStopGrid() throws Exception { cancelCorrect = false; @@ -125,4 +130,4 @@ public static final class CancelledTask extends ComputeTaskAdapter nodeRef = new AtomicReference<>(null); @@ -79,6 +83,7 @@ public GridStopWithWaitSelfTest() { /** * @throws Exception If failed. */ + @Test public void testWait() throws Exception { jobStarted = new CountDownLatch(1); @@ -113,6 +118,7 @@ public void testWait() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWaitFailover() throws Exception { jobStarted = new CountDownLatch(1); @@ -278,4 +284,4 @@ private static class JobFailTask implements ComputeTask { return res.get(0).getData(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskCancelSingleNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskCancelSingleNodeSelfTest.java index 950f89db09c24..22bfc7b0d4066 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskCancelSingleNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskCancelSingleNodeSelfTest.java @@ -38,6 +38,9 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_JOB_CANCELLED; import static org.apache.ignite.events.EventType.EVT_JOB_FINISHED; @@ -47,6 +50,7 @@ /** * Test for task cancellation issue. */ +@RunWith(JUnit4.class) public class GridTaskCancelSingleNodeSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { @@ -61,6 +65,7 @@ public class GridTaskCancelSingleNodeSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testImmediateCancellation() throws Exception { checkCancellation(0L); } @@ -68,6 +73,7 @@ public void testImmediateCancellation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCancellation() throws Exception { checkCancellation(2000L); } @@ -203,4 +209,4 @@ private static class TestTask extends ComputeTaskSplitAdapter { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskContinuousMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskContinuousMapperSelfTest.java index 8f551b6f002bd..42a3b5db8b6f5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskContinuousMapperSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskContinuousMapperSelfTest.java @@ -38,15 +38,20 @@ import org.apache.ignite.resources.TaskContinuousMapperResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * {@link org.apache.ignite.compute.ComputeTaskContinuousMapper} test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridTaskContinuousMapperSelfTest extends GridCommonAbstractTest { /** * @throws Exception If test failed. */ + @Test public void testContinuousMapperMethods() throws Exception { try { Ignite ignite = startGrid(0); @@ -63,6 +68,7 @@ public void testContinuousMapperMethods() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testContinuousMapperLifeCycle() throws Exception { try { Ignite ignite = startGrid(0); @@ -77,6 +83,7 @@ public void testContinuousMapperLifeCycle() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testContinuousMapperNegative() throws Exception { try { Ignite ignite = startGrid(0); @@ -340,4 +347,4 @@ public TestJob(int idx) { return argument(0); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionContextSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionContextSelfTest.java index c31c80508f58f..2f8ce1da6290b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionContextSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionContextSelfTest.java @@ -35,10 +35,14 @@ import org.apache.ignite.resources.TaskSessionResource; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@code GridProjection.withXXX(..)} methods. */ +@RunWith(JUnit4.class) public class GridTaskExecutionContextSelfTest extends GridCommonAbstractTest { /** */ private static final AtomicInteger CNT = new AtomicInteger(); @@ -56,6 +60,7 @@ public class GridTaskExecutionContextSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testWithName() throws Exception { IgniteCallable f = new IgniteCallable() { @TaskSessionResource @@ -80,6 +85,7 @@ public void testWithName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithNoFailoverClosure() throws Exception { final IgniteRunnable r = new GridAbsClosureX() { @Override public void applyx() { @@ -110,6 +116,7 @@ public void testWithNoFailoverClosure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithNoFailoverTask() throws Exception { final Ignite g = grid(0); @@ -165,4 +172,4 @@ private TestTask(boolean fail) { return F.first(results).getData(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java index e197908c15ec2..465a15d854e76 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java @@ -33,11 +33,15 @@ import org.apache.ignite.resources.JobContextResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Task execution test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridTaskExecutionSelfTest extends GridCommonAbstractTest { /** Grid instance. */ private Ignite ignite; @@ -78,6 +82,7 @@ protected boolean peerClassLoadingEnabled() { /** * @throws Exception If failed. */ + @Test public void testSynchronousExecute() throws Exception { ComputeTaskFuture fut = ignite.compute().executeAsync(GridTestTask.class, "testArg"); @@ -91,6 +96,7 @@ public void testSynchronousExecute() throws Exception { * * @throws Exception If failed. */ + @Test public void testJobIdCollision() throws Exception { fail("Test refactoring is needed: https://issues.apache.org/jira/browse/IGNITE-4706"); @@ -155,6 +161,7 @@ public void testJobIdCollision() throws Exception { * * @throws Exception If failed. */ + @Test public void testExecuteTaskWithInvalidName() throws Exception { try { ComputeTaskFuture fut = ignite.compute().execute("invalid.task.name", null); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java index 1358936a7a100..0d154620a3925 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java @@ -29,10 +29,11 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -41,10 +42,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridTaskFailoverAffinityRunTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean clientMode; @@ -52,8 +51,6 @@ public class GridTaskFailoverAffinityRunTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); boolean client = clientMode && igniteInstanceName.equals(getTestIgniteInstanceName(0)); @@ -86,6 +83,7 @@ public class GridTaskFailoverAffinityRunTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNodeRestart() throws Exception { clientMode = false; @@ -95,6 +93,7 @@ public void testNodeRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeRestartClient() throws Exception { clientMode = true; @@ -169,4 +168,4 @@ private static class TestJob implements IgniteCallable { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverSelfTest.java index 77368956d4391..101c5adb634b2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverSelfTest.java @@ -32,11 +32,15 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for task failover. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridTaskFailoverSelfTest extends GridCommonAbstractTest { /** Don't change it value. */ public static final int SPLIT_COUNT = 2; @@ -49,7 +53,7 @@ public GridTaskFailoverSelfTest() { /** * @throws Exception If test failed. */ - @SuppressWarnings("unchecked") + @Test public void testFailover() throws Exception { Ignite ignite = startGrid(); @@ -120,4 +124,4 @@ public static class GridFailoverTestTask extends ComputeTaskSplitAdapter { /** */ @LoggerResource @@ -220,4 +223,4 @@ public static class GridStopTestJob extends ComputeJobAdapter { return !Thread.currentThread().isInterrupted() ? 0 : 1; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstanceExecutionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstanceExecutionSelfTest.java index 2f153bbf70c6f..4bda43105d477 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstanceExecutionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstanceExecutionSelfTest.java @@ -30,12 +30,16 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Task instance execution test. */ @SuppressWarnings("PublicInnerClass") @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridTaskInstanceExecutionSelfTest extends GridCommonAbstractTest { /** */ private static Object testState; @@ -48,6 +52,7 @@ public GridTaskInstanceExecutionSelfTest() { /** * @throws Exception If failed. */ + @Test public void testSynchronousExecute() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -120,4 +125,4 @@ public Object getState() { return super.reduce(results); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstantiationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstantiationSelfTest.java index b50bcb6f20a55..1e9b2b75de7fd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstantiationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstantiationSelfTest.java @@ -32,12 +32,16 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests instantiation of various task types (defined as private inner class, without default constructor, non-public * default constructor). */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridTaskInstantiationSelfTest extends GridCommonAbstractTest { /** * Constructor. @@ -49,6 +53,7 @@ public GridTaskInstantiationSelfTest() { /** * @throws Exception If an error occurs. */ + @Test public void testTasksInstantiation() throws Exception { grid().compute().execute(PrivateClassTask.class, null); @@ -120,4 +125,4 @@ private NoDefaultConstructorTask(Object param) { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskJobRejectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskJobRejectSelfTest.java index a6678dadb2581..e5bc96694d08c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskJobRejectSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskJobRejectSelfTest.java @@ -35,6 +35,9 @@ import org.apache.ignite.spi.collision.fifoqueue.FifoQueueCollisionSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.events.EventType.EVTS_JOB_EXECUTION; @@ -47,6 +50,7 @@ /** * Test that rejected job is not failed over. */ +@RunWith(JUnit4.class) public class GridTaskJobRejectSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -70,6 +74,7 @@ public class GridTaskJobRejectSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testReject() throws Exception { grid(1).events().localListen(new IgnitePredicate() { @Override public boolean apply(Event evt) { @@ -156,4 +161,4 @@ private static final class SleepJob extends ComputeJobAdapter { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskListenerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskListenerSelfTest.java index 3cf9ef8a8086a..3505c4a2ff138 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskListenerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskListenerSelfTest.java @@ -34,12 +34,15 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * This test checks that GridTaskListener is only called once per task. */ -@SuppressWarnings("deprecation") @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridTaskListenerSelfTest extends GridCommonAbstractTest { /** */ public GridTaskListenerSelfTest() { @@ -51,7 +54,8 @@ public GridTaskListenerSelfTest() { * * @throws Exception If failed. */ - @SuppressWarnings({"BusyWait", "unchecked"}) + @SuppressWarnings({"BusyWait"}) + @Test public void testGridTaskListener() throws Exception { final AtomicInteger cnt = new AtomicInteger(0); @@ -111,4 +115,4 @@ private static class TestTask extends ComputeTaskSplitAdapter { return 1; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectServicesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectServicesTest.java index 1e6dd64f970b2..98803e0f18888 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectServicesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectServicesTest.java @@ -30,10 +30,14 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteClientReconnectServicesTest extends IgniteClientReconnectAbstractTest { /** {@inheritDoc} */ @Override protected int serverCount() { @@ -48,6 +52,7 @@ public class IgniteClientReconnectServicesTest extends IgniteClientReconnectAbst /** * @throws Exception If failed. */ + @Test public void testReconnect() throws Exception { Ignite client = grid(serverCount()); @@ -83,6 +88,7 @@ public void testReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServiceRemove() throws Exception { Ignite client = grid(serverCount()); @@ -125,6 +131,7 @@ public void testServiceRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectInDeploying() throws Exception { Ignite client = grid(serverCount()); @@ -172,6 +179,7 @@ public void testReconnectInDeploying() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectInProgress() throws Exception { Ignite client = grid(serverCount()); @@ -262,4 +270,4 @@ public static class TestServiceImpl implements Service, TestService { return ignite.cluster().topologyVersion(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectStopTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectStopTest.java index b5c3ee86d0d4a..f83b5d80c94ff 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectStopTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectStopTest.java @@ -27,6 +27,9 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.discovery.DiscoverySpi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED; import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_RECONNECTED; @@ -34,6 +37,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteClientReconnectStopTest extends IgniteClientReconnectAbstractTest { /** {@inheritDoc} */ @Override protected int serverCount() { @@ -43,6 +47,7 @@ public class IgniteClientReconnectStopTest extends IgniteClientReconnectAbstract /** * @throws Exception If failed. */ + @Test public void testStopWhenDisconnected() throws Exception { clientMode = true; @@ -112,4 +117,4 @@ public void testStopWhenDisconnected() throws Exception { log.info("Expected reconnect exception: " + e); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectStreamerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectStreamerTest.java index 36b989093440e..88a38b64b790f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectStreamerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectStreamerTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.internal.processors.datastreamer.DataStreamerResponse; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -36,6 +39,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteClientReconnectStreamerTest extends IgniteClientReconnectAbstractTest { /** */ public static final String CACHE_NAME = "streamer"; @@ -66,6 +70,7 @@ public class IgniteClientReconnectStreamerTest extends IgniteClientReconnectAbst /** * @throws Exception If failed. */ + @Test public void testStreamerReconnect() throws Exception { final Ignite client = grid(serverCount()); @@ -130,6 +135,7 @@ public void testStreamerReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStreamerReconnectInProgress() throws Exception { Ignite client = grid(serverCount()); @@ -234,4 +240,4 @@ private void checkStreamerClosed(IgniteDataStreamer streamer) streamer.close(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientRejoinTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientRejoinTest.java index 8744465402ce4..53fd4eb44b1fa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientRejoinTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientRejoinTest.java @@ -49,10 +49,14 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests client to be able restore connection to cluster if coordination is not available. */ +@RunWith(JUnit4.class) public class IgniteClientRejoinTest extends GridCommonAbstractTest { /** Block. */ private volatile boolean block; @@ -115,6 +119,7 @@ public class IgniteClientRejoinTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testClientsReconnectAfterStart() throws Exception { Ignite srv1 = startGrid("server1"); @@ -192,6 +197,7 @@ public void testClientsReconnectAfterStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientsReconnect() throws Exception { Ignite srv1 = startGrid("server1"); @@ -268,6 +274,7 @@ public void testClientsReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientsReconnectDisabled() throws Exception { clientReconnectDisabled = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeEmptyClusterGroupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeEmptyClusterGroupTest.java index f346b8edbfce9..68c1b1a4c7366 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeEmptyClusterGroupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeEmptyClusterGroupTest.java @@ -28,31 +28,23 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public class IgniteComputeEmptyClusterGroupTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - CacheConfiguration ccfg = defaultCacheConfiguration(); ccfg.setCacheMode(PARTITIONED); @@ -70,6 +62,7 @@ public class IgniteComputeEmptyClusterGroupTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAsync() throws Exception { ClusterGroup empty = ignite(0).cluster().forNodeId(UUID.randomUUID()); @@ -89,6 +82,7 @@ public void testAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSync() throws Exception { ClusterGroup empty = ignite(0).cluster().forNodeId(UUID.randomUUID()); @@ -177,4 +171,4 @@ private static class FailCallable implements IgniteCallable { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeJobOneThreadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeJobOneThreadTest.java index 76f669e5eadf7..8d1b44437539b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeJobOneThreadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeJobOneThreadTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.spi.collision.fifoqueue.FifoQueueCollisionSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test of absence of gaps between jobs in compute */ +@RunWith(JUnit4.class) public class IgniteComputeJobOneThreadTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { FifoQueueCollisionSpi colSpi = new FifoQueueCollisionSpi(); @@ -55,6 +59,7 @@ public class IgniteComputeJobOneThreadTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNoTimeout() throws Exception { Ignite ignite = ignite(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeResultExceptionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeResultExceptionTest.java index fab5de6d25229..59a476cc178b7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeResultExceptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeResultExceptionTest.java @@ -31,38 +31,48 @@ import org.apache.ignite.compute.ComputeTaskFuture; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Testing that if {@link ComputeTask#result(ComputeJobResult, List)} throws an {@link IgniteException} * then that exception is thrown as the execution result. */ +@RunWith(JUnit4.class) public class IgniteComputeResultExceptionTest extends GridCommonAbstractTest { /** */ + @Test public void testIgniteExceptionExecute() throws Exception { checkExecuteException(new IgniteException()); } /** */ + @Test public void testIgniteExceptionWithCauseExecute() throws Exception { checkExecuteException(new IgniteException(new Exception())); } /** */ + @Test public void testIgniteExceptionWithCauseChainExecute() throws Exception { checkExecuteException(new IgniteException(new Exception(new Throwable()))); } /** */ + @Test public void testCustomExceptionExecute() throws Exception { checkExecuteException(new TaskException()); } /** */ + @Test public void testCustomExceptionWithCauseExecute() throws Exception { checkExecuteException(new TaskException(new Exception())); } /** */ + @Test public void testCustomExceptionWithCauseChainExecute() throws Exception { checkExecuteException(new TaskException(new Exception(new Throwable()))); } @@ -80,32 +90,38 @@ private void checkExecuteException(IgniteException resE) throws Exception { } /** */ + @Test public void testIgniteExceptionExecuteAsync() throws Exception { checkExecuteAsyncException(new IgniteException()); } /** */ + @Test public void testIgniteExceptionWithCauseExecuteAsync() throws Exception { checkExecuteAsyncException(new IgniteException(new Exception())); } /** */ + @Test public void testIgniteExceptionWithCauseChainExecuteAsync() throws Exception { checkExecuteAsyncException(new IgniteException(new Exception(new Throwable()))); } /** */ + @Test public void testCustomExceptionExecuteAsync() throws Exception { checkExecuteAsyncException(new TaskException()); } /** */ + @Test public void testCustomExceptionWithCauseExecuteAsync() throws Exception { checkExecuteAsyncException(new TaskException(new Exception())); } /** */ + @Test public void testCustomExceptionWithCauseChainExecuteAsync() throws Exception { checkExecuteAsyncException(new TaskException(new Exception(new Throwable()))); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeTopologyExceptionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeTopologyExceptionTest.java index a82373b618507..583b9e42a4293 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeTopologyExceptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeTopologyExceptionTest.java @@ -26,12 +26,16 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.GridClosureCallMode.BALANCE; /** * */ +@RunWith(JUnit4.class) public class IgniteComputeTopologyExceptionTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { @@ -46,6 +50,7 @@ public class IgniteComputeTopologyExceptionTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCorrectException() throws Exception { Ignite ignite = ignite(0); @@ -72,6 +77,7 @@ public void testCorrectException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCorrectCheckedException() throws Exception { IgniteKernal ignite0 = (IgniteKernal)ignite(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteConcurrentEntryProcessorAccessStopTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteConcurrentEntryProcessorAccessStopTest.java index af65ffba2f51a..ac2e1e8d52364 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteConcurrentEntryProcessorAccessStopTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteConcurrentEntryProcessorAccessStopTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests node stop while it is being accessed from EntryProcessor. */ +@RunWith(JUnit4.class) public class IgniteConcurrentEntryProcessorAccessStopTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -38,6 +42,7 @@ public class IgniteConcurrentEntryProcessorAccessStopTest extends GridCommonAbst * * @throws Exception If failed. */ + @Test public void testConcurrentAccess() throws Exception { CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteConnectionConcurrentReserveAndRemoveTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteConnectionConcurrentReserveAndRemoveTest.java index fb194491b7c6b..3ca51de7fc330 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteConnectionConcurrentReserveAndRemoveTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteConnectionConcurrentReserveAndRemoveTest.java @@ -31,17 +31,15 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.communication.tcp.messages.HandshakeMessage2; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class IgniteConnectionConcurrentReserveAndRemoveTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -53,12 +51,6 @@ public class IgniteConnectionConcurrentReserveAndRemoveTest extends GridCommonAb c.setClientMode(igniteInstanceName.startsWith("client")); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - TestRecordingCommunicationSpi spi = new TestRecordingCommunicationSpi(); spi.setIdleConnectionTimeout(Integer.MAX_VALUE); @@ -79,6 +71,7 @@ private static final class TestClosure implements IgniteCallable { } + @Test public void test() throws Exception { IgniteEx svr = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteDiscoveryMassiveNodeFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteDiscoveryMassiveNodeFailTest.java index 32ce9783c0332..50b771bc7f9dd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteDiscoveryMassiveNodeFailTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteDiscoveryMassiveNodeFailTest.java @@ -38,12 +38,16 @@ import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests checks case when one node is unable to connect to next in a ring, * but those nodes are not experiencing any connectivity troubles between * each other. */ +@RunWith(JUnit4.class) public class IgniteDiscoveryMassiveNodeFailTest extends GridCommonAbstractTest { /** */ private static final int FAILURE_DETECTION_TIMEOUT = 5_000; @@ -118,6 +122,7 @@ public class IgniteDiscoveryMassiveNodeFailTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testMassiveFailDisabledRecovery() throws Exception { timeout = 0; // Disable previous node check. @@ -176,6 +181,7 @@ private long waitTime() { * * @throws Exception If failed. */ + @Test public void testMassiveFailSelfKill() throws Exception { startGrids(5); @@ -211,6 +217,7 @@ public void testMassiveFailSelfKill() throws Exception { * * @throws Exception If failed. */ + @Test public void testMassiveFailAndRecovery() throws Exception { startGrids(5); @@ -254,6 +261,7 @@ public void testMassiveFailAndRecovery() throws Exception { * * @throws Exception If failed. */ + @Test public void testMassiveFail() throws Exception { failNodes = true; @@ -270,6 +278,7 @@ public void testMassiveFail() throws Exception { * * @throws Exception If failed. */ + @Test public void testMassiveFailForceNodeFail() throws Exception { failNodes = true; @@ -285,6 +294,7 @@ public void testMassiveFailForceNodeFail() throws Exception { * * @throws Exception If failed. */ + @Test public void testRecoveryOnDisconnect() throws Exception { startGrids(3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteExecutorServiceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteExecutorServiceTest.java index 19f46fae56084..c7b0cf83b2237 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteExecutorServiceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteExecutorServiceTest.java @@ -32,11 +32,15 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid distributed executor test. */ @GridCommonTest(group = "Thread Tests") +@RunWith(JUnit4.class) public class IgniteExecutorServiceTest extends GridCommonAbstractTest { /** */ public IgniteExecutorServiceTest() { @@ -46,6 +50,7 @@ public IgniteExecutorServiceTest() { /** * @throws Exception Thrown in case of test failure. */ + @Test public void testExecute() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -70,6 +75,7 @@ public void testExecute() throws Exception { /** * @throws Exception Thrown in case of test failure. */ + @Test public void testSubmit() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -107,6 +113,7 @@ public void testSubmit() throws Exception { /** * @throws Exception Thrown in case of test failure. */ + @Test public void testSubmitWithFutureTimeout() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -134,6 +141,7 @@ public void testSubmitWithFutureTimeout() throws Exception { * @throws Exception Thrown in case of test failure. */ @SuppressWarnings("TooBroadScope") + @Test public void testInvokeAll() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -164,7 +172,7 @@ public void testInvokeAll() throws Exception { /** * @throws Exception Thrown in case of test failure. */ - @SuppressWarnings("TooBroadScope") + @Test public void testInvokeAllWithTimeout() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -211,6 +219,7 @@ public void testInvokeAllWithTimeout() throws Exception { * @throws Exception Thrown in case of test failure. */ @SuppressWarnings("TooBroadScope") + @Test public void testInvokeAny() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -236,7 +245,7 @@ public void testInvokeAny() throws Exception { /** * @throws Exception Thrown in case of test failure. */ - @SuppressWarnings("TooBroadScope") + @Test public void testInvokeAnyWithTimeout() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -317,4 +326,4 @@ private static class TestRunnable implements Runnable, Serializable { assert ignite != null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteExplicitImplicitDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteExplicitImplicitDeploymentSelfTest.java index 1b253ed821644..a6f0ba52665d5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteExplicitImplicitDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteExplicitImplicitDeploymentSelfTest.java @@ -46,11 +46,15 @@ import org.apache.ignite.testframework.GridTestClassLoader; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class IgniteExplicitImplicitDeploymentSelfTest extends GridCommonAbstractTest { /** */ public IgniteExplicitImplicitDeploymentSelfTest() { @@ -73,6 +77,7 @@ public IgniteExplicitImplicitDeploymentSelfTest() { /** * @throws Exception If test failed. */ + @Test public void testImplicitDeployLocally() throws Exception { execImplicitDeployLocally(true, true, true); } @@ -80,6 +85,7 @@ public void testImplicitDeployLocally() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testImplicitDeployP2P() throws Exception { execImplicitDeployP2P(true, true, true); } @@ -87,6 +93,7 @@ public void testImplicitDeployP2P() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testExplicitDeployLocally() throws Exception { execExplicitDeployLocally(true, true, true); } @@ -94,6 +101,7 @@ public void testExplicitDeployLocally() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testExplicitDeployP2P() throws Exception { execExplicitDeployP2P(true, true, true); } @@ -490,4 +498,4 @@ public static final class GridDeploymentResourceTestJob extends ComputeJobAdapte } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteInternalCacheRemoveTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteInternalCacheRemoveTest.java index ce45dc2e5c644..9ea04bc7dbefe 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteInternalCacheRemoveTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteInternalCacheRemoveTest.java @@ -19,10 +19,14 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteInternalCacheRemoveTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -32,10 +36,11 @@ public class IgniteInternalCacheRemoveTest extends GridCacheAbstractSelfTest { /** * @throws IgniteCheckedException If failed. */ + @Test public void testRemove() throws IgniteCheckedException { jcache().put("key", 1); assert jcache().remove("key", 1); assert !jcache().remove("key", 1); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteLocalNodeMapBeforeStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteLocalNodeMapBeforeStartTest.java index 7eae2ce2e6f37..e331bfb9b7a44 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteLocalNodeMapBeforeStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteLocalNodeMapBeforeStartTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.lifecycle.LifecycleEventType; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.lifecycle.LifecycleEventType.AFTER_NODE_START; import static org.apache.ignite.lifecycle.LifecycleEventType.AFTER_NODE_STOP; @@ -35,10 +38,12 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteLocalNodeMapBeforeStartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNodeLocalMapFromLifecycleBean() throws Exception { IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(0)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteReflectionFactorySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteReflectionFactorySelfTest.java index 899728c66a56d..b9207c6e0e222 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteReflectionFactorySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteReflectionFactorySelfTest.java @@ -20,16 +20,19 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; -import junit.framework.TestCase; import org.apache.ignite.configuration.IgniteReflectionFactory; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; /** * Tests for {@link IgniteReflectionFactory} class. */ -public class IgniteReflectionFactorySelfTest extends TestCase { +public class IgniteReflectionFactorySelfTest { /** * @throws Exception If failed. */ + @Test public void testByteMethod() throws Exception { byte expByteVal = 42; short expShortVal = 42; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java index 00a33a61ab656..b1ebbfea16fcb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test to reproduce IGNITE-4060. */ +@RunWith(JUnit4.class) public class IgniteRoundRobinErrorAfterClientReconnectTest extends GridCommonAbstractTest { /** Server index. */ private static final int SRV_IDX = 0; @@ -65,6 +69,7 @@ public class IgniteRoundRobinErrorAfterClientReconnectTest extends GridCommonAbs /** * @throws Exception If failed. */ + @Test public void testClientReconnect() throws Exception { final Ignite cli = grid(CLI_IDX); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteSlowClientDetectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteSlowClientDetectionSelfTest.java index d7387845c6e5d..2993d2144852b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteSlowClientDetectionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteSlowClientDetectionSelfTest.java @@ -37,23 +37,22 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; /** * */ +@RunWith(JUnit4.class) public class IgniteSlowClientDetectionSelfTest extends GridCommonAbstractTest { /** */ public static final String PARTITIONED = "partitioned"; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * @return Node count. */ @@ -65,7 +64,6 @@ private int nodeCount() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setClientReconnectDisabled(true); if (getTestIgniteInstanceName(nodeCount() - 1).equals(igniteInstanceName) || @@ -99,6 +97,7 @@ private int nodeCount() { /** * @throws Exception If failed. */ + @Test public void testSlowClient() throws Exception { final IgniteEx slowClient = grid(nodeCount() - 1); @@ -189,4 +188,4 @@ private static class Listener implements CacheEntryUpdatedListener>>> Received update: " + iterable); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java index a348ea555b4fe..fb6cde39136eb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteUpdateNotifierPerClusterSettingSelfTest.java @@ -21,18 +21,16 @@ import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cluster.ClusterProcessor; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class IgniteUpdateNotifierPerClusterSettingSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private String backup; @@ -55,8 +53,6 @@ public class IgniteUpdateNotifierPerClusterSettingSelfTest extends GridCommonAbs @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -65,6 +61,7 @@ public class IgniteUpdateNotifierPerClusterSettingSelfTest extends GridCommonAbs /** * @throws Exception If failed. */ + @Test public void testNotifierEnabledForCluster() throws Exception { checkNotifierStatusForCluster(true); } @@ -72,6 +69,7 @@ public void testNotifierEnabledForCluster() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotifierDisabledForCluster() throws Exception { checkNotifierStatusForCluster(false); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteVersionUtilsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteVersionUtilsSelfTest.java new file mode 100644 index 0000000000000..95624de55b539 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteVersionUtilsSelfTest.java @@ -0,0 +1,41 @@ +/* + * 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. + */ + +package org.apache.ignite.internal; + +import java.util.Calendar; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + */ +@RunWith(JUnit4.class) +public class IgniteVersionUtilsSelfTest extends GridCommonAbstractTest { + /** + * @throws Exception If failed. + */ + @Test + public void testIgniteCopyrights() throws Exception { + final String COPYRIGHT = String.valueOf(Calendar.getInstance().get(Calendar.YEAR)) + " Copyright(C) Apache Software Foundation"; + + assertNotNull(IgniteVersionUtils.COPYRIGHT); + + assertTrue(COPYRIGHT.equals(IgniteVersionUtils.COPYRIGHT)); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/LongJVMPauseDetectorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/LongJVMPauseDetectorTest.java index 267f389bdc1e9..34a58e69ffc7f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/LongJVMPauseDetectorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/LongJVMPauseDetectorTest.java @@ -20,10 +20,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests if LongJVMPauseDetector starts properly. */ +@RunWith(JUnit4.class) public class LongJVMPauseDetectorTest extends GridCommonAbstractTest { /** */ private GridStringLogger strLog; @@ -46,6 +50,7 @@ public class LongJVMPauseDetectorTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testJulMessage() throws Exception { this.strLog = new GridStringLogger(true); @@ -59,6 +64,7 @@ public void testJulMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopWorkerThread() throws Exception { strLog = new GridStringLogger(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java index f31a56da46975..1f153064b6683 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/MarshallerContextLockingSelfTest.java @@ -35,12 +35,16 @@ import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.MarshallerPlatformIds.JAVA_ID; /** * Test marshaller context. */ +@RunWith(JUnit4.class) public class MarshallerContextLockingSelfTest extends GridCommonAbstractTest { /** Inner logger. */ private InnerLogger innerLog; @@ -73,6 +77,7 @@ public class MarshallerContextLockingSelfTest extends GridCommonAbstractTest { /** * Multithreaded test, used custom class loader */ + @Test public void testMultithreadedUpdate() throws Exception { multithreaded(new Callable() { @Override public Object call() throws Exception { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/MemoryLeaksOnRestartNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/MemoryLeaksOnRestartNodeTest.java index bf0c91104fb53..88fc226e2d479 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/MemoryLeaksOnRestartNodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/MemoryLeaksOnRestartNodeTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.internal.util.GridDebug; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests leaks on node restart with enabled persistence. */ +@RunWith(JUnit4.class) public class MemoryLeaksOnRestartNodeTest extends GridCommonAbstractTest { /** Heap dump file name. */ private static final String HEAP_DUMP_FILE_NAME = "test.hprof"; @@ -70,6 +74,7 @@ public class MemoryLeaksOnRestartNodeTest extends GridCommonAbstractTest { /** * @throws Exception On failed. */ + @Test public void test() throws Exception { // Warmup for (int i = 0; i < RESTARTS / 2; ++i) { @@ -108,4 +113,4 @@ public void test() throws Exception { // Remove dump if successful. dumpFile.delete(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TaskNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/TaskNodeRestartTest.java index 7cab4e6dc8423..b8b0c6c2ef2ec 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/TaskNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/TaskNodeRestartTest.java @@ -37,20 +37,18 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class TaskNodeRestartTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 3; @@ -60,8 +58,6 @@ public class TaskNodeRestartTest extends GridCommonAbstractTest { ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - return cfg; } @@ -75,6 +71,7 @@ public class TaskNodeRestartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTaskNodeRestart() throws Exception { final AtomicBoolean finished = new AtomicBoolean(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestManagementVisorMultiNodeTask.java b/modules/core/src/test/java/org/apache/ignite/internal/TestManagementVisorMultiNodeTask.java new file mode 100644 index 0000000000000..beccd799043dd --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/TestManagementVisorMultiNodeTask.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +package org.apache.ignite.internal; + +import java.util.List; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorMultiNodeTask; +import org.apache.ignite.internal.visor.VisorTaskArgument; +import org.jetbrains.annotations.Nullable; + +/** + * + */ +@GridVisorManagementTask +public class TestManagementVisorMultiNodeTask extends VisorMultiNodeTask { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorValidMultiNodeJob job(VisorTaskArgument arg) { + return new VisorValidMultiNodeJob(arg, debug); + } + + /** {@inheritDoc} */ + @Nullable @Override protected Object reduce0(List results) { + return null; + } + + /** + * Valid Management multi node visor job. + */ + private static class VisorValidMultiNodeJob extends VisorJob { + /** */ + private static final long serialVersionUID = 0L; + + /** + * @param arg Argument. + * @param debug Debug flag. + */ + protected VisorValidMultiNodeJob(VisorTaskArgument arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected Object run(VisorTaskArgument arg) { + return null; + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestManagementVisorOneNodeTask.java b/modules/core/src/test/java/org/apache/ignite/internal/TestManagementVisorOneNodeTask.java new file mode 100644 index 0000000000000..f7479af08b19b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/TestManagementVisorOneNodeTask.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +package org.apache.ignite.internal; + +import java.util.List; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorOneNodeTask; +import org.apache.ignite.internal.visor.VisorTaskArgument; +import org.jetbrains.annotations.Nullable; + +/** + * + */ +@GridVisorManagementTask +public class TestManagementVisorOneNodeTask extends VisorOneNodeTask { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorValidOneNodeJob job(VisorTaskArgument arg) { + return new VisorValidOneNodeJob(arg, debug); + } + + /** {@inheritDoc} */ + @Nullable @Override protected Object reduce0(List results) { + return null; + } + + /** + * Valid Management one node visor job. + */ + private static class VisorValidOneNodeJob extends VisorJob { + /** */ + private static final long serialVersionUID = 0L; + + /** + * @param arg Argument. + * @param debug Debug flag. + */ + protected VisorValidOneNodeJob(VisorTaskArgument arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected Object run(VisorTaskArgument arg) { + return null; + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestNotManagementVisorMultiNodeTask.java b/modules/core/src/test/java/org/apache/ignite/internal/TestNotManagementVisorMultiNodeTask.java new file mode 100644 index 0000000000000..d8f279363385f --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/TestNotManagementVisorMultiNodeTask.java @@ -0,0 +1,64 @@ +/* + * 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. + */ + +package org.apache.ignite.internal; + +import java.util.List; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorMultiNodeTask; +import org.apache.ignite.internal.visor.VisorTaskArgument; +import org.jetbrains.annotations.Nullable; + +/** + * + */ +public class TestNotManagementVisorMultiNodeTask extends VisorMultiNodeTask { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorNotManagementMultiNodeJob job(VisorTaskArgument arg) { + return new VisorNotManagementMultiNodeJob(arg, debug); + } + + /** {@inheritDoc} */ + @Nullable @Override protected Object reduce0(List results) { + return null; + } + + /** + * Not management multi node visor job. + */ + private static class VisorNotManagementMultiNodeJob extends VisorJob { + /** */ + private static final long serialVersionUID = 0L; + + /** + * @param arg Argument. + * @param debug Debug flag. + */ + protected VisorNotManagementMultiNodeJob(VisorTaskArgument arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected Object run(VisorTaskArgument arg) { + return null; + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestNotManagementVisorOneNodeTask.java b/modules/core/src/test/java/org/apache/ignite/internal/TestNotManagementVisorOneNodeTask.java new file mode 100644 index 0000000000000..ea47ee09be730 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/TestNotManagementVisorOneNodeTask.java @@ -0,0 +1,64 @@ +/* + * 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. + */ + +package org.apache.ignite.internal; + +import java.util.List; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorOneNodeTask; +import org.apache.ignite.internal.visor.VisorTaskArgument; +import org.jetbrains.annotations.Nullable; + +/** + * + */ +public class TestNotManagementVisorOneNodeTask extends VisorOneNodeTask { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorNotManagementOneNodeJob job(VisorTaskArgument arg) { + return new VisorNotManagementOneNodeJob(arg, debug); + } + + /** {@inheritDoc} */ + @Nullable @Override protected Object reduce0(List results) { + return null; + } + + /** + * Not management one node visor job. + */ + private static class VisorNotManagementOneNodeJob extends VisorJob { + /** */ + private static final long serialVersionUID = 0L; + + /** + * @param arg Argument. + * @param debug Debug flag. + */ + protected VisorNotManagementOneNodeJob(VisorTaskArgument arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected Object run(VisorTaskArgument arg) { + return null; + } + } +} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java index 7b68a6bfd8337..988395f473573 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java @@ -217,6 +217,26 @@ public void waitForBlocked(int size) throws InterruptedException { } } + /** + * @param size Size + * @param timeout Timeout. + * @throws InterruptedException + */ + public boolean waitForBlocked(int size, long timeout) throws InterruptedException { + long t0 = U.currentTimeMillis() + timeout; + + synchronized (this) { + while (blockedMsgs.size() < size) { + wait(1000); + + if (U.currentTimeMillis() >= t0) + return false; + } + } + + return true; + } + /** * @throws InterruptedException If interrupted. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TransactionMetricsMxBeanImplTest.java b/modules/core/src/test/java/org/apache/ignite/internal/TransactionMetricsMxBeanImplTest.java index 91bd9bcf98271..7a6c832f874b1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/TransactionMetricsMxBeanImplTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/TransactionMetricsMxBeanImplTest.java @@ -17,13 +17,13 @@ package org.apache.ignite.internal; -import javax.management.MBeanServer; -import javax.management.MBeanServerInvocationHandler; -import javax.management.ObjectName; import java.lang.management.ManagementFactory; import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; +import javax.management.MBeanServer; +import javax.management.MBeanServerInvocationHandler; +import javax.management.ObjectName; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheRebalanceMode; @@ -32,11 +32,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.mxbean.TransactionMetricsMxBean; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -46,10 +47,8 @@ /** * */ +@RunWith(JUnit4.class) public class TransactionMetricsMxBeanImplTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int TRANSACTIONS = 10; @@ -57,8 +56,6 @@ public class TransactionMetricsMxBeanImplTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { final IgniteConfiguration cfg = super.getConfiguration(name); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); cfg.setLocalHost("127.0.0.1"); @@ -81,9 +78,17 @@ public class TransactionMetricsMxBeanImplTest extends GridCommonAbstractTest { super.afterTest(); } + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.METRICS); + + super.beforeTestsStarted(); + } + /** * */ + @Test public void testTxMetric() throws Exception { //given: int keysNumber = 10; @@ -171,6 +176,7 @@ public void testTxMetric() throws Exception { /** * */ + @Test public void testNearTxInfo() throws Exception { IgniteEx primaryNode1 = startGrid(0); IgniteEx primaryNode2 = startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TransactionsMXBeanImplTest.java b/modules/core/src/test/java/org/apache/ignite/internal/TransactionsMXBeanImplTest.java index d358c72e79917..c8a91b0aa54d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/TransactionsMXBeanImplTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/TransactionsMXBeanImplTest.java @@ -27,10 +27,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.mxbean.TransactionsMXBean; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -38,10 +38,8 @@ /** * */ +@RunWith(JUnit4.class) public class TransactionsMXBeanImplTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -53,8 +51,6 @@ public class TransactionsMXBeanImplTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { final IgniteConfiguration cfg = super.getConfiguration(name); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); final CacheConfiguration cCfg = new CacheConfiguration() @@ -73,6 +69,7 @@ public class TransactionsMXBeanImplTest extends GridCommonAbstractTest { /** * */ + @Test public void testBasic() throws Exception { IgniteEx ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/VisorManagementEventSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/VisorManagementEventSelfTest.java new file mode 100644 index 0000000000000..3ebb79aebf074 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/VisorManagementEventSelfTest.java @@ -0,0 +1,200 @@ +/* + * 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. + */ + +package org.apache.ignite.internal; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.compute.ComputeTask; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.events.EventType; +import org.apache.ignite.events.TaskEvent; +import org.apache.ignite.internal.visor.VisorTaskArgument; +import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.events.EventType.EVT_MANAGEMENT_TASK_STARTED;; + +/** + * + */ +@RunWith(JUnit4.class) +public class VisorManagementEventSelfTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = new IgniteConfiguration(); + + // Enable visor management events. + cfg.setIncludeEventTypes( + EVT_MANAGEMENT_TASK_STARTED + ); + + cfg.setCacheConfiguration( + new CacheConfiguration() + .setName("TEST") + .setIndexedTypes(Integer.class, Integer.class) + .setStatisticsEnabled(true) + ); + + TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); + + List addrs = Arrays.asList("127.0.0.1:47500..47502"); + + ipFinder.setAddresses(addrs); + + TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); + + discoSpi.setIpFinder(ipFinder); + + cfg.setDiscoverySpi(discoSpi); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + super.afterTest(); + } + + /** + * Current test case start valid one node visor task that has GridVisorManagementTask annotation. + * No exceptions are expected. + * + * @throws Exception If failed. + */ + @Test + public void testManagementOneNodeVisorTask() throws Exception { + IgniteEx ignite = startGrid(0); + + doTestVisorTask(TestManagementVisorOneNodeTask.class, new VisorTaskArgument(), ignite); + } + + /** + * Current test case start valid multi node visor task that has GridVisorManagementTask annotation. + * No exceptions are expected. + * + * @throws Exception If failed. + */ + @Test + public void testManagementMultiNodeVisorTask() throws Exception { + IgniteEx ignite = startGrid(0); + + doTestVisorTask(TestManagementVisorMultiNodeTask.class, new VisorTaskArgument(), ignite); + } + + /** + * Current test case start one node visor task that has not GridVisorManagementTask annotation. + * No exceptions are expected. + * + * @throws Exception If failed. + */ + @Test + public void testNotManagementOneNodeVisorTask() throws Exception { + IgniteEx ignite = startGrid(0); + + doTestNotManagementVisorTask(TestNotManagementVisorOneNodeTask.class, new VisorTaskArgument(), ignite); + } + + /** + * Current test case start multi node visor task that has not GridVisorManagementTask annotation. + * No exceptions are expected. + * + * @throws Exception If failed. + */ + @Test + public void testNotManagementMultiNodeVisorTask() throws Exception { + IgniteEx ignite = startGrid(0); + + doTestNotManagementVisorTask(TestNotManagementVisorMultiNodeTask.class, new VisorTaskArgument(), ignite); + } + + /** + * @param cls class of the task. + * @param arg argument. + * @param ignite instance of Ignite. + * + * @throws Exception If failed. + */ + private void doTestVisorTask( + Class, R>> cls, T arg, IgniteEx ignite) throws Exception + { + final AtomicReference evt = new AtomicReference<>(); + + final CountDownLatch evtLatch = new CountDownLatch(1); + + ignite.events().localListen(new IgnitePredicate() { + @Override public boolean apply(TaskEvent e) { + evt.set(e); + + evtLatch.countDown(); + + return false; + } + }, EventType.EVT_MANAGEMENT_TASK_STARTED); + + for (ClusterNode node : ignite.cluster().forServers().nodes()) + ignite.compute().executeAsync(cls, new VisorTaskArgument<>(node.id(), arg, true)); + + assertTrue(evtLatch.await(10000, TimeUnit.MILLISECONDS)); + + assertNotNull(evt.get()); + } + + /** + * @param cls class of the task. + * @param arg argument. + * @param ignite instance of Ignite. + * + * @throws Exception If failed. + */ + private void doTestNotManagementVisorTask( + Class, R>> cls, T arg, IgniteEx ignite) throws Exception + { + final AtomicReference evt = new AtomicReference<>(); + + final CountDownLatch evtLatch = new CountDownLatch(1); + + ignite.events().localListen(new IgnitePredicate() { + @Override public boolean apply(TaskEvent e) { + evt.set(e); + + evtLatch.countDown(); + + return false; + } + }, EventType.EVT_MANAGEMENT_TASK_STARTED); + + for (ClusterNode node : ignite.cluster().forServers().nodes()) + ignite.compute().executeAsync(cls, new VisorTaskArgument<>(node.id(), arg, true)); + + assertFalse(evtLatch.await(10000, TimeUnit.MILLISECONDS)); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolverSelfTest.java index 27c39c3feaf52..f13d666eb10de 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolverSelfTest.java @@ -34,12 +34,16 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.junit.Assert.assertNotEquals; /** * Array identity resolver self test. */ +@RunWith(JUnit4.class) public class BinaryArrayIdentityResolverSelfTest extends GridCommonAbstractTest { /** Pointers to release. */ private final Set ptrs = new ConcurrentHashSet<>(); @@ -88,6 +92,7 @@ public class BinaryArrayIdentityResolverSelfTest extends GridCommonAbstractTest /** * Test hash code generation for simple object. */ + @Test public void testHashCode() { InnerClass obj = new InnerClass(1, "2", 3); @@ -99,6 +104,7 @@ public void testHashCode() { /** * Test hash code generation for simple object. */ + @Test public void testHashCodeBinarylizable() { InnerClassBinarylizable obj = new InnerClassBinarylizable(1, "2", 3); @@ -110,6 +116,7 @@ public void testHashCodeBinarylizable() { /** * Test equals for simple object. */ + @Test public void testEquals() { InnerClass obj = new InnerClass(1, "2", 3); @@ -128,6 +135,7 @@ public void testEquals() { /** * Test equals for simple object. */ + @Test public void testEqualsBinarilyzable() { InnerClassBinarylizable obj = new InnerClassBinarylizable(1, "2", 3); @@ -148,6 +156,7 @@ public void testEqualsBinarilyzable() { /** * Test equals for different type IDs. */ + @Test public void testEqualsDifferenTypes() { InnerClass obj1 = new InnerClass(1, "2", 3); InnerClassBinarylizable obj2 = new InnerClassBinarylizable(1, "2", 3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java index 1d6da2cadd1fb..f0b6213d4a32a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java @@ -20,14 +20,19 @@ import org.apache.ignite.binary.BinaryBasicIdMapper; import org.apache.ignite.internal.binary.test.GridBinaryTestClass1; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class BinaryBasicIdMapperSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testLowerCase() throws Exception { BinaryBasicIdMapper mapper = new BinaryBasicIdMapper(true); @@ -40,6 +45,7 @@ public void testLowerCase() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultCase() throws Exception { BinaryBasicIdMapper mapper = new BinaryBasicIdMapper(false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java index 70fb8e7d76535..f2c94fec11af6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java @@ -20,14 +20,19 @@ import org.apache.ignite.binary.BinaryBasicNameMapper; import org.apache.ignite.internal.binary.test.GridBinaryTestClass1; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class BinaryBasicNameMapperSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSimpleName() throws Exception { BinaryBasicNameMapper mapper = new BinaryBasicNameMapper(true); @@ -39,6 +44,7 @@ public void testSimpleName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFullName() throws Exception { BinaryBasicNameMapper mapper = new BinaryBasicNameMapper(false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java index 3dfa17925549e..b7d81c4155260 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java @@ -30,12 +30,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK; /** * Tests a check of binary configuration consistency. */ +@RunWith(JUnit4.class) public class BinaryConfigurationConsistencySelfTest extends GridCommonAbstractTest { /** */ private BinaryConfiguration binaryCfg; @@ -66,6 +70,7 @@ public class BinaryConfigurationConsistencySelfTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testSkipCheckConsistencyFlagEnabled() throws Exception { String backup = System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, "true"); @@ -95,6 +100,7 @@ public void testSkipCheckConsistencyFlagEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPositiveNullConfig() throws Exception { binaryCfg = null; @@ -108,6 +114,7 @@ public void testPositiveNullConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPositiveEmptyConfig() throws Exception { binaryCfg = new BinaryConfiguration(); @@ -121,6 +128,7 @@ public void testPositiveEmptyConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPositiveCustomConfig() throws Exception { binaryCfg = customConfig(false); @@ -134,6 +142,7 @@ public void testPositiveCustomConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNegativeNullEmptyConfigs() throws Exception { checkNegative(null, new BinaryConfiguration()); } @@ -141,6 +150,7 @@ public void testNegativeNullEmptyConfigs() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNegativeEmptyNullConfigs() throws Exception { checkNegative(new BinaryConfiguration(), null); } @@ -148,6 +158,7 @@ public void testNegativeEmptyNullConfigs() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNegativeEmptyCustomConfigs() throws Exception { checkNegative(new BinaryConfiguration(), customConfig(false)); } @@ -156,6 +167,7 @@ public void testNegativeEmptyCustomConfigs() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNegativeCustomNullConfigs() throws Exception { checkNegative(customConfig(false), null); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationCustomSerializerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationCustomSerializerSelfTest.java index cedbbaf5f4bc1..32e0b527e4910 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationCustomSerializerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationCustomSerializerSelfTest.java @@ -38,10 +38,14 @@ import org.apache.ignite.internal.visor.node.VisorNodePingTask; import org.apache.ignite.internal.visor.node.VisorNodePingTaskArg; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests that node will start with custom binary serializer and thin client will connect to such node. */ +@RunWith(JUnit4.class) public class BinaryConfigurationCustomSerializerSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -88,6 +92,7 @@ public class BinaryConfigurationCustomSerializerSelfTest extends GridCommonAbstr * * @throws Exception If failed. */ + @Test public void testThinClientConnected() throws Exception { UUID nid = ignite(0).cluster().localNode().id(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java index c18c0eef3b749..754d33caf6a36 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java @@ -39,11 +39,15 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Contains tests for binary enums. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class BinaryEnumsSelfTest extends GridCommonAbstractTest { /** Cache name. */ private static String CACHE_NAME = "cache"; @@ -144,6 +148,7 @@ private void startUp(boolean register) throws Exception { * * @throws Exception If failed. */ + @Test public void testSimpleRegistered() throws Exception { checkSimple(true); } @@ -153,6 +158,7 @@ public void testSimpleRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testSimpleNotRegistered() throws Exception { checkSimple(false); } @@ -162,6 +168,7 @@ public void testSimpleNotRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testNestedRegistered() throws Exception { checkNested(true); } @@ -171,6 +178,7 @@ public void testNestedRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testNestedNotRegistered() throws Exception { checkNested(false); } @@ -180,6 +188,7 @@ public void testNestedNotRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testSimpleBuilderRegistered() throws Exception { checkSimpleBuilder(true); } @@ -189,6 +198,7 @@ public void testSimpleBuilderRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testSimpleBuilderNotRegistered() throws Exception { checkSimpleBuilder(false); } @@ -198,6 +208,7 @@ public void testSimpleBuilderNotRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testNestedBuilderRegistered() throws Exception { checkNestedBuilder(true); } @@ -207,6 +218,7 @@ public void testNestedBuilderRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testNestedBuilderNotRegistered() throws Exception { checkNestedBuilder(false); } @@ -214,6 +226,7 @@ public void testNestedBuilderNotRegistered() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInstanceFromBytes() throws Exception { startUp(true); @@ -353,6 +366,7 @@ public void checkSimpleBuilder(boolean registered) throws Exception { * * @throws Exception If failed. */ + @Test public void testSimpleArrayRegistered() throws Exception { checkSimpleArray(true); } @@ -362,6 +376,7 @@ public void testSimpleArrayRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testSimpleArrayNotRegistered() throws Exception { checkSimpleArray(false); } @@ -371,6 +386,7 @@ public void testSimpleArrayNotRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testSimpleBuilderArrayRegistered() throws Exception { checkSimpleBuilderArray(true); } @@ -380,6 +396,7 @@ public void testSimpleBuilderArrayRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testSimpleBuilderArrayNotRegistered() throws Exception { checkSimpleBuilderArray(false); } @@ -420,6 +437,7 @@ public void checkSimpleBuilderArray(boolean registered) throws Exception { * * @throws Exception If failed. */ + @Test public void testZeroTypeId() throws Exception { startUp(true); @@ -437,6 +455,7 @@ public void testZeroTypeId() throws Exception { * * @throws Exception */ + @Test public void testBinaryTypeEnumValues() throws Exception { startUp(false); @@ -455,6 +474,7 @@ public void testBinaryTypeEnumValues() throws Exception { * * @throws Exception */ + @Test public void testEnumWrongBinaryConfig() throws Exception { this.register = true; @@ -472,6 +492,7 @@ public void testEnumWrongBinaryConfig() throws Exception { * * @throws Exception */ + @Test public void testEnumValidation() throws Exception { startUp(false); @@ -493,6 +514,7 @@ public void testEnumValidation() throws Exception { * * @throws Exception */ + @Test public void testEnumMerge() throws Exception { startUp(false); @@ -543,6 +565,7 @@ public void testEnumMerge() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeclaredBodyEnumRegistered() throws Exception { checkDeclaredBodyEnum(true); } @@ -552,6 +575,7 @@ public void testDeclaredBodyEnumRegistered() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeclaredBodyEnumNotRegistered() throws Exception { checkDeclaredBodyEnum(false); } @@ -644,7 +668,7 @@ private void validate(BinaryObject obj, EnumType val) { if (register) assertEquals(val.name(), obj.enumName()); } - + /** * Validate single value. * diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldExtractionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldExtractionSelfTest.java index a050591b2d693..132253f8d8507 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldExtractionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldExtractionSelfTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.MarshallerContextTestImpl; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class BinaryFieldExtractionSelfTest extends GridCommonAbstractTest { /** * Create marshaller. @@ -60,6 +64,7 @@ protected BinaryMarshaller createMarshaller() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimitiveMarshalling() throws Exception { BinaryMarshaller marsh = createMarshaller(); @@ -101,6 +106,7 @@ public void testPrimitiveMarshalling() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimeMarshalling() throws Exception { BinaryMarshaller marsh = createMarshaller(); @@ -122,6 +128,7 @@ public void testTimeMarshalling() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDecimalFieldMarshalling() throws Exception { BinaryMarshaller marsh = createMarshaller(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsAbstractSelfTest.java index fd095e99f9d0b..19a349c3354ba 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsAbstractSelfTest.java @@ -33,10 +33,14 @@ import java.util.Arrays; import java.util.Date; import java.util.UUID; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Contains tests for binary object fields. */ +@RunWith(JUnit4.class) public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTest { /** Marshaller. */ protected BinaryMarshaller dfltMarsh; @@ -105,6 +109,7 @@ protected static BinaryContext binaryContext(BinaryMarshaller marsh) { * * @throws Exception If failed. */ + @Test public void testByte() throws Exception { check("fByte"); } @@ -114,6 +119,7 @@ public void testByte() throws Exception { * * @throws Exception If failed. */ + @Test public void testByteArray() throws Exception { check("fByteArr"); } @@ -123,6 +129,7 @@ public void testByteArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { check("fBool"); } @@ -132,6 +139,7 @@ public void testBoolean() throws Exception { * * @throws Exception If failed. */ + @Test public void testBooleanArray() throws Exception { check("fBoolArr"); } @@ -141,6 +149,7 @@ public void testBooleanArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testShort() throws Exception { check("fShort"); } @@ -150,6 +159,7 @@ public void testShort() throws Exception { * * @throws Exception If failed. */ + @Test public void testShortArray() throws Exception { check("fShortArr"); } @@ -159,6 +169,7 @@ public void testShortArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testChar() throws Exception { check("fChar"); } @@ -168,6 +179,7 @@ public void testChar() throws Exception { * * @throws Exception If failed. */ + @Test public void testCharArray() throws Exception { check("fCharArr"); } @@ -177,6 +189,7 @@ public void testCharArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testInt() throws Exception { check("fInt"); } @@ -186,6 +199,7 @@ public void testInt() throws Exception { * * @throws Exception If failed. */ + @Test public void testIntArray() throws Exception { check("fIntArr"); } @@ -195,6 +209,7 @@ public void testIntArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testLong() throws Exception { check("fLong"); } @@ -204,6 +219,7 @@ public void testLong() throws Exception { * * @throws Exception If failed. */ + @Test public void testLongArray() throws Exception { check("fLongArr"); } @@ -213,6 +229,7 @@ public void testLongArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { check("fFloat"); } @@ -222,6 +239,7 @@ public void testFloat() throws Exception { * * @throws Exception If failed. */ + @Test public void testFloatArray() throws Exception { check("fFloatArr"); } @@ -231,6 +249,7 @@ public void testFloatArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { check("fDouble"); } @@ -240,6 +259,7 @@ public void testDouble() throws Exception { * * @throws Exception If failed. */ + @Test public void testDoubleArray() throws Exception { check("fDoubleArr"); } @@ -249,6 +269,7 @@ public void testDoubleArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testString() throws Exception { check("fString"); } @@ -258,6 +279,7 @@ public void testString() throws Exception { * * @throws Exception If failed. */ + @Test public void testStringArray() throws Exception { check("fStringArr"); } @@ -267,6 +289,7 @@ public void testStringArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testDate() throws Exception { check("fDate"); } @@ -276,6 +299,7 @@ public void testDate() throws Exception { * * @throws Exception If failed. */ + @Test public void testDateArray() throws Exception { check("fDateArr"); } @@ -285,6 +309,7 @@ public void testDateArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { check("fTimestamp"); } @@ -294,6 +319,7 @@ public void testTimestamp() throws Exception { * * @throws Exception If failed. */ + @Test public void testTimestampArray() throws Exception { check("fTimestampArr"); } @@ -303,6 +329,7 @@ public void testTimestampArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testUuid() throws Exception { check("fUuid"); } @@ -312,6 +339,7 @@ public void testUuid() throws Exception { * * @throws Exception If failed. */ + @Test public void testUuidArray() throws Exception { check("fUuidArr"); } @@ -321,6 +349,7 @@ public void testUuidArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testDecimal() throws Exception { check("fDecimal"); } @@ -330,6 +359,7 @@ public void testDecimal() throws Exception { * * @throws Exception If failed. */ + @Test public void testDecimalArray() throws Exception { check("fDecimalArr"); } @@ -339,6 +369,7 @@ public void testDecimalArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testObject() throws Exception { check("fObj"); } @@ -348,6 +379,7 @@ public void testObject() throws Exception { * * @throws Exception If failed. */ + @Test public void testObjectArray() throws Exception { check("fObjArr"); } @@ -357,6 +389,7 @@ public void testObjectArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testNull() throws Exception { check("fNull"); } @@ -366,6 +399,7 @@ public void testNull() throws Exception { * * @throws Exception If failed. */ + @Test public void testMissing() throws Exception { String fieldName = "fMissing"; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsAbstractSelfTest.java index 265d283d3d378..f3e40c59ff287 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsAbstractSelfTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.logger.NullLogger; import org.apache.ignite.marshaller.MarshallerContextTestImpl; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Contains tests for compact offsets. */ +@RunWith(JUnit4.class) public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbstractTest { /** 2 pow 8. */ private static int POW_8 = 1 << 8; @@ -78,6 +82,7 @@ protected boolean compactFooter() { * * @throws Exception If failed. */ + @Test public void test1Byte() throws Exception { check(POW_8 >> 2); } @@ -87,6 +92,7 @@ public void test1Byte() throws Exception { * * @throws Exception If failed. */ + @Test public void test1ByteSign() throws Exception { check(POW_8 >> 1); } @@ -96,6 +102,7 @@ public void test1ByteSign() throws Exception { * * @throws Exception If failed. */ + @Test public void test2Bytes() throws Exception { check(POW_16 >> 2); } @@ -105,6 +112,7 @@ public void test2Bytes() throws Exception { * * @throws Exception If failed. */ + @Test public void test2BytesSign() throws Exception { check(POW_16 >> 1); } @@ -114,6 +122,7 @@ public void test2BytesSign() throws Exception { * * @throws Exception If failed. */ + @Test public void test4Bytes() throws Exception { check(POW_16 << 2); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java index 1ba6edc2bd979..eaca668365fe2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java @@ -25,7 +25,6 @@ import java.io.Serializable; import java.lang.reflect.Field; import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.math.BigDecimal; @@ -97,6 +96,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.ignite.internal.binary.streams.BinaryMemoryAllocator.INSTANCE; @@ -106,11 +108,13 @@ /** * Binary marshaller tests. */ -@SuppressWarnings({"OverlyStrongTypeCast", "ArrayHashCode", "ConstantConditions"}) +@SuppressWarnings({"OverlyStrongTypeCast", "ConstantConditions"}) +@RunWith(JUnit4.class) public class BinaryMarshallerSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNull() throws Exception { assertNull(marshalUnmarshal(null)); } @@ -118,6 +122,7 @@ public void testNull() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByte() throws Exception { assertEquals((byte)100, marshalUnmarshal((byte)100).byteValue()); } @@ -125,6 +130,7 @@ public void testByte() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { assertEquals((short)100, marshalUnmarshal((short)100).shortValue()); } @@ -132,6 +138,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInt() throws Exception { assertEquals(100, marshalUnmarshal(100).intValue()); } @@ -139,6 +146,7 @@ public void testInt() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { assertEquals(100L, marshalUnmarshal(100L).longValue()); } @@ -146,6 +154,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { assertEquals(100.001f, marshalUnmarshal(100.001f), 0); } @@ -153,6 +162,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { assertEquals(100.001d, marshalUnmarshal(100.001d), 0); } @@ -160,6 +170,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testChar() throws Exception { assertEquals((char)100, marshalUnmarshal((char)100).charValue()); } @@ -167,6 +178,7 @@ public void testChar() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { assertEquals(true, marshalUnmarshal(true).booleanValue()); } @@ -174,6 +186,7 @@ public void testBoolean() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDecimal() throws Exception { BigDecimal val; @@ -190,6 +203,7 @@ public void testDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNegativeScaleDecimal() throws Exception { BigDecimal val; @@ -202,6 +216,7 @@ public void testNegativeScaleDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNegativeScaleRoundingModeDecimal() throws Exception { BigDecimal val; @@ -218,6 +233,7 @@ public void testNegativeScaleRoundingModeDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStringVer1() throws Exception { doTestString(false); } @@ -225,6 +241,7 @@ public void testStringVer1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStringVer2() throws Exception { doTestString(true); } @@ -286,6 +303,7 @@ private void doTestString(boolean ver2) throws Exception { /** * @throws Exception If failed. */ + @Test public void testUuid() throws Exception { UUID uuid = UUID.randomUUID(); @@ -295,6 +313,7 @@ public void testUuid() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteUuid() throws Exception { IgniteUuid uuid = IgniteUuid.randomUuid(); @@ -304,6 +323,7 @@ public void testIgniteUuid() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDate() throws Exception { Date date = new Date(); @@ -316,6 +336,7 @@ public void testDate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { Timestamp ts = new Timestamp(System.currentTimeMillis()); @@ -327,6 +348,7 @@ public void testTimestamp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTime() throws Exception { Time time = new Time(System.currentTimeMillis()); assertEquals(time, marshalUnmarshal(time)); @@ -335,6 +357,7 @@ public void testTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimeArray() throws Exception { Time[] times = new Time[]{new Time(System.currentTimeMillis()), new Time(123456789)}; assertArrayEquals(times, marshalUnmarshal(times)); @@ -343,6 +366,7 @@ public void testTimeArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByteArray() throws Exception { byte[] arr = new byte[] {10, 20, 30}; @@ -352,6 +376,7 @@ public void testByteArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShortArray() throws Exception { short[] arr = new short[] {10, 20, 30}; @@ -361,6 +386,7 @@ public void testShortArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIntArray() throws Exception { int[] arr = new int[] {10, 20, 30}; @@ -370,6 +396,7 @@ public void testIntArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLongArray() throws Exception { long[] arr = new long[] {10, 20, 30}; @@ -379,6 +406,7 @@ public void testLongArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloatArray() throws Exception { float[] arr = new float[] {10.1f, 20.1f, 30.1f}; @@ -388,6 +416,7 @@ public void testFloatArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDoubleArray() throws Exception { double[] arr = new double[] {10.1d, 20.1d, 30.1d}; @@ -397,6 +426,7 @@ public void testDoubleArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCharArray() throws Exception { char[] arr = new char[] {10, 20, 30}; @@ -406,6 +436,7 @@ public void testCharArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBooleanArray() throws Exception { boolean[] arr = new boolean[] {true, false, true}; @@ -415,6 +446,7 @@ public void testBooleanArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDecimalArray() throws Exception { BigDecimal[] arr = new BigDecimal[] {BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN}; @@ -424,6 +456,7 @@ public void testDecimalArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStringArray() throws Exception { String[] arr = new String[] {"str1", "str2", "str3"}; @@ -433,6 +466,7 @@ public void testStringArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUuidArray() throws Exception { UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()}; @@ -442,6 +476,7 @@ public void testUuidArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDateArray() throws Exception { Date[] arr = new Date[] {new Date(11111), new Date(22222), new Date(33333)}; @@ -451,6 +486,7 @@ public void testDateArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectArray() throws Exception { Object[] arr = new Object[] {1, 2, 3}; @@ -460,6 +496,7 @@ public void testObjectArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testException() throws Exception { Exception ex = new RuntimeException(); @@ -471,6 +508,7 @@ public void testException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollection() throws Exception { testCollection(new ArrayList(3)); testCollection(new LinkedHashSet()); @@ -493,6 +531,7 @@ private void testCollection(Collection col) throws Exception { /** * @throws Exception If failed. */ + @Test public void testMap() throws Exception { testMap(new HashMap()); testMap(new LinkedHashMap()); @@ -518,6 +557,7 @@ private void testMap(Map map) throws Exception { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testCustomCollections() throws Exception { CustomCollections cc = new CustomCollections(); @@ -541,6 +581,7 @@ public void testCustomCollections() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testCustomCollections2() throws Exception { CustomArrayList arrList = new CustomArrayList(); @@ -563,6 +604,7 @@ public void testCustomCollections2() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testCustomCollectionsWithFactory() throws Exception { CustomCollectionsWithFactory cc = new CustomCollectionsWithFactory(); @@ -581,6 +623,7 @@ public void testCustomCollectionsWithFactory() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExternalizableInEnclosing() throws Exception { SimpleEnclosingObject obj = new SimpleEnclosingObject(); obj.simpl = new SimpleExternalizable("field"); @@ -593,6 +636,7 @@ public void testExternalizableInEnclosing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMapEntry() throws Exception { Map.Entry e = new GridMapEntry<>(1, "str1"); @@ -613,6 +657,7 @@ public void testMapEntry() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryObject() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName()))); @@ -640,6 +685,7 @@ public void testBinaryObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEnum() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(TestEnum.class.getName()))); @@ -649,6 +695,7 @@ public void testEnum() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeclaredBodyEnum() throws Exception { final MarshallerContextTestImpl ctx = new MarshallerContextTestImpl(); ctx.registerClassName((byte)0, 1, EnumObject.class.getName()); @@ -675,6 +722,7 @@ public void testDeclaredBodyEnum() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDateAndTimestampInSingleObject() throws Exception { BinaryTypeConfiguration cfg1 = new BinaryTypeConfiguration(DateClass1.class.getName()); @@ -712,6 +760,7 @@ public void testDateAndTimestampInSingleObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleObject() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -795,6 +844,7 @@ public void testSimpleObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinary() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()), @@ -916,6 +966,7 @@ public void testBinary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectFieldOfExternalizableCollection() throws Exception { EnclosingObj obj = new EnclosingObj(); @@ -927,6 +978,7 @@ public void testObjectFieldOfExternalizableCollection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVoid() throws Exception { Class clazz = Void.class; @@ -940,6 +992,7 @@ public void testVoid() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteReplacePrivate() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Collections.singleton( new BinaryTypeConfiguration(TestObject.class.getName()) @@ -957,6 +1010,7 @@ public void testWriteReplacePrivate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteReplaceInheritable() throws Exception { ImmutableList obj = ImmutableList.of("This is a test"); @@ -1114,6 +1168,7 @@ private void checkSimpleObjectData(SimpleObject obj, BinaryObject po) { /** * @throws Exception If failed. */ + @Test public void testClassWithoutPublicConstructor() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(NoPublicConstructor.class.getName()), @@ -1140,6 +1195,7 @@ public void testClassWithoutPublicConstructor() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomSerializer() throws Exception { BinaryTypeConfiguration type = new BinaryTypeConfiguration(CustomSerializedObject1.class.getName()); @@ -1158,6 +1214,7 @@ public void testCustomSerializer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomSerializerWithGlobal() throws Exception { BinaryTypeConfiguration type1 = new BinaryTypeConfiguration(CustomSerializedObject1.class.getName()); @@ -1184,6 +1241,7 @@ public void testCustomSerializerWithGlobal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomIdMapper() throws Exception { BinaryTypeConfiguration type = new BinaryTypeConfiguration(CustomMappedObject1.class.getName()); @@ -1224,6 +1282,7 @@ else if ("val2".equals(fieldName)) /** * @throws Exception If failed. */ + @Test public void testCustomIdMapperWithGlobal() throws Exception { BinaryTypeConfiguration type1 = new BinaryTypeConfiguration(CustomMappedObject1.class.getName()); @@ -1294,6 +1353,7 @@ else if ("val2".equals(fieldName)) /** * @throws Exception If failed. */ + @Test public void testSimpleNameLowerCaseMappers() throws Exception { BinaryTypeConfiguration innerClassType = new BinaryTypeConfiguration(InnerMappedObject.class.getName()); BinaryTypeConfiguration publicClassType = new BinaryTypeConfiguration(TestMappedObject.class.getName()); @@ -1351,6 +1411,7 @@ else if ("val2".equals(fieldName)) /** * @throws Exception If failed. */ + @Test public void testDynamicObject() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(DynamicObject.class.getName()) @@ -1396,6 +1457,7 @@ public void testDynamicObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCycleLink() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(CycleLinkObject.class.getName()) @@ -1415,6 +1477,7 @@ public void testCycleLink() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDetached() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(DetachedTestObject.class.getName()), @@ -1469,6 +1532,7 @@ public void testDetached() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollectionFields() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(CollectionFieldsObject.class.getName()), @@ -1509,24 +1573,14 @@ public void testCollectionFields() throws Exception { /** * @throws Exception If failed. */ - public void _testDefaultMapping() throws Exception { + @Test + public void testDefaultMapping() throws Exception { BinaryTypeConfiguration customMappingType = new BinaryTypeConfiguration(TestBinary.class.getName()); customMappingType.setIdMapper(new BinaryIdMapper() { @Override public int typeId(String clsName) { - String typeName; - - try { - Method mtd = BinaryContext.class.getDeclaredMethod("typeName", String.class); - - mtd.setAccessible(true); - - typeName = (String)mtd.invoke(null, clsName); - } - catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } + String typeName = BinaryContext.SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(clsName); return typeName.toLowerCase().hashCode(); } @@ -1558,6 +1612,7 @@ public void _testDefaultMapping() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTypeNamesSimpleNameMapper() throws Exception { BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName()); @@ -1636,6 +1691,7 @@ public void testTypeNamesSimpleNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTypeNamesFullNameMappers() throws Exception { BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName()); @@ -1714,6 +1770,7 @@ public void testTypeNamesFullNameMappers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTypeNamesSimpleNameMappers() throws Exception { BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName()); @@ -1801,6 +1858,7 @@ public void testTypeNamesSimpleNameMappers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTypeNamesCustomIdMapper() throws Exception { BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName()); @@ -1915,6 +1973,7 @@ else if ("NonExistentClass4".equals(clsName)) /** * @throws Exception If failed. */ + @Test public void testCustomTypeRegistration() throws Exception { BinaryTypeConfiguration customType = new BinaryTypeConfiguration(Value.class.getName()); @@ -1956,6 +2015,7 @@ public void testCustomTypeRegistration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFieldIdMapping() throws Exception { BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName()); @@ -2020,6 +2080,7 @@ public void testFieldIdMapping() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDuplicateTypeId() throws Exception { BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration("org.gridgain.Class1"); @@ -2061,6 +2122,7 @@ public void testDuplicateTypeId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopy() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2184,6 +2246,7 @@ public void testBinaryCopy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyString() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2205,6 +2268,7 @@ public void testBinaryCopyString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyUuid() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2228,6 +2292,7 @@ public void testBinaryCopyUuid() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyByteArray() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2265,6 +2330,7 @@ private BinaryObject copy(BinaryObject po, Map fields) { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyShortArray() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2286,6 +2352,7 @@ public void testBinaryCopyShortArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyIntArray() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2307,6 +2374,7 @@ public void testBinaryCopyIntArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyLongArray() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2328,6 +2396,7 @@ public void testBinaryCopyLongArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyFloatArray() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2349,6 +2418,7 @@ public void testBinaryCopyFloatArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyDoubleArray() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2370,6 +2440,7 @@ public void testBinaryCopyDoubleArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyCharArray() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2391,6 +2462,7 @@ public void testBinaryCopyCharArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyStringArray() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2412,6 +2484,7 @@ public void testBinaryCopyStringArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyObject() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2439,6 +2512,7 @@ public void testBinaryCopyObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyNonPrimitives() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(SimpleObject.class.getName()) @@ -2476,6 +2550,7 @@ public void testBinaryCopyNonPrimitives() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryCopyMixed() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName()))); @@ -2520,6 +2595,7 @@ public void testBinaryCopyMixed() throws Exception { /** * @throws Exception If failed. */ + @Test public void testKeepDeserialized() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName()))); @@ -2537,6 +2613,7 @@ public void testKeepDeserialized() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOffheapBinary() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName()))); @@ -2631,6 +2708,7 @@ public void testOffheapBinary() throws Exception { /** * */ + @Test public void testReadResolve() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Arrays.asList( new BinaryTypeConfiguration(MySingleton.class.getName()), @@ -2648,6 +2726,7 @@ public void testReadResolve() throws Exception { /** * */ + @Test public void testReadResolveOnBinaryAware() throws Exception { BinaryMarshaller marsh = binaryMarshaller(Collections.singletonList( new BinaryTypeConfiguration(MyTestClass.class.getName()))); @@ -2662,6 +2741,7 @@ public void testReadResolveOnBinaryAware() throws Exception { /** * */ + @Test public void testDecimalFields() throws Exception { Collection clsNames = new ArrayList<>(); @@ -2732,6 +2812,7 @@ public void testDecimalFields() throws Exception { /** * @throws IgniteCheckedException If failed. */ + @Test public void testFinalField() throws IgniteCheckedException { BinaryMarshaller marsh = binaryMarshaller(); @@ -2745,6 +2826,7 @@ public void testFinalField() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testThreadLocalArrayReleased() throws Exception { // Checking the writer directly. assertEquals(false, INSTANCE.isAcquired()); @@ -2786,6 +2868,7 @@ public void testThreadLocalArrayReleased() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDuplicateNameSimpleNameMapper() throws Exception { BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true), null, null, null); @@ -2810,6 +2893,7 @@ public void testDuplicateNameSimpleNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDuplicateNameFullNameMapper() throws Exception { BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false), null, null, null); @@ -2825,6 +2909,7 @@ public void testDuplicateNameFullNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClass() throws Exception { BinaryMarshaller marsh = binaryMarshaller(); @@ -2838,6 +2923,7 @@ public void testClass() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClassFieldsMarshalling() throws Exception { BinaryMarshaller marsh = binaryMarshaller(); @@ -2861,6 +2947,7 @@ public void testClassFieldsMarshalling() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMarshallingThroughJdk() throws Exception { BinaryMarshaller marsh = binaryMarshaller(); @@ -2897,6 +2984,7 @@ public void testMarshallingThroughJdk() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPredefinedTypeIds() throws Exception { BinaryMarshaller marsh = binaryMarshaller(); @@ -2925,6 +3013,7 @@ public void testPredefinedTypeIds() throws Exception { /** * @throws Exception If failed. */ + @Test public void testProxy() throws Exception { BinaryMarshaller marsh = binaryMarshaller(); @@ -2954,6 +3043,7 @@ public void testProxy() throws Exception { * * @throws Exception If fails. */ + @Test public void testObjectContainingProxy() throws Exception { BinaryMarshaller marsh = binaryMarshaller(); @@ -2983,6 +3073,7 @@ public void testObjectContainingProxy() throws Exception { * * @throws Exception If failed. */ + @Test public void testDuplicateFields() throws Exception { BinaryMarshaller marsh = binaryMarshaller(); @@ -3038,6 +3129,7 @@ public void testDuplicateFields() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingleHandle() throws Exception { SingleHandleA a = new SingleHandleA(new SingleHandleB()); @@ -3053,6 +3145,7 @@ public void testSingleHandle() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUnregisteredClass() throws Exception { BinaryMarshaller m = binaryMarshaller(null, Collections.singletonList(Value.class.getName())); @@ -3064,6 +3157,7 @@ public void testUnregisteredClass() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMixedRawCollections() throws Exception { Collection excludedClasses = Arrays.asList( ObjectRaw.class.getName(), @@ -3091,6 +3185,7 @@ public void testMixedRawCollections() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryEquals() throws Exception { Collection excludedClasses = Arrays.asList( ObjectRaw.class.getName(), @@ -3226,6 +3321,7 @@ private void checkEquals(Object binObj0, Object binObj1) { /** * @throws Exception If failed. */ + @Test public void testBinaryEqualsComplexObject() throws Exception { List excludedClasses = Arrays.asList( TestClass0.class.getName(), @@ -3284,6 +3380,7 @@ public void testBinaryEqualsComplexObject() throws Exception { * * @throws Exception If failed. */ + @Test public void testFieldOrder() throws Exception { if (BinaryUtils.FIELDS_SORTED_ORDER) return; @@ -3313,6 +3410,7 @@ public void testFieldOrder() throws Exception { * * @throws Exception If failed. */ + @Test public void testFieldOrderByBuilder() throws Exception { if (BinaryUtils.FIELDS_SORTED_ORDER) return; @@ -3402,7 +3500,6 @@ private static class NonSerializableA { * @param strArr Array. * @param shortVal Short value. */ - @SuppressWarnings({"UnusedDeclaration"}) private NonSerializableA(@Nullable String[] strArr, @Nullable Short shortVal) { // No-op. } @@ -3499,7 +3596,6 @@ private static class NonSerializable extends NonSerializableB { * * @param aVal Unused. */ - @SuppressWarnings({"UnusedDeclaration"}) private NonSerializable(NonSerializableA aVal) { } @@ -4169,7 +4265,6 @@ private static class SimpleObject { private SimpleObject inner; /** {@inheritDoc} */ - @SuppressWarnings("FloatingPointEquality") @Override public boolean equals(Object other) { if (this == other) return true; @@ -4525,7 +4620,6 @@ private static class TestBinary implements Binarylizable { } /** {@inheritDoc} */ - @SuppressWarnings("FloatingPointEquality") @Override public boolean equals(Object other) { if (this == other) return true; @@ -4916,7 +5010,6 @@ private DetachedInnerTestObject(DetachedInnerTestObject inner, UUID id) { /** */ - @SuppressWarnings("UnusedDeclaration") private static class CollectionFieldsObject { /** */ private Object[] arr; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java index 2366bac0dfaf5..5a405439d04bb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java @@ -56,7 +56,6 @@ import org.apache.ignite.configuration.BinaryConfiguration; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.MarshallerPlatformIds; import org.apache.ignite.internal.binary.builder.BinaryBuilderEnum; import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl; @@ -70,6 +69,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -77,6 +79,7 @@ /** * */ +@RunWith(JUnit4.class) public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -128,6 +131,7 @@ protected IgniteBinary binaries() { /** * @throws Exception If failed. */ + @Test public void testSimpleTypeFieldRead() throws Exception { GridBinaryTestClasses.TestObjectAllTypes exp = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -162,6 +166,7 @@ public void testSimpleTypeFieldRead() throws Exception { /** * */ + @Test public void testSimpleTypeFieldSerialize() { GridBinaryTestClasses.TestObjectAllTypes exp = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -177,6 +182,7 @@ public void testSimpleTypeFieldSerialize() { /** * @throws Exception If any error occurs. */ + @Test public void testSimpleTypeFieldOverride() throws Exception { GridBinaryTestClasses.TestObjectAllTypes exp = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -195,6 +201,7 @@ public void testSimpleTypeFieldOverride() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testSimpleTypeFieldSetNull() throws Exception { GridBinaryTestClasses.TestObjectAllTypes exp = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -218,6 +225,7 @@ public void testSimpleTypeFieldSetNull() throws Exception { /** * @throws IgniteCheckedException If any error occurs. */ + @Test public void testMakeCyclicDependency() throws IgniteCheckedException { GridBinaryTestClasses.TestObjectOuter outer = new GridBinaryTestClasses.TestObjectOuter(); outer.inner = new GridBinaryTestClasses.TestObjectInner(); @@ -238,6 +246,7 @@ public void testMakeCyclicDependency() throws IgniteCheckedException { /** * */ + @Test public void testDateArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -256,6 +265,7 @@ public void testDateArrayModification() { /** * */ + @Test public void testTimestampArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -274,6 +284,7 @@ public void testTimestampArrayModification() { /** * */ + @Test public void testUUIDArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -292,6 +303,7 @@ public void testUUIDArrayModification() { /** * */ + @Test public void testDecimalArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -311,6 +323,7 @@ public void testDecimalArrayModification() { /** * */ + @Test public void testBooleanArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -334,6 +347,7 @@ public void testBooleanArrayModification() { /** * */ + @Test public void testCharArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -352,6 +366,7 @@ public void testCharArrayModification() { /** * */ + @Test public void testDoubleArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -370,6 +385,7 @@ public void testDoubleArrayModification() { /** * */ + @Test public void testFloatArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -390,6 +406,7 @@ public void testFloatArrayModification() { /** * */ + @Test public void testLongArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -408,6 +425,7 @@ public void testLongArrayModification() { /** * */ + @Test public void testIntArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -426,6 +444,7 @@ public void testIntArrayModification() { /** * */ + @Test public void testShortArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -444,6 +463,7 @@ public void testShortArrayModification() { /** * */ + @Test public void testByteArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -462,6 +482,7 @@ public void testByteArrayModification() { /** * */ + @Test public void testStringArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -480,6 +501,7 @@ public void testStringArrayModification() { /** * */ + @Test public void testModifyObjectArray() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = new Object[] {"a"}; @@ -500,6 +522,7 @@ public void testModifyObjectArray() { /** * */ + @Test public void testOverrideObjectArrayField() { BinaryObjectBuilderImpl mutObj = wrap(new GridBinaryTestClasses.TestObjectContainer()); @@ -517,6 +540,7 @@ public void testOverrideObjectArrayField() { /** * */ + @Test public void testDeepArray() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = new Object[] {new Object[] {"a", obj}}; @@ -541,6 +565,7 @@ public void testDeepArray() { /** * */ + @Test public void testArrayListRead() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = Lists.newArrayList(obj, "a"); @@ -555,6 +580,7 @@ public void testArrayListRead() { /** * */ + @Test public void testArrayListOverride() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -575,6 +601,7 @@ public void testArrayListOverride() { /** * */ + @Test public void testArrayListModification() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = Lists.newArrayList("a", "b", "c"); @@ -602,6 +629,7 @@ public void testArrayListModification() { /** * */ + @Test public void testArrayListClear() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = Lists.newArrayList("a", "b", "c"); @@ -618,6 +646,7 @@ public void testArrayListClear() { /** * */ + @Test public void testArrayListWriteUnmodifiable() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -639,6 +668,7 @@ public void testArrayListWriteUnmodifiable() { /** * */ + @Test public void testLinkedListRead() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = Lists.newLinkedList(Arrays.asList(obj, "a")); @@ -653,6 +683,7 @@ public void testLinkedListRead() { /** * */ + @Test public void testLinkedListOverride() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -673,6 +704,7 @@ public void testLinkedListOverride() { /** * */ + @Test public void testLinkedListModification() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -701,6 +733,7 @@ public void testLinkedListModification() { /** * */ + @Test public void testLinkedListWriteUnmodifiable() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -722,6 +755,7 @@ public void testLinkedListWriteUnmodifiable() { /** * */ + @Test public void testHashSetRead() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = Sets.newHashSet(obj, "a"); @@ -736,6 +770,7 @@ public void testHashSetRead() { /** * */ + @Test public void testHashSetOverride() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -757,6 +792,7 @@ public void testHashSetOverride() { /** * */ + @Test public void testHashSetModification() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = Sets.newHashSet("a", "b", "c"); @@ -781,6 +817,7 @@ public void testHashSetModification() { /** * */ + @Test public void testHashSetWriteUnmodifiable() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -801,6 +838,7 @@ public void testHashSetWriteUnmodifiable() { /** * */ + @Test public void testMapRead() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = Maps.newHashMap(ImmutableMap.of(obj, "a", "b", obj)); @@ -815,6 +853,7 @@ public void testMapRead() { /** * */ + @Test public void testMapOverride() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -832,6 +871,7 @@ public void testMapOverride() { /** * */ + @Test public void testMapModification() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = Maps.newHashMap(ImmutableMap.of(1, "a", 2, "b")); @@ -853,6 +893,7 @@ public void testMapModification() { /** * */ + @Test public void testEnumArrayModification() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); @@ -871,6 +912,7 @@ public void testEnumArrayModification() { /** * */ + @Test public void testEditObjectWithRawData() { GridBinaryMarshalerAwareTestClass obj = new GridBinaryMarshalerAwareTestClass(); @@ -889,6 +931,7 @@ public void testEditObjectWithRawData() { /** * */ + @Test public void testHashCode() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -902,6 +945,7 @@ public void testHashCode() { /** * */ + @Test public void testCollectionsInCollection() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); obj.foo = Lists.newArrayList( @@ -919,6 +963,7 @@ public void testCollectionsInCollection() { /** * */ + @Test public void testMapEntryOverride() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -934,6 +979,7 @@ public void testMapEntryOverride() { /** * */ + @Test public void testMetadataChangingDoublePut() { BinaryObjectBuilderImpl mutableObj = wrap(new GridBinaryTestClasses.TestObjectContainer()); @@ -950,6 +996,7 @@ public void testMetadataChangingDoublePut() { /** * */ + @Test public void testMetadataChangingDoublePut2() { BinaryObjectBuilderImpl mutableObj = wrap(new GridBinaryTestClasses.TestObjectContainer()); @@ -966,6 +1013,7 @@ public void testMetadataChangingDoublePut2() { /** * */ + @Test public void testMetadataChanging() { GridBinaryTestClasses.TestObjectContainer c = new GridBinaryTestClasses.TestObjectContainer(); @@ -1000,6 +1048,7 @@ public void testMetadataChanging() { /** * */ + @Test public void testWrongMetadataNullField() { BinaryObjectBuilder builder = binaries().builder("SomeType"); @@ -1037,6 +1086,7 @@ public void testWrongMetadataNullField() { /** * */ + @Test public void testWrongMetadataNullField2() { BinaryObjectBuilder builder = binaries().builder("SomeType1"); @@ -1074,6 +1124,7 @@ public void testWrongMetadataNullField2() { /** * */ + @Test public void testCorrectMetadataNullField() { BinaryObjectBuilder builder = binaries().builder("SomeType2"); @@ -1096,6 +1147,7 @@ public void testCorrectMetadataNullField() { /** * */ + @Test public void testCorrectMetadataNullField2() { BinaryObjectBuilder builder = binaries().builder("SomeType3"); @@ -1117,6 +1169,7 @@ public void testCorrectMetadataNullField2() { /** * */ + @Test public void testDateInObjectField() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -1130,6 +1183,7 @@ public void testDateInObjectField() { /** * */ + @Test public void testTimestampInObjectField() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -1143,6 +1197,7 @@ public void testTimestampInObjectField() { /** * */ + @Test public void testDateInCollection() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -1156,6 +1211,7 @@ public void testDateInCollection() { /** * */ + @Test public void testTimestampInCollection() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -1169,7 +1225,7 @@ public void testTimestampInCollection() { /** * */ - @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes") + @Test public void testDateArrayOverride() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -1188,7 +1244,7 @@ public void testDateArrayOverride() { /** * */ - @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes") + @Test public void testTimestampArrayOverride() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -1207,6 +1263,7 @@ public void testTimestampArrayOverride() { /** * */ + @Test public void testChangeMap() { GridBinaryTestClasses.Addresses addrs = new GridBinaryTestClasses.Addresses(); @@ -1249,6 +1306,7 @@ public void testChangeMap() { /** * */ + @Test public void testSavingObjectWithNotZeroStart() { GridBinaryTestClasses.TestObjectOuter out = new GridBinaryTestClasses.TestObjectOuter(); GridBinaryTestClasses.TestObjectInner inner = new GridBinaryTestClasses.TestObjectInner(); @@ -1268,6 +1326,7 @@ public void testSavingObjectWithNotZeroStart() { /** * */ + @Test public void testBinaryObjectField() { GridBinaryTestClasses.TestObjectContainer container = new GridBinaryTestClasses.TestObjectContainer(toBinary(new GridBinaryTestClasses.TestObjectArrayList())); @@ -1282,6 +1341,7 @@ public void testBinaryObjectField() { /** * */ + @Test public void testAssignBinaryObject() { GridBinaryTestClasses.TestObjectContainer container = new GridBinaryTestClasses.TestObjectContainer(); @@ -1296,6 +1356,7 @@ public void testAssignBinaryObject() { /** * */ + @Test public void testRemoveFromNewObject() { BinaryObjectBuilderImpl wrapper = newWrapper(GridBinaryTestClasses.TestObjectAllTypes.class); @@ -1309,6 +1370,7 @@ public void testRemoveFromNewObject() { /** * */ + @Test public void testRemoveFromExistingObject() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); obj.setDefaultData(); @@ -1323,6 +1385,7 @@ public void testRemoveFromExistingObject() { /** * */ + @Test public void testCyclicArrays() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -1344,6 +1407,7 @@ public void testCyclicArrays() { * */ @SuppressWarnings("TypeMayBeWeakened") + @Test public void testCyclicArrayList() { GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer(); @@ -1365,6 +1429,7 @@ public void testCyclicArrayList() { /** * @throws Exception If failed. */ + @Test public void testSameBinaryKey() throws Exception { IgniteCache replicatedCache = jcache(0).withKeepBinary(); @@ -1392,6 +1457,7 @@ public void testSameBinaryKey() throws Exception { /** * Ensure that object w/o schema can be re-built. */ + @Test public void testBuildFromObjectWithoutSchema() { BinaryObjectBuilderImpl binBuilder = wrap(new GridBinaryTestClass2()); @@ -1441,6 +1507,7 @@ private BinaryObjectBuilderImpl newWrapper(String typeName) { /** * Check that correct type is stored in binary object. */ + @Test public void testCollectionsSerialization() { final BinaryObjectBuilder root = newWrapper(BigInteger.class); @@ -1522,6 +1589,7 @@ public void testCollectionsSerialization() { * * @throws Exception If failed. */ + @Test public void testBuilderExternalizable() throws Exception { BinaryObjectBuilder builder = newWrapper("TestType"); @@ -1557,6 +1625,7 @@ public void testBuilderExternalizable() throws Exception { * * @throws Exception If failed. */ + @Test public void testEnum() throws Exception { BinaryObjectBuilder builder = newWrapper("TestType"); @@ -1580,6 +1649,7 @@ public void testEnum() throws Exception { /** * Test {@link BinaryObjectBuilder#build()} adds type mapping to the binary marshaller's cache. */ + @Test public void testMarshallerMappings() throws IgniteCheckedException, ClassNotFoundException { String typeName = "TestType"; @@ -1614,6 +1684,7 @@ private TestEnum[] deserializeEnumBinaryArray(Object obj) { /** * @throws Exception If fails */ + @Test public void testBuilderReusage() throws Exception { // Check: rewrite null field value. BinaryObjectBuilder builder = newWrapper("SimpleCls1"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java index 1c5fbd7dece09..382687c1ff49b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java @@ -46,13 +46,16 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN; /** * Binary builder test. */ -@SuppressWarnings("ResultOfMethodCallIgnored") +@RunWith(JUnit4.class) public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstractTest { /** */ private static IgniteConfiguration cfg; @@ -111,6 +114,7 @@ protected boolean compactFooter() { /** * */ + @Test public void testAllFieldsSerialization() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); obj.setDefaultData(); @@ -124,6 +128,7 @@ public void testAllFieldsSerialization() { /** * @throws Exception If failed. */ + @Test public void testNullField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -152,6 +157,7 @@ public void testNullField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByteField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -168,6 +174,7 @@ public void testByteField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShortField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -184,6 +191,7 @@ public void testShortField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIntField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -200,6 +208,7 @@ public void testIntField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLongField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -216,6 +225,7 @@ public void testLongField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloatField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -232,6 +242,7 @@ public void testFloatField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDoubleField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -248,6 +259,7 @@ public void testDoubleField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCharField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -281,6 +293,7 @@ private int expectedHashCode(String fullName) { /** * @throws Exception If failed. */ + @Test public void testBooleanField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -297,6 +310,7 @@ public void testBooleanField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDecimalField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -313,6 +327,7 @@ public void testDecimalField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStringField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -329,6 +344,7 @@ public void testStringField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDateField() throws Exception { Date date = new Date(); @@ -338,6 +354,7 @@ public void testDateField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestampField() throws Exception { Timestamp ts = new Timestamp(new Date().getTime()); ts.setNanos(1000); @@ -348,6 +365,7 @@ public void testTimestampField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUuidField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -366,6 +384,7 @@ public void testUuidField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByteArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -382,6 +401,7 @@ public void testByteArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShortArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -398,6 +418,7 @@ public void testShortArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIntArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -414,6 +435,7 @@ public void testIntArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLongArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -430,6 +452,7 @@ public void testLongArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloatArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -446,6 +469,7 @@ public void testFloatArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDoubleArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -462,6 +486,7 @@ public void testDoubleArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCharArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -478,6 +503,7 @@ public void testCharArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBooleanArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -499,6 +525,7 @@ public void testBooleanArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDecimalArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -515,6 +542,7 @@ public void testDecimalArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStringArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -531,6 +559,7 @@ public void testStringArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDateArrayField() throws Exception { Date date1 = new Date(); Date date2 = new Date(date1.getTime() + 1000); @@ -543,6 +572,7 @@ public void testDateArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestampArrayField() throws Exception { Timestamp ts1 = new Timestamp(new Date().getTime()); Timestamp ts2 = new Timestamp(new Date().getTime() + 1000); @@ -558,6 +588,7 @@ public void testTimestampArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUuidArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -576,6 +607,7 @@ public void testUuidArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -592,6 +624,7 @@ public void testObjectField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectArrayField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -613,6 +646,7 @@ public void testObjectArrayField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollectionField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -640,6 +674,7 @@ public void testCollectionField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMapField() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -671,6 +706,7 @@ public void testMapField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSeveralFields() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -701,6 +737,7 @@ public void testSeveralFields() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOffheapBinary() throws Exception { BinaryObjectBuilder builder = builder("Class"); @@ -761,6 +798,7 @@ public void testOffheapBinary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBuildAndDeserialize() throws Exception { BinaryObjectBuilder builder = builder(Value.class.getName()); @@ -777,6 +815,7 @@ public void testBuildAndDeserialize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMetaData2() throws Exception { BinaryObjectBuilder builder = builder("org.test.MetaTest2"); @@ -806,6 +845,7 @@ private String expectedTypeName(String fullClsName) { /** * @throws Exception If failed. */ + @Test public void testMetaData() throws Exception { BinaryObjectBuilder builder = builder("org.test.MetaTest"); @@ -855,6 +895,7 @@ public void testMetaData() throws Exception { /** * */ + @Test public void testGetFromCopiedObj() { BinaryObject objStr = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName()).setField("str", "aaa").build(); @@ -872,6 +913,7 @@ public void testGetFromCopiedObj() { * */ @SuppressWarnings("unchecked") + @Test public void testCopyFromInnerObjects() { ArrayList list = new ArrayList<>(); list.add(new GridBinaryTestClasses.TestObjectAllTypes()); @@ -896,6 +938,7 @@ public void testCopyFromInnerObjects() { /** * */ + @Test public void testSetBinaryObject() { // Prepare marshaller context. CacheObjectBinaryProcessorImpl proc = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()); @@ -915,6 +958,7 @@ public void testSetBinaryObject() { /** * */ + @Test public void testPlainBinaryObjectCopyFrom() { GridBinaryTestClasses.TestObjectPlainBinary obj = new GridBinaryTestClasses.TestObjectPlainBinary(toBinary(new GridBinaryTestClasses.TestObjectAllTypes())); @@ -928,6 +972,7 @@ public void testPlainBinaryObjectCopyFrom() { /** * */ + @Test public void testRemoveFromNewObject() { BinaryObjectBuilder builder = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName()); @@ -941,6 +986,7 @@ public void testRemoveFromNewObject() { /** * */ + @Test public void testRemoveFromExistingObject() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); obj.setDefaultData(); @@ -960,6 +1006,7 @@ public void testRemoveFromExistingObject() { /** * */ + @Test public void testRemoveFromExistingObjectAfterGet() { GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes(); obj.setDefaultData(); @@ -977,6 +1024,7 @@ public void testRemoveFromExistingObjectAfterGet() { /** * @throws IgniteCheckedException If any error occurs. */ + @Test public void testDontBrokeCyclicDependency() throws IgniteCheckedException { GridBinaryTestClasses.TestObjectOuter outer = new GridBinaryTestClasses.TestObjectOuter(); outer.inner = new GridBinaryTestClasses.TestObjectInner(); @@ -1025,7 +1073,6 @@ private BinaryObjectBuilderImpl builder(BinaryObject obj) { /** * */ - @SuppressWarnings("UnusedDeclaration") private static class CustomIdMapper { /** */ private String str = "a"; @@ -1036,7 +1083,6 @@ private static class CustomIdMapper { /** */ - @SuppressWarnings("UnusedDeclaration") private static class Key { /** */ private int i; @@ -1075,7 +1121,6 @@ private Key(int i) { /** */ - @SuppressWarnings("UnusedDeclaration") private static class Value { /** */ private int i; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectExceptionSelfTest.java index 0a10fe74517fb..56517843b9275 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectExceptionSelfTest.java @@ -31,21 +31,19 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * BinaryObjectExceptionSelfTest */ +@RunWith(JUnit4.class) public class BinaryObjectExceptionSelfTest extends GridCommonAbstractTest { /** */ private static final String TEST_KEY = "test_key"; - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private final String cacheName = "cache"; @@ -54,7 +52,6 @@ public class BinaryObjectExceptionSelfTest extends GridCommonAbstractTest { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setMarshaller(new BinaryMarshaller()); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); cfg.setCacheConfiguration( new CacheConfiguration(cacheName) @@ -86,7 +83,7 @@ public class BinaryObjectExceptionSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ - @SuppressWarnings("WhileLoopReplaceableByForEach") + @Test public void testUnexpectedFieldType() throws Exception { IgniteEx grid = grid(0); @@ -157,6 +154,7 @@ public void testUnexpectedFieldType() throws Exception { * * @throws Exception If failed. */ + @Test public void testFailedMarshallingLogging() throws Exception { BinaryMarshaller marshaller = createStandaloneBinaryMarshaller(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectToStringSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectToStringSelfTest.java index e208daac0032d..7e8b183191895 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectToStringSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectToStringSelfTest.java @@ -23,24 +23,21 @@ import java.util.Map; import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@code BinaryObject.toString()}. */ +@RunWith(JUnit4.class) public class BinaryObjectToStringSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setMarshaller(new BinaryMarshaller()); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); return cfg; } @@ -59,6 +56,7 @@ public class BinaryObjectToStringSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testToString() throws Exception { MyObject obj = new MyObject(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectTypeCompatibilityTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectTypeCompatibilityTest.java index 3ef4a83b20ee8..0000029a5bcb4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectTypeCompatibilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectTypeCompatibilityTest.java @@ -36,31 +36,19 @@ import org.apache.ignite.Ignite; import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.binary.BinaryObjectBuilder; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class BinaryObjectTypeCompatibilityTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final Random RANDOM = new Random(System.currentTimeMillis()); - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration igniteCfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)igniteCfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return igniteCfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -69,6 +57,7 @@ public class BinaryObjectTypeCompatibilityTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCompatibilityWithObject() throws Exception { Ignite ignite = startGrid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySerialiedFieldComparatorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySerialiedFieldComparatorSelfTest.java index 4278ef43ea82f..e0f0450d62e33 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySerialiedFieldComparatorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySerialiedFieldComparatorSelfTest.java @@ -30,10 +30,14 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Unit tests for serialized field comparer. */ +@RunWith(JUnit4.class) public class BinarySerialiedFieldComparatorSelfTest extends GridCommonAbstractTest { /** Type counter. */ private static final AtomicInteger TYPE_CTR = new AtomicInteger(); @@ -80,6 +84,7 @@ public class BinarySerialiedFieldComparatorSelfTest extends GridCommonAbstractTe * * @throws Exception If failed. */ + @Test public void testByte() throws Exception { checkTwoValues((byte)1, (byte)2); } @@ -89,6 +94,7 @@ public void testByte() throws Exception { * * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { checkTwoValues(true, false); } @@ -98,6 +104,7 @@ public void testBoolean() throws Exception { * * @throws Exception If failed. */ + @Test public void testShort() throws Exception { checkTwoValues((short)1, (short)2); } @@ -107,6 +114,7 @@ public void testShort() throws Exception { * * @throws Exception If failed. */ + @Test public void testChar() throws Exception { checkTwoValues('a', 'b'); } @@ -116,6 +124,7 @@ public void testChar() throws Exception { * * @throws Exception If failed. */ + @Test public void testInt() throws Exception { checkTwoValues(1, 2); } @@ -125,6 +134,7 @@ public void testInt() throws Exception { * * @throws Exception If failed. */ + @Test public void testLong() throws Exception { checkTwoValues(1L, 2L); } @@ -134,6 +144,7 @@ public void testLong() throws Exception { * * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { checkTwoValues(1.0f, 2.0f); } @@ -143,6 +154,7 @@ public void testFloat() throws Exception { * * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { checkTwoValues(1.0d, 2.0d); } @@ -152,6 +164,7 @@ public void testDouble() throws Exception { * * @throws Exception If failed. */ + @Test public void testString() throws Exception { checkTwoValues("str1", "str2"); } @@ -161,6 +174,7 @@ public void testString() throws Exception { * * @throws Exception If failed. */ + @Test public void testDate() throws Exception { long time = System.currentTimeMillis(); @@ -172,6 +186,7 @@ public void testDate() throws Exception { * * @throws Exception If failed. */ + @Test public void testTimestamp() throws Exception { long time = System.currentTimeMillis(); @@ -183,6 +198,7 @@ public void testTimestamp() throws Exception { * * @throws Exception If failed. */ + @Test public void testUuid() throws Exception { checkTwoValues(UUID.randomUUID(), UUID.randomUUID()); } @@ -192,6 +208,7 @@ public void testUuid() throws Exception { * * @throws Exception If failed. */ + @Test public void testDecimal() throws Exception { checkTwoValues(new BigDecimal("12.3E+7"), new BigDecimal("12.4E+7")); checkTwoValues(new BigDecimal("12.3E+7"), new BigDecimal("12.3E+8")); @@ -202,6 +219,7 @@ public void testDecimal() throws Exception { * * @throws Exception If failed. */ + @Test public void testInnerObject() throws Exception { checkTwoValues(new InnerClass(1), new InnerClass(2)); } @@ -211,6 +229,7 @@ public void testInnerObject() throws Exception { * * @throws Exception If failed. */ + @Test public void testByteArray() throws Exception { checkTwoValues(new byte[] { 1, 2 }, new byte[] { 1, 3 }); checkTwoValues(new byte[] { 1, 2 }, new byte[] { 1 }); @@ -223,6 +242,7 @@ public void testByteArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testBooleanArray() throws Exception { checkTwoValues(new boolean[] { true, false }, new boolean[] { false, true }); checkTwoValues(new boolean[] { true, false }, new boolean[] { true }); @@ -235,6 +255,7 @@ public void testBooleanArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testShortArray() throws Exception { checkTwoValues(new short[] { 1, 2 }, new short[] { 1, 3 }); checkTwoValues(new short[] { 1, 2 }, new short[] { 1 }); @@ -247,6 +268,7 @@ public void testShortArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testCharArray() throws Exception { checkTwoValues(new char[] { 1, 2 }, new char[] { 1, 3 }); checkTwoValues(new char[] { 1, 2 }, new char[] { 1 }); @@ -259,6 +281,7 @@ public void testCharArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testIntArray() throws Exception { checkTwoValues(new int[] { 1, 2 }, new int[] { 1, 3 }); checkTwoValues(new int[] { 1, 2 }, new int[] { 1 }); @@ -271,6 +294,7 @@ public void testIntArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testLongArray() throws Exception { checkTwoValues(new long[] { 1, 2 }, new long[] { 1, 3 }); checkTwoValues(new long[] { 1, 2 }, new long[] { 1 }); @@ -283,6 +307,7 @@ public void testLongArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testFloatArray() throws Exception { checkTwoValues(new float[] { 1.0f, 2.0f }, new float[] { 1.0f, 3.0f }); checkTwoValues(new float[] { 1.0f, 2.0f }, new float[] { 1.0f }); @@ -295,6 +320,7 @@ public void testFloatArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testDoubleArray() throws Exception { checkTwoValues(new double[] { 1.0d, 2.0d }, new double[] { 1.0d, 3.0d }); checkTwoValues(new double[] { 1.0d, 2.0d }, new double[] { 1.0d }); @@ -307,6 +333,7 @@ public void testDoubleArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testStringArray() throws Exception { checkTwoValues(new String[] { "a", "b" }, new String[] { "a", "c" }); checkTwoValues(new String[] { "a", "b" }, new String[] { "a" }); @@ -319,6 +346,7 @@ public void testStringArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testDateArray() throws Exception { long curTime = System.currentTimeMillis(); @@ -337,6 +365,7 @@ public void testDateArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testTimestampArray() throws Exception { long curTime = System.currentTimeMillis(); @@ -355,6 +384,7 @@ public void testTimestampArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testUuidArray() throws Exception { UUID v1 = UUID.randomUUID(); UUID v2 = UUID.randomUUID(); @@ -371,6 +401,7 @@ public void testUuidArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testDecimalArray() throws Exception { BigDecimal v1 = new BigDecimal("12.3E+7"); BigDecimal v2 = new BigDecimal("12.4E+7"); @@ -395,6 +426,7 @@ public void testDecimalArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testInnerObjectArray() throws Exception { InnerClass v1 = new InnerClass(1); InnerClass v2 = new InnerClass(2); @@ -558,4 +590,4 @@ public InnerClass(int val) { this.val = val; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java index b9077d1c6b2f8..d02fb95d63c6f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java @@ -24,6 +24,9 @@ import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.config.GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER; import static org.apache.ignite.testframework.config.GridTestProperties.MARSH_CLASS_NAME; @@ -31,6 +34,7 @@ /** * Tests testing framewrok, epecially BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER test property. */ +@RunWith(JUnit4.class) public class BinarySimpleNameTestPropertySelfTest extends GridCommonAbstractTest { /** * flag for facade disabled test. As we use binary marshaller by default al @@ -55,6 +59,7 @@ public class BinarySimpleNameTestPropertySelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testPropertyEnabled() throws Exception { String useSimpleNameBackup = GridTestProperties.getProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER); @@ -72,6 +77,7 @@ public void testPropertyEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPropertyDisabled() throws Exception { checkProperty("org.ignite.test.TestClass"); } @@ -80,6 +86,7 @@ public void testPropertyDisabled() throws Exception { * Check if Binary facade is disabled test. Test uses JDK marshaller to provide warranty facade is not available * @throws Exception If failed. */ + @Test public void testBinaryDisabled() throws Exception { enableJdkMarshaller = true; assertNull(startGrid().binary()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryTreeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryTreeSelfTest.java index 8d84f54d072d4..4d9e3544ff5a4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryTreeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryTreeSelfTest.java @@ -33,10 +33,14 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for TreeMap and TreeSet structures. */ +@RunWith(JUnit4.class) public class BinaryTreeSelfTest extends GridCommonAbstractTest { /** Data structure size. */ private static final int SIZE = 100; @@ -69,6 +73,7 @@ public class BinaryTreeSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testTreeMapAsValueRegularNoComparator() throws Exception { checkTreeMapAsValue(false, false); } @@ -78,6 +83,7 @@ public void testTreeMapAsValueRegularNoComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeMapAsValueRegularComparator() throws Exception { checkTreeMapAsValue(false, true); } @@ -87,6 +93,7 @@ public void testTreeMapAsValueRegularComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeMapAsValueBinaryNoComparator() throws Exception { checkTreeMapAsValue(true, false); } @@ -96,6 +103,7 @@ public void testTreeMapAsValueBinaryNoComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeMapAsValueBinaryComparator() throws Exception { checkTreeMapAsValue(true, true); } @@ -105,6 +113,7 @@ public void testTreeMapAsValueBinaryComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeMapAsKeyNoComparator() throws Exception { checkTreeMapAsKey(false); } @@ -114,6 +123,7 @@ public void testTreeMapAsKeyNoComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeMapAsKeyComparator() throws Exception { checkTreeMapAsKey(true); } @@ -224,6 +234,7 @@ private TreeMap testMap(boolean useComp) { * * @throws Exception If failed. */ + @Test public void testTreeSetAsValueRegularNoComparator() throws Exception { checkTreeSetAsValue(false, false); } @@ -233,6 +244,7 @@ public void testTreeSetAsValueRegularNoComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeSetAsValueRegularComparator() throws Exception { checkTreeSetAsValue(false, true); } @@ -242,6 +254,7 @@ public void testTreeSetAsValueRegularComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeSetAsValueBinaryNoComparator() throws Exception { checkTreeSetAsValue(true, false); } @@ -251,6 +264,7 @@ public void testTreeSetAsValueBinaryNoComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeSetAsValueBinaryComparator() throws Exception { checkTreeSetAsValue(true, true); } @@ -260,6 +274,7 @@ public void testTreeSetAsValueBinaryComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeSetAsKeyNoComparator() throws Exception { checkTreeSetAsKey(false); } @@ -269,6 +284,7 @@ public void testTreeSetAsKeyNoComparator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTreeSetAsKeyComparator() throws Exception { checkTreeSetAsKey(true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryAffinityKeySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryAffinityKeySelfTest.java index 8d3f34bb1442a..67dc057f32c63 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryAffinityKeySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryAffinityKeySelfTest.java @@ -36,23 +36,21 @@ import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.binary.BinaryTypeConfiguration; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Test for binary object affinity key. */ +@RunWith(JUnit4.class) public class GridBinaryAffinityKeySelfTest extends GridCommonAbstractTest { /** */ private static final AtomicReference nodeId = new AtomicReference<>(); - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static int GRID_CNT = 5; @@ -85,8 +83,6 @@ public class GridBinaryAffinityKeySelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheCfg); } - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - return cfg; } @@ -98,6 +94,7 @@ public class GridBinaryAffinityKeySelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAffinity() throws Exception { checkAffinity(grid(0)); @@ -167,6 +164,7 @@ private void checkAffinity(Ignite ignite) throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityRun() throws Exception { Affinity aff = grid(0).affinity(DEFAULT_CACHE_NAME); @@ -200,6 +198,7 @@ public void testAffinityRun() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityCall() throws Exception { Affinity aff = grid(0).affinity(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMarshallerCtxDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMarshallerCtxDisabledSelfTest.java index bb7c65d6d2136..ac0fa000ceef2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMarshallerCtxDisabledSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMarshallerCtxDisabledSelfTest.java @@ -34,14 +34,19 @@ import org.apache.ignite.marshaller.MarshallerContext; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridBinaryMarshallerCtxDisabledSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testObjectExchange() throws Exception { BinaryMarshaller marsh = new BinaryMarshaller(); marsh.setContext(new MarshallerContextWithNoStorage()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java index f69cea45899f0..74b53d76a1fa0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java @@ -37,10 +37,14 @@ import org.apache.ignite.logger.NullLogger; import org.apache.ignite.marshaller.MarshallerContextTestImpl; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Wildcards test. */ +@RunWith(JUnit4.class) public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest { /** */ public static final String CLASS1_FULL_NAME = GridBinaryTestClass1.class.getName(); @@ -54,6 +58,7 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testClassNamesFullNameMapper() throws Exception { checkClassNames(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false)); } @@ -61,6 +66,7 @@ public void testClassNamesFullNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClassNamesSimpleNameMapper() throws Exception { checkClassNames(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true)); } @@ -68,6 +74,7 @@ public void testClassNamesSimpleNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClassNamesMixedMappers() throws Exception { checkClassNames(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(true)); } @@ -97,6 +104,7 @@ private void checkClassNames(BinaryNameMapper nameMapper, BinaryIdMapper mapper) /** * @throws Exception If failed. */ + @Test public void testClassNamesCustomMappers() throws Exception { BinaryMarshaller marsh = binaryMarshaller(null, new BinaryIdMapper() { @SuppressWarnings("IfMayBeConditional") @@ -133,6 +141,7 @@ else if (clsName.endsWith("InnerClass")) /** * @throws Exception If failed. */ + @Test public void testTypeConfigurationsSimpleNameIdMapper() throws Exception { checkTypeConfigurations(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true)); } @@ -140,6 +149,7 @@ public void testTypeConfigurationsSimpleNameIdMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTypeConfigurationsFullNameIdMapper() throws Exception { checkTypeConfigurations(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false)); } @@ -185,6 +195,7 @@ private int typeId(String typeName, BinaryNameMapper nameMapper, BinaryIdMapper /** * @throws Exception If failed. */ + @Test public void testTypeConfigurationsWithGlobalMapper() throws Exception { BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() { @SuppressWarnings("IfMayBeConditional") @@ -221,6 +232,7 @@ else if (clsName.endsWith("InnerClass")) /** * @throws Exception If failed. */ + @Test public void testTypeConfigurationsWithNonGlobalMapper() throws Exception { BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryIdMapper() { @SuppressWarnings("IfMayBeConditional") @@ -257,6 +269,7 @@ else if (clsName.endsWith("InnerClass")) /** * @throws Exception If failed. */ + @Test public void testOverrideIdMapperSimpleNameMapper() throws Exception { checkOverrideNameMapper(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true)); } @@ -264,6 +277,7 @@ public void testOverrideIdMapperSimpleNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOverrideIdMapperFullNameMapper() throws Exception { checkOverrideNameMapper(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false)); } @@ -310,6 +324,7 @@ private void checkOverrideIdMapper(BinaryNameMapper nameMapper, BinaryIdMapper m /** * @throws Exception If failed. */ + @Test public void testOverrideNameMapperSimpleNameMapper() throws Exception { checkOverrideNameMapper(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true)); } @@ -317,6 +332,7 @@ public void testOverrideNameMapperSimpleNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOverrideNameMapperFullNameMapper() throws Exception { checkOverrideNameMapper(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false)); } @@ -363,6 +379,7 @@ private void checkOverrideNameMapper(BinaryNameMapper nameMapper, BinaryIdMapper /** * @throws Exception If failed. */ + @Test public void testClassNamesJarFullNameMapper() throws Exception { checkClassNamesJar(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false)); } @@ -370,6 +387,7 @@ public void testClassNamesJarFullNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClassNamesJarSimpleNameMapper() throws Exception { checkClassNamesJar(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true)); } @@ -399,6 +417,7 @@ private void checkClassNamesJar(BinaryNameMapper nameMapper, BinaryIdMapper idMa /** * @throws Exception If failed. */ + @Test public void testClassNamesWithCustomMapperJar() throws Exception { BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() { @SuppressWarnings("IfMayBeConditional") @@ -435,6 +454,7 @@ else if (clsName.endsWith("2")) /** * @throws Exception If failed. */ + @Test public void testTypeConfigurationsJarSimpleNameMapper() throws Exception { checkTypeConfigurationJar(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true)); } @@ -442,6 +462,7 @@ public void testTypeConfigurationsJarSimpleNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTypeConfigurationsJarFullNameMapper() throws Exception { checkTypeConfigurationJar(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false)); } @@ -472,6 +493,7 @@ private void checkTypeConfigurationJar(BinaryNameMapper nameMapper, BinaryIdMapp /** * @throws Exception If failed. */ + @Test public void testTypeConfigurationsWithGlobalMapperJar() throws Exception { BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() { @SuppressWarnings("IfMayBeConditional") @@ -508,6 +530,7 @@ else if (clsName.endsWith("2")) /** * @throws Exception If failed. */ + @Test public void testTypeConfigurationsWithNonGlobalMapperJar() throws Exception { BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() { @SuppressWarnings("IfMayBeConditional") @@ -544,6 +567,7 @@ else if (clsName.endsWith("2")) /** * @throws Exception If failed. */ + @Test public void testOverrideJarSimpleNameMapper() throws Exception { checkOverrideJar(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true)); } @@ -551,6 +575,7 @@ public void testOverrideJarSimpleNameMapper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOverrideJarFullNameMapper() throws Exception { checkOverrideJar(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false)); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java index 06fb3f4c00757..649dd1dacb31c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java @@ -38,10 +38,14 @@ import org.apache.ignite.binary.BinaryReader; import org.apache.ignite.binary.BinaryWriter; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Binary meta data test. */ +@RunWith(JUnit4.class) public class GridDefaultBinaryMappersBinaryMetaDataSelfTest extends GridCommonAbstractTest { /** */ private static IgniteConfiguration cfg; @@ -95,6 +99,7 @@ protected IgniteBinary binaries() { /** * @throws Exception If failed. */ + @Test public void testGetAll() throws Exception { binaries().toBinary(new TestObject2()); @@ -155,6 +160,7 @@ else if (expectedTypeName(TestObject2.class.getName()).equals(meta.typeName())) /** * @throws Exception If failed. */ + @Test public void testNoConfiguration() throws Exception { binaries().toBinary(new TestObject3()); @@ -164,6 +170,7 @@ public void testNoConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReflection() throws Exception { BinaryType meta = binaries().type(TestObject1.class); @@ -208,6 +215,7 @@ private String expectedTypeName(String clsName) { /** * @throws Exception If failed. */ + @Test public void testBinaryMarshalAware() throws Exception { binaries().toBinary(new TestObject2()); @@ -241,6 +249,7 @@ public void testBinaryMarshalAware() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMerge() throws Exception { binaries().toBinary(new TestObject2()); @@ -282,6 +291,7 @@ public void testMerge() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSerializedObject() throws Exception { TestObject1 obj = new TestObject1(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java index c68a8862aba4e..e857ef2ea785c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java @@ -20,6 +20,9 @@ import java.util.Random; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.GridTestIoUtils.getCharByByteLE; import static org.apache.ignite.GridTestIoUtils.getDoubleByByteLE; @@ -31,6 +34,7 @@ /** * Binary input/output streams byte order sanity tests. */ +@RunWith(JUnit4.class) public abstract class AbstractBinaryStreamByteOrderSelfTest extends GridCommonAbstractTest { /** Array length. */ protected static final int ARR_LEN = 16; @@ -64,6 +68,7 @@ public abstract class AbstractBinaryStreamByteOrderSelfTest extends GridCommonAb /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { short val = (short)RND.nextLong(); @@ -109,6 +114,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShortArray() throws Exception { short[] arr = new short[ARR_LEN]; @@ -128,6 +134,7 @@ public void testShortArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testChar() throws Exception { char val = (char)RND.nextLong(); @@ -157,6 +164,7 @@ public void testChar() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCharArray() throws Exception { char[] arr = new char[ARR_LEN]; @@ -176,6 +184,7 @@ public void testCharArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInt() throws Exception { int val = RND.nextInt(); @@ -228,6 +237,7 @@ public void testInt() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIntArray() throws Exception { int[] arr = new int[ARR_LEN]; @@ -247,6 +257,7 @@ public void testIntArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { long val = RND.nextLong(); @@ -283,6 +294,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLongArray() throws Exception { long[] arr = new long[ARR_LEN]; @@ -302,6 +314,7 @@ public void testLongArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { float val = RND.nextFloat(); @@ -330,6 +343,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloatArray() throws Exception { float[] arr = new float[ARR_LEN]; @@ -349,6 +363,7 @@ public void testFloatArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { double val = RND.nextDouble(); @@ -377,6 +392,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDoubleArray() throws Exception { double[] arr = new double[ARR_LEN]; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStreamTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStreamTest.java index ed1d3d65ad19d..7ee9c74211a31 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStreamTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStreamTest.java @@ -18,14 +18,19 @@ package org.apache.ignite.internal.binary.streams; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class BinaryAbstractOutputStreamTest extends GridCommonAbstractTest { /** * */ + @Test public void testCapacity() { assertEquals(256, BinaryAbstractOutputStream.capacity(0, 1)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/commandline/CommandHandlerParsingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/commandline/CommandHandlerParsingTest.java index 0ac5d1a4483b0..45b0aab55b07e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/commandline/CommandHandlerParsingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/commandline/CommandHandlerParsingTest.java @@ -38,6 +38,7 @@ import static org.apache.ignite.internal.commandline.CommandHandler.VI_CHECK_THROUGH; import static org.apache.ignite.internal.commandline.CommandHandler.WAL_DELETE; import static org.apache.ignite.internal.commandline.CommandHandler.WAL_PRINT; +import static org.junit.Assert.assertArrayEquals; /** * Tests Command Handler parsing arguments. @@ -167,46 +168,66 @@ public void testExperimentalCommandIsDisabled() { } /** - * Tests parsing and validation for user and password arguments. + * Tests parsing and validation for the SSL arguments. */ - public void testParseAndValidateUserAndPassword() { + public void testParseAndValidateSSLArguments() { CommandHandler hnd = new CommandHandler(); for (Command cmd : Command.values()) { + if (cmd == Command.CACHE || cmd == Command.WAL) continue; // --cache subcommand requires its own specific arguments. try { - hnd.parseAndValidate(asList("--user")); + hnd.parseAndValidate(asList("--truststore")); - fail("expected exception: Expected user name"); + fail("expected exception: Expected truststore"); } catch (IllegalArgumentException e) { e.printStackTrace(); } - try { - hnd.parseAndValidate(asList("--password")); + Arguments args = hnd.parseAndValidate(asList("--keystore", "testKeystore", "--keystore-password", "testKeystorePassword", "--keystore-type", "testKeystoreType", + "--truststore", "testTruststore", "--truststore-password", "testTruststorePassword", "--truststore-type", "testTruststoreType", + "--ssl-key-algorithm", "testSSLKeyAlgorithm", "--ssl-protocol", "testSSLProtocol", cmd.text())); - fail("expected exception: Expected password"); - } - catch (IllegalArgumentException e) { - e.printStackTrace(); - } + assertEquals("testSSLProtocol", args.sslProtocol()); + assertEquals("testSSLKeyAlgorithm", args.sslKeyAlgorithm()); + assertEquals("testKeystore", args.sslKeyStorePath()); + assertArrayEquals("testKeystorePassword".toCharArray(), args.sslKeyStorePassword()); + assertEquals("testKeystoreType", args.sslKeyStoreType()); + assertEquals("testTruststore", args.sslTrustStorePath()); + assertArrayEquals("testTruststorePassword".toCharArray(), args.sslTrustStorePassword()); + assertEquals("testTruststoreType", args.sslTrustStoreType()); + + assertEquals(cmd, args.command()); + } + } + + + /** + * Tests parsing and validation for user and password arguments. + */ + public void testParseAndValidateUserAndPassword() { + CommandHandler hnd = new CommandHandler(); + + for (Command cmd : Command.values()) { + if (cmd == Command.CACHE || cmd == Command.WAL) + continue; // --cache subcommand requires its own specific arguments. try { - hnd.parseAndValidate(asList("--user", "testUser", cmd.text())); + hnd.parseAndValidate(asList("--user")); - fail("expected exception: Both user and password should be specified"); + fail("expected exception: Expected user name"); } catch (IllegalArgumentException e) { e.printStackTrace(); } try { - hnd.parseAndValidate(asList("--password", "testPass", cmd.text())); + hnd.parseAndValidate(asList("--password")); - fail("expected exception: Both user and password should be specified"); + fail("expected exception: Expected password"); } catch (IllegalArgumentException e) { e.printStackTrace(); @@ -214,8 +235,8 @@ public void testParseAndValidateUserAndPassword() { Arguments args = hnd.parseAndValidate(asList("--user", "testUser", "--password", "testPass", cmd.text())); - assertEquals("testUser", args.user()); - assertEquals("testPass", args.password()); + assertEquals("testUser", args.getUserName()); + assertEquals("testPass", args.getPassword()); assertEquals(cmd, args.command()); } } @@ -304,7 +325,7 @@ public void testParseAutoConfirmationFlag() { break; } case TX: { - args = hnd.parseAndValidate(asList(cmd.text(), "xid", "xid1", "minDuration", "10", "kill", "--yes")); + args = hnd.parseAndValidate(asList(cmd.text(), "--xid", "xid1", "--min-duration", "10", "--kill", "--yes")); assertEquals(cmd, args.command()); assertEquals(DFLT_HOST, args.host()); @@ -440,8 +461,8 @@ public void testTransactionArguments() { catch (IllegalArgumentException ignored) { } - args = hnd.parseAndValidate(asList("--tx", "minDuration", "120", "minSize", "10", "limit", "100", "order", "SIZE", - "servers")); + args = hnd.parseAndValidate(asList("--tx", "--min-duration", "120", "--min-size", "10", "--limit", "100", "--order", "SIZE", + "--servers")); VisorTxTaskArg arg = args.transactionArguments(); @@ -451,8 +472,8 @@ public void testTransactionArguments() { assertEquals(VisorTxSortOrder.SIZE, arg.getSortOrder()); assertEquals(VisorTxProjection.SERVER, arg.getProjection()); - args = hnd.parseAndValidate(asList("--tx", "minDuration", "130", "minSize", "1", "limit", "60", "order", "DURATION", - "clients")); + args = hnd.parseAndValidate(asList("--tx", "--min-duration", "130", "--min-size", "1", "--limit", "60", "--order", "DURATION", + "--clients")); arg = args.transactionArguments(); @@ -462,7 +483,7 @@ public void testTransactionArguments() { assertEquals(VisorTxSortOrder.DURATION, arg.getSortOrder()); assertEquals(VisorTxProjection.CLIENT, arg.getProjection()); - args = hnd.parseAndValidate(asList("--tx", "nodes", "1,2,3")); + args = hnd.parseAndValidate(asList("--tx", "--nodes", "1,2,3")); arg = args.transactionArguments(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java index 710e4454562c9..0423b78e0f490 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java @@ -22,13 +22,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import junit.framework.TestCase; import org.apache.ignite.IgniteException; import org.apache.ignite.internal.direct.stream.DirectByteBufferStream; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.jetbrains.annotations.Nullable; +import org.junit.Before; +import org.junit.Test; import static org.apache.ignite.GridTestIoUtils.getCharByByteLE; import static org.apache.ignite.GridTestIoUtils.getDoubleByByteLE; @@ -37,11 +38,15 @@ import static org.apache.ignite.GridTestIoUtils.getLongByByteLE; import static org.apache.ignite.GridTestIoUtils.getShortByByteLE; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * {@link DirectByteBufferStreamImplV2} byte order sanity tests. */ -public class DirectByteBufferStreamImplV2ByteOrderSelfTest extends TestCase { +public class DirectByteBufferStreamImplV2ByteOrderSelfTest { /** Array length. */ private static final int ARR_LEN = 16; @@ -60,10 +65,9 @@ public class DirectByteBufferStreamImplV2ByteOrderSelfTest extends TestCase { /** Array. */ private byte[] outArr; - /** {@inheritDoc} */ - @Override public void setUp() throws Exception { - super.setUp(); - + /** */ + @Before + public void setUp() throws Exception { outArr = new byte[ARR_LEN * 8 + LEN_BYTES]; buff = ByteBuffer.wrap(outArr); @@ -92,6 +96,7 @@ private static DirectByteBufferStreamImplV2 createStream(ByteBuffer buff) { /** * */ + @Test public void testShortArray() { short[] arr = new short[ARR_LEN]; @@ -111,6 +116,7 @@ public void testShortArray() { /** * */ + @Test public void testCharArray() { char[] arr = new char[ARR_LEN]; @@ -130,6 +136,7 @@ public void testCharArray() { /** * */ + @Test public void testIntArray() { int[] arr = new int[ARR_LEN]; @@ -149,6 +156,7 @@ public void testIntArray() { /** * */ + @Test public void testLongArray() { long[] arr = new long[ARR_LEN]; @@ -168,6 +176,7 @@ public void testLongArray() { /** * */ + @Test public void testFloatArray() { float[] arr = new float[ARR_LEN]; @@ -187,6 +196,7 @@ public void testFloatArray() { /** * */ + @Test public void testDoubleArray() { double[] arr = new double[ARR_LEN]; @@ -206,6 +216,7 @@ public void testDoubleArray() { /** * */ + @Test public void testCharArrayInternal() { char[] arr = new char[ARR_LEN]; @@ -226,6 +237,7 @@ public void testCharArrayInternal() { /** * */ + @Test public void testShortArrayInternal() { short[] arr = new short[ARR_LEN]; @@ -246,6 +258,7 @@ public void testShortArrayInternal() { /** * */ + @Test public void testIntArrayInternal() { int[] arr = new int[ARR_LEN]; @@ -266,6 +279,7 @@ public void testIntArrayInternal() { /** * */ + @Test public void testLongArrayInternal() { long[] arr = new long[ARR_LEN]; @@ -286,6 +300,7 @@ public void testLongArrayInternal() { /** * */ + @Test public void testFloatArrayInternal() { float[] arr = new float[ARR_LEN]; @@ -306,6 +321,7 @@ public void testFloatArrayInternal() { /** * */ + @Test public void testDoubleArrayInternal() { double[] arr = new double[ARR_LEN]; @@ -519,4 +535,4 @@ else if (arr.getClass().getComponentType() == double.class) else throw new IllegalArgumentException("Unsupported array type"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheBigEntryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheBigEntryTest.java index deb72e474efe6..a72e93e8b2f63 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheBigEntryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheBigEntryTest.java @@ -27,12 +27,16 @@ import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * Tests to check encryption of entry bigger then page size. */ +@RunWith(JUnit4.class) public class EncryptedCacheBigEntryTest extends AbstractEncryptionTest { /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { @@ -47,6 +51,7 @@ public class EncryptedCacheBigEntryTest extends AbstractEncryptionTest { } /** @throws Exception If failed. */ + @Test public void testCreateEncryptedCacheWithBigEntry() throws Exception { T2 grids = startTestGrids(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheCreateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheCreateTest.java index 47d8d8f6914d1..157f09d47ac52 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheCreateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheCreateTest.java @@ -33,8 +33,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class EncryptedCacheCreateTest extends AbstractEncryptionTest { /** Non-persistent data region name. */ private static final String NO_PERSISTENCE_REGION = "no-persistence-region"; @@ -74,6 +79,7 @@ public class EncryptedCacheCreateTest extends AbstractEncryptionTest { } /** @throws Exception If failed. */ + @Test public void testCreateEncryptedCache() throws Exception { CacheConfiguration ccfg = new CacheConfiguration<>(ENCRYPTED_CACHE); @@ -95,9 +101,9 @@ public void testCreateEncryptedCache() throws Exception { } /** @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8640") + @Test public void testCreateEncryptedNotPersistedCacheFail() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-8640"); - GridTestUtils.assertThrowsWithCause(() -> { CacheConfiguration ccfg = new CacheConfiguration<>(NO_PERSISTENCE_REGION); @@ -109,6 +115,7 @@ public void testCreateEncryptedNotPersistedCacheFail() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPersistedContentEncrypted() throws Exception { IgniteCache enc = grid(0).createCache( new CacheConfiguration(ENCRYPTED_CACHE) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheDestroyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheDestroyTest.java index 11855ecbdb602..cfbe642bc5e4b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheDestroyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheDestroyTest.java @@ -23,11 +23,15 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.managers.encryption.GridEncryptionManager.ENCRYPTION_KEY_PREFIX; /** */ +@RunWith(JUnit4.class) public class EncryptedCacheDestroyTest extends AbstractEncryptionTest { /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { @@ -39,6 +43,7 @@ public class EncryptedCacheDestroyTest extends AbstractEncryptionTest { /** * @throws Exception If failed. */ + @Test public void testEncryptedCacheDestroy() throws Exception { T2 grids = startTestGrids(true); @@ -62,6 +67,7 @@ public void testEncryptedCacheDestroy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEncryptedCacheFromGroupDestroy() throws Exception { T2 grids = startTestGrids(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheGroupCreateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheGroupCreateTest.java index 56f578d21e1b2..6a7bf83bdb9ca 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheGroupCreateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheGroupCreateTest.java @@ -25,9 +25,13 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class EncryptedCacheGroupCreateTest extends AbstractEncryptionTest { /** */ public static final String ENCRYPTED_GROUP = "encrypted-group"; @@ -53,6 +57,7 @@ public class EncryptedCacheGroupCreateTest extends AbstractEncryptionTest { } /** @throws Exception If failed. */ + @Test public void testCreateEncryptedCacheGroup() throws Exception { KeystoreEncryptionKey key = createEncryptedCache(ENCRYPTED_CACHE, ENCRYPTED_GROUP); @@ -78,6 +83,7 @@ public void testCreateEncryptedCacheGroup() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreateNotEncryptedCacheInEncryptedGroupFails() throws Exception { createEncryptedCache(ENCRYPTED_CACHE + "3", ENCRYPTED_GROUP + "3"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheNodeJoinTest.java b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheNodeJoinTest.java index 41a250cb3d6fa..cca156aea426f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheNodeJoinTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheNodeJoinTest.java @@ -23,11 +23,15 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; /** */ +@RunWith(JUnit4.class) public class EncryptedCacheNodeJoinTest extends AbstractEncryptionTest { /** */ private static final String GRID_2 = "grid-2"; @@ -105,6 +109,7 @@ protected CacheConfiguration cacheConfiguration(String gridName) { } /** */ + @Test public void testNodeCantJoinWithoutEncryptionSpi() throws Exception { startGrid(GRID_0); @@ -119,6 +124,7 @@ public void testNodeCantJoinWithoutEncryptionSpi() throws Exception { } /** */ + @Test public void testNodeCantJoinWithDifferentKeyStore() throws Exception { startGrid(GRID_0); @@ -133,6 +139,7 @@ public void testNodeCantJoinWithDifferentKeyStore() throws Exception { } /** */ + @Test public void testNodeCanJoin() throws Exception { startGrid(GRID_0); @@ -140,6 +147,7 @@ public void testNodeCanJoin() throws Exception { } /** */ + @Test public void testNodeCantJoinWithDifferentCacheKeys() throws Exception { IgniteEx grid0 = startGrid(GRID_0); startGrid(GRID_3); @@ -168,6 +176,7 @@ public void testNodeCantJoinWithDifferentCacheKeys() throws Exception { } /** */ + @Test public void testThirdNodeCanJoin() throws Exception { IgniteEx grid0 = startGrid(GRID_0); @@ -187,6 +196,7 @@ public void testThirdNodeCanJoin() throws Exception { } /** */ + @Test public void testClientNodeJoin() throws Exception { IgniteEx grid0 = startGrid(GRID_0); @@ -200,6 +210,7 @@ public void testClientNodeJoin() throws Exception { } /** */ + @Test public void testNodeCantJoinWithSameNameButNotEncCache() throws Exception { configureCache = true; @@ -218,6 +229,7 @@ public void testNodeCantJoinWithSameNameButNotEncCache() throws Exception { } /** */ + @Test public void testNodeCantJoinWithSameNameButEncCache() throws Exception { configureCache = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCachePreconfiguredRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCachePreconfiguredRestartTest.java index 2e1334038ee1b..58e2c3d1b1760 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCachePreconfiguredRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCachePreconfiguredRestartTest.java @@ -22,8 +22,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class EncryptedCachePreconfiguredRestartTest extends EncryptedCacheRestartTest { /** */ private boolean differentCachesOnNodes; @@ -41,6 +45,7 @@ public class EncryptedCachePreconfiguredRestartTest extends EncryptedCacheRestar } /** @throws Exception If failed. */ + @Test public void testDifferentPreconfiguredCachesOnNodes() throws Exception { differentCachesOnNodes = true; @@ -48,6 +53,7 @@ public void testDifferentPreconfiguredCachesOnNodes() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testCreateEncryptedCache() throws Exception { differentCachesOnNodes = false; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheRestartTest.java index 2b010720aecf3..638fc53320652 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/encryption/EncryptedCacheRestartTest.java @@ -21,8 +21,12 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class EncryptedCacheRestartTest extends AbstractEncryptionTest { /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { @@ -37,6 +41,7 @@ public class EncryptedCacheRestartTest extends AbstractEncryptionTest { } /** @throws Exception If failed. */ + @Test public void testCreateEncryptedCache() throws Exception { T2 grids = startTestGrids(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java index b88eef9e417d1..e969110d64018 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java @@ -32,11 +32,11 @@ import org.apache.ignite.spi.IgniteSpiContext; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.NANOSECONDS; @@ -45,10 +45,8 @@ /** * Test Managers to add and remove local message listener. */ +@RunWith(JUnit4.class) public class GridManagerLocalMessageListenerSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final short DIRECT_TYPE = 210; @@ -64,12 +62,6 @@ public class GridManagerLocalMessageListenerSelfTest extends GridCommonAbstractT @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - c.setDiscoverySpi(discoSpi); - TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); c.setCommunicationSpi(commSpi); @@ -85,6 +77,7 @@ public class GridManagerLocalMessageListenerSelfTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testSendMessage() throws Exception { startGridsMultiThreaded(2); @@ -121,6 +114,7 @@ public void testSendMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddLocalMessageListener() throws Exception { startGrid(); @@ -136,6 +130,7 @@ public void testAddLocalMessageListener() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveLocalMessageListener() throws Exception { startGrid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerMxBeanIllegalArgumentHandleTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerMxBeanIllegalArgumentHandleTest.java index 0276abdff2aa2..7e0caa916a1c4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerMxBeanIllegalArgumentHandleTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerMxBeanIllegalArgumentHandleTest.java @@ -21,17 +21,20 @@ import java.lang.management.MemoryUsage; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import junit.framework.TestCase; import org.apache.ignite.IgniteLogger; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.jetbrains.annotations.NotNull; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; /** @@ -39,7 +42,7 @@ * * Test modifies static final field, used only for development */ -public class GridManagerMxBeanIllegalArgumentHandleTest extends TestCase { +public class GridManagerMxBeanIllegalArgumentHandleTest { /** Original value of {@link GridDiscoveryManager#mem} to be restored after test */ private Object mxBeanToRestore; @@ -49,9 +52,9 @@ public class GridManagerMxBeanIllegalArgumentHandleTest extends TestCase { /** If we succeeded to set final field this flag is true, otherwise test assertions will not be performed */ private boolean correctSetupOfTestPerformed; - /** {@inheritDoc} Changes field to always failing mock */ - @Override public void setUp() throws Exception { - super.setUp(); + /** Changes field to always failing mock. */ + @Before + public void setUp() throws Exception { try { final MemoryMXBean memoryMXBean = createAlwaysFailingMxBean(); memMxBeanField = createAccessibleMemField(); @@ -95,13 +98,14 @@ public class GridManagerMxBeanIllegalArgumentHandleTest extends TestCase { * * @throws Exception if field set failed */ - @Override public void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() throws Exception { if (correctSetupOfTestPerformed) memMxBeanField.set(null, mxBeanToRestore); } /** Creates minimal disco manager mock, checks illegal state is not propagated */ + @Test public void testIllegalStateIsCatch() { final IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setDiscoverySpi(new TcpDiscoverySpi()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerStopSelfTest.java index 283ef8702ea56..bef42cba028d5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerStopSelfTest.java @@ -47,11 +47,15 @@ import org.apache.ignite.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi; import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Managers stop test. * */ +@RunWith(JUnit4.class) public class GridManagerStopSelfTest extends GridCommonAbstractTest { /** Kernal context. */ private GridTestKernalContext ctx; @@ -88,6 +92,7 @@ private void injectLogger(IgniteSpi target) throws IgniteCheckedException { /** * @throws Exception If failed. */ + @Test public void testStopCheckpointManager() throws Exception { SharedFsCheckpointSpi spi = new SharedFsCheckpointSpi(); @@ -103,6 +108,7 @@ public void testStopCheckpointManager() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopCollisionManager() throws Exception { CollisionSpi spi = new FifoQueueCollisionSpi(); @@ -118,6 +124,7 @@ public void testStopCollisionManager() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopCommunicationManager() throws Exception { CommunicationSpi spi = new TcpCommunicationSpi(); @@ -136,6 +143,7 @@ public void testStopCommunicationManager() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopDeploymentManager() throws Exception { DeploymentSpi spi = new LocalDeploymentSpi(); @@ -151,6 +159,7 @@ public void testStopDeploymentManager() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopDiscoveryManager() throws Exception { DiscoverySpi spi = new TcpDiscoverySpi(); @@ -166,6 +175,7 @@ public void testStopDiscoveryManager() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopEventStorageManager() throws Exception { EventStorageSpi spi = new MemoryEventStorageSpi(); @@ -181,6 +191,7 @@ public void testStopEventStorageManager() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopFailoverManager() throws Exception { AlwaysFailoverSpi spi = new AlwaysFailoverSpi(); @@ -196,6 +207,7 @@ public void testStopFailoverManager() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopLoadBalancingManager() throws Exception { RoundRobinLoadBalancingSpi spi = new RoundRobinLoadBalancingSpi(); @@ -207,4 +219,4 @@ public void testStopLoadBalancingManager() throws Exception { mgr.stop(true); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridNoopManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridNoopManagerSelfTest.java index 795bda41fe069..4146c2eba6999 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridNoopManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridNoopManagerSelfTest.java @@ -27,14 +27,19 @@ import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests manager with {@link org.apache.ignite.spi.IgniteSpiNoop} SPI's. */ +@RunWith(JUnit4.class) public class GridNoopManagerSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testEnabledManager() throws IgniteCheckedException { GridTestKernalContext ctx = new GridTestKernalContext(new GridStringLogger()); @@ -96,4 +101,4 @@ private static class Spi extends IgniteSpiAdapter implements TestSpi { private static class NoopSpi extends Spi { // No-op. } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java index a29d572cb6949..6de5bb510d14c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java @@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; @@ -43,17 +44,19 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -62,10 +65,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -82,8 +83,6 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (testSpi) cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); @@ -109,8 +108,17 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDiagnosticMessages1() throws Exception { - checkBasicDiagnosticInfo(); + checkBasicDiagnosticInfo(CacheAtomicityMode.TRANSACTIONAL); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testDiagnosticMessagesMvcc1() throws Exception { + checkBasicDiagnosticInfo(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); } /** @@ -119,13 +127,40 @@ public void testDiagnosticMessages1() throws Exception { public void testDiagnosticMessages2() throws Exception { connectionsPerNode = 5; - checkBasicDiagnosticInfo(); + checkBasicDiagnosticInfo(CacheAtomicityMode.TRANSACTIONAL); } /** * @throws Exception If failed. */ + @Test + public void testDiagnosticMessagesMvcc2() throws Exception { + connectionsPerNode = 5; + + checkBasicDiagnosticInfo(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testLongRunning() throws Exception { + checkLongRunning(TRANSACTIONAL); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testLongRunningMvcc() throws Exception { + checkLongRunning(TRANSACTIONAL_SNAPSHOT); + } + + /** + * @param atomicityMode Cache atomicity mode. + * @throws Exception If failed. + */ + public void checkLongRunning(CacheAtomicityMode atomicityMode) throws Exception { System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500"); try { @@ -139,11 +174,7 @@ public void testLongRunning() throws Exception { awaitPartitionMapExchange(); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode); final Ignite node0 = ignite(0); @@ -183,10 +214,40 @@ public void testLongRunning() throws Exception { } } + /** + * @param atomicityMode Cache atomicity mode. + * @return Cache configuration. + */ + @SuppressWarnings("unchecked") + private CacheConfiguration cacheConfiguration(CacheAtomicityMode atomicityMode) { + return defaultCacheConfiguration() + .setAtomicityMode(atomicityMode) + .setWriteSynchronizationMode(FULL_SYNC) + .setNearConfiguration(null); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9322") // Fix diagnostic message or disable test. + @Test + public void testSeveralLongRunningMvccTxs() throws Exception { + checkSeveralLongRunningTxs(TRANSACTIONAL_SNAPSHOT); + } + /** * @throws Exception If failed. */ + @Test public void testSeveralLongRunningTxs() throws Exception { + checkSeveralLongRunningTxs(TRANSACTIONAL); + } + + /** + * @param atomicityMode Cache atomicity mode. + * @throws Exception If failed. + */ + public void checkSeveralLongRunningTxs(CacheAtomicityMode atomicityMode) throws Exception { int timeout = 3500; System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(timeout)); @@ -204,11 +265,7 @@ public void testSeveralLongRunningTxs() throws Exception { awaitPartitionMapExchange(); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode); final Ignite node0 = ignite(0); final Ignite node1 = ignite(1); @@ -294,8 +351,29 @@ private int countTxKeysInASingleBlock(String log) { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9322") // Fix diagnostic message or disable test. + @Test + public void testLongRunningMvccTx() throws Exception { + checkLongRunningTx(TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testLongRunningTx() throws Exception { - System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500"); + checkLongRunningTx(TRANSACTIONAL); + + } + + /** + * @param atomicityMode Cache atomicity mode. + * @throws Exception If failed. + */ + public void checkLongRunningTx(CacheAtomicityMode atomicityMode) throws Exception { + final int longOpDumpTimeout = 1000; + + System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(longOpDumpTimeout)); try { startGrid(0); @@ -308,11 +386,7 @@ public void testLongRunningTx() throws Exception { awaitPartitionMapExchange(); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode); final Ignite node0 = ignite(0); final Ignite node1 = ignite(1); @@ -386,7 +460,24 @@ public void testLongRunningTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoteTx() throws Exception { + checkRemoteTx(TRANSACTIONAL); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testRemoteMvccTx() throws Exception { + checkRemoteTx(TRANSACTIONAL_SNAPSHOT); + } + + /** + * @param atomicityMode Cache atomicity mode. + * @throws Exception If failed. + */ + public void checkRemoteTx(CacheAtomicityMode atomicityMode) throws Exception { int timeout = 3500; System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(timeout)); @@ -404,13 +495,11 @@ public void testRemoteTx() throws Exception { awaitPartitionMapExchange(); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode).setBackups(1); - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); - ccfg.setBackups(1); - ccfg.setNearConfiguration(new NearCacheConfiguration()); + if (atomicityMode != TRANSACTIONAL_SNAPSHOT || + MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) + ccfg.setNearConfiguration(new NearCacheConfiguration<>()); final Ignite node0 = ignite(0); final Ignite node1 = ignite(1); @@ -462,9 +551,10 @@ public void testRemoteTx() throws Exception { } /** + * @param atomicityMode Cache atomicity mode. * @throws Exception If failed. */ - private void checkBasicDiagnosticInfo() throws Exception { + private void checkBasicDiagnosticInfo(CacheAtomicityMode atomicityMode) throws Exception { startGrids(3); client = true; @@ -473,11 +563,7 @@ private void checkBasicDiagnosticInfo() throws Exception { startGrid(4); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheMode(REPLICATED); - ccfg.setAtomicityMode(TRANSACTIONAL); + CacheConfiguration ccfg = cacheConfiguration(atomicityMode).setCacheMode(REPLICATED); ignite(0).createCache(ccfg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManagerAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManagerAbstractSelfTest.java index 45699796d2d62..8d22747386720 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManagerAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManagerAbstractSelfTest.java @@ -50,9 +50,6 @@ import org.apache.ignite.resources.TaskSessionResource; import org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpi; import org.apache.ignite.spi.checkpoint.jdbc.JdbcCheckpointSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.hsqldb.jdbc.jdbcDataSource; @@ -111,9 +108,6 @@ public abstract class GridCheckpointManagerAbstractSelfTest extends GridCommonAb /** */ private static final String SES_VAL_OVERWRITTEN = SES_VAL + "-overwritten"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** * Static variable to control whether test should retry checkpoint read attempts. * It is needed for s3-based tests because of weak s3 consistency model. @@ -139,12 +133,6 @@ private GridCheckpointManager checkpoints(Ignite ignite) { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - if (igniteInstanceName.contains("cache")) { String cacheName = "test-checkpoints"; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManagerSelfTest.java index 414d05c765877..beb3ce26daae6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManagerSelfTest.java @@ -18,15 +18,20 @@ package org.apache.ignite.internal.managers.checkpoint; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridCommonTest(group = "Checkpoint Manager") +@RunWith(JUnit4.class) public class GridCheckpointManagerSelfTest extends GridCheckpointManagerAbstractSelfTest { /** * @throws Exception Thrown if any exception occurs. */ + @Test public void testCacheBased() throws Exception { doTest("cache"); } @@ -34,6 +39,7 @@ public void testCacheBased() throws Exception { /** * @throws Exception Thrown if any exception occurs. */ + @Test public void testSharedFsBased() throws Exception { doTest("sharedfs"); } @@ -41,6 +47,7 @@ public void testSharedFsBased() throws Exception { /** * @throws Exception Thrown if any exception occurs. */ + @Test public void testDatabaseBased() throws Exception { doTest("jdbc"); } @@ -48,6 +55,7 @@ public void testDatabaseBased() throws Exception { /** * @throws Exception Thrown if any exception occurs. */ + @Test public void testMultiNodeCacheBased() throws Exception { doMultiNodeTest("cache"); } @@ -55,6 +63,7 @@ public void testMultiNodeCacheBased() throws Exception { /** * @throws Exception Thrown if any exception occurs. */ + @Test public void testMultiNodeSharedFsBased() throws Exception { doMultiNodeTest("sharedfs"); } @@ -62,7 +71,8 @@ public void testMultiNodeSharedFsBased() throws Exception { /** * @throws Exception Thrown if any exception occurs. */ + @Test public void testMultiNodeDatabaseBased() throws Exception { doMultiNodeTest("jdbc"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointTaskSelfTest.java index e36f54a77a9e7..8b071bbc1c8c1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointTaskSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointTaskSelfTest.java @@ -36,12 +36,11 @@ import org.apache.ignite.resources.TaskSessionResource; import org.apache.ignite.spi.checkpoint.CheckpointSpi; import org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpi; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -49,10 +48,8 @@ /** * Checkpoint tests. */ +@RunWith(JUnit4.class) public class GridCheckpointTaskSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Checkpoints cache name. */ private static final String CACHE_NAME = "checkpoints.cache"; @@ -65,7 +62,6 @@ public class GridCheckpointTaskSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheConfiguration()); cfg.setCheckpointSpi(checkpointSpi()); - cfg.setDiscoverySpi(discoverySpi()); return cfg; } @@ -94,17 +90,6 @@ private CheckpointSpi checkpointSpi() { return spi; } - /** - * @return Discovery SPI. - */ - private DiscoverySpi discoverySpi() { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - return spi; - } - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startGrid(1); @@ -122,6 +107,7 @@ private DiscoverySpi discoverySpi() { /** * @throws Exception If failed. */ + @Test public void testFailover() throws Exception { grid(1).compute().execute(FailoverTestTask.class, null); } @@ -129,6 +115,7 @@ public void testFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReduce() throws Exception { grid(1).compute().execute(ReduceTestTask.class, null); } @@ -238,4 +225,4 @@ private static class ReduceTestTask extends ComputeTaskAdapter { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationManagerListenersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationManagerListenersSelfTest.java index 03b7921f5b571..fb5e2921fd9d0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationManagerListenersSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationManagerListenersSelfTest.java @@ -33,11 +33,15 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid communication manager self test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridCommunicationManagerListenersSelfTest extends GridCommonAbstractTest { /** */ public GridCommunicationManagerListenersSelfTest() { @@ -47,7 +51,7 @@ public GridCommunicationManagerListenersSelfTest() { /** * Works fine. */ - @SuppressWarnings({"deprecation"}) + @Test public void testDifferentListeners() { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -68,6 +72,7 @@ public void testDifferentListeners() { /** * Fails on the 1001st time. */ + @Test public void testMultipleExecutionsWithoutListeners() { checkLoop(1001); } @@ -76,7 +81,7 @@ public void testMultipleExecutionsWithoutListeners() { * This is the workaround- as long as we keep a message listener in * the stack, our FIFO bug isn't exposed. Comment above out to see. */ - @SuppressWarnings({"deprecation"}) + @Test public void testOneListener() { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -101,6 +106,7 @@ public void testOneListener() { * Now, our test will fail on the first message added after our safety * message listener has been removed. */ + @Test public void testSingleExecutionWithoutListeners() { checkLoop(1); } @@ -163,4 +169,4 @@ private static class MessageListeningTask extends ComputeTaskSplitAdapter() { @Override public Object call() throws Exception { @@ -101,6 +106,7 @@ public void testSendIfOneOfNodesIsLocalAndTopicIsEnum() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSendUserMessageThinVersionIfOneOfNodesIsLocal() throws Exception { Object msg = new Object(); @@ -125,6 +131,7 @@ public void testSendUserMessageThinVersionIfOneOfNodesIsLocal() throws Exception /** * @throws Exception If failed. */ + @Test public void testSendUserMessageUnorderedThickVersionIfOneOfNodesIsLocal() throws Exception { Object msg = new Object(); @@ -149,6 +156,7 @@ public void testSendUserMessageUnorderedThickVersionIfOneOfNodesIsLocal() throws /** * @throws Exception If failed. */ + @Test public void testSendUserMessageOrderedThickVersionIfOneOfNodesIsLocal() throws Exception { Object msg = new Object(); @@ -243,4 +251,4 @@ private static class TestMessage implements Message { return 0; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteCommunicationBalanceMultipleConnectionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteCommunicationBalanceMultipleConnectionsTest.java index 444f086522a8b..e6aeee1313fe8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteCommunicationBalanceMultipleConnectionsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteCommunicationBalanceMultipleConnectionsTest.java @@ -17,9 +17,12 @@ package org.apache.ignite.internal.managers.communication; +import org.junit.Ignore; + /** * */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-5689") public class IgniteCommunicationBalanceMultipleConnectionsTest extends IgniteCommunicationBalanceTest { /** {@inheritDoc} */ @Override protected int connectionsPerNode() { @@ -28,6 +31,6 @@ public class IgniteCommunicationBalanceMultipleConnectionsTest extends IgniteCom /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-5689"); + // No-op. } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteCommunicationBalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteCommunicationBalanceTest.java index 666bc1dfbf6c2..4b4de15fc3e72 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteCommunicationBalanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteCommunicationBalanceTest.java @@ -36,19 +36,17 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCommunicationBalanceTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -68,8 +66,6 @@ public class IgniteCommunicationBalanceTest extends GridCommonAbstractTest { if (selectors > 0) commSpi.setSelectorsCount(selectors); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); if (sslEnabled()) @@ -109,6 +105,7 @@ protected int connectionsPerNode() { /** * @throws Exception If failed. */ + @Test public void testBalance1() throws Exception { if (sslEnabled()) return; @@ -210,6 +207,7 @@ public void testBalance1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBalance2() throws Exception { System.setProperty(IgniteSystemProperties.IGNITE_IO_BALANCE_PERIOD, "1000"); @@ -317,6 +315,7 @@ private void waitNioBalanceStop(List nodes, long timeout) throws Excepti /** * @throws Exception If failed. */ + @Test public void testRandomBalance() throws Exception { System.setProperty(GridNioServer.IGNITE_IO_BALANCE_RANDOM_BALANCE, "true"); System.setProperty(IgniteSystemProperties.IGNITE_IO_BALANCE_PERIOD, "500"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessagesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessagesTest.java index 65231e7097222..57e500c2874a8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessagesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteIoTestMessagesTest.java @@ -24,18 +24,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteIoTestMessagesTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -43,8 +41,6 @@ public class IgniteIoTestMessagesTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -66,6 +62,7 @@ public class IgniteIoTestMessagesTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testIoTestMessages() throws Exception { for (Ignite node : G.allGrids()) { IgniteKernal ignite = (IgniteKernal)node; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteVariousConnectionNumberTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteVariousConnectionNumberTest.java index 2ea1f90b854ff..e68047e269ec3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteVariousConnectionNumberTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/IgniteVariousConnectionNumberTest.java @@ -28,11 +28,11 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -40,10 +40,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteVariousConnectionNumberTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 6; @@ -57,8 +55,6 @@ public class IgniteVariousConnectionNumberTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - int connections = rnd.nextInt(10) + 1; log.info("Node connections [name=" + igniteInstanceName + ", connections=" + connections + ']'); @@ -86,6 +82,7 @@ public class IgniteVariousConnectionNumberTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testVariousConnectionNumber() throws Exception { startGridsMultiThreaded(3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/DeploymentRequestOfUnknownClassProcessingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/DeploymentRequestOfUnknownClassProcessingTest.java new file mode 100644 index 0000000000000..1c6027f710bc4 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/DeploymentRequestOfUnknownClassProcessingTest.java @@ -0,0 +1,141 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.managers.deployment; + +import java.net.URL; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.managers.communication.GridIoPolicy; +import org.apache.ignite.internal.managers.communication.GridMessageListener; +import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.GridTestExternalClassLoader; +import org.apache.ignite.testframework.ListeningTestLogger; +import org.apache.ignite.testframework.LogListener; +import org.apache.ignite.testframework.config.GridTestProperties; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +import static org.apache.ignite.internal.GridTopic.TOPIC_CLASSLOAD; + +/** + * Tests the processing of deployment request with an attempt to load a class with an unknown class name. + */ +public class DeploymentRequestOfUnknownClassProcessingTest extends GridCommonAbstractTest { + /** */ + private static final String TEST_TOPIC_NAME = "TEST_TOPIC_NAME"; + + /** */ + private static final String UNKNOWN_CLASS_NAME = "unknown.UnknownClassName"; + + /** */ + private final ListeningTestLogger remNodeLog = new ListeningTestLogger(false, log); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setPeerClassLoadingEnabled(true); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + startGrid(getConfiguration(getTestIgniteInstanceName(0))); + + IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(1)); + + cfg.setGridLogger(remNodeLog); + + startGrid(cfg); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testResponseReceivingOnDeploymentRequestOfUnknownClass() throws Exception { + IgniteEx locNode = grid(0); + IgniteEx remNode = grid(1); + + // Register deployment on remote node for attemt to load class on request receiving + GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(new URL[] { + new URL(GridTestProperties.getProperty("p2p.uri.cls")) + }); + + Class task = ldr.loadClass("org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1"); + + GridDeployment locDep = remNode.context().deploy().deploy(task, task.getClassLoader()); + + final GridFutureAdapter testResultFut = new GridFutureAdapter<>(); + + final LogListener remNodeLogLsnr = LogListener + .matches(s -> s.startsWith("Failed to resolve class: " + UNKNOWN_CLASS_NAME)).build(); + + remNodeLog.registerListener(remNodeLogLsnr); + + locNode.context().io().addMessageListener(TEST_TOPIC_NAME, new GridMessageListener() { + @Override public void onMessage(UUID nodeId, Object msg, byte plc) { + try { + assertTrue(msg instanceof GridDeploymentResponse); + + GridDeploymentResponse resp = (GridDeploymentResponse)msg; + + assertFalse("Unexpected response result, success=" + resp.success(), resp.success()); + + String errMsg = resp.errorMessage(); + + assertNotNull("Response should contain an error message.", errMsg); + + assertTrue("Response contains unexpected error message, errorMessage=" + errMsg, + errMsg.startsWith("Requested resource not found (ignoring locally): " + UNKNOWN_CLASS_NAME)); + + testResultFut.onDone(); + } + catch (Error e) { + testResultFut.onDone(e); + } + } + }); + + GridDeploymentRequest req = new GridDeploymentRequest(TEST_TOPIC_NAME, locDep.classLoaderId(), + UNKNOWN_CLASS_NAME, false); + + req.responseTopicBytes(U.marshal(locNode.context(), req.responseTopic())); + + locNode.context().io().sendToGridTopic(remNode.localNode(), TOPIC_CLASSLOAD, req, GridIoPolicy.P2P_POOL); + + // Сhecks that the expected response has been received. + testResultFut.get(5_000, TimeUnit.MILLISECONDS); + + // Checks that error has been logged on remote node. + assertTrue(remNodeLogLsnr.check()); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/GridDeploymentManagerStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/GridDeploymentManagerStopSelfTest.java index 1d1a20a20c5bd..71aabb1a092b9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/GridDeploymentManagerStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/GridDeploymentManagerStopSelfTest.java @@ -30,15 +30,20 @@ import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid deployment manager stop test. */ @GridCommonTest(group = "Kernal Self") +@RunWith(JUnit4.class) public class GridDeploymentManagerStopSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testOnKernalStop() throws Exception { DeploymentSpi spi = new GridTestDeploymentSpi(); @@ -106,4 +111,4 @@ private static class GridTestDeploymentSpi implements DeploymentSpi { /** {@inheritDoc} */ @Override public void onClientReconnected(boolean clusterRestarted) { /* No-op. */ } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/GridDeploymentMessageCountSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/GridDeploymentMessageCountSelfTest.java index 6b9a6818346cd..b417de41e487e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/GridDeploymentMessageCountSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/GridDeploymentMessageCountSelfTest.java @@ -20,23 +20,20 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteException; -import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.compute.ComputeTaskFuture; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.managers.communication.GridIoMessage; -import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -44,16 +41,11 @@ /** * Tests message count for different deployment scenarios. */ +@RunWith(JUnit4.class) public class GridDeploymentMessageCountSelfTest extends GridCommonAbstractTest { - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Test p2p task. */ private static final String TEST_TASK = "org.apache.ignite.tests.p2p.SingleSplitTestTask"; - /** Test p2p value. */ - private static final String TEST_VALUE = "org.apache.ignite.tests.p2p.CacheDeploymentTestValue"; - /** SPIs. */ private Map commSpis = new ConcurrentHashMap<>(); @@ -61,12 +53,6 @@ public class GridDeploymentMessageCountSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - cfg.setPeerClassLoadingEnabled(true); CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -86,7 +72,7 @@ public class GridDeploymentMessageCountSelfTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ - @SuppressWarnings("unchecked") + @Test public void testTaskDeployment() throws Exception { ClassLoader ldr = getExternalClassLoader(); @@ -123,49 +109,6 @@ public void testTaskDeployment() throws Exception { } } - /** - * @throws Exception If failed. - */ - public void testCacheValueDeploymentOnPut() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-4551"); - - ClassLoader ldr = getExternalClassLoader(); - - Class valCls = ldr.loadClass(TEST_VALUE); - - try { - startGrids(2); - - IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); - - cache.put("key", valCls.newInstance()); - - for (int i = 0; i < 2; i++) - assertNotNull("For grid: " + i, grid(i).cache(DEFAULT_CACHE_NAME).localPeek("key", CachePeekMode.ONHEAP)); - - for (MessageCountingCommunicationSpi spi : commSpis.values()) { - assertTrue(spi.deploymentMessageCount() > 0); - - spi.resetCount(); - } - - for (int i = 0; i < 10; i++) { - String key = "key" + i; - - cache.put(key, valCls.newInstance()); - - for (int k = 0; k < 2; k++) - assertNotNull(grid(k).cache(DEFAULT_CACHE_NAME).localPeek(key, CachePeekMode.ONHEAP)); - } - - for (MessageCountingCommunicationSpi spi : commSpis.values()) - assertEquals(0, spi.deploymentMessageCount()); - } - finally { - stopAllGrids(); - } - } - /** * */ @@ -174,12 +117,12 @@ private class MessageCountingCommunicationSpi extends TcpCommunicationSpi { private AtomicInteger msgCnt = new AtomicInteger(); /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure ackClosure) + @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure ackC) throws IgniteSpiException { if (isDeploymentMessage((GridIoMessage)msg)) msgCnt.incrementAndGet(); - super.sendMessage(node, msg, ackClosure); + super.sendMessage(node, msg, ackC); } /** @@ -213,4 +156,4 @@ private boolean isDeploymentMessage(GridIoMessage msg) { return dep; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java index 8fad6404f1936..b58f056293a27 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java @@ -32,9 +32,10 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -43,10 +44,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int PERM_NODES_CNT = 5; @@ -96,19 +95,17 @@ public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTe cCfg.setRebalanceMode(SYNC); cCfg.setWriteSynchronizationMode(FULL_SYNC); - TcpDiscoverySpi disc = new TcpDiscoverySpi(); + TcpDiscoverySpi disc = (TcpDiscoverySpi)cfg.getDiscoverySpi(); if (clientMode && ((igniteInstanceName.charAt(igniteInstanceName.length() - 1) - '0') & 1) != 0) cfg.setClientMode(true); else cfg.setClientFailureDetectionTimeout(50000); - disc.setIpFinder(IP_FINDER); disc.setAckTimeout(1000); disc.setSocketTimeout(1000); cfg.setCacheConfiguration(cCfg); - cfg.setDiscoverySpi(disc); cfg.setMetricsUpdateFrequency(500); return cfg; @@ -159,6 +156,7 @@ private void doTestAlive() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAlives() throws Exception { clientMode = false; @@ -168,6 +166,7 @@ public void testAlives() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAlivesClient() throws Exception { clientMode = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java index 69f95e8aab1d9..8db1551e94594 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java @@ -27,27 +27,25 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.TestReconnectPluginProvider; import org.apache.ignite.spi.discovery.tcp.TestReconnectProcessor; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2; import static org.apache.ignite.IgniteSystemProperties.IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SECURITY_COMPATIBILITY_MODE; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_SERVICES_COMPATIBILITY_MODE; import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; import static org.apache.ignite.configuration.DeploymentMode.SHARED; /** * Tests for node attributes consistency checks. */ +@RunWith(JUnit4.class) public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonAbstractTest { /** */ private static final String PREFER_IPV4 = "java.net.preferIPv4Stack"; - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static DeploymentMode mode; @@ -71,12 +69,6 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA cfg.setDeploymentMode(mode); cfg.setPeerClassLoadingEnabled(p2pEnabled); - TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi(); - - discoverySpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoverySpi); - return cfg; } @@ -95,6 +87,7 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA /** * @throws Exception If failed. */ + @Test public void testPreferIpV4StackTrue() throws Exception { testPreferIpV4Stack(true); } @@ -102,6 +95,7 @@ public void testPreferIpV4StackTrue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreferIpV4StackFalse() throws Exception { testPreferIpV4Stack(false); } @@ -116,6 +110,7 @@ public void testPreferIpV4StackFalse() throws Exception { * * @throws Exception If failed. */ + @Test public void testPreferIpV4StackDifferentValues() throws Exception { System.setProperty(PREFER_IPV4, "true"); @@ -137,6 +132,7 @@ public void testPreferIpV4StackDifferentValues() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUseDefaultSuid() throws Exception { try { doTestUseDefaultSuid(Boolean.TRUE.toString(), Boolean.FALSE.toString(), true); @@ -184,6 +180,7 @@ private void doTestUseDefaultSuid(String first, String second, boolean fail) thr } } + @Test public void testUseStringSerVer2() throws Exception { String old = System.getProperty(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2); @@ -248,42 +245,7 @@ private void doTestUseStrSerVer2(String first, String second, boolean fail) thro /** * @throws Exception If failed. */ - public void testServiceCompatibilityEnabled() throws Exception { - String backup = System.getProperty(IGNITE_SERVICES_COMPATIBILITY_MODE); - - try { - doTestServiceCompatibilityEnabled(true, null, true); - doTestServiceCompatibilityEnabled(false, null, true); - doTestServiceCompatibilityEnabled(null, false, true); - doTestServiceCompatibilityEnabled(true, false, true); - doTestServiceCompatibilityEnabled(null, true, true); - doTestServiceCompatibilityEnabled(false, true, true); - - doTestServiceCompatibilityEnabled(true, true, false); - doTestServiceCompatibilityEnabled(false, false, false); - doTestServiceCompatibilityEnabled(null, null, false); - } - finally { - if (backup != null) - System.setProperty(IGNITE_SERVICES_COMPATIBILITY_MODE, backup); - else - System.clearProperty(IGNITE_SERVICES_COMPATIBILITY_MODE); - } - } - - /** - * @param first Service compatibility enabled flag for first node. - * @param second Service compatibility enabled flag for second node. - * @param fail Fail flag. - * @throws Exception If failed. - */ - private void doTestServiceCompatibilityEnabled(Object first, Object second, boolean fail) throws Exception { - doTestCompatibilityEnabled(IGNITE_SERVICES_COMPATIBILITY_MODE, first, second, fail); - } - - /** - * @throws Exception If failed. - */ + @Test public void testSecurityCompatibilityEnabled() throws Exception { TestReconnectPluginProvider.enabled = true; TestReconnectProcessor.enabled = true; @@ -370,6 +332,7 @@ private void doTestCompatibilityEnabled(String prop, Object first, Object second /** * @throws Exception If failed. */ + @Test public void testDifferentDeploymentModes() throws Exception { IgniteEx g = startGrid(0); @@ -391,6 +354,7 @@ public void testDifferentDeploymentModes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentPeerClassLoadingEnabledFlag() throws Exception { IgniteEx g = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/IgniteTopologyPrintFormatSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/IgniteTopologyPrintFormatSelfTest.java index 4041d6e5b818a..fb572db8d7a84 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/IgniteTopologyPrintFormatSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/IgniteTopologyPrintFormatSelfTest.java @@ -27,16 +27,18 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; import org.apache.log4j.Level; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteTopologyPrintFormatSelfTest extends GridCommonAbstractTest { /** */ public static final String TOPOLOGY_SNAPSHOT = "Topology snapshot"; @@ -47,26 +49,18 @@ public class IgniteTopologyPrintFormatSelfTest extends GridCommonAbstractTest { /** */ public static final String CLIENT_NODE = ">>> Number of client nodes"; - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disc = new TcpDiscoverySpi(); - disc.setIpFinder(IP_FINDER); - if (igniteInstanceName.endsWith("client")) cfg.setClientMode(true); if (igniteInstanceName.endsWith("client_force_server")) { cfg.setClientMode(true); - disc.setForceServerMode(true); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); } - cfg.setDiscoverySpi(disc); - return cfg; } @@ -86,6 +80,7 @@ public class IgniteTopologyPrintFormatSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testServerLogs() throws Exception { MockLogger log = new MockLogger(); @@ -97,6 +92,7 @@ public void testServerLogs() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerDebugLogs() throws Exception { MockLogger log = new MockLogger(); @@ -138,6 +134,7 @@ private void doServerLogTest(MockLogger log) throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerAndClientLogs() throws Exception { MockLogger log = new MockLogger(); @@ -149,6 +146,7 @@ public void testServerAndClientLogs() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerAndClientDebugLogs() throws Exception { MockLogger log = new MockLogger(); @@ -192,6 +190,7 @@ private void doServerAndClientTest(MockLogger log) throws Exception { /** * @throws Exception If failed. */ + @Test public void testForceServerAndClientLogs() throws Exception { MockLogger log = new MockLogger(); @@ -203,6 +202,7 @@ public void testForceServerAndClientLogs() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForceServerAndClientDebugLogs() throws Exception { MockLogger log = new MockLogger(); @@ -299,4 +299,4 @@ public void clear() { logs.clear(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/events/GridEventStorageManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/events/GridEventStorageManagerSelfTest.java index 0479b81beb104..9103e6cc2396d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/events/GridEventStorageManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/events/GridEventStorageManagerSelfTest.java @@ -28,12 +28,16 @@ import org.apache.ignite.lang.IgniteFutureTimeoutException; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVTS_ALL; /** * Tests for {@link GridEventStorageManager}. */ +@RunWith(JUnit4.class) public class GridEventStorageManagerSelfTest extends GridCommonAbstractTest { /** * @@ -60,6 +64,7 @@ public GridEventStorageManagerSelfTest() { /** * @throws Exception If failed. */ + @Test public void testWaitForEvent() throws Exception { Ignite ignite = grid(); @@ -92,6 +97,7 @@ public void testWaitForEvent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWaitForEventContinuationTimeout() throws Exception { Ignite ignite = grid(); @@ -111,6 +117,7 @@ public void testWaitForEventContinuationTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUserEvent() throws Exception { Ignite ignite = grid(); @@ -126,4 +133,4 @@ public void testUserEvent() throws Exception { info("Caught expected exception: " + e); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java index c7a58f74a2b6a..5dfebc4d7a590 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.marshaller.optimized; -import junit.framework.TestCase; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.configuration.IgniteConfiguration; @@ -25,11 +24,14 @@ import org.apache.ignite.marshaller.MarshallerContextTestImpl; import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * */ -public class OptimizedMarshallerEnumSelfTest extends TestCase { +public class OptimizedMarshallerEnumSelfTest { private String igniteHome = System.getProperty("user.dir"); @@ -37,6 +39,7 @@ public class OptimizedMarshallerEnumSelfTest extends TestCase { /** * @throws Exception If failed. */ + @Test public void testEnumSerialisation() throws Exception { OptimizedMarshaller marsh = new OptimizedMarshaller(); @@ -84,4 +87,4 @@ private enum TestEnum { public abstract String getTestString(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java index 7bd0a5d492b73..33bb3eaaacaec 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerNodeFailoverTest.java @@ -30,11 +30,11 @@ import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshaller; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -42,10 +42,8 @@ /** * */ +@RunWith(JUnit4.class) public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean cache; @@ -56,12 +54,6 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(new OptimizedMarshaller()); cfg.setWorkDirectory(workDir); @@ -84,6 +76,7 @@ public class OptimizedMarshallerNodeFailoverTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testClassCacheUpdateFailover1() throws Exception { classCacheUpdateFailover(false); } @@ -91,6 +84,7 @@ public void testClassCacheUpdateFailover1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClassCacheUpdateFailover2() throws Exception { classCacheUpdateFailover(true); } @@ -141,6 +135,7 @@ private void classCacheUpdateFailover(boolean stopSrv) throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestartAllNodes() throws Exception { cache = true; @@ -355,4 +350,4 @@ static class TestClass19 implements Serializable {} * */ static class TestClass20 implements Serializable {} -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSelfTest.java index fa95abc43c164..9238cf012d7b3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSelfTest.java @@ -29,11 +29,15 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Optimized marshaller self test. */ @GridCommonTest(group = "Marshaller") +@RunWith(JUnit4.class) public class OptimizedMarshallerSelfTest extends GridMarshallerAbstractTest { /** {@inheritDoc} */ @Override protected Marshaller marshaller() { @@ -43,6 +47,7 @@ public class OptimizedMarshallerSelfTest extends GridMarshallerAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTestMarshalling() throws Exception { final String msg = "PASSED"; @@ -70,6 +75,7 @@ public void testTestMarshalling() throws Exception { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testMarshallingSelfLink() throws IgniteCheckedException { SelfLink sl = new SelfLink("a string 1"); @@ -83,6 +89,7 @@ public void testMarshallingSelfLink() throws IgniteCheckedException { /** * @throws Exception If failed. */ + @Test public void testInvalid() throws Exception { GridTestUtils.assertThrows( log, @@ -105,6 +112,7 @@ public void testInvalid() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNested() throws Exception { NestedTestObject obj = new NestedTestObject("String", 100); @@ -281,4 +289,4 @@ public void link(SelfLink link) { this.link = link; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSerialPersistentFieldsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSerialPersistentFieldsSelfTest.java index 5a9d10cd1fe61..560884cf5b01e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSerialPersistentFieldsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerSerialPersistentFieldsSelfTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshaller; import org.apache.ignite.marshaller.GridMarshallerAbstractTest; import org.apache.ignite.marshaller.Marshaller; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that Optimized Marshaller works with classes with serialPersistentFields. */ +@RunWith(JUnit4.class) public class OptimizedMarshallerSerialPersistentFieldsSelfTest extends GridMarshallerAbstractTest { /** {@inheritDoc} */ @Override protected Marshaller marshaller() { @@ -38,6 +42,7 @@ public class OptimizedMarshallerSerialPersistentFieldsSelfTest extends GridMars /** * @throws Exception If failed. */ + @Test public void testOptimizedMarshaller() throws Exception { unmarshal(marshal(new TestClass())); @@ -113,4 +118,4 @@ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundEx s.readObject(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerTest.java index a7e29c41a16ee..0da247335243e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerTest.java @@ -45,10 +45,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class OptimizedMarshallerTest extends GridCommonAbstractTest { /** * @return Marshaller. @@ -68,6 +72,7 @@ private OptimizedMarshaller marshaller() { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testNonSerializable() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); @@ -83,6 +88,7 @@ public void testNonSerializable() throws IgniteCheckedException { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testNonSerializable1() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); @@ -104,6 +110,7 @@ public void testNonSerializable1() throws IgniteCheckedException { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testNonSerializable2() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); @@ -137,6 +144,7 @@ public void testNonSerializable2() throws IgniteCheckedException { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testNonSerializable3() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); @@ -154,6 +162,7 @@ public void testNonSerializable3() throws IgniteCheckedException { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testNonSerializable4() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); @@ -173,6 +182,7 @@ public void testNonSerializable4() throws IgniteCheckedException { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testNonSerializable5() throws IgniteCheckedException { Marshaller marsh = marshaller(); @@ -188,6 +198,7 @@ public void testNonSerializable5() throws IgniteCheckedException { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testSerializable() throws IgniteCheckedException { Marshaller marsh = marshaller(); @@ -199,6 +210,7 @@ public void testSerializable() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testSerializableAfterChangingValue() throws IgniteCheckedException { Marshaller marsh = marshaller(); @@ -220,6 +232,7 @@ public void testSerializableAfterChangingValue() throws IgniteCheckedException { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testExternalizable() throws IgniteCheckedException { Marshaller marsh = marshaller(); @@ -233,6 +246,7 @@ public void testExternalizable() throws IgniteCheckedException { /** * Tests {@link OptimizedMarshaller#setRequireSerializable(boolean)}. */ + @Test public void testRequireSerializable() { OptimizedMarshaller marsh = marshaller(); @@ -253,6 +267,7 @@ public void testRequireSerializable() { * * @throws IgniteCheckedException If marshalling failed. */ + @Test public void testProxy() throws IgniteCheckedException { OptimizedMarshaller marsh = marshaller(); @@ -286,6 +301,7 @@ public void testProxy() throws IgniteCheckedException { /** * @throws Exception If failed. */ + @Test public void testDescriptorCache() throws Exception { try { Ignite ignite = startGridsMultiThreaded(2); @@ -322,6 +338,7 @@ public void testDescriptorCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPerformance() throws Exception { System.gc(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedObjectStreamSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedObjectStreamSelfTest.java index 5efc5b97ceda9..ed2d8004ba14a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedObjectStreamSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedObjectStreamSelfTest.java @@ -68,12 +68,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.junit.Assert.assertArrayEquals; /** * Test for optimized object streams. */ +@RunWith(JUnit4.class) public class OptimizedObjectStreamSelfTest extends GridCommonAbstractTest { /** */ private static final MarshallerContext CTX = new MarshallerContextTestImpl(); @@ -84,6 +88,7 @@ public class OptimizedObjectStreamSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNull() throws Exception { assertNull(marshalUnmarshal(null)); } @@ -91,6 +96,7 @@ public void testNull() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByte() throws Exception { byte val = 10; @@ -100,6 +106,7 @@ public void testByte() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { short val = 100; @@ -109,6 +116,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInteger() throws Exception { int val = 100; @@ -118,6 +126,7 @@ public void testInteger() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { long val = 1000L; @@ -127,6 +136,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { float val = 10.0f; @@ -136,6 +146,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { double val = 100.0d; @@ -145,6 +156,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBoolean() throws Exception { assertEquals(Boolean.TRUE, marshalUnmarshal(Boolean.TRUE)); @@ -154,6 +166,7 @@ public void testBoolean() throws Exception { /** * @throws Exception If failed. */ + @Test public void testChar() throws Exception { char val = 10; @@ -163,6 +176,7 @@ public void testChar() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByteArray() throws Exception { byte[] arr = marshalUnmarshal(new byte[] {1, 2}); @@ -172,6 +186,7 @@ public void testByteArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShortArray() throws Exception { short[] arr = marshalUnmarshal(new short[] {1, 2}); @@ -181,6 +196,7 @@ public void testShortArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIntArray() throws Exception { int[] arr = marshalUnmarshal(new int[] {1, 2}); @@ -190,6 +206,7 @@ public void testIntArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLongArray() throws Exception { long[] arr = marshalUnmarshal(new long[] {1L, 2L}); @@ -199,6 +216,7 @@ public void testLongArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloatArray() throws Exception { float[] arr = marshalUnmarshal(new float[] {1.0f, 2.0f}); @@ -208,6 +226,7 @@ public void testFloatArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDoubleArray() throws Exception { double[] arr = marshalUnmarshal(new double[] {1.0d, 2.0d}); @@ -217,6 +236,7 @@ public void testDoubleArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBooleanArray() throws Exception { boolean[] arr = marshalUnmarshal(new boolean[] {true, false, false}); @@ -229,6 +249,7 @@ public void testBooleanArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCharArray() throws Exception { char[] arr = marshalUnmarshal(new char[] {1, 2}); @@ -238,6 +259,7 @@ public void testCharArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObject() throws Exception { TestObject obj = new TestObject(); @@ -252,6 +274,7 @@ public void testObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRequireSerializable() throws Exception { try { OptimizedMarshaller marsh = new OptimizedMarshaller(true); @@ -275,6 +298,7 @@ public void testRequireSerializable() throws Exception { * * @throws Exception If failed. */ + @Test public void testFailedUnmarshallingLogging() throws Exception { OptimizedMarshaller marsh = new OptimizedMarshaller(true); @@ -297,6 +321,7 @@ public void testFailedUnmarshallingLogging() throws Exception { * * @throws Exception If failed. */ + @Test public void testFailedMarshallingLogging() throws Exception { OptimizedMarshaller marsh = new OptimizedMarshaller(true); @@ -316,6 +341,7 @@ public void testFailedMarshallingLogging() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPool() throws Exception { final TestObject obj = new TestObject(); @@ -351,6 +377,7 @@ public void testPool() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectWithNulls() throws Exception { TestObject obj = new TestObject(); @@ -363,6 +390,7 @@ public void testObjectWithNulls() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectArray() throws Exception { TestObject obj1 = new TestObject(); @@ -390,6 +418,7 @@ public void testObjectArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExternalizable() throws Exception { ExternalizableTestObject1 obj = new ExternalizableTestObject1(); @@ -404,6 +433,7 @@ public void testExternalizable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExternalizableWithNulls() throws Exception { ExternalizableTestObject2 obj = new ExternalizableTestObject2(); @@ -423,6 +453,7 @@ public void testExternalizableWithNulls() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLink() throws Exception { for (int i = 0; i < 20; i++) { LinkTestObject1 obj1 = new LinkTestObject1(); @@ -442,6 +473,7 @@ public void testLink() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCycleLink() throws Exception { for (int i = 0; i < 20; i++) { CycleLinkTestObject obj = new CycleLinkTestObject(); @@ -456,6 +488,7 @@ public void testCycleLink() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoDefaultConstructor() throws Exception { NoDefaultConstructorTestObject obj = new NoDefaultConstructorTestObject(100); @@ -465,6 +498,7 @@ public void testNoDefaultConstructor() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEnum() throws Exception { assertEquals(TestEnum.B, marshalUnmarshal(TestEnum.B)); @@ -476,6 +510,7 @@ public void testEnum() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollection() throws Exception { TestObject obj1 = new TestObject(); @@ -499,6 +534,7 @@ public void testCollection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMap() throws Exception { TestObject obj1 = new TestObject(); @@ -522,6 +558,7 @@ public void testMap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUuid() throws Exception { UUID uuid = UUID.randomUUID(); @@ -531,6 +568,7 @@ public void testUuid() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDate() throws Exception { Date date = new Date(); @@ -540,6 +578,7 @@ public void testDate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransient() throws Exception { TransientTestObject obj = marshalUnmarshal(new TransientTestObject(100, 200, "str1", "str2")); @@ -552,6 +591,7 @@ public void testTransient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteReadObject() throws Exception { WriteReadTestObject obj = marshalUnmarshal(new WriteReadTestObject(100, "str")); @@ -562,6 +602,7 @@ public void testWriteReadObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteReplace() throws Exception { ReplaceTestObject obj = marshalUnmarshal(new ReplaceTestObject(100)); @@ -571,6 +612,7 @@ public void testWriteReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteReplaceNull() throws Exception { ReplaceNullTestObject obj = marshalUnmarshal(new ReplaceNullTestObject()); @@ -580,6 +622,7 @@ public void testWriteReplaceNull() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadResolve() throws Exception { ResolveTestObject obj = marshalUnmarshal(new ResolveTestObject(100)); @@ -589,6 +632,7 @@ public void testReadResolve() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArrayDeque() throws Exception { Queue queue = new ArrayDeque<>(); @@ -608,6 +652,7 @@ public void testArrayDeque() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArrayList() throws Exception { Collection list = new ArrayList<>(); @@ -620,6 +665,7 @@ public void testArrayList() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHashMap() throws Exception { Map map = new HashMap<>(); @@ -632,6 +678,7 @@ public void testHashMap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHashSet() throws Exception { Collection set = new HashSet<>(); @@ -645,6 +692,7 @@ public void testHashSet() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("UseOfObsoleteCollectionType") + @Test public void testHashtable() throws Exception { Map map = new Hashtable<>(); @@ -657,6 +705,7 @@ public void testHashtable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIdentityHashMap() throws Exception { Map map = new IdentityHashMap<>(); @@ -669,6 +718,7 @@ public void testIdentityHashMap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLinkedHashMap() throws Exception { Map map = new LinkedHashMap<>(); @@ -681,6 +731,7 @@ public void testLinkedHashMap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLinkedHashSet() throws Exception { Collection set = new LinkedHashSet<>(); @@ -693,6 +744,7 @@ public void testLinkedHashSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLinkedList() throws Exception { Collection list = new LinkedList<>(); @@ -705,6 +757,7 @@ public void testLinkedList() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPriorityQueue() throws Exception { Queue queue = new PriorityQueue<>(); @@ -724,6 +777,7 @@ public void testPriorityQueue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testProperties() throws Exception { Properties dflts = new Properties(); @@ -743,6 +797,7 @@ public void testProperties() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTreeMap() throws Exception { Map map = new TreeMap<>(); @@ -755,6 +810,7 @@ public void testTreeMap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTreeSet() throws Exception { Collection set = new TreeSet<>(); @@ -768,6 +824,7 @@ public void testTreeSet() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("UseOfObsoleteCollectionType") + @Test public void testVector() throws Exception { Collection vector = new Vector<>(); @@ -780,6 +837,7 @@ public void testVector() throws Exception { /** * @throws Exception If failed. */ + @Test public void testString() throws Exception { assertEquals("Latin", marshalUnmarshal("Latin")); assertEquals("Кириллица", marshalUnmarshal("Кириллица")); @@ -789,6 +847,7 @@ public void testString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadLine() throws Exception { OptimizedObjectInputStream in = new OptimizedObjectInputStream(new GridUnsafeDataInput()); @@ -805,6 +864,7 @@ public void testReadLine() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHierarchy() throws Exception { C c = new C(100, "str", 200, "str", 300, "str"); @@ -821,6 +881,7 @@ public void testHierarchy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInet4Address() throws Exception { Inet4Address addr = (Inet4Address)InetAddress.getByName("localhost"); @@ -830,6 +891,7 @@ public void testInet4Address() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClass() throws Exception { assertEquals(int.class, marshalUnmarshal(int.class)); assertEquals(Long.class, marshalUnmarshal(Long.class)); @@ -839,6 +901,7 @@ public void testClass() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteReadFields() throws Exception { WriteReadFieldsTestObject obj = marshalUnmarshal(new WriteReadFieldsTestObject(100, "str")); @@ -849,6 +912,7 @@ public void testWriteReadFields() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteFields() throws Exception { WriteFieldsTestObject obj = marshalUnmarshal(new WriteFieldsTestObject(100, "str")); @@ -859,6 +923,7 @@ public void testWriteFields() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigInteger() throws Exception { BigInteger b = new BigInteger("54654865468745468465321414646834562346475457488"); @@ -868,6 +933,7 @@ public void testBigInteger() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimal() throws Exception { BigDecimal b = new BigDecimal("849572389457208934572093574.123512938654126458542145"); @@ -877,6 +943,7 @@ public void testBigDecimal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleDateFormat() throws Exception { SimpleDateFormat f = new SimpleDateFormat("MM/dd/yyyy"); @@ -886,6 +953,7 @@ public void testSimpleDateFormat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testComplexObject() throws Exception { ComplexTestObject obj = new ComplexTestObject(); @@ -959,6 +1027,7 @@ public void testComplexObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadToArray() throws Exception { OptimizedObjectInputStream in = OptimizedObjectStreamRegistry.in(); @@ -1006,6 +1075,7 @@ public void testReadToArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHandleTableGrow() throws Exception { List c = new ArrayList<>(); @@ -1025,6 +1095,7 @@ public void testHandleTableGrow() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncorrectExternalizable() throws Exception { GridTestUtils.assertThrows( log, @@ -1040,6 +1111,7 @@ public void testIncorrectExternalizable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExcludedClass() throws Exception { Class[] exclClasses = U.staticField(MarshallerExclusions.class, "EXCL_CLASSES"); @@ -1052,6 +1124,7 @@ public void testExcludedClass() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInet6Address() throws Exception { final InetAddress address = Inet6Address.getByAddress(new byte[16]); @@ -1061,7 +1134,7 @@ public void testInet6Address() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testPutFieldsWithDefaultWriteObject() throws Exception { try { marshalUnmarshal(new CustomWriteObjectMethodObject("test")); @@ -1074,7 +1147,7 @@ public void testPutFieldsWithDefaultWriteObject() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("ThrowableInstanceNeverThrown") + @Test public void testThrowable() throws Exception { Throwable t = new Throwable("Throwable"); @@ -1084,6 +1157,7 @@ public void testThrowable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNestedReadWriteObject() throws Exception { NestedReadWriteObject[] arr = new NestedReadWriteObject[5]; @@ -1460,7 +1534,6 @@ private TransientTestObject(int val1, int val2, String str1, String str2) { /** * Test object with {@code writeObject} and {@code readObject} methods. */ - @SuppressWarnings("TransientFieldNotInitialized") private static class WriteReadTestObject implements Serializable { /** */ private int val; @@ -1552,7 +1625,6 @@ private static class WriteFieldsTestObject implements Serializable { private int val; /** */ - @SuppressWarnings("UnusedDeclaration") private String str; /** @@ -1772,7 +1844,6 @@ String stringB() { /** * Class C. */ - @SuppressWarnings("MethodOverridesPrivateMethodOfSuperclass") private static class C extends B { /** */ @SuppressWarnings("InstanceVariableMayNotBeInitializedByReadObject") @@ -2171,7 +2242,6 @@ private ComplexTestObject(byte byteVal1, short shortVal1, int intVal1, long long /** * Test enum. */ - @SuppressWarnings("JavaDoc") private enum TestEnum { /** */ A, @@ -2327,4 +2397,4 @@ private void readObject(ObjectInputStream os){ } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageIdUtilsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageIdUtilsSelfTest.java index 8b419444815cd..9b6d0b0b8d9a2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageIdUtilsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageIdUtilsSelfTest.java @@ -22,14 +22,19 @@ import org.apache.ignite.internal.pagemem.PageIdUtils; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class PageIdUtilsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRotatePageId() throws Exception { assertEquals(0x0102FFFFFFFFFFFFL, PageIdUtils.rotatePageId(0x0002FFFFFFFFFFFFL)); assertEquals(0x0B02FFFFFFFFFFFFL, PageIdUtils.rotatePageId(0x0A02FFFFFFFFFFFFL)); @@ -41,6 +46,7 @@ public void testRotatePageId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEffectivePageId() throws Exception { assertEquals(0x0000FFFFFFFFFFFFL, PageIdUtils.effectivePageId(0x0002FFFFFFFFFFFFL)); assertEquals(0x0000FFFFFFFFFFFFL, PageIdUtils.effectivePageId(0x0A02FFFFFFFFFFFFL)); @@ -51,6 +57,7 @@ public void testEffectivePageId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLinkConstruction() throws Exception { assertEquals(0x00FFFFFFFFFFFFFFL, PageIdUtils.link(0xFFFFFFFFFFFFFFL, 0)); assertEquals(0x01FFFFFFFFFFFFFFL, PageIdUtils.link(0xFFFFFFFFFFFFFFL, 1)); @@ -71,6 +78,7 @@ public void testLinkConstruction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOffsetExtraction() throws Exception { assertEquals(0, PageIdUtils.itemId(0x00FFFFFFFFFFFFFFL)); assertEquals(1, PageIdUtils.itemId(0x01FFFFFFFFFFFFFFL)); @@ -91,6 +99,7 @@ public void testOffsetExtraction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPageIdFromLink() throws Exception { assertEquals(0x00FFFFFFFFFFFFFFL, PageIdUtils.pageId(0x00FFFFFFFFFFFFFFL)); assertEquals(0x00FFFFFFFFFFFFFFL, PageIdUtils.pageId(0x10FFFFFFFFFFFFFFL)); @@ -121,6 +130,7 @@ public void testPageIdFromLink() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomIds() throws Exception { Random rnd = new Random(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoLoadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoLoadSelfTest.java index b3936341c4c00..68581dc7d2172 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoLoadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoLoadSelfTest.java @@ -37,10 +37,14 @@ import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class PageMemoryNoLoadSelfTest extends GridCommonAbstractTest { /** */ protected static final int PAGE_SIZE = 8 * 1024; @@ -59,6 +63,7 @@ public class PageMemoryNoLoadSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPageTearingInner() throws Exception { PageMemory mem = memory(); @@ -103,6 +108,7 @@ public void testPageTearingInner() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadedPagesCount() throws Exception { PageMemory mem = memory(); @@ -128,6 +134,7 @@ public void testLoadedPagesCount() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPageTearingSequential() throws Exception { PageMemory mem = memory(); @@ -180,6 +187,7 @@ public void testPageTearingSequential() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPageHandleDeallocation() throws Exception { PageMemory mem = memory(); @@ -207,6 +215,7 @@ public void testPageHandleDeallocation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPageIdRotation() throws Exception { PageMemory mem = memory(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/GridCacheTxLoadFromStoreOnLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/GridCacheTxLoadFromStoreOnLockSelfTest.java index 6293723f18ae6..5ac51b4b2780b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/GridCacheTxLoadFromStoreOnLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/GridCacheTxLoadFromStoreOnLockSelfTest.java @@ -30,33 +30,33 @@ import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheTxLoadFromStoreOnLockSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - cfg.getTransactionConfiguration().setTxSerializableEnabled(true); - cfg.setDiscoverySpi(disco); - return cfg; } @@ -68,6 +68,7 @@ public class GridCacheTxLoadFromStoreOnLockSelfTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testLoadedValueOneBackup() throws Exception { checkLoadedValue(1); } @@ -75,6 +76,7 @@ public void testLoadedValueOneBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadedValueNoBackups() throws Exception { checkLoadedValue(0); } @@ -152,4 +154,4 @@ private static class Store extends CacheStoreAdapter implement // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorAbstractSelfTest.java index 74c8ef22ea54d..dc8aa3db1a51f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorAbstractSelfTest.java @@ -28,10 +28,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -39,6 +40,7 @@ * Tests for {@link GridAffinityProcessor}. */ @GridCommonTest(group = "Affinity Processor") +@RunWith(JUnit4.class) public abstract class GridAffinityProcessorAbstractSelfTest extends GridCommonAbstractTest { /** Number of grids started for tests. Should not be less than 2. */ private static final int NODES_CNT = 3; @@ -46,9 +48,6 @@ public abstract class GridAffinityProcessorAbstractSelfTest extends GridCommonAb /** Cache name. */ private static final String CACHE_NAME = "cache"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Flag to start grid with cache. */ private boolean withCache; @@ -56,12 +55,7 @@ public abstract class GridAffinityProcessorAbstractSelfTest extends GridCommonAb @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setForceServerMode(true); - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); if (withCache) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -107,7 +101,7 @@ public abstract class GridAffinityProcessorAbstractSelfTest extends GridCommonAb * * @throws Exception In case of any exception. */ - @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes") + @Test public void testAffinityProcessor() throws Exception { Random rnd = new Random(); @@ -159,6 +153,7 @@ public void testAffinityProcessor() throws Exception { * * @throws Exception In case of any exception. */ + @Test public void testPerformance() throws Exception { IgniteKernal grid = (IgniteKernal)grid(0); GridAffinityProcessor aff = grid.context().affinity(); @@ -184,4 +179,4 @@ public void testPerformance() throws Exception { assertTrue(diff < 25000); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorMemoryLeakTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorMemoryLeakTest.java index d6c5727bc21f2..a9f57a7adf2fe 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorMemoryLeakTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorMemoryLeakTest.java @@ -26,11 +26,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE; import static org.apache.ignite.IgniteSystemProperties.getInteger; @@ -39,6 +40,7 @@ * Tests for {@link GridAffinityProcessor}. */ @GridCommonTest(group = "Affinity Processor") +@RunWith(JUnit4.class) public class GridAffinityProcessorMemoryLeakTest extends GridCommonAbstractTest { /** Max value for affinity history size name. Should be the same as in GridAffinityAssignmentCache.MAX_HIST_SIZE */ private final int MAX_HIST_SIZE = getInteger(IGNITE_AFFINITY_HISTORY_SIZE, 500); @@ -46,20 +48,11 @@ public class GridAffinityProcessorMemoryLeakTest extends GridCommonAbstractTest /** Cache name. */ private static final String CACHE_NAME = "cache"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setForceServerMode(true); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -84,6 +77,7 @@ public class GridAffinityProcessorMemoryLeakTest extends GridCommonAbstractTest * * @throws Exception In case of any exception. */ + @Test public void testAffinityProcessor() throws Exception { Ignite ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/Authentication1kUsersNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/Authentication1kUsersNodeRestartTest.java index 0ca621e3bc2ad..10f112162304b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/Authentication1kUsersNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/Authentication1kUsersNodeRestartTest.java @@ -22,29 +22,24 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link IgniteAuthenticationProcessor} on unstable topology. */ +@RunWith(JUnit4.class) public class Authentication1kUsersNodeRestartTest extends GridCommonAbstractTest { /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - + private static final int USERS_COUNT = 1000; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - cfg.setAuthenticationEnabled(true); cfg.setDataStorageConfiguration(new DataStorageConfiguration() @@ -71,6 +66,7 @@ public class Authentication1kUsersNodeRestartTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void test1kUsersNodeRestartServer() throws Exception { final int USERS_COUNT = 1000; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationConfigurationClusterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationConfigurationClusterTest.java index fb61d60ad656a..2e7dfc7e5ee83 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationConfigurationClusterTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationConfigurationClusterTest.java @@ -24,19 +24,17 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for disabled {@link IgniteAuthenticationProcessor}. */ +@RunWith(JUnit4.class) public class AuthenticationConfigurationClusterTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** * @param idx Node index. * @param authEnabled Authentication enabled. @@ -49,12 +47,6 @@ private IgniteConfiguration configuration(int idx, boolean authEnabled, boolean cfg.setClientMode(client); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - cfg.setAuthenticationEnabled(authEnabled); cfg.setDataStorageConfiguration(new DataStorageConfiguration() @@ -82,6 +74,7 @@ private IgniteConfiguration configuration(int idx, boolean authEnabled, boolean /** * @throws Exception If failed. */ + @Test public void testServerNodeJoinDisabled() throws Exception { checkNodeJoinDisabled(false); } @@ -89,6 +82,7 @@ public void testServerNodeJoinDisabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNodeJoinDisabled() throws Exception { checkNodeJoinDisabled(true); } @@ -96,6 +90,7 @@ public void testClientNodeJoinDisabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerNodeJoinEnabled() throws Exception { checkNodeJoinEnabled(false); } @@ -103,6 +98,7 @@ public void testServerNodeJoinEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNodeJoinEnabled() throws Exception { checkNodeJoinEnabled(true); } @@ -146,6 +142,7 @@ private void checkNodeJoinEnabled(boolean client) throws Exception { /** * @throws Exception If failed. */ + @Test public void testDisabledAuthentication() throws Exception { startGrid(configuration(0, false, false)); @@ -191,6 +188,7 @@ public void testDisabledAuthentication() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEnableAuthenticationWithoutPersistence() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable() { @Override public Object call() throws Exception { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationOnNotActiveClusterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationOnNotActiveClusterTest.java index 638c378bb1837..751577707d7e0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationOnNotActiveClusterTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationOnNotActiveClusterTest.java @@ -21,18 +21,17 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link IgniteAuthenticationProcessor}. */ +@RunWith(JUnit4.class) public class AuthenticationOnNotActiveClusterTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Nodes count. */ protected static final int NODES_COUNT = 4; @@ -46,12 +45,6 @@ public class AuthenticationOnNotActiveClusterTest extends GridCommonAbstractTest if (getTestIgniteInstanceIndex(igniteInstanceName) == CLI_NODE) cfg.setClientMode(true); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - cfg.setAuthenticationEnabled(true); cfg.setDataStorageConfiguration(new DataStorageConfiguration() @@ -79,6 +72,7 @@ public class AuthenticationOnNotActiveClusterTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testDefaultUser() throws Exception { startGrids(NODES_COUNT); @@ -93,6 +87,7 @@ public void testDefaultUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotDefaultUser() throws Exception { startGrids(NODES_COUNT + 1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorNPEOnStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorNPEOnStartTest.java index 661c875e61916..cc8bc325006ee 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorNPEOnStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorNPEOnStartTest.java @@ -22,29 +22,21 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for NPE on start node simultaneous. */ +@RunWith(JUnit4.class) public class AuthenticationProcessorNPEOnStartTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - cfg.setAuthenticationEnabled(true); cfg.setDataStorageConfiguration(new DataStorageConfiguration() @@ -72,6 +64,7 @@ public class AuthenticationProcessorNPEOnStartTest extends GridCommonAbstractTes /** * @throws Exception If failed. */ + @Test public void test() throws Exception { final AtomicInteger nodeIdx = new AtomicInteger(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorNodeRestartTest.java index 6f10aa784040d..4534a4f73108e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorNodeRestartTest.java @@ -25,19 +25,17 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link IgniteAuthenticationProcessor} on unstable topology. */ +@RunWith(JUnit4.class) public class AuthenticationProcessorNodeRestartTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Nodes count. */ private static final int NODES_COUNT = 4; @@ -60,12 +58,6 @@ public class AuthenticationProcessorNodeRestartTest extends GridCommonAbstractTe if (getTestIgniteInstanceIndex(igniteInstanceName) == CLI_NODE) cfg.setClientMode(true); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - cfg.setAuthenticationEnabled(true); cfg.setDataStorageConfiguration(new DataStorageConfiguration() @@ -101,6 +93,7 @@ public class AuthenticationProcessorNodeRestartTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testConcurrentAddUpdateRemoveNodeRestartCoordinator() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-7472"); @@ -163,6 +156,7 @@ public void testConcurrentAddUpdateRemoveNodeRestartCoordinator() throws Excepti /** * @throws Exception If failed. */ + @Test public void testConcurrentAuthorize() throws Exception { final int testUsersCnt = 10; @@ -262,6 +256,7 @@ private IgniteInternalFuture restartCoordinator() { /** * @throws Exception If failed. */ + @Test public void test1kUsersNodeRestartServer() throws Exception { final AtomicInteger usrCnt = new AtomicInteger(); @@ -316,6 +311,7 @@ public void test1kUsersNodeRestartServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentAddUpdateRemoveNodeRestartServer() throws Exception { IgniteInternalFuture restartFut = loopServerRestarts(); @@ -349,6 +345,7 @@ public void testConcurrentAddUpdateRemoveNodeRestartServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentFailedOperationNodeRestartServer() throws Exception { IgniteInternalFuture restartFut = loopServerRestarts(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorSelfTest.java index 6c79c7f380411..b47b0e7a87e86 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/authentication/AuthenticationProcessorSelfTest.java @@ -28,19 +28,17 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link IgniteAuthenticationProcessor}. */ +@RunWith(JUnit4.class) public class AuthenticationProcessorSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Nodes count. */ protected static final int NODES_COUNT = 4; @@ -75,12 +73,6 @@ private static String randomString(int len) { if (getTestIgniteInstanceIndex(igniteInstanceName) == CLI_NODE) cfg.setClientMode(true); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - cfg.setAuthenticationEnabled(true); cfg.setDataStorageConfiguration(new DataStorageConfiguration() @@ -116,6 +108,7 @@ private static String randomString(int len) { /** * @throws Exception If failed. */ + @Test public void testDefaultUser() throws Exception { for (int i = 0; i < NODES_COUNT; ++i) { AuthorizationContext actx = grid(i).context().authentication().authenticate("ignite", "ignite"); @@ -128,6 +121,7 @@ public void testDefaultUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultUserUpdate() throws Exception { AuthorizationContext.context(actxDflt); @@ -153,6 +147,7 @@ public void testDefaultUserUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveDefault() throws Exception { AuthorizationContext.context(actxDflt); @@ -179,6 +174,7 @@ public void testRemoveDefault() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUserManagementPermission() throws Exception { AuthorizationContext.context(actxDflt); @@ -232,6 +228,7 @@ public void testUserManagementPermission() throws Exception { /** * @throws Exception If failed. */ + @Test public void testProceedUsersOnJoinNode() throws Exception { AuthorizationContext.context(actxDflt); @@ -259,6 +256,7 @@ public void testProceedUsersOnJoinNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAuthenticationInvalidUser() throws Exception { AuthorizationContext.context(actxDflt); @@ -291,6 +289,7 @@ public void testAuthenticationInvalidUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddUpdateRemoveUser() throws Exception { AuthorizationContext.context(actxDflt); @@ -308,6 +307,7 @@ public void testAddUpdateRemoveUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateUser() throws Exception { AuthorizationContext.context(actxDflt); @@ -329,6 +329,7 @@ public void testUpdateUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateRemoveDoesNotExistsUser() throws Exception { AuthorizationContext.context(actxDflt); @@ -361,6 +362,7 @@ public void testUpdateRemoveDoesNotExistsUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddAlreadyExistsUser() throws Exception { AuthorizationContext.context(actxDflt); @@ -387,6 +389,7 @@ public void testAddAlreadyExistsUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAuthorizeOnClientDisconnect() throws Exception { AuthorizationContext.context(actxDflt); @@ -431,6 +434,7 @@ public void testAuthorizeOnClientDisconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentAddRemove() throws Exception { final AtomicInteger usrCnt = new AtomicInteger(); @@ -457,6 +461,7 @@ public void testConcurrentAddRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUserPersistence() throws Exception { AuthorizationContext.context(actxDflt); @@ -494,6 +499,7 @@ public void testUserPersistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultUserPersistence() throws Exception { AuthorizationContext.context(actxDflt); @@ -529,6 +535,7 @@ public void testDefaultUserPersistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvalidUserNamePassword() throws Exception { AuthorizationContext.context(actxDflt); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/AtomicCacheAffinityConfigurationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/AtomicCacheAffinityConfigurationTest.java index 3fd4e1f476807..726450969e1c7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/AtomicCacheAffinityConfigurationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/AtomicCacheAffinityConfigurationTest.java @@ -29,9 +29,13 @@ import org.apache.ignite.internal.processors.datastructures.AtomicDataStructureProxy; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class AtomicCacheAffinityConfigurationTest extends GridCommonAbstractTest { /** Affinity function. */ private AffinityFunction affinityFunction; @@ -48,6 +52,7 @@ public class AtomicCacheAffinityConfigurationTest extends GridCommonAbstractTest * @throws Exception If failed. * */ + @Test public void testRendezvousAffinity() throws Exception { try { affinityFunction = new RendezvousAffinityFunction(false, 10); @@ -80,6 +85,7 @@ public void testRendezvousAffinity() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTestAffinity() throws Exception { try { affinityFunction = new TestAffinityFunction("Some value"); @@ -112,6 +118,7 @@ public void testTestAffinity() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultAffinity() throws Exception { try { affinityFunction = null; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataRegistrationInsideEntryProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataRegistrationInsideEntryProcessorTest.java index 73dae4bb39a5d..0c878c7d4602a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataRegistrationInsideEntryProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataRegistrationInsideEntryProcessorTest.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.cache; -import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.cache.processor.EntryProcessor; @@ -29,10 +29,14 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class BinaryMetadataRegistrationInsideEntryProcessorTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "test-cache"; @@ -40,7 +44,7 @@ public class BinaryMetadataRegistrationInsideEntryProcessorTest extends GridComm /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration() { TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder() - .setAddresses(Arrays.asList("127.0.0.1:47500..47509")); + .setAddresses(Collections.singletonList("127.0.0.1:47500..47509")); return new IgniteConfiguration() .setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder)) @@ -50,6 +54,7 @@ public class BinaryMetadataRegistrationInsideEntryProcessorTest extends GridComm /** * @throws Exception If failed; */ + @Test public void test() throws Exception { Ignite ignite = startGrids(2); @@ -60,9 +65,9 @@ public void test() throws Exception { cache.invoke(i, new CustomProcessor()); } catch (Exception e) { - Map value = cache.get(1); + Map val = cache.get(1); - if ((value != null) && (value.get(1) != null) && (value.get(1).getObj() == CustomEnum.ONE)) + if ((val != null) && (val.get(1).anEnum == CustomEnum.ONE) && val.get(1).obj.data.equals("test")) System.out.println("Data was saved."); else System.out.println("Data wasn't saved."); @@ -82,7 +87,7 @@ private static class CustomProcessor implements EntryProcessor map = new HashMap<>(); - map.put(1, new CustomObj(CustomEnum.ONE)); + map.put(1, new CustomObj(new CustomInnerObject("test"), CustomEnum.ONE)); entry.setValue(map); @@ -95,27 +100,20 @@ private static class CustomProcessor implements EntryProcessor { clo.apply(i, i); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheComparatorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheComparatorTest.java index 0bd587de85d40..94b3a33aa4d7e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheComparatorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheComparatorTest.java @@ -17,17 +17,20 @@ package org.apache.ignite.internal.processors.cache; -import junit.framework.TestCase; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.query.QuerySchema; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * Test for CacheComparators from ClusterCachesInfo */ -public class CacheComparatorTest extends TestCase { +public class CacheComparatorTest { /** * Test if comparator not violates its general contract */ + @Test public void testDirect() { DynamicCacheDescriptor desc1 = new DynamicCacheDescriptor(null, new CacheConfiguration().setName("1111"), CacheType.DATA_STRUCTURES, diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java index 130280dd3fcb0..87190f01737ed 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java @@ -24,7 +24,6 @@ import javax.cache.configuration.Factory; import javax.cache.integration.CacheLoaderException; import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCompute; import org.apache.ignite.IgniteException; import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.configuration.CacheConfiguration; @@ -32,31 +31,35 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test was added to check fix for IGNITE-4465. */ +@RunWith(JUnit4.class) public class CacheConcurrentReadThroughTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SYS_THREADS = 16; /** */ private boolean client; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); if (!client) { @@ -77,6 +80,7 @@ public class CacheConcurrentReadThroughTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testConcurrentReadThrough() throws Exception { startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java index 6b0386729e738..d85c52bbfa174 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationLeakTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheConfigurationLeakTest extends GridCommonAbstractTest { /** * @@ -60,6 +64,7 @@ public CacheConfigurationLeakTest() { /** * @throws Exception If failed. */ + @Test public void testCacheCreateLeak() throws Exception { final Ignite ignite = grid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConnectionLeakStoreTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConnectionLeakStoreTxTest.java index 27dbe62577a61..5e16e173523c2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConnectionLeakStoreTxTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConnectionLeakStoreTxTest.java @@ -34,14 +34,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.resources.CacheStoreSessionResource; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.cache.TestCacheSession; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -51,10 +52,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheConnectionLeakStoreTxTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -71,11 +70,6 @@ public class CacheConnectionLeakStoreTxTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); cfg.setClientMode(client); return cfg; @@ -101,6 +95,7 @@ public class CacheConnectionLeakStoreTxTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testConnectionLeakOneBackupAtomic() throws Exception { checkConnectionLeak(CacheAtomicityMode.ATOMIC, null, null); } @@ -108,6 +103,7 @@ public void testConnectionLeakOneBackupAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionLeakOneBackupAtomicLoadFromStore() throws Exception { isLoadFromStore = true; @@ -117,6 +113,7 @@ public void testConnectionLeakOneBackupAtomicLoadFromStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionLeakOneBackupOptimisticRepeatableRead() throws Exception { checkConnectionLeak(CacheAtomicityMode.TRANSACTIONAL, OPTIMISTIC, REPEATABLE_READ); } @@ -124,6 +121,7 @@ public void testConnectionLeakOneBackupOptimisticRepeatableRead() throws Excepti /** * @throws Exception If failed. */ + @Test public void testConnectionLeakOneBackupOptimisticRepeatableReadLoadFromStore() throws Exception { isLoadFromStore = true; @@ -133,6 +131,7 @@ public void testConnectionLeakOneBackupOptimisticRepeatableReadLoadFromStore() t /** * @throws Exception If failed. */ + @Test public void testConnectionLeakOneBackupOptimisticReadCommitted() throws Exception { checkConnectionLeak(CacheAtomicityMode.TRANSACTIONAL, OPTIMISTIC, READ_COMMITTED); } @@ -140,6 +139,7 @@ public void testConnectionLeakOneBackupOptimisticReadCommitted() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testConnectionLeakOneBackupOptimisticReadCommittedLoadFromStore() throws Exception { isLoadFromStore = true; @@ -149,6 +149,7 @@ public void testConnectionLeakOneBackupOptimisticReadCommittedLoadFromStore() th /** * @throws Exception If failed. */ + @Test public void testConnectionLeakOneBackupPessimisticRepeatableRead() throws Exception { checkConnectionLeak(CacheAtomicityMode.TRANSACTIONAL, PESSIMISTIC, REPEATABLE_READ); } @@ -156,6 +157,7 @@ public void testConnectionLeakOneBackupPessimisticRepeatableRead() throws Except /** * @throws Exception If failed. */ + @Test public void testConnectionLeakOneBackupPessimisticReadCommitted() throws Exception { checkConnectionLeak(CacheAtomicityMode.TRANSACTIONAL, PESSIMISTIC, READ_COMMITTED); } @@ -163,12 +165,33 @@ public void testConnectionLeakOneBackupPessimisticReadCommitted() throws Excepti /** * @throws Exception If failed. */ + @Test public void testConnectionLeakOneBackupPessimisticReadCommittedLoadFromStore() throws Exception { isLoadFromStore = true; checkConnectionLeak(CacheAtomicityMode.TRANSACTIONAL, PESSIMISTIC, READ_COMMITTED); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testConnectionLeakOneBackupMvccPessimisticRepeatableRead() throws Exception { + checkConnectionLeak(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, PESSIMISTIC, REPEATABLE_READ); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testConnectionLeakOneBackupMvccPessimisticRepeatableReadLoadFromStore() throws Exception { + isLoadFromStore = true; + + checkConnectionLeak(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, PESSIMISTIC, REPEATABLE_READ); + } + /** * @param atomicityMode Atomicity mode. * @param txConcurrency Transaction concurrency. @@ -283,4 +306,4 @@ private void addSession() { sessions.remove(ses == null ? NULL : ses); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDataRegionConfigurationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDataRegionConfigurationTest.java index 614c90051ca55..852fca470b174 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDataRegionConfigurationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDataRegionConfigurationTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheDataRegionConfigurationTest extends GridCommonAbstractTest { /** */ private volatile CacheConfiguration ccfg; @@ -77,6 +81,7 @@ private void checkStartGridException(Class ex, String messa /** * Verifies that proper exception is thrown when DataRegion is misconfigured for cache. */ + @Test public void testMissingDataRegion() { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -88,6 +93,7 @@ public void testMissingDataRegion() { /** * Verifies that {@link IgniteOutOfMemoryException} is thrown when cache is configured with too small DataRegion. */ + @Test public void testTooSmallDataRegion() throws Exception { memCfg = new DataStorageConfiguration(); @@ -142,6 +148,7 @@ public void testTooSmallDataRegion() throws Exception { /** * Verifies that with enough memory allocated adding values to cache doesn't cause any exceptions. */ + @Test public void testProperlySizedMemoryPolicy() throws Exception { memCfg = new DataStorageConfiguration(); @@ -177,6 +184,7 @@ public void testProperlySizedMemoryPolicy() throws Exception { * Verifies that {@link IgniteCheckedException} is thrown when swap and persistence are enabled at the same time * for a data region. */ + @Test public void testSetPersistenceAndSwap() { DataRegionConfiguration invCfg = new DataRegionConfiguration(); @@ -200,6 +208,7 @@ public void testSetPersistenceAndSwap() { /** * Verifies that {@link IgniteCheckedException} is thrown when page eviction threshold is less than 0.5. */ + @Test public void testSetSmallInvalidEviction() { final double SMALL_EVICTION_THRESHOLD = 0.1D; DataRegionConfiguration invCfg = new DataRegionConfiguration(); @@ -222,6 +231,7 @@ public void testSetSmallInvalidEviction() { /** * Verifies that {@link IgniteCheckedException} is thrown when page eviction threshold is greater than 0.999. */ + @Test public void testSetBigInvalidEviction() { final double BIG_EVICTION_THRESHOLD = 1.0D; DataRegionConfiguration invCfg = new DataRegionConfiguration(); @@ -244,6 +254,7 @@ public void testSetBigInvalidEviction() { /** * Verifies that {@link IgniteCheckedException} is thrown when empty pages pool size is less than 10 */ + @Test public void testInvalidSmallEmptyPagesPoolSize() { final int SMALL_PAGES_POOL_SIZE = 5; DataRegionConfiguration invCfg = new DataRegionConfiguration(); @@ -267,6 +278,7 @@ public void testInvalidSmallEmptyPagesPoolSize() { * Verifies that {@link IgniteCheckedException} is thrown when empty pages pool size is greater than * DataRegionConfiguration.getMaxSize() / DataStorageConfiguration.getPageSize() / 10. */ + @Test public void testInvalidBigEmptyPagesPoolSize() { final int DFLT_PAGE_SIZE = 1024; long expectedMaxPoolSize; @@ -298,6 +310,7 @@ public void testInvalidBigEmptyPagesPoolSize() { * Verifies that {@link IgniteCheckedException} is thrown when IgniteCheckedException if validation of * memory metrics properties fails. Metrics rate time interval must not be less than 1000ms. */ + @Test public void testInvalidMetricsProperties() { final long SMALL_RATE_TIME_INTERVAL_MS = 999; DataRegionConfiguration invCfg = new DataRegionConfiguration(); @@ -321,6 +334,7 @@ public void testInvalidMetricsProperties() { * Verifies that {@link IgniteCheckedException} is thrown when IgniteCheckedException if validation of * memory metrics properties fails. Metrics sub interval count must be positive. */ + @Test public void testInvalidSubIntervalCount() { final int NEG_SUB_INTERVAL_COUNT = -1000; DataRegionConfiguration invCfg = new DataRegionConfiguration(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteQueueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteQueueTest.java index 871bc338e9698..c4f0c1bced992 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteQueueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteQueueTest.java @@ -28,16 +28,22 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_REMOVED_ENTRIES_TTL; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class CacheDeferredDeleteQueueTest extends GridCommonAbstractTest { /** */ private static String ttlProp; @@ -65,16 +71,28 @@ public class CacheDeferredDeleteQueueTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDeferredDeleteQueue() throws Exception { testQueue(ATOMIC, false); testQueue(TRANSACTIONAL, false); + testQueue(TRANSACTIONAL_SNAPSHOT, false); + testQueue(ATOMIC, true); testQueue(TRANSACTIONAL, true); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testDeferredDeleteQueueMvcc() throws Exception { + testQueue(TRANSACTIONAL_SNAPSHOT, true); + } + /** * @param atomicityMode Cache atomicity mode. * @param nearCache {@code True} if need create near cache. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java index dd7579905b29d..ae63b1ba9c471 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDeferredDeleteSanitySelfTest.java @@ -23,9 +23,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -33,6 +38,7 @@ /** * Sanity tests of deferred delete for different cache configurations. */ +@RunWith(JUnit4.class) public class CacheDeferredDeleteSanitySelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -42,6 +48,7 @@ public class CacheDeferredDeleteSanitySelfTest extends GridCommonAbstractTest { /** * @throws Exception If fails. */ + @Test public void testDeferredDelete() throws Exception { testDeferredDelete(LOCAL, ATOMIC, false, false); testDeferredDelete(LOCAL, TRANSACTIONAL, false, false); @@ -63,6 +70,35 @@ public void testDeferredDelete() throws Exception { testDeferredDelete(REPLICATED, TRANSACTIONAL, true, true); } + /** + * @throws Exception If fails. + */ + @Test + public void testDeferredDeleteMvcc() throws Exception { + testDeferredDelete(PARTITIONED, TRANSACTIONAL_SNAPSHOT, false, true); + testDeferredDelete(REPLICATED, TRANSACTIONAL_SNAPSHOT, false, true); + } + + /** + * @throws Exception If fails. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testDeferredDeleteMvccNear() throws Exception { + testDeferredDelete(PARTITIONED, TRANSACTIONAL_SNAPSHOT, true, false); + testDeferredDelete(REPLICATED, TRANSACTIONAL_SNAPSHOT, true, true); + } + + /** + * @throws Exception If fails. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9530") + @Test + public void testDeferredDeleteMvccLocal() throws Exception { + testDeferredDelete(LOCAL, TRANSACTIONAL_SNAPSHOT, false, false); + testDeferredDelete(LOCAL, TRANSACTIONAL_SNAPSHOT, true, false); + } + /** * @param mode Mode. * @param atomicityMode Atomicity mode. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java index 09f2a6a8b7d67..3d380f096cd7b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java @@ -22,12 +22,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * Test for remove operation. */ +@RunWith(JUnit4.class) public class CacheDhtLocalPartitionAfterRemoveSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 3; @@ -54,6 +58,7 @@ public class CacheDhtLocalPartitionAfterRemoveSelfTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testMemoryUsage() throws Exception { assertEquals(10_000, GridDhtLocalPartition.MAX_DELETE_QUEUE_SIZE); @@ -105,4 +110,4 @@ public TestKey(String key) { return key.equals(((TestKey)obj).key); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java index aabd3b6445826..bb293f096807d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java @@ -31,14 +31,17 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for value copy in entry processor. */ +@RunWith(JUnit4.class) public class CacheEntryProcessorCopySelfTest extends GridCommonAbstractTest { /** Old value. */ private static final int OLD_VAL = 100; @@ -69,6 +72,7 @@ public class CacheEntryProcessorCopySelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testMutableEntryWithP2PEnabled() throws Exception { doTestMutableEntry(true); } @@ -76,6 +80,7 @@ public void testMutableEntryWithP2PEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMutableEntryWithP2PDisabled() throws Exception { doTestMutableEntry(false); } @@ -158,7 +163,7 @@ private void doTest(boolean cpOnRead, final boolean mutate, int expVal, int expC CacheObject obj = entry.peekVisibleValue(); - entry.touch(AffinityTopologyVersion.NONE); + entry.touch(); int actCnt = cnt.get(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEnumOperationsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEnumOperationsAbstractTest.java index 148b60e473060..61d4289db314b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEnumOperationsAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEnumOperationsAbstractTest.java @@ -29,22 +29,23 @@ import org.apache.ignite.internal.binary.BinaryEnumObjectImpl; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public abstract class CacheEnumOperationsAbstractTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -52,8 +53,6 @@ public abstract class CacheEnumOperationsAbstractTest extends GridCommonAbstract @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -82,6 +81,7 @@ public abstract class CacheEnumOperationsAbstractTest extends GridCommonAbstract /** * @throws Exception If failed. */ + @Test public void testAtomic() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, ATOMIC); @@ -91,8 +91,21 @@ public void testAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTx() throws Exception { - CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, ATOMIC); + CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, TRANSACTIONAL); + + enumOperations(ccfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTx() throws Exception { + Assume.assumeTrue("https://issues.apache.org/jira/browse/IGNITE-7187", singleNode()); + + CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, TRANSACTIONAL_SNAPSHOT); enumOperations(ccfg); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java index cdd0002d573ac..86919349b0662 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java @@ -39,20 +39,18 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.getFieldValue; /** * */ +@RunWith(JUnit4.class) public class CacheExchangeMessageDuplicatedStateTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String AFF1_CACHE1 = "a1c1"; @@ -75,8 +73,6 @@ public class CacheExchangeMessageDuplicatedStateTest extends GridCommonAbstractT @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi(); @@ -146,6 +142,7 @@ public class CacheExchangeMessageDuplicatedStateTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testExchangeMessages() throws Exception { ignite(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java index a51765c652d4c..2c522e7db9ebc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java @@ -30,20 +30,19 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; /** * Cache future self test. */ +@RunWith(JUnit4.class) public class CacheFutureExceptionSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static volatile boolean fail; @@ -53,12 +52,6 @@ public class CacheFutureExceptionSelfTest extends GridCommonAbstractTest { cfg.setIgniteInstanceName(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - if (igniteInstanceName.equals(getTestIgniteInstanceName(1))) cfg.setClientMode(true); @@ -73,6 +66,7 @@ public class CacheFutureExceptionSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAsyncCacheFuture() throws Exception { startGrid(0); @@ -93,6 +87,11 @@ public void testAsyncCacheFuture() throws Exception { * @throws Exception If failed. */ private void testGet(boolean nearCache, boolean cpyOnRead) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) { + if (!MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) + return; + } + fail = false; Ignite srv = grid(0); @@ -157,4 +156,4 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE in.readObject(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java index 6a7cfc6da4772..bfba956c0dbaf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java @@ -42,6 +42,9 @@ import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionOptimisticException; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -58,6 +61,7 @@ /** * Test getEntry and getEntries methods. */ +@RunWith(JUnit4.class) public abstract class CacheGetEntryAbstractTest extends GridCacheAbstractSelfTest { /** */ private static final String UPDATED_ENTRY_ERR = "Impossible to get version for entry updated in transaction"; @@ -98,6 +102,7 @@ public abstract class CacheGetEntryAbstractTest extends GridCacheAbstractSelfTes /** * @throws Exception If failed. */ + @Test public void testNear() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -113,6 +118,7 @@ public void testNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearTransactional() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -128,6 +134,7 @@ public void testNearTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitioned() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -142,6 +149,7 @@ public void testPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionedTransactional() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -156,6 +164,7 @@ public void testPartitionedTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocal() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -170,9 +179,8 @@ public void testLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalTransactional() throws Exception { - // TODO: fails since d13520e9a05bd9e9b987529472d6317951b72f96, need to review changes. - CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); cfg.setWriteSynchronizationMode(FULL_SYNC); @@ -186,6 +194,7 @@ public void testLocalTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicated() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -200,6 +209,7 @@ public void testReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedTransactional() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -215,7 +225,7 @@ public void testReplicatedTransactional() throws Exception { * @param cfg Cache configuration. * @throws Exception If failed. */ - private void test(CacheConfiguration cfg) throws Exception { + protected void test(CacheConfiguration cfg) throws Exception { test(cfg, true); test(cfg, false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSelfTest.java similarity index 95% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSelfTest.java index c04612d08d235..09275468b338e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSelfTest.java @@ -23,7 +23,7 @@ /** * Test getEntry and getEntries methods. */ -public class CacheGetEntryOptimisticReadCommittedSeltTest extends CacheGetEntryAbstractTest { +public class CacheGetEntryOptimisticReadCommittedSelfTest extends CacheGetEntryAbstractTest { /** {@inheritDoc} */ @Override protected TransactionConcurrency concurrency() { return TransactionConcurrency.OPTIMISTIC; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSelfTest.java similarity index 95% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSelfTest.java index 6153869821a0b..2c6a20440e196 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSelfTest.java @@ -23,7 +23,7 @@ /** * Test getEntry and getEntries methods. */ -public class CacheGetEntryOptimisticRepeatableReadSeltTest extends CacheGetEntryAbstractTest { +public class CacheGetEntryOptimisticRepeatableReadSelfTest extends CacheGetEntryAbstractTest { /** {@inheritDoc} */ @Override protected TransactionConcurrency concurrency() { return TransactionConcurrency.OPTIMISTIC; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSelfTest.java similarity index 95% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSelfTest.java index 6ded4a9acd2e2..63161e245d401 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSelfTest.java @@ -23,7 +23,7 @@ /** * Test getEntry and getEntries methods. */ -public class CacheGetEntryOptimisticSerializableSeltTest extends CacheGetEntryAbstractTest { +public class CacheGetEntryOptimisticSerializableSelfTest extends CacheGetEntryAbstractTest { /** {@inheritDoc} */ @Override protected TransactionConcurrency concurrency() { return TransactionConcurrency.OPTIMISTIC; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSelfTest.java similarity index 95% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSelfTest.java index 975d2718af5e5..0a291f768d997 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSelfTest.java @@ -23,7 +23,7 @@ /** * Test getEntry and getEntries methods. */ -public class CacheGetEntryPessimisticReadCommittedSeltTest extends CacheGetEntryAbstractTest { +public class CacheGetEntryPessimisticReadCommittedSelfTest extends CacheGetEntryAbstractTest { /** {@inheritDoc} */ @Override protected TransactionConcurrency concurrency() { return TransactionConcurrency.PESSIMISTIC; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSelfTest.java new file mode 100644 index 0000000000000..6852997a825b2 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSelfTest.java @@ -0,0 +1,109 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Ignore; +import org.junit.Test; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheMode.LOCAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheMode.REPLICATED; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; + +/** + * Test getEntry and getEntries methods. + */ +public class CacheGetEntryPessimisticRepeatableReadSelfTest extends CacheGetEntryAbstractTest { + /** {@inheritDoc} */ + @Override protected TransactionConcurrency concurrency() { + return TransactionConcurrency.PESSIMISTIC; + } + + /** {@inheritDoc} */ + @Override protected TransactionIsolation isolation() { + return TransactionIsolation.REPEATABLE_READ; + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testNearTransactionalMvcc() throws Exception { + CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + + cfg.setWriteSynchronizationMode(FULL_SYNC); + cfg.setCacheMode(PARTITIONED); + cfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + cfg.setName("nearT"); + cfg.setNearConfiguration(new NearCacheConfiguration()); + + test(cfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPartitionedTransactionalMvcc() throws Exception { + CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + + cfg.setWriteSynchronizationMode(FULL_SYNC); + cfg.setCacheMode(PARTITIONED); + cfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + cfg.setName("partitionedT"); + + test(cfg); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9530") + @Test + public void testLocalTransactionalMvcc() throws Exception { + CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + + cfg.setWriteSynchronizationMode(FULL_SYNC); + cfg.setCacheMode(LOCAL); + cfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + cfg.setName("localT"); + + test(cfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testReplicatedTransactionalMvcc() throws Exception { + CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + + cfg.setWriteSynchronizationMode(FULL_SYNC); + cfg.setCacheMode(REPLICATED); + cfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + cfg.setName("replicatedT"); + + test(cfg); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSelfTest.java similarity index 95% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSelfTest.java index 70f71ced31342..dfaed7e4149fa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSelfTest.java @@ -23,7 +23,7 @@ /** * Test getEntry and getEntries methods. */ -public class CacheGetEntryPessimisticSerializableSeltTest extends CacheGetEntryAbstractTest { +public class CacheGetEntryPessimisticSerializableSelfTest extends CacheGetEntryAbstractTest { /** {@inheritDoc} */ @Override protected TransactionConcurrency concurrency() { return TransactionConcurrency.PESSIMISTIC; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetFromJobTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetFromJobTest.java index 7c9eeec7f9278..05a7c58ef9b89 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetFromJobTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetFromJobTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Job tries to get cache during topology change. */ +@RunWith(JUnit4.class) public class CacheGetFromJobTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -49,6 +53,7 @@ public class CacheGetFromJobTest extends GridCacheAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testTopologyChange() throws Exception { final AtomicReference err = new AtomicReference<>(); @@ -113,4 +118,4 @@ public TestJob() { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetsDistributionAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetsDistributionAbstractTest.java new file mode 100644 index 0000000000000..c4d490983e6cd --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetsDistributionAbstractTest.java @@ -0,0 +1,383 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.UUID; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.TransactionConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.util.lang.GridAbsPredicate; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; +import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS; +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Tests of replicated cache's 'get' requests distribution. + */ +@RunWith(JUnit4.class) +public abstract class CacheGetsDistributionAbstractTest extends GridCommonAbstractTest { + /** Client nodes instance's name. */ + private static final String CLIENT_NAME = "client"; + + /** Value prefix. */ + private static final String VAL_PREFIX = "val"; + + /** */ + private static final int PRIMARY_KEYS_NUMBER = 1_000; + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + assert gridCount() >= 1 : "At least one grid must be started"; + + startGridsMultiThreaded(gridCount()); + + IgniteConfiguration clientCfg = getConfiguration(CLIENT_NAME); + + clientCfg.setClientMode(true); + + startGrid(clientCfg); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + IgniteCache cache = ignite(0).cache(DEFAULT_CACHE_NAME); + + if (cache != null) + cache.destroy(); + + // Setting different MAC addresses for all nodes + Map macs = getClusterMacs(); + + int idx = 0; + + for (Map.Entry entry : macs.entrySet()) + entry.setValue("x2-xx-xx-xx-xx-x" + idx++); + + replaceMacAddresses(G.allGrids(), macs); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + TransactionConfiguration txCfg = new TransactionConfiguration() + .setDefaultTxIsolation(transactionIsolation()) + .setDefaultTxConcurrency(transactionConcurrency()); + + cfg.setTransactionConfiguration(txCfg); + + return cfg; + } + + /** + * @return Grids count to start. + */ + protected int gridCount() { + return 4; + } + + /** + * @return Cache configuration. + */ + protected CacheConfiguration cacheConfiguration() { + CacheConfiguration ccfg = defaultCacheConfiguration(); + + ccfg.setCacheMode(cacheMode()); + ccfg.setAtomicityMode(atomicityMode()); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setReadFromBackup(true); + ccfg.setStatisticsEnabled(true); + + if (cacheMode() == CacheMode.PARTITIONED) + ccfg.setBackups(backupsCount()); + + return ccfg; + } + + /** + * @return Cache mode. + */ + protected abstract CacheMode cacheMode(); + + /** + * @return Cache atomicity mode. + */ + protected abstract CacheAtomicityMode atomicityMode(); + + /** + * @return Cache transaction isolation. + */ + protected TransactionIsolation transactionIsolation() { + return REPEATABLE_READ; + } + + /** + * @return Cache transaction concurrency. + */ + protected TransactionConcurrency transactionConcurrency() { + return PESSIMISTIC; + } + + /** + * @return Backups count. + */ + protected int backupsCount() { + return gridCount() - 1; + } + + /** + * Test 'get' operations requests generator distribution. + * + * @throws Exception In case of an error. + * @see #runTestBalancingDistribution(boolean) + */ + @Test + public void testGetRequestsGeneratorDistribution() throws Exception { + runTestBalancingDistribution(false); + } + + /** + * Test 'getAll' operations requests generator distribution. + * + * @throws Exception In case of an error. + * @see #runTestBalancingDistribution(boolean) + */ + @Test + public void testGetAllRequestsGeneratorDistribution() throws Exception { + runTestBalancingDistribution(true); + } + + /** + * @param batchMode Whenever 'get' or 'getAll' operations are used in the test. + * @throws Exception In case of an error. + */ + protected void runTestBalancingDistribution(boolean batchMode) throws Exception { + IgniteCache cache = grid(0).createCache(cacheConfiguration()); + + List keys = primaryKeys(cache, PRIMARY_KEYS_NUMBER); + + for (Integer key : keys) + cache.put(key, VAL_PREFIX + key); + + IgniteCache clientCache = grid(CLIENT_NAME).cache(DEFAULT_CACHE_NAME) + .withAllowAtomicOpsInTx(); + + assertTrue(GridTestUtils.waitForCondition( + new GridAbsPredicate() { + int batchSize = 10; + int idx = 0; + + @Override public boolean apply() { + if (idx >= PRIMARY_KEYS_NUMBER) + idx = 0; + + try (Transaction tx = grid(CLIENT_NAME).transactions().txStart()) { + if (batchMode) { + Set keys0 = new TreeSet<>(); + + for (int i = idx; i < idx + batchSize && i < PRIMARY_KEYS_NUMBER; i++) + keys0.add(keys.get(i)); + + idx += batchSize; + + Map results = clientCache.getAll(keys0); + + for (Map.Entry entry : results.entrySet()) + assertEquals(VAL_PREFIX + entry.getKey(), entry.getValue()); + } + else { + for (int i = idx; i < idx + gridCount() && i < PRIMARY_KEYS_NUMBER; i++) { + Integer key = keys.get(i); + + assertEquals(VAL_PREFIX + key, clientCache.get(key)); + } + + idx += gridCount(); + } + + tx.commit(); + } + + for (int i = 0; i < gridCount(); i++) { + IgniteEx ignite = grid(i); + + long getsCnt = ignite.cache(DEFAULT_CACHE_NAME).localMetrics().getCacheGets(); + + if (getsCnt == 0) + return false; + } + + return true; + } + }, + getTestTimeout()) + ); + } + + /** + * Tests that the 'get' operation requests are routed to node with same MAC address as at requester. + * + * @throws Exception In case of an error. + * @see #runTestSameHostDistribution(UUID, boolean) + */ + @Test + public void testGetRequestsDistribution() throws Exception { + UUID destId = grid(0).localNode().id(); + + runTestSameHostDistribution(destId, false); + } + + /** + * Tests that the 'getAll' operation requests are routed to node with same MAC address as at requester. + * + * @throws Exception In case of an error. + * @see #runTestSameHostDistribution(UUID, boolean) + */ + @Test + public void testGetAllRequestsDistribution() throws Exception { + UUID destId = grid(gridCount() - 1).localNode().id(); + + runTestSameHostDistribution(destId, true); + } + + /** + * Tests that the 'get' and 'getAll' requests are routed to node with same MAC address as at requester. + * + * @param destId Destination Ignite instance id for requests distribution. + * @param batchMode Test mode. + * @throws Exception In case of an error. + */ + protected void runTestSameHostDistribution(final UUID destId, final boolean batchMode) throws Exception { + Map macs = getClusterMacs(); + + String clientMac = macs.get(grid(CLIENT_NAME).localNode().id()); + + macs.put(destId, clientMac); + + replaceMacAddresses(G.allGrids(), macs); + + IgniteCache cache = grid(0).createCache(cacheConfiguration()); + + List keys = primaryKeys(cache, PRIMARY_KEYS_NUMBER); + + for (Integer key : keys) + cache.put(key, VAL_PREFIX + key); + + IgniteCache clientCache = grid(CLIENT_NAME).cache(DEFAULT_CACHE_NAME) + .withAllowAtomicOpsInTx(); + + try (Transaction tx = grid(CLIENT_NAME).transactions().txStart()) { + if (batchMode) { + Map results = clientCache.getAll(new TreeSet<>(keys)); + + for (Map.Entry entry : results.entrySet()) + assertEquals(VAL_PREFIX + entry.getKey(), entry.getValue()); + } + else { + for (Integer key : keys) + assertEquals(VAL_PREFIX + key, clientCache.get(key)); + } + + tx.commit(); + } + + for (int i = 0; i < gridCount(); i++) { + IgniteEx ignite = grid(i); + + long getsCnt = ignite.cache(DEFAULT_CACHE_NAME).localMetrics().getCacheGets(); + + if (destId.equals(ignite.localNode().id())) + assertEquals(PRIMARY_KEYS_NUMBER, getsCnt); + else + assertEquals(0L, getsCnt); + } + } + + /** + * @param instances Started Ignite instances. + * @param macs Mapping MAC addresses to UUID. + */ + private void replaceMacAddresses(List instances, Map macs) { + for (Ignite ignite : instances) { + for (ClusterNode node : ignite.cluster().nodes()) { + String mac = macs.get(node.id()); + + assertNotNull(mac); + + Map attrs = new HashMap<>(node.attributes()); + + attrs.put(ATTR_MACS, mac); + + ((TcpDiscoveryNode)node).setAttributes(attrs); + } + } + } + + /** + * @return Cluster nodes MAC addresses. + */ + private Map getClusterMacs() { + Map macs = new HashMap<>(); + + for (Ignite ignite : G.allGrids()) { + ClusterNode node = ignite.cluster().localNode(); + + String mac = node.attribute(ATTR_MACS); + + assert mac != null; + + macs.put(node.id(), mac); + } + + return macs; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupLocalConfigurationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupLocalConfigurationSelfTest.java index 51f900165dbed..eb8d39531edba 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupLocalConfigurationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupLocalConfigurationSelfTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheGroupLocalConfigurationSelfTest extends GridCommonAbstractTest { /** */ private static final String SECOND_NODE_NAME = "secondNode"; @@ -84,6 +88,7 @@ public class CacheGroupLocalConfigurationSelfTest extends GridCommonAbstractTest * * @throws Exception If failed. */ + @Test public void testDefaultGroupLocalAttributesPreserved() throws Exception { useNonDfltCacheGrp = false; @@ -96,6 +101,7 @@ public void testDefaultGroupLocalAttributesPreserved() throws Exception { * * @throws Exception If failed. */ + @Test public void testNonDefaultGroupLocalAttributesPreserved() throws Exception { useNonDfltCacheGrp = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMBeanTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMBeanTest.java index f8108eb7123a2..9dca0b1aef17e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMBeanTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsMBeanTest.java @@ -34,6 +34,7 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.affinity.AffinityFunction; import org.apache.ignite.cache.affinity.AffinityFunctionContext; @@ -51,10 +52,14 @@ import org.apache.ignite.mxbean.CacheGroupMetricsMXBean; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Cache group JMX metrics test. */ +@RunWith(JUnit4.class) public class CacheGroupMetricsMBeanTest extends GridCommonAbstractTest implements Serializable { /** */ private boolean pds = false; @@ -132,21 +137,25 @@ private static class RoundRobinVariableSizeAffinityFunction implements AffinityF .setGroupName("group1") .setCacheMode(CacheMode.PARTITIONED) .setBackups(3) - .setAffinity(new RoundRobinVariableSizeAffinityFunction()); + .setAffinity(new RoundRobinVariableSizeAffinityFunction()) + .setAtomicityMode(atomicityMode()); CacheConfiguration cCfg2 = new CacheConfiguration() .setName("cache2") .setGroupName("group2") - .setCacheMode(CacheMode.REPLICATED); + .setCacheMode(CacheMode.REPLICATED) + .setAtomicityMode(atomicityMode()); CacheConfiguration cCfg3 = new CacheConfiguration() .setName("cache3") .setGroupName("group2") - .setCacheMode(CacheMode.REPLICATED); + .setCacheMode(CacheMode.REPLICATED) + .setAtomicityMode(atomicityMode()); CacheConfiguration cCfg4 = new CacheConfiguration() .setName("cache4") - .setCacheMode(CacheMode.PARTITIONED); + .setCacheMode(CacheMode.PARTITIONED) + .setAtomicityMode(atomicityMode()); cfg.setCacheConfiguration(cCfg1, cCfg2, cCfg3, cCfg4); @@ -163,6 +172,13 @@ private static class RoundRobinVariableSizeAffinityFunction implements AffinityF return cfg; } + /** + * @return Cache atomicity mode. + */ + protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -234,6 +250,7 @@ private Map> arrayToAssignmentMap(int[][] arr) { /** * @throws Exception If failed. */ + @Test public void testCacheGroupMetrics() throws Exception { pds = false; @@ -336,6 +353,7 @@ public void testCacheGroupMetrics() throws Exception { /** * Test allocated pages counts for cache groups. */ + @Test public void testAllocatedPages() throws Exception { pds = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java index af2dc633d825e..02841a4c9c0e5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java @@ -17,6 +17,8 @@ package org.apache.ignite.internal.processors.cache; +import java.util.Collections; +import java.util.Random; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.apache.ignite.Ignite; @@ -31,14 +33,18 @@ import org.apache.ignite.events.CacheRebalancingEvent; import org.apache.ignite.events.Event; import org.apache.ignite.events.EventType; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorTaskArgument; +import org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTask; +import org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTaskArg; +import org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTaskResult; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; import static org.apache.ignite.IgniteSystemProperties.IGNITE_REBALANCE_STATISTICS_TIME_INTERVAL; import static org.apache.ignite.testframework.GridTestUtils.runAsync; @@ -48,9 +54,6 @@ * */ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE1 = "cache1"; @@ -83,13 +86,11 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration cfg1 = new CacheConfiguration() .setName(CACHE1) .setGroupName(GROUP) .setCacheMode(CacheMode.PARTITIONED) - .setAtomicityMode(CacheAtomicityMode.ATOMIC) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setRebalanceMode(CacheRebalanceMode.ASYNC) .setRebalanceBatchSize(100) .setStatisticsEnabled(true); @@ -100,7 +101,7 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest { CacheConfiguration cfg3 = new CacheConfiguration() .setName(CACHE3) .setCacheMode(CacheMode.PARTITIONED) - .setAtomicityMode(CacheAtomicityMode.ATOMIC) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setRebalanceMode(CacheRebalanceMode.ASYNC) .setRebalanceBatchSize(100) .setStatisticsEnabled(true) @@ -114,6 +115,7 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRebalance() throws Exception { Ignite ignite = startGrids(4); @@ -171,6 +173,74 @@ public void testRebalance() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testRebalanceProgressUnderLoad() throws Exception { + Ignite ignite = startGrids(4); + + IgniteCache cache1 = ignite.cache(CACHE1); + + Random r = new Random(); + + GridTestUtils.runAsync(new Runnable() { + @Override public void run() { + for (int i = 0; i < 100_000; i++) { + int next = r.nextInt(); + + cache1.put(next, CACHE1 + "-" + next); + } + } + }); + + IgniteEx ig = startGrid(4); + + GridTestUtils.runAsync(new Runnable() { + @Override public void run() { + for (int i = 0; i < 100_000; i++) { + int next = r.nextInt(); + + cache1.put(next, CACHE1 + "-" + next); + } + } + }); + + CountDownLatch latch = new CountDownLatch(1); + + ig.events().localListen(new IgnitePredicate() { + @Override public boolean apply(Event evt) { + latch.countDown(); + + return false; + } + }, EventType.EVT_CACHE_REBALANCE_STOPPED); + + latch.await(); + + VisorNodeDataCollectorTaskArg taskArg = new VisorNodeDataCollectorTaskArg(); + taskArg.setCacheGroups(Collections.emptySet()); + + VisorTaskArgument arg = new VisorTaskArgument<>( + Collections.singletonList(ignite.cluster().localNode().id()), + taskArg, + false + ); + + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + VisorNodeDataCollectorTaskResult res = ignite.compute().execute(VisorNodeDataCollectorTask.class, arg); + + CacheMetrics snapshot = ig.cache(CACHE1).metrics(); + + return snapshot.getRebalancedKeys() > snapshot.getEstimatedRebalancingKeys() + && res.getRebalance().get(ignite.cluster().localNode().id()) == 1.0 + && snapshot.getRebalancingPartitionsCount() == 0; + } + }, 5000); + } + + /** + * @throws Exception If failed. + */ + @Test public void testRebalanceEstimateFinishTime() throws Exception { System.setProperty(IGNITE_REBALANCE_STATISTICS_TIME_INTERVAL, String.valueOf(1000)); @@ -298,6 +368,7 @@ public void testRebalanceEstimateFinishTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalanceDelay() throws Exception { Ignite ig1 = startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterLocalSanityTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterLocalSanityTest.java index acb929b5672ef..9f370ddcf9231 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterLocalSanityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterLocalSanityTest.java @@ -47,11 +47,15 @@ import org.apache.ignite.transactions.TransactionIsolation; import org.eclipse.jetty.util.BlockingArrayQueue; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -60,6 +64,7 @@ /** * */ +@RunWith(JUnit4.class) public class CacheInterceptorPartitionCounterLocalSanityTest extends GridCommonAbstractTest { /** */ private static final int NODES = 1; @@ -104,6 +109,7 @@ public class CacheInterceptorPartitionCounterLocalSanityTest extends GridCommonA /** * @throws Exception If failed. */ + @Test public void testLocal() throws Exception { CacheConfiguration ccfg = cacheConfiguration(ATOMIC,false); @@ -113,6 +119,7 @@ public void testLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalWithStore() throws Exception { CacheConfiguration ccfg = cacheConfiguration(ATOMIC,true); @@ -122,6 +129,7 @@ public void testLocalWithStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalTx() throws Exception { CacheConfiguration ccfg = cacheConfiguration(TRANSACTIONAL,false); @@ -131,12 +139,37 @@ public void testLocalTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalTxWithStore() throws Exception { CacheConfiguration ccfg = cacheConfiguration(TRANSACTIONAL,true); doTestPartitionCounterOperation(ccfg); } + /** + * @throws Exception If failed. + */ + @Test + public void testLocalMvccTx() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + CacheConfiguration ccfg = cacheConfiguration(TRANSACTIONAL_SNAPSHOT,false); + + doTestPartitionCounterOperation(ccfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testLocalMvccTxWithStore() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + CacheConfiguration ccfg = cacheConfiguration(TRANSACTIONAL_SNAPSHOT,true); + + doTestPartitionCounterOperation(ccfg); + } + /** * @param ccfg Cache configuration. * @throws Exception If failed. @@ -187,7 +220,7 @@ private void randomUpdate( Transaction tx = null; - if (cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL && rnd.nextBoolean()) + if (atomicityMode(cache) == TRANSACTIONAL && rnd.nextBoolean()) tx = ignite.transactions().txStart(txRandomConcurrency(rnd), txRandomIsolation(rnd)); try { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterRandomOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterRandomOperationsTest.java index 74170a6559a65..e69cc6b1f0b68 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterRandomOperationsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheInterceptorPartitionCounterRandomOperationsTest.java @@ -48,20 +48,21 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.eclipse.jetty.util.BlockingArrayQueue; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -72,10 +73,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 5; @@ -103,8 +102,6 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -137,6 +134,7 @@ public class CacheInterceptorPartitionCounterRandomOperationsTest extends GridCo /** * @throws Exception If failed. */ + @Test public void testAtomic() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, @@ -149,6 +147,7 @@ public void testAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicWithStore() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, @@ -161,6 +160,7 @@ public void testAtomicWithStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicReplicated() throws Exception { CacheConfiguration ccfg = cacheConfiguration(REPLICATED, 0, @@ -173,6 +173,7 @@ public void testAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicReplicatedWithStore() throws Exception { CacheConfiguration ccfg = cacheConfiguration(REPLICATED, 0, @@ -185,6 +186,7 @@ public void testAtomicReplicatedWithStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicNoBackups() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, @@ -197,6 +199,7 @@ public void testAtomicNoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTx() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, @@ -209,6 +212,7 @@ public void testTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxWithStore() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, @@ -221,6 +225,7 @@ public void testTxWithStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxExplicit() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, @@ -233,6 +238,7 @@ public void testTxExplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxReplicated() throws Exception { CacheConfiguration ccfg = cacheConfiguration(REPLICATED, 0, @@ -245,6 +251,7 @@ public void testTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxReplicatedWithStore() throws Exception { CacheConfiguration ccfg = cacheConfiguration(REPLICATED, 0, @@ -257,6 +264,7 @@ public void testTxReplicatedWithStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoBackups() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, @@ -269,6 +277,7 @@ public void testTxNoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoBackupsWithStore() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, @@ -281,6 +290,7 @@ public void testTxNoBackupsWithStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoBackupsExplicit() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, @@ -290,12 +300,119 @@ public void testTxNoBackupsExplicit() throws Exception { doTestPartitionCounterOperation(ccfg); } + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTx() throws Exception { + CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, + 1, + TRANSACTIONAL_SNAPSHOT, + false); + + doTestPartitionCounterOperation(ccfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTxWithStore() throws Exception { + CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, + 1, + TRANSACTIONAL_SNAPSHOT, + true); + + doTestPartitionCounterOperation(ccfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTxExplicit() throws Exception { + CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, + 1, + TRANSACTIONAL_SNAPSHOT, + false); + + doTestPartitionCounterOperation(ccfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTxReplicated() throws Exception { + CacheConfiguration ccfg = cacheConfiguration(REPLICATED, + 0, + TRANSACTIONAL_SNAPSHOT, + false); + + doTestPartitionCounterOperation(ccfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTxReplicatedWithStore() throws Exception { + CacheConfiguration ccfg = cacheConfiguration(REPLICATED, + 0, + TRANSACTIONAL_SNAPSHOT, + true); + + doTestPartitionCounterOperation(ccfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTxNoBackups() throws Exception { + CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, + 0, + TRANSACTIONAL_SNAPSHOT, + false); + + doTestPartitionCounterOperation(ccfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTxNoBackupsWithStore() throws Exception { + CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, + 0, + TRANSACTIONAL_SNAPSHOT, + true); + + doTestPartitionCounterOperation(ccfg); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTxNoBackupsExplicit() throws Exception { + CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, + 0, + TRANSACTIONAL_SNAPSHOT, + false); + + doTestPartitionCounterOperation(ccfg); + } + /** * @param ccfg Cache configuration. * @throws Exception If failed. */ protected void doTestPartitionCounterOperation(CacheConfiguration ccfg) throws Exception { + if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) + fail("https://issues.apache.org/jira/browse/IGNITE-9323"); + ignite(0).createCache(ccfg); try { @@ -345,7 +462,9 @@ private void randomUpdate( Transaction tx = null; - if (cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL && rnd.nextBoolean()) + CacheAtomicityMode atomicityMode = GridCommonAbstractTest.atomicityMode(cache); + + if (atomicityMode == TRANSACTIONAL && rnd.nextBoolean()) tx = ignite.transactions().txStart(txRandomConcurrency(rnd), txRandomIsolation(rnd)); try { @@ -578,8 +697,7 @@ private void randomUpdate( Object key, boolean rmv ) { - Collection nodes = - cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL ? + Collection nodes = atomicityMode(cache) == TRANSACTIONAL ? affinity(cache).mapKeyToPrimaryAndBackups(key) : Collections.singletonList(affinity(cache).mapKeyToNode(key)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheKeepBinaryTransactionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheKeepBinaryTransactionTest.java index 841e49c7c1a66..538bf8dda3611 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheKeepBinaryTransactionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheKeepBinaryTransactionTest.java @@ -26,22 +26,30 @@ import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that no deserialization happens with binary objects and keepBinary set flag. */ +@RunWith(JUnit4.class) public class CacheKeepBinaryTransactionTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); TransactionConfiguration txCfg = new TransactionConfiguration(); - txCfg.setDefaultTxConcurrency(TransactionConcurrency.OPTIMISTIC); - txCfg.setDefaultTxIsolation(TransactionIsolation.REPEATABLE_READ); + + if (!MvccFeatureChecker.forcedMvcc()) { + txCfg.setDefaultTxConcurrency(TransactionConcurrency.OPTIMISTIC); + txCfg.setDefaultTxIsolation(TransactionIsolation.REPEATABLE_READ); + } cfg.setTransactionConfiguration(txCfg); @@ -65,6 +73,7 @@ public class CacheKeepBinaryTransactionTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testBinaryGet() throws Exception { IgniteEx ignite = grid(0); IgniteCache cache = ignite.cache("tx-cache").withKeepBinary(); @@ -80,6 +89,7 @@ public void testBinaryGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryContains() throws Exception { IgniteEx ignite = grid(0); IgniteCache cache = ignite.cache("tx-cache").withKeepBinary(); @@ -95,6 +105,7 @@ public void testBinaryContains() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryPutGetContains() throws Exception { IgniteEx ignite = grid(0); IgniteCache cache = ignite.cache("tx-cache").withKeepBinary(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsEntitiesCountTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsEntitiesCountTest.java index 1ab7c40ced6a0..df396b6bd459d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsEntitiesCountTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsEntitiesCountTest.java @@ -17,15 +17,23 @@ package org.apache.ignite.internal.processors.cache; +import java.util.ArrayList; +import java.util.Collection; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * This test checks that entries count metrics, calculated by method @@ -33,6 +41,7 @@ * over local partitions to get all set of metrics), have the same values as metrics, calculated by individual methods * (which use iteration over local partition per each method call). */ +@RunWith(JUnit4.class) public class CacheMetricsEntitiesCountTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 3; @@ -48,35 +57,45 @@ public class CacheMetricsEntitiesCountTest extends GridCommonAbstractTest { CachePeekMode.ONHEAP, CachePeekMode.PRIMARY, CachePeekMode.BACKUP, CachePeekMode.NEAR}; /** Cache count. */ - private static final int CACHE_CNT = 4; + private static int cacheCnt = 4; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - CacheConfiguration ccfg0 = new CacheConfiguration<>() - .setName(CACHE_PREFIX + 0) - .setCacheMode(CacheMode.LOCAL); + Collection ccfgs = new ArrayList<>(4); - CacheConfiguration ccfg1 = new CacheConfiguration<>() - .setName(CACHE_PREFIX + 1) + ccfgs.add(new CacheConfiguration<>() + .setName(CACHE_PREFIX + 0) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) - .setCacheMode(CacheMode.REPLICATED); + .setCacheMode(CacheMode.REPLICATED) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); - CacheConfiguration ccfg2 = new CacheConfiguration<>() - .setName(CACHE_PREFIX + 2) + ccfgs.add(new CacheConfiguration<>() + .setName(CACHE_PREFIX + 1) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) .setCacheMode(CacheMode.PARTITIONED) - .setBackups(1); + .setBackups(1) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); - CacheConfiguration ccfg3 = new CacheConfiguration<>() - .setName(CACHE_PREFIX + 3) + ccfgs.add(new CacheConfiguration<>() + .setName(CACHE_PREFIX + 2) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) .setCacheMode(CacheMode.PARTITIONED) .setBackups(1) - .setNearConfiguration(new NearCacheConfiguration<>()); + .setNearConfiguration(new NearCacheConfiguration<>()) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); + + if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.LOCAL_CACHE)) { + ccfgs.add(new CacheConfiguration<>() + .setName(CACHE_PREFIX + 3) + .setCacheMode(CacheMode.LOCAL) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); + } + + cacheCnt = ccfgs.size(); - cfg.setCacheConfiguration(ccfg0, ccfg1, ccfg2, ccfg3); + cfg.setCacheConfiguration(U.toArray(ccfgs, new CacheConfiguration[cacheCnt])); return cfg; } @@ -89,15 +108,16 @@ public class CacheMetricsEntitiesCountTest extends GridCommonAbstractTest { /** * Test entities count, calculated by different implementations. */ + @Test public void testEnitiesCount() throws Exception { awaitPartitionMapExchange(); for (int igniteIdx = 0; igniteIdx < GRID_CNT; igniteIdx++) - for (int cacheIdx = 0; cacheIdx < CACHE_CNT; cacheIdx++) + for (int cacheIdx = 0; cacheIdx < cacheCnt; cacheIdx++) fillCache(igniteIdx, cacheIdx); for (int igniteIdx = 0; igniteIdx < GRID_CNT; igniteIdx++) - for (int cacheIdx = 0; cacheIdx < CACHE_CNT; cacheIdx++) + for (int cacheIdx = 0; cacheIdx < cacheCnt; cacheIdx++) checkCache(igniteIdx, cacheIdx); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsForClusterGroupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsForClusterGroupSelfTest.java index 3f196a57ad80b..73ff37ce819e5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsForClusterGroupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsForClusterGroupSelfTest.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cache.CacheMetrics; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; @@ -30,13 +31,18 @@ import org.apache.ignite.internal.managers.discovery.IgniteClusterNode; import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED; /** * Test for cluster wide cache metrics. */ +@RunWith(JUnit4.class) public class CacheMetricsForClusterGroupSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 3; @@ -63,30 +69,31 @@ public class CacheMetricsForClusterGroupSelfTest extends GridCommonAbstractTest private boolean daemon; /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDaemon(daemon); + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.METRICS); - return cfg; + super.beforeTestsStarted(); } /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGrids(GRID_CNT); + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - daemon = true; + cfg.setDaemon(daemon); - startGrid(GRID_CNT); + return cfg; } /** * Test cluster group metrics in case of statistics enabled. */ + @Test public void testMetricsStatisticsEnabled() throws Exception { - createCaches(true); + startGrids(); try { + createCaches(true); + populateCacheData(cache1, ENTRY_CNT_CACHE1); populateCacheData(cache2, ENTRY_CNT_CACHE2); @@ -107,7 +114,7 @@ public void testMetricsStatisticsEnabled() throws Exception { assertMetrics(cache2, true); } finally { - destroyCaches(); + stopAllGrids(); } } @@ -116,10 +123,13 @@ public void testMetricsStatisticsEnabled() throws Exception { * * @throws Exception If failed. */ + @Test public void testMetricsStatisticsDisabled() throws Exception { - createCaches(false); + startGrids(); try { + createCaches(false); + populateCacheData(cache1, ENTRY_CNT_CACHE1); populateCacheData(cache2, ENTRY_CNT_CACHE2); @@ -140,10 +150,62 @@ public void testMetricsStatisticsDisabled() throws Exception { assertMetrics(cache2, false); } finally { - destroyCaches(); + stopAllGrids(); + } + } + + /** + * Tests that only local metrics are updating if discovery updates disabled. + */ + @Test + public void testMetricsDiscoveryUpdatesDisabled() throws Exception { + System.setProperty(IgniteSystemProperties.IGNITE_DISCOVERY_DISABLE_CACHE_METRICS_UPDATE, "true"); + + try { + startGrids(); + + try { + createCaches(true); + + populateCacheData(cache1, ENTRY_CNT_CACHE1); + populateCacheData(cache2, ENTRY_CNT_CACHE2); + + readCacheData(cache1, ENTRY_CNT_CACHE1); + readCacheData(cache2, ENTRY_CNT_CACHE2); + + awaitMetricsUpdate(); + + Collection nodes = grid(0).cluster().forRemotes().nodes(); + + for (ClusterNode node : nodes) { + Map metrics = ((IgniteClusterNode)node).cacheMetrics(); + assertNotNull(metrics); + assertTrue(metrics.isEmpty()); + } + + assertOnlyLocalMetricsUpdating(CACHE1); + assertOnlyLocalMetricsUpdating(CACHE2); + } + finally { + stopAllGrids(); + } + } + finally { + System.setProperty(IgniteSystemProperties.IGNITE_DISCOVERY_DISABLE_CACHE_METRICS_UPDATE, "false"); } } + /** + * Start grids. + */ + private void startGrids() throws Exception { + startGrids(GRID_CNT); + + daemon = true; + + startGrid(GRID_CNT); + } + /** * @param statisticsEnabled Statistics enabled. */ @@ -267,6 +329,34 @@ private void assertMetrics(IgniteCache cache, boolean expectNo } } + /** + * Asserts that only local metrics are updating. + * + * @param cacheName Cache name. + */ + private void assertOnlyLocalMetricsUpdating(String cacheName) { + for (int i = 0; i < GRID_CNT; i++) { + IgniteCache cache = grid(i).cache(cacheName); + + CacheMetrics clusterMetrics = cache.metrics(grid(i).cluster().forCacheNodes(cacheName)); + CacheMetrics locMetrics = cache.localMetrics(); + + assertEquals(clusterMetrics.name(), locMetrics.name()); + + assertEquals(0L, clusterMetrics.getCacheGets()); + assertEquals(0L, cache.mxBean().getCacheGets()); + assertEquals(locMetrics.getCacheGets(), cache.localMxBean().getCacheGets()); + + assertEquals(0L, clusterMetrics.getCachePuts()); + assertEquals(0L, cache.mxBean().getCachePuts()); + assertEquals(locMetrics.getCachePuts(), cache.localMxBean().getCachePuts()); + + assertEquals(0L, clusterMetrics.getCacheHits()); + assertEquals(0L, cache.mxBean().getCacheHits()); + assertEquals(locMetrics.getCacheHits(), cache.localMxBean().getCacheHits()); + } + } + /** * @param ms Milliseconds. * @param f Function. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsManageTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsManageTest.java index ae00ac9659225..8a94166386465 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsManageTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsManageTest.java @@ -48,19 +48,19 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.mxbean.CacheMetricsMXBean; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheMetricsManageTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE1 = "cache1"; @@ -79,20 +79,27 @@ public class CacheMetricsManageTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testJmxNoPdsStatisticsEnable() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9224", MvccFeatureChecker.forcedMvcc()); + testJmxStatisticsEnable(false); } /** * @throws Exception If failed. */ + @Test public void testJmxPdsStatisticsEnable() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10421", MvccFeatureChecker.forcedMvcc()); + testJmxStatisticsEnable(true); } /** * @throws Exception If failed. */ + @Test public void testCacheManagerStatisticsEnable() throws Exception { final CacheManager mgr1 = Caching.getCachingProvider().getCacheManager(); final CacheManager mgr2 = Caching.getCachingProvider().getCacheManager(); @@ -101,7 +108,7 @@ public void testCacheManagerStatisticsEnable() throws Exception { .setName(CACHE1) .setGroupName(GROUP) .setCacheMode(CacheMode.PARTITIONED) - .setAtomicityMode(CacheAtomicityMode.ATOMIC); + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); mgr1.createCache(CACHE1, cfg1); @@ -132,6 +139,7 @@ public void testCacheManagerStatisticsEnable() throws Exception { /** * */ + @Test public void testPublicApiStatisticsEnable() throws Exception { Ignite ig1 = startGrid(1); startGrid(2); @@ -159,6 +167,7 @@ public void testPublicApiStatisticsEnable() throws Exception { /** * */ + @Test public void testMultiThreadStatisticsEnable() throws Exception { startGrids(5); @@ -215,6 +224,7 @@ public void testMultiThreadStatisticsEnable() throws Exception { /** * */ + @Test public void testCacheApiClearStatistics() throws Exception { startGrids(3); @@ -232,6 +242,7 @@ public void testCacheApiClearStatistics() throws Exception { /** * */ + @Test public void testClearStatisticsAfterDisableStatistics() throws Exception { startGrids(3); @@ -253,6 +264,7 @@ public void testClearStatisticsAfterDisableStatistics() throws Exception { /** * */ + @Test public void testClusterApiClearStatistics() throws Exception { startGrids(3); @@ -277,6 +289,7 @@ public void testClusterApiClearStatistics() throws Exception { /** * */ + @Test public void testJmxApiClearStatistics() throws Exception { startGrids(3); @@ -484,13 +497,11 @@ private CacheMetricsMXBean mxBean(int nodeIdx, String cacheName, Class cache = ignite.cache(DEFAULT_CACHE_NAME); + + for (boolean commit : new boolean[] {true, false}) { + try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { + checkFastTxFinish(tx, commit); + } + + for (int i = 0; i < 100; i++) { + try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.get(i); + + checkNormalTxFinish(tx, commit); + } + } + + for (int i = 0; i < 100; i++) { + try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.put(i, i); + + checkNormalTxFinish(tx, commit); + } + } + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java index d7d06a1c090a6..de04b9e1b527d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that validates {@link Ignite#cacheNames()} implementation. */ +@RunWith(JUnit4.class) public class CacheNamesSelfTest extends GridCommonAbstractTest { /** */ private boolean client; @@ -57,6 +61,7 @@ public class CacheNamesSelfTest extends GridCommonAbstractTest { /** * @throws Exception In case of failure. */ + @Test public void testCacheNames() throws Exception { try { startGridsMultiThreaded(2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java index ecb8227e58f53..0272de8d61695 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesWithSpecialCharactersTest.java @@ -17,21 +17,26 @@ package org.apache.ignite.internal.processors.cache; +import java.util.Collection; import org.apache.ignite.Ignite; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -import java.util.Collection; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that validates {@link Ignite#cacheNames()} implementation. */ +@RunWith(JUnit4.class) public class CacheNamesWithSpecialCharactersTest extends GridCommonAbstractTest { + /** */ + private static final String CACHE_NAME_1 = "--№=+:(replicated)"; - public static final String CACHE_NAME_1 = "--№=+:(replicated)"; - public static final String CACHE_NAME_2 = ":_&:: (partitioned)"; + /** */ + private static final String CACHE_NAME_2 = ":_&:: (partitioned)"; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -53,6 +58,7 @@ public class CacheNamesWithSpecialCharactersTest extends GridCommonAbstractTest /** * @throws Exception In case of failure. */ + @Test public void testCacheNames() throws Exception { try { startGridsMultiThreaded(2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java index 96167f5d038dc..b6aff93c79a34 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java @@ -39,15 +39,17 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionOptimisticException; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -60,10 +62,9 @@ /** * */ +@RunWith(JUnit4.class) +@Ignore("https://issues.apache.org/jira/browse/IGNITE-627") public class CacheNearReaderUpdateTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -82,8 +83,6 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -91,6 +90,8 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + super.beforeTestsStarted(); startGridsMultiThreaded(SRVS); @@ -110,6 +111,7 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNoBackups() throws Exception { runTestGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 0, false, false)); } @@ -117,6 +119,7 @@ public void testNoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOneBackup() throws Exception { runTestGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, false)); } @@ -124,6 +127,7 @@ public void testOneBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOneBackupNearEnabled() throws Exception { runTestGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, false, true)); } @@ -131,6 +135,7 @@ public void testOneBackupNearEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOneBackupStoreEnabled() throws Exception { runTestGetUpdateMultithreaded(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, true, false)); } @@ -336,6 +341,9 @@ private CacheConfiguration cacheConfiguration( int backups, boolean storeEnabled, boolean nearCache) { + if (storeEnabled) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setCacheMode(cacheMode); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearUpdateTopologyChangeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearUpdateTopologyChangeAbstractTest.java index 21b3c727dcd4c..6cf9b013b3686 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearUpdateTopologyChangeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearUpdateTopologyChangeAbstractTest.java @@ -27,6 +27,9 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CachePeekMode.ONHEAP; @@ -34,6 +37,7 @@ /** * */ +@RunWith(JUnit4.class) public abstract class CacheNearUpdateTopologyChangeAbstractTest extends IgniteCacheAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -53,6 +57,7 @@ public abstract class CacheNearUpdateTopologyChangeAbstractTest extends IgniteCa /** * @throws Exception If failed. */ + @Test public void testNearUpdateTopologyChange() throws Exception { awaitPartitionMapExchange(); @@ -140,4 +145,4 @@ public void testNearUpdateTopologyChange() throws Exception { assertEquals((Object)2, nearCache.localPeek(key, ONHEAP)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNoAffinityExchangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNoAffinityExchangeTest.java new file mode 100644 index 0000000000000..d300e9a854643 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNoAffinityExchangeTest.java @@ -0,0 +1,317 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.Collections; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.locks.Lock; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteException; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.lang.IgniteBiPredicate; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeLeftMessage; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * + */ +@RunWith(JUnit4.class) +public class CacheNoAffinityExchangeTest extends GridCommonAbstractTest { + /** */ + private volatile boolean startClient; + + /** */ + private final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder().setShared(true); + + /** */ + private final TcpDiscoveryIpFinder CLIENT_IP_FINDER = new TcpDiscoveryVmIpFinder() + .setAddresses(Collections.singleton("127.0.0.1:47500")); + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); + + cfg.setDiscoverySpi(new TestDiscoverySpi().setIpFinder(IP_FINDER)); + + if (startClient) { + cfg.setClientMode(true); + + // It is necessary to ensure that client always connects to grid(0). + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(CLIENT_IP_FINDER); + } + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + super.afterTest(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testNoAffinityChangeOnClientJoin() throws Exception { + Ignite ig = startGrids(4); + + ig.cluster().active(true); + + IgniteCache atomicCache = ig.createCache(new CacheConfiguration() + .setName("atomic").setAtomicityMode(CacheAtomicityMode.ATOMIC)); + + IgniteCache txCache = ig.createCache(new CacheConfiguration() + .setName("tx").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); + + assertTrue(GridTestUtils.waitForCondition(() -> + new AffinityTopologyVersion(4, 3).equals(grid(3).context().discovery().topologyVersionEx()), + 5_000)); + + TestDiscoverySpi discoSpi = (TestDiscoverySpi) grid(2).context().discovery().getInjectedDiscoverySpi(); + + CountDownLatch latch = new CountDownLatch(1); + + discoSpi.latch = latch; + + startClient = true; + + startGrid(4); + + assertTrue(GridTestUtils.waitForCondition(() -> + new AffinityTopologyVersion(5, 0).equals(grid(0).context().discovery().topologyVersionEx()) && + new AffinityTopologyVersion(5, 0).equals(grid(1).context().discovery().topologyVersionEx()) && + new AffinityTopologyVersion(4, 3).equals(grid(2).context().discovery().topologyVersionEx()) && + new AffinityTopologyVersion(4, 3).equals(grid(3).context().discovery().topologyVersionEx()), + 10_000)); + + for (int k = 0; k < 100; k++) { + atomicCache.put(k, k); + txCache.put(k, k); + + Lock lock = txCache.lock(k); + lock.lock(); + lock.unlock(); + } + + for (int k = 0; k < 100; k++) { + assertEquals(Integer.valueOf(k), atomicCache.get(k)); + assertEquals(Integer.valueOf(k), txCache.get(k)); + } + + assertEquals(new AffinityTopologyVersion(5, 0), grid(0).context().discovery().topologyVersionEx()); + assertEquals(new AffinityTopologyVersion(5, 0), grid(1).context().discovery().topologyVersionEx()); + assertEquals(new AffinityTopologyVersion(4, 3), grid(2).context().discovery().topologyVersionEx()); + assertEquals(new AffinityTopologyVersion(4, 3), grid(3).context().discovery().topologyVersionEx()); + + latch.countDown(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testNoAffinityChangeOnClientLeft() throws Exception { + Ignite ig = startGrids(4); + + ig.cluster().active(true); + + IgniteCache atomicCache = ig.createCache(new CacheConfiguration() + .setName("atomic").setAtomicityMode(CacheAtomicityMode.ATOMIC)); + + IgniteCache txCache = ig.createCache(new CacheConfiguration() + .setName("tx").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); + + assertTrue(GridTestUtils.waitForCondition(() -> + new AffinityTopologyVersion(4, 3).equals(grid(3).context().discovery().topologyVersionEx()), + 5_000)); + + startClient = true; + + startGrid(4); + + TestDiscoverySpi discoSpi = (TestDiscoverySpi)grid(2).context().discovery().getInjectedDiscoverySpi(); + + CountDownLatch latch = new CountDownLatch(1); + + discoSpi.latch = latch; + + stopGrid(4); + + assertTrue(GridTestUtils.waitForCondition(() -> + new AffinityTopologyVersion(6, 0).equals(grid(0).context().discovery().topologyVersionEx()) && + new AffinityTopologyVersion(6, 0).equals(grid(1).context().discovery().topologyVersionEx()) && + new AffinityTopologyVersion(5, 0).equals(grid(2).context().discovery().topologyVersionEx()) && + new AffinityTopologyVersion(5, 0).equals(grid(3).context().discovery().topologyVersionEx()), + 10_000)); + + for (int k = 0; k < 100; k++) { + atomicCache.put(k, k); + txCache.put(k, k); + + Lock lock = txCache.lock(k); + lock.lock(); + lock.unlock(); + } + + for (int k = 0; k < 100; k++) { + assertEquals(Integer.valueOf(k), atomicCache.get(k)); + assertEquals(Integer.valueOf(k), txCache.get(k)); + } + + assertEquals(new AffinityTopologyVersion(6, 0), grid(0).context().discovery().topologyVersionEx()); + assertEquals(new AffinityTopologyVersion(6, 0), grid(1).context().discovery().topologyVersionEx()); + assertEquals(new AffinityTopologyVersion(5, 0), grid(2).context().discovery().topologyVersionEx()); + assertEquals(new AffinityTopologyVersion(5, 0), grid(3).context().discovery().topologyVersionEx()); + + latch.countDown(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testNoAffinityChangeOnClientLeftWithMergedExchanges() throws Exception { + System.setProperty(IgniteSystemProperties.IGNITE_EXCHANGE_MERGE_DELAY, "1000"); + + try { + Ignite ig = startGridsMultiThreaded(4); + + IgniteCache atomicCache = ig.createCache(new CacheConfiguration() + .setName("atomic").setAtomicityMode(CacheAtomicityMode.ATOMIC).setCacheMode(CacheMode.REPLICATED)); + + IgniteCache txCache = ig.createCache(new CacheConfiguration() + .setName("tx").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setCacheMode(CacheMode.REPLICATED)); + + startClient = true; + + Ignite client = startGrid("client"); + + startClient = false; + + stopGrid(1); + stopGrid(2); + stopGrid(3); + + awaitPartitionMapExchange(); + + atomicCache.put(-1, -1); + txCache.put(-1, -1); + + TestRecordingCommunicationSpi.spi(ig).blockMessages(new IgniteBiPredicate() { + @Override public boolean apply(ClusterNode node, Message message) { + return message instanceof GridDhtPartitionSupplyMessageV2; + } + }); + + startGridsMultiThreaded(1, 3); + + CountDownLatch latch = new CountDownLatch(1); + for (Ignite ignite : G.allGrids()) { + if (ignite.cluster().localNode().order() == 9) { + TestDiscoverySpi discoSpi = + (TestDiscoverySpi)((IgniteEx)ignite).context().discovery().getInjectedDiscoverySpi(); + + discoSpi.latch = latch; + + break; + } + } + + client.close(); + + for (int k = 0; k < 100; k++) { + atomicCache.put(k, k); + txCache.put(k, k); + + Lock lock = txCache.lock(k); + lock.lock(); + lock.unlock(); + } + + for (int k = 0; k < 100; k++) { + assertEquals(Integer.valueOf(k), atomicCache.get(k)); + assertEquals(Integer.valueOf(k), txCache.get(k)); + } + + latch.countDown(); + } + finally { + System.clearProperty(IgniteSystemProperties.IGNITE_EXCHANGE_MERGE_DELAY); + } + } + + /** + * + */ + public static class TestDiscoverySpi extends TcpDiscoverySpi { + /** */ + private volatile CountDownLatch latch; + + /** {@inheritDoc} */ + @Override protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) { + if (msg instanceof TcpDiscoveryNodeAddFinishedMessage || msg instanceof TcpDiscoveryNodeLeftMessage || msg instanceof TcpDiscoveryNodeFailedMessage) { + CountDownLatch latch0 = latch; + + if (latch0 != null) + try { + latch0.await(); + } + catch (InterruptedException ex) { + throw new IgniteException(ex); + } + } + + super.startMessageProcess(msg); + } + } + +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java index e520d455c1aaa..fae80ebe2024e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java @@ -25,9 +25,14 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry; import org.apache.ignite.internal.processors.cache.local.GridLocalCacheEntry; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -35,6 +40,7 @@ /** * Cache map entry self test. */ +@RunWith(JUnit4.class) public class CacheOffheapMapEntrySelfTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -76,24 +82,37 @@ private CacheConfiguration cacheConfiguration(String gridName, cfg.setAtomicityMode(atomicityMode); cfg.setName(cacheName); + if (atomicityMode == TRANSACTIONAL_SNAPSHOT && !MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) + cfg.setNearConfiguration(null); + return cfg; } /** * @throws Exception If failed. */ + @Test public void testCacheMapEntry() throws Exception { checkCacheMapEntry(ATOMIC, LOCAL, GridLocalCacheEntry.class); checkCacheMapEntry(TRANSACTIONAL, LOCAL, GridLocalCacheEntry.class); + if (MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.LOCAL_CACHE)) + checkCacheMapEntry(TRANSACTIONAL_SNAPSHOT, LOCAL, GridLocalCacheEntry.class); + checkCacheMapEntry(ATOMIC, PARTITIONED, GridNearCacheEntry.class); checkCacheMapEntry(TRANSACTIONAL, PARTITIONED, GridNearCacheEntry.class); + if (MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.CACHE_STORE)) + checkCacheMapEntry(TRANSACTIONAL_SNAPSHOT, PARTITIONED, GridDhtCacheEntry.class); + checkCacheMapEntry(ATOMIC, REPLICATED, GridDhtCacheEntry.class); checkCacheMapEntry(TRANSACTIONAL, REPLICATED, GridDhtCacheEntry.class); + + if (MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.CACHE_STORE)) + checkCacheMapEntry(TRANSACTIONAL_SNAPSHOT, REPLICATED, GridDhtCacheEntry.class); } /** @@ -135,4 +154,4 @@ private void checkCacheMapEntry(CacheAtomicityMode atomicityMode, jcache.destroy(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOptimisticTransactionsWithFilterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOptimisticTransactionsWithFilterTest.java index d953e04355faa..e98cb78b2e621 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOptimisticTransactionsWithFilterTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOptimisticTransactionsWithFilterTest.java @@ -27,13 +27,13 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -46,10 +46,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheOptimisticTransactionsWithFilterTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -60,8 +58,6 @@ public class CacheOptimisticTransactionsWithFilterTest extends GridCommonAbstrac @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -92,6 +88,7 @@ protected int serversNumber() { /** * @throws Exception If failed. */ + @Test public void testCasReplace() throws Exception { executeTestForAllCaches(new TestClosure() { @Override public void apply(Ignite ignite, String cacheName) throws Exception { @@ -179,6 +176,7 @@ public void testCasReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsent() throws Exception { executeTestForAllCaches(new TestClosure() { @Override public void apply(Ignite ignite, String cacheName) throws Exception { @@ -238,6 +236,7 @@ public void testPutIfAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplace() throws Exception { executeTestForAllCaches(new TestClosure() { @Override public void apply(Ignite ignite, String cacheName) throws Exception { @@ -297,6 +296,7 @@ public void testReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveWithOldValue() throws Exception { executeTestForAllCaches(new TestClosure() { @Override public void apply(Ignite ignite, String cacheName) throws Exception { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java index 8891f64233476..aa6a1b1aaf5b8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java @@ -31,28 +31,21 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for cache put with error in event listener. */ +@RunWith(JUnit4.class) public class CachePutEventListenerErrorSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setIncludeEventTypes(EventType.EVT_CACHE_OBJECT_PUT); return cfg; @@ -60,6 +53,8 @@ public class CachePutEventListenerErrorSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + startGridsMultiThreaded(3); Ignition.setClientMode(true); @@ -89,6 +84,7 @@ public class CachePutEventListenerErrorSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPartitionedAtomicOnHeap() throws Exception { doTest(CacheMode.PARTITIONED, CacheAtomicityMode.ATOMIC); } @@ -96,6 +92,7 @@ public void testPartitionedAtomicOnHeap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionedTransactionalOnHeap() throws Exception { doTest(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL); } @@ -103,6 +100,7 @@ public void testPartitionedTransactionalOnHeap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedAtomicOnHeap() throws Exception { doTest(CacheMode.REPLICATED, CacheAtomicityMode.ATOMIC); } @@ -110,6 +108,7 @@ public void testReplicatedAtomicOnHeap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedTransactionalOnHeap() throws Exception { doTest(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutIfAbsentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutIfAbsentTest.java index 00ba25fb7651c..256b561736e4c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutIfAbsentTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutIfAbsentTest.java @@ -26,14 +26,14 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -43,22 +43,11 @@ /** * */ +@RunWith(JUnit4.class) public class CachePutIfAbsentTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRVS = 4; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); @@ -111,6 +100,7 @@ private CacheConfiguration cacheConfiguration( /** * @throws Exception If failed. */ + @Test public void testTxConflictGetAndPutIfAbsent() throws Exception { Ignite ignite0 = ignite(0); @@ -129,6 +119,9 @@ public void testTxConflictGetAndPutIfAbsent() throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, isolation)) + continue; + try (Transaction tx = txs.txStart(concurrency, isolation)) { Object old = cache.getAndPutIfAbsent(key, 3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalRestartSelfTest.java index 58fa8d6f62828..5e8b1eb442abe 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalRestartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughLocalRestartSelfTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -29,4 +30,11 @@ public class CacheReadThroughLocalRestartSelfTest extends CacheReadThroughRestar @Override protected CacheMode cacheMode() { return LOCAL; } + + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } } \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java index 422ed586be455..dd60974d45b7a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java @@ -24,12 +24,13 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,9 +38,14 @@ /** * Test for read through store. */ +@RunWith(JUnit4.class) public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } /** {@inheritDoc} */ @Override protected int gridCount() { @@ -62,12 +68,6 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest { cfg.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -84,6 +84,7 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testReadThroughInTx() throws Exception { testReadThroughInTx(false); } @@ -91,6 +92,7 @@ public void testReadThroughInTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadEntryThroughInTx() throws Exception { testReadThroughInTx(true); } @@ -116,6 +118,9 @@ private void testReadThroughInTx(boolean needVer) throws Exception { for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) { for (TransactionIsolation txIsolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(txConcurrency, txIsolation)) + continue; + try (Transaction tx = ignite.transactions().txStart(txConcurrency, txIsolation, 100000, 1000)) { for (int k = 0; k < 1000; k++) { String key = "key" + k; @@ -139,6 +144,7 @@ private void testReadThroughInTx(boolean needVer) throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadThrough() throws Exception { testReadThrough(false); } @@ -146,6 +152,7 @@ public void testReadThrough() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadEntryThrough() throws Exception { testReadThrough(true); } @@ -175,4 +182,4 @@ private void testReadThrough(boolean needVer) throws Exception { assertNotNull("Null value for key: " + key, cache.get(key)); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalanceConfigValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalanceConfigValidationTest.java index 2f31b31372396..c3eee1b13d0da 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalanceConfigValidationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalanceConfigValidationTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheRebalanceConfigValidationTest extends GridCommonAbstractTest { /** Rebalance pool size. */ private int rebalancePoolSize; @@ -43,6 +47,7 @@ public class CacheRebalanceConfigValidationTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testParameterConsistency() throws Exception { rebalancePoolSize = 2; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalancingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalancingSelfTest.java index 75e62964b3ac8..c3085f6c83a28 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalancingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalancingSelfTest.java @@ -35,11 +35,16 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for rebalancing. */ +@RunWith(JUnit4.class) public class CacheRebalancingSelfTest extends GridCommonAbstractTest { /** Cache name with one backups */ private static final String REBALANCE_TEST_CACHE_NAME = "rebalanceCache"; @@ -48,12 +53,12 @@ public class CacheRebalancingSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - CacheConfiguration rebalabceCacheCfg = new CacheConfiguration<>(); - rebalabceCacheCfg.setBackups(1); - rebalabceCacheCfg.setName(REBALANCE_TEST_CACHE_NAME); - rebalabceCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); + CacheConfiguration ccfg = new CacheConfiguration<>(); + ccfg.setBackups(1); + ccfg.setName(REBALANCE_TEST_CACHE_NAME); + ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME), rebalabceCacheCfg); + cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME), ccfg); return cfg; } @@ -68,7 +73,10 @@ public class CacheRebalancingSelfTest extends GridCommonAbstractTest { /** * @throws Exception If fails. */ + @Test public void testRebalanceLocalCacheFuture() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + startGrid( getTestIgniteInstanceName(0), getConfiguration(getTestIgniteInstanceName(0)) @@ -86,6 +94,7 @@ public void testRebalanceLocalCacheFuture() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalanceFuture() throws Exception { IgniteEx ig0 = startGrid(0); @@ -121,6 +130,7 @@ private static IgniteInternalFuture internalFuture(IgniteFuture fut) { * * @throws Exception If failed. */ + @Test public void testDisableRebalancing() throws Exception { IgniteEx ig0 = startGrid(0); IgniteEx ig1 = startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRemoveAllSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRemoveAllSelfTest.java index a27bdda62a177..665e7cee9adb5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRemoveAllSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRemoveAllSelfTest.java @@ -24,11 +24,24 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * Test remove all method. */ +@RunWith(JUnit4.class) public class CacheRemoveAllSelfTest extends GridCacheAbstractSelfTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10082"); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected long getTestTimeout() { return 2 * 60 * 1000; @@ -42,6 +55,7 @@ public class CacheRemoveAllSelfTest extends GridCacheAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testRemoveAll() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -76,4 +90,4 @@ public void testRemoveAll() throws Exception { 0, locCache.localSize()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java index 714ae6aa59bb4..37c4fabd279c6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java @@ -67,15 +67,15 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionOptimisticException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -92,10 +92,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheSerializableTransactionsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final boolean FAST = false; @@ -117,8 +115,6 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); cfg.setClientMode(client); @@ -147,6 +143,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTxStreamerLoad() throws Exception { txStreamerLoad(false); } @@ -154,6 +151,7 @@ public void testTxStreamerLoad() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxStreamerLoadAllowOverwrite() throws Exception { txStreamerLoad(true); } @@ -240,6 +238,7 @@ private void txStreamerLoad(Ignite ignite, /** * @throws Exception If failed. */ + @Test public void testTxLoadFromStore() throws Exception { Ignite ignite0 = ignite(0); @@ -295,6 +294,7 @@ public void testTxLoadFromStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxCommitReadOnly1() throws Exception { Ignite ignite0 = ignite(0); @@ -353,6 +353,7 @@ public void testTxCommitReadOnly1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxCommitReadOnly2() throws Exception { Ignite ignite0 = ignite(0); @@ -419,6 +420,7 @@ public void testTxCommitReadOnly2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxCommit() throws Exception { Ignite ignite0 = ignite(0); Ignite ignite1 = ignite(1); @@ -500,6 +502,7 @@ public void testTxCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxRollback() throws Exception { Ignite ignite0 = ignite(0); Ignite ignite1 = ignite(1); @@ -567,6 +570,7 @@ public void testTxRollback() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxCommitReadOnlyGetAll() throws Exception { testTxCommitReadOnlyGetAll(false); } @@ -574,6 +578,7 @@ public void testTxCommitReadOnlyGetAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxCommitReadOnlyGetEntries() throws Exception { testTxCommitReadOnlyGetAll(true); } @@ -642,6 +647,7 @@ private void testTxCommitReadOnlyGetAll(boolean needVer) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxCommitReadWriteTwoNodes() throws Exception { Ignite ignite0 = ignite(0); @@ -673,6 +679,7 @@ public void testTxCommitReadWriteTwoNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictRead1() throws Exception { txConflictRead(true, false); } @@ -680,6 +687,7 @@ public void testTxConflictRead1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictRead2() throws Exception { txConflictRead(false, false); } @@ -687,6 +695,7 @@ public void testTxConflictRead2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadEntry1() throws Exception { txConflictRead(true, true); } @@ -694,6 +703,7 @@ public void testTxConflictReadEntry1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadEntry2() throws Exception { txConflictRead(false, true); } @@ -778,6 +788,7 @@ private void txConflictRead(boolean noVal, boolean needVer) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadWrite1() throws Exception { txConflictReadWrite(true, false, false); } @@ -785,6 +796,7 @@ public void testTxConflictReadWrite1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadWrite2() throws Exception { txConflictReadWrite(false, false, false); } @@ -792,6 +804,7 @@ public void testTxConflictReadWrite2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadRemove1() throws Exception { txConflictReadWrite(true, true, false); } @@ -799,6 +812,7 @@ public void testTxConflictReadRemove1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadRemove2() throws Exception { txConflictReadWrite(false, true, false); } @@ -806,6 +820,7 @@ public void testTxConflictReadRemove2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadEntryWrite1() throws Exception { txConflictReadWrite(true, false, true); } @@ -813,6 +828,7 @@ public void testTxConflictReadEntryWrite1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadEntryWrite2() throws Exception { txConflictReadWrite(false, false, true); } @@ -820,6 +836,7 @@ public void testTxConflictReadEntryWrite2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadEntryRemove1() throws Exception { txConflictReadWrite(true, true, true); } @@ -827,6 +844,7 @@ public void testTxConflictReadEntryRemove1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReadEntryRemove2() throws Exception { txConflictReadWrite(false, true, true); } @@ -923,6 +941,7 @@ private void txConflictReadWrite(boolean noVal, boolean rmv, boolean needVer) th /** * @throws Exception If failed. */ + @Test public void testTxConflictReadWrite3() throws Exception { Ignite ignite0 = ignite(0); @@ -988,6 +1007,7 @@ public void testTxConflictReadWrite3() throws Exception { /** * @throws Exception If failed */ + @Test public void testTxConflictGetAndPut1() throws Exception { txConflictGetAndPut(true, false); } @@ -995,6 +1015,7 @@ public void testTxConflictGetAndPut1() throws Exception { /** * @throws Exception If failed */ + @Test public void testTxConflictGetAndPut2() throws Exception { txConflictGetAndPut(false, false); } @@ -1002,6 +1023,7 @@ public void testTxConflictGetAndPut2() throws Exception { /** * @throws Exception If failed */ + @Test public void testTxConflictGetAndRemove1() throws Exception { txConflictGetAndPut(true, true); } @@ -1009,6 +1031,7 @@ public void testTxConflictGetAndRemove1() throws Exception { /** * @throws Exception If failed */ + @Test public void testTxConflictGetAndRemove2() throws Exception { txConflictGetAndPut(false, true); } @@ -1081,6 +1104,7 @@ private void txConflictGetAndPut(boolean noVal, boolean rmv) throws Exception { /** * @throws Exception If failed */ + @Test public void testTxConflictInvoke1() throws Exception { txConflictInvoke(true, false); } @@ -1088,6 +1112,7 @@ public void testTxConflictInvoke1() throws Exception { /** * @throws Exception If failed */ + @Test public void testTxConflictInvoke2() throws Exception { txConflictInvoke(false, false); } @@ -1095,6 +1120,7 @@ public void testTxConflictInvoke2() throws Exception { /** * @throws Exception If failed */ + @Test public void testTxConflictInvoke3() throws Exception { txConflictInvoke(true, true); } @@ -1102,6 +1128,7 @@ public void testTxConflictInvoke3() throws Exception { /** * @throws Exception If failed */ + @Test public void testTxConflictInvoke4() throws Exception { txConflictInvoke(false, true); } @@ -1174,6 +1201,7 @@ private void txConflictInvoke(boolean noVal, boolean rmv) throws Exception { /** * @throws Exception If failed */ + @Test public void testTxConflictInvokeAll() throws Exception { Ignite ignite0 = ignite(0); @@ -1268,6 +1296,7 @@ public void testTxConflictInvokeAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictPutIfAbsent() throws Exception { Ignite ignite0 = ignite(0); @@ -1354,6 +1383,7 @@ public void testTxConflictPutIfAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictGetAndPutIfAbsent() throws Exception { Ignite ignite0 = ignite(0); @@ -1440,6 +1470,7 @@ public void testTxConflictGetAndPutIfAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictReplace() throws Exception { Ignite ignite0 = ignite(0); @@ -1565,6 +1596,7 @@ public void testTxConflictReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictGetAndReplace() throws Exception { Ignite ignite0 = ignite(0); @@ -1690,6 +1722,7 @@ public void testTxConflictGetAndReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictRemoveWithOldValue() throws Exception { Ignite ignite0 = ignite(0); @@ -1827,6 +1860,7 @@ public void testTxConflictRemoveWithOldValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictCasReplace() throws Exception { Ignite ignite0 = ignite(0); @@ -1964,6 +1998,7 @@ public void testTxConflictCasReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictRemoveReturnBoolean1() throws Exception { txConflictRemoveReturnBoolean(false); } @@ -1971,6 +2006,7 @@ public void testTxConflictRemoveReturnBoolean1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxConflictRemoveReturnBoolean2() throws Exception { txConflictRemoveReturnBoolean(true); } @@ -2135,6 +2171,7 @@ private void txConflictRemoveReturnBoolean(boolean noVal) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoConflictPut1() throws Exception { txNoConflictUpdate(true, false, false); } @@ -2142,6 +2179,7 @@ public void testTxNoConflictPut1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoConflictPut2() throws Exception { txNoConflictUpdate(false, false, false); } @@ -2149,6 +2187,7 @@ public void testTxNoConflictPut2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoConflictPut3() throws Exception { txNoConflictUpdate(false, false, true); } @@ -2156,6 +2195,7 @@ public void testTxNoConflictPut3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoConflictRemove1() throws Exception { txNoConflictUpdate(true, true, false); } @@ -2163,6 +2203,7 @@ public void testTxNoConflictRemove1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoConflictRemove2() throws Exception { txNoConflictUpdate(false, true, false); } @@ -2170,6 +2211,7 @@ public void testTxNoConflictRemove2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoConflictRemove3() throws Exception { txNoConflictUpdate(false, true, true); } @@ -2285,6 +2327,7 @@ private void txNoConflictUpdate(boolean noVal, boolean rmv, boolean getAfterUpda /** * @throws Exception If failed. */ + @Test public void testTxNoConflictContainsKey1() throws Exception { txNoConflictContainsKey(false); } @@ -2292,6 +2335,7 @@ public void testTxNoConflictContainsKey1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoConflictContainsKey2() throws Exception { txNoConflictContainsKey(true); } @@ -2375,6 +2419,7 @@ private void txNoConflictContainsKey(boolean noVal) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxRollbackIfLocked1() throws Exception { Ignite ignite0 = ignite(0); @@ -2434,6 +2479,7 @@ public void testTxRollbackIfLocked1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxRollbackIfLocked2() throws Exception { rollbackIfLockedPartialLock(false); } @@ -2441,6 +2487,7 @@ public void testTxRollbackIfLocked2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxRollbackIfLocked3() throws Exception { rollbackIfLockedPartialLock(true); } @@ -2507,6 +2554,7 @@ private void rollbackIfLockedPartialLock(boolean locKey) throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoReadLockConflict() throws Exception { checkNoReadLockConflict(false); } @@ -2514,6 +2562,7 @@ public void testNoReadLockConflict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoReadLockConflictGetEntry() throws Exception { checkNoReadLockConflict(true); } @@ -2614,6 +2663,7 @@ private void checkNoReadLockConflict(final Ignite ignite, /** * @throws Exception If failed. */ + @Test public void testNoReadLockConflictMultiNode() throws Exception { Ignite ignite0 = ignite(0); @@ -2675,6 +2725,7 @@ public void testNoReadLockConflictMultiNode() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("UnnecessaryLocalVariable") + @Test public void testReadLockPessimisticTxConflict() throws Exception { Ignite ignite0 = ignite(0); @@ -2729,6 +2780,7 @@ public void testReadLockPessimisticTxConflict() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("UnnecessaryLocalVariable") + @Test public void testReadWriteTxConflict() throws Exception { Ignite ignite0 = ignite(0); @@ -2782,6 +2834,7 @@ public void testReadWriteTxConflict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadWriteTransactionsNoDeadlock() throws Exception { checkReadWriteTransactionsNoDeadlock(false); } @@ -2789,6 +2842,7 @@ public void testReadWriteTransactionsNoDeadlock() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadWriteTransactionsNoDeadlockMultinode() throws Exception { checkReadWriteTransactionsNoDeadlock(true); } @@ -2853,6 +2907,7 @@ private void checkReadWriteTransactionsNoDeadlock(final boolean multiNode) throw /** * @throws Exception If failed. */ + @Test public void testReadWriteAccountTx() throws Exception { final CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, FULL_SYNC, @@ -3032,6 +3087,7 @@ public void testReadWriteAccountTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearCacheReaderUpdate() throws Exception { Ignite ignite0 = ignite(0); @@ -3080,6 +3136,7 @@ public void testNearCacheReaderUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollbackNearCache1() throws Exception { rollbackNearCacheWrite(true); } @@ -3087,6 +3144,7 @@ public void testRollbackNearCache1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollbackNearCache2() throws Exception { rollbackNearCacheWrite(false); } @@ -3166,6 +3224,7 @@ private void rollbackNearCacheWrite(boolean near) throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollbackNearCache3() throws Exception { rollbackNearCacheRead(true); } @@ -3173,6 +3232,7 @@ public void testRollbackNearCache3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollbackNearCache4() throws Exception { rollbackNearCacheRead(false); } @@ -3246,6 +3306,7 @@ private void rollbackNearCacheRead(boolean near) throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCacheTx() throws Exception { Ignite ignite0 = ignite(0); @@ -3509,6 +3570,7 @@ public void testCrossCacheTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomOperations() throws Exception { Ignite ignite0 = ignite(0); @@ -3608,6 +3670,7 @@ private void randomOperation(ThreadLocalRandom rnd, IgniteCache cache0 = grid(0).getOrCreateCache(getNearConfig()); @@ -635,7 +654,10 @@ public void testNearClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testNearCloseWithTry() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + startGridsMultiThreaded(gridCount()); String curVal = null; @@ -673,7 +695,10 @@ public void testNearCloseWithTry() throws Exception { * * @throws Exception If failed. */ + @Test public void testLocalClose() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + memCfg = new DataStorageConfiguration(); startGridsMultiThreaded(gridCount()); @@ -724,7 +749,10 @@ public void testLocalClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testLocalCloseWithTry() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + memCfg = new DataStorageConfiguration(); startGridsMultiThreaded(gridCount()); @@ -756,6 +784,7 @@ public void testLocalCloseWithTry() throws Exception { /** * Tests start -> destroy -> start -> close using CacheManager. */ + @Test public void testTckStyleCreateDestroyClose() throws Exception { startGridsMultiThreaded(gridCount()); @@ -788,6 +817,7 @@ public void testTckStyleCreateDestroyClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentUseAndCloseFromClient() throws Exception { testConcurrentUseAndClose(true); } @@ -795,6 +825,7 @@ public void testConcurrentUseAndCloseFromClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentUseAndCloseFromServer() throws Exception { testConcurrentUseAndClose(false); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeAbstractTest.java index b75500fe9649a..ff4fb753c71d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeAbstractTest.java @@ -37,9 +37,6 @@ import org.apache.ignite.internal.processors.cache.store.CacheLocalStore; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; @@ -57,9 +54,6 @@ * */ public abstract class CacheStoreUsageMultinodeAbstractTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ protected boolean client; @@ -87,8 +81,6 @@ public abstract class CacheStoreUsageMultinodeAbstractTest extends GridCommonAbs cfg.setClientMode(client); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - if (cache) cfg.setCacheConfiguration(cacheConfiguration()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeDynamicStartAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeDynamicStartAbstractTest.java index 745e97b81324b..80fc6da1c85ca 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeDynamicStartAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeDynamicStartAbstractTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class CacheStoreUsageMultinodeDynamicStartAbstractTest extends CacheStoreUsageMultinodeAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -40,6 +44,7 @@ public abstract class CacheStoreUsageMultinodeDynamicStartAbstractTest extends C /** * @throws Exception If failed. */ + @Test public void testDynamicStart() throws Exception { checkStoreWithDynamicStart(false); } @@ -47,6 +52,7 @@ public void testDynamicStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicStartNearEnabled() throws Exception { nearCache = true; @@ -56,6 +62,7 @@ public void testDynamicStartNearEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicFromClientStart() throws Exception { checkStoreWithDynamicStart(true); } @@ -63,6 +70,7 @@ public void testDynamicFromClientStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicStartFromClientNearEnabled() throws Exception { nearCache = true; @@ -72,6 +80,7 @@ public void testDynamicStartFromClientNearEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicStartLocalStore() throws Exception { locStore = true; @@ -81,6 +90,7 @@ public void testDynamicStartLocalStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicStartFromClientLocalStore() throws Exception { locStore = true; @@ -90,6 +100,7 @@ public void testDynamicStartFromClientLocalStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicStartLocalStoreNearEnabled() throws Exception { locStore = true; @@ -101,6 +112,7 @@ public void testDynamicStartLocalStoreNearEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicStartWriteBehindStore() throws Exception { writeBehind = true; @@ -110,6 +122,7 @@ public void testDynamicStartWriteBehindStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicStartFromClientWriteBehindStore() throws Exception { writeBehind = true; @@ -119,6 +132,7 @@ public void testDynamicStartFromClientWriteBehindStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicStartWriteBehindStoreNearEnabled() throws Exception { writeBehind = true; @@ -161,4 +175,4 @@ private void checkStoreWithDynamicStart(boolean clientStart) throws Exception { cache.destroy(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeDynamicStartTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeDynamicStartTxTest.java index 4511fc5a3d826..e217a1f878382 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeDynamicStartTxTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeDynamicStartTxTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -25,6 +26,13 @@ * */ public class CacheStoreUsageMultinodeDynamicStartTxTest extends CacheStoreUsageMultinodeDynamicStartAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeStaticStartAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeStaticStartAbstractTest.java index e16f16ed937dc..a3b0ea5f58796 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeStaticStartAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeStaticStartAbstractTest.java @@ -17,9 +17,14 @@ package org.apache.ignite.internal.processors.cache; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + /** * */ +@RunWith(JUnit4.class) public abstract class CacheStoreUsageMultinodeStaticStartAbstractTest extends CacheStoreUsageMultinodeAbstractTest { /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { @@ -31,6 +36,7 @@ public abstract class CacheStoreUsageMultinodeStaticStartAbstractTest extends Ca /** * @throws Exception If failed. */ + @Test public void testStaticConfiguration() throws Exception { checkStoreUpdateStaticConfig(true); } @@ -38,6 +44,7 @@ public void testStaticConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationNearEnabled() throws Exception { nearCache = true; @@ -47,6 +54,7 @@ public void testStaticConfigurationNearEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationLocalStore() throws Exception { locStore = true; @@ -56,6 +64,7 @@ public void testStaticConfigurationLocalStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationLocalStoreNearEnabled() throws Exception { locStore = true; @@ -67,6 +76,7 @@ public void testStaticConfigurationLocalStoreNearEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationTxLocalStoreNoClientStore() throws Exception { locStore = true; @@ -76,6 +86,7 @@ public void testStaticConfigurationTxLocalStoreNoClientStore() throws Exception /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationTxLocalStoreNoClientStoreNearEnabled() throws Exception { locStore = true; @@ -87,6 +98,7 @@ public void testStaticConfigurationTxLocalStoreNoClientStoreNearEnabled() throws /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationTxWriteBehindStore() throws Exception { writeBehind = true; @@ -96,6 +108,7 @@ public void testStaticConfigurationTxWriteBehindStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationTxWriteBehindStoreNearEnabled() throws Exception { writeBehind = true; @@ -107,6 +120,7 @@ public void testStaticConfigurationTxWriteBehindStoreNearEnabled() throws Except /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationTxWriteBehindStoreNoClientStore() throws Exception { writeBehind = true; @@ -116,6 +130,7 @@ public void testStaticConfigurationTxWriteBehindStoreNoClientStore() throws Exce /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationTxWriteBehindStoreNoClientStoreNearEnabled() throws Exception { writeBehind = true; @@ -148,4 +163,4 @@ private void checkStoreUpdateStaticConfig(boolean clientStore) throws Exception stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeStaticStartTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeStaticStartTxTest.java index 2f11fc862b47c..8fa7e65b2c37e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeStaticStartTxTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStoreUsageMultinodeStaticStartTxTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -25,6 +26,13 @@ * */ public class CacheStoreUsageMultinodeStaticStartTxTest extends CacheStoreUsageMultinodeStaticStartAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java index 79316bfa457b4..407788ccf07d7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxFastFinishTest.java @@ -27,14 +27,14 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFastFinishFuture; import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -48,10 +48,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheTxFastFinishTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -62,8 +60,6 @@ public class CacheTxFastFinishTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(PARTITIONED); @@ -91,6 +87,7 @@ public class CacheTxFastFinishTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testFastFinishTxNearCache() throws Exception { nearCache = true; @@ -100,6 +97,7 @@ public void testFastFinishTxNearCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFastFinishTx() throws Exception { fastFinishTx(); } @@ -107,7 +105,7 @@ public void testFastFinishTx() throws Exception { /** * @throws Exception If failed. */ - private void fastFinishTx() throws Exception { + protected void fastFinishTx() throws Exception { startGrid(0); fastFinishTx(ignite(0)); @@ -142,7 +140,7 @@ private void fastFinishTx() throws Exception { /** * @param ignite Node. */ - private void fastFinishTx(Ignite ignite) { + protected void fastFinishTx(Ignite ignite) { IgniteTransactions txs = ignite.transactions(); IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -202,7 +200,7 @@ private void fastFinishTx(Ignite ignite) { * @param tx Transaction. * @param commit Commit flag. */ - private void checkFastTxFinish(Transaction tx, boolean commit) { + protected void checkFastTxFinish(Transaction tx, boolean commit) { if (commit) tx.commit(); else @@ -218,7 +216,7 @@ private void checkFastTxFinish(Transaction tx, boolean commit) { * @param tx Transaction. * @param commit Commit flag. */ - private void checkNormalTxFinish(Transaction tx, boolean commit) { + protected void checkNormalTxFinish(Transaction tx, boolean commit) { IgniteInternalTx tx0 = ((TransactionProxyImpl)tx).tx(); if (commit) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxNotAllowReadFromBackupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxNotAllowReadFromBackupTest.java index f0ec084a55764..dcc9a07e2eed2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxNotAllowReadFromBackupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheTxNotAllowReadFromBackupTest.java @@ -29,22 +29,20 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for query with BinaryMarshaller and different serialization modes and with reflective serializer. */ +@RunWith(JUnit4.class) public class CacheTxNotAllowReadFromBackupTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 2; @@ -61,7 +59,6 @@ public class CacheTxNotAllowReadFromBackupTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); return cfg; @@ -77,6 +74,7 @@ public class CacheTxNotAllowReadFromBackupTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testBackupConsistencyReplicated() throws Exception { CacheConfiguration cfg = new CacheConfiguration<>("test-cache"); @@ -105,6 +103,7 @@ public void testBackupConsistencyReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupConsistencyReplicatedFullSync() throws Exception { CacheConfiguration cfg = new CacheConfiguration<>("test-cache"); @@ -133,6 +132,7 @@ public void testBackupConsistencyReplicatedFullSync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupConsistencyPartitioned() throws Exception { CacheConfiguration cfg = new CacheConfiguration<>("test-cache"); @@ -162,6 +162,7 @@ public void testBackupConsistencyPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupConsistencyPartitionedFullSync() throws Exception { CacheConfiguration cfg = new CacheConfiguration<>("test-cache"); @@ -188,6 +189,76 @@ public void testBackupConsistencyPartitionedFullSync() throws Exception { checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE); } + /** + * @throws Exception If failed. + */ + @Test + public void testBackupConsistencyReplicatedMvcc() throws Exception { + CacheConfiguration cfg = new CacheConfiguration<>("test-cache"); + + cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC); + cfg.setCacheMode(CacheMode.REPLICATED); + cfg.setReadFromBackup(false); + + checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + + checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBackupConsistencyReplicatedFullSyncMvcc() throws Exception { + CacheConfiguration cfg = new CacheConfiguration<>("test-cache"); + + cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); + cfg.setCacheMode(CacheMode.REPLICATED); + cfg.setReadFromBackup(false); + + checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + + checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBackupConsistencyPartitionedMvcc() throws Exception { + CacheConfiguration cfg = new CacheConfiguration<>("test-cache"); + + cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC); + cfg.setCacheMode(CacheMode.PARTITIONED); + cfg.setBackups(NODES - 1); + cfg.setReadFromBackup(false); + + checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + + checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBackupConsistencyPartitionedFullSyncMvcc() throws Exception { + CacheConfiguration cfg = new CacheConfiguration<>("test-cache"); + + cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); + cfg.setCacheMode(CacheMode.PARTITIONED); + cfg.setBackups(NODES - 1); + cfg.setReadFromBackup(false); + + checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + + checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); + } + /** * @param ccfg Cache configuration. * @throws Exception If failed. @@ -287,4 +358,4 @@ private void checkBackupConsistencyGetAll(CacheConfiguration c } return batches; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheValidatorMetricsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheValidatorMetricsTest.java index 4a950dda8f1a1..84216c51d5daf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheValidatorMetricsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheValidatorMetricsTest.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.List; import org.apache.ignite.Ignite; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.PartitionLossPolicy; import org.apache.ignite.cluster.ClusterNode; @@ -29,10 +30,14 @@ import org.apache.ignite.configuration.TopologyValidator; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Cache validator metrics test. */ +@RunWith(JUnit4.class) public class CacheValidatorMetricsTest extends GridCommonAbstractTest implements Serializable { /** Cache name 1. */ private static String CACHE_NAME_1 = "cache1"; @@ -48,11 +53,13 @@ public class CacheValidatorMetricsTest extends GridCommonAbstractTest implements .setName(CACHE_NAME_1) .setCacheMode(CacheMode.PARTITIONED) .setBackups(0) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setPartitionLossPolicy(PartitionLossPolicy.READ_ONLY_ALL); CacheConfiguration cCfg2 = new CacheConfiguration() .setName(CACHE_NAME_2) .setCacheMode(CacheMode.REPLICATED) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setTopologyValidator(new TopologyValidator() { @Override public boolean validate(Collection nodes) { return nodes.size() == 2; @@ -90,6 +97,7 @@ void assertCacheStatus(String cacheName, boolean validForReading, boolean validF * * @throws Exception If failed. */ + @Test public void testCacheValidatorMetrics() throws Exception { startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterReadOnlyModeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterReadOnlyModeAbstractTest.java new file mode 100644 index 0000000000000..3134f1c4ff1f3 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterReadOnlyModeAbstractTest.java @@ -0,0 +1,123 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.Collection; +import java.util.Collections; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheMode.REPLICATED; + +/** + * + */ +public class ClusterReadOnlyModeAbstractTest extends GridCommonAbstractTest { + /** */ + private static final int SRVS = 3; + + /** Replicated atomic cache. */ + private static final String REPL_ATOMIC_CACHE = "repl_atomic_cache"; + + /** Replicated transactional cache. */ + private static final String REPL_TX_CACHE = "repl_tx_cache"; + + /** Replicated transactional cache. */ + private static final String REPL_MVCC_CACHE = "repl_mvcc_cache"; + + /** Partitioned atomic cache. */ + private static final String PART_ATOMIC_CACHE = "part_atomic_cache"; + + /** Partitioned transactional cache. */ + private static final String PART_TX_CACHE = "part_tx_cache"; + + /** Partitioned mvcc transactional cache. */ + private static final String PART_MVCC_CACHE = "part_mvcc_cache"; + + /** Cache names. */ + protected static final Collection CACHE_NAMES = F.asList(REPL_ATOMIC_CACHE, REPL_TX_CACHE, + PART_ATOMIC_CACHE, PART_TX_CACHE); + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + startGridsMultiThreaded(SRVS); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + changeClusterReadOnlyMode(false); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setCacheConfiguration( + cacheConfiguration(REPL_ATOMIC_CACHE, REPLICATED, ATOMIC, null), + cacheConfiguration(REPL_TX_CACHE, REPLICATED, TRANSACTIONAL, null), + cacheConfiguration(REPL_MVCC_CACHE, REPLICATED, TRANSACTIONAL_SNAPSHOT, "mvcc_repl_grp"), + cacheConfiguration(PART_ATOMIC_CACHE, PARTITIONED, ATOMIC, "part_grp"), + cacheConfiguration(PART_TX_CACHE, PARTITIONED, TRANSACTIONAL, "part_grp"), + cacheConfiguration(PART_MVCC_CACHE, PARTITIONED, TRANSACTIONAL_SNAPSHOT, "mvcc_part_grp") + ); + + return cfg; + } + + /** + * @param cacheMode Cache mode. + * @param atomicityMode Atomicity mode. + * @param grpName Cache group name. + */ + private CacheConfiguration cacheConfiguration(String name, CacheMode cacheMode, + CacheAtomicityMode atomicityMode, String grpName) { + return new CacheConfiguration() + .setName(name) + .setCacheMode(cacheMode) + .setAtomicityMode(atomicityMode) + .setGroupName(grpName) + .setQueryEntities(Collections.singletonList(new QueryEntity(Integer.class, Integer.class))); + } + + /** + * Change read only mode on all nodes. + * + * @param readOnly Read only. + */ + protected void changeClusterReadOnlyMode(boolean readOnly) { + for (int idx = 0; idx < SRVS; idx++) { + IgniteEx ignite = grid(idx); + + ignite.context().cache().context().readOnlyMode(readOnly); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterReadOnlyModeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterReadOnlyModeTest.java new file mode 100644 index 0000000000000..2da280c74a773 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterReadOnlyModeTest.java @@ -0,0 +1,140 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.Random; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl; +import org.apache.ignite.internal.util.typedef.G; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests cache get/put/remove and data streaming in read-only cluster mode. + */ +@RunWith(JUnit4.class) +public class ClusterReadOnlyModeTest extends ClusterReadOnlyModeAbstractTest { + /** + * Tests cache get/put/remove. + */ + @Test + public void testCacheGetPutRemove() { + assertCachesReadOnlyMode(false); + + changeClusterReadOnlyMode(true); + + assertCachesReadOnlyMode(true); + + changeClusterReadOnlyMode(false); + + assertCachesReadOnlyMode(false); + } + + /** + * Tests data streamer. + */ + @Test + public void testDataStreamerReadOnly() { + assertDataStreamerReadOnlyMode(false); + + changeClusterReadOnlyMode(true); + + assertDataStreamerReadOnlyMode(true); + + changeClusterReadOnlyMode(false); + + assertDataStreamerReadOnlyMode(false); + } + + /** + * Asserts that all caches in read-only or in read/write mode on all nodes. + * + * @param readOnly If {@code true} then cache must be in read only mode, else in read/write mode. + */ + private void assertCachesReadOnlyMode(boolean readOnly) { + Random rnd = new Random(); + + for (Ignite ignite : G.allGrids()) { + for (String cacheName : CACHE_NAMES) { + IgniteCache cache = ignite.cache(cacheName); + + for (int i = 0; i < 10; i++) { + cache.get(rnd.nextInt(100)); // All gets must succeed. + + if (readOnly) { + // All puts must fail. + try { + cache.put(rnd.nextInt(100), rnd.nextInt()); + + fail("Put must fail for cache " + cacheName); + } + catch (Exception e) { + // No-op. + } + + // All removes must fail. + try { + cache.remove(rnd.nextInt(100)); + + fail("Remove must fail for cache " + cacheName); + } + catch (Exception e) { + // No-op. + } + } + else { + cache.put(rnd.nextInt(100), rnd.nextInt()); // All puts must succeed. + + cache.remove(rnd.nextInt(100)); // All removes must succeed. + } + } + } + } + } + + /** + * @param readOnly If {@code true} then data streamer must fail, else succeed. + */ + private void assertDataStreamerReadOnlyMode(boolean readOnly) { + Random rnd = new Random(); + + for (Ignite ignite : G.allGrids()) { + for (String cacheName : CACHE_NAMES) { + boolean failed = false; + + try (IgniteDataStreamer streamer = ignite.dataStreamer(cacheName)) { + for (int i = 0; i < 10; i++) { + ((DataStreamerImpl)streamer).maxRemapCount(5); + + streamer.addData(rnd.nextInt(1000), rnd.nextInt()); + } + } + catch (CacheException ignored) { + failed = true; + } + + if (failed != readOnly) + fail("Streaming to " + cacheName + " must " + (readOnly ? "fail" : "succeed")); + } + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterStateAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterStateAbstractTest.java index d5f9c900b0fe9..fc8d2f22edf86 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterStateAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ClusterStateAbstractTest.java @@ -42,11 +42,14 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ -@SuppressWarnings("TooBroadScope") +@RunWith(JUnit4.class) public abstract class ClusterStateAbstractTest extends GridCommonAbstractTest { /** Entry count. */ public static final int ENTRY_CNT = 5000; @@ -106,6 +109,7 @@ public abstract class ClusterStateAbstractTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testDynamicCacheStart() throws Exception { activeOnStart = false; @@ -118,14 +122,14 @@ public void testDynamicCacheStart() throws Exception { forbidden.clear(); - grid(0).active(true); + grid(0).cluster().active(true); IgniteCache cache2 = grid(0).createCache(new CacheConfiguration<>("cache2")); for (int k = 0; k < ENTRY_CNT; k++) cache2.put(k, k); - grid(0).active(false); + grid(0).cluster().active(false); checkInactive(GRID_CNT); @@ -135,6 +139,7 @@ public void testDynamicCacheStart() throws Exception { /** * @throws Exception if failed. */ + @Test public void testNoRebalancing() throws Exception { activeOnStart = false; @@ -147,7 +152,7 @@ public void testNoRebalancing() throws Exception { forbidden.clear(); - grid(0).active(true); + grid(0).cluster().active(true); awaitPartitionMapExchange(); @@ -158,7 +163,7 @@ public void testNoRebalancing() throws Exception { for (int g = 0; g < GRID_CNT; g++) { // Tests that state changes are propagated to existing and new nodes. - assertTrue(grid(g).active()); + assertTrue(grid(g).cluster().active()); IgniteCache cache0 = grid(g).cache(CACHE_NAME); @@ -191,12 +196,12 @@ public void testNoRebalancing() throws Exception { assertEquals(k, cache0.get(k)); } - grid(0).active(false); + grid(0).cluster().active(false); GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { for (int g = 0; g < GRID_CNT; g++) { - if (grid(g).active()) + if (grid(g).cluster().active()) return false; } @@ -216,6 +221,7 @@ public void testNoRebalancing() throws Exception { /** * @throws Exception if failed. */ + @Test public void testActivationFromClient() throws Exception { forbidden.add(GridDhtPartitionSupplyMessage.class); forbidden.add(GridDhtPartitionDemandMessage.class); @@ -234,7 +240,7 @@ public void testActivationFromClient() throws Exception { forbidden.clear(); - cl.active(true); + cl.cluster().active(true); awaitPartitionMapExchange(); @@ -245,7 +251,7 @@ public void testActivationFromClient() throws Exception { for (int g = 0; g < GRID_CNT + 1; g++) { // Tests that state changes are propagated to existing and new nodes. - assertTrue(grid(g).active()); + assertTrue(grid(g).cluster().active()); IgniteCache cache0 = grid(g).cache(CACHE_NAME); @@ -253,12 +259,12 @@ public void testActivationFromClient() throws Exception { assertEquals(k, cache0.get(k)); } - cl.active(false); + cl.cluster().active(false); GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { for (int g = 0; g < GRID_CNT + 1; g++) { - if (grid(g).active()) + if (grid(g).cluster().active()) return false; } @@ -274,6 +280,7 @@ public void testActivationFromClient() throws Exception { * * @throws Exception If fails. */ + @Test public void testDeactivationWithPendingLock() throws Exception { startGrids(GRID_CNT); @@ -281,16 +288,20 @@ public void testDeactivationWithPendingLock() throws Exception { lock.lock(); - GridTestUtils.assertThrowsAnyCause(log, new Callable() { - @Override public Object call() throws Exception { - grid(0).active(false); - - return null; - } - }, IgniteException.class, - "Failed to deactivate cluster (must invoke the method outside of an active transaction or lock)."); + try { + //noinspection ThrowableNotThrown + GridTestUtils.assertThrowsAnyCause(log, new Callable() { + @Override public Object call() { + grid(0).cluster().active(false); - lock.unlock(); + return null; + } + }, IgniteException.class, + "Failed to deactivate cluster (must invoke the method outside of an active transaction)."); + } + finally { + lock.unlock(); + } } /** @@ -298,6 +309,7 @@ public void testDeactivationWithPendingLock() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeactivationWithPendingTransaction() throws Exception { startGrids(GRID_CNT); @@ -308,25 +320,25 @@ public void testDeactivationWithPendingTransaction() throws Exception { } /** - * @throws Exception if failed. */ private void deactivateWithPendingTransaction(TransactionConcurrency concurrency, - TransactionIsolation isolation) throws Exception { + TransactionIsolation isolation) { final Ignite ignite0 = grid(0); final IgniteCache cache0 = ignite0.cache(CACHE_NAME); - try (Transaction tx = ignite0.transactions().txStart(concurrency, isolation)) { + try (Transaction ignore = ignite0.transactions().txStart(concurrency, isolation)) { cache0.put(1, "1"); + //noinspection ThrowableNotThrown GridTestUtils.assertThrowsAnyCause(log, new Callable() { - @Override public Object call() throws Exception { - grid(0).active(false); + @Override public Object call() { + grid(0).cluster().active(false); return null; } }, IgniteException.class, - "Failed to deactivate cluster (must invoke the method outside of an active transaction or lock)."); + "Failed to deactivate cluster (must invoke the method outside of an active transaction)."); } assertNull(cache0.get(1)); @@ -338,7 +350,7 @@ private void deactivateWithPendingTransaction(TransactionConcurrency concurrency */ private void checkInactive(int cnt) { for (int g = 0; g < cnt; g++) - assertFalse(grid(g).active()); + assertFalse(grid(g).cluster().active()); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ConcurrentCacheStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ConcurrentCacheStartTest.java index 28a6683e19aed..8828c577dee63 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ConcurrentCacheStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ConcurrentCacheStartTest.java @@ -24,14 +24,19 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class ConcurrentCacheStartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void test() throws Exception { try { final IgniteEx ignite = (IgniteEx) startGrids(4); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheLockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheLockTest.java index 8f0e20f604ece..387bf3a2236ca 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheLockTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheLockTest.java @@ -22,20 +22,19 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * */ +@RunWith(JUnit4.class) public class CrossCacheLockTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_CNT = 4; @@ -45,12 +44,17 @@ public class CrossCacheLockTest extends GridCommonAbstractTest { /** */ private static final String CACHE2 = "cache2"; + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - if (igniteInstanceName.equals(getTestIgniteInstanceName(GRID_CNT - 1))) cfg.setClientMode(true); @@ -80,6 +84,7 @@ public class CrossCacheLockTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testLockUnlock() throws Exception { for (int i = 0; i < GRID_CNT; i++) { Ignite ignite = ignite(i); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java index cc9823bc63e7e..2337de8af9054 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java @@ -35,14 +35,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -57,10 +58,8 @@ /** * */ +@RunWith(JUnit4.class) public class CrossCacheTxRandomOperationsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE1 = "cache1"; @@ -77,8 +76,6 @@ public class CrossCacheTxRandomOperationsTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - if (igniteInstanceName.equals(getTestIgniteInstanceName(GRID_CNT - 1))) cfg.setClientMode(true); @@ -92,6 +89,9 @@ public class CrossCacheTxRandomOperationsTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + if (nearCacheEnabled()) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + super.beforeTestsStarted(); startGridsMultiThreaded(GRID_CNT - 1); @@ -109,6 +109,7 @@ protected boolean nearCacheEnabled() { /** * @throws Exception If failed. */ + @Test public void testTxOperations() throws Exception { txOperations(PARTITIONED, FULL_SYNC, false); } @@ -116,6 +117,7 @@ public void testTxOperations() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCacheTxOperations() throws Exception { txOperations(PARTITIONED, FULL_SYNC, true); } @@ -123,6 +125,7 @@ public void testCrossCacheTxOperations() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCacheTxOperationsPrimarySync() throws Exception { txOperations(PARTITIONED, PRIMARY_SYNC, true); } @@ -130,6 +133,7 @@ public void testCrossCacheTxOperationsPrimarySync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCacheTxOperationsReplicated() throws Exception { txOperations(REPLICATED, FULL_SYNC, true); } @@ -137,6 +141,7 @@ public void testCrossCacheTxOperationsReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCacheTxOperationsReplicatedPrimarySync() throws Exception { txOperations(REPLICATED, PRIMARY_SYNC, true); } @@ -194,6 +199,13 @@ protected void createCache(CacheMode cacheMode, private void txOperations(CacheMode cacheMode, CacheWriteSynchronizationMode writeSync, boolean crossCacheTx) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) { + assert !nearCacheEnabled(); + + if(writeSync != CacheWriteSynchronizationMode.FULL_SYNC) + return; + } + Ignite ignite = ignite(0); try { @@ -203,12 +215,14 @@ private void txOperations(CacheMode cacheMode, txOperations(PESSIMISTIC, REPEATABLE_READ, crossCacheTx, false); txOperations(PESSIMISTIC, REPEATABLE_READ, crossCacheTx, true); - txOperations(OPTIMISTIC, REPEATABLE_READ, crossCacheTx, false); - txOperations(OPTIMISTIC, REPEATABLE_READ, crossCacheTx, true); + if(!MvccFeatureChecker.forcedMvcc()) { + txOperations(OPTIMISTIC, REPEATABLE_READ, crossCacheTx, false); + txOperations(OPTIMISTIC, REPEATABLE_READ, crossCacheTx, true); - if (writeSync == FULL_SYNC) { - txOperations(OPTIMISTIC, SERIALIZABLE, crossCacheTx, false); - txOperations(OPTIMISTIC, SERIALIZABLE, crossCacheTx, true); + if (writeSync == FULL_SYNC) { + txOperations(OPTIMISTIC, SERIALIZABLE, crossCacheTx, false); + txOperations(OPTIMISTIC, SERIALIZABLE, crossCacheTx, true); + } } } finally { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DataStorageConfigurationValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DataStorageConfigurationValidationTest.java index 9471a826fa426..8a6e2c1f39b27 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DataStorageConfigurationValidationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DataStorageConfigurationValidationTest.java @@ -18,19 +18,22 @@ package org.apache.ignite.internal.processors.cache; import java.util.concurrent.Callable; -import junit.framework.TestCase; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * Tests assertions in DataStorageConfiguration. */ -public class DataStorageConfigurationValidationTest extends TestCase { +public class DataStorageConfigurationValidationTest { /** * Tests {@link DataStorageConfiguration#walSegmentSize} property assertion. * * @throws Exception If failed. */ + @Test public void testWalSegmentSizeOverflow() throws Exception { final DataStorageConfiguration cfg = new DataStorageConfiguration(); @@ -46,6 +49,7 @@ public void testWalSegmentSizeOverflow() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetWalSegmentSizeShouldThrowExceptionWhenSizeLessThen512Kb() throws Exception { final DataStorageConfiguration cfg = new DataStorageConfiguration(); @@ -61,6 +65,7 @@ public void testSetWalSegmentSizeShouldThrowExceptionWhenSizeLessThen512Kb() thr /** * @throws Exception If failed. */ + @Test public void testSetWalSegmentSizeShouldBeOkWhenSizeBetween512KbAnd2Gb() throws Exception { final DataStorageConfiguration cfg = new DataStorageConfiguration(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/EntryVersionConsistencyReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/EntryVersionConsistencyReadThroughTest.java index ebf253d50cd73..09228601ef454 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/EntryVersionConsistencyReadThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/EntryVersionConsistencyReadThroughTest.java @@ -38,16 +38,23 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * Tests consistency of entry's versions after invokeAll. */ +@RunWith(JUnit4.class) public class EntryVersionConsistencyReadThroughTest extends GridCommonAbstractTest { /** */ private static final int NODES_CNT = 5; @@ -102,6 +109,7 @@ private CacheConfiguration> createCacheConfiguration(CacheA /** * @throws Exception If failed. */ + @Test public void testInvokeAllTransactionalCache() throws Exception { check(false, createCacheConfiguration(TRANSACTIONAL)); } @@ -109,6 +117,18 @@ public void testInvokeAllTransactionalCache() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testInvokeAllMvccTxCache() throws Exception { + Assume.assumeTrue("https://issues.apache.org/jira/browse/IGNITE-8582", + MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.CACHE_STORE)); + + check(false, createCacheConfiguration(TRANSACTIONAL_SNAPSHOT)); + } + + /** + * @throws Exception If failed. + */ + @Test public void testInvokeAllAtomicCache() throws Exception { check(false, createCacheConfiguration(ATOMIC)); } @@ -116,6 +136,7 @@ public void testInvokeAllAtomicCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAtomicCache() throws Exception { check(true, createCacheConfiguration(ATOMIC)); } @@ -123,10 +144,22 @@ public void testInvokeAtomicCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeTransactionalCache() throws Exception { check(true, createCacheConfiguration(TRANSACTIONAL)); } + /** + * @throws Exception If failed. + */ + @Test + public void testInvokeMvccTxCache() throws Exception { + Assume.assumeTrue("https://issues.apache.org/jira/browse/IGNITE-8582", + MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.CACHE_STORE)); + + check(true, createCacheConfiguration(TRANSACTIONAL_SNAPSHOT)); + } + /** * Tests entry's versions consistency after invokeAll. * diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridAbstractCacheInterceptorRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridAbstractCacheInterceptorRebalanceTest.java index 611f42b76f34e..30a86f0f7c763 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridAbstractCacheInterceptorRebalanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridAbstractCacheInterceptorRebalanceTest.java @@ -33,13 +33,13 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -49,10 +49,8 @@ /** * */ +@RunWith(JUnit4.class) public abstract class GridAbstractCacheInterceptorRebalanceTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE_NAME = "test_cache"; @@ -87,8 +85,6 @@ public abstract class GridAbstractCacheInterceptorRebalanceTest extends GridComm cfg.setCacheConfiguration(ccfg); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - return cfg; } @@ -109,6 +105,7 @@ public abstract class GridAbstractCacheInterceptorRebalanceTest extends GridComm /** * @throws Exception If fail. */ + @Test public void testRebalanceUpdate() throws Exception { interceptor = new RebalanceUpdateInterceptor(); @@ -122,6 +119,7 @@ public void testRebalanceUpdate() throws Exception { /** * @throws Exception If fail. */ + @Test public void testRebalanceUpdateInvoke() throws Exception { interceptor = new RebalanceUpdateInterceptor(); @@ -137,6 +135,7 @@ public void testRebalanceUpdateInvoke() throws Exception { /** * @throws Exception If fail. */ + @Test public void testRebalanceRemoveInvoke() throws Exception { interceptor = new RebalanceUpdateInterceptor(); @@ -152,6 +151,7 @@ public void testRebalanceRemoveInvoke() throws Exception { /** * @throws Exception If fail. */ + @Test public void testRebalanceRemove() throws Exception { interceptor = new RebalanceRemoveInterceptor(); @@ -165,6 +165,7 @@ public void testRebalanceRemove() throws Exception { /** * @throws Exception If fail. */ + @Test public void testPutIfAbsent() throws Exception { interceptor = new RebalanceUpdateInterceptor(); @@ -178,6 +179,7 @@ public void testPutIfAbsent() throws Exception { /** * @throws Exception If fail. */ + @Test public void testGetAndPut() throws Exception { interceptor = new RebalanceUpdateInterceptor(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractByteArrayValuesSelfTest.java index cabe41f23d2cd..00f5dafb27bf4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractByteArrayValuesSelfTest.java @@ -17,44 +17,18 @@ package org.apache.ignite.internal.processors.cache; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** * Base class for various tests for byte array values. */ public abstract class GridCacheAbstractByteArrayValuesSelfTest extends GridCommonAbstractTest { - /** Regular cache name. */ - protected static final String CACHE_REGULAR = "cache"; - /** Key 1. */ protected static final Integer KEY_1 = 1; /** Key 2. */ protected static final Integer KEY_2 = 2; - /** Use special key for swap test, otherwise entry with readers is not evicted. */ - protected static final Integer SWAP_TEST_KEY = 3; - - /** Shared IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - - return c; - } - /** * Wrap provided values into byte array. * diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java index 26f75295257ac..755e8cb5278c5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java @@ -41,12 +41,16 @@ import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; /** * Failover tests for cache. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstractSelfTest { /** */ private static final long TEST_TIMEOUT = 3 * 60 * 1000; @@ -129,6 +133,7 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac /** * @throws Exception If failed. */ + @Test public void testTopologyChange() throws Exception { testTopologyChange(null, null); } @@ -136,6 +141,7 @@ public void testTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConstantTopologyChange() throws Exception { testConstantTopologyChange(null, null); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverTxSelfTest.java index 353386b921db0..c5433f5841e9c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverTxSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverTxSelfTest.java @@ -17,6 +17,10 @@ package org.apache.ignite.internal.processors.cache; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; @@ -26,10 +30,12 @@ /** * */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractFailoverTxSelfTest extends GridCacheAbstractFailoverSelfTest { /** * @throws Exception If failed. */ + @Test public void testOptimisticReadCommittedTxConstantTopologyChange() throws Exception { testConstantTopologyChange(OPTIMISTIC, READ_COMMITTED); } @@ -37,6 +43,7 @@ public void testOptimisticReadCommittedTxConstantTopologyChange() throws Excepti /** * @throws Exception If failed. */ + @Test public void testOptimisticRepeatableReadTxConstantTopologyChange() throws Exception { testConstantTopologyChange(OPTIMISTIC, REPEATABLE_READ); } @@ -44,6 +51,7 @@ public void testOptimisticRepeatableReadTxConstantTopologyChange() throws Except /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableTxConstantTopologyChange() throws Exception { testConstantTopologyChange(OPTIMISTIC, SERIALIZABLE); } @@ -51,6 +59,7 @@ public void testOptimisticSerializableTxConstantTopologyChange() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testPessimisticReadCommittedTxConstantTopologyChange() throws Exception { testConstantTopologyChange(PESSIMISTIC, READ_COMMITTED); } @@ -58,6 +67,7 @@ public void testPessimisticReadCommittedTxConstantTopologyChange() throws Except /** * @throws Exception If failed. */ + @Test public void testPessimisticRepeatableReadTxConstantTopologyChange() throws Exception { testConstantTopologyChange(PESSIMISTIC, REPEATABLE_READ); } @@ -65,6 +75,7 @@ public void testPessimisticRepeatableReadTxConstantTopologyChange() throws Excep /** * @throws Exception If failed. */ + @Test public void testPessimisticSerializableTxConstantTopologyChange() throws Exception { testConstantTopologyChange(PESSIMISTIC, SERIALIZABLE); } @@ -72,6 +83,7 @@ public void testPessimisticSerializableTxConstantTopologyChange() throws Excepti /** * @throws Exception If failed. */ + @Test public void testOptimisticReadCommittedTxTopologyChange() throws Exception { testTopologyChange(OPTIMISTIC, READ_COMMITTED); } @@ -79,6 +91,7 @@ public void testOptimisticReadCommittedTxTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticRepeatableReadTxTopologyChange() throws Exception { testTopologyChange(OPTIMISTIC, REPEATABLE_READ); } @@ -86,6 +99,7 @@ public void testOptimisticRepeatableReadTxTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableTxTopologyChange() throws Exception { testTopologyChange(OPTIMISTIC, SERIALIZABLE); } @@ -93,6 +107,7 @@ public void testOptimisticSerializableTxTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticReadCommittedTxTopologyChange() throws Exception { testTopologyChange(PESSIMISTIC, READ_COMMITTED); } @@ -100,6 +115,7 @@ public void testPessimisticReadCommittedTxTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticRepeatableReadTxTopologyChange() throws Exception { testTopologyChange(PESSIMISTIC, REPEATABLE_READ); } @@ -107,7 +123,8 @@ public void testPessimisticRepeatableReadTxTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticSerializableTxTopologyChange() throws Exception { testTopologyChange(PESSIMISTIC, SERIALIZABLE); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java index 140efb0fd8be6..809ec59fb21d8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java @@ -39,10 +39,14 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Multithreaded cache API tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends GridCacheAbstractSelfTest { /** */ private static final Random RND = new Random(); @@ -163,6 +167,7 @@ private Set rangeKeys(int fromIncl, int toExcl) { /** * @throws Exception In case of error. */ + @Test public void testContainsKey() throws Exception { runTest(new CI1>() { @Override public void apply(IgniteCache cache) { @@ -175,6 +180,7 @@ public void testContainsKey() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGet() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -189,6 +195,7 @@ public void testGet() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAsyncOld() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -210,6 +217,7 @@ public void testGetAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAsync() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -225,6 +233,7 @@ public void testGetAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAll() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -243,6 +252,7 @@ public void testGetAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllAsyncOld() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -265,6 +275,7 @@ public void testGetAllAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllAsync() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -283,6 +294,7 @@ public void testGetAllAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemove() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -314,6 +326,7 @@ public void testRemove() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAsyncOld() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -352,6 +365,7 @@ public void testRemoveAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAsync() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -384,6 +398,7 @@ public void testRemoveAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAll() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -404,6 +419,7 @@ public void testRemoveAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllAsyncOld() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -428,6 +444,7 @@ public void testRemoveAllAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllAsync() throws Exception { runTest(new CIX1>() { @Override public void applyx(IgniteCache cache) { @@ -463,4 +480,4 @@ private V removeAsync(IgniteCache cache, K key) { private boolean removeAsync(IgniteCache cache, K key, V val) { return cache.removeAsync(key, val).get(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index f238786c780f0..1d1cb255c5404 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -99,10 +99,14 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Assume; +import org.junit.Ignore; +import org.junit.Test; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -174,6 +178,13 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } }; + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9543", MvccFeatureChecker.forcedMvcc()); + + super.setUp(); + } + /** Dflt grid. */ protected transient Ignite dfltIgnite; @@ -273,20 +284,14 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * Checks that any invoke returns result. * * @throws Exception if something goes bad. - * - * TODO https://issues.apache.org/jira/browse/IGNITE-4380. */ - public void _testInvokeAllMultithreaded() throws Exception { + @Ignore("https://issues.apache.org/jira/browse/IGNITE-4380") + @Test + public void testInvokeAllMultithreaded() throws Exception { final IgniteCache cache = jcache(); final int threadCnt = 4; final int cnt = 5000; - // Concurrent invoke can not be used for ATOMIC cache in CLOCK mode. - if (atomicityMode() == ATOMIC && - cacheMode() != LOCAL && - false) - return; - final Set keys = Collections.singleton("myKey"); GridTestUtils.runMultiThreaded(new Runnable() { @@ -305,6 +310,7 @@ public void _testInvokeAllMultithreaded() throws Exception { /** * Checks that skipStore flag gets overridden inside a transaction. */ + @Test public void testWriteThroughTx() { String key = "writeThroughKey"; @@ -331,6 +337,7 @@ public void testWriteThroughTx() { /** * Checks that skipStore flag gets overridden inside a transaction. */ + @Test public void testNoReadThroughTx() { String key = "writeThroughKey"; @@ -412,6 +419,7 @@ protected IgniteCache fullCache() { /** * @throws Exception In case of error. */ + @Test public void testSize() throws Exception { assert jcache().localSize() == 0; @@ -477,6 +485,7 @@ public void testSize() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testContainsKey() throws Exception { jcache().put("testContainsKey", 1); @@ -487,6 +496,7 @@ public void testContainsKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContainsKeyTx() throws Exception { if (!txEnabled()) return; @@ -521,6 +531,7 @@ public void testContainsKeyTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContainsKeysTx() throws Exception { if (!txEnabled()) return; @@ -562,6 +573,7 @@ public void testContainsKeysTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveInExplicitLocks() throws Exception { if (lockingEnabled()) { IgniteCache cache = jcache(); @@ -587,6 +599,7 @@ public void testRemoveInExplicitLocks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAllSkipStore() throws Exception { IgniteCache jcache = jcache(); @@ -602,6 +615,7 @@ public void testRemoveAllSkipStore() throws Exception { /** * @throws IgniteCheckedException If failed. */ + @Test public void testAtomicOps() throws IgniteCheckedException { IgniteCache c = jcache(); @@ -634,6 +648,7 @@ public void testAtomicOps() throws IgniteCheckedException { /** * @throws Exception In case of error. */ + @Test public void testGet() throws Exception { IgniteCache cache = jcache(); @@ -648,6 +663,7 @@ public void testGet() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetEntry() throws Exception { IgniteCache cache = jcache(); @@ -672,6 +688,7 @@ public void testGetEntry() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAsync() throws Exception { IgniteCache cache = jcache(); @@ -692,6 +709,7 @@ public void testGetAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -721,6 +739,7 @@ public void testGetAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAll() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -801,6 +820,7 @@ public void testGetAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetEntries() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -917,6 +937,7 @@ public void testGetEntries() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllWithLastNull() throws Exception { final IgniteCache cache = jcache(); @@ -937,6 +958,7 @@ public void testGetAllWithLastNull() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllWithFirstNull() throws Exception { final IgniteCache cache = jcache(); @@ -957,6 +979,7 @@ public void testGetAllWithFirstNull() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllWithInTheMiddle() throws Exception { final IgniteCache cache = jcache(); @@ -978,6 +1001,7 @@ public void testGetAllWithInTheMiddle() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetTxNonExistingKey() throws Exception { if (txShouldBeUsed()) { try (Transaction ignored = transactions().txStart()) { @@ -989,6 +1013,7 @@ public void testGetTxNonExistingKey() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllAsync() throws Exception { final IgniteCache cache = jcache(); @@ -1016,6 +1041,7 @@ public void testGetAllAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllAsyncOld() throws Exception { final IgniteCache cache = jcache(); @@ -1047,6 +1073,7 @@ public void testGetAllAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPut() throws Exception { IgniteCache cache = jcache(); @@ -1083,6 +1110,7 @@ public void testPut() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutTx() throws Exception { if (txShouldBeUsed()) { IgniteCache cache = jcache(); @@ -1122,6 +1150,7 @@ public void testPutTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformOptimisticReadCommitted() throws Exception { checkTransform(OPTIMISTIC, READ_COMMITTED); } @@ -1129,6 +1158,7 @@ public void testTransformOptimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformOptimisticRepeatableRead() throws Exception { checkTransform(OPTIMISTIC, REPEATABLE_READ); } @@ -1136,6 +1166,7 @@ public void testTransformOptimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPessimisticReadCommitted() throws Exception { checkTransform(PESSIMISTIC, READ_COMMITTED); } @@ -1143,6 +1174,7 @@ public void testTransformPessimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPessimisticRepeatableRead() throws Exception { checkTransform(PESSIMISTIC, REPEATABLE_READ); } @@ -1150,6 +1182,7 @@ public void testTransformPessimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteTransformOptimisticReadCommitted() throws Exception { checkIgniteTransform(OPTIMISTIC, READ_COMMITTED); } @@ -1157,6 +1190,7 @@ public void testIgniteTransformOptimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteTransformOptimisticRepeatableRead() throws Exception { checkIgniteTransform(OPTIMISTIC, REPEATABLE_READ); } @@ -1164,6 +1198,7 @@ public void testIgniteTransformOptimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteTransformPessimisticReadCommitted() throws Exception { checkIgniteTransform(PESSIMISTIC, READ_COMMITTED); } @@ -1171,6 +1206,7 @@ public void testIgniteTransformPessimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteTransformPessimisticRepeatableRead() throws Exception { checkIgniteTransform(PESSIMISTIC, REPEATABLE_READ); } @@ -1287,6 +1323,7 @@ private void checkTransform(TransactionConcurrency concurrency, TransactionIsola /** * @throws Exception If failed. */ + @Test public void testTransformAllOptimisticReadCommitted() throws Exception { checkTransformAll(OPTIMISTIC, READ_COMMITTED); } @@ -1294,6 +1331,7 @@ public void testTransformAllOptimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformAllOptimisticRepeatableRead() throws Exception { checkTransformAll(OPTIMISTIC, REPEATABLE_READ); } @@ -1301,6 +1339,7 @@ public void testTransformAllOptimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformAllPessimisticReadCommitted() throws Exception { checkTransformAll(PESSIMISTIC, READ_COMMITTED); } @@ -1308,6 +1347,7 @@ public void testTransformAllPessimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformAllPessimisticRepeatableRead() throws Exception { checkTransformAll(PESSIMISTIC, REPEATABLE_READ); } @@ -1398,6 +1438,7 @@ private void checkTransformAll(TransactionConcurrency concurrency, TransactionIs /** * @throws Exception If failed. */ + @Test public void testTransformAllWithNulls() throws Exception { final IgniteCache cache = jcache(); @@ -1444,6 +1485,7 @@ public void testTransformAllWithNulls() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformSequentialOptimisticNoStart() throws Exception { checkTransformSequential0(false, OPTIMISTIC); } @@ -1451,6 +1493,7 @@ public void testTransformSequentialOptimisticNoStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformSequentialPessimisticNoStart() throws Exception { checkTransformSequential0(false, PESSIMISTIC); } @@ -1458,6 +1501,7 @@ public void testTransformSequentialPessimisticNoStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformSequentialOptimisticWithStart() throws Exception { checkTransformSequential0(true, OPTIMISTIC); } @@ -1465,6 +1509,7 @@ public void testTransformSequentialOptimisticWithStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformSequentialPessimisticWithStart() throws Exception { checkTransformSequential0(true, PESSIMISTIC); } @@ -1521,6 +1566,7 @@ private void checkTransformSequential0(boolean startVal, TransactionConcurrency /** * @throws Exception If failed. */ + @Test public void testTransformAfterRemoveOptimistic() throws Exception { checkTransformAfterRemove(OPTIMISTIC); } @@ -1528,6 +1574,7 @@ public void testTransformAfterRemoveOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformAfterRemovePessimistic() throws Exception { checkTransformAfterRemove(PESSIMISTIC); } @@ -1564,6 +1611,7 @@ private void checkTransformAfterRemove(TransactionConcurrency concurrency) throw /** * @throws Exception If failed. */ + @Test public void testTransformReturnValueGetOptimisticReadCommitted() throws Exception { checkTransformReturnValue(false, OPTIMISTIC, READ_COMMITTED); } @@ -1571,6 +1619,7 @@ public void testTransformReturnValueGetOptimisticReadCommitted() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testTransformReturnValueGetOptimisticRepeatableRead() throws Exception { checkTransformReturnValue(false, OPTIMISTIC, REPEATABLE_READ); } @@ -1578,6 +1627,7 @@ public void testTransformReturnValueGetOptimisticRepeatableRead() throws Excepti /** * @throws Exception If failed. */ + @Test public void testTransformReturnValueGetPessimisticReadCommitted() throws Exception { checkTransformReturnValue(false, PESSIMISTIC, READ_COMMITTED); } @@ -1585,6 +1635,7 @@ public void testTransformReturnValueGetPessimisticReadCommitted() throws Excepti /** * @throws Exception If failed. */ + @Test public void testTransformReturnValueGetPessimisticRepeatableRead() throws Exception { checkTransformReturnValue(false, PESSIMISTIC, REPEATABLE_READ); } @@ -1592,6 +1643,7 @@ public void testTransformReturnValueGetPessimisticRepeatableRead() throws Except /** * @throws Exception If failed. */ + @Test public void testTransformReturnValuePutInTx() throws Exception { checkTransformReturnValue(true, OPTIMISTIC, READ_COMMITTED); } @@ -1637,6 +1689,7 @@ private void checkTransformReturnValue(boolean put, /** * @throws Exception In case of error. */ + @Test public void testGetAndPutAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -1663,6 +1716,7 @@ public void testGetAndPutAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAndPutAsync() throws Exception { IgniteCache cache = jcache(); @@ -1683,6 +1737,7 @@ public void testGetAndPutAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAsyncOld0() throws Exception { IgniteCache cacheAsync = jcache().withAsync(); @@ -1701,6 +1756,7 @@ public void testPutAsyncOld0() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAsync0() throws Exception { IgniteCache cache = jcache(); @@ -1715,6 +1771,7 @@ public void testPutAsync0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -1750,6 +1807,7 @@ public void testInvokeAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAsync() throws Exception { IgniteCache cache = jcache(); @@ -1777,6 +1835,7 @@ public void testInvokeAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvoke() throws Exception { final IgniteCache cache = jcache(); @@ -1820,6 +1879,7 @@ public void testInvoke() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutx() throws Exception { if (txShouldBeUsed()) checkPut(true); @@ -1828,6 +1888,7 @@ public void testPutx() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutxNoTx() throws Exception { checkPut(false); } @@ -1872,6 +1933,7 @@ private void checkPut(boolean inTx) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAsyncOld() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -1917,6 +1979,7 @@ public void testPutAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAsync() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -1956,6 +2019,7 @@ public void testPutAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAll() throws Exception { Map map = F.asMap("key1", 1, "key2", 2); @@ -1982,6 +2046,7 @@ public void testPutAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testNullInTx() throws Exception { if (!txShouldBeUsed()) return; @@ -2073,6 +2138,7 @@ public void testNullInTx() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAllWithNulls() throws Exception { final IgniteCache cache = jcache(); @@ -2201,6 +2267,7 @@ public void testPutAllWithNulls() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAllAsyncOld() throws Exception { Map map = F.asMap("key1", 1, "key2", 2); @@ -2231,6 +2298,7 @@ public void testPutAllAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAllAsync() throws Exception { Map map = F.asMap("key1", 1, "key2", 2); @@ -2255,6 +2323,7 @@ public void testPutAllAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAndPutIfAbsent() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -2332,6 +2401,7 @@ public void testGetAndPutIfAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPutIfAbsentAsyncOld() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -2404,6 +2474,7 @@ public void testGetAndPutIfAbsentAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPutIfAbsentAsync() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -2465,6 +2536,7 @@ public void testGetAndPutIfAbsentAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsent() throws Exception { IgniteCache cache = jcache(); @@ -2510,6 +2582,7 @@ public void testPutIfAbsent() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutxIfAbsentAsync() throws Exception { if (txShouldBeUsed()) checkPutxIfAbsentAsync(true); @@ -2518,6 +2591,7 @@ public void testPutxIfAbsentAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutxIfAbsentAsyncNoTx() throws Exception { checkPutxIfAbsentAsync(false); } @@ -2652,6 +2726,7 @@ private void checkPutxIfAbsentAsync(boolean inTx) throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutIfAbsentAsyncConcurrentOld() throws Exception { IgniteCache cacheAsync = jcache().withAsync(); @@ -2670,6 +2745,7 @@ public void testPutIfAbsentAsyncConcurrentOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutIfAbsentAsyncConcurrent() throws Exception { IgniteCache cache = jcache(); @@ -2684,6 +2760,7 @@ public void testPutIfAbsentAsyncConcurrent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndReplace() throws Exception { IgniteCache cache = jcache(); @@ -2769,6 +2846,7 @@ public void testGetAndReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplace() throws Exception { IgniteCache cache = jcache(); @@ -2817,6 +2895,7 @@ public void testReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndReplaceAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -2897,6 +2976,7 @@ public void testGetAndReplaceAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndReplaceAsync() throws Exception { IgniteCache cache = jcache(); @@ -2959,6 +3039,7 @@ public void testGetAndReplaceAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplacexAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -3021,6 +3102,7 @@ public void testReplacexAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplacexAsync() throws Exception { IgniteCache cache = jcache(); @@ -3071,6 +3153,7 @@ public void testReplacexAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAndRemove() throws Exception { IgniteCache cache = jcache(); @@ -3089,6 +3172,7 @@ public void testGetAndRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndRemoveObject() throws Exception { IgniteCache cache = ignite(0).cache(DEFAULT_CACHE_NAME); @@ -3119,6 +3203,7 @@ public void testGetAndRemoveObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPutObject() throws Exception { IgniteCache cache = ignite(0).cache(DEFAULT_CACHE_NAME); @@ -3145,6 +3230,7 @@ public void testGetAndPutObject() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeletedEntriesFlag() throws Exception { if (cacheMode() != LOCAL && cacheMode() != REPLICATED) { final int cnt = 3; @@ -3165,6 +3251,7 @@ public void testDeletedEntriesFlag() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveLoad() throws Exception { int cnt = 10; @@ -3196,6 +3283,7 @@ public void testRemoveLoad() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveLoadAsync() throws Exception { if (isMultiJvm()) return; @@ -3230,6 +3318,7 @@ public void testRemoveLoadAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -3264,6 +3353,7 @@ public void testRemoveAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAsync() throws Exception { IgniteCache cache = jcache(); @@ -3288,6 +3378,7 @@ public void testRemoveAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemove() throws Exception { IgniteCache cache = jcache(); @@ -3301,6 +3392,7 @@ public void testRemove() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemovexAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -3322,6 +3414,7 @@ public void testRemovexAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemovexAsync() throws Exception { IgniteCache cache = jcache(); @@ -3337,6 +3430,7 @@ public void testRemovexAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGlobalRemoveAll() throws Exception { globalRemoveAll(false); } @@ -3344,6 +3438,7 @@ public void testGlobalRemoveAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGlobalRemoveAllAsync() throws Exception { globalRemoveAll(true); } @@ -3475,6 +3570,7 @@ protected long hugeRemoveAllEntryCount() { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllWithNulls() throws Exception { final IgniteCache cache = jcache(); @@ -3529,6 +3625,7 @@ public void testRemoveAllWithNulls() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllDuplicates() throws Exception { jcache().removeAll(ImmutableSet.of("key1", "key1", "key1")); } @@ -3536,6 +3633,7 @@ public void testRemoveAllDuplicates() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllDuplicatesTx() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart()) { @@ -3549,6 +3647,7 @@ public void testRemoveAllDuplicatesTx() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllEmpty() throws Exception { jcache().removeAll(); } @@ -3556,6 +3655,7 @@ public void testRemoveAllEmpty() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -3581,6 +3681,7 @@ public void testRemoveAllAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllAsync() throws Exception { IgniteCache cache = jcache(); @@ -3602,6 +3703,7 @@ public void testRemoveAllAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testLoadAll() throws Exception { IgniteCache cache = jcache(); @@ -3639,6 +3741,7 @@ public void testLoadAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAfterClear() throws Exception { IgniteEx ignite = grid(0); @@ -3685,6 +3788,7 @@ public void testRemoveAfterClear() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testClear() throws Exception { IgniteCache cache = jcache(); @@ -3829,6 +3933,7 @@ protected void checkUnlocked(final Collection keys0) throws IgniteChecke /** * @throws Exception If failed. */ + @Test public void testGlobalClearAll() throws Exception { globalClearAll(false, false); } @@ -3836,6 +3941,7 @@ public void testGlobalClearAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearAllAsyncOld() throws Exception { globalClearAll(true, true); } @@ -3843,6 +3949,7 @@ public void testGlobalClearAllAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearAllAsync() throws Exception { globalClearAll(true, false); } @@ -3881,6 +3988,7 @@ protected void globalClearAll(boolean async, boolean oldAsync) throws Exception * @throws Exception In case of error. */ @SuppressWarnings("BusyWait") + @Test public void testLockUnlock() throws Exception { if (lockingEnabled()) { final CountDownLatch lockCnt = new CountDownLatch(1); @@ -3940,6 +4048,7 @@ public void testLockUnlock() throws Exception { * @throws Exception In case of error. */ @SuppressWarnings("BusyWait") + @Test public void testLockUnlockAll() throws Exception { if (lockingEnabled()) { IgniteCache cache = jcache(); @@ -3995,6 +4104,7 @@ public void testLockUnlockAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPeek() throws Exception { Ignite ignite = primaryIgnite("key"); IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -4011,6 +4121,7 @@ public void testPeek() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPeekTxRemoveOptimistic() throws Exception { checkPeekTxRemove(OPTIMISTIC); } @@ -4018,6 +4129,7 @@ public void testPeekTxRemoveOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPeekTxRemovePessimistic() throws Exception { checkPeekTxRemove(PESSIMISTIC); } @@ -4047,6 +4159,7 @@ private void checkPeekTxRemove(TransactionConcurrency concurrency) throws Except /** * @throws Exception If failed. */ + @Test public void testPeekRemove() throws Exception { IgniteCache cache = primaryCache("key"); @@ -4057,9 +4170,9 @@ public void testPeekRemove() throws Exception { } /** - * TODO GG-11133. * @throws Exception In case of error. */ + @Test public void testEvictExpired() throws Exception { final IgniteCache cache = jcache(); @@ -4111,10 +4224,9 @@ public void testEvictExpired() throws Exception { } /** - * TODO GG-11133. - * * @throws Exception If failed. */ + @Test public void testPeekExpired() throws Exception { final IgniteCache c = jcache(); @@ -4146,10 +4258,9 @@ public void testPeekExpired() throws Exception { } /** - * TODO GG-11133. - * * @throws Exception If failed. */ + @Test public void testPeekExpiredTx() throws Exception { if (txShouldBeUsed()) { final IgniteCache c = jcache(); @@ -4180,6 +4291,7 @@ public void testPeekExpiredTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTtlTx() throws Exception { if (txShouldBeUsed()) checkTtl(true, false); @@ -4188,6 +4300,7 @@ public void testTtlTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTtlNoTx() throws Exception { checkTtl(false, false); } @@ -4195,6 +4308,7 @@ public void testTtlNoTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTtlNoTxOldEntry() throws Exception { checkTtl(false, true); } @@ -4205,10 +4319,6 @@ public void testTtlNoTxOldEntry() throws Exception { * @throws Exception If failed. */ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { - // TODO GG-11133. - if (true) - return; - int ttl = 1000; final ExpiryPolicy expiry = new TouchedExpiryPolicy(new Duration(MILLISECONDS, ttl)); @@ -4273,7 +4383,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { assertNotNull(curEntryTtl.get1()); assertNotNull(curEntryTtl.get2()); - assertEquals(ttl, (long)curEntryTtl.get1()); assertTrue(curEntryTtl.get2() > startTime); expireTimes[i] = curEntryTtl.get2(); @@ -4302,7 +4411,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { assertNotNull(curEntryTtl.get1()); assertNotNull(curEntryTtl.get2()); - assertEquals(ttl, (long)curEntryTtl.get1()); assertTrue(curEntryTtl.get2() > startTime); expireTimes[i] = curEntryTtl.get2(); @@ -4331,7 +4439,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { assertNotNull(curEntryTtl.get1()); assertNotNull(curEntryTtl.get2()); - assertEquals(ttl, (long)curEntryTtl.get1()); assertTrue(curEntryTtl.get2() > startTime); expireTimes[i] = curEntryTtl.get2(); @@ -4364,7 +4471,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { assertNotNull(curEntryTtl.get1()); assertNotNull(curEntryTtl.get2()); - assertEquals(ttl, (long)curEntryTtl.get1()); assertEquals(expireTimes[i], (long)curEntryTtl.get2()); } } @@ -4373,7 +4479,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { storeStgy.removeFromStore(key); assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() { - @SuppressWarnings("unchecked") @Override public boolean applyx() { try { Integer val = c.get(key); @@ -4450,6 +4555,7 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { /** * @throws Exception In case of error. */ + @Test public void testLocalEvict() throws Exception { IgniteCache cache = jcache(); @@ -4492,6 +4598,7 @@ public void testLocalEvict() throws Exception { /** * JUnit. */ + @Test public void testCacheProxy() { IgniteCache cache = jcache(); @@ -4499,10 +4606,9 @@ public void testCacheProxy() { } /** - * TODO GG-11133. - * * @throws Exception If failed. */ + @Test public void testCompactExpired() throws Exception { final IgniteCache cache = jcache(); @@ -4536,6 +4642,7 @@ public void testCompactExpired() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimisticTxMissingKey() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { @@ -4552,6 +4659,7 @@ public void testOptimisticTxMissingKey() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimisticTxMissingKeyNoCommit() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { @@ -4566,6 +4674,7 @@ public void testOptimisticTxMissingKeyNoCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticTxReadCommittedInTx() throws Exception { checkRemovexInTx(OPTIMISTIC, READ_COMMITTED); } @@ -4573,6 +4682,7 @@ public void testOptimisticTxReadCommittedInTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticTxRepeatableReadInTx() throws Exception { checkRemovexInTx(OPTIMISTIC, REPEATABLE_READ); } @@ -4580,6 +4690,7 @@ public void testOptimisticTxRepeatableReadInTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxReadCommittedInTx() throws Exception { checkRemovexInTx(PESSIMISTIC, READ_COMMITTED); } @@ -4587,6 +4698,7 @@ public void testPessimisticTxReadCommittedInTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxRepeatableReadInTx() throws Exception { checkRemovexInTx(PESSIMISTIC, REPEATABLE_READ); } @@ -4635,6 +4747,7 @@ private void checkRemovexInTx(TransactionConcurrency concurrency, TransactionIso * * @throws Exception If failed. */ + @Test public void testPessimisticTxMissingKey() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { @@ -4651,6 +4764,7 @@ public void testPessimisticTxMissingKey() throws Exception { * * @throws Exception If failed. */ + @Test public void testPessimisticTxMissingKeyNoCommit() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { @@ -4665,6 +4779,7 @@ public void testPessimisticTxMissingKeyNoCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxRepeatableRead() throws Exception { if (txShouldBeUsed()) { try (Transaction ignored = transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { @@ -4678,6 +4793,7 @@ public void testPessimisticTxRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxRepeatableReadOnUpdate() throws Exception { if (txShouldBeUsed()) { try (Transaction ignored = transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { @@ -4691,6 +4807,7 @@ public void testPessimisticTxRepeatableReadOnUpdate() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testToMap() throws Exception { IgniteCache cache = jcache(); @@ -4819,6 +4936,7 @@ protected IgnitePair entryTtl(IgniteCache cache, String key) { /** * @throws Exception If failed. */ + @Test public void testIterator() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -4846,6 +4964,7 @@ public void testIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteCacheIterator() throws Exception { IgniteCache cache = jcache(0); @@ -4892,6 +5011,7 @@ public void testIgniteCacheIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorLeakOnCancelCursor() throws Exception { IgniteCache cache = jcache(0); @@ -5046,7 +5166,7 @@ private void waitForIteratorsCleared(IgniteCache cache, int sec // If AssertionFailedError is in the chain, assume we need to wait and retry. if (!X.hasCause(t, AssertionFailedError.class)) throw t; - + if (i == 9) { for (int j = 0; j < gridCount(); j++) executeOnLocalOrRemoteJvm(j, new PrintIteratorStateTask()); @@ -5086,6 +5206,7 @@ private void checkIteratorEmpty(IgniteCache cache) throws Excep /** * @throws Exception If failed. */ + @Test public void testLocalClearKey() throws Exception { addKeys(); @@ -5137,6 +5258,7 @@ protected void checkLocalRemovedKey(String keyToRmv) { /** * @throws Exception If failed. */ + @Test public void testLocalClearKeys() throws Exception { Map> keys = addKeys(); @@ -5208,6 +5330,7 @@ protected Map> addKeys() { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKey() throws Exception { testGlobalClearKey(false, Arrays.asList("key25"), false); } @@ -5215,6 +5338,7 @@ public void testGlobalClearKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeyAsyncOld() throws Exception { testGlobalClearKey(true, Arrays.asList("key25"), true); } @@ -5222,6 +5346,7 @@ public void testGlobalClearKeyAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeyAsync() throws Exception { testGlobalClearKey(true, Arrays.asList("key25"), false); } @@ -5229,6 +5354,7 @@ public void testGlobalClearKeyAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeys() throws Exception { testGlobalClearKey(false, Arrays.asList("key25", "key100", "key150"), false); } @@ -5236,6 +5362,7 @@ public void testGlobalClearKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeysAsyncOld() throws Exception { testGlobalClearKey(true, Arrays.asList("key25", "key100", "key150"), true); } @@ -5243,6 +5370,7 @@ public void testGlobalClearKeysAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeysAsync() throws Exception { testGlobalClearKey(true, Arrays.asList("key25", "key100", "key150"), false); } @@ -5309,6 +5437,7 @@ protected void testGlobalClearKey(boolean async, Collection keysToRmv, b /** * @throws Exception If failed. */ + @Test public void testWithSkipStore() throws Exception { IgniteCache cache = jcache(0); @@ -5518,6 +5647,7 @@ public void testWithSkipStore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithSkipStoreRemoveAll() throws Exception { if (atomicityMode() == TRANSACTIONAL || (atomicityMode() == ATOMIC && nearEnabled())) // TODO IGNITE-373. return; @@ -5559,6 +5689,7 @@ public void testWithSkipStoreRemoveAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithSkipStoreTx() throws Exception { if (txShouldBeUsed()) { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -5861,6 +5992,7 @@ protected CacheStartMode cacheStartType() { /** * @throws Exception If failed. */ + @Test public void testGetOutTx() throws Exception { checkGetOutTx(false); } @@ -5868,6 +6000,7 @@ public void testGetOutTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOutTxAsync() throws Exception { checkGetOutTx(true); } @@ -5945,6 +6078,7 @@ private void checkGetOutTx(boolean async) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformException() throws Exception { final IgniteCache cache = jcache(); @@ -5966,6 +6100,7 @@ public void testTransformException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockInsideTransaction() throws Exception { if (txEnabled()) { GridTestUtils.assertThrows( @@ -6007,6 +6142,7 @@ public void testLockInsideTransaction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformResourceInjection() throws Exception { ClusterGroup servers = grid(0).cluster().forServers(); @@ -6390,7 +6526,7 @@ public CheckEntriesTask(Collection keys) { size++; - e.touch(null); + e.touch(); } } @@ -6492,11 +6628,16 @@ public EntryTtlTask(String key, boolean useDhtForNearCache) { if (useDhtForNearCache && internalCache.context().isNear()) internalCache = internalCache.context().near().dht(); - GridCacheEntryEx entry = internalCache.peekEx(key); + GridCacheEntryEx entry = internalCache.entryEx(key); + + entry.unswap(); + + IgnitePair pair = new IgnitePair<>(entry.ttl(), entry.expireTime()); + + if (!entry.isNear()) + entry.context().cache().removeEntry(entry); - return entry != null ? - new IgnitePair<>(entry.ttl(), entry.expireTime()) : - new IgnitePair(null, null); + return pair; } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractIteratorsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractIteratorsSelfTest.java index 85e3d6544298c..cfee6aafd8736 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractIteratorsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractIteratorsSelfTest.java @@ -23,10 +23,16 @@ import org.apache.ignite.internal.util.typedef.CA; import org.apache.ignite.internal.util.typedef.CAX; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for cache iterators. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractIteratorsSelfTest extends GridCacheAbstractSelfTest { /** Key prefix. */ protected static final String KEY_PREFIX = "testKey"; @@ -47,6 +53,7 @@ public abstract class GridCacheAbstractIteratorsSelfTest extends GridCacheAbstra /** * @throws Exception If failed. */ + @Test public void testCacheIterator() throws Exception { int cnt = 0; @@ -68,6 +75,7 @@ public void testCacheIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheIteratorMultithreaded() throws Exception { for (int i = 0; i < gridCount(); i++) jcache(i).removeAll(); @@ -95,7 +103,10 @@ public void testCacheIteratorMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntrySetIterator() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10082", MvccFeatureChecker.forcedMvcc()); + assert jcache().localSize(CachePeekMode.ALL) == entryCount(); int cnt = 0; @@ -118,6 +129,7 @@ public void testEntrySetIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntrySetIteratorMultithreaded() throws Exception { for (int i = 0; i < gridCount(); i++) jcache(i).removeAll(); @@ -142,4 +154,4 @@ public void testEntrySetIteratorMultithreaded() throws Exception { }, 3, "iterator-thread"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java index bc1996b8b596c..5f52d3e224722 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java @@ -59,13 +59,13 @@ import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_LOCAL_STORE_KEEPS_PRIMARY_ONLY; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -75,10 +75,8 @@ /** * */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ public static final TestLocalStore LOCAL_STORE_1 = new TestLocalStore<>(); @@ -134,12 +132,6 @@ public GridCacheAbstractLocalStoreSelfTest() { cfg.setCacheConfiguration(cacheCfg, cacheBackup1Cfg, cacheBackup2Cfg); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - return cfg; } @@ -204,6 +196,7 @@ protected NearCacheConfiguration nearConfiguration() { /** * @throws Exception If failed. */ + @Test public void testEvict() throws Exception { Ignite ignite1 = startGrid(1); @@ -232,6 +225,7 @@ public void testEvict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryNode() throws Exception { Ignite ignite1 = startGrid(1); @@ -280,6 +274,7 @@ public void testPrimaryNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupRestorePrimary() throws Exception { testBackupRestore(); } @@ -287,6 +282,7 @@ public void testBackupRestorePrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupRestore() throws Exception { final IgniteEx ignite1 = startGrid(1); Ignite ignite2 = startGrid(2); @@ -406,6 +402,7 @@ public void testBackupRestore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalStoreCorrespondsAffinityWithBackups() throws Exception { testLocalStoreCorrespondsAffinity(BACKUP_CACHE_2); } @@ -413,6 +410,7 @@ public void testLocalStoreCorrespondsAffinityWithBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalStoreCorrespondsAffinityWithBackup() throws Exception { testLocalStoreCorrespondsAffinity(BACKUP_CACHE_1); } @@ -420,6 +418,7 @@ public void testLocalStoreCorrespondsAffinityWithBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalStoreCorrespondsAffinityNoBackups() throws Exception { testLocalStoreCorrespondsAffinity(DEFAULT_CACHE_NAME); } @@ -506,6 +505,7 @@ private void testLocalStoreCorrespondsAffinity(String name) throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalStoreWithNearKeysPrimary() throws Exception { try { System.setProperty(IGNITE_LOCAL_STORE_KEEPS_PRIMARY_ONLY, "true"); @@ -520,6 +520,7 @@ public void testLocalStoreWithNearKeysPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalStoreWithNearKeysPrimaryAndBackups() throws Exception { testLocalStoreWithNearKeys(); } @@ -527,6 +528,7 @@ public void testLocalStoreWithNearKeysPrimaryAndBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalStoreWithNearKeys() throws Exception { if (getCacheMode() == REPLICATED) return; @@ -619,6 +621,7 @@ public void testLocalStoreWithNearKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupNode() throws Exception { Ignite ignite1 = startGrid(1); @@ -684,6 +687,7 @@ public void testBackupNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSwap() throws Exception { Ignite ignite1 = startGrid(1); @@ -883,4 +887,4 @@ else if (igniteInstanceName.endsWith("5")) return LOCAL_STORE_6; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java index 3c0f0017cf5ca..873987a079f24 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java @@ -45,12 +45,16 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; /** * Cache metrics test. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int KEY_CNT = 500; @@ -169,6 +173,7 @@ protected int expectedMissesPerPut(boolean isPrimary) { /** * @throws Exception If failed. */ + @Test public void testGetMetricsDisable() throws Exception { // Disable statistics. for (int i = 0; i < gridCount(); i++) { @@ -262,6 +267,7 @@ public Object process(MutableEntry entry, /** * @throws Exception If failed. */ + @Test public void testGetMetricsSnapshot() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -271,6 +277,7 @@ public void testGetMetricsSnapshot() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndRemoveAsyncAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -288,6 +295,7 @@ public void testGetAndRemoveAsyncAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAsyncValAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -315,6 +323,7 @@ public void testRemoveAsyncValAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -332,6 +341,7 @@ public void testRemoveAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAllAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -356,6 +366,7 @@ public void testRemoveAllAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAllAsyncAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -385,6 +396,7 @@ public void testRemoveAllAsyncAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -406,6 +418,7 @@ public void testGetAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -430,6 +443,7 @@ public void testGetAllAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllAsyncAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -458,6 +472,7 @@ public void testGetAllAsyncAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAvgTime() throws Exception { final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -475,6 +490,7 @@ public void testPutAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAsyncAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -491,6 +507,7 @@ public void testPutAsyncAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPutAsyncAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -518,6 +535,7 @@ public void testGetAndPutAsyncAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsentAsyncAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -543,6 +561,7 @@ public void testPutIfAbsentAsyncAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPutIfAbsentAsyncAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -568,6 +587,7 @@ public void testGetAndPutIfAbsentAsyncAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllAvgTime() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -591,6 +611,7 @@ public void testPutAllAvgTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutsReads() throws Exception { IgniteCache cache0 = grid(0).cache(DEFAULT_CACHE_NAME); @@ -649,6 +670,7 @@ public void testPutsReads() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMissHitPercentage() throws Exception { IgniteCache cache0 = grid(0).cache(DEFAULT_CACHE_NAME); @@ -683,6 +705,7 @@ public void testMissHitPercentage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMisses() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -725,6 +748,7 @@ public void testMisses() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMissesOnEmptyCache() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -763,6 +787,7 @@ public void testMissesOnEmptyCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoves() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -779,6 +804,7 @@ public void testRemoves() throws Exception { * * @throws Exception If failed. */ + @Test public void testCacheSizeWorksAsSize() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -816,6 +842,7 @@ public void testCacheSizeWorksAsSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxEvictions() throws Exception { if (grid(0).cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getAtomicityMode() != CacheAtomicityMode.ATOMIC) checkTtl(true); @@ -824,6 +851,7 @@ public void testTxEvictions() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNonTxEvictions() throws Exception { if (grid(0).cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getAtomicityMode() == CacheAtomicityMode.ATOMIC) checkTtl(false); @@ -1038,6 +1066,7 @@ private void checkTtl(boolean inTx) throws Exception { /** * @throws IgniteCheckedException If failed. */ + @Test public void testInvocationRemovesOnEmptyCache() throws IgniteCheckedException { testInvocationRemoves(true); } @@ -1045,6 +1074,7 @@ public void testInvocationRemovesOnEmptyCache() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testInvocationRemoves() throws IgniteCheckedException { testInvocationRemoves(false); } @@ -1094,6 +1124,7 @@ private void testInvocationRemoves(boolean emptyCache) throws IgniteCheckedExcep /** * @throws IgniteCheckedException If failed. */ + @Test public void testUpdateInvocationsOnEmptyCache() throws IgniteCheckedException { testUpdateInvocations(true); } @@ -1101,6 +1132,7 @@ public void testUpdateInvocationsOnEmptyCache() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testUpdateInvocations() throws IgniteCheckedException { testUpdateInvocations(false); } @@ -1150,6 +1182,7 @@ private void testUpdateInvocations(final boolean emptyCache) throws IgniteChecke /** * @throws IgniteCheckedException If failed. */ + @Test public void testReadOnlyInvocationsOnEmptyCache() throws IgniteCheckedException { testReadOnlyInvocations(true); } @@ -1157,6 +1190,7 @@ public void testReadOnlyInvocationsOnEmptyCache() throws IgniteCheckedException /** * @throws IgniteCheckedException If failed. */ + @Test public void testReadOnlyInvocations() throws IgniteCheckedException { testReadOnlyInvocations(false); } @@ -1201,6 +1235,7 @@ private void testReadOnlyInvocations(final boolean emptyCache) throws IgniteChec /** * @throws IgniteCheckedException If failed. */ + @Test public void testInvokeAvgTime() throws IgniteCheckedException { IgniteCache cache0 = grid(0).cache(DEFAULT_CACHE_NAME); @@ -1265,6 +1300,7 @@ public Object process(MutableEntry entry, /** * @throws IgniteCheckedException If failed. */ + @Test public void testInvokeAsyncAvgTime() throws IgniteCheckedException { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -1282,6 +1318,7 @@ public void testInvokeAsyncAvgTime() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testInvokeAllAvgTime() throws IgniteCheckedException { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -1299,6 +1336,7 @@ public void testInvokeAllAvgTime() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testInvokeAllAsyncAvgTime() throws IgniteCheckedException { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -1317,6 +1355,7 @@ public void testInvokeAllAsyncAvgTime() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testInvokeAllMultipleKeysAvgTime() throws IgniteCheckedException { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -1336,6 +1375,7 @@ public void testInvokeAllMultipleKeysAvgTime() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testInvokeAllAsyncMultipleKeysAvgTime() throws IgniteCheckedException { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java index 036153dcc0b91..324f69ad75eb5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java @@ -47,14 +47,15 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import java.util.concurrent.ConcurrentHashMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -67,10 +68,8 @@ /** * Tests that removes are not lost when topology changes. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractRemoveFailureTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_CNT = 3; @@ -96,7 +95,7 @@ public abstract class GridCacheAbstractRemoveFailureTest extends GridCommonAbstr @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER).setForceServerMode(true); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); if (testClientNode() && getTestIgniteInstanceName(0).equals(igniteInstanceName)) cfg.setClientMode(true); @@ -151,6 +150,7 @@ protected boolean testClientNode() { /** * @throws Exception If failed. */ + @Test public void testPutAndRemove() throws Exception { putAndRemove(duration(), null, null); } @@ -158,6 +158,7 @@ public void testPutAndRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAndRemovePessimisticTx() throws Exception { if (atomicityMode() != CacheAtomicityMode.TRANSACTIONAL) return; @@ -168,6 +169,7 @@ public void testPutAndRemovePessimisticTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAndRemoveOptimisticSerializableTx() throws Exception { if (atomicityMode() != CacheAtomicityMode.TRANSACTIONAL) return; @@ -485,4 +487,4 @@ protected static int random(int min, int max) { return ThreadLocalRandom.current().nextInt(min, max); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java index 89f0ca79b2a69..9504b812ee83d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java @@ -53,6 +53,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; @@ -92,7 +93,8 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { assert cnt >= 1 : "At least one grid must be started"; - initStoreStrategy(); + if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.CACHE_STORE)) + initStoreStrategy(); startGrids(cnt); @@ -256,7 +258,7 @@ protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throw cfg.setIndexedTypes(idxTypes); if (cacheMode() == PARTITIONED) - cfg.setBackups(1); + cfg.setBackups(backups()); return cfg; } @@ -361,6 +363,13 @@ protected IgniteTransactions transactions() { return grid(0).transactions(); } + /** + * @return Backups. + */ + protected int backups() { + return 1; + } + /** * @param idx Index of grid. * @return Default cache. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractTxReadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractTxReadTest.java index c6d99ec19659a..5c57384408971 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractTxReadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractTxReadTest.java @@ -24,12 +24,16 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * Tests value read inside transaction. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractTxReadTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -53,6 +57,7 @@ public abstract class GridCacheAbstractTxReadTest extends GridCacheAbstractSelfT /** * @throws IgniteCheckedException If failed */ + @Test public void testTxReadOptimisticReadCommitted() throws IgniteCheckedException { checkTransactionalRead(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED); } @@ -60,6 +65,7 @@ public void testTxReadOptimisticReadCommitted() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed */ + @Test public void testTxReadOptimisticRepeatableRead() throws IgniteCheckedException { checkTransactionalRead(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ); } @@ -67,6 +73,7 @@ public void testTxReadOptimisticRepeatableRead() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed */ + @Test public void testTxReadOptimisticSerializable() throws IgniteCheckedException { checkTransactionalRead(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE); } @@ -74,6 +81,7 @@ public void testTxReadOptimisticSerializable() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed */ + @Test public void testTxReadPessimisticReadCommitted() throws IgniteCheckedException { checkTransactionalRead(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED); } @@ -81,6 +89,7 @@ public void testTxReadPessimisticReadCommitted() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed */ + @Test public void testTxReadPessimisticRepeatableRead() throws IgniteCheckedException { checkTransactionalRead(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ); } @@ -88,6 +97,7 @@ public void testTxReadPessimisticRepeatableRead() throws IgniteCheckedException /** * @throws IgniteCheckedException If failed */ + @Test public void testTxReadPessimisticSerializable() throws IgniteCheckedException { checkTransactionalRead(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE); } @@ -135,4 +145,4 @@ protected void checkTransactionalRead(TransactionConcurrency concurrency, Transa @Override protected int gridCount() { return 1; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractUsersAffinityMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractUsersAffinityMapperSelfTest.java index 37355f77ef688..e0b20720aed28 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractUsersAffinityMapperSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractUsersAffinityMapperSelfTest.java @@ -32,23 +32,21 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.GridArgumentCheck; import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; /** * Test affinity mapper. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractUsersAffinityMapperSelfTest extends GridCommonAbstractTest { /** */ private static final int KEY_CNT = 1000; - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ public static final AffinityKeyMapper AFFINITY_MAPPER = new UsersAffinityKeyMapper(); @@ -79,12 +77,6 @@ protected GridCacheAbstractUsersAffinityMapperSelfTest() { cfg.setCacheConfiguration(cacheCfg); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - return cfg; } @@ -106,6 +98,7 @@ protected GridCacheAbstractUsersAffinityMapperSelfTest() { /** * @throws Exception If failed. */ + @Test public void testAffinityMapper() throws Exception { IgniteCache cache = startGrid(0).cache(DEFAULT_CACHE_NAME); @@ -212,4 +205,4 @@ private static class NoopClosure implements IgniteRunnable { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityApiSelfTest.java index c1465250d7397..f5686896c5414 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityApiSelfTest.java @@ -35,6 +35,9 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -42,6 +45,7 @@ /** * Affinity API tests. */ +@RunWith(JUnit4.class) public class GridCacheAffinityApiSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int GRID_CNT = 4; @@ -85,6 +89,7 @@ private AffinityKeyMapper affinityMapper() { * * @throws Exception If failed. */ + @Test public void testPartitions() throws Exception { assertEquals(affinity().partitions(), grid(0).affinity(DEFAULT_CACHE_NAME).partitions()); } @@ -94,6 +99,7 @@ public void testPartitions() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartition() throws Exception { String key = "key"; @@ -105,6 +111,7 @@ public void testPartition() throws Exception { * * @throws Exception If failed. */ + @Test public void testPrimaryPartitionsOneNode() throws Exception { AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(new ArrayList<>(grid(0).cluster().nodes()), null, null, @@ -134,6 +141,7 @@ public void testPrimaryPartitionsOneNode() throws Exception { * * @throws Exception If failed. */ + @Test public void testPrimaryPartitions() throws Exception { // Pick 2 nodes and create a projection over them. ClusterNode n0 = grid(0).localNode(); @@ -171,6 +179,7 @@ public void testPrimaryPartitions() throws Exception { * * @throws Exception If failed. */ + @Test public void testBackupPartitions() throws Exception { // Pick 2 nodes and create a projection over them. ClusterNode n0 = grid(0).localNode(); @@ -206,6 +215,7 @@ public void testBackupPartitions() throws Exception { * * @throws Exception If failed. */ + @Test public void testAllPartitions() throws Exception { // Pick 2 nodes and create a projection over them. ClusterNode n0 = grid(0).localNode(); @@ -234,6 +244,7 @@ public void testAllPartitions() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapPartitionToNode() throws Exception { int part = RND.nextInt(affinity().partitions()); @@ -253,6 +264,7 @@ public void testMapPartitionToNode() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapPartitionsToNode() throws Exception { Map map = grid(0).affinity(DEFAULT_CACHE_NAME).mapPartitionsToNodes(F.asList(0, 1, 5, 19, 12)); @@ -273,6 +285,7 @@ public void testMapPartitionsToNode() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapPartitionsToNodeArray() throws Exception { Map map = grid(0).affinity(DEFAULT_CACHE_NAME).mapPartitionsToNodes(F.asList(0, 1, 5, 19, 12)); @@ -293,6 +306,7 @@ public void testMapPartitionsToNodeArray() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapPartitionsToNodeCollection() throws Exception { Collection parts = new LinkedList<>(); @@ -337,6 +351,7 @@ private Iterable nodes(List> assignment, Affinity /** * @throws Exception If failed. */ + @Test public void testPartitionWithAffinityMapper() throws Exception { AffinityKey key = new AffinityKey<>(1, 2); @@ -345,4 +360,4 @@ public void testPartitionWithAffinityMapper() throws Exception { for (int i = 0; i < gridCount(); i++) assertEquals(expPart, grid(i).affinity(DEFAULT_CACHE_NAME).partition(key)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java index 09fc296344331..272e3e2a38a78 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.cache.affinity.AffinityKeyMapper; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test affinity mapper. */ +@RunWith(JUnit4.class) public class GridCacheAffinityMapperSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -37,6 +41,7 @@ public class GridCacheAffinityMapperSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testMethodAffinityMapper() { AffinityKeyMapper mapper = new GridCacheDefaultAffinityKeyMapper(); @@ -63,6 +68,7 @@ public void testMethodAffinityMapper() { /** * */ + @Test public void testFieldAffinityMapper() { AffinityKeyMapper mapper = new GridCacheDefaultAffinityKeyMapper(); @@ -89,6 +95,7 @@ public void testFieldAffinityMapper() { /** * */ + @Test public void testFieldAffinityMapperWithWrongClass() { AffinityKeyMapper mapper = new GridCacheDefaultAffinityKeyMapper(); @@ -143,4 +150,4 @@ public Object affinityKey() { return affKey; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java index ddb38e0520c8b..a9f9e11c117a1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java @@ -32,12 +32,12 @@ import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.JobContextResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -45,6 +45,7 @@ /** * Affinity routing tests. */ +@RunWith(JUnit4.class) public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 4; @@ -58,9 +59,6 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest { /** */ private static final int MAX_FAILOVER_ATTEMPTS = 5; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * Constructs test. */ @@ -72,12 +70,6 @@ public GridCacheAffinityRoutingSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi(); failSpi.setMaximumFailoverAttempts(MAX_FAILOVER_ATTEMPTS); cfg.setFailoverSpi(failSpi); @@ -129,6 +121,7 @@ public GridCacheAffinityRoutingSelfTest() { * * @throws Exception If failed. */ + @Test public void testAffinityRun() throws Exception { for (int i = 0; i < KEY_CNT; i++) grid(0).compute().affinityRun(NON_DFLT_CACHE_NAME, i, new CheckRunnable(i, i)); @@ -137,6 +130,7 @@ public void testAffinityRun() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityCallRestartFails() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -150,6 +144,7 @@ public void testAffinityCallRestartFails() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityCallRestart() throws Exception { assertEquals(MAX_FAILOVER_ATTEMPTS, grid(0).compute().affinityCall(NON_DFLT_CACHE_NAME, "key", @@ -159,6 +154,7 @@ public void testAffinityCallRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityRunRestartFails() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -172,6 +168,7 @@ public void testAffinityRunRestartFails() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityRunRestart() throws Exception { grid(0).compute().affinityRun(NON_DFLT_CACHE_NAME, "key", new FailedRunnable("key", MAX_FAILOVER_ATTEMPTS)); } @@ -181,6 +178,7 @@ public void testAffinityRunRestart() throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinityRunComplexKey() throws Exception { for (int i = 0; i < KEY_CNT; i++) { AffinityTestKey key = new AffinityTestKey(i); @@ -195,6 +193,7 @@ public void testAffinityRunComplexKey() throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinityCall() throws Exception { for (int i = 0; i < KEY_CNT; i++) grid(0).compute().affinityCall(NON_DFLT_CACHE_NAME, i, new CheckCallable(i, i)); @@ -205,6 +204,7 @@ public void testAffinityCall() throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinityCallComplexKey() throws Exception { for (int i = 0; i < KEY_CNT; i++) { final AffinityTestKey key = new AffinityTestKey(i); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAsyncOperationsLimitSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAsyncOperationsLimitSelfTest.java index cebab2f45a99e..fad6806dfe5c2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAsyncOperationsLimitSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAsyncOperationsLimitSelfTest.java @@ -22,10 +22,14 @@ import org.apache.ignite.internal.util.GridAtomicInteger; import org.apache.ignite.internal.util.typedef.CI1; import org.apache.ignite.lang.IgniteFuture; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks that number of concurrent asynchronous operations is limited when configuration parameter is set. */ +@RunWith(JUnit4.class) public class GridCacheAsyncOperationsLimitSelfTest extends GridCacheAbstractSelfTest { /** */ public static final int MAX_CONCURRENT_ASYNC_OPS = 50; @@ -47,6 +51,7 @@ public class GridCacheAsyncOperationsLimitSelfTest extends GridCacheAbstractSelf /** * @throws Exception If failed. */ + @Test public void testAsyncOps() throws Exception { final AtomicInteger cnt = new AtomicInteger(); final GridAtomicInteger max = new GridAtomicInteger(); @@ -70,4 +75,4 @@ public void testAsyncOps() throws Exception { assertTrue("Maximum number of permits exceeded: " + max.get(), max.get() <= 51); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicEntryProcessorDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicEntryProcessorDeploymentSelfTest.java index 4f513b3845668..729fcc7f0b86c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicEntryProcessorDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicEntryProcessorDeploymentSelfTest.java @@ -27,11 +27,12 @@ import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -41,10 +42,8 @@ /** * Cache EntryProcessor + Deployment. */ +@RunWith(JUnit4.class) public class GridCacheAtomicEntryProcessorDeploymentSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Test value. */ protected static String TEST_VALUE = "org.apache.ignite.tests.p2p.CacheDeploymentTestValue"; @@ -54,6 +53,14 @@ public class GridCacheAtomicEntryProcessorDeploymentSelfTest extends GridCommonA /** */ protected boolean clientMode; + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) { + assert atomicityMode() != ATOMIC; + + fail("https://issues.apache.org/jira/browse/IGNITE-10359"); + } + } /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -68,12 +75,6 @@ public class GridCacheAtomicEntryProcessorDeploymentSelfTest extends GridCommonA cfg.setCacheConfiguration(cacheConfiguration()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(null); return cfg; @@ -119,6 +120,7 @@ protected CacheAtomicityMode atomicityMode() { /** * @throws Exception In case of error. */ + @Test public void testInvokeDeployment() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -128,6 +130,7 @@ public void testInvokeDeployment() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testInvokeDeployment2() throws Exception { depMode = DeploymentMode.SHARED; @@ -137,6 +140,7 @@ public void testInvokeDeployment2() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testInvokeAllDeployment() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -146,6 +150,7 @@ public void testInvokeAllDeployment() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testInvokeAllDeployment2() throws Exception { depMode = DeploymentMode.SHARED; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java index ca94c7f60137d..c45490a03c4b4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java @@ -35,9 +35,10 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -45,10 +46,8 @@ /** * Tests messages being sent between nodes in ATOMIC mode. */ +@RunWith(JUnit4.class) public class GridCacheAtomicMessageCountSelfTest extends GridCommonAbstractTest { - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Starting grid index. */ private int idx; @@ -59,12 +58,7 @@ public class GridCacheAtomicMessageCountSelfTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setForceServerMode(true); - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); CacheConfiguration cCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -87,6 +81,7 @@ public class GridCacheAtomicMessageCountSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testPartitioned() throws Exception { checkMessages(false); } @@ -94,6 +89,7 @@ public void testPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClient() throws Exception { checkMessages(true); } @@ -203,4 +199,4 @@ public void resetCount() { cntMap.clear(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java index f766d01517d65..03e8e6817553b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java @@ -38,8 +38,12 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestThread; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVTS_CACHE; @@ -50,6 +54,7 @@ * Test cases for multi-threaded tests. */ @SuppressWarnings("LockAcquiredButNotSafelyReleased") +@RunWith(JUnit4.class) public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTest { /** Grid. */ private Ignite ignite; @@ -88,7 +93,10 @@ protected GridCacheBasicApiAbstractTest() { * * @throws Exception If test failed. */ + @Test public void testBasicLock() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); Lock lock = cache.lock(1); @@ -105,7 +113,10 @@ public void testBasicLock() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testSingleLockReentry() throws IgniteCheckedException { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); Lock lock = cache.lock(1); @@ -133,7 +144,10 @@ public void testSingleLockReentry() throws IgniteCheckedException { * * @throws Exception If test failed. */ + @Test public void testReentry() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); Lock lock = cache.lock(1); @@ -172,7 +186,10 @@ public void testReentry() throws Exception { /** * */ + @Test public void testInterruptLock() throws InterruptedException { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + final IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); final Lock lock = cache.lock(1); @@ -216,7 +233,10 @@ public void testInterruptLock() throws InterruptedException { /** * */ + @Test public void testInterruptLockWithTimeout() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + final IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); startGrid(1); @@ -275,7 +295,10 @@ public void testInterruptLockWithTimeout() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testManyLockReentries() throws IgniteCheckedException { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); Integer key = 1; @@ -318,7 +341,10 @@ public void testManyLockReentries() throws IgniteCheckedException { /** * @throws Exception If test failed. */ + @Test public void testLockMultithreaded() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + final IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); final CountDownLatch l1 = new CountDownLatch(1); @@ -436,7 +462,11 @@ public void testLockMultithreaded() throws Exception { * * @throws Exception If error occur. */ + @Test public void testBasicOps() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); CountDownLatch latch = new CountDownLatch(1); @@ -497,7 +527,11 @@ public void testBasicOps() throws Exception { /** * @throws Exception If error occur. */ + @Test public void testBasicOpsWithReentry() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); int key = (int)System.currentTimeMillis(); @@ -569,7 +603,10 @@ public void testBasicOpsWithReentry() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMultiLocks() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); Collection keys = Arrays.asList(1, 2, 3); @@ -600,6 +637,7 @@ public void testMultiLocks() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testGetPutRemove() throws IgniteCheckedException { IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -624,7 +662,12 @@ public void testGetPutRemove() throws IgniteCheckedException { * * @throws Exception In case of error. */ + @Test public void testPutWithExpiration() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); CacheEventListener lsnr = new CacheEventListener(new CountDownLatch(1)); @@ -699,4 +742,4 @@ void await() throws InterruptedException { return true; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreAbstractTest.java index 84ce5385256c3..5537e9b73ac9b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreAbstractTest.java @@ -30,12 +30,13 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.P2; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -46,13 +47,18 @@ /** * Basic store test. */ +@RunWith(JUnit4.class) public abstract class GridCacheBasicStoreAbstractTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache store. */ private static final GridCacheTestStore store = new GridCacheTestStore(); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** * */ @@ -80,12 +86,6 @@ protected GridCacheBasicStoreAbstractTest() { @Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(cacheMode()); @@ -113,6 +113,7 @@ protected CacheAtomicityMode atomicityMode() { /** * @throws IgniteCheckedException If failed. */ + @Test public void testNotExistingKeys() throws IgniteCheckedException { IgniteCache cache = jcache(); Map map = store.getMap(); @@ -137,6 +138,7 @@ public void testNotExistingKeys() throws IgniteCheckedException { } /** @throws Exception If test fails. */ + @Test public void testWriteThrough() throws Exception { IgniteCache cache = jcache(); @@ -208,6 +210,7 @@ public void testWriteThrough() throws Exception { } /** @throws Exception If test failed. */ + @Test public void testReadThrough() throws Exception { IgniteCache cache = jcache(); @@ -301,6 +304,7 @@ public void testReadThrough() throws Exception { } /** @throws Exception If test failed. */ + @Test public void testLoadCache() throws Exception { IgniteCache cache = jcache(); @@ -331,6 +335,7 @@ public void testLoadCache() throws Exception { } /** @throws Exception If test failed. */ + @Test public void testLoadCacheWithPredicate() throws Exception { IgniteCache cache = jcache(); @@ -368,6 +373,7 @@ public void testLoadCacheWithPredicate() throws Exception { } /** @throws Exception If test failed. */ + @Test public void testReloadCache() throws Exception { IgniteCache cache = jcache(); @@ -438,6 +444,7 @@ public void testReloadCache() throws Exception { } /** @throws Exception If test failed. */ + @Test public void testReloadAll() throws Exception { IgniteCache cache = jcache(); @@ -501,7 +508,7 @@ public void testReloadAll() throws Exception { } /** @throws Exception If test failed. */ - @SuppressWarnings("StringEquality") + @Test public void testReload() throws Exception { IgniteCache cache = jcache(); @@ -587,4 +594,4 @@ private void checkLastMethod(@Nullable String mtd) { assert lastMtd.equals(mtd) : "Last method does not match [expected=" + mtd + ", lastMtd=" + lastMtd + ']'; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java index 22b02dc51ad97..a65a0c69cb88f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java @@ -29,12 +29,16 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * Basic store test. */ +@RunWith(JUnit4.class) public abstract class GridCacheBasicStoreMultithreadedAbstractTest extends GridCommonAbstractTest { /** Cache store. */ private CacheStore store; @@ -90,6 +94,7 @@ protected GridCacheBasicStoreMultithreadedAbstractTest() { /** * @throws Exception If failed. */ + @Test public void testConcurrentGet() throws Exception { final AtomicInteger cntr = new AtomicInteger(); @@ -129,4 +134,4 @@ public void testConcurrentGet() throws Exception { assertEquals(1, cntr.get()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java index cae58e1816e4d..756fe0051df95 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllSelfTest.java @@ -25,10 +25,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -38,6 +39,7 @@ * Test {@link IgniteCache#clear()} operation in multinode environment with nodes * having caches with different names. */ +@RunWith(JUnit4.class) public class GridCacheClearAllSelfTest extends GridCommonAbstractTest { /** Grid nodes count. */ private static final int GRID_CNT = 3; @@ -57,15 +59,20 @@ public class GridCacheClearAllSelfTest extends GridCommonAbstractTest { /** Test attribute name. */ private static final String TEST_ATTRIBUTE = "TestAttribute"; - /** VM IP finder for TCP discovery SPI. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name which will be passed to grid configuration. */ private CacheMode cacheMode = PARTITIONED; /** Cache mode which will be passed to grid configuration. */ private String cacheName = CACHE_NAME; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-7952"); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -84,12 +91,6 @@ public class GridCacheClearAllSelfTest extends GridCommonAbstractTest { cfg.setUserAttributes(F.asMap(TEST_ATTRIBUTE, cacheName)); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - return cfg; } @@ -122,6 +123,7 @@ private void startNodes() throws Exception { * * @throws Exception In case of exception. */ + @Test public void testGlobalClearAllPartitioned() throws Exception { cacheMode = PARTITIONED; @@ -135,6 +137,7 @@ public void testGlobalClearAllPartitioned() throws Exception { * * @throws Exception In case of exception. */ + @Test public void testGlobalClearAllReplicated() throws Exception { cacheMode = REPLICATED; @@ -195,4 +198,4 @@ private AttributeFilter(String attrValue) { return F.eq(attrValue, clusterNode.attribute(TEST_ATTRIBUTE)); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearLocallySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearLocallySelfTest.java index 82c4659a74aa4..f3c669e4e7047 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearLocallySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearLocallySelfTest.java @@ -27,11 +27,11 @@ import org.apache.ignite.internal.IgniteNodeAttributes; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -43,6 +43,7 @@ /** * Test {@link IgniteCache#localClearAll(java.util.Set)} operations in multinode environment with nodes having caches with different names. */ +@RunWith(JUnit4.class) public class GridCacheClearLocallySelfTest extends GridCommonAbstractTest { /** Local cache. */ private static final String CACHE_LOCAL = "cache_local"; @@ -59,9 +60,6 @@ public class GridCacheClearLocallySelfTest extends GridCommonAbstractTest { /** Grid nodes count. */ private static final int GRID_CNT = 3; - /** VM IP finder for TCP discovery SPI. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Local caches. */ private IgniteCache[] cachesLoc; @@ -116,12 +114,6 @@ public class GridCacheClearLocallySelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfgLoc, ccfgPartitioned, ccfgColocated, ccfgReplicated); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - return cfg; } @@ -170,6 +162,7 @@ private void startUp() throws Exception { * * @throws Exception If failed. */ + @Test public void testLocalNoSplit() throws Exception { test(Mode.TEST_LOCAL, CLEAR_ALL_SPLIT_THRESHOLD / 2); } @@ -179,6 +172,7 @@ public void testLocalNoSplit() throws Exception { * * @throws Exception If failed. */ + @Test public void testLocalSplit() throws Exception { test(Mode.TEST_LOCAL, CLEAR_ALL_SPLIT_THRESHOLD + 1); } @@ -188,6 +182,7 @@ public void testLocalSplit() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitionedNoSplit() throws Exception { test(Mode.TEST_PARTITIONED, CLEAR_ALL_SPLIT_THRESHOLD / 2); } @@ -197,6 +192,7 @@ public void testPartitionedNoSplit() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitionedSplit() throws Exception { test(Mode.TEST_PARTITIONED, CLEAR_ALL_SPLIT_THRESHOLD + 1); } @@ -206,6 +202,7 @@ public void testPartitionedSplit() throws Exception { * * @throws Exception If failed. */ + @Test public void testColocatedNoSplit() throws Exception { test(Mode.TEST_COLOCATED, CLEAR_ALL_SPLIT_THRESHOLD / 2); } @@ -215,6 +212,7 @@ public void testColocatedNoSplit() throws Exception { * * @throws Exception If failed. */ + @Test public void testColocatedSplit() throws Exception { test(Mode.TEST_COLOCATED, CLEAR_ALL_SPLIT_THRESHOLD + 1); } @@ -224,6 +222,7 @@ public void testColocatedSplit() throws Exception { * * @throws Exception If failed. */ + @Test public void testReplicatedNoSplit() throws Exception { test(Mode.TEST_REPLICATED, CLEAR_ALL_SPLIT_THRESHOLD / 2); } @@ -233,6 +232,7 @@ public void testReplicatedNoSplit() throws Exception { * * @throws Exception If failed. */ + @Test public void testReplicatedSplit() throws Exception { test(Mode.TEST_REPLICATED, CLEAR_ALL_SPLIT_THRESHOLD + 1); } @@ -378,4 +378,4 @@ private AttributeFilter(String... attrs) { return false; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java index 81c44134b6d90..8a24410032a45 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearSelfTest.java @@ -25,37 +25,21 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for cache clear. */ +@RunWith(JUnit4.class) public class GridCacheClearSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(3); @@ -74,6 +58,7 @@ public class GridCacheClearSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testClearPartitioned() throws Exception { testClear(CacheMode.PARTITIONED, false, null); } @@ -81,6 +66,7 @@ public void testClearPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearPartitionedNear() throws Exception { testClear(CacheMode.PARTITIONED, true, null); } @@ -88,6 +74,7 @@ public void testClearPartitionedNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearReplicated() throws Exception { testClear(CacheMode.REPLICATED, false, null); } @@ -95,6 +82,7 @@ public void testClearReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearReplicatedNear() throws Exception { testClear(CacheMode.REPLICATED, true, null); } @@ -102,6 +90,7 @@ public void testClearReplicatedNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearKeyPartitioned() throws Exception { testClear(CacheMode.PARTITIONED, false, Collections.singleton(3)); } @@ -109,6 +98,7 @@ public void testClearKeyPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearKeyPartitionedNear() throws Exception { testClear(CacheMode.PARTITIONED, true, Collections.singleton(3)); } @@ -116,6 +106,7 @@ public void testClearKeyPartitionedNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearKeyReplicated() throws Exception { testClear(CacheMode.REPLICATED, false, Collections.singleton(3)); } @@ -123,6 +114,7 @@ public void testClearKeyReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearKeyReplicatedNear() throws Exception { testClear(CacheMode.REPLICATED, true, Collections.singleton(3)); } @@ -130,6 +122,7 @@ public void testClearKeyReplicatedNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearKeysPartitioned() throws Exception { testClear(CacheMode.PARTITIONED, false, F.asSet(2, 6, 9)); } @@ -137,6 +130,7 @@ public void testClearKeysPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearKeysPartitionedNear() throws Exception { testClear(CacheMode.PARTITIONED, true, F.asSet(2, 6, 9)); } @@ -144,6 +138,7 @@ public void testClearKeysPartitionedNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearKeysReplicated() throws Exception { testClear(CacheMode.REPLICATED, false, F.asSet(2, 6, 9)); } @@ -151,6 +146,7 @@ public void testClearKeysReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClearKeysReplicatedNear() throws Exception { testClear(CacheMode.REPLICATED, true, F.asSet(2, 6, 9)); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentGetCacheOnClientTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentGetCacheOnClientTest.java index fb83405f08e7c..6d51de76152ad 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentGetCacheOnClientTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentGetCacheOnClientTest.java @@ -23,33 +23,22 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.runAsync; /** * */ +@RunWith(JUnit4.class) public class GridCacheConcurrentGetCacheOnClientTest extends GridCommonAbstractTest{ - /** Ip finder. */ - private final static TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** - * @param gridName Grid name. - */ - @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception { - final IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** * */ + @Test public void test() throws Exception { IgniteConfiguration node1cfg = getConfiguration("node1"); IgniteConfiguration node2cfg = getConfiguration("node2"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java index ae1f8224dc23a..1f08236094307 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java @@ -27,10 +27,10 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -38,10 +38,8 @@ /** * Grid cache concurrent hash map self test. */ +@RunWith(JUnit4.class) public class GridCacheConcurrentMapSelfTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -51,12 +49,6 @@ public class GridCacheConcurrentMapSelfTest extends GridCommonAbstractTest { cc.setCacheMode(LOCAL); cc.setWriteSynchronizationMode(FULL_SYNC); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cc); return cfg; @@ -75,6 +67,7 @@ public class GridCacheConcurrentMapSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRehash() throws Exception { IgniteCache c = grid().cache(DEFAULT_CACHE_NAME); @@ -106,6 +99,7 @@ public void testRehash() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRehashRandom() throws Exception { IgniteCache c = grid().cache(DEFAULT_CACHE_NAME); @@ -145,6 +139,7 @@ public void testRehashRandom() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRehashMultithreaded1() throws Exception { final AtomicInteger tidGen = new AtomicInteger(); @@ -217,6 +212,7 @@ public void testRehashMultithreaded1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRehashMultithreaded2() throws Exception { final AtomicInteger tidGen = new AtomicInteger(0); @@ -310,7 +306,7 @@ public void testRehashMultithreaded2() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("ResultOfObjectAllocationIgnored") + @Test public void testEmptyWeakIterator() throws Exception { final IgniteCache c = grid().cache(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeLoadTest.java index 0d2dc008d8946..41d536a88f0e6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeLoadTest.java @@ -67,12 +67,12 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.NONE; @@ -83,10 +83,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheConcurrentTxMultiNodeLoadTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Timers. */ private static final ConcurrentMap>> timers = new ConcurrentHashMap<>(); @@ -153,12 +151,6 @@ public class GridCacheConcurrentTxMultiNodeLoadTest extends GridCommonAbstractTe else c.setCacheConfiguration(); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - c.setPeerClassLoadingEnabled(false); return c; @@ -172,6 +164,7 @@ public class GridCacheConcurrentTxMultiNodeLoadTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testEvictions() throws Exception { try { cacheOn = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java index b0d9f0e135359..15f368fa29405 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java @@ -26,11 +26,10 @@ import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.CO; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -40,10 +39,8 @@ /** * Cache + conditional deployment test. */ +@RunWith(JUnit4.class) public class GridCacheConditionalDeploymentSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -61,12 +58,6 @@ public class GridCacheConditionalDeploymentSelfTest extends GridCommonAbstractTe cfg.setCacheConfiguration(cacheConfiguration()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -105,6 +96,7 @@ protected CacheConfiguration cacheConfiguration() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testNoDeploymentInfo() throws Exception { GridCacheIoManager ioMgr = cacheIoManager(); @@ -122,6 +114,7 @@ public void testNoDeploymentInfo() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testAddedDeploymentInfo() throws Exception { GridCacheContext ctx = cacheContext(); @@ -145,6 +138,7 @@ public void testAddedDeploymentInfo() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testAddedDeploymentInfo2() throws Exception { GridCacheContext ctx = cacheContext(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java index 3f4efc293e045..833ba5a6963ee 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java @@ -42,15 +42,16 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.lang.IgniteCallable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -65,6 +66,7 @@ * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstractTest { /** */ private boolean cacheEnabled; @@ -93,9 +95,6 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac /** */ private int backups; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -110,12 +109,6 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac cfg.setGridLogger(strLog); } - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setDeploymentMode(depMode); if (cacheEnabled) { @@ -141,6 +134,7 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testCacheUtilsCheckAttributeMismatch() throws Exception { Ignite ignite = startGrid(1); @@ -188,6 +182,7 @@ public void testCacheUtilsCheckAttributeMismatch() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNullCacheMode() throws Exception { // Grid with null cache mode. // This is a legal case. The default cache mode should be used. @@ -202,6 +197,7 @@ public void testNullCacheMode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithCacheAndWithoutCache() throws Exception { // 1st grid without cache. cacheEnabled = false; @@ -221,6 +217,7 @@ public void testWithCacheAndWithoutCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSameCacheDifferentModes() throws Exception { // 1st grid with replicated cache. cacheEnabled = true; @@ -249,6 +246,7 @@ public void testSameCacheDifferentModes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentCacheDifferentModes() throws Exception { // 1st grid with local cache. cacheEnabled = true; @@ -286,6 +284,7 @@ public void testDifferentCacheDifferentModes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentDeploymentModes() throws Exception { // 1st grid with SHARED mode. cacheEnabled = true; @@ -311,6 +310,7 @@ public void testDifferentDeploymentModes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentAffinities() throws Exception { cacheMode = PARTITIONED; @@ -335,6 +335,7 @@ public void testDifferentAffinities() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentPreloadModes() throws Exception { checkSecondGridStartFails( new C1() { @@ -357,6 +358,7 @@ public void testDifferentPreloadModes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentEvictionEnabled() throws Exception { checkSecondGridStartFails( new C1() { @@ -379,6 +381,7 @@ public void testDifferentEvictionEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentEvictionPolicyEnabled() throws Exception { checkSecondGridStartFails( new C1() { @@ -401,6 +404,7 @@ public void testDifferentEvictionPolicyEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentEvictionPolicies() throws Exception { checkSecondGridStartFails( new C1() { @@ -425,6 +429,7 @@ public void testDifferentEvictionPolicies() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentEvictionPolicyFactories() throws Exception { checkSecondGridStartFails( new C1() { @@ -449,6 +454,7 @@ public void testDifferentEvictionPolicyFactories() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentEvictionFilters() throws Exception { checkSecondGridStartFails( new C1() { @@ -471,6 +477,7 @@ public void testDifferentEvictionFilters() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentAffinityMappers() throws Exception { checkSecondGridStartFails( new C1() { @@ -493,6 +500,7 @@ public void testDifferentAffinityMappers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentAtomicity() throws Exception { cacheMode = PARTITIONED; @@ -519,6 +527,34 @@ public void testDifferentAtomicity() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testDifferentTxAtomicity() throws Exception { + cacheMode = PARTITIONED; + + checkSecondGridStartFails( + new C1() { + /** {@inheritDoc} */ + @Override public Void apply(CacheConfiguration cfg) { + cfg.setNearConfiguration(null); + cfg.setAtomicityMode(TRANSACTIONAL); + return null; + } + }, + new C1() { + /** {@inheritDoc} */ + @Override public Void apply(CacheConfiguration cfg) { + cfg.setNearConfiguration(null); + cfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + return null; + } + } + ); + } + + /** + * @throws Exception If failed. + */ + @Test public void testDifferentSynchronization() throws Exception { cacheMode = PARTITIONED; @@ -543,6 +579,7 @@ public void testDifferentSynchronization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityFunctionConsistency() throws Exception { cacheEnabled = true; cacheMode = PARTITIONED; @@ -589,6 +626,7 @@ public void testAffinityFunctionConsistency() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAttributesWarnings() throws Exception { cacheEnabled = true; @@ -624,6 +662,7 @@ public void testAttributesWarnings() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionedOnlyAttributesIgnoredForReplicated() throws Exception { cacheEnabled = true; @@ -663,6 +702,7 @@ public void testPartitionedOnlyAttributesIgnoredForReplicated() throws Exception /** * @throws Exception If failed. */ + @Test public void testIgnoreMismatchForLocalCaches() throws Exception { cacheEnabled = true; @@ -710,6 +750,7 @@ public void testIgnoreMismatchForLocalCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStoreCheckAtomic() throws Exception { cacheEnabled = true; @@ -755,6 +796,7 @@ public void testStoreCheckAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStoreCheckTransactional() throws Exception { cacheEnabled = true; @@ -802,6 +844,7 @@ public void testStoreCheckTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityForReplicatedCache() throws Exception { cacheEnabled = true; @@ -822,6 +865,7 @@ public void testAffinityForReplicatedCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentInterceptors() throws Exception { cacheMode = PARTITIONED; @@ -906,4 +950,4 @@ private static class TestCacheInterceptor extends CacheInterceptorAdapter implem private static class TestCacheDefaultAffinityKeyMapper extends GridCacheDefaultAffinityKeyMapper { // No-op, just different class. } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java index 7b793b78d8138..81452980f2f1c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java @@ -21,10 +21,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -35,6 +35,7 @@ /** * Attribute validation self test. */ +@RunWith(JUnit4.class) public class GridCacheConfigurationValidationSelfTest extends GridCommonAbstractTest { /** */ private static final String NON_DFLT_CACHE_NAME = "non-dflt-cache"; @@ -65,9 +66,6 @@ public class GridCacheConfigurationValidationSelfTest extends GridCommonAbstract private static final String RESERVED_FOR_DATASTRUCTURES_CACHE_GROUP_NAME_IGNITE_INSTANCE_NAME = "reservedForDsCacheGroupNameCheckFails"; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * Constructs test. */ @@ -79,12 +77,6 @@ public GridCacheConfigurationValidationSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - // Default cache config. CacheConfiguration dfltCacheCfg = defaultCacheConfiguration(); @@ -138,6 +130,7 @@ else if (igniteInstanceName.contains(DUP_DFLT_CACHES_IGNITE_INSTANCE_NAME)) * * @throws Exception If failed. */ + @Test public void testDuplicateCacheConfigurations() throws Exception { // This grid should not start. startInvalidGrid(DUP_CACHES_IGNITE_INSTANCE_NAME); @@ -149,6 +142,7 @@ public void testDuplicateCacheConfigurations() throws Exception { /** * @throws Exception If fails. */ + @Test public void testCacheAttributesValidation() throws Exception { try { startGrid(0); @@ -215,4 +209,4 @@ public TestRendezvousAffinityFunction() { private static class TestCacheDefaultAffinityKeyMapper extends GridCacheDefaultAffinityKeyMapper { // No-op. Just to have another class name. } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDaemonNodeAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDaemonNodeAbstractSelfTest.java index 807725159eebf..c55187eead73c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDaemonNodeAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDaemonNodeAbstractSelfTest.java @@ -27,12 +27,12 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -41,10 +41,8 @@ /** * Test cache operations with daemon node. */ +@RunWith(JUnit4.class) public abstract class GridCacheDaemonNodeAbstractSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Daemon flag. */ protected boolean daemon; @@ -61,12 +59,6 @@ public abstract class GridCacheDaemonNodeAbstractSelfTest extends GridCommonAbst c.setDaemon(daemon); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - c.setConnectorConfiguration(null); CacheConfiguration cc = defaultCacheConfiguration(); @@ -90,6 +82,7 @@ public abstract class GridCacheDaemonNodeAbstractSelfTest extends GridCommonAbst /** * @throws Exception If failed. */ + @Test public void testImplicit() throws Exception { try { startGridsMultiThreaded(3); @@ -121,6 +114,7 @@ public void testImplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExplicit() throws Exception { try { startGridsMultiThreaded(3); @@ -162,6 +156,7 @@ public void testExplicit() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapKeyToNode() throws Exception { try { // Start normal nodes. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java index ff3ab362fe726..3396932188129 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java @@ -30,10 +30,10 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -45,10 +45,8 @@ /** * Cache + Deployment test. */ +@RunWith(JUnit4.class) public class GridCacheDeploymentSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Name for Ignite instance without cache. */ protected static final String IGNITE_INSTANCE_NAME = "grid-no-cache"; @@ -84,12 +82,6 @@ public class GridCacheDeploymentSelfTest extends GridCommonAbstractTest { else cfg.setCacheConfiguration(cacheConfiguration()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(null); return cfg; @@ -124,6 +116,7 @@ protected boolean isCacheUndeployed(Ignite g) { /** @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testDeployment() throws Exception { try { depMode = CONTINUOUS; @@ -150,6 +143,7 @@ public void testDeployment() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testDeployment2() throws Exception { try { depMode = CONTINUOUS; @@ -185,6 +179,7 @@ public void testDeployment2() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testDeployment3() throws Exception { try { depMode = SHARED; @@ -231,12 +226,14 @@ public void testDeployment3() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testDeployment4() throws Exception { doDeployment4(false); } /** @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testDeployment4BackupLeavesGrid() throws Exception { doDeployment4(true); } @@ -288,6 +285,7 @@ private void doDeployment4(boolean backupLeavesGrid) throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testDeployment5() throws Exception { ClassLoader ldr = getExternalClassLoader(); @@ -345,6 +343,7 @@ public void testDeployment5() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testDeployment6() throws Exception { try { depMode = SHARED; @@ -378,6 +377,7 @@ public void testDeployment6() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testDeployment7() throws Exception { try { depMode = SHARED; @@ -410,6 +410,7 @@ public void testDeployment7() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedDeploymentPreloading() throws Exception { ClassLoader ldr = getExternalClassLoader(); @@ -434,6 +435,7 @@ public void testPartitionedDeploymentPreloading() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheUndeploymentSharedMode() throws Exception { testCacheUndeployment(SHARED); } @@ -441,6 +443,7 @@ public void testCacheUndeploymentSharedMode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheUndeploymentContMode() throws Exception { testCacheUndeployment(CONTINUOUS); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java index 016f3a099afc5..e23ff3f21e74c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java @@ -35,10 +35,11 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.MarshallerContext; import org.apache.ignite.marshaller.jdk.JdkMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -48,10 +49,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Null reference size (optimized marshaller writes one byte for null reference). */ private static final int NULL_REF_SIZE = 1; @@ -83,12 +82,6 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMarshaller(createMarshaller()); return cfg; @@ -115,12 +108,26 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { startGrids(2); } + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + grid(0).destroyCache(DEFAULT_CACHE_NAME); + + super.afterTest(); + } + /** * @param nearEnabled {@code True} if near cache should be enabled. * @param mode Cache mode. * @return Created cache. */ - private IgniteCache testCache(boolean nearEnabled, CacheMode mode) { + private IgniteCache createCache(boolean nearEnabled, CacheMode mode) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(mode); @@ -176,8 +183,11 @@ protected Marshaller createMarshaller() throws IgniteCheckedException { } /** @throws Exception If failed. */ + @Test public void testLocal() throws Exception { - IgniteCache cache = testCache(false, LOCAL); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + IgniteCache cache = createCache(false, LOCAL); try { cache.put(1, new Value(new byte[1024])); @@ -199,8 +209,9 @@ public void testLocal() throws Exception { } /** @throws Exception If failed. */ + @Test public void testReplicated() throws Exception { - IgniteCache cache = testCache(false, REPLICATED); + IgniteCache cache = createCache(false, REPLICATED); try { cache.put(1, new Value(new byte[1024])); @@ -222,8 +233,11 @@ public void testReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedNearEnabled() throws Exception { - IgniteCache cache = testCache(true, PARTITIONED); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + IgniteCache cache = createCache(true, PARTITIONED); try { int[] keys = new int[3]; @@ -274,8 +288,9 @@ public void testPartitionedNearEnabled() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedNearDisabled() throws Exception { - IgniteCache cache = testCache(false, PARTITIONED); + IgniteCache cache = createCache(false, PARTITIONED); try { int[] keys = new int[3]; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryVersionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryVersionSelfTest.java index 9e933be2acfca..a692455b4177c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryVersionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryVersionSelfTest.java @@ -24,13 +24,14 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager.TOP_VER_BASE_TIME; @@ -38,10 +39,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheEntryVersionSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Atomicity mode. */ private CacheAtomicityMode atomicityMode; @@ -49,10 +48,6 @@ public class GridCacheEntryVersionSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(PARTITIONED); @@ -62,14 +57,13 @@ public class GridCacheEntryVersionSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfg); - cfg.setDiscoverySpi(discoSpi); - return cfg; } /** * @throws Exception If failed. */ + @Test public void testVersionAtomic() throws Exception { atomicityMode = ATOMIC; @@ -79,12 +73,23 @@ public void testVersionAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersionTransactional() throws Exception { atomicityMode = TRANSACTIONAL; checkVersion(); } + /** + * @throws Exception If failed. + */ + @Test + public void testVersionMvccTx() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + checkVersion(); + } + /** * @throws Exception If failed. */ @@ -155,4 +160,4 @@ private void checkVersion() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionEventAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionEventAbstractTest.java index 554a7a9ed3db4..6cc11f9a0c107 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionEventAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionEventAbstractTest.java @@ -32,10 +32,11 @@ import org.apache.ignite.events.Event; import org.apache.ignite.events.EventType; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_ENTRY_EVICTED; import static org.apache.ignite.events.EventType.EVT_JOB_MAPPED; @@ -45,9 +46,15 @@ /** * Eviction event self test. */ +@RunWith(JUnit4.class) public abstract class GridCacheEvictionEventAbstractTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + + super.setUp(); + } /** * @@ -60,12 +67,6 @@ protected GridCacheEvictionEventAbstractTest() { @Override protected IgniteConfiguration getConfiguration() throws Exception { IgniteConfiguration c = super.getConfiguration(); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(cacheMode()); @@ -93,6 +94,7 @@ protected GridCacheEvictionEventAbstractTest() { /** * @throws Exception If failed. */ + @Test public void testEvictionEvent() throws Exception { Ignite g = grid(); @@ -120,4 +122,4 @@ public void testEvictionEvent() throws Exception { assertTrue("Failed to wait for eviction event", latch.await(10, TimeUnit.SECONDS)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java index 9732272d5f1e1..2d70e544bf8be 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java @@ -34,7 +34,11 @@ import org.apache.ignite.internal.util.typedef.CI1; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -44,6 +48,7 @@ /** * Abstract class for cache tests. */ +@RunWith(JUnit4.class) public class GridCacheFinishPartitionsSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int GRID_CNT = 1; @@ -56,6 +61,13 @@ public class GridCacheFinishPartitionsSelfTest extends GridCacheAbstractSelfTest return GRID_CNT; } + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { grid = (IgniteKernal)grid(0); @@ -85,6 +97,7 @@ public class GridCacheFinishPartitionsSelfTest extends GridCacheAbstractSelfTest /** * @throws Exception If failed. */ + @Test public void testTxFinishPartitions() throws Exception { String key = "key"; String val = "value"; @@ -167,6 +180,7 @@ private long runTransactions(final String key, final int keyPart, final Collecti * * @throws Exception If failed. */ + @Test public void testMvccFinishPartitions() throws Exception { String key = "key"; @@ -193,6 +207,7 @@ public void testMvccFinishPartitions() throws Exception { * * @throws Exception If failed. */ + @Test public void testMvccFinishKeys() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -226,6 +241,7 @@ public void testMvccFinishKeys() throws Exception { * * @throws Exception If failed. */ + @Test public void testMvccFinishPartitionsContinuousLockAcquireRelease() throws Exception { int key = 1; @@ -330,4 +346,4 @@ private long runLock(String key, int keyPart, Collection waitParts) thr return end.get() - start; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQueryMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQueryMultithreadedSelfTest.java index 90f8d60915cd5..b993948931a7f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQueryMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQueryMultithreadedSelfTest.java @@ -28,6 +28,9 @@ import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.S; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -35,6 +38,7 @@ /** * Multithreaded reduce query tests with lots of data. */ +@RunWith(JUnit4.class) public class GridCacheFullTextQueryMultithreadedSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int GRID_CNT = 3; @@ -69,6 +73,7 @@ public class GridCacheFullTextQueryMultithreadedSelfTest extends GridCacheAbstra * @throws Exception In case of error. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testH2Text() throws Exception { int duration = 20 * 1000; final int keyCnt = 5000; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheGetAndTransformStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheGetAndTransformStoreAbstractTest.java index f140945656e26..d180b794de9a4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheGetAndTransformStoreAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheGetAndTransformStoreAbstractTest.java @@ -29,10 +29,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -41,13 +42,18 @@ /** * Basic get and transform store test. */ +@RunWith(JUnit4.class) public abstract class GridCacheGetAndTransformStoreAbstractTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache store. */ private static final GridCacheTestStore store = new GridCacheTestStore(); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** * */ @@ -75,12 +81,6 @@ protected GridCacheGetAndTransformStoreAbstractTest() { @Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(cacheMode()); @@ -108,6 +108,7 @@ protected CacheAtomicityMode atomicityMode() { /** * @throws Exception If failed. */ + @Test public void testGetAndTransform() throws Exception { final AtomicBoolean finish = new AtomicBoolean(); @@ -165,4 +166,4 @@ private static class Processor implements EntryProcessor, return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIncrementTransformTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIncrementTransformTest.java index 33b094f1f2f52..3ccb7c11eaf83 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIncrementTransformTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheIncrementTransformTest.java @@ -30,11 +30,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -44,10 +44,8 @@ /** * Tests cache in-place modification logic with iterative value increment. */ +@RunWith(JUnit4.class) public class GridCacheIncrementTransformTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of nodes to test on. */ private static final int GRID_CNT = 4; @@ -71,12 +69,6 @@ public class GridCacheIncrementTransformTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -102,6 +94,7 @@ public class GridCacheIncrementTransformTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testIncrement() throws Exception { testIncrement(false); } @@ -109,6 +102,7 @@ public void testIncrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrementRestart() throws Exception { final AtomicBoolean stop = new AtomicBoolean(); final AtomicReference error = new AtomicReference<>(); @@ -230,4 +224,4 @@ private static class Processor implements EntryProcessor> emptyFilter() { /** * @throws Exception If failed. */ + @Test public void testSmall() throws Exception { IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); @@ -135,6 +128,7 @@ public void testSmall() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLarge() throws Exception { IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); @@ -164,6 +158,7 @@ public void testLarge() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFiltered() throws Exception { IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); @@ -243,4 +238,4 @@ void reset() { i = 0; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheKeyCheckSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheKeyCheckSelfTest.java index ebb88a3a821ca..56c241e08a214 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheKeyCheckSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheKeyCheckSelfTest.java @@ -22,9 +22,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -34,10 +34,8 @@ /** * Tests for cache key check. */ +@RunWith(JUnit4.class) public class GridCacheKeyCheckSelfTest extends GridCacheAbstractSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Atomicity mode. */ private CacheAtomicityMode atomicityMode; @@ -55,12 +53,6 @@ public class GridCacheKeyCheckSelfTest extends GridCacheAbstractSelfTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCacheConfiguration(cacheConfiguration()); return cfg; @@ -84,6 +76,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testGetTransactional() throws Exception { checkGet(TRANSACTIONAL); } @@ -91,6 +84,7 @@ public void testGetTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAtomic() throws Exception { checkGet(ATOMIC); } @@ -98,6 +92,7 @@ public void testGetAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutTransactional() throws Exception { checkPut(TRANSACTIONAL); } @@ -105,6 +100,7 @@ public void testPutTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAtomic() throws Exception { checkPut(ATOMIC); } @@ -112,6 +108,7 @@ public void testPutAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveTransactional() throws Exception { checkRemove(TRANSACTIONAL); } @@ -119,6 +116,7 @@ public void testRemoveTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAtomic() throws Exception { checkRemove(ATOMIC); } @@ -204,4 +202,4 @@ public int getSomeVal() { return someVal; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java index 1fed55fafdbdd..63449f1621418 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java @@ -25,10 +25,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -38,10 +38,8 @@ /** * Leak test. */ +@RunWith(JUnit4.class) public class GridCacheLeakTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private static final String CACHE_NAME = "igfs-data"; @@ -52,12 +50,6 @@ public class GridCacheLeakTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCacheConfiguration(cacheConfiguration()); return cfg; @@ -87,6 +79,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testLeakTransactional() throws Exception { checkLeak(TRANSACTIONAL); } @@ -94,6 +87,7 @@ public void testLeakTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLeakAtomic() throws Exception { checkLeak(ATOMIC); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLifecycleAwareSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLifecycleAwareSelfTest.java index 22d94fbbc27b9..6654edc6a463b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLifecycleAwareSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLifecycleAwareSelfTest.java @@ -49,12 +49,16 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridAbstractLifecycleAwareSelfTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Test for {@link LifecycleAware} support in {@link CacheConfiguration}. */ +@RunWith(JUnit4.class) public class GridCacheLifecycleAwareSelfTest extends GridAbstractLifecycleAwareSelfTest { /** */ private static final String CACHE_NAME = "cache"; @@ -365,6 +369,7 @@ public TestTopologyValidator() { /** {@inheritDoc} */ @SuppressWarnings("ErrorNotRethrown") + @Test @Override public void testLifecycleAware() throws Exception { for (boolean nearEnabled : new boolean[] {true, false}) { near = nearEnabled; @@ -390,4 +395,4 @@ public TestTopologyValidator() { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLocalTxStoreExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLocalTxStoreExceptionSelfTest.java index 71f1f7f9765e0..fccf5ecd9bf4e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLocalTxStoreExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLocalTxStoreExceptionSelfTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -25,6 +26,13 @@ * */ public class GridCacheLocalTxStoreExceptionSelfTest extends IgniteTxStoreExceptionAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMarshallerTxAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMarshallerTxAbstractTest.java index 0d616d4a1f141..57c019d304497 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMarshallerTxAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMarshallerTxAbstractTest.java @@ -22,12 +22,11 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.UUID; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -35,6 +34,7 @@ /** * Test transaction with wrong marshalling. */ +@RunWith(JUnit4.class) public abstract class GridCacheMarshallerTxAbstractTest extends GridCommonAbstractTest { /** * Wrong Externalizable class. @@ -57,9 +57,6 @@ private static class GridCacheWrongValue1 { private long val2 = 9; } - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * Constructs a test. */ @@ -67,24 +64,12 @@ protected GridCacheMarshallerTxAbstractTest() { super(true /* start grid. */); } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - - return cfg; - } - /** * JUnit. * * @throws Exception If failed. */ + @Test public void testValueMarshallerFail() throws Exception { String key = UUID.randomUUID().toString(); String value = UUID.randomUUID().toString(); @@ -131,4 +116,4 @@ public void testValueMarshallerFail() throws Exception { tx.close(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMarshallingNodeJoinSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMarshallingNodeJoinSelfTest.java index df3430f2bbfc2..001d88fba3a35 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMarshallingNodeJoinSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMarshallingNodeJoinSelfTest.java @@ -36,20 +36,26 @@ import org.apache.ignite.events.EventType; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.PE; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** */ +@RunWith(JUnit4.class) public class GridCacheMarshallingNodeJoinSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -66,12 +72,6 @@ public class GridCacheMarshallingNodeJoinSelfTest extends GridCommonAbstractTest cfg.setCacheConfiguration(cacheCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -83,6 +83,7 @@ public class GridCacheMarshallingNodeJoinSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testNodeJoin() throws Exception { final CountDownLatch allowJoin = new CountDownLatch(1); final CountDownLatch joined = new CountDownLatch(2); @@ -168,4 +169,4 @@ public TestObject() { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java index a6f202218d28c..a9f6d392e5af5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MAX_COMPLETED_TX_COUNT; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -38,6 +41,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheMissingCommitVersionSelfTest extends GridCommonAbstractTest { /** */ private volatile boolean putFailed; @@ -86,6 +90,7 @@ public GridCacheMissingCommitVersionSelfTest() { /** * @throws Exception If failed. */ + @Test public void testMissingCommitVersion() throws Exception { final IgniteCache cache = jcache(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java index f6f47517e4de2..7867be29c2a5d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java @@ -30,11 +30,13 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -46,18 +48,24 @@ * exchange should be skipped in this case). */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class GridCacheMixedPartitionExchangeSelfTest extends GridCommonAbstractTest { - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Flag indicating whether to include cache to the node configuration. */ private boolean cache; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-9470"); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder).setForceServerMode(true); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); if (cache) cfg.setCacheConfiguration(cacheConfiguration()); @@ -84,6 +92,7 @@ private CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testNodeJoinLeave() throws Exception { try { cache = true; @@ -169,4 +178,4 @@ public void testNodeJoinLeave() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultiUpdateLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultiUpdateLockSelfTest.java index 367d8ac833d66..fbe629d1a9c69 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultiUpdateLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultiUpdateLockSelfTest.java @@ -29,11 +29,11 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.checkpoint.noop.NoopCheckpointSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -44,10 +44,8 @@ /** * Tests multi-update locks. */ +@RunWith(JUnit4.class) public class GridCacheMultiUpdateLockSelfTest extends GridCommonAbstractTest { - /** Shared IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Near enabled flag. */ private boolean nearEnabled; @@ -55,12 +53,6 @@ public class GridCacheMultiUpdateLockSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCacheConfiguration(cacheConfiguration()); cfg.setCheckpointSpi(new NoopCheckpointSpi()); @@ -89,6 +81,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testMultiUpdateLocksNear() throws Exception { checkMultiUpdateLocks(true); } @@ -96,6 +89,7 @@ public void testMultiUpdateLocksNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultiUpdateLocksColocated() throws Exception { checkMultiUpdateLocks(false); } @@ -202,4 +196,4 @@ private void checkMultiUpdateLocks(boolean nearEnabled) throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java index 800f4bac7b67c..298e2917bea35 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java @@ -26,14 +26,19 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.testframework.MvccFeatureChecker.assertMvccWriteConflict; /** * Multinode update test. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public abstract class GridCacheMultinodeUpdateAbstractSelfTest extends GridCacheAbstractSelfTest { /** */ protected static volatile boolean failed; @@ -74,7 +79,11 @@ public abstract class GridCacheMultinodeUpdateAbstractSelfTest extends GridCache /** * @throws Exception If failed. */ + @Test public void testInvoke() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10778"); + IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); final Integer key = primaryKey(cache); @@ -86,8 +95,12 @@ public void testInvoke() throws Exception { Integer expVal = 0; - for (int i = 0; i < iterations(); i++) { - log.info("Iteration: " + i); + final long endTime = System.currentTimeMillis() + GridTestUtils.SF.applyLB(60_000, 10_000); + + int iter = 0; + + while (System.currentTimeMillis() < endTime) { + log.info("Iteration: " + iter++); final AtomicInteger gridIdx = new AtomicInteger(); @@ -97,8 +110,20 @@ public void testInvoke() throws Exception { final IgniteCache cache = grid(idx).cache(DEFAULT_CACHE_NAME); - for (int i = 0; i < ITERATIONS_PER_THREAD && !failed; i++) - cache.invoke(key, new IncProcessor()); + for (int i = 0; i < ITERATIONS_PER_THREAD && !failed; i++) { + boolean updated = false; + + while (!updated) { + try { + cache.invoke(key, new IncProcessor()); + + updated = true; + } + catch (Exception e) { + assertMvccWriteConflict(e); + } + } + } return null; } @@ -116,13 +141,6 @@ public void testInvoke() throws Exception { } } - /** - * @return Number of iterations. - */ - protected int iterations() { - return atomicityMode() == ATOMIC ? 30 : 15; - } - /** * */ @@ -144,4 +162,4 @@ protected static class IncProcessor implements EntryProcessor cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -107,6 +112,7 @@ public void testAllTrueFlags() { /** * */ + @Test public void testAllFalseFlags() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -140,4 +146,4 @@ public void testAllFalseFlags() { for (GridCacheMvccCandidate.Mask mask : GridCacheMvccCandidate.Mask.values()) assertFalse("Mask check failed [mask=" + mask + ", c=" + c + ']', mask.get(flags)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManagerSelfTest.java index 0a284e989c1ee..dcc4dcb88871a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManagerSelfTest.java @@ -24,11 +24,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -38,10 +38,8 @@ /** * Tests for {@link GridCacheMvccManager}. */ +@RunWith(JUnit4.class) public class GridCacheMvccManagerSelfTest extends GridCommonAbstractTest { - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Cache mode. */ private CacheMode mode; @@ -49,12 +47,6 @@ public class GridCacheMvccManagerSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration()); return cfg; @@ -72,6 +64,7 @@ protected CacheConfiguration cacheConfiguration() { } /** @throws Exception If failed. */ + @Test public void testLocalCache() throws Exception { mode = LOCAL; @@ -79,6 +72,7 @@ public void testLocalCache() throws Exception { } /** @throws Exception If failed. */ + @Test public void testReplicatedCache() throws Exception { mode = REPLICATED; @@ -86,6 +80,7 @@ public void testReplicatedCache() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedCache() throws Exception { mode = PARTITIONED; @@ -117,4 +112,4 @@ private void testCandidates(int gridCnt) throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccMultiThreadedUpdateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccMultiThreadedUpdateSelfTest.java new file mode 100644 index 0000000000000..1f9cbf027766c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccMultiThreadedUpdateSelfTest.java @@ -0,0 +1,207 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.concurrent.Callable; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteTransactions; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.transactions.Transaction; +import org.junit.Test; + +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Multithreaded update test. + */ +public class GridCacheMvccMultiThreadedUpdateSelfTest extends GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest { + /** */ + public static final int THREADS = 5; + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return 5 * 60_000; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-9470"); + + super.beforeTestsStarted(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testTransformTx() throws Exception { + testTransformTx(keyForNode(0)); + + if (gridCount() > 1) + testTransformTx(keyForNode(1)); + } + + /** + * @param key Key. + * @throws Exception If failed. + */ + private void testTransformTx(final Integer key) throws Exception { + final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); + + cache.put(key, 0); + + final int ITERATIONS_PER_THREAD = iterations(); + + GridTestUtils.runMultiThreaded(new Callable() { + @Override public Void call() throws Exception { + IgniteTransactions txs = ignite(0).transactions(); + + for (int i = 0; i < ITERATIONS_PER_THREAD && !failed; i++) { + if (i % 500 == 0) + log.info("Iteration " + i); + + try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.invoke(key, new IncProcessor()); + + tx.commit(); + } + } + + return null; + } + }, THREADS, "transform"); + + for (int i = 0; i < gridCount(); i++) { + Integer val = (Integer)grid(i).cache(DEFAULT_CACHE_NAME).get(key); + + assertEquals("Unexpected value for grid " + i, (Integer)(ITERATIONS_PER_THREAD * THREADS), val); + } + + if (failed) { + for (int g = 0; g < gridCount(); g++) + info("Value for cache [g=" + g + ", val=" + grid(g).cache(DEFAULT_CACHE_NAME).get(key) + ']'); + + assertFalse(failed); + } + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTxPessimistic() throws Exception { + testPutTx(keyForNode(0)); + + if (gridCount() > 1) + testPutTx(keyForNode(1)); + } + + /** + * @param key Key. + * @throws Exception If failed. + */ + private void testPutTx(final Integer key) throws Exception { + final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); + + cache.put(key, 0); + + final int ITERATIONS_PER_THREAD = iterations(); + + GridTestUtils.runMultiThreaded(new Callable() { + @Override public Void call() throws Exception { + for (int i = 0; i < ITERATIONS_PER_THREAD; i++) { + if (i % 500 == 0) + log.info("Iteration " + i); + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + Integer val = cache.getAndPut(key, i); + + assertNotNull(val); + + tx.commit(); + } + } + + return null; + } + }, THREADS, "put"); + + for (int i = 0; i < gridCount(); i++) { + Integer val = (Integer)grid(i).cache(DEFAULT_CACHE_NAME).get(key); + + assertNotNull("Unexpected value for grid " + i, val); + } + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutxIfAbsentTxPessimistic() throws Exception { + testPutxIfAbsentTx(keyForNode(0)); + + if (gridCount() > 1) + testPutxIfAbsentTx(keyForNode(1)); + } + + /** + * @param key Key. + * @throws Exception If failed. + */ + private void testPutxIfAbsentTx(final Integer key) throws Exception { + final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); + + cache.put(key, 0); + + final int ITERATIONS_PER_THREAD = iterations(); + + GridTestUtils.runMultiThreaded(new Callable() { + @Override public Void call() throws Exception { + for (int i = 0; i < ITERATIONS_PER_THREAD && !failed; i++) { + if (i % 500 == 0) + log.info("Iteration " + i); + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.putIfAbsent(key, 100); + + tx.commit(); + } + } + + return null; + } + }, THREADS, "putxIfAbsent"); + + for (int i = 0; i < gridCount(); i++) { + Integer val = (Integer)grid(i).cache(DEFAULT_CACHE_NAME).get(key); + + assertEquals("Unexpected value for grid " + i, (Integer)0, val); + } + + assertFalse(failed); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccPartitionedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccPartitionedSelfTest.java index 119002ca75717..7117adf3c0cc4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccPartitionedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccPartitionedSelfTest.java @@ -25,11 +25,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,6 +37,7 @@ /** * Test cases for multi-threaded tests in partitioned cache. */ +@RunWith(JUnit4.class) public class GridCacheMvccPartitionedSelfTest extends GridCommonAbstractTest { /** */ private static final UUID nodeId = UUID.randomUUID(); @@ -44,9 +45,6 @@ public class GridCacheMvccPartitionedSelfTest extends GridCommonAbstractTest { /** Grid. */ private IgniteKernal grid; - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -68,12 +66,6 @@ public GridCacheMvccPartitionedSelfTest() { @Override protected IgniteConfiguration getConfiguration() throws Exception { IgniteConfiguration cfg = super.getConfiguration(); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); @@ -88,6 +80,7 @@ public GridCacheMvccPartitionedSelfTest() { /** * Tests remote candidates. */ + @Test public void testNearLocalsWithPending() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -122,6 +115,7 @@ public void testNearLocalsWithPending() { /** * Tests remote candidates. */ + @Test public void testNearLocalsWithCommitted() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -155,6 +149,7 @@ public void testNearLocalsWithCommitted() { /** * Tests remote candidates. */ + @Test public void testNearLocalsWithRolledback() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -188,6 +183,7 @@ public void testNearLocalsWithRolledback() { /** * Tests remote candidates. */ + @Test public void testNearLocals() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -218,6 +214,7 @@ public void testNearLocals() { /** * Tests remote candidates. */ + @Test public void testNearLocalsWithOwned() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -257,6 +254,7 @@ public void testNearLocalsWithOwned() { /** * @throws Exception If failed. */ + @Test public void testAddPendingRemote0() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -289,6 +287,7 @@ public void testAddPendingRemote0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddPendingRemote1() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -332,6 +331,7 @@ public void testAddPendingRemote1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddPendingRemote2() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -376,6 +376,7 @@ public void testAddPendingRemote2() throws Exception { /** * Tests salvageRemote method */ + @Test public void testSalvageRemote() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -434,6 +435,7 @@ public void testSalvageRemote() { /** * @throws Exception If failed. */ + @Test public void testNearRemoteConsistentOrdering0() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -472,6 +474,7 @@ public void testNearRemoteConsistentOrdering0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearRemoteConsistentOrdering1() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -517,6 +520,7 @@ public void testNearRemoteConsistentOrdering1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearRemoteConsistentOrdering2() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -562,6 +566,7 @@ public void testNearRemoteConsistentOrdering2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearRemoteConsistentOrdering3() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -601,6 +606,7 @@ public void testNearRemoteConsistentOrdering3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSerializableReadLocksAdd() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -678,6 +684,7 @@ public void testSerializableReadLocksAdd() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSerializableReadLocksAssign() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -817,6 +824,7 @@ private void checkCandidates(CacheLockCandidates all, GridCacheVersion...vers) { /** * @throws Exception If failed. */ + @Test public void testSerializableLocks() throws Exception { checkSerializableAdd(false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java index 6f52cce302d09..ef653d308f135 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java @@ -27,23 +27,21 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * Test cases for multi-threaded tests. */ +@RunWith(JUnit4.class) public class GridCacheMvccSelfTest extends GridCommonAbstractTest { /** Grid. */ private IgniteKernal grid; - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -65,12 +63,6 @@ public GridCacheMvccSelfTest() { @Override protected IgniteConfiguration getConfiguration() throws Exception { IgniteConfiguration cfg = super.getConfiguration(); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(REPLICATED); @@ -83,6 +75,7 @@ public GridCacheMvccSelfTest() { /** * @throws Exception If failed. */ + @Test public void testMarshalUnmarshalCandidate() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -115,6 +108,7 @@ public void testMarshalUnmarshalCandidate() throws Exception { /** * Tests remote candidates. */ + @Test public void testRemotes() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -266,6 +260,7 @@ public void testRemotes() { /** * Tests that orderOwned does not reorder owned locks. */ + @Test public void testNearRemoteWithOwned() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -308,6 +303,7 @@ public void testNearRemoteWithOwned() { /** * Tests that orderOwned does not reorder owned locks. */ + @Test public void testNearRemoteWithOwned1() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -354,6 +350,7 @@ public void testNearRemoteWithOwned1() { /** * Tests that orderOwned does not reorder owned locks. */ + @Test public void testNearRemoteWithOwned2() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -402,6 +399,7 @@ public void testNearRemoteWithOwned2() { /** * Tests remote candidates. */ + @Test public void testLocal() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -476,6 +474,7 @@ public void testLocal() { /** * Tests assignment of local candidates when remote exist. */ + @Test public void testLocalWithRemote() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -512,6 +511,7 @@ public void testLocalWithRemote() { /** * */ + @Test public void testCompletedWithBaseInTheMiddle() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -565,6 +565,7 @@ public void testCompletedWithBaseInTheMiddle() { /** * */ + @Test public void testCompletedWithCompletedBaseInTheMiddle() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -607,6 +608,7 @@ public void testCompletedWithCompletedBaseInTheMiddle() { /** * */ + @Test public void testCompletedTwiceWithBaseInTheMiddle() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -653,6 +655,7 @@ public void testCompletedTwiceWithBaseInTheMiddle() { /** * */ + @Test public void testCompletedWithBaseInTheMiddleNoChange() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -692,6 +695,7 @@ public void testCompletedWithBaseInTheMiddleNoChange() { /** * */ + @Test public void testCompletedWithBaseInTheBeginning() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -734,6 +738,7 @@ public void testCompletedWithBaseInTheBeginning() { /** * This case should never happen, nevertheless we need to test for it. */ + @Test public void testCompletedWithBaseInTheBeginningNoChange() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -773,6 +778,7 @@ public void testCompletedWithBaseInTheBeginningNoChange() { /** * This case should never happen, nevertheless we need to test for it. */ + @Test public void testCompletedWithBaseInTheEndNoChange() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -812,6 +818,7 @@ public void testCompletedWithBaseInTheEndNoChange() { /** * */ + @Test public void testCompletedWithBaseNotPresentInTheMiddle() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -853,6 +860,7 @@ public void testCompletedWithBaseNotPresentInTheMiddle() { /** * */ + @Test public void testCompletedWithBaseNotPresentInTheMiddleNoChange() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -888,6 +896,7 @@ public void testCompletedWithBaseNotPresentInTheMiddleNoChange() { /** * */ + @Test public void testCompletedWithBaseNotPresentInTheBeginning() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -929,6 +938,7 @@ public void testCompletedWithBaseNotPresentInTheBeginning() { /** * */ + @Test public void testCompletedWithBaseNotPresentInTheBeginningNoChange() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -970,6 +980,7 @@ public void testCompletedWithBaseNotPresentInTheBeginningNoChange() { /** * */ + @Test public void testCompletedWithBaseNotPresentInTheEndNoChange() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -1007,6 +1018,7 @@ public void testCompletedWithBaseNotPresentInTheEndNoChange() { /** * Test local and remote candidates together. */ + @Test public void testLocalAndRemote() { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -1133,6 +1145,7 @@ public void testLocalAndRemote() { /** * @throws Exception If test failed. */ + @Test public void testMultipleLocalAndRemoteLocks1() throws Exception { UUID nodeId = UUID.randomUUID(); @@ -1206,6 +1219,7 @@ public void testMultipleLocalAndRemoteLocks1() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMultipleLocalAndRemoteLocks2() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -1293,6 +1307,7 @@ public void testMultipleLocalAndRemoteLocks2() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMultipleLocalLocks() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -1334,6 +1349,7 @@ public void testMultipleLocalLocks() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"ObjectEquality"}) + @Test public void testUsedCandidates() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -1399,6 +1415,7 @@ public void testUsedCandidates() throws Exception { /** * Test 2 keys with candidates in reverse order. */ + @Test public void testReverseOrder1() { UUID id = UUID.randomUUID(); @@ -1452,6 +1469,7 @@ public void testReverseOrder1() { * * @throws Exception If failed. */ + @Test public void testReverseOrder2() throws Exception { UUID id = UUID.randomUUID(); @@ -1514,6 +1532,7 @@ public void testReverseOrder2() throws Exception { * * @throws Exception If failed. */ + @Test public void testReverseOrder3() throws Exception { GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); @@ -1562,6 +1581,7 @@ public void testReverseOrder3() throws Exception { * * @throws Exception If failed. */ + @Test public void testReverseOrder4() throws Exception { UUID id = UUID.randomUUID(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheNestedTxAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheNestedTxAbstractTest.java index 762cc4d9d1484..fc38fb88d956b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheNestedTxAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheNestedTxAbstractTest.java @@ -26,14 +26,13 @@ import java.util.concurrent.locks.Lock; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteException; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -43,10 +42,8 @@ /** * Nested transaction emulation. */ +@RunWith(JUnit4.class) public class GridCacheNestedTxAbstractTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Counter key. */ private static final String CNTR_KEY = "CNTR_KEY"; @@ -62,19 +59,6 @@ public class GridCacheNestedTxAbstractTest extends GridCommonAbstractTest { /** */ private static final AtomicInteger globalCntr = new AtomicInteger(); - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { for (int i = 0; i < GRID_CNT; i++) @@ -105,6 +89,7 @@ protected GridCacheNestedTxAbstractTest() { * * @throws Exception If failed. */ + @Test public void testTwoTx() throws Exception { final IgniteCache c = grid(0).cache(DEFAULT_CACHE_NAME); @@ -136,6 +121,7 @@ public void testTwoTx() throws Exception { * * @throws Exception If failed. */ + @Test public void testLockAndTx() throws Exception { final IgniteCache c = grid(0).cache(DEFAULT_CACHE_NAME); @@ -212,6 +198,7 @@ public void testLockAndTx() throws Exception { * * @throws Exception If failed. */ + @Test public void testLockAndTx1() throws Exception { final IgniteCache c = grid(0).cache(DEFAULT_CACHE_NAME); @@ -281,4 +268,4 @@ public void testLockAndTx1() throws Exception { for (int i = 0; i < globalCntr.get(); i++) assertNotNull(c1.get(i)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheObjectToStringSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheObjectToStringSelfTest.java index 33b7033df911e..aa810122ac05c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheObjectToStringSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheObjectToStringSelfTest.java @@ -27,11 +27,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -43,10 +44,8 @@ /** * Tests that common cache objects' toString() methods do not lead to stack overflow. */ +@RunWith(JUnit4.class) public class GridCacheObjectToStringSelfTest extends GridCommonAbstractTest { - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Cache mode for test. */ private CacheMode cacheMode; @@ -56,14 +55,17 @@ public class GridCacheObjectToStringSelfTest extends GridCommonAbstractTest { /** Near enabled flag. */ private boolean nearEnabled; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(ipFinder); - cfg.setDiscoverySpi(discoSpi); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(cacheMode); @@ -85,6 +87,7 @@ public class GridCacheObjectToStringSelfTest extends GridCommonAbstractTest { } /** @throws Exception If failed. */ + @Test public void testLocalCacheFifoEvictionPolicy() throws Exception { cacheMode = LOCAL; evictionPlc = new FifoEvictionPolicy(); @@ -93,6 +96,7 @@ public void testLocalCacheFifoEvictionPolicy() throws Exception { } /** @throws Exception If failed. */ + @Test public void testLocalCacheLruEvictionPolicy() throws Exception { cacheMode = LOCAL; evictionPlc = new LruEvictionPolicy(); @@ -101,6 +105,7 @@ public void testLocalCacheLruEvictionPolicy() throws Exception { } /** @throws Exception If failed. */ + @Test public void testReplicatedCacheFifoEvictionPolicy() throws Exception { cacheMode = REPLICATED; evictionPlc = new FifoEvictionPolicy(); @@ -109,6 +114,7 @@ public void testReplicatedCacheFifoEvictionPolicy() throws Exception { } /** @throws Exception If failed. */ + @Test public void testReplicatedCacheLruEvictionPolicy() throws Exception { cacheMode = REPLICATED; evictionPlc = new LruEvictionPolicy(); @@ -117,6 +123,7 @@ public void testReplicatedCacheLruEvictionPolicy() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedCacheFifoEvictionPolicy() throws Exception { cacheMode = PARTITIONED; nearEnabled = true; @@ -126,6 +133,7 @@ public void testPartitionedCacheFifoEvictionPolicy() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedCacheLruEvictionPolicy() throws Exception { cacheMode = PARTITIONED; nearEnabled = true; @@ -135,6 +143,7 @@ public void testPartitionedCacheLruEvictionPolicy() throws Exception { } /** @throws Exception If failed. */ + @Test public void testColocatedCacheFifoEvictionPolicy() throws Exception { cacheMode = PARTITIONED; nearEnabled = false; @@ -144,6 +153,7 @@ public void testColocatedCacheFifoEvictionPolicy() throws Exception { } /** @throws Exception If failed. */ + @Test public void testColocatedCacheLruEvictionPolicy() throws Exception { cacheMode = PARTITIONED; nearEnabled = false; @@ -188,4 +198,4 @@ private void checkToString() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest.java index afc41ffcd34ab..c0b0ddab0ca47 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest.java @@ -28,6 +28,9 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -35,6 +38,7 @@ /** * Multithreaded update test with off heap enabled. */ +@RunWith(JUnit4.class) public abstract class GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest extends GridCacheAbstractSelfTest { /** */ protected static volatile boolean failed; @@ -71,6 +75,7 @@ public abstract class GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest extend /** * @throws Exception If failed. */ + @Test public void testTransform() throws Exception { testTransform(keyForNode(0)); @@ -115,6 +120,7 @@ private void testTransform(final Integer key) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { testPut(keyForNode(0)); @@ -161,6 +167,7 @@ private void testPut(final Integer key) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutxIfAbsent() throws Exception { testPutxIfAbsent(keyForNode(0)); @@ -205,6 +212,7 @@ private void testPutxIfAbsent(final Integer key) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGet() throws Exception { testPutGet(keyForNode(0)); @@ -345,4 +353,4 @@ else if (e.getValue() == null) { return true; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateSelfTest.java index 40e2e23322f9e..4f50d384920f8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateSelfTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -31,6 +34,7 @@ /** * Multithreaded update test with off heap enabled. */ +@RunWith(JUnit4.class) public class GridCacheOffHeapMultiThreadedUpdateSelfTest extends GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest { /** {@inheritDoc} */ @Override protected long getTestTimeout() { @@ -40,6 +44,7 @@ public class GridCacheOffHeapMultiThreadedUpdateSelfTest extends GridCacheOffHea /** * @throws Exception If failed. */ + @Test public void testTransformTx() throws Exception { info(">>> PESSIMISTIC node 0"); @@ -109,6 +114,7 @@ private void testTransformTx(final Integer key, final TransactionConcurrency txC /** * @throws Exception If failed. */ + @Test public void testPutTxPessimistic() throws Exception { testPutTx(keyForNode(0), PESSIMISTIC); @@ -121,6 +127,7 @@ public void testPutTxPessimistic() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutTxOptimistic() throws Exception { testPutTx(keyForNode(0), OPTIMISTIC); @@ -170,6 +177,7 @@ private void testPutTx(final Integer key, final TransactionConcurrency txConcurr /** * @throws Exception If failed. */ + @Test public void testPutxIfAbsentTxPessimistic() throws Exception { testPutxIfAbsentTx(keyForNode(0), PESSIMISTIC); @@ -182,6 +190,7 @@ public void testPutxIfAbsentTxPessimistic() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutxIfAbsentTxOptimistic() throws Exception { testPutxIfAbsentTx(keyForNode(0), OPTIMISTIC); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapUpdateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapUpdateSelfTest.java index b8f68585a2a03..dac3e6713628b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapUpdateSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapUpdateSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -35,6 +38,7 @@ /** * Check for specific support issue. */ +@RunWith(JUnit4.class) public class GridCacheOffheapUpdateSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -56,6 +60,7 @@ public class GridCacheOffheapUpdateSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testUpdateInPessimisticTxOnRemoteNode() throws Exception { try { Ignite ignite = startGrids(2); @@ -99,6 +104,7 @@ public void testUpdateInPessimisticTxOnRemoteNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadEvictedPartition() throws Exception { try { Ignite grid = startGrid(0); @@ -127,16 +133,23 @@ public void testReadEvictedPartition() throws Exception { assertEquals(10, cache.get(key)); - try (Transaction ignored = grid.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - assertEquals(10, cache.get(key)); - } + if(((IgniteCacheProxy)cache).context().config().getAtomicityMode() != CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) { + try (Transaction ignored = grid.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + assertEquals(10, cache.get(key)); + } - try (Transaction ignored = grid.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { - assertEquals(10, cache.get(key)); + try (Transaction ignored = grid.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { + assertEquals(10, cache.get(key)); + } + } + else { + try (Transaction ignored = grid.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + assertEquals(10, cache.get(key)); + } } } finally { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java index 2a90bf608b3f1..15cb4891b3533 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java @@ -36,21 +36,19 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.junit.Assert.assertNotEquals; /** * Tests that cache value is copied for get, interceptor and invoke closure. */ +@RunWith(JUnit4.class) public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ public static final int ITER_CNT = 1000; @@ -83,12 +81,6 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCommonAbst @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(spi); - c.setPeerClassLoadingEnabled(p2pEnabled); c.getTransactionConfiguration().setTxSerializableEnabled(true); @@ -117,6 +109,7 @@ protected CacheConfiguration cacheConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCopyOnReadFlagP2PEnabled() throws Exception { doTest(true); } @@ -124,6 +117,7 @@ public void testCopyOnReadFlagP2PEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCopyOnReadFlagP2PDisbaled() throws Exception { doTest(false); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOrderedPreloadingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOrderedPreloadingSelfTest.java index 34b5876f3e0fd..c81a2b332e960 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOrderedPreloadingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOrderedPreloadingSelfTest.java @@ -31,10 +31,10 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -43,10 +43,8 @@ /** * Checks ordered preloading. */ +@RunWith(JUnit4.class) public class GridCacheOrderedPreloadingSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of grids in test. */ private static final int GRID_CNT = 4; @@ -86,12 +84,6 @@ public class GridCacheOrderedPreloadingSelfTest extends GridCommonAbstractTest { cacheConfig(firstCacheMode, 1, FIRST_CACHE_NAME), cacheConfig(secondCacheMode, 2, SECOND_CACHE_NAME)); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - Map, int[]> listeners = new HashMap<>(); listeners.put(new IgnitePredicate() { @@ -125,6 +117,7 @@ private CacheConfiguration cacheConfig(CacheMode cacheMode, int preloadOrder, St /** * @throws Exception If failed. */ + @Test public void testPreloadOrderPartitionedPartitioned() throws Exception { checkPreloadOrder(PARTITIONED, PARTITIONED); } @@ -132,6 +125,7 @@ public void testPreloadOrderPartitionedPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreloadOrderReplicatedReplicated() throws Exception { checkPreloadOrder(REPLICATED, REPLICATED); } @@ -139,6 +133,7 @@ public void testPreloadOrderReplicatedReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreloadOrderPartitionedReplicated() throws Exception { checkPreloadOrder(PARTITIONED, REPLICATED); } @@ -146,6 +141,7 @@ public void testPreloadOrderPartitionedReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreloadOrderReplicatedPartitioned() throws Exception { checkPreloadOrder(REPLICATED, PARTITIONED); } @@ -203,4 +199,4 @@ private void checkPreloadOrder(CacheMode first, CacheMode second) throws Excepti private int gridIdx(Event evt) { return getTestIgniteInstanceIndex((String)evt.node().attributes().get(GRID_NAME_ATTR)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java index 8de8e04d0b61c..21b936745aedc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java @@ -32,11 +32,11 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.jdk.JdkMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -48,16 +48,11 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest { /** Test p2p value. */ private static final String TEST_VALUE = "org.apache.ignite.tests.p2p.GridCacheDeploymentTestValue3"; - /** */ - private static final long OFFHEAP = 0;// 4 * 1024 * 1024; - - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private final AtomicInteger idxGen = new AtomicInteger(); @@ -73,12 +68,6 @@ public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest { cfg.setNetworkTimeout(2000); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - cfg.setMarshaller(new JdkMarshaller()); CacheConfiguration repCacheCfg = defaultCacheConfiguration(); @@ -121,6 +110,7 @@ public class GridCacheP2PUndeploySelfTest extends GridCommonAbstractTest { } /** @throws Exception If failed. */ + @Test public void testSwapP2PReplicated() throws Exception { offheap = false; @@ -128,6 +118,7 @@ public void testSwapP2PReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOffHeapP2PReplicated() throws Exception { offheap = true; @@ -135,6 +126,7 @@ public void testOffHeapP2PReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSwapP2PPartitioned() throws Exception { offheap = false; @@ -142,6 +134,7 @@ public void testSwapP2PPartitioned() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOffheapP2PPartitioned() throws Exception { offheap = true; @@ -149,6 +142,7 @@ public void testOffheapP2PPartitioned() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSwapP2PReplicatedNoPreloading() throws Exception { mode = NONE; offheap = false; @@ -157,6 +151,7 @@ public void testSwapP2PReplicatedNoPreloading() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOffHeapP2PReplicatedNoPreloading() throws Exception { mode = NONE; offheap = true; @@ -165,6 +160,7 @@ public void testOffHeapP2PReplicatedNoPreloading() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSwapP2PPartitionedNoPreloading() throws Exception { mode = NONE; offheap = false; @@ -173,6 +169,7 @@ public void testSwapP2PPartitionedNoPreloading() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOffHeapP2PPartitionedNoPreloading() throws Exception { mode = NONE; offheap = true; @@ -299,4 +296,4 @@ private boolean waitCacheEmpty(IgniteCache cache, long timeout) return cache.localSize() == 0; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedGetSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedGetSelfTest.java index f5cc65b9b8ec5..b44dceb59b425 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedGetSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedGetSelfTest.java @@ -29,11 +29,11 @@ import org.apache.ignite.internal.managers.communication.GridMessageListener; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -43,10 +43,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridCachePartitionedGetSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_CNT = 3; @@ -63,23 +61,11 @@ public class GridCachePartitionedGetSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(discoverySpi()); cfg.setCacheConfiguration(cacheConfiguration()); return cfg; } - /** - * @return Discovery SPI; - */ - private DiscoverySpi discoverySpi() { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - return spi; - } - /** * @return Cache configuration. */ @@ -109,6 +95,7 @@ private CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testGetFromPrimaryNode() throws Exception { for (int i = 0; i < GRID_CNT; i++) { IgniteCache c = grid(i).cache(DEFAULT_CACHE_NAME); @@ -128,7 +115,13 @@ public void testGetFromPrimaryNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetFromBackupNode() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10274"); + + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + for (int i = 0; i < GRID_CNT; i++) { IgniteCache c = grid(i).cache(DEFAULT_CACHE_NAME); @@ -159,6 +152,7 @@ public void testGetFromBackupNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetFromNearNode() throws Exception { for (int i = 0; i < GRID_CNT; i++) { IgniteCache c = grid(i).cache(DEFAULT_CACHE_NAME); @@ -235,4 +229,4 @@ private void prepare() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedProjectionAffinitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedProjectionAffinitySelfTest.java index 7f589fe82fa75..e3c4129d174fb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedProjectionAffinitySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedProjectionAffinitySelfTest.java @@ -23,11 +23,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -36,7 +36,7 @@ /** * Partitioned affinity test for projections. */ -@SuppressWarnings({"PointlessArithmeticExpression"}) +@RunWith(JUnit4.class) public class GridCachePartitionedProjectionAffinitySelfTest extends GridCommonAbstractTest { /** Backup count. */ private static final int BACKUPS = 1; @@ -44,9 +44,6 @@ public class GridCachePartitionedProjectionAffinitySelfTest extends GridCommonAb /** Grid count. */ private static final int GRIDS = 3; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -61,12 +58,6 @@ public class GridCachePartitionedProjectionAffinitySelfTest extends GridCommonAb cfg.setCacheConfiguration(cacheCfg); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - return cfg; } @@ -81,6 +72,7 @@ public class GridCachePartitionedProjectionAffinitySelfTest extends GridCommonAb } /** @throws Exception If failed. */ + @Test public void testAffinity() throws Exception { waitTopologyUpdate(); @@ -92,7 +84,7 @@ public void testAffinity() throws Exception { } /** @throws Exception If failed. */ - @SuppressWarnings("deprecation") + @Test public void testProjectionAffinity() throws Exception { waitTopologyUpdate(); @@ -110,7 +102,6 @@ public void testProjectionAffinity() throws Exception { } /** @throws Exception If failed. */ - @SuppressWarnings("BusyWait") private void waitTopologyUpdate() throws Exception { GridTestUtils.waitTopologyUpdate(DEFAULT_CACHE_NAME, BACKUPS, log()); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedWritesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedWritesTest.java index 0d00bef472dac..9e4f251bf78b0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedWritesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedWritesTest.java @@ -27,8 +27,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -38,10 +42,16 @@ * wrapped only in near cache (see {@link GridCacheProcessor} init logic). */ @SuppressWarnings({"unchecked"}) +@RunWith(JUnit4.class) public class GridCachePartitionedWritesTest extends GridCommonAbstractTest { /** Cache store. */ private CacheStore store; + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + } + /** {@inheritDoc} */ @Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -78,6 +88,7 @@ public class GridCachePartitionedWritesTest extends GridCommonAbstractTest { } /** @throws Exception If test fails. */ + @Test public void testWrite() throws Exception { final AtomicInteger putCnt = new AtomicInteger(); final AtomicInteger rmvCnt = new AtomicInteger(); @@ -143,4 +154,4 @@ public void testWrite() throws Exception { stopGrid(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java index f9042ef39e3b2..d97b6ac61b774 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java @@ -38,12 +38,13 @@ import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -54,14 +55,12 @@ /** * */ +@RunWith(JUnit4.class) public class GridCachePreloadingEvictionsSelfTest extends GridCommonAbstractTest { /** */ private static final String VALUE = createValue(); public static final CachePeekMode[] ALL_PEEK_MODES = new CachePeekMode[] {CachePeekMode.ALL}; - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private final AtomicInteger idxGen = new AtomicInteger(); @@ -69,12 +68,6 @@ public class GridCachePreloadingEvictionsSelfTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - CacheConfiguration partCacheCfg = defaultCacheConfiguration(); partCacheCfg.setCacheMode(PARTITIONED); @@ -100,8 +93,11 @@ public class GridCachePreloadingEvictionsSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testEvictions() throws Exception { try { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + final Ignite ignite1 = startGrid(1); final IgniteCache cache1 = ignite1.cache(DEFAULT_CACHE_NAME); @@ -234,7 +230,7 @@ private void checkCachesConsistency(Ignite ignite1, Ignite ignite2) throws Excep "Sizes do not match [s1=" + cache1.size(ALL_PEEK_MODES) + ", s2=" + cache2.size(ALL_PEEK_MODES) + ']'; for (Integer key : cache1.keySet()) { - Object e = cache1.localPeek(key, new CachePeekMode[] {CachePeekMode.ONHEAP}, null); + Object e = cache1.localPeek(key, new CachePeekMode[] {CachePeekMode.ONHEAP}); if (e != null) assert cache2.containsKey(key) : "Cache2 does not contain key: " + key; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java index 1d9a4eca4ffd6..cb343b2521e7c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java @@ -57,12 +57,13 @@ import org.apache.ignite.spi.IgniteSpiConsistencyChecked; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.failover.FailoverContext; import org.apache.ignite.spi.failover.always.AlwaysFailoverSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -72,10 +73,8 @@ /** * Tests putAll() method along with failover and different configurations. */ +@RunWith(JUnit4.class) public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Size of the test map. */ private static final int TEST_MAP_SIZE = 30_000; @@ -135,6 +134,7 @@ public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverColocatedNearEnabledThreeBackups() throws Exception { checkPutAllFailoverColocated(true, 7, 3); } @@ -142,6 +142,7 @@ public void testPutAllFailoverColocatedNearEnabledThreeBackups() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverColocatedNearDisabledThreeBackups() throws Exception { checkPutAllFailoverColocated(false, 7, 3); } @@ -149,6 +150,7 @@ public void testPutAllFailoverColocatedNearDisabledThreeBackups() throws Excepti /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverNearEnabledOneBackup() throws Exception { checkPutAllFailover(true, 3, 1); } @@ -156,6 +158,7 @@ public void testPutAllFailoverNearEnabledOneBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverNearDisabledOneBackup() throws Exception { checkPutAllFailover(false, 3, 1); } @@ -163,6 +166,7 @@ public void testPutAllFailoverNearDisabledOneBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverNearEnabledTwoBackups() throws Exception { checkPutAllFailover(true, 5, 2); } @@ -170,6 +174,7 @@ public void testPutAllFailoverNearEnabledTwoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverNearDisabledTwoBackups() throws Exception { checkPutAllFailover(false, 5, 2); } @@ -177,6 +182,7 @@ public void testPutAllFailoverNearDisabledTwoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverNearEnabledThreeBackups() throws Exception { checkPutAllFailover(true, 7, 3); } @@ -184,6 +190,7 @@ public void testPutAllFailoverNearEnabledThreeBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverNearDisabledThreeBackups() throws Exception { checkPutAllFailover(false, 7, 3); } @@ -191,6 +198,7 @@ public void testPutAllFailoverNearDisabledThreeBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverColocatedNearEnabledOneBackup() throws Exception { checkPutAllFailoverColocated(true, 3, 1); } @@ -198,6 +206,7 @@ public void testPutAllFailoverColocatedNearEnabledOneBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverColocatedNearDisabledOneBackup() throws Exception { checkPutAllFailoverColocated(false, 3, 1); } @@ -205,6 +214,7 @@ public void testPutAllFailoverColocatedNearDisabledOneBackup() throws Exception /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverColocatedNearEnabledTwoBackups() throws Exception { checkPutAllFailoverColocated(true, 5, 2); } @@ -212,6 +222,7 @@ public void testPutAllFailoverColocatedNearEnabledTwoBackups() throws Exception /** * @throws Exception If failed. */ + @Test public void testPutAllFailoverColocatedNearDisabledTwoBackups() throws Exception { checkPutAllFailoverColocated(false, 5, 2); } @@ -671,10 +682,9 @@ protected CacheAtomicityMode atomicityMode() { cfg.setDeploymentMode(DeploymentMode.CONTINUOUS); - TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi(); + TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); discoverySpi.setAckTimeout(60000); - discoverySpi.setIpFinder(ipFinder); discoverySpi.setForceServerMode(true); cfg.setDiscoverySpi(discoverySpi); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexingDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexingDisabledSelfTest.java index 92a70847fbc95..fbbacd80480d6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexingDisabledSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexingDisabledSelfTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.cache.query.TextQuery; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheQueryIndexingDisabledSelfTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -56,6 +60,7 @@ private void doTest(Callable c, String expectedMsg) { /** * @throws IgniteCheckedException If failed. */ + @Test public void testSqlFieldsQuery() throws IgniteCheckedException { // Should not throw despite the cache not having QueryEntities. jcache().query(new SqlFieldsQuery("select * from dual")).getAll(); @@ -64,6 +69,7 @@ public void testSqlFieldsQuery() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testTextQuery() throws IgniteCheckedException { doTest(new Callable() { @Override public Object call() throws IgniteCheckedException { @@ -75,6 +81,7 @@ public void testTextQuery() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testSqlQuery() throws IgniteCheckedException { // Failure occurs not on validation stage, hence specific error message. doTest(new Callable() { @@ -87,7 +94,8 @@ public void testSqlQuery() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testScanQuery() throws IgniteCheckedException { jcache().query(new ScanQuery<>(null)).getAll(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryInternalKeysSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryInternalKeysSelfTest.java index 288e5721dc091..18d37195aea90 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryInternalKeysSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryInternalKeysSelfTest.java @@ -31,6 +31,9 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.P1; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -38,6 +41,7 @@ /** * Cache query internal keys self test. */ +@RunWith(JUnit4.class) public class GridCacheQueryInternalKeysSelfTest extends GridCacheAbstractSelfTest { /** Grid count. */ private static final int GRID_CNT = 2; @@ -68,6 +72,7 @@ public class GridCacheQueryInternalKeysSelfTest extends GridCacheAbstractSelfTes * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testInternalKeysPreloading() throws Exception { try { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -112,4 +117,4 @@ public void testInternalKeysPreloading() throws Exception { } }); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySqlFieldInlineSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySqlFieldInlineSizeSelfTest.java index a2571602471d4..11ceef6c75247 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySqlFieldInlineSizeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySqlFieldInlineSizeSelfTest.java @@ -26,15 +26,20 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests cache configuration with inlineSize property of the QuerySqlField annotation. */ -@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unchecked", "unused"}) +@SuppressWarnings({"unchecked", "unused"}) +@RunWith(JUnit4.class) public class GridCacheQuerySqlFieldInlineSizeSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSingleFieldIndexes() throws Exception { CacheConfiguration ccfg = defaultCacheConfiguration(); @@ -57,6 +62,7 @@ else if(idx.getFields().containsKey("val1")) /** * @throws Exception If failed. */ + @Test public void testGroupIndex() throws Exception { CacheConfiguration ccfg = defaultCacheConfiguration(); @@ -76,6 +82,7 @@ public void testGroupIndex() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGroupIndexInvalidAnnotaion() throws Exception { final CacheConfiguration ccfg = defaultCacheConfiguration(); @@ -91,6 +98,7 @@ public void testGroupIndexInvalidAnnotaion() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNegativeInlineSize() throws Exception { final CacheConfiguration ccfg = defaultCacheConfiguration(); @@ -157,4 +165,4 @@ static class TestValueNegativeInlineSize { @QuerySqlField(index = true, inlineSize = -10) String val; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReferenceCleanupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReferenceCleanupSelfTest.java index e6a40a64c1819..0849d3a700270 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReferenceCleanupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReferenceCleanupSelfTest.java @@ -37,8 +37,12 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.testframework.GridTestUtils.cacheContext; @@ -46,10 +50,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheReferenceCleanupSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Cache mode for the current test. */ private CacheMode mode; @@ -60,12 +62,6 @@ public class GridCacheReferenceCleanupSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(mode); @@ -79,6 +75,7 @@ public class GridCacheReferenceCleanupSelfTest extends GridCommonAbstractTest { } /** @throws Exception If failed. */ + @Test public void testAtomicLongPartitioned() throws Exception { mode = CacheMode.PARTITIONED; @@ -93,6 +90,7 @@ public void testAtomicLongPartitioned() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAtomicLongReplicated() throws Exception { mode = CacheMode.REPLICATED; @@ -107,7 +105,10 @@ public void testAtomicLongReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAtomicLongLocal() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + mode = CacheMode.LOCAL; try { @@ -119,6 +120,7 @@ public void testAtomicLongLocal() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOneAsyncOpPartitioned() throws Exception { mode = CacheMode.PARTITIONED; @@ -133,6 +135,7 @@ public void testOneAsyncOpPartitioned() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOneAsyncOpReplicated() throws Exception { mode = CacheMode.REPLICATED; @@ -147,7 +150,10 @@ public void testOneAsyncOpReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOneAsyncOpLocal() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + mode = CacheMode.LOCAL; try { @@ -159,6 +165,7 @@ public void testOneAsyncOpLocal() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSeveralAsyncOpsPartitioned() throws Exception { mode = CacheMode.PARTITIONED; @@ -173,6 +180,7 @@ public void testSeveralAsyncOpsPartitioned() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSeveralAsyncOpsReplicated() throws Exception { mode = CacheMode.REPLICATED; @@ -187,7 +195,10 @@ public void testSeveralAsyncOpsReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSeveralAsyncOpsLocal() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + mode = CacheMode.LOCAL; try { @@ -199,6 +210,7 @@ public void testSeveralAsyncOpsLocal() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSyncOpAsyncCommitPartitioned() throws Exception { mode = CacheMode.PARTITIONED; @@ -213,6 +225,7 @@ public void testSyncOpAsyncCommitPartitioned() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSyncOpAsyncCommitReplicated() throws Exception { mode = CacheMode.REPLICATED; @@ -227,7 +240,10 @@ public void testSyncOpAsyncCommitReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSyncOpAsyncCommitLocal() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + mode = CacheMode.LOCAL; try { @@ -239,6 +255,7 @@ public void testSyncOpAsyncCommitLocal() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAsyncOpsAsyncCommitPartitioned() throws Exception { mode = CacheMode.PARTITIONED; @@ -253,6 +270,7 @@ public void testAsyncOpsAsyncCommitPartitioned() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAsyncOpsAsyncCommitReplicated() throws Exception { mode = CacheMode.REPLICATED; @@ -267,7 +285,10 @@ public void testAsyncOpsAsyncCommitReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAsyncOpsAsyncCommitLocal() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + mode = CacheMode.LOCAL; try { @@ -502,4 +523,4 @@ private TestValue(int i) { this.i = i; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReloadSelfTest.java index 50bed2a611f99..2006a478037bc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReloadSelfTest.java @@ -30,13 +30,18 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Checks that CacheProjection.reload() operations are performed correctly. */ +@RunWith(JUnit4.class) public class GridCacheReloadSelfTest extends GridCommonAbstractTest { /** Maximum allowed number of cache entries. */ public static final int MAX_CACHE_ENTRIES = 500; @@ -53,6 +58,26 @@ public class GridCacheReloadSelfTest extends GridCommonAbstractTest { /** Near enabled flag. */ private boolean nearEnabled = true; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + + if (nearEnabled) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + + if (nearEnabled) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { cacheMode = null; @@ -118,7 +143,10 @@ public class GridCacheReloadSelfTest extends GridCommonAbstractTest { * * @throws Exception If error occurs. */ + @Test public void testReloadEvictionLocalCache() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + cacheMode = CacheMode.LOCAL; doTest(); @@ -130,6 +158,7 @@ public void testReloadEvictionLocalCache() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testReloadEvictionPartitionedCacheNearEnabled() throws Exception { cacheMode = PARTITIONED; @@ -142,6 +171,7 @@ public void testReloadEvictionPartitionedCacheNearEnabled() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testReloadEvictionPartitionedCacheNearDisabled() throws Exception { cacheMode = PARTITIONED; nearEnabled = false; @@ -154,6 +184,7 @@ public void testReloadEvictionPartitionedCacheNearDisabled() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testReloadEvictionReplicatedCache() throws Exception { cacheMode = CacheMode.REPLICATED; @@ -180,4 +211,4 @@ private void doTest() throws Exception { stopGrid(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedSynchronousCommitTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedSynchronousCommitTest.java index deca296f59033..fddfe1cfeb00c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedSynchronousCommitTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedSynchronousCommitTest.java @@ -35,17 +35,18 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * Test cases for preload tests. */ +@RunWith(JUnit4.class) public class GridCacheReplicatedSynchronousCommitTest extends GridCommonAbstractTest { /** */ private static final int ADDITION_CACHE_NUMBER = 2; @@ -56,9 +57,6 @@ public class GridCacheReplicatedSynchronousCommitTest extends GridCommonAbstract /** */ private final Collection commSpis = new ConcurrentLinkedDeque<>(); - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -84,12 +82,6 @@ public GridCacheReplicatedSynchronousCommitTest() { commSpis.add(commSpi); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - return c; } @@ -103,6 +95,7 @@ public GridCacheReplicatedSynchronousCommitTest() { /** * @throws Exception If test failed. */ + @Test public void testSynchronousCommit() throws Exception { try { Ignite firstIgnite = startGrid("1"); @@ -129,6 +122,7 @@ public void testSynchronousCommit() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testSynchronousCommitNodeLeave() throws Exception { try { Ignite ignite1 = startGrid("1"); @@ -202,4 +196,4 @@ public int messagesCount() { super.sendMessage(node, msg, ackClosure); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java index 1b06e00cf5095..1ad3f4cca2ba0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java @@ -32,6 +32,9 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -39,6 +42,7 @@ /** * Tests transform for extra traffic. */ +@RunWith(JUnit4.class) public class GridCacheReturnValueTransferSelfTest extends GridCommonAbstractTest { /** Distribution mode. */ private boolean cache; @@ -76,6 +80,7 @@ public class GridCacheReturnValueTransferSelfTest extends GridCommonAbstractTest * @throws Exception If failed. * TODO IGNITE-581 enable when fixed. */ + @Test public void testTransformTransactionalNoBackups() throws Exception { // Test works too long and fails. fail("https://issues.apache.org/jira/browse/IGNITE-581"); @@ -87,6 +92,7 @@ public void testTransformTransactionalNoBackups() throws Exception { * @throws Exception If failed. * TODO IGNITE-581 enable when fixed. */ + @Test public void testTransformTransactionalOneBackup() throws Exception { // Test works too long and fails. fail("https://issues.apache.org/jira/browse/IGNITE-581"); @@ -179,4 +185,4 @@ public TestObject() { assert !failDeserialization; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSlowTxWarnTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSlowTxWarnTest.java index a37bbf36da7d5..09f81d3e35bf4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSlowTxWarnTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSlowTxWarnTest.java @@ -22,11 +22,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,10 +37,8 @@ * {@link org.apache.ignite.IgniteSystemProperties#IGNITE_SLOW_TX_WARN_TIMEOUT} * system property. */ +@RunWith(JUnit4.class) public class GridCacheSlowTxWarnTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -63,18 +61,13 @@ public class GridCacheSlowTxWarnTest extends GridCommonAbstractTest { c.setCacheConfiguration(cc1, cc2, cc3); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - return c; } /** * @throws Exception If failed. */ + @Test public void testWarningOutput() throws Exception { try { IgniteKernal g = (IgniteKernal)startGrid(1); @@ -147,4 +140,4 @@ private void checkCache(Ignite g, String cacheName, boolean simulateTimeout, tx.close(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java index 7f82d75d02ca1..f7efc9e398e46 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStopSelfTest.java @@ -27,21 +27,23 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -51,15 +53,10 @@ /** * Tests correct cache stopping. */ +@RunWith(JUnit4.class) public class GridCacheStopSelfTest extends GridCommonAbstractTest { /** */ - private static final String EXPECTED_MSG = "Cache has been closed or destroyed"; - - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private boolean atomic; + private CacheAtomicityMode atomicityMode = TRANSACTIONAL; /** */ private boolean replicated; @@ -68,21 +65,14 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disc = new TcpDiscoverySpi(); - - disc.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disc); + CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME) + .setAtomicityMode(atomicityMode); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setCacheMode(replicated ? REPLICATED : PARTITIONED); - - if (!replicated) + if (replicated) + ccfg.setCacheMode(REPLICATED); + else ccfg.setBackups(1); - ccfg.setAtomicityMode(atomic ? ATOMIC : TRANSACTIONAL); - cfg.setCacheConfiguration(ccfg); return cfg; @@ -96,21 +86,29 @@ public class GridCacheStopSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStopExplicitTransactions() throws Exception { + atomicityMode = TRANSACTIONAL; + testStop(true); } /** * @throws Exception If failed. */ + @Test public void testStopImplicitTransactions() throws Exception { + atomicityMode = TRANSACTIONAL; + testStop(false); } /** * @throws Exception If failed. */ + @Test public void testStopExplicitTransactionsReplicated() throws Exception { + atomicityMode = TRANSACTIONAL; replicated = true; testStop(true); @@ -119,7 +117,51 @@ public void testStopExplicitTransactionsReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopImplicitTransactionsReplicated() throws Exception { + atomicityMode = TRANSACTIONAL; + replicated = true; + + testStop(false); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testStopExplicitMvccTransactions() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + testStop(true); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testStopImplicitMvccTransactions() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + testStop(false); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testStopExplicitMvccTransactionsReplicated() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + replicated = true; + + testStop(true); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testStopImplicitMvccTransactionsReplicated() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; replicated = true; testStop(false); @@ -128,8 +170,9 @@ public void testStopImplicitTransactionsReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopAtomic() throws Exception { - atomic = true; + atomicityMode = ATOMIC; testStop(false); } @@ -137,6 +180,7 @@ public void testStopAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopMultithreaded() throws Exception { try { startGrid(0); @@ -218,6 +262,7 @@ public void testStopMultithreaded() throws Exception { * @param node Node. * @param cache Cache. */ + @SuppressWarnings("unchecked") private void cacheOperations(Ignite node, IgniteCache cache) { ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -227,10 +272,12 @@ private void cacheOperations(Ignite node, IgniteCache cache) { cache.get(key); - try (Transaction tx = node.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - cache.put(key, key); + if (cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() != TRANSACTIONAL_SNAPSHOT) { + try (Transaction tx = node.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + cache.put(key, key); - tx.commit(); + tx.commit(); + } } try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { @@ -260,7 +307,7 @@ private void testStop(final boolean startTx) throws Exception { CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class); - assertEquals(atomic ? ATOMIC : TRANSACTIONAL, ccfg.getAtomicityMode()); + assertEquals(atomicityMode, ccfg.getAtomicityMode()); assertEquals(replicated ? REPLICATED : PARTITIONED, ccfg.getCacheMode()); Collection> putFuts = new ArrayList<>(); @@ -272,7 +319,8 @@ private void testStop(final boolean startTx) throws Exception { @Override public Void call() throws Exception { try { if (startTx) { - TransactionConcurrency concurrency = key % 2 == 0 ? OPTIMISTIC : PESSIMISTIC; + TransactionConcurrency concurrency = + atomicityMode != TRANSACTIONAL_SNAPSHOT && (key % 2 == 0) ? OPTIMISTIC : PESSIMISTIC; try (Transaction tx = grid(0).transactions().txStart(concurrency, REPEATABLE_READ)) { cache.put(key, key); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManagerDeserializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManagerDeserializationTest.java index a1623d2880497..0a97c53d2a818 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManagerDeserializationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManagerDeserializationTest.java @@ -39,10 +39,11 @@ import org.apache.ignite.internal.processors.cache.store.CacheLocalStore; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.marshaller.jdk.JdkMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -56,16 +57,21 @@ * https://issues.apache.org/jira/browse/IGNITE-2753 * */ +@RunWith(JUnit4.class) public class GridCacheStoreManagerDeserializationTest extends GridCommonAbstractTest { - /** IP finder. */ - protected static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache store. */ protected static final GridCacheLocalTestStore store = new GridCacheLocalTestStore(); /** Test cache name. */ protected static final String CACHE_NAME = "cache_name"; + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** * @return Cache mode. */ @@ -81,7 +87,6 @@ private CacheWriteSynchronizationMode cacheWriteSynchronizationMode() { } /** {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -90,12 +95,6 @@ private CacheWriteSynchronizationMode cacheWriteSynchronizationMode() { else c.setMarshaller(new JdkMarshaller()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - c.setCacheConfiguration(cacheConfiguration()); return c; @@ -124,7 +123,7 @@ protected CacheConfiguration cacheConfiguration() { cc.setBackups(0); - cc.setAtomicityMode(CacheAtomicityMode.ATOMIC); + cc.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); return cc; } @@ -144,6 +143,7 @@ protected CacheConfiguration cacheConfiguration() { * * @throws Exception If failed. */ + @Test public void testStream() throws Exception { final Ignite grid = startGrid(); @@ -169,6 +169,7 @@ public void testStream() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitionMove() throws Exception { final Ignite grid = startGrid("binaryGrid1"); @@ -203,13 +204,12 @@ public void testPartitionMove() throws Exception { } /** - * TODO GG-11148. - * * Check whether binary objects are stored without unmarshalling via stream API. * * @throws Exception If failed. */ - public void _testBinaryStream() throws Exception { + @Test + public void testBinaryStream() throws Exception { final Ignite grid = startGrid("binaryGrid"); final IgniteCache cache = grid.createCache(CACHE_NAME).withKeepBinary(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStorePutxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStorePutxSelfTest.java deleted file mode 100644 index 2175abb43d39e..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStorePutxSelfTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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. - */ - -package org.apache.ignite.internal.processors.cache; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.store.CacheStore; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.transactions.Transaction; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; - -/** - * Tests for reproduce problem with GG-6895: - * putx calls CacheStore.load() when null GridPredicate passed in to avoid IDE warnings - */ -public class GridCacheStorePutxSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static AtomicInteger loads; - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(TRANSACTIONAL); - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setCacheStoreFactory(singletonFactory(new TestStore())); - ccfg.setReadThrough(true); - ccfg.setWriteThrough(true); - ccfg.setLoadPreviousValue(true); - - cfg.setCacheConfiguration(ccfg); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - loads = new AtomicInteger(); - - startGrid(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopGrid(); - } - - /** - * @throws Exception If failed. - */ - public void testPutShouldNotTriggerLoad() throws Exception { - jcache().put(1, 1); - jcache().put(2, 2); - - assertEquals(0, loads.get()); - } - - /** - * @throws Exception If failed. - */ - public void testPutShouldNotTriggerLoadWithTx() throws Exception { - IgniteCache cache = jcache(); - - try (Transaction tx = grid().transactions().txStart()) { - cache.put(1, 1); - cache.put(2, 2); - - tx.commit(); - } - - assertEquals(0, loads.get()); - } - - /** */ - private static class TestStore implements CacheStore { - /** {@inheritDoc} */ - @Nullable @Override public Integer load(Integer key) { - loads.incrementAndGet(); - - return null; - } - - /** {@inheritDoc} */ - @Override public void loadCache(IgniteBiInClosure clo, @Nullable Object... args) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public Map loadAll(Iterable keys) { - return Collections.emptyMap(); - } - - /** {@inheritDoc} */ - @Override public void write(javax.cache.Cache.Entry entry) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void writeAll(Collection> entries) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void delete(Object key) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void deleteAll(Collection keys) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void sessionEnd(boolean commit) { - // No-op. - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreValueBytesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreValueBytesSelfTest.java index 237ae72544ee0..6a74c08956163 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreValueBytesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreValueBytesSelfTest.java @@ -22,10 +22,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -33,23 +33,15 @@ /** * Test for {@link CacheConfiguration#isStoreKeepBinary()}. */ +@RunWith(JUnit4.class) public class GridCacheStoreValueBytesSelfTest extends GridCommonAbstractTest { /** */ private boolean storeValBytes; - /** VM ip finder for TCP discovery. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration ccfg = defaultCacheConfiguration(); ccfg.setCacheMode(REPLICATED); @@ -74,6 +66,7 @@ public class GridCacheStoreValueBytesSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testEnabled() throws Exception { storeValBytes = true; @@ -92,4 +85,4 @@ public void testEnabled() throws Exception { assert entry.valueBytes() != null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapPreloadSelfTest.java deleted file mode 100644 index 261411fa52217..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapPreloadSelfTest.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * 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. - */ - -package org.apache.ignite.internal.processors.cache; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Random; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.Callable; -import java.util.concurrent.atomic.AtomicBoolean; -import javax.cache.Cache; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; -import static org.apache.ignite.cache.CacheMode.REPLICATED; -import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; - -/** - * Test for cache swap preloading. - */ -public class GridCacheSwapPreloadSelfTest extends GridCommonAbstractTest { - /** Entry count. */ - private static final int ENTRY_CNT = 15_000; - - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private CacheMode cacheMode; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - - cfg.setNetworkTimeout(2000); - - CacheConfiguration cacheCfg = defaultCacheConfiguration(); - - cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cacheCfg.setCacheMode(cacheMode); - cacheCfg.setRebalanceMode(SYNC); - cacheCfg.setAtomicityMode(TRANSACTIONAL); - - if (cacheMode == PARTITIONED) - cacheCfg.setBackups(1); - - cfg.setCacheConfiguration(cacheCfg); - - return cfg; - } - - /** @throws Exception If failed. */ - public void testSwapReplicated() throws Exception { - cacheMode = REPLICATED; - - checkSwap(); - } - - /** @throws Exception If failed. */ - public void testSwapPartitioned() throws Exception { - cacheMode = PARTITIONED; - - checkSwap(); - } - - /** @throws Exception If failed. */ - private void checkSwap() throws Exception { - try { - startGrid(0); - - IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); - - Set keys = new HashSet<>(); - - // Populate. - for (int i = 0; i < ENTRY_CNT; i++) { - keys.add(i); - - cache.put(i, i); - } - - info("Put finished."); - - // Evict all. - cache.localEvict(keys); - - info("Evict finished."); - - for (int i = 0; i < ENTRY_CNT; i++) - assertNull(cache.localPeek(i, CachePeekMode.ONHEAP)); - - assert cache.localSize(CachePeekMode.PRIMARY, CachePeekMode.BACKUP, CachePeekMode.NEAR, - CachePeekMode.ONHEAP) == 0; - - startGrid(1); - - int size = grid(1).cache(DEFAULT_CACHE_NAME).localSize(CachePeekMode.ALL); - - info("New node cache size: " + size); - - assertEquals(ENTRY_CNT, size); - } - finally { - stopAllGrids(); - } - } - - /** - * @throws Exception If failed. - */ - public void testSwapReplicatedMultithreaded() throws Exception { - cacheMode = REPLICATED; - - checkSwapMultithreaded(); - } - - /** @throws Exception If failed. */ - public void testSwapPartitionedMultithreaded() throws Exception { - cacheMode = PARTITIONED; - - checkSwapMultithreaded(); - } - - /** @throws Exception If failed. */ - private void checkSwapMultithreaded() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-614"); - - final AtomicBoolean done = new AtomicBoolean(); - IgniteInternalFuture fut = null; - - try { - startGrid(0); - - final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); - - assertNotNull(cache); - - // Populate. - for (int i = 0; i < ENTRY_CNT; i++) - cache.put(i, i); - - Set keys = new HashSet<>(); - - for (Cache.Entry entry : cache.localEntries()) - keys.add(entry.getKey()); - - cache.localEvict(keys); - - fut = multithreadedAsync(new Callable() { - @Nullable @Override public Object call() throws Exception { - Random rnd = new Random(); - - while (!done.get()) { - int key = rnd.nextInt(ENTRY_CNT); - - Integer i = cache.get(key); - - assertNotNull(i); - assertEquals(Integer.valueOf(key), i); - - cache.localEvict(Collections.singleton(rnd.nextInt(ENTRY_CNT))); - } - - return null; - } - }, 10); - - startGrid(1); - - done.set(true); - - fut.get(); - - fut = null; - - int size = grid(1).cache(DEFAULT_CACHE_NAME).localSize(CachePeekMode.PRIMARY, CachePeekMode.BACKUP, - CachePeekMode.NEAR, CachePeekMode.ONHEAP); - - info("New node cache size: " + size); - - if (size != ENTRY_CNT) { - Set keySet = new TreeSet<>(); - - int next = 0; - - for (IgniteCache.Entry e : grid(1).cache(DEFAULT_CACHE_NAME).localEntries()) - keySet.add(e.getKey()); - - for (Integer i : keySet) { - while (next < i) - info("Missing key: " + next++); - - next++; - } - } - - assertEquals(ENTRY_CNT, size); - } - finally { - done.set(true); - - try { - if (fut != null) - fut.get(); - } - finally { - stopAllGrids(); - } - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTcpClientDiscoveryMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTcpClientDiscoveryMultiThreadedTest.java index 8a2f5d5bc8521..0bb3cd56d8f20 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTcpClientDiscoveryMultiThreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTcpClientDiscoveryMultiThreadedTest.java @@ -31,12 +31,16 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Tests {@link TcpDiscoverySpi} in client mode with multiple client nodes that interact with a cache concurrently. */ +@RunWith(JUnit4.class) public class GridCacheTcpClientDiscoveryMultiThreadedTest extends GridCacheAbstractSelfTest { /** Server nodes count. */ private static int srvNodesCnt; @@ -104,6 +108,7 @@ public class GridCacheTcpClientDiscoveryMultiThreadedTest extends GridCacheAbstr /** * @throws Exception If failed. */ + @Test public void testCacheConcurrentlyWithMultipleClientNodes() throws Exception { srvNodesCnt = 2; clientNodesCnt = 3; @@ -190,4 +195,4 @@ private void performSimpleOperationsOnCache(IgniteCache cache) for (int i = 100; i < 200; i++) assertEquals(i, (int) cache.get(i)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java index cc634fae5daca..6e640110afd76 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java @@ -911,18 +911,21 @@ GridCacheMvccCandidate anyOwner() { return false; } + /** {@inheritDoc} */ + @Nullable @Override public CacheObject mvccPeek(boolean onheapOnly) { + return null; + } + /** {@inheritDoc} */ @Nullable @Override public CacheObject peek(boolean heap, boolean offheap, AffinityTopologyVersion topVer, - @Nullable IgniteCacheExpiryPolicy plc) - { + @Nullable IgniteCacheExpiryPolicy plc) { return null; } /** {@inheritDoc} */ - @Nullable @Override public CacheObject peek( - @Nullable IgniteCacheExpiryPolicy plc) + @Nullable @Override public CacheObject peek() throws GridCacheEntryRemovedException, IgniteCheckedException { return null; } @@ -960,7 +963,7 @@ GridCacheMvccCandidate anyOwner() { } /** {@inheritDoc} */ - @Override public void touch(AffinityTopologyVersion topVer) { - context().evicts().touch(this, topVer); + @Override public void touch() { + context().evicts().touch(this); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java index c4458797dde9f..e3d9a5ca8f702 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionMetrics; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -37,6 +40,7 @@ /** * Transactional cache metrics test. */ +@RunWith(JUnit4.class) public abstract class GridCacheTransactionalAbstractMetricsSelfTest extends GridCacheAbstractMetricsSelfTest { /** */ private static final int TX_CNT = 3; @@ -47,6 +51,7 @@ public abstract class GridCacheTransactionalAbstractMetricsSelfTest extends Grid /** * @throws Exception If failed. */ + @Test public void testOptimisticReadCommittedCommits() throws Exception { testCommits(OPTIMISTIC, READ_COMMITTED, true); } @@ -54,6 +59,7 @@ public void testOptimisticReadCommittedCommits() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticReadCommittedCommitsNoData() throws Exception { testCommits(OPTIMISTIC, READ_COMMITTED, false); } @@ -61,6 +67,7 @@ public void testOptimisticReadCommittedCommitsNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticRepeatableReadCommits() throws Exception { testCommits(OPTIMISTIC, REPEATABLE_READ, true); } @@ -68,6 +75,7 @@ public void testOptimisticRepeatableReadCommits() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticRepeatableReadCommitsNoData() throws Exception { testCommits(OPTIMISTIC, REPEATABLE_READ, false); } @@ -75,6 +83,7 @@ public void testOptimisticRepeatableReadCommitsNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableCommits() throws Exception { testCommits(OPTIMISTIC, SERIALIZABLE, true); } @@ -82,6 +91,7 @@ public void testOptimisticSerializableCommits() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableCommitsNoData() throws Exception { testCommits(OPTIMISTIC, SERIALIZABLE, false); } @@ -89,6 +99,7 @@ public void testOptimisticSerializableCommitsNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticReadCommittedCommits() throws Exception { testCommits(PESSIMISTIC, READ_COMMITTED, true); } @@ -96,6 +107,7 @@ public void testPessimisticReadCommittedCommits() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticReadCommittedCommitsNoData() throws Exception { testCommits(PESSIMISTIC, READ_COMMITTED, false); } @@ -103,6 +115,7 @@ public void testPessimisticReadCommittedCommitsNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticRepeatableReadCommits() throws Exception { testCommits(PESSIMISTIC, REPEATABLE_READ, true); } @@ -110,6 +123,7 @@ public void testPessimisticRepeatableReadCommits() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticRepeatableReadCommitsNoData() throws Exception { testCommits(PESSIMISTIC, REPEATABLE_READ, false); } @@ -117,6 +131,7 @@ public void testPessimisticRepeatableReadCommitsNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticSerializableCommits() throws Exception { testCommits(PESSIMISTIC, SERIALIZABLE, true); } @@ -124,6 +139,7 @@ public void testPessimisticSerializableCommits() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticSerializableCommitsNoData() throws Exception { testCommits(PESSIMISTIC, SERIALIZABLE, false); } @@ -131,6 +147,7 @@ public void testPessimisticSerializableCommitsNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticReadCommittedRollbacks() throws Exception { testRollbacks(OPTIMISTIC, READ_COMMITTED, true); } @@ -138,6 +155,7 @@ public void testOptimisticReadCommittedRollbacks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticReadCommittedRollbacksNoData() throws Exception { testRollbacks(OPTIMISTIC, READ_COMMITTED, false); } @@ -145,6 +163,7 @@ public void testOptimisticReadCommittedRollbacksNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticRepeatableReadRollbacks() throws Exception { testRollbacks(OPTIMISTIC, REPEATABLE_READ, true); } @@ -152,6 +171,7 @@ public void testOptimisticRepeatableReadRollbacks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticRepeatableReadRollbacksNoData() throws Exception { testRollbacks(OPTIMISTIC, REPEATABLE_READ, false); } @@ -159,6 +179,7 @@ public void testOptimisticRepeatableReadRollbacksNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableRollbacks() throws Exception { testRollbacks(OPTIMISTIC, SERIALIZABLE, true); } @@ -166,6 +187,7 @@ public void testOptimisticSerializableRollbacks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableRollbacksNoData() throws Exception { testRollbacks(OPTIMISTIC, SERIALIZABLE, false); } @@ -173,6 +195,7 @@ public void testOptimisticSerializableRollbacksNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticReadCommittedRollbacks() throws Exception { testRollbacks(PESSIMISTIC, READ_COMMITTED, true); } @@ -180,6 +203,7 @@ public void testPessimisticReadCommittedRollbacks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticReadCommittedRollbacksNoData() throws Exception { testRollbacks(PESSIMISTIC, READ_COMMITTED, false); } @@ -187,6 +211,7 @@ public void testPessimisticReadCommittedRollbacksNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticRepeatableReadRollbacks() throws Exception { testRollbacks(PESSIMISTIC, REPEATABLE_READ, true); } @@ -194,6 +219,7 @@ public void testPessimisticRepeatableReadRollbacks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticRepeatableReadRollbacksNoData() throws Exception { testRollbacks(PESSIMISTIC, REPEATABLE_READ, false); } @@ -201,6 +227,7 @@ public void testPessimisticRepeatableReadRollbacksNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticSerializableRollbacks() throws Exception { testRollbacks(PESSIMISTIC, SERIALIZABLE, true); } @@ -208,6 +235,7 @@ public void testPessimisticSerializableRollbacks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticSerializableRollbacksNoData() throws Exception { testRollbacks(PESSIMISTIC, SERIALIZABLE, false); } @@ -215,6 +243,7 @@ public void testPessimisticSerializableRollbacksNoData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSuspendedReadCommittedTxTimeoutRollbacks() throws Exception { doTestSuspendedTxTimeoutRollbacks(OPTIMISTIC, READ_COMMITTED); } @@ -222,6 +251,7 @@ public void testOptimisticSuspendedReadCommittedTxTimeoutRollbacks() throws Exce /** * @throws Exception If failed. */ + @Test public void testOptimisticSuspendedRepeatableReadTxTimeoutRollbacks() throws Exception { doTestSuspendedTxTimeoutRollbacks(OPTIMISTIC, REPEATABLE_READ); } @@ -229,6 +259,7 @@ public void testOptimisticSuspendedRepeatableReadTxTimeoutRollbacks() throws Exc /** * @throws Exception If failed. */ + @Test public void testOptimisticSuspendedSerializableTxTimeoutRollbacks() throws Exception { doTestSuspendedTxTimeoutRollbacks(OPTIMISTIC, SERIALIZABLE); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java index 66ef47c8be5d2..dab80fddf2e3d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerEvictionSelfTest.java @@ -28,14 +28,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * TTL manager eviction self test. */ +@RunWith(JUnit4.class) public class GridCacheTtlManagerEvictionSelfTest extends GridCommonAbstractTest { /** */ private static final int ENTRIES_TO_PUT = 10_100; @@ -43,21 +45,20 @@ public class GridCacheTtlManagerEvictionSelfTest extends GridCommonAbstractTest /** */ private static final int ENTRIES_LIMIT = 1_000; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache mode. */ private volatile CacheMode cacheMode; /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); - discoSpi.setIpFinder(IP_FINDER); + super.beforeTestsStarted(); + } - cfg.setDiscoverySpi(discoSpi); + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -75,6 +76,7 @@ public class GridCacheTtlManagerEvictionSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testLocalEviction() throws Exception { checkEviction(CacheMode.LOCAL); } @@ -82,6 +84,7 @@ public void testLocalEviction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionedEviction() throws Exception { checkEviction(CacheMode.PARTITIONED); } @@ -89,6 +92,7 @@ public void testPartitionedEviction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedEviction() throws Exception { checkEviction(CacheMode.REPLICATED); } @@ -131,4 +135,4 @@ private void checkEviction(CacheMode mode) throws Exception { Ignition.stopAll(true); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerLoadTest.java index b117c86c806c9..f8fe56097d1ce 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerLoadTest.java @@ -25,6 +25,9 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -32,10 +35,12 @@ /** * Check ttl manager for memory leak. */ +@RunWith(JUnit4.class) public class GridCacheTtlManagerLoadTest extends GridCacheTtlManagerSelfTest { /** * @throws Exception If failed. */ + @Test public void testLoad() throws Exception { cacheMode = REPLICATED; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerNotificationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerNotificationTest.java index d25b2af645ce6..4bc0b98623b99 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerNotificationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerNotificationTest.java @@ -33,12 +33,12 @@ import org.apache.ignite.events.Event; import org.apache.ignite.events.EventType; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.eclipse.jetty.util.BlockingArrayQueue; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; @@ -46,6 +46,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheTtlManagerNotificationTest extends GridCommonAbstractTest { /** Count of caches in multi caches test. */ private static final int CACHES_CNT = 10; @@ -53,9 +54,6 @@ public class GridCacheTtlManagerNotificationTest extends GridCommonAbstractTest /** Prefix for cache name fir multi caches test. */ private static final String CACHE_PREFIX = "cache-"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Test cache mode. */ protected CacheMode cacheMode; @@ -63,12 +61,6 @@ public class GridCacheTtlManagerNotificationTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - CacheConfiguration[] ccfgs = new CacheConfiguration[CACHES_CNT + 1]; ccfgs[0] = createCacheConfiguration(DEFAULT_CACHE_NAME); @@ -98,6 +90,7 @@ private CacheConfiguration createCacheConfiguration(String name) { /** * @throws Exception If failed. */ + @Test public void testThatNotificationWorkAsExpected() throws Exception { try (final Ignite g = startGrid(0)) { final BlockingArrayQueue queue = new BlockingArrayQueue<>(); @@ -134,6 +127,7 @@ public void testThatNotificationWorkAsExpected() throws Exception { * * @throws Exception If failed. */ + @Test public void testThatNotificationWorkAsExpectedInMultithreadedMode() throws Exception { final CyclicBarrier barrier = new CyclicBarrier(21); final AtomicInteger keysRangeGen = new AtomicInteger(); @@ -185,6 +179,7 @@ public void testThatNotificationWorkAsExpectedInMultithreadedMode() throws Excep * * @throws Exception If failed. */ + @Test public void testThatNotificationWorkAsExpectedManyCaches() throws Exception { final int smallDuration = 4_000; @@ -294,4 +289,4 @@ private static class CacheFiller implements Runnable { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerSelfTest.java index 52f19b78ca65a..1648ff3cd742f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManagerSelfTest.java @@ -25,11 +25,12 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.CAX; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -39,22 +40,21 @@ /** * TTL manager self test. */ +@RunWith(JUnit4.class) public class GridCacheTtlManagerSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Test cache mode. */ protected CacheMode cacheMode; /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); - discoSpi.setIpFinder(IP_FINDER); + super.beforeTestsStarted(); + } - cfg.setDiscoverySpi(discoSpi); + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -69,6 +69,7 @@ public class GridCacheTtlManagerSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testLocalTtl() throws Exception { checkTtl(LOCAL); } @@ -76,6 +77,7 @@ public void testLocalTtl() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionedTtl() throws Exception { checkTtl(PARTITIONED); } @@ -83,6 +85,7 @@ public void testPartitionedTtl() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedTtl() throws Exception { checkTtl(REPLICATED); } @@ -121,4 +124,4 @@ private void checkTtl(CacheMode mode) throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java index 272665b7555d5..9000c95f51e11 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -27,6 +28,13 @@ * */ public class GridCacheTxPartitionedLocalStoreSelfTest extends GridCacheAbstractLocalStoreSelfTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode getAtomicMode() { return TRANSACTIONAL; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheUtilsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheUtilsSelfTest.java index e28daf335f633..8dc33e6a8632e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheUtilsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheUtilsSelfTest.java @@ -35,10 +35,14 @@ import org.apache.ignite.marshaller.MarshallerContextTestImpl; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid cache utils test. */ +@RunWith(JUnit4.class) public class GridCacheUtilsSelfTest extends GridCommonAbstractTest { /** * Does not override equals and hashCode. @@ -74,7 +78,6 @@ private static class WrongEquals { * @param obj Object. * @return {@code False}. */ - @SuppressWarnings("CovariantEquals") @Override public boolean equals(Object obj) { return false; } @@ -118,7 +121,7 @@ private static class ExtendsClassWithEqualsAndHashCode2 extends EqualsAndHashCod /** */ - @SuppressWarnings("ResultOfMethodCallIgnored") + @Test public void testCacheKeyValidation() throws IgniteCheckedException { CU.validateCacheKey("key"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytesPreloadingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytesPreloadingSelfTest.java index e32d8aaa63bef..2d0eed043b95d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytesPreloadingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytesPreloadingSelfTest.java @@ -22,6 +22,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -30,6 +33,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheValueBytesPreloadingSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -61,6 +65,7 @@ protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throw /** * @throws Exception If failed. */ + @Test public void testOnHeapTiered() throws Exception { startGrids(1); @@ -108,4 +113,4 @@ private void checkByteArrays() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java index 19f98ff8ab373..9f0a564500de3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheValueConsistencyAbstractSelfTest.java @@ -26,6 +26,10 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -35,6 +39,7 @@ /** * */ +@RunWith(JUnit4.class) public abstract class GridCacheValueConsistencyAbstractSelfTest extends GridCacheAbstractSelfTest { /** Number of threads for test. */ private static final int THREAD_CNT = 16; @@ -76,6 +81,14 @@ public abstract class GridCacheValueConsistencyAbstractSelfTest extends GridCach super.beforeTestsStarted(); } + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + if (nearEnabled()) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + } + /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { super.afterTestsStopped(); @@ -98,6 +111,7 @@ public abstract class GridCacheValueConsistencyAbstractSelfTest extends GridCach /** * @throws Exception If failed. */ + @Test public void testPutRemove() throws Exception { awaitPartitionMapExchange(); @@ -156,6 +170,7 @@ public void testPutRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemoveAll() throws Exception { awaitPartitionMapExchange(); @@ -219,6 +234,7 @@ public void testPutRemoveAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutConsistencyMultithreaded() throws Exception { if (nearEnabled()) fail("https://issues.apache.org/jira/browse/IGNITE-627"); @@ -272,6 +288,7 @@ public void testPutConsistencyMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemoveConsistencyMultithreaded() throws Exception { if (nearEnabled()) fail("https://issues.apache.org/jira/browse/IGNITE-627"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java index 25817a191c3ee..7756d4c70f882 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVariableTopologySelfTest.java @@ -31,13 +31,14 @@ import org.apache.ignite.internal.util.typedef.CAX; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionRollbackException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -45,12 +46,18 @@ /** * Affinity routing tests. */ +@RunWith(JUnit4.class) public class GridCacheVariableTopologySelfTest extends GridCommonAbstractTest { /** */ private static final Random RAND = new Random(); - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-7388"); + + super.setUp(); + } /** Constructs test. */ public GridCacheVariableTopologySelfTest() { @@ -61,12 +68,6 @@ public GridCacheVariableTopologySelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - // Default cache configuration. CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -108,6 +109,7 @@ private void startGrids(int cnt, int startIdx) throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testNodeStop() throws Exception { // -- Test parameters. -- // int nodeCnt = 3; @@ -201,4 +203,4 @@ public void testNodeStop() throws Exception { //debugFut.get(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionMultinodeTest.java index 0fd3fb9ca5ca3..bb604093e770e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionMultinodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionMultinodeTest.java @@ -30,9 +30,14 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.jetbrains.annotations.Nullable; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -41,6 +46,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheVersionMultinodeTest extends GridCacheAbstractSelfTest { /** */ private CacheAtomicityMode atomicityMode; @@ -89,6 +95,7 @@ public class GridCacheVersionMultinodeTest extends GridCacheAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testVersionTx() throws Exception { atomicityMode = TRANSACTIONAL; @@ -98,6 +105,7 @@ public void testVersionTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersionTxNearEnabled() throws Exception { atomicityMode = TRANSACTIONAL; @@ -109,6 +117,31 @@ public void testVersionTxNearEnabled() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testVersionMvccTx() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + checkVersion(); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testVersionMvccTxNearEnabled() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + near = true; + + checkVersion(); + } + + /** + * @throws Exception If failed. + */ + @Test public void testVersionAtomicPrimary() throws Exception { atomicityMode = ATOMIC; @@ -118,6 +151,7 @@ public void testVersionAtomicPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersionAtomicPrimaryNearEnabled() throws Exception { atomicityMode = ATOMIC; @@ -138,17 +172,19 @@ private void checkVersion() throws Exception { checkVersion(String.valueOf(i), null); // Update. } - if (atomicityMode == TRANSACTIONAL) { + if (atomicityMode != ATOMIC) { for (int i = 100; i < 200; i++) { checkVersion(String.valueOf(i), PESSIMISTIC); // Create. checkVersion(String.valueOf(i), PESSIMISTIC); // Update. } - for (int i = 200; i < 300; i++) { - checkVersion(String.valueOf(i), OPTIMISTIC); // Create. + if (atomicityMode != TRANSACTIONAL_SNAPSHOT) { + for (int i = 200; i < 300; i++) { + checkVersion(String.valueOf(i), OPTIMISTIC); // Create. - checkVersion(String.valueOf(i), OPTIMISTIC); // Update. + checkVersion(String.valueOf(i), OPTIMISTIC); // Update. + } } } } @@ -224,4 +260,4 @@ private void checkEntryVersion(String key) throws Exception { assertTrue(verified); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionSelfTest.java index 9cec7ecf7b270..f70dfd25c8d8a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionSelfTest.java @@ -23,14 +23,19 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheVersionSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTopologyVersionDrId() throws Exception { GridCacheVersion ver = version(10, 0); @@ -76,6 +81,7 @@ public void testTopologyVersionDrId() throws Exception { * * @throws Exception If failed. */ + @Test public void testMarshalling() throws Exception { GridCacheVersion ver = version(1, 1); GridCacheVersionEx verEx = new GridCacheVersionEx(2, 2, 0, ver); @@ -100,4 +106,4 @@ public void testMarshalling() throws Exception { private GridCacheVersion version(int nodeOrder, int drId) { return new GridCacheVersion(0, 0, nodeOrder, drId); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionTopologyChangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionTopologyChangeTest.java index 5c9ecd71f6d13..b4f7981396f11 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionTopologyChangeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionTopologyChangeTest.java @@ -31,32 +31,22 @@ import org.apache.ignite.cache.affinity.AffinityFunction; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils.SF; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class GridCacheVersionTopologyChangeTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -67,6 +57,7 @@ public class GridCacheVersionTopologyChangeTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testVersionIncreaseAtomic() throws Exception { checkVersionIncrease(cacheConfigurations(ATOMIC)); } @@ -74,10 +65,19 @@ public void testVersionIncreaseAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersionIncreaseTx() throws Exception { checkVersionIncrease(cacheConfigurations(TRANSACTIONAL)); } + /** + * @throws Exception If failed. + */ + @Test + public void testVersionIncreaseMvccTx() throws Exception { + checkVersionIncrease(cacheConfigurations(TRANSACTIONAL_SNAPSHOT)); + } + /** * @param ccfgs Cache configurations. * @throws Exception If failed. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridDataStorageConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridDataStorageConfigurationConsistencySelfTest.java index 3c728f7898045..fe730bb2ddf50 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridDataStorageConfigurationConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridDataStorageConfigurationConsistencySelfTest.java @@ -21,28 +21,21 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests a check of memory configuration consistency. */ +@RunWith(JUnit4.class) public class GridDataStorageConfigurationConsistencySelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - DataStorageConfiguration memCfg = new DataStorageConfiguration(); // Nodes will have different page size. @@ -56,6 +49,7 @@ public class GridDataStorageConfigurationConsistencySelfTest extends GridCommonA /** * @throws Exception If failed. */ + @Test public void testMemoryConfigurationConsistency() throws Exception { GridTestUtils.assertThrows(log, new Callable() { /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridEvictionPolicyMBeansTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridEvictionPolicyMBeansTest.java index b093bb2f33307..d9ab3ab6b45cc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridEvictionPolicyMBeansTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridEvictionPolicyMBeansTest.java @@ -25,17 +25,29 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.IgniteUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for the eviction policy JMX beans registered by the kernal. */ +@RunWith(JUnit4.class) public class GridEvictionPolicyMBeansTest extends GridCommonAbstractTest { /** Create test and auto-start the grid */ public GridEvictionPolicyMBeansTest() { super(true); } + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + + super.beforeTestsStarted(); + } + /** * {@inheritDoc} * @@ -60,8 +72,6 @@ public GridEvictionPolicyMBeansTest() { ncf.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(40, 10, 500)); - cache1.setNearConfiguration(ncf); - CacheConfiguration cache2 = defaultCacheConfiguration(); cache2.setName("cache2"); @@ -81,7 +91,11 @@ public GridEvictionPolicyMBeansTest() { lep.setMaxMemorySize(500); lep.setMaxSize(40); ncf.setNearEvictionPolicy(lep); - cache2.setNearConfiguration(ncf); + + if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) { + cache1.setNearConfiguration(ncf); + cache2.setNearConfiguration(ncf); + } cfg.setCacheConfiguration(cache1, cache2); @@ -89,22 +103,27 @@ public GridEvictionPolicyMBeansTest() { } /** Check that eviction bean is available */ + @Test public void testEvictionPolicyBeans() throws Exception{ checkBean("cache1", "org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy", "MaxSize", 100); checkBean("cache1", "org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy", "BatchSize", 10); checkBean("cache1", "org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy", "MaxMemorySize", 20L); - checkBean("cache1-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxSize", 40); - checkBean("cache1-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "BatchSize", 10); - checkBean("cache1-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxMemorySize", 500L); + if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) { + checkBean("cache1-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxSize", 40); + checkBean("cache1-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "BatchSize", 10); + checkBean("cache1-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxMemorySize", 500L); + } checkBean("cache2", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxSize", 30); checkBean("cache2", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "BatchSize", 10); checkBean("cache2", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxMemorySize", 125L); - checkBean("cache2-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxSize", 40); - checkBean("cache2-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "BatchSize", 10); - checkBean("cache2-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxMemorySize", 500L); + if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) { + checkBean("cache2-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxSize", 40); + checkBean("cache2-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "BatchSize", 10); + checkBean("cache2-near", "org.apache.ignite.cache.eviction.lru.LruEvictionPolicy", "MaxMemorySize", 500L); + } } /** Checks that a bean with the specified group and name is available and has the expected attribute */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalCacheStoreManagerDeserializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalCacheStoreManagerDeserializationTest.java index 827b3cf3a1e54..c2fea0cfc94c9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalCacheStoreManagerDeserializationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalCacheStoreManagerDeserializationTest.java @@ -27,6 +27,9 @@ import javax.cache.expiry.ExpiryPolicy; import java.util.UUID; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks whether storing to local store doesn't cause binary objects unmarshalling, @@ -36,6 +39,7 @@ * https://issues.apache.org/jira/browse/IGNITE-2753 * */ +@RunWith(JUnit4.class) public class GridLocalCacheStoreManagerDeserializationTest extends GridCacheStoreManagerDeserializationTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -50,6 +54,7 @@ public class GridLocalCacheStoreManagerDeserializationTest extends GridCacheStor * * @throws Exception */ + @Test public void testUpdate() throws Exception { // Goal is to check correct saving to store (no exception must be thrown) @@ -78,6 +83,7 @@ public void testUpdate() throws Exception { * * @throws Exception */ + @Test public void testBinaryUpdate() throws Exception { // Goal is to check correct saving to store (no exception must be thrown) final Ignite grid = startGrid("binaryGrid"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalIgniteSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalIgniteSerializationTest.java index 00b3137149742..1ced797f3f8aa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalIgniteSerializationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalIgniteSerializationTest.java @@ -39,10 +39,14 @@ import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for local Ignite instance processing during serialization/deserialization. */ +@RunWith(JUnit4.class) public class GridLocalIgniteSerializationTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "cache_name"; @@ -63,6 +67,7 @@ public class GridLocalIgniteSerializationTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testPutGetSimple() throws Exception { checkPutGet(new SimpleTestObject("one"), null); } @@ -70,6 +75,7 @@ public void testPutGetSimple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetSerializable() throws Exception { checkPutGet(new SerializableTestObject("test"), null); } @@ -77,6 +83,7 @@ public void testPutGetSerializable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetExternalizable() throws Exception { checkPutGet(new ExternalizableTestObject("test"), null); } @@ -84,6 +91,7 @@ public void testPutGetExternalizable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetBinarylizable() throws Exception { checkPutGet(new BinarylizableTestObject("test"), "binaryIgnite"); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridProjectionForCachesOnDaemonNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridProjectionForCachesOnDaemonNodeSelfTest.java index 85b237323191f..068ebcffa010f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridProjectionForCachesOnDaemonNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridProjectionForCachesOnDaemonNodeSelfTest.java @@ -21,19 +21,16 @@ import org.apache.ignite.cluster.ClusterGroup; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests of cache related cluster projections for daemon node. */ +@RunWith(JUnit4.class) public class GridProjectionForCachesOnDaemonNodeSelfTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Daemon node. */ private static boolean daemonNode; @@ -47,24 +44,11 @@ public class GridProjectionForCachesOnDaemonNodeSelfTest extends GridCommonAbstr @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(discoverySpi()); - cfg.setDaemon(daemonNode); return cfg; } - /** - * @return Discovery SPI; - */ - private DiscoverySpi discoverySpi() { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - return spi; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { ignite = startGrid(0); @@ -89,6 +73,7 @@ private DiscoverySpi discoverySpi() { /** * @throws Exception If failed. */ + @Test public void testForDataNodes() throws Exception { ClusterGroup grp = ignite.cluster().forDataNodes(DEFAULT_CACHE_NAME); @@ -107,6 +92,7 @@ public void testForDataNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForClientNodes() throws Exception { ClusterGroup grp = ignite.cluster().forClientNodes(DEFAULT_CACHE_NAME); @@ -125,6 +111,7 @@ public void testForClientNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForCacheNodes() throws Exception { ClusterGroup grp = ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteAbstractDynamicCacheStartFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteAbstractDynamicCacheStartFailTest.java index db13c11d1a947..ee3a8e0816be6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteAbstractDynamicCacheStartFailTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteAbstractDynamicCacheStartFailTest.java @@ -1,786 +1,1200 @@ -/* - * 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. - */ - -package org.apache.ignite.internal.processors.cache; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicInteger; -import javax.cache.CacheException; -import javax.cache.configuration.Factory; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.affinity.AffinityFunctionContext; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; -import org.apache.ignite.cache.query.annotations.QuerySqlField; -import org.apache.ignite.cache.store.CacheStore; -import org.apache.ignite.cluster.BaselineNode; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.testframework.GridTestUtils; - -/** - * Tests the recovery after a dynamic cache start failure. - */ -public abstract class IgniteAbstractDynamicCacheStartFailTest extends GridCacheAbstractSelfTest { - /** */ - private static final String DYNAMIC_CACHE_NAME = "TestDynamicCache"; - - /** */ - private static final String CLIENT_GRID_NAME = "client"; - - /** */ - protected static final String EXISTING_CACHE_NAME = "existing-cache";; - - /** */ - private static final int PARTITION_COUNT = 16; - - /** Coordinator node index. */ - private int crdIdx = 0; - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 3; - } - - /** - * Returns {@code true} if persistence is enabled. - * - * @return {@code true} if persistence is enabled. - */ - protected boolean persistenceEnabled() { - return false; - } - - /** - * @throws Exception If failed. - */ - public void testBrokenAffinityFunStartOnServerFailedOnClient() throws Exception { - final String clientName = CLIENT_GRID_NAME + "testBrokenAffinityFunStartOnServerFailedOnClient"; - - IgniteConfiguration clientCfg = getConfiguration(clientName); - - clientCfg.setClientMode(true); - - Ignite client = startGrid(clientName, clientCfg); - - CacheConfiguration cfg = new CacheConfiguration(); - - cfg.setName(DYNAMIC_CACHE_NAME + "-server-1"); - - cfg.setAffinity(new BrokenAffinityFunction(false, clientName)); - - try { - IgniteCache cache = ignite(0).getOrCreateCache(cfg); - } - catch (CacheException e) { - fail("Exception should not be thrown."); - } - - stopGrid(clientName); - } - - /** - * @throws Exception If failed. - */ - public void testBrokenAffinityFunStartOnServerFailedOnServer() throws Exception { - final String clientName = CLIENT_GRID_NAME + "testBrokenAffinityFunStartOnServerFailedOnServer"; - - IgniteConfiguration clientCfg = getConfiguration(clientName); - - clientCfg.setClientMode(true); - - Ignite client = startGrid(clientName, clientCfg); - - CacheConfiguration cfg = new CacheConfiguration(); - - cfg.setName(DYNAMIC_CACHE_NAME + "-server-2"); - - cfg.setAffinity(new BrokenAffinityFunction(false, getTestIgniteInstanceName(0))); - - try { - IgniteCache cache = ignite(0).getOrCreateCache(cfg); - - fail("Expected exception was not thrown."); - } - catch (CacheException e) { - } - - stopGrid(clientName); - } - - /** - * @throws Exception If failed. - */ - public void testBrokenAffinityFunStartOnClientFailOnServer() throws Exception { - final String clientName = CLIENT_GRID_NAME + "testBrokenAffinityFunStartOnClientFailOnServer"; - - IgniteConfiguration clientCfg = getConfiguration(clientName); - - clientCfg.setClientMode(true); - - Ignite client = startGrid(clientName, clientCfg); - - CacheConfiguration cfg = new CacheConfiguration(); - - cfg.setName(DYNAMIC_CACHE_NAME + "-client-2"); - - cfg.setAffinity(new BrokenAffinityFunction(false, getTestIgniteInstanceName(0))); - - try { - IgniteCache cache = client.getOrCreateCache(cfg); - - fail("Expected exception was not thrown."); - } - catch (CacheException e) { - } - - stopGrid(clientName); - } - - /** - * Test cache start with broken affinity function that throws an exception on all nodes. - */ - public void testBrokenAffinityFunOnAllNodes() { - final boolean failOnAllNodes = true; - final int unluckyNode = 0; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = 0; - - testDynamicCacheStart( - createCacheConfigsWithBrokenAffinityFun( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Test cache start with broken affinity function that throws an exception on initiator node. - */ - public void testBrokenAffinityFunOnInitiator() { - final boolean failOnAllNodes = false; - final int unluckyNode = 1; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = 1; - - testDynamicCacheStart( - createCacheConfigsWithBrokenAffinityFun( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Test cache start with broken affinity function that throws an exception on non-initiator node. - */ - public void testBrokenAffinityFunOnNonInitiator() { - final boolean failOnAllNodes = false; - final int unluckyNode = 1; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = 2; - - testDynamicCacheStart( - createCacheConfigsWithBrokenAffinityFun( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Test cache start with broken affinity function that throws an exception on coordinator node. - */ - public void testBrokenAffinityFunOnCoordinatorDiffInitiator() { - final boolean failOnAllNodes = false; - final int unluckyNode = crdIdx; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = (crdIdx + 1) % gridCount(); - - testDynamicCacheStart( - createCacheConfigsWithBrokenAffinityFun( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Test cache start with broken affinity function that throws an exception on initiator node. - */ - public void testBrokenAffinityFunOnCoordinator() { - final boolean failOnAllNodes = false; - final int unluckyNode = crdIdx; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = crdIdx; - - testDynamicCacheStart( - createCacheConfigsWithBrokenAffinityFun( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Tests cache start with node filter and broken affinity function that throws an exception on initiator node. - */ - public void testBrokenAffinityFunWithNodeFilter() { - final boolean failOnAllNodes = false; - final int unluckyNode = 0; - final int unluckyCfg = 0; - final int numOfCaches = 1; - final int initiator = 0; - - testDynamicCacheStart( - createCacheConfigsWithBrokenAffinityFun( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, true), - initiator); - } - - /** - * Tests cache start with broken cache store that throws an exception on all nodes. - */ - public void testBrokenCacheStoreOnAllNodes() { - final boolean failOnAllNodes = true; - final int unluckyNode = 0; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = 0; - - testDynamicCacheStart( - createCacheConfigsWithBrokenCacheStore( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Tests cache start with broken cache store that throws an exception on initiator node. - */ - public void testBrokenCacheStoreOnInitiator() { - final boolean failOnAllNodes = false; - final int unluckyNode = 1; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = 1; - - testDynamicCacheStart( - createCacheConfigsWithBrokenCacheStore( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Tests cache start with broken cache store that throws an exception on non-initiator node. - */ - public void testBrokenCacheStoreOnNonInitiator() { - final boolean failOnAllNodes = false; - final int unluckyNode = 1; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = 2; - - testDynamicCacheStart( - createCacheConfigsWithBrokenCacheStore( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Tests cache start with broken cache store that throws an exception on initiator node. - */ - public void testBrokenCacheStoreOnCoordinatorDiffInitiator() { - final boolean failOnAllNodes = false; - final int unluckyNode = crdIdx; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = (crdIdx + 1) % gridCount(); - - testDynamicCacheStart( - createCacheConfigsWithBrokenCacheStore( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Tests cache start with broken cache store that throws an exception on coordinator node. - */ - public void testBrokenCacheStoreFunOnCoordinator() { - final boolean failOnAllNodes = false; - final int unluckyNode = crdIdx; - final int unluckyCfg = 1; - final int numOfCaches = 3; - final int initiator = crdIdx; - - testDynamicCacheStart( - createCacheConfigsWithBrokenCacheStore( - failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), - initiator); - } - - /** - * Tests multiple creation of cache with broken affinity function. - */ - public void testCreateCacheMultipleTimes() { - final boolean failOnAllNodes = false; - final int unluckyNode = 1; - final int unluckyCfg = 0; - final int numOfAttempts = 15; - - CacheConfiguration cfg = createCacheConfigsWithBrokenAffinityFun( - failOnAllNodes, unluckyNode, unluckyCfg, 1, false).get(0); - - for (int i = 0; i < numOfAttempts; ++i) { - try { - IgniteCache cache = ignite(0).getOrCreateCache(cfg); - - fail("Expected exception was not thrown"); - } - catch (CacheException e) { - } - } - } - - /** - * Tests that a cache with the same name can be started after failure if cache configuration is corrected. - * - * @throws Exception If test failed. - */ - public void testCacheStartAfterFailure() throws Exception { - CacheConfiguration cfg = createCacheConfigsWithBrokenAffinityFun( - false, 1, 0, 1, false).get(0); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Object call() throws Exception { - grid(0).getOrCreateCache(cfg); - return null; - } - }, CacheException.class, null); - - // Correct the cache configuration. Default constructor creates a good affinity function. - cfg.setAffinity(new BrokenAffinityFunction()); - - IgniteCache cache = grid(0).getOrCreateCache(createCacheConfiguration(EXISTING_CACHE_NAME)); - - checkCacheOperations(cache); - } - - /** - * Tests that other cache (existed before the failed start) is still operable after the failure. - * - * @throws Exception If test failed. - */ - public void testExistingCacheAfterFailure() throws Exception { - IgniteCache cache = grid(0).getOrCreateCache(createCacheConfiguration(EXISTING_CACHE_NAME)); - - CacheConfiguration cfg = createCacheConfigsWithBrokenAffinityFun( - false, 1, 0, 1, false).get(0); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Object call() throws Exception { - grid(0).getOrCreateCache(cfg); - return null; - } - }, CacheException.class, null); - - checkCacheOperations(cache); - } - - /** - * Tests that other cache works as expected after the failure and further topology changes. - * - * @throws Exception If test failed. - */ - public void testTopologyChangesAfterFailure() throws Exception { - final String clientName = "testTopologyChangesAfterFailure"; - - IgniteCache cache = grid(0).getOrCreateCache(createCacheConfiguration(EXISTING_CACHE_NAME)); - - checkCacheOperations(cache); - - CacheConfiguration cfg = createCacheConfigsWithBrokenAffinityFun( - false, 0, 0, 1, false).get(0); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Object call() throws Exception { - grid(0).getOrCreateCache(cfg); - return null; - } - }, CacheException.class, null); - - awaitPartitionMapExchange(); - - checkCacheOperations(cache); - - // Start a new server node and check cache operations. - Ignite serverNode = startGrid(gridCount() + 1); - - if (persistenceEnabled()) { - // Start a new client node to perform baseline change. - // TODO: This change is workaround: - // Sometimes problem with caches configuration deserialization from test thread arises. - final String clientName1 = "baseline-changer"; - - IgniteConfiguration clientCfg = getConfiguration(clientName1); - - clientCfg.setClientMode(true); - - Ignite clientNode = startGrid(clientName1, clientCfg); - - List baseline = new ArrayList<>(grid(0).cluster().currentBaselineTopology()); - - baseline.add(serverNode.cluster().localNode()); - - clientNode.cluster().setBaselineTopology(baseline); - } - - awaitPartitionMapExchange(); - - checkCacheOperations(serverNode.cache(EXISTING_CACHE_NAME)); - - // Start a new client node and check cache operations. - IgniteConfiguration clientCfg = getConfiguration(clientName); - - clientCfg.setClientMode(true); - - Ignite clientNode = startGrid(clientName, clientCfg); - - checkCacheOperations(clientNode.cache(EXISTING_CACHE_NAME)); - } - - public void testConcurrentClientNodeJoins() throws Exception { - final int clientCnt = 3; - final int numberOfAttempts = 5; - - IgniteCache cache = grid(0).getOrCreateCache(createCacheConfiguration(EXISTING_CACHE_NAME)); - - final AtomicInteger attemptCnt = new AtomicInteger(); - final CountDownLatch stopLatch = new CountDownLatch(clientCnt); - - IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Callable() { - @Override public Object call() throws Exception { - String clientName = Thread.currentThread().getName(); - - try { - for (int i = 0; i < numberOfAttempts; ++i) { - int uniqueCnt = attemptCnt.getAndIncrement(); - - IgniteConfiguration clientCfg = getConfiguration(clientName + uniqueCnt); - - clientCfg.setClientMode(true); - - final Ignite clientNode = startGrid(clientName, clientCfg); - - CacheConfiguration cfg = new CacheConfiguration(); - - cfg.setName(clientName + uniqueCnt); - - String instanceName = getTestIgniteInstanceName(uniqueCnt % gridCount()); - - cfg.setAffinity(new BrokenAffinityFunction(false, instanceName)); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Object call() throws Exception { - clientNode.getOrCreateCache(cfg); - return null; - } - }, CacheException.class, null); - - stopGrid(clientName, true); - } - } - catch (Exception e) { - fail("Unexpected exception: " + e.getMessage()); - } - finally { - stopLatch.countDown(); - } - - return null; - } - }, clientCnt, "start-client-thread"); - - stopLatch.await(); - - assertEquals(numberOfAttempts * clientCnt, attemptCnt.get()); - - checkCacheOperations(cache); - } - - protected void testDynamicCacheStart(final Collection cfgs, final int initiatorId) { - assert initiatorId < gridCount(); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Object call() throws Exception { - grid(initiatorId).getOrCreateCaches(cfgs); - return null; - } - }, CacheException.class, null); - - for (CacheConfiguration cfg: cfgs) { - IgniteCache cache = grid(initiatorId).cache(cfg.getName()); - - assertNull(cache); - } - } - - /** - * Creates new cache configuration with the given name. - * - * @param cacheName Cache name. - * @return New cache configuration. - */ - protected CacheConfiguration createCacheConfiguration(String cacheName) { - CacheConfiguration cfg = new CacheConfiguration() - .setName(cacheName) - .setCacheMode(CacheMode.PARTITIONED) - .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) - .setAffinity(new BrokenAffinityFunction()); - - return cfg; - } - - /** - * Create list of cache configurations. - * - * @param failOnAllNodes {@code true} if affinity function should be broken on all nodes. - * @param unluckyNode Node, where exception is raised. - * @param unluckyCfg Unlucky cache configuration number. - * @param cacheNum Number of caches. - * @param useFilter {@code true} if NodeFilter should be used. - * - * @return List of cache configurations. - */ - protected List createCacheConfigsWithBrokenAffinityFun( - boolean failOnAllNodes, - int unluckyNode, - final int unluckyCfg, - int cacheNum, - boolean useFilter - ) { - assert unluckyCfg >= 0 && unluckyCfg < cacheNum; - - final UUID uuid = ignite(unluckyNode).cluster().localNode().id(); - - List cfgs = new ArrayList<>(); - - for (int i = 0; i < cacheNum; ++i) { - CacheConfiguration cfg = createCacheConfiguration(DYNAMIC_CACHE_NAME + "-" + i); - - if (i == unluckyCfg) - cfg.setAffinity(new BrokenAffinityFunction(failOnAllNodes, getTestIgniteInstanceName(unluckyNode))); - - if (useFilter) - cfg.setNodeFilter(new NodeFilter(uuid)); - - cfgs.add(cfg); - } - - return cfgs; - } - - /** - * Create list of cache configurations. - * - * @param failOnAllNodes {@code true} if cache store should be broken on all nodes. - * @param unluckyNode Node, where exception is raised. - * @param unluckyCfg Unlucky cache configuration number. - * @param cacheNum Number of caches. - * @param useFilter {@code true} if NodeFilter should be used. - * - * @return List of cache configurations. - */ - protected List createCacheConfigsWithBrokenCacheStore( - boolean failOnAllNodes, - int unluckyNode, - int unluckyCfg, - int cacheNum, - boolean useFilter - ) { - assert unluckyCfg >= 0 && unluckyCfg < cacheNum; - - final UUID uuid = ignite(unluckyNode).cluster().localNode().id(); - - List cfgs = new ArrayList<>(); - - for (int i = 0; i < cacheNum; ++i) { - CacheConfiguration cfg = new CacheConfiguration(); - - cfg.setName(DYNAMIC_CACHE_NAME + "-" + i); - - if (i == unluckyCfg) - cfg.setCacheStoreFactory(new BrokenStoreFactory(failOnAllNodes, getTestIgniteInstanceName(unluckyNode))); - - if (useFilter) - cfg.setNodeFilter(new NodeFilter(uuid)); - - cfgs.add(cfg); - } - - return cfgs; - } - - /** - * Test the basic cache operations. - * - * @param cache Cache. - * @throws Exception If test failed. - */ - protected void checkCacheOperations(IgniteCache cache) throws Exception { - int cnt = 1000; - - // Check cache operations. - for (int i = 0; i < cnt; ++i) - cache.put(i, new Value(i)); - - for (int i = 0; i < cnt; ++i) { - Value v = cache.get(i); - - assertNotNull(v); - assertEquals(i, v.getValue()); - } - - // Check Data Streamer functionality. - try (IgniteDataStreamer streamer = grid(0).dataStreamer(cache.getName())) { - for (int i = 0; i < 10_000; ++i) - streamer.addData(i, new Value(i)); - } - } - - /** - * - */ - public static class Value { - @QuerySqlField - private final int fieldVal; - - public Value(int fieldVal) { - this.fieldVal = fieldVal; - } - - public int getValue() { - return fieldVal; - } - } - - /** - * Filter specifying on which node the cache should be started. - */ - public static class NodeFilter implements IgnitePredicate { - /** Cache should be created node with certain UUID. */ - public UUID uuid; - - /** - * @param uuid node ID. - */ - public NodeFilter(UUID uuid) { - this.uuid = uuid; - } - - /** {@inheritDoc} */ - @Override public boolean apply(ClusterNode clusterNode) { - return clusterNode.id().equals(uuid); - } - } - - /** - * Affinity function that throws an exception when affinity nodes are calculated on the given node. - */ - public static class BrokenAffinityFunction extends RendezvousAffinityFunction { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - @IgniteInstanceResource - private Ignite ignite; - - /** Exception should arise on all nodes. */ - private boolean eOnAllNodes = false; - - /** Exception should arise on node with certain name. */ - private String gridName; - - /** - * Constructs a good affinity function. - */ - public BrokenAffinityFunction() { - super(false, PARTITION_COUNT); - // No-op. - } - - /** - * @param eOnAllNodes {@code True} if exception should be thrown on all nodes. - * @param gridName Exception should arise on node with certain name. - */ - public BrokenAffinityFunction(boolean eOnAllNodes, String gridName) { - super(false, PARTITION_COUNT); - - this.eOnAllNodes = eOnAllNodes; - this.gridName = gridName; - } - - /** {@inheritDoc} */ - @Override public List> assignPartitions(AffinityFunctionContext affCtx) { - if (eOnAllNodes || ignite.name().equals(gridName)) - throw new IllegalStateException("Simulated exception [locNodeId=" - + ignite.cluster().localNode().id() + "]"); - else - return super.assignPartitions(affCtx); - } - } - - /** - * Factory that throws an exception is got created. - */ - public static class BrokenStoreFactory implements Factory> { - /** */ - @IgniteInstanceResource - private Ignite ignite; - - /** Exception should arise on all nodes. */ - boolean eOnAllNodes = true; - - /** Exception should arise on node with certain name. */ - public static String gridName; - - /** - * @param eOnAllNodes {@code True} if exception should be thrown on all nodes. - * @param gridName Exception should arise on node with certain name. - */ - public BrokenStoreFactory(boolean eOnAllNodes, String gridName) { - this.eOnAllNodes = eOnAllNodes; - - this.gridName = gridName; - } - - /** {@inheritDoc} */ - @Override public CacheStore create() { - if (eOnAllNodes || ignite.name().equals(gridName)) - throw new IllegalStateException("Simulated exception [locNodeId=" - + ignite.cluster().localNode().id() + "]"); - else - return null; - } - } -} +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.io.ObjectInputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicInteger; +import javax.cache.CacheException; +import javax.cache.configuration.Factory; +import javax.management.Attribute; +import javax.management.AttributeList; +import javax.management.AttributeNotFoundException; +import javax.management.InstanceAlreadyExistsException; +import javax.management.InstanceNotFoundException; +import javax.management.IntrospectionException; +import javax.management.InvalidAttributeValueException; +import javax.management.ListenerNotFoundException; +import javax.management.MBeanException; +import javax.management.MBeanInfo; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServer; +import javax.management.NotCompliantMBeanException; +import javax.management.NotificationFilter; +import javax.management.NotificationListener; +import javax.management.ObjectInstance; +import javax.management.ObjectName; +import javax.management.OperationsException; +import javax.management.QueryExp; +import javax.management.ReflectionException; +import javax.management.loading.ClassLoaderRepository; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.affinity.AffinityFunctionContext; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.cache.query.annotations.QuerySqlField; +import org.apache.ignite.cache.store.CacheStore; +import org.apache.ignite.cluster.BaselineNode; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.resources.IgniteInstanceResource; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests the recovery after a dynamic cache start failure. + */ +@RunWith(JUnit4.class) +public abstract class IgniteAbstractDynamicCacheStartFailTest extends GridCacheAbstractSelfTest { + /** */ + private static final String DYNAMIC_CACHE_NAME = "TestDynamicCache"; + + /** */ + private static final String CLIENT_GRID_NAME = "client"; + + /** */ + protected static final String EXISTING_CACHE_NAME = "existing-cache";; + + /** */ + private static final int PARTITION_COUNT = 16; + + /** Failure MBean server. */ + private static FailureMBeanServer mbSrv; + + /** Coordinator node index. */ + private int crdIdx = 0; + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 3; + } + + /** + * Returns {@code true} if persistence is enabled. + * + * @return {@code true} if persistence is enabled. + */ + protected boolean persistenceEnabled() { + return false; + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBrokenAffinityFunStartOnServerFailedOnClient() throws Exception { + final String clientName = CLIENT_GRID_NAME + "testBrokenAffinityFunStartOnServerFailedOnClient"; + + IgniteConfiguration clientCfg = getConfiguration(clientName); + + clientCfg.setClientMode(true); + + Ignite client = startGrid(clientName, clientCfg); + + CacheConfiguration cfg = new CacheConfiguration(); + + cfg.setName(DYNAMIC_CACHE_NAME + "-server-1"); + + cfg.setAffinity(new BrokenAffinityFunction(false, clientName)); + + try { + IgniteCache cache = ignite(0).getOrCreateCache(cfg); + } + catch (CacheException e) { + fail("Exception should not be thrown."); + } + + stopGrid(clientName); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBrokenAffinityFunStartOnServerFailedOnServer() throws Exception { + final String clientName = CLIENT_GRID_NAME + "testBrokenAffinityFunStartOnServerFailedOnServer"; + + IgniteConfiguration clientCfg = getConfiguration(clientName); + + clientCfg.setClientMode(true); + + Ignite client = startGrid(clientName, clientCfg); + + CacheConfiguration cfg = new CacheConfiguration(); + + cfg.setName(DYNAMIC_CACHE_NAME + "-server-2"); + + cfg.setAffinity(new BrokenAffinityFunction(false, getTestIgniteInstanceName(0))); + + try { + IgniteCache cache = ignite(0).getOrCreateCache(cfg); + + fail("Expected exception was not thrown."); + } + catch (CacheException e) { + } + + stopGrid(clientName); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testBrokenAffinityFunStartOnClientFailOnServer() throws Exception { + final String clientName = CLIENT_GRID_NAME + "testBrokenAffinityFunStartOnClientFailOnServer"; + + IgniteConfiguration clientCfg = getConfiguration(clientName); + + clientCfg.setClientMode(true); + + Ignite client = startGrid(clientName, clientCfg); + + CacheConfiguration cfg = new CacheConfiguration(); + + cfg.setName(DYNAMIC_CACHE_NAME + "-client-2"); + + cfg.setAffinity(new BrokenAffinityFunction(false, getTestIgniteInstanceName(0))); + + try { + IgniteCache cache = client.getOrCreateCache(cfg); + + fail("Expected exception was not thrown."); + } + catch (CacheException e) { + } + + stopGrid(clientName); + } + + /** + * Test cache start with broken affinity function that throws an exception on all nodes. + */ + @Test + public void testBrokenAffinityFunOnAllNodes() { + final boolean failOnAllNodes = true; + final int unluckyNode = 0; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = 0; + + testDynamicCacheStart( + createCacheConfigsWithBrokenAffinityFun( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Test cache start with broken affinity function that throws an exception on initiator node. + */ + @Test + public void testBrokenAffinityFunOnInitiator() { + final boolean failOnAllNodes = false; + final int unluckyNode = 1; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = 1; + + testDynamicCacheStart( + createCacheConfigsWithBrokenAffinityFun( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Test cache start with broken affinity function that throws an exception on non-initiator node. + */ + @Test + public void testBrokenAffinityFunOnNonInitiator() { + final boolean failOnAllNodes = false; + final int unluckyNode = 1; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = 2; + + testDynamicCacheStart( + createCacheConfigsWithBrokenAffinityFun( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Test cache start with broken affinity function that throws an exception on coordinator node. + */ + @Test + public void testBrokenAffinityFunOnCoordinatorDiffInitiator() { + final boolean failOnAllNodes = false; + final int unluckyNode = crdIdx; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = (crdIdx + 1) % gridCount(); + + testDynamicCacheStart( + createCacheConfigsWithBrokenAffinityFun( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Test cache start with broken affinity function that throws an exception on initiator node. + */ + @Test + public void testBrokenAffinityFunOnCoordinator() { + final boolean failOnAllNodes = false; + final int unluckyNode = crdIdx; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = crdIdx; + + testDynamicCacheStart( + createCacheConfigsWithBrokenAffinityFun( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Tests cache start with node filter and broken affinity function that throws an exception on initiator node. + */ + @Test + public void testBrokenAffinityFunWithNodeFilter() { + final boolean failOnAllNodes = false; + final int unluckyNode = 0; + final int unluckyCfg = 0; + final int numOfCaches = 1; + final int initiator = 0; + + testDynamicCacheStart( + createCacheConfigsWithBrokenAffinityFun( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, true), + initiator); + } + + /** + * Tests cache start with broken cache store that throws an exception on all nodes. + */ + @Test + public void testBrokenCacheStoreOnAllNodes() { + final boolean failOnAllNodes = true; + final int unluckyNode = 0; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = 0; + + testDynamicCacheStart( + createCacheConfigsWithBrokenCacheStore( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Tests cache start with broken cache store that throws an exception on initiator node. + */ + @Test + public void testBrokenCacheStoreOnInitiator() { + final boolean failOnAllNodes = false; + final int unluckyNode = 1; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = 1; + + testDynamicCacheStart( + createCacheConfigsWithBrokenCacheStore( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Tests cache start that throws an Ignite checked exception on initiator node. + */ + @Test + public void testThrowsIgniteCheckedExceptionOnInitiator() { + final int unluckyNode = 1; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = 1; + + testDynamicCacheStart( + createCacheConfigsWithFailureMbServer(unluckyNode, unluckyCfg, numOfCaches), + initiator); + } + + /** + * Tests cache start with broken cache store that throws an exception on non-initiator node. + */ + @Test + public void testBrokenCacheStoreOnNonInitiator() { + final boolean failOnAllNodes = false; + final int unluckyNode = 1; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = 2; + + testDynamicCacheStart( + createCacheConfigsWithBrokenCacheStore( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Tests cache start that throws an Ignite checked exception on non-initiator node. + */ + @Test + public void testThrowsIgniteCheckedExceptionOnNonInitiator() { + final int unluckyNode = 1; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = 2; + + testDynamicCacheStart( + createCacheConfigsWithFailureMbServer(unluckyNode, unluckyCfg, numOfCaches), + initiator); + } + + /** + * Tests cache start with broken cache store that throws an exception on initiator node. + */ + @Test + public void testBrokenCacheStoreOnCoordinatorDiffInitiator() { + final boolean failOnAllNodes = false; + final int unluckyNode = crdIdx; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = (crdIdx + 1) % gridCount(); + + testDynamicCacheStart( + createCacheConfigsWithBrokenCacheStore( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Tests cache start that throws an Ignite checked exception on coordinator node + * that doesn't initiator node. + */ + @Test + public void testThrowsIgniteCheckedExceptionOnCoordinatorDiffInitiator() { + final int unluckyNode = crdIdx; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = (crdIdx + 1) % gridCount(); + + testDynamicCacheStart( + createCacheConfigsWithFailureMbServer(unluckyNode, unluckyCfg, numOfCaches), + initiator); + } + + /** + * Tests cache start with broken cache store that throws an exception on coordinator node. + */ + @Test + public void testBrokenCacheStoreFunOnCoordinator() { + final boolean failOnAllNodes = false; + final int unluckyNode = crdIdx; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = crdIdx; + + testDynamicCacheStart( + createCacheConfigsWithBrokenCacheStore( + failOnAllNodes, unluckyNode, unluckyCfg, numOfCaches, false), + initiator); + } + + /** + * Tests cache start that throws an Ignite checked exception on coordinator node. + */ + @Test + public void testThrowsIgniteCheckedExceptionOnCoordinator() { + final int unluckyNode = crdIdx; + final int unluckyCfg = 1; + final int numOfCaches = 3; + final int initiator = crdIdx; + + testDynamicCacheStart( + createCacheConfigsWithFailureMbServer(unluckyNode, unluckyCfg, numOfCaches), + initiator); + } + + /** + * Tests multiple creation of cache with broken affinity function. + */ + @Test + public void testCreateCacheMultipleTimes() { + final boolean failOnAllNodes = false; + final int unluckyNode = 1; + final int unluckyCfg = 0; + final int numOfAttempts = 15; + + CacheConfiguration cfg = createCacheConfigsWithBrokenAffinityFun( + failOnAllNodes, unluckyNode, unluckyCfg, 1, false).get(0); + + for (int i = 0; i < numOfAttempts; ++i) { + try { + IgniteCache cache = ignite(0).getOrCreateCache(cfg); + + fail("Expected exception was not thrown"); + } + catch (CacheException e) { + } + } + } + + /** + * Tests that a cache with the same name can be started after failure if cache configuration is corrected. + * + * @throws Exception If test failed. + */ + @Test + public void testCacheStartAfterFailure() throws Exception { + CacheConfiguration cfg = createCacheConfigsWithBrokenAffinityFun( + false, 1, 0, 1, false).get(0); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + grid(0).getOrCreateCache(cfg); + return null; + } + }, CacheException.class, null); + + // Correct the cache configuration. Default constructor creates a good affinity function. + cfg.setAffinity(new BrokenAffinityFunction()); + + checkCacheOperations(grid(0).getOrCreateCache(cfg)); + } + + /** + * Tests that other cache (existed before the failed start) is still operable after the failure. + * + * @throws Exception If test failed. + */ + @Test + public void testExistingCacheAfterFailure() throws Exception { + IgniteCache cache = grid(0).getOrCreateCache(createCacheConfiguration(EXISTING_CACHE_NAME)); + + CacheConfiguration cfg = createCacheConfigsWithBrokenAffinityFun( + false, 1, 0, 1, false).get(0); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + grid(0).getOrCreateCache(cfg); + return null; + } + }, CacheException.class, null); + + checkCacheOperations(cache); + } + + /** + * Tests that other cache works as expected after the failure and further topology changes. + * + * @throws Exception If test failed. + */ + @Test + public void testTopologyChangesAfterFailure() throws Exception { + final String clientName = "testTopologyChangesAfterFailure"; + + IgniteCache cache = grid(0).getOrCreateCache(createCacheConfiguration(EXISTING_CACHE_NAME)); + + checkCacheOperations(cache); + + CacheConfiguration cfg = createCacheConfigsWithBrokenAffinityFun( + false, 0, 0, 1, false).get(0); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + grid(0).getOrCreateCache(cfg); + return null; + } + }, CacheException.class, null); + + awaitPartitionMapExchange(); + + checkCacheOperations(cache); + + // Start a new server node and check cache operations. + Ignite serverNode = startGrid(gridCount() + 1); + + if (persistenceEnabled()) { + // Start a new client node to perform baseline change. + // TODO: This change is workaround: + // Sometimes problem with caches configuration deserialization from test thread arises. + final String clientName1 = "baseline-changer"; + + IgniteConfiguration clientCfg = getConfiguration(clientName1); + + clientCfg.setClientMode(true); + + Ignite clientNode = startGrid(clientName1, clientCfg); + + List baseline = new ArrayList<>(grid(0).cluster().currentBaselineTopology()); + + baseline.add(serverNode.cluster().localNode()); + + clientNode.cluster().setBaselineTopology(baseline); + } + + awaitPartitionMapExchange(); + + checkCacheOperations(serverNode.cache(EXISTING_CACHE_NAME)); + + // Start a new client node and check cache operations. + IgniteConfiguration clientCfg = getConfiguration(clientName); + + clientCfg.setClientMode(true); + + Ignite clientNode = startGrid(clientName, clientCfg); + + checkCacheOperations(clientNode.cache(EXISTING_CACHE_NAME)); + } + + @Test + public void testConcurrentClientNodeJoins() throws Exception { + final int clientCnt = 3; + final int numberOfAttempts = 5; + + IgniteCache cache = grid(0).getOrCreateCache(createCacheConfiguration(EXISTING_CACHE_NAME)); + + final AtomicInteger attemptCnt = new AtomicInteger(); + final CountDownLatch stopLatch = new CountDownLatch(clientCnt); + + IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Callable() { + @Override public Object call() throws Exception { + String clientName = Thread.currentThread().getName(); + + try { + for (int i = 0; i < numberOfAttempts; ++i) { + int uniqueCnt = attemptCnt.getAndIncrement(); + + IgniteConfiguration clientCfg = getConfiguration(clientName + uniqueCnt); + + clientCfg.setClientMode(true); + + final Ignite clientNode = startGrid(clientName, clientCfg); + + CacheConfiguration cfg = new CacheConfiguration(); + + cfg.setName(clientName + uniqueCnt); + + String instanceName = getTestIgniteInstanceName(uniqueCnt % gridCount()); + + cfg.setAffinity(new BrokenAffinityFunction(false, instanceName)); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + clientNode.getOrCreateCache(cfg); + return null; + } + }, CacheException.class, null); + + stopGrid(clientName, true); + } + } + catch (Exception e) { + fail("Unexpected exception: " + e.getMessage()); + } + finally { + stopLatch.countDown(); + } + + return null; + } + }, clientCnt, "start-client-thread"); + + stopLatch.await(); + + assertEquals(numberOfAttempts * clientCnt, attemptCnt.get()); + + checkCacheOperations(cache); + } + + protected void testDynamicCacheStart(final Collection cfgs, final int initiatorId) { + assert initiatorId < gridCount(); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + grid(initiatorId).getOrCreateCaches(cfgs); + return null; + } + }, CacheException.class, null); + + for (CacheConfiguration cfg: cfgs) { + IgniteCache cache = grid(initiatorId).cache(cfg.getName()); + + assertNull(cache); + } + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration res = super.getConfiguration(igniteInstanceName); + + if (mbSrv == null) + mbSrv = new FailureMBeanServer(res.getMBeanServer()); + + res.setMBeanServer(mbSrv); + + return res; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + mbSrv.clear(); + + for (String cacheName : grid(0).cacheNames()) { + if (!(EXISTING_CACHE_NAME.equals(cacheName) || DEFAULT_CACHE_NAME.equals(cacheName))) + grid(0).cache(cacheName).destroy(); + } + } + + /** + * Creates new cache configuration with the given name. + * + * @param cacheName Cache name. + * @return New cache configuration. + */ + protected CacheConfiguration createCacheConfiguration(String cacheName) { + CacheConfiguration cfg = new CacheConfiguration() + .setName(cacheName) + .setCacheMode(CacheMode.PARTITIONED) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setAffinity(new BrokenAffinityFunction()); + + return cfg; + } + + /** + * Create list of cache configurations. + * + * @param failOnAllNodes {@code true} if affinity function should be broken on all nodes. + * @param unluckyNode Node, where exception is raised. + * @param unluckyCfg Unlucky cache configuration number. + * @param cacheNum Number of caches. + * @param useFilter {@code true} if NodeFilter should be used. + * + * @return List of cache configurations. + */ + protected List createCacheConfigsWithBrokenAffinityFun( + boolean failOnAllNodes, + int unluckyNode, + final int unluckyCfg, + int cacheNum, + boolean useFilter + ) { + assert unluckyCfg >= 0 && unluckyCfg < cacheNum; + + final UUID uuid = ignite(unluckyNode).cluster().localNode().id(); + + List cfgs = new ArrayList<>(); + + for (int i = 0; i < cacheNum; ++i) { + CacheConfiguration cfg = createCacheConfiguration(DYNAMIC_CACHE_NAME + "-" + i); + + if (i == unluckyCfg) + cfg.setAffinity(new BrokenAffinityFunction(failOnAllNodes, getTestIgniteInstanceName(unluckyNode))); + + if (useFilter) + cfg.setNodeFilter(new NodeFilter(uuid)); + + cfgs.add(cfg); + } + + return cfgs; + } + + /** + * Create list of cache configurations. + * + * @param failOnAllNodes {@code true} if cache store should be broken on all nodes. + * @param unluckyNode Node, where exception is raised. + * @param unluckyCfg Unlucky cache configuration number. + * @param cacheNum Number of caches. + * @param useFilter {@code true} if NodeFilter should be used. + * + * @return List of cache configurations. + */ + protected List createCacheConfigsWithBrokenCacheStore( + boolean failOnAllNodes, + int unluckyNode, + int unluckyCfg, + int cacheNum, + boolean useFilter + ) { + assert unluckyCfg >= 0 && unluckyCfg < cacheNum; + + final UUID uuid = ignite(unluckyNode).cluster().localNode().id(); + + List cfgs = new ArrayList<>(); + + for (int i = 0; i < cacheNum; ++i) { + CacheConfiguration cfg = new CacheConfiguration(); + + cfg.setName(DYNAMIC_CACHE_NAME + "-" + i); + + if (i == unluckyCfg) + cfg.setCacheStoreFactory(new BrokenStoreFactory(failOnAllNodes, getTestIgniteInstanceName(unluckyNode))); + + if (useFilter) + cfg.setNodeFilter(new NodeFilter(uuid)); + + cfgs.add(cfg); + } + + return cfgs; + } + + /** + * Create list of cache configurations. + * + * @param unluckyNode Node, where exception is raised. + * @param unluckyCfg Unlucky cache configuration number. + * @param cacheNum Number of caches. + * + * @return List of cache configurations. + */ + private List createCacheConfigsWithFailureMbServer( + int unluckyNode, + int unluckyCfg, + int cacheNum + ) { + assert unluckyCfg >= 0 && unluckyCfg < cacheNum; + + List cfgs = new ArrayList<>(); + + for (int i = 0; i < cacheNum; ++i) { + CacheConfiguration cfg = new CacheConfiguration(); + + String cacheName = DYNAMIC_CACHE_NAME + "-" + i; + + cfg.setName(cacheName); + + if (i == unluckyCfg) + mbSrv.cache(cacheName); + + cfgs.add(cfg); + } + + mbSrv.node(getTestIgniteInstanceName(unluckyNode)); + + return cfgs; + } + + /** + * Test the basic cache operations. + * + * @param cache Cache. + * @throws Exception If test failed. + */ + protected void checkCacheOperations(IgniteCache cache) throws Exception { + int cnt = 1000; + + // Check cache operations. + for (int i = 0; i < cnt; ++i) + cache.put(i, new Value(i)); + + for (int i = 0; i < cnt; ++i) { + Value v = cache.get(i); + + assertNotNull(v); + assertEquals(i, v.getValue()); + } + + // Check Data Streamer functionality. + try (IgniteDataStreamer streamer = grid(0).dataStreamer(cache.getName())) { + for (int i = 0; i < 10_000; ++i) + streamer.addData(i, new Value(i)); + } + } + + /** + * + */ + public static class Value { + @QuerySqlField + private final int fieldVal; + + public Value(int fieldVal) { + this.fieldVal = fieldVal; + } + + public int getValue() { + return fieldVal; + } + } + + /** + * Filter specifying on which node the cache should be started. + */ + public static class NodeFilter implements IgnitePredicate { + /** Cache should be created node with certain UUID. */ + public UUID uuid; + + /** + * @param uuid node ID. + */ + public NodeFilter(UUID uuid) { + this.uuid = uuid; + } + + /** {@inheritDoc} */ + @Override public boolean apply(ClusterNode clusterNode) { + return clusterNode.id().equals(uuid); + } + } + + /** + * Affinity function that throws an exception when affinity nodes are calculated on the given node. + */ + public static class BrokenAffinityFunction extends RendezvousAffinityFunction { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + @IgniteInstanceResource + private Ignite ignite; + + /** Exception should arise on all nodes. */ + private boolean eOnAllNodes = false; + + /** Exception should arise on node with certain name. */ + private String gridName; + + /** + * Constructs a good affinity function. + */ + public BrokenAffinityFunction() { + super(false, PARTITION_COUNT); + // No-op. + } + + /** + * @param eOnAllNodes {@code True} if exception should be thrown on all nodes. + * @param gridName Exception should arise on node with certain name. + */ + public BrokenAffinityFunction(boolean eOnAllNodes, String gridName) { + super(false, PARTITION_COUNT); + + this.eOnAllNodes = eOnAllNodes; + this.gridName = gridName; + } + + /** {@inheritDoc} */ + @Override public List> assignPartitions(AffinityFunctionContext affCtx) { + if (eOnAllNodes || ignite.name().equals(gridName)) + throw new IllegalStateException("Simulated exception [locNodeId=" + + ignite.cluster().localNode().id() + "]"); + else + return super.assignPartitions(affCtx); + } + } + + /** + * Factory that throws an exception is got created. + */ + public static class BrokenStoreFactory implements Factory> { + /** */ + @IgniteInstanceResource + private Ignite ignite; + + /** Exception should arise on all nodes. */ + boolean eOnAllNodes = true; + + /** Exception should arise on node with certain name. */ + public static String gridName; + + /** + * @param eOnAllNodes {@code True} if exception should be thrown on all nodes. + * @param gridName Exception should arise on node with certain name. + */ + public BrokenStoreFactory(boolean eOnAllNodes, String gridName) { + this.eOnAllNodes = eOnAllNodes; + + this.gridName = gridName; + } + + /** {@inheritDoc} */ + @Override public CacheStore create() { + if (eOnAllNodes || ignite.name().equals(gridName)) + throw new IllegalStateException("Simulated exception [locNodeId=" + + ignite.cluster().localNode().id() + "]"); + else + return null; + } + } + + /** Failure MBean server. */ + private class FailureMBeanServer implements MBeanServer { + /** */ + private final MBeanServer origin; + + /** Set of caches that must be failure. */ + private final Set caches = new HashSet<>(); + + /** Set of nodes that must be failure. */ + private final Set nodes = new HashSet<>(); + + /** */ + private FailureMBeanServer(MBeanServer origin) { + this.origin = origin; + } + + /** Add cache name to failure set. */ + void cache(String cache) { + caches.add('\"' + cache + '\"'); + } + + /** Add node name to failure set. */ + void node(String node) { + nodes.add(node); + } + + /** Clear failure set of caches and set of nodes. */ + void clear() { + caches.clear(); + nodes.clear(); + } + + /** {@inheritDoc} */ + @Override public ObjectInstance registerMBean(Object obj, ObjectName name) + throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { + String node = name.getKeyProperty("igniteInstanceName"); + + if (nodes.contains(node) && caches.contains(name.getKeyProperty("group"))) + throw new MBeanRegistrationException(new Exception("Simulate exception [node=" + node + ']')); + + return origin.registerMBean(obj, name); + } + + /** {@inheritDoc} */ + @Override public ObjectInstance createMBean(String clsName, ObjectName name) + throws ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException { + return origin.createMBean(clsName, name); + } + + /** {@inheritDoc} */ + @Override public ObjectInstance createMBean(String clsName, ObjectName name, ObjectName ldrName) + throws ReflectionException, InstanceAlreadyExistsException, + MBeanException, NotCompliantMBeanException, InstanceNotFoundException { + return origin.createMBean(clsName, name, ldrName); + } + + /** {@inheritDoc} */ + @Override public ObjectInstance createMBean(String clsName, ObjectName name, Object[] params, + String[] signature) throws ReflectionException, InstanceAlreadyExistsException, + MBeanException, NotCompliantMBeanException { + return origin.createMBean(clsName, name, params, signature); + } + + /** {@inheritDoc} */ + @Override public ObjectInstance createMBean(String clsName, ObjectName name, ObjectName ldrName, + Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, + MBeanException, NotCompliantMBeanException, InstanceNotFoundException { + return origin.createMBean(clsName, name, ldrName, params, signature); + } + + /** {@inheritDoc} */ + @Override public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException { + origin.unregisterMBean(name); + } + + /** {@inheritDoc} */ + @Override public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException { + return origin.getObjectInstance(name); + } + + /** {@inheritDoc} */ + @Override public Set queryMBeans(ObjectName name, QueryExp qry) { + return origin.queryMBeans(name, qry); + } + + /** {@inheritDoc} */ + @Override public Set queryNames(ObjectName name, QueryExp qry) { + return origin.queryNames(name, qry); + } + + /** {@inheritDoc} */ + @Override public boolean isRegistered(ObjectName name) { + return origin.isRegistered(name); + } + + /** {@inheritDoc} */ + @Override public Integer getMBeanCount() { + return origin.getMBeanCount(); + } + + /** {@inheritDoc} */ + @Override public Object getAttribute(ObjectName name, String attribute) + throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException { + return origin.getAttribute(name, attribute); + } + + /** {@inheritDoc} */ + @Override public AttributeList getAttributes(ObjectName name, + String[] attrs) throws InstanceNotFoundException, ReflectionException { + return origin.getAttributes(name, attrs); + } + + /** {@inheritDoc} */ + @Override public void setAttribute(ObjectName name, + Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, + InvalidAttributeValueException, MBeanException, ReflectionException { + origin.setAttribute(name, attribute); + } + + /** {@inheritDoc} */ + @Override public AttributeList setAttributes(ObjectName name, + AttributeList attrs) throws InstanceNotFoundException, ReflectionException { + return origin.setAttributes(name, attrs); + } + + /** {@inheritDoc} */ + @Override public Object invoke(ObjectName name, String operationName, Object[] params, + String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException { + return origin.invoke(name, operationName, params, signature); + } + + /** {@inheritDoc} */ + @Override public String getDefaultDomain() { + return origin.getDefaultDomain(); + } + + /** {@inheritDoc} */ + @Override public String[] getDomains() { + return origin.getDomains(); + } + + /** {@inheritDoc} */ + @Override public void addNotificationListener(ObjectName name, NotificationListener lsnr, + NotificationFilter filter, Object handback) throws InstanceNotFoundException { + origin.addNotificationListener(name, lsnr, filter, handback); + } + + /** {@inheritDoc} */ + @Override public void addNotificationListener(ObjectName name, ObjectName lsnr, + NotificationFilter filter, Object handback) throws InstanceNotFoundException { + origin.addNotificationListener(name, lsnr, filter, handback); + } + + /** {@inheritDoc} */ + @Override public void removeNotificationListener(ObjectName name, + ObjectName lsnr) throws InstanceNotFoundException, ListenerNotFoundException { + origin.removeNotificationListener(name, lsnr); + } + + /** {@inheritDoc} */ + @Override public void removeNotificationListener(ObjectName name, ObjectName lsnr, + NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { + origin.removeNotificationListener(name, lsnr, filter, handback); + } + + /** {@inheritDoc} */ + @Override public void removeNotificationListener(ObjectName name, + NotificationListener lsnr) throws InstanceNotFoundException, ListenerNotFoundException { + origin.removeNotificationListener(name, lsnr); + } + + /** {@inheritDoc} */ + @Override public void removeNotificationListener(ObjectName name, NotificationListener lsnr, + NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { + origin.removeNotificationListener(name, lsnr, filter, handback); + } + + /** {@inheritDoc} */ + @Override public MBeanInfo getMBeanInfo( + ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException { + return origin.getMBeanInfo(name); + } + + /** {@inheritDoc} */ + @Override public boolean isInstanceOf(ObjectName name, String clsName) throws InstanceNotFoundException { + return origin.isInstanceOf(name, clsName); + } + + /** {@inheritDoc} */ + @Override public Object instantiate(String clsName) throws ReflectionException, MBeanException { + return origin.instantiate(clsName); + } + + /** {@inheritDoc} */ + @Override public Object instantiate(String clsName, + ObjectName ldrName) throws ReflectionException, MBeanException, InstanceNotFoundException { + return origin.instantiate(clsName, ldrName); + } + + /** {@inheritDoc} */ + @Override public Object instantiate(String clsName, Object[] params, + String[] signature) throws ReflectionException, MBeanException { + return origin.instantiate(clsName, params, signature); + } + + /** {@inheritDoc} */ + @Override public Object instantiate(String clsName, ObjectName ldrName, Object[] params, + String[] signature) throws ReflectionException, MBeanException, InstanceNotFoundException { + return origin.instantiate(clsName, ldrName, params, signature); + } + + /** {@inheritDoc} */ + @Override @Deprecated public ObjectInputStream deserialize(ObjectName name, byte[] data) + throws OperationsException { + return origin.deserialize(name, data); + } + + /** {@inheritDoc} */ + @Override @Deprecated public ObjectInputStream deserialize(String clsName, byte[] data) + throws OperationsException, ReflectionException { + return origin.deserialize(clsName, data); + } + + /** {@inheritDoc} */ + @Override @Deprecated public ObjectInputStream deserialize(String clsName, ObjectName ldrName, byte[] data) + throws OperationsException, ReflectionException { + return origin.deserialize(clsName, ldrName, data); + } + + /** {@inheritDoc} */ + @Override public ClassLoader getClassLoaderFor(ObjectName mbeanName) throws InstanceNotFoundException { + return origin.getClassLoaderFor(mbeanName); + } + + /** {@inheritDoc} */ + @Override public ClassLoader getClassLoader(ObjectName ldrName) throws InstanceNotFoundException { + return origin.getClassLoader(ldrName); + } + + /** {@inheritDoc} */ + @Override public ClassLoaderRepository getClassLoaderRepository() { + return origin.getClassLoaderRepository(); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractStopBusySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractStopBusySelfTest.java index 257ca77399f08..1950630d4be56 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractStopBusySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractStopBusySelfTest.java @@ -47,12 +47,12 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -60,6 +60,7 @@ /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheAbstractStopBusySelfTest extends GridCommonAbstractTest { /** */ public static final int CLN_GRD = 0; @@ -70,9 +71,6 @@ public abstract class IgniteCacheAbstractStopBusySelfTest extends GridCommonAbst /** */ public static final String CACHE_NAME = "StopTest"; - /** */ - public final TcpDiscoveryIpFinder finder = new TcpDiscoveryVmIpFinder(true); - /** */ private AtomicBoolean suspended = new AtomicBoolean(false); @@ -119,7 +117,7 @@ protected CacheAtomicityMode atomicityMode(){ cfg.setCommunicationSpi(commSpi); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(finder).setForceServerMode(true)); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); cfg.setCacheConfiguration(cacheCfg); @@ -166,6 +164,7 @@ protected CacheAtomicityMode atomicityMode(){ /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { executeTest(new Callable() { /** {@inheritDoc} */ @@ -184,6 +183,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { executeTest(new Callable() { /** {@inheritDoc} */ @@ -202,6 +202,7 @@ public void testRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAsync() throws Exception { executeTest(new Callable() { /** {@inheritDoc} */ @@ -220,6 +221,7 @@ public void testPutAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { bannedMsg.set(GridNearSingleGetRequest.class); @@ -240,6 +242,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAll() throws Exception { bannedMsg.set(GridNearGetRequest.class); @@ -303,6 +306,7 @@ private void executeTest(Callable call) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutBatch() throws Exception { assert !suspended.get(); @@ -407,4 +411,4 @@ private class StopRunnable implements Runnable { info("Grid stopped."); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java index 370a7a8af70d0..403a800ee2b1d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java @@ -34,8 +34,6 @@ import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.concurrent.ConcurrentHashMap; @@ -47,9 +45,6 @@ * Abstract class for cache tests. */ public abstract class IgniteCacheAbstractTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ public static final Map storeMap = new ConcurrentHashMap<>(); @@ -87,9 +82,9 @@ protected void startGrids() throws Exception { ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); - TcpDiscoverySpi disco = new TcpDiscoverySpi().setForceServerMode(true); + TcpDiscoverySpi disco = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - disco.setIpFinder(ipFinder); + disco.setForceServerMode(true); if (isDebug()) disco.setAckTimeout(Integer.MAX_VALUE); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicStopBusySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicStopBusySelfTest.java index 281397a7c98c8..58ab3bb3279b3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicStopBusySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicStopBusySelfTest.java @@ -19,10 +19,14 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateRequest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Stopped node when client operations are executing. */ +@RunWith(JUnit4.class) public class IgniteCacheAtomicStopBusySelfTest extends IgniteCacheAbstractStopBusySelfTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { @@ -30,6 +34,7 @@ public class IgniteCacheAtomicStopBusySelfTest extends IgniteCacheAbstractStopBu } /** {@inheritDoc} */ + @Test @Override public void testPut() throws Exception { bannedMsg.set(GridNearAtomicSingleUpdateRequest.class); @@ -37,6 +42,7 @@ public class IgniteCacheAtomicStopBusySelfTest extends IgniteCacheAbstractStopBu } /** {@inheritDoc} */ + @Test @Override public void testPutBatch() throws Exception { bannedMsg.set(GridNearAtomicSingleUpdateRequest.class); @@ -44,6 +50,7 @@ public class IgniteCacheAtomicStopBusySelfTest extends IgniteCacheAbstractStopBu } /** {@inheritDoc} */ + @Test @Override public void testPutAsync() throws Exception { bannedMsg.set(GridNearAtomicSingleUpdateRequest.class); @@ -51,9 +58,10 @@ public class IgniteCacheAtomicStopBusySelfTest extends IgniteCacheAbstractStopBu } /** {@inheritDoc} */ + @Test @Override public void testRemove() throws Exception { bannedMsg.set(GridNearAtomicSingleUpdateRequest.class); super.testPut(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryEntryProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryEntryProcessorSelfTest.java index 963fe88b899e5..12208865d4bb9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryEntryProcessorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryEntryProcessorSelfTest.java @@ -30,18 +30,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheBinaryEntryProcessorSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRV_CNT = 4; @@ -52,8 +50,6 @@ public class IgniteCacheBinaryEntryProcessorSelfTest extends GridCommonAbstractT @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (getTestIgniteInstanceName(SRV_CNT).equals(igniteInstanceName)) cfg.setClientMode(true); @@ -88,6 +84,7 @@ private CacheConfiguration cacheConfiguration(CacheMode cach /** * @throws Exception If failed. */ + @Test public void testPartitionedTransactional() throws Exception { checkInvokeBinaryObject(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL); } @@ -95,6 +92,7 @@ public void testPartitionedTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedTransactional() throws Exception { checkInvokeBinaryObject(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL); } @@ -102,6 +100,7 @@ public void testReplicatedTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionedAtomic() throws Exception { checkInvokeBinaryObject(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL); } @@ -109,6 +108,7 @@ public void testPartitionedAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedAtomic() throws Exception { checkInvokeBinaryObject(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java index 64c2bbc6e6f89..7c7ae98f21960 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java @@ -26,19 +26,17 @@ import org.apache.ignite.cache.query.ScanQuery; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheBinaryObjectsScanSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String PERSON_CLS_NAME = "org.apache.ignite.tests.p2p.cache.Person"; @@ -68,11 +66,6 @@ public class IgniteCacheBinaryObjectsScanSelfTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); cfg.setIncludeEventTypes(getIncludeEventTypes()); cfg.setMarshaller(null); @@ -120,6 +113,7 @@ private void populateCache(ClassLoader ldr) throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanNoClasses() throws Exception { Ignite client = grid("client"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java index 84d0a98e9229f..a7a2fdc25d17f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java @@ -88,6 +88,9 @@ import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -113,7 +116,8 @@ /** * Full API cache test. */ -@SuppressWarnings({"TransientFieldInNonSerializableClass", "unchecked"}) +@SuppressWarnings({"unchecked"}) +@RunWith(JUnit4.class) public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVariationsAbstractTest { /** Test timeout */ private static final long TEST_TIMEOUT = 60 * 1000; @@ -168,6 +172,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar /** * @throws Exception In case of error. */ + @Test public void testSize() throws Exception { assert jcache().localSize() == 0; @@ -271,6 +276,7 @@ else if (cacheMode() == PARTITIONED) /** * @throws Exception In case of error. */ + @Test public void testContainsKey() throws Exception { Map vals = new HashMap<>(); @@ -292,6 +298,7 @@ public void testContainsKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContainsKeyTx() throws Exception { if (!txEnabled()) return; @@ -326,6 +333,7 @@ public void testContainsKeyTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContainsKeysTx() throws Exception { if (!txEnabled()) return; @@ -367,6 +375,7 @@ public void testContainsKeysTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveInExplicitLocks() throws Exception { if (lockingEnabled()) { IgniteCache cache = jcache(); @@ -392,6 +401,7 @@ public void testRemoveInExplicitLocks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAllSkipStore() throws Exception { if (!storeEnabled()) return; @@ -410,6 +420,7 @@ public void testRemoveAllSkipStore() throws Exception { /** * @throws IgniteCheckedException If failed. */ + @Test public void testAtomicOps() throws IgniteCheckedException { IgniteCache c = jcache(); @@ -442,6 +453,7 @@ public void testAtomicOps() throws IgniteCheckedException { /** * @throws Exception In case of error. */ + @Test public void testGet() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() { @@ -461,6 +473,7 @@ public void testGet() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -489,6 +502,7 @@ public void testGetAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAsync() throws Exception { IgniteCache cache = jcache(); @@ -509,6 +523,7 @@ public void testGetAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAll() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() { @@ -600,6 +615,7 @@ public void testGetAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllWithNulls() throws Exception { final IgniteCache cache = jcache(); @@ -620,6 +636,7 @@ public void testGetAllWithNulls() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetTxNonExistingKey() throws Exception { if (txShouldBeUsed()) { try (Transaction ignored = transactions().txStart()) { @@ -631,6 +648,7 @@ public void testGetTxNonExistingKey() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllAsyncOld() throws Exception { final IgniteCache cache = jcache(); @@ -662,6 +680,7 @@ public void testGetAllAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAllAsync() throws Exception { final IgniteCache cache = jcache(); @@ -689,6 +708,7 @@ public void testGetAllAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPut() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -734,6 +754,7 @@ public void testPut() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutTx() throws Exception { if (txShouldBeUsed()) { IgniteCache cache = jcache(); @@ -773,6 +794,7 @@ public void testPutTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeOptimisticReadCommitted() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -784,6 +806,7 @@ public void testInvokeOptimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeOptimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -795,6 +818,7 @@ public void testInvokeOptimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokePessimisticReadCommitted() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -806,6 +830,7 @@ public void testInvokePessimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokePessimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -817,6 +842,7 @@ public void testInvokePessimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteInvokeOptimisticReadCommitted1() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -828,6 +854,7 @@ public void testIgniteInvokeOptimisticReadCommitted1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteInvokeOptimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -839,6 +866,7 @@ public void testIgniteInvokeOptimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteInvokePessimisticReadCommitted() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -850,6 +878,7 @@ public void testIgniteInvokePessimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteInvokePessimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -945,6 +974,7 @@ private void checkInvoke(TransactionConcurrency concurrency, TransactionIsolatio /** * @throws Exception If failed. */ + @Test public void testInvokeAllOptimisticReadCommitted() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -956,6 +986,7 @@ public void testInvokeAllOptimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAllOptimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -967,6 +998,7 @@ public void testInvokeAllOptimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAllPessimisticReadCommitted() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -978,6 +1010,7 @@ public void testInvokeAllPessimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAllPessimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -989,6 +1022,7 @@ public void testInvokeAllPessimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAllAsyncOptimisticReadCommitted() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1000,6 +1034,7 @@ public void testInvokeAllAsyncOptimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAllAsyncOptimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1011,6 +1046,7 @@ public void testInvokeAllAsyncOptimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAllAsyncPessimisticReadCommitted() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1022,6 +1058,7 @@ public void testInvokeAllAsyncPessimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAllAsyncPessimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1225,6 +1262,7 @@ private void checkInvokeAllAsync(TransactionConcurrency concurrency, Transaction /** * @throws Exception If failed. */ + @Test public void testInvokeAllWithNulls() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1277,6 +1315,7 @@ public void testInvokeAllWithNulls() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeSequentialOptimisticNoStart() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1288,6 +1327,7 @@ public void testInvokeSequentialOptimisticNoStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeSequentialPessimisticNoStart() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1299,6 +1339,7 @@ public void testInvokeSequentialPessimisticNoStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeSequentialOptimisticWithStart() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1310,6 +1351,7 @@ public void testInvokeSequentialOptimisticWithStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeSequentialPessimisticWithStart() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1374,6 +1416,7 @@ private void checkInvokeSequential0(boolean startVal, TransactionConcurrency con /** * @throws Exception If failed. */ + @Test public void testInvokeAfterRemoveOptimistic() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1385,6 +1428,7 @@ public void testInvokeAfterRemoveOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAfterRemovePessimistic() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1427,6 +1471,7 @@ private void checkInvokeAfterRemove(TransactionConcurrency concurrency) throws E /** * @throws Exception If failed. */ + @Test public void testInvokeReturnValueGetOptimisticReadCommitted() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1438,6 +1483,7 @@ public void testInvokeReturnValueGetOptimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReturnValueGetOptimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1449,6 +1495,7 @@ public void testInvokeReturnValueGetOptimisticRepeatableRead() throws Exception /** * @throws Exception If failed. */ + @Test public void testInvokeReturnValueGetPessimisticReadCommitted() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1460,6 +1507,7 @@ public void testInvokeReturnValueGetPessimisticReadCommitted() throws Exception /** * @throws Exception If failed. */ + @Test public void testInvokeReturnValueGetPessimisticRepeatableRead() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1471,6 +1519,7 @@ public void testInvokeReturnValueGetPessimisticRepeatableRead() throws Exception /** * @throws Exception If failed. */ + @Test public void testInvokeReturnValuePutInTx() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1524,6 +1573,7 @@ private void checkInvokeReturnValue(boolean put, /** * @throws Exception In case of error. */ + @Test public void testGetAndPutAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -1550,6 +1600,7 @@ public void testGetAndPutAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAndPutAsync() throws Exception { IgniteCache cache = jcache(); @@ -1570,6 +1621,7 @@ public void testGetAndPutAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAsyncOld0() throws Exception { IgniteCache cacheAsync = jcache().withAsync(); @@ -1588,6 +1640,7 @@ public void testPutAsyncOld0() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAsync0() throws Exception { IgniteFuture fut1 = jcache().getAndPutAsync("key1", 0); @@ -1600,6 +1653,7 @@ public void testPutAsync0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAsyncOld() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1647,6 +1701,7 @@ public void testInvokeAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAsync() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1687,6 +1742,7 @@ public void testInvokeAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvoke() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -1741,6 +1797,7 @@ public void testInvoke() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutx() throws Exception { if (txShouldBeUsed()) checkPut(true); @@ -1749,6 +1806,7 @@ public void testPutx() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutxNoTx() throws Exception { checkPut(false); } @@ -1793,6 +1851,7 @@ private void checkPut(boolean inTx) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAsyncOld() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -1838,6 +1897,7 @@ public void testPutAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAsync() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -1877,6 +1937,7 @@ public void testPutAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAll() throws Exception { Map map = F.asMap("key1", 1, "key2", 2); @@ -1903,6 +1964,7 @@ public void testPutAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testNullInTx() throws Exception { if (!txShouldBeUsed()) return; @@ -1994,6 +2056,7 @@ public void testNullInTx() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAllWithNulls() throws Exception { final IgniteCache cache = jcache(); @@ -2122,6 +2185,7 @@ public void testPutAllWithNulls() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAllAsyncOld() throws Exception { Map map = F.asMap("key1", 1, "key2", 2); @@ -2152,6 +2216,7 @@ public void testPutAllAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutAllAsync() throws Exception { Map map = F.asMap("key1", 1, "key2", 2); @@ -2176,6 +2241,7 @@ public void testPutAllAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAndPutIfAbsent() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -2262,6 +2328,7 @@ public void testGetAndPutIfAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPutIfAbsentAsyncOld() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -2343,6 +2410,7 @@ public void testGetAndPutIfAbsentAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPutIfAbsentAsync() throws Exception { Transaction tx = txShouldBeUsed() ? transactions().txStart() : null; @@ -2412,6 +2480,7 @@ public void testGetAndPutIfAbsentAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsent() throws Exception { IgniteCache cache = jcache(); @@ -2466,6 +2535,7 @@ public void testPutIfAbsent() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutxIfAbsentAsyncOld() throws Exception { if (txShouldBeUsed()) checkPutxIfAbsentAsyncOld(true); @@ -2474,6 +2544,7 @@ public void testPutxIfAbsentAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutxIfAbsentAsyncOldNoTx() throws Exception { checkPutxIfAbsentAsyncOld(false); } @@ -2481,6 +2552,7 @@ public void testPutxIfAbsentAsyncOldNoTx() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutxIfAbsentAsync() throws Exception { if (txShouldBeUsed()) checkPutxIfAbsentAsync(true); @@ -2489,6 +2561,7 @@ public void testPutxIfAbsentAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutxIfAbsentAsyncNoTx() throws Exception { checkPutxIfAbsentAsync(false); } @@ -2641,6 +2714,7 @@ private void checkPutxIfAbsentAsync(boolean inTx) throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutIfAbsentAsyncOldConcurrent() throws Exception { IgniteCache cacheAsync = jcache().withAsync(); @@ -2659,6 +2733,7 @@ public void testPutIfAbsentAsyncOldConcurrent() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPutIfAbsentAsyncConcurrent() throws Exception { IgniteCache cache = jcache(); @@ -2673,6 +2748,7 @@ public void testPutIfAbsentAsyncConcurrent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndReplace() throws Exception { IgniteCache cache = jcache(); @@ -2767,6 +2843,7 @@ public void testGetAndReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplace() throws Exception { IgniteCache cache = jcache(); @@ -2824,6 +2901,7 @@ public void testReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndReplaceAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -2913,6 +2991,7 @@ public void testGetAndReplaceAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndReplaceAsync() throws Exception { IgniteCache cache = jcache(); @@ -2984,6 +3063,7 @@ public void testGetAndReplaceAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplacexAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -3055,6 +3135,7 @@ public void testReplacexAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplacexAsync() throws Exception { IgniteCache cache = jcache(); @@ -3114,6 +3195,7 @@ public void testReplacexAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetAndRemove() throws Exception { IgniteCache cache = jcache(); @@ -3133,6 +3215,7 @@ public void testGetAndRemove() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testGetAndRemoveObject() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -3181,6 +3264,7 @@ public void testGetAndRemoveObject() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndPutSerializableObject() throws Exception { IgniteCache cache = ignite(0).cache(cacheName()); @@ -3203,11 +3287,10 @@ public void testGetAndPutSerializableObject() throws Exception { } /** - * TODO: GG-11241. - * * @throws Exception If failed. */ - public void _testDeletedEntriesFlag() throws Exception { + @Test + public void testDeletedEntriesFlag() throws Exception { if (cacheMode() != LOCAL && cacheMode() != REPLICATED) { final int cnt = 3; @@ -3227,6 +3310,7 @@ public void _testDeletedEntriesFlag() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveLoad() throws Exception { if (!storeEnabled()) return; @@ -3261,6 +3345,7 @@ public void testRemoveLoad() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -3295,6 +3380,7 @@ public void testRemoveAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAsync() throws Exception { IgniteCache cache = jcache(); @@ -3319,6 +3405,7 @@ public void testRemoveAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemove() throws Exception { IgniteCache cache = jcache(); @@ -3332,6 +3419,7 @@ public void testRemove() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemovexAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -3353,6 +3441,7 @@ public void testRemovexAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemovexAsync() throws Exception { IgniteCache cache = jcache(); @@ -3368,6 +3457,7 @@ public void testRemovexAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGlobalRemoveAll() throws Exception { globalRemoveAll(false, false); } @@ -3375,6 +3465,7 @@ public void testGlobalRemoveAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGlobalRemoveAllAsyncOld() throws Exception { globalRemoveAll(true, true); } @@ -3382,6 +3473,7 @@ public void testGlobalRemoveAllAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGlobalRemoveAllAsync() throws Exception { globalRemoveAll(true, false); } @@ -3474,6 +3566,7 @@ protected long hugeRemoveAllEntryCount() { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllWithNulls() throws Exception { final IgniteCache cache = jcache(); @@ -3528,6 +3621,7 @@ public void testRemoveAllWithNulls() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllDuplicates() throws Exception { jcache().removeAll(ImmutableSet.of("key1", "key1", "key1")); } @@ -3535,6 +3629,7 @@ public void testRemoveAllDuplicates() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllDuplicatesTx() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart()) { @@ -3548,6 +3643,7 @@ public void testRemoveAllDuplicatesTx() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllEmpty() throws Exception { jcache().removeAll(); } @@ -3555,6 +3651,7 @@ public void testRemoveAllEmpty() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllAsyncOld() throws Exception { IgniteCache cache = jcache(); @@ -3580,6 +3677,7 @@ public void testRemoveAllAsyncOld() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testRemoveAllAsync() throws Exception { IgniteCache cache = jcache(); @@ -3601,6 +3699,7 @@ public void testRemoveAllAsync() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testLoadAll() throws Exception { if (!storeEnabled()) return; @@ -3641,6 +3740,7 @@ public void testLoadAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAfterClear() throws Exception { IgniteEx ignite = grid(0); @@ -3687,6 +3787,7 @@ public void testRemoveAfterClear() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testClear() throws Exception { IgniteCache cache = jcache(); @@ -3834,6 +3935,7 @@ protected void checkUnlocked(final Collection keys0) throws IgniteChecke /** * @throws Exception If failed. */ + @Test public void testGlobalClearAll() throws Exception { globalClearAll(false, false); } @@ -3841,6 +3943,7 @@ public void testGlobalClearAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearAllAsyncOld() throws Exception { globalClearAll(true, true); } @@ -3848,6 +3951,7 @@ public void testGlobalClearAllAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearAllAsync() throws Exception { globalClearAll(true, false); } @@ -3887,6 +3991,7 @@ protected void globalClearAll(boolean async, boolean oldAsync) throws Exception * @throws Exception In case of error. */ @SuppressWarnings("BusyWait") + @Test public void testLockUnlock() throws Exception { if (lockingEnabled()) { final CountDownLatch lockCnt = new CountDownLatch(1); @@ -3946,6 +4051,7 @@ public void testLockUnlock() throws Exception { * @throws Exception In case of error. */ @SuppressWarnings("BusyWait") + @Test public void testLockUnlockAll() throws Exception { if (lockingEnabled()) { IgniteCache cache = jcache(); @@ -4001,6 +4107,7 @@ public void testLockUnlockAll() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testPeek() throws Exception { Ignite ignite = primaryIgnite("key"); IgniteCache cache = ignite.cache(cacheName()); @@ -4017,6 +4124,7 @@ public void testPeek() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPeekTxRemoveOptimistic() throws Exception { checkPeekTxRemove(OPTIMISTIC); } @@ -4024,6 +4132,7 @@ public void testPeekTxRemoveOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPeekTxRemovePessimistic() throws Exception { checkPeekTxRemove(PESSIMISTIC); } @@ -4053,6 +4162,7 @@ private void checkPeekTxRemove(TransactionConcurrency concurrency) throws Except /** * @throws Exception If failed. */ + @Test public void testPeekRemove() throws Exception { IgniteCache cache = primaryCache("key"); @@ -4063,10 +4173,10 @@ public void testPeekRemove() throws Exception { } /** - * TODO GG-11133. * @throws Exception In case of error. */ - public void _testEvictExpired() throws Exception { + @Test + public void testEvictExpired() throws Exception { final IgniteCache cache = jcache(); final String key = primaryKeysForCache(1).get(0); @@ -4123,6 +4233,7 @@ public void _testEvictExpired() throws Exception { * * @throws Exception If failed. */ + @Test public void testPeekExpired() throws Exception { final IgniteCache c = jcache(); @@ -4158,6 +4269,7 @@ public void testPeekExpired() throws Exception { * * @throws Exception If failed. */ + @Test public void testPeekExpiredTx() throws Exception { if (txShouldBeUsed()) { final IgniteCache c = jcache(); @@ -4188,6 +4300,7 @@ public void testPeekExpiredTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTtlTx() throws Exception { if (txShouldBeUsed()) checkTtl(true, false); @@ -4196,6 +4309,7 @@ public void testTtlTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTtlNoTx() throws Exception { checkTtl(false, false); } @@ -4203,6 +4317,7 @@ public void testTtlNoTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTtlNoTxOldEntry() throws Exception { checkTtl(false, true); } @@ -4213,12 +4328,31 @@ public void testTtlNoTxOldEntry() throws Exception { * @throws Exception If failed. */ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { - // TODO GG-11133. - if (true) - return; + int ttlVals[] = {600, 1000, 3000}; - int ttl = 1000; + int i = 0; + while (i < ttlVals.length) { + try { + checkTtl0(inTx, oldEntry, ttlVals[i]); + break; + } + catch (AssertionFailedError e) { + if (i < ttlVals.length - 1) + info("Ttl test failed, try execute with increased ttl"); + else + throw e; + } + i++; + } + } + /** + * @param inTx In tx flag. + * @param oldEntry {@code True} to check TTL on old entry, {@code false} on new. + * @param ttl TTL value. + * @throws Exception If failed. + */ + private void checkTtl0(boolean inTx, boolean oldEntry, int ttl) throws Exception { final ExpiryPolicy expiry = new TouchedExpiryPolicy(new Duration(MILLISECONDS, ttl)); final IgniteCache c = jcache(); @@ -4280,7 +4414,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { assertNotNull(curEntryTtl.get1()); assertNotNull(curEntryTtl.get2()); - assertEquals(ttl, (long)curEntryTtl.get1()); assertTrue(curEntryTtl.get2() > startTime); expireTimes[i] = curEntryTtl.get2(); } @@ -4308,7 +4441,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { assertNotNull(curEntryTtl.get1()); assertNotNull(curEntryTtl.get2()); - assertEquals(ttl, (long)curEntryTtl.get1()); assertTrue(curEntryTtl.get2() > startTime); expireTimes[i] = curEntryTtl.get2(); } @@ -4336,7 +4468,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { assertNotNull(curEntryTtl.get1()); assertNotNull(curEntryTtl.get2()); - assertEquals(ttl, (long)curEntryTtl.get1()); assertTrue(curEntryTtl.get2() > startTime); expireTimes[i] = curEntryTtl.get2(); } @@ -4368,7 +4499,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { assertNotNull(curEntryTtl.get1()); assertNotNull(curEntryTtl.get2()); - assertEquals(ttl, (long)curEntryTtl.get1()); assertEquals(expireTimes[i], (long)curEntryTtl.get2()); } } @@ -4377,7 +4507,6 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { storeStgy.removeFromStore(key); assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() { - @SuppressWarnings("unchecked") @Override public boolean applyx() { try { Integer val = c.get(key); @@ -4418,11 +4547,7 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { // Ensure that old TTL and expire time are not longer "visible". entryTtl = entryTtl(srvNodeCache, key); - - assertNotNull(entryTtl.get1()); - assertNotNull(entryTtl.get2()); - assertEquals(0, (long)entryTtl.get1()); - assertEquals(0, (long)entryTtl.get2()); + assertNull(entryTtl); // Ensure that next update will not pick old expire time. @@ -4439,7 +4564,7 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { tx.close(); } - U.sleep(2000); + U.sleep(ttl + 500); entryTtl = entryTtl(srvNodeCache, key); @@ -4454,6 +4579,7 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { /** * @throws Exception In case of error. */ + @Test public void testLocalEvict() throws Exception { IgniteCache cache = jcache(); @@ -4507,6 +4633,7 @@ private void checkKeyAfterLocalEvict(IgniteCache cache, String /** * JUnit. */ + @Test public void testCacheProxy() { IgniteCache cache = jcache(); @@ -4518,6 +4645,7 @@ public void testCacheProxy() { * * @throws Exception If failed. */ + @Test public void testCompactExpired() throws Exception { final IgniteCache cache = jcache(); @@ -4551,6 +4679,7 @@ public void testCompactExpired() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimisticTxMissingKey() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { @@ -4567,6 +4696,7 @@ public void testOptimisticTxMissingKey() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimisticTxMissingKeyNoCommit() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { @@ -4581,6 +4711,7 @@ public void testOptimisticTxMissingKeyNoCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticTxReadCommittedInTx() throws Exception { checkRemovexInTx(OPTIMISTIC, READ_COMMITTED); } @@ -4588,6 +4719,7 @@ public void testOptimisticTxReadCommittedInTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticTxRepeatableReadInTx() throws Exception { checkRemovexInTx(OPTIMISTIC, REPEATABLE_READ); } @@ -4595,6 +4727,7 @@ public void testOptimisticTxRepeatableReadInTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxReadCommittedInTx() throws Exception { checkRemovexInTx(PESSIMISTIC, READ_COMMITTED); } @@ -4602,6 +4735,7 @@ public void testPessimisticTxReadCommittedInTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxRepeatableReadInTx() throws Exception { checkRemovexInTx(PESSIMISTIC, REPEATABLE_READ); } @@ -4654,6 +4788,7 @@ private void checkRemovexInTx(final TransactionConcurrency concurrency, * * @throws Exception If failed. */ + @Test public void testPessimisticTxMissingKey() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { @@ -4670,6 +4805,7 @@ public void testPessimisticTxMissingKey() throws Exception { * * @throws Exception If failed. */ + @Test public void testPessimisticTxMissingKeyNoCommit() throws Exception { if (txShouldBeUsed()) { try (Transaction tx = transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { @@ -4684,6 +4820,7 @@ public void testPessimisticTxMissingKeyNoCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxRepeatableRead() throws Exception { if (txShouldBeUsed()) { try (Transaction ignored = transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { @@ -4697,6 +4834,7 @@ public void testPessimisticTxRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxRepeatableReadOnUpdate() throws Exception { if (txShouldBeUsed()) { try (Transaction ignored = transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { @@ -4710,6 +4848,7 @@ public void testPessimisticTxRepeatableReadOnUpdate() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testToMap() throws Exception { IgniteCache cache = jcache(); @@ -4867,6 +5006,7 @@ protected IgnitePair entryTtl(IgniteCache cache, String key) { /** * @throws Exception If failed. */ + @Test public void testIterator() throws Exception { IgniteCache cache = grid(0).cache(cacheName()); @@ -4894,6 +5034,7 @@ public void testIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteCacheIterator() throws Exception { IgniteCache cache = jcache(0); @@ -5084,6 +5225,7 @@ private void checkIteratorEmpty(IgniteCache cache) throws Excep /** * @throws Exception If failed. */ + @Test public void testLocalClearKey() throws Exception { addKeys(); @@ -5135,6 +5277,7 @@ protected void checkLocalRemovedKey(String keyToRmv) { /** * @throws Exception If failed. */ + @Test public void testLocalClearKeys() throws Exception { Map> keys = addKeys(); @@ -5206,6 +5349,7 @@ protected Map> addKeys() { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKey() throws Exception { testGlobalClearKey(false, false, Arrays.asList("key25")); } @@ -5213,6 +5357,7 @@ public void testGlobalClearKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeyAsyncOld() throws Exception { testGlobalClearKey(true, true, Arrays.asList("key25")); } @@ -5220,6 +5365,7 @@ public void testGlobalClearKeyAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeyAsync() throws Exception { testGlobalClearKey(true, false, Arrays.asList("key25")); } @@ -5227,6 +5373,7 @@ public void testGlobalClearKeyAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeys() throws Exception { testGlobalClearKey(false, false, Arrays.asList("key25", "key100", "key150")); } @@ -5234,6 +5381,7 @@ public void testGlobalClearKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeysAsyncOld() throws Exception { testGlobalClearKey(true, true, Arrays.asList("key25", "key100", "key150")); } @@ -5241,6 +5389,7 @@ public void testGlobalClearKeysAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGlobalClearKeysAsync() throws Exception { testGlobalClearKey(true, false, Arrays.asList("key25", "key100", "key150")); } @@ -5307,6 +5456,7 @@ protected void testGlobalClearKey(boolean async, boolean oldAsync, Collection cache = grid(0).cache(cacheName()); @@ -5850,6 +6002,7 @@ private void checkEmpty(IgniteCache cache, IgniteCache pair = new IgnitePair<>(entry.ttl(), entry.expireTime()); + + if (!entry.isNear()) + entry.context().cache().removeEntry(entry); - return entry != null ? - new IgnitePair<>(entry.ttl(), entry.expireTime()) : - new IgnitePair(null, null); + return pair; } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationDefaultTemplateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationDefaultTemplateTest.java index c1af11ee9ac9c..fb080a207850a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationDefaultTemplateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationDefaultTemplateTest.java @@ -21,24 +21,20 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheConfigurationDefaultTemplateTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration templateCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); templateCfg.setName("org.apache.ignite.template*"); @@ -59,6 +55,7 @@ public class IgniteCacheConfigurationDefaultTemplateTest extends GridCommonAbstr /** * @throws Exception If failed. */ + @Test public void testDefaultTemplate() throws Exception { Ignite ignite = startGrid(0); @@ -110,4 +107,4 @@ private void checkGetOrCreate(Ignite ignite, String name, int expBackups) { assertEquals(name, cfg.getName()); assertEquals(expBackups, cfg.getBackups()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java index cad629d0035b0..4cb07a48c10c4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java @@ -31,20 +31,19 @@ import org.apache.ignite.events.EventType; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheConfigurationTemplateTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String TEMPLATE1 = "org.apache.ignite*"; @@ -64,7 +63,7 @@ public class IgniteCacheConfigurationTemplateTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder).setForceServerMode(true); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); if (addTemplate) { CacheConfiguration dfltCfg = new CacheConfiguration("*"); @@ -102,6 +101,7 @@ public class IgniteCacheConfigurationTemplateTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testCreateFromTemplate() throws Exception { addTemplate = true; @@ -156,6 +156,7 @@ public void testCreateFromTemplate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateFromTemplate() throws Exception { addTemplate = true; @@ -233,6 +234,7 @@ public void testGetOrCreateFromTemplate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartClientNodeFirst() throws Exception { addTemplate = true; clientMode = true; @@ -259,6 +261,7 @@ public void testStartClientNodeFirst() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddCacheConfigurationMultinode() throws Exception { addTemplate = true; @@ -306,6 +309,7 @@ public void testAddCacheConfigurationMultinode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoPartitionExchangeForTemplate() throws Exception{ final int GRID_CNT = 3; @@ -355,6 +359,7 @@ public void testNoPartitionExchangeForTemplate() throws Exception{ /** * @throws Exception If failed. */ + @Test public void testTemplateCleanup() throws Exception { startGridsMultiThreaded(3); @@ -447,4 +452,4 @@ private void checkNoTemplateCaches(int nodes) { assertNull(ignite.cache(TEMPLATE3)); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheContainsKeyAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheContainsKeyAbstractSelfTest.java index 7d98968cbf291..66259b720fb92 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheContainsKeyAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheContainsKeyAbstractSelfTest.java @@ -28,12 +28,16 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * Tests various scenarios for {@code containsKey()} method. */ +@RunWith(JUnit4.class) public abstract class IgniteCacheContainsKeyAbstractSelfTest extends GridCacheAbstractSelfTest { /** * @return Number of grids to start. @@ -76,6 +80,7 @@ public abstract class IgniteCacheContainsKeyAbstractSelfTest extends GridCacheAb /** * @throws Exception If failed. */ + @Test public void testDistributedContains() throws Exception { String key = "1"; @@ -91,6 +96,7 @@ public void testDistributedContains() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContainsInTx() throws Exception { if (atomicityMode() == TRANSACTIONAL) { String key = "1"; @@ -137,4 +143,4 @@ private boolean txContainsKey(Transaction tx, String key) { return entry != null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheContainsKeyAtomicTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheContainsKeyAtomicTest.java index 981d245245a20..73324685437a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheContainsKeyAtomicTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheContainsKeyAtomicTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -31,6 +34,7 @@ /** * Verifies that containsKey() works as expected on atomic cache. */ +@RunWith(JUnit4.class) public class IgniteCacheContainsKeyAtomicTest extends GridCacheAbstractSelfTest { /** Cache name. */ public static final String CACHE_NAME = "replicated"; @@ -53,6 +57,7 @@ public class IgniteCacheContainsKeyAtomicTest extends GridCacheAbstractSelfTest /** * @throws Exception If failed. */ + @Test public void testContainsPutIfAbsent() throws Exception { checkPutIfAbsent(false); } @@ -60,6 +65,7 @@ public void testContainsPutIfAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContainsPutIfAbsentAll() throws Exception { checkPutIfAbsent(true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java index 61f8136ab796d..f2eb5dcbd3dc8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCopyOnReadDisabledAbstractTest.java @@ -22,10 +22,14 @@ import javax.cache.processor.MutableEntry; import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheCopyOnReadDisabledAbstractTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -51,6 +55,7 @@ public abstract class IgniteCacheCopyOnReadDisabledAbstractTest extends GridCach /** * @throws Exception If failed. */ + @Test public void testCopyOnReadDisabled() throws Exception { IgniteCache cache = ignite(0).cache(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCreateRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCreateRestartSelfTest.java index e8544517bcda5..4b6e1d4663104 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCreateRestartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCreateRestartSelfTest.java @@ -25,22 +25,20 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheCreateRestartSelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "partitioned"; - /** IP finder. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 4; @@ -52,8 +50,6 @@ public class IgniteCacheCreateRestartSelfTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - return cfg; } @@ -70,6 +66,7 @@ public class IgniteCacheCreateRestartSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStopOriginatingNode() throws Exception { startGrids(NODES); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDynamicStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDynamicStopSelfTest.java index b1047ba829d35..1a0c575095db7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDynamicStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDynamicStopSelfTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheDynamicStopSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -44,6 +48,7 @@ public class IgniteCacheDynamicStopSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStopStartCacheWithDataLoaderNoOverwrite() throws Exception { checkStopStartCacheWithDataLoader(false); } @@ -51,6 +56,7 @@ public void testStopStartCacheWithDataLoaderNoOverwrite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopStartCacheWithDataLoaderOverwrite() throws Exception { checkStopStartCacheWithDataLoader(true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java index b4e564faa8ebd..b612c6bcacbf8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java @@ -67,7 +67,11 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static javax.cache.event.EventType.CREATED; @@ -81,6 +85,7 @@ /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAbstractTest { /** */ private static volatile List> evts; @@ -103,6 +108,13 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb /** */ private static AtomicBoolean serialized = new AtomicBoolean(false); + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { @@ -152,6 +164,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb /** * @throws Exception If failed. */ + @Test public void testExceptionIgnored() throws Exception { CacheEntryListenerConfiguration lsnrCfg = new MutableCacheEntryListenerConfiguration<>( new Factory>() { @@ -211,6 +224,7 @@ public void testExceptionIgnored() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoOldValue() throws Exception { CacheEntryListenerConfiguration lsnrCfg = new MutableCacheEntryListenerConfiguration<>( new Factory>() { @@ -242,6 +256,7 @@ public void testNoOldValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSynchronousEventsObjectKeyValue() throws Exception { useObjects = true; @@ -251,6 +266,7 @@ public void testSynchronousEventsObjectKeyValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSynchronousEvents() throws Exception { final CacheEntryCreatedListener lsnr = new CreateUpdateRemoveExpireListener() { @Override public void onRemoved(Iterable> evts) { @@ -348,6 +364,7 @@ private void awaitLatch() { /** * @throws Exception If failed. */ + @Test public void testSynchronousEventsListenerNodeFailed() throws Exception { if (cacheMode() != PARTITIONED) return; @@ -402,6 +419,7 @@ public void testSynchronousEventsListenerNodeFailed() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentRegisterDeregister() throws Exception { final int THREADS = 10; @@ -438,6 +456,7 @@ public void testConcurrentRegisterDeregister() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSerialization() throws Exception { if (cacheMode() == LOCAL) return; @@ -541,6 +560,7 @@ private Object value(Integer val) { /** * @throws Exception If failed. */ + @Test public void testEventsObjectKeyValue() throws Exception { useObjects = true; @@ -550,6 +570,7 @@ public void testEventsObjectKeyValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvents() throws Exception { IgniteCache cache = jcache(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerEagerTtlDisabledTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerEagerTtlDisabledTest.java index a1bf26b1632dd..90e28618eac33 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerEagerTtlDisabledTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerEagerTtlDisabledTest.java @@ -19,11 +19,19 @@ import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * Tests expire events when {@link CacheConfiguration#isEagerTtl()} is disabled. */ public class IgniteCacheEntryListenerEagerTtlDisabledTest extends IgniteCacheEntryListenerTxTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected boolean eagerTtl() { return false; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerExpiredEventsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerExpiredEventsTest.java index 524d0fb34bec2..ed72511928a11 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerExpiredEventsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerExpiredEventsTest.java @@ -30,14 +30,13 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -48,22 +47,11 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheEntryListenerExpiredEventsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static AtomicInteger evtCntr; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); @@ -74,6 +62,7 @@ public class IgniteCacheEntryListenerExpiredEventsTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testExpiredEventAtomic() throws Exception { checkExpiredEvents(cacheConfiguration(PARTITIONED, ATOMIC)); } @@ -81,6 +70,7 @@ public void testExpiredEventAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExpiredEventTx() throws Exception { checkExpiredEvents(cacheConfiguration(PARTITIONED, TRANSACTIONAL)); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxLocalTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxLocalTest.java index 5da10c626ca24..0212ddd6d983c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxLocalTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxLocalTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -28,6 +29,13 @@ * */ public class IgniteCacheEntryListenerTxLocalTest extends IgniteCacheEntryListenerAbstractTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryProcessorCallTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryProcessorCallTest.java index 4efe51303cbca..02a6fbed7ed50 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryProcessorCallTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryProcessorCallTest.java @@ -26,17 +26,18 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -47,10 +48,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheEntryProcessorCallTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ static final AtomicInteger callCnt = new AtomicInteger(); @@ -76,8 +75,6 @@ public class IgniteCacheEntryProcessorCallTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -99,7 +96,8 @@ public class IgniteCacheEntryProcessorCallTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ - public void testEntryProcessorCall() throws Exception { + @Test + public void testEntryProcessorCallOnAtomicCache() throws Exception { { CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setBackups(1); @@ -117,7 +115,13 @@ public void testEntryProcessorCall() throws Exception { checkEntryProcessorCallCount(ccfg, 1); } + } + /** + * @throws Exception If failed. + */ + @Test + public void testEntryProcessorCallOnTxCache() throws Exception { { CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setBackups(1); @@ -137,6 +141,30 @@ public void testEntryProcessorCall() throws Exception { } } + /** + * @throws Exception If failed. + */ + @Test + public void testEntryProcessorCallOnMvccCache() throws Exception { + { + CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); + ccfg.setBackups(1); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + + checkEntryProcessorCallCount(ccfg, 2); + } + + { + CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); + ccfg.setBackups(0); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + + checkEntryProcessorCallCount(ccfg, 1); + } + } + /** * @param ccfg Cache configuration. * @param expCallCnt Expected entry processor calls count. @@ -163,18 +191,22 @@ private void checkEntryProcessorCallCount(CacheConfiguration if (ccfg.getAtomicityMode() == TRANSACTIONAL) { checkEntryProcessCall(key++, clientCache1, OPTIMISTIC, REPEATABLE_READ, expCallCnt + 1); - checkEntryProcessCall(key++, clientCache1, PESSIMISTIC, REPEATABLE_READ, expCallCnt + 1); checkEntryProcessCall(key++, clientCache1, OPTIMISTIC, SERIALIZABLE, expCallCnt + 1); + checkEntryProcessCall(key++, clientCache1, PESSIMISTIC, REPEATABLE_READ, expCallCnt + 1); } + else if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) + checkEntryProcessCall(key++, clientCache1, PESSIMISTIC, REPEATABLE_READ, expCallCnt); for (int i = 100; i < 110; i++) { checkEntryProcessCall(key++, srvCache, null, null, expCallCnt); if (ccfg.getAtomicityMode() == TRANSACTIONAL) { - checkEntryProcessCall(key++, srvCache, OPTIMISTIC, REPEATABLE_READ, expCallCnt + 1); - checkEntryProcessCall(key++, srvCache, PESSIMISTIC, REPEATABLE_READ, expCallCnt + 1); - checkEntryProcessCall(key++, srvCache, OPTIMISTIC, SERIALIZABLE, expCallCnt + 1); + checkEntryProcessCall(key++, clientCache1, OPTIMISTIC, REPEATABLE_READ, expCallCnt + 1); + checkEntryProcessCall(key++, clientCache1, OPTIMISTIC, SERIALIZABLE, expCallCnt + 1); + checkEntryProcessCall(key++, clientCache1, PESSIMISTIC, REPEATABLE_READ, expCallCnt + 1); } + else if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) + checkEntryProcessCall(key++, clientCache1, PESSIMISTIC, REPEATABLE_READ, expCallCnt); } for (int i = 0; i < NODES; i++) @@ -182,7 +214,6 @@ private void checkEntryProcessorCallCount(CacheConfiguration } /** - * * @param key Key. * @param cache Cache. * @param concurrency Transaction concurrency. @@ -205,6 +236,9 @@ private void checkEntryProcessCall(Integer key, ", concurrency=" + concurrency + ", isolation=" + isolation + "]"); + int expCallCntOnGet = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL_SNAPSHOT ? + 1 : expCallCnt; + Transaction tx; TestReturnValue retVal; @@ -237,7 +271,7 @@ private void checkEntryProcessCall(Integer key, if (tx != null) tx.commit(); - assertEquals(expCallCnt, callCnt.get()); + assertEquals(expCallCntOnGet, callCnt.get()); checkReturnValue(retVal, "0"); checkCacheValue(cache.getName(), key, new TestValue(0)); @@ -415,7 +449,7 @@ public Integer value() { if (o == null || getClass() != o.getClass()) return false; - TestValue testVal = (TestValue) o; + TestValue testVal = (TestValue)o; return val.equals(testVal.val); @@ -473,7 +507,7 @@ public Object argument() { if (o == null || getClass() != o.getClass()) return false; - TestReturnValue testVal = (TestReturnValue) o; + TestReturnValue testVal = (TestReturnValue)o; return val.equals(testVal.val); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryProcessorNodeJoinTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryProcessorNodeJoinTest.java index ec982949efb3c..60ce7e88cf327 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryProcessorNodeJoinTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryProcessorNodeJoinTest.java @@ -38,13 +38,15 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.GridTestUtils.SF; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -53,18 +55,19 @@ /** * Tests cache in-place modification logic with iterative value increment. */ +@RunWith(JUnit4.class) public class IgniteCacheEntryProcessorNodeJoinTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of nodes to test on. */ private static final int GRID_CNT = 2; /** Number of increment iterations. */ - private static final int INCREMENTS = 100; + private final int INCREMENTS = SF.apply(100); + + /** Number of test iterations. */ + private final int ITERATIONS = SF.applyLB(10, 2); /** */ - private static final int KEYS = 50; + private final int KEYS = SF.apply(50); /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -72,18 +75,12 @@ public class IgniteCacheEntryProcessorNodeJoinTest extends GridCommonAbstractTes cfg.setCacheConfiguration(cacheConfiguration()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); commSpi.setSharedMemoryPort(-1); cfg.setCommunicationSpi(commSpi); - cfg.setDiscoverySpi(disco); - return cfg; } @@ -111,7 +108,7 @@ protected CacheAtomicityMode atomicityMode() { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { - startGrids(GRID_CNT); + startGridsMultiThreaded(GRID_CNT, true); } /** {@inheritDoc} */ @@ -122,6 +119,7 @@ protected CacheAtomicityMode atomicityMode() { /** * @throws Exception If failed. */ + @Test public void testSingleEntryProcessorNodeJoin() throws Exception { checkEntryProcessorNodeJoin(false); } @@ -129,6 +127,7 @@ public void testSingleEntryProcessorNodeJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAllEntryProcessorNodeJoin() throws Exception { checkEntryProcessorNodeJoin(true); } @@ -136,11 +135,12 @@ public void testAllEntryProcessorNodeJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntryProcessorNodeLeave() throws Exception { startGrid(GRID_CNT); // TODO: IGNITE-1525 (test fails with one-phase commit). - boolean createCache = atomicityMode() == TRANSACTIONAL; + boolean createCache = atomicityMode() != ATOMIC; String cacheName = DEFAULT_CACHE_NAME; @@ -160,7 +160,7 @@ public void testEntryProcessorNodeLeave() throws Exception { final int RESTART_IDX = GRID_CNT + 1; - for (int iter = 0; iter < 10; iter++) { + for (int iter = 0; iter < ITERATIONS; iter++) { log.info("Iteration: " + iter); startGrid(RESTART_IDX); @@ -179,7 +179,7 @@ public void testEntryProcessorNodeLeave() throws Exception { } }, "stop-thread"); - int increments = checkIncrement(cacheName, iter % 2 == 2, fut, latch); + int increments = checkIncrement(cacheName, iter % 2 == 1, fut, latch); assert increments >= INCREMENTS; @@ -212,28 +212,27 @@ private void checkEntryProcessorNodeJoin(boolean invokeAll) throws Exception { final AtomicReference error = new AtomicReference<>(); final int started = 6; - try { - IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Runnable() { - @Override public void run() { - try { - for (int i = 0; i < started; i++) { - U.sleep(1_000); + IgniteInternalFuture fut = GridTestUtils.runAsync(new Runnable() { + @Override public void run() { + try { + for (int i = 0; i < started && !stop.get(); i++) { + U.sleep(1_000); + if (!stop.get()) startGrid(GRID_CNT + i); - } - } - catch (Exception e) { - error.compareAndSet(null, e); } } - }, 1, "starter"); + catch (Exception e) { + error.compareAndSet(null, e); + } + } + }, "starter"); + try { try { checkIncrement(DEFAULT_CACHE_NAME, invokeAll, null, null); } finally { - stop.set(true); - fut.get(getTestTimeout()); } @@ -247,8 +246,10 @@ private void checkEntryProcessorNodeJoin(boolean invokeAll) throws Exception { } } finally { - for (int i = 0; i < started; i++) - stopGrid(GRID_CNT + i); + stop.set(true); + + if (!fut.isDone()) + fut.cancel(); } } @@ -257,8 +258,8 @@ private void checkEntryProcessorNodeJoin(boolean invokeAll) throws Exception { * @param invokeAll If {@code true} tests invokeAll operation. * @param fut If not null then executes updates while future is not done. * @param latch Latch to count down when first update is done. - * @throws Exception If failed. * @return Number of increments. + * @throws Exception If failed. */ private int checkIncrement( String cacheName, @@ -289,7 +290,7 @@ private int checkIncrement( EntryProcessorResult res = resMap.get(key); assertNotNull(res); - assertEquals(k + 1, (Object) res.get()); + assertEquals(k + 1, (Object)res.get()); } } else { @@ -323,55 +324,56 @@ private int checkIncrement( /** * @throws Exception If failed. */ + @Test public void testReplaceNodeJoin() throws Exception { final AtomicReference error = new AtomicReference<>(); final int started = 6; - try { - int keys = 100; + int keys = 100; - final AtomicBoolean done = new AtomicBoolean(false); + final AtomicBoolean stop = new AtomicBoolean(false); - for (int i = 0; i < keys; i++) - ignite(0).cache(DEFAULT_CACHE_NAME).put(i, 0); + for (int i = 0; i < keys; i++) + ignite(0).cache(DEFAULT_CACHE_NAME).put(i, 0); - IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Runnable() { - @Override public void run() { - try { - for (int i = 0; i < started; i++) { - U.sleep(1_000); + IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Runnable() { + @Override public void run() { + try { + for (int i = 0; i < started && !stop.get(); i++) { + U.sleep(1_000); - IgniteEx grid = startGrid(GRID_CNT + i); + if (stop.get()) + continue; - info("Test started grid [idx=" + (GRID_CNT + i) + ", nodeId=" + grid.localNode().id() + ']'); - } - } - catch (Exception e) { - error.compareAndSet(null, e); - } - finally { - done.set(true); + IgniteEx grid = startGrid(GRID_CNT + i); + + info("Test started grid [idx=" + (GRID_CNT + i) + ", nodeId=" + grid.localNode().id() + ']'); } } - }, 1, "starter"); + catch (Exception e) { + error.compareAndSet(null, e); + } + finally { + stop.set(true); + } + } + }, 1, "starter"); + try { int updVal = 0; - try { - while (!done.get()) { - info("Will put: " + (updVal + 1)); + while (!stop.get()) { + info("Will put: " + (updVal + 1)); - for (int i = 0; i < keys; i++) - assertTrue("Failed [key=" + i + ", oldVal=" + updVal+ ']', - ignite(0).cache(DEFAULT_CACHE_NAME).replace(i, updVal, updVal + 1)); + for (int i = 0; i < keys; i++) + assertTrue("Failed [key=" + i + ", oldVal=" + updVal+ ']', + ignite(0).cache(DEFAULT_CACHE_NAME).replace(i, updVal, updVal + 1)); - updVal++; - } - } - finally { - fut.get(getTestTimeout()); + updVal++; } + fut.get(getTestTimeout()); + for (int i = 0; i < keys; i++) { for (int g = 0; g < GRID_CNT + started; g++) { Integer val = ignite(g).cache(DEFAULT_CACHE_NAME).get(i); @@ -386,8 +388,10 @@ public void testReplaceNodeJoin() throws Exception { } } finally { - for (int i = 0; i < started; i++) - stopGrid(GRID_CNT + i); + stop.set(true); + + if (!fut.isDone()) + fut.cancel(); } } @@ -417,4 +421,4 @@ private Processor(String val) { return vals.size(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheExpireAndUpdateConsistencyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheExpireAndUpdateConsistencyTest.java index 5257a4a9f7d4e..d47e5167bfc6c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheExpireAndUpdateConsistencyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheExpireAndUpdateConsistencyTest.java @@ -42,12 +42,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -60,10 +60,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheExpireAndUpdateConsistencyTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -74,8 +72,6 @@ public class IgniteCacheExpireAndUpdateConsistencyTest extends GridCommonAbstrac @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -97,6 +93,7 @@ public class IgniteCacheExpireAndUpdateConsistencyTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testAtomic1() throws Exception { updateAndEventConsistencyTest(cacheConfiguration(ATOMIC, 0)); } @@ -104,6 +101,7 @@ public void testAtomic1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomic2() throws Exception { updateAndEventConsistencyTest(cacheConfiguration(ATOMIC, 1)); } @@ -111,6 +109,7 @@ public void testAtomic2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomic3() throws Exception { updateAndEventConsistencyTest(cacheConfiguration(ATOMIC, 2)); } @@ -118,6 +117,7 @@ public void testAtomic3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTx1() throws Exception { updateAndEventConsistencyTest(cacheConfiguration(TRANSACTIONAL, 0)); } @@ -125,6 +125,7 @@ public void testTx1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTx2() throws Exception { updateAndEventConsistencyTest(cacheConfiguration(TRANSACTIONAL, 1)); } @@ -132,6 +133,7 @@ public void testTx2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTx3() throws Exception { updateAndEventConsistencyTest(cacheConfiguration(TRANSACTIONAL, 2)); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetCustomCollectionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetCustomCollectionsSelfTest.java index 9e6fd5a57fc7a..489c53106c653 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetCustomCollectionsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGetCustomCollectionsSelfTest.java @@ -28,18 +28,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheGetCustomCollectionsSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -55,18 +53,13 @@ public class IgniteCacheGetCustomCollectionsSelfTest extends GridCommonAbstractT cfg.setCacheConfiguration(mapCacheConfig); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - return cfg; } /** * @throws Exception If failed. */ + @Test public void testPutGet() throws Exception { startGrids(3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java index 2104c5d91ecb4..abdd07f5afeca 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache; +import com.google.common.collect.Sets; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -49,7 +50,6 @@ import javax.cache.integration.CacheWriterException; import javax.cache.processor.EntryProcessorException; import javax.cache.processor.MutableEntry; -import com.google.common.collect.Sets; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; @@ -94,16 +94,18 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -117,16 +119,17 @@ * */ @SuppressWarnings({"unchecked", "ThrowableNotThrown"}) +@RunWith(JUnit4.class) public class IgniteCacheGroupsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String GROUP1 = "grp1"; /** */ private static final String GROUP2 = "grp2"; + /** */ + private static final String GROUP3 = "grp3"; + /** */ private static final String CACHE1 = "cache1"; @@ -146,8 +149,6 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); if (ccfgs != null) { @@ -174,6 +175,7 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCloseCache1() throws Exception { startGrid(0); @@ -208,6 +210,7 @@ public void testCloseCache1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateDestroyCaches1() throws Exception { createDestroyCaches(1); } @@ -215,6 +218,7 @@ public void testCreateDestroyCaches1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateDestroyCaches2() throws Exception { createDestroyCaches(5); } @@ -222,6 +226,7 @@ public void testCreateDestroyCaches2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateCacheWithSameNameInAnotherGroup() throws Exception { startGridsMultiThreaded(2); @@ -240,6 +245,7 @@ public void testCreateCacheWithSameNameInAnotherGroup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateDestroyCachesAtomicPartitioned() throws Exception { createDestroyCaches(PARTITIONED, ATOMIC); } @@ -247,6 +253,7 @@ public void testCreateDestroyCachesAtomicPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateDestroyCachesTxPartitioned() throws Exception { createDestroyCaches(PARTITIONED, TRANSACTIONAL); } @@ -254,6 +261,15 @@ public void testCreateDestroyCachesTxPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testCreateDestroyCachesMvccTxPartitioned() throws Exception { + createDestroyCaches(PARTITIONED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCreateDestroyCachesAtomicReplicated() throws Exception { createDestroyCaches(REPLICATED, ATOMIC); } @@ -261,6 +277,7 @@ public void testCreateDestroyCachesAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateDestroyCachesTxReplicated() throws Exception { createDestroyCaches(REPLICATED, TRANSACTIONAL); } @@ -268,6 +285,16 @@ public void testCreateDestroyCachesTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test + public void testCreateDestroyCachesMvccTxReplicated() throws Exception { + createDestroyCaches(REPLICATED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testScanQueryAtomicPartitioned() throws Exception { scanQuery(PARTITIONED, ATOMIC); } @@ -275,6 +302,7 @@ public void testScanQueryAtomicPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQueryTxPartitioned() throws Exception { scanQuery(PARTITIONED, TRANSACTIONAL); } @@ -282,6 +310,15 @@ public void testScanQueryTxPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testScanQueryMvccTxPartitioned() throws Exception { + scanQuery(PARTITIONED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testScanQueryAtomicReplicated() throws Exception { scanQuery(REPLICATED, ATOMIC); } @@ -289,6 +326,7 @@ public void testScanQueryAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQueryTxReplicated() throws Exception { scanQuery(REPLICATED, TRANSACTIONAL); } @@ -296,6 +334,17 @@ public void testScanQueryTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10750") + @Test + public void testScanQueryMvccTxReplicated() throws Exception { + scanQuery(REPLICATED, TRANSACTIONAL_SNAPSHOT); + } + + + /** + * @throws Exception If failed. + */ + @Test public void testScanQueryAtomicLocal() throws Exception { scanQuery(LOCAL, ATOMIC); } @@ -303,6 +352,7 @@ public void testScanQueryAtomicLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQueryTxLocal() throws Exception { scanQuery(LOCAL, TRANSACTIONAL); } @@ -310,6 +360,17 @@ public void testScanQueryTxLocal() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testScanQueryMvccTxLocal() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + scanQuery(LOCAL, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testEntriesTtlAtomicPartitioned() throws Exception { entriesTtl(PARTITIONED, ATOMIC); } @@ -317,6 +378,7 @@ public void testEntriesTtlAtomicPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntriesTtlTxPartitioned() throws Exception { entriesTtl(PARTITIONED, TRANSACTIONAL); } @@ -324,6 +386,17 @@ public void testEntriesTtlTxPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testEntriesTtlMvccTxPartitioned() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-7311"); + + entriesTtl(PARTITIONED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testEntriesTtlAtomicReplicated() throws Exception { entriesTtl(REPLICATED, ATOMIC); } @@ -331,6 +404,7 @@ public void testEntriesTtlAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntriesTtlTxReplicated() throws Exception { entriesTtl(REPLICATED, TRANSACTIONAL); } @@ -338,6 +412,17 @@ public void testEntriesTtlTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testEntriesTtlMvccTxReplicated() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-7311"); + + entriesTtl(REPLICATED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testEntriesTtlAtomicLocal() throws Exception { entriesTtl(LOCAL, ATOMIC); } @@ -345,6 +430,7 @@ public void testEntriesTtlAtomicLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntriesTtlTxLocal() throws Exception { entriesTtl(LOCAL, TRANSACTIONAL); } @@ -352,6 +438,18 @@ public void testEntriesTtlTxLocal() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testEntriesTtlMvccTxLocal() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + fail("https://issues.apache.org/jira/browse/IGNITE-7311"); + + entriesTtl(LOCAL, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCacheIteratorAtomicPartitioned() throws Exception { cacheIterator(PARTITIONED, ATOMIC); } @@ -359,6 +457,7 @@ public void testCacheIteratorAtomicPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheIteratorTxPartitioned() throws Exception { cacheIterator(PARTITIONED, TRANSACTIONAL); } @@ -366,6 +465,15 @@ public void testCacheIteratorTxPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testCacheIteratorMvccTxPartitioned() throws Exception { + cacheIterator(PARTITIONED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCacheIteratorAtomicReplicated() throws Exception { cacheIterator(REPLICATED, ATOMIC); } @@ -373,6 +481,7 @@ public void testCacheIteratorAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheIteratorTxReplicated() throws Exception { cacheIterator(REPLICATED, TRANSACTIONAL); } @@ -380,6 +489,15 @@ public void testCacheIteratorTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testCacheIteratorMvccTxReplicated() throws Exception { + cacheIterator(REPLICATED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCacheIteratorAtomicLocal() throws Exception { cacheIterator(LOCAL, ATOMIC); } @@ -387,6 +505,7 @@ public void testCacheIteratorAtomicLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheIteratorTxLocal() throws Exception { cacheIterator(LOCAL, TRANSACTIONAL); } @@ -394,6 +513,17 @@ public void testCacheIteratorTxLocal() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testCacheIteratorMvccTxLocal() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + cacheIterator(LOCAL, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testScanQueryMultiplePartitionsAtomicPartitioned() throws Exception { scanQueryMultiplePartitions(PARTITIONED, ATOMIC); } @@ -401,6 +531,7 @@ public void testScanQueryMultiplePartitionsAtomicPartitioned() throws Exception /** * @throws Exception If failed. */ + @Test public void testScanQueryMultiplePartitionsTxPartitioned() throws Exception { scanQueryMultiplePartitions(PARTITIONED, TRANSACTIONAL); } @@ -408,6 +539,15 @@ public void testScanQueryMultiplePartitionsTxPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testScanQueryMultiplePartitionsMvccTxPartitioned() throws Exception { + scanQueryMultiplePartitions(PARTITIONED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testScanQueryMultiplePartitionsAtomicReplicated() throws Exception { scanQueryMultiplePartitions(REPLICATED, ATOMIC); } @@ -415,6 +555,7 @@ public void testScanQueryMultiplePartitionsAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQueryMultiplePartitionsTxReplicated() throws Exception { scanQueryMultiplePartitions(REPLICATED, TRANSACTIONAL); } @@ -422,6 +563,15 @@ public void testScanQueryMultiplePartitionsTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testScanQueryMultiplePartitionsMvccTxReplicated() throws Exception { + scanQueryMultiplePartitions(REPLICATED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testContinuousQueryTxReplicated() throws Exception { continuousQuery(REPLICATED, TRANSACTIONAL); } @@ -429,6 +579,15 @@ public void testContinuousQueryTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testContinuousQueryMvccTxReplicated() throws Exception { + continuousQuery(REPLICATED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testContinuousQueryTxPartitioned() throws Exception { continuousQuery(PARTITIONED, TRANSACTIONAL); } @@ -436,6 +595,15 @@ public void testContinuousQueryTxPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testContinuousQueryMvccTxPartitioned() throws Exception { + continuousQuery(PARTITIONED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testContinuousQueryTxLocal() throws Exception { continuousQuery(LOCAL, TRANSACTIONAL); } @@ -443,6 +611,17 @@ public void testContinuousQueryTxLocal() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testContinuousQueryMvccTxLocal() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + continuousQuery(LOCAL, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testContinuousQueryAtomicReplicated() throws Exception { continuousQuery(REPLICATED, ATOMIC); } @@ -450,6 +629,7 @@ public void testContinuousQueryAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContinuousQueryAtomicPartitioned() throws Exception { continuousQuery(PARTITIONED, ATOMIC); } @@ -457,6 +637,7 @@ public void testContinuousQueryAtomicPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContinuousQueryAtomicLocal() throws Exception { continuousQuery(LOCAL, ATOMIC); } @@ -1194,6 +1375,7 @@ private CacheConfiguration[] staticConfigurations1(boolean cache3) { /** * @throws Exception If failed. */ + @Test public void testDiscoveryDataConsistency1() throws Exception { ccfgs = staticConfigurations1(true); Ignite srv0 = startGrid(0); @@ -1288,6 +1470,7 @@ private CacheConfiguration[] cacheConfigurations(int cnt, String grp, String bas /** * @throws Exception If failed. */ + @Test public void testStartManyCaches() throws Exception { final int CACHES = 5_000; @@ -1330,6 +1513,7 @@ public void testStartManyCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalance1() throws Exception { Ignite srv0 = startGrid(0); @@ -1341,6 +1525,10 @@ public void testRebalance1() throws Exception { srv0.createCache(cacheConfiguration(GROUP2, "c3", PARTITIONED, TRANSACTIONAL, 2, false)); IgniteCache srv0Cache4 = srv0.createCache(cacheConfiguration(GROUP2, "c4", PARTITIONED, TRANSACTIONAL, 2, false)); + IgniteCache srv0Cache5 = + srv0.createCache(cacheConfiguration(GROUP3, "c5", PARTITIONED, TRANSACTIONAL_SNAPSHOT, 2, false)); + IgniteCache srv0Cache6 = + srv0.createCache(cacheConfiguration(GROUP3, "c6", PARTITIONED, TRANSACTIONAL_SNAPSHOT, 2, false)); final int ITEMS = 1_000; @@ -1349,6 +1537,9 @@ public void testRebalance1() throws Exception { srv0Cache3.put(new Key1(i), i); srv0Cache4.put(new Key1(i), -i); + + srv0Cache5.put(new Key1(i), i); + srv0Cache6.put(new Key1(i), -i); } assertEquals(ITEMS, srv0Cache1.size()); @@ -1356,6 +1547,8 @@ public void testRebalance1() throws Exception { assertEquals(0, srv0Cache2.size()); assertEquals(ITEMS, srv0Cache3.size()); assertEquals(ITEMS, srv0Cache4.localSize()); + assertEquals(ITEMS, srv0Cache5.size()); + assertEquals(ITEMS, srv0Cache6.localSize()); startGrid(1); @@ -1368,6 +1561,8 @@ public void testRebalance1() throws Exception { IgniteCache cache2 = node.cache("c2"); IgniteCache cache3 = node.cache("c3"); IgniteCache cache4 = node.cache("c4"); + IgniteCache cache5 = node.cache("c5"); + IgniteCache cache6 = node.cache("c6"); assertEquals(ITEMS * 2, cache1.size(CachePeekMode.ALL)); assertEquals(ITEMS, cache1.localSize(CachePeekMode.ALL)); @@ -1380,11 +1575,20 @@ public void testRebalance1() throws Exception { assertEquals(ITEMS * 2, cache4.size(CachePeekMode.ALL)); assertEquals(ITEMS, cache4.localSize(CachePeekMode.ALL)); + assertEquals(ITEMS * 2, cache5.size(CachePeekMode.ALL)); + assertEquals(ITEMS, cache5.localSize(CachePeekMode.ALL)); + + assertEquals(ITEMS * 2, cache6.size(CachePeekMode.ALL)); + assertEquals(ITEMS, cache6.localSize(CachePeekMode.ALL)); + + for (int k = 0; k < ITEMS; k++) { assertEquals(i, cache1.localPeek(new Key1(i))); assertNull(cache2.localPeek(new Key1(i))); assertEquals(i, cache3.localPeek(new Key1(i))); assertEquals(-i, cache4.localPeek(new Key1(i))); + assertEquals(i, cache5.localPeek(new Key1(i))); + assertEquals(-i, cache6.localPeek(new Key1(i))); } } @@ -1402,6 +1606,8 @@ public void testRebalance1() throws Exception { IgniteCache cache2 = node.cache("c2"); IgniteCache cache3 = node.cache("c3"); IgniteCache cache4 = node.cache("c4"); + IgniteCache cache5 = node.cache("c5"); + IgniteCache cache6 = node.cache("c6"); assertEquals(ITEMS * 3, cache1.size(CachePeekMode.ALL)); assertEquals(ITEMS, cache1.localSize(CachePeekMode.ALL)); @@ -1409,6 +1615,8 @@ public void testRebalance1() throws Exception { assertEquals(ITEMS * 2, cache2.localSize(CachePeekMode.ALL)); assertEquals(ITEMS, cache3.localSize(CachePeekMode.ALL)); assertEquals(ITEMS, cache4.localSize(CachePeekMode.ALL)); + assertEquals(ITEMS, cache5.localSize(CachePeekMode.ALL)); + assertEquals(ITEMS, cache6.localSize(CachePeekMode.ALL)); } IgniteCache srv2Cache1 = srv2.cache("c1"); @@ -1424,6 +1632,7 @@ public void testRebalance1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalance2() throws Exception { Ignite srv0 = startGrid(0); @@ -1507,6 +1716,7 @@ public void testRebalance2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoKeyIntersectTx() throws Exception { testNoKeyIntersect(TRANSACTIONAL); } @@ -1514,6 +1724,15 @@ public void testNoKeyIntersectTx() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testNoKeyIntersectMvccTx() throws Exception { + testNoKeyIntersect(TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testNoKeyIntersectAtomic() throws Exception { testNoKeyIntersect(ATOMIC); } @@ -1825,6 +2044,7 @@ private void testNoKeyIntersectTxLocks(final IgniteCache cache1, final IgniteCac /** * @throws Exception If failed. */ + @Test public void testCacheApiTxPartitioned() throws Exception { cacheApiTest(PARTITIONED, TRANSACTIONAL); } @@ -1832,6 +2052,17 @@ public void testCacheApiTxPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testCacheApiMvccTxPartitioned() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-7952"); + + cacheApiTest(PARTITIONED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCacheApiTxReplicated() throws Exception { cacheApiTest(REPLICATED, TRANSACTIONAL); } @@ -1839,6 +2070,17 @@ public void testCacheApiTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testCacheApiMvccTxReplicated() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-7952"); + + cacheApiTest(REPLICATED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCacheApiAtomicPartitioned() throws Exception { cacheApiTest(PARTITIONED, ATOMIC); } @@ -1846,6 +2088,7 @@ public void testCacheApiAtomicPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheApiAtomicReplicated() throws Exception { cacheApiTest(REPLICATED, ATOMIC); } @@ -2638,6 +2881,7 @@ private void cacheInvokeAsync(IgniteCache cache) { /** * @throws Exception If failed. */ + @Test public void testLoadCacheAtomicPartitioned() throws Exception { loadCache(PARTITIONED, ATOMIC); } @@ -2645,6 +2889,7 @@ public void testLoadCacheAtomicPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheAtomicReplicated() throws Exception { loadCache(REPLICATED, ATOMIC); } @@ -2652,6 +2897,7 @@ public void testLoadCacheAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheTxPartitioned() throws Exception { loadCache(PARTITIONED, TRANSACTIONAL); } @@ -2659,6 +2905,17 @@ public void testLoadCacheTxPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testLoadCacheMvccTxPartitioned() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-7954"); + + loadCache(PARTITIONED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testLoadCacheTxReplicated() throws Exception { loadCache(REPLICATED, TRANSACTIONAL); } @@ -2666,6 +2923,17 @@ public void testLoadCacheTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testLoadCacheMvccTxReplicated() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-7954"); + + loadCache(REPLICATED, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testLoadCacheAtomicLocal() throws Exception { loadCache(LOCAL, ATOMIC); } @@ -2673,10 +2941,21 @@ public void testLoadCacheAtomicLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheTxLocal() throws Exception { loadCache(LOCAL, TRANSACTIONAL); } + /** + * @throws Exception If failed. + */ + @Test + public void testLoadCacheMvccTxLocal() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + loadCache(LOCAL, TRANSACTIONAL_SNAPSHOT); + } + /** * @param cacheMode Cache mode. * @param atomicityMode Atomicity mode. @@ -2724,6 +3003,7 @@ private void loadCache(CacheMode cacheMode, CacheAtomicityMode atomicityMode) th /** * @throws Exception If failed. */ + @Test public void testConcurrentOperationsSameKeys() throws Exception { final int SRVS = 4; final int CLIENTS = 4; @@ -2828,6 +3108,7 @@ private IgniteInternalFuture updateFuture(final int nodes, /** * @throws Exception If failed. */ + @Test public void testConcurrentOperationsAndCacheDestroy() throws Exception { final int SRVS = 4; final int CLIENTS = 4; @@ -2854,6 +3135,8 @@ public void testConcurrentOperationsAndCacheDestroy() throws Exception { srv0.createCache( cacheConfiguration(GROUP2, GROUP2 + "-" + i, PARTITIONED, TRANSACTIONAL, grp2Backups, i % 2 == 0)); + + // TODO IGNITE-7164: add Mvcc cache to test. } final AtomicInteger idx = new AtomicInteger(); @@ -2975,6 +3258,7 @@ public void testConcurrentOperationsAndCacheDestroy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStaticConfigurationsValidation() throws Exception { ccfgs = new CacheConfiguration[2]; @@ -3015,6 +3299,7 @@ public void testStaticConfigurationsValidation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheIdConflict() throws Exception { ccfgs = new CacheConfiguration[]{new CacheConfiguration("AaAaAa"), new CacheConfiguration("AaAaBB")}; @@ -3058,6 +3343,7 @@ public void testCacheIdConflict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheGroupIdConflict1() throws Exception { ccfgs = new CacheConfiguration[]{new CacheConfiguration(CACHE1).setGroupName("AaAaAa"), new CacheConfiguration(CACHE2).setGroupName("AaAaBB")}; @@ -3102,6 +3388,7 @@ public void testCacheGroupIdConflict1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheGroupIdConflict2() throws Exception { ccfgs = new CacheConfiguration[]{new CacheConfiguration("AaAaAa"), new CacheConfiguration(CACHE2).setGroupName("AaAaBB")}; @@ -3146,6 +3433,7 @@ public void testCacheGroupIdConflict2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheGroupIdConflict3() throws Exception { ccfgs = new CacheConfiguration[]{new CacheConfiguration(CACHE2).setGroupName("AaAaBB"), new CacheConfiguration("AaAaAa")}; @@ -3190,6 +3478,7 @@ public void testCacheGroupIdConflict3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheGroupNameConflict1() throws Exception { ccfgs = new CacheConfiguration[]{new CacheConfiguration("cache1"), new CacheConfiguration("cache2").setGroupName("cache1")}; @@ -3233,6 +3522,7 @@ public void testCacheGroupNameConflict1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheGroupNameConflict2() throws Exception { ccfgs = new CacheConfiguration[]{new CacheConfiguration("cache2").setGroupName("cache1"), new CacheConfiguration("cache1")}; @@ -3276,6 +3566,7 @@ public void testCacheGroupNameConflict2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConfigurationConsistencyValidation() throws Exception { startGrids(2); @@ -3305,6 +3596,16 @@ public void testConfigurationConsistencyValidation() throws Exception { assertTrue("Unexpected message: " + e.getMessage(), e.getMessage().contains("Backups mismatch for caches related to the same group [groupName=grp1")); } + + try { + ignite(i).createCache(cacheConfiguration(GROUP1, "c2", PARTITIONED, TRANSACTIONAL_SNAPSHOT, 1, false)); + + fail(); + } + catch (CacheException e) { + assertTrue("Unexpected message: " + e.getMessage(), + e.getMessage().contains("Atomicity mode mismatch for caches related to the same group [groupName=grp1")); + } } } @@ -3321,6 +3622,8 @@ private CacheConfiguration[] interceptorConfigurations() { ccfgs[4] = cacheConfiguration(GROUP1, "c5", PARTITIONED, ATOMIC, 2, false); ccfgs[5] = cacheConfiguration(GROUP1, "c6", PARTITIONED, TRANSACTIONAL, 2, false); + //TODO IGNITE-9323: Check Mvcc mode. + return ccfgs; } @@ -3329,6 +3632,7 @@ private CacheConfiguration[] interceptorConfigurations() { * * @throws Exception If failed. */ + @Test public void testInterceptors() throws Exception { for (int i = 0; i < 4; i++) { ccfgs = interceptorConfigurations(); @@ -3384,6 +3688,8 @@ private CacheConfiguration[] cacheStoreConfigurations() { ccfgs[4] = cacheConfiguration(GROUP1, "c5", PARTITIONED, ATOMIC, 2, false); ccfgs[5] = cacheConfiguration(GROUP1, "c6", PARTITIONED, TRANSACTIONAL, 2, false); + //TODO IGNITE-8582: Check Mvcc mode. + return ccfgs; } @@ -3392,6 +3698,7 @@ private CacheConfiguration[] cacheStoreConfigurations() { * * @throws Exception If failed. */ + @Test public void testCacheStores() throws Exception { for (int i = 0; i < 4; i++) { ccfgs = cacheStoreConfigurations(); @@ -3464,6 +3771,7 @@ private CacheConfiguration[] mapperConfigurations() { /** * @throws Exception If failed. */ + @Test public void testAffinityMappers() throws Exception { for (int i = 0; i < 4; i++) { ccfgs = mapperConfigurations(); @@ -3526,6 +3834,7 @@ private void checkAffinityMappers(Ignite node) { /** * @throws Exception If failed. */ + @Test public void testContinuousQueriesMultipleGroups1() throws Exception { continuousQueriesMultipleGroups(1); } @@ -3533,6 +3842,7 @@ public void testContinuousQueriesMultipleGroups1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContinuousQueriesMultipleGroups2() throws Exception { continuousQueriesMultipleGroups(4); } @@ -3559,7 +3869,9 @@ private void continuousQueriesMultipleGroups(int srvs) throws Exception { client.createCache(cacheConfiguration(null, "c7", PARTITIONED, ATOMIC, 1, false)); client.createCache(cacheConfiguration(null, "c8", PARTITIONED, TRANSACTIONAL, 1, false)); - String[] cacheNames = {"c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8"}; + client.createCache(cacheConfiguration(GROUP3, "c9", PARTITIONED, TRANSACTIONAL_SNAPSHOT, 1, false)); + + String[] cacheNames = {"c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9"}; AtomicInteger c1 = registerListener(client, "c1"); @@ -3577,6 +3889,7 @@ private void continuousQueriesMultipleGroups(int srvs) throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheIdSort() throws Exception { Ignite node = startGrid(0); @@ -3651,6 +3964,7 @@ public void testCacheIdSort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDataCleanup() throws Exception { Ignite node = startGrid(0); @@ -3711,6 +4025,7 @@ public void testDataCleanup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestartsAndCacheCreateDestroy() throws Exception { final int SRVS = 5; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheIncrementTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheIncrementTxTest.java index b3a505597b8dd..b0b547219ad02 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheIncrementTxTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheIncrementTxTest.java @@ -32,12 +32,12 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -47,10 +47,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheIncrementTxTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRVS = 4; @@ -58,8 +56,6 @@ public class IgniteCacheIncrementTxTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); if (getTestIgniteInstanceName(SRVS).equals(igniteInstanceName)) @@ -80,6 +76,7 @@ public class IgniteCacheIncrementTxTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testIncrementTxTopologyChange0() throws Exception { nodeJoin(cacheConfiguration(0)); } @@ -87,6 +84,7 @@ public void testIncrementTxTopologyChange0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrementTxTopologyChange1() throws Exception { nodeJoin(cacheConfiguration(1)); } @@ -94,6 +92,7 @@ public void testIncrementTxTopologyChange1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrementTxTopologyChange2() throws Exception { nodeJoin(cacheConfiguration(2)); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInterceptorSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInterceptorSelfTestSuite.java index f457e5df8d4db..5afe40618f95b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInterceptorSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInterceptorSelfTestSuite.java @@ -17,50 +17,62 @@ package org.apache.ignite.internal.processors.cache; +import java.util.Collection; import junit.framework.TestSuite; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Cache interceptor suite. */ -public class IgniteCacheInterceptorSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheInterceptorSelfTestSuite { /** * @return Cache API test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { + return suite(null); + } + + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("CacheInterceptor Test Suite"); - suite.addTestSuite(GridCacheInterceptorLocalSelfTest.class); - suite.addTestSuite(GridCacheInterceptorLocalWithStoreSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorLocalSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorLocalWithStoreSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheInterceptorLocalAtomicSelfTest.class); - suite.addTestSuite(GridCacheInterceptorLocalAtomicWithStoreSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorLocalAtomicSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorLocalAtomicWithStoreSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheInterceptorAtomicSelfTest.class); - suite.addTestSuite(GridCacheInterceptorAtomicNearEnabledSelfTest.class); - suite.addTestSuite(GridCacheInterceptorAtomicWithStoreSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorAtomicSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorAtomicNearEnabledSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorAtomicWithStoreSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheInterceptorAtomicReplicatedSelfTest.class); - suite.addTestSuite(GridCacheInterceptorAtomicWithStoreReplicatedSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorAtomicReplicatedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorAtomicWithStoreReplicatedSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheInterceptorSelfTest.class); - suite.addTestSuite(GridCacheInterceptorNearEnabledSelfTest.class); - suite.addTestSuite(GridCacheInterceptorWithStoreSelfTest.class); - suite.addTestSuite(GridCacheInterceptorReplicatedSelfTest.class); - suite.addTestSuite(GridCacheInterceptorReplicatedWithStoreSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorNearEnabledSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorWithStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorReplicatedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorReplicatedWithStoreSelfTest.class, ignoredTests); // TODO GG-11141. -// suite.addTestSuite(GridCacheOnCopyFlagTxPartitionedSelfTest.class); -// suite.addTestSuite(GridCacheOnCopyFlagReplicatedSelfTest.class); -// suite.addTestSuite(GridCacheOnCopyFlagLocalSelfTest.class); -// suite.addTestSuite(GridCacheOnCopyFlagAtomicSelfTest.class); +// GridTestUtils.addTestIfNeeded(suite,GridCacheOnCopyFlagTxPartitionedSelfTest.class, ignoredTests); +// GridTestUtils.addTestIfNeeded(suite,GridCacheOnCopyFlagReplicatedSelfTest.class, ignoredTests); +// GridTestUtils.addTestIfNeeded(suite,GridCacheOnCopyFlagLocalSelfTest.class, ignoredTests); +// GridTestUtils.addTestIfNeeded(suite,GridCacheOnCopyFlagAtomicSelfTest.class, ignoredTests); - suite.addTestSuite(CacheInterceptorPartitionCounterRandomOperationsTest.class); - suite.addTestSuite(CacheInterceptorPartitionCounterLocalSanityTest.class); + GridTestUtils.addTestIfNeeded(suite,CacheInterceptorPartitionCounterRandomOperationsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,CacheInterceptorPartitionCounterLocalSanityTest.class, ignoredTests); - suite.addTestSuite(GridCacheInterceptorAtomicRebalanceTest.class); - suite.addTestSuite(GridCacheInterceptorTransactionalRebalanceTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorAtomicRebalanceTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheInterceptorTransactionalRebalanceTest.class, ignoredTests); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java index d9a04280eff3b..955781025ae03 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java @@ -48,7 +48,11 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -58,6 +62,7 @@ /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheInvokeAbstractTest extends IgniteCacheAbstractTest { /** */ private Integer lastKey = 0; @@ -65,21 +70,24 @@ public abstract class IgniteCacheInvokeAbstractTest extends IgniteCacheAbstractT /** * @throws Exception If failed. */ + @Test public void testInvoke() throws Exception { IgniteCache cache = jcache(); invoke(cache, null); - if (atomicityMode() == TRANSACTIONAL) { - invoke(cache, PESSIMISTIC); + if (atomicityMode() != ATOMIC) { + invoke(cache, PESSIMISTIC); // Tx or Mvcc tx. - invoke(cache, OPTIMISTIC); + if (atomicityMode() == TRANSACTIONAL) + invoke(cache, OPTIMISTIC); } } /** * @throws Exception If failed. */ + @Test public void testInternalInvokeNullable() throws Exception { IgniteInternalCache cache = grid(0).cachex(DEFAULT_CACHE_NAME); @@ -230,15 +238,17 @@ private void invoke(final IgniteCache cache, @Nullable Transac /** * @throws Exception If failed. */ + @Test public void testInvokeAll() throws Exception { IgniteCache cache = jcache(); invokeAll(cache, null); - if (atomicityMode() == TRANSACTIONAL) { + if (atomicityMode() != ATOMIC) { invokeAll(cache, PESSIMISTIC); - invokeAll(cache, OPTIMISTIC); + if (atomicityMode() == TRANSACTIONAL) + invokeAll(cache, OPTIMISTIC); } } @@ -305,6 +315,7 @@ static class MyClass3{} /** * @throws Exception If failed. */ + @Test public void testInvokeAllAppliedOnceOnBinaryTypeRegistration() { IgniteCache cache = jcache(); @@ -996,4 +1007,4 @@ public String value() { return S.toString(TestValue.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java index 9baa176e1e003..5efa2ee59e6b9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java @@ -36,9 +36,6 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; @@ -53,9 +50,6 @@ * */ public abstract class IgniteCacheInvokeReadThroughAbstractTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static volatile boolean failed; @@ -66,8 +60,6 @@ public abstract class IgniteCacheInvokeReadThroughAbstractTest extends GridCommo @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughSingleNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughSingleNodeTest.java index 406e5afe9ff7d..44029457956c4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughSingleNodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughSingleNodeTest.java @@ -17,8 +17,16 @@ package org.apache.ignite.internal.processors.cache; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import org.apache.ignite.testframework.MvccFeatureChecker; + import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -26,7 +34,15 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheInvokeReadThroughSingleNodeTest extends IgniteCacheInvokeReadThroughAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected void startNodes() throws Exception { startGrid(0); @@ -35,6 +51,7 @@ public class IgniteCacheInvokeReadThroughSingleNodeTest extends IgniteCacheInvok /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughAtomic() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 1, false)); } @@ -42,6 +59,7 @@ public void testInvokeReadThroughAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughAtomicNearCache() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 1, true)); } @@ -49,6 +67,7 @@ public void testInvokeReadThroughAtomicNearCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughAtomicReplicated() throws Exception { invokeReadThrough(cacheConfiguration(REPLICATED, ATOMIC, 0, false)); } @@ -56,6 +75,7 @@ public void testInvokeReadThroughAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughAtomicLocal() throws Exception { invokeReadThrough(cacheConfiguration(LOCAL, ATOMIC, 0, false)); } @@ -63,6 +83,7 @@ public void testInvokeReadThroughAtomicLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughTx() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 1, false)); } @@ -70,6 +91,7 @@ public void testInvokeReadThroughTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughTxNearCache() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 1, true)); } @@ -77,6 +99,7 @@ public void testInvokeReadThroughTxNearCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughTxReplicated() throws Exception { invokeReadThrough(cacheConfiguration(REPLICATED, TRANSACTIONAL, 0, false)); } @@ -84,7 +107,44 @@ public void testInvokeReadThroughTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughTxLocal() throws Exception { invokeReadThrough(cacheConfiguration(LOCAL, TRANSACTIONAL, 0, false)); } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testInvokeReadThroughMvccTx() throws Exception { + invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, 1, false)); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testInvokeReadThroughMvccTxNearCache() throws Exception { + invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, 1, true)); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testInvokeReadThroughMvccTxReplicated() throws Exception { + invokeReadThrough(cacheConfiguration(REPLICATED, TRANSACTIONAL_SNAPSHOT, 0, false)); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testInvokeReadThroughMvccTxLocal() throws Exception { + invokeReadThrough(cacheConfiguration(LOCAL, TRANSACTIONAL_SNAPSHOT, 0, false)); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java index 8fd37588a43eb..cb14e18613ddb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java @@ -17,15 +17,31 @@ package org.apache.ignite.internal.processors.cache; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import org.apache.ignite.testframework.MvccFeatureChecker; + import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheInvokeReadThroughTest extends IgniteCacheInvokeReadThroughAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected void startNodes() throws Exception { startGridsMultiThreaded(4); @@ -38,6 +54,7 @@ public class IgniteCacheInvokeReadThroughTest extends IgniteCacheInvokeReadThrou /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughAtomic0() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 0, false)); } @@ -45,6 +62,7 @@ public void testInvokeReadThroughAtomic0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughAtomic1() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 1, false)); } @@ -52,6 +70,7 @@ public void testInvokeReadThroughAtomic1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughAtomic2() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 2, false)); } @@ -59,6 +78,7 @@ public void testInvokeReadThroughAtomic2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughAtomicNearCache() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, ATOMIC, 1, true)); } @@ -66,6 +86,7 @@ public void testInvokeReadThroughAtomicNearCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughAtomicReplicated() throws Exception { invokeReadThrough(cacheConfiguration(REPLICATED, ATOMIC, 0, false)); } @@ -73,6 +94,7 @@ public void testInvokeReadThroughAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughTx0() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 0, false)); } @@ -80,6 +102,7 @@ public void testInvokeReadThroughTx0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughTx1() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 1, false)); } @@ -87,6 +110,7 @@ public void testInvokeReadThroughTx1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughTx2() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 2, false)); } @@ -94,6 +118,7 @@ public void testInvokeReadThroughTx2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughTxNearCache() throws Exception { invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL, 1, true)); } @@ -101,7 +126,53 @@ public void testInvokeReadThroughTxNearCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeReadThroughTxReplicated() throws Exception { invokeReadThrough(cacheConfiguration(REPLICATED, TRANSACTIONAL, 0, false)); } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testInvokeReadThroughMvccTx0() throws Exception { + invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, 0, false)); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testInvokeReadThroughMvccTx1() throws Exception { + invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, 1, false)); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testInvokeReadThroughMvccTx2() throws Exception { + invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, 2, false)); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testInvokeReadThroughMvccTxNearCache() throws Exception { + invokeReadThrough(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, 1, true)); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582") + @Test + public void testInvokeReadThroughMvccTxReplicated() throws Exception { + invokeReadThrough(cacheConfiguration(REPLICATED, TRANSACTIONAL_SNAPSHOT, 0, false)); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLoadRebalanceEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLoadRebalanceEvictionSelfTest.java index d545d09747682..a56916da1f891 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLoadRebalanceEvictionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLoadRebalanceEvictionSelfTest.java @@ -40,23 +40,21 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheLoadRebalanceEvictionSelfTest extends GridCommonAbstractTest { /** */ public static final int LRU_MAX_SIZE = 10; - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int ENTRIES_CNT = 10000; @@ -64,12 +62,6 @@ public class IgniteCacheLoadRebalanceEvictionSelfTest extends GridCommonAbstract @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - LruEvictionPolicy evictionPolicy = new LruEvictionPolicy<>(); evictionPolicy.setMaxSize(LRU_MAX_SIZE); @@ -95,6 +87,7 @@ public class IgniteCacheLoadRebalanceEvictionSelfTest extends GridCommonAbstract /** * @throws Exception If failed. */ + @Test public void testStartRebalancing() throws Exception { List> futs = new ArrayList<>(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java index ca9d15b311e85..856bea9307cef 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.lang.IgniteFuture; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -36,6 +39,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheManyAsyncOperationsTest extends IgniteCacheAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -70,6 +74,7 @@ public class IgniteCacheManyAsyncOperationsTest extends IgniteCacheAbstractTest /** * @throws Exception If failed. */ + @Test public void testManyAsyncOperations() throws Exception { try (Ignite client = startGrid(gridCount())) { assertTrue(client.configuration().isClientMode()); @@ -108,4 +113,4 @@ public void testManyAsyncOperations() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCachePartitionedExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMvccTxInvokeTest.java similarity index 70% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCachePartitionedExecutionContextTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMvccTxInvokeTest.java index 36d2c2b7f3262..a2da68cc2d207 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCachePartitionedExecutionContextTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMvccTxInvokeTest.java @@ -15,30 +15,39 @@ * limitations under the License. */ -package org.apache.ignite.internal.processors.cache.context; +package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ -public class IgniteCachePartitionedExecutionContextTest extends IgniteCacheAbstractExecutionContextTest { +@RunWith(JUnit4.class) +public class IgniteCacheMvccTxInvokeTest extends IgniteCacheInvokeAbstractTest { + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 3; + } + /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { - return CacheMode.PARTITIONED; + return PARTITIONED; } /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { - return ATOMIC; + return TRANSACTIONAL_SNAPSHOT; } /** {@inheritDoc} */ @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMvccTxNearEnabledInvokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMvccTxNearEnabledInvokeTest.java new file mode 100644 index 0000000000000..fb3e280c5edbf --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMvccTxNearEnabledInvokeTest.java @@ -0,0 +1,32 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.junit.Ignore; + +/** + * + */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") +public class IgniteCacheMvccTxNearEnabledInvokeTest extends IgniteCacheMvccTxInvokeTest { + /** {@inheritDoc} */ + @Override protected NearCacheConfiguration nearConfiguration() { + return new NearCacheConfiguration(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNearLockValueSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNearLockValueSelfTest.java index 37fe5fa830ad5..8dc44638130f8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNearLockValueSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNearLockValueSelfTest.java @@ -28,10 +28,12 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockRequest; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -39,12 +41,12 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheNearLockValueSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + startGrid(1); startGrid(0); @@ -54,7 +56,7 @@ public class IgniteCacheNearLockValueSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setForceServerMode(true).setIpFinder(IP_FINDER)); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); if (getTestIgniteInstanceName(0).equals(igniteInstanceName)) cfg.setClientMode(true); @@ -71,6 +73,7 @@ public class IgniteCacheNearLockValueSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDhtVersion() throws Exception { CacheConfiguration pCfg = new CacheConfiguration<>("partitioned"); @@ -114,4 +117,4 @@ public void testDhtVersion() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoSyncForGetTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoSyncForGetTest.java index b14fecc5d4a27..42fa66ab501fd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoSyncForGetTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoSyncForGetTest.java @@ -39,24 +39,23 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheNoSyncForGetTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static volatile CountDownLatch processorStartLatch; @@ -70,8 +69,6 @@ public class IgniteCacheNoSyncForGetTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -91,6 +88,7 @@ public class IgniteCacheNoSyncForGetTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAtomicGet() throws Exception { getTest(ATOMIC); } @@ -98,10 +96,19 @@ public void testAtomicGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxGet() throws Exception { getTest(TRANSACTIONAL); } + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTxGet() throws Exception { + getTest(TRANSACTIONAL_SNAPSHOT); + } + /** * @param atomicityMode Cache atomicity mode. * @throws Exception If failed. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheObjectPutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheObjectPutSelfTest.java index f924e83b92ce0..916d494449853 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheObjectPutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheObjectPutSelfTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheObjectPutSelfTest extends GridCommonAbstractTest { /** */ public static final String CACHE_NAME = "partitioned"; @@ -58,6 +62,7 @@ public class IgniteCacheObjectPutSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPrimitiveValues() throws Exception { IgniteEx ignite = grid(0); @@ -100,6 +105,7 @@ public void testPrimitiveValues() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClassValues() throws Exception { IgniteEx ignite = grid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java index 55ff31a62ed17..89f75a65b001f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks behavior on exception while unmarshalling key. */ +@RunWith(JUnit4.class) public class IgniteCacheP2pUnmarshallingErrorTest extends IgniteCacheAbstractTest { /** Allows to change behavior of readExternal method. */ protected static final AtomicInteger readCnt = new AtomicInteger(); @@ -152,6 +156,7 @@ protected void failGet(int k) { * * @throws Exception If failed. */ + @Test public void testResponseMessageOnUnmarshallingFailed() throws Exception { // GridNearAtomicFullUpdateRequest unmarshalling failed test. readCnt.set(1); @@ -281,4 +286,4 @@ public TestValue() { throw new IOException("Class can not be unmarshalled."); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingNearErrorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingNearErrorTest.java index 546ec06f5cf24..5dca856e5accf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingNearErrorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingNearErrorTest.java @@ -20,10 +20,14 @@ import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks behavior on exception while unmarshalling key. */ +@RunWith(JUnit4.class) public class IgniteCacheP2pUnmarshallingNearErrorTest extends IgniteCacheP2pUnmarshallingErrorTest { /** {@inheritDoc} */ @Override protected NearCacheConfiguration nearConfiguration() { @@ -43,6 +47,7 @@ public class IgniteCacheP2pUnmarshallingNearErrorTest extends IgniteCacheP2pUnma } /** {@inheritDoc} */ + @Test @Override public void testResponseMessageOnUnmarshallingFailed() throws InterruptedException { //GridCacheEvictionRequest unmarshalling failed test. readCnt.set(5); //2 for each put. @@ -55,4 +60,4 @@ public class IgniteCacheP2pUnmarshallingNearErrorTest extends IgniteCacheP2pUnma // Wait for eviction complete. Thread.sleep(1000); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingRebalanceErrorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingRebalanceErrorTest.java index 28fc31c003af7..1183d6a17300b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingRebalanceErrorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingRebalanceErrorTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks behavior on exception while unmarshalling key. */ +@RunWith(JUnit4.class) public class IgniteCacheP2pUnmarshallingRebalanceErrorTest extends IgniteCacheP2pUnmarshallingErrorTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -35,6 +39,7 @@ public class IgniteCacheP2pUnmarshallingRebalanceErrorTest extends IgniteCacheP2 } /** {@inheritDoc} */ + @Test @Override public void testResponseMessageOnUnmarshallingFailed() throws Exception { //GridDhtPartitionSupplyMessage unmarshalling failed test. readCnt.set(Integer.MAX_VALUE); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingTxErrorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingTxErrorTest.java index ba77c701dd54e..9fb14d2eafa98 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingTxErrorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingTxErrorTest.java @@ -24,6 +24,9 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -32,6 +35,7 @@ /** * Checks behavior on exception while unmarshalling key. */ +@RunWith(JUnit4.class) public class IgniteCacheP2pUnmarshallingTxErrorTest extends IgniteCacheP2pUnmarshallingErrorTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { @@ -77,6 +81,7 @@ private void failPessimictic() { } /** {@inheritDoc} */ + @Test @Override public void testResponseMessageOnUnmarshallingFailed() { //GridNearTxPrepareRequest unmarshalling failed test readCnt.set(2); @@ -100,4 +105,4 @@ private void failPessimictic() { jcache(0).put(new TestKey(String.valueOf(++key)), ""); //No failure at client side. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionMapUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionMapUpdateTest.java index 87549cf4d4865..7e0694a7223f6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionMapUpdateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionMapUpdateTest.java @@ -28,20 +28,18 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public class IgniteCachePartitionMapUpdateTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE1_ATTR = "cache1"; @@ -67,8 +65,6 @@ public class IgniteCachePartitionMapUpdateTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration ccfg1 = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg1.setName(CACHE1); @@ -115,6 +111,7 @@ public class IgniteCachePartitionMapUpdateTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPartitionMapUpdate1() throws Exception { cache1 = false; cache2 = false; @@ -156,6 +153,7 @@ public void testPartitionMapUpdate1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionMapUpdate2() throws Exception { startClientCache = true; @@ -165,6 +163,7 @@ public void testPartitionMapUpdate2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandom() throws Exception { ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -202,6 +201,7 @@ public void testRandom() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandom2() throws Exception { startClientCache = true; @@ -227,4 +227,4 @@ public AttributeFilter(String attrName) { return F.eq(node.attribute(attrName), "true"); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java index ae1cf8851b34f..a813422ba0e58 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java @@ -42,6 +42,9 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.spi.IgniteSpiCloseableIterator; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -62,6 +65,7 @@ *
  • {@link IgniteCache#localEntries(CachePeekMode...)}
  • * */ +@RunWith(JUnit4.class) public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstractTest { /** */ private static final int HEAP_ENTRIES = 30; @@ -106,6 +110,7 @@ protected boolean hasNearCache() { /** * @throws Exception If failed. */ + @Test public void testLocalPeek() throws Exception { if (cacheMode() == LOCAL) { checkAffinityLocalCache(); @@ -371,6 +376,7 @@ private void checkStorage(int nodeIdx) throws Exception { /** * @throws Exception If failed. */ + @Test public void testSize() throws Exception { checkEmpty(); @@ -479,6 +485,7 @@ public void testSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalPartitionSize() throws Exception { if (cacheMode() != LOCAL) return; @@ -534,6 +541,7 @@ public void testLocalPartitionSize() throws Exception { /** * @throws InterruptedException If failed. */ + @Test public void testLocalPartitionSizeFlags() throws InterruptedException { if (true) // TODO GG-11148. return; @@ -595,6 +603,7 @@ public void testLocalPartitionSizeFlags() throws InterruptedException { /** * @throws Exception If failed. */ + @Test public void testNonLocalPartitionSize() throws Exception { if (true) // TODO GG-11148. return; @@ -1280,6 +1289,7 @@ private void checkPrimarySize(int exp) { /** * @throws Exception If failed. */ + @Test public void testLocalEntries() throws Exception { if (cacheMode() == LOCAL) { IgniteCache cache0 = jcache(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java index c90030e87f2cf..1217974af05eb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java @@ -32,11 +32,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -44,13 +44,11 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCachePutAllRestartTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "partitioned"; - /** IP finder. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 4; @@ -62,8 +60,6 @@ public class IgniteCachePutAllRestartTest extends GridCommonAbstractTest { ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(CACHE_NAME); @@ -104,6 +100,7 @@ public class IgniteCachePutAllRestartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStopNode() throws Exception { startGrids(NODES); @@ -165,6 +162,7 @@ public void testStopNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopOriginatingNode() throws Exception { startGrids(NODES); @@ -222,4 +220,4 @@ public void testStopOriginatingNode() throws Exception { startGrid(node); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutStackOverflowSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutStackOverflowSelfTest.java index 86f34feb5e3da..568246fcf7f52 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutStackOverflowSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutStackOverflowSelfTest.java @@ -21,13 +21,12 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -36,23 +35,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCachePutStackOverflowSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrid(0); @@ -61,6 +45,7 @@ public class IgniteCachePutStackOverflowSelfTest extends GridCommonAbstractTest /** * @throws Exception if failed. */ + @Test public void testStackLocal() throws Exception { checkCache(CacheMode.LOCAL); } @@ -68,6 +53,7 @@ public void testStackLocal() throws Exception { /** * @throws Exception if failed. */ + @Test public void testStackPartitioned() throws Exception { checkCache(CacheMode.PARTITIONED); } @@ -75,6 +61,7 @@ public void testStackPartitioned() throws Exception { /** * @throws Exception if failed. */ + @Test public void testStackReplicated() throws Exception { checkCache(CacheMode.REPLICATED); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionSelfTest.java index 00431b195a021..0135732d96cfe 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionSelfTest.java @@ -28,6 +28,7 @@ import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.IgniteCacheConfigVariationsAbstractTest; import javax.cache.configuration.Factory; @@ -36,11 +37,15 @@ import javax.cache.expiry.Duration; import javax.cache.expiry.ExpiryPolicy; import java.util.concurrent.TimeUnit; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheReadThroughEvictionSelfTest extends IgniteCacheConfigVariationsAbstractTest { /** */ private static final int TIMEOUT = 400; @@ -48,6 +53,13 @@ public class IgniteCacheReadThroughEvictionSelfTest extends IgniteCacheConfigVar /** */ private static final int KEYS = 100; + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { storeStgy.resetStore(); @@ -56,7 +68,10 @@ public class IgniteCacheReadThroughEvictionSelfTest extends IgniteCacheConfigVar /** * @throws Exception if failed. */ + @Test public void testReadThroughWithExpirePolicy() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + Ignite ig = testedGrid(); CacheConfiguration cc = variationConfig("expire"); @@ -96,7 +111,10 @@ public void testReadThroughWithExpirePolicy() throws Exception { /** * @throws Exception if failed. */ + @Test public void testReadThroughExpirePolicyConfigured() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + Ignite ig = testedGrid(); CacheConfiguration cc = variationConfig("expireConfig"); @@ -149,7 +167,10 @@ public void testReadThroughExpirePolicyConfigured() throws Exception { /** * @throws Exception if failed. */ + @Test public void testReadThroughEvictionPolicy() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + Ignite ig = testedGrid(); CacheConfiguration cc = variationConfig("eviction"); @@ -185,6 +206,7 @@ public void testReadThroughEvictionPolicy() throws Exception { /** * @throws Exception if failed. */ + @Test public void testReadThroughSkipStore() throws Exception { Ignite ig = testedGrid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionsVariationsSuite.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionsVariationsSuite.java index 400b2e95eee65..e17c60e384784 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionsVariationsSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionsVariationsSuite.java @@ -22,16 +22,18 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgniteCacheReadThroughEvictionsVariationsSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheReadThroughEvictionsVariationsSuite { /** * @return Cache API test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return new ConfigVariationsTestSuiteBuilder( "Cache Read Through Variations Test", IgniteCacheReadThroughEvictionSelfTest.class) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughStoreCallTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughStoreCallTest.java index 423c4a156575e..96fdad68b18bd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughStoreCallTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughStoreCallTest.java @@ -36,14 +36,15 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -54,22 +55,25 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheReadThroughStoreCallTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final Map storeMap = new ConcurrentHashMap<>(); /** */ protected boolean client; + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -87,6 +91,7 @@ public class IgniteCacheReadThroughStoreCallTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testMultiNode() throws Exception { startGridsMultiThreaded(4); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheScanPredicateDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheScanPredicateDeploymentSelfTest.java index 37f08797ed8f8..0b37291ab2fee 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheScanPredicateDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheScanPredicateDeploymentSelfTest.java @@ -24,10 +24,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgniteBiPredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,10 +37,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheScanPredicateDeploymentSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Test value. */ protected static final String TEST_PREDICATE = "org.apache.ignite.tests.p2p.CacheDeploymentAlwaysTruePredicate"; @@ -53,12 +51,6 @@ public class IgniteCacheScanPredicateDeploymentSelfTest extends GridCommonAbstra cfg.setCacheConfiguration(cacheConfiguration()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setConnectorConfiguration(null); return cfg; @@ -87,6 +79,7 @@ protected CacheAtomicityMode atomicityMode() { /** * @throws Exception In case of error. */ + @Test public void testDeployScanPredicate() throws Exception { startGrids(4); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSerializationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSerializationSelfTest.java index 436c1982ff43d..da800a64f4fe3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSerializationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSerializationSelfTest.java @@ -24,10 +24,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgniteCallable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -35,10 +35,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheSerializationSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 3; @@ -49,8 +47,6 @@ public class IgniteCacheSerializationSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (getTestIgniteInstanceName(CLIENT).equals(igniteInstanceName)) cfg.setClientMode(true); @@ -83,6 +79,7 @@ private CacheConfiguration cacheConfiguration(CacheMode cacheM /** * @throws Exception If failed. */ + @Test public void testSerializeClosure() throws Exception { Ignite client = ignite(CLIENT); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartStopLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartStopLoadTest.java index daa5d8337b842..15467ee4eadf7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartStopLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartStopLoadTest.java @@ -27,11 +27,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for dynamic cache start. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheStartStopLoadTest extends GridCommonAbstractTest { /** */ private static final long DURATION = 20_000L; @@ -76,6 +80,7 @@ public int nodeCount() { /** * @throws Exception If failed. */ + @Test public void testMemoryLeaks() throws Exception { final Ignite ignite = ignite(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java index c889c31ac7b4a..b95698e292cd4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java @@ -24,19 +24,17 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheStartTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE_NAME = "c1"; @@ -50,8 +48,6 @@ public class IgniteCacheStartTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); if (ccfg != null) @@ -71,6 +67,7 @@ public class IgniteCacheStartTest extends GridCommonAbstractTest { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testStartAndNodeJoin() throws Exception { Ignite node0 = startGrid(0); @@ -103,6 +100,7 @@ public void testStartAndNodeJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartFromJoiningNode1() throws Exception { checkStartFromJoiningNode(false); } @@ -110,6 +108,7 @@ public void testStartFromJoiningNode1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartFromJoiningNode2() throws Exception { checkStartFromJoiningNode(true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreCollectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreCollectionTest.java index 13841e3f3556d..f9442e2b3d942 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreCollectionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreCollectionTest.java @@ -25,41 +25,47 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheStoreCollectionTest extends GridCommonAbstractTest { /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + private static final String CACHE1 = "cache1"; + + /** */ + private static final String CACHE2 = "cache2"; + + /** */ + private static final String CACHE3 = "cache3"; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - CacheConfiguration ccfg1 = new CacheConfiguration<>(DEFAULT_CACHE_NAME); - ccfg1.setName("cache1"); + CacheConfiguration ccfg1 = new CacheConfiguration<>(CACHE1); ccfg1.setAtomicityMode(ATOMIC); ccfg1.setWriteSynchronizationMode(FULL_SYNC); - CacheConfiguration ccfg2 = new CacheConfiguration<>(DEFAULT_CACHE_NAME); - ccfg2.setName("cache2"); + CacheConfiguration ccfg2 = new CacheConfiguration<>(CACHE2); ccfg2.setAtomicityMode(TRANSACTIONAL); ccfg2.setWriteSynchronizationMode(FULL_SYNC); - cfg.setCacheConfiguration(ccfg1, ccfg2); + CacheConfiguration ccfg3 = new CacheConfiguration<>(CACHE3); + ccfg3.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + ccfg3.setWriteSynchronizationMode(FULL_SYNC); - cfg.setMarshaller(null); + cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg3); return cfg; } @@ -74,12 +80,15 @@ public class IgniteCacheStoreCollectionTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStoreMap() throws Exception { - IgniteCache cache1 = ignite(0).cache("cache1"); - IgniteCache cache2 = ignite(0).cache("cache2"); + IgniteCache cache1 = ignite(0).cache(CACHE1); + IgniteCache cache2 = ignite(0).cache(CACHE2); + IgniteCache cache3 = ignite(0).cache(CACHE3); checkStoreMap(cache1); checkStoreMap(cache2); + checkStoreMap(cache3); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java index bd259a5aa88ea..f4ffb1249f391 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java @@ -45,12 +45,16 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstractTest { /** */ private boolean cpyOnRead; @@ -125,6 +129,7 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr /** * @throws Exception If failed. */ + @Test public void testValueNotStored() throws Exception { cpyOnRead = true; @@ -296,6 +301,7 @@ private void checkNoValue(Affinity aff, Object key) { /** * @throws Exception If failed. */ + @Test public void testValueStored() throws Exception { cpyOnRead = false; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTransactionalStopBusySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTransactionalStopBusySelfTest.java index 06e60454dc837..2ee30b145a0f5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTransactionalStopBusySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTransactionalStopBusySelfTest.java @@ -18,12 +18,17 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Stopped node when client operations are executing. */ +@RunWith(JUnit4.class) public class IgniteCacheTransactionalStopBusySelfTest extends IgniteCacheAbstractStopBusySelfTest { /** {@inheritDoc} */ + @Test @Override public void testPut() throws Exception { bannedMsg.set(GridNearTxPrepareRequest.class); @@ -31,6 +36,7 @@ public class IgniteCacheTransactionalStopBusySelfTest extends IgniteCacheAbstrac } /** {@inheritDoc} */ + @Test @Override public void testPutBatch() throws Exception { bannedMsg.set(GridNearTxPrepareRequest.class); @@ -38,6 +44,7 @@ public class IgniteCacheTransactionalStopBusySelfTest extends IgniteCacheAbstrac } /** {@inheritDoc} */ + @Test @Override public void testPutAsync() throws Exception { bannedMsg.set(GridNearTxPrepareRequest.class); @@ -45,9 +52,10 @@ public class IgniteCacheTransactionalStopBusySelfTest extends IgniteCacheAbstrac } /** {@inheritDoc} */ + @Test @Override public void testRemove() throws Exception { bannedMsg.set(GridNearTxPrepareRequest.class); super.testPut(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxCopyOnReadDisabledTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxCopyOnReadDisabledTest.java index 2909f0a296cf8..1b44df8678ee7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxCopyOnReadDisabledTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxCopyOnReadDisabledTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -25,8 +26,14 @@ * */ public class IgniteCacheTxCopyOnReadDisabledTest extends IgniteCacheCopyOnReadDisabledAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalInvokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalInvokeTest.java index 55cc431dde553..107ad7dae88e0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalInvokeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalInvokeTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxLocalInvokeTest extends IgniteCacheInvokeAbstractTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java index 3439590040fcf..ccc2950d57eec 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -27,6 +28,13 @@ * */ public class IgniteCacheTxLocalPeekModesTest extends IgniteCachePeekModesAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; @@ -41,4 +49,4 @@ public class IgniteCacheTxLocalPeekModesTest extends IgniteCachePeekModesAbstrac @Override protected CacheMode cacheMode() { return LOCAL; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalStoreValueTest.java index b3987265c1da4..9a0385fea1348 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalStoreValueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalStoreValueTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxLocalStoreValueTest extends IgniteCacheStoreValueAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; @@ -47,4 +55,4 @@ public class IgniteCacheTxLocalStoreValueTest extends IgniteCacheStoreValueAbstr @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearEnabledStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearEnabledStoreValueTest.java index fc719fa9862c2..d3f0618b64ca9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearEnabledStoreValueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearEnabledStoreValueTest.java @@ -18,13 +18,21 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * */ public class IgniteCacheTxNearEnabledStoreValueTest extends IgniteCacheTxStoreValueTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected NearCacheConfiguration nearConfiguration() { return new NearCacheConfiguration(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearPeekModesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearPeekModesTest.java index aa4faaf6049ea..193e6ee37dac1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearPeekModesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearPeekModesTest.java @@ -17,16 +17,31 @@ package org.apache.ignite.internal.processors.cache; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import org.apache.ignite.testframework.MvccFeatureChecker; + /** * Tests peek modes with near tx cache. */ +@RunWith(JUnit4.class) public class IgniteCacheTxNearPeekModesTest extends IgniteCacheTxPeekModesTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected boolean hasNearCache() { return true; } /** {@inheritDoc} */ + @Test @Override public void testLocalPeek() throws Exception { // TODO: uncomment and re-open ticket if fails. // fail("https://issues.apache.org/jira/browse/IGNITE-1824"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java index ea22f53b0b5bc..9ce23b49bc0a9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java @@ -19,6 +19,8 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -26,6 +28,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheTxPeekModesTest extends IgniteCachePeekModesAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -41,12 +44,4 @@ public class IgniteCacheTxPeekModesTest extends IgniteCachePeekModesAbstractTest @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; } - - /** {@inheritDoc} */ - @Override public void testLocalPeek() throws Exception { - // TODO: uncomment and re-open ticket if fails. -// fail("https://issues.apache.org/jira/browse/IGNITE-1824"); - - super.testLocalPeek(); - } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPreloadNoWriteTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPreloadNoWriteTest.java index ebd0a96c8980e..641e3acfbd613 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPreloadNoWriteTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPreloadNoWriteTest.java @@ -25,11 +25,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -41,22 +41,14 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheTxPreloadNoWriteTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(REPLICATED); @@ -80,6 +72,7 @@ public class IgniteCacheTxPreloadNoWriteTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTxNoWrite() throws Exception { txNoWrite(true); } @@ -87,6 +80,7 @@ public void testTxNoWrite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxNoWriteRollback() throws Exception { txNoWrite(false); } @@ -129,4 +123,4 @@ private void txNoWrite(boolean commit) throws Exception { // Try to start one more node. startGrid(2); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxStoreValueTest.java index f3f52ebdf196d..eb5edd0baab6e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxStoreValueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxStoreValueTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxStoreValueTest extends IgniteCacheStoreValueAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.INTERCEPTOR); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 4; @@ -47,4 +55,4 @@ public class IgniteCacheTxStoreValueTest extends IgniteCacheStoreValueAbstractTe @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java index 37dda12853077..67f16b0d8d2da 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachingProviderSelfTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCachingProviderSelfTest extends IgniteCacheAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -90,6 +94,7 @@ public class IgniteCachingProviderSelfTest extends IgniteCacheAbstractTest { /** * */ + @Test public void testStartIgnite() { javax.cache.spi.CachingProvider cachingProvider = Caching.getCachingProvider(); @@ -118,6 +123,7 @@ public void testStartIgnite() { /** * @throws Exception If failed. */ + @Test public void testCloseManager() throws Exception { startGridsMultiThreaded(1); @@ -131,4 +137,4 @@ public void testCloseManager() throws Exception { assertNotSame(cacheMgr, cachingProvider.getCacheManager()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientAffinityAssignmentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientAffinityAssignmentSelfTest.java index 0a7a680f81d21..34b0e5d9309d1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientAffinityAssignmentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientAffinityAssignmentSelfTest.java @@ -28,19 +28,17 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.lang.GridAbsPredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests affinity assignment for different affinity types. */ +@RunWith(JUnit4.class) public class IgniteClientAffinityAssignmentSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ public static final int PARTS = 256; @@ -51,8 +49,6 @@ public class IgniteClientAffinityAssignmentSelfTest extends GridCommonAbstractTe @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (cache) { CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -75,6 +71,7 @@ public class IgniteClientAffinityAssignmentSelfTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testRendezvousAssignment() throws Exception { checkAffinityFunction(); } @@ -200,4 +197,4 @@ private void awaitTopology(final long topVer) throws Exception { assertEquals(topVer, cache.context().affinity().affinityTopologyVersion().topologyVersion()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java index b1df28e37f86b..564119390137b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java @@ -41,6 +41,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker; @@ -65,11 +66,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test checks whether cache initialization error on client side * doesn't causes hangs and doesn't impact other caches. */ +@RunWith(JUnit4.class) public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractTest { /** Failed cache name. */ private static final String CACHE_NAME = "cache"; @@ -80,12 +86,18 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT /** Tx cache name. */ private static final String TX_CACHE_NAME = "tx-cache"; + /** Mvcc tx cache name. */ + private static final String MVCC_TX_CACHE_NAME = "mvcc-tx-cache"; + /** Near atomic cache name. */ private static final String NEAR_ATOMIC_CACHE_NAME = "near-atomic-cache"; /** Near tx cache name. */ private static final String NEAR_TX_CACHE_NAME = "near-tx-cache"; + /** Near mvcc tx cache name. */ + private static final String NEAR_MVCC_TX_CACHE_NAME = "near-mvcc-tx-cache"; + /** Failed caches. */ private static final Set FAILED_CACHES; @@ -96,6 +108,8 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT set.add(TX_CACHE_NAME); set.add(NEAR_ATOMIC_CACHE_NAME); set.add(NEAR_TX_CACHE_NAME); + set.add(MVCC_TX_CACHE_NAME); + set.add(NEAR_MVCC_TX_CACHE_NAME); FAILED_CACHES = Collections.unmodifiableSet(set); } @@ -123,7 +137,13 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT ccfg2.setName(TX_CACHE_NAME); ccfg2.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); - cfg.setCacheConfiguration(ccfg1, ccfg2); + CacheConfiguration ccfg3 = new CacheConfiguration<>(); + + ccfg3.setIndexedTypes(Integer.class, String.class); + ccfg3.setName(MVCC_TX_CACHE_NAME); + ccfg3.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + + cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg3); } else { GridQueryProcessor.idxCls = FailedIndexing.class; @@ -137,6 +157,7 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testAtomicCacheInitialization() throws Exception { checkCacheInitialization(ATOMIC_CACHE_NAME); } @@ -144,6 +165,7 @@ public void testAtomicCacheInitialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransactionalCacheInitialization() throws Exception { checkCacheInitialization(TX_CACHE_NAME); } @@ -151,6 +173,15 @@ public void testTransactionalCacheInitialization() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testMvccTransactionalCacheInitialization() throws Exception { + checkCacheInitialization(MVCC_TX_CACHE_NAME); + } + + /** + * @throws Exception If failed. + */ + @Test public void testAtomicNearCacheInitialization() throws Exception { checkCacheInitialization(NEAR_ATOMIC_CACHE_NAME); } @@ -158,10 +189,20 @@ public void testAtomicNearCacheInitialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransactionalNearCacheInitialization() throws Exception { checkCacheInitialization(NEAR_TX_CACHE_NAME); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testMvccTransactionalNearCacheInitialization() throws Exception { + checkCacheInitialization(NEAR_MVCC_TX_CACHE_NAME); + } + /** * @param cacheName Cache name. * @throws Exception If failed. @@ -200,12 +241,15 @@ private void checkFailedCache(final Ignite client, final String cacheName) { IgniteCache cache; // Start cache with near enabled. - if (NEAR_ATOMIC_CACHE_NAME.equals(cacheName) || NEAR_TX_CACHE_NAME.equals(cacheName)) { + if (NEAR_ATOMIC_CACHE_NAME.equals(cacheName) || NEAR_TX_CACHE_NAME.equals(cacheName) || + NEAR_MVCC_TX_CACHE_NAME.equals(cacheName)) { CacheConfiguration ccfg = new CacheConfiguration(cacheName) .setNearConfiguration(new NearCacheConfiguration()); if (NEAR_TX_CACHE_NAME.equals(cacheName)) ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + else if (NEAR_MVCC_TX_CACHE_NAME.equals(cacheName)) + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); cache = client.getOrCreateCache(ccfg); } @@ -345,13 +389,8 @@ private static class FailedIndexing implements GridQueryIndexing { } /** {@inheritDoc} */ - @Override public void rebuildIndexesFromHash(String cacheName) throws IgniteCheckedException { - // No-op - } - - /** {@inheritDoc} */ - @Override public void markForRebuildFromHash(String cacheName) { - // No-op + @Override public IgniteInternalFuture rebuildIndexesFromHash(GridCacheContext cctx) { + return null; } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheStartFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheStartFailoverTest.java index a2d9da719ce98..8fb9795e16be2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheStartFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheStartFailoverTest.java @@ -41,30 +41,29 @@ import org.apache.ignite.internal.TestRecordingCommunicationSpi; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class IgniteClientCacheStartFailoverTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -72,8 +71,6 @@ public class IgniteClientCacheStartFailoverTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); @@ -81,6 +78,13 @@ public class IgniteClientCacheStartFailoverTest extends GridCommonAbstractTest { return cfg; } + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + client = false; + } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -91,6 +95,7 @@ public class IgniteClientCacheStartFailoverTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testClientStartCoordinatorFailsAtomic() throws Exception { clientStartCoordinatorFails(ATOMIC); } @@ -98,10 +103,19 @@ public void testClientStartCoordinatorFailsAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientStartCoordinatorFailsTx() throws Exception { clientStartCoordinatorFails(TRANSACTIONAL); } + /** + * @throws Exception If failed. + */ + @Test + public void testClientStartCoordinatorFailsMvccTx() throws Exception { + clientStartCoordinatorFails(TRANSACTIONAL_SNAPSHOT); + } + /** * @param atomicityMode Cache atomicity mode. * @throws Exception If failed. @@ -152,6 +166,7 @@ private void clientStartCoordinatorFails(CacheAtomicityMode atomicityMode) throw /** * @throws Exception If failed. */ + @Test public void testClientStartLastServerFailsAtomic() throws Exception { clientStartLastServerFails(ATOMIC); } @@ -159,10 +174,20 @@ public void testClientStartLastServerFailsAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientStartLastServerFailsTx() throws Exception { clientStartLastServerFails(TRANSACTIONAL); } + /** + * @throws Exception If failed. + */ + @Test + public void testClientStartLastServerFailsMvccTx() throws Exception { + clientStartLastServerFails(TRANSACTIONAL_SNAPSHOT); + } + + /** * @param atomicityMode Cache atomicity mode. * @throws Exception If failed. @@ -248,6 +273,7 @@ private void clientStartLastServerFails(CacheAtomicityMode atomicityMode) throws /** * @throws Exception If failed. */ + @Test public void testRebalanceState() throws Exception { final int SRVS = 3; @@ -319,6 +345,7 @@ public void testRebalanceState() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalanceStateConcurrentStart() throws Exception { final int SRVS1 = 3; final int CLIENTS = 5; @@ -413,6 +440,7 @@ public void testRebalanceStateConcurrentStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientStartCloseServersRestart() throws Exception { final int SRVS = 4; final int CLIENTS = 4; @@ -547,6 +575,18 @@ private List startCaches(Ignite node, int keys) { cache.putAll(map); } + //TODO: uncomment TRANSACTIONAL_SNAPSHOT cache creation when IGNITE-9470 will be fixed. + /* for (int i = 0; i < 3; i++) { + CacheConfiguration ccfg = cacheConfiguration("mvcc-" + i, TRANSACTIONAL_SNAPSHOT, i); + + IgniteCache cache = node.createCache(ccfg); + + cacheNames.add(ccfg.getName()); + + cache.putAll(map); + }*/ + + return cacheNames; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java index 9e2286e43fe8c..b7ed96ff11628 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java @@ -50,11 +50,14 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -63,10 +66,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteClusterActivateDeactivateTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ static final String CACHE_NAME_PREFIX = "cache-"; @@ -106,7 +107,7 @@ public class IgniteClusterActivateDeactivateTest extends GridCommonAbstractTest spi.setJoinTimeout(2 * 60_000); } - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(sharedStaticIpFinder); cfg.setConsistentId(igniteInstanceName); @@ -168,6 +169,7 @@ protected boolean persistenceEnabled() { /** * @throws Exception If failed. */ + @Test public void testActivateSimple_SingleNode() throws Exception { activateSimple(1, 0, 0); } @@ -175,6 +177,7 @@ public void testActivateSimple_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivateSimple_5_Servers() throws Exception { activateSimple(5, 0, 0); } @@ -182,6 +185,7 @@ public void testActivateSimple_5_Servers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivateSimple_5_Servers2() throws Exception { activateSimple(5, 0, 4); } @@ -189,6 +193,7 @@ public void testActivateSimple_5_Servers2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivateSimple_5_Servers_5_Clients() throws Exception { activateSimple(5, 4, 0); } @@ -196,6 +201,7 @@ public void testActivateSimple_5_Servers_5_Clients() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivateSimple_5_Servers_5_Clients_FromClient() throws Exception { activateSimple(5, 4, 6); } @@ -262,6 +268,7 @@ private void activateSimple(int srvs, int clients, int activateFrom) throws Exce /** * @throws Exception If failed. */ + @Test public void testReActivateSimple_5_Servers_4_Clients_FromClient() throws Exception { reactivateSimple(5, 4, 6); } @@ -269,6 +276,7 @@ public void testReActivateSimple_5_Servers_4_Clients_FromClient() throws Excepti /** * @throws Exception If failed. */ + @Test public void testReActivateSimple_5_Servers_4_Clients_FromServer() throws Exception { reactivateSimple(5, 4, 0); } @@ -342,20 +350,29 @@ final void checkCaches(int nodes, int caches) { /** * @throws Exception If failed. */ + @Test public void testJoinWhileActivate1_Server() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + joinWhileActivate1(false, false); } /** * @throws Exception If failed. */ + @Test public void testJoinWhileActivate1_WithCache_Server() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + joinWhileActivate1(false, true); } /** * @throws Exception If failed. */ + @Test public void testJoinWhileActivate1_Client() throws Exception { joinWhileActivate1(true, false); } @@ -490,6 +507,7 @@ private void blockExchangeSingleMessage(TestRecordingCommunicationSpi spi, final /** * @throws Exception If failed. */ + @Test public void testJoinWhileDeactivate1_Server() throws Exception { joinWhileDeactivate1(false, false); } @@ -497,6 +515,7 @@ public void testJoinWhileDeactivate1_Server() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinWhileDeactivate1_WithCache_Server() throws Exception { joinWhileDeactivate1(false, true); } @@ -504,6 +523,7 @@ public void testJoinWhileDeactivate1_WithCache_Server() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinWhileDeactivate1_Client() throws Exception { joinWhileDeactivate1(true, false); } @@ -567,6 +587,7 @@ private void joinWhileDeactivate1(final boolean startClient, final boolean withN /** * @throws Exception If failed. */ + @Test public void testConcurrentJoinAndActivate() throws Exception { for (int iter = 0; iter < 3; iter++) { log.info("Iteration: " + iter); @@ -617,6 +638,7 @@ public void testConcurrentJoinAndActivate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeactivateSimple_SingleNode() throws Exception { deactivateSimple(1, 0, 0); } @@ -624,6 +646,7 @@ public void testDeactivateSimple_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeactivateSimple_5_Servers() throws Exception { deactivateSimple(5, 0, 0); } @@ -631,6 +654,7 @@ public void testDeactivateSimple_5_Servers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeactivateSimple_5_Servers2() throws Exception { deactivateSimple(5, 0, 4); } @@ -638,6 +662,7 @@ public void testDeactivateSimple_5_Servers2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeactivateSimple_5_Servers_5_Clients() throws Exception { deactivateSimple(5, 4, 0); } @@ -645,6 +670,7 @@ public void testDeactivateSimple_5_Servers_5_Clients() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeactivateSimple_5_Servers_5_Clients_FromClient() throws Exception { deactivateSimple(5, 4, 6); } @@ -734,6 +760,7 @@ private void startWithCaches1(int srvs, int clients) throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectClusterActive() throws Exception { testReconnectSpi = true; @@ -772,6 +799,7 @@ public void testClientReconnectClusterActive() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectClusterInactive() throws Exception { testReconnectSpi = true; @@ -811,6 +839,7 @@ public void testClientReconnectClusterInactive() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectClusterDeactivated() throws Exception { clientReconnectClusterDeactivated(false); } @@ -818,6 +847,7 @@ public void testClientReconnectClusterDeactivated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectClusterDeactivateInProgress() throws Exception { clientReconnectClusterDeactivated(true); } @@ -846,8 +876,7 @@ private void clientReconnectClusterDeactivated(final boolean transition) throws checkCaches1(SRVS + CLIENTS); // Wait for late affinity assignment to finish. - grid(0).context().cache().context().exchange().affinityReadyFuture( - new AffinityTopologyVersion(SRVS + CLIENTS, 1)).get(); + awaitPartitionMapExchange(); final AffinityTopologyVersion STATE_CHANGE_TOP_VER = new AffinityTopologyVersion(SRVS + CLIENTS + 1, 1); @@ -912,6 +941,7 @@ private void clientReconnectClusterDeactivated(final boolean transition) throws /** * @throws Exception If failed. */ + @Test public void testClientReconnectClusterActivated() throws Exception { clientReconnectClusterActivated(false); } @@ -919,6 +949,7 @@ public void testClientReconnectClusterActivated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectClusterActivateInProgress() throws Exception { clientReconnectClusterActivated(true); } @@ -999,6 +1030,7 @@ private void clientReconnectClusterActivated(final boolean transition) throws Ex /** * @throws Exception If failed. */ + @Test public void testInactiveTopologyChanges() throws Exception { testSpi = true; @@ -1055,6 +1087,7 @@ public void testInactiveTopologyChanges() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivateFailover1() throws Exception { stateChangeFailover1(true); } @@ -1062,6 +1095,7 @@ public void testActivateFailover1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeactivateFailover1() throws Exception { stateChangeFailover1(false); } @@ -1112,6 +1146,7 @@ private void stateChangeFailover1(boolean activate) throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivateFailover2() throws Exception { stateChangeFailover2(true); } @@ -1119,6 +1154,7 @@ public void testActivateFailover2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeactivateFailover2() throws Exception { stateChangeFailover2(false); } @@ -1180,6 +1216,8 @@ private void stateChangeFailover2(boolean activate) throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8220") + @Test public void testActivateFailover3() throws Exception { stateChangeFailover3(true); } @@ -1187,6 +1225,8 @@ public void testActivateFailover3() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8220") + @Test public void testDeactivateFailover3() throws Exception { stateChangeFailover3(false); } @@ -1196,21 +1236,19 @@ public void testDeactivateFailover3() throws Exception { * @throws Exception If failed. */ private void stateChangeFailover3(boolean activate) throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-8220"); - testReconnectSpi = true; startNodesAndBlockStatusChange(4, 0, 0, !activate); client = false; - IgniteInternalFuture startFut1 = GridTestUtils.runAsync((Callable)() -> { + IgniteInternalFuture startFut1 = GridTestUtils.runAsync(() -> { startGrid(4); return null; }, "start-node1"); - IgniteInternalFuture startFut2 = GridTestUtils.runAsync((Callable)() -> { + IgniteInternalFuture startFut2 = GridTestUtils.runAsync(() -> { startGrid(5); return null; @@ -1242,6 +1280,7 @@ private void stateChangeFailover3(boolean activate) throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterStateNotWaitForDeactivation() throws Exception { testSpi = true; @@ -1379,7 +1418,7 @@ final void checkNoCaches(int nodes) { GridCacheProcessor cache = ((IgniteEx)ignite(i)).context().cache(); assertTrue(cache.caches().isEmpty()); - assertTrue(cache.internalCaches().isEmpty()); + assertTrue(cache.internalCaches().stream().allMatch(c -> c.context().isRecoveryMode())); } } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistence.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistence.java index 0972ea2a8f6ab..70d0034131ceb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistence.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistence.java @@ -28,6 +28,7 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; @@ -40,11 +41,16 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteClusterActivateDeactivateTestWithPersistence extends IgniteClusterActivateDeactivateTest { /** {@inheritDoc} */ @Override protected boolean persistenceEnabled() { @@ -73,6 +79,7 @@ public class IgniteClusterActivateDeactivateTestWithPersistence extends IgniteCl /** * @throws Exception If failed. */ + @Test public void testActivateCachesRestore_SingleNode() throws Exception { activateCachesRestore(1, false); } @@ -80,6 +87,7 @@ public void testActivateCachesRestore_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivateCachesRestore_SingleNode_WithNewCaches() throws Exception { activateCachesRestore(1, true); } @@ -87,6 +95,7 @@ public void testActivateCachesRestore_SingleNode_WithNewCaches() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testActivateCachesRestore_5_Servers() throws Exception { activateCachesRestore(5, false); } @@ -94,10 +103,63 @@ public void testActivateCachesRestore_5_Servers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivateCachesRestore_5_Servers_WithNewCaches() throws Exception { activateCachesRestore(5, true); } + /** {@inheritDoc} */ + @Test + @Override public void testReActivateSimple_5_Servers_4_Clients_FromServer() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10750"); + + super.testReActivateSimple_5_Servers_4_Clients_FromServer(); + } + + /** + * Test deactivation on cluster that is not yet activated. + * + * @throws Exception If failed. + */ + @Test + public void testDeactivateInactiveCluster() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10582"); + + ccfgs = new CacheConfiguration[] { + new CacheConfiguration<>("test_cache_1") + .setGroupName("test_cache") + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL), + new CacheConfiguration<>("test_cache_2") + .setGroupName("test_cache") + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + }; + + Ignite ignite = startGrids(3); + + ignite.cluster().active(true); + + ignite.cache("test_cache_1") + .put("key1", "val1"); + ignite.cache("test_cache_2") + .put("key1", "val1"); + + ignite.cluster().active(false); + + assertFalse(ignite.cluster().active()); + + stopAllGrids(); + + ignite = startGrids(2); + + assertFalse(ignite.cluster().active()); + + ignite.cluster().active(false); + + assertFalse(ignite.cluster().active()); + } + /** */ private Map startGridsAndLoadData(int srvs) throws Exception { Ignite srv = startGrids(srvs); @@ -188,6 +250,7 @@ private void activateCachesRestore(int srvs, boolean withNewCaches) throws Excep /** * @see IGNITE-7330 for more information about context of the test */ + @Test public void testClientJoinsWhenActivationIsInProgress() throws Exception { startGridsAndLoadData(5); @@ -246,6 +309,7 @@ private void checkCachesData(Map cacheData, DataStorageConfigu /** * @throws Exception If failed. */ + @Test public void testActivateCacheRestoreConfigurationConflict() throws Exception { final int SRVS = 3; @@ -253,13 +317,15 @@ public void testActivateCacheRestoreConfigurationConflict() throws Exception { srv.cluster().active(true); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); srv.createCache(ccfg); stopAllGrids(); - ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME + 1); + ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME + 1) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); ccfg.setGroupName(DEFAULT_CACHE_NAME); @@ -282,7 +348,11 @@ public void testActivateCacheRestoreConfigurationConflict() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeactivateDuringEvictionAndRebalance() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10786"); + IgniteEx srv = (IgniteEx) startGrids(3); srv.cluster().active(true); @@ -291,7 +361,8 @@ public void testDeactivateDuringEvictionAndRebalance() throws Exception { .setBackups(1) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) .setIndexedTypes(Integer.class, Integer.class) - .setAffinity(new RendezvousAffinityFunction(false, 64)); + .setAffinity(new RendezvousAffinityFunction(false, 64)) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); IgniteCache cache = srv.createCache(ccfg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistenceAndMemoryReuse.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistenceAndMemoryReuse.java index 48d17545aa766..c95fe3dc4a505 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistenceAndMemoryReuse.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistenceAndMemoryReuse.java @@ -18,6 +18,8 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; /** * @@ -37,4 +39,29 @@ public class IgniteClusterActivateDeactivateTestWithPersistenceAndMemoryReuse ex System.clearProperty(IgniteSystemProperties.IGNITE_REUSE_MEMORY_ON_DEACTIVATE); } + + /** {@inheritDoc} */ + @Test + @Override public void testDeactivateDuringEvictionAndRebalance() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10788"); + + super.testDeactivateDuringEvictionAndRebalance(); + } + + /** {@inheritDoc} */ + @Test + @Override public void testDeactivateInactiveCluster() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10788"); + + super.testDeactivateInactiveCluster(); + } + + @Override public void testReActivateSimple_5_Servers_4_Clients_FromServer() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10750"); + + super.testReActivateSimple_5_Servers_4_Clients_FromServer(); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDaemonNodeMarshallerCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDaemonNodeMarshallerCacheTest.java index 2f9bd533ae916..a985a460b2378 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDaemonNodeMarshallerCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDaemonNodeMarshallerCacheTest.java @@ -24,10 +24,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -36,10 +36,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteDaemonNodeMarshallerCacheTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean daemon; @@ -49,8 +47,6 @@ public class IgniteDaemonNodeMarshallerCacheTest extends GridCommonAbstractTest cfg.setDaemon(daemon); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - return cfg; } @@ -64,6 +60,7 @@ public class IgniteDaemonNodeMarshallerCacheTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testMarshalOnDaemonNode1() throws Exception { marshalOnDaemonNode(true); } @@ -71,6 +68,7 @@ public void testMarshalOnDaemonNode1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMarshalOnDaemonNode2() throws Exception { marshalOnDaemonNode(false); } @@ -191,4 +189,4 @@ public TestClass2(int val) { this.val = val; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheAndNodeStop.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheAndNodeStop.java index 50f45a7ed3f36..febfe61bb1073 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheAndNodeStop.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheAndNodeStop.java @@ -20,30 +20,19 @@ import org.apache.ignite.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.common.*; import java.util.concurrent.*; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteDynamicCacheAndNodeStop extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); @@ -54,6 +43,7 @@ public class IgniteDynamicCacheAndNodeStop extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCacheAndNodeStop() throws Exception { final Ignite ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheFilterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheFilterTest.java index 53c1cb29fe452..e0919763a4ab8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheFilterTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheFilterTest.java @@ -21,14 +21,15 @@ import java.util.Map; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -37,10 +38,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteDynamicCacheFilterTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String ATTR_NAME = "cacheAttr"; @@ -51,8 +50,6 @@ public class IgniteDynamicCacheFilterTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setWriteSynchronizationMode(FULL_SYNC); @@ -60,6 +57,7 @@ public class IgniteDynamicCacheFilterTest extends GridCommonAbstractTest { ccfg.setRebalanceMode(SYNC); ccfg.setNodeFilter(new TestNodeFilter("A")); + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); if (attrVal != null) { Map attrs = new HashMap<>(); @@ -84,6 +82,7 @@ public class IgniteDynamicCacheFilterTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCofiguredCacheFilter() throws Exception { attrVal = "A"; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheMultinodeTest.java index fb1643efeb526..b7865c126d659 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheMultinodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheMultinodeTest.java @@ -26,11 +26,11 @@ import org.apache.ignite.Ignite; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -38,10 +38,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteDynamicCacheMultinodeTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 6; @@ -52,8 +50,6 @@ public class IgniteDynamicCacheMultinodeTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -73,6 +69,7 @@ public class IgniteDynamicCacheMultinodeTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateCache() throws Exception { createCacheMultinode(TestOp.GET_OR_CREATE_CACHE); } @@ -80,6 +77,7 @@ public void testGetOrCreateCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateCaches() throws Exception { createCacheMultinode(TestOp.GET_OR_CREATE_CACHES); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartCoordinatorFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartCoordinatorFailoverTest.java index 36e1879a1c96b..f0cbd77c13478 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartCoordinatorFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartCoordinatorFailoverTest.java @@ -1,262 +1,258 @@ -/* - * 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. - */ - -package org.apache.ignite.internal.processors.cache; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import javax.cache.CacheException; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.IgniteException; -import org.apache.ignite.cache.affinity.AffinityFunctionContext; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.GridJobExecuteResponse; -import org.apache.ignite.internal.managers.communication.GridIoMessage; -import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.IgniteSpiException; -import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; -import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -public class IgniteDynamicCacheStartCoordinatorFailoverTest extends GridCommonAbstractTest { - /** Default IP finder for single-JVM cloud grid. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** Latch which blocks DynamicCacheChangeFailureMessage until main thread has sent node fail signal. */ - private static volatile CountDownLatch latch; - - /** */ - private static final String COORDINATOR_ATTRIBUTE = "coordinator"; - - /** Client mode flag. */ - private Boolean appendCustomAttribute; - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - latch = new CountDownLatch(1); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - - TcpCommunicationSpi commSpi = new CustomCommunicationSpi(); - commSpi.setLocalPort(GridTestUtils.getNextCommPort(getClass())); - - cfg.setCommunicationSpi(commSpi); - - cfg.setFailureDetectionTimeout(15_000); - - if (appendCustomAttribute) { - Map attrs = new HashMap<>(); - - attrs.put(COORDINATOR_ATTRIBUTE, Boolean.TRUE); - - cfg.setUserAttributes(attrs); - } - - return cfg; - } - - /** - * Tests coordinator failover during cache start failure. - * - * @throws Exception If test failed. - */ - public void testCoordinatorFailure() throws Exception { - // Start coordinator node. - appendCustomAttribute = true; - - Ignite g = startGrid(0); - - appendCustomAttribute = false; - - Ignite g1 = startGrid(1); - Ignite g2 = startGrid(2); - - awaitPartitionMapExchange(); - - CacheConfiguration cfg = new CacheConfiguration(); - - cfg.setName("test-coordinator-failover"); - - cfg.setAffinity(new BrokenAffinityFunction(false, getTestIgniteInstanceName(2))); - - GridTestUtils.runAsync(new Callable() { - @Override public Object call() throws Exception { - GridTestUtils.assertThrows(log, new Callable() { - @Override public Object call() throws Exception { - g1.getOrCreateCache(cfg); - return null; - } - }, CacheException.class, null); - - return null; - } - }, "cache-starter-thread"); - - latch.await(); - - stopGrid(0, true); - - awaitPartitionMapExchange(); - - // Correct the cache configuration. - cfg.setAffinity(new RendezvousAffinityFunction()); - - IgniteCache cache = g1.getOrCreateCache(cfg); - - checkCacheOperations(g1, cache); - } - - /** - * Test the basic cache operations. - * - * @param cache Cache. - * @throws Exception If test failed. - */ - protected void checkCacheOperations(Ignite ignite, IgniteCache cache) throws Exception { - int cnt = 1000; - - // Check base cache operations. - for (int i = 0; i < cnt; ++i) - cache.put(i, i); - - for (int i = 0; i < cnt; ++i) { - Integer v = (Integer) cache.get(i); - - assertNotNull(v); - assertEquals(i, v.intValue()); - } - - // Check Data Streamer capabilities. - try (IgniteDataStreamer streamer = ignite.dataStreamer(cache.getName())) { - for (int i = 0; i < 10_000; ++i) - streamer.addData(i, i); - } - } - - /** - * Communication SPI which could optionally block outgoing messages. - */ - private static class CustomCommunicationSpi extends TcpCommunicationSpi { - /** - * Send message optionally either blocking it or throwing an exception if it is of - * {@link GridJobExecuteResponse} type. - * - * @param node Destination node. - * @param msg Message to be sent. - * @param ackClosure Ack closure. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure ackClosure) - throws IgniteSpiException { - - if (msg instanceof GridIoMessage) { - GridIoMessage msg0 = (GridIoMessage)msg; - - if (msg0.message() instanceof GridDhtPartitionsSingleMessage) { - Boolean attr = (Boolean) node.attributes().get(COORDINATOR_ATTRIBUTE); - - GridDhtPartitionsSingleMessage singleMsg = (GridDhtPartitionsSingleMessage) msg0.message(); - - Exception err = singleMsg.getError(); - - if (Boolean.TRUE.equals(attr) && err != null) { - // skip message - latch.countDown(); - - return; - } - } - } - - super.sendMessage(node, msg, ackClosure); - } - } - - /** - * Affinity function that throws an exception when affinity nodes are calculated on the given node. - */ - public static class BrokenAffinityFunction extends RendezvousAffinityFunction { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - @IgniteInstanceResource - private Ignite ignite; - - /** Exception should arise on all nodes. */ - private boolean eOnAllNodes = false; - - /** Exception should arise on node with certain name. */ - private String gridName; - - /** - * Default constructor. - */ - public BrokenAffinityFunction() { - // No-op. - } - - /** - * @param eOnAllNodes {@code True} if exception should be thrown on all nodes. - * @param gridName Exception should arise on node with certain name. - */ - public BrokenAffinityFunction(boolean eOnAllNodes, String gridName) { - this.eOnAllNodes = eOnAllNodes; - this.gridName = gridName; - } - - /** {@inheritDoc} */ - @Override public List> assignPartitions(AffinityFunctionContext affCtx) { - if (eOnAllNodes || ignite.name().equals(gridName)) - throw new IllegalStateException("Simulated exception [locNodeId=" - + ignite.cluster().localNode().id() + "]"); - else - return super.assignPartitions(affCtx); - } - } -} +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.affinity.AffinityFunctionContext; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.GridJobExecuteResponse; +import org.apache.ignite.internal.managers.communication.GridIoMessage; +import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteInClosure; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.resources.IgniteInstanceResource; +import org.apache.ignite.spi.IgniteSpiException; +import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** */ +@RunWith(JUnit4.class) +public class IgniteDynamicCacheStartCoordinatorFailoverTest extends GridCommonAbstractTest { + /** Latch which blocks DynamicCacheChangeFailureMessage until main thread has sent node fail signal. */ + private static volatile CountDownLatch latch; + + /** */ + private static final String COORDINATOR_ATTRIBUTE = "coordinator"; + + /** Client mode flag. */ + private Boolean appendCustomAttribute; + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + latch = new CountDownLatch(1); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + TcpCommunicationSpi commSpi = new CustomCommunicationSpi(); + commSpi.setLocalPort(GridTestUtils.getNextCommPort(getClass())); + + cfg.setCommunicationSpi(commSpi); + + cfg.setFailureDetectionTimeout(15_000); + + if (appendCustomAttribute) { + Map attrs = new HashMap<>(); + + attrs.put(COORDINATOR_ATTRIBUTE, Boolean.TRUE); + + cfg.setUserAttributes(attrs); + } + + return cfg; + } + + /** + * Tests coordinator failover during cache start failure. + * + * @throws Exception If test failed. + */ + @Test + public void testCoordinatorFailure() throws Exception { + // Start coordinator node. + appendCustomAttribute = true; + + Ignite g = startGrid(0); + + appendCustomAttribute = false; + + Ignite g1 = startGrid(1); + Ignite g2 = startGrid(2); + + awaitPartitionMapExchange(); + + CacheConfiguration cfg = new CacheConfiguration(); + + cfg.setName("test-coordinator-failover"); + + cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + + cfg.setAffinity(new BrokenAffinityFunction(false, getTestIgniteInstanceName(2))); + + GridTestUtils.runAsync(new Callable() { + @Override public Object call() throws Exception { + GridTestUtils.assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + g1.getOrCreateCache(cfg); + return null; + } + }, CacheException.class, null); + + return null; + } + }, "cache-starter-thread"); + + latch.await(); + + stopGrid(0, true); + + awaitPartitionMapExchange(); + + // Correct the cache configuration. + cfg.setAffinity(new RendezvousAffinityFunction()); + + IgniteCache cache = g1.getOrCreateCache(cfg); + + checkCacheOperations(g1, cache); + } + + /** + * Test the basic cache operations. + * + * @param cache Cache. + * @throws Exception If test failed. + */ + protected void checkCacheOperations(Ignite ignite, IgniteCache cache) throws Exception { + int cnt = 1000; + + // Check base cache operations. + for (int i = 0; i < cnt; ++i) + cache.put(i, i); + + for (int i = 0; i < cnt; ++i) { + Integer v = (Integer) cache.get(i); + + assertNotNull(v); + assertEquals(i, v.intValue()); + } + + // Check Data Streamer capabilities. + try (IgniteDataStreamer streamer = ignite.dataStreamer(cache.getName())) { + for (int i = 0; i < 10_000; ++i) + streamer.addData(i, i); + } + } + + /** + * Communication SPI which could optionally block outgoing messages. + */ + private static class CustomCommunicationSpi extends TcpCommunicationSpi { + /** + * Send message optionally either blocking it or throwing an exception if it is of + * {@link GridJobExecuteResponse} type. + * + * @param node Destination node. + * @param msg Message to be sent. + * @param ackClosure Ack closure. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure ackClosure) + throws IgniteSpiException { + + if (msg instanceof GridIoMessage) { + GridIoMessage msg0 = (GridIoMessage)msg; + + if (msg0.message() instanceof GridDhtPartitionsSingleMessage) { + Boolean attr = (Boolean) node.attributes().get(COORDINATOR_ATTRIBUTE); + + GridDhtPartitionsSingleMessage singleMsg = (GridDhtPartitionsSingleMessage) msg0.message(); + + Exception err = singleMsg.getError(); + + if (Boolean.TRUE.equals(attr) && err != null) { + // skip message + latch.countDown(); + + return; + } + } + } + + super.sendMessage(node, msg, ackClosure); + } + } + + /** + * Affinity function that throws an exception when affinity nodes are calculated on the given node. + */ + public static class BrokenAffinityFunction extends RendezvousAffinityFunction { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + @IgniteInstanceResource + private Ignite ignite; + + /** Exception should arise on all nodes. */ + private boolean eOnAllNodes = false; + + /** Exception should arise on node with certain name. */ + private String gridName; + + /** + * Default constructor. + */ + public BrokenAffinityFunction() { + // No-op. + } + + /** + * @param eOnAllNodes {@code True} if exception should be thrown on all nodes. + * @param gridName Exception should arise on node with certain name. + */ + public BrokenAffinityFunction(boolean eOnAllNodes, String gridName) { + this.eOnAllNodes = eOnAllNodes; + this.gridName = gridName; + } + + /** {@inheritDoc} */ + @Override public List> assignPartitions(AffinityFunctionContext affCtx) { + if (eOnAllNodes || ignite.name().equals(gridName)) + throw new IllegalStateException("Simulated exception [locNodeId=" + + ignite.cluster().localNode().id() + "]"); + else + return super.assignPartitions(affCtx); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartFailWithPersistenceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartFailWithPersistenceTest.java index 24c9342be20ce..bc00d3416b2e4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartFailWithPersistenceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartFailWithPersistenceTest.java @@ -24,6 +24,8 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Assume; /** * Tests the recovery after a dynamic cache start failure, with enabled persistence. @@ -34,6 +36,7 @@ public class IgniteDynamicCacheStartFailWithPersistenceTest extends IgniteAbstra return 5 * 60 * 1000; } + /** {@inheritDoc} */ @Override protected boolean persistenceEnabled() { return true; } @@ -56,6 +59,8 @@ public class IgniteDynamicCacheStartFailWithPersistenceTest extends IgniteAbstra /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10421", MvccFeatureChecker.forcedMvcc()); + cleanPersistenceDir(); startGrids(gridCount()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartNoExchangeTimeoutTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartNoExchangeTimeoutTest.java index c3e3e884cbc5d..65e00010fc997 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartNoExchangeTimeoutTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartNoExchangeTimeoutTest.java @@ -36,24 +36,23 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 4; @@ -61,8 +60,6 @@ public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbst @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setCommunicationSpi(new TestCommunicationSpi()); if (igniteInstanceName.equals(getTestIgniteInstanceName(NODES - 1))) @@ -90,6 +87,7 @@ public class IgniteDynamicCacheStartNoExchangeTimeoutTest extends GridCommonAbst /** * @throws Exception If failed. */ + @Test public void testMultinodeCacheStart() throws Exception { for (int i = 0; i < 10; i++) { log.info("Iteration: " + i); @@ -121,6 +119,7 @@ public void testMultinodeCacheStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOldestNotAffinityNode1() throws Exception { for (CacheConfiguration ccfg : cacheConfigurations()) oldestNotAffinityNode1(ccfg); @@ -149,6 +148,7 @@ private void oldestNotAffinityNode1(final CacheConfiguration ccfg) throws Except /** * @throws Exception If failed. */ + @Test public void testOldestNotAffinityNode2() throws Exception { for (CacheConfiguration ccfg : cacheConfigurations()) oldestNotAffinityNode2(ccfg); @@ -180,6 +180,7 @@ private void oldestNotAffinityNode2(final CacheConfiguration ccfg) throws Except /** * @throws Exception If failed. */ + @Test public void testNotAffinityNode1() throws Exception { for (CacheConfiguration ccfg : cacheConfigurations()) notAffinityNode1(ccfg); @@ -208,6 +209,7 @@ private void notAffinityNode1(final CacheConfiguration ccfg) throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotAffinityNode2() throws Exception { for (CacheConfiguration ccfg : cacheConfigurations()) notAffinityNode2(ccfg); @@ -239,6 +241,7 @@ private void notAffinityNode2(final CacheConfiguration ccfg) throws Exception { /** * @throws Exception If failed. */ + @Test public void testOldestChanged1() throws Exception { IgniteEx ignite0 = grid(0); @@ -266,6 +269,7 @@ public void testOldestChanged1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOldestChanged2() throws Exception { IgniteEx ignite0 = grid(0); @@ -291,6 +295,7 @@ public void testOldestChanged2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOldestChanged3() throws Exception { IgniteEx ignite0 = grid(0); @@ -400,7 +405,7 @@ private List cacheConfigurations() { { CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - ccfg.setName("cache-4"); + ccfg.setName("cache-6"); ccfg.setAtomicityMode(TRANSACTIONAL); ccfg.setBackups(1); ccfg.setWriteSynchronizationMode(FULL_SYNC); @@ -408,6 +413,39 @@ private List cacheConfigurations() { res.add(ccfg); } + { + CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + + ccfg.setName("cache-7"); + ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + ccfg.setBackups(0); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + + res.add(ccfg); + } + + { + CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + + ccfg.setName("cache-8"); + ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + ccfg.setBackups(1); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + + res.add(ccfg); + } + + { + CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + + ccfg.setName("cache-9"); + ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + ccfg.setBackups(1); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + + res.add(ccfg); + } + return res; } @@ -476,4 +514,4 @@ private static class TestCommunicationSpi extends TcpCommunicationSpi { super.sendMessage(node, msg, ackClosure); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java index 53de23f90a602..e0b6a89f8f17d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java @@ -19,11 +19,13 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -47,22 +49,23 @@ import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for dynamic cache start. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String DYNAMIC_CACHE_NAME = "TestDynamicCache"; @@ -104,8 +107,6 @@ public int nodeCount() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (client) { cfg.setClientMode(true); @@ -140,6 +141,7 @@ public int nodeCount() { /** * @throws Exception If failed. */ + @Test public void testStartStopCacheMultithreadedSameNode() throws Exception { final IgniteEx kernal = grid(0); @@ -191,7 +193,7 @@ public void testStartStopCacheMultithreadedSameNode() throws Exception { GridTestUtils.runMultiThreaded(new Callable() { @Override public Object call() throws Exception { - futs.add(kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, false, true, false)); + futs.add(kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, false, true, false, null)); return null; } @@ -206,6 +208,7 @@ public void testStartStopCacheMultithreadedSameNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartCacheMultithreadedDifferentNodes() throws Exception { final Collection> futs = new ConcurrentLinkedDeque<>(); @@ -259,7 +262,7 @@ public void testStartCacheMultithreadedDifferentNodes() throws Exception { @Override public Object call() throws Exception { IgniteEx kernal = grid(ThreadLocalRandom.current().nextInt(nodeCount())); - futs.add(kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, false, true, false)); + futs.add(kernal.context().cache().dynamicDestroyCache(DYNAMIC_CACHE_NAME, false, true, false, null)); return null; } @@ -274,6 +277,7 @@ public void testStartCacheMultithreadedDifferentNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStopCacheSimpleTransactional() throws Exception { checkStartStopCacheSimple(CacheAtomicityMode.TRANSACTIONAL); } @@ -281,6 +285,15 @@ public void testStartStopCacheSimpleTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testStartStopCacheSimpleTransactionalMvcc() throws Exception { + checkStartStopCacheSimple(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testStartStopCacheSimpleAtomic() throws Exception { checkStartStopCacheSimple(CacheAtomicityMode.ATOMIC); } @@ -288,6 +301,7 @@ public void testStartStopCacheSimpleAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStopCachesSimpleTransactional() throws Exception { checkStartStopCachesSimple(CacheAtomicityMode.TRANSACTIONAL); } @@ -295,6 +309,15 @@ public void testStartStopCachesSimpleTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testStartStopCachesSimpleTransactionalMvcc() throws Exception { + checkStartStopCachesSimple(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testStartStopCachesSimpleAtomic() throws Exception { checkStartStopCachesSimple(CacheAtomicityMode.ATOMIC); } @@ -432,6 +455,7 @@ private void checkStartStopCachesSimple(CacheAtomicityMode mode) throws Exceptio /** * @throws Exception If failed. */ + @Test public void testStartStopCacheAddNode() throws Exception { final IgniteEx kernal = grid(0); @@ -484,6 +508,7 @@ public void testStartStopCacheAddNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployFilter() throws Exception { try { testAttribute = false; @@ -550,6 +575,7 @@ public void testDeployFilter() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailWhenConfiguredCacheExists() throws Exception { GridTestUtils.assertThrowsInherited(log, new Callable() { @Override public Object call() throws Exception { @@ -571,6 +597,7 @@ public void testFailWhenConfiguredCacheExists() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailWhenOneOfConfiguredCacheExists() throws Exception { GridTestUtils.assertThrowsInherited(log, new Callable() { @Override public Object call() throws Exception { @@ -601,6 +628,7 @@ public void testFailWhenOneOfConfiguredCacheExists() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientCache() throws Exception { try { testAttribute = false; @@ -644,6 +672,7 @@ public void testClientCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartFromClientNode() throws Exception { try { testAttribute = false; @@ -686,6 +715,7 @@ public void testStartFromClientNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartNearCacheFromClientNode() throws Exception { try { testAttribute = false; @@ -731,6 +761,7 @@ public void testStartNearCacheFromClientNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvents() throws Exception { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -802,6 +833,7 @@ public void testEvents() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearNodesCache() throws Exception { try { testAttribute = false; @@ -845,6 +877,7 @@ public void testNearNodesCache() throws Exception { } /** {@inheritDoc} */ + @Test public void testGetOrCreate() throws Exception { try { final CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -906,6 +939,7 @@ public void testGetOrCreate() throws Exception { } /** {@inheritDoc} */ + @Test public void testGetOrCreateCollection() throws Exception { final int cacheCnt = 3; @@ -942,6 +976,7 @@ public void testGetOrCreateCollection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateMultiNode() throws Exception { try { final AtomicInteger cnt = new AtomicInteger(); @@ -984,6 +1019,7 @@ public void testGetOrCreateMultiNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateMultiNodeTemplate() throws Exception { final AtomicInteger idx = new AtomicInteger(); @@ -1003,6 +1039,7 @@ public void testGetOrCreateMultiNodeTemplate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateNearOnlyMultiNode() throws Exception { checkGetOrCreateNear(true); } @@ -1010,6 +1047,7 @@ public void testGetOrCreateNearOnlyMultiNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateNearMultiNode() throws Exception { checkGetOrCreateNear(false); } @@ -1131,6 +1169,7 @@ private void lightCheckDynamicCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerNodesLeftEvent() throws Exception { testAttribute = false; @@ -1185,6 +1224,7 @@ public void testServerNodesLeftEvent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDaemonNode() throws Exception { daemon = true; @@ -1217,6 +1257,7 @@ public void testDaemonNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAwaitPartitionMapExchange() throws Exception { IgniteCache cache = grid(0).getOrCreateCache(new CacheConfiguration(DYNAMIC_CACHE_NAME)); @@ -1242,6 +1283,7 @@ public void testAwaitPartitionMapExchange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStopWithClientJoin() throws Exception { Ignite ignite1 = ignite(1); @@ -1296,6 +1338,7 @@ public void testStartStopWithClientJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStopSameCacheMultinode() throws Exception { final AtomicInteger idx = new AtomicInteger(); @@ -1327,4 +1370,62 @@ public void testStartStopSameCacheMultinode() throws Exception { fut.get(); } + + /** + * @throws Exception If failed. + */ + @Test + public void testCacheRestartIsAllowedOnlyToItsInititator() throws Exception { + IgniteEx kernal = grid(ThreadLocalRandom.current().nextInt(nodeCount())); + + CacheConfiguration ccfg = new CacheConfiguration("testCacheRestartIsAllowedOnlyToItsInititator"); + + kernal.createCache(ccfg); + + IgniteUuid restartId = IgniteUuid.randomUuid(); + + kernal.context().cache().dynamicDestroyCache(ccfg.getName(), false, true, true, restartId) + .get(getTestTimeout(), TimeUnit.MILLISECONDS); + + try { + kernal.createCache(ccfg); + + fail(); + } + catch (Exception e) { + assertTrue(X.hasCause(e, CacheExistsException.class)); + + System.out.println("User couldn't start new cache with the same name"); + } + + try { + kernal.context().cache().dynamicStartCache(ccfg, ccfg.getName(), null, true, false, true).get(); + + fail(); + } + catch (Exception e) { + assertTrue(X.hasCause(e, CacheExistsException.class)); + + System.out.println("We couldn't start new cache with private API"); + } + + StoredCacheData storedCacheData = new StoredCacheData(ccfg); + + try { + kernal.context().cache().dynamicStartCachesByStoredConf(Collections.singleton(storedCacheData), true, true, false, IgniteUuid.randomUuid()).get(); + + fail(); + } + catch (Exception e) { + assertTrue(X.hasCause(e, CacheExistsException.class)); + + System.out.println("We couldn't start new cache with wrong restart id."); + } + + kernal.context().cache().dynamicStartCachesByStoredConf(Collections.singleton(storedCacheData), true, true, false, restartId).get(); + + System.out.println("We successfully restarted cache with initial restartId."); + + kernal.destroyCache(ccfg.getName()); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartStopConcurrentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartStopConcurrentTest.java index 15d10fc5b60e6..62511392a4705 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartStopConcurrentTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartStopConcurrentTest.java @@ -19,36 +19,24 @@ import org.apache.ignite.Ignite; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteDynamicCacheStartStopConcurrentTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 4; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); @@ -59,6 +47,7 @@ public class IgniteDynamicCacheStartStopConcurrentTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testConcurrentStartStop() throws Exception { awaitPartitionMapExchange(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheWithConfigStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheWithConfigStartSelfTest.java index ec6b82de7c6d0..c42e2a22109db 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheWithConfigStartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheWithConfigStartSelfTest.java @@ -17,21 +17,20 @@ package org.apache.ignite.internal.processors.cache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteDynamicCacheWithConfigStartSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE_NAME = "partitioned"; @@ -42,12 +41,6 @@ public class IgniteDynamicCacheWithConfigStartSelfTest extends GridCommonAbstrac @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - if (client) cfg.setCacheConfiguration(cacheConfiguration()); @@ -63,6 +56,7 @@ private CacheConfiguration cacheConfiguration() { CacheConfiguration ccfg = new CacheConfiguration<>(CACHE_NAME); ccfg.setIndexedTypes(String.class, String.class); + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); return ccfg; } @@ -70,6 +64,7 @@ private CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testStartCacheOnClient() throws Exception { int srvCnt = 3; @@ -95,4 +90,4 @@ public void testStartCacheOnClient() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java index 0cb08561521b0..afd8e45cba51f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java @@ -37,14 +37,17 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.cache.CacheAtomicityMode.*; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheAtomicityMode.values; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME; @@ -52,10 +55,8 @@ /** * Tests that cache specified in configuration start on client nodes. */ +@RunWith(JUnit4.class) public class IgniteDynamicClientCacheStartSelfTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private CacheConfiguration ccfg; @@ -66,8 +67,6 @@ public class IgniteDynamicClientCacheStartSelfTest extends GridCommonAbstractTes @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); if (ccfg != null) @@ -88,6 +87,7 @@ public class IgniteDynamicClientCacheStartSelfTest extends GridCommonAbstractTes /** * @throws Exception If failed. */ + @Test public void testConfiguredCacheOnClientNode() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -133,6 +133,7 @@ public void testConfiguredCacheOnClientNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearCacheStartError() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -172,6 +173,7 @@ public void testNearCacheStartError() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedCacheClient() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -205,6 +207,7 @@ public void testReplicatedCacheClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedWithNearCacheClient() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -240,6 +243,7 @@ public void testReplicatedWithNearCacheClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateCloseClientCache1() throws Exception { Ignite ignite0 = startGrid(0); @@ -265,6 +269,7 @@ public void testCreateCloseClientCache1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateCloseClientCache2_1() throws Exception { createCloseClientCache2(false); } @@ -272,6 +277,7 @@ public void testCreateCloseClientCache2_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateCloseClientCache2_2() throws Exception { createCloseClientCache2(true); } @@ -279,6 +285,7 @@ public void testCreateCloseClientCache2_2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartMultipleClientCaches() throws Exception { startMultipleClientCaches(null); } @@ -286,6 +293,7 @@ public void testStartMultipleClientCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartMultipleClientCachesForGroup() throws Exception { startMultipleClientCaches("testGrp"); } @@ -377,6 +385,7 @@ private void startCachesForGroup(Ignite srv, * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testStartNewAndClientCaches() throws Exception { final int SRVS = 4; @@ -394,8 +403,9 @@ public void testStartNewAndClientCaches() throws Exception { cfgs.addAll(cacheConfigurations(null, ATOMIC)); cfgs.addAll(cacheConfigurations(null, TRANSACTIONAL)); + cfgs.addAll(cacheConfigurations(null, TRANSACTIONAL_SNAPSHOT)); - assertEquals(6, cfgs.size()); + assertEquals(9, cfgs.size()); Collection caches = client.getOrCreateCaches(cfgs); @@ -551,6 +561,7 @@ private void checkNoCache(Ignite ignite, final String cacheName) throws Exceptio /** * @throws Exception If failed. */ + @Test public void testStartClientCachesOnCoordinatorWithGroup() throws Exception { startGrids(3); @@ -598,4 +609,4 @@ public CachePredicate(List excludeNodes) { return !excludeNodes.contains(name); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteExchangeFutureHistoryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteExchangeFutureHistoryTest.java index a5930c992935e..7e5e17848e713 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteExchangeFutureHistoryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteExchangeFutureHistoryTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks that top value at {@link GridCachePartitionExchangeManager#exchangeFutures()} is the newest one. */ +@RunWith(JUnit4.class) public class IgniteExchangeFutureHistoryTest extends IgniteCacheAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -55,6 +59,7 @@ public class IgniteExchangeFutureHistoryTest extends IgniteCacheAbstractTest { * * @throws Exception If failed. */ + @Test public void testExchangeFutures() throws Exception { GridCachePartitionExchangeManager mgr = ((IgniteKernal)grid(0)).internalCache(DEFAULT_CACHE_NAME).context().shared().exchange(); @@ -71,4 +76,4 @@ public void testExchangeFutures() throws Exception { assertEquals(futs.get(j), sortedFuts.get(j)); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java index 5b6d7f3b95c29..cdfb8a359613c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java @@ -26,16 +26,21 @@ import java.nio.ByteBuffer; import java.util.concurrent.ThreadLocalRandom; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Simple test for arbitrary CacheObject reading/writing. */ +@RunWith(JUnit4.class) public class IgniteIncompleteCacheObjectSelfTest extends GridCommonAbstractTest { /** * Test case when requested data cut on cache object header. * * @throws Exception If failed. */ + @Test public void testIncompleteObject() throws Exception { final byte[] data = new byte[1024]; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java index 7f3807e63bd69..eb043dbf54de1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java @@ -23,11 +23,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL; import static org.apache.ignite.internal.managers.communication.GridIoPolicy.UTILITY_CACHE_POOL; @@ -35,10 +35,8 @@ /** * Sanity test for cache types. */ +@RunWith(JUnit4.class) public class IgniteInternalCacheTypesTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE1 = "cache1"; @@ -49,8 +47,6 @@ public class IgniteInternalCacheTypesTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (igniteInstanceName.equals(getTestIgniteInstanceName(0))) { CacheConfiguration ccfg = defaultCacheConfiguration(); @@ -65,6 +61,7 @@ public class IgniteInternalCacheTypesTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCacheTypes() throws Exception { Ignite ignite0 = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClassNameConflictTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClassNameConflictTest.java index b3e0e454eb321..56fd4d3cb6f4f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClassNameConflictTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClassNameConflictTest.java @@ -40,6 +40,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -53,6 +56,7 @@ * and {@link org.apache.ignite.internal.processors.marshaller.MappingProposedMessage} is sent * with not-null conflictingClsName field. */ +@RunWith(JUnit4.class) public class IgniteMarshallerCacheClassNameConflictTest extends GridCommonAbstractTest { /** */ private volatile boolean bbClsRejected; @@ -104,6 +108,7 @@ public class IgniteMarshallerCacheClassNameConflictTest extends GridCommonAbstra /** * @throws Exception If failed. */ + @Test public void testCachePutGetClassesWithNameConflict() throws Exception { Ignite srv1 = startGrid(0); Ignite srv2 = startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClientRequestsMappingOnMissTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClientRequestsMappingOnMissTest.java index 057b97005b081..da287a7020515 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClientRequestsMappingOnMissTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheClientRequestsMappingOnMissTest.java @@ -41,6 +41,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -49,6 +52,7 @@ /** * Tests for client requesting missing mappings from server nodes with and without server nodes failures. */ +@RunWith(JUnit4.class) public class IgniteMarshallerCacheClientRequestsMappingOnMissTest extends GridCommonAbstractTest { /** * Need to point client node to a different working directory @@ -114,6 +118,7 @@ private void cleanupMarshallerFileStore() throws IOException { /** * @throws Exception If failed. */ + @Test public void testRequestedMappingIsStoredInFS() throws Exception { Ignite srv1 = startGrid(0); @@ -151,6 +156,7 @@ public void testRequestedMappingIsStoredInFS() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoNodesDieOnRequest() throws Exception { Ignite srv1 = startGrid(0); @@ -181,6 +187,7 @@ public void testNoNodesDieOnRequest() throws Exception { /** * */ + @Test public void testOneNodeDiesOnRequest() throws Exception { CountDownLatch nodeStopLatch = new CountDownLatch(1); @@ -216,6 +223,7 @@ public void testOneNodeDiesOnRequest() throws Exception { /** * */ + @Test public void testTwoNodesDieOnRequest() throws Exception { CountDownLatch nodeStopLatch = new CountDownLatch(2); @@ -252,6 +260,7 @@ public void testTwoNodesDieOnRequest() throws Exception { /** * */ + @Test public void testAllNodesDieOnRequest() throws Exception { CountDownLatch nodeStopLatch = new CountDownLatch(3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheConcurrentReadWriteTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheConcurrentReadWriteTest.java index 4e477f2c96b1b..a16e17d1e59ec 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheConcurrentReadWriteTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheConcurrentReadWriteTest.java @@ -27,11 +27,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -40,18 +40,14 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteMarshallerCacheConcurrentReadWriteTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setPeerClassLoadingEnabled(false); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -75,6 +71,7 @@ public class IgniteMarshallerCacheConcurrentReadWriteTest extends GridCommonAbst /** * @throws Exception If failed. */ + @Test public void testConcurrentReadWrite() throws Exception { Ignite ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheFSRestoreTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheFSRestoreTest.java index 47c01dc47f212..15560d32e9b72 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheFSRestoreTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMarshallerCacheFSRestoreTest.java @@ -44,10 +44,14 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteMarshallerCacheFSRestoreTest extends GridCommonAbstractTest { /** */ private volatile boolean isDuplicateObserved = true; @@ -128,6 +132,7 @@ private void cleanUpWorkDir() throws Exception { * * This test must never hang on proposing of MarshallerMapping. */ + @Test public void testFileMappingReadAndPropose() throws Exception { isPersistenceEnabled = false; @@ -185,6 +190,7 @@ private void prepareMarshallerFileStore() throws Exception { * @see IGNITE-6536 JIRA provides more information * about this case. */ + @Test public void testNodeStartFailsOnCorruptedStorage() throws Exception { isPersistenceEnabled = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMvccTxMultiThreadedAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMvccTxMultiThreadedAbstractTest.java new file mode 100644 index 0000000000000..f7c434a4c3ba1 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMvccTxMultiThreadedAbstractTest.java @@ -0,0 +1,132 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Tests for local transactions. + */ +@RunWith(JUnit4.class) +public abstract class IgniteMvccTxMultiThreadedAbstractTest extends IgniteTxAbstractTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9470"); + + super.beforeTestsStarted(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9470"); + } + + /** + * @return Thread count. + */ + protected abstract int threadCount(); + + /** + /** + * @throws IgniteCheckedException If test failed. + */ + @Test + public void testPessimisticRepeatableReadCommitMultithreaded() throws Exception { + checkCommitMultithreaded(PESSIMISTIC, REPEATABLE_READ); + + finalChecks(); + } + + /** + * @throws IgniteCheckedException If test failed. + */ + @Test + public void testPessimisticRepeatableReadRollbackMultithreaded() throws Exception { + checkRollbackMultithreaded(PESSIMISTIC, REPEATABLE_READ); + + finalChecks(); + } + + /** + * @param concurrency Concurrency. + * @param isolation Isolation. + * @throws Exception If check failed. + */ + protected void checkCommitMultithreaded(final TransactionConcurrency concurrency, + final TransactionIsolation isolation) throws Exception { + GridTestUtils.runMultiThreaded(new Callable() { + @Nullable @Override public Object call() throws Exception { + Thread t = Thread.currentThread(); + + t.setName(t.getName() + "-id-" + t.getId()); + + info("Starting commit thread: " + Thread.currentThread().getName()); + + try { + checkCommit(concurrency, isolation); + } + finally { + info("Finished commit thread: " + Thread.currentThread().getName()); + } + + return null; + } + }, threadCount(), concurrency + "-" + isolation); + } + + /** + * @param concurrency Concurrency. + * @param isolation Isolation. + * @throws Exception If check failed. + */ + protected void checkRollbackMultithreaded(final TransactionConcurrency concurrency, + final TransactionIsolation isolation) throws Exception { + final ConcurrentMap map = new ConcurrentHashMap<>(); + GridTestUtils.runMultiThreaded(new Callable() { + @Nullable @Override public Object call() throws Exception { + Thread t = Thread.currentThread(); + + t.setName(t.getName() + "-id-" + t.getId()); + + info("Starting rollback thread: " + Thread.currentThread().getName()); + + try { + checkRollback(map, concurrency, isolation); + + return null; + } + finally { + info("Finished rollback thread: " + Thread.currentThread().getName()); + } + } + }, threadCount(), concurrency + "-" + isolation); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMvccTxSingleThreadedAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMvccTxSingleThreadedAbstractTest.java new file mode 100644 index 0000000000000..51e96e120ee75 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteMvccTxSingleThreadedAbstractTest.java @@ -0,0 +1,56 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.IgniteCheckedException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Tests for local transactions. + */ +@RunWith(JUnit4.class) +public abstract class IgniteMvccTxSingleThreadedAbstractTest extends IgniteTxAbstractTest { + /** + * @throws IgniteCheckedException If test failed. + */ + @Test + public void testPessimisticRepeatableReadCommit() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10261"); + + checkCommit(PESSIMISTIC, REPEATABLE_READ); + + finalChecks(); + } + + /** + * @throws IgniteCheckedException If test failed. + */ + @Test + public void testPessimisticRepeatableReadRollback() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10261"); + + checkRollback(PESSIMISTIC, REPEATABLE_READ); + + finalChecks(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteNearClientCacheCloseTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteNearClientCacheCloseTest.java index e7ab805c3de7c..692f01207a8c9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteNearClientCacheCloseTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteNearClientCacheCloseTest.java @@ -33,23 +33,23 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class IgniteNearClientCacheCloseTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -57,8 +57,6 @@ public class IgniteNearClientCacheCloseTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -74,6 +72,7 @@ public class IgniteNearClientCacheCloseTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNearCacheCloseAtomic1() throws Exception { nearCacheClose(1, false, ATOMIC); @@ -83,6 +82,7 @@ public void testNearCacheCloseAtomic1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearCacheCloseAtomic2() throws Exception { nearCacheClose(4, false, ATOMIC); @@ -92,6 +92,7 @@ public void testNearCacheCloseAtomic2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearCacheCloseTx1() throws Exception { nearCacheClose(1, false, TRANSACTIONAL); @@ -101,12 +102,35 @@ public void testNearCacheCloseTx1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearCacheCloseTx2() throws Exception { nearCacheClose(4, false, TRANSACTIONAL); nearCacheClose(4, true, TRANSACTIONAL); } + /** + * @throws Exception If failed. + */ + @Test + public void testNearCacheCloseMvccTx1() throws Exception { + nearCacheClose(1, false, TRANSACTIONAL_SNAPSHOT); + + if (MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) + nearCacheClose(1, true, TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testNearCacheCloseMvccTx2() throws Exception { + nearCacheClose(4, false, TRANSACTIONAL_SNAPSHOT); + + if (MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) + nearCacheClose(4, true, TRANSACTIONAL_SNAPSHOT); + } + /** * @param srvs Number of server nodes. * @param srvNearCache {@code True} to enable near cache on server nodes. @@ -162,6 +186,7 @@ private void nearCacheClose(int srvs, boolean srvNearCache, CacheAtomicityMode a /** * @throws Exception If failed. */ + @Test public void testConcurrentUpdateAndNearCacheClose() throws Exception { final int SRVS = 4; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java index bccebaa0ab505..35d09b8dc939e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java @@ -33,11 +33,11 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; @@ -46,10 +46,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteOnePhaseCommitInvokeTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -60,8 +58,6 @@ public class IgniteOnePhaseCommitInvokeTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi(); cfg.setCommunicationSpi(commSpi); @@ -91,6 +87,7 @@ public class IgniteOnePhaseCommitInvokeTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testOnePhaseInvoke() throws Exception { boolean flags[] = {true, false}; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearReadersTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearReadersTest.java index f796ceace8a3e..8f5e35dbc5824 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearReadersTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearReadersTest.java @@ -27,14 +27,14 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionRollbackException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -43,10 +43,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteOnePhaseCommitNearReadersTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -57,8 +55,6 @@ public class IgniteOnePhaseCommitNearReadersTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); if (testSpi) { @@ -80,6 +76,7 @@ public class IgniteOnePhaseCommitNearReadersTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testPutReadersUpdate1() throws Exception { putReadersUpdate(1); } @@ -87,6 +84,7 @@ public void testPutReadersUpdate1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutReadersUpdate2() throws Exception { putReadersUpdate(0); } @@ -145,6 +143,7 @@ private void putReadersUpdate(int backups) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutReaderUpdatePrimaryFails1() throws Exception { putReaderUpdatePrimaryFails(1); } @@ -152,6 +151,7 @@ public void testPutReaderUpdatePrimaryFails1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutReaderUpdatePrimaryFails2() throws Exception { putReaderUpdatePrimaryFails(0); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java index 55323bb64501d..542ca53c7bddd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitNearSelfTest.java @@ -40,6 +40,9 @@ import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.*; import static org.apache.ignite.transactions.TransactionIsolation.*; @@ -47,6 +50,7 @@ /** * Checks one-phase commit scenarios. */ +@RunWith(JUnit4.class) public class IgniteOnePhaseCommitNearSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 4; @@ -88,6 +92,7 @@ protected CacheConfiguration cacheConfiguration(String igniteInstanceName) { /** * @throws Exception If failed. */ + @Test public void testOnePhaseCommitFromNearNode() throws Exception { backups = 1; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOutOfMemoryPropagationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOutOfMemoryPropagationTest.java index 34fb74951d213..bf0a286b0b04f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOutOfMemoryPropagationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOutOfMemoryPropagationTest.java @@ -38,10 +38,14 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteOutOfMemoryPropagationTest extends GridCommonAbstractTest { /** */ public static final int NODES = 3; @@ -67,11 +71,13 @@ public class IgniteOutOfMemoryPropagationTest extends GridCommonAbstractTest { } /** */ + @Test public void testPutOOMPropagation() throws Exception { testOOMPropagation(false); } /** */ + @Test public void testStreamerOOMPropagation() throws Exception { testOOMPropagation(true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePdsDataRegionMetricsTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePdsDataRegionMetricsTxTest.java new file mode 100644 index 0000000000000..09b1213737fe5 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePdsDataRegionMetricsTxTest.java @@ -0,0 +1,55 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsDataRegionMetricsTest; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * + */ +@RunWith(JUnit4.class) +public class IgnitePdsDataRegionMetricsTxTest extends IgnitePdsDataRegionMetricsTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + return super.getConfiguration(igniteInstanceName) + .setMvccVacuumFrequency(Long.MAX_VALUE); + } + + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration() { + return super.cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + } + + /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10662") + @Test + @Override public void testMemoryUsageMultipleNodes() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10583"); + + super.testMemoryUsageMultipleNodes(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllLargeBatchSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllLargeBatchSelfTest.java index 56a438107c40f..45e52e90119ee 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllLargeBatchSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllLargeBatchSelfTest.java @@ -30,10 +30,14 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -42,6 +46,7 @@ /** * Tests putAll method with large number of keys. */ +@RunWith(JUnit4.class) public class IgnitePutAllLargeBatchSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 4; @@ -52,6 +57,13 @@ public class IgnitePutAllLargeBatchSelfTest extends GridCommonAbstractTest { /** Backups. */ private int backups = 1; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -79,6 +91,7 @@ public CacheConfiguration cacheConfiguration(String igniteInstanceName) { /** * @throws Exception If failed. */ + @Test public void testPutAllPessimisticOneBackupPartitioned() throws Exception { backups = 1; @@ -88,6 +101,7 @@ public void testPutAllPessimisticOneBackupPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllPessimisticOneBackupNear() throws Exception { backups = 1; @@ -97,6 +111,7 @@ public void testPutAllPessimisticOneBackupNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllOptimisticOneBackupPartitioned() throws Exception { backups = 1; @@ -106,6 +121,7 @@ public void testPutAllOptimisticOneBackupPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllOptimisticOneBackupNear() throws Exception { backups = 1; @@ -115,6 +131,7 @@ public void testPutAllOptimisticOneBackupNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllPessimisticTwoBackupsPartitioned() throws Exception { backups = 2; @@ -124,6 +141,7 @@ public void testPutAllPessimisticTwoBackupsPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllPessimisticTwoBackupsNear() throws Exception { backups = 2; @@ -133,6 +151,7 @@ public void testPutAllPessimisticTwoBackupsNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllOptimisticTwoBackupsPartitioned() throws Exception { backups = 2; @@ -142,6 +161,7 @@ public void testPutAllOptimisticTwoBackupsPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllOptimisticTwoBackupsNear() throws Exception { backups = 2; @@ -236,6 +256,7 @@ private void checkPutAll(TransactionConcurrency concurrency, boolean nearEnabled /** * @throws Exception If failed. */ + @Test public void testPreviousValuePartitionedOneBackup() throws Exception { backups = 1; nearEnabled = false; @@ -246,6 +267,7 @@ public void testPreviousValuePartitionedOneBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreviousValuePartitionedTwoBackups() throws Exception { backups = 2; nearEnabled = false; @@ -256,6 +278,7 @@ public void testPreviousValuePartitionedTwoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreviousValueNearOneBackup() throws Exception { backups = 1; nearEnabled = true; @@ -266,6 +289,7 @@ public void testPreviousValueNearOneBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreviousValueNearTwoBackups() throws Exception { backups = 2; nearEnabled = true; @@ -304,4 +328,4 @@ private void checkPreviousValue() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllUpdateNonPreloadedPartitionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllUpdateNonPreloadedPartitionSelfTest.java index 2503e219455e7..99fc4c93cfa6a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllUpdateNonPreloadedPartitionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllUpdateNonPreloadedPartitionSelfTest.java @@ -25,8 +25,12 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -34,6 +38,7 @@ /** * Tests . */ +@RunWith(JUnit4.class) public class IgnitePutAllUpdateNonPreloadedPartitionSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 4; @@ -41,6 +46,13 @@ public class IgnitePutAllUpdateNonPreloadedPartitionSelfTest extends GridCommonA /** Backups. */ private int backups = 1; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -70,6 +82,7 @@ public CacheConfiguration cacheConfiguration(String igniteInstanceName) { /** * @throws Exception If failed. */ + @Test public void testPessimistic() throws Exception { backups = 2; @@ -129,4 +142,4 @@ public void testPessimistic() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionSelfTest.java index b037a7b8ef6a8..00be0508ab7cc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionSelfTest.java @@ -26,12 +26,13 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -40,10 +41,8 @@ /** * Check starting cache in transaction. */ +@RunWith(JUnit4.class) public class IgniteStartCacheInTransactionSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String EXPECTED_MSG = "Cannot start/stop cache within lock or transaction."; @@ -51,8 +50,6 @@ public class IgniteStartCacheInTransactionSelfTest extends GridCommonAbstractTes @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setAtomicityMode(atomicityMode()); @@ -90,6 +87,7 @@ public CacheConfiguration cacheConfiguration(String cacheName) { /** * @throws Exception If failed. */ + @Test public void testStartCache() throws Exception { final Ignite ignite = grid(0); @@ -116,6 +114,7 @@ public void testStartCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartConfigurationCache() throws Exception { final Ignite ignite = grid(0); @@ -142,6 +141,7 @@ public void testStartConfigurationCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartConfigurationCacheWithNear() throws Exception { final Ignite ignite = grid(0); @@ -168,6 +168,7 @@ public void testStartConfigurationCacheWithNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateCache() throws Exception { final Ignite ignite = grid(0); @@ -194,6 +195,7 @@ public void testGetOrCreateCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateCacheConfiguration() throws Exception { final Ignite ignite = grid(0); @@ -220,6 +222,7 @@ public void testGetOrCreateCacheConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopCache() throws Exception { final Ignite ignite = grid(0); @@ -246,10 +249,13 @@ public void testStopCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockCache() throws Exception { if (atomicityMode() != TRANSACTIONAL) return; + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + final Ignite ignite = grid(0); final String key = "key"; @@ -268,4 +274,4 @@ public void testLockCache() throws Exception { lock.unlock(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStaticCacheStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStaticCacheStartSelfTest.java index 0c64a79a81c2a..75a924e89fa56 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStaticCacheStartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStaticCacheStartSelfTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests cache deploy on topology from static configuration. */ +@RunWith(JUnit4.class) public class IgniteStaticCacheStartSelfTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "TestCache"; @@ -58,6 +62,7 @@ public class IgniteStaticCacheStartSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDeployCacheOnNodeStart() throws Exception { startGrids(3); @@ -99,4 +104,4 @@ public void testDeployCacheOnNodeStart() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteSystemCacheOnClientTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteSystemCacheOnClientTest.java index cc83c8fbb8c86..82eb70626922c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteSystemCacheOnClientTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteSystemCacheOnClientTest.java @@ -23,25 +23,20 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteSystemCacheOnClientTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (igniteInstanceName.equals(getTestIgniteInstanceName(1))) cfg.setClientMode(true); @@ -51,6 +46,7 @@ public class IgniteSystemCacheOnClientTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSystemCacheOnClientNode() throws Exception { startGrids(2); @@ -65,4 +61,4 @@ public void testSystemCacheOnClientNode() throws Exception { assertEquals(1, affNodes.size()); assertTrue(affNodes.contains(ignite(0).cluster().localNode())); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java index e2a4a08e7e8d4..5688afa892704 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractCacheTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Topology validator test. */ +@RunWith(JUnit4.class) public abstract class IgniteTopologyValidatorAbstractCacheTest extends IgniteCacheAbstractTest implements Serializable { /** key-value used at test. */ private static String KEY_VAL = "1"; @@ -241,6 +245,7 @@ void assertEmpty(String cacheName) { /** * @throws Exception If failed. */ + @Test public void testTopologyValidator() throws Exception { putValid(DEFAULT_CACHE_NAME); remove(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractTxCacheGroupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractTxCacheGroupsTest.java index 07875350886e8..a56ccea167d1d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractTxCacheGroupsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractTxCacheGroupsTest.java @@ -19,7 +19,11 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -29,6 +33,7 @@ /** * Topology validator test */ +@RunWith(JUnit4.class) public abstract class IgniteTopologyValidatorAbstractTxCacheGroupsTest extends IgniteTopologyValidatorCacheGroupsAbstractTest { /** {@inheritDoc} */ @@ -42,11 +47,22 @@ public abstract class IgniteTopologyValidatorAbstractTxCacheGroupsTest } /** {@inheritDoc} */ + @Test @Override public void testTopologyValidator() throws Exception { - try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - putValid(CACHE_NAME_1); - putValid(CACHE_NAME_3); - commitFailed(tx); + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + putInvalid(CACHE_NAME_1); + } + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + putInvalid(CACHE_NAME_3); + } + + if (!MvccFeatureChecker.forcedMvcc()) { + try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + putValid(CACHE_NAME_1); + putValid(CACHE_NAME_3); + commitFailed(tx); + } } assertEmpty(CACHE_NAME_1); // Rolled back. @@ -69,10 +85,19 @@ public abstract class IgniteTopologyValidatorAbstractTxCacheGroupsTest startGrid(1); - try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - putValid(CACHE_NAME_1); - putValid(CACHE_NAME_3); - tx.commit(); + if (!MvccFeatureChecker.forcedMvcc()) { + try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + putValid(CACHE_NAME_1); + putValid(CACHE_NAME_3); + tx.commit(); + } + } + else { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + putValid(CACHE_NAME_1); + putValid(CACHE_NAME_3); + tx.commit(); + } } remove(CACHE_NAME_1); @@ -96,19 +121,30 @@ public abstract class IgniteTopologyValidatorAbstractTxCacheGroupsTest assertEmpty(CACHE_NAME_3); // Rolled back. - try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - putValid(CACHE_NAME_1); - putValid(CACHE_NAME_3); - commitFailed(tx); + if (!MvccFeatureChecker.forcedMvcc()) { + try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + putValid(CACHE_NAME_1); + putValid(CACHE_NAME_3); + commitFailed(tx); + } } assertEmpty(CACHE_NAME_1); // Rolled back. assertEmpty(CACHE_NAME_3); // Rolled back. - try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - putValid(DEFAULT_CACHE_NAME); - putValid(CACHE_NAME_3); - tx.commit(); + if (!MvccFeatureChecker.forcedMvcc()) { + try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + putValid(DEFAULT_CACHE_NAME); + putValid(CACHE_NAME_3); + tx.commit(); + } + } + else { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + putValid(DEFAULT_CACHE_NAME); + putValid(CACHE_NAME_3); + tx.commit(); + } } remove(DEFAULT_CACHE_NAME); @@ -123,4 +159,4 @@ public abstract class IgniteTopologyValidatorAbstractTxCacheGroupsTest remove(DEFAULT_CACHE_NAME); remove(CACHE_NAME_3); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractTxCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractTxCacheTest.java index 781d88de40134..ecb62ae824d11 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractTxCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorAbstractTxCacheTest.java @@ -19,7 +19,11 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -29,6 +33,7 @@ /** * Topology validator test */ +@RunWith(JUnit4.class) public abstract class IgniteTopologyValidatorAbstractTxCacheTest extends IgniteTopologyValidatorAbstractCacheTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { @@ -41,21 +46,24 @@ public abstract class IgniteTopologyValidatorAbstractTxCacheTest extends IgniteT } /** {@inheritDoc} */ + @Test @Override public void testTopologyValidator() throws Exception { - try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - putValid(CACHE_NAME_1); - commitFailed(tx); - } - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { putInvalid(CACHE_NAME_1); } - try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - putValid(CACHE_NAME_1); - putValid(DEFAULT_CACHE_NAME); - putValid(CACHE_NAME_2); - commitFailed(tx); + if (!MvccFeatureChecker.forcedMvcc()) { + try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + putValid(CACHE_NAME_1); + commitFailed(tx); + } + + try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + putValid(CACHE_NAME_1); + putValid(DEFAULT_CACHE_NAME); + putValid(CACHE_NAME_2); + commitFailed(tx); + } } assertEmpty(DEFAULT_CACHE_NAME); // rolled back @@ -72,7 +80,7 @@ public abstract class IgniteTopologyValidatorAbstractTxCacheTest extends IgniteT startGrid(1); - try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { putValid(CACHE_NAME_1); tx.commit(); } @@ -96,16 +104,19 @@ public abstract class IgniteTopologyValidatorAbstractTxCacheTest extends IgniteT assertEmpty(DEFAULT_CACHE_NAME); // rolled back assertEmpty(CACHE_NAME_1); // rolled back - try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { - putValid(CACHE_NAME_1); - commitFailed(tx); + if (!MvccFeatureChecker.forcedMvcc()) { + try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + putValid(CACHE_NAME_1); + commitFailed(tx); + } } + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { putInvalid(CACHE_NAME_1); } - try (Transaction tx = grid(0).transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { putValid(DEFAULT_CACHE_NAME); putValid(CACHE_NAME_2); tx.commit(); @@ -123,4 +134,4 @@ public abstract class IgniteTopologyValidatorAbstractTxCacheTest extends IgniteT remove(DEFAULT_CACHE_NAME); remove(CACHE_NAME_2); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorCacheGroupsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorCacheGroupsAbstractTest.java index 8613225d5fc42..b42091073b055 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorCacheGroupsAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorCacheGroupsAbstractTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TopologyValidator; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteTopologyValidatorCacheGroupsAbstractTest extends IgniteTopologyValidatorAbstractCacheTest { /** group name 1. */ protected static final String GROUP_1 = "group1"; @@ -79,6 +83,7 @@ public abstract class IgniteTopologyValidatorCacheGroupsAbstractTest extends Ign /** * @throws Exception If failed. */ + @Test @Override public void testTopologyValidator() throws Exception { putValid(DEFAULT_CACHE_NAME); remove(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java index c315ba50f4707..4fa3d8f8e0758 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java @@ -42,6 +42,10 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; @@ -52,6 +56,7 @@ * #DC_NODE_ATTR}. If only nodes from single DC are left in topology, grid is moved into inoperative state until special * activator node'll enter a topology, enabling grid operations. */ +@RunWith(JUnit4.class) public class IgniteTopologyValidatorGridSplitCacheTest extends IgniteCacheTopologySplitAbstractTest { /** */ private static final String DC_NODE_ATTR = "dc"; @@ -197,6 +202,9 @@ private String testCacheName(int idx) { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-7952"); + super.beforeTest(); startGridsMultiThreaded(GRID_CNT); @@ -220,6 +228,7 @@ protected void stopGrids(int... grids) { * * @throws Exception If failed. */ + @Test public void testTopologyValidator() throws Exception { testTopologyValidator0(false); } @@ -229,6 +238,7 @@ public void testTopologyValidator() throws Exception { * * @throws Exception If failed. */ + @Test public void testTopologyValidatorWithCacheGroup() throws Exception { testTopologyValidator0(true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorNearPartitionedTxCacheGroupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorNearPartitionedTxCacheGroupsTest.java index acfad80fc5a9d..d9cf301885882 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorNearPartitionedTxCacheGroupsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorNearPartitionedTxCacheGroupsTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * Topology validator test. @@ -28,4 +29,11 @@ public class IgniteTopologyValidatorNearPartitionedTxCacheGroupsTest extends @Override protected NearCacheConfiguration nearConfiguration() { return new NearCacheConfiguration(); } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.beforeTestsStarted(); + } } \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorNearPartitionedTxCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorNearPartitionedTxCacheTest.java index 800c2e654d333..c1a8fa81898eb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorNearPartitionedTxCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorNearPartitionedTxCacheTest.java @@ -18,11 +18,19 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * Topology validator test */ public class IgniteTopologyValidatorNearPartitionedTxCacheTest extends IgniteTopologyValidatorPartitionedTxCacheTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected NearCacheConfiguration nearConfiguration() { return new NearCacheConfiguration(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxAbstractTest.java index 1830db03c367d..93054ab0d026d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxAbstractTest.java @@ -29,13 +29,9 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.affinity.AffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; @@ -56,9 +52,6 @@ abstract class IgniteTxAbstractTest extends GridCommonAbstractTest { /** Execution count. */ private static final AtomicInteger cntr = new AtomicInteger(); - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * Start grid by default. */ @@ -66,19 +59,6 @@ protected IgniteTxAbstractTest() { super(false /*start grid. */); } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - - return c; - } - /** * @return Grid count. */ @@ -115,12 +95,16 @@ private void debug(String msg) { info(msg); } - /** - * @throws Exception If failed. - */ + /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { - for (int i = 0; i < gridCount(); i++) - startGrid(i); + startGridsMultiThreaded(gridCount()); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConcurrentGetAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConcurrentGetAbstractTest.java index 5fb076633da19..a0451a262646d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConcurrentGetAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConcurrentGetAbstractTest.java @@ -20,15 +20,14 @@ import java.util.UUID; import java.util.concurrent.Callable; import org.apache.ignite.Ignite; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -36,13 +35,11 @@ /** * Checks multithreaded put/get cache operations on one node. */ +@RunWith(JUnit4.class) public abstract class IgniteTxConcurrentGetAbstractTest extends GridCommonAbstractTest { /** Debug flag. */ private static final boolean DEBUG = false; - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int THREAD_NUM = 20; @@ -54,19 +51,6 @@ protected IgniteTxConcurrentGetAbstractTest() { super(true /** Start grid. */); } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - - return cfg; - } - /** * @param g Grid. * @return Near cache. @@ -88,6 +72,7 @@ GridDhtCacheAdapter dht(Ignite g) { * * @throws Exception If failed. */ + @Test public void testPutGet() throws Exception { // Random key. final String key = UUID.randomUUID().toString(); @@ -138,4 +123,4 @@ private String txGet(Ignite ignite, String key) throws Exception { return val; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java index 680381a21d799..accf079fb519b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java @@ -41,24 +41,24 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionTimeoutException; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; -import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** * Test checks that grid transaction configuration doesn't influence system caches. */ +@RunWith(JUnit4.class) public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Test cache name. */ private static final String CACHE_NAME = "cache_name"; @@ -69,8 +69,6 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - TcpCommunicationSpi commSpi = new TestCommunicationSpi(); cfg.setCommunicationSpi(commSpi); @@ -108,7 +106,10 @@ public CacheAtomicityMode atomicityMode() { * * @throws Exception If failed. */ + @Test public void testUserTxTimeout() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-7952", MvccFeatureChecker.forcedMvcc()); + final Ignite ignite = grid(0); final IgniteCache cache = ignite.getOrCreateCache(CACHE_NAME); @@ -122,6 +123,7 @@ public void testUserTxTimeout() throws Exception { * * @throws Exception If failed. */ + @Test public void testSystemCacheTx() throws Exception { final Ignite ignite = grid(0); @@ -214,7 +216,7 @@ protected void checkExplicitTxTimeout(final IgniteCache cache, f * @throws Exception If failed. */ protected void checkStartTxSuccess(final IgniteInternalCache cache) throws Exception { - try (final GridNearTxLocal tx = CU.txStartInternal(cache.context(), cache, PESSIMISTIC, READ_COMMITTED)) { + try (final GridNearTxLocal tx = CU.txStartInternal(cache.context(), cache, PESSIMISTIC, REPEATABLE_READ)) { assert tx != null; sleepForTxFailure(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java index ac294b05067fb..48c18b3e20330 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxExceptionAbstractSelfTest.java @@ -41,11 +41,16 @@ import org.apache.ignite.spi.indexing.IndexingQueryFilter; import org.apache.ignite.spi.indexing.IndexingSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionHeuristicException; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -53,6 +58,7 @@ /** * Tests that transaction is invalidated in case of {@link IgniteTxHeuristicCheckedException}. */ +@RunWith(JUnit4.class) public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int PRIMARY = 0; @@ -77,8 +83,6 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac cfg.setIndexingSpi(new TestIndexingSpi()); - cfg.getTransactionConfiguration().setTxSerializableEnabled(true); - return cfg; } @@ -89,7 +93,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac ccfg.setCacheStoreFactory(null); ccfg.setReadThrough(false); ccfg.setWriteThrough(false); - ccfg.setLoadPreviousValue(true); + ccfg.setLoadPreviousValue(false); ccfg.setIndexedTypes(Integer.class, Integer.class); @@ -98,6 +102,8 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10377", MvccFeatureChecker.forcedMvcc()); + super.beforeTestsStarted(); lastKey = 0; @@ -131,6 +137,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac /** * @throws Exception If failed. */ + @Test public void testPutNear() throws Exception { checkPut(true, keyForNode(grid(0).localNode(), NOT_PRIMARY_AND_BACKUP)); @@ -140,6 +147,7 @@ public void testPutNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutPrimary() throws Exception { checkPut(true, keyForNode(grid(0).localNode(), PRIMARY)); @@ -149,6 +157,7 @@ public void testPutPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutBackup() throws Exception { checkPut(true, keyForNode(grid(0).localNode(), BACKUP)); @@ -158,6 +167,7 @@ public void testPutBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAll() throws Exception { checkPutAll(true, keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY), @@ -181,6 +191,7 @@ public void testPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveNear() throws Exception { checkRemove(false, keyForNode(grid(0).localNode(), NOT_PRIMARY_AND_BACKUP)); @@ -190,7 +201,10 @@ public void testRemoveNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemovePrimary() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9470", MvccFeatureChecker.forcedMvcc()); + checkRemove(false, keyForNode(grid(0).localNode(), PRIMARY)); checkRemove(true, keyForNode(grid(0).localNode(), PRIMARY)); @@ -199,6 +213,7 @@ public void testRemovePrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveBackup() throws Exception { checkRemove(false, keyForNode(grid(0).localNode(), BACKUP)); @@ -208,6 +223,7 @@ public void testRemoveBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformNear() throws Exception { checkTransform(false, keyForNode(grid(0).localNode(), NOT_PRIMARY_AND_BACKUP)); @@ -217,6 +233,7 @@ public void testTransformNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPrimary() throws Exception { checkTransform(false, keyForNode(grid(0).localNode(), PRIMARY)); @@ -226,6 +243,7 @@ public void testTransformPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformBackup() throws Exception { checkTransform(false, keyForNode(grid(0).localNode(), BACKUP)); @@ -235,6 +253,7 @@ public void testTransformBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutNearTx() throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { @@ -248,6 +267,7 @@ public void testPutNearTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutPrimaryTx() throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { @@ -261,6 +281,7 @@ public void testPutPrimaryTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutBackupTx() throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { @@ -274,6 +295,7 @@ public void testPutBackupTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutMultipleKeysTx() throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { @@ -311,6 +333,10 @@ public void testPutMultipleKeysTx() throws Exception { */ private void checkPutTx(boolean putBefore, TransactionConcurrency concurrency, TransactionIsolation isolation, final Integer... keys) throws Exception { + if (MvccFeatureChecker.forcedMvcc() && + !MvccFeatureChecker.isSupported(concurrency, isolation)) + return; + assertTrue(keys.length > 0); info("Test transaction [concurrency=" + concurrency + ", isolation=" + isolation + ']'); @@ -477,6 +503,8 @@ private void checkPut(boolean putBefore, final Integer key) throws Exception { * @throws Exception If failed. */ private void checkTransform(boolean putBefore, final Integer key) throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9470", MvccFeatureChecker.forcedMvcc()); + if (putBefore) { TestIndexingSpi.forceFail(false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxMultiNodeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxMultiNodeAbstractTest.java index 3df934ff44fdd..0edc1e1779600 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxMultiNodeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxMultiNodeAbstractTest.java @@ -34,7 +34,6 @@ import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; @@ -44,12 +43,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -58,7 +57,7 @@ /** * Checks basic multi-node transactional operations. */ -@SuppressWarnings({"PointlessBooleanExpression", "ConstantConditions", "PointlessArithmeticExpression"}) +@RunWith(JUnit4.class) public abstract class IgniteTxMultiNodeAbstractTest extends GridCommonAbstractTest { /** Debug flag. */ private static final boolean DEBUG = false; @@ -66,9 +65,6 @@ public abstract class IgniteTxMultiNodeAbstractTest extends GridCommonAbstractTe /** */ protected static final int GRID_CNT = 4; - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ protected static final int RETRIES = 300; @@ -90,19 +86,6 @@ public abstract class IgniteTxMultiNodeAbstractTest extends GridCommonAbstractTe /** Number of backups for partitioned tests. */ protected int backups = 2; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { backups = 0; @@ -163,7 +146,6 @@ private static UUID primaryId(Ignite ignite, Object key) { * @param itemKey Item key. * @param retry Retry count. */ - @SuppressWarnings("unchecked") private void onItemNear(boolean putCntr, Ignite ignite, String itemKey, int retry) { IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -214,7 +196,6 @@ private void onItemNear(boolean putCntr, Ignite ignite, String itemKey, int retr * @param itemKey Item key. * @param retry Retry count. */ - @SuppressWarnings("unchecked") private void onItemPrimary(boolean putCntr, Ignite ignite, String itemKey, int retry) { IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -267,7 +248,6 @@ private void onItemPrimary(boolean putCntr, Ignite ignite, String itemKey, int r * @param retry Retry count. * @throws IgniteCheckedException If failed. */ - @SuppressWarnings("unchecked") private void onRemoveItemQueried(boolean putCntr, Ignite ignite, int retry) throws IgniteCheckedException { IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -356,7 +336,6 @@ private void onRemoveItemQueried(boolean putCntr, Ignite ignite, int retry) thro * @param ignite Grid. * @param retry Retry count. */ - @SuppressWarnings("unchecked") private void onRemoveItemSimple(boolean putCntr, Ignite ignite, int retry) { IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -494,6 +473,7 @@ private void removeRetriesSimple(Ignite ignite, boolean putCntr) { * * @throws Exception If failed. */ + @Test public void testPutOneEntryInTx() throws Exception { // resetLog4j(Level.INFO, true, GridCacheTxManager.class.getName()); @@ -514,6 +494,7 @@ public void testPutOneEntryInTx() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutTwoEntriesInTx() throws Exception { // resetLog4j(Level.INFO, true, GridCacheTxManager.class.getName()); @@ -538,6 +519,7 @@ public void testPutTwoEntriesInTx() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutOneEntryInTxMultiThreaded() throws Exception { // resetLog4j(Level.INFO, true, GridCacheTxManager.class.getName()); @@ -577,6 +559,7 @@ public void testPutOneEntryInTxMultiThreaded() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutTwoEntryInTxMultiThreaded() throws Exception { // resetLog4j(Level.INFO, true, GridCacheTxManager.class.getName()); @@ -617,6 +600,7 @@ public void testPutTwoEntryInTxMultiThreaded() throws Exception { * * @throws Exception If failed. */ + @Test public void testRemoveInTxQueried() throws Exception { //resetLog4j(Level.INFO, true, GridCacheTxManager.class.getPackage().getName()); @@ -659,6 +643,7 @@ public void testRemoveInTxQueried() throws Exception { * * @throws Exception If failed. */ + @Test public void testRemoveInTxSimple() throws Exception { startGrids(GRID_CNT); @@ -705,6 +690,7 @@ public void testRemoveInTxSimple() throws Exception { * * @throws Exception If failed. */ + @Test public void testRemoveInTxQueriedMultiThreaded() throws Exception { //resetLog4j(Level.INFO, true, GridCacheTxManager.class.getPackage().getName()); @@ -808,7 +794,6 @@ protected class PutTwoEntriesInTxJob implements IgniteCallable { private Ignite ignite; /** {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override public Integer call() throws IgniteCheckedException { assertNotNull(ignite); @@ -835,7 +820,6 @@ protected class PutOneEntryInTxJob implements IgniteCallable { private Ignite ignite; /** {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override public Integer call() throws IgniteCheckedException { assertNotNull(ignite); @@ -862,7 +846,6 @@ protected class RemoveInTxJobQueried implements IgniteCallable { private Ignite ignite; /** {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override public Integer call() throws IgniteCheckedException { assertNotNull(ignite); @@ -889,7 +872,6 @@ protected class RemoveInTxJobSimple implements IgniteCallable { private Ignite ignite; /** {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override public Integer call() throws IgniteCheckedException { assertNotNull(ignite); @@ -905,4 +887,4 @@ protected class RemoveInTxJobSimple implements IgniteCallable { return S.toString(RemoveInTxJobSimple.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxMultiThreadedAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxMultiThreadedAbstractTest.java index 5a1a1db2fdafe..1ce99ce1683ec 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxMultiThreadedAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxMultiThreadedAbstractTest.java @@ -34,6 +34,9 @@ import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionOptimisticException; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -44,7 +47,7 @@ /** * Tests for local transactions. */ -@SuppressWarnings( {"BusyWait"}) +@RunWith(JUnit4.class) public abstract class IgniteTxMultiThreadedAbstractTest extends IgniteTxAbstractTest { /** * @return Thread count. @@ -86,7 +89,6 @@ protected void checkCommitMultithreaded(final TransactionConcurrency concurrency protected void checkRollbackMultithreaded(final TransactionConcurrency concurrency, final TransactionIsolation isolation) throws Exception { final ConcurrentMap map = new ConcurrentHashMap<>(); - GridTestUtils.runMultiThreaded(new Callable() { @Nullable @Override public Object call() throws Exception { Thread t = Thread.currentThread(); @@ -110,6 +112,7 @@ protected void checkRollbackMultithreaded(final TransactionConcurrency concurren /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticReadCommittedCommitMultithreaded() throws Exception { checkCommitMultithreaded(PESSIMISTIC, READ_COMMITTED); @@ -119,6 +122,7 @@ public void testPessimisticReadCommittedCommitMultithreaded() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticRepeatableReadCommitMultithreaded() throws Exception { checkCommitMultithreaded(PESSIMISTIC, REPEATABLE_READ); @@ -128,6 +132,7 @@ public void testPessimisticRepeatableReadCommitMultithreaded() throws Exception /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticSerializableCommitMultithreaded() throws Exception { checkCommitMultithreaded(PESSIMISTIC, SERIALIZABLE); @@ -137,6 +142,7 @@ public void testPessimisticSerializableCommitMultithreaded() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticReadCommittedCommitMultithreaded() throws Exception { checkCommitMultithreaded(OPTIMISTIC, READ_COMMITTED); @@ -146,6 +152,7 @@ public void testOptimisticReadCommittedCommitMultithreaded() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticRepeatableReadCommitMultithreaded() throws Exception { checkCommitMultithreaded(OPTIMISTIC, REPEATABLE_READ); @@ -155,6 +162,7 @@ public void testOptimisticRepeatableReadCommitMultithreaded() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticSerializableCommitMultithreaded() throws Exception { checkCommitMultithreaded(OPTIMISTIC, SERIALIZABLE); @@ -164,6 +172,7 @@ public void testOptimisticSerializableCommitMultithreaded() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticReadCommittedRollbackMultithreaded() throws Exception { checkRollbackMultithreaded(PESSIMISTIC, READ_COMMITTED); @@ -173,6 +182,7 @@ public void testPessimisticReadCommittedRollbackMultithreaded() throws Exception /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticRepeatableReadRollbackMultithreaded() throws Exception { checkRollbackMultithreaded(PESSIMISTIC, REPEATABLE_READ); @@ -182,6 +192,7 @@ public void testPessimisticRepeatableReadRollbackMultithreaded() throws Exceptio /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticSerializableRollbackMultithreaded() throws Exception { checkRollbackMultithreaded(PESSIMISTIC, SERIALIZABLE); @@ -191,6 +202,7 @@ public void testPessimisticSerializableRollbackMultithreaded() throws Exception /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticReadCommittedRollbackMultithreaded() throws Exception { checkRollbackMultithreaded(OPTIMISTIC, READ_COMMITTED); @@ -200,6 +212,7 @@ public void testOptimisticReadCommittedRollbackMultithreaded() throws Exception /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticRepeatableReadRollbackMultithreaded() throws Exception { checkRollbackMultithreaded(OPTIMISTIC, REPEATABLE_READ); @@ -209,6 +222,7 @@ public void testOptimisticRepeatableReadRollbackMultithreaded() throws Exception /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticSerializableRollbackMultithreaded() throws Exception { checkRollbackMultithreaded(OPTIMISTIC, SERIALIZABLE); @@ -218,6 +232,7 @@ public void testOptimisticSerializableRollbackMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableConsistency() throws Exception { final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxReentryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxReentryAbstractSelfTest.java index 39066a24a24b2..a2e9fc7cc02bd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxReentryAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxReentryAbstractSelfTest.java @@ -34,11 +34,11 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -47,10 +47,8 @@ /** * Tests reentry in pessimistic repeatable read tx. */ +@RunWith(JUnit4.class) public abstract class IgniteTxReentryAbstractSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** @return Cache mode. */ protected abstract CacheMode cacheMode(); @@ -76,12 +74,7 @@ public abstract class IgniteTxReentryAbstractSelfTest extends GridCommonAbstract @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - cfg.setCommunicationSpi(new CountingCommunicationSpi()); - cfg.setDiscoverySpi(discoSpi); CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -98,6 +91,7 @@ public abstract class IgniteTxReentryAbstractSelfTest extends GridCommonAbstract } /** @throws Exception If failed. */ + @Test public void testLockReentry() throws Exception { startGridsMultiThreaded(gridCount(), true); @@ -180,4 +174,4 @@ public int dhtLocks() { return dhtLocks.get(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxSingleThreadedAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxSingleThreadedAbstractTest.java index f7034d1736076..72ccb7b66d9f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxSingleThreadedAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxSingleThreadedAbstractTest.java @@ -18,6 +18,9 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.IgniteCheckedException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -28,11 +31,12 @@ /** * Tests for local transactions. */ -@SuppressWarnings( {"BusyWait"}) +@RunWith(JUnit4.class) public abstract class IgniteTxSingleThreadedAbstractTest extends IgniteTxAbstractTest { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticReadCommittedCommit() throws Exception { checkCommit(PESSIMISTIC, READ_COMMITTED); @@ -42,6 +46,7 @@ public void testPessimisticReadCommittedCommit() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticRepeatableReadCommit() throws Exception { checkCommit(PESSIMISTIC, REPEATABLE_READ); @@ -51,6 +56,7 @@ public void testPessimisticRepeatableReadCommit() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticSerializableCommit() throws Exception { checkCommit(PESSIMISTIC, SERIALIZABLE); @@ -60,6 +66,7 @@ public void testPessimisticSerializableCommit() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticReadCommittedCommit() throws Exception { checkCommit(OPTIMISTIC, READ_COMMITTED); @@ -69,6 +76,7 @@ public void testOptimisticReadCommittedCommit() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticRepeatableReadCommit() throws Exception { checkCommit(OPTIMISTIC, REPEATABLE_READ); @@ -78,6 +86,7 @@ public void testOptimisticRepeatableReadCommit() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticSerializableCommit() throws Exception { checkCommit(OPTIMISTIC, SERIALIZABLE); @@ -87,6 +96,7 @@ public void testOptimisticSerializableCommit() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticReadCommittedRollback() throws Exception { checkRollback(PESSIMISTIC, READ_COMMITTED); @@ -96,6 +106,7 @@ public void testPessimisticReadCommittedRollback() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticRepeatableReadRollback() throws Exception { checkRollback(PESSIMISTIC, REPEATABLE_READ); @@ -105,6 +116,7 @@ public void testPessimisticRepeatableReadRollback() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticSerializableRollback() throws Exception { checkRollback(PESSIMISTIC, SERIALIZABLE); @@ -114,6 +126,7 @@ public void testPessimisticSerializableRollback() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticReadCommittedRollback() throws Exception { checkRollback(OPTIMISTIC, READ_COMMITTED); @@ -123,6 +136,7 @@ public void testOptimisticReadCommittedRollback() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticRepeatableReadRollback() throws Exception { checkRollback(OPTIMISTIC, REPEATABLE_READ); @@ -132,9 +146,10 @@ public void testOptimisticRepeatableReadRollback() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticSerializableRollback() throws Exception { checkRollback(OPTIMISTIC, SERIALIZABLE); finalChecks(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java index 863ab38ad74ea..54218d5b881c1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java @@ -37,11 +37,15 @@ import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionRollbackException; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -49,6 +53,7 @@ /** * Tests that transaction is invalidated in case of {@link IgniteTxHeuristicCheckedException}. */ +@RunWith(JUnit4.class) public abstract class IgniteTxStoreExceptionAbstractSelfTest extends GridCacheAbstractSelfTest { /** Index SPI throwing exception. */ private static TestStore store; @@ -94,6 +99,8 @@ public abstract class IgniteTxStoreExceptionAbstractSelfTest extends GridCacheAb /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + store = new TestStore(); super.beforeTestsStarted(); @@ -118,6 +125,7 @@ public abstract class IgniteTxStoreExceptionAbstractSelfTest extends GridCacheAb /** * @throws Exception If failed. */ + @Test public void testPutNear() throws Exception { checkPut(true, keyForNode(grid(0).localNode(), NOT_PRIMARY_AND_BACKUP)); @@ -127,6 +135,7 @@ public void testPutNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutPrimary() throws Exception { checkPut(true, keyForNode(grid(0).localNode(), PRIMARY)); @@ -136,6 +145,7 @@ public void testPutPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutBackup() throws Exception { checkPut(true, keyForNode(grid(0).localNode(), BACKUP)); @@ -145,6 +155,7 @@ public void testPutBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAll() throws Exception { checkPutAll(true, keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY), @@ -168,6 +179,7 @@ public void testPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveNear() throws Exception { checkRemove(false, keyForNode(grid(0).localNode(), NOT_PRIMARY_AND_BACKUP)); @@ -177,6 +189,7 @@ public void testRemoveNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemovePrimary() throws Exception { checkRemove(false, keyForNode(grid(0).localNode(), PRIMARY)); @@ -186,6 +199,7 @@ public void testRemovePrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveBackup() throws Exception { checkRemove(false, keyForNode(grid(0).localNode(), BACKUP)); @@ -195,6 +209,7 @@ public void testRemoveBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformNear() throws Exception { checkTransform(false, keyForNode(grid(0).localNode(), NOT_PRIMARY_AND_BACKUP)); @@ -204,6 +219,7 @@ public void testTransformNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPrimary() throws Exception { checkTransform(false, keyForNode(grid(0).localNode(), PRIMARY)); @@ -213,6 +229,7 @@ public void testTransformPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformBackup() throws Exception { checkTransform(false, keyForNode(grid(0).localNode(), BACKUP)); @@ -222,6 +239,7 @@ public void testTransformBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutNearTx() throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { @@ -235,6 +253,7 @@ public void testPutNearTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutPrimaryTx() throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { @@ -248,6 +267,7 @@ public void testPutPrimaryTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutBackupTx() throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { @@ -261,6 +281,7 @@ public void testPutBackupTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutMultipleKeysTx() throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { @@ -672,4 +693,4 @@ public void forceFail(boolean fail) { throw new CacheWriterException("Store exception"); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/InterceptorCacheConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/InterceptorCacheConfigVariationsFullApiTest.java index b6f5333e04806..a323067fcfb00 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/InterceptorCacheConfigVariationsFullApiTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/InterceptorCacheConfigVariationsFullApiTest.java @@ -23,11 +23,15 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.lang.IgniteBiTuple; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Full API cache test. */ -@SuppressWarnings({"TransientFieldInNonSerializableClass", "unchecked"}) +@SuppressWarnings({"unchecked"}) +@RunWith(JUnit4.class) public class InterceptorCacheConfigVariationsFullApiTest extends IgniteCacheConfigVariationsFullApiTest { /** */ private static volatile boolean validate = true; @@ -42,16 +46,19 @@ public class InterceptorCacheConfigVariationsFullApiTest extends IgniteCacheConf } /** {@inheritDoc} */ + @Test @Override public void testTtlNoTx() throws Exception { // No-op. } /** {@inheritDoc} */ + @Test @Override public void testTtlNoTxOldEntry() throws Exception { // No-op. } /** {@inheritDoc} */ + @Test @Override public void testTtlTx() throws Exception { // No-op. } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java index 2ebc232c922df..cef26366d82cc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java @@ -25,19 +25,17 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -45,8 +43,6 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -55,6 +51,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testJobRun() throws Exception { for (int i = 0; i < 5; i++) { U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java index 6dec847954f82..c73f6d6299d7f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.configuration.MemoryConfiguration; import org.apache.ignite.configuration.MemoryPolicyConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest { /** */ private static final String VALID_DEFAULT_MEM_PLC_NAME = "valid_dlft_mem_plc"; @@ -240,6 +244,7 @@ private MemoryPolicyConfiguration createMemoryPolicy(String name, long initialSi /** * 'sysMemPlc' name is reserved for MemoryPolicyConfiguration for system caches. */ + @Test public void testReservedMemoryPolicyMisuse() throws Exception { violationType = ValidationViolationType.SYSTEM_MEMORY_POLICY_NAME_MISUSE; @@ -249,6 +254,7 @@ public void testReservedMemoryPolicyMisuse() throws Exception { /** * If user defines default is must be presented among configured memory policies. */ + @Test public void testMissingUserDefinedDefault() throws Exception { violationType = ValidationViolationType.MISSING_USER_DEFINED_DEFAULT; @@ -258,6 +264,7 @@ public void testMissingUserDefinedDefault() throws Exception { /** * Names of all MemoryPolicies must be distinct. */ + @Test public void testNamesConflict() throws Exception { violationType = ValidationViolationType.NAMES_CONFLICT; @@ -267,6 +274,7 @@ public void testNamesConflict() throws Exception { /** * User-defined policy must have a non-null non-empty name. */ + @Test public void testNullNameOnUserDefinedPolicy() throws Exception { violationType = ValidationViolationType.NULL_NAME_ON_USER_DEFINED_POLICY; @@ -276,6 +284,7 @@ public void testNullNameOnUserDefinedPolicy() throws Exception { /** * MemoryPolicy must be configured with size of at least 1MB. */ + @Test public void testMemoryTooSmall() throws Exception { violationType = ValidationViolationType.TOO_SMALL_MEMORY_SIZE; @@ -285,6 +294,7 @@ public void testMemoryTooSmall() throws Exception { /** * MemoryPolicy must be configured with size of at least 1MB. */ + @Test public void testMaxSizeSmallerThanInitialSize() throws Exception { violationType = ValidationViolationType.MAX_SIZE_IS_SMALLER_THAN_INITIAL_SIZE; @@ -294,6 +304,7 @@ public void testMaxSizeSmallerThanInitialSize() throws Exception { /** * User-defined size of default MemoryPolicy must be at least 1MB. */ + @Test public void testUserDefinedDefaultMemoryTooSmall() throws Exception { violationType = ValidationViolationType.TOO_SMALL_USER_DEFINED_DFLT_MEM_PLC_SIZE; @@ -304,6 +315,7 @@ public void testUserDefinedDefaultMemoryTooSmall() throws Exception { * Defining size of default MemoryPolicy twice with and through defaultMemoryPolicySize property * and using MemoryPolicyConfiguration description is prohibited. */ + @Test public void testDefaultMemoryPolicySizeDefinedTwice() throws Exception { violationType = ValidationViolationType.DEFAULT_SIZE_IS_DEFINED_TWICE; @@ -313,6 +325,7 @@ public void testDefaultMemoryPolicySizeDefinedTwice() throws Exception { /** * */ + @Test public void testRateTimeIntervalPropertyIsNegative() throws Exception { violationType = ValidationViolationType.LTE_ZERO_RATE_TIME_INTERVAL; @@ -322,6 +335,7 @@ public void testRateTimeIntervalPropertyIsNegative() throws Exception { /** * */ + @Test public void testSubIntervalsPropertyIsNegative() throws Exception { violationType = ValidationViolationType.LTE_ZERO_SUB_INTERVALS; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MvccCacheGroupMetricsMBeanTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MvccCacheGroupMetricsMBeanTest.java new file mode 100644 index 0000000000000..2642eb5925c97 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MvccCacheGroupMetricsMBeanTest.java @@ -0,0 +1,29 @@ +/* + * 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. + */ +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.cache.CacheAtomicityMode; + +/** + * + */ +public class MvccCacheGroupMetricsMBeanTest extends CacheGroupMetricsMBeanTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/NonAffinityCoordinatorDynamicStartStopTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/NonAffinityCoordinatorDynamicStartStopTest.java index f88f5b95d600c..300763bfcb8ac 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/NonAffinityCoordinatorDynamicStartStopTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/NonAffinityCoordinatorDynamicStartStopTest.java @@ -27,18 +27,16 @@ import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class NonAffinityCoordinatorDynamicStartStopTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String TEST_ATTRIBUTE = "test-attribute"; @@ -56,9 +54,6 @@ public class NonAffinityCoordinatorDynamicStartStopTest extends GridCommonAbstra @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - discoverySpi.setIpFinder(ipFinder); - DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration( new DataRegionConfiguration().setMaxSize(200L * 1024 * 1024)); @@ -98,6 +93,7 @@ public class NonAffinityCoordinatorDynamicStartStopTest extends GridCommonAbstra /** * @throws Exception If failed. */ + @Test public void testStartStop() throws Exception { startGrids(2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheMetricsForClusterGroupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheMetricsForClusterGroupSelfTest.java index 9ff6db7c2a5ee..81ac4c2b21da2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheMetricsForClusterGroupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheMetricsForClusterGroupSelfTest.java @@ -17,20 +17,25 @@ package org.apache.ignite.internal.processors.cache; +import java.util.concurrent.CountDownLatch; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.Event; import org.apache.ignite.events.EventType; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import java.util.concurrent.CountDownLatch; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED; /** * Test for cluster wide offheap cache metrics. */ +@RunWith(JUnit4.class) public class OffheapCacheMetricsForClusterGroupSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 3; @@ -63,6 +68,8 @@ public class OffheapCacheMetricsForClusterGroupSelfTest extends GridCommonAbstra startGrid("client-" + i); } + /** */ + @Test public void testGetOffHeapPrimaryEntriesCount() throws Exception { String cacheName = "testGetOffHeapPrimaryEntriesCount"; IgniteCache cache = grid("client-0").createCache(cacheConfiguration(cacheName)); @@ -140,11 +147,16 @@ private void assertGetOffHeapPrimaryEntriesCount(String cacheName, int count) th } } + /** + * @param cacheName Cache name. + * @return Cache configuration. + */ private static CacheConfiguration cacheConfiguration(String cacheName) { CacheConfiguration cfg = new CacheConfiguration<>(cacheName); cfg.setBackups(1); cfg.setStatisticsEnabled(true); + cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); return cfg; } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedAtomicCacheGetsDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedAtomicCacheGetsDistributionTest.java index 2241a956e0908..963ccc81d02c8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedAtomicCacheGetsDistributionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedAtomicCacheGetsDistributionTest.java @@ -17,33 +17,23 @@ package org.apache.ignite.internal.processors.cache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.CacheConfiguration; +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Tests of partitioned atomic cache's 'get' requests distribution. */ -public class PartitionedAtomicCacheGetsDistributionTest extends ReplicatedAtomicCacheGetsDistributionTest { +public class PartitionedAtomicCacheGetsDistributionTest extends CacheGetsDistributionAbstractTest { /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return PARTITIONED; + @Override protected CacheAtomicityMode atomicityMode() { + return ATOMIC; } /** {@inheritDoc} */ - @Override protected CacheConfiguration cacheConfiguration() { - CacheConfiguration cacheCfg = super.cacheConfiguration(); - - cacheCfg.setBackups(backupsCount()); - - return cacheCfg; - } - - /** - * @return Backups count. - */ - protected int backupsCount() { - return gridCount() - 1; + @Override protected CacheMode cacheMode() { + return PARTITIONED; } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedMvccTxPessimisticCacheGetsDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedMvccTxPessimisticCacheGetsDistributionTest.java new file mode 100644 index 0000000000000..de9d9a658afc6 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedMvccTxPessimisticCacheGetsDistributionTest.java @@ -0,0 +1,32 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.transactions.TransactionIsolation; + +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Tests of pessimistic transactional partitioned cache's 'get' requests distribution. + */ +public class PartitionedMvccTxPessimisticCacheGetsDistributionTest extends PartitionedTransactionalPessimisticCacheGetsDistributionTest { + /** {@inheritDoc} */ + @Override protected TransactionIsolation transactionIsolation() { + return REPEATABLE_READ; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedTransactionalOptimisticCacheGetsDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedTransactionalOptimisticCacheGetsDistributionTest.java index 4c882294f89eb..e518e32ef5340 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedTransactionalOptimisticCacheGetsDistributionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedTransactionalOptimisticCacheGetsDistributionTest.java @@ -18,29 +18,36 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; /** * Tests of optimistic transactional partitioned cache's 'get' requests distribution. */ -public class PartitionedTransactionalOptimisticCacheGetsDistributionTest extends PartitionedAtomicCacheGetsDistributionTest { +public class PartitionedTransactionalOptimisticCacheGetsDistributionTest extends CacheGetsDistributionAbstractTest { /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return TRANSACTIONAL; + @Override protected CacheMode cacheMode() { + return PARTITIONED; } /** {@inheritDoc} */ - @Override protected TransactionIsolation transactionIsolation() { - return READ_COMMITTED; + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; } /** {@inheritDoc} */ @Override protected TransactionConcurrency transactionConcurrency() { return OPTIMISTIC; } + + /** {@inheritDoc} */ + @Override protected TransactionIsolation transactionIsolation() { + return READ_COMMITTED; + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedTransactionalPessimisticCacheGetsDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedTransactionalPessimisticCacheGetsDistributionTest.java index 78ea7a6f8d30d..ce1f7b66ceaa5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedTransactionalPessimisticCacheGetsDistributionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionedTransactionalPessimisticCacheGetsDistributionTest.java @@ -17,17 +17,37 @@ package org.apache.ignite.internal.processors.cache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; /** * Tests of pessimistic transactional partitioned cache's 'get' requests distribution. */ -public class PartitionedTransactionalPessimisticCacheGetsDistributionTest - extends PartitionedTransactionalOptimisticCacheGetsDistributionTest { +public class PartitionedTransactionalPessimisticCacheGetsDistributionTest extends CacheGetsDistributionAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return PARTITIONED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; + } + /** {@inheritDoc} */ @Override protected TransactionConcurrency transactionConcurrency() { return PESSIMISTIC; } + + /** {@inheritDoc} */ + @Override protected TransactionIsolation transactionIsolation() { + return READ_COMMITTED; + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeCoordinatorFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeCoordinatorFailoverTest.java index 1c847f9fea843..dc42b29379038 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeCoordinatorFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeCoordinatorFailoverTest.java @@ -18,45 +18,76 @@ package org.apache.ignite.internal.processors.cache; import java.util.concurrent.CountDownLatch; +import java.util.function.Function; +import java.util.function.Supplier; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteException; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.managers.communication.GridIoMessage; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.spi.IgniteSpiException; +import org.apache.ignite.spi.communication.CommunicationSpi; +import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Advanced coordinator failure scenarios during PME. */ +@RunWith(JUnit4.class) public class PartitionsExchangeCoordinatorFailoverTest extends GridCommonAbstractTest { + /** */ + private static final String CACHE_NAME = "cache"; + + /** */ + private Supplier spiFactory = TcpCommunicationSpi::new; + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setConsistentId(igniteInstanceName); - cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); - - IgnitePredicate nodeFilter = node -> node.consistentId().equals(igniteInstanceName); + cfg.setCommunicationSpi(spiFactory.get()); cfg.setCacheConfiguration( - new CacheConfiguration("cache-" + igniteInstanceName) - .setBackups(1) - .setNodeFilter(nodeFilter) - .setAffinity(new RendezvousAffinityFunction(false, 32)) + new CacheConfiguration(CACHE_NAME) + .setBackups(2) + .setAffinity(new RendezvousAffinityFunction(false, 32)) ); + // Add cache that exists only on coordinator node. + if (igniteInstanceName.equals("crd")) { + IgnitePredicate nodeFilter = node -> node.consistentId().equals(igniteInstanceName); + + cfg.setCacheConfiguration( + new CacheConfiguration(CACHE_NAME + 0) + .setBackups(2) + .setNodeFilter(nodeFilter) + .setAffinity(new RendezvousAffinityFunction(false, 32)) + ); + } + return cfg; } @@ -75,7 +106,10 @@ public class PartitionsExchangeCoordinatorFailoverTest extends GridCommonAbstrac /** * Tests that new coordinator is able to finish old exchanges in case of in-complete coordinator initialization. */ + @Test public void testNewCoordinatorCompletedExchange() throws Exception { + spiFactory = TestRecordingCommunicationSpi::new; + IgniteEx crd = (IgniteEx) startGrid("crd"); IgniteEx newCrd = startGrid(1); @@ -145,7 +179,7 @@ public void testNewCoordinatorCompletedExchange() throws Exception { // Check that all caches are operable. for (Ignite grid : G.allGrids()) { - IgniteCache cache = grid.cache("cache-" + grid.cluster().localNode().consistentId()); + IgniteCache cache = grid.cache(CACHE_NAME); Assert.assertNotNull(cache); @@ -158,7 +192,10 @@ public void testNewCoordinatorCompletedExchange() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayedFullMessageReplacedIfCoordinatorChanged() throws Exception { + spiFactory = TestRecordingCommunicationSpi::new; + IgniteEx crd = startGrid("crd"); IgniteEx newCrd = startGrid(1); @@ -192,6 +229,94 @@ public void testDelayedFullMessageReplacedIfCoordinatorChanged() throws Exceptio awaitPartitionMapExchange(); } + /** + * Test that exchange coordinator initialized correctly in case of exchanges merge and caches without affinity nodes. + * + * @throws Exception If failed. + */ + @Test + public void testCoordinatorChangeAfterExchangesMerge() throws Exception { + // Delay demand messages sending to suspend late affinity assignment. + spiFactory = () -> new DynamicDelayingCommunicationSpi(msg -> { + final int delay = 5_000; + + if (msg instanceof GridDhtPartitionDemandMessage) { + GridDhtPartitionDemandMessage demandMessage = (GridDhtPartitionDemandMessage) msg; + + if (demandMessage.groupId() == GridCacheUtils.cacheId(GridCacheUtils.UTILITY_CACHE_NAME)) + return 0; + + return delay; + } + + return 0; + }); + + final IgniteEx crd = startGrid("crd"); + + startGrid(1); + + for (int k = 0; k < 1024; k++) + crd.cache(CACHE_NAME).put(k, k); + + // Delay sending single messages to ensure exchanges are merged. + spiFactory = () -> new DynamicDelayingCommunicationSpi(msg -> { + final int delay = 1_000; + + if (msg instanceof GridDhtPartitionsSingleMessage) { + GridDhtPartitionsSingleMessage singleMsg = (GridDhtPartitionsSingleMessage) msg; + + if (singleMsg.exchangeId() != null) + return delay; + } + + return 0; + }); + + // This should trigger exchanges merge. + startGridsMultiThreaded(2, 2); + + // Delay sending single message from new node to have time to shutdown coordinator. + spiFactory = () -> new DynamicDelayingCommunicationSpi(msg -> { + final int delay = 5_000; + + if (msg instanceof GridDhtPartitionsSingleMessage) { + GridDhtPartitionsSingleMessage singleMsg = (GridDhtPartitionsSingleMessage) msg; + + if (singleMsg.exchangeId() != null) + return delay; + } + + return 0; + }); + + // Trigger next exchange. + IgniteInternalFuture startNodeFut = GridTestUtils.runAsync(() -> startGrid(4)); + + // Wait till other nodes will send their messages to coordinator. + U.sleep(2_500); + + // And then stop coordinator node. + stopGrid("crd", true); + + startNodeFut.get(); + + awaitPartitionMapExchange(); + + // Check that all caches are operable. + for (Ignite grid : G.allGrids()) { + IgniteCache cache = grid.cache(CACHE_NAME); + + Assert.assertNotNull(cache); + + for (int k = 0; k < 1024; k++) + Assert.assertEquals(k, cache.get(k)); + + for (int k = 0; k < 1024; k++) + cache.put(k, k); + } + } + /** * Blocks sending full message from coordinator to non-coordinator node. * @param from Coordinator node. @@ -216,4 +341,45 @@ private void blockSendingFullMessage(IgniteEx from, IgniteEx to) { return false; }); } + + /** + * Communication SPI that allows to delay sending message by predicate. + */ + class DynamicDelayingCommunicationSpi extends TcpCommunicationSpi { + /** Function that returns delay in milliseconds for given message. */ + private final Function delayMessageFunc; + + /** */ + DynamicDelayingCommunicationSpi() { + this(msg -> 0); + } + + /** + * @param delayMessageFunc Function to calculate delay for message. + */ + DynamicDelayingCommunicationSpi(final Function delayMessageFunc) { + this.delayMessageFunc = delayMessageFunc; + } + + /** {@inheritDoc} */ + @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure ackC) + throws IgniteSpiException { + try { + GridIoMessage ioMsg = (GridIoMessage)msg; + + int delay = delayMessageFunc.apply(ioMsg.message()); + + if (delay > 0) { + log.warning(String.format("Delay sending %s to %s", msg, node)); + + U.sleep(delay); + } + } + catch (IgniteInterruptedCheckedException e) { + throw new IgniteSpiException(e); + } + + super.sendMessage(node, msg, ackC); + } + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeOnDiscoveryHistoryOverflowTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeOnDiscoveryHistoryOverflowTest.java index c0896c87a0c4f..1a3909091e6dd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeOnDiscoveryHistoryOverflowTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/PartitionsExchangeOnDiscoveryHistoryOverflowTest.java @@ -32,6 +32,9 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCOVERY_HISTORY_SIZE; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -44,6 +47,7 @@ /** * Test discovery history overflow. */ +@RunWith(JUnit4.class) public class PartitionsExchangeOnDiscoveryHistoryOverflowTest extends IgniteCacheAbstractTest { /** */ private static final int CACHES_COUNT = 30; @@ -121,6 +125,7 @@ public class PartitionsExchangeOnDiscoveryHistoryOverflowTest extends IgniteCach /** * @throws Exception In case of error. */ + @Test public void testDynamicCacheCreation() throws Exception { for (int iter = 0; iter < 5; iter++) { log.info("Iteration: " + iter); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedAtomicCacheGetsDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedAtomicCacheGetsDistributionTest.java index 1aaea761d084a..ef90408e4a20a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedAtomicCacheGetsDistributionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedAtomicCacheGetsDistributionTest.java @@ -17,350 +17,23 @@ package org.apache.ignite.internal.processors.cache; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.UUID; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.TransactionConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.util.lang.GridAbsPredicate; -import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.transactions.Transaction; -import org.apache.ignite.transactions.TransactionConcurrency; -import org.apache.ignite.transactions.TransactionIsolation; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.REPLICATED; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS; -import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; -import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** * Tests of replicated cache's 'get' requests distribution. */ -public class ReplicatedAtomicCacheGetsDistributionTest extends GridCacheAbstractSelfTest { - /** Cache name. */ - private static final String CACHE_NAME = "getsDistributionTest"; - - /** Client nodes instance's name. */ - private static final String CLIENT_NAME = "client"; - - /** Value prefix. */ - private static final String VAL_PREFIX = "val"; - - /** */ - private static final int PRIMARY_KEYS_NUMBER = 1_000; - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - super.beforeTestsStarted(); - - IgniteConfiguration clientCfg = getConfiguration(CLIENT_NAME); - - clientCfg.setClientMode(true); - - startGrid(clientCfg); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); - - IgniteCache cache = ignite(0).cache(CACHE_NAME); - - if (cache != null) - cache.destroy(); - - // Setting different MAC addresses for all nodes - Map macs = getClusterMacs(); - - int idx = 0; - - for (Map.Entry entry : macs.entrySet()) - entry.setValue("x2-xx-xx-xx-xx-x" + idx++); - - replaceMacAddresses(G.allGrids(), macs); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setTransactionConfiguration(transactionConfiguration()); - - return cfg; - } - +public class ReplicatedAtomicCacheGetsDistributionTest extends CacheGetsDistributionAbstractTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return ATOMIC; } /** {@inheritDoc} */ - @Override protected int gridCount() { - return 4; - } - - /** - * Test 'get' operations requests generator distribution. - * - * @throws Exception In case of an error. - * @see #runTestBalancingDistribution(boolean) - */ - public void testGetRequestsGeneratorDistribution() throws Exception { - runTestBalancingDistribution(false); - } - - /** - * Test 'getAll' operations requests generator distribution. - * - * @throws Exception In case of an error. - * @see #runTestBalancingDistribution(boolean) - */ - public void testGetAllRequestsGeneratorDistribution() throws Exception { - runTestBalancingDistribution(true); - } - - /** - * @param batchMode Whenever 'get' or 'getAll' operations are used in the test. - * @throws Exception In case of an error. - */ - protected void runTestBalancingDistribution(boolean batchMode) throws Exception { - IgniteCache cache = grid(0).createCache(cacheConfiguration()); - - List keys = primaryKeys(cache, PRIMARY_KEYS_NUMBER); - - for (Integer key : keys) - cache.put(key, VAL_PREFIX + key); - - IgniteCache clientCache = grid(CLIENT_NAME).getOrCreateCache(CACHE_NAME) - .withAllowAtomicOpsInTx(); - - assertTrue(GridTestUtils.waitForCondition( - new GridAbsPredicate() { - int batchSize = 10; - int idx = 0; - - @Override public boolean apply() { - if (idx >= PRIMARY_KEYS_NUMBER) - idx = 0; - - try (Transaction tx = grid(CLIENT_NAME).transactions().txStart()) { - if (batchMode) { - Set keys0 = new TreeSet<>(); - - for (int i = idx; i < idx + batchSize && i < PRIMARY_KEYS_NUMBER; i++) - keys0.add(keys.get(i)); - - idx += batchSize; - - Map results = clientCache.getAll(keys0); - - for (Map.Entry entry : results.entrySet()) - assertEquals(VAL_PREFIX + entry.getKey(), entry.getValue()); - } - else { - for (int i = idx; i < idx + gridCount() && i < PRIMARY_KEYS_NUMBER; i++) { - Integer key = keys.get(i); - - assertEquals(VAL_PREFIX + key, clientCache.get(key)); - } - - idx += gridCount(); - } - - tx.commit(); - } - - for (int i = 0; i < gridCount(); i++) { - IgniteEx ignite = grid(i); - - long getsCnt = ignite.cache(CACHE_NAME).localMetrics().getCacheGets(); - - if (getsCnt == 0) - return false; - } - - return true; - } - }, - getTestTimeout()) - ); - } - - /** - * Tests that the 'get' operation requests are routed to node with same MAC address as at requester. - * - * @throws Exception In case of an error. - * @see #runTestSameHostDistribution(UUID, boolean) - */ - public void testGetRequestsDistribution() throws Exception { - UUID destId = grid(0).localNode().id(); - - runTestSameHostDistribution(destId, false); - } - - /** - * Tests that the 'getAll' operation requests are routed to node with same MAC address as at requester. - * - * @throws Exception In case of an error. - * @see #runTestSameHostDistribution(UUID, boolean) - */ - public void testGetAllRequestsDistribution() throws Exception { - UUID destId = grid(gridCount() - 1).localNode().id(); - - runTestSameHostDistribution(destId, true); - } - - /** - * Tests that the 'get' and 'getAll' requests are routed to node with same MAC address as at requester. - * - * @param destId Destination Ignite instance id for requests distribution. - * @param batchMode Test mode. - * @throws Exception In case of an error. - */ - protected void runTestSameHostDistribution(final UUID destId, final boolean batchMode) throws Exception { - Map macs = getClusterMacs(); - - String clientMac = macs.get(grid(CLIENT_NAME).localNode().id()); - - macs.put(destId, clientMac); - - replaceMacAddresses(G.allGrids(), macs); - - IgniteCache cache = grid(0).createCache(cacheConfiguration()); - - List keys = primaryKeys(cache, PRIMARY_KEYS_NUMBER); - - for (Integer key : keys) - cache.put(key, VAL_PREFIX + key); - - IgniteCache clientCache = grid(CLIENT_NAME).getOrCreateCache(CACHE_NAME) - .withAllowAtomicOpsInTx(); - - try (Transaction tx = grid(CLIENT_NAME).transactions().txStart()) { - if (batchMode) { - Map results = clientCache.getAll(new TreeSet<>(keys)); - - for (Map.Entry entry : results.entrySet()) - assertEquals(VAL_PREFIX + entry.getKey(), entry.getValue()); - } - else { - for (Integer key : keys) - assertEquals(VAL_PREFIX + key, clientCache.get(key)); - } - - tx.commit(); - } - - for (int i = 0; i < gridCount(); i++) { - IgniteEx ignite = grid(i); - - long getsCnt = ignite.cache(CACHE_NAME).localMetrics().getCacheGets(); - - if (destId.equals(ignite.localNode().id())) - assertEquals(PRIMARY_KEYS_NUMBER, getsCnt); - else - assertEquals(0L, getsCnt); - } - } - - /** - * @return Transaction configuration. - */ - protected TransactionConfiguration transactionConfiguration() { - TransactionConfiguration txCfg = new TransactionConfiguration(); - - txCfg.setDefaultTxIsolation(transactionIsolation()); - txCfg.setDefaultTxConcurrency(transactionConcurrency()); - - return txCfg; - } - - /** - * @return Cache transaction isolation. - */ - protected TransactionIsolation transactionIsolation() { - return REPEATABLE_READ; - } - - /** - * @return Cache transaction concurrency. - */ - protected TransactionConcurrency transactionConcurrency() { - return PESSIMISTIC; - } - - /** - * @return Caching mode. - */ @Override protected CacheMode cacheMode() { return REPLICATED; } - - /** - * @return Cache configuration. - */ - protected CacheConfiguration cacheConfiguration() { - CacheConfiguration cfg = new CacheConfiguration(CACHE_NAME); - - cfg.setCacheMode(cacheMode()); - cfg.setAtomicityMode(atomicityMode()); - cfg.setWriteSynchronizationMode(FULL_SYNC); - cfg.setReadFromBackup(true); - cfg.setStatisticsEnabled(true); - - return cfg; - } - - /** - * @param instances Started Ignite instances. - * @param macs Mapping MAC addresses to UUID. - */ - private void replaceMacAddresses(List instances, Map macs) { - for (Ignite ignite : instances) { - for (ClusterNode node : ignite.cluster().nodes()) { - String mac = macs.get(node.id()); - - assertNotNull(mac); - - Map attrs = new HashMap<>(node.attributes()); - - attrs.put(ATTR_MACS, mac); - - ((TcpDiscoveryNode)node).setAttributes(attrs); - } - } - } - - /** - * @return Cluster nodes MAC addresses. - */ - private Map getClusterMacs() { - Map macs = new HashMap<>(); - - for (Ignite ignite : G.allGrids()) { - ClusterNode node = ignite.cluster().localNode(); - - String mac = node.attribute(ATTR_MACS); - - assert mac != null; - - macs.put(node.id(), mac); - } - - return macs; - } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedMvccTxPessimisticCacheGetsDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedMvccTxPessimisticCacheGetsDistributionTest.java new file mode 100644 index 0000000000000..6e2d67c3137d7 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedMvccTxPessimisticCacheGetsDistributionTest.java @@ -0,0 +1,32 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.transactions.TransactionIsolation; + +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Tests of pessimistic transactional replicated cache's 'get' requests distribution. + */ +public class ReplicatedMvccTxPessimisticCacheGetsDistributionTest extends ReplicatedTransactionalPessimisticCacheGetsDistributionTest { + /** {@inheritDoc} */ + @Override protected TransactionIsolation transactionIsolation() { + return REPEATABLE_READ; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedTransactionalOptimisticCacheGetsDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedTransactionalOptimisticCacheGetsDistributionTest.java index 3bc680972c050..4744f0a1eaba2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedTransactionalOptimisticCacheGetsDistributionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedTransactionalOptimisticCacheGetsDistributionTest.java @@ -18,17 +18,24 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; /** * Tests of optimistic transactional replicated cache's 'get' requests distribution. */ -public class ReplicatedTransactionalOptimisticCacheGetsDistributionTest extends ReplicatedAtomicCacheGetsDistributionTest { +public class ReplicatedTransactionalOptimisticCacheGetsDistributionTest extends CacheGetsDistributionAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return REPLICATED; + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedTransactionalPessimisticCacheGetsDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedTransactionalPessimisticCacheGetsDistributionTest.java index 7bace3c74fddc..2648851d426be 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedTransactionalPessimisticCacheGetsDistributionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/ReplicatedTransactionalPessimisticCacheGetsDistributionTest.java @@ -17,17 +17,37 @@ package org.apache.ignite.internal.processors.cache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; /** * Tests of pessimistic transactional replicated cache's 'get' requests distribution. */ -public class ReplicatedTransactionalPessimisticCacheGetsDistributionTest - extends ReplicatedTransactionalOptimisticCacheGetsDistributionTest { +public class ReplicatedTransactionalPessimisticCacheGetsDistributionTest extends CacheGetsDistributionAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return REPLICATED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; + } + /** {@inheritDoc} */ @Override protected TransactionConcurrency transactionConcurrency() { return PESSIMISTIC; } + + /** {@inheritDoc} */ + @Override protected TransactionIsolation transactionIsolation() { + return READ_COMMITTED; + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/SetTxTimeoutOnPartitionMapExchangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/SetTxTimeoutOnPartitionMapExchangeTest.java index c9ae34fcc18cd..dc9fa97f1d69c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/SetTxTimeoutOnPartitionMapExchangeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/SetTxTimeoutOnPartitionMapExchangeTest.java @@ -30,7 +30,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; @@ -41,14 +40,14 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.mxbean.TransactionsMXBean; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionRollbackException; import org.apache.ignite.transactions.TransactionTimeoutException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.util.typedef.X.hasCause; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -57,10 +56,8 @@ /** * */ +@RunWith(JUnit4.class) public class SetTxTimeoutOnPartitionMapExchangeTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Wait condition timeout. */ private static final long WAIT_CONDITION_TIMEOUT = 10_000L; @@ -71,19 +68,10 @@ public class SetTxTimeoutOnPartitionMapExchangeTest extends GridCommonAbstractTe stopAllGrids(); } - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** * */ + @Test public void testDefaultTxTimeoutOnPartitionMapExchange() throws Exception { IgniteEx ig1 = startGrid(1); IgniteEx ig2 = startGrid(2); @@ -100,6 +88,7 @@ public void testDefaultTxTimeoutOnPartitionMapExchange() throws Exception { /** * */ + @Test public void testJmxSetTxTimeoutOnPartitionMapExchange() throws Exception { startGrid(1); startGrid(2); @@ -122,6 +111,7 @@ public void testJmxSetTxTimeoutOnPartitionMapExchange() throws Exception { /** * */ + @Test public void testClusterSetTxTimeoutOnPartitionMapExchange() throws Exception { Ignite ig1 = startGrid(1); Ignite ig2 = startGrid(2); @@ -141,6 +131,7 @@ public void testClusterSetTxTimeoutOnPartitionMapExchange() throws Exception { * * @throws Exception If fails. */ + @Test public void testSetTxTimeoutDuringPartitionMapExchange() throws Exception { IgniteEx ig = (IgniteEx) startGrids(2); @@ -152,6 +143,7 @@ public void testSetTxTimeoutDuringPartitionMapExchange() throws Exception { * * @throws Exception If fails. */ + @Test public void testSetTxTimeoutOnClientDuringPartitionMapExchange() throws Exception { IgniteEx ig = (IgniteEx) startGrids(2); IgniteEx client = startGrid(getConfiguration("client").setClientMode(true)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeAbstractSelfTest.java index 15376411d9afb..9bc1347d562db 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeAbstractSelfTest.java @@ -17,16 +17,20 @@ package org.apache.ignite.internal.processors.cache; +import java.util.concurrent.Callable; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.lang.IgniteInClosureX; import org.apache.ignite.internal.util.typedef.internal.U; - -import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -38,6 +42,7 @@ * Test dynamic WAL mode change. */ +@RunWith(JUnit4.class) public abstract class WalModeChangeAbstractSelfTest extends WalModeChangeCommonAbstractSelfTest { /** Whether coordinator node should be filtered out. */ private final boolean filterOnCrd; @@ -72,6 +77,7 @@ protected WalModeChangeAbstractSelfTest(boolean filterOnCrd, boolean jdbc) { * * @throws Exception If failed. */ + @Test public void testNullCacheName() throws Exception { forAllNodes(new IgniteInClosureX() { @Override public void applyx(Ignite ignite) throws IgniteCheckedException { @@ -91,6 +97,7 @@ public void testNullCacheName() throws Exception { * * @throws Exception If failed. */ + @Test public void testNoCache() throws Exception { forAllNodes(new IgniteInClosureX() { @Override public void applyx(Ignite ignite) throws IgniteCheckedException { @@ -111,6 +118,7 @@ public void testNoCache() throws Exception { * * @throws Exception If failed. */ + @Test public void testSharedCacheGroup() throws Exception { forAllNodes(new IgniteInClosureX() { @Override public void applyx(Ignite ignite) throws IgniteCheckedException { @@ -146,6 +154,7 @@ public void testSharedCacheGroup() throws Exception { * * @throws Exception If failed. */ + @Test public void testPersistenceDisabled() throws Exception { forAllNodes(new IgniteInClosureX() { @Override public void applyx(Ignite ignite) throws IgniteCheckedException { @@ -182,11 +191,14 @@ public void testPersistenceDisabled() throws Exception { * * @throws Exception If failed. */ + @Test public void testLocalCache() throws Exception { if (jdbc) // Doesn't make sense for JDBC. return; + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + forAllNodes(new IgniteInClosureX() { @Override public void applyx(Ignite ignite) throws IgniteCheckedException { createCache(ignite, cacheConfig(LOCAL).setDataRegionName(REGION_VOLATILE)); @@ -217,6 +229,7 @@ public void testLocalCache() throws Exception { * * @throws Exception If failed. */ + @Test public void testEnableDisablePartitionedAtomic() throws Exception { checkEnableDisable(PARTITIONED, ATOMIC); } @@ -226,6 +239,7 @@ public void testEnableDisablePartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testEnableDisablePartitionedTransactional() throws Exception { checkEnableDisable(PARTITIONED, TRANSACTIONAL); } @@ -235,6 +249,7 @@ public void testEnableDisablePartitionedTransactional() throws Exception { * * @throws Exception If failed. */ + @Test public void testEnableDisableReplicatedAtomic() throws Exception { checkEnableDisable(REPLICATED, ATOMIC); } @@ -244,6 +259,7 @@ public void testEnableDisableReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testEnableDisableReplicatedTransactional() throws Exception { checkEnableDisable(REPLICATED, TRANSACTIONAL); } @@ -272,4 +288,46 @@ private void checkEnableDisable(CacheMode mode, CacheAtomicityMode atomicityMode } }); } + + /** + * Test {@link WalStateManager#prohibitWALDisabling(boolean)} feature. + * + * @throws Exception If failed. + */ + @Test + public void testDisablingProhibition() throws Exception { + forAllNodes(new IgniteInClosureX() { + @Override public void applyx(Ignite ig) throws IgniteCheckedException { + assert ig instanceof IgniteEx; + + IgniteEx ignite = (IgniteEx)ig; + + createCache(ignite, cacheConfig(CACHE_NAME, PARTITIONED, TRANSACTIONAL)); + + WalStateManager stateMgr = ignite.context().cache().context().walState(); + + assertFalse(stateMgr.prohibitWALDisabling()); + + stateMgr.prohibitWALDisabling(true); + assertTrue(stateMgr.prohibitWALDisabling()); + + try { + walDisable(ignite, CACHE_NAME); + + fail(); + } + catch (Exception e) { + // No-op. + } + + stateMgr.prohibitWALDisabling(false); + assertFalse(stateMgr.prohibitWALDisabling()); + + createCache(ignite, cacheConfig(CACHE_NAME, PARTITIONED, TRANSACTIONAL)); + + assertWalDisable(ignite, CACHE_NAME, true); + assertWalEnable(ignite, CACHE_NAME, true); + } + }); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeAdvancedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeAdvancedSelfTest.java index be0f5df158761..da5196c6d796e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeAdvancedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeAdvancedSelfTest.java @@ -29,6 +29,12 @@ import org.apache.ignite.internal.IgniteClientReconnectAbstractTest; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Assume; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,6 +43,7 @@ * Concurrent and advanced tests for WAL state change. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class WalModeChangeAdvancedSelfTest extends WalModeChangeCommonAbstractSelfTest { /** * Constructor. @@ -64,6 +71,7 @@ public WalModeChangeAdvancedSelfTest() { * * @throws Exception If failed. */ + @Test public void testCacheCleanup() throws Exception { Ignite srv = startGrid(config(SRV_1, false, false)); @@ -132,7 +140,10 @@ public void testCacheCleanup() throws Exception { * * @throws Exception If failed. */ + @Test public void testJoin() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10421", MvccFeatureChecker.forcedMvcc()); + checkJoin(false); } @@ -141,6 +152,7 @@ public void testJoin() throws Exception { * * @throws Exception If failed. */ + @Test public void testJoinCoordinator() throws Exception { checkJoin(true); } @@ -209,6 +221,7 @@ private void checkJoin(boolean crdFiltered) throws Exception { * * @throws Exception If failed. */ + @Test public void testServerRestartNonCoordinator() throws Exception { checkNodeRestart(false); } @@ -218,9 +231,9 @@ public void testServerRestartNonCoordinator() throws Exception { * * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7472") + @Test public void testServerRestartCoordinator() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-7472"); - checkNodeRestart(true); } @@ -300,6 +313,7 @@ public void checkNodeRestart(boolean failCrd) throws Exception { * * @throws Exception If failed. */ + @Test public void testClientReconnect() throws Exception { final Ignite srv = startGrid(config(SRV_1, false, false)); Ignite cli = startGrid(config(CLI, true, false)); @@ -358,6 +372,7 @@ public void testClientReconnect() throws Exception { * * @throws Exception If failed. */ + @Test public void testCacheDestroy() throws Exception { final Ignite srv = startGrid(config(SRV_1, false, false)); Ignite cli = startGrid(config(CLI, true, false)); @@ -418,6 +433,7 @@ public void testCacheDestroy() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentOperations() throws Exception { final Ignite srv1 = startGrid(config(SRV_1, false, false)); final Ignite srv2 = startGrid(config(SRV_2, false, false)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeCommonAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeCommonAbstractSelfTest.java index a902bfa977ccd..944b85d97456f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeCommonAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeCommonAbstractSelfTest.java @@ -31,7 +31,6 @@ import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteClientReconnectAbstractTest; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -39,7 +38,6 @@ import org.apache.ignite.internal.util.lang.IgniteInClosureX; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -50,9 +48,6 @@ */ public abstract class WalModeChangeCommonAbstractSelfTest extends GridCommonAbstractTest { - /** Shared IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Node filter. */ private static final IgnitePredicate FILTER = new CacheNodeFilter(); @@ -303,8 +298,6 @@ protected IgniteConfiguration config(String name, boolean cli, boolean filter) t cfg.setClientMode(cli); cfg.setLocalHost("127.0.0.1"); - cfg.setDiscoverySpi(new IgniteClientReconnectAbstractTest.TestTcpDiscoverySpi().setIpFinder(IP_FINDER)); - DataRegionConfiguration regionCfg = new DataRegionConfiguration() .setPersistenceEnabled(true) .setMaxSize(DataStorageConfiguration.DFLT_DATA_REGION_INITIAL_SIZE); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WithKeepBinaryCacheFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WithKeepBinaryCacheFullApiTest.java index a8eb01d65e439..0fb737e71fdef 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WithKeepBinaryCacheFullApiTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WithKeepBinaryCacheFullApiTest.java @@ -36,6 +36,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest.DataMode.PLANE_OBJECT; @@ -45,6 +48,7 @@ * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsAbstractTest { /** */ protected static volatile boolean interceptorBinaryObjExp = true; @@ -123,6 +127,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testRemovePutGet() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -178,6 +183,7 @@ public void testRemovePutGet() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testRemovePutGetAsync() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -234,6 +240,7 @@ public void testRemovePutGetAsync() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testPutAllGetAll() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -301,6 +308,7 @@ public void testPutAllGetAll() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testPutAllGetAllAsync() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -374,6 +382,7 @@ public void testPutAllGetAllAsync() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testInvoke() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -439,6 +448,7 @@ public void testInvoke() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeTx() throws Exception { if (!txShouldBeUsed()) return; @@ -558,6 +568,7 @@ public void checkInvokeTx(final TransactionConcurrency conc, final TransactionIs * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testInvokeAsync() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -623,6 +634,7 @@ public void testInvokeAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeAsyncTx() throws Exception { if (!txShouldBeUsed()) return; @@ -744,6 +756,7 @@ public void checkInvokeAsyncTx(final TransactionConcurrency conc, final Transact * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testInvokeAll() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -795,6 +808,7 @@ public void testInvokeAll() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testInvokeAllTx() throws Exception { if (!txShouldBeUsed()) return; @@ -927,6 +941,7 @@ private void checkInvokeAllResult(IgniteCache cache, Map updatesQueue = new LinkedBlockingDeque<>(UPDATES_COUNT); - - /** */ - private static volatile BlockingDeque srvResurrectQueue = new LinkedBlockingDeque<>(1); + private static final int UPDATES_COUNT = 1_000; /** */ - private static final CountDownLatch START_LATCH = new CountDownLatch(1); + private static final int RESTART_DELAY = 1_000; /** */ - private static final CountDownLatch FINISH_LATCH_NO_CLIENTS = new CountDownLatch(5); + private static final int GRID_CNT = 5; /** */ - private static volatile AtomicBoolean stopFlag0 = new AtomicBoolean(false); + private static final String BINARY_TYPE_NAME = "TestBinaryType"; /** */ - private static volatile AtomicBoolean stopFlag1 = new AtomicBoolean(false); + private static final int BINARY_TYPE_ID = 708045005; /** */ - private static volatile AtomicBoolean stopFlag2 = new AtomicBoolean(false); + private final Queue updatesQueue = new ConcurrentLinkedQueue<>(); /** */ - private static volatile AtomicBoolean stopFlag3 = new AtomicBoolean(false); + private final List updatesList = new ArrayList<>(UPDATES_COUNT); /** */ - private static volatile AtomicBoolean stopFlag4 = new AtomicBoolean(false); + private final CountDownLatch startLatch = new CountDownLatch(1); - /** */ - private static final String BINARY_TYPE_NAME = "TestBinaryType"; - - /** */ - private static final int BINARY_TYPE_ID = 708045005; /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { for (int i = 0; i < UPDATES_COUNT; i++) { FieldType fType = null; + Object fVal = null; + switch (i % 4) { case 0: fType = FieldType.NUMBER; + fVal = getNumberFieldVal(); break; case 1: fType = FieldType.STRING; + fVal = getStringFieldVal(); break; case 2: fType = FieldType.ARRAY; + fVal = getArrayFieldVal(); break; case 3: fType = FieldType.OBJECT; + fVal = new Object(); } - updatesQueue.add(new BinaryUpdateDescription(i, "f" + (i + 1), fType)); + BinaryUpdateDescription desc = new BinaryUpdateDescription(i, "f" + (i + 1), fType, fVal); + + updatesQueue.add(desc); + updatesList.add(desc); } } @@ -144,12 +128,10 @@ public class BinaryMetadataUpdatesFlowTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - if (applyDiscoveryHook) { - final DiscoveryHook hook = discoveryHook != null ? discoveryHook : new DiscoveryHook(); - + if (discoveryHook != null) { TcpDiscoverySpi discoSpi = new TcpDiscoverySpi() { @Override public void setListener(@Nullable DiscoverySpiListener lsnr) { - super.setListener(GridTestUtils.DiscoverySpiListenerWrapper.wrap(lsnr, hook)); + super.setListener(GridTestUtils.DiscoverySpiListenerWrapper.wrap(lsnr, discoveryHook)); } }; @@ -158,11 +140,11 @@ public class BinaryMetadataUpdatesFlowTest extends GridCommonAbstractTest { cfg.setMetricsUpdateFrequency(1000); } - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(sharedStaticIpFinder); cfg.setMarshaller(new BinaryMarshaller()); - cfg.setClientMode(clientMode); + cfg.setClientMode("client".equals(gridName) || getTestIgniteInstanceIndex(gridName) >= GRID_CNT); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -181,185 +163,147 @@ public class BinaryMetadataUpdatesFlowTest extends GridCommonAbstractTest { } /** - * Starts new ignite node and submits computation job to it. - * @param idx Index. - * @param stopFlag Stop flag. - * @throws Exception If failed. + * Starts computation job. + * + * @param idx Grid index on which computation job should start. + * @param restartIdx The index of the node to be restarted. + * @param workersCntr The current number of computation threads. */ - private void startComputation(int idx, AtomicBoolean stopFlag) throws Exception { - clientMode = false; - - final IgniteEx ignite0 = startGrid(idx); + private void startComputation(int idx, AtomicInteger restartIdx, AtomicInteger workersCntr) { + Ignite ignite = grid(idx); - ClusterGroup cg = ignite0.cluster().forNodeId(ignite0.localNode().id()); + ClusterGroup cg = ignite.cluster().forLocal(); - ignite0.compute(cg).withAsync().call(new BinaryObjectAdder(ignite0, updatesQueue, 30, stopFlag)); + ignite.compute(cg).callAsync(new BinaryObjectAdder(startLatch, idx, updatesQueue, restartIdx, workersCntr)); } /** - * @param idx Index. - * @param deafClient Deaf client. - * @param observedIds Observed ids. * @throws Exception If failed. */ - private void startListening(int idx, boolean deafClient, Set observedIds) throws Exception { - clientMode = true; + @Test + public void testFlowNoConflicts() throws Exception { + startGridsMultiThreaded(GRID_CNT); - ContinuousQuery qry = new ContinuousQuery(); + doTestFlowNoConflicts(); - qry.setLocalListener(new CQListener(observedIds)); + awaitPartitionMapExchange(); - if (deafClient) { - applyDiscoveryHook = true; - discoveryHook = new DiscoveryHook() { - @Override public void handleDiscoveryMessage(DiscoverySpiCustomMessage msg) { - DiscoveryCustomMessage customMsg = msg == null ? null - : (DiscoveryCustomMessage) IgniteUtils.field(msg, "delegate"); + Ignite randomNode = G.allGrids().get(0); - if (customMsg instanceof MetadataUpdateProposedMessage) { - if (((MetadataUpdateProposedMessage) customMsg).typeId() == BINARY_TYPE_ID) - GridTestUtils.setFieldValue(customMsg, "typeId", 1); - } - else if (customMsg instanceof MetadataUpdateAcceptedMessage) { - if (((MetadataUpdateAcceptedMessage) customMsg).typeId() == BINARY_TYPE_ID) - GridTestUtils.setFieldValue(customMsg, "typeId", 1); - } - } - }; + IgniteCache cache = randomNode.cache(DEFAULT_CACHE_NAME); - IgniteEx client = startGrid(idx); + int cacheEntries = cache.size(CachePeekMode.PRIMARY); - client.cache(DEFAULT_CACHE_NAME).withKeepBinary().query(qry); - } - else { - applyDiscoveryHook = false; + assertTrue("Cache cannot contain more entries than were put in it;", cacheEntries <= UPDATES_COUNT); - IgniteEx client = startGrid(idx); + assertEquals("There are less than expected entries, data loss occurred;", UPDATES_COUNT, cacheEntries); - client.cache(DEFAULT_CACHE_NAME).withKeepBinary().query(qry); - } + validateCache(randomNode); } /** - * + * @throws Exception If failed. */ - private static class CQListener implements CacheEntryUpdatedListener { - /** */ - private final Set observedIds; - - /** - * @param observedIds - */ - CQListener(Set observedIds) { - this.observedIds = observedIds; - } - - /** {@inheritDoc} */ - @Override public void onUpdated(Iterable iterable) throws CacheEntryListenerException { - for (Object o : iterable) { - if (o instanceof CacheQueryEntryEvent) { - CacheQueryEntryEvent e = (CacheQueryEntryEvent) o; + @Test + public void testFlowNoConflictsWithClients() throws Exception { + startGridsMultiThreaded(GRID_CNT); - BinaryObjectImpl val = (BinaryObjectImpl) e.getValue(); + if (!tcpDiscovery()) + return; - Integer seqNum = val.field(SEQ_NUM_FLD); + discoveryHook = new DiscoveryHook() { + @Override public void handleDiscoveryMessage(DiscoverySpiCustomMessage msg) { + DiscoveryCustomMessage customMsg = msg == null ? null + : (DiscoveryCustomMessage) IgniteUtils.field(msg, "delegate"); - observedIds.add(seqNum); + if (customMsg instanceof MetadataUpdateProposedMessage) { + if (((MetadataUpdateProposedMessage) customMsg).typeId() == BINARY_TYPE_ID) + GridTestUtils.setFieldValue(customMsg, "typeId", 1); + } + else if (customMsg instanceof MetadataUpdateAcceptedMessage) { + if (((MetadataUpdateAcceptedMessage) customMsg).typeId() == BINARY_TYPE_ID) + GridTestUtils.setFieldValue(customMsg, "typeId", 1); } } - } - } - - /** - * @throws Exception If failed. - */ - public void testFlowNoConflicts() throws Exception { - startComputation(0, stopFlag0); + }; - startComputation(1, stopFlag1); + Ignite deafClient = startGrid(GRID_CNT); - startComputation(2, stopFlag2); + discoveryHook = null; - startComputation(3, stopFlag3); + Ignite regClient = startGrid(GRID_CNT + 1); - startComputation(4, stopFlag4); + doTestFlowNoConflicts(); - Thread killer = new Thread(new ServerNodeKiller()); - Thread resurrection = new Thread(new ServerNodeResurrection()); - killer.setName("node-killer-thread"); - killer.start(); - resurrection.setName("node-resurrection-thread"); - resurrection.start(); + awaitPartitionMapExchange(); - START_LATCH.countDown(); + validateCache(deafClient); + validateCache(regClient); + } - while (!updatesQueue.isEmpty()) - Thread.sleep(1000); - FINISH_LATCH_NO_CLIENTS.await(); + /** + * Validates that all updates are readable on the specified node. + * + * @param ignite Ignite instance. + */ + private void validateCache(Ignite ignite) { + String name = ignite.name(); - IgniteEx ignite0 = grid(0); + for (Cache.Entry entry : ignite.cache(DEFAULT_CACHE_NAME).withKeepBinary()) { + BinaryObject binObj = (BinaryObject)entry.getValue(); - IgniteCache cache0 = ignite0.cache(DEFAULT_CACHE_NAME); + Integer idx = binObj.field(SEQ_NUM_FLD); - int cacheEntries = cache0.size(CachePeekMode.PRIMARY); + BinaryUpdateDescription desc = updatesList.get(idx - 1); - assertTrue("Cache cannot contain more entries than were put in it;", cacheEntries <= UPDATES_COUNT); + Object val = binObj.field(desc.fieldName); - assertEquals("There are less than expected entries, data loss occurred;", UPDATES_COUNT, cacheEntries); + String errMsg = "Field " + desc.fieldName + " has unexpeted value (index=" + idx + ", node=" + name + ")"; - killer.interrupt(); - resurrection.interrupt(); + if (desc.fieldType == FieldType.OBJECT) + assertTrue(errMsg, val instanceof BinaryObject); + else if (desc.fieldType == FieldType.ARRAY) + assertArrayEquals(errMsg, (byte[])desc.val, (byte[])val); + else + assertEquals(errMsg, desc.val, binObj.field(desc.fieldName)); + } } /** * @throws Exception If failed. */ - public void testFlowNoConflictsWithClients() throws Exception { - startComputation(0, stopFlag0); - - if (!tcpDiscovery()) - return; - - startComputation(1, stopFlag1); - - startComputation(2, stopFlag2); - - startComputation(3, stopFlag3); - - startComputation(4, stopFlag4); - - final Set deafClientObservedIds = new ConcurrentHashSet<>(); + private void doTestFlowNoConflicts() throws Exception { + final AtomicBoolean stopFlag = new AtomicBoolean(); + final AtomicInteger restartIdx = new AtomicInteger(-1); + final AtomicInteger workersCntr = new AtomicInteger(0); - startListening(5, true, deafClientObservedIds); + try { + for (int i = 0; i < GRID_CNT; i++) + startComputation(i, restartIdx, workersCntr); - final Set regClientObservedIds = new ConcurrentHashSet<>(); + IgniteInternalFuture fut = + GridTestUtils.runAsync(new NodeRestarter(stopFlag, restartIdx, workersCntr), "worker"); - startListening(6, false, regClientObservedIds); + startLatch.countDown(); - START_LATCH.countDown(); - - Thread killer = new Thread(new ServerNodeKiller()); - Thread resurrection = new Thread(new ServerNodeResurrection()); - killer.setName("node-killer-thread"); - killer.start(); - resurrection.setName("node-resurrection-thread"); - resurrection.start(); - - while (!updatesQueue.isEmpty()) - Thread.sleep(1000); + fut.get(); - killer.interrupt(); - resurrection.interrupt(); + GridTestUtils.waitForCondition(() -> workersCntr.get() == 0, 5_000); + } + finally { + stopFlag.set(true); + } } /** * @throws Exception If failed. */ + @Test public void testConcurrentMetadataUpdates() throws Exception { startGrid(0); - final Ignite client = startGrid(getConfiguration("client").setClientMode(true)); + final Ignite client = startGrid(getConfiguration("client")); final IgniteCache cache = client.cache(DEFAULT_CACHE_NAME).withKeepBinary(); @@ -395,101 +339,6 @@ public void testConcurrentMetadataUpdates() throws Exception { fut.get(); } - /** - * Runnable responsible for stopping (gracefully) server nodes during metadata updates process. - */ - private final class ServerNodeKiller implements Runnable { - /** {@inheritDoc} */ - @Override public void run() { - Thread curr = Thread.currentThread(); - try { - START_LATCH.await(); - - while (!curr.isInterrupted()) { - int idx = ThreadLocalRandom.current().nextInt(5); - - AtomicBoolean stopFlag; - - switch (idx) { - case 0: - stopFlag = stopFlag0; - break; - case 1: - stopFlag = stopFlag1; - break; - case 2: - stopFlag = stopFlag2; - break; - case 3: - stopFlag = stopFlag3; - break; - default: - stopFlag = stopFlag4; - } - - stopFlag.set(true); - - while (stopFlag.get()) - Thread.sleep(10); - - stopGrid(idx); - - srvResurrectQueue.put(idx); - - Thread.sleep(RESTART_DELAY); - } - } - catch (Exception ignored) { - // No-op. - } - } - } - - /** - * {@link Runnable} object to restart nodes killed by {@link ServerNodeKiller}. - */ - private final class ServerNodeResurrection implements Runnable { - /** {@inheritDoc} */ - @Override public void run() { - Thread curr = Thread.currentThread(); - - try { - START_LATCH.await(); - - while (!curr.isInterrupted()) { - Integer idx = srvResurrectQueue.takeFirst(); - - AtomicBoolean stopFlag; - - switch (idx) { - case 0: - stopFlag = stopFlag0; - break; - case 1: - stopFlag = stopFlag1; - break; - case 2: - stopFlag = stopFlag2; - break; - case 3: - stopFlag = stopFlag3; - break; - default: - stopFlag = stopFlag4; - } - - clientMode = false; - applyDiscoveryHook = false; - - startComputation(idx, stopFlag); - } - } - catch (Exception ignored) { - // No-op. - } - } - } - /** * Instruction for node to perform add new binary object action on cache in keepBinary mode. * @@ -506,15 +355,20 @@ private static final class BinaryUpdateDescription { /** */ private FieldType fieldType; + /** */ + private Object val; + /** * @param itemId Item id. * @param fieldName Field name. * @param fieldType Field type. + * @param val Field value. */ - private BinaryUpdateDescription(int itemId, String fieldName, FieldType fieldType) { + private BinaryUpdateDescription(int itemId, String fieldName, FieldType fieldType, Object val) { this.itemId = itemId; this.fieldName = fieldName; this.fieldType = fieldType; + this.val = val; } } @@ -565,20 +419,7 @@ private static byte[] getArrayFieldVal() { */ private static BinaryObject newBinaryObject(BinaryObjectBuilder builder, BinaryUpdateDescription desc) { builder.setField(SEQ_NUM_FLD, desc.itemId + 1); - - switch (desc.fieldType) { - case NUMBER: - builder.setField(desc.fieldName, getNumberFieldVal()); - break; - case STRING: - builder.setField(desc.fieldName, getStringFieldVal()); - break; - case ARRAY: - builder.setField(desc.fieldName, getArrayFieldVal()); - break; - case OBJECT: - builder.setField(desc.fieldName, new Object()); - } + builder.setField(desc.fieldName, desc.val); return builder.build(); } @@ -589,60 +430,142 @@ private static BinaryObject newBinaryObject(BinaryObjectBuilder builder, BinaryU */ private static final class BinaryObjectAdder implements IgniteCallable { /** */ - private final IgniteEx ignite; + private final CountDownLatch startLatch; + + /** */ + private final int idx; /** */ private final Queue updatesQueue; /** */ - private final long timeout; + private final AtomicInteger restartIdx; /** */ - private final AtomicBoolean stopFlag; + private final AtomicInteger workersCntr; + + /** */ + @IgniteInstanceResource + private Ignite ignite; /** - * @param ignite Ignite. + * @param startLatch Startup latch. + * @param idx Ignite instance index. * @param updatesQueue Updates queue. - * @param timeout Timeout. - * @param stopFlag Stop flag. + * @param restartIdx The index of the node to be restarted. + * @param workersCntr The number of active computation threads. */ - BinaryObjectAdder(IgniteEx ignite, Queue updatesQueue, long timeout, AtomicBoolean stopFlag) { - this.ignite = ignite; + BinaryObjectAdder( + CountDownLatch startLatch, + int idx, + Queue updatesQueue, + AtomicInteger restartIdx, + AtomicInteger workersCntr + ) { + this.startLatch = startLatch; + this.idx = idx; this.updatesQueue = updatesQueue; - this.timeout = timeout; - this.stopFlag = stopFlag; + this.restartIdx = restartIdx; + this.workersCntr = workersCntr; } /** {@inheritDoc} */ @Override public Object call() throws Exception { - START_LATCH.await(); + startLatch.await(); IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME).withKeepBinary(); - while (!updatesQueue.isEmpty()) { - BinaryUpdateDescription desc = updatesQueue.poll(); + workersCntr.incrementAndGet(); - if (desc == null) - break; + try { + while (!updatesQueue.isEmpty()) { + BinaryUpdateDescription desc = updatesQueue.poll(); - BinaryObjectBuilder builder = ignite.binary().builder(BINARY_TYPE_NAME); + if (desc == null) + break; - BinaryObject bo = newBinaryObject(builder, desc); + BinaryObjectBuilder builder = ignite.binary().builder(BINARY_TYPE_NAME); - cache.put(desc.itemId, bo); + BinaryObject bo = newBinaryObject(builder, desc); - if (stopFlag.get()) - break; - else - Thread.sleep(timeout); - } + cache.put(desc.itemId, bo); - if (updatesQueue.isEmpty()) - FINISH_LATCH_NO_CLIENTS.countDown(); + if (restartIdx.get() == idx) + break; + } + } + finally { + workersCntr.decrementAndGet(); - stopFlag.set(false); + if (restartIdx.get() == idx) + restartIdx.set(-1); + } return null; } } + + /** + * Restarts random server node and computation job. + */ + private final class NodeRestarter implements Runnable { + /** Stop thread flag. */ + private final AtomicBoolean stopFlag; + + /** The index of the node to be restarted. */ + private final AtomicInteger restartIdx; + + /** The current number of computation threads. */ + private final AtomicInteger workersCntr; + + /** + * @param stopFlag Stop thread flag. + * @param restartIdx The index of the node to be restarted. + * @param workersCntr The current number of computation threads. + */ + NodeRestarter(AtomicBoolean stopFlag, AtomicInteger restartIdx, AtomicInteger workersCntr) { + this.stopFlag = stopFlag; + this.restartIdx = restartIdx; + this.workersCntr = workersCntr; + } + + /** {@inheritDoc} */ + @Override public void run() { + try { + startLatch.await(); + + while (!shouldStop()) { + int idx = ThreadLocalRandom.current().nextInt(5); + + restartIdx.set(idx); + + while (restartIdx.get() != -1) { + if (shouldStop()) + return; + + Thread.sleep(10); + } + + stopGrid(idx); + + if (shouldStop()) + return; + + startGrid(idx); + + startComputation(idx, restartIdx, workersCntr); + + Thread.sleep(RESTART_DELAY); + } + } + catch (Exception ignore) { + // No-op. + } + } + + /** */ + private boolean shouldStop() { + return updatesQueue.isEmpty() || stopFlag.get() || Thread.currentThread().isInterrupted(); + } + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/BinaryTxCacheLocalEntriesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/BinaryTxCacheLocalEntriesSelfTest.java index 3528161b589f2..1240dd94113bf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/BinaryTxCacheLocalEntriesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/BinaryTxCacheLocalEntriesSelfTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class BinaryTxCacheLocalEntriesSelfTest extends GridCacheAbstractSelfTest { /** */ private static final String FIELD = "user-name"; @@ -58,6 +62,7 @@ public class BinaryTxCacheLocalEntriesSelfTest extends GridCacheAbstractSelfTest /** * @throws Exception If failed. */ + @Test public void testLocalEntries() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME).withKeepBinary(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/CacheKeepBinaryWithInterceptorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/CacheKeepBinaryWithInterceptorTest.java index 6cef6d20c2790..144988ca1d547 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/CacheKeepBinaryWithInterceptorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/CacheKeepBinaryWithInterceptorTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache.binary; +import javax.cache.Cache; import org.apache.ignite.IgniteCache; import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.cache.CacheAtomicityMode; @@ -24,47 +25,47 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -import javax.cache.Cache; - -import static org.apache.ignite.cache.CacheAtomicityMode.*; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class CacheKeepBinaryWithInterceptorTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setMarshaller(null); return cfg; } /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - super.beforeTestsStarted(); + @Override protected void afterTest() throws Exception { + stopAllGrids(); - startGrid(0); + super.afterTest(); } /** * @throws Exception If failed. */ + @Test public void testKeepBinaryWithInterceptor() throws Exception { + startGrid(0); + keepBinaryWithInterceptor(cacheConfiguration(ATOMIC, false)); keepBinaryWithInterceptor(cacheConfiguration(TRANSACTIONAL, false)); @@ -80,6 +81,23 @@ public void testKeepBinaryWithInterceptor() throws Exception { keepBinaryWithInterceptorPrimitives(cacheConfiguration(TRANSACTIONAL, true)); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9323") + @Test + public void testKeepBinaryWithInterceptorOnMvccCache() throws Exception { + startGrid(0); + + keepBinaryWithInterceptor(cacheConfiguration(TRANSACTIONAL_SNAPSHOT, false)); + keepBinaryWithInterceptorPrimitives(cacheConfiguration(TRANSACTIONAL_SNAPSHOT, true)); + + startGridsMultiThreaded(1, 3); + + keepBinaryWithInterceptor(cacheConfiguration(TRANSACTIONAL_SNAPSHOT, false)); + keepBinaryWithInterceptorPrimitives(cacheConfiguration(TRANSACTIONAL_SNAPSHOT, true)); + } + /** * @param ccfg Cache configuration. */ @@ -230,7 +248,8 @@ static class TestInterceptor1 implements CacheInterceptor entry, BinaryObject newVal) { + @Nullable @Override public BinaryObject onBeforePut(Cache.Entry entry, + BinaryObject newVal) { System.out.println("Before put [e=" + entry + ", newVal=" + newVal + ']'); onBeforePut++; @@ -255,7 +274,8 @@ static class TestInterceptor1 implements CacheInterceptor onBeforeRemove(Cache.Entry entry) { + @Nullable @Override public IgniteBiTuple onBeforeRemove( + Cache.Entry entry) { assertEquals(1, (int)entry.getKey().field("key")); assertEquals(10, (int)entry.getValue().field("val")); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.java index c65f41c45cb85..35a4d7630841d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.java @@ -22,10 +22,14 @@ import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.internal.processors.cache.GridCacheAtomicEntryProcessorDeploymentSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Cache EntryProcessor + Deployment. */ +@RunWith(JUnit4.class) public class GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest extends GridCacheAtomicEntryProcessorDeploymentSelfTest { /** {@inheritDoc} */ @@ -41,6 +45,7 @@ public class GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest /** * @throws Exception In case of error. */ + @Test public void testGetDeployment() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -50,6 +55,7 @@ public void testGetDeployment() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetDeployment2() throws Exception { depMode = DeploymentMode.SHARED; @@ -59,6 +65,7 @@ public void testGetDeployment2() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetDeploymentWithKeepBinary() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -68,6 +75,7 @@ public void testGetDeploymentWithKeepBinary() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testGetDeployment2WithKeepBinary() throws Exception { depMode = DeploymentMode.SHARED; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectMetadataExchangeMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectMetadataExchangeMultinodeTest.java index 01ef73d167e9c..eebcce33d16a1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectMetadataExchangeMultinodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectMetadataExchangeMultinodeTest.java @@ -18,10 +18,9 @@ import java.util.Map; import java.util.UUID; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Future; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import junit.framework.AssertionFailedError; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.binary.BinaryObject; @@ -39,26 +38,28 @@ import org.apache.ignite.internal.managers.communication.GridMessageListener; import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; import org.apache.ignite.internal.util.IgniteUtils; +import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteCallable; +import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage; import org.apache.ignite.spi.discovery.DiscoverySpiListener; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.GridTestUtils.DiscoveryHook; import org.apache.ignite.testframework.GridTestUtils.DiscoverySpiListenerWrapper; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheBinaryObjectMetadataExchangeMultinodeTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean clientMode; @@ -74,6 +75,9 @@ public class GridCacheBinaryObjectMetadataExchangeMultinodeTest extends GridComm /** */ private static final int BINARY_TYPE_ID = 708045005; + /** */ + private static final long MAX_AWAIT = 9_000; + /** */ private static final AtomicInteger metadataReqsCounter = new AtomicInteger(0); @@ -91,7 +95,7 @@ public class GridCacheBinaryObjectMetadataExchangeMultinodeTest extends GridComm }); } - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(sharedStaticIpFinder); cfg.setMarshaller(new BinaryMarshaller()); @@ -107,35 +111,6 @@ public class GridCacheBinaryObjectMetadataExchangeMultinodeTest extends GridComm return cfg; } - /** - * - */ - private static final class ErrorHolder { - /** */ - private volatile Error e; - - /** - * @param e Exception. - */ - void error(Error e) { - this.e = e; - } - - /** - * - */ - void fail() { - throw e; - } - - /** - * - */ - boolean isEmpty() { - return e == null; - } - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); @@ -143,45 +118,29 @@ boolean isEmpty() { stopAllGrids(); } - /** */ - private static final CountDownLatch LATCH1 = new CountDownLatch(1); - /** * Verifies that if thread tries to read metadata with ongoing update it gets blocked * until acknowledge message arrives. */ + @Test public void testReadRequestBlockedOnUpdatingMetadata() throws Exception { - applyDiscoveryHook = true; - discoveryHook = new DiscoveryHook() { - @Override public void handleDiscoveryMessage(DiscoverySpiCustomMessage msg) { - DiscoveryCustomMessage customMsg = msg == null ? null - : (DiscoveryCustomMessage) IgniteUtils.field(msg, "delegate"); - - if (customMsg instanceof MetadataUpdateAcceptedMessage) { - if (((MetadataUpdateAcceptedMessage)customMsg).typeId() == BINARY_TYPE_ID) - try { - Thread.sleep(300); - } - catch (InterruptedException ignored) { - // No-op. - } - } - } - }; - - final IgniteEx ignite0 = startGrid(0); + final CyclicBarrier barrier = new CyclicBarrier(2); applyDiscoveryHook = false; - final IgniteEx ignite1 = startGrid(1); + final Ignite ignite0 = startGrid(0); + final Ignite ignite1 = startGrid(1); - final ErrorHolder errorHolder = new ErrorHolder(); + final GridFutureAdapter finishFut = new GridFutureAdapter(); applyDiscoveryHook = true; discoveryHook = new DiscoveryHook() { private volatile IgniteEx ignite; @Override public void handleDiscoveryMessage(DiscoverySpiCustomMessage msg) { + if (finishFut.isDone()) + return; + DiscoveryCustomMessage customMsg = msg == null ? null : (DiscoveryCustomMessage) IgniteUtils.field(msg, "delegate"); @@ -192,10 +151,17 @@ public void testReadRequestBlockedOnUpdatingMetadata() throws Exception { Object transport = U.field(binaryProc, "transport"); try { + barrier.await(MAX_AWAIT, TimeUnit.MILLISECONDS); + Map syncMap = U.field(transport, "syncMap"); - int size = syncMap.size(); - assertEquals("unexpected size of syncMap: ", 1, size); + GridTestUtils.waitForCondition(new PA() { + @Override public boolean apply() { + return syncMap.size() == 1; + } + }, MAX_AWAIT); + + assertEquals("unexpected size of syncMap: ", 1, syncMap.size()); Object syncKey = syncMap.keySet().iterator().next(); @@ -204,9 +170,11 @@ public void testReadRequestBlockedOnUpdatingMetadata() throws Exception { int ver = U.field(syncKey, "ver"); assertEquals("unexpected pendingVersion: ", 2, ver); + + finishFut.onDone(); } - catch (AssertionFailedError err) { - errorHolder.error(err); + catch (Throwable t) { + finishFut.onDone(t); } } } @@ -220,47 +188,41 @@ public void testReadRequestBlockedOnUpdatingMetadata() throws Exception { final IgniteEx ignite2 = startGrid(2); discoveryHook.ignite(ignite2); - ignite0.executorService().submit(new Runnable() { + // Unfinished PME may affect max await timeout. + awaitPartitionMapExchange(); + + // Update metadata (version 1). + ignite0.executorService(ignite0.cluster().forLocal()).submit(new Runnable() { @Override public void run() { addIntField(ignite0, "f1", 101, 1); } }).get(); - UUID id2 = ignite2.localNode().id(); - - ClusterGroup cg2 = ignite2.cluster().forNodeId(id2); - - Future fut = ignite1.executorService().submit(new Runnable() { + // Update metadata (version 2). + ignite1.executorService(ignite1.cluster().forLocal()).submit(new Runnable() { @Override public void run() { - LATCH1.countDown(); addStringField(ignite1, "f2", "str", 2); } }); - ignite2.compute(cg2).withAsync().call(new IgniteCallable() { + // Read metadata. + IgniteFuture readFut = ignite2.compute(ignite2.cluster().forLocal()).callAsync(new IgniteCallable() { @Override public Object call() throws Exception { - try { - LATCH1.await(); - } - catch (InterruptedException ignored) { - // No-op. - } - - Object fieldVal = ((BinaryObject) ignite2.cache(DEFAULT_CACHE_NAME).withKeepBinary().get(1)).field("f1"); + barrier.await(MAX_AWAIT, TimeUnit.MILLISECONDS); - return fieldVal; + return ((BinaryObject) ignite2.cache(DEFAULT_CACHE_NAME).withKeepBinary().get(1)).field("f1"); } }); - fut.get(); + finishFut.get(MAX_AWAIT); - if (!errorHolder.isEmpty()) - errorHolder.fail(); + assertEquals(101, readFut.get(MAX_AWAIT)); } /** * Verifies that all sequential updates that don't introduce any conflicts are accepted and observed by all nodes. */ + @Test public void testSequentialUpdatesNoConflicts() throws Exception { IgniteEx ignite0 = startGrid(0); @@ -294,6 +256,7 @@ public void testSequentialUpdatesNoConflicts() throws Exception { /** * Verifies that client is able to detect obsolete metadata situation and request up-to-date from the cluster. */ + @Test public void testClientRequestsUpToDateMetadata() throws Exception { final IgniteEx ignite0 = startGrid(0); @@ -329,6 +292,7 @@ public void testClientRequestsUpToDateMetadata() throws Exception { /** * Verifies that client resends request for up-to-date metadata in case of failure on server received first request. */ + @Test public void testClientRequestsUpToDateMetadataOneNodeDies() throws Exception { final Ignite srv0 = startGrid(0); replaceWithStoppingMappingRequestListener(((GridKernalContext)U.field(srv0, "ctx")).io(), 0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java index 40d8d041bcca6..a32e04a3218ea 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java @@ -32,10 +32,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -43,6 +43,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheBinaryObjectUserClassloaderSelfTest extends GridCommonAbstractTest { /** */ private static volatile boolean customBinaryConf = false; @@ -53,9 +54,6 @@ public class GridCacheBinaryObjectUserClassloaderSelfTest extends GridCommonAbst /** */ private static volatile boolean useWrappingLoader = false; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); @@ -67,12 +65,6 @@ public class GridCacheBinaryObjectUserClassloaderSelfTest extends GridCommonAbst @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName)); cfg.setMarshaller(new BinaryMarshaller()); @@ -140,6 +132,7 @@ CacheConfiguration cacheConfiguration(String igniteInstanceName) { /** * @throws Exception If test failed. */ + @Test public void testConfigurationRegistration() throws Exception { useWrappingLoader = false; @@ -149,6 +142,7 @@ public void testConfigurationRegistration() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testConfigurationRegistrationWithWrappingLoader() throws Exception { useWrappingLoader = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java index 472a7a03b8f7b..05fac42eb405f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java @@ -39,12 +39,16 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; /** * Test for binary objects stored in cache. */ +@RunWith(JUnit4.class) public abstract class GridCacheBinaryObjectsAbstractDataStreamerSelfTest extends GridCommonAbstractTest { /** */ private static final int THREAD_CNT = 64; @@ -111,6 +115,7 @@ protected int gridCount() { * @throws Exception If failed. */ @SuppressWarnings("BusyWait") + @Test public void testGetPut() throws Exception { final AtomicBoolean flag = new AtomicBoolean(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java index e2a1a8b041ae2..16222296c8b48 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java @@ -41,20 +41,18 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; /** * Test for binary objects stored in cache. */ +@RunWith(JUnit4.class) public abstract class GridCacheBinaryObjectsAbstractMultiThreadedSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int THREAD_CNT = 64; @@ -65,8 +63,6 @@ public abstract class GridCacheBinaryObjectsAbstractMultiThreadedSelfTest extend @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); cacheCfg.setCacheMode(cacheMode()); @@ -124,7 +120,9 @@ protected int gridCount() { /** * @throws Exception If failed. */ - @SuppressWarnings("BusyWait") public void testGetPut() throws Exception { + @SuppressWarnings("BusyWait") + @Test + public void testGetPut() throws Exception { final AtomicBoolean flag = new AtomicBoolean(); final LongAdder cnt = new LongAdder(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java index cc2f2c4cb2011..91a53307529e3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java @@ -68,15 +68,15 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -87,10 +87,8 @@ /** * Test for binary objects stored in cache. */ +@RunWith(JUnit4.class) public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonAbstractTest { - /** */ - public static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int ENTRY_CNT = 100; @@ -102,12 +100,6 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = createCacheConfig(); cacheCfg.setCacheStoreFactory(singletonFactory(new TestStore())); @@ -222,6 +214,7 @@ protected boolean onheapCacheEnabled() { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testCircularReference() throws Exception { IgniteCache c = keepBinaryCache(); @@ -266,6 +259,7 @@ public void testCircularReference() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { IgniteCache c = jcache(0); @@ -290,6 +284,67 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testReplace() throws Exception { + IgniteCache c = jcache(0); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; i++) { + TestObject obj = c.get(i); + + assertEquals(i, obj.val); + } + + IgniteCache kpc = keepBinaryCache(); + + BinaryObjectBuilder bldr = grid(0).binary().builder(TestObject.class.getName()); + + bldr.setField("val", -42); + + BinaryObject testObj = bldr.build(); + + for (int i = 0; i < ENTRY_CNT; i++) { + BinaryObject po = kpc.get(i); + + assertEquals(i, (int)po.field("val")); + + assertTrue(kpc.replace(i, po, testObj)); + } + } + + /** + * @throws Exception If failed. + */ + @Test + public void testRemove() throws Exception { + IgniteCache c = jcache(0); + + for (int i = 0; i < ENTRY_CNT; i++) + c.put(i, new TestObject(i)); + + for (int i = 0; i < ENTRY_CNT; i++) { + TestObject obj = c.get(i); + + assertEquals(i, obj.val); + } + + IgniteCache kpc = keepBinaryCache(); + + for (int i = 0; i < ENTRY_CNT; i++) { + BinaryObject po = kpc.get(i); + + assertEquals(i, (int)po.field("val")); + + assertTrue(kpc.remove(i, po)); + } + } + + /** + * @throws Exception If failed. + */ + @Test public void testIterator() throws Exception { IgniteCache c = jcache(0); @@ -329,6 +384,7 @@ public void testIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollection() throws Exception { IgniteCache> c = jcache(0); @@ -375,6 +431,7 @@ public void testCollection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMap() throws Exception { IgniteCache> c = jcache(0); @@ -420,6 +477,7 @@ public void testMap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingletonList() throws Exception { IgniteCache> c = jcache(0); @@ -447,6 +505,7 @@ public void testSingletonList() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAsync() throws Exception { IgniteCache c = jcache(0); @@ -473,6 +532,7 @@ public void testGetAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBasicArrays() throws Exception { IgniteCache cache = jcache(0); @@ -506,6 +566,7 @@ public void testBasicArrays() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomArrays() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-3244"); @@ -542,6 +603,7 @@ private void checkArrayClass(IgniteCache cache, Object arr) { /** * @throws Exception If failed. */ + @Test public void testGetTx1() throws Exception { checkGetTx(PESSIMISTIC, REPEATABLE_READ); } @@ -549,6 +611,7 @@ public void testGetTx1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetTx2() throws Exception { checkGetTx(PESSIMISTIC, READ_COMMITTED); } @@ -595,6 +658,7 @@ private void checkGetTx(TransactionConcurrency concurrency, TransactionIsolation /** * @throws Exception If failed. */ + @Test public void testGetTxAsync1() throws Exception { checkGetAsyncTx(PESSIMISTIC, REPEATABLE_READ); } @@ -602,6 +666,7 @@ public void testGetTxAsync1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetTxAsync2() throws Exception { checkGetAsyncTx(PESSIMISTIC, READ_COMMITTED); } @@ -649,6 +714,7 @@ private void checkGetAsyncTx(TransactionConcurrency concurrency, TransactionIsol /** * @throws Exception If failed. */ + @Test public void testGetAsyncTx() throws Exception { if (atomicityMode() != TRANSACTIONAL) return; @@ -684,6 +750,7 @@ public void testGetAsyncTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAll() throws Exception { IgniteCache c = jcache(0); @@ -724,6 +791,7 @@ public void testGetAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllAsync() throws Exception { IgniteCache c = jcache(0); @@ -764,6 +832,7 @@ public void testGetAllAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllTx1() throws Exception { checkGetAllTx(PESSIMISTIC, REPEATABLE_READ); } @@ -771,6 +840,7 @@ public void testGetAllTx1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllTx2() throws Exception { checkGetAllTx(PESSIMISTIC, READ_COMMITTED); } @@ -836,6 +906,7 @@ private void checkGetAllTx(TransactionConcurrency concurrency, TransactionIsolat /** * @throws Exception If failed. */ + @Test public void testGetAllAsyncTx1() throws Exception { checkGetAllAsyncTx(PESSIMISTIC, REPEATABLE_READ); } @@ -843,6 +914,7 @@ public void testGetAllAsyncTx1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAllAsyncTx2() throws Exception { checkGetAllAsyncTx(PESSIMISTIC, READ_COMMITTED); } @@ -908,6 +980,7 @@ private void checkGetAllAsyncTx(TransactionConcurrency concurrency, TransactionI * */ @SuppressWarnings("unchecked") + @Test public void testCrossFormatObjectsIdentity() { IgniteCache c = binKeysCache(); @@ -929,6 +1002,7 @@ public void testCrossFormatObjectsIdentity() { * */ @SuppressWarnings("unchecked") + @Test public void testPutWithArrayHashing() { IgniteCache c = binKeysCache(); @@ -963,6 +1037,7 @@ public void testPutWithArrayHashing() { * */ @SuppressWarnings("unchecked") + @Test public void testPutWithFieldsHashing() { IgniteCache c = binKeysCache(); @@ -996,6 +1071,7 @@ public void testPutWithFieldsHashing() { * */ @SuppressWarnings("unchecked") + @Test public void testPutWithCustomHashing() { IgniteCache c = binKeysCache(); @@ -1026,6 +1102,7 @@ public void testPutWithCustomHashing() { /** * @throws Exception if failed. */ + @Test public void testKeepBinaryTxOverwrite() throws Exception { if (atomicityMode() != TRANSACTIONAL) return; @@ -1050,6 +1127,7 @@ public void testKeepBinaryTxOverwrite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCache() throws Exception { for (int i = 0; i < gridCount(); i++) jcache(i).localLoadCache(null); @@ -1066,6 +1144,7 @@ public void testLoadCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheAsync() throws Exception { for (int i = 0; i < gridCount(); i++) jcache(i).loadCacheAsync(null).get(); @@ -1082,6 +1161,7 @@ public void testLoadCacheAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheFilteredAsync() throws Exception { for (int i = 0; i < gridCount(); i++) { IgniteCache c = jcache(i); @@ -1106,6 +1186,7 @@ public void testLoadCacheFilteredAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransform() throws Exception { IgniteCache c = keepBinaryCache(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java index 1b7cb298bc620..b62252f6f7c83 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java @@ -31,20 +31,18 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; import java.util.concurrent.ConcurrentHashMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for cache store with binary. */ +@RunWith(JUnit4.class) public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final TestStore STORE = new TestStore(); @@ -77,12 +75,6 @@ public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbs cfg.setCacheConfiguration(cacheCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - GridCacheBinaryStoreAbstractSelfTest.cfg = cfg; return cfg; @@ -110,6 +102,7 @@ public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbs /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { jcache().put(new Key(1), new Value(1)); @@ -119,6 +112,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAll() throws Exception { Map map = new HashMap<>(); @@ -133,6 +127,7 @@ public void testPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoad() throws Exception { populateMap(STORE.map(), 1); @@ -146,6 +141,7 @@ public void testLoad() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadAll() throws Exception { populateMap(STORE.map(), 1, 2, 3); @@ -170,6 +166,7 @@ public void testLoadAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { for (int i = 1; i <= 3; i++) jcache().put(new Key(i), new Value(i)); @@ -182,6 +179,7 @@ public void testRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoveAll() throws Exception { for (int i = 1; i <= 3; i++) jcache().put(new Key(i), new Value(i)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java index 81614cb9ff7a5..7c40031251b85 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java @@ -31,27 +31,26 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.binary.BinaryObjectBuilder; import org.apache.ignite.binary.BinaryType; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.eclipse.jetty.util.ConcurrentHashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class GridCacheClientNodeBinaryObjectMetadataMultinodeTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -61,7 +60,7 @@ public class GridCacheClientNodeBinaryObjectMetadataMultinodeTest extends GridCo cfg.setPeerClassLoadingEnabled(false); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder).setForceServerMode(true); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); cfg.setMarshaller(new BinaryMarshaller()); @@ -86,12 +85,13 @@ public class GridCacheClientNodeBinaryObjectMetadataMultinodeTest extends GridCo /** * @throws Exception If failed. */ + @Test public void testClientMetadataInitialization() throws Exception { startGrids(2); final AtomicBoolean stop = new AtomicBoolean(); - final ConcurrentHashSet allTypes = new ConcurrentHashSet<>(); + final GridConcurrentHashSet allTypes = new GridConcurrentHashSet<>(); IgniteInternalFuture fut; @@ -181,6 +181,7 @@ public void testClientMetadataInitialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailoverOnStart() throws Exception { startGrids(4); @@ -267,6 +268,7 @@ public void testFailoverOnStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientStartsFirst() throws Exception { client = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheClientNodeBinaryObjectMetadataTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheClientNodeBinaryObjectMetadataTest.java index 0316edc54307a..3215713ef89e4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheClientNodeBinaryObjectMetadataTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheClientNodeBinaryObjectMetadataTest.java @@ -32,12 +32,16 @@ import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; /** * */ +@RunWith(JUnit4.class) public class GridCacheClientNodeBinaryObjectMetadataTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -94,6 +98,7 @@ public class GridCacheClientNodeBinaryObjectMetadataTest extends GridCacheAbstra /** * @throws Exception If failed. */ + @Test public void testBinaryMetadataOnClient() throws Exception { Ignite ignite0 = ignite(gridCount() - 1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeMultiServerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/datastreaming/DataStreamProcessorPersistenceBinarySelfTest.java similarity index 73% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeMultiServerTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/datastreaming/DataStreamProcessorPersistenceBinarySelfTest.java index b7003d4df6288..84fb997375273 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeMultiServerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/datastreaming/DataStreamProcessorPersistenceBinarySelfTest.java @@ -15,16 +15,14 @@ * limitations under the License. */ -package org.apache.ignite.internal.processors.cache.distributed; +package org.apache.ignite.internal.processors.cache.binary.datastreaming; /** * */ -public class IgniteOptimisticTxSuspendResumeMultiServerTest extends IgniteOptimisticTxSuspendResumeTest { - /** - * @return Number of server nodes. - */ - @Override protected int serversNumber() { - return 4; +public class DataStreamProcessorPersistenceBinarySelfTest extends DataStreamProcessorBinarySelfTest { + /** {@inheritDoc} */ + @Override public boolean persistenceEnabled() { + return true; } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/datastreaming/GridDataStreamerImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/datastreaming/GridDataStreamerImplSelfTest.java index c629871333952..9cacc5abf5264 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/datastreaming/GridDataStreamerImplSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/datastreaming/GridDataStreamerImplSelfTest.java @@ -37,10 +37,10 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -48,10 +48,8 @@ /** * Tests for {@code IgniteDataStreamerImpl}. */ +@RunWith(JUnit4.class) public class GridDataStreamerImplSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of keys to load via data streamer. */ private static final int KEYS_COUNT = 1000; @@ -62,11 +60,6 @@ public class GridDataStreamerImplSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - if (binaries) { BinaryMarshaller marsh = new BinaryMarshaller(); @@ -100,6 +93,7 @@ private CacheConfiguration cacheConfiguration() { * * @throws Exception If failed. */ + @Test public void testAddDataFromMap() throws Exception { try { binaries = false; @@ -148,6 +142,7 @@ public void testAddDataFromMap() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddMissingBinary() throws Exception { try { binaries = true; @@ -183,6 +178,7 @@ public void testAddMissingBinary() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddBinaryDataFromMap() throws Exception { try { binaries = true; @@ -242,6 +238,7 @@ public void testAddBinaryDataFromMap() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddBinaryCreatedWithBuilder() throws Exception { try { binaries = true; @@ -258,7 +255,7 @@ public void testAddBinaryCreatedWithBuilder() throws Exception { BinaryObjectBuilder obj = g0.binary().builder("NoExistedClass"); obj.setField("id", i); - obj.setField("name", String.valueOf("name = " + i)); + obj.setField("name", "name = " + i); dataLdr.addData(i, obj.build()); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java index 10a5912fc91c7..2f96c9f1b2a17 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; import org.apache.ignite.testframework.GridTestExternalClassLoader; import org.apache.ignite.testframework.config.GridTestProperties; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheAbstractExecutionContextTest extends IgniteCacheAbstractTest { /** */ public static final String TEST_VALUE = "org.apache.ignite.tests.p2p.CacheDeploymentTestValue"; @@ -62,6 +66,7 @@ public abstract class IgniteCacheAbstractExecutionContextTest extends IgniteCach /** * @throws Exception If failed. */ + @Test public void testUsersClassLoader() throws Exception { UsersClassLoader testClassLdr = (UsersClassLoader)grid(0).configuration().getClassLoader(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java index 797e90f6a0d4f..e408b97e9bba7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java @@ -69,6 +69,9 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; @@ -76,6 +79,7 @@ /** * Failover tests for cache data structures. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends IgniteCollectionAbstractTest { /** */ private static final long TEST_TIMEOUT = 3 * 60 * 1000; @@ -171,6 +175,7 @@ protected IgniteEx startClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicLongFailsWhenServersLeft() throws Exception { client = true; @@ -201,6 +206,7 @@ public void testAtomicLongFailsWhenServersLeft() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicLongTopologyChange() throws Exception { try (IgniteAtomicLong atomic = grid(0).atomicLong(STRUCTURE_NAME, 10, true)) { Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME); @@ -218,6 +224,7 @@ public void testAtomicLongTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicLongConstantTopologyChange() throws Exception { doTestAtomicLong(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT)); } @@ -225,6 +232,7 @@ public void testAtomicLongConstantTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicLongConstantMultipleTopologyChange() throws Exception { doTestAtomicLong(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT)); } @@ -263,6 +271,7 @@ private void doTestAtomicLong(ConstantTopologyChangeWorker topWorker) throws Exc /** * @throws Exception If failed. */ + @Test public void testAtomicReferenceTopologyChange() throws Exception { try (IgniteAtomicReference atomic = grid(0).atomicReference(STRUCTURE_NAME, 10, true)) { Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME); @@ -280,6 +289,7 @@ public void testAtomicReferenceTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicReferenceConstantTopologyChange() throws Exception { doTestAtomicReference(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT)); } @@ -287,6 +297,7 @@ public void testAtomicReferenceConstantTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicReferenceConstantMultipleTopologyChange() throws Exception { doTestAtomicReference(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT)); } @@ -325,6 +336,7 @@ private void doTestAtomicReference(ConstantTopologyChangeWorker topWorker) throw /** * @throws Exception If failed. */ + @Test public void testAtomicStampedTopologyChange() throws Exception { try (IgniteAtomicStamped atomic = grid(0).atomicStamped(STRUCTURE_NAME, 10, 10, true)) { Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME); @@ -348,6 +360,7 @@ public void testAtomicStampedTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicStampedConstantTopologyChange() throws Exception { doTestAtomicStamped(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT)); } @@ -355,6 +368,7 @@ public void testAtomicStampedConstantTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicStampedConstantMultipleTopologyChange() throws Exception { doTestAtomicStamped(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT)); } @@ -405,6 +419,7 @@ private void doTestAtomicStamped(ConstantTopologyChangeWorker topWorker) throws /** * @throws Exception If failed. */ + @Test public void testCountDownLatchTopologyChange() throws Exception { try (IgniteCountDownLatch latch = grid(0).countDownLatch(STRUCTURE_NAME, 20, true, true)) { try { @@ -427,6 +442,7 @@ public void testCountDownLatchTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSemaphoreFailoverSafe() throws Exception { try (final IgniteSemaphore semaphore = grid(0).semaphore(STRUCTURE_NAME, 20, true, true)) { Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME); @@ -450,6 +466,7 @@ public void testSemaphoreFailoverSafe() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSemaphoreNonFailoverSafe() throws Exception { try (IgniteSemaphore sem = grid(0).semaphore(STRUCTURE_NAME, 20, false, true)) { Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME); @@ -481,6 +498,7 @@ public void testSemaphoreNonFailoverSafe() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCanCloseSetInInterruptedThread() throws Exception { doCloseByInterruptedThread(grid(0).set(STRUCTURE_NAME, new CollectionConfiguration())); } @@ -488,6 +506,7 @@ public void testCanCloseSetInInterruptedThread() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCanCloseQueueInInterruptedThread() throws Exception { doCloseByInterruptedThread(grid(0).queue(STRUCTURE_NAME, 0, new CollectionConfiguration())); } @@ -495,6 +514,7 @@ public void testCanCloseQueueInInterruptedThread() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCanCloseAtomicLongInInterruptedThread() throws Exception { doCloseByInterruptedThread(grid(0).atomicLong(STRUCTURE_NAME, 10, true)); } @@ -502,6 +522,7 @@ public void testCanCloseAtomicLongInInterruptedThread() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCanCloseAtomicReferenceInInterruptedThread() throws Exception { doCloseByInterruptedThread(grid(0).atomicReference(STRUCTURE_NAME, 10, true)); } @@ -509,6 +530,7 @@ public void testCanCloseAtomicReferenceInInterruptedThread() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCanCloseCountDownLatchInInterruptedThread() throws Exception { IgniteCountDownLatch latch = grid(0).countDownLatch(STRUCTURE_NAME, 1, true, true); latch.countDown(); @@ -519,6 +541,7 @@ public void testCanCloseCountDownLatchInInterruptedThread() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCanCloseAtomicStampedInInterruptedThread() throws Exception { doCloseByInterruptedThread(grid(0).atomicStamped(STRUCTURE_NAME, 10, 10,true)); } @@ -526,6 +549,7 @@ public void testCanCloseAtomicStampedInInterruptedThread() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCanCloseSemaphoreInInterruptedThread() throws Exception { doCloseByInterruptedThread(grid(0).semaphore(STRUCTURE_NAME, 1, true, true)); } @@ -553,6 +577,7 @@ private void doCloseByInterruptedThread(final Closeable closeableDs) throws Exce /** * @throws Exception If failed. */ + @Test public void testSemaphoreSingleNodeFailure() throws Exception { final Ignite i1 = grid(0); @@ -606,6 +631,7 @@ public void testSemaphoreSingleNodeFailure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSemaphoreConstantTopologyChangeFailoverSafe() throws Exception { doTestSemaphore(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), true); } @@ -613,6 +639,7 @@ public void testSemaphoreConstantTopologyChangeFailoverSafe() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSemaphoreConstantTopologyChangeNonFailoverSafe() throws Exception { doTestSemaphore(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), false); } @@ -620,6 +647,7 @@ public void testSemaphoreConstantTopologyChangeNonFailoverSafe() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testSemaphoreMultipleTopologyChangeFailoverSafe() throws Exception { doTestSemaphore(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), true); } @@ -627,6 +655,7 @@ public void testSemaphoreMultipleTopologyChangeFailoverSafe() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSemaphoreMultipleTopologyChangeNonFailoverSafe() throws Exception { doTestSemaphore(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), false); } @@ -705,6 +734,7 @@ private void doTestSemaphore(ConstantTopologyChangeWorker topWorker, final boole /** * @throws Exception If failed. */ + @Test public void testReentrantLockFailsWhenServersLeft() throws Exception { testReentrantLockFailsWhenServersLeft(false); } @@ -712,6 +742,7 @@ public void testReentrantLockFailsWhenServersLeft() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFairReentrantLockFailsWhenServersLeft() throws Exception { testReentrantLockFailsWhenServersLeft(true); } @@ -785,6 +816,7 @@ public void testReentrantLockFailsWhenServersLeft(final boolean fair) throws Exc /** * @throws Exception If failed. */ + @Test public void testReentrantLockConstantTopologyChangeFailoverSafe() throws Exception { doTestReentrantLock(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), true, false); } @@ -792,6 +824,7 @@ public void testReentrantLockConstantTopologyChangeFailoverSafe() throws Excepti /** * @throws Exception If failed. */ + @Test public void testReentrantLockConstantMultipleTopologyChangeFailoverSafe() throws Exception { doTestReentrantLock(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), true, false); } @@ -799,6 +832,7 @@ public void testReentrantLockConstantMultipleTopologyChangeFailoverSafe() throws /** * @throws Exception If failed. */ + @Test public void testReentrantLockConstantTopologyChangeNonFailoverSafe() throws Exception { doTestReentrantLock(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), false, false); } @@ -806,6 +840,7 @@ public void testReentrantLockConstantTopologyChangeNonFailoverSafe() throws Exce /** * @throws Exception If failed. */ + @Test public void testReentrantLockConstantMultipleTopologyChangeNonFailoverSafe() throws Exception { doTestReentrantLock(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), false, false); } @@ -813,6 +848,7 @@ public void testReentrantLockConstantMultipleTopologyChangeNonFailoverSafe() thr /** * @throws Exception If failed. */ + @Test public void testFairReentrantLockConstantTopologyChangeFailoverSafe() throws Exception { doTestReentrantLock(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), true, true); } @@ -820,6 +856,7 @@ public void testFairReentrantLockConstantTopologyChangeFailoverSafe() throws Exc /** * @throws Exception If failed. */ + @Test public void testFairReentrantLockConstantMultipleTopologyChangeFailoverSafe() throws Exception { doTestReentrantLock(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), true, true); } @@ -827,6 +864,7 @@ public void testFairReentrantLockConstantMultipleTopologyChangeFailoverSafe() th /** * @throws Exception If failed. */ + @Test public void testFairReentrantLockConstantTopologyChangeNonFailoverSafe() throws Exception { doTestReentrantLock(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), false, true); } @@ -834,6 +872,7 @@ public void testFairReentrantLockConstantTopologyChangeNonFailoverSafe() throws /** * @throws Exception If failed. */ + @Test public void testFairReentrantLockConstantMultipleTopologyChangeNonFailoverSafe() throws Exception { doTestReentrantLock(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT), false, true); } @@ -916,6 +955,7 @@ private void doTestReentrantLock( /** * @throws Exception If failed. */ + @Test public void testCountDownLatchConstantTopologyChange() throws Exception { doTestCountDownLatch(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT)); } @@ -923,6 +963,7 @@ public void testCountDownLatchConstantTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCountDownLatchConstantMultipleTopologyChange() throws Exception { doTestCountDownLatch(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT)); } @@ -966,6 +1007,7 @@ private void doTestCountDownLatch(ConstantTopologyChangeWorker topWorker) throws /** * @throws Exception If failed. */ + @Test public void testFifoQueueTopologyChange() throws Exception { try { grid(0).queue(STRUCTURE_NAME, 0, config(false)).put(10); @@ -988,6 +1030,7 @@ public void testFifoQueueTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueueTopologyChange() throws Exception { ConstantTopologyChangeWorker topWorker = new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT); @@ -1042,6 +1085,7 @@ public void testQueueTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueueConstantTopologyChange() throws Exception { int topChangeThreads = collectionCacheMode() == CacheMode.PARTITIONED ? 1 : TOP_CHANGE_THREAD_CNT; @@ -1051,6 +1095,7 @@ public void testQueueConstantTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueueConstantMultipleTopologyChange() throws Exception { int topChangeThreads = collectionCacheMode() == CacheMode.PARTITIONED ? 1 : TOP_CHANGE_THREAD_CNT; @@ -1121,6 +1166,7 @@ private void doTestQueue(ConstantTopologyChangeWorker topWorker) throws Exceptio /** * @throws Exception If failed. */ + @Test public void testAtomicSequenceInitialization() throws Exception { checkAtomicSequenceInitialization(false); } @@ -1128,6 +1174,7 @@ public void testAtomicSequenceInitialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicSequenceInitializationOnStableNodes() throws Exception { checkAtomicSequenceInitialization(true); } @@ -1211,6 +1258,7 @@ private void checkAtomicSequenceInitialization(boolean limitProjection) throws E /** * @throws Exception If failed. */ + @Test public void testAtomicSequenceTopologyChange() throws Exception { try (IgniteAtomicSequence s = grid(0).atomicSequence(STRUCTURE_NAME, 10, true)) { Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME); @@ -1226,6 +1274,7 @@ public void testAtomicSequenceTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicSequenceConstantTopologyChange() throws Exception { doTestAtomicSequence(new ConstantTopologyChangeWorker(TOP_CHANGE_THREAD_CNT, true)); } @@ -1233,6 +1282,7 @@ public void testAtomicSequenceConstantTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicSequenceConstantMultipleTopologyChange() throws Exception { doTestAtomicSequence(multipleTopologyChangeWorker(TOP_CHANGE_THREAD_CNT)); } @@ -1272,6 +1322,7 @@ private void doTestAtomicSequence(ConstantTopologyChangeWorker topWorker) throws /** * @throws Exception If failed. */ + @Test public void testUncommitedTxLeave() throws Exception { final int val = 10; @@ -1320,7 +1371,7 @@ private class ConstantTopologyChangeWorker { protected final AtomicBoolean failed = new AtomicBoolean(false); /** */ - private final int topChangeThreads; + protected final int topChangeThreads; /** Flag to enable circular topology change. */ private boolean circular; @@ -1445,7 +1496,7 @@ public MultipleTopologyChangeWorker(int topChangeThreads) { throw F.wrap(e); } } - }, TOP_CHANGE_THREAD_CNT, "topology-change-thread"); + }, topChangeThreads, "topology-change-thread"); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java index 5b3d201917d44..1cf1b11a87e0d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java @@ -37,6 +37,9 @@ import org.apache.ignite.internal.processors.datastructures.GridCacheQueueHeaderKey; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -44,6 +47,7 @@ /** * Queue failover test. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractQueueFailoverDataConsistencySelfTest extends IgniteCollectionAbstractTest { /** */ private static final String QUEUE_NAME = "FailoverQueueTest"; @@ -104,6 +108,7 @@ public abstract class GridCacheAbstractQueueFailoverDataConsistencySelfTest exte /** * @throws Exception If failed. */ + @Test public void testAddFailover() throws Exception { testAddFailover(false); } @@ -111,6 +116,7 @@ public void testAddFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddFailoverCollocated() throws Exception { testAddFailover(true); } @@ -199,6 +205,7 @@ private void testAddFailover(IgniteQueue queue, final List kil /** * @throws Exception If failed. */ + @Test public void testPollFailover() throws Exception { testPollFailover(false); } @@ -206,6 +213,7 @@ public void testPollFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPollFailoverCollocated() throws Exception { testPollFailover(true); } @@ -380,4 +388,4 @@ private int primaryQueueNode(IgniteQueue queue) throws Exception { return -1; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java index 015d154ed0e37..a4d4094d0cc91 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java @@ -25,6 +25,9 @@ import org.apache.ignite.configuration.AtomicConfiguration; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -32,6 +35,7 @@ /** * Basic tests for atomic reference. */ +@RunWith(JUnit4.class) public abstract class GridCacheAtomicReferenceApiSelfAbstractTest extends IgniteAtomicsAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -43,6 +47,7 @@ public abstract class GridCacheAtomicReferenceApiSelfAbstractTest extends Ignite * * @throws Exception If failed. */ + @Test public void testPrepareAtomicReference() throws Exception { /* Name of first atomic. */ String atomicName1 = UUID.randomUUID().toString(); @@ -81,6 +86,7 @@ public void testPrepareAtomicReference() throws Exception { * * @throws Exception If failed. */ + @Test public void testSetAndGet() throws Exception { String atomicName = UUID.randomUUID().toString(); @@ -100,6 +106,7 @@ public void testSetAndGet() throws Exception { * * @throws Exception If failed. */ + @Test public void testCompareAndSetSimpleValue() throws Exception { String atomicName = UUID.randomUUID().toString(); @@ -123,6 +130,7 @@ public void testCompareAndSetSimpleValue() throws Exception { * * @throws Exception If failed. */ + @Test public void testCompareAndSetNullValue() throws Exception { String atomicName = UUID.randomUUID().toString(); @@ -142,6 +150,7 @@ public void testCompareAndSetNullValue() throws Exception { * * @throws Exception If failed. */ + @Test public void testIsolation() throws Exception { Ignite ignite = grid(0); @@ -192,6 +201,7 @@ public void testIsolation() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleStructuresInDifferentGroups() throws Exception { Ignite ignite = grid(0); @@ -253,4 +263,4 @@ public void testMultipleStructuresInDifferentGroups() throws Exception { assertNotNull(ignite.atomicReference("ref4", cfg, "d", false)); assertNotNull(ignite.atomicReference("ref6", cfg, "f", false)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceMultiNodeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceMultiNodeAbstractTest.java index 8331454583934..b6c88a6a0a9cd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceMultiNodeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceMultiNodeAbstractTest.java @@ -22,10 +22,14 @@ import org.apache.ignite.IgniteAtomicReference; import org.apache.ignite.IgniteAtomicStamped; import org.apache.ignite.lang.IgniteCallable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * AtomicReference and AtomicStamped multi node tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheAtomicReferenceMultiNodeAbstractTest extends IgniteAtomicsAbstractTest { /** */ protected static final int GRID_CNT = 4; @@ -40,6 +44,7 @@ public abstract class GridCacheAtomicReferenceMultiNodeAbstractTest extends Igni * * @throws Exception If failed. */ + @Test public void testAtomicReference() throws Exception { // Get random name of reference. final String refName = UUID.randomUUID().toString(); @@ -96,6 +101,7 @@ public void testAtomicReference() throws Exception { * * @throws Exception If failed. */ + @Test public void testAtomicStamped() throws Exception { // Get random name of stamped. final String stampedName = UUID.randomUUID().toString(); @@ -153,4 +159,4 @@ public void testAtomicStamped() throws Exception { } }); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicStampedApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicStampedApiSelfAbstractTest.java index 9629e8b715b1f..f5e93ae13b129 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicStampedApiSelfAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicStampedApiSelfAbstractTest.java @@ -25,6 +25,9 @@ import org.apache.ignite.configuration.AtomicConfiguration; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -32,6 +35,7 @@ /** * Basic tests for atomic stamped. */ +@RunWith(JUnit4.class) public abstract class GridCacheAtomicStampedApiSelfAbstractTest extends IgniteAtomicsAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -43,6 +47,7 @@ public abstract class GridCacheAtomicStampedApiSelfAbstractTest extends IgniteAt * * @throws Exception If failed. */ + @Test public void testPrepareAtomicStamped() throws Exception { /** Name of first atomic. */ String atomicName1 = UUID.randomUUID().toString(); @@ -81,6 +86,7 @@ public void testPrepareAtomicStamped() throws Exception { * * @throws Exception If failed. */ + @Test public void testSetAndGet() throws Exception { String atomicName = UUID.randomUUID().toString(); @@ -105,6 +111,7 @@ public void testSetAndGet() throws Exception { * * @throws Exception If failed. */ + @Test public void testCompareAndSetSimpleValue() throws Exception { String atomicName = UUID.randomUUID().toString(); @@ -132,6 +139,7 @@ public void testCompareAndSetSimpleValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIsolation() throws Exception { Ignite ignite = grid(0); @@ -186,6 +194,7 @@ public void testIsolation() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleStructuresInDifferentGroups() throws Exception { Ignite ignite = grid(0); @@ -226,4 +235,4 @@ public void testMultipleStructuresInDifferentGroups() throws Exception { assertNotNull(ignite.atomicStamped("atomic1", "a", 1, false)); assertNotNull(ignite.atomicStamped("atomic3", cfg, "c", 3, false)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java index ef97c91f03230..d25f4057a79b0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java @@ -43,6 +43,9 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -51,6 +54,7 @@ /** * Queue basic tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheQueueApiSelfAbstractTest extends IgniteCollectionAbstractTest { /** */ private static final int QUEUE_CAPACITY = 3; @@ -68,6 +72,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends IgniteCollection * * @throws Exception If failed. */ + @Test public void testPrepareQueue() throws Exception { // Random sequence names. String queueName1 = UUID.randomUUID().toString(); @@ -99,6 +104,7 @@ public void testPrepareQueue() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -117,6 +123,7 @@ public void testAddUnbounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddDeleteUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -137,6 +144,7 @@ public void testAddDeleteUnbounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testCollectionMethods() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -213,6 +221,7 @@ public void testCollectionMethods() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddPollUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -235,6 +244,7 @@ public void testAddPollUnbounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddPeekUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -258,6 +268,7 @@ public void testAddPeekUnbounded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIterator() throws Exception { checkIterator(false); } @@ -265,6 +276,7 @@ public void testIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorCollocated() throws Exception { checkIterator(true); } @@ -328,6 +340,7 @@ private void checkIterator(boolean collocated) { * * @throws Exception If failed. */ + @Test public void testPutGetUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -350,6 +363,7 @@ public void testPutGetUnbounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutGetMultithreadUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -378,6 +392,7 @@ public void testPutGetMultithreadUnbounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutGetMultithreadBounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -405,6 +420,7 @@ public void testPutGetMultithreadBounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testQueueRemoveMultithreadBounded() throws Exception { // Random queue name. final String queueName = UUID.randomUUID().toString(); @@ -485,6 +501,7 @@ public void testQueueRemoveMultithreadBounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutRemoveUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -510,6 +527,7 @@ public void testPutRemoveUnbounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutRemoveMultiThreadedUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -544,6 +562,7 @@ public void testPutRemoveMultiThreadedUnbounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutRemovePeekPollUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -575,6 +594,7 @@ public void testPutRemovePeekPollUnbounded() throws Exception { * * @throws Exception If failed. */ + @Test public void testRemovePeek() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -608,6 +628,7 @@ public void testRemovePeek() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReuseCache() throws Exception { CollectionConfiguration colCfg = collectionConfiguration(); @@ -621,6 +642,7 @@ public void testReuseCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotReuseCache() throws Exception { CollectionConfiguration colCfg1 = collectionConfiguration(); @@ -641,6 +663,7 @@ public void testNotReuseCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFilterNode() throws Exception { CollectionConfiguration colCfg1 = collectionConfiguration(); @@ -667,6 +690,7 @@ public void testFilterNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSystemCache() throws Exception { CollectionConfiguration colCfg = collectionConfiguration(); @@ -687,6 +711,7 @@ public void testSystemCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityRun() throws Exception { final CollectionConfiguration colCfg = collectionConfiguration(); @@ -735,6 +760,7 @@ public void testAffinityRun() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityCall() throws Exception { final CollectionConfiguration colCfg = collectionConfiguration(); @@ -788,6 +814,7 @@ public void testAffinityCall() throws Exception { * * @throws Exception If failed. */ + @Test public void testIsolation() throws Exception { Ignite ignite = grid(0); @@ -841,6 +868,7 @@ public void testIsolation() throws Exception { * * @throws Exception If failed. */ + @Test public void testCacheReuse() throws Exception { Ignite ignite = grid(0); @@ -877,6 +905,7 @@ public void testCacheReuse() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleStructuresInDifferentGroups() throws Exception { Ignite ignite = grid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueCleanupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueCleanupSelfTest.java index 75183b0c36609..6489eb803fd76 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueCleanupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueCleanupSelfTest.java @@ -36,6 +36,9 @@ import org.apache.ignite.internal.processors.datastructures.GridCacheQueueHeaderKey; import org.apache.ignite.internal.util.typedef.PAX; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -43,6 +46,7 @@ /** * Tests cleanup of orphaned queue items. */ +@RunWith(JUnit4.class) public class GridCacheQueueCleanupSelfTest extends IgniteCollectionAbstractTest { /** */ private static final String QUEUE_NAME1 = "CleanupTestQueue1"; @@ -77,6 +81,7 @@ public class GridCacheQueueCleanupSelfTest extends IgniteCollectionAbstractTest /** * @throws Exception If failed. */ + @Test public void testCleanup() throws Exception { IgniteQueue queue = grid(0).queue(QUEUE_NAME1, 0, config(false)); @@ -234,4 +239,4 @@ private IgniteInternalFuture startAddPollThread(final Ignite ignite, final At } }); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueClientDisconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueClientDisconnectTest.java index dac3ff6730e41..0b66ebc0cf6ab 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueClientDisconnectTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueClientDisconnectTest.java @@ -1,127 +1,121 @@ -/* - * 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. - */ - -package org.apache.ignite.internal.processors.cache.datastructures; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteClientDisconnectedException; -import org.apache.ignite.IgniteQueue; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.configuration.CollectionConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * - */ -public class GridCacheQueueClientDisconnectTest extends GridCommonAbstractTest { - /** */ - private static final String IGNITE_QUEUE_NAME = "ignite-queue-client-reconnect-test"; - - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final int FAILURE_DETECTION_TIMEOUT = 10_000; - - /** */ - private boolean clientMode; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - spi.setClientReconnectDisabled(false); - - cfg.setDiscoverySpi(spi); - - cfg.setFailureDetectionTimeout(FAILURE_DETECTION_TIMEOUT); - cfg.setClientFailureDetectionTimeout(FAILURE_DETECTION_TIMEOUT); - - if (clientMode) - cfg.setClientMode(true); - - return cfg; - } - - /** - * @param cacheAtomicityMode Atomicity mode. - * @return Configuration. - */ - private static CollectionConfiguration collectionConfiguration(CacheAtomicityMode cacheAtomicityMode) { - CollectionConfiguration colCfg = new CollectionConfiguration(); - - colCfg.setAtomicityMode(cacheAtomicityMode); - - return colCfg; - } - - /** - * @throws Exception If failed. - */ - public void testClientDisconnect() throws Exception { - try { - Ignite server = startGrid(0); - - clientMode = true; - - Ignite client = startGrid(1); - - awaitPartitionMapExchange(); - - final IgniteQueue queue = client.queue( - IGNITE_QUEUE_NAME, 0, collectionConfiguration(CacheAtomicityMode.ATOMIC)); - - final CountDownLatch latch = new CountDownLatch(1); - - GridTestUtils.runAsync(new Runnable() { - @Override public void run() { - try { - Object value = queue.take(); - } - catch (IgniteClientDisconnectedException icd) { - latch.countDown(); - } - catch (Exception e) { - } - } - }); - - U.sleep(5000); - - server.close(); - - boolean countReachedZero = latch.await(FAILURE_DETECTION_TIMEOUT * 2, TimeUnit.MILLISECONDS); - - assertTrue("IgniteClientDisconnectedException was not thrown", countReachedZero); - } - finally { - stopAllGrids(); - } - } -} +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.datastructures; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteClientDisconnectedException; +import org.apache.ignite.IgniteQueue; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.configuration.CollectionConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * + */ +@RunWith(JUnit4.class) +public class GridCacheQueueClientDisconnectTest extends GridCommonAbstractTest { + /** */ + private static final String IGNITE_QUEUE_NAME = "ignite-queue-client-reconnect-test"; + + /** */ + private static final int FAILURE_DETECTION_TIMEOUT = 10_000; + + /** */ + private boolean clientMode; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setClientReconnectDisabled(false); + + cfg.setFailureDetectionTimeout(FAILURE_DETECTION_TIMEOUT); + cfg.setClientFailureDetectionTimeout(FAILURE_DETECTION_TIMEOUT); + + if (clientMode) + cfg.setClientMode(true); + + return cfg; + } + + /** + * @param cacheAtomicityMode Atomicity mode. + * @return Configuration. + */ + private static CollectionConfiguration collectionConfiguration(CacheAtomicityMode cacheAtomicityMode) { + CollectionConfiguration colCfg = new CollectionConfiguration(); + + colCfg.setAtomicityMode(cacheAtomicityMode); + + return colCfg; + } + + /** + * @throws Exception If failed. + */ + @Test + public void testClientDisconnect() throws Exception { + try { + Ignite server = startGrid(0); + + clientMode = true; + + Ignite client = startGrid(1); + + awaitPartitionMapExchange(); + + final IgniteQueue queue = client.queue( + IGNITE_QUEUE_NAME, 0, collectionConfiguration(CacheAtomicityMode.ATOMIC)); + + final CountDownLatch latch = new CountDownLatch(1); + + GridTestUtils.runAsync(new Runnable() { + @Override public void run() { + try { + Object value = queue.take(); + } + catch (IgniteClientDisconnectedException icd) { + latch.countDown(); + } + catch (Exception e) { + } + } + }); + + U.sleep(5000); + + server.close(); + + boolean countReachedZero = latch.await(FAILURE_DETECTION_TIMEOUT * 2, TimeUnit.MILLISECONDS); + + assertTrue("IgniteClientDisconnectedException was not thrown", countReachedZero); + } + finally { + stopAllGrids(); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueJoinedNodeSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueJoinedNodeSelfAbstractTest.java index eb8c3c08eef78..a418b01eb2616 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueJoinedNodeSelfAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueJoinedNodeSelfAbstractTest.java @@ -33,21 +33,20 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that joining node is able to take items from queue. * See GG-2311 for more information. */ +@RunWith(JUnit4.class) public abstract class GridCacheQueueJoinedNodeSelfAbstractTest extends IgniteCollectionAbstractTest { /** */ protected static final int GRID_CNT = 3; - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ protected static final int ITEMS_CNT = 300; @@ -59,6 +58,7 @@ public abstract class GridCacheQueueJoinedNodeSelfAbstractTest extends IgniteCol /** * @throws Exception If failed. */ + @Test public void testTakeFromJoined() throws Exception { String queueName = UUID.randomUUID().toString(); @@ -283,4 +283,4 @@ private void awaitDone() throws IgniteInterruptedCheckedException { return S.toString(TakeJob.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeAbstractSelfTest.java index f62d165778f47..4e691dd8ea8ab 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeAbstractSelfTest.java @@ -39,10 +39,14 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Queue multi node tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheQueueMultiNodeAbstractSelfTest extends IgniteCollectionAbstractTest { /** */ private static final int GRID_CNT = 4; @@ -110,6 +114,7 @@ public abstract class GridCacheQueueMultiNodeAbstractSelfTest extends IgniteColl /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { String queueName = UUID.randomUUID().toString(); @@ -125,6 +130,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutPollCollocated() throws Exception { try { final String queueName = UUID.randomUUID().toString(); @@ -227,7 +233,7 @@ public void testPutPollCollocated() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("unchecked") + @Test public void testAddAll() throws Exception { try { String queueName = UUID.randomUUID().toString(); @@ -256,6 +262,7 @@ public void testAddAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { String queueName = UUID.randomUUID().toString(); @@ -279,6 +286,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutTake() throws Exception { String queueName = UUID.randomUUID().toString(); @@ -298,6 +306,7 @@ public void testPutTake() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddMultinode() throws Exception { testAddMultinode(true); @@ -361,6 +370,7 @@ private void testAddMultinode(final boolean collocated) throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddPollMultinode() throws Exception { testAddPollMultinode(true); @@ -465,6 +475,7 @@ private void testAddPollMultinode(final boolean collocated) throws Exception { /** * @throws Exception If failed. */ + @Test public void testIterator() throws Exception { final String queueName = UUID.randomUUID().toString(); @@ -513,6 +524,7 @@ public void testIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSerialization() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); @@ -776,4 +788,4 @@ protected static class PutTakeJob implements IgniteCallable { return S.toString(PutTakeJob.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeConsistencySelfTest.java index a48c3e29982ec..8d79ca36fe5d8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeConsistencySelfTest.java @@ -31,6 +31,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -40,6 +43,7 @@ /** * Consistency test for cache queue in multi node environment. */ +@RunWith(JUnit4.class) public class GridCacheQueueMultiNodeConsistencySelfTest extends IgniteCollectionAbstractTest { /** */ protected static final int GRID_CNT = 3; @@ -93,6 +97,7 @@ public class GridCacheQueueMultiNodeConsistencySelfTest extends IgniteCollection /** * @throws Exception If failed. */ + @Test public void testIteratorIfBackupDisabled() throws Exception { backups = 0; @@ -102,6 +107,7 @@ public void testIteratorIfBackupDisabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorIfNoPreloadingAndBackupDisabledAndRepartitionForced() throws Exception { backups = 0; @@ -113,6 +119,7 @@ public void testIteratorIfNoPreloadingAndBackupDisabledAndRepartitionForced() th /** * @throws Exception If failed. */ + @Test public void testIteratorIfBackupEnabled() throws Exception { backups = 1; @@ -122,6 +129,7 @@ public void testIteratorIfBackupEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorIfBackupEnabledAndOneNodeIsKilled() throws Exception { backups = 1; @@ -203,4 +211,4 @@ private void checkCacheQueue() throws Exception { queue0.close(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueRotativeMultiNodeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueRotativeMultiNodeAbstractTest.java index d10a020a4a459..b816efd98638c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueRotativeMultiNodeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueRotativeMultiNodeAbstractTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Queue multi node tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheQueueRotativeMultiNodeAbstractTest extends IgniteCollectionAbstractTest { /** */ protected static final int GRID_CNT = 4; @@ -79,6 +83,7 @@ public abstract class GridCacheQueueRotativeMultiNodeAbstractTest extends Ignite * * @throws Exception If failed. */ + @Test public void testPutRotativeNodes() throws Exception { String queueName = UUID.randomUUID().toString(); @@ -108,6 +113,7 @@ public void testPutRotativeNodes() throws Exception { * * @throws Exception If failed. */ + @Test public void testPutTakeRotativeNodes() throws Exception { String queueName = UUID.randomUUID().toString(); @@ -137,6 +143,7 @@ public void testPutTakeRotativeNodes() throws Exception { * * @throws Exception If failed. */ + @Test public void testTakeRemoveRotativeNodes() throws Exception { lthTake = new CountDownLatch(1); @@ -378,4 +385,4 @@ protected static class RemoveQueueJob implements IgniteCallable { return S.toString(RemoveQueueJob.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceApiSelfAbstractTest.java index 81292c7cbefcf..0924d4c0af11c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceApiSelfAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceApiSelfAbstractTest.java @@ -38,6 +38,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -46,6 +49,7 @@ /** * Cache sequence basic tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheSequenceApiSelfAbstractTest extends IgniteAtomicsAbstractTest { /** */ protected static final int BATCH_SIZE = 3; @@ -145,6 +149,7 @@ public abstract class GridCacheSequenceApiSelfAbstractTest extends IgniteAtomics /** * @throws Exception If failed. */ + @Test public void testPrepareSequence() throws Exception { // Random sequence names. String locSeqName1 = UUID.randomUUID().toString(); @@ -169,6 +174,7 @@ public void testPrepareSequence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddWrongValue() throws Exception { for (IgniteAtomicSequence seq : seqArr) { try { @@ -194,6 +200,7 @@ public void testAddWrongValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndIncrement() throws Exception { for (int i = 0; i < MAX_LOOPS_NUM; i++) { for (IgniteAtomicSequence seq : seqArr) @@ -207,6 +214,7 @@ public void testGetAndIncrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrementAndGet() throws Exception { for (int i = 0; i < MAX_LOOPS_NUM; i++) { for (IgniteAtomicSequence seq : seqArr) @@ -220,6 +228,7 @@ public void testIncrementAndGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddAndGet() throws Exception { for (int i = 1; i < MAX_LOOPS_NUM; i++) { for (IgniteAtomicSequence seq : seqArr) @@ -233,6 +242,7 @@ public void testAddAndGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndAdd() throws Exception { for (int i = 1; i < MAX_LOOPS_NUM; i++) { for (IgniteAtomicSequence seq : seqArr) @@ -246,6 +256,7 @@ public void testGetAndAdd() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndAddInTx() throws Exception { try (Transaction tx = grid().transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { for (int i = 1; i < MAX_LOOPS_NUM; i++) { @@ -261,6 +272,7 @@ public void testGetAndAddInTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSequenceIntegrity0() throws Exception { // Random sequence names. String locSeqName1 = UUID.randomUUID().toString(); @@ -294,6 +306,7 @@ public void testSequenceIntegrity0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSequenceIntegrity1() throws Exception { sequenceIntegrity(1, 0); sequenceIntegrity(7, -1500); @@ -303,6 +316,7 @@ public void testSequenceIntegrity1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultiThreadedSequenceIntegrity() throws Exception { multiThreadedSequenceIntegrity(1, 0); multiThreadedSequenceIntegrity(7, -1500); @@ -312,6 +326,7 @@ public void testMultiThreadedSequenceIntegrity() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { String locSeqName = UUID.randomUUID().toString(); @@ -334,6 +349,7 @@ public void testRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheSets() throws Exception { // Make new atomic sequence in cache. IgniteAtomicSequence seq = grid().atomicSequence(UUID.randomUUID().toString(), 0, true); @@ -363,6 +379,7 @@ public void testCacheSets() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleStructuresInDifferentGroups() throws Exception { Ignite ignite = grid(0); @@ -404,6 +421,7 @@ public void testMultipleStructuresInDifferentGroups() throws Exception { * * @throws Exception If failed. */ + @Test public void testSequenceReserveSizeFromExplicitConfiguration() throws Exception { Ignite ignite = grid(0); @@ -631,4 +649,4 @@ private void removeSequence(String name) throws Exception { assertNull(grid().atomicSequence(name, 0, false)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceMultiNodeAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceMultiNodeAbstractSelfTest.java index 7747d1bd2a80b..48d36b537c17d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceMultiNodeAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSequenceMultiNodeAbstractSelfTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.LoggerResource; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Sequence multi node tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheSequenceMultiNodeAbstractSelfTest extends IgniteAtomicsAbstractTest implements Externalizable { /** */ @@ -59,6 +63,7 @@ public abstract class GridCacheSequenceMultiNodeAbstractSelfTest extends IgniteA * * @throws Exception If failed. */ + @Test public void testIncrementAndGet() throws Exception { Collection res = new HashSet<>(); @@ -94,6 +99,7 @@ public void testIncrementAndGet() throws Exception { * * @throws Exception If failed. */ + @Test public void testGetAndIncrement() throws Exception { Collection res = new HashSet<>(); @@ -129,6 +135,7 @@ public void testGetAndIncrement() throws Exception { * * @throws Exception If failed. */ + @Test public void testMarshalling() throws Exception { String seqName = UUID.randomUUID().toString(); @@ -266,4 +273,4 @@ private static class GetAndIncrementJob implements IgniteCallable> { return S.toString(GetAndIncrementJob.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetAbstractSelfTest.java index 59f13d9b0151e..bb1b8d54e521f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetAbstractSelfTest.java @@ -32,6 +32,7 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteCluster; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteSet; import org.apache.ignite.cache.CacheMode; @@ -52,6 +53,9 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -62,6 +66,7 @@ /** * Cache set tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheSetAbstractSelfTest extends IgniteCollectionAbstractTest { /** */ protected static final String SET_NAME = "testSet"; @@ -166,6 +171,7 @@ private void assertSetIteratorsCleared() { /** * @throws Exception If failed. */ + @Test public void testCreateRemove() throws Exception { testCreateRemove(false); } @@ -173,6 +179,7 @@ public void testCreateRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateRemoveCollocated() throws Exception { testCreateRemove(true); } @@ -181,13 +188,22 @@ public void testCreateRemoveCollocated() throws Exception { * @param collocated Collocation flag. * @throws Exception If failed. */ - private void testCreateRemove(boolean collocated) throws Exception { + protected void testCreateRemove(boolean collocated) throws Exception { + testCreateRemove(collocated, 0); + } + + /** + * @param collocated Collocation flag. + * @param nodeIdx Index of the node from which to create set. + * @throws Exception If failed. + */ + protected void testCreateRemove(boolean collocated, int nodeIdx) throws Exception { for (int i = 0; i < gridCount(); i++) assertNull(grid(i).set(SET_NAME, null)); CollectionConfiguration colCfg0 = config(collocated); - IgniteSet set0 = grid(0).set(SET_NAME, colCfg0); + IgniteSet set0 = grid(nodeIdx).set(SET_NAME, colCfg0); assertNotNull(set0); @@ -233,6 +249,7 @@ private void testCreateRemove(boolean collocated) throws Exception { /** * @throws Exception If failed. */ + @Test public void testApi() throws Exception { testApi(false); } @@ -240,6 +257,7 @@ public void testApi() throws Exception { /** * @throws Exception If failed. */ + @Test public void testApiCollocated() throws Exception { testApi(true); } @@ -396,6 +414,7 @@ private void testApi(boolean collocated) throws Exception { /** * @throws Exception If failed. */ + @Test public void testIterator() throws Exception { testIterator(false); } @@ -403,6 +422,7 @@ public void testIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorCollocated() throws Exception { testIterator(true); } @@ -411,11 +431,19 @@ public void testIteratorCollocated() throws Exception { * @param collocated Collocation flag. * @throws Exception If failed. */ - @SuppressWarnings("deprecation") - private void testIterator(boolean collocated) throws Exception { + protected void testIterator(boolean collocated) throws Exception { + testIterator(collocated, 0); + } + + /** + * @param collocated Collocation flag. + * @param nodeIdx Index of the node from which to create set. + * @throws Exception If failed. + */ + protected void testIterator(boolean collocated, int nodeIdx) throws Exception { CollectionConfiguration colCfg = config(collocated); - final IgniteSet set0 = grid(0).set(SET_NAME, colCfg); + final IgniteSet set0 = grid(nodeIdx).set(SET_NAME, colCfg); for (int i = 0; i < gridCount(); i++) { IgniteSet set = grid(i).set(SET_NAME, null); @@ -488,6 +516,7 @@ private void testIterator(boolean collocated) throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorClose() throws Exception { testIteratorClose(false); } @@ -495,6 +524,7 @@ public void testIteratorClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorCloseCollocated() throws Exception { testIteratorClose(true); } @@ -573,6 +603,7 @@ private void createIterators(IgniteSet set) { /** * @throws Exception If failed. */ + @Test public void testNodeJoinsAndLeaves() throws Exception { if (collectionCacheMode() == LOCAL) return; @@ -583,6 +614,7 @@ public void testNodeJoinsAndLeaves() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeJoinsAndLeavesCollocated() throws Exception { if (collectionCacheMode() == LOCAL) return; @@ -633,6 +665,7 @@ private void testNodeJoinsAndLeaves(boolean collocated) throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreaded() throws Exception { testMultithreaded(false); } @@ -640,6 +673,7 @@ public void testMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedCollocated() throws Exception { if (collectionCacheMode() != PARTITIONED) return; @@ -719,6 +753,7 @@ private void testMultithreaded(final boolean collocated) throws Exception { /** * @throws Exception If failed. */ + @Test public void testCleanup() throws Exception { testCleanup(false); } @@ -726,6 +761,7 @@ public void testCleanup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCleanupCollocated() throws Exception { testCleanup(true); } @@ -734,7 +770,6 @@ public void testCleanupCollocated() throws Exception { * @param collocated Collocation flag. * @throws Exception If failed. */ - @SuppressWarnings("WhileLoopReplaceableByForEach") private void testCleanup(boolean collocated) throws Exception { CollectionConfiguration colCfg = config(collocated); @@ -833,6 +868,7 @@ private void testCleanup(boolean collocated) throws Exception { /** * @throws Exception If failed. */ + @Test public void testSerialization() throws Exception { final IgniteSet set = grid(0).set(SET_NAME, config(false)); @@ -841,7 +877,9 @@ public void testSerialization() throws Exception { for (int i = 0; i < 10; i++) set.add(i); - Collection c = grid(0).compute().broadcast(new IgniteCallable() { + IgniteCluster cluster = grid(0).cluster(); + + Collection c = grid(0).compute(cluster).broadcast(new IgniteCallable() { @Override public Integer call() throws Exception { assertEquals(SET_NAME, set.name()); @@ -858,6 +896,7 @@ public void testSerialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityRun() throws Exception { final CollectionConfiguration colCfg = collectionConfiguration(); @@ -908,6 +947,7 @@ public void testAffinityRun() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityCall() throws Exception { final CollectionConfiguration colCfg = collectionConfiguration(); @@ -963,6 +1003,7 @@ public void testAffinityCall() throws Exception { * * @throws Exception If failed. */ + @Test public void testIsolation() throws Exception { CollectionConfiguration colCfg = collectionConfiguration(); @@ -1008,6 +1049,7 @@ public void testIsolation() throws Exception { /** * Test that non collocated sets are stored in a separated cache. */ + @Test public void testCacheReuse() { testCacheReuse(false); } @@ -1015,6 +1057,7 @@ public void testCacheReuse() { /** * Test that collocated sets within the same group and compatible configurations are stored in the same cache. */ + @Test public void testCacheReuseCollocated() { testCacheReuse(true); } @@ -1062,7 +1105,8 @@ private void testCacheReuse(boolean collocated) { * * @throws Exception If failed. */ - public void _testMultipleStructuresInDifferentGroups() throws Exception { + @Test + public void testMultipleStructuresInDifferentGroups() throws Exception { Ignite ignite = grid(0); CollectionConfiguration cfg1 = collectionConfiguration(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java index ce320bd4a5ec6..16c93635c8391 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java @@ -36,12 +36,16 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Set failover tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheSetFailoverAbstractSelfTest extends IgniteCollectionAbstractTest { /** */ private static final String SET_NAME = "testFailoverSet"; @@ -88,6 +92,7 @@ public abstract class GridCacheSetFailoverAbstractSelfTest extends IgniteCollect * @throws Exception If failed. */ @SuppressWarnings("WhileLoopReplaceableByForEach") + @Test public void testNodeRestart() throws Exception { IgniteSet set = grid(0).set(SET_NAME, config(false)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicLongApiAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicLongApiAbstractSelfTest.java index d2cb361fee6ff..6b02ec46bb48e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicLongApiAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicLongApiAbstractSelfTest.java @@ -26,12 +26,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * Cache atomic long api test. */ +@RunWith(JUnit4.class) public abstract class IgniteAtomicLongApiAbstractSelfTest extends IgniteAtomicsAbstractTest { /** Random number generator. */ private static final Random RND = new Random(); @@ -61,6 +65,7 @@ public abstract class IgniteAtomicLongApiAbstractSelfTest extends IgniteAtomicsA /** * @throws Exception If failed. */ + @Test public void testCreateRemove() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -102,6 +107,7 @@ public void testCreateRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIncrementAndGet() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -118,6 +124,7 @@ public void testIncrementAndGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndIncrement() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -134,6 +141,7 @@ public void testGetAndIncrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDecrementAndGet() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -150,6 +158,7 @@ public void testDecrementAndGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndDecrement() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -166,6 +175,7 @@ public void testGetAndDecrement() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndAdd() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -184,6 +194,7 @@ public void testGetAndAdd() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAddAndGet() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -202,6 +213,7 @@ public void testAddAndGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndSet() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -220,7 +232,7 @@ public void testGetAndSet() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"NullableProblems", "ConstantConditions"}) + @Test public void testCompareAndSet() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -246,6 +258,7 @@ public void testCompareAndSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetAndSetInTx() throws Exception { info("Running test [name=" + getName() + ", cacheMode=" + atomicsCacheMode() + ']'); @@ -273,6 +286,7 @@ public void testGetAndSetInTx() throws Exception { * * @throws Exception If failed. */ + @Test public void testIsolation() throws Exception { Ignite ignite = grid(0); @@ -299,6 +313,7 @@ public void testIsolation() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleStructuresInDifferentGroups() throws Exception { Ignite ignite = grid(0); @@ -339,4 +354,4 @@ public void testMultipleStructuresInDifferentGroups() throws Exception { assertNotNull(ignite.atomicLong("atomic1", 1, false)); assertNotNull(ignite.atomicLong("atomic3", cfg, 3, false)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicsAbstractTest.java index 8c8e30fe051ef..4ebc67532deda 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicsAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicsAbstractTest.java @@ -20,28 +20,16 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.AtomicConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** * */ public abstract class IgniteAtomicsAbstractTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - AtomicConfiguration atomicCfg = atomicConfiguration(); assertNotNull(atomicCfg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java index 118ea52c0ab1c..909a87046545f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteClientDataStructuresAbstractTest.java @@ -39,18 +39,17 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteClientDataStructuresAbstractTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODE_CNT = 4; @@ -65,8 +64,6 @@ public abstract class IgniteClientDataStructuresAbstractTest extends GridCommonA ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); } - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); return cfg; @@ -87,6 +84,7 @@ public abstract class IgniteClientDataStructuresAbstractTest extends GridCommonA /** * @throws Exception If failed. */ + @Test public void testSequence() throws Exception { Ignite clientNode = clientIgnite(); Ignite srvNode = serverNode(); @@ -147,6 +145,7 @@ private void testSequence(Ignite creator, Ignite other) throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicLong() throws Exception { Ignite clientNode = clientIgnite(); Ignite srvNode = serverNode(); @@ -226,6 +225,7 @@ private void assertAtomicLongClosedCorrect(IgniteAtomicLong atomicLong) { /** * @throws Exception If failed. */ + @Test public void testSet() throws Exception { Ignite clientNode = clientIgnite(); Ignite srvNode = serverNode(); @@ -274,6 +274,7 @@ private void testSet(Ignite creator, Ignite other) throws Exception { /** * @throws Exception If failed. */ + @Test public void testLatch() throws Exception { Ignite clientNode = clientIgnite(); Ignite srvNode = serverNode(); @@ -352,6 +353,7 @@ private void testLatch(Ignite creator, final Ignite other) throws Exception { /** * @throws Exception If failed. */ + @Test public void testSemaphore() throws Exception { Ignite clientNode = clientIgnite(); Ignite srvNode = serverNode(); @@ -430,6 +432,7 @@ private void testSemaphore(Ignite creator, final Ignite other) throws Exception /** * @throws Exception If failed. */ + @Test public void testReentrantLock() throws Exception { Ignite clientNode = clientIgnite(); Ignite srvNode = serverNode(); @@ -520,6 +523,7 @@ private void testReentrantLock(Ignite creator, final Ignite other) throws Except /** * @throws Exception If failed. */ + @Test public void testQueue() throws Exception { Ignite clientNode = clientIgnite(); Ignite srvNode = serverNode(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCollectionAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCollectionAbstractTest.java index f7e12dd29da3e..f3fbbfa21382f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCollectionAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCollectionAbstractTest.java @@ -30,9 +30,6 @@ import org.apache.ignite.internal.processors.datastructures.GridCacheSetImpl; import org.apache.ignite.internal.processors.datastructures.GridCacheSetProxy; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -42,21 +39,12 @@ * */ public abstract class IgniteCollectionAbstractTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - return cfg; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCountDownLatchAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCountDownLatchAbstractSelfTest.java index 4dcdbb7a6cf4b..7cbf3ccb42a7d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCountDownLatchAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCountDownLatchAbstractSelfTest.java @@ -48,6 +48,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.MINUTES; @@ -58,6 +61,7 @@ /** * Cache count down latch self test. */ +@RunWith(JUnit4.class) public abstract class IgniteCountDownLatchAbstractSelfTest extends IgniteAtomicsAbstractTest implements Externalizable { /** */ @@ -77,6 +81,7 @@ public abstract class IgniteCountDownLatchAbstractSelfTest extends IgniteAtomics /** * @throws Exception If failed. */ + @Test public void testLatch() throws Exception { checkLatch(); } @@ -87,6 +92,7 @@ public void testLatch() throws Exception { * * @throws Exception If failed. */ + @Test public void testIsolation() throws Exception { Ignite ignite = grid(0); @@ -325,6 +331,7 @@ private void removeLatch(String latchName) /** * @throws Exception If failed. */ + @Test public void testLatchMultinode1() throws Exception { if (gridCount() == 1) return; @@ -382,6 +389,7 @@ public void testLatchMultinode1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLatchBroadcast() throws Exception { Ignite ignite = grid(0); ClusterGroup srvsGrp = ignite.cluster().forServers(); @@ -434,6 +442,7 @@ private IgniteCountDownLatch createLatch2(Ignite client, int numOfSrvs) { /** * @throws Exception If failed. */ + @Test public void testLatchMultinode2() throws Exception { if (gridCount() == 1) return; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureUniqueNameTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureUniqueNameTest.java index db4754c0a7f54..fa32d698e8c17 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureUniqueNameTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureUniqueNameTest.java @@ -41,6 +41,9 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -48,6 +51,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteDataStructureUniqueNameTest extends IgniteCollectionAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -81,6 +85,7 @@ public class IgniteDataStructureUniqueNameTest extends IgniteCollectionAbstractT /** * @throws Exception If failed. */ + @Test public void testUniqueNameMultithreaded() throws Exception { testUniqueName(true); } @@ -88,6 +93,7 @@ public void testUniqueNameMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUniqueNameMultinode() throws Exception { testUniqueName(false); } @@ -95,6 +101,7 @@ public void testUniqueNameMultinode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateRemove() throws Exception { final String name = IgniteUuid.randomUuid().toString(); @@ -232,6 +239,7 @@ public void testCreateRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUniqueNamePerGroup() throws Exception { Ignite ignite = ignite(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureWithJobTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureWithJobTest.java index 2b99a911e02bb..5b471dc620190 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureWithJobTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteDataStructureWithJobTest.java @@ -23,32 +23,20 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteQueue; import org.apache.ignite.configuration.CollectionConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteDataStructureWithJobTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - /** {@inheritDoc} */ @Override protected long getTestTimeout() { return 2 * 60_000; @@ -57,6 +45,7 @@ public class IgniteDataStructureWithJobTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testJobWithRestart() throws Exception { Ignite ignite = startGrid(0); @@ -103,4 +92,4 @@ public void testJobWithRestart() throws Exception { fut.get(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteExchangeLatchManagerCoordinatorFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteExchangeLatchManagerCoordinatorFailTest.java index d8f23acdfc1da..9aa1fc62ca276 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteExchangeLatchManagerCoordinatorFailTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteExchangeLatchManagerCoordinatorFailTest.java @@ -31,10 +31,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link ExchangeLatchManager} functionality when latch coordinator is failed. */ +@RunWith(JUnit4.class) public class IgniteExchangeLatchManagerCoordinatorFailTest extends GridCommonAbstractTest { /** */ private static final String LATCH_NAME = "test"; @@ -145,6 +149,7 @@ public class IgniteExchangeLatchManagerCoordinatorFailTest extends GridCommonAbs * Node 3 state -> {@link #all} * Node 4 state -> {@link #beforeCreate} */ + @Test public void testCoordinatorFail1() throws Exception { List> nodeStates = Lists.newArrayList( beforeCreate, @@ -164,6 +169,7 @@ public void testCoordinatorFail1() throws Exception { * Node 3 state -> {@link #all} * Node 4 state -> {@link #beforeCreate} */ + @Test public void testCoordinatorFail2() throws Exception { List> nodeStates = Lists.newArrayList( beforeCountDown, @@ -183,6 +189,7 @@ public void testCoordinatorFail2() throws Exception { * Node 3 state -> {@link #all} * Node 4 state -> {@link #beforeCreate} */ + @Test public void testCoordinatorFail3() throws Exception { List> nodeStates = Lists.newArrayList( all, diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteLockAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteLockAbstractSelfTest.java index 812ff23ffd789..0052183540a40 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteLockAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteLockAbstractSelfTest.java @@ -58,7 +58,10 @@ import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; import org.junit.Rule; +import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MICROSECONDS; import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -70,6 +73,7 @@ /** * Cache reentrant lock self test. */ +@RunWith(JUnit4.class) public abstract class IgniteLockAbstractSelfTest extends IgniteAtomicsAbstractTest implements Externalizable { /** */ @@ -93,6 +97,7 @@ public abstract class IgniteLockAbstractSelfTest extends IgniteAtomicsAbstractTe /** * @throws Exception If failed. */ + @Test public void testReentrantLock() throws Exception { checkReentrantLock(false); @@ -102,6 +107,7 @@ public void testReentrantLock() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailover() throws Exception { if (atomicsCacheMode() == LOCAL) return; @@ -121,6 +127,7 @@ public void testFailover() throws Exception { * * @throws Exception If failed. */ + @Test public void testIsolation() throws Exception { Ignite ignite = grid(0); @@ -414,6 +421,7 @@ private void removeReentrantLock(String lockName, final boolean fair) /** * @throws Exception If failed. */ + @Test public void testLockSerialization() throws Exception { final IgniteLock lock = grid(0).reentrantLock("lock", true, true, true); @@ -443,6 +451,7 @@ public void testLockSerialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInitialization() throws Exception { // Test #name() method. { @@ -682,6 +691,7 @@ public void testInitialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReentrantLockMultinode1() throws Exception { testReentrantLockMultinode1(false); @@ -759,6 +769,7 @@ private void testReentrantLockMultinode1(final boolean fair) throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockInterruptibly() throws Exception { testLockInterruptibly(false); @@ -836,6 +847,7 @@ private void testLockInterruptibly(final boolean fair) throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockInterruptiblyMultinode() throws Exception { testLockInterruptiblyMultinode(false); @@ -959,6 +971,7 @@ private void testLockInterruptiblyMultinode(final boolean fair) throws Exception /** * @throws Exception If failed. */ + @Test public void testLock() throws Exception { testLock(false); @@ -1042,6 +1055,7 @@ private void testLock(final boolean fair) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTryLock() throws Exception { testTryLock(false); @@ -1125,6 +1139,7 @@ private void testTryLock(final boolean fair) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTryLockTimed() throws Exception { testTryLockTimed(false); @@ -1201,6 +1216,7 @@ private void testTryLockTimed(final boolean fair) throws Exception { /** * @throws Exception If failed. */ + @Test public void testConditionAwaitUninterruptibly() throws Exception { testConditionAwaitUninterruptibly(false); @@ -1290,6 +1306,7 @@ private void testConditionAwaitUninterruptibly(final boolean fair) throws Except /** * @throws Exception If failed. */ + @Test public void testConditionInterruptAwait() throws Exception { testConditionInterruptAwait(false); @@ -1369,6 +1386,7 @@ private void testConditionInterruptAwait(final boolean fair) throws Exception { /** * @throws Exception If failed. */ + @Test public void testHasQueuedThreads() throws Exception { testHasQueuedThreads(false); @@ -1446,6 +1464,7 @@ private void testHasQueuedThreads(final boolean fair) throws Exception { /** * @throws Exception If failed. */ + @Test public void testHasConditionQueuedThreads() throws Exception { testHasConditionQueuedThreads(false); @@ -1557,6 +1576,7 @@ private void testHasConditionQueuedThreads(final boolean fair) throws Exception * on the OS thread scheduling, certain deviation from uniform distribution is tolerated. * @throws Exception If failed. */ + @Test public void testFairness() throws Exception { if (gridCount() == 1) return; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSemaphoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSemaphoreAbstractSelfTest.java index 445d469952409..8ddabb7e459a2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSemaphoreAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSemaphoreAbstractSelfTest.java @@ -47,7 +47,10 @@ import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; import org.junit.Rule; +import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MICROSECONDS; import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -59,6 +62,7 @@ /** * Cache semaphore self test. */ +@RunWith(JUnit4.class) public abstract class IgniteSemaphoreAbstractSelfTest extends IgniteAtomicsAbstractTest implements Externalizable { /** */ @@ -82,6 +86,7 @@ public abstract class IgniteSemaphoreAbstractSelfTest extends IgniteAtomicsAbstr /** * @throws Exception If failed. */ + @Test public void testSemaphore() throws Exception { checkSemaphore(); checkSemaphoreSerialization(); @@ -90,6 +95,7 @@ public void testSemaphore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailover() throws Exception { if (atomicsCacheMode() == LOCAL) return; @@ -104,6 +110,7 @@ public void testFailover() throws Exception { * * @throws Exception If failed. */ + @Test public void testIsolation() throws Exception { Ignite ignite = grid(0); @@ -282,6 +289,7 @@ private void checkSemaphore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSemaphoreClosing() throws Exception { IgniteConfiguration cfg; GridStringLogger stringLogger; @@ -472,6 +480,7 @@ private void removeSemaphore(final String semaphoreName) throws Exception { /** * @throws Exception If failed. */ + @Test public void testSemaphoreMultinode1() throws Exception { if (gridCount() == 1) return; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSequenceInternalCleanupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSequenceInternalCleanupTest.java index d5a76f859266b..b6199e160bd31 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSequenceInternalCleanupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSequenceInternalCleanupTest.java @@ -26,16 +26,17 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** */ +@RunWith(JUnit4.class) public class IgniteSequenceInternalCleanupTest extends GridCommonAbstractTest { /** */ public static final int GRIDS_CNT = 5; @@ -46,9 +47,6 @@ public class IgniteSequenceInternalCleanupTest extends GridCommonAbstractTest { /** */ public static final int CACHES_CNT = 10; - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -59,12 +57,6 @@ public class IgniteSequenceInternalCleanupTest extends GridCommonAbstractTest { cfg.setActiveOnStart(false); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - AtomicConfiguration atomicCfg = atomicConfiguration(); assertNotNull(atomicCfg); @@ -98,6 +90,7 @@ protected AtomicConfiguration atomicConfiguration() { } /** */ + @Test public void testDeactivate() throws Exception { try { Ignite ignite = startGridsMultiThreaded(GRIDS_CNT); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverNoWaitingAcquirerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverNoWaitingAcquirerTest.java index 862d240339ca1..73a8220207ea9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverNoWaitingAcquirerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverNoWaitingAcquirerTest.java @@ -21,19 +21,19 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.AtomicConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.concurrent.TimeUnit; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * - * Class to test the retrieval of a permit on a semaphore after initial semaphore owner has been closed. + * Class to test the retrieval of a permit on a semaphore after initial semaphore owner has been closed. * * IGNITE-7090 * @@ -42,10 +42,8 @@ * * */ +@RunWith(JUnit4.class) public class SemaphoreFailoverNoWaitingAcquirerTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Grid count. */ private static final int GRID_CNT = 3; @@ -56,12 +54,6 @@ public class SemaphoreFailoverNoWaitingAcquirerTest extends GridCommonAbstractTe @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - AtomicConfiguration atomicCfg = atomicConfiguration(); assertNotNull(atomicCfg); @@ -74,6 +66,7 @@ public class SemaphoreFailoverNoWaitingAcquirerTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testReleasePermitsPartitioned() throws Exception { atomicsCacheMode = PARTITIONED; @@ -83,6 +76,7 @@ public void testReleasePermitsPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReleasePermitsReplicated() throws Exception { atomicsCacheMode = REPLICATED; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverSafeReleasePermitsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverSafeReleasePermitsTest.java index 210b234e600b5..d1de54dede2d9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverSafeReleasePermitsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/SemaphoreFailoverSafeReleasePermitsTest.java @@ -23,10 +23,10 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.AtomicConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -34,10 +34,8 @@ /** * */ +@RunWith(JUnit4.class) public class SemaphoreFailoverSafeReleasePermitsTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Grid count. */ private static final int GRID_CNT = 3; @@ -48,12 +46,6 @@ public class SemaphoreFailoverSafeReleasePermitsTest extends GridCommonAbstractT @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - AtomicConfiguration atomicCfg = atomicConfiguration(); assertNotNull(atomicCfg); @@ -66,6 +58,7 @@ public class SemaphoreFailoverSafeReleasePermitsTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testReleasePermitsPartitioned() throws Exception { atomicsCacheMode = PARTITIONED; @@ -75,6 +68,7 @@ public void testReleasePermitsPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReleasePermitsReplicated() throws Exception { atomicsCacheMode = REPLICATED; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalCountDownLatchSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalCountDownLatchSelfTest.java index 9182c398971c3..d39cf5d3111ae 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalCountDownLatchSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalCountDownLatchSelfTest.java @@ -24,6 +24,9 @@ import org.apache.ignite.internal.processors.cache.datastructures.IgniteCountDownLatchAbstractSelfTest; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; @@ -32,6 +35,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteLocalCountDownLatchSelfTest extends IgniteCountDownLatchAbstractSelfTest { /** {@inheritDoc} */ @Override protected CacheMode atomicsCacheMode() { @@ -44,6 +48,7 @@ public class IgniteLocalCountDownLatchSelfTest extends IgniteCountDownLatchAbstr } /** {@inheritDoc} */ + @Test @Override public void testLatch() throws Exception { // Test main functionality. IgniteCountDownLatch latch = grid(0).countDownLatch("latch", 2, false, true); @@ -92,4 +97,4 @@ public class IgniteLocalCountDownLatchSelfTest extends IgniteCountDownLatchAbstr checkRemovedLatch(latch); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalLockSelfTest.java index 7e1a11c17678a..b3f1a9d9a6380 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalLockSelfTest.java @@ -24,6 +24,9 @@ import org.apache.ignite.internal.processors.cache.datastructures.IgniteLockAbstractSelfTest; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MINUTES; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -31,6 +34,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteLocalLockSelfTest extends IgniteLockAbstractSelfTest { /** {@inheritDoc} */ @Override protected CacheMode atomicsCacheMode() { @@ -43,6 +47,7 @@ public class IgniteLocalLockSelfTest extends IgniteLockAbstractSelfTest { } /** {@inheritDoc} */ + @Test @Override public void testReentrantLock() throws Exception { // Test main functionality. IgniteLock lock = grid(0).reentrantLock("lock", true, false, true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalSemaphoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalSemaphoreSelfTest.java index a516fc11e2d57..2af67e0d8ab14 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalSemaphoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/IgniteLocalSemaphoreSelfTest.java @@ -24,6 +24,9 @@ import org.apache.ignite.internal.processors.cache.datastructures.IgniteSemaphoreAbstractSelfTest; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MINUTES; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -31,6 +34,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteLocalSemaphoreSelfTest extends IgniteSemaphoreAbstractSelfTest { /** {@inheritDoc} */ @Override protected CacheMode atomicsCacheMode() { @@ -43,6 +47,7 @@ public class IgniteLocalSemaphoreSelfTest extends IgniteSemaphoreAbstractSelfTes } /** {@inheritDoc} */ + @Test @Override public void testSemaphore() throws Exception { // Test main functionality. IgniteSemaphore semaphore = grid(0).semaphore("semaphore", -2, false, true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceMultiThreadedTest.java index 4db9bd3339904..31d77f86c73cc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceMultiThreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceMultiThreadedTest.java @@ -28,12 +28,16 @@ import org.apache.ignite.internal.processors.datastructures.GridCacheAtomicSequenceImpl; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Cache partitioned multi-threaded tests. */ +@RunWith(JUnit4.class) public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends IgniteAtomicsAbstractTest { /** Number of threads for multithreaded test. */ private static final int THREAD_NUM = 30; @@ -62,6 +66,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends IgniteA } /** @throws Exception If failed. */ + @Test public void testValues() throws Exception { String seqName = UUID.randomUUID().toString(); @@ -137,16 +142,19 @@ public void testValues() throws Exception { } /** @throws Exception If failed. */ + @Test public void testUpdatedSync() throws Exception { checkUpdate(true); } /** @throws Exception If failed. */ + @Test public void testPreviousSync() throws Exception { checkUpdate(false); } /** @throws Exception If failed. */ + @Test public void testIncrementAndGet() throws Exception { // Random sequence names. String seqName = UUID.randomUUID().toString(); @@ -163,6 +171,7 @@ public void testIncrementAndGet() throws Exception { } /** @throws Exception If failed. */ + @Test public void testIncrementAndGetAsync() throws Exception { // Random sequence names. String seqName = UUID.randomUUID().toString(); @@ -179,6 +188,7 @@ public void testIncrementAndGetAsync() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetAndIncrement() throws Exception { // Random sequence names. String seqName = UUID.randomUUID().toString(); @@ -195,6 +205,7 @@ public void testGetAndIncrement() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetAndIncrementAsync() throws Exception { // Random sequence names. String seqName = UUID.randomUUID().toString(); @@ -211,6 +222,7 @@ public void testGetAndIncrementAsync() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAddAndGet() throws Exception { // Random sequence names. String seqName = UUID.randomUUID().toString(); @@ -227,6 +239,7 @@ public void testAddAndGet() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetAndAdd() throws Exception { // Random sequence names. String seqName = UUID.randomUUID().toString(); @@ -243,6 +256,7 @@ public void testGetAndAdd() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMixed1() throws Exception { // Random sequence names. String seqName = UUID.randomUUID().toString(); @@ -264,6 +278,7 @@ public void testMixed1() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMixed2() throws Exception { // Random sequence names. String seqName = UUID.randomUUID().toString(); @@ -285,6 +300,7 @@ public void testMixed2() throws Exception { /** * @throws Exception if failed. */ + @Test public void testMultipleSequences() throws Exception { final int seqCnt = 5; final int threadCnt = 5; @@ -369,4 +385,4 @@ private void checkUpdate(boolean updated) throws Exception { private abstract static class GridInUnsafeClosure { public abstract void apply(E p) throws IgniteCheckedException; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceTxSelfTest.java index 19f97bd75ebf6..68727b2a79f62 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceTxSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceTxSelfTest.java @@ -27,17 +27,18 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * Tests {@link IgniteAtomicSequence} operations inside started user transaction. */ +@RunWith(JUnit4.class) public class GridCachePartitionedAtomicSequenceTxSelfTest extends GridCommonAbstractTest { /** Number of threads. */ private static final int THREAD_NUM = 8; @@ -54,19 +55,10 @@ public class GridCachePartitionedAtomicSequenceTxSelfTest extends GridCommonAbst /** Latch. */ private static CountDownLatch latch; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - cfg.setPublicThreadPoolSize(THREAD_NUM); AtomicConfiguration atomicCfg = atomicConfiguration(); @@ -107,6 +99,7 @@ protected AtomicConfiguration atomicConfiguration() { * * @throws Exception If failed. */ + @Test public void testTransactionIncrement() throws Exception { ignite(0).atomicSequence(SEQ_NAME, 0, true); @@ -123,6 +116,7 @@ public void testTransactionIncrement() throws Exception { /** * Tests isolation of system and user transactions. */ + @Test public void testIsolation() { IgniteAtomicSequence seq = ignite(0).atomicSequence(SEQ_NAME, 0, true); @@ -166,4 +160,4 @@ private static class IncrementClosure implements IgniteRunnable { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSetFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSetFailoverSelfTest.java index 4673549ca88aa..9e88a187fcf2d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSetFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSetFailoverSelfTest.java @@ -19,12 +19,16 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.processors.cache.datastructures.GridCacheSetFailoverAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; /** * Set failover tests. */ +@RunWith(JUnit4.class) public class GridCachePartitionedAtomicSetFailoverSelfTest extends GridCacheSetFailoverAbstractSelfTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { @@ -32,6 +36,7 @@ public class GridCachePartitionedAtomicSetFailoverSelfTest extends GridCacheSetF } /** {@inheritDoc} */ + @Test @Override public void testNodeRestart() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-170"); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedDataStructuresFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedDataStructuresFailoverSelfTest.java index eecfefe949816..ecb2df9b7b1c9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedDataStructuresFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedDataStructuresFailoverSelfTest.java @@ -38,18 +38,4 @@ public class GridCachePartitionedDataStructuresFailoverSelfTest @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { return TRANSACTIONAL; } - - /** - * - */ - @Override public void testReentrantLockConstantTopologyChangeNonFailoverSafe() { - fail("https://issues.apache.org/jira/browse/IGNITE-6454"); - } - - /** - * - */ - @Override public void testFairReentrantLockConstantTopologyChangeNonFailoverSafe() { - fail("https://issues.apache.org/jira/browse/IGNITE-6454"); - } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedNodeRestartTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedNodeRestartTxSelfTest.java index 00217184d5252..baf3bcde73f61 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedNodeRestartTxSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedNodeRestartTxSelfTest.java @@ -25,11 +25,11 @@ import org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongValue; import org.apache.ignite.internal.processors.datastructures.GridCacheInternalKey; import org.apache.ignite.internal.processors.datastructures.GridCacheInternalKeyImpl; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -41,10 +41,8 @@ /** * Test with variable number of nodes. */ +@RunWith(JUnit4.class) public class GridCachePartitionedNodeRestartTxSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int INIT_GRID_NUM = 3; @@ -62,12 +60,6 @@ public GridCachePartitionedNodeRestartTxSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); @@ -94,6 +86,7 @@ public GridCachePartitionedNodeRestartTxSelfTest() { * * @throws Exception If failed. */ + @Test public void testSimple() throws Exception { String key = UUID.randomUUID().toString(); @@ -115,6 +108,7 @@ public void testSimple() throws Exception { * * @throws Exception If failed. */ + @Test public void testCustom() throws Exception { String key = UUID.randomUUID().toString(); @@ -136,6 +130,7 @@ public void testCustom() throws Exception { * * @throws Exception If failed. */ + @Test public void testAtomic() throws Exception { String key = UUID.randomUUID().toString(); @@ -299,4 +294,4 @@ private void prepareAtomic(String key) throws Exception { stopGrid(0); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueCreateMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueCreateMultiNodeSelfTest.java index 4412c57b938b6..7979e3cb1fbff 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueCreateMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueCreateMultiNodeSelfTest.java @@ -33,6 +33,9 @@ import org.apache.ignite.internal.processors.cache.datastructures.IgniteCollectionAbstractTest; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -46,6 +49,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridCachePartitionedQueueCreateMultiNodeSelfTest extends IgniteCollectionAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -107,6 +111,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testQueueCreation() throws Exception { final AtomicInteger idx = new AtomicInteger(); @@ -161,6 +166,7 @@ public void testQueueCreation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTx() throws Exception { if (cacheConfiguration().getAtomicityMode() != TRANSACTIONAL) return; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java index cd66f4dbc10ad..ea34e74e6bf12 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java @@ -38,6 +38,9 @@ import org.apache.ignite.internal.processors.cache.datastructures.IgniteCollectionAbstractTest; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -45,6 +48,7 @@ /** * Cache queue test with changing topology. */ +@RunWith(JUnit4.class) public class GridCachePartitionedQueueEntryMoveSelfTest extends IgniteCollectionAbstractTest { /** Queue capacity. */ private static final int QUEUE_CAP = 5; @@ -82,6 +86,7 @@ public class GridCachePartitionedQueueEntryMoveSelfTest extends IgniteCollection /** * @throws Exception If failed. */ + @Test public void testQueue() throws Exception { final String queueName = "qq"; @@ -212,4 +217,4 @@ private Collection nodes(AffinityFunction aff, int part, Collection return assignment.get(part); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedSetFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedSetFailoverSelfTest.java index ec57deab71c5f..a37944dc77c53 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedSetFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedSetFailoverSelfTest.java @@ -19,19 +19,24 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.processors.cache.datastructures.GridCacheSetFailoverAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * Set failover tests. */ +@RunWith(JUnit4.class) public class GridCachePartitionedSetFailoverSelfTest extends GridCacheSetFailoverAbstractSelfTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { return TRANSACTIONAL; } + @Test @Override public void testNodeRestart(){ fail("https://issues.apache.org/jira/browse/IGNITE-1593"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedCountDownLatchSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedCountDownLatchSelfTest.java index fc9356e21631c..dc1702b7bf0df 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedCountDownLatchSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedCountDownLatchSelfTest.java @@ -19,6 +19,8 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.datastructures.IgniteCountDownLatchAbstractSelfTest; +import org.junit.Ignore; +import org.junit.Test; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -32,7 +34,9 @@ public class IgnitePartitionedCountDownLatchSelfTest extends IgniteCountDownLatc } /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-1793") + @Test @Override public void testLatch() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-1793"); + // No-op. } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedQueueNoBackupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedQueueNoBackupsTest.java index aa075c0a9eb16..bb68bbfc9eb0d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedQueueNoBackupsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedQueueNoBackupsTest.java @@ -28,6 +28,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -35,6 +38,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgnitePartitionedQueueNoBackupsTest extends GridCachePartitionedQueueApiSelfTest { /** {@inheritDoc} */ @Override protected CacheMode collectionCacheMode() { @@ -58,6 +62,7 @@ public class IgnitePartitionedQueueNoBackupsTest extends GridCachePartitionedQue /** * @throws Exception If failed. */ + @Test public void testCollocation() throws Exception { IgniteQueue queue = grid(0).queue("queue", 0, config(true)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedSetNoBackupsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedSetNoBackupsSelfTest.java index 5f09dfa84a54b..1c8618d1e2cc6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedSetNoBackupsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedSetNoBackupsSelfTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePartitionedSetNoBackupsSelfTest extends GridCachePartitionedSetSelfTest { /** {@inheritDoc} */ @Override protected CollectionConfiguration collectionConfiguration() { @@ -43,6 +47,7 @@ public class IgnitePartitionedSetNoBackupsSelfTest extends GridCachePartitionedS /** * @throws Exception If failed. */ + @Test public void testCollocation() throws Exception { Set set0 = grid(0).set(SET_NAME, config(true)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedDataStructuresFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedDataStructuresFailoverSelfTest.java index 27fbdcf1d48d7..b093d12f1bb33 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedDataStructuresFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedDataStructuresFailoverSelfTest.java @@ -38,32 +38,4 @@ public class GridCacheReplicatedDataStructuresFailoverSelfTest @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { return TRANSACTIONAL; } - - /** - * - */ - @Override public void testFairReentrantLockConstantMultipleTopologyChangeNonFailoverSafe() { - fail("https://issues.apache.org/jira/browse/IGNITE-6454"); - } - - /** - * - */ - @Override public void testReentrantLockConstantMultipleTopologyChangeNonFailoverSafe() { - fail("https://issues.apache.org/jira/browse/IGNITE-6454"); - } - - /** - * - */ - @Override public void testReentrantLockConstantTopologyChangeNonFailoverSafe() { - fail("https://issues.apache.org/jira/browse/IGNITE-6454"); - } - - /** - * - */ - @Override public void testFairReentrantLockConstantTopologyChangeNonFailoverSafe() { - fail("https://issues.apache.org/jira/browse/IGNITE-6454"); - } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/Cache64kPartitionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/Cache64kPartitionsTest.java index e54251e2b836c..078c5737dae0a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/Cache64kPartitionsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/Cache64kPartitionsTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class Cache64kPartitionsTest extends GridCommonAbstractTest { /** */ private boolean persistenceEnabled; @@ -62,6 +66,7 @@ public class Cache64kPartitionsTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testManyPartitionsNoPersistence() throws Exception { checkManyPartitions(); } @@ -69,6 +74,7 @@ public void testManyPartitionsNoPersistence() throws Exception { /** * @throws Exception if failed. */ + @Test public void testManyPartitionsWithPersistence() throws Exception { persistenceEnabled = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java index dd9362671c504..61d96bc71339b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAbstractRestartSelfTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Abstract restart test. */ +@RunWith(JUnit4.class) public abstract class CacheAbstractRestartSelfTest extends IgniteCacheAbstractTest { /** */ private volatile CountDownLatch cacheCheckedLatch = new CountDownLatch(1); @@ -72,6 +76,7 @@ protected int updatersNumber() { /** * @throws Exception If failed. */ + @Test public void testRestart() throws Exception { final int clientGrid = gridCount() - 1; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java index 46669acc56807..8d48651f143e4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java @@ -30,14 +30,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheAffinityEarlyTest extends GridCommonAbstractTest { /** Grid count. */ private static int GRID_CNT = 8; @@ -54,18 +55,10 @@ public class CacheAffinityEarlyTest extends GridCommonAbstractTest { /** Futs. */ private Collection> futs = new ArrayList<>(GRID_CNT); - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - cfg.setMarshaller(new BinaryMarshaller()); return cfg; @@ -79,6 +72,7 @@ public class CacheAffinityEarlyTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStartNodes() throws Exception { for (int i = 0; i < iters; i++) { try { @@ -156,10 +150,10 @@ private IgniteCache getCache(Ignite grid) { CacheConfiguration ccfg = defaultCacheConfiguration(); ccfg.setCacheMode(CacheMode.PARTITIONED); - ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); ccfg.setBackups(1); ccfg.setNearConfiguration(null); return grid.getOrCreateCache(ccfg); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsFailoverAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsFailoverAbstractTest.java index f1377df8ddf9f..eff8118dc76ed 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsFailoverAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsFailoverAbstractTest.java @@ -39,12 +39,16 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public abstract class CacheAsyncOperationsFailoverAbstractTest extends GridCacheAbstractSelfTest { /** */ private static final int NODE_CNT = 4; @@ -96,6 +100,7 @@ public abstract class CacheAsyncOperationsFailoverAbstractTest extends GridCache /** * @throws Exception If failed. */ + @Test public void testPutAllAsyncFailover() throws Exception { putAllAsyncFailover(5, 10); } @@ -103,6 +108,7 @@ public void testPutAllAsyncFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllAsyncFailoverManyThreads() throws Exception { putAllAsyncFailover(ignite(0).configuration().getSystemThreadPoolSize() * 2, 3); } @@ -110,6 +116,7 @@ public void testPutAllAsyncFailoverManyThreads() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAsyncFailover() throws Exception { IgniteCache cache = ignite(0).cache(DEFAULT_CACHE_NAME); @@ -372,4 +379,4 @@ public long value() { return S.toString(TestValue.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsTest.java index 0b6d7b1cba115..4f93bb4adb573 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsTest.java @@ -30,23 +30,22 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class CacheAsyncOperationsTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static volatile CountDownLatch latch; @@ -54,8 +53,6 @@ public class CacheAsyncOperationsTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (igniteInstanceName.equals(getTestIgniteInstanceName(1))) cfg.setClientMode(true); @@ -72,6 +69,7 @@ public class CacheAsyncOperationsTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAsyncOperationsTx() throws Exception { asyncOperations(TRANSACTIONAL); } @@ -79,6 +77,15 @@ public void testAsyncOperationsTx() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testAsyncOperationsMvccTx() throws Exception { + asyncOperations(TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testAsyncOperationsAtomic() throws Exception { asyncOperations(ATOMIC); } @@ -255,4 +262,4 @@ private static class TestStore extends CacheStoreAdapter { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAtomicPrimarySyncBackPressureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAtomicPrimarySyncBackPressureTest.java index 62707c7a48166..053400177a8b2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAtomicPrimarySyncBackPressureTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAtomicPrimarySyncBackPressureTest.java @@ -34,12 +34,16 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks that back-pressure control restricts uncontrolled growing * of backup message queue. This means, if queue too big - any reads * will be stopped until received acks from backup nodes. */ +@RunWith(JUnit4.class) public class CacheAtomicPrimarySyncBackPressureTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -73,6 +77,7 @@ public class CacheAtomicPrimarySyncBackPressureTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testClientPut() throws Exception { Ignite srv1 = startGrid("server1"); Ignite srv2 = startGrid("server2"); @@ -85,6 +90,7 @@ public void testClientPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerPut() throws Exception { Ignite srv1 = startGrid("server1"); Ignite srv2 = startGrid("server2"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBaselineTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBaselineTopologyTest.java index 053ed82c569d4..272735032786b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBaselineTopologyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBaselineTopologyTest.java @@ -52,10 +52,11 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -64,6 +65,7 @@ /** * */ +@RunWith(JUnit4.class) public class CacheBaselineTopologyTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "cache"; @@ -83,9 +85,6 @@ public class CacheBaselineTopologyTest extends GridCommonAbstractTest { /** */ private static final String DATA_NODE = "dataNodeUserAttr"; - /** */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -110,11 +109,6 @@ public class CacheBaselineTopologyTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setConsistentId(igniteInstanceName); if (disableAutoActivation) @@ -151,6 +145,7 @@ public class CacheBaselineTopologyTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testRebalanceForCacheWithNodeFilter() throws Exception { try { final int EMPTY_NODE_IDX = 2; @@ -232,6 +227,7 @@ private static class DataNodeFilter implements IgnitePredicate { /** * @throws Exception If failed. */ + @Test public void testTopologyChangesWithFixedBaseline() throws Exception { startGrids(NODE_COUNT); @@ -367,6 +363,7 @@ public void testTopologyChangesWithFixedBaseline() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBaselineTopologyChangesFromServer() throws Exception { testBaselineTopologyChanges(false); } @@ -374,6 +371,7 @@ public void testBaselineTopologyChangesFromServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBaselineTopologyChangesFromClient() throws Exception { testBaselineTopologyChanges(true); } @@ -381,6 +379,7 @@ public void testBaselineTopologyChangesFromClient() throws Exception { /** * @throws Exception if failed. */ + @Test public void testClusterActiveWhileBaselineChanging() throws Exception { startGrids(NODE_COUNT); @@ -542,6 +541,7 @@ private void testBaselineTopologyChanges(boolean fromClient) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryLeft() throws Exception { startGrids(NODE_COUNT); @@ -629,6 +629,7 @@ else if (grid(i).localNode().equals(affNodes.get(1))) /** * @throws Exception If failed. */ + @Test public void testPrimaryLeftAndClusterRestart() throws Exception { startGrids(NODE_COUNT); @@ -740,6 +741,7 @@ else if (grid(i).localNode().equals(affNodes.get(1))) { /** * @throws Exception if failed. */ + @Test public void testMetadataUpdate() throws Exception { startGrids(5); @@ -776,6 +778,7 @@ public void testMetadataUpdate() throws Exception { /** * @throws Exception if failed. */ + @Test public void testClusterRestoredOnRestart() throws Exception { startGrids(5); @@ -811,6 +814,7 @@ public void testClusterRestoredOnRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNonPersistentCachesIgnoreBaselineTopology() throws Exception { Ignite ig = startGrids(4); @@ -832,6 +836,7 @@ public void testNonPersistentCachesIgnoreBaselineTopology() throws Exception { /** * @throws Exception if failed. */ + @Test public void testAffinityAssignmentChangedAfterRestart() throws Exception { int parts = 32; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnGetAllTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnGetAllTest.java new file mode 100644 index 0000000000000..dd301b13417a1 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnGetAllTest.java @@ -0,0 +1,280 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import java.util.HashSet; +import java.util.Random; +import java.util.Set; +import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheMode.REPLICATED; + +/** + * + */ +@RunWith(JUnit4.class) +public class CacheBlockOnGetAllTest extends CacheBlockOnReadAbstractTest { + + /** {@inheritDoc} */ + @Override @NotNull protected CacheReadBackgroundOperation getReadOperation() { + return new IntCacheReadBackgroundOperation() { + /** Random. */ + private Random random = new Random(); + + /** {@inheritDoc} */ + @Override public void doRead() { + Set keys = new HashSet<>(); + + for (int i = 0; i < 500; i++) + keys.add(random.nextInt(entriesCount())); + + cache().getAll(keys); + } + }; + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStopBaselineAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9915"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStopBaselineAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9915"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStopBaselineTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9915"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStopBaselineTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9915"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testCreateCacheAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testCreateCacheAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testCreateCacheTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testCreateCacheTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testDestroyCacheAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testDestroyCacheAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testDestroyCacheTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testDestroyCacheTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStartServerAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStartServerAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStartServerTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStartServerTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStopServerAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStopServerAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStopServerTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStopServerTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testUpdateBaselineTopologyAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testUpdateBaselineTopologyAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testUpdateBaselineTopologyTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testUpdateBaselineTopologyTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStartClientAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStartClientAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStartClientTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStartClientTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStopClientAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStopClientAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStopClientTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStopClientTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnReadAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnReadAbstractTest.java new file mode 100644 index 0000000000000..297d2d29c4a94 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnReadAbstractTest.java @@ -0,0 +1,1487 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.BiConsumer; +import java.util.function.Predicate; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.IgniteException; +import org.apache.ignite.IgniteInterruptedException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.events.DiscoveryEvent; +import org.apache.ignite.events.EventType; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; +import org.apache.ignite.internal.events.DiscoveryCustomEvent; +import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; +import org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch; +import org.apache.ignite.internal.processors.cache.ExchangeActions; +import org.apache.ignite.internal.processors.cache.ExchangeActions.CacheActionData; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage; +import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiPredicate; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeLeftMessage; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheMode.REPLICATED; + +/** + * + */ +@RunWith(JUnit4.class) +public abstract class CacheBlockOnReadAbstractTest extends GridCommonAbstractTest { + /** Default cache entries count. */ + private static final int DFLT_CACHE_ENTRIES_CNT = 2 * 1024; + + /** Ip finder. */ + private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** List of baseline nodes started at the beginning of the test. */ + protected final List baseline = new CopyOnWriteArrayList<>(); + + /** List of server nodes started at the beginning of the test. */ + protected final List srvs = new CopyOnWriteArrayList<>(); + + /** List of client nodes started at the beginning of the test. */ + protected final List clients = new CopyOnWriteArrayList<>(); + + /** Start node in client mode. */ + private volatile boolean startNodesInClientMode; + + /** Latch that is used to wait until all required messages are blocked. */ + private volatile CountDownLatch cntFinishedReadOperations; + + /** Custom ip finder. Replaces {@link #IP_FINDER} if present at the moment of node starting. */ + private volatile TcpDiscoveryIpFinder customIpFinder; + + /** Discovery message processor. Used in every started node. */ + private volatile BiConsumer discoveryMsgProcessor; + + /** + * Number of baseline servers to start before test. + * + * @see Params#baseline() + */ + protected int baselineServersCount() { + return currentTestParams().baseline(); + } + + /** + * Number of non-baseline servers to start before test. + * + * @see Params#servers() + */ + protected int serversCount() { + return currentTestParams().servers(); + } + + /** + * Number of clients to start before test. + * + * @see Params#clients() + */ + protected int clientsCount() { + return currentTestParams().clients(); + } + + /** + * Number of backups to configure in caches by default. + */ + protected int backupsCount() { + return Math.min(3, baselineServersCount() - 1); + } + + /** + * Number of milliseconds to warmup reading process. Used to lower fluctuations in run time. Might be 0. + * + * @see Params#warmup() + */ + protected long warmup() { + return currentTestParams().warmup(); + } + + /** + * Number of milliseconds to wait on the potentially blocking operation. + * + * @see Params#timeout() + */ + protected long timeout() { + return currentTestParams().timeout(); + } + + /** + * Cache atomicity mode. + * + * @see Params#atomicityMode() + */ + protected CacheAtomicityMode atomicityMode() { + return currentTestParams().atomicityMode(); + } + + /** + * Cache mode. + * + * @see Params#cacheMode() + */ + protected CacheMode cacheMode() { + return currentTestParams().cacheMode(); + } + + /** + * Whether allowing {@link ClusterTopologyCheckedException} as the valid reading result or not. + * + * @see Params#allowException() + */ + protected boolean allowException() { + return currentTestParams().allowException(); + } + + /** + * @param startNodesInClientMode Start nodes on client mode. + */ + public void startNodesInClientMode(boolean startNodesInClientMode) { + this.startNodesInClientMode = startNodesInClientMode; + } + + /** List of baseline nodes started at the beginning of the test. */ + public List baseline() { + return baseline; + } + + /** List of server nodes started at the beginning of the test. */ + public List servers() { + return srvs; + } + + /** List of client nodes started at the beginning of the test. */ + public List clients() { + return clients; + } + + /** + * Annotation to configure test methods in {@link CacheBlockOnReadAbstractTest}. Its values are used throughout + * test implementation. + */ + @Target(ElementType.METHOD) + @Retention(RetentionPolicy.RUNTIME) + public @interface Params { + /** + * Number of baseline servers to start before test. + */ + int baseline() default 3; + + /** + * Number of non-baseline servers to start before test. + */ + int servers() default 1; + + /** + * Number of clients to start before test. + */ + int clients() default 1; + + /** + * Number of milliseconds to warmup reading process. Used to lower fluctuations in run time. Might be 0. + */ + long warmup() default 2000L; + + /** + * Number of milliseconds to wait on the potentially blocking operation. + */ + long timeout() default 3000L; + + /** + * Cache atomicity mode. + */ + CacheAtomicityMode atomicityMode(); + + /** + * Cache mode. + */ + CacheMode cacheMode(); + + /** + * Whether allowing {@link ClusterTopologyCheckedException} as the valid reading result or not. + */ + boolean allowException() default false; + } + + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setConsistentId(igniteInstanceName); + + cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); + + cfg.setDiscoverySpi(new TestTcpDiscoverySpi() { + /** {@inheritDoc} */ + @Override protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) { + if (discoveryMsgProcessor != null) + discoveryMsgProcessor.accept(msg, igniteInstanceName); + } + }.setIpFinder(customIpFinder == null ? IP_FINDER : customIpFinder)); + + cfg.setDataStorageConfiguration( + new DataStorageConfiguration() + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setPersistenceEnabled(true) + ) + ); + + cfg.setClientMode(startNodesInClientMode); + + return cfg; + } + + /** {@inheritDoc} */ + @Override public void beforeTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + // Checking prerequisites. + assertTrue("Positive timeout is required for the test.", timeout() > 0); + + assertTrue("No baseline servers were requested.", baselineServersCount() > 0); + + int idx = 0; + + // Start baseline nodes. + for (int i = 0; i < baselineServersCount(); i++) + baseline.add(startGrid(idx++)); + + // Activate cluster. + baseline.get(0).cluster().active(true); + + // Start server nodes in activated cluster. + for (int i = 0; i < serversCount(); i++) + srvs.add(startGrid(idx++)); + + // Start client nodes. + startNodesInClientMode(true); + + customIpFinder = new TcpDiscoveryVmIpFinder(false) + .setAddresses( + Collections.singletonList("127.0.0.1:47500") + ); + + for (int i = 0; i < clientsCount(); i++) + clients.add(startGrid(idx++)); + + customIpFinder = null; + } + + /** {@inheritDoc} */ + @Override public void afterTest() throws Exception { + baseline.clear(); + + srvs.clear(); + + clients.clear(); + + grid(0).cluster().active(false); + + stopAllGrids(); + + cleanPersistenceDir(); + } + + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + public void testCreateCacheAtomicPartitioned() throws Exception { + testCreateCacheTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + public void testCreateCacheAtomicReplicated() throws Exception { + testCreateCacheTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + public void testCreateCacheTransactionalPartitioned() throws Exception { + testCreateCacheTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + public void testCreateCacheTransactionalReplicated() throws Exception { + doTest( + asMessagePredicate(CacheBlockOnReadAbstractTest::createCachePredicate), + () -> baseline.get(0).createCache(UUID.randomUUID().toString()) + ); + } + + /** + * @throws Exception If failed. + */ + @Params(timeout = 5000L, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + public void testDestroyCacheAtomicPartitioned() throws Exception { + testDestroyCacheTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(timeout = 5000L, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + public void testDestroyCacheAtomicReplicated() throws Exception { + testDestroyCacheTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(timeout = 5000L, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + public void testDestroyCacheTransactionalPartitioned() throws Exception { + testDestroyCacheTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(timeout = 5000L, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + public void testDestroyCacheTransactionalReplicated() throws Exception { + List cacheNames = new ArrayList<>(Arrays.asList( + UUID.randomUUID().toString(), + UUID.randomUUID().toString(), + UUID.randomUUID().toString()) + ); + + for (String cacheName : cacheNames) + baseline.get(0).createCache(cacheName); + + doTest( + asMessagePredicate(CacheBlockOnReadAbstractTest::destroyCachePredicate), + () -> baseline.get(0).destroyCache(cacheNames.remove(0)) + ); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + public void testStartServerAtomicPartitioned() throws Exception { + testStartServerTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + public void testStartServerAtomicReplicated() throws Exception { + testStartServerTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + public void testStartServerTransactionalPartitioned() throws Exception { + testStartServerTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + public void testStartServerTransactionalReplicated() throws Exception { + startNodesInClientMode(false); + + doTest( + asMessagePredicate(discoEvt -> discoEvt.type() == EventType.EVT_NODE_JOINED), + () -> startGrid(UUID.randomUUID().toString()) + ); + } + + /** + * @throws Exception If failed. + */ + @Params(servers = 4, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + public void testStopServerAtomicPartitioned() throws Exception { + testStopServerTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(servers = 4, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + public void testStopServerAtomicReplicated() throws Exception { + testStopServerTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(servers = 4, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + public void testStopServerTransactionalPartitioned() throws Exception { + testStopServerTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(servers = 4, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + public void testStopServerTransactionalReplicated() throws Exception { + doTest( + asMessagePredicate(discoEvt -> discoEvt.type() == EventType.EVT_NODE_LEFT), + () -> stopGrid(srvs.remove(srvs.size() - 1).name()) + ); + } + + /** + * @throws Exception If failed. + */ + @Params(baseline = 4, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + public void testRestartBaselineAtomicPartitioned() throws Exception { + testRestartBaselineTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(baseline = 4, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + public void testRestartBaselineAtomicReplicated() throws Exception { + testRestartBaselineTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(baseline = 4, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + public void testRestartBaselineTransactionalPartitioned() throws Exception { + testRestartBaselineTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(baseline = 4, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + public void testRestartBaselineTransactionalReplicated() throws Exception { + doTest( + asMessagePredicate(discoEvt -> discoEvt.type() == EventType.EVT_NODE_JOINED), + () -> { + IgniteEx node = baseline.get(baseline.size() - 1); + + TestRecordingCommunicationSpi.spi(node).stopBlock(); + + stopGrid(node.name()); + + for (int i = 0; i < baselineServersCount() - 2; i++) + cntFinishedReadOperations.countDown(); + + startGrid(node.name()); + } + ); + } + + /** + * @throws Exception If failed. + */ + @Params(timeout = 5000L, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + public void testUpdateBaselineTopologyAtomicPartitioned() throws Exception { + testUpdateBaselineTopologyTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(timeout = 5000L, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + public void testUpdateBaselineTopologyAtomicReplicated() throws Exception { + testUpdateBaselineTopologyTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(timeout = 5000L, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + public void testUpdateBaselineTopologyTransactionalPartitioned() throws Exception { + testUpdateBaselineTopologyTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(timeout = 5000L, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + public void testUpdateBaselineTopologyTransactionalReplicated() throws Exception { + doTest( + asMessagePredicate(discoEvt -> { + if (discoEvt instanceof DiscoveryCustomEvent) { + DiscoveryCustomEvent discoCustomEvt = (DiscoveryCustomEvent)discoEvt; + + DiscoveryCustomMessage customMsg = discoCustomEvt.customMessage(); + + return customMsg instanceof ChangeGlobalStateMessage; + } + + return false; + }), + () -> { + startNodesInClientMode(false); + + IgniteEx ignite = startGrid(UUID.randomUUID().toString()); + + baseline.get(0).cluster().setBaselineTopology(baseline.get(0).context().discovery().topologyVersion()); + + baseline.add(ignite); + } + ); + } + + /** + * @throws Exception If failed. + */ + @Params(baseline = 9, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + public void testStopBaselineAtomicPartitioned() throws Exception { + testStopBaselineTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(baseline = 9, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + public void testStopBaselineAtomicReplicated() throws Exception { + testStopBaselineTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(baseline = 9, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + public void testStopBaselineTransactionalPartitioned() throws Exception { + testStopBaselineTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(baseline = 9, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + public void testStopBaselineTransactionalReplicated() throws Exception { + AtomicInteger cntDownCntr = new AtomicInteger(0); + + doTest( + asMessagePredicate(discoEvt -> discoEvt.type() == EventType.EVT_NODE_LEFT), + () -> { + IgniteEx node = baseline.get(baseline.size() - cntDownCntr.get() - 1); + + TestRecordingCommunicationSpi.spi(node).stopBlock(); + + cntDownCntr.incrementAndGet(); + + for (int i = 0; i < cntDownCntr.get(); i++) + cntFinishedReadOperations.countDown(); // This node and previously stopped nodes as well. + + stopGrid(node.name()); + } + ); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + public void testStartClientAtomicPartitioned() throws Exception { + testStartClientTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + public void testStartClientAtomicReplicated() throws Exception { + testStartClientTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + public void testStartClientTransactionalPartitioned() throws Exception { + testStartClientTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + public void testStartClientTransactionalReplicated() throws Exception { + doTest( + TcpDiscoveryNodeAddFinishedMessage.class, + () -> { + startNodesInClientMode(true); + + customIpFinder = new TcpDiscoveryVmIpFinder(false) + .setAddresses( + Collections.singletonList("127.0.0.1:47502") + ); + + try { + startGrid(UUID.randomUUID().toString()); + } + finally { + customIpFinder = null; + } + } + ); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + public void testStopClientAtomicPartitioned() throws Exception { + testStopClientTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + public void testStopClientAtomicReplicated() throws Exception { + testStopClientTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + public void testStopClientTransactionalPartitioned() throws Exception { + testStopClientTransactionalReplicated(); + } + + /** + * @throws Exception If failed. + */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED, timeout = 5_000L) + @Test + public void testStopClientTransactionalReplicated() throws Exception { + startNodesInClientMode(true); + + customIpFinder = new TcpDiscoveryVmIpFinder(false) + .setAddresses( + Collections.singletonList("127.0.0.1:47502") + ); + + for (int i = 0; i < 3; i++) + clients.add(startGrid(UUID.randomUUID().toString())); + + customIpFinder = null; + + doTest( + TcpDiscoveryNodeLeftMessage.class, + () -> stopGrid(clients.remove(clients.size() - 1).name()) + ); + } + + /** + * Checks that given discovery event is from "Create cache" operation. + * + * @param discoEvt Discovery event. + */ + private static boolean createCachePredicate(DiscoveryEvent discoEvt) { + if (discoEvt instanceof DiscoveryCustomEvent) { + + DiscoveryCustomEvent discoCustomEvt = (DiscoveryCustomEvent)discoEvt; + + DiscoveryCustomMessage customMsg = discoCustomEvt.customMessage(); + + if (customMsg instanceof DynamicCacheChangeBatch) { + DynamicCacheChangeBatch cacheChangeBatch = (DynamicCacheChangeBatch)customMsg; + + ExchangeActions exchangeActions = U.field(cacheChangeBatch, "exchangeActions"); + + Collection startRequests = exchangeActions.cacheStartRequests(); + + return !startRequests.isEmpty(); + } + } + + return false; + } + + /** + * Checks that given discovery event is from "Destroy cache" operation. + * + * @param discoEvt Discovery event. + */ + private static boolean destroyCachePredicate(DiscoveryEvent discoEvt) { + if (discoEvt instanceof DiscoveryCustomEvent) { + + DiscoveryCustomEvent discoCustomEvt = (DiscoveryCustomEvent)discoEvt; + + DiscoveryCustomMessage customMsg = discoCustomEvt.customMessage(); + + if (customMsg instanceof DynamicCacheChangeBatch) { + DynamicCacheChangeBatch cacheChangeBatch = (DynamicCacheChangeBatch)customMsg; + + ExchangeActions exchangeActions = U.field(cacheChangeBatch, "exchangeActions"); + + Collection stopRequests = exchangeActions.cacheStopRequests(); + + return !stopRequests.isEmpty(); + } + } + + return false; + } + + /** + * Read operation tat is going to be executed during blocking operation. + */ + @NotNull protected abstract CacheReadBackgroundOperation getReadOperation(); + + /** + * Checks that {@code block} closure doesn't block read operation. + * Does it for client, baseline and regular server node. + * + * @param blockMsgPred Predicate that check whether the message corresponds to the {@code block} or not. + * @param block Blocking operation. + * @throws Exception If failed. + */ + public void doTest(Predicate blockMsgPred, RunnableX block) throws Exception { + BackgroundOperation backgroundOperation = new BlockMessageOnBaselineBackgroundOperation( + block, + blockMsgPred + ); + + doTest(backgroundOperation); + } + + /** + * Checks that {@code block} closure doesn't block read operation. + * Does it for client, baseline and regular server node. + * + * @param blockMsgCls Class of discovery message to block. + * @param block Blocking operation. + * @throws Exception If failed. + */ + public void doTest(Class blockMsgCls, RunnableX block) throws Exception { + BlockDiscoveryMessageBackgroundOperation backgroundOperation = new BlockDiscoveryMessageBackgroundOperation( + block, + blockMsgCls + ); + + doTest(backgroundOperation); + } + + /** + * Checks that {@code block} closure doesn't block read operation. + * Does it for client, baseline and regular server node. + * + * @param backgroundOperation Background operation. + * @throws Exception If failed. + */ + public void doTest(BackgroundOperation backgroundOperation) throws Exception { + CacheReadBackgroundOperation readOperation = getReadOperation(); + + readOperation.initCache(baseline.get(0), true); + + // Warmup. + if (warmup() > 0) { + try (AutoCloseable read = readOperation.start()) { + Thread.sleep(warmup()); + } + + assertEquals( + readOperation.readOperationsFailed() + " read operations failed during warmup.", + 0, + readOperation.readOperationsFailed() + ); + + assertTrue( + "No read operations were finished during warmup.", + readOperation.readOperationsFinishedUnderBlock() > 0 + ); + } + + doTest0(clients.get(0), readOperation, backgroundOperation); + + doTest0(srvs.get(0), readOperation, backgroundOperation); + + doTest0(baseline.get(0), readOperation, backgroundOperation); + + try (AutoCloseable read = readOperation.start()) { + Thread.sleep(500L); + } + + assertEquals( + readOperation.readOperationsFailed() + " read operations failed during finish stage.", + 0, + readOperation.readOperationsFailed() + ); + + assertTrue( + "No read operations were finished during finish stage.", + readOperation.readOperationsFinishedUnderBlock() > 0 + ); + } + + /** + * Internal part for {@link CacheBlockOnReadAbstractTest#doTest(Predicate, RunnableX)}. + * + * @param ignite Ignite instance. Client / baseline / server node. + * @param readOperation Read operation. + * @param backgroundOperation Background operation. + */ + private void doTest0( + IgniteEx ignite, + CacheReadBackgroundOperation readOperation, + BackgroundOperation backgroundOperation + ) throws Exception { + // Reinit internal cache state with given ignite instance. + readOperation.initCache(ignite, false); + + cntFinishedReadOperations = new CountDownLatch(baseline.size() - 1); + + // Read while potentially blocking operation is executing. + try (AutoCloseable block = backgroundOperation.start()) { + cntFinishedReadOperations.await(5 * timeout(), TimeUnit.MILLISECONDS); + + // Possible if test itself is wrong. + assertEquals("Messages weren't blocked in time", 0, cntFinishedReadOperations.getCount()); + + try (AutoCloseable read = readOperation.start()) { + Thread.sleep(timeout()); + } + } + finally { + cntFinishedReadOperations = null; + } + + log.info("Operations finished: " + readOperation.readOperationsFinishedUnderBlock()); + log.info("Longest operation took " + readOperation.maxReadDuration() + "ms"); + + // None of read operations should fail. + assertEquals( + readOperation.readOperationsFailed() + " read operations failed.", + 0, + readOperation.readOperationsFailed() + ); + + assertTrue( + "No read operations were finished during timeout.", + readOperation.readOperationsFinishedUnderBlock() > 0 + ); + + // There were no operations as long as blocking timeout. + assertNotAlmostEqual(timeout(), readOperation.maxReadDuration()); + + // On average every read operation was much faster then blocking timeout. + double avgDuration = (double)timeout() / readOperation.readOperationsFinishedUnderBlock(); + + assertTrue("Avarage duration was too long.",avgDuration < timeout() * 0.25); + } + + /** + * Utility class that allows to start and stop some background operation many times. + */ + protected abstract static class BackgroundOperation { + /** */ + private IgniteInternalFuture fut; + + /** + * Invoked strictly before background thread is started. + */ + protected void init() { + // No-op. + } + + /** + * Operation itself. Will be executed in separate thread. Thread interruption has to be considered as a valid + * way to stop operation. + */ + protected abstract void execute(); + + /** + * @return Allowed time to wait in {@link BackgroundOperation#stop()} method before canceling background thread. + */ + protected abstract long stopTimeout(); + + /** + * Start separate thread and execute method {@link BackgroundOperation#execute()} in it. + * + * @return {@link AutoCloseable} that invokes {@link BackgroundOperation#stop()} on closing. + */ + AutoCloseable start() { + if (fut != null) + throw new UnsupportedOperationException("Only one simultanious operation is allowed"); + + init(); + + CountDownLatch threadStarted = new CountDownLatch(1); + + fut = GridTestUtils.runAsync(() -> { + try { + threadStarted.countDown(); + + execute(); + } + catch (Exception e) { + throw new IgniteException("Unexpected exception in background operation thread", e); + } + }); + + try { + threadStarted.await(); + } + catch (InterruptedException e) { + try { + fut.cancel(); + } + catch (IgniteCheckedException e1) { + e.addSuppressed(e1); + } + + throw new IgniteException(e); + } + + return this::stop; + } + + /** + * Interrupt the operation started in {@link BackgroundOperation#start()} method and join interrupted thread. + */ + void stop() throws Exception { + if (fut == null) + return; + + try { + fut.get(stopTimeout()); + } + catch (IgniteFutureTimeoutCheckedException e) { + fut.cancel(); + + fut.get(); + } + finally { + fut = null; + } + } + } + + /** + * @param discoEvtPred Predicate that tests discovery events. + * @return New predicate that test any message based on {@code discoEvtPred} predicate. + */ + public static Predicate asMessagePredicate(Predicate discoEvtPred) { + return msg -> { + if (msg instanceof GridDhtPartitionsFullMessage) { + GridDhtPartitionsFullMessage fullMsg = (GridDhtPartitionsFullMessage)msg; + + GridDhtPartitionExchangeId exchangeId = fullMsg.exchangeId(); + + if (exchangeId != null) + return discoEvtPred.test(U.field(exchangeId, "discoEvt")); + } + + return false; + }; + } + + /** + * Background operation that executes some node request and doesn't allow its exchange messages to be fully + * processed until operation is stopped. + */ + protected class BlockMessageOnBaselineBackgroundOperation extends BackgroundOperation { + /** */ + private final RunnableX block; + + /** */ + private final Predicate blockMsg; + + /** + * @param block Blocking operation. + * @param blockMsgPred Predicate that checks whether to block message or not. + * + * @see BlockMessageOnBaselineBackgroundOperation#blockMessage(ClusterNode, Message) + */ + protected BlockMessageOnBaselineBackgroundOperation( + RunnableX block, + Predicate blockMsgPred + ) { + this.block = block; + blockMsg = blockMsgPred; + } + + /** {@inheritDoc} */ + @Override protected void execute() { + for (IgniteEx server : baseline) { + TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(server); + + spi.blockMessages(this::blockMessage); + } + + block.run(); + } + + /** + * Function to pass into {@link TestRecordingCommunicationSpi#blockMessages(IgniteBiPredicate)}. + * + * @param node Node that receives message. + * @param msg Message. + * @return Whether the given message should be blocked or not. + */ + private boolean blockMessage(ClusterNode node, Message msg) { + boolean block = blockMsg.test(msg) + && baseline.stream().map(IgniteEx::name).anyMatch(node.consistentId()::equals); + + if (block) + cntFinishedReadOperations.countDown(); + + return block; + } + + /** {@inheritDoc} */ + @Override protected long stopTimeout() { + // Should be big enough so thread will stop by it's own. Otherwise test will fail, but that's fine. + return 30_000L; + } + + /** {@inheritDoc} */ + @Override void stop() throws Exception { + for (IgniteEx server : baseline) { + TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(server); + + spi.stopBlock(); + } + + super.stop(); + } + } + + /** + * Background operation that executes some node request and doesn't allow its discovery messages to be fully + * processed until operation is stopped. + */ + protected class BlockDiscoveryMessageBackgroundOperation extends BackgroundOperation { + /** */ + private final RunnableX block; + + /** */ + private final Class blockMsgCls; + + /** */ + private volatile CountDownLatch blockLatch; + + /** + * @param block Blocking operation. + * @param blockMsgCls Class of message to block. + * + * @see BlockMessageOnBaselineBackgroundOperation#blockMessage(ClusterNode, Message) + */ + protected BlockDiscoveryMessageBackgroundOperation( + RunnableX block, + Class blockMsgCls + ) { + this.block = block; + this.blockMsgCls = blockMsgCls; + } + + /** {@inheritDoc} */ + @Override protected void execute() { + try { + blockLatch = new CountDownLatch(1); + + discoveryMsgProcessor = this::processMessage; + + for (int i = 0; i < baselineServersCount() - 2; i++) + cntFinishedReadOperations.countDown(); + + block.run(); + } + finally { + discoveryMsgProcessor = null; + } + } + + /** + * Process discovery spi message. + * + * @param msg Message. + * @param receiverConsistentId Consistent ID of message receiver. + */ + private void processMessage(TcpDiscoveryAbstractMessage msg, String receiverConsistentId) { + if (!blockMsgCls.isInstance(msg)) + return; + + boolean baselineSnd = Objects.equals( + baseline.get(1).localNode().consistentId(), + receiverConsistentId + ); + + if (baselineSnd) { + cntFinishedReadOperations.countDown(); + + try { + blockLatch.await(); + } + catch (InterruptedException ignore) { + } + } + } + + /** {@inheritDoc} */ + @Override protected long stopTimeout() { + // Should be big enough so thread will stop by it's own. Otherwise test will fail, but that's fine. + return 30_000L; + } + + /** {@inheritDoc} */ + @Override void stop() throws Exception { + blockLatch.countDown(); + + super.stop(); + } + } + + /** + * Runnable that can throw exceptions. + */ + @FunctionalInterface + public interface RunnableX extends Runnable { + /** + * Closure body. + * + * @throws Exception If failed. + */ + void runx() throws Exception; + + /** {@inheritdoc} */ + @Override default void run() { + try { + runx(); + } + catch (Exception e) { + throw new IgniteException(e); + } + } + } + + /** + * {@link BackgroundOperation} implementation for cache reading operations. + */ + protected abstract class ReadBackgroundOperation extends BackgroundOperation { + + /** Counter for successfully finished operations. */ + private final AtomicInteger readOperationsFinishedUnderBlock = new AtomicInteger(); + + /** Counter for failed operations. */ + private final AtomicInteger readOperationsFailed = new AtomicInteger(); + + /** Duration of the longest read operation. */ + private final AtomicLong maxReadDuration = new AtomicLong(-1); + + /** + * Do single iteration of reading operation. Will be executed in a loop. + */ + protected abstract void doRead() throws Exception; + + + /** {@inheritDoc} */ + @Override protected void init() { + readOperationsFinishedUnderBlock.set(0); + + readOperationsFailed.set(0); + + maxReadDuration.set(-1); + } + + /** {@inheritDoc} */ + @Override protected void execute() { + Set loggedMessages = new HashSet<>(); + + while (!Thread.currentThread().isInterrupted()) { + long prevTs = System.currentTimeMillis(); + + try { + doRead(); + + readOperationsFinishedUnderBlock.incrementAndGet(); + } + catch (Exception e) { + boolean threadInterrupted = X.hasCause(e, + InterruptedException.class, + IgniteInterruptedException.class, + IgniteInterruptedCheckedException.class + ); + + if (threadInterrupted) + Thread.currentThread().interrupt(); + else if (allowException() && X.hasCause(e, ClusterTopologyCheckedException.class)) + readOperationsFinishedUnderBlock.incrementAndGet(); + else { + readOperationsFailed.incrementAndGet(); + + if (loggedMessages.add(e.getMessage())) + log.error("Error during read operation execution", e); + + continue; + } + } + + maxReadDuration.set(Math.max(maxReadDuration.get(), System.currentTimeMillis() - prevTs)); + } + } + + /** {@inheritDoc} */ + @Override protected long stopTimeout() { + return 0; + } + + /** + * @return Number of successfully finished operations. + */ + public int readOperationsFinishedUnderBlock() { + return readOperationsFinishedUnderBlock.get(); + } + + /** + * @return Number of failed operations. + */ + public int readOperationsFailed() { + return readOperationsFailed.get(); + } + + /** + * @return Duration of the longest read operation. + */ + public long maxReadDuration() { + return maxReadDuration.get(); + } + } + + /** + * + */ + protected abstract class CacheReadBackgroundOperation extends ReadBackgroundOperation { + /** + * {@link CacheReadBackgroundOperation#cache()} method backing field. Updated on each + * {@link CacheReadBackgroundOperation#initCache(IgniteEx, boolean)} invocation. + */ + private IgniteCache cache; + + /** + * Reinit internal cache using passed ignite instance and fill it with data if required. + * + * @param ignite Node to get or create cache from. + * @param fillData Whether the cache should be filled with new data or not. + */ + public void initCache(IgniteEx ignite, boolean fillData) { + cache = ignite.getOrCreateCache( + createCacheConfiguration() + .setAtomicityMode(atomicityMode()) + .setCacheMode(cacheMode()) + ); + + if (fillData) { + try (IgniteDataStreamer dataStreamer = ignite.dataStreamer(cache.getName())) { + dataStreamer.allowOverwrite(true); + + for (int i = 0; i < entriesCount(); i++) + dataStreamer.addData(createKey(i), createValue(i)); + } + } + } + + /** + * @return Cache configuration. + */ + protected CacheConfiguration createCacheConfiguration() { + return new CacheConfiguration(DEFAULT_CACHE_NAME) + .setBackups(backupsCount()) + .setAffinity( + new RendezvousAffinityFunction() + .setPartitions(32) + ); + } + + /** + * @return Current cache. + */ + protected final IgniteCache cache() { + return cache; + } + + /** + * @return Count of cache entries to create in {@link CacheReadBackgroundOperation#initCache(IgniteEx, boolean)} + * method. + */ + protected int entriesCount() { + return DFLT_CACHE_ENTRIES_CNT; + } + + /** + * @param idx Unique number. + * @return Key to be used for inserting into cache. + * @see CacheReadBackgroundOperation#createValue(int) + */ + protected abstract KeyType createKey(int idx); + + /** + * @param idx Unique number. + * @return Value to be used for inserting into cache. + * @see CacheReadBackgroundOperation#createKey(int) + */ + protected abstract ValueType createValue(int idx); + } + + /** + * {@link CacheReadBackgroundOperation} implementation for (int -> int) cache. Keys and values are equal by default. + */ + protected abstract class IntCacheReadBackgroundOperation + extends CacheReadBackgroundOperation { + /** {@inheritDoc} */ + @Override protected Integer createKey(int idx) { + return idx; + } + + /** {@inheritDoc} */ + @Override protected Integer createValue(int idx) { + return idx; + } + } + + /** + * @return {@link Params} annotation object from the current test method. + */ + protected Params currentTestParams() { + Params params = currentTestAnnotation(Params.class); + + assertNotNull("Test " + getName() + " is not annotated with @Param annotation.", params); + + return params; + } + + /** + * Assert that two numbers are close to each other. + */ + private static void assertAlmostEqual(long exp, long actual) { + assertTrue(String.format("Numbers differ too much [exp=%d, actual=%d]", exp, actual), almostEqual(exp, actual)); + } + + /** + * Assert that two numbers are not close to each other. + */ + private static void assertNotAlmostEqual(long exp, long actual) { + assertFalse(String.format("Numbers are almost equal [exp=%d, actual=%d]", exp, actual), almostEqual(exp, actual)); + } + + /** + * Check that two numbers are close to each other. + */ + private static boolean almostEqual(long exp, long actual) { + double rel = (double)(actual - exp) / exp; + + return Math.abs(rel) < 0.05; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnScanTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnScanTest.java new file mode 100644 index 0000000000000..2b0289b3e8149 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnScanTest.java @@ -0,0 +1,137 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import java.util.Objects; +import java.util.Random; +import org.apache.ignite.cache.query.ScanQuery; +import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheMode.REPLICATED; + +/** + * + */ +@RunWith(JUnit4.class) +public class CacheBlockOnScanTest extends CacheBlockOnReadAbstractTest { + + /** {@inheritDoc} */ + @Override @NotNull protected CacheReadBackgroundOperation getReadOperation() { + return new IntCacheReadBackgroundOperation() { + /** Random. */ + private Random random = new Random(); + + /** {@inheritDoc} */ + @Override public void doRead() { + int idx = random.nextInt(entriesCount()); + + cache().query(new ScanQuery<>((k, v) -> Objects.equals(k, idx))).getAll(); + } + }; + } + + /** {@inheritDoc} */ + @Params(baseline = 9, atomicityMode = ATOMIC, cacheMode = PARTITIONED, allowException = true) + @Test + @Override public void testStopBaselineAtomicPartitioned() throws Exception { + super.testStopBaselineAtomicPartitioned(); + } + + /** {@inheritDoc} */ + @Params(baseline = 9, atomicityMode = ATOMIC, cacheMode = REPLICATED, allowException = true) + @Test + @Override public void testStopBaselineAtomicReplicated() throws Exception { + super.testStopBaselineAtomicReplicated(); + } + + /** {@inheritDoc} */ + @Params(baseline = 9, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED, allowException = true) + @Test + @Override public void testStopBaselineTransactionalPartitioned() throws Exception { + super.testStopBaselineTransactionalPartitioned(); + } + + /** {@inheritDoc} */ + @Params(baseline = 9, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED, allowException = true) + @Test + @Override public void testStopBaselineTransactionalReplicated() throws Exception { + super.testStopBaselineTransactionalReplicated(); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStartClientAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStartClientTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStopClientAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStopClientTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStartClientAtomicPartitioned() throws Exception { + super.testStartClientTransactionalReplicated(); + } + + /** {@inheritDoc} */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStartClientTransactionalPartitioned() throws Exception { + super.testStartClientTransactionalReplicated(); + } + + /** {@inheritDoc} */ + @Params(atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStopClientAtomicPartitioned() throws Exception { + super.testStopClientTransactionalReplicated(); + } + + /** {@inheritDoc} */ + @Params(atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStopClientTransactionalPartitioned() throws Exception { + super.testStopClientTransactionalReplicated(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnSingleGetTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnSingleGetTest.java new file mode 100644 index 0000000000000..08c15b4e4442a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheBlockOnSingleGetTest.java @@ -0,0 +1,274 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import java.util.Random; +import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheMode.REPLICATED; + +/** + * + */ +@RunWith(JUnit4.class) +public class CacheBlockOnSingleGetTest extends CacheBlockOnReadAbstractTest { + + /** {@inheritDoc} */ + @Override @NotNull protected CacheReadBackgroundOperation getReadOperation() { + return new IntCacheReadBackgroundOperation() { + /** Random. */ + private Random random = new Random(); + + /** {@inheritDoc} */ + @Override public void doRead() { + for (int i = 0; i < 300; i++) + cache().get(random.nextInt(entriesCount())); + } + }; + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStopBaselineAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9915"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStopBaselineAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9915"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStopBaselineTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9915"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStopBaselineTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9915"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testCreateCacheAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testCreateCacheAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testCreateCacheTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testCreateCacheTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testDestroyCacheAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testDestroyCacheAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testDestroyCacheTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testDestroyCacheTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStartServerAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStartServerAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStartServerTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStartServerTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStopServerAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStopServerAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStopServerTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStopServerTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testUpdateBaselineTopologyAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testUpdateBaselineTopologyAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testUpdateBaselineTopologyTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testUpdateBaselineTopologyTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9883"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStartClientAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStartClientAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStartClientTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStartClientTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = PARTITIONED) + @Test + @Override public void testStopClientAtomicPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = ATOMIC, cacheMode = REPLICATED) + @Test + @Override public void testStopClientAtomicReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = PARTITIONED) + @Test + @Override public void testStopClientTransactionalPartitioned() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } + + /** {@inheritDoc} */ + @Params(baseline = 1, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) + @Test + @Override public void testStopClientTransactionalReplicated() { + fail("https://issues.apache.org/jira/browse/IGNITE-9987"); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheClientsConcurrentStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheClientsConcurrentStartTest.java index 58d4ea2c2af58..4e7bbab5e56eb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheClientsConcurrentStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheClientsConcurrentStartTest.java @@ -36,8 +36,6 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -52,6 +50,9 @@ import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicBoolean; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; @@ -59,10 +60,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheClientsConcurrentStartTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRV_CNT = 4; @@ -99,8 +98,6 @@ public class CacheClientsConcurrentStartTest extends GridCommonAbstractTest { } }; - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setMarshaller(null); cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); @@ -127,6 +124,7 @@ public class CacheClientsConcurrentStartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStartNodes() throws Exception { for (int i = 0; i < ITERATIONS; i++) { try { @@ -247,4 +245,4 @@ private CacheConfiguration cacheConfiguration(String cacheName) { return ccfg; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDataLossOnPartitionMoveTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDataLossOnPartitionMoveTest.java index 9ff072500b6fc..02c7ee8ce385a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDataLossOnPartitionMoveTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDataLossOnPartitionMoveTest.java @@ -36,15 +36,20 @@ import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.TestRecordingCommunicationSpi; import org.apache.ignite.internal.processors.cache.GridCacheUtils; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.testframework.GridTestNode; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.EVICTED; import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING; @@ -52,6 +57,7 @@ /** * */ +@RunWith(JUnit4.class) public class CacheDataLossOnPartitionMoveTest extends GridCommonAbstractTest { /** */ public static final long MB = 1024 * 1024L; @@ -118,7 +124,10 @@ private String grp(int idx) { /** * @throws Exception if failed. */ + @Test public void testDataLossOnPartitionMove() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10421", MvccFeatureChecker.forcedMvcc()); + try { Ignite ignite = startGridsMultiThreaded(GRIDS_CNT / 2, false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java index 4cf89b2521031..1fa054df51311 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java @@ -31,23 +31,21 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.GridAtomicInteger; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * */ -@SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Iteration. */ private static final int ITERATIONS = 3; @@ -87,7 +85,7 @@ public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest } }; - testSpi.setIpFinder(ipFinder); + testSpi.setIpFinder(sharedStaticIpFinder); testSpi.setJoinTimeout(60_000); cfg.setDiscoverySpi(testSpi); @@ -120,6 +118,7 @@ public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testConcurrentJoin() throws Exception { for (int iter = 0; iter < ITERATIONS; iter++) { log.info("Iteration: " + iter); @@ -170,6 +169,7 @@ public void testConcurrentJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentJoinCacheWithGroup() throws Exception { withCacheGrp = true; @@ -212,4 +212,4 @@ private CacheConfiguration cacheConfiguration(String cacheName) { private void checkCache(Ignite node, final String cacheName) { assertNotNull(((IgniteKernal)node).context().cache().cache(cacheName)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheExchangeMergeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheExchangeMergeTest.java index d95a7bf978aa3..189b4dd029253 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheExchangeMergeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheExchangeMergeTest.java @@ -66,19 +66,22 @@ import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.eclipse.jetty.util.ConcurrentHashSet; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_EXCHANGE_HISTORY_SIZE; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -88,10 +91,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheExchangeMergeTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final long WAIT_SECONDS = 15; @@ -120,8 +121,6 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (testSpi) cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); else if (testDelaySpi) @@ -149,7 +148,12 @@ else if (testDelaySpi) cacheConfiguration("c7", TRANSACTIONAL, PARTITIONED, 1), cacheConfiguration("c8", TRANSACTIONAL, PARTITIONED, 2), cacheConfiguration("c9", TRANSACTIONAL, PARTITIONED, 10), - cacheConfiguration("c10", TRANSACTIONAL, REPLICATED, 0) + cacheConfiguration("c10", TRANSACTIONAL, REPLICATED, 0), + cacheConfiguration("c11", TRANSACTIONAL_SNAPSHOT, PARTITIONED, 0), + cacheConfiguration("c12", TRANSACTIONAL_SNAPSHOT, PARTITIONED, 1), + cacheConfiguration("c13", TRANSACTIONAL_SNAPSHOT, PARTITIONED, 2), + cacheConfiguration("c14", TRANSACTIONAL_SNAPSHOT, PARTITIONED, 10), + cacheConfiguration("c15", TRANSACTIONAL_SNAPSHOT, REPLICATED, 0) ); } @@ -203,6 +207,7 @@ private CacheConfiguration cacheConfiguration(String name, /** * @throws Exception If failed. */ + @Test public void testDelayExchangeMessages() throws Exception { testDelaySpi = true; @@ -275,6 +280,7 @@ public void testDelayExchangeMessages() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeStartRandomClientsServers() throws Exception { for (int iter = 0; iter < 3; iter++) { ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -331,6 +337,7 @@ public void testMergeStartRandomClientsServers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeStartStopRandomClientsServers() throws Exception { for (int iter = 0; iter < 3; iter++) { log.info("Iteration: " + iter); @@ -403,6 +410,7 @@ public void testMergeStartStopRandomClientsServers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartServers() throws Exception { concurrentStart(false); } @@ -410,6 +418,7 @@ public void testConcurrentStartServers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartServersAndClients() throws Exception { concurrentStart(true); } @@ -419,7 +428,9 @@ public void testConcurrentStartServersAndClients() throws Exception { * @throws Exception If failed. */ private void concurrentStart(final boolean withClients) throws Exception { - for (int i = 0; i < 5; i++) { + int iterations = GridTestUtils.SF.applyLB(5, 1); + + for (int i = 0; i < iterations; i++) { log.info("Iteration: " + i); startGrid(0); @@ -456,6 +467,8 @@ private void concurrentStart(final boolean withClients) throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10186") + @Test public void testMergeServerAndClientJoin1() throws Exception { final IgniteEx srv0 = startGrid(0); @@ -494,6 +507,7 @@ public void testMergeServerAndClientJoin1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartCacheOnJoinAndJoinMerge_2_nodes() throws Exception { startCacheOnJoinAndJoinMerge1(2, false); } @@ -501,6 +515,7 @@ public void testStartCacheOnJoinAndJoinMerge_2_nodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartCacheOnJoinAndJoinMerge_4_nodes() throws Exception { startCacheOnJoinAndJoinMerge1(4, false); } @@ -508,6 +523,7 @@ public void testStartCacheOnJoinAndJoinMerge_4_nodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartCacheOnJoinAndJoinMerge_WithClients() throws Exception { startCacheOnJoinAndJoinMerge1(5, true); } @@ -544,6 +560,7 @@ private void startCacheOnJoinAndJoinMerge1(int nodes, boolean withClients) throw /** * @throws Exception If failed. */ + @Test public void testMergeAndHistoryCleanup() throws Exception { final int histSize = 5; @@ -608,6 +625,7 @@ private void checkHistorySize(int histSize) { /** * @throws Exception If failed. */ + @Test public void testStartCacheOnJoinAndMergeWithFail() throws Exception { cfgCache = false; @@ -633,6 +651,7 @@ public void testStartCacheOnJoinAndMergeWithFail() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartCacheOnJoinAndCoordinatorFailed1() throws Exception { cfgCache = false; @@ -654,6 +673,7 @@ public void testStartCacheOnJoinAndCoordinatorFailed1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartCacheOnJoinAndCoordinatorFailed2() throws Exception { cfgCache = false; @@ -675,6 +695,7 @@ public void testStartCacheOnJoinAndCoordinatorFailed2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeServersJoin1() throws Exception { IgniteEx srv0 = startGrid(0); @@ -702,6 +723,7 @@ public void testMergeServersJoin1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeServerJoin1ClientsInTopology() throws Exception { IgniteEx srv0 = startGrid(0); @@ -739,6 +761,7 @@ public void testMergeServerJoin1ClientsInTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeAndNewCoordinator() throws Exception { final Ignite srv0 = startGrids(3); @@ -758,6 +781,7 @@ public void testMergeAndNewCoordinator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeServersFail1_1() throws Exception { mergeServersFail1(false); } @@ -765,6 +789,7 @@ public void testMergeServersFail1_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeServersFail1_2() throws Exception { mergeServersFail1(true); } @@ -810,6 +835,7 @@ private void mergeServersFail1(boolean waitRebalance) throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeServersAndClientsFail1() throws Exception { mergeServersAndClientsFail(false); } @@ -817,11 +843,11 @@ public void testMergeServersAndClientsFail1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeServersAndClientsFail2() throws Exception { mergeServersAndClientsFail(true); } - /** * @param waitRebalance Wait for rebalance end before start tested topology change. * @throws Exception If failed. @@ -859,6 +885,7 @@ private void mergeServersAndClientsFail(boolean waitRebalance) throws Exception /** * @throws Exception If failed. */ + @Test public void testJoinExchangeCoordinatorChange_NoMerge_1() throws Exception { for (CoordinatorChangeMode mode : CoordinatorChangeMode.values()) { exchangeCoordinatorChangeNoMerge(4, true, mode); @@ -870,6 +897,7 @@ public void testJoinExchangeCoordinatorChange_NoMerge_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinExchangeCoordinatorChange_NoMerge_2() throws Exception { for (CoordinatorChangeMode mode : CoordinatorChangeMode.values()) { exchangeCoordinatorChangeNoMerge(8, true, mode); @@ -881,6 +909,7 @@ public void testJoinExchangeCoordinatorChange_NoMerge_2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailExchangeCoordinatorChange_NoMerge_1() throws Exception { for (CoordinatorChangeMode mode : CoordinatorChangeMode.values()) { exchangeCoordinatorChangeNoMerge(5, false, mode); @@ -892,6 +921,7 @@ public void testFailExchangeCoordinatorChange_NoMerge_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailExchangeCoordinatorChange_NoMerge_2() throws Exception { for (CoordinatorChangeMode mode : CoordinatorChangeMode.values()) { exchangeCoordinatorChangeNoMerge(8, false, mode); @@ -903,6 +933,7 @@ public void testFailExchangeCoordinatorChange_NoMerge_2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMergeJoinExchangesCoordinatorChange1_4_servers() throws Exception { for (CoordinatorChangeMode mode : CoordinatorChangeMode.values()) { mergeJoinExchangesCoordinatorChange1(4, mode); @@ -914,6 +945,7 @@ public void testMergeJoinExchangesCoordinatorChange1_4_servers() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testMergeJoinExchangesCoordinatorChange1_8_servers() throws Exception { for (CoordinatorChangeMode mode : CoordinatorChangeMode.values()) { mergeJoinExchangesCoordinatorChange1(8, mode); @@ -955,6 +987,7 @@ private void mergeJoinExchangesCoordinatorChange1(final int srvs, CoordinatorCha /** * @throws Exception If failed. */ + @Test public void testMergeJoinExchangesCoordinatorChange2_4_servers() throws Exception { mergeJoinExchangeCoordinatorChange2(4, 2, F.asList(1, 2, 3, 4), F.asList(5)); @@ -998,6 +1031,7 @@ private void mergeJoinExchangeCoordinatorChange2(final int srvs, /** * @throws Exception If failed. */ + @Test public void testMergeExchangeCoordinatorChange4() throws Exception { testSpi = true; @@ -1378,7 +1412,7 @@ private void checkNodeCaches(final Ignite node) throws Exception { assertEquals(err, e.getValue(), res.get(e.getKey())); } - if (cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL) { + if (atomicityMode(cache) == TRANSACTIONAL) { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) checkNodeCaches(err, node, cache, concurrency, isolation); @@ -1456,11 +1490,12 @@ private void checkExchanges(Ignite node, long... vers) { for (int i = futs.size() - 1; i >= 0; i--) { GridDhtPartitionsExchangeFuture fut = futs.get(i); - if (fut.exchangeDone() && fut.firstEvent().type() != EVT_DISCOVERY_CUSTOM_EVT) { + if (!fut.isMerged() && fut.exchangeDone() && fut.firstEvent().type() != EVT_DISCOVERY_CUSTOM_EVT) { AffinityTopologyVersion resVer = fut.topologyVersion(); - if (resVer != null) - doneVers.add(resVer); + Assert.assertNotNull(resVer); + + doneVers.add(resVer); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java index 3d1fe11bec8b9..16962e6431bbe 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java @@ -35,21 +35,19 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshaller; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; /** * Test for reproducing problems during simultaneously Ignite instances stopping and cache requests executing. */ +@RunWith(JUnit4.class) public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Grid count. */ private static final int GRID_CNT = 8; @@ -64,8 +62,6 @@ public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); cfg.setMarshaller(new BinaryMarshaller()); @@ -90,6 +86,7 @@ public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testContainsKeyFailover() throws Exception { int cnt = 3; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetInsideLockChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetInsideLockChangingTopologyTest.java index 80aa9eee5d006..9d00367d39127 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetInsideLockChangingTopologyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetInsideLockChangingTopologyTest.java @@ -37,13 +37,13 @@ import org.apache.ignite.internal.processors.cache.GridCacheAlwaysEvictionPolicy; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -56,9 +56,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheGetInsideLockChangingTopologyTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); /** */ private static ThreadLocal client = new ThreadLocal<>(); @@ -84,8 +83,6 @@ public class CacheGetInsideLockChangingTopologyTest extends GridCommonAbstractTe ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - Boolean clientMode = client.get(); client.set(null); @@ -155,6 +152,7 @@ private CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode at /** * @throws Exception If failed. */ + @Test public void testTxGetInsideLockStopPrimary() throws Exception { getInsideLockStopPrimary(ignite(SRVS), TX_CACHE1); getInsideLockStopPrimary(ignite(SRVS + 1), TX_CACHE1); @@ -166,6 +164,7 @@ public void testTxGetInsideLockStopPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicGetInsideLockStopPrimary() throws Exception { getInsideLockStopPrimary(ignite(SRVS), ATOMIC_CACHE); @@ -175,6 +174,7 @@ public void testAtomicGetInsideLockStopPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicGetInsideTxStopPrimary() throws Exception { getInsideTxStopPrimary(ignite(SRVS), ATOMIC_CACHE); @@ -184,6 +184,7 @@ public void testAtomicGetInsideTxStopPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadCommittedPessimisticStopPrimary() throws Exception { getReadCommittedStopPrimary(ignite(SRVS), TX_CACHE1, PESSIMISTIC); getReadCommittedStopPrimary(ignite(SRVS + 1), TX_CACHE1, PESSIMISTIC); @@ -195,6 +196,7 @@ public void testReadCommittedPessimisticStopPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadCommittedOptimisticStopPrimary() throws Exception { getReadCommittedStopPrimary(ignite(SRVS), TX_CACHE1, OPTIMISTIC); getReadCommittedStopPrimary(ignite(SRVS + 1), TX_CACHE1, OPTIMISTIC); @@ -363,6 +365,7 @@ private void getInsideTxStopPrimary(Ignite ignite, String cacheName) throws Exce /** * @throws Exception If failed. */ + @Test public void testMultithreaded() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-2204"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGroupsPreloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGroupsPreloadTest.java index 88596380c2aca..34d9dca53ca15 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGroupsPreloadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGroupsPreloadTest.java @@ -22,18 +22,17 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheGroupsPreloadTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE1 = "cache1"; @@ -67,8 +66,6 @@ public class CacheGroupsPreloadTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration cfg1 = defaultCacheConfiguration() .setName(CACHE1) .setGroupName(GROUP1) @@ -90,6 +87,7 @@ public class CacheGroupsPreloadTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCachePreload1() throws Exception { cachePreloadTest(); } @@ -97,6 +95,7 @@ public void testCachePreload1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCachePreload2() throws Exception { atomicityMode = CacheAtomicityMode.TRANSACTIONAL; @@ -106,6 +105,18 @@ public void testCachePreload2() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testCachePreloadMvcc2() throws Exception { + atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCachePreload3() throws Exception { cacheMode = CacheMode.REPLICATED; @@ -115,6 +126,7 @@ public void testCachePreload3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCachePreload4() throws Exception { cacheMode = CacheMode.REPLICATED; atomicityMode = CacheAtomicityMode.TRANSACTIONAL; @@ -125,6 +137,18 @@ public void testCachePreload4() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testCachePreloadMvcc4() throws Exception { + cacheMode = CacheMode.REPLICATED; + atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCachePreload5() throws Exception { sameGrp = false; @@ -134,6 +158,7 @@ public void testCachePreload5() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCachePreload6() throws Exception { sameGrp = false; atomicityMode = CacheAtomicityMode.TRANSACTIONAL; @@ -144,6 +169,19 @@ public void testCachePreload6() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testCachePreloadMvcc6() throws Exception { + sameGrp = false; + atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCachePreload7() throws Exception { sameGrp = false; cacheMode = CacheMode.REPLICATED; @@ -154,6 +192,7 @@ public void testCachePreload7() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCachePreload8() throws Exception { sameGrp = false; cacheMode = CacheMode.REPLICATED; @@ -162,6 +201,18 @@ public void testCachePreload8() throws Exception { cachePreloadTest(); } + /** + * @throws Exception If failed. + */ + @Test + public void testCachePreloadMvcc8() throws Exception { + sameGrp = false; + cacheMode = CacheMode.REPLICATED; + atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + + cachePreloadTest(); + } + /** * @throws Exception If failed. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentNodeJoinValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentNodeJoinValidationTest.java index 48b33b6c20b7e..0256f9355d6ed 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentNodeJoinValidationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentNodeJoinValidationTest.java @@ -19,18 +19,16 @@ import org.apache.ignite.Ignite; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheLateAffinityAssignmentNodeJoinValidationTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean lateAff; @@ -43,8 +41,6 @@ public class CacheLateAffinityAssignmentNodeJoinValidationTest extends GridCommo cfg.setLateAffinityAssignment(lateAff); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -60,6 +56,7 @@ public class CacheLateAffinityAssignmentNodeJoinValidationTest extends GridCommo /** * @throws Exception If failed. */ + @Test public void testJoinValidation1() throws Exception { checkNodeJoinValidation(false); } @@ -67,6 +64,7 @@ public void testJoinValidation1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinValidation2() throws Exception { checkNodeJoinValidation(true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java index c777abaf4caeb..e4fc758c632b1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java @@ -54,13 +54,12 @@ import org.apache.ignite.events.DiscoveryEvent; import org.apache.ignite.internal.DiscoverySpiTestListener; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.cluster.NodeOrderComparator; -import org.apache.ignite.internal.cluster.NodeOrderLegacyComparator; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.IgniteNodeAttributes; import org.apache.ignite.internal.TestRecordingCommunicationSpi; import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException; +import org.apache.ignite.internal.cluster.NodeOrderComparator; import org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl; @@ -90,14 +89,16 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -109,10 +110,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -158,14 +157,11 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest { cfg.setCommunicationSpi(commSpi); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); + TcpDiscoverySpi discoSpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); discoSpi.setForceServerMode(forceSrvMode); - discoSpi.setIpFinder(ipFinder); discoSpi.setNetworkTimeout(60_000); - cfg.setDiscoverySpi(discoSpi); - cfg.setClientFailureDetectionTimeout(100000); CacheConfiguration[] ccfg; @@ -234,6 +230,7 @@ protected AffinityFunction affinityFunction(@Nullable Integer parts) { * * @throws Exception If failed. */ + @Test public void testDelayedAffinityCalculation() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -293,6 +290,7 @@ public void testDelayedAffinityCalculation() throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinitySimpleSequentialStart() throws Exception { startServer(0, 1); @@ -314,6 +312,7 @@ public void testAffinitySimpleSequentialStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinitySimpleSequentialStartNoCacheOnCoordinator() throws Exception { cacheC = new IgniteClosure() { @Override public CacheConfiguration[] apply(String igniteInstanceName) { @@ -334,6 +333,7 @@ public void testAffinitySimpleSequentialStartNoCacheOnCoordinator() throws Excep /** * @throws Exception If failed. */ + @Test public void testAffinitySimpleNoCacheOnCoordinator1() throws Exception { cacheC = new IgniteClosure() { @Override public CacheConfiguration[] apply(String igniteInstanceName) { @@ -373,6 +373,7 @@ public void testAffinitySimpleNoCacheOnCoordinator1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinitySimpleNoCacheOnCoordinator2() throws Exception { System.setProperty(IGNITE_EXCHANGE_COMPATIBILITY_VER_1, "true"); @@ -432,6 +433,7 @@ public void testAffinitySimpleNoCacheOnCoordinator2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateCloseClientCacheOnCoordinator1() throws Exception { cacheC = new IgniteClosure() { @Override public CacheConfiguration[] apply(String igniteInstanceName) { @@ -457,6 +459,7 @@ public void testCreateCloseClientCacheOnCoordinator1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateCloseClientCacheOnCoordinator2() throws Exception { cacheC = new IgniteClosure() { @Override public CacheConfiguration[] apply(String igniteInstanceName) { @@ -503,6 +506,7 @@ public void testCreateCloseClientCacheOnCoordinator2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheDestroyAndCreate1() throws Exception { cacheDestroyAndCreate(true); } @@ -510,6 +514,7 @@ public void testCacheDestroyAndCreate1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheDestroyAndCreate2() throws Exception { cacheDestroyAndCreate(false); } @@ -579,6 +584,7 @@ private void cacheDestroyAndCreate(boolean cacheOnCrd) throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinitySimpleNodeLeave1() throws Exception { affinitySimpleNodeLeave(2); } @@ -588,6 +594,7 @@ public void testAffinitySimpleNodeLeave1() throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinitySimpleNodeLeave2() throws Exception { affinitySimpleNodeLeave(4); } @@ -623,6 +630,7 @@ private void affinitySimpleNodeLeave(int cnt) throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinitySimpleNodeLeaveClientAffinity() throws Exception { startServer(0, 1); @@ -644,6 +652,7 @@ public void testAffinitySimpleNodeLeaveClientAffinity() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeLeaveExchangeWaitAffinityMessage() throws Exception { System.setProperty(IGNITE_EXCHANGE_COMPATIBILITY_VER_1, "true"); @@ -693,6 +702,7 @@ public void testNodeLeaveExchangeWaitAffinityMessage() throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinitySimpleClientNodeEvents1() throws Exception { affinitySimpleClientNodeEvents(1); } @@ -702,6 +712,7 @@ public void testAffinitySimpleClientNodeEvents1() throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinitySimpleClientNodeEvents2() throws Exception { affinitySimpleClientNodeEvents(3); } @@ -737,6 +748,7 @@ private void affinitySimpleClientNodeEvents(int srvs) throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentMultipleJoin1() throws Exception { delayAssignmentMultipleJoin(2); } @@ -746,6 +758,7 @@ public void testDelayAssignmentMultipleJoin1() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentMultipleJoin2() throws Exception { delayAssignmentMultipleJoin(4); } @@ -794,6 +807,7 @@ private void delayAssignmentMultipleJoin(int joinCnt) throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentClientJoin() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -818,6 +832,7 @@ public void testDelayAssignmentClientJoin() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentClientLeave() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -848,6 +863,7 @@ public void testDelayAssignmentClientLeave() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentClientCacheStart() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -884,6 +900,7 @@ public void testDelayAssignmentClientCacheStart() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentCacheStart() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -918,6 +935,7 @@ public void testDelayAssignmentCacheStart() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentCacheDestroy() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -952,6 +970,7 @@ public void testDelayAssignmentCacheDestroy() throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinitySimpleStopRandomNode() throws Exception { //fail("IGNITE-GG-12292"); @@ -1001,6 +1020,7 @@ public void testAffinitySimpleStopRandomNode() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentCoordinatorLeave1() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -1025,6 +1045,7 @@ public void testDelayAssignmentCoordinatorLeave1() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentCoordinatorLeave2() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -1054,6 +1075,7 @@ public void testDelayAssignmentCoordinatorLeave2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlockedFinishMsg1() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(4, 3, false, 2); } @@ -1062,6 +1084,7 @@ public void testBlockedFinishMsg1() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockedFinishMsg2() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(4, 3, false); } @@ -1070,6 +1093,7 @@ public void testBlockedFinishMsg2() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockedFinishMsg3() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(4, 3, false, 1); } @@ -1078,6 +1102,7 @@ public void testBlockedFinishMsg3() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockedFinishMsg4() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(5, 3, false); } @@ -1086,6 +1111,7 @@ public void testBlockedFinishMsg4() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockedFinishMsg5() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(5, 3, false, 1); } @@ -1094,6 +1120,7 @@ public void testBlockedFinishMsg5() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockedFinishMsg6() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(5, 3, false, 2); } @@ -1102,6 +1129,7 @@ public void testBlockedFinishMsg6() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockedFinishMsg7() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(5, 3, false, 2, 4); } @@ -1110,6 +1138,7 @@ public void testBlockedFinishMsg7() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockedFinishMsg8() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(6, 3, false, 2, 4); } @@ -1118,6 +1147,7 @@ public void testBlockedFinishMsg8() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockedFinishMsg9() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(5, 1, false, 4); } @@ -1126,6 +1156,7 @@ public void testBlockedFinishMsg9() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockedFinishMsgForClient() throws Exception { doTestCoordLeaveBlockedFinishExchangeMessage(5, 1, true, 4); } @@ -1223,6 +1254,7 @@ private void doTestCoordLeaveBlockedFinishExchangeMessage(int cnt, * * @throws Exception If failed. */ + @Test public void testCoordinatorLeaveAfterNodeLeavesDelayAssignment() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -1272,6 +1304,7 @@ public void testCoordinatorLeaveAfterNodeLeavesDelayAssignment() throws Exceptio * * @throws Exception If failed. */ + @Test public void testNodeLeftExchangeCoordinatorLeave1() throws Exception { nodeLeftExchangeCoordinatorLeave(3); } @@ -1281,6 +1314,7 @@ public void testNodeLeftExchangeCoordinatorLeave1() throws Exception { * * @throws Exception If failed. */ + @Test public void testNodeLeftExchangeCoordinatorLeave2() throws Exception { nodeLeftExchangeCoordinatorLeave(5); } @@ -1335,6 +1369,7 @@ private void nodeLeftExchangeCoordinatorLeave(int nodes) throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinExchangeBecomeCoordinator() throws Exception { long topVer = 0; @@ -1396,6 +1431,7 @@ public void testJoinExchangeBecomeCoordinator() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentAffinityChanged() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -1438,6 +1474,7 @@ public void testDelayAssignmentAffinityChanged() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentAffinityChanged2() throws Exception { System.setProperty(IGNITE_EXCHANGE_COMPATIBILITY_VER_1, "true"); @@ -1519,6 +1556,7 @@ public void testDelayAssignmentAffinityChanged2() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelayAssignmentCacheDestroyCreate() throws Exception { Ignite ignite0 = startServer(0, 1); @@ -1572,6 +1610,7 @@ public void testDelayAssignmentCacheDestroyCreate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientCacheStartClose() throws Exception { cacheC = new IgniteClosure() { @Override public CacheConfiguration[] apply(String igniteInstanceName) { @@ -1600,6 +1639,7 @@ public void testClientCacheStartClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheStartDestroy() throws Exception { startGridsMultiThreaded(3, false); @@ -1634,6 +1674,7 @@ public void testCacheStartDestroy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInitCacheReceivedOnJoin() throws Exception { cacheC = new IgniteClosure() { @Override public CacheConfiguration[] apply(String s) { @@ -1677,6 +1718,7 @@ public void testInitCacheReceivedOnJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientStartFirst1() throws Exception { clientStartFirst(1); } @@ -1684,6 +1726,7 @@ public void testClientStartFirst1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientStartFirst2() throws Exception { clientStartFirst(3); } @@ -1724,7 +1767,11 @@ private void clientStartFirst(int clients) throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomOperations() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10261"); + forceSrvMode = true; final int MAX_SRVS = 10; @@ -1935,6 +1982,7 @@ public void testRandomOperations() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartStaticCaches() throws Exception { concurrentStartStaticCaches(false); } @@ -1942,6 +1990,7 @@ public void testConcurrentStartStaticCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartStaticCachesWithClientNodes() throws Exception { concurrentStartStaticCaches(true); } @@ -2014,6 +2063,7 @@ private void concurrentStartStaticCaches(boolean withClients) throws Exception { /** * @throws Exception If failed. */ + @Test public void testServiceReassign() throws Exception { skipCheckOrder = true; @@ -2047,7 +2097,11 @@ public void testServiceReassign() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoForceKeysRequests() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10604"); + cacheC = new IgniteClosure() { @Override public CacheConfiguration[] apply(String s) { return null; @@ -2157,6 +2211,7 @@ public void testNoForceKeysRequests() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStreamer1() throws Exception { cacheC = new IgniteClosure() { @Override public CacheConfiguration[] apply(String s) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLoadingConcurrentGridStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLoadingConcurrentGridStartSelfTest.java index cbd012443de9b..723161131ce0d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLoadingConcurrentGridStartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLoadingConcurrentGridStartSelfTest.java @@ -22,6 +22,7 @@ import java.util.LinkedHashSet; import java.util.Set; import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; import javax.cache.Cache; import javax.cache.configuration.FactoryBuilder; import javax.cache.integration.CacheLoaderException; @@ -48,8 +49,12 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -59,6 +64,7 @@ /** * Tests for cache data loading during simultaneous grids start. */ +@RunWith(JUnit4.class) public class CacheLoadingConcurrentGridStartSelfTest extends GridCommonAbstractTest implements Serializable { /** Grids count */ private static int GRIDS_CNT = 5; @@ -78,6 +84,11 @@ public class CacheLoadingConcurrentGridStartSelfTest extends GridCommonAbstractT /** Restarts. */ protected volatile boolean restarts; + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + } + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -135,6 +146,7 @@ protected CacheAtomicityMode atomicityMode() { /** * @throws Exception if failed */ + @Test public void testLoadCacheWithDataStreamer() throws Exception { configured = true; @@ -162,6 +174,7 @@ public void testLoadCacheWithDataStreamer() throws Exception { /** * @throws Exception if failed */ + @Test public void testLoadCacheFromStore() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-4210"); @@ -175,6 +188,7 @@ public void testLoadCacheFromStore() throws Exception { /** * @throws Exception if failed */ + @Test public void testLoadCacheWithDataStreamerSequentialClient() throws Exception { client = true; @@ -189,6 +203,7 @@ public void testLoadCacheWithDataStreamerSequentialClient() throws Exception { /** * @throws Exception if failed */ + @Test public void testLoadCacheWithDataStreamerSequentialClientWithConfig() throws Exception { client = true; configured = true; @@ -205,6 +220,7 @@ public void testLoadCacheWithDataStreamerSequentialClientWithConfig() throws Exc /** * @throws Exception if failed */ + @Test public void testLoadCacheWithDataStreamerSequential() throws Exception { loadCacheWithDataStreamerSequential(); } @@ -212,6 +228,7 @@ public void testLoadCacheWithDataStreamerSequential() throws Exception { /** * @throws Exception if failed */ + @Test public void testLoadCacheWithDataStreamerSequentialWithConfigAndRestarts() throws Exception { restarts = true; configured = true; @@ -228,6 +245,7 @@ public void testLoadCacheWithDataStreamerSequentialWithConfigAndRestarts() throw /** * @throws Exception if failed */ + @Test public void testLoadCacheWithDataStreamerSequentialWithConfig() throws Exception { configured = true; @@ -261,8 +279,11 @@ private void loadCacheWithDataStreamerSequential() throws Exception { } }); + CountDownLatch startNodesLatch = new CountDownLatch(1); IgniteInternalFuture fut = runAsync(new Callable() { @Override public Object call() throws Exception { + startNodesLatch.await(); + for (int i = 2; i < GRIDS_CNT; i++) startGrid(i); @@ -272,24 +293,35 @@ private void loadCacheWithDataStreamerSequential() throws Exception { final HashSet set = new HashSet<>(); - IgniteInClosure f = new IgniteInClosure() { - @Override public void apply(Ignite grid) { - try (IgniteDataStreamer dataStreamer = grid.dataStreamer(DEFAULT_CACHE_NAME)) { - dataStreamer.allowOverwrite(allowOverwrite); + boolean stop = false; + int insertedKeys = 0; - ((DataStreamerImpl)dataStreamer).maxRemapCount(Integer.MAX_VALUE); + startNodesLatch.countDown(); - for (int i = 0; i < KEYS_CNT; i++) { - set.add(dataStreamer.addData(i, "Data")); + try (IgniteDataStreamer dataStreamer = g0.dataStreamer(DEFAULT_CACHE_NAME)) { + dataStreamer.allowOverwrite(allowOverwrite); + ((DataStreamerImpl)dataStreamer).maxRemapCount(Integer.MAX_VALUE); - if (i % 100000 == 0) - log.info("Streaming " + i + "'th entry."); - } - } - } - }; + long startingEndTs = -1L; - f.apply(g0); + while (!stop) { + set.add(dataStreamer.addData(insertedKeys, "Data")); + insertedKeys = insertedKeys + 1; + + if (insertedKeys % 100000 == 0) + log.info("Streaming " + insertedKeys + "'th entry."); + + //When all nodes started we continue restart nodes during 1 second and stop it after this timeout. + if (fut.isDone() && startingEndTs == -1) + startingEndTs = System.currentTimeMillis(); + + if (startingEndTs != -1) //Nodes starting was ended and we check restarts duration after it. + restarts = (System.currentTimeMillis() - startingEndTs) < 1000; + + //Stop test when all keys were inserted or restarts timeout was exceeded. + stop = insertedKeys >= KEYS_CNT || (fut.isDone() && !restarts); + } + } log.info("Data loaded."); @@ -305,10 +337,10 @@ private void loadCacheWithDataStreamerSequential() throws Exception { long size = cache.size(CachePeekMode.PRIMARY); - if (size != KEYS_CNT) { + if (size != insertedKeys) { Set failedKeys = new LinkedHashSet<>(); - for (int i = 0; i < KEYS_CNT; i++) + for (int i = 0; i < insertedKeys; i++) if (!cache.containsKey(i)) { log.info("Actual cache size: " + size); @@ -336,7 +368,7 @@ private void loadCacheWithDataStreamerSequential() throws Exception { assert failedKeys.isEmpty() : "Some failed keys: " + failedKeys.toString(); } - assertCacheSize(); + assertCacheSize(insertedKeys); } /** @@ -361,20 +393,20 @@ protected void loadCache(IgniteInClosure f) throws Exception { fut.get(); } - assertCacheSize(); + assertCacheSize(KEYS_CNT); } /** * @throws Exception If failed. */ - private void assertCacheSize() throws Exception { + private void assertCacheSize(int expectedCacheSize) throws Exception { final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); boolean consistentCache = GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { int size = cache.size(CachePeekMode.PRIMARY); - if (size != KEYS_CNT) + if (size != expectedCacheSize) log.info("Cache size: " + size); int total = 0; @@ -382,10 +414,10 @@ private void assertCacheSize() throws Exception { for (int i = 0; i < GRIDS_CNT; i++) total += grid(i).cache(DEFAULT_CACHE_NAME).localSize(CachePeekMode.PRIMARY); - if (total != KEYS_CNT) + if (total != expectedCacheSize) log.info("Total size: " + size); - return size == KEYS_CNT && KEYS_CNT == total; + return size == expectedCacheSize && expectedCacheSize == total; } }, 2 * 60_000); @@ -418,4 +450,4 @@ private static class TestCacheStoreAdapter extends CacheStoreAdapter f; + + Exception err = null; + + while ((f = q.poll()) != null) { + try { + f.get(60_000); + } + catch (Exception e) { + error("Test operation failed: " + e, e); - lock.unlock(); + if (err == null) + err = e; + } + } + + if (err != null) + fail("Test operation failed, see log for details"); + } + finally { + stopAllGrids(); + } + } + + /** + * @throws Exception If failed. + */ + @Test + public void testLockNodeStop() throws Exception { + final int nodeCnt = 3; + int threadCnt = 2; + final int keys = 100; + + try { + final AtomicBoolean stop = new AtomicBoolean(false); + + Queue> q = new ArrayDeque<>(nodeCnt); + + for (int i = 0; i < nodeCnt; i++) { + final Ignite ignite = startGrid(i); + + IgniteInternalFuture f = GridTestUtils.runMultiThreadedAsync(new Runnable() { + @Override public void run() { + while (!Thread.currentThread().isInterrupted() && !stop.get()) { + try { + IgniteCache cache = ignite.cache(REPLICATED_TEST_CACHE); + + for (int i = 0; i < keys; i++) { + Lock lock = cache.lock(i); + lock.lock(); + + try { + cache.put(i, i); + } + finally { + lock.unlock(); + } + } + } + catch (Exception e) { + log.info("Ignore error: " + e); + + break; } } } @@ -168,12 +251,31 @@ public void testLockTopologyChange() throws Exception { U.sleep(1_000); } + U.sleep(ThreadLocalRandom.current().nextLong(500) + 500); + + // Stop all nodes, check that threads executing cache operations do not hang. + stopAllGrids(); + stop.set(true); IgniteInternalFuture f; - while ((f = q.poll()) != null) - f.get(2_000); + Exception err = null; + + while ((f = q.poll()) != null) { + try { + f.get(60_000); + } + catch (Exception e) { + error("Test operation failed: " + e, e); + + if (err == null) + err = e; + } + } + + if (err != null) + fail("Test operation failed, see log for details"); } finally { stopAllGrids(); @@ -183,6 +285,7 @@ public void testLockTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxLockRelease() throws Exception { startGrids(2); @@ -231,6 +334,7 @@ public void testTxLockRelease() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockRelease2() throws Exception { final Ignite ignite0 = startGrid(0); @@ -277,6 +381,7 @@ public void testLockRelease2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockRelease3() throws Exception { startGrid(0); @@ -311,6 +416,7 @@ public void testLockRelease3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxLockRelease2() throws Exception { final Ignite ignite0 = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheOperationsInterruptTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheOperationsInterruptTest.java new file mode 100644 index 0000000000000..50de443ad8a34 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheOperationsInterruptTest.java @@ -0,0 +1,167 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; + +import java.util.concurrent.Callable; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicBoolean; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.REPLICATED; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * + */ +@RunWith(JUnit4.class) +public class CacheOperationsInterruptTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + + ccfg.setAtomicityMode(TRANSACTIONAL); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setCacheMode(REPLICATED); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + super.afterTest(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testInterruptPessimisticTx() throws Exception { + final int NODES = 3; + + startGrids(NODES); + + awaitPartitionMapExchange(); + + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + Ignite node = ignite(0); + + IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); + + final int KEYS = 100; + + final boolean changeTop = true; + + for (int i = 0; i < 10; i++) { + info("Iteration: " + i); + + final AtomicBoolean stop = new AtomicBoolean(); + + try { + IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Runnable() { + @Override public void run() { + Ignite node = ignite(0); + + IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); + + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + while (!stop.get()) { + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + for (int i = 0; i < KEYS; i++) { + if (rnd.nextBoolean()) + cache.get(i); + } + } + } + } + }, 3, "tx-thread"); + + IgniteInternalFuture changeTopFut = null; + + if (changeTop) { + changeTopFut = GridTestUtils.runAsync(new Callable() { + @Override public Void call() throws Exception { + while (!stop.get()) { + startGrid(NODES); + + stopGrid(NODES); + } + + return null; + } + }); + } + + U.sleep(rnd.nextInt(500)); + + fut.cancel(); + + U.sleep(rnd.nextInt(500)); + + stop.set(true); + + try { + fut.get(); + } + catch (Exception e) { + info("Ignore error: " + e); + } + + if (changeTopFut != null) + changeTopFut.get(); + + info("Try get"); + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + for (int k = 0; k < KEYS; k++) + cache.get(k); + } + + info("Try get done"); + + startGrid(NODES); + stopGrid(NODES); + } + finally { + stop.set(true); + } + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePageWriteLockUnlockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePageWriteLockUnlockTest.java index 84fd91656f9c2..7af5c8d346b20 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePageWriteLockUnlockTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePageWriteLockUnlockTest.java @@ -21,6 +21,7 @@ import javax.cache.Cache; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; @@ -37,12 +38,16 @@ import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING; /** * */ +@RunWith(JUnit4.class) public class CachePageWriteLockUnlockTest extends GridCommonAbstractTest { /** */ public static final int PARTITION = 0; @@ -51,8 +56,9 @@ public class CachePageWriteLockUnlockTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME). - setAffinity(new RendezvousAffinityFunction(false, 32))); + cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME) + .setAffinity(new RendezvousAffinityFunction(false, 32)) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); cfg.setActiveOnStart(false); @@ -72,6 +78,7 @@ public class CachePageWriteLockUnlockTest extends GridCommonAbstractTest { /** * */ + @Test public void testPreloadPartition() throws Exception { try { IgniteEx grid0 = startGrid(0); @@ -100,6 +107,8 @@ public void testPreloadPartition() throws Exception { grid0 = startGrid(0); + grid0.cluster().active(true); + preloadPartition(grid0, DEFAULT_CACHE_NAME, PARTITION); Iterator> it = grid0.cache(DEFAULT_CACHE_NAME).iterator(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheParallelStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheParallelStartTest.java new file mode 100644 index 0000000000000..1f5bd356d5cef --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheParallelStartTest.java @@ -0,0 +1,197 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import java.util.ArrayList; +import java.util.Collection; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.util.typedef.internal.CU; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Test covers parallel start and stop of caches. + */ +@RunWith(JUnit4.class) +public class CacheParallelStartTest extends GridCommonAbstractTest { + /** */ + private static final int CACHES_COUNT = 500; + + /** */ + private static final String STATIC_CACHE_PREFIX = "static-cache-"; + + /** */ + private static final String STATIC_CACHE_CACHE_GROUP_NAME = "static-cache-group"; + + /** + * {@inheritDoc} + */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setSystemThreadPoolSize(Runtime.getRuntime().availableProcessors() * 3); + + long sz = 100 * 1024 * 1024; + + DataStorageConfiguration memCfg = new DataStorageConfiguration().setPageSize(1024) + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration().setPersistenceEnabled(false).setInitialSize(sz).setMaxSize(sz)) + .setWalMode(WALMode.LOG_ONLY).setCheckpointFrequency(24L * 60 * 60 * 1000); + + cfg.setDataStorageConfiguration(memCfg); + + ArrayList staticCaches = new ArrayList<>(CACHES_COUNT); + + for (int i = 0; i < CACHES_COUNT; i++) + staticCaches.add(cacheConfiguration(STATIC_CACHE_PREFIX + i)); + + cfg.setCacheConfiguration(staticCaches.toArray(new CacheConfiguration[CACHES_COUNT])); + + return cfg; + } + + /** + * @param cacheName Cache name. + * @return Cache configuration. + */ + private CacheConfiguration cacheConfiguration(String cacheName) { + CacheConfiguration cfg = defaultCacheConfiguration(); + + cfg.setName(cacheName); + cfg.setBackups(1); + cfg.setGroupName(STATIC_CACHE_CACHE_GROUP_NAME); + cfg.setIndexedTypes(Long.class, Long.class); + + return cfg; + } + + /** + * {@inheritDoc} + */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + cleanupTestData(); + } + + /** + * {@inheritDoc} + */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + cleanupTestData(); + } + + /** */ + private void cleanupTestData() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + System.clearProperty(IgniteSystemProperties.IGNITE_ALLOW_START_CACHES_IN_PARALLEL); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testParallelStartAndStop() throws Exception { + testParallelStartAndStop(true); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testSequentialStartAndStop() throws Exception { + testParallelStartAndStop(false); + } + + /** + * + */ + private void testParallelStartAndStop(boolean parallel) throws Exception { + System.setProperty(IgniteSystemProperties.IGNITE_ALLOW_START_CACHES_IN_PARALLEL, String.valueOf(parallel)); + + IgniteEx igniteEx = startGrid(0); + + IgniteEx igniteEx2 = startGrid(1); + + igniteEx.cluster().active(true); + + assertCaches(igniteEx); + + assertCaches(igniteEx2); + + igniteEx.cluster().active(false); + + assertCachesAfterStop(igniteEx); + + assertCachesAfterStop(igniteEx2); + } + + /** + * + */ + private void assertCachesAfterStop(IgniteEx igniteEx) { + assertNull(igniteEx + .context() + .cache() + .cacheGroup(CU.cacheId(STATIC_CACHE_CACHE_GROUP_NAME))); + + assertTrue(igniteEx.context().cache().cacheGroups().isEmpty()); + + for (int i = 0; i < CACHES_COUNT; i++) { + assertNull(igniteEx.context().cache().cache(STATIC_CACHE_PREFIX + i)); + assertNull(igniteEx.context().cache().internalCache(STATIC_CACHE_PREFIX + i)); + } + } + + /** + * + */ + private void assertCaches(IgniteEx igniteEx) { + Collection caches = igniteEx + .context() + .cache() + .cacheGroup(CU.cacheId(STATIC_CACHE_CACHE_GROUP_NAME)) + .caches(); + + assertEquals(CACHES_COUNT, caches.size()); + + @Nullable CacheGroupContext cacheGroup = igniteEx + .context() + .cache() + .cacheGroup(CU.cacheId(STATIC_CACHE_CACHE_GROUP_NAME)); + + for (GridCacheContext cacheContext : caches) + assertEquals(cacheContext.group(), cacheGroup); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePartitionStateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePartitionStateTest.java index 95059187cfdcf..158de18fe2347 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePartitionStateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePartitionStateTest.java @@ -37,10 +37,10 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.EVICTED; @@ -50,10 +50,8 @@ /** * */ +@RunWith(JUnit4.class) public class CachePartitionStateTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -64,8 +62,6 @@ public class CachePartitionStateTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); cfg.setClientMode(client); @@ -89,6 +85,7 @@ public class CachePartitionStateTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPartitionState1_1() throws Exception { partitionState1(0, true); } @@ -96,6 +93,7 @@ public void testPartitionState1_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionState1_2() throws Exception { partitionState1(1, true); } @@ -103,6 +101,7 @@ public void testPartitionState1_2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionState1_2_NoCacheOnCoordinator() throws Exception { partitionState1(1, false); } @@ -110,6 +109,7 @@ public void testPartitionState1_2_NoCacheOnCoordinator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionState1_3() throws Exception { partitionState1(100, true); } @@ -117,6 +117,7 @@ public void testPartitionState1_3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionState2_1() throws Exception { partitionState2(0, true); } @@ -124,6 +125,7 @@ public void testPartitionState2_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionState2_2() throws Exception { partitionState2(1, true); } @@ -131,6 +133,7 @@ public void testPartitionState2_2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionState2_2_NoCacheOnCoordinator() throws Exception { partitionState2(1, false); } @@ -138,6 +141,7 @@ public void testPartitionState2_2_NoCacheOnCoordinator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionState2_3() throws Exception { partitionState2(100, true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java index 57a150fbfd2b1..cc7d5ece5d6c3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java @@ -38,12 +38,15 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractSelfTest { /** */ private static final int NODE_CNT = 2; @@ -95,6 +98,7 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS /** * @throws Exception If failed. */ + @org.junit.Test public void testPutAllFailover() throws Exception { testPutAllFailover(Test.PUT_ALL); } @@ -102,6 +106,7 @@ public void testPutAllFailover() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testPutAllFailoverPessimisticTx() throws Exception { if (atomicityMode() == CacheAtomicityMode.ATOMIC) return; @@ -112,6 +117,7 @@ public void testPutAllFailoverPessimisticTx() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testPutAllFailoverAsync() throws Exception { testPutAllFailover(Test.PUT_ALL_ASYNC); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRentingStateRepairTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRentingStateRepairTest.java index b21c95ea88a9f..0933a51cb2ad0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRentingStateRepairTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheRentingStateRepairTest.java @@ -31,22 +31,21 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; /** * */ +@RunWith(JUnit4.class) public class CacheRentingStateRepairTest extends GridCommonAbstractTest { /** */ public static final int PARTS = 1024; - /** */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -69,12 +68,6 @@ public class CacheRentingStateRepairTest extends GridCommonAbstractTest { cfg.setConsistentId(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - long sz = 100 * 1024 * 1024; DataStorageConfiguration memCfg = new DataStorageConfiguration().setPageSize(1024) @@ -95,6 +88,7 @@ public class CacheRentingStateRepairTest extends GridCommonAbstractTest { /** * */ + @Test public void testRentingStateRepairAfterRestart() throws Exception { try { IgniteEx g0 = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheResultIsNotNullOnPartitionLossTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheResultIsNotNullOnPartitionLossTest.java index ceafc9e61600d..4e042633fafef 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheResultIsNotNullOnPartitionLossTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheResultIsNotNullOnPartitionLossTest.java @@ -17,15 +17,21 @@ package org.apache.ignite.internal.processors.cache.distributed; +import java.util.Collections; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteClientDisconnectedException; import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.PartitionLossPolicy; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.EventType; @@ -35,26 +41,25 @@ import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.processors.cache.CacheInvalidStateException; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of servers to be started. */ - private static final int SERVERS = 10; + private static final int SERVERS = 5; /** Index of node that is goning to be the only client node. */ private static final int CLIENT_IDX = SERVERS; /** Number of cache entries to insert into the test cache. */ - private static final int CACHE_ENTRIES_CNT = 10_000; + private static final int CACHE_ENTRIES_CNT = 60; /** True if {@link #getConfiguration(String)} is expected to configure client node on next invocations. */ private boolean isClient; @@ -66,8 +71,6 @@ public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractT @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setIncludeEventTypes(EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST); cfg.setCacheConfiguration( @@ -75,6 +78,7 @@ public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractT .setCacheMode(CacheMode.PARTITIONED) .setBackups(0) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) + .setAffinity(new RendezvousAffinityFunction(false, 50)) .setPartitionLossPolicy(PartitionLossPolicy.READ_WRITE_SAFE) ); @@ -90,7 +94,12 @@ public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractT cleanPersistenceDir(); - startGrids(SERVERS); + List list = IntStream.range(0, SERVERS).boxed().collect(Collectors.toList()); + + Collections.shuffle(list); + + for (Integer i : list) + startGrid(i); isClient = true; @@ -114,6 +123,7 @@ public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testCacheResultIsNotNullOnClient() throws Exception { testCacheResultIsNotNull0(client); } @@ -121,6 +131,7 @@ public void testCacheResultIsNotNullOnClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheResultIsNotNullOnLastServer() throws Exception { testCacheResultIsNotNull0(grid(SERVERS - 1)); } @@ -128,6 +139,7 @@ public void testCacheResultIsNotNullOnLastServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheResultIsNotNullOnServer() throws Exception { testCacheResultIsNotNull0(grid(SERVERS - 2)); } @@ -178,9 +190,9 @@ private void testCacheResultIsNotNull0(IgniteEx ignite) throws Exception { readerThreadStarted.await(1, TimeUnit.SECONDS); for (int i = 0; i < SERVERS - 1; i++) { - Thread.sleep(50L); - grid(i).close(); + + Thread.sleep(400L); } } finally { @@ -204,6 +216,7 @@ private void testCacheResultIsNotNull0(IgniteEx ignite) throws Exception { private boolean expectedThrowableClass(Throwable throwable) { return X.hasCause( throwable, + IgniteClientDisconnectedException.class, CacheInvalidStateException.class, ClusterTopologyCheckedException.class, IllegalStateException.class, diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheStartOnJoinTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheStartOnJoinTest.java index d59f4709506d1..e04f27b9f2be8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheStartOnJoinTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheStartOnJoinTest.java @@ -38,23 +38,23 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.testframework.MvccFeatureChecker.assertMvccWriteConflict; /** * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class CacheStartOnJoinTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Iteration. */ private static final int ITERATIONS = 3; @@ -92,7 +92,7 @@ public class CacheStartOnJoinTest extends GridCommonAbstractTest { } }; - testSpi.setIpFinder(ipFinder); + testSpi.setIpFinder(sharedStaticIpFinder); testSpi.setJoinTimeout(60_000); cfg.setDiscoverySpi(testSpi); @@ -128,6 +128,7 @@ public class CacheStartOnJoinTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testConcurrentClientsStart1() throws Exception { concurrentClientsStart(false); } @@ -135,6 +136,7 @@ public void testConcurrentClientsStart1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentClientsStart2() throws Exception { concurrentClientsStart(true); } @@ -184,7 +186,18 @@ private void doTest(final boolean createCache) throws Exception { if (createCache) { for (int c = 0; c < 5; c++) { for (IgniteCache cache : node.getOrCreateCaches(cacheConfigurations())) { - cache.put(c, c); + boolean updated = false; + + while (!updated) { + try { + cache.put(c, c); + + updated = true; + } + catch (Exception e) { + assertMvccWriteConflict(e); + } + } assertEquals(c, cache.get(c)); } @@ -256,4 +269,4 @@ private CacheConfiguration cacheConfiguration(String cacheName) { private void checkCache(Ignite node, final String cacheName) { assertNotNull(((IgniteKernal)node).context().cache().cache(cacheName)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheTryLockMultithreadedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheTryLockMultithreadedTest.java index 82d9c129bcebd..ca4ad037e747e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheTryLockMultithreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheTryLockMultithreadedTest.java @@ -23,11 +23,12 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -37,10 +38,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheTryLockMultithreadedTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRVS = 2; @@ -51,8 +50,6 @@ public class CacheTryLockMultithreadedTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); @@ -77,9 +74,15 @@ public class CacheTryLockMultithreadedTest extends GridCommonAbstractTest { startGrid(SRVS); } + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + } + /** * @throws Exception If failed. */ + @Test public void testTryLock() throws Exception { Ignite client = grid(SRVS); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheTxNearUpdateTopologyChangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheTxNearUpdateTopologyChangeTest.java index df02bb963ddf5..f00f56b78cd47 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheTxNearUpdateTopologyChangeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheTxNearUpdateTopologyChangeTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.processors.cache.CacheNearUpdateTopologyChangeAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -26,6 +27,13 @@ * */ public class CacheTxNearUpdateTopologyChangeTest extends CacheNearUpdateTopologyChangeAbstractTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java index 6210a302f0b67..85a91b7714132 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java @@ -17,17 +17,19 @@ package org.apache.ignite.internal.processors.cache.distributed; -import java.util.Arrays; -import java.util.Collections; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CachePeekMode; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractByteArrayValuesSelfTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -37,19 +39,34 @@ /** * Tests for byte array values in distributed caches. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractDistributedByteArrayValuesSelfTest extends GridCacheAbstractByteArrayValuesSelfTest { - /** Grids. */ - protected static Ignite[] ignites; + /** */ + private static final String CACHE = "cache"; + + /** */ + private static final String MVCC_CACHE = "mvccCache"; /** Regular caches. */ private static IgniteCache[] caches; + /** Regular caches. */ + private static IgniteCache[] mvccCaches; + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - c.setCacheConfiguration(cacheConfiguration()); + CacheConfiguration mvccCfg = cacheConfiguration(MVCC_CACHE) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) + .setNearConfiguration(null); // TODO IGNITE-7187: remove near cache disabling. + + + CacheConfiguration ccfg = cacheConfiguration(CACHE); + + c.setCacheConfiguration(ccfg, mvccCfg); c.setPeerClassLoadingEnabled(peerClassLoading()); @@ -69,12 +86,13 @@ protected int gridCount() { } /** + * @param name Cache name. * @return Cache configuration. */ - protected CacheConfiguration cacheConfiguration() { + protected CacheConfiguration cacheConfiguration(String name) { CacheConfiguration cfg = cacheConfiguration0(); - cfg.setName(CACHE_REGULAR); + cfg.setName(name); return cfg; } @@ -87,26 +105,31 @@ protected CacheConfiguration cacheConfiguration() { /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + int gridCnt = gridCount(); assert gridCnt > 0; - ignites = new Ignite[gridCnt]; - caches = new IgniteCache[gridCnt]; + mvccCaches = new IgniteCache[gridCnt]; - for (int i = 0; i < gridCnt; i++) { - ignites[i] = startGrid(i); + startGridsMultiThreaded(gridCnt); - caches[i] = ignites[i].cache(CACHE_REGULAR); + for (int i = 0; i < gridCnt; i++) { + caches[i] = grid(i).cache(CACHE); + mvccCaches[i] = grid(i).cache(MVCC_CACHE); } } /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { caches = null; + mvccCaches = null; - ignites = null; + stopAllGrids(); + + super.afterTestsStopped(); } /** @@ -114,6 +137,7 @@ protected CacheConfiguration cacheConfiguration() { * * @throws Exception If failed. */ + @Test public void testPessimistic() throws Exception { testTransaction0(caches, PESSIMISTIC, KEY_1, wrap(1)); } @@ -123,6 +147,7 @@ public void testPessimistic() throws Exception { * * @throws Exception If failed. */ + @Test public void testPessimisticMixed() throws Exception { testTransactionMixed0(caches, PESSIMISTIC, KEY_1, wrap(1), KEY_2, 1); } @@ -132,6 +157,7 @@ public void testPessimisticMixed() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimistic() throws Exception { testTransaction0(caches, OPTIMISTIC, KEY_1, wrap(1)); } @@ -141,10 +167,32 @@ public void testOptimistic() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimisticMixed() throws Exception { testTransactionMixed0(caches, OPTIMISTIC, KEY_1, wrap(1), KEY_2, 1); } + /** + * Check whether cache with byte array entry works correctly in PESSIMISTIC transaction. + * + * @throws Exception If failed. + */ + @Test + public void testPessimisticMvcc() throws Exception { + testTransaction0(mvccCaches, PESSIMISTIC, KEY_1, wrap(1)); + } + + /** + * Check whether cache with byte array entry works correctly in PESSIMISTIC transaction. + * + * @throws Exception If failed. + */ + @Test + public void testPessimisticMvccMixed() throws Exception { + testTransactionMixed0(mvccCaches, PESSIMISTIC, KEY_1, wrap(1), KEY_2, 1); + } + + /** * Test transaction behavior. * @@ -172,6 +220,9 @@ private void testTransaction0(IgniteCache[] caches, Transaction */ private void testTransactionMixed0(IgniteCache[] caches, TransactionConcurrency concurrency, Integer key1, byte[] val1, @Nullable Integer key2, @Nullable Object val2) throws Exception { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, REPEATABLE_READ)) + return; + for (IgniteCache cache : caches) { info("Checking cache: " + cache.getName()); @@ -227,4 +278,4 @@ private void testTransactionMixed0(IgniteCache[] caches, Transa assertNull(cache.get(key1)); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractJobExecutionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractJobExecutionTest.java index 589435951d247..0242b773d6ec3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractJobExecutionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractJobExecutionTest.java @@ -22,20 +22,19 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.util.typedef.CX1; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -44,29 +43,14 @@ /** * Tests cache access from within jobs. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractJobExecutionTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Job counter. */ private static final AtomicInteger cntr = new AtomicInteger(0); /** */ private static final int GRID_CNT = 4; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(GRID_CNT, true); @@ -97,6 +81,7 @@ public abstract class GridCacheAbstractJobExecutionTest extends GridCommonAbstra /** * @throws Exception If failed. */ + @Test public void testPessimisticRepeatableRead() throws Exception { checkTransactions(PESSIMISTIC, REPEATABLE_READ, 1000); } @@ -104,6 +89,7 @@ public void testPessimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticSerializable() throws Exception { checkTransactions(PESSIMISTIC, SERIALIZABLE, 1000); } @@ -192,4 +178,4 @@ private void checkTransactions( } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java index f32aab5fe9b6a..1fbc13fdb176b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java @@ -42,12 +42,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -60,7 +60,7 @@ /** * Test node restart. */ -@SuppressWarnings({"PointlessArithmeticExpression"}) +@RunWith(JUnit4.class) public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbstractTest { /** Cache name. */ protected static final String CACHE_NAME = "TEST_CACHE"; @@ -119,9 +119,6 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs /** Retries. */ private int retries = DFLT_RETRIES; - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -129,16 +126,12 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs ((TcpCommunicationSpi)c.getCommunicationSpi()).setSharedMemoryPort(-1); // Discovery. - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); + TcpDiscoverySpi disco = (TcpDiscoverySpi)c.getDiscoverySpi(); disco.setSocketTimeout(30_000); disco.setAckTimeout(30_000); disco.setNetworkTimeout(30_000); - c.setDiscoverySpi(disco); - CacheConfiguration ccfg = cacheConfiguration(); if (evict) { @@ -217,6 +210,7 @@ private void startGrids() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestart() throws Exception { rebalancMode = SYNC; partitions = 3; @@ -293,6 +287,7 @@ protected TransactionConcurrency txConcurrency() { /** * @throws Exception If failed. */ + @Test public void testRestartWithPutTwoNodesNoBackups() throws Throwable { backups = 0; nodeCnt = 2; @@ -309,6 +304,7 @@ public void testRestartWithPutTwoNodesNoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithTxTwoNodesNoBackups() throws Throwable { backups = 0; nodeCnt = 2; @@ -325,6 +321,7 @@ public void testRestartWithTxTwoNodesNoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithPutTwoNodesOneBackup() throws Throwable { backups = 1; nodeCnt = 2; @@ -341,6 +338,7 @@ public void testRestartWithPutTwoNodesOneBackup() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithTxTwoNodesOneBackup() throws Throwable { backups = 1; nodeCnt = 2; @@ -357,6 +355,7 @@ public void testRestartWithTxTwoNodesOneBackup() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithPutFourNodesNoBackups() throws Throwable { backups = 0; nodeCnt = 4; @@ -373,6 +372,7 @@ public void testRestartWithPutFourNodesNoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithTxFourNodesNoBackups() throws Throwable { backups = 0; nodeCnt = 4; @@ -389,6 +389,7 @@ public void testRestartWithTxFourNodesNoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithPutFourNodesOneBackups() throws Throwable { backups = 1; nodeCnt = 4; @@ -405,6 +406,7 @@ public void testRestartWithPutFourNodesOneBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithPutFourNodesOneBackupsOffheapEvict() throws Throwable { backups = 1; nodeCnt = 4; @@ -421,6 +423,7 @@ public void testRestartWithPutFourNodesOneBackupsOffheapEvict() throws Throwable /** * @throws Exception If failed. */ + @Test public void testRestartWithTxFourNodesOneBackups() throws Throwable { backups = 1; nodeCnt = 4; @@ -437,6 +440,7 @@ public void testRestartWithTxFourNodesOneBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithTxFourNodesOneBackupsOffheapEvict() throws Throwable { backups = 1; nodeCnt = 4; @@ -453,6 +457,7 @@ public void testRestartWithTxFourNodesOneBackupsOffheapEvict() throws Throwable /** * @throws Exception If failed. */ + @Test public void testRestartWithPutSixNodesTwoBackups() throws Throwable { backups = 2; nodeCnt = 6; @@ -469,6 +474,7 @@ public void testRestartWithPutSixNodesTwoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithTxSixNodesTwoBackups() throws Throwable { backups = 2; nodeCnt = 6; @@ -485,6 +491,7 @@ public void testRestartWithTxSixNodesTwoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithPutEightNodesTwoBackups() throws Throwable { backups = 2; nodeCnt = 8; @@ -501,6 +508,7 @@ public void testRestartWithPutEightNodesTwoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithTxEightNodesTwoBackups() throws Throwable { backups = 2; nodeCnt = 8; @@ -517,6 +525,7 @@ public void testRestartWithTxEightNodesTwoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithPutTenNodesTwoBackups() throws Throwable { backups = 2; nodeCnt = 10; @@ -533,6 +542,7 @@ public void testRestartWithPutTenNodesTwoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithTxTenNodesTwoBackups() throws Throwable { backups = 2; nodeCnt = 10; @@ -549,6 +559,7 @@ public void testRestartWithTxTenNodesTwoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithTxPutAllTenNodesTwoBackups() throws Throwable { backups = 2; nodeCnt = 10; @@ -565,6 +576,7 @@ public void testRestartWithTxPutAllTenNodesTwoBackups() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testRestartWithTxPutAllFourNodesTwoBackups() throws Throwable { backups = 2; nodeCnt = 4; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPartitionedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPartitionedByteArrayValuesSelfTest.java index 4af2571ada55b..78429446a84ca 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPartitionedByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPartitionedByteArrayValuesSelfTest.java @@ -18,9 +18,7 @@ package org.apache.ignite.internal.processors.cache.distributed; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.configuration.TransactionConfiguration; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -31,22 +29,9 @@ */ public abstract class GridCacheAbstractPartitionedByteArrayValuesSelfTest extends GridCacheAbstractDistributedByteArrayValuesSelfTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TransactionConfiguration tCfg = new TransactionConfiguration(); - - tCfg.setTxSerializableEnabled(true); - - cfg.setTransactionConfiguration(tCfg); - - return cfg; - } - /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration0() { - CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + CacheConfiguration cfg = new CacheConfiguration(); cfg.setCacheMode(PARTITIONED); cfg.setAtomicityMode(TRANSACTIONAL); @@ -61,4 +46,4 @@ public abstract class GridCacheAbstractPartitionedByteArrayValuesSelfTest extend * @return Distribution mode. */ protected abstract NearCacheConfiguration nearConfiguration(); -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPrimarySyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPrimarySyncSelfTest.java index 625cb18a3d792..30729e06d326a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPrimarySyncSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPrimarySyncSelfTest.java @@ -21,11 +21,12 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,13 +38,11 @@ /** * Test ensuring that PRIMARY_SYNC mode works correctly. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractPrimarySyncSelfTest extends GridCommonAbstractTest { /** Grids count. */ private static final int GRID_CNT = 3; - /** IP_FINDER. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -59,12 +58,6 @@ public abstract class GridCacheAbstractPrimarySyncSelfTest extends GridCommonAbs cfg.setCacheConfiguration(ccfg); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - return cfg; } @@ -75,6 +68,12 @@ public abstract class GridCacheAbstractPrimarySyncSelfTest extends GridCommonAbs startGrids(GRID_CNT); } + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + if (nearConfiguration() != null) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + } + /** * @return Distribution mode. */ @@ -83,6 +82,7 @@ public abstract class GridCacheAbstractPrimarySyncSelfTest extends GridCommonAbs /** * @throws Exception If failed. */ + @Test public void testPrimarySync() throws Exception { for (int i = 0; i < GRID_CNT; i++) { for (int j = 0; j < GRID_CNT; j++) { @@ -102,4 +102,4 @@ public void testPrimarySync() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBasicOpAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBasicOpAbstractTest.java index a55ff2d2ef5f7..1e981c365b6c4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBasicOpAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBasicOpAbstractTest.java @@ -24,16 +24,16 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.Event; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; @@ -45,6 +45,7 @@ /** * Simple cache test. */ +@RunWith(JUnit4.class) public abstract class GridCacheBasicOpAbstractTest extends GridCommonAbstractTest { /** Grid 1. */ private static Ignite ignite1; @@ -55,22 +56,6 @@ public abstract class GridCacheBasicOpAbstractTest extends GridCommonAbstractTes /** Grid 3. */ private static Ignite ignite3; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(3); @@ -89,6 +74,11 @@ public abstract class GridCacheBasicOpAbstractTest extends GridCommonAbstractTes /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-7952"); + for (Ignite g : G.allGrids()) g.cache(DEFAULT_CACHE_NAME).clear(); } @@ -97,6 +87,7 @@ public abstract class GridCacheBasicOpAbstractTest extends GridCommonAbstractTes * * @throws Exception If error occur. */ + @Test public void testBasicOps() throws Exception { CountDownLatch latch = new CountDownLatch(3); @@ -172,6 +163,7 @@ public void testBasicOps() throws Exception { /** * @throws Exception If test fails. */ + @Test public void testBasicOpsAsync() throws Exception { CountDownLatch latch = new CountDownLatch(3); @@ -252,6 +244,7 @@ public void testBasicOpsAsync() throws Exception { * * @throws IgniteCheckedException If test fails. */ + @Test public void testOptimisticTransaction() throws Exception { CountDownLatch latch = new CountDownLatch(9); @@ -326,7 +319,10 @@ public void testOptimisticTransaction() throws Exception { * * @throws Exception In case of error. */ + @Test public void testPutWithExpiration() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + IgniteCache cache1 = ignite1.cache(DEFAULT_CACHE_NAME); IgniteCache cache2 = ignite2.cache(DEFAULT_CACHE_NAME); IgniteCache cache3 = ignite3.cache(DEFAULT_CACHE_NAME); @@ -390,4 +386,4 @@ void setLatch(CountDownLatch latch) { return true; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java index 33766f3725986..0bf51f644e1fa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java @@ -30,6 +30,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -37,6 +41,7 @@ /** * Tests near-only cache. */ +@RunWith(JUnit4.class) public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbstractSelfTest { /** Grid cnt. */ private static AtomicInteger gridCnt; @@ -51,6 +56,9 @@ public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbst /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + if (nearEnabled()) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + gridCnt = new AtomicInteger(); super.beforeTestsStarted(); @@ -59,6 +67,12 @@ public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbst grid(nearOnlyIgniteInstanceName).createNearCache(DEFAULT_CACHE_NAME, nearConfiguration()); } + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + if (nearEnabled()) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -109,6 +123,7 @@ protected boolean isClientStartedLast() { /** * @throws Exception If failed. */ + @Test public void testPutFromClientNode() throws Exception { IgniteCache nearOnly = nearOnlyCache(); @@ -151,6 +166,7 @@ public void testPutFromClientNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetFromClientNode() throws Exception { IgniteCache dht = dhtCache(); @@ -190,6 +206,7 @@ public void testGetFromClientNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearOnlyAffinity() throws Exception { for (int i = 0; i < gridCount(); i++) { Ignite g = grid(i); @@ -278,4 +295,4 @@ public TestClass2(int val) { this.val = val; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java index aea6ce6f3c409..cb830ab352975 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java @@ -27,6 +27,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -36,6 +39,7 @@ /** * */ +@RunWith(JUnit4.class) public abstract class GridCacheEntrySetAbstractSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int GRID_CNT = 2; @@ -61,6 +65,7 @@ public abstract class GridCacheEntrySetAbstractSelfTest extends GridCacheAbstrac /** * @throws Exception If failed. */ + @Test public void testEntrySet() throws Exception { for (int i = 0; i < 10; i++) { log.info("Iteration: " + i); @@ -114,4 +119,4 @@ private void putAndCheckEntrySet(IgniteCache cache) throws Excep tx.commit(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetIterationPreloadingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetIterationPreloadingSelfTest.java index 53d3a7aede3d0..160f8fc22d9d2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetIterationPreloadingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetIterationPreloadingSelfTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests entry wrappers after preloading happened. */ +@RunWith(JUnit4.class) public class GridCacheEntrySetIterationPreloadingSelfTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -63,6 +67,7 @@ public class GridCacheEntrySetIterationPreloadingSelfTest extends GridCacheAbstr /** * @throws Exception If failed. */ + @Test public void testIteration() throws Exception { try { final IgniteCache cache = jcache(); @@ -93,4 +98,4 @@ public void testIteration() throws Exception { stopGrid(1); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java index daa1557d7273a..abaaa7e021b51 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java @@ -40,7 +40,11 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVTS_CACHE; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; @@ -52,6 +56,7 @@ /** * Tests events. */ +@RunWith(JUnit4.class) public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTest { /** */ private static final boolean TEST_INFO = true; @@ -77,6 +82,8 @@ protected boolean partitioned() { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + super.beforeTestsStarted(); gridCnt = gridCount(); @@ -222,6 +229,7 @@ private Map pairs(int size) { * Note: test was disabled for REPPLICATED cache case because IGNITE-607. * This comment should be removed if test passed stably. */ + @Test public void testGetPutRemove() throws Exception { runTest( new TestCacheRunnable() { @@ -249,6 +257,7 @@ public void testGetPutRemove() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testGetPutRemoveTx1() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -282,6 +291,7 @@ public void testGetPutRemoveTx1() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testGetPutRemoveTx2() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -322,6 +332,7 @@ public void testGetPutRemoveTx2() throws Exception { * Note: test was disabled for REPPLICATED cache case because IGNITE-607. * This comment should be removed if test passed stably. */ + @Test public void testGetPutRemoveAsync() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -348,6 +359,7 @@ public void testGetPutRemoveAsync() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testGetPutRemoveAsyncTx1() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -381,6 +393,7 @@ public void testGetPutRemoveAsyncTx1() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testGetPutRemoveAsyncTx2() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -418,6 +431,7 @@ public void testGetPutRemoveAsyncTx2() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testPutRemovex() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -442,6 +456,7 @@ public void testPutRemovex() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testPutRemovexTx1() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -472,6 +487,7 @@ public void testPutRemovexTx1() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testPutRemovexTx2() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -507,6 +523,7 @@ public void testPutRemovexTx2() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testPutIfAbsent() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -538,6 +555,7 @@ public void testPutIfAbsent() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testPutIfAbsentTx() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -576,6 +594,7 @@ public void testPutIfAbsentTx() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testPutIfAbsentAsync() throws Exception { runTest(new TestCacheRunnable() { @Override public void run(IgniteCache cache) throws IgniteCheckedException { @@ -610,6 +629,7 @@ public void testPutIfAbsentAsync() throws Exception { * @throws Exception If test failed. */ @SuppressWarnings("unchecked") + @Test public void testPutIfAbsentAsyncTx() throws Exception { IgniteBiTuple[] evts = new IgniteBiTuple[] {F.t(EVT_CACHE_OBJECT_PUT, 2 * gridCnt)}; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java index 16c1f5a8cce87..6d5ac3016c642 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java @@ -33,13 +33,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestThread; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -49,6 +50,7 @@ * Test cases for multi-threaded tests. */ @SuppressWarnings({"FieldCanBeLocal"}) +@RunWith(JUnit4.class) public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { /** Grid1. */ private static Ignite ignite1; @@ -62,8 +64,12 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { /** (for convenience). */ private static IgniteCache cache2; - /** Ip-finder. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + + super.setUp(); + } /** * @@ -76,12 +82,6 @@ protected GridCacheLockAbstractTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration()); return cfg; @@ -195,6 +195,7 @@ private boolean locked(Iterable keys, int idx) { * @throws Exception If test failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testLockSingleThread() throws Exception { int k = 1; String v = String.valueOf(k); @@ -229,7 +230,7 @@ public void testLockSingleThread() throws Exception { /** * @throws Exception If test failed. */ - @SuppressWarnings({"TooBroadScope"}) + @Test public void testLock() throws Exception { final int kv = 1; @@ -320,6 +321,7 @@ public void testLock() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testLockAndPut() throws Exception { final CountDownLatch l1 = new CountDownLatch(1); final CountDownLatch l2 = new CountDownLatch(1); @@ -405,7 +407,7 @@ public void testLockAndPut() throws Exception { /** * @throws Exception If test failed. */ - @SuppressWarnings({"TooBroadScope"}) + @Test public void testLockTimeoutTwoThreads() throws Exception { int keyCnt = 1; @@ -501,6 +503,7 @@ public void testLockTimeoutTwoThreads() throws Exception { /** * @throws Throwable If failed. */ + @Test public void testLockReentrancy() throws Throwable { Affinity aff = ignite1.affinity(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMixedModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMixedModeSelfTest.java index 3d6c08806db2b..abfff2a3392bc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMixedModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMixedModeSelfTest.java @@ -24,10 +24,16 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests cache puts in mixed mode. + * + * TODO IGNITE-10345: Remove test in ignite 3.0. */ +@RunWith(JUnit4.class) public class GridCacheMixedModeSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -63,6 +69,7 @@ private CacheConfiguration cacheConfiguration(String igniteInstanceName) { /** * @throws Exception If failed. */ + @Test public void testBasicOps() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -78,4 +85,4 @@ public void testBasicOps() throws Exception { for (int i = 0; i < 1000; i++) assertNull(cache.get(i)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeAbstractTest.java index 1d56ab6cbc00c..963ff33682c6d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeAbstractTest.java @@ -26,16 +26,16 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.Event; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; @@ -47,6 +47,7 @@ /** * Multi-node cache test. */ +@RunWith(JUnit4.class) public abstract class GridCacheMultiNodeAbstractTest extends GridCommonAbstractTest { /** Grid 1. */ private static Ignite ignite1; @@ -66,25 +67,9 @@ public abstract class GridCacheMultiNodeAbstractTest extends GridCommonAbstractT /** Cache 3. */ private static IgniteCache cache3; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Listeners. */ private static Collection lsnrs = new ArrayList<>(); - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - - return c; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { ignite1 = startGrid(1); @@ -96,6 +81,11 @@ public abstract class GridCacheMultiNodeAbstractTest extends GridCommonAbstractT cache3 = ignite3.cache(DEFAULT_CACHE_NAME); } + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + } + /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { cache1 = null; @@ -144,6 +134,7 @@ private void addListener(Ignite ignite, CacheEventListener lsnr, int... type) { /** * @throws Exception If test failed. */ + @Test public void testBasicPut() throws Exception { checkPuts(3, ignite1); } @@ -151,6 +142,7 @@ public void testBasicPut() throws Exception { /** * @throws Exception If test fails. */ + @Test public void testMultiNodePut() throws Exception { checkPuts(1, ignite1, ignite2, ignite3); checkPuts(1, ignite2, ignite1, ignite3); @@ -160,6 +152,7 @@ public void testMultiNodePut() throws Exception { /** * @throws Exception If test fails. */ + @Test public void testMultiValuePut() throws Exception { checkPuts(1, ignite1); } @@ -167,6 +160,7 @@ public void testMultiValuePut() throws Exception { /** * @throws Exception If test fails. */ + @Test public void testMultiValueMultiNodePut() throws Exception { checkPuts(3, ignite1, ignite2, ignite3); checkPuts(3, ignite2, ignite1, ignite3); @@ -181,6 +175,8 @@ public void testMultiValueMultiNodePut() throws Exception { * @throws Exception If check fails. */ private void checkPuts(int cnt, Ignite... ignites) throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + CountDownLatch latch = new CountDownLatch(ignites.length * cnt); CacheEventListener lsnr = new CacheEventListener(latch, EVT_CACHE_OBJECT_PUT); @@ -227,7 +223,10 @@ private void checkPuts(int cnt, Ignite... ignites) throws Exception { /** * @throws Exception If test failed. */ + @Test public void testLockUnlock() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + CacheEventListener lockLsnr1 = new CacheEventListener(ignite1, new CountDownLatch(1), EVT_CACHE_OBJECT_LOCKED); addListener(ignite1, lockLsnr1, EVT_CACHE_OBJECT_LOCKED); @@ -273,6 +272,7 @@ public void testLockUnlock() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testConcurrentPutAsync() throws Exception { CountDownLatch latch = new CountDownLatch(9); @@ -323,6 +323,7 @@ public void testConcurrentPutAsync() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testGlobalClearAll() throws Exception { cache1.put(1, "val1"); cache2.put(2, "val2"); @@ -410,4 +411,4 @@ void setLatch(CountDownLatch latch) { "grid", ignite != null ? ignite.name() : "N/A", "evts", evts); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java index cc3b894cb41d0..5d6987fa36384 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java @@ -34,12 +34,13 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestThread; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVTS_CACHE; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNLOCKED; @@ -47,6 +48,7 @@ /** * Test cases for multi-threaded tests. */ +@RunWith(JUnit4.class) public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstractTest { /** */ private static final String CACHE2 = "cache2"; @@ -57,12 +59,17 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr /** Grid 2. */ private static Ignite ignite2; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Listeners. */ private static Collection> lsnrs = new ArrayList<>(); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + + super.setUp(); + } + /** * */ @@ -74,12 +81,6 @@ protected GridCacheMultiNodeLockAbstractTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration ccfg1 = cacheConfiguration().setName(DEFAULT_CACHE_NAME); CacheConfiguration ccfg2 = cacheConfiguration().setName(CACHE2); @@ -225,6 +226,7 @@ private void checkUnlocked(IgniteCache cache, Iterable * * @throws Exception If test failed. */ + @Test public void testBasicLock() throws Exception { IgniteCache cache = ignite1.cache(DEFAULT_CACHE_NAME); @@ -266,6 +268,7 @@ private String entries(int key) throws IgniteCheckedException { /** * @throws Exception If test fails. */ + @Test public void testMultiNodeLock() throws Exception { IgniteCache cache1 = ignite1.cache(DEFAULT_CACHE_NAME); IgniteCache cache2 = ignite2.cache(DEFAULT_CACHE_NAME); @@ -324,6 +327,7 @@ public void testMultiNodeLock() throws Exception { /** * @throws Exception If test fails. */ + @Test public void testMultiNodeLockWithKeyLists() throws Exception { IgniteCache cache1 = ignite1.cache(DEFAULT_CACHE_NAME); IgniteCache cache2 = ignite2.cache(DEFAULT_CACHE_NAME); @@ -401,6 +405,7 @@ public void testMultiNodeLockWithKeyLists() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testLockReentry() throws IgniteCheckedException { IgniteCache cache = ignite1.cache(DEFAULT_CACHE_NAME); @@ -429,6 +434,7 @@ public void testLockReentry() throws IgniteCheckedException { /** * @throws Exception If test failed. */ + @Test public void testLockMultithreaded() throws Exception { final IgniteCache cache = ignite1.cache(DEFAULT_CACHE_NAME); @@ -547,6 +553,7 @@ public void testLockMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTwoCaches() throws Exception { IgniteCache cache1 = ignite1.cache(DEFAULT_CACHE_NAME); IgniteCache cache2 = ignite1.cache(CACHE2); @@ -616,4 +623,4 @@ private class UnlockListener implements IgnitePredicate { return true; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultithreadedFailoverAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultithreadedFailoverAbstractTest.java index 7bb0012e77862..76b9da60cc62b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultithreadedFailoverAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultithreadedFailoverAbstractTest.java @@ -55,12 +55,12 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -71,6 +71,7 @@ /** * Base test for all multithreaded cache scenarios w/ and w/o failover. */ +@RunWith(JUnit4.class) public class GridCacheMultithreadedFailoverAbstractTest extends GridCommonAbstractTest { /** Node name prefix. */ private static final String NODE_PREFIX = "node"; @@ -87,9 +88,6 @@ public class GridCacheMultithreadedFailoverAbstractTest extends GridCommonAbstra /** Proceed put condition. */ private final Condition putCond = lock.newCondition(); - /** Shared IP finder. */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Caches comparison start latch. */ private CountDownLatch cmpLatch; @@ -223,11 +221,6 @@ private IgniteConfiguration configuration(int idx) throws Exception { IgniteConfiguration cfg = getConfiguration(nodeName(idx)); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); cfg.setLocalHost("127.0.0.1"); cfg.setCacheConfiguration(ccfg); cfg.setConnectorConfiguration(null); @@ -240,6 +233,7 @@ private IgniteConfiguration configuration(int idx) throws Exception { * * @throws Exception If failed. */ + @Test public void test() throws Exception { startUp(); @@ -599,4 +593,4 @@ private boolean compareCaches(Map expVals) throws Exception { return !failed; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java index 8de2d79b097fd..ba154174a28f1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java @@ -34,13 +34,14 @@ import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteState.STOPPED; import static org.apache.ignite.IgniteSystemProperties.IGNITE_TX_SALVAGE_TIMEOUT; @@ -56,6 +57,7 @@ /** * Tests for node failure in transactions. */ +@RunWith(JUnit4.class) public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstractTest { /** Random number generator. */ private static final Random RAND = new Random(); @@ -69,12 +71,16 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac /** */ private static final String VALUE = "test"; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Grid instances. */ private static final List IGNITEs = new ArrayList<>(); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + + super.setUp(); + } + /** * Start grid by default. */ @@ -86,12 +92,6 @@ protected GridCacheNodeFailureAbstractTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - c.setDeploymentMode(DeploymentMode.SHARED); return c; @@ -137,10 +137,11 @@ protected GridCacheNodeFailureAbstractTest() { /** * @throws IgniteCheckedException If test failed. - * + * * Note: test was disabled for REPPLICATED cache case because IGNITE-601. * This comment should be removed if test passed stably. */ + @Test public void testPessimisticReadCommitted() throws Throwable { checkTransaction(PESSIMISTIC, READ_COMMITTED); } @@ -148,6 +149,7 @@ public void testPessimisticReadCommitted() throws Throwable { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticRepeatableRead() throws Throwable { checkTransaction(PESSIMISTIC, REPEATABLE_READ); } @@ -155,6 +157,7 @@ public void testPessimisticRepeatableRead() throws Throwable { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticSerializable() throws Throwable { checkTransaction(PESSIMISTIC, SERIALIZABLE); } @@ -232,10 +235,11 @@ private void checkTransaction(TransactionConcurrency concurrency, TransactionIso /** * @throws Exception If check failed. - * + * * Note: test was disabled for REPPLICATED cache case because IGNITE-601. * This comment should be removed if test passed stably. */ + @Test public void testLock() throws Exception { int idx = 0; @@ -293,4 +297,4 @@ public void testLock() throws Exception { assert !checkCache.isLocalLocked(KEY, false); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionEvictionDuringReadThroughSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionEvictionDuringReadThroughSelfTest.java index 01316f64284c9..e1e57598392d6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionEvictionDuringReadThroughSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionEvictionDuringReadThroughSelfTest.java @@ -40,10 +40,16 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) +@Ignore("https://issues.apache.org/jira/browse/IGNITE-5759") public class GridCachePartitionEvictionDuringReadThroughSelfTest extends GridCommonAbstractTest { /** Failing key. */ private static final int FAILING_KEY = 3; @@ -83,16 +89,15 @@ public class GridCachePartitionEvictionDuringReadThroughSelfTest extends GridCom /** * @throws Exception if failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-5759") + @Test public void testPartitionRent() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-5759"); - startGrid(DATA_READ_GRID_IDX); final AtomicBoolean done = new AtomicBoolean(); IgniteInternalFuture gridAndCacheAccessFut = GridTestUtils.runMultiThreadedAsync(new Callable() { - @Override - public Integer call() throws Exception { + @Override public Integer call() throws Exception { final Set keysSet = new LinkedHashSet<>(); keysSet.add(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionNotLoadedEventSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionNotLoadedEventSelfTest.java index d25304beda669..b96a964788cbe 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionNotLoadedEventSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionNotLoadedEventSelfTest.java @@ -34,13 +34,16 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.GridTestUtils.SF; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.util.TestTcpCommunicationSpi; import org.eclipse.jetty.util.ConcurrentHashSet; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -48,21 +51,22 @@ /** * */ +@RunWith(JUnit4.class) public class GridCachePartitionNotLoadedEventSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private int backupCnt; + /** {@inheritDoc} */ + @Override public void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - disco.setIpFinder(ipFinder); - cfg.setDiscoverySpi(disco); - if (igniteInstanceName.matches(".*\\d")) { String idStr = UUID.randomUUID().toString(); @@ -97,13 +101,12 @@ public class GridCachePartitionNotLoadedEventSelfTest extends GridCommonAbstract /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-5968") + @Test public void testPrimaryAndBackupDead() throws Exception { backupCnt = 1; - startGrid(0); - startGrid(1); - startGrid(2); - startGrid(3); + startGridsMultiThreaded(4); awaitPartitionMapExchange(); @@ -140,22 +143,25 @@ public void testPrimaryAndBackupDead() throws Exception { assert !cache.containsKey(key); - GridTestUtils.waitForCondition(new GridAbsPredicate() { + final long awaitingTimeoutMs = SF.apply(5 * 60 * 1000); + + assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return !lsnr1.lostParts.isEmpty(); } - }, getTestTimeout()); + }, awaitingTimeoutMs)); - GridTestUtils.waitForCondition(new GridAbsPredicate() { + assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return !lsnr2.lostParts.isEmpty(); } - }, getTestTimeout()); + }, awaitingTimeoutMs)); } /** * @throws Exception If failed. */ + @Test public void testPrimaryDead() throws Exception { startGrid(0); startGrid(1); @@ -190,6 +196,7 @@ public void testPrimaryDead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStableTopology() throws Exception { backupCnt = 1; @@ -226,6 +233,7 @@ public void testStableTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMapPartitioned() throws Exception { backupCnt = 0; diff --git a/modules/web-console/frontend/app/modules/branding/header-logo.directive.js b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedNearDisabledMvccTxMultiThreadedSelfTest.java similarity index 66% rename from modules/web-console/frontend/app/modules/branding/header-logo.directive.js rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedNearDisabledMvccTxMultiThreadedSelfTest.java index 60e5d5d68aec0..cf8115c52213f 100644 --- a/modules/web-console/frontend/app/modules/branding/header-logo.directive.js +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedNearDisabledMvccTxMultiThreadedSelfTest.java @@ -15,25 +15,17 @@ * limitations under the License. */ -import template from './header-logo.pug'; +package org.apache.ignite.internal.processors.cache.distributed; + +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMvccTxMultiThreadedSelfTest; /** - * @param {import('./branding.service').default} branding + * */ -export default function factory(branding) { - function controller() { - const ctrl = this; - - ctrl.url = branding.headerLogo; +public class GridCachePartitionedNearDisabledMvccTxMultiThreadedSelfTest + extends GridCachePartitionedMvccTxMultiThreadedSelfTest { + /** {@inheritDoc} */ + @Override protected boolean nearEnabled() { + return false; } - - return { - restrict: 'E', - template, - controller, - controllerAs: 'logo', - replace: true - }; } - -factory.$inject = ['IgniteBranding']; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java index d7186443ca39d..52a27c0de6654 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java @@ -36,10 +36,10 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -47,6 +47,7 @@ /** * Check reloadAll() on partitioned cache. */ +@RunWith(JUnit4.class) public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends GridCommonAbstractTest { /** Amount of nodes in the grid. */ private static final int GRID_CNT = 4; @@ -54,9 +55,6 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends Grid /** Amount of backups in partitioned cache. */ private static final int BACKUP_CNT = 1; - /** IP finder. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Map where dummy cache store values are stored. */ private final Map map = new ConcurrentHashMap<>(); @@ -68,12 +66,6 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends Grid @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); if (!nearEnabled()) @@ -175,6 +167,7 @@ protected CacheAtomicityMode atomicityMode() { /** * @throws Exception If test failed. */ + @Test public void testReloadAll() throws Exception { // Fill caches with values. for (IgniteCache cache : caches) { @@ -203,4 +196,4 @@ public void testReloadAll() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadEventsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadEventsAbstractSelfTest.java index 59af680c80002..80b906ccb081a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadEventsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePreloadEventsAbstractSelfTest.java @@ -28,11 +28,12 @@ import org.apache.ignite.events.Event; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -42,18 +43,17 @@ /** * */ +@RunWith(JUnit4.class) public abstract class GridCachePreloadEventsAbstractSelfTest extends GridCommonAbstractTest { - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + } /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - disco.setIpFinder(ipFinder); - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration()); MemoryEventStorageSpi evtStorageSpi = new MemoryEventStorageSpi(); @@ -95,6 +95,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception if failed. */ + @Test public void testPreloadEvents() throws Exception { Ignite g1 = startGrid("g1"); @@ -130,4 +131,4 @@ protected void checkPreloadEvents(Collection evts, Ignite g, Collection c, int key, int at error("Attempt: " + attempt); error("Node: " + c.unwrap(Ignite.class).cluster().localNode().id()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java index 6f27ce728da73..e7810cf411102 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java @@ -36,19 +36,20 @@ import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.events.CacheEvent; import org.apache.ignite.events.Event; +import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; -import org.eclipse.jetty.util.ConcurrentHashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -64,6 +65,7 @@ * Test for TRANSFORM events recording. */ @SuppressWarnings("ConstantConditions") +@RunWith(JUnit4.class) public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest { /** Nodes count. */ private static final int GRID_CNT = 3; @@ -83,9 +85,6 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest { /** Two keys in form of a set. */ private Set keys; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Nodes. */ private Ignite[] ignites; @@ -96,7 +95,7 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest { private IgniteCache[] caches; /** Recorded events. */ - private ConcurrentHashSet evts; + private GridConcurrentHashSet evts; /** Cache mode. */ private CacheMode cacheMode; @@ -114,10 +113,6 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - TransactionConfiguration tCfg = cfg.getTransactionConfiguration(); tCfg.setDefaultTxConcurrency(txConcurrency); @@ -134,7 +129,6 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest { if (cacheMode == PARTITIONED) ccfg.setBackups(BACKUP_CNT); - cfg.setDiscoverySpi(discoSpi); cfg.setCacheConfiguration(ccfg); cfg.setLocalHost("127.0.0.1"); cfg.setIncludeEventTypes(EVT_CACHE_OBJECT_READ); @@ -174,7 +168,7 @@ private void initialize(CacheMode cacheMode, CacheAtomicityMode atomicityMode, this.txConcurrency = txConcurrency; this.txIsolation = txIsolation; - evts = new ConcurrentHashSet<>(); + evts = new GridConcurrentHashSet<>(); startGridsMultiThreaded(GRID_CNT, true); @@ -278,6 +272,7 @@ private boolean backup(int gridIdx, Object key) { * * @throws Exception If failed. */ + @Test public void testTxLocalOptimisticRepeatableRead() throws Exception { checkTx(LOCAL, OPTIMISTIC, REPEATABLE_READ); } @@ -287,6 +282,7 @@ public void testTxLocalOptimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxLocalOptimisticReadCommitted() throws Exception { checkTx(LOCAL, OPTIMISTIC, READ_COMMITTED); } @@ -296,6 +292,7 @@ public void testTxLocalOptimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxLocalOptimisticSerializable() throws Exception { checkTx(LOCAL, OPTIMISTIC, SERIALIZABLE); } @@ -305,6 +302,7 @@ public void testTxLocalOptimisticSerializable() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxLocalPessimisticRepeatableRead() throws Exception { checkTx(LOCAL, PESSIMISTIC, REPEATABLE_READ); } @@ -314,6 +312,7 @@ public void testTxLocalPessimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxLocalPessimisticReadCommitted() throws Exception { checkTx(LOCAL, PESSIMISTIC, READ_COMMITTED); } @@ -323,15 +322,29 @@ public void testTxLocalPessimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxLocalPessimisticSerializable() throws Exception { checkTx(LOCAL, PESSIMISTIC, SERIALIZABLE); } + /** + * Test TRANSACTIONAL_SNAPSHOT LOCAL cache with PESSIMISTIC/REPEATABLE_READ transaction. + * + * @throws Exception If failed. + */ + @Test + public void testMvccTxLocalPessimisticRepeatableRead() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + checkMvccTx(LOCAL, PESSIMISTIC, REPEATABLE_READ); + } + /** * Test TRANSACTIONAL PARTITIONED cache with OPTIMISTIC/REPEATABLE_READ transaction. * * @throws Exception If failed. */ + @Test public void testTxPartitionedOptimisticRepeatableRead() throws Exception { checkTx(PARTITIONED, OPTIMISTIC, REPEATABLE_READ); } @@ -341,6 +354,7 @@ public void testTxPartitionedOptimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxPartitionedOptimisticReadCommitted() throws Exception { checkTx(PARTITIONED, OPTIMISTIC, READ_COMMITTED); } @@ -350,6 +364,7 @@ public void testTxPartitionedOptimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxPartitionedOptimisticSerializable() throws Exception { checkTx(PARTITIONED, OPTIMISTIC, SERIALIZABLE); } @@ -359,6 +374,7 @@ public void testTxPartitionedOptimisticSerializable() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxPartitionedPessimisticRepeatableRead() throws Exception { checkTx(PARTITIONED, PESSIMISTIC, REPEATABLE_READ); } @@ -368,6 +384,7 @@ public void testTxPartitionedPessimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxPartitionedPessimisticReadCommitted() throws Exception { checkTx(PARTITIONED, PESSIMISTIC, READ_COMMITTED); } @@ -377,15 +394,30 @@ public void testTxPartitionedPessimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxPartitionedPessimisticSerializable() throws Exception { checkTx(PARTITIONED, PESSIMISTIC, SERIALIZABLE); } + /** + * Test TRANSACTIONAL_SNAPSHOT PARTITIONED cache with PESSIMISTIC/REPEATABLE_READ transaction. + * + * @throws Exception If failed. + */ + @Test + public void testMvccTxPartitionedPessimisticRepeatableRead() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9321"); + + checkMvccTx(PARTITIONED, PESSIMISTIC, REPEATABLE_READ); + } + + /** * Test TRANSACTIONAL REPLICATED cache with OPTIMISTIC/REPEATABLE_READ transaction. * * @throws Exception If failed. */ + @Test public void testTxReplicatedOptimisticRepeatableRead() throws Exception { checkTx(REPLICATED, OPTIMISTIC, REPEATABLE_READ); } @@ -395,6 +427,7 @@ public void testTxReplicatedOptimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxReplicatedOptimisticReadCommitted() throws Exception { checkTx(REPLICATED, OPTIMISTIC, READ_COMMITTED); } @@ -404,6 +437,7 @@ public void testTxReplicatedOptimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxReplicatedOptimisticSerializable() throws Exception { checkTx(REPLICATED, OPTIMISTIC, SERIALIZABLE); } @@ -413,6 +447,7 @@ public void testTxReplicatedOptimisticSerializable() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxReplicatedPessimisticRepeatableRead() throws Exception { checkTx(REPLICATED, PESSIMISTIC, REPEATABLE_READ); } @@ -422,6 +457,7 @@ public void testTxReplicatedPessimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxReplicatedPessimisticReadCommitted() throws Exception { checkTx(REPLICATED, PESSIMISTIC, READ_COMMITTED); } @@ -431,15 +467,29 @@ public void testTxReplicatedPessimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxReplicatedPessimisticSerializable() throws Exception { checkTx(REPLICATED, PESSIMISTIC, SERIALIZABLE); } + /** + * Test TRANSACTIONAL_SNAPSHOT REPLICATED cache with PESSIMISTIC/REPEATABLE_READ transaction. + * + * @throws Exception If failed. + */ + @Test + public void testMvccTxReplicatedPessimisticRepeatableRead() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9321"); + + checkMvccTx(REPLICATED, PESSIMISTIC, REPEATABLE_READ); + } + /** * Test ATOMIC LOCAL cache. * * @throws Exception If failed. */ + @Test public void testAtomicLocal() throws Exception { checkAtomic(LOCAL); } @@ -449,6 +499,7 @@ public void testAtomicLocal() throws Exception { * * @throws Exception If failed. */ + @Test public void testAtomicPartitioned() throws Exception { checkAtomic(PARTITIONED); } @@ -458,6 +509,7 @@ public void testAtomicPartitioned() throws Exception { * * @throws Exception If failed. */ + @Test public void testAtomicReplicated() throws Exception { checkAtomic(REPLICATED); } @@ -494,6 +546,21 @@ private void checkAtomic(CacheMode cacheMode) throws Exception { checkEventNodeIdsStrict(TransformerWithInjection.class.getName(), primaryIdsForKeys(key1, key2)); } + /** + * Check TRANSACTIONAL_SNAPSHOT cache. + * + * @param cacheMode Cache mode. + * @param txConcurrency TX concurrency. + * @param txIsolation TX isolation. + * @throws Exception If failed. + */ + private void checkMvccTx(CacheMode cacheMode, TransactionConcurrency txConcurrency, + TransactionIsolation txIsolation) throws Exception { + initialize(cacheMode, TRANSACTIONAL_SNAPSHOT, txConcurrency, txIsolation); + + checkTx0(); + } + /** * Check TRANSACTIONAL cache. * @@ -506,6 +573,14 @@ private void checkTx(CacheMode cacheMode, TransactionConcurrency txConcurrency, TransactionIsolation txIsolation) throws Exception { initialize(cacheMode, TRANSACTIONAL, txConcurrency, txIsolation); + checkTx0(); + } + + /** + * Check TX cache. + */ + private void checkTx0() { + System.out.println("BEFORE: " + evts.size()); caches[0].invoke(key1, new Transformer()); @@ -564,7 +639,6 @@ private UUID[] primaryIdsForKeys(int... keys) { * @param keys Keys. * @return Node IDs. */ - @SuppressWarnings("UnusedDeclaration") private UUID[] idsForKeys(boolean primaryOnly, int... keys) { List res = new ArrayList<>(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateChangingTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateChangingTopologySelfTest.java index edfeb967d70e1..c17ce417561dc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateChangingTopologySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateChangingTopologySelfTest.java @@ -46,20 +46,18 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests specific scenario when binary metadata should be updated from a system thread * and topology has been already changed since the original transaction start. */ +@RunWith(JUnit4.class) public class IgniteBinaryMetadataUpdateChangingTopologySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -73,12 +71,6 @@ public class IgniteBinaryMetadataUpdateChangingTopologySelfTest extends GridComm cfg.setCacheConfiguration(ccfg); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCommunicationSpi(new TestCommunicationSpi()); return cfg; @@ -92,6 +84,7 @@ public class IgniteBinaryMetadataUpdateChangingTopologySelfTest extends GridComm /** * @throws Exception If failed. */ + @Test public void testNoDeadlockOptimistic() throws Exception { int key1 = primaryKey(ignite(1).cache("cache")); int key2 = primaryKey(ignite(2).cache("cache")); @@ -131,6 +124,7 @@ public void testNoDeadlockOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoDeadlockInvoke() throws Exception { int key1 = primaryKey(ignite(1).cache("cache")); int key2 = primaryKey(ignite(2).cache("cache")); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateNodeRestartTest.java index b95ad4ad5b8ba..fcd8615e08626 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateNodeRestartTest.java @@ -36,11 +36,11 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -50,10 +50,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteBinaryMetadataUpdateNodeRestartTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String ATOMIC_CACHE = "atomicCache"; @@ -73,15 +71,13 @@ public class IgniteBinaryMetadataUpdateNodeRestartTest extends GridCommonAbstrac @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); cfg.setMarshaller(null); CacheConfiguration ccfg1 = cacheConfiguration(TX_CACHE, TRANSACTIONAL); CacheConfiguration ccfg2 = cacheConfiguration(ATOMIC_CACHE, ATOMIC); - + cfg.setCacheConfiguration(ccfg1, ccfg2); cfg.setClientMode(client); @@ -121,6 +117,7 @@ private CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode at /** * @throws Exception If failed. */ + @Test public void testNodeRestart() throws Exception { for (int i = 0; i < 10; i++) { log.info("Iteration: " + i); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java index b7ae84400c2fe..301f5bd55b992 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java @@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ClientConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; @@ -32,25 +33,25 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; /** * */ +@RunWith(JUnit4.class) public class IgniteCache150ClientsTest extends GridCommonAbstractTest { /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + private static final int CACHES = 10; /** */ - private static final int CACHES = 10; + private static final int CLIENTS = 150; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -66,7 +67,6 @@ public class IgniteCache150ClientsTest extends GridCommonAbstractTest { ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setLocalPortRange(200); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setJoinTimeout(0); cfg.setClientFailureDetectionTimeout(200000); @@ -80,7 +80,7 @@ public class IgniteCache150ClientsTest extends GridCommonAbstractTest { CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(PARTITIONED); - ccfg.setAtomicityMode(i % 2 == 0 ? ATOMIC : TRANSACTIONAL); + ccfg.setAtomicityMode(CacheAtomicityMode.values()[i % 3]); ccfg.setWriteSynchronizationMode(PRIMARY_SYNC); ccfg.setBackups(1); @@ -109,13 +109,12 @@ public class IgniteCache150ClientsTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void test150Clients() throws Exception { Ignite srv = startGrid(0); assertFalse(srv.configuration().isClientMode()); - final int CLIENTS = 150; - final AtomicInteger idx = new AtomicInteger(1); final CountDownLatch latch = new CountDownLatch(CLIENTS); @@ -196,4 +195,4 @@ private void checkNodes(int expCnt) { ignite.cluster().nodes().size()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java index 6b62912e22eb9..cf171393a37d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheAtomicNodeRestartTest.java @@ -19,20 +19,18 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedNodeRestartTest; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheAtomicNodeRestartTest extends GridCachePartitionedNodeRestartTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return ATOMIC; } - - /** {@inheritDoc} */ - @Override public void testRestartWithPutFourNodesNoBackups() { - fail("https://issues.apache.org/jira/browse/IGNITE-1587"); - } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java index 7711bbbaa927e..3ced0500f9d18 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java @@ -32,12 +32,12 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; @@ -48,10 +48,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheClientMultiNodeUpdateTopologyLockTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String TEST_CACHE = "testCache"; @@ -64,8 +62,6 @@ public class IgniteCacheClientMultiNodeUpdateTopologyLockTest extends GridCommon cfg.setConsistentId(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi(); cfg.setCommunicationSpi(commSpi); @@ -78,6 +74,7 @@ public class IgniteCacheClientMultiNodeUpdateTopologyLockTest extends GridCommon /** * @throws Exception If failed. */ + @Test public void testPessimisticTx() throws Exception { startGrids(3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java index 300ecb938f42f..a35833c7dfe16 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java @@ -82,15 +82,17 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.eclipse.jetty.util.ConcurrentHashSet; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -105,10 +107,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private CacheConfiguration ccfg; @@ -124,7 +124,7 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac cfg.setConsistentId(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder).setForceServerMode(true); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); cfg.setClientMode(client); @@ -139,6 +139,11 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac return cfg; } + /** {@inheritDoc} */ + @Override public void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); @@ -149,6 +154,7 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testAtomicPutAllPrimaryMode() throws Exception { atomicPut(true, null); } @@ -156,6 +162,7 @@ public void testAtomicPutAllPrimaryMode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicPutAllNearEnabledPrimaryMode() throws Exception { atomicPut(true, new NearCacheConfiguration()); } @@ -163,6 +170,7 @@ public void testAtomicPutAllNearEnabledPrimaryMode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicPutPrimaryMode() throws Exception { atomicPut(false, null); } @@ -288,6 +296,7 @@ private void atomicPut(final boolean putAll, /** * @throws Exception If failed. */ + @Test public void testAtomicNoRemapPrimaryMode() throws Exception { atomicNoRemap(); } @@ -375,6 +384,7 @@ private void atomicNoRemap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicGetAndPutPrimaryMode() throws Exception { atomicGetAndPut(); } @@ -442,6 +452,7 @@ private void atomicGetAndPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxPutAll() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -509,6 +520,7 @@ public void testTxPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTx() throws Exception { pessimisticTx(null); } @@ -516,6 +528,7 @@ public void testPessimisticTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxNearEnabled() throws Exception { pessimisticTx(new NearCacheConfiguration()); } @@ -734,6 +747,7 @@ private Integer findKey(Affinity aff, int part) { * * @throws Exception If failed. */ + @Test public void testPessimisticTx2() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -827,6 +841,7 @@ public void testPessimisticTx2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxNearEnabledNoRemap() throws Exception { pessimisticTxNoRemap(new NearCacheConfiguration()); } @@ -834,6 +849,7 @@ public void testPessimisticTxNearEnabledNoRemap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxNoRemap() throws Exception { pessimisticTxNoRemap(null); } @@ -948,6 +964,7 @@ private CacheConfiguration testPessimisticTx3Cfg() { /** * @throws Exception If failed. */ + @Test public void testPessimisticTx3() throws Exception { for (int iter = 0; iter < 5; iter++) { info("Iteration: " + iter); @@ -1013,6 +1030,7 @@ public void testPessimisticTx3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableTx() throws Exception { optimisticSerializableTx(null); } @@ -1020,6 +1038,7 @@ public void testOptimisticSerializableTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableTxNearEnabled() throws Exception { optimisticSerializableTx(new NearCacheConfiguration()); } @@ -1165,6 +1184,7 @@ private void optimisticSerializableTx(NearCacheConfiguration nearCfg) throws Exc /** * @throws Exception If failed. */ + @Test public void testLock() throws Exception { lock(null); } @@ -1172,6 +1192,7 @@ public void testLock() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockNearEnabled() throws Exception { lock(new NearCacheConfiguration()); } @@ -1302,6 +1323,7 @@ private boolean unlocked(Ignite ignite) { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxMessageClientFirstFlag() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -1402,6 +1424,7 @@ private void checkClientLockMessages(List msgs, int expCnt) { /** * @throws Exception If failed. */ + @Test public void testOptimisticTxMessageClientFirstFlag() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -1497,6 +1520,7 @@ private void checkClientPrepareMessages(List msgs, int expCnt) { /** * @throws Exception If failed. */ + @Test public void testLockRemoveAfterClientFailed() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -1555,6 +1579,7 @@ public void testLockRemoveAfterClientFailed() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockFromClientBlocksExchange() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -1703,7 +1728,7 @@ private void checkData(final Map map, } } finally { - entry.touch(entry.context().affinity().affinityTopologyVersion()); + entry.touch(); } } else @@ -1730,6 +1755,7 @@ private void checkData(final Map map, /** * @throws Exception If failed. */ + @Test public void testAtomicPrimaryPutAllMultinode() throws Exception { multinode(ATOMIC, TestType.PUT_ALL); } @@ -1737,6 +1763,7 @@ public void testAtomicPrimaryPutAllMultinode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticTxPutAllMultinode() throws Exception { multinode(TRANSACTIONAL, TestType.OPTIMISTIC_TX); } @@ -1744,6 +1771,7 @@ public void testOptimisticTxPutAllMultinode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializableTxPutAllMultinode() throws Exception { multinode(TRANSACTIONAL, TestType.OPTIMISTIC_SERIALIZABLE_TX); } @@ -1751,6 +1779,7 @@ public void testOptimisticSerializableTxPutAllMultinode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxPutAllMultinode() throws Exception { multinode(TRANSACTIONAL, TestType.PESSIMISTIC_TX); } @@ -1758,6 +1787,7 @@ public void testPessimisticTxPutAllMultinode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockAllMultinode() throws Exception { multinode(TRANSACTIONAL, TestType.LOCK); } @@ -1993,6 +2023,7 @@ private void multinode(CacheAtomicityMode atomicityMode, final TestType testType /** * @throws Exception If failed. */ + @Test public void testServersLeaveOnStart() throws Exception { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeConcurrentStart.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeConcurrentStart.java index cdb69133ed262..d92351bdd5f49 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeConcurrentStart.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeConcurrentStart.java @@ -23,20 +23,18 @@ import org.apache.ignite.Ignite; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheClientNodeConcurrentStart extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES_CNT = 6; @@ -49,8 +47,6 @@ public class IgniteCacheClientNodeConcurrentStart extends GridCommonAbstractTest assertNotNull(clientNodes); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - boolean client = false; for (Integer clientIdx : clientNodes) { @@ -76,6 +72,7 @@ public class IgniteCacheClientNodeConcurrentStart extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testConcurrentStart() throws Exception { ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -111,4 +108,4 @@ public void testConcurrentStart() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodePartitionsExchangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodePartitionsExchangeTest.java index 510140299931c..8f399c101821a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodePartitionsExchangeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodePartitionsExchangeTest.java @@ -53,20 +53,19 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.ExchangeContext.IGNITE_EXCHANGE_COMPATIBILITY_VER_1; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheClientNodePartitionsExchangeTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -74,7 +73,7 @@ public class IgniteCacheClientNodePartitionsExchangeTest extends GridCommonAbstr @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder).setForceServerMode(true); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); cfg.setClientMode(client); @@ -97,6 +96,7 @@ public class IgniteCacheClientNodePartitionsExchangeTest extends GridCommonAbstr /** * @throws Exception If failed. */ + @Test public void testServerNodeLeave() throws Exception { Ignite ignite0 = startGrid(0); @@ -146,6 +146,7 @@ public void testServerNodeLeave() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSkipPreload() throws Exception { Ignite ignite0 = startGrid(0); @@ -198,6 +199,7 @@ public void testSkipPreload() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionsExchange() throws Exception { partitionsExchange(false); } @@ -205,6 +207,7 @@ public void testPartitionsExchange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionsExchangeCompatibilityMode() throws Exception { System.setProperty(IGNITE_EXCHANGE_COMPATIBILITY_VER_1, "true"); @@ -474,6 +477,7 @@ private void waitForTopologyUpdate(int expNodes, final AffinityTopologyVersion t /** * @throws Exception If failed. */ + @Test public void testClientOnlyCacheStart() throws Exception { clientOnlyCacheStart(false, false); } @@ -481,6 +485,7 @@ public void testClientOnlyCacheStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearOnlyCacheStart() throws Exception { clientOnlyCacheStart(true, false); } @@ -488,6 +493,7 @@ public void testNearOnlyCacheStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientOnlyCacheStartFromServerNode() throws Exception { clientOnlyCacheStart(false, true); } @@ -495,6 +501,7 @@ public void testClientOnlyCacheStartFromServerNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearOnlyCacheStartFromServerNode() throws Exception { clientOnlyCacheStart(true, true); } @@ -691,4 +698,4 @@ int partitionsFullMessages() { } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java index a0796a3e22ec7..7ebd602250bc1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java @@ -36,10 +36,11 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -49,10 +50,8 @@ /** * Test for customer scenario. */ +@RunWith(JUnit4.class) public class IgniteCacheClientReconnectTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRV_CNT = 3; @@ -80,8 +79,6 @@ public class IgniteCacheClientReconnectTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (!client) { CacheConfiguration[] ccfgs = new CacheConfiguration[CACHES]; @@ -129,6 +126,7 @@ public class IgniteCacheClientReconnectTest extends GridCommonAbstractTest { * * @throws Exception If failed */ + @Test public void testClientReconnectOnExchangeHistoryExhaustion() throws Exception { System.setProperty(IgniteSystemProperties.IGNITE_EXCHANGE_HISTORY_SIZE, "1"); @@ -161,6 +159,7 @@ public void testClientReconnectOnExchangeHistoryExhaustion() throws Exception { * * @throws Exception If failed */ + @Test public void testClientInForceServerModeStopsOnExchangeHistoryExhaustion() throws Exception { System.setProperty(IgniteSystemProperties.IGNITE_EXCHANGE_HISTORY_SIZE, "1"); @@ -268,6 +267,7 @@ private void verifyAffinityTopologyVersions() { /** * @throws Exception If failed. */ + @Test public void testClientReconnect() throws Exception { startGrids(SRV_CNT); @@ -342,4 +342,4 @@ private void putGet(Ignite ignite) { assertEquals(key, cache.get(key)); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java index 5241c37f680c8..0edef90a15fa1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java @@ -35,25 +35,25 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -67,15 +67,14 @@ public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); cfg.setClientMode(client); cfg.setCacheConfiguration( cacheConfiguration("cache1", TRANSACTIONAL), - cacheConfiguration("cache2", ATOMIC)); + cacheConfiguration("cache2", TRANSACTIONAL_SNAPSHOT), + cacheConfiguration("cache3", ATOMIC)); return cfg; } @@ -94,6 +93,8 @@ public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test + @SuppressWarnings("unchecked") public void testConnectionRecovery() throws Exception { final Map data = new TreeMap<>(); @@ -115,16 +116,27 @@ public void testConnectionRecovery() throws Exception { Thread.currentThread().setName("test-thread-" + idx0 + "-" + node.name()); - IgniteCache cache1 = node.cache("cache1"); - IgniteCache cache2 = node.cache("cache2"); + IgniteCache[] caches = { + node.cache("cache1"), + node.cache("cache2"), + node.cache("cache3")}; int iter = 0; while (U.currentTimeMillis() < stopTime) { try { - cache1.putAllAsync(data).get(15, SECONDS); - - cache2.putAllAsync(data).get(15, SECONDS); + for (IgniteCache cache : caches) { + while (true) { + try { + cache.putAllAsync(data).get(15, SECONDS); + + break; + } + catch (Exception e) { + MvccFeatureChecker.assertMvccWriteConflict(e); + } + } + } CyclicBarrier b = barrierRef.get(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutMultiNodeSelfTest.java index 23fc941472bc1..e26a18582d1fc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutMultiNodeSelfTest.java @@ -30,31 +30,25 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheCreatePutMultiNodeSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 4; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - cfg.setMarshaller(new BinaryMarshaller()); return cfg; @@ -68,6 +62,7 @@ public class IgniteCacheCreatePutMultiNodeSelfTest extends GridCommonAbstractTes /** * @throws Exception If failed. */ + @Test public void testStartNodes() throws Exception { try { Collection> futs = new ArrayList<>(GRID_CNT); @@ -94,8 +89,18 @@ public void testStartNodes() throws Exception { IgniteCache cache = getCache(ignite, cacheName); - for (int i = 0; i < 100; i++) - cache.getAndPut(i, i); + for (int i = 0; i < 100; i++) { + while (true) { + try { + cache.getAndPut(i, i); + + break; + } + catch (Exception e) { + MvccFeatureChecker.assertMvccWriteConflict(e); + } + } + } barrier.await(); @@ -139,10 +144,10 @@ private IgniteCache getCache(Ignite grid, String cacheName) { CacheConfiguration ccfg = new CacheConfiguration<>(cacheName); ccfg.setCacheMode(CacheMode.PARTITIONED); - ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); ccfg.setBackups(1); ccfg.setNearConfiguration(null); return grid.getOrCreateCache(ccfg); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutTest.java index 646084c869a32..8173456dd5660 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheCreatePutTest.java @@ -29,28 +29,28 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; +import static org.apache.ignite.testframework.MvccFeatureChecker.assertMvccWriteConflict; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheCreatePutTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 3; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -62,11 +62,6 @@ public class IgniteCacheCreatePutTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - cfg.setMarshaller(new BinaryMarshaller()); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -98,6 +93,7 @@ public class IgniteCacheCreatePutTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStartNodes() throws Exception { long stopTime = System.currentTimeMillis() + 2 * 60_000; @@ -140,6 +136,7 @@ public void testStartNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdatesAndCacheStart() throws Exception { final int NODES = 4; @@ -149,6 +146,7 @@ public void testUpdatesAndCacheStart() throws Exception { ignite0.createCache(cacheConfiguration("atomic-cache", ATOMIC)); ignite0.createCache(cacheConfiguration("tx-cache", TRANSACTIONAL)); + ignite0.createCache(cacheConfiguration("mvcc-tx-cache", TRANSACTIONAL_SNAPSHOT)); final long stopTime = System.currentTimeMillis() + 60_000; @@ -162,6 +160,7 @@ public void testUpdatesAndCacheStart() throws Exception { IgniteCache cache1 = node.cache("atomic-cache"); IgniteCache cache2 = node.cache("tx-cache"); + IgniteCache cache3 = node.cache("mvcc-tx-cache"); ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -174,6 +173,13 @@ public void testUpdatesAndCacheStart() throws Exception { cache2.put(key, key); + try { + cache3.put(key, key); + } + catch (Exception e) { + assertMvccWriteConflict(e); // Do not retry. + } + if (iter++ % 1000 == 0) log.info("Update iteration: " + iter); } @@ -246,4 +252,4 @@ private CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode at return ccfg; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheFailedUpdateResponseTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheFailedUpdateResponseTest.java index ebcff7c43898e..57b1c8c3acc4e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheFailedUpdateResponseTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheFailedUpdateResponseTest.java @@ -38,11 +38,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -51,8 +56,9 @@ import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE; /** - * Checks that no future hangs on non-srializable exceptions and values. + * Checks that no future hangs on non-serializable exceptions and values. */ +@RunWith(JUnit4.class) public class IgniteCacheFailedUpdateResponseTest extends GridCommonAbstractTest { /** Atomic cache. */ private static final String ATOMIC_CACHE = "atomic"; @@ -60,25 +66,34 @@ public class IgniteCacheFailedUpdateResponseTest extends GridCommonAbstractTest /** Tx cache. */ private static final String TX_CACHE = "tx"; + /** Mvcc tx cache. */ + private static final String MVCC_TX_CACHE = "mvcc-tx"; + /** Atomic cache. */ private IgniteCache atomicCache; /** Tx cache. */ private IgniteCache txCache; + /** Mvcc tx cache. */ + private IgniteCache mvccTxCache; + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration atomicCfg = new CacheConfiguration(ATOMIC_CACHE); CacheConfiguration txCfg = new CacheConfiguration(TX_CACHE); + CacheConfiguration mvccTxCfg = new CacheConfiguration(MVCC_TX_CACHE); atomicCfg.setBackups(1); txCfg.setBackups(1); + mvccTxCfg.setBackups(1); txCfg.setAtomicityMode(TRANSACTIONAL); + mvccTxCfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); - cfg.setCacheConfiguration(atomicCfg, txCfg); + cfg.setCacheConfiguration(atomicCfg, txCfg, mvccTxCfg); cfg.setClientMode(igniteInstanceName.contains("client")); @@ -98,11 +113,13 @@ public class IgniteCacheFailedUpdateResponseTest extends GridCommonAbstractTest @Override protected void beforeTest() throws Exception { atomicCache = grid("client").cache(ATOMIC_CACHE); txCache = grid("client").cache(TX_CACHE); + mvccTxCache = grid("client").cache(MVCC_TX_CACHE); } /** * @throws Exception If failed. */ + @Test public void testInvokeAtomic() throws Exception { testInvoke(atomicCache); testInvokeAll(atomicCache); @@ -111,6 +128,7 @@ public void testInvokeAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeTx() throws Exception { testInvoke(txCache); testInvokeAll(txCache); @@ -134,11 +152,33 @@ public void testInvokeTx() throws Exception { doInTransaction(client, OPTIMISTIC, SERIALIZABLE, clos); } + /** + * @throws Exception If failed. + */ + @Test + public void testInvokeMvccTx() throws Exception { + testInvoke(mvccTxCache); + testInvokeAll(mvccTxCache); + + IgniteEx client = grid("client"); + + Callable clos = new Callable() { + @Override public Object call() throws Exception { + testInvoke(mvccTxCache); + testInvokeAll(mvccTxCache); + + return null; + } + }; + + doInTransaction(client, PESSIMISTIC, REPEATABLE_READ, clos); + } + /** * @param cache Cache. */ private void testInvoke(final IgniteCache cache) throws Exception { - Class exp = grid("client").transactions().tx() == null + Class exp = grid("client").transactions().tx() == null || ((IgniteCacheProxy)cache).context().mvccEnabled() ? EntryProcessorException.class : NonSerializableException.class; @@ -174,7 +214,7 @@ private void testInvokeAll(final IgniteCache cache) throws Excep assertNotNull(epRes); // In transactions EP will be invoked locally. - Class exp = grid("client").transactions().tx() == null + Class exp = grid("client").transactions().tx() == null || ((IgniteCacheProxy)cache).context().mvccEnabled() ? EntryProcessorException.class : NonSerializableException.class; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java index e194e2820bbac..94814605c5049 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java @@ -35,11 +35,11 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -49,10 +49,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheGetRestartTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final long TEST_TIME = 60_000; @@ -72,8 +70,6 @@ public class IgniteCacheGetRestartTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); Boolean clientMode = client.get(); @@ -119,6 +115,7 @@ public class IgniteCacheGetRestartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testGetRestartReplicated() throws Exception { CacheConfiguration cache = cacheConfiguration(REPLICATED, 0, false); @@ -128,6 +125,7 @@ public void testGetRestartReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetRestartPartitioned1() throws Exception { CacheConfiguration cache = cacheConfiguration(PARTITIONED, 1, false); @@ -137,6 +135,7 @@ public void testGetRestartPartitioned1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetRestartPartitioned2() throws Exception { CacheConfiguration cache = cacheConfiguration(PARTITIONED, 2, false); @@ -146,6 +145,7 @@ public void testGetRestartPartitioned2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetRestartPartitionedNearEnabled() throws Exception { CacheConfiguration cache = cacheConfiguration(PARTITIONED, 1, true); @@ -209,25 +209,28 @@ private void checkRestart(final CacheConfiguration ccfg, final int restartCnt) t log.info("Restart node [node=" + nodeIdx + ", client=" + clientMode + ']'); - Ignite ignite = startGrid(nodeIdx); + try { + Ignite ignite = startGrid(nodeIdx); - IgniteCache cache; + IgniteCache cache; - if (clientMode && ccfg.getNearConfiguration() != null) - cache = ignite.createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); - else - cache = ignite.cache(ccfg.getName()); - - checkGet(cache); + if (clientMode && ccfg.getNearConfiguration() != null) + cache = ignite.createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); + else + cache = ignite.cache(ccfg.getName()); - IgniteInternalFuture syncFut = ((IgniteCacheProxy)cache).context().preloader().syncFuture(); - - while (!syncFut.isDone() && U.currentTimeMillis() < stopTime) checkGet(cache); - checkGet(cache); + IgniteInternalFuture syncFut = ((IgniteCacheProxy)cache).context().preloader().syncFuture(); - stopGrid(nodeIdx); + while (!syncFut.isDone() && U.currentTimeMillis() < stopTime) + checkGet(cache); + + checkGet(cache); + } + finally { + stopGrid(nodeIdx); + } } return null; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGroupsPartitionLossPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGroupsPartitionLossPolicySelfTest.java index 186255318dc49..f0e2c416cae3a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGroupsPartitionLossPolicySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGroupsPartitionLossPolicySelfTest.java @@ -37,10 +37,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.P1; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -48,10 +48,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheGroupsPartitionLossPolicySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -72,8 +70,6 @@ public class IgniteCacheGroupsPartitionLossPolicySelfTest extends GridCommonAbst @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); CacheConfiguration ccfg1 = new CacheConfiguration(CACHE_1) @@ -100,6 +96,7 @@ public class IgniteCacheGroupsPartitionLossPolicySelfTest extends GridCommonAbst /** * @throws Exception if failed. */ + @Test public void testReadOnlySafe() throws Exception { partLossPlc = PartitionLossPolicy.READ_ONLY_SAFE; @@ -109,6 +106,7 @@ public void testReadOnlySafe() throws Exception { /** * @throws Exception if failed. */ + @Test public void testReadOnlyAll() throws Exception { partLossPlc = PartitionLossPolicy.READ_ONLY_ALL; @@ -118,6 +116,7 @@ public void testReadOnlyAll() throws Exception { /** * @throws Exception if failed. */ + @Test public void testReadWriteSafe() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; @@ -127,6 +126,7 @@ public void testReadWriteSafe() throws Exception { /** * @throws Exception if failed. */ + @Test public void testReadWriteAll() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_ALL; @@ -136,6 +136,7 @@ public void testReadWriteAll() throws Exception { /** * @throws Exception if failed. */ + @Test public void testIgnore() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-5078"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java index 1e7b32a4232cc..64d577953aa05 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java @@ -36,11 +36,12 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -49,10 +50,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheManyClientsTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRVS = 4; @@ -80,7 +79,6 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest { ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setLocalPortRange(200); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinderCleanFrequency(10 * 60_000); ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setJoinTimeout(2 * 60_000); @@ -114,6 +112,7 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testManyClientsClientDiscovery() throws Throwable { clientDiscovery = true; @@ -123,6 +122,7 @@ public void testManyClientsClientDiscovery() throws Throwable { /** * @throws Exception If failed. */ + @Test public void testManyClientsSequentiallyClientDiscovery() throws Exception { clientDiscovery = true; @@ -132,6 +132,7 @@ public void testManyClientsSequentiallyClientDiscovery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testManyClientsForceServerMode() throws Throwable { manyClientsPutGet(); } @@ -331,4 +332,4 @@ private void manyClientsPutGet() throws Throwable { stop.set(true); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java index 8b75695736e6f..944f86fd6fac2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java @@ -38,6 +38,9 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -45,6 +48,7 @@ /** * Tests message delivery after reconnection. */ +@RunWith(JUnit4.class) public abstract class IgniteCacheMessageRecoveryAbstractTest extends GridCommonAbstractTest { /** Grid count. */ public static final int GRID_CNT = 3; @@ -107,6 +111,7 @@ protected int connectionsPerNode() { /** * @throws Exception If failed. */ + @Test public void testMessageRecovery() throws Exception { final Ignite ignite = grid(0); @@ -195,4 +200,4 @@ static boolean closeSessions(Ignite ignite) throws Exception { return closed; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java index 0f4aaa7a85c17..fcabcefb0e1ea 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java @@ -30,23 +30,22 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheMessageRecoveryIdleConnectionTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 3; @@ -57,8 +56,6 @@ public class IgniteCacheMessageRecoveryIdleConnectionTest extends GridCommonAbst @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); commSpi.setIdleConnectionTimeout(IDLE_TIMEOUT); @@ -84,6 +81,7 @@ public class IgniteCacheMessageRecoveryIdleConnectionTest extends GridCommonAbst /** * @throws Exception If failed. */ + @Test public void testCacheOperationsIdleConnectionCloseTx() throws Exception { cacheOperationsIdleConnectionClose(TRANSACTIONAL); } @@ -91,6 +89,15 @@ public void testCacheOperationsIdleConnectionCloseTx() throws Exception { /** * @throws Exception If failed. */ + @Test + public void testCacheOperationsIdleConnectionCloseMvccTx() throws Exception { + cacheOperationsIdleConnectionClose(TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCacheOperationsIdleConnectionCloseAtomic() throws Exception { cacheOperationsIdleConnectionClose(ATOMIC); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageWriteTimeoutTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageWriteTimeoutTest.java index 3ba319bde6bd2..93cff7fd3de8c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageWriteTimeoutTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageWriteTimeoutTest.java @@ -26,25 +26,21 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheMessageWriteTimeoutTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - TcpCommunicationSpi commSpi = (TcpCommunicationSpi)cfg.getCommunicationSpi(); // Try provoke connection close on socket writeTimeout. @@ -74,6 +70,7 @@ public class IgniteCacheMessageWriteTimeoutTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testMessageQueueLimit() throws Exception { for (int i = 0; i < 3; i++) { log.info("Iteration: " + i); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java index 54b78209c56a2..4c0b699b1e782 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java @@ -43,12 +43,13 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionRollbackException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -56,10 +57,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheNearRestartRollbackSelfTest extends GridCommonAbstractTest { - /** Shared IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** * The number of entries to put to the test cache. */ @@ -69,19 +68,14 @@ public class IgniteCacheNearRestartRollbackSelfTest extends GridCommonAbstractTe @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - cfg.setClientFailureDetectionTimeout(50000); - cfg.setDiscoverySpi(discoSpi); cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName)); if (getTestIgniteInstanceName(3).equals(igniteInstanceName)) { cfg.setClientMode(true); - discoSpi.setForceServerMode(true); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); } TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); @@ -128,7 +122,7 @@ protected CacheConfiguration cacheConfiguration(String igniteIns /** * @throws Exception If failed. */ - @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") + @Test public void testRestarts() throws Exception { startGrids(4); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNodeJoinAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNodeJoinAbstractTest.java index 002a28d3fca84..b34da817a3b42 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNodeJoinAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNodeJoinAbstractTest.java @@ -28,12 +28,16 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheNodeJoinAbstractTest extends IgniteCacheAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -57,6 +61,7 @@ public abstract class IgniteCacheNodeJoinAbstractTest extends IgniteCacheAbstrac /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { final IgniteCache cache = jcache(0); @@ -111,6 +116,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQuery() throws Exception { final IgniteCache cache = jcache(0); @@ -148,4 +154,4 @@ public void testScanQuery() throws Exception { stopGrid(1); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java index 1616e8f41359d..49979759d92f6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java @@ -18,23 +18,27 @@ package org.apache.ignite.internal.processors.cache.distributed; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.TreeSet; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; import javax.cache.CacheException; +import junit.framework.AssertionFailedError; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.PartitionLossPolicy; import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.cache.query.ScanQuery; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.CacheRebalancingEvent; import org.apache.ignite.events.Event; @@ -43,28 +47,30 @@ import org.apache.ignite.internal.TestDelayingCommunicationSpi; import org.apache.ignite.internal.managers.communication.GridIoMessage; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsAbstractMessage; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.P1; +import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -72,37 +78,44 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe private PartitionLossPolicy partLossPlc; /** */ - protected static final String CACHE_NAME = "partitioned"; + private int backups; /** */ - private int backups = 0; + private final AtomicBoolean delayPartExchange = new AtomicBoolean(false); /** */ - private final AtomicBoolean delayPartExchange = new AtomicBoolean(false); + private final TopologyChanger killSingleNode = new TopologyChanger( + false, singletonList(3), asList(0, 1, 2, 4), 0); /** */ - private final TopologyChanger killSingleNode = new TopologyChanger(false, Arrays.asList(3), Arrays.asList(0, 1, 2, 4),0); + private boolean isPersistenceEnabled; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setCommunicationSpi(new TestDelayingCommunicationSpi() { + /** {@inheritDoc} */ @Override protected boolean delayMessage(Message msg, GridIoMessage ioMsg) { - return delayPartExchange.get() && (msg instanceof GridDhtPartitionsFullMessage || msg instanceof GridDhtPartitionsAbstractMessage); + return delayPartExchange.get() && + (msg instanceof GridDhtPartitionsFullMessage || msg instanceof GridDhtPartitionsAbstractMessage); } - @Override protected int delayMillis() { - return 250; - } }); cfg.setClientMode(client); cfg.setCacheConfiguration(cacheConfiguration()); + cfg.setConsistentId(gridName); + + cfg.setDataStorageConfiguration( + new DataStorageConfiguration() + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setPersistenceEnabled(isPersistenceEnabled) + )); + return cfg; } @@ -110,7 +123,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe * @return Cache configuration. */ protected CacheConfiguration cacheConfiguration() { - CacheConfiguration cacheCfg = new CacheConfiguration<>(CACHE_NAME); + CacheConfiguration cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setBackups(backups); @@ -121,23 +134,32 @@ protected CacheConfiguration cacheConfiguration() { return cacheCfg; } - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - } - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); delayPartExchange.set(false); + partLossPlc = PartitionLossPolicy.IGNORE; + backups = 0; + + isPersistenceEnabled = false; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + super.afterTest(); } /** * @throws Exception if failed. */ + @Test public void testReadOnlySafe() throws Exception { partLossPlc = PartitionLossPolicy.READ_ONLY_SAFE; @@ -147,6 +169,19 @@ public void testReadOnlySafe() throws Exception { /** * @throws Exception if failed. */ + @Test + public void testReadOnlySafeWithPersistence() throws Exception { + partLossPlc = PartitionLossPolicy.READ_ONLY_SAFE; + + isPersistenceEnabled = true; + + checkLostPartition(false, true, killSingleNode); + } + + /** + * @throws Exception if failed. + */ + @Test public void testReadOnlyAll() throws Exception { partLossPlc = PartitionLossPolicy.READ_ONLY_ALL; @@ -156,6 +191,21 @@ public void testReadOnlyAll() throws Exception { /** * @throws Exception if failed. */ + @Test + public void testReadOnlyAllWithPersistence() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10041"); + + partLossPlc = PartitionLossPolicy.READ_ONLY_ALL; + + isPersistenceEnabled = true; + + checkLostPartition(false, false, killSingleNode); + } + + /** + * @throws Exception if failed. + */ + @Test public void testReadWriteSafe() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; @@ -165,6 +215,19 @@ public void testReadWriteSafe() throws Exception { /** * @throws Exception if failed. */ + @Test + public void testReadWriteSafeWithPersistence() throws Exception { + partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; + + isPersistenceEnabled = true; + + checkLostPartition(true, true, killSingleNode); + } + + /** + * @throws Exception if failed. + */ + @Test public void testReadWriteAll() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_ALL; @@ -174,80 +237,238 @@ public void testReadWriteAll() throws Exception { /** * @throws Exception if failed. */ + @Test + public void testReadWriteAllWithPersistence() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10041"); + + partLossPlc = PartitionLossPolicy.READ_WRITE_ALL; + + isPersistenceEnabled = true; + + checkLostPartition(true, false, killSingleNode); + } + + /** + * @throws Exception if failed. + */ + @Test public void testReadWriteSafeAfterKillTwoNodes() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; - checkLostPartition(true, true, new TopologyChanger(false, Arrays.asList(3, 2), Arrays.asList(0, 1, 4), 0)); + checkLostPartition(true, true, new TopologyChanger(false, asList(3, 2), asList(0, 1, 4), 0)); } /** * @throws Exception if failed. */ + @Test + public void testReadWriteSafeAfterKillTwoNodesWithPersistence() throws Exception { + partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; + + isPersistenceEnabled = true; + + checkLostPartition(true, true, new TopologyChanger(false, asList(3, 2), asList(0, 1, 4), 0)); + } + + /** + * @throws Exception if failed. + */ + @Test public void testReadWriteSafeAfterKillTwoNodesWithDelay() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; - checkLostPartition(true, true, new TopologyChanger(false, Arrays.asList(3, 2), Arrays.asList(0, 1, 4), 20)); + checkLostPartition(true, true, new TopologyChanger(false, asList(3, 2), asList(0, 1, 4), 20)); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testReadWriteSafeAfterKillTwoNodesWithDelayWithPersistence() throws Exception { + partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; + + isPersistenceEnabled = true; + + checkLostPartition(true, true, new TopologyChanger(false, asList(3, 2), asList(0, 1, 4), 20)); } /** * @throws Exception if failed. */ + @Test public void testReadWriteSafeWithBackupsAfterKillThreeNodes() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; backups = 1; - checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 2, 1), Arrays.asList(0, 4), 0)); + checkLostPartition(true, true, new TopologyChanger(true, asList(3, 2, 1), asList(0, 4), 0)); } /** * @throws Exception if failed. */ + @Test + public void testReadWriteSafeWithBackupsAfterKillThreeNodesWithPersistence() throws Exception { + partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; + + backups = 1; + + isPersistenceEnabled = true; + + checkLostPartition(true, true, new TopologyChanger(true, asList(3, 2, 1), asList(0, 4), 0)); + } + + /** + * @throws Exception if failed. + */ + @Test public void testReadWriteSafeAfterKillCrd() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; - checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 0), Arrays.asList(1, 2, 4), 0)); + checkLostPartition(true, true, new TopologyChanger(true, asList(3, 0), asList(1, 2, 4), 0)); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testReadWriteSafeAfterKillCrdWithPersistence() throws Exception { + partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; + + isPersistenceEnabled = true; + + checkLostPartition(true, true, new TopologyChanger(true, asList(3, 0), asList(1, 2, 4), 0)); } /** * @throws Exception if failed. */ + @Test public void testReadWriteSafeWithBackups() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; backups = 1; - checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 2), Arrays.asList(0, 1, 4), 0)); + checkLostPartition(true, true, new TopologyChanger(true, asList(3, 2), asList(0, 1, 4), 0)); } /** * @throws Exception if failed. */ + @Test + public void testReadWriteSafeWithBackupsWithPersistence() throws Exception { + partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; + + backups = 1; + + isPersistenceEnabled = true; + + checkLostPartition(true, true, new TopologyChanger(true, asList(3, 2), asList(0, 1, 4), 0)); + } + + /** + * @throws Exception if failed. + */ + @Test public void testReadWriteSafeWithBackupsAfterKillCrd() throws Exception { partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; backups = 1; - checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 0), Arrays.asList(1, 2, 4), 0)); + checkLostPartition(true, true, new TopologyChanger(true, asList(3, 0), asList(1, 2, 4), 0)); } /** - * @param topChanger topology changer. * @throws Exception if failed. */ - public void testIgnore(TopologyChanger topChanger) throws Exception { + @Test + public void testReadWriteSafeWithBackupsAfterKillCrdWithPersistence() throws Exception { + partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE; + + backups = 1; + + isPersistenceEnabled = true; + + checkLostPartition(true, true, new TopologyChanger(true, asList(3, 0), asList(1, 2, 4), 0)); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testIgnore() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-5078"); + partLossPlc = PartitionLossPolicy.IGNORE; + + checkIgnore(killSingleNode); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testIgnoreWithPersistence() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-5078"); + + fail("https://issues.apache.org/jira/browse/IGNITE-10041"); + + partLossPlc = PartitionLossPolicy.IGNORE; + + isPersistenceEnabled = true; + + checkIgnore(killSingleNode); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testIgnoreKillThreeNodes() throws Exception { + partLossPlc = PartitionLossPolicy.IGNORE; + + // TODO aliveNodes should include node 4, but it fails due to https://issues.apache.org/jira/browse/IGNITE-5078. + // TODO need to add 4 to the aliveNodes after IGNITE-5078 is fixed. + // TopologyChanger onlyCrdIsAlive = new TopologyChanger(false, Arrays.asList(1, 2, 3), Arrays.asList(0, 4), 0); + TopologyChanger onlyCrdIsAlive = new TopologyChanger(false, asList(1, 2, 3), singletonList(0), 0); + + checkIgnore(onlyCrdIsAlive); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testIgnoreKillThreeNodesWithPersistence() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10041"); + + partLossPlc = PartitionLossPolicy.IGNORE; + + isPersistenceEnabled = true; + + // TODO aliveNodes should include node 4, but it fails due to https://issues.apache.org/jira/browse/IGNITE-5078. + // TODO need to add 4 to the aliveNodes after IGNITE-5078 is fixed. + // TopologyChanger onlyCrdIsAlive = new TopologyChanger(false, Arrays.asList(1, 2, 3), Arrays.asList(0, 4), 0); + TopologyChanger onlyCrdIsAlive = new TopologyChanger(false, asList(1, 2, 3), singletonList(0), 0); + + checkIgnore(onlyCrdIsAlive); + } + + /** + * @param topChanger topology changer. + * @throws Exception if failed. + */ + private void checkIgnore(TopologyChanger topChanger) throws Exception { topChanger.changeTopology(); for (Ignite ig : G.allGrids()) { - IgniteCache cache = ig.cache(CACHE_NAME); + IgniteCache cache = ig.cache(DEFAULT_CACHE_NAME); Collection lost = cache.lostPartitions(); assertTrue("[grid=" + ig.name() + ", lost=" + lost.toString() + ']', lost.isEmpty()); - int parts = ig.affinity(CACHE_NAME).partitions(); + int parts = ig.affinity(DEFAULT_CACHE_NAME).partitions(); for (int i = 0; i < parts; i++) { cache.get(i); @@ -266,14 +487,14 @@ public void testIgnore(TopologyChanger topChanger) throws Exception { private void checkLostPartition(boolean canWrite, boolean safe, TopologyChanger topChanger) throws Exception { assert partLossPlc != null; - int part = topChanger.changeTopology().get(0); + List lostParts = topChanger.changeTopology(); // Wait for all grids (servers and client) have same topology version // to make sure that all nodes received map with lost partition. - GridTestUtils.waitForCondition(() -> { + boolean success = GridTestUtils.waitForCondition(() -> { AffinityTopologyVersion last = null; for (Ignite ig : G.allGrids()) { - AffinityTopologyVersion ver = ((IgniteEx) ig).context().cache().context().exchange().readyAffinityVersion(); + AffinityTopologyVersion ver = ((IgniteEx)ig).context().cache().context().exchange().readyAffinityVersion(); if (last != null && !last.equals(ver)) return false; @@ -284,71 +505,143 @@ private void checkLostPartition(boolean canWrite, boolean safe, TopologyChanger return true; }, 10000); + assertTrue("Failed to wait for new topology", success); + for (Ignite ig : G.allGrids()) { info("Checking node: " + ig.cluster().localNode().id()); - IgniteCache cache = ig.cache(CACHE_NAME); + IgniteCache cache = ig.cache(DEFAULT_CACHE_NAME); - verifyCacheOps(canWrite, safe, part, ig); + verifyLostPartitions(ig, lostParts); - // Check we can read and write to lost partition in recovery mode. - IgniteCache recoverCache = cache.withPartitionRecover(); + verifyCacheOps(canWrite, safe, ig); - for (int lostPart : recoverCache.lostPartitions()) { - recoverCache.get(lostPart); - recoverCache.put(lostPart, lostPart); - } + validateQuery(safe, ig); - // Check that writing in recover mode does not clear partition state. - verifyCacheOps(canWrite, safe, part, ig); + // TODO withPartitionRecover doesn't work with BLT - https://issues.apache.org/jira/browse/IGNITE-10041. + if (!isPersistenceEnabled) { + // Check we can read and write to lost partition in recovery mode. + IgniteCache recoverCache = cache.withPartitionRecover(); - // Validate queries. - validateQuery(safe, part, ig); + for (int lostPart : recoverCache.lostPartitions()) { + recoverCache.get(lostPart); + recoverCache.put(lostPart, lostPart); + } + + // Check that writing in recover mode does not clear partition state. + verifyLostPartitions(ig, lostParts); + + verifyCacheOps(canWrite, safe, ig); + + validateQuery(safe, ig); + } } - // Check that partition state does not change after we start a new node. - IgniteEx grd = startGrid(3); + checkNewNode(true, canWrite, safe); + checkNewNode(false, canWrite, safe); - info("Newly started node: " + grd.cluster().localNode().id()); + // Bring all nodes back. + for (int i : topChanger.killNodes) { + IgniteEx grd = startGrid(i); - for (Ignite ig : G.allGrids()) - verifyCacheOps(canWrite, safe, part, ig); + info("Newly started node: " + grd.cluster().localNode().id()); - ignite(4).resetLostPartitions(Collections.singletonList(CACHE_NAME)); + // Check that partition state does not change after we start each node. + // TODO With persistence enabled LOST partitions become OWNING after a node joins back - https://issues.apache.org/jira/browse/IGNITE-10044. + if (!isPersistenceEnabled) { + for (Ignite ig : G.allGrids()) { + verifyCacheOps(canWrite, safe, ig); + + // TODO Query effectively waits for rebalance due to https://issues.apache.org/jira/browse/IGNITE-10057 + // TODO and after resetLostPartition there is another OWNING copy in the cluster due to https://issues.apache.org/jira/browse/IGNITE-10058. + // TODO Uncomment after https://issues.apache.org/jira/browse/IGNITE-10058 is fixed. +// validateQuery(safe, ig); + } + } + } + + ignite(4).resetLostPartitions(singletonList(DEFAULT_CACHE_NAME)); awaitPartitionMapExchange(true, true, null); for (Ignite ig : G.allGrids()) { - IgniteCache cache = ig.cache(CACHE_NAME); + IgniteCache cache = ig.cache(DEFAULT_CACHE_NAME); assertTrue(cache.lostPartitions().isEmpty()); - int parts = ig.affinity(CACHE_NAME).partitions(); + int parts = ig.affinity(DEFAULT_CACHE_NAME).partitions(); for (int i = 0; i < parts; i++) { cache.get(i); cache.put(i, i); } + + for (int i = 0; i < parts; i++) { + checkQueryPasses(ig, false, i); + + if (shouldExecuteLocalQuery(ig, i)) + checkQueryPasses(ig, true, i); + + } + + checkQueryPasses(ig, false); } } /** - * + * @param client Client flag. + * @param canWrite Can write flag. + * @param safe Safe flag. + * @throws Exception If failed to start a new node. + */ + private void checkNewNode( + boolean client, + boolean canWrite, + boolean safe + ) throws Exception { + this.client = client; + + try { + IgniteEx cl = (IgniteEx)startGrid("newNode"); + + CacheGroupContext grpCtx = cl.context().cache().cacheGroup(CU.cacheId(DEFAULT_CACHE_NAME)); + + assertTrue(grpCtx.needsRecovery()); + + verifyCacheOps(canWrite, safe, cl); + + validateQuery(safe, cl); + } + finally { + stopGrid("newNode", false); + + this.client = false; + } + } + + /** + * @param node Node. + * @param lostParts Lost partition IDs. + */ + private void verifyLostPartitions(Ignite node, List lostParts) { + IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); + + Set actualSortedLostParts = new TreeSet<>(cache.lostPartitions()); + Set expSortedLostParts = new TreeSet<>(lostParts); + + assertEqualsCollections(expSortedLostParts, actualSortedLostParts); + } + + /** * @param canWrite {@code True} if writes are allowed. * @param safe {@code True} if lost partition should trigger exception. - * @param part Lost partition ID. * @param ig Ignite instance. */ - private void verifyCacheOps(boolean canWrite, boolean safe, int part, Ignite ig) { - IgniteCache cache = ig.cache(CACHE_NAME); - - Collection lost = cache.lostPartitions(); + private void verifyCacheOps(boolean canWrite, boolean safe, Ignite ig) { + IgniteCache cache = ig.cache(DEFAULT_CACHE_NAME); - assertTrue("Failed to find expected lost partition [exp=" + part + ", lost=" + lost + ']', - lost.contains(part)); - - int parts = ig.affinity(CACHE_NAME).partitions(); + int parts = ig.affinity(DEFAULT_CACHE_NAME).partitions(); // Check read. for (int i = 0; i < parts; i++) { @@ -395,8 +688,8 @@ private void verifyCacheOps(boolean canWrite, boolean safe, int part, Ignite ig) * @param nodes List of nodes to find partition. * @return List of partitions that aren't primary or backup for specified nodes. */ - protected List noPrimaryOrBackupPartition(List nodes) { - Affinity aff = ignite(4).affinity(CACHE_NAME); + private List noPrimaryOrBackupPartition(List nodes) { + Affinity aff = ignite(4).affinity(DEFAULT_CACHE_NAME); List parts = new ArrayList<>(); @@ -424,15 +717,125 @@ protected List noPrimaryOrBackupPartition(List nodes) { * Validate query execution on a node. * * @param safe Safe flag. - * @param part Partition. * @param node Node. */ - protected void validateQuery(boolean safe, int part, Ignite node) { + private void validateQuery(boolean safe, Ignite node) { + // Get node lost and remaining partitions. + IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); + + Collection lostParts = cache.lostPartitions(); + + int part = cache.lostPartitions().stream().findFirst().orElseThrow(AssertionFailedError::new); + + Integer remainingPart = null; + + for (int i = 0; i < node.affinity(DEFAULT_CACHE_NAME).partitions(); i++) { + if (lostParts.contains(i)) + continue; + + remainingPart = i; + + break; + } + + assertNotNull("Failed to find a partition that isn't lost", remainingPart); + + // 1. Check query against all partitions. + validateQuery0(safe, node); + + // 2. Check query against LOST partition. + validateQuery0(safe, node, part); + + // 3. Check query on remaining partition. + checkQueryPasses(node, false, remainingPart); + + if (shouldExecuteLocalQuery(node, remainingPart)) + checkQueryPasses(node, true, remainingPart); + + // 4. Check query over two partitions - normal and LOST. + validateQuery0(safe, node, part, remainingPart); + } + + /** + * Query validation routine. + * + * @param safe Safe flag. + * @param node Node. + * @param parts Partitions. + */ + private void validateQuery0(boolean safe, Ignite node, int... parts) { + if (safe) + checkQueryFails(node, false, parts); + else + checkQueryPasses(node, false, parts); + + if (shouldExecuteLocalQuery(node, parts)) { + if (safe) + checkQueryFails(node, true, parts); + else + checkQueryPasses(node, true, parts); + } + } + + /** + * @return true if the given node is primary for all given partitions. + */ + private boolean shouldExecuteLocalQuery(Ignite node, int... parts) { + if (parts == null || parts.length == 0) + return false; + + int numOfPrimaryParts = 0; + + for (int nodePrimaryPart : node.affinity(DEFAULT_CACHE_NAME).primaryPartitions(node.cluster().localNode())) { + for (int part : parts) { + if (part == nodePrimaryPart) + numOfPrimaryParts++; + } + } + + return numOfPrimaryParts == parts.length; + } + + /** + * @param node Node. + * @param loc Local flag. + * @param parts Partitions. + */ + protected void checkQueryPasses(Ignite node, boolean loc, int... parts) { + // Scan queries don't support multiple partitions. + if (parts != null && parts.length > 1) + return; + + // TODO Local scan queries fail in non-safe modes - https://issues.apache.org/jira/browse/IGNITE-10059. + if (loc) + return; + + IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); + + ScanQuery qry = new ScanQuery(); + + if (parts != null && parts.length > 0) + qry.setPartition(parts[0]); + + if (loc) + qry.setLocal(true); + + cache.query(qry).getAll(); + } + + /** + * @param node Node. + * @param loc Local flag. + * @param parts Partitions. + */ + protected void checkQueryFails(Ignite node, boolean loc, int... parts) { + // TODO Scan queries never fail due to partition loss - https://issues.apache.org/jira/browse/IGNITE-9902. + // TODO Need to add an actual check after https://issues.apache.org/jira/browse/IGNITE-9902 is fixed. // No-op. } /** */ - class TopologyChanger { + private class TopologyChanger { /** Flag to delay partition exchange */ private boolean delayExchange; @@ -451,7 +854,7 @@ class TopologyChanger { * @param aliveNodes List of nodes to be alive. * @param stopDelay Delay between stopping nodes. */ - public TopologyChanger(boolean delayExchange, List killNodes, List aliveNodes, + private TopologyChanger(boolean delayExchange, List killNodes, List aliveNodes, long stopDelay) { this.delayExchange = delayExchange; this.killNodes = killNodes; @@ -463,13 +866,16 @@ public TopologyChanger(boolean delayExchange, List killNodes, List changeTopology() throws Exception { + private List changeTopology() throws Exception { startGrids(4); - Affinity aff = ignite(0).affinity(CACHE_NAME); + if (isPersistenceEnabled) + grid(0).cluster().active(true); + + Affinity aff = ignite(0).affinity(DEFAULT_CACHE_NAME); for (int i = 0; i < aff.partitions(); i++) - ignite(0).cache(CACHE_NAME).put(i, i); + ignite(0).cache(DEFAULT_CACHE_NAME).put(i, i); client = true; @@ -497,14 +903,13 @@ protected List changeTopology() throws Exception { lostMap.add(semaphoreMap); - grid(i).events().localListen(new P1() { @Override public boolean apply(Event evt) { assert evt.type() == EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST; CacheRebalancingEvent cacheEvt = (CacheRebalancingEvent)evt; - if (F.eq(CACHE_NAME, cacheEvt.cacheName())) { + if (F.eq(DEFAULT_CACHE_NAME, cacheEvt.cacheName())) { if (semaphoreMap.containsKey(cacheEvt.partition())) semaphoreMap.get(cacheEvt.partition()).release(); } @@ -512,7 +917,6 @@ protected List changeTopology() throws Exception { return true; } }, EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST); - } if (delayExchange) @@ -538,16 +942,15 @@ protected List changeTopology() throws Exception { for (Map map : lostMap) { for (Map.Entry entry : map.entrySet()) - assertTrue("Failed to wait for partition LOST event for partition:" + entry.getKey(), entry.getValue().tryAcquire(1)); + assertTrue("Failed to wait for partition LOST event for partition: " + entry.getKey(), entry.getValue().tryAcquire(1)); } for (Map map : lostMap) { for (Map.Entry entry : map.entrySet()) - assertFalse("Partition LOST event raised twice for partition:" + entry.getKey(), entry.getValue().tryAcquire(1)); + assertFalse("Partition LOST event raised twice for partition: " + entry.getKey(), entry.getValue().tryAcquire(1)); } return parts; } } - } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePrimarySyncTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePrimarySyncTest.java index e9e22ee90429f..19a23cc2d0c7e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePrimarySyncTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePrimarySyncTest.java @@ -24,17 +24,20 @@ import org.apache.ignite.IgniteTransactions; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -45,12 +48,19 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCachePrimarySyncTest extends GridCommonAbstractTest { /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + private static final int SRVS = 4; /** */ - private static final int SRVS = 4; + private static final String ATOMIC_CACHE = "atomicCache"; + + /** */ + private static final String TX_CACHE = "txCache"; + + /** */ + private static final String MVCC_CACHE = "mvccCache"; /** */ private boolean clientMode; @@ -59,21 +69,22 @@ public class IgniteCachePrimarySyncTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + CacheConfiguration ccfg1 = new CacheConfiguration<>(ATOMIC_CACHE) + .setAtomicityMode(ATOMIC) + .setBackups(2) + .setWriteSynchronizationMode(PRIMARY_SYNC); - CacheConfiguration ccfg1 = new CacheConfiguration<>(DEFAULT_CACHE_NAME); - ccfg1.setName("cache1"); - ccfg1.setAtomicityMode(ATOMIC); - ccfg1.setBackups(2); - ccfg1.setWriteSynchronizationMode(PRIMARY_SYNC); + CacheConfiguration ccfg2 = new CacheConfiguration<>(TX_CACHE) + .setAtomicityMode(TRANSACTIONAL) + .setBackups(2) + .setWriteSynchronizationMode(PRIMARY_SYNC); - CacheConfiguration ccfg2 = new CacheConfiguration<>(DEFAULT_CACHE_NAME); - ccfg2.setName("cache2"); - ccfg2.setAtomicityMode(TRANSACTIONAL); - ccfg2.setBackups(2); - ccfg2.setWriteSynchronizationMode(PRIMARY_SYNC); + CacheConfiguration ccfg3 = new CacheConfiguration<>(MVCC_CACHE) + .setAtomicityMode(TRANSACTIONAL_SNAPSHOT) + .setBackups(2) + .setWriteSynchronizationMode(PRIMARY_SYNC); - cfg.setCacheConfiguration(ccfg1, ccfg2); + cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg3); cfg.setClientMode(clientMode); @@ -96,18 +107,25 @@ public class IgniteCachePrimarySyncTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPutGet() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10520", MvccFeatureChecker.forcedMvcc()); + Ignite ignite = ignite(SRVS); - checkPutGet(ignite.cache("cache1"), null, null, null); + checkPutGet(ignite.cache(ATOMIC_CACHE), null, null, null); + + checkPutGet(ignite.cache(TX_CACHE), null, null, null); + + checkPutGet(ignite.cache(MVCC_CACHE), null, null, null); - checkPutGet(ignite.cache("cache2"), null, null, null); + checkPutGet(ignite.cache(TX_CACHE), ignite.transactions(), OPTIMISTIC, REPEATABLE_READ); - checkPutGet(ignite.cache("cache2"), ignite.transactions(), OPTIMISTIC, REPEATABLE_READ); + checkPutGet(ignite.cache(TX_CACHE), ignite.transactions(), OPTIMISTIC, SERIALIZABLE); - checkPutGet(ignite.cache("cache2"), ignite.transactions(), OPTIMISTIC, SERIALIZABLE); + checkPutGet(ignite.cache(TX_CACHE), ignite.transactions(), PESSIMISTIC, READ_COMMITTED); - checkPutGet(ignite.cache("cache2"), ignite.transactions(), PESSIMISTIC, READ_COMMITTED); + checkPutGet(ignite.cache(MVCC_CACHE), ignite.transactions(), PESSIMISTIC, REPEATABLE_READ); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java index 5c3265faea6c5..0650ea08fd16d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java @@ -35,6 +35,9 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -45,6 +48,7 @@ /** * Test for specific user scenario. */ +@RunWith(JUnit4.class) public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAbstractTest { /** */ private static final int ENTRY_CNT = 1000; @@ -104,6 +108,7 @@ public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAb /** * @throws Exception If failed. */ + @Test public void testTxPutGetRestart() throws Exception { int clientGrid = gridCount() - 1; @@ -240,4 +245,4 @@ private void updateCache(IgniteCache cache, IgniteTransactions log.error("Update failed: " + e, e); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java index 2bb5fbba81e72..960e51a22b81d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java @@ -43,23 +43,23 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheReadFromBackupTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 4; @@ -71,8 +71,6 @@ public class IgniteCacheReadFromBackupTest extends GridCommonAbstractTest { cfg.setCommunicationSpi(commSpi); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - return cfg; } @@ -86,8 +84,25 @@ public class IgniteCacheReadFromBackupTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testGetFromBackupStoreReadThroughEnabled() throws Exception { - for (CacheConfiguration ccfg : cacheConfigurations()) { + checkGetFromBackupStoreReadThroughEnabled(cacheConfigurations()); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10274") + @Test + public void testMvccGetFromBackupStoreReadThroughEnabled() throws Exception { + checkGetFromBackupStoreReadThroughEnabled(mvccCacheConfigurations()); + } + + /** + * @throws Exception If failed. + */ + private void checkGetFromBackupStoreReadThroughEnabled(List> cacheCfgs) throws Exception { + for (CacheConfiguration ccfg : cacheCfgs) { ccfg.setCacheStoreFactory(new TestStoreFactory()); ccfg.setReadThrough(true); @@ -130,8 +145,25 @@ public void testGetFromBackupStoreReadThroughEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetFromBackupStoreReadThroughDisabled() throws Exception { - for (CacheConfiguration ccfg : cacheConfigurations()) { + checkGetFromBackupStoreReadThroughDisabled(cacheConfigurations()); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10274") + @Test + public void testMvccGetFromBackupStoreReadThroughDisabled() throws Exception { + checkGetFromBackupStoreReadThroughDisabled(mvccCacheConfigurations()); + } + + /** + * @throws Exception If failed. + */ + private void checkGetFromBackupStoreReadThroughDisabled(List> cacheCfgs) throws Exception { + for (CacheConfiguration ccfg : cacheCfgs) { ccfg.setCacheStoreFactory(new TestStoreFactory()); ccfg.setReadThrough(false); @@ -158,8 +190,25 @@ public void testGetFromBackupStoreReadThroughDisabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetFromPrimaryPreloadInProgress() throws Exception { - for (final CacheConfiguration ccfg : cacheConfigurations()) { + checkGetFromPrimaryPreloadInProgress(cacheConfigurations()); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10274") + @Test + public void testMvccGetFromPrimaryPreloadInProgress() throws Exception { + checkGetFromPrimaryPreloadInProgress(mvccCacheConfigurations()); + } + + /** + * @throws Exception If failed. + */ + private void checkGetFromPrimaryPreloadInProgress(List> cacheCfgs) throws Exception { + for (final CacheConfiguration ccfg : cacheCfgs) { boolean near = (ccfg.getNearConfiguration() != null); log.info("Test cache [mode=" + ccfg.getCacheMode() + @@ -244,8 +293,26 @@ public void testGetFromPrimaryPreloadInProgress() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoPrimaryReadPreloadFinished() throws Exception { - for (CacheConfiguration ccfg : cacheConfigurations()) { + checkNoPrimaryReadPreloadFinished(cacheConfigurations()); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10274") + @Test + public void testMvccNoPrimaryReadPreloadFinished() throws Exception { + checkNoPrimaryReadPreloadFinished(mvccCacheConfigurations()); + + } + + /** + * @throws Exception If failed. + */ + private void checkNoPrimaryReadPreloadFinished(List> cacheCfgs) throws Exception { + for (CacheConfiguration ccfg : cacheCfgs) { boolean near = (ccfg.getNearConfiguration() != null); log.info("Test cache [mode=" + ccfg.getCacheMode() + @@ -369,6 +436,21 @@ private List> cacheConfigurations() { return ccfgs; } + /** + * @return Cache configurations to test. + */ + private List> mvccCacheConfigurations() { + List> ccfgs = new ArrayList<>(); + + ccfgs.add(cacheConfiguration(REPLICATED, TRANSACTIONAL_SNAPSHOT, 0, false)); + + ccfgs.add(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, 1, false)); + ccfgs.add(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, 1, true)); + ccfgs.add(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, 2, false)); + + return ccfgs; + } + /** * @param cacheMode Cache mode. * @param atomicityMode Cache atomicity mode. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java index 0b5280d4c4392..f680758516845 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java @@ -21,9 +21,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -32,10 +33,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheServerNodeConcurrentStart extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int ITERATIONS = 2; @@ -43,7 +42,6 @@ public class IgniteCacheServerNodeConcurrentStart extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinderCleanFrequency(getTestTimeout() * 2); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); @@ -81,6 +79,7 @@ public class IgniteCacheServerNodeConcurrentStart extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testConcurrentStart() throws Exception { for (int i = 0; i < ITERATIONS; i++) { log.info("Iteration: " + i); @@ -98,4 +97,4 @@ public void testConcurrentStart() throws Exception { log.info("Iteration finished, time: " + (System.currentTimeMillis() - start) / 1000f); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSingleGetMessageTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSingleGetMessageTest.java index 974bcf21dc292..37d89ca27c864 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSingleGetMessageTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSingleGetMessageTest.java @@ -29,14 +29,16 @@ import org.apache.ignite.internal.TestRecordingCommunicationSpi; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -46,10 +48,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheSingleGetMessageTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRVS = 4; @@ -66,8 +66,6 @@ public class IgniteCacheSingleGetMessageTest extends GridCommonAbstractTest { cfg.setCommunicationSpi(commSpi); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - return cfg; } @@ -87,12 +85,27 @@ public class IgniteCacheSingleGetMessageTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSingleGetMessage() throws Exception { + checkSingleGetMessage(cacheConfigurations()); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7371") + @Test + public void testMvccSingleGetMessage() throws Exception { + checkSingleGetMessage(mvccCacheConfigurations()); + } + + /** + * @throws Exception If failed. + */ + public void checkSingleGetMessage(List> ccfgs) throws Exception { assertFalse(ignite(0).configuration().isClientMode()); assertTrue(ignite(SRVS).configuration().isClientMode()); - List> ccfgs = cacheConfigurations(); - for (int i = 0; i < ccfgs.size(); i++) { CacheConfiguration ccfg = ccfgs.get(i); @@ -281,6 +294,19 @@ private List> cacheConfigurations() { return ccfgs; } + /** + * @return Mvcc cache configurations to test. + */ + private List> mvccCacheConfigurations() { + List> ccfgs = new ArrayList<>(); + + ccfgs.add(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, FULL_SYNC, 0)); + ccfgs.add(cacheConfiguration(PARTITIONED, TRANSACTIONAL_SNAPSHOT, FULL_SYNC, 1)); + ccfgs.add(cacheConfiguration(REPLICATED, TRANSACTIONAL_SNAPSHOT, FULL_SYNC, 0)); + + return ccfgs; + } + /** * @param cacheMode Cache mode. * @param atomicityMode Cache atomicity mode. @@ -297,7 +323,6 @@ private CacheConfiguration cacheConfiguration( ccfg.setCacheMode(cacheMode); ccfg.setAtomicityMode(atomicityMode); - ccfg.setAtomicityMode(TRANSACTIONAL); ccfg.setWriteSynchronizationMode(syncMode); if (cacheMode == PARTITIONED) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSizeFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSizeFailoverTest.java index cd859506895e4..b80c31cfae4e0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSizeFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSizeFailoverTest.java @@ -26,11 +26,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -39,16 +39,12 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheSizeFailoverTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -73,6 +69,7 @@ public class IgniteCacheSizeFailoverTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSize() throws Exception { startGrids(2); @@ -123,4 +120,4 @@ public void testSize() throws Exception { fut.get(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java index eb19873c816f5..a7646f816493f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java @@ -19,9 +19,8 @@ import java.util.Map; import org.apache.ignite.IgniteCache; -import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; @@ -30,7 +29,13 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -41,19 +46,23 @@ /** * Tests that system transactions do not interact with user transactions. */ -public class IgniteCacheSystemTransactionsSelfTest extends GridCacheAbstractSelfTest { +@RunWith(JUnit4.class) +public class IgniteCacheSystemTransactionsSelfTest extends GridCommonAbstractTest { + /** */ + private static final int NODES_CNT = 4; + /** {@inheritDoc} */ - @Override protected int gridCount() { - return 4; + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + startGridsMultiThreaded(NODES_CNT); } /** {@inheritDoc} */ - @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { - CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName); + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); - ccfg.setAtomicityMode(TRANSACTIONAL); - - return ccfg; + super.afterTestsStopped(); } /** {@inheritDoc} */ @@ -67,10 +76,19 @@ public class IgniteCacheSystemTransactionsSelfTest extends GridCacheAbstractSelf } } + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + return super.getConfiguration(igniteInstanceName) + .setCacheConfiguration(defaultCacheConfiguration().setAtomicityMode(TRANSACTIONAL)); + } + /** * @throws Exception If failed. */ + @Test public void testSystemTxInsideUserTx() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10473", MvccFeatureChecker.forcedMvcc()); + IgniteKernal ignite = (IgniteKernal)grid(0); IgniteCache jcache = ignite.cache(DEFAULT_CACHE_NAME); @@ -100,19 +118,22 @@ public void testSystemTxInsideUserTx() throws Exception { checkTransactionsCommitted(); - checkEntries(DEFAULT_CACHE_NAME, "1", "11", "2", "22", "3", null); - checkEntries(CU.UTILITY_CACHE_NAME, "1", null, "2", "2", "3", "3"); + checkEntries(DEFAULT_CACHE_NAME, "1", "11", "2", "22", "3", null); + checkEntries(CU.UTILITY_CACHE_NAME, "1", null, "2", "2", "3", "3"); } /** * @throws Exception If failed. */ + @Test public void testGridNearTxLocalDuplicateAsyncCommit() throws Exception { IgniteKernal ignite = (IgniteKernal)grid(0); IgniteInternalCache utilityCache = ignite.context().cache().utilityCache(); - try (GridNearTxLocal itx = utilityCache.txStartEx(OPTIMISTIC, SERIALIZABLE)) { + try (GridNearTxLocal itx = MvccFeatureChecker.forcedMvcc() ? + utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ) : + utilityCache.txStartEx(OPTIMISTIC, SERIALIZABLE)) { utilityCache.put("1", "1"); itx.commitNearTxLocalAsync(); @@ -124,7 +145,7 @@ public void testGridNearTxLocalDuplicateAsyncCommit() throws Exception { * @throws Exception If failed. */ private void checkTransactionsCommitted() throws Exception { - for (int i = 0; i < gridCount(); i++) { + for (int i = 0; i < NODES_CNT; i++) { IgniteKernal kernal = (IgniteKernal)grid(i); IgniteTxManager tm = kernal.context().cache().context().tm(); @@ -149,7 +170,7 @@ private void checkTransactionsCommitted() throws Exception { * @throws Exception If failed. */ private void checkEntries(String cacheName, Object... vals) throws Exception { - for (int g = 0; g < gridCount(); g++) { + for (int g = 0; g < NODES_CNT; g++) { IgniteKernal kernal = (IgniteKernal)grid(g); GridCacheAdapter cache = kernal.context().cache().internalCache(cacheName); @@ -170,4 +191,4 @@ private void checkEntries(String cacheName, Object... vals) throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheThreadLocalTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheThreadLocalTxTest.java index c8eac20782fe5..6363a1f4e7e15 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheThreadLocalTxTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheThreadLocalTxTest.java @@ -26,23 +26,22 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheThreadLocalTxTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -50,8 +49,6 @@ public class IgniteCacheThreadLocalTxTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -67,6 +64,7 @@ public class IgniteCacheThreadLocalTxTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSingleNode() throws Exception { threadLocalTx(startGrid(0)); } @@ -74,6 +72,7 @@ public void testSingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultiNode() throws Exception { startGridsMultiThreaded(4); @@ -106,6 +105,9 @@ private void threadLocalTx(Ignite node) throws Exception { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, isolation)) + continue; + for (boolean read : reads) { for (boolean write : writes) { for (int i = 0; i < endOps; i++) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxIteratorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxIteratorSelfTest.java index d5212e5e98547..8c58309de946c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxIteratorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxIteratorSelfTest.java @@ -27,20 +27,23 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.MvccFeatureChecker.Feature; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import javax.cache.Cache; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheTxIteratorSelfTest extends GridCommonAbstractTest { /** */ public static final String CACHE_NAME = "testCache"; @@ -87,6 +90,7 @@ private CacheConfiguration cacheConfiguration( /** * @throws Exception if failed. */ + @Test public void testModesSingleNode() throws Exception { checkModes(1); } @@ -94,6 +98,7 @@ public void testModesSingleNode() throws Exception { /** * @throws Exception if failed. */ + @Test public void testModesMultiNode() throws Exception { checkModes(3); } @@ -107,14 +112,14 @@ public void checkModes(int gridCnt) throws Exception { try { for (CacheMode mode : CacheMode.values()) { for (CacheAtomicityMode atomMode : CacheAtomicityMode.values()) { - if (mode == CacheMode.PARTITIONED && atomMode != CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) { + if (mode == CacheMode.PARTITIONED) { // Near cache makes sense only for partitioned cache. checkTxCache(CacheMode.PARTITIONED, atomMode, true, false); } - checkTxCache(CacheMode.PARTITIONED, atomMode, false, true); + checkTxCache(mode, atomMode, false, true); - checkTxCache(CacheMode.PARTITIONED, atomMode, false, false); + checkTxCache(mode, atomMode, false, false); } } } @@ -132,6 +137,13 @@ private void checkTxCache( boolean nearEnabled, boolean useEvicPlc ) throws Exception { + if (atomMode == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) { + if (!MvccFeatureChecker.isSupported(mode) || + (nearEnabled && !MvccFeatureChecker.isSupported(Feature.NEAR_CACHE)) || + (useEvicPlc && !MvccFeatureChecker.isSupported(Feature.EVICTION))) + return; // Nothing to do. Mode is not supported. + } + final Ignite ignite = grid(0); final CacheConfiguration ccfg = cacheConfiguration( @@ -156,14 +168,11 @@ private void checkTxCache( for (TransactionIsolation iso : TransactionIsolation.values()) { for (TransactionConcurrency con : TransactionConcurrency.values()) { - try (Transaction transaction = ignite.transactions().txStart(con, iso)) { - //TODO: IGNITE-7187: Fix when ticket will be implemented. (Near cache) - //TODO: IGNITE-7956: Fix when ticket will be implemented. (Eviction) - if (((IgniteCacheProxy)cache).context().mvccEnabled() && - ((iso != TransactionIsolation.REPEATABLE_READ && con != TransactionConcurrency.PESSIMISTIC) - || nearEnabled || useEvicPlc)) - return; // Nothing to do. Mode is not supported. + if (atomMode == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT && + !MvccFeatureChecker.isSupported(con, iso)) + continue; // Mode not supported. + try (Transaction transaction = ignite.transactions().txStart(con, iso)) { assertEquals(val, cache.get(key)); transaction.commit(); @@ -233,4 +242,4 @@ private TestClass(String data) { return S.toString(TestClass.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCrossCacheTxStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCrossCacheTxStoreSelfTest.java index 870ce675ec688..85d6b759877dc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCrossCacheTxStoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCrossCacheTxStoreSelfTest.java @@ -37,13 +37,18 @@ import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.resources.CacheStoreSessionResource; import org.apache.ignite.resources.IgniteInstanceResource; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCrossCacheTxStoreSelfTest extends GridCommonAbstractTest { /** */ private static Map firstStores = new ConcurrentHashMap<>(); @@ -61,7 +66,7 @@ public class IgniteCrossCacheTxStoreSelfTest extends GridCommonAbstractTest { CacheConfiguration cfg3 = cacheConfiguration("cacheC", new SecondStoreFactory()); CacheConfiguration cfg4 = cacheConfiguration("cacheD", null); - cfg.setCacheConfiguration(cfg1, cfg2, cfg3, cfg4); + cfg.setCacheConfiguration(cfg4, cfg2, cfg3, cfg1); return cfg; } @@ -90,8 +95,12 @@ private CacheConfiguration cacheConfiguration(String cacheName, Factory { private Ignite ignite; /** {@inheritDoc} */ - @Override public CacheStore create() { + @Override public synchronized CacheStore create() { String igniteInstanceName = ignite.name(); - CacheStore store = firstStores.get(igniteInstanceName); - - if (store == null) - store = F.addIfAbsent(firstStores, igniteInstanceName, new TestStore()); - - return store; + return firstStores.computeIfAbsent(igniteInstanceName, (k) -> new TestStore()); } } @@ -384,12 +391,7 @@ private static class SecondStoreFactory implements Factory { @Override public CacheStore create() { String igniteInstanceName = ignite.name(); - CacheStore store = secondStores.get(igniteInstanceName); - - if (store == null) - store = F.addIfAbsent(secondStores, igniteInstanceName, new TestStore()); - - return store; + return secondStores.computeIfAbsent(igniteInstanceName, (k) -> new TestStore()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteMvccTxTimeoutAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteMvccTxTimeoutAbstractTest.java new file mode 100644 index 0000000000000..f2977bcae96da --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteMvccTxTimeoutAbstractTest.java @@ -0,0 +1,139 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import java.util.Random; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.TransactionConfiguration; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import org.apache.ignite.transactions.TransactionTimeoutException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Simple cache test. + */ +@RunWith(JUnit4.class) +public class IgniteMvccTxTimeoutAbstractTest extends GridCommonAbstractTest { + /** Random number generator. */ + private static final Random RAND = new Random(); + + /** Grid count. */ + private static final int GRID_COUNT = 2; + + /** Transaction timeout. */ + private static final long TIMEOUT = 50; + + /** + * @throws Exception If failed. + */ + @Override protected void beforeTestsStarted() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-7388"); + + startGridsMultiThreaded(GRID_COUNT, true); + } + + /** + * @throws Exception If failed. + */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration c = super.getConfiguration(igniteInstanceName); + + TransactionConfiguration txCfg = c.getTransactionConfiguration(); + + txCfg.setDefaultTxTimeout(TIMEOUT); + + return c; + } + + /** + * @param i Grid index. + * @return Cache. + */ + @Override protected IgniteCache jcache(int i) { + return grid(i).cache(DEFAULT_CACHE_NAME); + } + + /** + * @throws IgniteCheckedException If test failed. + */ + @Test + public void testPessimisticRepeatableRead() throws Exception { + checkTransactionTimeout(PESSIMISTIC, REPEATABLE_READ); + } + + /** + * @param concurrency Concurrency. + * @param isolation Isolation. + * @throws IgniteCheckedException If test failed. + */ + private void checkTransactionTimeout(TransactionConcurrency concurrency, + TransactionIsolation isolation) throws Exception { + int idx = RAND.nextInt(GRID_COUNT); + + IgniteCache cache = jcache(idx); + + Transaction tx = ignite(idx).transactions().txStart(concurrency, isolation, TIMEOUT, 0); + + try { + info("Storing value in cache [key=1, val=1]"); + + cache.put(1, "1"); + + long sleep = TIMEOUT * 2; + + info("Going to sleep for (ms): " + sleep); + + Thread.sleep(sleep); + + info("Storing value in cache [key=1, val=2]"); + + cache.put(1, "2"); + + info("Committing transaction: " + tx); + + tx.commit(); + + assert false : "Timeout never happened for transaction: " + tx; + } + catch (Exception e) { + if (!(X.hasCause(e, TransactionTimeoutException.class))) + throw e; + + info("Received expected timeout exception [msg=" + e.getMessage() + ", tx=" + tx + ']'); + } + finally { + tx.close(); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java index 1d92376a3a935..68034498e21a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteNoClassOnServerAbstractTest.java @@ -30,6 +30,7 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; import static java.util.concurrent.TimeUnit.SECONDS; @@ -73,6 +74,7 @@ private IgniteConfiguration createConfiguration() { /** * @throws Exception If failed. */ + @Test public final void testNoClassOnServerNode() throws Exception { info("Run test with client: " + clientClassName()); @@ -132,4 +134,4 @@ public final void testNoClassOnServerNode() throws Exception { } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeTest.java index 4b613c2cd355c..0b05a08659000 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimisticTxSuspendResumeTest.java @@ -19,17 +19,21 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; +import java.util.IdentityHashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.Callable; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteException; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.typedef.CI1; import org.apache.ignite.internal.util.typedef.CI2; import org.apache.ignite.internal.util.typedef.PA; @@ -40,6 +44,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionTimeoutException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -54,6 +61,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteOptimisticTxSuspendResumeTest extends GridCommonAbstractTest { /** Transaction timeout. */ private static final long TX_TIMEOUT = 200; @@ -62,7 +70,13 @@ public class IgniteOptimisticTxSuspendResumeTest extends GridCommonAbstractTest private static final int FUT_TIMEOUT = 5000; /** */ - private boolean client = false; + private static final int CLIENT_CNT = 2; + + /** */ + private static final int SERVER_CNT = 4; + + /** */ + private static final int GRID_CNT = CLIENT_CNT + SERVER_CNT; /** * List of closures to execute transaction operation that prohibited in suspended state. @@ -109,6 +123,10 @@ public class IgniteOptimisticTxSuspendResumeTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + int idx = getTestIgniteInstanceIndex(igniteInstanceName); + + boolean client = idx >= SERVER_CNT && idx < GRID_CNT; + cfg.setClientMode(client); return cfg; @@ -118,16 +136,21 @@ public class IgniteOptimisticTxSuspendResumeTest extends GridCommonAbstractTest @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); - startGrids(serversNumber()); + startGridsMultiThreaded(gridCount()); + } - if (serversNumber() > 1) { - client = true; + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); - startGrid(serversNumber()); + Ignite client = ignite(gridCount() - 1); - startGrid(serversNumber() + 1); + assertTrue(client.cluster().localNode().isClient()); + + for (CacheConfiguration ccfg : cacheConfigurations()) { + grid(0).createCache(ccfg); - client = false; + client.createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); } awaitPartitionMapExchange(); @@ -138,11 +161,19 @@ public class IgniteOptimisticTxSuspendResumeTest extends GridCommonAbstractTest stopAllGrids(true); } + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + for (CacheConfiguration ccfg : cacheConfigurations()) + ignite(0).destroyCache(ccfg.getName()); + + super.afterTest(); + } + /** * @return Number of server nodes. */ - protected int serversNumber() { - return 1; + protected int gridCount() { + return GRID_CNT; } /** @@ -150,6 +181,7 @@ protected int serversNumber() { * * @throws Exception If failed. */ + @Test public void testResumeTxInAnotherThread() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -211,12 +243,13 @@ public void testResumeTxInAnotherThread() throws Exception { * * @throws Exception If failed. */ + @Test public void testCrossCacheTxInAnotherThread() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { for (TransactionIsolation isolation : TransactionIsolation.values()) { - final IgniteCache otherCache = - ignite.getOrCreateCache(cacheConfiguration(PARTITIONED, 0, false).setName("otherCache")); + final IgniteCache otherCache = ignite.getOrCreateCache( + cacheConfiguration("otherCache", PARTITIONED, 0, false)); final Transaction tx = ignite.transactions().txStart(OPTIMISTIC, isolation); @@ -271,6 +304,7 @@ public void testCrossCacheTxInAnotherThread() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxRollback() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -321,6 +355,7 @@ public void testTxRollback() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultiTxSuspendResume() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -365,6 +400,7 @@ public void testMultiTxSuspendResume() throws Exception { * * @throws Exception If failed. */ + @Test public void testOpsProhibitedOnSuspendedTxFromOtherThread() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -397,6 +433,7 @@ public void testOpsProhibitedOnSuspendedTxFromOtherThread() throws Exception { * * @throws Exception If failed. */ + @Test public void testOpsProhibitedOnSuspendedTx() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -425,6 +462,7 @@ public void testOpsProhibitedOnSuspendedTx() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxTimeoutOnResumed() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -435,10 +473,7 @@ public void testTxTimeoutOnResumed() throws Exception { tx.suspend(); - long start = U.currentTimeMillis(); - - while(TX_TIMEOUT >= U.currentTimeMillis() - start) - Thread.sleep(TX_TIMEOUT * 2); + U.sleep(TX_TIMEOUT * 2); GridTestUtils.assertThrowsWithCause(new Callable() { @Override public Object call() throws Exception { @@ -467,6 +502,7 @@ public void testTxTimeoutOnResumed() throws Exception { * * @throws Exception If failed. */ + @Test public void testTxTimeoutOnSuspend() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -475,10 +511,7 @@ public void testTxTimeoutOnSuspend() throws Exception { cache.put(1, 1); - long start = U.currentTimeMillis(); - - while(TX_TIMEOUT >= U.currentTimeMillis() - start) - Thread.sleep(TX_TIMEOUT * 2); + U.sleep(TX_TIMEOUT * 2); GridTestUtils.assertThrowsWithCause(new Callable() { @Override public Object call() throws Exception { @@ -510,6 +543,7 @@ public void testTxTimeoutOnSuspend() throws Exception { * * @throws Exception If failed. */ + @Test public void testSuspendTxAndStartNew() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -550,6 +584,7 @@ public void testSuspendTxAndStartNew() throws Exception { * * @throws Exception If failed. */ + @Test public void testSuspendTxAndStartNewWithoutCommit() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -598,34 +633,94 @@ public void testSuspendTxAndStartNewWithoutCommit() throws Exception { * * @throws Exception If failed. */ + @Test public void testSuspendTxAndResumeAfterTopologyChange() throws Exception { - executeTestForAllCaches(new CI2Exc>() { - @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { + Ignite srv = ignite(ThreadLocalRandom.current().nextInt(SERVER_CNT)); + Ignite client = ignite(SERVER_CNT); + Ignite clientNear = ignite(SERVER_CNT + 1); + + Map>> cacheKeys = generateKeys(srv, TransactionIsolation.values().length); + + doCheckSuspendTxAndResume(srv, cacheKeys); + doCheckSuspendTxAndResume(client, cacheKeys); + doCheckSuspendTxAndResume(clientNear, cacheKeys); + } + + /** + * @param node Ignite isntance. + * @param cacheKeys Different key types mapped to cache name. + * @throws Exception If failed. + */ + private void doCheckSuspendTxAndResume(Ignite node, Map>> cacheKeys) throws Exception { + ClusterNode locNode = node.cluster().localNode(); + + log.info("Run test for node [node=" + locNode.id() + ", client=" + locNode.isClient() + ']'); + + Map, Map> cacheTxMap = new IdentityHashMap<>(); + + for (Map.Entry>> cacheKeysEntry : cacheKeys.entrySet()) { + String cacheName = cacheKeysEntry.getKey(); + + IgniteCache cache = node.cache(cacheName); + + Map suspendedTxs = new IdentityHashMap<>(); + + for (List keysList : cacheKeysEntry.getValue()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { - Transaction tx = ignite.transactions().txStart(OPTIMISTIC, isolation); + Transaction tx = node.transactions().txStart(OPTIMISTIC, isolation); - cache.put(1, 1); + int key = keysList.get(isolation.ordinal()); + + cache.put(key, key); tx.suspend(); - assertEquals(SUSPENDED, tx.state()); + suspendedTxs.put(tx, key); - try (IgniteEx g = startGrid(serversNumber() + 3)) { - tx.resume(); + String msg = "node=" + node.cluster().localNode() + + ", cache=" + cacheName + ", isolation=" + isolation + ", key=" + key; - assertEquals(ACTIVE, tx.state()); + assertEquals(msg, SUSPENDED, tx.state()); + } + } - assertEquals(1, (int)cache.get(1)); + cacheTxMap.put(cache, suspendedTxs); + } - tx.commit(); + int newNodeIdx = gridCount(); - assertEquals(1, (int)cache.get(1)); - } + startGrid(newNodeIdx); - cache.removeAll(); + try { + for (Map.Entry, Map> entry : cacheTxMap.entrySet()) { + IgniteCache cache = entry.getKey(); + + for (Map.Entry suspendedTx : entry.getValue().entrySet()) { + Transaction tx = suspendedTx.getKey(); + + Integer key = suspendedTx.getValue(); + + tx.resume(); + + String msg = "node=" + node.cluster().localNode() + + ", cache=" + cache.getName() + ", isolation=" + tx.isolation() + ", key=" + key; + + assertEquals(msg, ACTIVE, tx.state()); + + assertEquals(msg, key, cache.get(key)); + + tx.commit(); + + assertEquals(msg, key, cache.get(key)); } } - }); + } + finally { + stopGrid(newNodeIdx); + + for (IgniteCache cache : cacheTxMap.keySet()) + cache.removeAll(); + } } /** @@ -633,6 +728,7 @@ public void testSuspendTxAndResumeAfterTopologyChange() throws Exception { * * @throws Exception If failed. */ + @Test public void testResumeActiveTx() throws Exception { executeTestForAllCaches(new CI2Exc>() { @Override public void applyx(Ignite ignite, final IgniteCache cache) throws Exception { @@ -666,10 +762,10 @@ public void testResumeActiveTx() throws Exception { private List> cacheConfigurations() { List> cfgs = new ArrayList<>(); - cfgs.add(cacheConfiguration(PARTITIONED, 0, false)); - cfgs.add(cacheConfiguration(PARTITIONED, 1, false)); - cfgs.add(cacheConfiguration(PARTITIONED, 1, true)); - cfgs.add(cacheConfiguration(REPLICATED, 0, false)); + cfgs.add(cacheConfiguration("cache1", PARTITIONED, 0, false)); + cfgs.add(cacheConfiguration("cache2", PARTITIONED, 1, false)); + cfgs.add(cacheConfiguration("cache3", PARTITIONED, 1, true)); + cfgs.add(cacheConfiguration("cache4", REPLICATED, 0, false)); return cfgs; } @@ -681,10 +777,11 @@ private List> cacheConfigurations() { * @return Cache configuration. */ private CacheConfiguration cacheConfiguration( + String name, CacheMode cacheMode, int backups, boolean nearCache) { - CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); + CacheConfiguration ccfg = new CacheConfiguration<>(name); ccfg.setCacheMode(cacheMode); ccfg.setAtomicityMode(TRANSACTIONAL); @@ -701,37 +798,56 @@ private CacheConfiguration cacheConfiguration( /** * @param c Closure. - * @throws Exception If failed. */ - private void executeTestForAllCaches(CI2> c) throws Exception { - for (CacheConfiguration ccfg : cacheConfigurations()) { - ignite(0).createCache(ccfg); + private void executeTestForAllCaches(CI2> c) { + for (int i = 0; i < gridCount(); i++) { + Ignite ignite = ignite(i); - log.info("Run test for cache [cache=" + ccfg.getCacheMode() + - ", backups=" + ccfg.getBackups() + - ", near=" + (ccfg.getNearConfiguration() != null) + "]"); + ClusterNode locNode = ignite.cluster().localNode(); - awaitPartitionMapExchange(); + log.info("Run test for node [node=" + locNode.id() + ", client=" + locNode.isClient() + ']'); - int srvNum = serversNumber(); - if (serversNumber() > 1) { - ignite(serversNumber() + 1).createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); - srvNum += 2; - } + for (CacheConfiguration ccfg : cacheConfigurations()) + c.apply(ignite, ignite.cache(ccfg.getName())); + } + } - try { - for (int i = 0; i < srvNum; i++) { - Ignite ignite = ignite(i); + /** + * Generates list of keys (primary, backup and neither primary nor backup). + * + * @param ignite Ignite instance. + * @param keysCnt The number of keys generated for each type of key. + * @return List of different keys mapped to cache name. + */ + private Map>> generateKeys(Ignite ignite, int keysCnt) { + Map>> cacheKeys = new HashMap<>(); - log.info("Run test for node [node=" + i + ", client=" + ignite.configuration().isClientMode() + ']'); + for (CacheConfiguration cfg : cacheConfigurations()) { + String cacheName = cfg.getName(); - c.apply(ignite, ignite.cache(ccfg.getName())); - } - } - finally { - ignite(0).destroyCache(ccfg.getName()); + IgniteCache cache = ignite.cache(cacheName); + + List> keys = new ArrayList<>(); + + // Generate different keys: 0 - primary, 1 - backup, 2 - neither primary nor backup. + for (int type = 0; type < 3; type++) { + if (type == 1 && cfg.getCacheMode() == PARTITIONED && cfg.getBackups() == 0) + continue; + + if (type == 2 && cfg.getCacheMode() == REPLICATED) + continue; + + List keys0 = findKeys(cache, keysCnt, type * 100_000, type); + + assertEquals(cacheName, keysCnt, keys0.size()); + + keys.add(keys0); } + + cacheKeys.put(cacheName, keys); } + + return cacheKeys; } /** @@ -750,7 +866,7 @@ public static abstract class CI2Exc implements CI2 { */ public abstract void applyx(E1 e1, E2 e2) throws Exception; - /** {@inheritdoc} */ + /** {@inheritDoc} */ @Override public void apply(E1 e1, E2 e2) { try { applyx(e1, e2); @@ -775,7 +891,7 @@ public static abstract class CI1Exc implements CI1 { */ public abstract void applyx(T o) throws Exception; - /** {@inheritdoc} */ + /** {@inheritDoc} */ @Override public void apply(T o) { try { applyx(o); @@ -797,7 +913,7 @@ public static abstract class RunnableX implements Runnable { */ public abstract void runx() throws Exception; - /** {@inheritdoc} */ + /** {@inheritDoc} */ @Override public void run() { try { runx(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgnitePessimisticTxSuspendResumeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgnitePessimisticTxSuspendResumeTest.java index 57a1470010578..81ec3fe4ca18b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgnitePessimisticTxSuspendResumeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgnitePessimisticTxSuspendResumeTest.java @@ -24,16 +24,21 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public class IgnitePessimisticTxSuspendResumeTest extends GridCommonAbstractTest { /** * Creates new cache configuration. @@ -63,6 +68,7 @@ protected CacheConfiguration getCacheConfiguration() { * * @throws Exception If failed. */ + @Test public void testSuspendPessimisticTx() throws Exception { try (Ignite g = startGrid()) { IgniteCache cache = jcache(); @@ -70,6 +76,10 @@ public void testSuspendPessimisticTx() throws Exception { IgniteTransactions txs = g.transactions(); for (TransactionIsolation isolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && + !MvccFeatureChecker.isSupported(TransactionConcurrency.PESSIMISTIC, isolation)) + continue; + final Transaction tx = txs.txStart(TransactionConcurrency.PESSIMISTIC, isolation); cache.put(1, "1"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteRejectConnectOnNodeStopTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteRejectConnectOnNodeStopTest.java index 97d685f225357..bd4278973b8fd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteRejectConnectOnNodeStopTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteRejectConnectOnNodeStopTest.java @@ -31,20 +31,19 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MINUTES; /** * Sanity test to check that node starts to reject connections when stop procedure started. */ +@RunWith(JUnit4.class) public class IgniteRejectConnectOnNodeStopTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -62,7 +61,7 @@ public class IgniteRejectConnectOnNodeStopTest extends GridCommonAbstractTest { discoSpi.setReconnectCount(2); discoSpi.setAckTimeout(30_000); discoSpi.setSocketTimeout(30_000); - discoSpi.setIpFinder(IP_FINDER); + discoSpi.setIpFinder(sharedStaticIpFinder); TcpCommunicationSpi commSpi = (TcpCommunicationSpi)cfg.getCommunicationSpi(); @@ -89,6 +88,7 @@ public class IgniteRejectConnectOnNodeStopTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNodeStop() throws Exception { Ignite srv = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java index bdf0b12dee21d..cfda1c2ec50cb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCachePrimarySyncTest.java @@ -54,15 +54,17 @@ import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.MvccFeatureChecker.Feature; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC; @@ -72,10 +74,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteTxCachePrimarySyncTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRVS = 4; @@ -92,8 +92,6 @@ public class IgniteTxCachePrimarySyncTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(clientMode); TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi(); @@ -133,6 +131,7 @@ public class IgniteTxCachePrimarySyncTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSingleKeyCommitFromPrimary() throws Exception { singleKeyCommitFromPrimary(cacheConfiguration(DEFAULT_CACHE_NAME, PRIMARY_SYNC, 1, true, false)); @@ -148,6 +147,16 @@ public void testSingleKeyCommitFromPrimary() throws Exception { * @throws Exception If failed. */ private void singleKeyCommitFromPrimary(CacheConfiguration ccfg) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) { + if (ccfg.getCacheStoreFactory() != null && + !MvccFeatureChecker.isSupported(Feature.CACHE_STORE)) + return; + + if (ccfg.getNearConfiguration() != null && + !MvccFeatureChecker.isSupported(Feature.NEAR_CACHE)) + return; + } + Ignite ignite = ignite(0); IgniteCache cache = ignite.createCache(ccfg); @@ -164,6 +173,9 @@ private void singleKeyCommitFromPrimary(CacheConfiguration ccfg) for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (final TransactionIsolation isolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, isolation)) + continue; + singleKeyCommitFromPrimary(node, ccfg, new IgniteBiInClosure>() { @Override public void apply(Integer key, IgniteCache cache) { Ignite ignite = cache.unwrap(Ignite.class); @@ -246,6 +258,7 @@ private void singleKeyCommitFromPrimary( /** * @throws Exception If failed. */ + @Test public void testSingleKeyPrimaryNodeFail1() throws Exception { singleKeyPrimaryNodeLeft(cacheConfiguration(DEFAULT_CACHE_NAME, PRIMARY_SYNC, 1, true, false)); @@ -255,6 +268,7 @@ public void testSingleKeyPrimaryNodeFail1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingleKeyPrimaryNodeFail2() throws Exception { singleKeyPrimaryNodeLeft(cacheConfiguration(DEFAULT_CACHE_NAME, PRIMARY_SYNC, 2, true, false)); @@ -266,12 +280,19 @@ public void testSingleKeyPrimaryNodeFail2() throws Exception { * @throws Exception If failed. */ private void singleKeyPrimaryNodeLeft(CacheConfiguration ccfg) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) { + if (ccfg.getCacheStoreFactory() != null && + !MvccFeatureChecker.isSupported(Feature.CACHE_STORE)) + return; + } + Ignite ignite = ignite(0); IgniteCache cache = ignite.createCache(ccfg); try { - ignite(NODES - 1).createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); + if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(Feature.NEAR_CACHE)) + ignite(NODES - 1).createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); for (int i = 0; i < NODES; i++) { Ignite node = ignite(i); @@ -284,6 +305,9 @@ private void singleKeyPrimaryNodeLeft(CacheConfiguration ccfg) t for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (final TransactionIsolation isolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, isolation)) + continue; + singleKeyPrimaryNodeLeft(node, ccfg, new IgniteBiInClosure>() { @Override public void apply(Integer key, IgniteCache cache) { Ignite ignite = cache.unwrap(Ignite.class); @@ -371,6 +395,7 @@ private void singleKeyPrimaryNodeLeft( /** * @throws Exception If failed. */ + @Test public void testSingleKeyCommit() throws Exception { singleKeyCommit(cacheConfiguration(DEFAULT_CACHE_NAME, PRIMARY_SYNC, 1, true, false)); @@ -386,12 +411,23 @@ public void testSingleKeyCommit() throws Exception { * @throws Exception If failed. */ private void singleKeyCommit(CacheConfiguration ccfg) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) { + if (ccfg.getCacheStoreFactory() != null && + !MvccFeatureChecker.isSupported(Feature.CACHE_STORE)) + return; + + if (ccfg.getNearConfiguration() != null && + !MvccFeatureChecker.isSupported(Feature.NEAR_CACHE)) + return; + } + Ignite ignite = ignite(0); IgniteCache cache = ignite.createCache(ccfg); try { - ignite(NODES - 1).createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); + if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(Feature.NEAR_CACHE)) + ignite(NODES - 1).createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); for (int i = 1; i < NODES; i++) { Ignite node = ignite(i); @@ -406,6 +442,9 @@ private void singleKeyCommit(CacheConfiguration ccfg) throws Exc for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (final TransactionIsolation isolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, isolation)) + continue; + singleKeyCommit(node, ccfg, new IgniteBiInClosure>() { @Override public void apply(Integer key, IgniteCache cache) { Ignite ignite = cache.unwrap(Ignite.class); @@ -513,6 +552,7 @@ private void singleKeyCommit( /** * @throws Exception If failed. */ + @Test public void testWaitPrimaryResponse() throws Exception { checkWaitPrimaryResponse(cacheConfiguration(DEFAULT_CACHE_NAME, PRIMARY_SYNC, 1, true, false)); @@ -528,12 +568,23 @@ public void testWaitPrimaryResponse() throws Exception { * @throws Exception If failed. */ private void checkWaitPrimaryResponse(CacheConfiguration ccfg) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) { + if (ccfg.getCacheStoreFactory() != null && + !MvccFeatureChecker.isSupported(Feature.CACHE_STORE)) + return; + + if (ccfg.getNearConfiguration() != null && + !MvccFeatureChecker.isSupported(Feature.NEAR_CACHE)) + return; + } + Ignite ignite = ignite(0); IgniteCache cache = ignite.createCache(ccfg); try { - ignite(NODES - 1).createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); + if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(Feature.NEAR_CACHE)) + ignite(NODES - 1).createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); for (int i = 1; i < NODES; i++) { Ignite node = ignite(i); @@ -561,6 +612,9 @@ private void checkWaitPrimaryResponse(CacheConfiguration ccfg) t for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (final TransactionIsolation isolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, isolation)) + continue; + checkWaitPrimaryResponse(node, ccfg, new IgniteBiInClosure>() { @Override public void apply(Integer key, IgniteCache cache) { Ignite ignite = cache.unwrap(Ignite.class); @@ -651,7 +705,11 @@ private void checkWaitPrimaryResponse( /** * @throws Exception If failed. */ + @Test public void testOnePhaseMessages() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + return; // Not supported. Commit flow differs for Mvcc mode. + checkOnePhaseMessages(cacheConfiguration(DEFAULT_CACHE_NAME, PRIMARY_SYNC, 1, false, false)); } @@ -678,6 +736,9 @@ private void checkOnePhaseMessages(CacheConfiguration ccfg) thro for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (final TransactionIsolation isolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, isolation)) + continue; + checkOnePhaseMessages(node, ccfg, new IgniteBiInClosure>() { @Override public void apply(Integer key, IgniteCache cache) { Ignite ignite = cache.unwrap(Ignite.class); @@ -754,18 +815,19 @@ private void checkOnePhaseMessages( /** * @throws Exception If failed. */ + @Test public void testTxSyncMode() throws Exception { Ignite ignite = ignite(0); List> caches = new ArrayList<>(); try { - caches.add(createCache(ignite, cacheConfiguration("fullSync1", FULL_SYNC, 1, false, false), true)); - caches.add(createCache(ignite, cacheConfiguration("fullSync2", FULL_SYNC, 1, false, false), true)); - caches.add(createCache(ignite, cacheConfiguration("fullAsync1", FULL_ASYNC, 1, false, false), true)); - caches.add(createCache(ignite, cacheConfiguration("fullAsync2", FULL_ASYNC, 1, false, false), true)); - caches.add(createCache(ignite, cacheConfiguration("primarySync1", PRIMARY_SYNC, 1, false, false), true)); - caches.add(createCache(ignite, cacheConfiguration("primarySync2", PRIMARY_SYNC, 1, false, false), true)); + caches.add(createCache(ignite, cacheConfiguration("fullSync1", FULL_SYNC, 1, false, false))); + caches.add(createCache(ignite, cacheConfiguration("fullSync2", FULL_SYNC, 1, false, false))); + caches.add(createCache(ignite, cacheConfiguration("fullAsync1", FULL_ASYNC, 1, false, false))); + caches.add(createCache(ignite, cacheConfiguration("fullAsync2", FULL_ASYNC, 1, false, false))); + caches.add(createCache(ignite, cacheConfiguration("primarySync1", PRIMARY_SYNC, 1, false, false))); + caches.add(createCache(ignite, cacheConfiguration("primarySync2", PRIMARY_SYNC, 1, false, false))); for (int i = 0; i < NODES; i++) { checkTxSyncMode(ignite(i), true); @@ -805,7 +867,8 @@ private void waitKeyRemoved(final String cacheName, final Object key) throws Exc * @param key Cache key. * @throws Exception If failed. */ - private void waitKeyUpdated(Ignite ignite, int expNodes, final String cacheName, final Object key) throws Exception { + private void waitKeyUpdated(Ignite ignite, int expNodes, final String cacheName, + final Object key) throws Exception { Affinity aff = ignite.affinity(cacheName); final Collection nodes = aff.mapKeyToPrimaryAndBackups(key); @@ -834,14 +897,12 @@ private void waitKeyUpdated(Ignite ignite, int expNodes, final String cacheName, /** * @param ignite Node. * @param ccfg Cache configuration. - * @param nearCache If {@code true} creates near cache on one of client nodes. * @return Created cache. */ - private IgniteCache createCache(Ignite ignite, CacheConfiguration ccfg, - boolean nearCache) { + private IgniteCache createCache(Ignite ignite, CacheConfiguration ccfg) { IgniteCache cache = ignite.createCache(ccfg); - if (nearCache) + if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(Feature.NEAR_CACHE)) ignite(NODES - 1).createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); return cache; @@ -866,6 +927,9 @@ private void checkTxSyncMode(Ignite ignite, boolean commit) { for (TransactionConcurrency concurrency : TransactionConcurrency.values()) { for (TransactionIsolation isolation : TransactionIsolation.values()) { + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, isolation)) + continue; + try (Transaction tx = txs.txStart(concurrency, isolation)) { fullSync1.put(key++, 1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java index bed8a41149a80..bdf67b87c8684 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java @@ -32,7 +32,6 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteException; -import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.store.CacheStore; import org.apache.ignite.cache.store.CacheStoreAdapter; @@ -45,14 +44,16 @@ import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionOptimisticException; import org.jetbrains.annotations.NotNull; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC; @@ -66,10 +67,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteTxCacheWriteSynchronizationModesMultithreadedTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRVS = 4; @@ -89,8 +88,6 @@ public class IgniteTxCacheWriteSynchronizationModesMultithreadedTest extends Gri @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(clientMode); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); @@ -105,29 +102,31 @@ public class IgniteTxCacheWriteSynchronizationModesMultithreadedTest extends Gri /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { - super.beforeTestsStarted(); + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9470", MvccFeatureChecker.forcedMvcc()); - System.setProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL,"true"); + super.beforeTestsStarted(); - startGrids(SRVS); + startGridsMultiThreaded(SRVS); clientMode = true; - for (int i = 0; i < CLIENTS; i++) { - Ignite client = startGrid(SRVS + i); + startGridsMultiThreaded(SRVS, CLIENTS); - assertTrue(client.configuration().isClientMode()); - } + for (int i = 0; i < CLIENTS; i++) + assertTrue(grid(SRVS + i).configuration().isClientMode()); } /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { - System.clearProperty(IgniteSystemProperties.IGNITE_ENABLE_FORCIBLE_NODE_KILL); + stopAllGrids(); + + super.afterTestsStopped(); } /** * @throws Exception If failed. */ + @Test public void testMultithreadedPrimarySyncRestart() throws Exception { multithreadedTests(PRIMARY_SYNC, true); } @@ -135,6 +134,7 @@ public void testMultithreadedPrimarySyncRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedPrimarySync() throws Exception { multithreadedTests(PRIMARY_SYNC, false); } @@ -142,6 +142,7 @@ public void testMultithreadedPrimarySync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedFullSync() throws Exception { multithreadedTests(FULL_SYNC, false); } @@ -149,6 +150,7 @@ public void testMultithreadedFullSync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedFullSyncRestart() throws Exception { multithreadedTests(FULL_SYNC, true); } @@ -156,6 +158,7 @@ public void testMultithreadedFullSyncRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedFullAsync() throws Exception { multithreadedTests(FULL_ASYNC, false); } @@ -163,6 +166,7 @@ public void testMultithreadedFullAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedFullAsyncRestart() throws Exception { multithreadedTests(FULL_ASYNC, true); } @@ -195,6 +199,14 @@ private void multithreaded(CacheWriteSynchronizationMode syncMode, boolean store, boolean nearCache, boolean restart) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) { + if (store && !MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.CACHE_STORE)) + return; + + if (nearCache && !MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE)) + return; + } + final Ignite ignite = ignite(0); createCache(ignite, cacheConfiguration(DEFAULT_CACHE_NAME, syncMode, backups, store), nearCache); @@ -271,36 +283,38 @@ private void multithreaded(CacheWriteSynchronizationMode syncMode, } }); - commitMultithreaded(new IgniteBiInClosure>() { - @Override public void apply(Ignite ignite, IgniteCache cache) { - ThreadLocalRandom rnd = ThreadLocalRandom.current(); + if (!MvccFeatureChecker.forcedMvcc()) { + commitMultithreaded(new IgniteBiInClosure>() { + @Override public void apply(Ignite ignite, IgniteCache cache) { + ThreadLocalRandom rnd = ThreadLocalRandom.current(); - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); - for (int i = 0; i < 10; i++) { - Integer key = rnd.nextInt(MULTITHREADED_TEST_KEYS); + for (int i = 0; i < 10; i++) { + Integer key = rnd.nextInt(MULTITHREADED_TEST_KEYS); - map.put(key, rnd.nextInt()); - } - - while (true) { - try (Transaction tx = ignite.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) { - for (Map.Entry e : map.entrySet()) - cache.put(e.getKey(), e.getValue()); - - tx.commit(); - - break; - } - catch (TransactionOptimisticException ignored) { - // Retry. + map.put(key, rnd.nextInt()); } - catch (CacheException | IgniteException ignored) { - break; + + while (true) { + try (Transaction tx = ignite.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) { + for (Map.Entry e : map.entrySet()) + cache.put(e.getKey(), e.getValue()); + + tx.commit(); + + break; + } + catch (TransactionOptimisticException ignored) { + // Retry. + } + catch (CacheException | IgniteException ignored) { + break; + } } } - } - }); + }); + } } finally { stop.set(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConcurrentRemoveObjectsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConcurrentRemoveObjectsTest.java new file mode 100644 index 0000000000000..76d3bc61a2deb --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConcurrentRemoveObjectsTest.java @@ -0,0 +1,178 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import java.util.UUID; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_REMOVED_ENTRIES_TTL; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; +import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE; + +/** + * + */ +@RunWith(JUnit4.class) +public class IgniteTxConcurrentRemoveObjectsTest extends GridCommonAbstractTest { + /** Cache partitions. */ + private static final int CACHE_PARTITIONS = 16; + + /** Cache entries count. */ + private static final int CACHE_ENTRIES_COUNT = 512 * CACHE_PARTITIONS; + + /** New value for {@link IgniteSystemProperties#IGNITE_CACHE_REMOVED_ENTRIES_TTL} property. */ + private static final long newIgniteCacheRemovedEntriesTtl = 50L; + + /** Old value of {@link IgniteSystemProperties#IGNITE_CACHE_REMOVED_ENTRIES_TTL} property. */ + private static long oldIgniteCacheRmvEntriesTtl; + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + oldIgniteCacheRmvEntriesTtl = Long.getLong(IGNITE_CACHE_REMOVED_ENTRIES_TTL, 10_000); + + System.setProperty(IGNITE_CACHE_REMOVED_ENTRIES_TTL, Long.toString(newIgniteCacheRemovedEntriesTtl)); + + startGrid(0); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + System.setProperty(IGNITE_CACHE_REMOVED_ENTRIES_TTL, Long.toString(oldIgniteCacheRmvEntriesTtl)); + + super.afterTestsStopped(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + grid(0).destroyCache(DEFAULT_CACHE_NAME); + + super.afterTest(); + } + + /** + * @return Cache configuration. + */ + private CacheConfiguration cacheConfiguration() { + CacheConfiguration ccfg = new CacheConfiguration<>(); + + ccfg.setName(DEFAULT_CACHE_NAME); + + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + + ccfg.setAffinity(new RendezvousAffinityFunction().setPartitions(CACHE_PARTITIONS)); + + return ccfg; + } + + /** + * @throws Exception If failed. + */ + @Test + public void testOptimisticTxLeavesObjectsInLocalPartition() throws Exception { + checkTxLeavesObjectsInLocalPartition(cacheConfiguration(), TransactionConcurrency.OPTIMISTIC, SERIALIZABLE); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPessimisticTxLeavesObjectsInLocalPartition() throws Exception { + checkTxLeavesObjectsInLocalPartition(cacheConfiguration(), TransactionConcurrency.PESSIMISTIC, SERIALIZABLE); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMvccTxLeavesObjectsInLocalPartition() throws Exception { + checkTxLeavesObjectsInLocalPartition(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT), + TransactionConcurrency.PESSIMISTIC, REPEATABLE_READ); + } + + /** + * Too many deletes in single transaction may overflow {@link GridDhtLocalPartition#rmvQueue} and entries will be + * deleted synchronously in {@link GridDhtLocalPartition#onDeferredDelete(int, KeyCacheObject, GridCacheVersion)}. + * This should not corrupt internal map state in {@link GridDhtLocalPartition}. + * + * @throws Exception If failed. + */ + public void checkTxLeavesObjectsInLocalPartition(CacheConfiguration ccfg, + TransactionConcurrency optimistic, TransactionIsolation isolation) throws Exception { + IgniteEx igniteEx = grid(0); + + igniteEx.getOrCreateCache(ccfg); + + try (IgniteDataStreamer dataStreamer = igniteEx.dataStreamer(DEFAULT_CACHE_NAME)) { + for (int i = 0; i < CACHE_ENTRIES_COUNT; i++) + dataStreamer.addData(i, UUID.randomUUID().toString()); + } + + IgniteEx client = startGrid( + getConfiguration() + .setClientMode(true) + .setIgniteInstanceName(UUID.randomUUID().toString()) + ); + + awaitPartitionMapExchange(); + + assertEquals(CACHE_ENTRIES_COUNT, client.getOrCreateCache(DEFAULT_CACHE_NAME).size()); + + try (Transaction tx = client.transactions().txStart(optimistic, isolation)) { + IgniteCache cache = client.getOrCreateCache(cacheConfiguration()); + + for (int v = 0; v < CACHE_ENTRIES_COUNT; v++) { + cache.get(v); + + cache.remove(v); + } + + tx.commit(); + } + + GridTestUtils.waitForCondition( + () -> igniteEx.context().cache().cacheGroups().stream() + .filter(CacheGroupContext::userCache) + .flatMap(cgctx -> cgctx.topology().localPartitions().stream()) + .mapToInt(GridDhtLocalPartition::internalSize) + .max().orElse(-1) == 0, + newIgniteCacheRemovedEntriesTtl * 10 + ); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConsistencyRestartAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConsistencyRestartAbstractSelfTest.java index a530cab0834d8..f775c76da9747 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConsistencyRestartAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxConsistencyRestartAbstractSelfTest.java @@ -33,11 +33,11 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -48,10 +48,8 @@ /** * */ +@RunWith(JUnit4.class) public abstract class IgniteTxConsistencyRestartAbstractSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Grid count. */ private static final int GRID_CNT = 4; @@ -62,12 +60,6 @@ public abstract class IgniteTxConsistencyRestartAbstractSelfTest extends GridCom @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName)); return cfg; @@ -105,6 +97,7 @@ public CacheConfiguration cacheConfiguration(String igniteInstanceName) { /** * @throws Exception If failed. */ + @Test public void testTxConsistency() throws Exception { startGridsMultiThreaded(GRID_CNT); @@ -208,4 +201,4 @@ public void testTxConsistency() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxGetAfterStopTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxGetAfterStopTest.java index 837763f0ecab8..0236ad2224a55 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxGetAfterStopTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxGetAfterStopTest.java @@ -24,6 +24,9 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -32,6 +35,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteTxGetAfterStopTest extends IgniteCacheAbstractTest { /** */ private CacheMode cacheMode; @@ -74,6 +78,7 @@ public class IgniteTxGetAfterStopTest extends IgniteCacheAbstractTest { /** * @throws Exception If failed. */ + @Test public void testReplicated() throws Exception { getAfterStop(REPLICATED, null); } @@ -81,6 +86,7 @@ public void testReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitioned() throws Exception { getAfterStop(PARTITIONED, new NearCacheConfiguration()); } @@ -88,6 +94,7 @@ public void testPartitioned() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionedNearDisabled() throws Exception { getAfterStop(PARTITIONED, null); } @@ -130,4 +137,4 @@ private void getAfterStop(CacheMode cacheMode, @Nullable NearCacheConfiguration assertEquals(key0, cache0.get(key0)); assertNull(cache1.get(key1)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java index a7880a2eab3ce..b1276917fc038 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java @@ -48,12 +48,16 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; /** * Abstract test for originating node failure. */ +@RunWith(JUnit4.class) public abstract class IgniteTxOriginatingNodeFailureAbstractSelfTest extends GridCacheAbstractSelfTest { /** */ protected static final int GRID_CNT = 5; @@ -67,6 +71,7 @@ public abstract class IgniteTxOriginatingNodeFailureAbstractSelfTest extends Gri /** * @throws Exception If failed. */ + @Test public void testManyKeysCommit() throws Exception { Collection keys = new ArrayList<>(200); @@ -79,6 +84,7 @@ public void testManyKeysCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testManyKeysRollback() throws Exception { Collection keys = new ArrayList<>(200); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java index 3f55e9c8e68bc..5fbe8b115276e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java @@ -61,6 +61,9 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -68,6 +71,7 @@ /** * Abstract test for originating node failure. */ +@RunWith(JUnit4.class) public abstract class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest extends GridCacheAbstractSelfTest { /** */ protected static final int GRID_CNT = 5; @@ -84,6 +88,7 @@ public abstract class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest /** * @throws Exception If failed. */ + @Test public void testManyKeysCommit() throws Exception { Collection keys = new ArrayList<>(200); @@ -96,6 +101,7 @@ public void testManyKeysCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testManyKeysRollback() throws Exception { Collection keys = new ArrayList<>(200); @@ -108,6 +114,7 @@ public void testManyKeysRollback() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryNodeFailureCommit() throws Exception { checkPrimaryNodeCrash(true); } @@ -115,6 +122,7 @@ public void testPrimaryNodeFailureCommit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryNodeFailureRollback() throws Exception { checkPrimaryNodeCrash(false); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java index c94457f942a88..26a04afc33320 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -45,6 +49,7 @@ /** * Tests transaction during cache preloading. */ +@RunWith(JUnit4.class) public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfTest { /** */ private static final int GRID_CNT = 6; @@ -77,6 +82,7 @@ public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfT /** * @throws Exception If failed. */ + @Test public void testRemoteTxPreloading() throws Exception { IgniteCache cache = jcache(0); @@ -146,13 +152,16 @@ public void testRemoteTxPreloading() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalTxPreloadingOptimistic() throws Exception { - testLocalTxPreloading(OPTIMISTIC); + if (!MvccFeatureChecker.forcedMvcc()) // Do not check optimistic tx for mvcc. + testLocalTxPreloading(OPTIMISTIC); } /** * @throws Exception If failed. */ + @Test public void testLocalTxPreloadingPessimistic() throws Exception { testLocalTxPreloading(PESSIMISTIC); } @@ -186,7 +195,7 @@ private void testLocalTxPreloading(TransactionConcurrency txConcurrency) throws IgniteTransactions txs = ignite(i).transactions(); - try (Transaction tx = txs.txStart(txConcurrency, TransactionIsolation.READ_COMMITTED)) { + try (Transaction tx = txs.txStart(txConcurrency, TransactionIsolation.REPEATABLE_READ)) { cache.invoke(TX_KEY, new EntryProcessor() { @Override public Void process(MutableEntry e, Object... args) { Integer val = e.getValue(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxRemoveTimeoutObjectsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxRemoveTimeoutObjectsTest.java index 571362143ea5f..b186b45e983e1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxRemoveTimeoutObjectsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxRemoveTimeoutObjectsTest.java @@ -32,8 +32,12 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionTimeoutException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE; @@ -41,6 +45,7 @@ /** * Test correctness of rollback a transaction with timeout during the grid stop. */ +@RunWith(JUnit4.class) public class IgniteTxRemoveTimeoutObjectsTest extends GridCacheAbstractSelfTest { /** */ private static final int PUT_CNT = 1000; @@ -55,9 +60,21 @@ public class IgniteTxRemoveTimeoutObjectsTest extends GridCacheAbstractSelfTest return 60_000; } + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-7388"); + + if (nearEnabled()) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.setUp(); + } + /** * @throws Exception If failed. */ + @Test public void testTxRemoveTimeoutObjects() throws Exception { IgniteCache cache0 = grid(0).cache(DEFAULT_CACHE_NAME); IgniteCache cache1 = grid(1).cache(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java index a0ec70a9c3519..6bcee94add948 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java @@ -17,18 +17,20 @@ package org.apache.ignite.internal.processors.cache.distributed; -import java.util.ArrayList; -import java.util.List; import java.util.Random; -import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionTimeoutException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -39,6 +41,7 @@ /** * Simple cache test. */ +@RunWith(JUnit4.class) public class IgniteTxTimeoutAbstractTest extends GridCommonAbstractTest { /** Random number generator. */ private static final Random RAND = new Random(); @@ -46,9 +49,6 @@ public class IgniteTxTimeoutAbstractTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_COUNT = 2; - /** Grid instances. */ - private static final List IGNITEs = new ArrayList<>(); - /** Transaction timeout. */ private static final long TIMEOUT = 50; @@ -56,15 +56,25 @@ public class IgniteTxTimeoutAbstractTest extends GridCommonAbstractTest { * @throws Exception If failed. */ @Override protected void beforeTestsStarted() throws Exception { - for (int i = 0; i < GRID_COUNT; i++) - IGNITEs.add(startGrid(i)); + startGridsMultiThreaded(GRID_COUNT); } /** * @throws Exception If failed. */ @Override protected void afterTestsStopped() throws Exception { - IGNITEs.clear(); + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration c = super.getConfiguration(igniteInstanceName); + + TransactionConfiguration txCfg = c.getTransactionConfiguration(); + + txCfg.setDefaultTxTimeout(TIMEOUT); + + return c; } /** @@ -72,12 +82,13 @@ public class IgniteTxTimeoutAbstractTest extends GridCommonAbstractTest { * @return Cache. */ @Override protected IgniteCache jcache(int i) { - return IGNITEs.get(i).cache(DEFAULT_CACHE_NAME); + return grid(i).cache(DEFAULT_CACHE_NAME); } /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticReadCommitted() throws Exception { checkTransactionTimeout(PESSIMISTIC, READ_COMMITTED); } @@ -85,6 +96,7 @@ public void testPessimisticReadCommitted() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticRepeatableRead() throws Exception { checkTransactionTimeout(PESSIMISTIC, REPEATABLE_READ); } @@ -92,6 +104,7 @@ public void testPessimisticRepeatableRead() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticSerializable() throws Exception { checkTransactionTimeout(PESSIMISTIC, SERIALIZABLE); } @@ -99,6 +112,7 @@ public void testPessimisticSerializable() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticReadCommitted() throws Exception { checkTransactionTimeout(OPTIMISTIC, READ_COMMITTED); } @@ -106,6 +120,7 @@ public void testOptimisticReadCommitted() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticRepeatableRead() throws Exception { checkTransactionTimeout(OPTIMISTIC, REPEATABLE_READ); } @@ -113,6 +128,7 @@ public void testOptimisticRepeatableRead() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticSerializable() throws Exception { checkTransactionTimeout(OPTIMISTIC, SERIALIZABLE); } @@ -124,7 +140,6 @@ public void testOptimisticSerializable() throws Exception { */ private void checkTransactionTimeout(TransactionConcurrency concurrency, TransactionIsolation isolation) throws Exception { - int idx = RAND.nextInt(GRID_COUNT); IgniteCache cache = jcache(idx); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheGetReadFromBackupFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheGetReadFromBackupFailoverTest.java new file mode 100644 index 0000000000000..8fc5ac8cf0cd3 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheGetReadFromBackupFailoverTest.java @@ -0,0 +1,255 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.dht; + +import java.util.Collections; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.IgniteIllegalStateException; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.failure.AbstractFailureHandler; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgniteNodeAttributes; +import org.apache.ignite.internal.NodeStoppingException; +import org.apache.ignite.internal.processors.cache.GridCacheFuture; +import org.apache.ignite.internal.processors.cache.GridCacheMvccManager; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; + +/** + * Test for getting values on unstable topology with read from backup enabled. + */ +@RunWith(JUnit4.class) +public class CacheGetReadFromBackupFailoverTest extends GridCommonAbstractTest { + /** Tx cache name. */ + private static final String TX_CACHE = "txCache"; + /** Atomic cache name. */ + private static final String ATOMIC_CACHE = "atomicCache"; + /** Keys count. */ + private static final int KEYS_CNT = 50000; + /** Stop load flag. */ + private static final AtomicBoolean stop = new AtomicBoolean(); + /** Error. */ + private static final AtomicReference err = new AtomicReference<>(); + + /** + * @return Grid count. + */ + public int gridCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setFailureHandler(new AbstractFailureHandler() { + @Override protected boolean handle(Ignite ignite, FailureContext failureCtx) { + err.compareAndSet(null, failureCtx.error()); + stop.set(true); + return false; + } + }); + + cfg.setConsistentId(igniteInstanceName); + + CacheConfiguration txCcfg = new CacheConfiguration(TX_CACHE) + .setAtomicityMode(TRANSACTIONAL) + .setCacheMode(PARTITIONED) + .setBackups(1) + .setWriteSynchronizationMode(FULL_SYNC) + .setReadFromBackup(true); + + CacheConfiguration atomicCcfg = new CacheConfiguration(ATOMIC_CACHE) + .setAtomicityMode(ATOMIC) + .setCacheMode(PARTITIONED) + .setBackups(1) + .setWriteSynchronizationMode(FULL_SYNC) + .setReadFromBackup(true); + + cfg.setCacheConfiguration(txCcfg, atomicCcfg); + + // Enforce different mac adresses to emulate distributed environment by default. + cfg.setUserAttributes(Collections.singletonMap( + IgniteNodeAttributes.ATTR_MACS_OVERRIDE, UUID.randomUUID().toString())); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + stop.set(false); + + err.set(null); + + startGrids(gridCount()); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testFailover() throws Exception { + Ignite ignite = ignite(0); + + ignite.cluster().active(true); + + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + try (IgniteDataStreamer stmr = ignite.dataStreamer(TX_CACHE)) { + for (int i = 0; i < KEYS_CNT; i++) + stmr.addData(i, rnd.nextLong()); + } + + try (IgniteDataStreamer stmr = ignite.dataStreamer(ATOMIC_CACHE)) { + for (int i = 0; i < KEYS_CNT; i++) + stmr.addData(i, rnd.nextLong()); + } + + AtomicInteger idx = new AtomicInteger(-1); + + AtomicInteger successGet = new AtomicInteger(); + + IgniteInternalFuture fut = GridTestUtils.runAsync(() -> { + ThreadLocalRandom rnd0 = ThreadLocalRandom.current(); + + while (!stop.get()) { + Ignite ig = null; + + while (ig == null) { + int n = rnd0.nextInt(gridCount()); + + if (idx.get() != n) { + try { + ig = ignite(n); + } + catch (IgniteIllegalStateException e) { + // No-op. + } + } + } + + try { + if (rnd.nextBoolean()) { + ig.cache(TX_CACHE).get(rnd0.nextLong(KEYS_CNT)); + ig.cache(ATOMIC_CACHE).get(rnd0.nextLong(KEYS_CNT)); + } + else { + ig.cache(TX_CACHE).getAll(rnd.longs(16, 0, KEYS_CNT).boxed().collect(Collectors.toSet())); + ig.cache(ATOMIC_CACHE).getAll(rnd.longs(16, 0, KEYS_CNT).boxed().collect(Collectors.toSet())); + } + + successGet.incrementAndGet(); + } + catch (CacheException e) { + if (!X.hasCause(e, NodeStoppingException.class)) + throw e; + } + + } + }, "load-thread"); + + long startTime = System.currentTimeMillis(); + + while (System.currentTimeMillis() - startTime < 30 * 1000L) { + int idx0 = idx.get(); + + if (idx0 >= 0) + startGrid(idx0); + + U.sleep(500); + + int next = rnd.nextInt(gridCount()); + + idx.set(next); + + stopGrid(next); + + U.sleep(500); + } + + stop.set(true); + + while (true){ + try { + fut.get(10_000); + + break; + } + catch (IgniteFutureTimeoutCheckedException e) { + for (Ignite i : G.allGrids()) { + IgniteEx ex = (IgniteEx)i; + + log.info(">>>> " + ex.context().localNodeId()); + + GridCacheMvccManager mvcc = ex.context().cache().context().mvcc(); + + for (GridCacheFuture fut0 : mvcc.activeFutures()) { + log.info("activeFut - " + fut0); + } + + for (GridCacheFuture fut0 : mvcc.atomicFutures()) { + log.info("atomicFut - " + fut0); + } + } + } + } + + Assert.assertTrue(String.valueOf(successGet.get()), successGet.get() > 50); + + Throwable e = err.get(); + + if (e != null) { + log.error("Test failed", e); + + fail("Test failed"); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/CachePartitionPartialCountersMapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/CachePartitionPartialCountersMapSelfTest.java index a4afbcace876b..5f4f4d9b6fa04 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/CachePartitionPartialCountersMapSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/CachePartitionPartialCountersMapSelfTest.java @@ -19,9 +19,15 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +/** */ +@RunWith(JUnit4.class) public class CachePartitionPartialCountersMapSelfTest extends GridCommonAbstractTest { - + /** */ + @Test public void testAddAndRemove() throws Exception { CachePartitionPartialCountersMap map = new CachePartitionPartialCountersMap(10); @@ -54,4 +60,14 @@ public void testAddAndRemove() throws Exception { } } -} \ No newline at end of file + /** */ + public void testEmptyMap() throws Exception { + CachePartitionPartialCountersMap map = CachePartitionPartialCountersMap.EMPTY; + + assertFalse(map.remove(1)); + + map.trim(); + + assertNotNull(map.toString()); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest.java index 86738f5211662..5ed637baf3370 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest.java @@ -17,11 +17,15 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; +import java.util.Arrays; import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheAbstractPartitionedByteArrayValuesSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.junit.Assert.assertArrayEquals; @@ -29,13 +33,11 @@ /** * Tests for byte array values in PARTITIONED-ONLY caches. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest extends GridCacheAbstractPartitionedByteArrayValuesSelfTest { - /** Offheap cache name. */ - protected static final String CACHE_ATOMIC = "cache_atomic"; - - /** Offheap cache name. */ - protected static final String CACHE_ATOMIC_OFFHEAP = "cache_atomic_offheap"; + /** */ + public static final String ATOMIC_CACHE = "atomicCache"; /** Atomic caches. */ private static IgniteCache[] cachesAtomic; @@ -46,10 +48,16 @@ public abstract class GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest ex CacheConfiguration atomicCacheCfg = cacheConfiguration0(); - atomicCacheCfg.setName(CACHE_ATOMIC); + atomicCacheCfg.setName(ATOMIC_CACHE); atomicCacheCfg.setAtomicityMode(ATOMIC); - c.setCacheConfiguration(cacheConfiguration(), atomicCacheCfg); + int size = c.getCacheConfiguration().length; + + CacheConfiguration[] configs = Arrays.copyOf(c.getCacheConfiguration(), size + 1); + + configs[size] = atomicCacheCfg; + + c.setCacheConfiguration(configs); c.setPeerClassLoadingEnabled(peerClassLoading()); @@ -71,7 +79,7 @@ public abstract class GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest ex cachesAtomic = new IgniteCache[gridCnt]; for (int i = 0; i < gridCount(); i++) - cachesAtomic[i] = ignites[i].cache(CACHE_ATOMIC); + cachesAtomic[i] = grid(i).cache(ATOMIC_CACHE); } /** {@inheritDoc} */ @@ -86,6 +94,7 @@ public abstract class GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest ex * * @throws Exception If failed. */ + @Test public void testAtomic() throws Exception { testAtomic0(cachesAtomic); } @@ -110,4 +119,4 @@ private void testAtomic0(IgniteCache[] caches) throws Exception assertNull(cache.get(KEY_1)); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java index 34c96fd999394..0b9b16f05b3b2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java @@ -28,12 +28,13 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheGenericTestStore; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -44,6 +45,7 @@ /** * Tests write-through. */ +@RunWith(JUnit4.class) public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends GridCommonAbstractTest { /** Grid count. */ protected static final int GRID_CNT = 3; @@ -66,9 +68,6 @@ public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends Gri /** Keys number. */ public static final int KEYS_CNT = 30; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Value increment processor. */ private static final EntryProcessor INCR_CLOS = new EntryProcessor() { @Override public Void process(MutableEntry e, Object... args) { @@ -104,12 +103,6 @@ public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends Gri @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - GridCacheGenericTestStore store = new GridCacheGenericTestStore<>(); stores.add(store); @@ -132,6 +125,8 @@ public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends Gri /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + super.beforeTestsStarted(); for (int i = 0; i < GRID_CNT; i++) @@ -147,6 +142,8 @@ public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends Gri /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + super.beforeTest(); for (GridCacheGenericTestStore store : stores) @@ -156,6 +153,7 @@ public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends Gri /** * @throws Exception If failed. */ + @Test public void testTransformOptimisticNearUpdate() throws Exception { checkTransform(OPTIMISTIC, NEAR_NODE, OP_UPDATE); } @@ -163,6 +161,7 @@ public void testTransformOptimisticNearUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformOptimisticPrimaryUpdate() throws Exception { checkTransform(OPTIMISTIC, PRIMARY_NODE, OP_UPDATE); } @@ -170,6 +169,7 @@ public void testTransformOptimisticPrimaryUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformOptimisticBackupUpdate() throws Exception { checkTransform(OPTIMISTIC, BACKUP_NODE, OP_UPDATE); } @@ -177,6 +177,7 @@ public void testTransformOptimisticBackupUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformOptimisticNearDelete() throws Exception { checkTransform(OPTIMISTIC, NEAR_NODE, OP_DELETE); } @@ -184,6 +185,7 @@ public void testTransformOptimisticNearDelete() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformOptimisticPrimaryDelete() throws Exception { checkTransform(OPTIMISTIC, PRIMARY_NODE, OP_DELETE); } @@ -191,6 +193,7 @@ public void testTransformOptimisticPrimaryDelete() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformOptimisticBackupDelete() throws Exception { checkTransform(OPTIMISTIC, BACKUP_NODE, OP_DELETE); } @@ -198,6 +201,7 @@ public void testTransformOptimisticBackupDelete() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPessimisticNearUpdate() throws Exception { checkTransform(PESSIMISTIC, NEAR_NODE, OP_UPDATE); } @@ -205,6 +209,7 @@ public void testTransformPessimisticNearUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPessimisticPrimaryUpdate() throws Exception { checkTransform(PESSIMISTIC, PRIMARY_NODE, OP_UPDATE); } @@ -212,6 +217,7 @@ public void testTransformPessimisticPrimaryUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPessimisticBackupUpdate() throws Exception { checkTransform(PESSIMISTIC, BACKUP_NODE, OP_UPDATE); } @@ -219,6 +225,7 @@ public void testTransformPessimisticBackupUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPessimisticNearDelete() throws Exception { checkTransform(PESSIMISTIC, NEAR_NODE, OP_DELETE); } @@ -226,6 +233,7 @@ public void testTransformPessimisticNearDelete() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPessimisticPrimaryDelete() throws Exception { checkTransform(PESSIMISTIC, PRIMARY_NODE, OP_DELETE); } @@ -233,6 +241,7 @@ public void testTransformPessimisticPrimaryDelete() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformPessimisticBackupDelete() throws Exception { checkTransform(PESSIMISTIC, BACKUP_NODE, OP_DELETE); } @@ -334,4 +343,4 @@ else if (nodeType == BACKUP_NODE) { return keys; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java index b027aead6e6a1..b83e1c1a83402 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java @@ -27,12 +27,16 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedFullApiSelfTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; /** * Multi node test for disabled near cache. */ +@RunWith(JUnit4.class) public class GridCacheAtomicFullApiSelfTest extends GridCachePartitionedFullApiSelfTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { @@ -57,6 +61,7 @@ public class GridCacheAtomicFullApiSelfTest extends GridCachePartitionedFullApiS /** * @throws Exception If failed. */ + @Test public void testLock() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -74,6 +79,7 @@ public void testLock() throws Exception { /** * @throws Exception In case of error. */ + @Test @Override public void testGetAll() throws Exception { jcache().put("key1", 1); jcache().put("key2", 2); @@ -108,4 +114,4 @@ public void testLock() throws Exception { assertEquals(2, (int)map2.get("key2")); assertNull(map2.get("key9999")); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java index 687a1bfc28066..1ae62a505de43 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java @@ -45,6 +45,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -55,6 +58,7 @@ /** * Tests near cache with various atomic cache configuration. */ +@RunWith(JUnit4.class) public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 4; @@ -100,6 +104,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNoBackups() throws Exception { doStartGrids(0); @@ -109,6 +114,7 @@ public void testNoBackups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithBackups() throws Exception { doStartGrids(2); @@ -822,4 +828,4 @@ private Processor(Integer newVal) { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java index 282b79219f412..a19af9f4cc49f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java @@ -42,13 +42,13 @@ import org.apache.ignite.internal.processors.cache.GridCacheTestStore; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -60,10 +60,8 @@ /** * Tests for colocated cache. */ +@RunWith(JUnit4.class) public class GridCacheColocatedDebugTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Test thread count. */ private static final int THREAD_CNT = 10; @@ -75,12 +73,6 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); @@ -106,6 +98,7 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSimplestPessimistic() throws Exception { checkSinglePut(false, PESSIMISTIC, REPEATABLE_READ); } @@ -113,6 +106,7 @@ public void testSimplestPessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleOptimistic() throws Exception { checkSinglePut(true, OPTIMISTIC, REPEATABLE_READ); } @@ -120,6 +114,7 @@ public void testSimpleOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReentry() throws Exception { checkReentry(PESSIMISTIC, REPEATABLE_READ); } @@ -127,6 +122,7 @@ public void testReentry() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedInTxSeparatePessimistic() throws Exception { checkDistributedPut(true, true, PESSIMISTIC, REPEATABLE_READ); } @@ -134,6 +130,7 @@ public void testDistributedInTxSeparatePessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedInTxPessimistic() throws Exception { checkDistributedPut(true, false, PESSIMISTIC, REPEATABLE_READ); } @@ -141,6 +138,7 @@ public void testDistributedInTxPessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedSeparatePessimistic() throws Exception { checkDistributedPut(false, true, PESSIMISTIC, REPEATABLE_READ); } @@ -148,6 +146,7 @@ public void testDistributedSeparatePessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedPessimistic() throws Exception { checkDistributedPut(false, false, PESSIMISTIC, REPEATABLE_READ); } @@ -155,6 +154,7 @@ public void testDistributedPessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedNonLocalInTxSeparatePessimistic() throws Exception { checkNonLocalPuts(true, true, PESSIMISTIC, REPEATABLE_READ); } @@ -162,6 +162,7 @@ public void testDistributedNonLocalInTxSeparatePessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedNonLocalInTxPessimistic() throws Exception { checkNonLocalPuts(true, false, PESSIMISTIC, REPEATABLE_READ); } @@ -169,6 +170,7 @@ public void testDistributedNonLocalInTxPessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedNonLocalSeparatePessimistic() throws Exception { checkNonLocalPuts(false, true, PESSIMISTIC, REPEATABLE_READ); } @@ -176,6 +178,7 @@ public void testDistributedNonLocalSeparatePessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedNonLocalPessimistic() throws Exception { checkNonLocalPuts(false, false, PESSIMISTIC, REPEATABLE_READ); } @@ -183,6 +186,7 @@ public void testDistributedNonLocalPessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollbackSeparatePessimistic() throws Exception { checkRollback(true, PESSIMISTIC, REPEATABLE_READ); } @@ -190,6 +194,7 @@ public void testRollbackSeparatePessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedInTxSeparateOptimistic() throws Exception { checkDistributedPut(true, true, OPTIMISTIC, REPEATABLE_READ); } @@ -197,6 +202,7 @@ public void testDistributedInTxSeparateOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedInTxOptimistic() throws Exception { checkDistributedPut(true, false, OPTIMISTIC, REPEATABLE_READ); } @@ -204,6 +210,7 @@ public void testDistributedInTxOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedNonLocalInTxSeparateOptimistic() throws Exception { checkNonLocalPuts(true, true, OPTIMISTIC, REPEATABLE_READ); } @@ -211,6 +218,7 @@ public void testDistributedNonLocalInTxSeparateOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedNonLocalInTxOptimistic() throws Exception { checkNonLocalPuts(true, false, OPTIMISTIC, REPEATABLE_READ); } @@ -218,6 +226,7 @@ public void testDistributedNonLocalInTxOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollbackSeparateOptimistic() throws Exception { checkRollback(true, OPTIMISTIC, REPEATABLE_READ); } @@ -225,6 +234,7 @@ public void testRollbackSeparateOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRollback() throws Exception { checkRollback(false, PESSIMISTIC, REPEATABLE_READ); } @@ -232,6 +242,7 @@ public void testRollback() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutsMultithreadedColocated() throws Exception { checkPutsMultithreaded(true, false, 100000); } @@ -239,6 +250,7 @@ public void testPutsMultithreadedColocated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutsMultithreadedRemote() throws Exception { checkPutsMultithreaded(false, true, 100000); } @@ -246,6 +258,7 @@ public void testPutsMultithreadedRemote() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutsMultithreadedMixed() throws Exception { checkPutsMultithreaded(true, true, 100000); } @@ -352,6 +365,7 @@ public void checkPutsMultithreaded(boolean loc, boolean remote, final long maxIt /** * @throws Exception If failed. */ + @Test public void testLockLockedLocal() throws Exception { checkLockLocked(true); } @@ -359,6 +373,7 @@ public void testLockLockedLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockLockedRemote() throws Exception { checkLockLocked(false); } @@ -430,6 +445,7 @@ private void checkLockLocked(boolean loc) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticGet() throws Exception { storeEnabled = false; @@ -711,6 +727,7 @@ private void checkNonLocalPuts(boolean explicitTx, boolean separate, Transaction /** * @throws Exception If failed. */ + @Test public void testWriteThrough() throws Exception { storeEnabled = true; @@ -897,6 +914,7 @@ private void checkRollback(boolean separate, TransactionConcurrency concurrency, /** * @throws Exception If failed. */ + @Test public void testExplicitLocks() throws Exception { storeEnabled = false; @@ -923,6 +941,7 @@ public void testExplicitLocks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExplicitLocksDistributed() throws Exception { storeEnabled = false; @@ -989,4 +1008,4 @@ private static Integer forPrimary(Ignite g, int prev) { throw new IllegalArgumentException("Can not find key being primary for node: " + g.cluster().localNode().id()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedMvccTxSingleThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedMvccTxSingleThreadedSelfTest.java new file mode 100644 index 0000000000000..717d77113413f --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedMvccTxSingleThreadedSelfTest.java @@ -0,0 +1,85 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.dht; + +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.cache.IgniteMvccTxSingleThreadedAbstractTest; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheRebalanceMode.NONE; + +/** + * Test Mvcc txs in single-threaded mode for colocated cache. + */ +public class GridCacheColocatedMvccTxSingleThreadedSelfTest extends IgniteMvccTxSingleThreadedAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + CacheConfiguration ccfg = defaultCacheConfiguration(); + + ccfg.setCacheMode(PARTITIONED); + ccfg.setBackups(1); + ccfg.setNearConfiguration(null); + ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + + ccfg.setEvictionPolicy(null); + + ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC); + + ccfg.setRebalanceMode(NONE); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 4; + } + + /** {@inheritDoc} */ + @Override protected int keyCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int maxKeyValue() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int iterations() { + return 3000; + } + + /** {@inheritDoc} */ + @Override protected boolean isTestDebug() { + return false; + } + + /** {@inheritDoc} */ + @Override protected boolean printMemoryStats() { + return true; + } + +} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedOptimisticTransactionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedOptimisticTransactionSelfTest.java index 5ed6b38cc01c0..fa87637b382a8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedOptimisticTransactionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedOptimisticTransactionSelfTest.java @@ -22,11 +22,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,6 +37,7 @@ /** * Test ensuring that values are visible inside OPTIMISTIC transaction in co-located cache. */ +@RunWith(JUnit4.class) public class GridCacheColocatedOptimisticTransactionSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 3; @@ -50,9 +51,6 @@ public class GridCacheColocatedOptimisticTransactionSelfTest extends GridCommonA /** Value. */ private static final String VAL = "val"; - /** Shared IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Grids. */ private static Ignite[] ignites; @@ -65,10 +63,6 @@ public class GridCacheColocatedOptimisticTransactionSelfTest extends GridCommonA c.getTransactionConfiguration().setTxSerializableEnabled(true); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - CacheConfiguration cc = new CacheConfiguration(DEFAULT_CACHE_NAME); cc.setName(CACHE); @@ -78,7 +72,6 @@ public class GridCacheColocatedOptimisticTransactionSelfTest extends GridCommonA cc.setBackups(1); cc.setWriteSynchronizationMode(FULL_SYNC); - c.setDiscoverySpi(disco); c.setCacheConfiguration(cc); return c; @@ -110,6 +103,7 @@ public class GridCacheColocatedOptimisticTransactionSelfTest extends GridCommonA * * @throws Exception If failed. */ + @Test public void testOptimisticTransaction() throws Exception { for (IgniteCache cache : caches) { Transaction tx = cache.unwrap(Ignite.class).transactions().txStart(OPTIMISTIC, REPEATABLE_READ); @@ -148,4 +142,4 @@ public void testOptimisticTransaction() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxSingleThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxSingleThreadedSelfTest.java index c55a606d20068..90502dafe4dcc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxSingleThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxSingleThreadedSelfTest.java @@ -22,9 +22,6 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.IgniteTxSingleThreadedAbstractTest; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.log4j.Level; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -38,9 +35,6 @@ public class GridCacheColocatedTxSingleThreadedSelfTest extends IgniteTxSingleTh /** Cache debug flag. */ private static final boolean CACHE_DEBUG = false; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @SuppressWarnings({"ConstantConditions"}) @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -61,12 +55,6 @@ public class GridCacheColocatedTxSingleThreadedSelfTest extends IgniteTxSingleTh cc.setRebalanceMode(NONE); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - c.setCacheConfiguration(cc); if (CACHE_DEBUG) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java index 7767da9721017..9f834d907f47e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java @@ -34,11 +34,12 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -46,23 +47,15 @@ /** * Unit tests for dht entry. */ +@RunWith(JUnit4.class) public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 2; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); @@ -78,12 +71,16 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + startGridsMultiThreaded(GRID_CNT); } /** {@inheritDoc} */ @SuppressWarnings({"SizeReplaceableByIsEmpty"}) @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + for (int i = 0; i < GRID_CNT; i++) { assert near(grid(i)).size() == 0 : "Near cache size is not zero for grid: " + i; assert dht(grid(i)).size() == 0 : "DHT cache size is not zero for grid: " + i; @@ -94,7 +91,6 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ - @SuppressWarnings({"SizeReplaceableByIsEmpty"}) @Override protected void afterTest() throws Exception { for (int i = 0; i < GRID_CNT; i++) { near(grid(i)).removeAll(); @@ -126,7 +122,7 @@ private IgniteCache near(Ignite g) { * @param g Grid. * @return Dht cache. */ - @SuppressWarnings({"unchecked", "TypeMayBeWeakened"}) + @SuppressWarnings({"unchecked"}) private GridDhtCacheAdapter dht(Ignite g) { return ((GridNearCacheAdapter)((IgniteKernal)g).internalCache(DEFAULT_CACHE_NAME)).dht(); } @@ -140,6 +136,7 @@ private Ignite grid(UUID nodeId) { } /** @throws Exception If failed. */ + @Test public void testClearWithReaders() throws Exception { Integer key = 1; @@ -188,6 +185,7 @@ public void testClearWithReaders() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRemoveWithReaders() throws Exception { Integer key = 1; @@ -236,7 +234,7 @@ public void testRemoveWithReaders() throws Exception { } /** @throws Exception If failed. */ - @SuppressWarnings({"AssertWithSideEffects"}) + @Test public void testEvictWithReaders() throws Exception { Integer key = 1; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java index 36da261d331ef..427bbf7d794c2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java @@ -37,10 +37,10 @@ import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -50,13 +50,11 @@ /** * Tests for dht cache eviction. */ +@RunWith(JUnit4.class) public class GridCacheDhtEvictionNearReadersSelfTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 4; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Default constructor. */ public GridCacheDhtEvictionNearReadersSelfTest() { super(false /* don't start grid. */); @@ -66,12 +64,6 @@ public GridCacheDhtEvictionNearReadersSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); @@ -188,6 +180,7 @@ private IgnitePredicate nodeEvent(final UUID nodeId) { * * @throws Exception If failed. */ + @Test public void testReaders() throws Exception { Integer key = 1; @@ -280,4 +273,4 @@ public void testReaders() throws Exception { assertNull(localPeek(dhtOther, key)); assertNull(localPeek(nearOther, key)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java index d31015d9e419d..00ed47c299df1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java @@ -21,10 +21,10 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -33,10 +33,8 @@ /** * Test cache closure execution. */ +@RunWith(JUnit4.class) public class GridCacheDhtEvictionsDisabledSelfTest extends GridCommonAbstractTest { - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -48,12 +46,6 @@ public GridCacheDhtEvictionsDisabledSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setName("test"); @@ -73,6 +65,7 @@ public GridCacheDhtEvictionsDisabledSelfTest() { } /** @throws Exception If failed. */ + @Test public void testOneNode() throws Exception { checkNodes(startGridsMultiThreaded(1)); @@ -81,6 +74,7 @@ public void testOneNode() throws Exception { } /** @throws Exception If failed. */ + @Test public void testTwoNodes() throws Exception { checkNodes(startGridsMultiThreaded(2)); @@ -89,6 +83,7 @@ public void testTwoNodes() throws Exception { } /** @throws Exception If failed. */ + @Test public void testThreeNodes() throws Exception { checkNodes(startGridsMultiThreaded(3)); @@ -124,4 +119,4 @@ private void checkNodes(Ignite g) throws Exception { assertEquals(v1, v2); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMappingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMappingSelfTest.java index bd0af345fed34..36e2aa55b226b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMappingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMappingSelfTest.java @@ -24,10 +24,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -36,12 +37,15 @@ /** * Tests dht mapping. */ +@RunWith(JUnit4.class) public class GridCacheDhtMappingSelfTest extends GridCommonAbstractTest { /** Number of key backups. */ private static final int BACKUPS = 1; - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + } /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -55,17 +59,13 @@ public class GridCacheDhtMappingSelfTest extends GridCommonAbstractTest { cacheCfg.setBackups(BACKUPS); cacheCfg.setAtomicityMode(TRANSACTIONAL); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); cfg.setCacheConfiguration(cacheCfg); return cfg; } /** @throws Exception If failed. */ + @Test public void testMapping() throws Exception { int nodeCnt = 5; @@ -95,4 +95,4 @@ public void testMapping() throws Exception { // Test key should be on primary and backup node only. assertEquals(1 + BACKUPS, cnt); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMultiBackupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMultiBackupTest.java index e1e5315dda4d3..1f5bc28bbe165 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMultiBackupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMultiBackupTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheDhtMultiBackupTest extends GridCommonAbstractTest { /** * @@ -41,6 +45,7 @@ public GridCacheDhtMultiBackupTest() { /** * @throws Exception If failed */ + @Test public void testPut() throws Exception { try { Ignite g = G.start("examples/config/example-cache.xml"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java index 86dbd4fb86d89..5b4fcc02a8f6b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java @@ -27,10 +27,10 @@ import org.apache.ignite.lifecycle.LifecycleBean; import org.apache.ignite.lifecycle.LifecycleEventType; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; @@ -42,6 +42,7 @@ /** * Test large cache counts. */ +@RunWith(JUnit4.class) public class GridCacheDhtPreloadBigDataSelfTest extends GridCommonAbstractTest { /** Size of values in KB. */ private static final int KBSIZE = 10 * 1024; @@ -70,9 +71,6 @@ public class GridCacheDhtPreloadBigDataSelfTest extends GridCommonAbstractTest { /** */ private LifecycleBean lbean; - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -93,14 +91,9 @@ public GridCacheDhtPreloadBigDataSelfTest() { cc.setAffinity(new RendezvousAffinityFunction(false, partitions)); cc.setBackups(backups); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - if (lbean != null) c.setLifecycleBeans(lbean); - c.setDiscoverySpi(disco); c.setCacheConfiguration(cc); c.setDeploymentMode(CONTINUOUS); c.setNetworkTimeout(1000); @@ -125,6 +118,7 @@ public GridCacheDhtPreloadBigDataSelfTest() { /** * @throws Exception If failed. */ + @Test public void testLargeObjects() throws Exception { preloadMode = SYNC; @@ -159,6 +153,7 @@ public void testLargeObjects() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLargeObjectsWithLifeCycleBean() throws Exception { preloadMode = SYNC; partitions = 23; @@ -230,4 +225,4 @@ private byte[] value(int size) { @Override protected long getTestTimeout() { return 6 * 60 * 1000; // 6 min. } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java index 9941d58af0dae..f3c627637b716 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java @@ -35,6 +35,7 @@ import org.apache.ignite.events.Event; import org.apache.ignite.events.EventType; import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader; @@ -45,11 +46,11 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -60,6 +61,7 @@ /** * Test cases for partitioned cache {@link GridDhtPreloader preloader}. */ +@RunWith(JUnit4.class) public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest { /** Key count. */ private static final int KEY_CNT = 100; @@ -73,9 +75,6 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest { /** Preload delay. */ private long delay = -1; - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -92,11 +91,6 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest { cc.setBackups(1); cc.setAtomicityMode(TRANSACTIONAL); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); c.setCacheConfiguration(cc); return c; @@ -110,6 +104,7 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testManualPreload() throws Exception { delay = -1; @@ -189,6 +184,7 @@ public void testManualPreload() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDelayedPreload() throws Exception { delay = PRELOAD_DELAY; @@ -260,6 +256,7 @@ public void testDelayedPreload() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAutomaticPreload() throws Exception { delay = 0; preloadMode = CacheRebalanceMode.SYNC; @@ -293,6 +290,7 @@ public void testAutomaticPreload() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAutomaticPreloadWithEmptyCache() throws Exception { preloadMode = SYNC; @@ -343,6 +341,7 @@ public void testAutomaticPreloadWithEmptyCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testManualPreloadSyncMode() throws Exception { preloadMode = CacheRebalanceMode.SYNC; delay = -1; @@ -358,6 +357,7 @@ public void testManualPreloadSyncMode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreloadManyNodes() throws Exception { delay = 0; preloadMode = ASYNC; @@ -390,7 +390,10 @@ public void testPreloadManyNodes() throws Exception { * @return Topology. */ private GridDhtPartitionTopology topology(Ignite g) { - return ((GridNearCacheAdapter)((IgniteKernal)g).internalCache(DEFAULT_CACHE_NAME)).dht().topology(); + GridCacheAdapter internalCache = ((IgniteKernal)g).internalCache(DEFAULT_CACHE_NAME); + + return internalCache.isNear() ? ((GridNearCacheAdapter)internalCache).dht().topology() : + internalCache.context().dht().topology(); } /** @@ -479,4 +482,4 @@ private final void checkMaps(final boolean strict, final GridDhtCacheAdapter c, int cnt) { for (int i = 0; i < cnt; i++) c.put(i, Integer.toString(i)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java index 886a8864ac6bf..41f0af499c1de 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java @@ -28,10 +28,10 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -39,6 +39,7 @@ /** * Test cases for partitioned cache {@link GridDhtPreloader preloader}. */ +@RunWith(JUnit4.class) public class GridCacheDhtPreloadMessageCountTest extends GridCommonAbstractTest { /** Key count. */ private static final int KEY_CNT = 1000; @@ -46,9 +47,6 @@ public class GridCacheDhtPreloadMessageCountTest extends GridCommonAbstractTest /** Preload mode. */ private CacheRebalanceMode preloadMode = CacheRebalanceMode.SYNC; - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -63,11 +61,6 @@ public class GridCacheDhtPreloadMessageCountTest extends GridCommonAbstractTest cc.setAffinity(new RendezvousAffinityFunction(false, 521)); cc.setBackups(1); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); c.setCacheConfiguration(cc); TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi(); @@ -87,6 +80,7 @@ public class GridCacheDhtPreloadMessageCountTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testAutomaticPreload() throws Exception { Ignite g0 = startGrid(0); @@ -134,4 +128,4 @@ private void checkCache(IgniteCache c, int keyCnt) { assertEquals(Integer.valueOf(i), c.localPeek(key, CachePeekMode.ONHEAP)); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMultiThreadedSelfTest.java index 6c32a67b98f24..3349d55d884b2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMultiThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMultiThreadedSelfTest.java @@ -29,20 +29,19 @@ import org.apache.ignite.failure.NoOpFailureHandler; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * MultiThreaded load test for DHT preloader. */ +@RunWith(JUnit4.class) public class GridCacheDhtPreloadMultiThreadedSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** * Creates new test. */ @@ -53,6 +52,7 @@ public GridCacheDhtPreloadMultiThreadedSelfTest() { /** * @throws Exception If failed. */ + @Test public void testNodeLeaveBeforePreloadingComplete() throws Exception { try { final CountDownLatch startLatch = new CountDownLatch(1); @@ -110,6 +110,7 @@ public void testNodeLeaveBeforePreloadingComplete() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentNodesStart() throws Exception { try { multithreadedAsync( @@ -136,7 +137,10 @@ public void testConcurrentNodesStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentNodesStartStop() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + try { multithreadedAsync( new Callable() { @@ -177,8 +181,6 @@ public void testConcurrentNodesStartStop() throws Exception { } } - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - return cfg; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPerformanceTest.java index 4b08a09b9557a..582404fa5d0d1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPerformanceTest.java @@ -27,23 +27,21 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test cases for partitioned cache {@link GridDhtPreloader preloader}. */ +@RunWith(JUnit4.class) public class GridCacheDhtPreloadPerformanceTest extends GridCommonAbstractTest { /** */ private static final int THREAD_CNT = 30; - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -74,12 +72,6 @@ public class GridCacheDhtPreloadPerformanceTest extends GridCommonAbstractTest { 1300)); cc1.setBackups(2); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - c.setIgfsThreadPoolSize(1); c.setSystemThreadPoolSize(2); c.setPublicThreadPoolSize(2); @@ -101,6 +93,7 @@ public class GridCacheDhtPreloadPerformanceTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartPerformance() throws Exception { // // for (int i = 0; i < 10; i++) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPutGetSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPutGetSelfTest.java index 71911e8f9c965..d9e12c76bde1e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPutGetSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadPutGetSelfTest.java @@ -29,12 +29,13 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; @@ -45,6 +46,7 @@ /** * Test cases for partitioned cache {@link GridDhtPreloader preloader}. */ +@RunWith(JUnit4.class) public class GridCacheDhtPreloadPutGetSelfTest extends GridCommonAbstractTest { /** Key count. */ private static final int KEY_CNT = 1000; @@ -61,9 +63,6 @@ public class GridCacheDhtPreloadPutGetSelfTest extends GridCommonAbstractTest { /** Preload mode. */ private CacheRebalanceMode preloadMode; - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -79,11 +78,6 @@ public class GridCacheDhtPreloadPutGetSelfTest extends GridCommonAbstractTest { cacheCfg.setAffinity(new RendezvousAffinityFunction()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); cfg.setCacheConfiguration(cacheCfg); return cfg; @@ -92,6 +86,7 @@ public class GridCacheDhtPreloadPutGetSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPutGetAsync0() throws Exception { preloadMode = ASYNC; backups = 0; @@ -102,6 +97,7 @@ public void testPutGetAsync0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetAsync1() throws Exception { preloadMode = ASYNC; backups = 1; @@ -112,6 +108,7 @@ public void testPutGetAsync1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetAsync2() throws Exception { preloadMode = ASYNC; backups = 2; @@ -122,6 +119,7 @@ public void testPutGetAsync2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetSync0() throws Exception { preloadMode = SYNC; backups = 0; @@ -132,6 +130,7 @@ public void testPutGetSync0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetSync1() throws Exception { preloadMode = SYNC; backups = 1; @@ -142,6 +141,7 @@ public void testPutGetSync1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetSync2() throws Exception { preloadMode = SYNC; backups = 2; @@ -152,6 +152,7 @@ public void testPutGetSync2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetNone0() throws Exception { preloadMode = NONE; backups = 0; @@ -162,7 +163,11 @@ public void testPutGetNone0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetNone1() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10261"); + preloadMode = NONE; backups = 1; @@ -172,7 +177,11 @@ public void testPutGetNone1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetNone2() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10261"); + preloadMode = NONE; backups = 2; @@ -273,4 +282,4 @@ private void performTest() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java index 82ed95e52531f..6b8b5698ef2f2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java @@ -43,10 +43,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; @@ -62,6 +62,7 @@ /** * Test cases for partitioned cache {@link GridDhtPreloader preloader}. */ +@RunWith(JUnit4.class) public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest { /** Flag to print preloading events. */ private static final boolean DEBUG = false; @@ -90,9 +91,6 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest { /** Number of partitions. */ private int partitions = DFLT_PARTITIONS; - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -104,11 +102,6 @@ public GridCacheDhtPreloadSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName)); cfg.setDeploymentMode(CONTINUOUS); @@ -158,6 +151,7 @@ protected boolean onheapCacheEnabled() { /** * @throws Exception If failed. */ + @Test public void testActivePartitionTransferSyncSameCoordinator() throws Exception { preloadMode = SYNC; @@ -167,6 +161,7 @@ public void testActivePartitionTransferSyncSameCoordinator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivePartitionTransferAsyncSameCoordinator() throws Exception { checkActivePartitionTransfer(1000, 4, true, false); } @@ -174,6 +169,7 @@ public void testActivePartitionTransferAsyncSameCoordinator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActivePartitionTransferSyncChangingCoordinator() throws Exception { preloadMode = SYNC; @@ -183,6 +179,7 @@ public void testActivePartitionTransferSyncChangingCoordinator() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testActivePartitionTransferAsyncChangingCoordinator() throws Exception { checkActivePartitionTransfer(1000, 4, false, false); } @@ -190,6 +187,7 @@ public void testActivePartitionTransferAsyncChangingCoordinator() throws Excepti /** * @throws Exception If failed. */ + @Test public void testActivePartitionTransferSyncRandomCoordinator() throws Exception { preloadMode = SYNC; @@ -199,6 +197,7 @@ public void testActivePartitionTransferSyncRandomCoordinator() throws Exception /** * @throws Exception If failed. */ + @Test public void testActivePartitionTransferAsyncRandomCoordinator() throws Exception { checkActivePartitionTransfer(1000, 4, false, true); } @@ -212,7 +211,6 @@ public void testActivePartitionTransferAsyncRandomCoordinator() throws Exception */ private void checkActivePartitionTransfer(int keyCnt, int nodeCnt, boolean sameCoord, boolean shuffle) throws Exception { - try { Ignite ignite1 = startGrid(0); @@ -350,6 +348,7 @@ private void checkActiveState(Iterable grids) { /** * @throws Exception If failed. */ + @Test public void testMultiplePartitionBatchesSyncPreload() throws Exception { preloadMode = SYNC; preloadBatchSize = 100; @@ -361,6 +360,7 @@ public void testMultiplePartitionBatchesSyncPreload() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultiplePartitionBatchesAsyncPreload() throws Exception { preloadBatchSize = 100; partitions = 2; @@ -371,6 +371,7 @@ public void testMultiplePartitionBatchesAsyncPreload() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleNodesSyncPreloadSameCoordinator() throws Exception { preloadMode = SYNC; @@ -380,6 +381,7 @@ public void testMultipleNodesSyncPreloadSameCoordinator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleNodesAsyncPreloadSameCoordinator() throws Exception { checkNodes(1000, 4, true, false); } @@ -387,6 +389,7 @@ public void testMultipleNodesAsyncPreloadSameCoordinator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleNodesSyncPreloadChangingCoordinator() throws Exception { preloadMode = SYNC; @@ -396,6 +399,7 @@ public void testMultipleNodesSyncPreloadChangingCoordinator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleNodesAsyncPreloadChangingCoordinator() throws Exception { checkNodes(1000, 4, false, false); } @@ -403,6 +407,7 @@ public void testMultipleNodesAsyncPreloadChangingCoordinator() throws Exception /** * @throws Exception If failed. */ + @Test public void testMultipleNodesSyncPreloadRandomCoordinator() throws Exception { preloadMode = SYNC; @@ -412,6 +417,7 @@ public void testMultipleNodesSyncPreloadRandomCoordinator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleNodesAsyncPreloadRandomCoordinator() throws Exception { checkNodes(1000, 4, false, true); } @@ -456,7 +462,6 @@ private void stopGrids(Iterable grids) { */ private void checkNodes(int keyCnt, int nodeCnt, boolean sameCoord, boolean shuffle) throws Exception { - try { Ignite ignite1 = startGrid(0); @@ -627,4 +632,4 @@ private String top2string(Iterable grids) { return "Grid partition maps [" + map.toString() + ']'; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java index e77e5c8d1f6f7..e91d81a54df85 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java @@ -34,10 +34,10 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -50,6 +50,7 @@ /** * Test cases for partitioned cache {@link GridDhtPreloader preloader}. */ +@RunWith(JUnit4.class) public class GridCacheDhtPreloadStartStopSelfTest extends GridCommonAbstractTest { /** */ private static final long TEST_TIMEOUT = 5 * 60 * 1000; @@ -81,9 +82,6 @@ public class GridCacheDhtPreloadStartStopSelfTest extends GridCommonAbstractTest /** */ private int cacheCnt = DFLT_CACHE_CNT; - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -113,11 +111,6 @@ public GridCacheDhtPreloadStartStopSelfTest() { cacheCfgs[i] = cacheCfg; } - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); cfg.setCacheConfiguration(cacheCfgs); cfg.setDeploymentMode(CONTINUOUS); @@ -164,6 +157,7 @@ private void stopGrids(Iterable grids) { } /** @throws Exception If failed. */ + @Test public void testDeadlock() throws Exception { info("Testing deadlock..."); @@ -263,4 +257,4 @@ private void checkKeys(IgniteCache c, int cnt) { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java index bc5e3d472138d..d74f7422d9642 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java @@ -28,10 +28,10 @@ import org.apache.ignite.lifecycle.LifecycleBean; import org.apache.ignite.lifecycle.LifecycleEventType; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -44,6 +44,7 @@ * Test large cache counts. */ @SuppressWarnings({"BusyWait"}) +@RunWith(JUnit4.class) public class GridCacheDhtPreloadUnloadSelfTest extends GridCommonAbstractTest { /** Default backups. */ private static final int DFLT_BACKUPS = 1; @@ -69,9 +70,6 @@ public class GridCacheDhtPreloadUnloadSelfTest extends GridCommonAbstractTest { /** */ private LifecycleBean lbean; - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Network timeout. */ private long netTimeout = 1000; @@ -96,14 +94,9 @@ public GridCacheDhtPreloadUnloadSelfTest() { cc.setBackups(backups); cc.setAtomicityMode(TRANSACTIONAL); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - if (lbean != null) c.setLifecycleBeans(lbean); - c.setDiscoverySpi(disco); c.setCacheConfiguration(cc); c.setDeploymentMode(CONTINUOUS); c.setNetworkTimeout(netTimeout); @@ -121,6 +114,7 @@ public GridCacheDhtPreloadUnloadSelfTest() { } /** @throws Exception If failed. */ + @Test public void testUnloadZeroBackupsTwoNodes() throws Exception { preloadMode = SYNC; backups = 0; @@ -148,6 +142,7 @@ public void testUnloadZeroBackupsTwoNodes() throws Exception { } /** @throws Exception If failed. */ + @Test public void testUnloadOneBackupTwoNodes() throws Exception { preloadMode = SYNC; backups = 1; @@ -226,6 +221,7 @@ private void waitForUnload(long gridCnt, long cnt, long wait) throws Interrupted } /** @throws Exception If failed. */ + @Test public void testUnloadOneBackupThreeNodes() throws Exception { preloadMode = SYNC; backups = 1; @@ -258,6 +254,7 @@ public void testUnloadOneBackupThreeNodes() throws Exception { } /** @throws Exception If failed. */ + @Test public void testUnloadOneBackThreeNodesWithLifeCycleBean() throws Exception { preloadMode = SYNC; backups = 1; @@ -324,4 +321,4 @@ private String value(int size) { return b.toString(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java index 6024030ab6f15..ea9360dc49543 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java @@ -32,8 +32,12 @@ import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.resources.IgniteInstanceResource; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.jetbrains.annotations.Nullable; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -42,6 +46,7 @@ * Load cache test. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest { /** */ private static ConcurrentMap map; @@ -69,9 +74,17 @@ public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest { return new NearCacheConfiguration(); } + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + /** * @throws Exception If failed. */ + @Test public void testLoadCache() throws Exception { loadCache(false, false); } @@ -79,6 +92,7 @@ public void testLoadCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheAsyncOld() throws Exception { loadCache(true, true); } @@ -86,6 +100,7 @@ public void testLoadCacheAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheAsync() throws Exception { loadCache(true, false); } @@ -242,4 +257,4 @@ private static class TestStore extends CacheStoreAdapter { fail(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java index 102185c24da03..ff738c6714cea 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java @@ -19,10 +19,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedLockSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCachePartitionedNearDisabledLockSelfTest extends GridCachePartitionedLockSelfTest { /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration() { @@ -41,7 +45,8 @@ public class GridCachePartitionedNearDisabledLockSelfTest extends GridCacheParti } /** {@inheritDoc} */ + @Test @Override public void testLockReentrancy() throws Throwable { fail("https://issues.apache.org/jira/browse/IGNITE-835"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMetricsSelfTest.java index 6c2da72db43b0..2abfe79b97977 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMetricsSelfTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -31,6 +34,7 @@ /** * Metrics test for partitioned cache with disabled near cache. */ +@RunWith(JUnit4.class) public class GridCachePartitionedNearDisabledMetricsSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int GRID_CNT = 2; @@ -77,6 +81,7 @@ public class GridCachePartitionedNearDisabledMetricsSelfTest extends GridCacheAb /** * @throws Exception If failed. */ + @Test public void testGettingRemovedKey() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-819"); @@ -120,4 +125,4 @@ public void testGettingRemovedKey() throws Exception { assertEquals(0, hits); assertEquals(1, misses); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTopologyChangeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTopologyChangeSelfTest.java index 2051616e85f3b..6344c12543635 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTopologyChangeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTopologyChangeSelfTest.java @@ -41,11 +41,11 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -58,6 +58,7 @@ /** * Tests that new transactions do not start until partition exchange is completed. */ +@RunWith(JUnit4.class) public class GridCachePartitionedTopologyChangeSelfTest extends GridCommonAbstractTest { /** Partition does not belong to node. */ private static final int PARTITION_READER = 0; @@ -68,9 +69,6 @@ public class GridCachePartitionedTopologyChangeSelfTest extends GridCommonAbstra /** Node is backup for partition. */ private static final int PARTITION_BACKUP = 2; - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-807"); @@ -80,13 +78,6 @@ public class GridCachePartitionedTopologyChangeSelfTest extends GridCommonAbstra @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - // Discovery. - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -103,6 +94,7 @@ public class GridCachePartitionedTopologyChangeSelfTest extends GridCommonAbstra /** * @throws Exception If failed. */ + @Test public void testNearTxNodeJoined() throws Exception { checkTxNodeJoined(PARTITION_READER); } @@ -110,6 +102,7 @@ public void testNearTxNodeJoined() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryTxNodeJoined() throws Exception { checkTxNodeJoined(PARTITION_PRIMARY); } @@ -117,6 +110,7 @@ public void testPrimaryTxNodeJoined() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupTxNodeJoined() throws Exception { checkTxNodeJoined(PARTITION_BACKUP); } @@ -124,6 +118,7 @@ public void testBackupTxNodeJoined() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearTxNodeLeft() throws Exception { checkTxNodeLeft(PARTITION_READER); } @@ -131,6 +126,7 @@ public void testNearTxNodeLeft() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryTxNodeLeft() throws Exception { // This test does not make sense because if node is primary for some partition, // it will reside on node until node leaves grid. @@ -139,6 +135,7 @@ public void testPrimaryTxNodeLeft() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupTxNodeLeft() throws Exception { checkTxNodeLeft(PARTITION_BACKUP); } @@ -146,6 +143,7 @@ public void testBackupTxNodeLeft() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExplicitLocks() throws Exception { try { startGridsMultiThreaded(2); @@ -617,4 +615,4 @@ private List partitions(Ignite node, int partType) { return res; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java index 81d479665067d..66f25bdd077ae 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.IgniteTxOriginatingNodeFailureAbstractSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests transaction consistency when originating node fails. */ +@RunWith(JUnit4.class) public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends IgniteTxOriginatingNodeFailureAbstractSelfTest { /** */ @@ -58,6 +62,7 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends /** * @throws Exception If failed. */ + @Test public void testTxFromPrimary() throws Exception { ClusterNode txNode = grid(originatingNode()).localNode(); @@ -79,6 +84,7 @@ public void testTxFromPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxFromBackup() throws Exception { ClusterNode txNode = grid(originatingNode()).localNode(); @@ -100,6 +106,7 @@ public void testTxFromBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxFromNotColocated() throws Exception { ClusterNode txNode = grid(originatingNode()).localNode(); @@ -122,6 +129,7 @@ public void testTxFromNotColocated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxAllNodes() throws Exception { List allNodes = new ArrayList<>(GRID_CNT); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java index d00dd7a71dcc3..9db4ae8e5d7f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java @@ -32,10 +32,10 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -44,10 +44,8 @@ /** */ +@RunWith(JUnit4.class) public class GridCachePartitionedUnloadEventsSelfTest extends GridCommonAbstractTest { - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int EVENTS_COUNT = 40; @@ -58,10 +56,6 @@ public class GridCachePartitionedUnloadEventsSelfTest extends GridCommonAbstract @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - disco.setIpFinder(ipFinder); - cfg.setDiscoverySpi(disco); - CacheConfiguration ccfg = cacheConfiguration(); CacheConfiguration ccfgEvtsDisabled = new CacheConfiguration<>(ccfg); @@ -89,6 +83,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception if failed. */ + @Test public void testUnloadEvents() throws Exception { final Ignite g1 = startGrid("g1"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionsStateValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionsStateValidationTest.java index fcc1293a959f7..90f1477cd05cf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionsStateValidationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionsStateValidationTest.java @@ -51,14 +51,19 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCachePartitionsStateValidationTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -102,6 +107,7 @@ public class GridCachePartitionsStateValidationTest extends GridCommonAbstractTe * * @throws Exception If failed. */ + @Test public void testValidationIfPartitionCountersAreInconsistent() throws Exception { IgniteEx ignite = (IgniteEx) startGrids(2); ignite.cluster().active(true); @@ -134,7 +140,11 @@ public void testValidationIfPartitionCountersAreInconsistent() throws Exception * * @throws Exception If failed. */ + @Test public void testPartitionCountersConsistencyOnExchange() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10766"); + IgniteEx ignite = (IgniteEx) startGrids(4); ignite.cluster().active(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionsStateValidatorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionsStateValidatorSelfTest.java index 9cf296a8eeae6..9d21162f5cb34 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionsStateValidatorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionsStateValidatorSelfTest.java @@ -33,12 +33,16 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.mockito.Matchers; import org.mockito.Mockito; /** * Test correct behaviour of {@link GridDhtPartitionsStateValidator} class. */ +@RunWith(JUnit4.class) public class GridCachePartitionsStateValidatorSelfTest extends GridCommonAbstractTest { /** Mocks and stubs. */ private final UUID localNodeId = UUID.randomUUID(); @@ -100,6 +104,7 @@ private GridDhtPartitionsSingleMessage from(@Nullable Map queue = new ConcurrentLinkedQueue<>(); - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -77,11 +76,7 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi).setNetworkTimeout(30_000); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setNetworkTimeout(30_000); AtomicConfiguration atomicCfg = new AtomicConfiguration(); atomicCfg.setCacheMode(PARTITIONED); @@ -108,6 +103,7 @@ public class IgniteAtomicLongChangingTopologySelfTest extends GridCommonAbstract /** * @throws Exception If failed. */ + @Test public void testQueueCreateNodesJoin() throws Exception { CountDownLatch startLatch = new CountDownLatch(GRID_CNT); final AtomicBoolean run = new AtomicBoolean(true); @@ -136,6 +132,7 @@ public void testQueueCreateNodesJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientAtomicLongCreateCloseFailover() throws Exception { testFailoverWithClient(new IgniteInClosure() { @Override public void apply(Ignite ignite) { @@ -151,6 +148,7 @@ public void testClientAtomicLongCreateCloseFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientQueueCreateCloseFailover() throws Exception { testFailoverWithClient(new IgniteInClosure() { @Override public void apply(Ignite ignite) { @@ -172,6 +170,7 @@ public void testClientQueueCreateCloseFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientSetCreateCloseFailover() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-9015"); @@ -181,6 +180,7 @@ public void testClientSetCreateCloseFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientCollocatedSetCreateCloseFailover() throws Exception { checkClientSetCreateCloseFailover(true); } @@ -284,6 +284,7 @@ private IgniteInternalFuture restartThread(final AtomicBoolean finished) { /** * @throws Exception If failed. */ + @Test public void testIncrementConsistency() throws Exception { startGrids(GRID_CNT); @@ -323,6 +324,7 @@ public void testIncrementConsistency() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueueClose() throws Exception { startGrids(GRID_CNT); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheClearDuringRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheClearDuringRebalanceTest.java index 8561c5c5211b9..1ec27d11dbd71 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheClearDuringRebalanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheClearDuringRebalanceTest.java @@ -24,23 +24,28 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheClearDuringRebalanceTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "cache"; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + if(MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-7952"); + } /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { @@ -53,12 +58,6 @@ public class IgniteCacheClearDuringRebalanceTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - cfg.setCacheConfiguration(new CacheConfiguration(CACHE_NAME) .setCacheMode(PARTITIONED)); @@ -68,6 +67,7 @@ public class IgniteCacheClearDuringRebalanceTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testClearAll() throws Exception { final IgniteEx node = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCommitDelayTxRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCommitDelayTxRecoveryTest.java index 7b8854d40d2ac..2e629c63bde4c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCommitDelayTxRecoveryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCommitDelayTxRecoveryTest.java @@ -38,12 +38,12 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -55,10 +55,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheCommitDelayTxRecoveryTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SRVS = 4; @@ -78,8 +76,6 @@ public class IgniteCacheCommitDelayTxRecoveryTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); cfg.setClientMode(client); @@ -97,6 +93,7 @@ public class IgniteCacheCommitDelayTxRecoveryTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testRecovery1() throws Exception { checkRecovery(1, false); } @@ -104,6 +101,7 @@ public void testRecovery1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRecovery2() throws Exception { checkRecovery(2, false); } @@ -111,6 +109,7 @@ public void testRecovery2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRecoveryStoreEnabled1() throws Exception { checkRecovery(1, true); } @@ -118,6 +117,7 @@ public void testRecoveryStoreEnabled1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRecoveryStoreEnabled2() throws Exception { checkRecovery(2, true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheConcurrentPutGetRemove.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheConcurrentPutGetRemove.java index a83e9998ca699..5686954090c50 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheConcurrentPutGetRemove.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheConcurrentPutGetRemove.java @@ -27,12 +27,11 @@ import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -41,22 +40,11 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheConcurrentPutGetRemove extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 4; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); @@ -67,6 +55,7 @@ public class IgniteCacheConcurrentPutGetRemove extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPutGetRemoveAtomic() throws Exception { putGetRemove(cacheConfiguration(ATOMIC, 1)); } @@ -74,6 +63,7 @@ public void testPutGetRemoveAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetRemoveTx() throws Exception { putGetRemove(cacheConfiguration(TRANSACTIONAL, 1)); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java index 40f9dc4f3ac90..aae3e1650aafb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java @@ -40,15 +40,15 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -63,10 +63,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheCrossCacheTxFailoverTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE1 = "cache1"; @@ -86,8 +84,6 @@ public class IgniteCacheCrossCacheTxFailoverTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - if (igniteInstanceName.equals(getTestIgniteInstanceName(GRID_CNT - 1))) cfg.setClientMode(true); @@ -135,6 +131,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name, /** * @throws Exception If failed. */ + @Test public void testCrossCachePessimisticTxFailover() throws Exception { crossCacheTxFailover(PARTITIONED, true, PESSIMISTIC, REPEATABLE_READ); } @@ -142,6 +139,7 @@ public void testCrossCachePessimisticTxFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCachePessimisticTxFailoverDifferentAffinity() throws Exception { crossCacheTxFailover(PARTITIONED, false, PESSIMISTIC, REPEATABLE_READ); } @@ -149,6 +147,7 @@ public void testCrossCachePessimisticTxFailoverDifferentAffinity() throws Except /** * @throws Exception If failed. */ + @Test public void testCrossCacheOptimisticTxFailover() throws Exception { crossCacheTxFailover(PARTITIONED, true, OPTIMISTIC, REPEATABLE_READ); } @@ -156,6 +155,7 @@ public void testCrossCacheOptimisticTxFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCacheOptimisticSerializableTxFailover() throws Exception { crossCacheTxFailover(PARTITIONED, true, OPTIMISTIC, SERIALIZABLE); } @@ -163,6 +163,7 @@ public void testCrossCacheOptimisticSerializableTxFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCacheOptimisticTxFailoverDifferentAffinity() throws Exception { crossCacheTxFailover(PARTITIONED, false, OPTIMISTIC, REPEATABLE_READ); } @@ -170,6 +171,7 @@ public void testCrossCacheOptimisticTxFailoverDifferentAffinity() throws Excepti /** * @throws Exception If failed. */ + @Test public void testCrossCachePessimisticTxFailoverReplicated() throws Exception { crossCacheTxFailover(REPLICATED, true, PESSIMISTIC, REPEATABLE_READ); } @@ -177,6 +179,7 @@ public void testCrossCachePessimisticTxFailoverReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCacheOptimisticTxFailoverReplicated() throws Exception { crossCacheTxFailover(REPLICATED, true, OPTIMISTIC, REPEATABLE_READ); } @@ -184,6 +187,7 @@ public void testCrossCacheOptimisticTxFailoverReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCachePessimisticTxFailoverDifferentAffinityReplicated() throws Exception { crossCacheTxFailover(PARTITIONED, false, PESSIMISTIC, REPEATABLE_READ); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheLockFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheLockFailoverSelfTest.java index f813ef89000fe..e97931f9478a4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheLockFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheLockFailoverSelfTest.java @@ -31,12 +31,24 @@ import org.apache.ignite.lang.IgniteFutureTimeoutException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheLockFailoverSelfTest extends GridCacheAbstractSelfTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 2; @@ -85,6 +97,7 @@ public class IgniteCacheLockFailoverSelfTest extends GridCacheAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testLockFailover() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -149,6 +162,7 @@ public Object call() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUnlockPrimaryLeft() throws Exception { GridCacheAdapter cache = ((IgniteKernal)grid(0)).internalCache(DEFAULT_CACHE_NAME); @@ -166,4 +180,4 @@ public void testUnlockPrimaryLeft() throws Exception { startGrid(1); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheMultiTxLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheMultiTxLockSelfTest.java index b5771054a56cf..abef429530146 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheMultiTxLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheMultiTxLockSelfTest.java @@ -22,6 +22,7 @@ import java.util.TreeMap; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; @@ -29,12 +30,12 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager; -import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -43,28 +44,30 @@ /** * Tests explicit lock. */ +@RunWith(JUnit4.class) public class IgniteCacheMultiTxLockSelfTest extends GridCommonAbstractTest { /** */ public static final String CACHE_NAME = "part_cache"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private volatile boolean run = true; /** */ private boolean client; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); + /** Unexpected lock error. */ + private volatile Throwable err; - TcpDiscoverySpi disco = new TcpDiscoverySpi(); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); - disco.setIpFinder(ipFinder); + super.setUp(); + } - c.setDiscoverySpi(disco); + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration c = super.getConfiguration(igniteInstanceName); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -95,6 +98,7 @@ public class IgniteCacheMultiTxLockSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testExplicitLockOneKey() throws Exception { checkExplicitLock(1, false); } @@ -102,6 +106,7 @@ public void testExplicitLockOneKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExplicitLockManyKeys() throws Exception { checkExplicitLock(4, false); } @@ -109,6 +114,7 @@ public void testExplicitLockManyKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExplicitLockManyKeysWithClient() throws Exception { checkExplicitLock(4, true); } @@ -121,6 +127,8 @@ public void testExplicitLockManyKeysWithClient() throws Exception { public void checkExplicitLock(int keys, boolean testClient) throws Exception { Collection threads = new ArrayList<>(); + err = null; + try { // Start grid 1. IgniteEx grid1 = startGrid(1); @@ -172,6 +180,8 @@ public void checkExplicitLock(int keys, boolean testClient) throws Exception { assertEquals("txMap is not empty:" + i, 0, tm.idMapSize()); } + + assertNull(err); } finally { stopAllGrids(); @@ -198,7 +208,6 @@ private void stopThreads(Iterable threads) { * @param keys Number of keys. * @return Running thread. */ - @SuppressWarnings("TypeMayBeWeakened") private Thread runCacheOperations(final IgniteInternalCache cache, final int keys) { Thread t = new Thread() { @Override public void run() { @@ -216,7 +225,7 @@ private Thread runCacheOperations(final IgniteInternalCache cache else cache.removeAll(vals.keySet()); } - catch (Exception e) { + catch (IgniteCheckedException e) { U.error(log(), "Failed cache operation.", e); } finally { @@ -225,8 +234,12 @@ private Thread runCacheOperations(final IgniteInternalCache cache U.sleep(100); } - catch (Exception e){ + catch (Throwable e){ U.error(log(), "Failed unlock.", e); + + err = e; + + return; } } } @@ -254,4 +267,4 @@ private TreeMap generateValues(int cnt) { return res; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePartitionedBackupNodeFailureRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePartitionedBackupNodeFailureRecoveryTest.java index 98520ab01a0de..6863601a6e7d6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePartitionedBackupNodeFailureRecoveryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePartitionedBackupNodeFailureRecoveryTest.java @@ -33,6 +33,9 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; import org.apache.ignite.internal.util.typedef.PA; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -43,8 +46,9 @@ /** */ +@RunWith(JUnit4.class) public class IgniteCachePartitionedBackupNodeFailureRecoveryTest extends IgniteCacheAbstractTest { - /** {@inheritDoc}*/ + /** {@inheritDoc}*/ @Override protected int gridCount() { return 3; } @@ -80,6 +84,7 @@ public class IgniteCachePartitionedBackupNodeFailureRecoveryTest extends IgniteC * * @throws Exception If failed. */ + @Test public void testBackUpFail() throws Exception { final IgniteEx node1 = grid(0); final IgniteEx node2 = grid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePrimaryNodeFailureRecoveryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePrimaryNodeFailureRecoveryAbstractTest.java index b0d083d5b66d0..48755e8e9eb91 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePrimaryNodeFailureRecoveryAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePrimaryNodeFailureRecoveryAbstractTest.java @@ -59,6 +59,9 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; @@ -72,6 +75,7 @@ /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCachePrimaryNodeFailureRecoveryAbstractTest extends IgniteCacheAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -120,6 +124,7 @@ public abstract class IgniteCachePrimaryNodeFailureRecoveryAbstractTest extends /** * @throws Exception If failed. */ + @Test public void testOptimisticPrimaryNodeFailureRecovery1() throws Exception { if (atomicityMode() == TRANSACTIONAL_SNAPSHOT) return; @@ -129,6 +134,7 @@ public void testOptimisticPrimaryNodeFailureRecovery1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticPrimaryNodeFailureRecovery2() throws Exception { if (atomicityMode() == TRANSACTIONAL_SNAPSHOT) return; @@ -138,6 +144,7 @@ public void testOptimisticPrimaryNodeFailureRecovery2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticPrimaryNodeFailureRollback1() throws Exception { if (atomicityMode() == TRANSACTIONAL_SNAPSHOT) return; @@ -147,6 +154,7 @@ public void testOptimisticPrimaryNodeFailureRollback1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticPrimaryNodeFailureRollback2() throws Exception { if (atomicityMode() == TRANSACTIONAL_SNAPSHOT) return; @@ -156,6 +164,7 @@ public void testOptimisticPrimaryNodeFailureRollback2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticPrimaryNodeFailureRecovery1() throws Exception { primaryNodeFailure(false, false, false); } @@ -163,6 +172,7 @@ public void testPessimisticPrimaryNodeFailureRecovery1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticPrimaryNodeFailureRecovery2() throws Exception { primaryNodeFailure(true, false, false); } @@ -170,6 +180,7 @@ public void testPessimisticPrimaryNodeFailureRecovery2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticPrimaryNodeFailureRollback1() throws Exception { primaryNodeFailure(false, true, false); } @@ -177,6 +188,7 @@ public void testPessimisticPrimaryNodeFailureRollback1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticPrimaryNodeFailureRollback2() throws Exception { primaryNodeFailure(true, true, false); } @@ -281,6 +293,7 @@ private void primaryNodeFailure(boolean locBackupKey, final boolean rollback, bo /** * @throws Exception If failed. */ + @Test public void testOptimisticPrimaryAndOriginatingNodeFailureRecovery1() throws Exception { if (atomicityMode() == TRANSACTIONAL_SNAPSHOT) return; @@ -290,6 +303,7 @@ public void testOptimisticPrimaryAndOriginatingNodeFailureRecovery1() throws Exc /** * @throws Exception If failed. */ + @Test public void testOptimisticPrimaryAndOriginatingNodeFailureRecovery2() throws Exception { if (atomicityMode() == TRANSACTIONAL_SNAPSHOT) return; @@ -299,6 +313,7 @@ public void testOptimisticPrimaryAndOriginatingNodeFailureRecovery2() throws Exc /** * @throws Exception If failed. */ + @Test public void testOptimisticPrimaryAndOriginatingNodeFailureRollback1() throws Exception { if (atomicityMode() == TRANSACTIONAL_SNAPSHOT) return; @@ -308,6 +323,7 @@ public void testOptimisticPrimaryAndOriginatingNodeFailureRollback1() throws Exc /** * @throws Exception If failed. */ + @Test public void testOptimisticPrimaryAndOriginatingNodeFailureRollback2() throws Exception { if (atomicityMode() == TRANSACTIONAL_SNAPSHOT) return; @@ -317,6 +333,7 @@ public void testOptimisticPrimaryAndOriginatingNodeFailureRollback2() throws Exc /** * @throws Exception If failed. */ + @Test public void testPessimisticPrimaryAndOriginatingNodeFailureRecovery1() throws Exception { primaryAndOriginatingNodeFailure(false, false, false); } @@ -324,6 +341,7 @@ public void testPessimisticPrimaryAndOriginatingNodeFailureRecovery1() throws Ex /** * @throws Exception If failed. */ + @Test public void testPessimisticPrimaryAndOriginatingNodeFailureRecovery2() throws Exception { primaryAndOriginatingNodeFailure(true, false, false); } @@ -331,6 +349,7 @@ public void testPessimisticPrimaryAndOriginatingNodeFailureRecovery2() throws Ex /** * @throws Exception If failed. */ + @Test public void testPessimisticPrimaryAndOriginatingNodeFailureRollback1() throws Exception { primaryAndOriginatingNodeFailure(false, true, false); } @@ -338,6 +357,7 @@ public void testPessimisticPrimaryAndOriginatingNodeFailureRollback1() throws Ex /** * @throws Exception If failed. */ + @Test public void testPessimisticPrimaryAndOriginatingNodeFailureRollback2() throws Exception { primaryAndOriginatingNodeFailure(true, true, false); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java index fbb7c3ae65ffc..b4541420a28fc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java @@ -51,11 +51,10 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -64,10 +63,8 @@ /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ protected static final long DURATION = 60_000; @@ -120,8 +117,6 @@ protected CacheConfiguration cacheConfiguration(boolean evict, boolean store) th cfg.setIncludeEventTypes(); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); AtomicConfiguration acfg = new AtomicConfiguration(); @@ -169,6 +164,7 @@ protected CacheConfiguration cacheConfiguration(boolean evict, boolean store) th /** * @throws Exception If failed. */ + @org.junit.Test public void testPut() throws Exception { checkRetry(Test.PUT, false, false); } @@ -176,6 +172,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testGetAndPut() throws Exception { checkRetry(Test.GET_AND_PUT, false, false); } @@ -183,6 +180,7 @@ public void testGetAndPut() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testPutStoreEnabled() throws Exception { checkRetry(Test.PUT, false, true); } @@ -190,6 +188,7 @@ public void testPutStoreEnabled() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testPutAll() throws Exception { checkRetry(Test.PUT_ALL, false, false); } @@ -197,6 +196,7 @@ public void testPutAll() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testPutAsync() throws Exception { checkRetry(Test.PUT_ASYNC, false, false); } @@ -204,6 +204,7 @@ public void testPutAsync() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testPutAsyncStoreEnabled() throws Exception { checkRetry(Test.PUT_ASYNC, false, true); } @@ -211,6 +212,7 @@ public void testPutAsyncStoreEnabled() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testInvoke() throws Exception { checkRetry(Test.INVOKE, false, false); } @@ -218,6 +220,7 @@ public void testInvoke() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testInvokeAll() throws Exception { checkRetry(Test.INVOKE_ALL, false, false); } @@ -225,6 +228,7 @@ public void testInvokeAll() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testInvokeAllEvict() throws Exception { checkRetry(Test.INVOKE_ALL, true, false); } @@ -468,6 +472,7 @@ private void checkNoAtomicFutures() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testFailsWithNoRetries() throws Exception { checkFailsWithNoRetries(false); } @@ -475,6 +480,7 @@ public void testFailsWithNoRetries() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testFailsWithNoRetriesAsync() throws Exception { checkFailsWithNoRetries(true); } @@ -628,4 +634,4 @@ private static class TestCacheStore extends CacheStoreAdapter { STORE_MAP.remove(key); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAtomicSelfTest.java index d7e9981e67e19..fc37e5f4dfb65 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAtomicSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAtomicSelfTest.java @@ -28,6 +28,8 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -37,6 +39,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCachePutRetryAtomicSelfTest extends IgniteCachePutRetryAbstractSelfTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { @@ -46,6 +49,7 @@ public class IgniteCachePutRetryAtomicSelfTest extends IgniteCachePutRetryAbstra /** * @throws Exception If failed. */ + @org.junit.Test public void testPutInsideTransaction() throws Exception { ignite(0).createCache(cacheConfiguration(false, false)); @@ -104,4 +108,4 @@ public void testPutInsideTransaction() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java index 161025fdb1e8d..8c7f859334093 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryTransactionalSelfTest.java @@ -34,6 +34,8 @@ import org.apache.ignite.cache.CacheEntryProcessor; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.testframework.GridTestUtils.runAsync; @@ -42,6 +44,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetryAbstractSelfTest { /** */ private static final int FACTOR = 1000; @@ -54,6 +57,7 @@ public class IgniteCachePutRetryTransactionalSelfTest extends IgniteCachePutRetr /** * @throws Exception If failed. */ + @org.junit.Test public void testAtomicLongRetries() throws Exception { final AtomicBoolean finished = new AtomicBoolean(); @@ -91,6 +95,7 @@ public void testAtomicLongRetries() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExplicitTransactionRetriesSingleValue() throws Exception { checkRetry(Test.TX_PUT, false, false); } @@ -98,6 +103,7 @@ public void testExplicitTransactionRetriesSingleValue() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExplicitTransactionRetriesSingleValueStoreEnabled() throws Exception { checkRetry(Test.TX_PUT, false, true); } @@ -105,6 +111,7 @@ public void testExplicitTransactionRetriesSingleValueStoreEnabled() throws Excep /** * @throws Exception If failed. */ + @org.junit.Test public void testExplicitTransactionRetries() throws Exception { explicitTransactionRetries(false, false); } @@ -112,6 +119,7 @@ public void testExplicitTransactionRetries() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExplicitTransactionRetriesStoreEnabled() throws Exception { explicitTransactionRetries(false, true); } @@ -119,6 +127,7 @@ public void testExplicitTransactionRetriesStoreEnabled() throws Exception { /** * @throws Exception If failed. */ + @org.junit.Test public void testExplicitTransactionRetriesEvictionEnabled() throws Exception { explicitTransactionRetries(true, false); } @@ -202,6 +211,7 @@ public void explicitTransactionRetries(boolean evict, boolean store) throws Exce /** * @throws Exception If failed. */ + @org.junit.Test public void testOriginatingNodeFailureForcesOnePhaseCommitDataCleanup() throws Exception { ignite(0).createCache(cacheConfiguration(false, false)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheStartWithLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheStartWithLoadTest.java index acccc5be07fed..594db17d17ecb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheStartWithLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheStartWithLoadTest.java @@ -38,10 +38,14 @@ import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheStartWithLoadTest extends GridCommonAbstractTest { /** */ static final String CACHE_NAME = "tx_repl"; @@ -75,6 +79,7 @@ protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws /** * @throws Exception if failed. */ + @Test public void testNoRebalanceDuringCacheStart() throws Exception { IgniteEx crd = (IgniteEx)startGrids(4); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java index 11c4c67f415c8..59f2a3256675d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheTxRecoveryRollbackTest.java @@ -49,13 +49,13 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.resources.LoggerResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; @@ -67,10 +67,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheTxRecoveryRollbackTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static ConcurrentHashMap storeMap = new ConcurrentHashMap<>(); @@ -83,8 +81,6 @@ public class IgniteCacheTxRecoveryRollbackTest extends GridCommonAbstractTest { cfg.setConsistentId(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi(); cfg.setCommunicationSpi(commSpi); @@ -115,6 +111,7 @@ public class IgniteCacheTxRecoveryRollbackTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNearTx1Implicit() throws Exception { nearTx1(null); } @@ -122,6 +119,7 @@ public void testNearTx1Implicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearTx1Optimistic() throws Exception { nearTx1(OPTIMISTIC); } @@ -129,6 +127,7 @@ public void testNearTx1Optimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearTx1Pessimistic() throws Exception { nearTx1(PESSIMISTIC); } @@ -213,6 +212,7 @@ private void nearTx1(final TransactionConcurrency concurrency) throws Exception /** * @throws Exception If failed. */ + @Test public void testNearTx2Implicit() throws Exception { nearTx2(null); } @@ -220,6 +220,7 @@ public void testNearTx2Implicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearTx2Optimistic() throws Exception { nearTx2(OPTIMISTIC); } @@ -227,6 +228,7 @@ public void testNearTx2Optimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearTx2Pessimistic() throws Exception { nearTx2(PESSIMISTIC); } @@ -319,6 +321,7 @@ private void nearTx2(final TransactionConcurrency concurrency) throws Exception /** * @throws Exception If failed. */ + @Test public void testTxWithStoreImplicit() throws Exception { txWithStore(null, true); } @@ -326,6 +329,7 @@ public void testTxWithStoreImplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxWithStoreOptimistic() throws Exception { txWithStore(OPTIMISTIC, true); } @@ -333,6 +337,7 @@ public void testTxWithStoreOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxWithStorePessimistic() throws Exception { txWithStore(PESSIMISTIC, true); } @@ -340,6 +345,7 @@ public void testTxWithStorePessimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxWithStoreNoWriteThroughImplicit() throws Exception { txWithStore(null, false); } @@ -347,6 +353,7 @@ public void testTxWithStoreNoWriteThroughImplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxWithStoreNoWriteThroughOptimistic() throws Exception { txWithStore(OPTIMISTIC, false); } @@ -354,6 +361,7 @@ public void testTxWithStoreNoWriteThroughOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxWithStoreNoWriteThroughPessimistic() throws Exception { txWithStore(PESSIMISTIC, false); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheMvccTxSelfTest.java similarity index 54% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheMvccTxSelfTest.java index 4aa693c29c1b3..be7591cd52c43 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheMvccTxSelfTest.java @@ -14,27 +14,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.ignite.internal.processors.cache.distributed.dht; -package org.apache.ignite.internal.processors.cache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.junit.Test; -import org.apache.ignite.transactions.TransactionConcurrency; -import org.apache.ignite.transactions.TransactionIsolation; +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** - * Test getEntry and getEntries methods. + * */ -public class CacheGetEntryPessimisticRepeatableReadSeltTest extends CacheGetEntryAbstractTest { - /** {@inheritDoc} */ - @Override protected TransactionConcurrency concurrency() { - return TransactionConcurrency.PESSIMISTIC; - } - +public class IgniteCrossCacheMvccTxSelfTest extends IgniteCrossCacheTxAbstractSelfTest { /** {@inheritDoc} */ - @Override protected TransactionIsolation isolation() { - return TransactionIsolation.REPEATABLE_READ; + @Override public CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; } - @Override public void testReplicatedTransactional() throws Exception { - super.testReplicatedTransactional(); + /** + * @throws Exception If failed. + */ + @Test + public void testPessimisticRepeatableRead() throws Exception { + checkTxsSingleOp(PESSIMISTIC, REPEATABLE_READ); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxAbstractSelfTest.java new file mode 100644 index 0000000000000..d2769e392e947 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxAbstractSelfTest.java @@ -0,0 +1,165 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.dht; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; + +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; + +/** + * Tests specific combinations of cross-cache transactions. + */ +public abstract class IgniteCrossCacheTxAbstractSelfTest extends GridCommonAbstractTest { + /** */ + private static final String FIRST_CACHE = "FirstCache"; + + /** */ + private static final String SECOND_CACHE = "SecondCache"; + + /** */ + private static final int TX_CNT = 500; + + /** + * @return Node count for this test. + */ + private int nodeCount() { + return 4; + } + + /** + * @return {@code True} if near cache should be enabled. + */ + protected boolean nearEnabled() { + return false; + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override protected void beforeTestsStarted() throws Exception { + startGridsMultiThreaded(nodeCount()); + + CacheConfiguration firstCfg = new CacheConfiguration(FIRST_CACHE); + firstCfg.setBackups(1); + firstCfg.setAtomicityMode(atomicityMode()); + firstCfg.setWriteSynchronizationMode(FULL_SYNC); + + grid(0).createCache(firstCfg); + + CacheConfiguration secondCfg = new CacheConfiguration(SECOND_CACHE); + secondCfg.setBackups(1); + secondCfg.setAtomicityMode(atomicityMode()); + secondCfg.setWriteSynchronizationMode(FULL_SYNC); + + if (nearEnabled()) + secondCfg.setNearConfiguration(new NearCacheConfiguration()); + + grid(0).createCache(secondCfg); + } + + /** + * @return Atomicity mode. + */ + public abstract CacheAtomicityMode atomicityMode(); + + /** + * @param concurrency Concurrency. + * @param isolation Isolation. + * @throws Exception If failed. + */ + protected void checkTxsSingleOp(TransactionConcurrency concurrency, TransactionIsolation isolation) throws Exception { + Map firstCheck = new HashMap<>(); + Map secondCheck = new HashMap<>(); + + for (int i = 0; i < TX_CNT; i++) { + int grid = ThreadLocalRandom.current().nextInt(nodeCount()); + + IgniteCache first = grid(grid).cache(FIRST_CACHE); + IgniteCache second = grid(grid).cache(SECOND_CACHE); + + try (Transaction tx = grid(grid).transactions().txStart(concurrency, isolation)) { + try { + int size = ThreadLocalRandom.current().nextInt(24) + 1; + + for (int k = 0; k < size; k++) { + boolean rnd = ThreadLocalRandom.current().nextBoolean(); + + IgniteCache cache = rnd ? first : second; + Map check = rnd ? firstCheck : secondCheck; + + String val = rnd ? "first" + i : "second" + i; + + cache.put(k, val); + check.put(k, val); + } + + tx.commit(); + } + catch (Throwable e) { + e.printStackTrace(); + + throw e; + } + } + + if (i > 0 && i % 100 == 0) + info("Finished iteration: " + i); + } + + for (int g = 0; g < nodeCount(); g++) { + IgniteEx grid = grid(g); + + assertEquals(0, grid.context().cache().context().tm().idMapSize()); + + ClusterNode locNode = grid.localNode(); + + IgniteCache firstCache = grid.cache(FIRST_CACHE); + + for (Map.Entry entry : firstCheck.entrySet()) { + boolean primary = grid.affinity(FIRST_CACHE).isPrimary(locNode, entry.getKey()); + + boolean backup = grid.affinity(FIRST_CACHE).isBackup(locNode, entry.getKey()); + + assertEquals("Invalid value found first cache [primary=" + primary + ", backup=" + backup + + ", node=" + locNode.id() + ", key=" + entry.getKey() + ']', + entry.getValue(), firstCache.get(entry.getKey())); + } + + for (Map.Entry entry : secondCheck.entrySet()) { + boolean primary = grid.affinity(SECOND_CACHE).isPrimary(locNode, entry.getKey()); + + boolean backup = grid.affinity(SECOND_CACHE).isBackup(locNode, entry.getKey()); + + assertEquals("Invalid value found second cache [primary=" + primary + ", backup=" + backup + + ", node=" + locNode.id() + ", key=" + entry.getKey() + ']', + entry.getValue(), grid.cache(SECOND_CACHE).get(entry.getKey())); + } + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxSelfTest.java index 91c66850a6f23..b8ae501d67372 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCrossCacheTxSelfTest.java @@ -14,28 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.ignite.internal.processors.cache.distributed.dht; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ThreadLocalRandom; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.transactions.Transaction; -import org.apache.ignite.transactions.TransactionConcurrency; -import org.apache.ignite.transactions.TransactionIsolation; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; @@ -43,70 +28,19 @@ import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE; /** - * Tests specific combinations of cross-cache transactions. + * */ -public class IgniteCrossCacheTxSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final String FIRST_CACHE = "FirstCache"; - - /** */ - private static final String SECOND_CACHE = "SecondCache"; - - /** */ - private static final int TX_CNT = 500; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - - /** - * @return Node count for this test. - */ - private int nodeCount() { - return 4; - } - - /** - * @return {@code True} if near cache should be enabled. - */ - protected boolean nearEnabled() { - return false; - } - +@RunWith(JUnit4.class) +public class IgniteCrossCacheTxSelfTest extends IgniteCrossCacheTxAbstractSelfTest { /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override protected void beforeTestsStarted() throws Exception { - startGridsMultiThreaded(nodeCount()); - - CacheConfiguration firstCfg = new CacheConfiguration(FIRST_CACHE); - firstCfg.setBackups(1); - firstCfg.setAtomicityMode(TRANSACTIONAL); - firstCfg.setWriteSynchronizationMode(FULL_SYNC); - - grid(0).createCache(firstCfg); - - CacheConfiguration secondCfg = new CacheConfiguration(SECOND_CACHE); - secondCfg.setBackups(1); - secondCfg.setAtomicityMode(TRANSACTIONAL); - secondCfg.setWriteSynchronizationMode(FULL_SYNC); - - if (nearEnabled()) - secondCfg.setNearConfiguration(new NearCacheConfiguration()); - - grid(0).createCache(secondCfg); + @Override public CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL; } /** * @throws Exception If failed. */ + @Test public void testPessimisticReadCommitted() throws Exception { checkTxsSingleOp(PESSIMISTIC, READ_COMMITTED); } @@ -114,6 +48,7 @@ public void testPessimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticRepeatableRead() throws Exception { checkTxsSingleOp(PESSIMISTIC, REPEATABLE_READ); } @@ -121,6 +56,7 @@ public void testPessimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticReadCommitted() throws Exception { checkTxsSingleOp(OPTIMISTIC, READ_COMMITTED); } @@ -128,6 +64,7 @@ public void testOptimisticReadCommitted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticRepeatableRead() throws Exception { checkTxsSingleOp(OPTIMISTIC, REPEATABLE_READ); } @@ -135,82 +72,9 @@ public void testOptimisticRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSerializable() throws Exception { checkTxsSingleOp(OPTIMISTIC, SERIALIZABLE); } - /** - * @param concurrency Concurrency. - * @param isolation Isolation. - * @throws Exception If failed. - */ - private void checkTxsSingleOp(TransactionConcurrency concurrency, TransactionIsolation isolation) throws Exception { - Map firstCheck = new HashMap<>(); - Map secondCheck = new HashMap<>(); - - for (int i = 0; i < TX_CNT; i++) { - int grid = ThreadLocalRandom.current().nextInt(nodeCount()); - - IgniteCache first = grid(grid).cache(FIRST_CACHE); - IgniteCache second = grid(grid).cache(SECOND_CACHE); - - try (Transaction tx = grid(grid).transactions().txStart(concurrency, isolation)) { - try { - int size = ThreadLocalRandom.current().nextInt(24) + 1; - - for (int k = 0; k < size; k++) { - boolean rnd = ThreadLocalRandom.current().nextBoolean(); - - IgniteCache cache = rnd ? first : second; - Map check = rnd ? firstCheck : secondCheck; - - String val = rnd ? "first" + i : "second" + i; - - cache.put(k, val); - check.put(k, val); - } - - tx.commit(); - } - catch (Throwable e) { - e.printStackTrace(); - - throw e; - } - } - - if (i > 0 && i % 100 == 0) - info("Finished iteration: " + i); - } - - for (int g = 0; g < nodeCount(); g++) { - IgniteEx grid = grid(g); - - assertEquals(0, grid.context().cache().context().tm().idMapSize()); - - ClusterNode locNode = grid.localNode(); - - IgniteCache firstCache = grid.cache(FIRST_CACHE); - - for (Map.Entry entry : firstCheck.entrySet()) { - boolean primary = grid.affinity(FIRST_CACHE).isPrimary(locNode, entry.getKey()); - - boolean backup = grid.affinity(FIRST_CACHE).isBackup(locNode, entry.getKey()); - - assertEquals("Invalid value found first cache [primary=" + primary + ", backup=" + backup + - ", node=" + locNode.id() + ", key=" + entry.getKey() + ']', - entry.getValue(), firstCache.get(entry.getKey())); - } - - for (Map.Entry entry : secondCheck.entrySet()) { - boolean primary = grid.affinity(SECOND_CACHE).isPrimary(locNode, entry.getKey()); - - boolean backup = grid.affinity(SECOND_CACHE).isBackup(locNode, entry.getKey()); - - assertEquals("Invalid value found second cache [primary=" + primary + ", backup=" + backup + - ", node=" + locNode.id() + ", key=" + entry.getKey() + ']', - entry.getValue(), grid.cache(SECOND_CACHE).get(entry.getKey())); - } - } - } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java index e09cf53c51c11..0bad828931db9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/NotMappedPartitionInTxTest.java @@ -39,6 +39,9 @@ import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -49,6 +52,7 @@ /** */ @SuppressWarnings({"unchecked", "ThrowableNotThrown"}) +@RunWith(JUnit4.class) public class NotMappedPartitionInTxTest extends GridCommonAbstractTest { /** Cache. */ private static final String CACHE = "testCache"; @@ -62,23 +66,34 @@ public class NotMappedPartitionInTxTest extends GridCommonAbstractTest { /** Is client. */ private boolean isClient; + /** Atomicity mode. */ + private CacheAtomicityMode atomicityMode = CacheAtomicityMode.TRANSACTIONAL; + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + atomicityMode = CacheAtomicityMode.TRANSACTIONAL; + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { return super.getConfiguration(gridName) .setClientMode(isClient) .setCacheConfiguration( new CacheConfiguration(CACHE) - .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setAtomicityMode(atomicityMode) .setCacheMode(CacheMode.REPLICATED) .setAffinity(new TestAffinity()), new CacheConfiguration(CACHE2) - .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); + .setAtomicityMode(atomicityMode)); } /** * */ - public void testOneServerOptimistic() throws Exception { + @Test + public void testOneServerTx() throws Exception { try { isClient = false; startGrid(0); @@ -86,37 +101,11 @@ public void testOneServerOptimistic() throws Exception { isClient = true; final IgniteEx client = startGrid(1); - GridTestUtils.assertThrowsAnyCause(log, new Callable() { - @Override public Void call() throws Exception { - testNotMapped(client, OPTIMISTIC, REPEATABLE_READ); - - return null; - } - }, ClusterTopologyServerNotFoundException.class, "Failed to map keys to nodes (partition is not mapped to any node)"); - } - finally { - stopAllGrids(); - } - } - - /** - * - */ - public void testOneServerOptimisticSerializable() throws Exception { - try { - isClient = false; - startGrid(0); + checkNotMapped(client, OPTIMISTIC, REPEATABLE_READ); - isClient = true; - final IgniteEx client = startGrid(1); - - GridTestUtils.assertThrowsAnyCause(log, new Callable() { - @Override public Void call() throws Exception { - testNotMapped(client, OPTIMISTIC, SERIALIZABLE); + checkNotMapped(client, OPTIMISTIC, SERIALIZABLE); - return null; - } - }, ClusterTopologyServerNotFoundException.class, "Failed to map keys to nodes (partition is not mapped to any node)"); + checkNotMapped(client, PESSIMISTIC, READ_COMMITTED); } finally { stopAllGrids(); @@ -126,21 +115,20 @@ public void testOneServerOptimisticSerializable() throws Exception { /** * */ - public void testOneServerPessimistic() throws Exception { + @Test + public void testOneServerMvcc() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10377"); + try { + atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + isClient = false; startGrid(0); isClient = true; final IgniteEx client = startGrid(1); - GridTestUtils.assertThrowsAnyCause(log, new Callable() { - @Override public Void call() throws Exception { - testNotMapped(client, PESSIMISTIC, READ_COMMITTED); - - return null; - } - }, ClusterTopologyServerNotFoundException.class, "Failed to lock keys (all partition nodes left the grid)"); + checkNotMapped(client, PESSIMISTIC, REPEATABLE_READ); } finally { stopAllGrids(); @@ -150,21 +138,20 @@ public void testOneServerPessimistic() throws Exception { /** * */ - public void testFourServersOptimistic() throws Exception { + @Test + public void testFourServersTx() throws Exception { try { isClient = false; - startGrids(4); + startGridsMultiThreaded(4); isClient = true; final IgniteEx client = startGrid(4); - GridTestUtils.assertThrowsAnyCause(log, new Callable() { - @Override public Void call() throws Exception { - testNotMapped(client, OPTIMISTIC, REPEATABLE_READ); + checkNotMapped(client, OPTIMISTIC, REPEATABLE_READ); - return null; - } - }, ClusterTopologyServerNotFoundException.class, "Failed to map keys to nodes (partition is not mapped to any node)"); + checkNotMapped(client, OPTIMISTIC, SERIALIZABLE); + + checkNotMapped(client, PESSIMISTIC, READ_COMMITTED); } finally { stopAllGrids(); @@ -174,21 +161,20 @@ public void testFourServersOptimistic() throws Exception { /** * */ - public void testFourServersOptimisticSerializable() throws Exception { + @Test + public void testFourServersMvcc() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10377"); + try { + atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + isClient = false; - startGrids(4); + startGridsMultiThreaded(4); isClient = true; final IgniteEx client = startGrid(4); - GridTestUtils.assertThrowsAnyCause(log, new Callable() { - @Override public Void call() throws Exception { - testNotMapped(client, OPTIMISTIC, SERIALIZABLE); - - return null; - } - }, ClusterTopologyServerNotFoundException.class, "Failed to map keys to nodes (partition is not mapped to any node)"); + checkNotMapped(client, PESSIMISTIC, READ_COMMITTED); } finally { stopAllGrids(); @@ -196,50 +182,37 @@ public void testFourServersOptimisticSerializable() throws Exception { } /** - * + * @param client Ignite client. */ - public void testFourServersPessimistic() throws Exception { - try { - isClient = false; - startGrids(4); + private void checkNotMapped(final IgniteEx client, final TransactionConcurrency concurrency, + final TransactionIsolation isolation) { + String msg = concurrency == PESSIMISTIC ? "Failed to lock keys (all partition nodes left the grid)" : + "Failed to map keys to nodes (partition is not mapped to any node"; - isClient = true; - final IgniteEx client = startGrid(4); - GridTestUtils.assertThrowsAnyCause(log, new Callable() { - @Override public Void call() throws Exception { - testNotMapped(client, PESSIMISTIC, READ_COMMITTED); + GridTestUtils.assertThrowsAnyCause(log, new Callable() { + @Override public Void call() { + IgniteCache cache2 = client.cache(CACHE2); + IgniteCache cache1 = client.cache(CACHE).withKeepBinary(); - return null; - } - }, ClusterTopologyServerNotFoundException.class, "Failed to lock keys (all partition nodes left the grid)"); - } - finally { - stopAllGrids(); - } - } + try (Transaction tx = client.transactions().txStart(concurrency, isolation)) { - /** - * @param client Ignite client. - */ - private void testNotMapped(IgniteEx client, TransactionConcurrency concurrency, TransactionIsolation isolation) { - IgniteCache cache2 = client.cache(CACHE2); - IgniteCache cache1 = client.cache(CACHE).withKeepBinary(); + Map param = new TreeMap<>(); + param.put(TEST_KEY + 1, 1); + param.put(TEST_KEY + 1, 3); + param.put(TEST_KEY, 3); - try(Transaction tx = client.transactions().txStart(concurrency, isolation)) { + cache1.put(TEST_KEY, 3); - Map param = new TreeMap<>(); - param.put(TEST_KEY + 1, 1); - param.put(TEST_KEY + 1, 3); - param.put(TEST_KEY, 3); + cache1.putAll(param); + cache2.putAll(param); - cache1.put(TEST_KEY, 3); - - cache1.putAll(param); - cache2.putAll(param); + tx.commit(); + } - tx.commit(); - } + return null; + } + }, ClusterTopologyServerNotFoundException.class, msg); } /** */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/TxRecoveryStoreEnabledTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/TxRecoveryStoreEnabledTest.java index 30ac83d5f50b9..d4e9395197908 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/TxRecoveryStoreEnabledTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/TxRecoveryStoreEnabledTest.java @@ -43,6 +43,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -51,6 +54,7 @@ /** * */ +@RunWith(JUnit4.class) public class TxRecoveryStoreEnabledTest extends GridCommonAbstractTest { /** Nodes count. */ private static final int NODES_CNT = 2; @@ -102,6 +106,7 @@ public class TxRecoveryStoreEnabledTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testOptimistic() throws Exception { checkTxRecovery(OPTIMISTIC); } @@ -109,6 +114,7 @@ public void testOptimistic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimistic() throws Exception { checkTxRecovery(PESSIMISTIC); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicPutAllChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicPutAllChangingTopologyTest.java index 1eb8347d078ec..b49e2dfe1bed1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicPutAllChangingTopologyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicPutAllChangingTopologyTest.java @@ -28,14 +28,13 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -45,10 +44,8 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** */ +@RunWith(JUnit4.class) public class AtomicPutAllChangingTopologyTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES_CNT = 3; @@ -74,18 +71,10 @@ private CacheConfiguration cacheConfig() { .setName(CACHE_NAME); } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - /** * @throws Exception If failed. */ + @Test public void testPutAllOnChangingTopology() throws Exception { List futs = new LinkedList<>(); @@ -209,4 +198,4 @@ private void checkCacheState(Ignite node, IgniteCache cache) t ", actual2=" + locSize2 + "]", locSize, CACHE_SIZE); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java index ba17da04e378d..877a7a633bf48 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java @@ -48,10 +48,11 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -63,10 +64,8 @@ * Test GridDhtInvalidPartitionException handling in ATOMIC cache during restarts. */ @SuppressWarnings("ErrorNotRethrown") +@RunWith(JUnit4.class) public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Delay flag. */ private static volatile boolean delay; @@ -77,7 +76,7 @@ public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonA @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER).setForceServerMode(true)); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); CacheConfiguration ccfg = cacheConfiguration(); @@ -131,6 +130,7 @@ protected boolean testClientNode() { /** * @throws Exception If failed. */ + @Test public void testPrimaryFullSync() throws Exception { checkRestarts(FULL_SYNC); } @@ -138,6 +138,7 @@ public void testPrimaryFullSync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryPrimarySync() throws Exception { checkRestarts(PRIMARY_SYNC); } @@ -145,6 +146,7 @@ public void testPrimaryPrimarySync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryFullAsync() throws Exception { checkRestarts(FULL_ASYNC); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicPreloadSelfTest.java index a14c3efb3d3e1..da7ce8f034d60 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicPreloadSelfTest.java @@ -35,6 +35,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -44,6 +47,7 @@ /** * Simple test for preloading in ATOMIC cache. */ +@RunWith(JUnit4.class) public class GridCacheAtomicPreloadSelfTest extends GridCommonAbstractTest { /** */ private boolean nearEnabled; @@ -68,6 +72,7 @@ public class GridCacheAtomicPreloadSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPessimisticSimpleTxsNear() throws Exception { checkSimpleTxs(true, PESSIMISTIC); } @@ -75,6 +80,7 @@ public void testPessimisticSimpleTxsNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticSimpleTxsColocated() throws Exception { checkSimpleTxs(false, PESSIMISTIC); } @@ -82,6 +88,7 @@ public void testPessimisticSimpleTxsColocated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSimpleTxsColocated() throws Exception { checkSimpleTxs(false, OPTIMISTIC); } @@ -89,6 +96,7 @@ public void testOptimisticSimpleTxsColocated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticSimpleTxsNear() throws Exception { checkSimpleTxs(false, OPTIMISTIC); } @@ -218,4 +226,4 @@ private List generateKeys(ClusterNode node, IgniteCache return keys; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java index 14c85717ae857..34809b6d81673 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java @@ -44,11 +44,11 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; @@ -59,10 +59,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String TEST_CACHE = "testCache"; @@ -81,7 +79,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest { cfg.setConsistentId(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); cfg.setClientFailureDetectionTimeout(Integer.MAX_VALUE); TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi(); @@ -122,6 +119,7 @@ private void blockRebalance() { /** * @throws Exception If failed. */ + @Test public void testPutAllPrimaryFailure1() throws Exception { putAllPrimaryFailure(true, false); } @@ -129,6 +127,7 @@ public void testPutAllPrimaryFailure1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllPrimaryFailure1_UnstableTopology() throws Exception { blockRebalance = true; @@ -138,6 +137,7 @@ public void testPutAllPrimaryFailure1_UnstableTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllPrimaryFailure2() throws Exception { putAllPrimaryFailure(true, true); } @@ -145,6 +145,7 @@ public void testPutAllPrimaryFailure2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllPrimaryFailure2_UnstableTopology() throws Exception { blockRebalance = true; @@ -214,6 +215,7 @@ private void putAllPrimaryFailure(boolean fail0, boolean fail1) throws Exception /** * @throws Exception If failed. */ + @Test public void testPutAllBackupFailure1() throws Exception { putAllBackupFailure1(); } @@ -221,6 +223,7 @@ public void testPutAllBackupFailure1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllBackupFailure1_UnstableTopology() throws Exception { blockRebalance = true; @@ -275,6 +278,7 @@ private void putAllBackupFailure1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutBackupFailure1() throws Exception { putBackupFailure1(); } @@ -282,6 +286,7 @@ public void testPutBackupFailure1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutBackupFailure1_UnstableTopology() throws Exception { blockRebalance = true; @@ -331,6 +336,7 @@ private void putBackupFailure1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFullAsyncPutRemap() throws Exception { fullAsyncRemap(false); } @@ -338,6 +344,7 @@ public void testFullAsyncPutRemap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFullAsyncPutAllRemap() throws Exception { fullAsyncRemap(true); } @@ -406,6 +413,7 @@ private void fullAsyncRemap(boolean putAll) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutPrimarySync() throws Exception { startGrids(2); @@ -448,6 +456,7 @@ public void testPutPrimarySync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutNearNodeFailure() throws Exception { startGrids(2); @@ -485,6 +494,7 @@ public void testPutNearNodeFailure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllNearNodeFailure() throws Exception { final int SRVS = 4; @@ -545,6 +555,7 @@ public void testPutAllNearNodeFailure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheOperations0() throws Exception { cacheOperations(0); } @@ -552,6 +563,7 @@ public void testCacheOperations0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheOperations_UnstableTopology0() throws Exception { blockRebalance = true; @@ -561,6 +573,7 @@ public void testCacheOperations_UnstableTopology0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheOperations1() throws Exception { cacheOperations(1); } @@ -568,6 +581,7 @@ public void testCacheOperations1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheOperations_UnstableTopology1() throws Exception { blockRebalance = true; @@ -577,6 +591,7 @@ public void testCacheOperations_UnstableTopology1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheOperations2() throws Exception { cacheOperations(2); } @@ -584,6 +599,7 @@ public void testCacheOperations2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheOperations_UnstableTopology2() throws Exception { blockRebalance = true; @@ -639,6 +655,7 @@ private void cacheOperations(int backups) throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutMissedDhtRequest_UnstableTopology() throws Exception { blockRebalance = true; @@ -678,6 +695,7 @@ public void testPutMissedDhtRequest_UnstableTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllMissedDhtRequest_UnstableTopology1() throws Exception { putAllMissedDhtRequest_UnstableTopology(true, false); } @@ -685,6 +703,7 @@ public void testPutAllMissedDhtRequest_UnstableTopology1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllMissedDhtRequest_UnstableTopology2() throws Exception { putAllMissedDhtRequest_UnstableTopology(true, true); } @@ -750,6 +769,7 @@ private void putAllMissedDhtRequest_UnstableTopology(boolean fail0, boolean fail /** * @throws Exception If failed. */ + @Test public void testPutReaderUpdate1() throws Exception { readerUpdateDhtFails(false, false, false); @@ -761,6 +781,7 @@ public void testPutReaderUpdate1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutReaderUpdate2() throws Exception { readerUpdateDhtFails(true, false, false); @@ -772,6 +793,7 @@ public void testPutReaderUpdate2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllReaderUpdate1() throws Exception { readerUpdateDhtFails(false, false, true); @@ -783,6 +805,7 @@ public void testPutAllReaderUpdate1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllReaderUpdate2() throws Exception { readerUpdateDhtFails(true, false, true); @@ -806,13 +829,15 @@ private void readerUpdateDhtFails(boolean updateNearEnabled, startServers(2); - // Waiting for minor topology changing because of late affinity assignment. - awaitPartitionMapExchange(); - Ignite srv0 = ignite(0); Ignite srv1 = ignite(1); - List keys = primaryKeys(srv0.cache(TEST_CACHE), putAll ? 3 : 1); + IgniteCache cache = srv0.cache(TEST_CACHE); + + // Waiting for minor topology changing because of late affinity assignment. + awaitPartitionMapExchange(); + + List keys = primaryKeys(cache, putAll ? 3 : 1); ccfg = null; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAbstractNearPartitionedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAbstractNearPartitionedByteArrayValuesSelfTest.java index c6c849ac9bd42..a352f8fa631df 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAbstractNearPartitionedByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAbstractNearPartitionedByteArrayValuesSelfTest.java @@ -19,6 +19,8 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheAbstractPartitionedByteArrayValuesSelfTest; +import org.junit.Ignore; +import org.junit.Test; /** * Tests for byte array values in NEAR-PARTITIONED caches. @@ -29,4 +31,18 @@ public abstract class GridCacheAbstractNearPartitionedByteArrayValuesSelfTest ex @Override protected NearCacheConfiguration nearConfiguration() { return new NearCacheConfiguration(); } -} \ No newline at end of file + + /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + @Override public void testPessimisticMvcc() throws Exception { + super.testPessimisticMvcc(); + } + + /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + @Override public void testPessimisticMvccMixed() throws Exception { + super.testPessimisticMvccMixed(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java index 5de7af055f262..7a9812abfe0e8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java @@ -36,6 +36,9 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -44,6 +47,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCacheNearOnlyMultiNodeFullApiSelfTest { /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { @@ -80,16 +84,19 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache } /** {@inheritDoc} */ - @Override public void _testReaderTtlNoTx() throws Exception { + @Test + @Override public void testReaderTtlNoTx() { // No-op. } /** {@inheritDoc} */ - @Override public void _testReaderTtlTx() throws Exception { + @Test + @Override public void testReaderTtlTx() { // No-op. } /** {@inheritDoc} */ + @Test @Override public void testSize() throws Exception { IgniteCache cache = jcache(); @@ -119,6 +126,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache } /** {@inheritDoc} */ + @Test @Override public void testClear() throws Exception { IgniteCache nearCache = jcache(); IgniteCache primary = fullCache(); @@ -154,6 +162,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache } /** {@inheritDoc} */ + @Test @Override public void testLocalClearKeys() throws Exception { IgniteCache nearCache = jcache(); IgniteCache primary = fullCache(); @@ -185,6 +194,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache } /** {@inheritDoc} */ + @Test @Override public void testEvictExpired() throws Exception { IgniteCache cache = jcache(); @@ -232,6 +242,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache } /** {@inheritDoc} */ + @Test @Override public void testLocalEvict() throws Exception { IgniteCache cache = jcache(); @@ -281,6 +292,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache } /** {@inheritDoc} */ + @Test @Override public void testPeekExpired() throws Exception { IgniteCache c = jcache(); @@ -303,4 +315,4 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache assert c.localSize() == 0 : "Cache is not empty."; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java index c78c976869cad..7e64ce03a4792 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java @@ -18,26 +18,23 @@ package org.apache.ignite.internal.processors.cache.distributed.near; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.Map; -import javax.cache.expiry.Duration; -import javax.cache.expiry.TouchedExpiryPolicy; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.util.lang.GridAbsPredicate; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; -import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; /** * Tests NEAR_ONLY cache. */ +@RunWith(JUnit4.class) public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNearOnlyMultiNodeFullApiSelfTest { /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { @@ -82,6 +79,7 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe } /** {@inheritDoc} */ + @Test @Override public void testClear() throws Exception { IgniteCache nearCache = jcache(); IgniteCache primary = fullCache(); @@ -118,4 +116,4 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe for (String key : keys) assertEquals((Integer)i++, nearCache.localPeek(key, CachePeekMode.ONHEAP)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicPartitionedTckMetricsSelfTestImpl.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicPartitionedTckMetricsSelfTestImpl.java index da0c7a92d94f8..08a44ec10e9f8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicPartitionedTckMetricsSelfTestImpl.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicPartitionedTckMetricsSelfTestImpl.java @@ -21,10 +21,14 @@ import javax.cache.processor.EntryProcessorException; import javax.cache.processor.MutableEntry; import org.apache.ignite.IgniteCache; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Partitioned atomic cache metrics test. */ +@RunWith(JUnit4.class) public class GridCacheAtomicPartitionedTckMetricsSelfTestImpl extends GridCacheAtomicPartitionedMetricsSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -34,6 +38,7 @@ public class GridCacheAtomicPartitionedTckMetricsSelfTestImpl extends GridCacheA /** * @throws Exception If failed. */ + @Test public void testEntryProcessorRemove() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -68,6 +73,7 @@ public void testEntryProcessorRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheStatistics() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -108,6 +114,7 @@ public void testCacheStatistics() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConditionReplace() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -158,6 +165,7 @@ public void testConditionReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsent() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -177,7 +185,7 @@ public void testPutIfAbsent() throws Exception { assertEquals(putCount, cache.localMetrics().getCachePuts()); result = cache.putIfAbsent(1, 1); - + ++hitCount; cache.containsKey(123); @@ -187,4 +195,4 @@ public void testPutIfAbsent() throws Exception { assertEquals(putCount, cache.localMetrics().getCachePuts()); assertEquals(missCount, cache.localMetrics().getCacheMisses()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java index cb537ee67dfcf..731b623505e44 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java @@ -28,11 +28,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.IgniteReflectionFactory; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -45,27 +46,27 @@ /** * Checks that exception is propagated to user when cache store throws an exception. */ +@RunWith(JUnit4.class) public class GridCacheGetStoreErrorSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Near enabled flag. */ private boolean nearEnabled; /** Cache mode for test. */ private CacheMode cacheMode; + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(cacheMode); @@ -88,21 +89,25 @@ public class GridCacheGetStoreErrorSelfTest extends GridCommonAbstractTest { } /** @throws Exception If failed. */ + @Test public void testGetErrorNear() throws Exception { checkGetError(true, PARTITIONED); } /** @throws Exception If failed. */ + @Test public void testGetErrorColocated() throws Exception { checkGetError(false, PARTITIONED); } /** @throws Exception If failed. */ + @Test public void testGetErrorReplicated() throws Exception { checkGetError(false, REPLICATED); } /** @throws Exception If failed. */ + @Test public void testGetErrorLocal() throws Exception { checkGetError(false, LOCAL); } @@ -116,7 +121,7 @@ private void checkGetError(boolean nearEnabled, CacheMode cacheMode) throws Exce this.nearEnabled = nearEnabled; this.cacheMode = cacheMode; - startGrids(3); + startGridsMultiThreaded(3); try { GridTestUtils.assertThrows(log, new Callable() { @@ -166,4 +171,4 @@ public static class TestStore extends CacheStoreAdapter { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheMvccNearEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheMvccNearEvictionSelfTest.java new file mode 100644 index 0000000000000..3cc5b247e5e02 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheMvccNearEvictionSelfTest.java @@ -0,0 +1,33 @@ +/* + * 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. + */ +package org.apache.ignite.internal.processors.cache.distributed.near; + +import org.apache.ignite.cache.CacheAtomicityMode; +import org.junit.Ignore; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + +/** + * Test for mvcc cache. + */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-7187,https://issues.apache.org/jira/browse/IGNITE-7956") +public class GridCacheMvccNearEvictionSelfTest extends GridCacheNearEvictionSelfTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL_SNAPSHOT; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearAtomicMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearAtomicMetricsSelfTest.java index 4d82c71181fa5..da8d8e20d40d9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearAtomicMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearAtomicMetricsSelfTest.java @@ -22,10 +22,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Atomic cache metrics test. */ +@RunWith(JUnit4.class) public class GridCacheNearAtomicMetricsSelfTest extends GridCacheNearMetricsSelfTest { /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { @@ -39,6 +43,7 @@ public class GridCacheNearAtomicMetricsSelfTest extends GridCacheNearMetricsSelf /** * Checks that enabled near cache does not affect metrics. */ + @Test public void testNearCachePutRemoveGetMetrics() { IgniteEx initiator = grid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearClientHitTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearClientHitTest.java index 1dd62e49863be..083979b5925ce 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearClientHitTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearClientHitTest.java @@ -26,31 +26,21 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CachePeekMode.NEAR; /** * */ +@RunWith(JUnit4.class) public class GridCacheNearClientHitTest extends GridCommonAbstractTest { - /** Ip finder. */ - private final static TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private final static String CACHE_NAME = "test-near-cache"; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception { - final IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** * @param igniteInstanceName Node name. * @return Configuration. @@ -71,14 +61,11 @@ private CacheConfiguration cacheConfiguration() { CacheConfiguration cfg = new CacheConfiguration<>(); cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); - cfg.setCacheMode(CacheMode.PARTITIONED); - cfg.setBackups(1); - cfg.setCopyOnRead(false); - cfg.setName(CACHE_NAME); + cfg.setNearConfiguration(new NearCacheConfiguration<>()); return cfg; } @@ -97,6 +84,7 @@ private NearCacheConfiguration nearCacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testLocalPeekAfterPrimaryNodeLeft() throws Exception { try { Ignite crd = startGrid("coordinator", getConfiguration("coordinator")); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearEvictionSelfTest.java index 9c7c93345d9d5..37124c76e2c32 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearEvictionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearEvictionSelfTest.java @@ -27,11 +27,11 @@ import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -41,13 +41,11 @@ /** * Tests entries distribution between primary-backup-near caches according to nodes count in grid. */ +@RunWith(JUnit4.class) public class GridCacheNearEvictionSelfTest extends GridCommonAbstractTest { /** Grid count. */ private int gridCnt; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -66,12 +64,6 @@ public class GridCacheNearEvictionSelfTest extends GridCommonAbstractTest { c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - return c; } @@ -83,6 +75,7 @@ protected CacheAtomicityMode atomicityMode() { } /** @throws Exception If failed. */ + @Test public void testNearEnabledOneNode() throws Exception { gridCnt = 1; @@ -106,6 +99,7 @@ public void testNearEnabledOneNode() throws Exception { } /** @throws Exception If failed. */ + @Test public void testNearEnabledTwoNodes() throws Exception { gridCnt = 2; @@ -139,6 +133,7 @@ public void testNearEnabledTwoNodes() throws Exception { } /** @throws Exception If failed. */ + @Test public void testNearEnabledThreeNodes() throws Exception { gridCnt = 3; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java index 70b06f34f2d9f..17f2e34d6b6e1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java @@ -29,12 +29,17 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * Cache metrics test. */ +@RunWith(JUnit4.class) public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int KEY_CNT = 50; @@ -83,6 +88,8 @@ protected int keyCount() { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.METRICS); + super.beforeTest(); for (int i = 0; i < gridCount(); i++) { @@ -107,6 +114,7 @@ protected int keyCount() { /** * @throws Exception If failed. */ + @Test public void testNearCacheDoesNotAffectCacheSize() throws Exception { IgniteCache cache0 = grid(0).cache(DEFAULT_CACHE_NAME); @@ -132,6 +140,7 @@ public void testNearCacheDoesNotAffectCacheSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimaryPut() throws Exception { Ignite g0 = grid(0); @@ -187,6 +196,7 @@ public void testPrimaryPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupPut() throws Exception { Ignite g0 = grid(0); @@ -241,6 +251,7 @@ else if (affinity(jcache).isBackup(g.cluster().localNode(), key)){ /** * @throws Exception If failed. */ + @Test public void testNearPut() throws Exception { Ignite g0 = grid(0); @@ -293,6 +304,7 @@ else if (affinity(jcache).isBackup(g.cluster().localNode(), key)){ /** * @throws Exception If failed. */ + @Test public void testPrimaryRead() throws Exception { Ignite g0 = grid(0); @@ -349,6 +361,7 @@ public void testPrimaryRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBackupRead() throws Exception { Ignite g0 = grid(0); @@ -400,6 +413,7 @@ public void testBackupRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearRead() throws Exception { Ignite g0 = grid(0); @@ -453,6 +467,7 @@ else if (affinity(jcache).isBackup(g.cluster().localNode(), key)){ /** * @throws Exception If failed. */ + @Test public void testCreateReadRemoveInvokesFromPrimary() throws Exception { Ignite g0 = grid(0); @@ -508,6 +523,7 @@ else if (affinity(jcache).isBackup(g.cluster().localNode(), key)) { /** * @throws Exception If failed. */ + @Test public void testCreateReadRemoveInvokesFromBackup() throws Exception { Ignite g0 = grid(0); @@ -563,6 +579,7 @@ else if (affinity(jcache).isBackup(g.cluster().localNode(), key)) { /** * @throws Exception If failed. */ + @Test public void testCreateReadRemoveInvokesFromNear() throws Exception { Ignite g0 = grid(0); @@ -618,6 +635,7 @@ public void testCreateReadRemoveInvokesFromNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadRemoveInvokesFromPrimary() throws Exception { Ignite g0 = grid(0); @@ -664,6 +682,7 @@ else if (affinity(jcache).isBackup(g.cluster().localNode(), key)) { /** * @throws Exception If failed. */ + @Test public void testReadRemoveInvokesFromBackup() throws Exception { Ignite g0 = grid(0); @@ -709,6 +728,7 @@ else if (affinity(jcache).isBackup(g.cluster().localNode(), key)) { /** * @throws Exception If failed. */ + @Test public void testReadRemoveInvokesFromNear() throws Exception { Ignite g0 = grid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java index e27c9ad8fe9ee..4a417893d6286 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java @@ -20,24 +20,25 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionOptimisticException; -import org.apache.log4j.Level; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.NONE; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -49,10 +50,8 @@ /** * Test getting the same value twice within the same transaction. */ +@RunWith(JUnit4.class) public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest { - /** Cache debug flag. */ - private static final boolean CACHE_DEBUG = false; - /** Number of gets. */ private static final int GET_CNT = 5; @@ -60,43 +59,33 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest { private static final int GRID_CNT = 3; /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @SuppressWarnings({"ConstantConditions"}) - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - - c.getTransactionConfiguration().setTxSerializableEnabled(true); + private CacheAtomicityMode atomicityMode; + /** + * @return Cache configuration. + */ + private CacheConfiguration cacheConfiguration() { CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); cc.setBackups(1); - cc.setAtomicityMode(TRANSACTIONAL); - + cc.setAtomicityMode(atomicityMode); cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - cc.setRebalanceMode(NONE); + cc.setNearConfiguration(new NearCacheConfiguration()); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - - c.setCacheConfiguration(cc); - - if (CACHE_DEBUG) - resetLog4j(Level.DEBUG, false, GridCacheProcessor.class.getPackage().getName()); - - return c; + return cc; } /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { - for (int i = 0; i < GRID_CNT; i++) - startGrid(i); + startGridsMultiThreaded(GRID_CNT); + } + + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + atomicityMode = TRANSACTIONAL; } /** {@inheritDoc} */ @@ -111,6 +100,8 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest { assertEquals("Cache size mismatch for grid [igniteInstanceName=" + g.name() + ", entrySet=" + entrySet(c) + ']', 0, c.size()); } + + grid(0).destroyCache(DEFAULT_CACHE_NAME); } /** @return {@code True} if debug enabled. */ @@ -119,101 +110,137 @@ private boolean isTestDebug() { } /** @throws Exception If failed. */ + @Test public void testOptimisticReadCommittedNoPut() throws Exception { checkDoubleGet(OPTIMISTIC, READ_COMMITTED, false); } /** @throws Exception If failed. */ + @Test public void testOptimisticReadCommittedWithPut() throws Exception { checkDoubleGet(OPTIMISTIC, READ_COMMITTED, true); } /** @throws Exception If failed. */ + @Test public void testOptimisticReadCommitted() throws Exception { checkDoubleGet(OPTIMISTIC, READ_COMMITTED, false); checkDoubleGet(OPTIMISTIC, READ_COMMITTED, true); } /** @throws Exception If failed. */ + @Test public void testOptimisticRepeatableReadNoPut() throws Exception { checkDoubleGet(OPTIMISTIC, REPEATABLE_READ, false); } /** @throws Exception If failed. */ + @Test public void testOptimisticRepeatableReadWithPut() throws Exception { checkDoubleGet(OPTIMISTIC, REPEATABLE_READ, true); } /** @throws Exception If failed. */ + @Test public void testOptimisticRepeatableRead() throws Exception { checkDoubleGet(OPTIMISTIC, REPEATABLE_READ, false); checkDoubleGet(OPTIMISTIC, REPEATABLE_READ, true); } /** @throws Exception If failed. */ + @Test public void testOptimisticSerializableNoPut() throws Exception { checkDoubleGet(OPTIMISTIC, SERIALIZABLE, false); } /** @throws Exception If failed. */ + @Test public void testOptimisticSerializableWithPut() throws Exception { checkDoubleGet(OPTIMISTIC, SERIALIZABLE, true); } /** @throws Exception If failed. */ + @Test public void testOptimisticSerializable() throws Exception { checkDoubleGet(OPTIMISTIC, SERIALIZABLE, false); checkDoubleGet(OPTIMISTIC, SERIALIZABLE, true); } /** @throws Exception If failed. */ + @Test public void testPessimisticReadCommittedNoPut() throws Exception { checkDoubleGet(PESSIMISTIC, READ_COMMITTED, false); } /** @throws Exception If failed. */ + @Test public void testPessimisticReadCommittedWithPut() throws Exception { checkDoubleGet(PESSIMISTIC, READ_COMMITTED, true); } /** @throws Exception If failed. */ + @Test public void testPessimisticReadCommitted() throws Exception { checkDoubleGet(PESSIMISTIC, READ_COMMITTED, false); checkDoubleGet(PESSIMISTIC, READ_COMMITTED, true); } /** @throws Exception If failed. */ + @Test public void testPessimisticRepeatableReadNoPut() throws Exception { checkDoubleGet(PESSIMISTIC, REPEATABLE_READ, false); } /** @throws Exception If failed. */ + @Test public void testPessimisticRepeatableReadWithPut() throws Exception { checkDoubleGet(PESSIMISTIC, REPEATABLE_READ, true); } /** @throws Exception If failed. */ + @Test public void testPessimisticRepeatableRead() throws Exception { checkDoubleGet(PESSIMISTIC, REPEATABLE_READ, false); checkDoubleGet(PESSIMISTIC, REPEATABLE_READ, true); } /** @throws Exception If failed. */ + @Test public void testPessimisticSerializableNoPut() throws Exception { checkDoubleGet(PESSIMISTIC, SERIALIZABLE, false); } /** @throws Exception If failed. */ + @Test public void testPessimisticSerializableWithPut() throws Exception { checkDoubleGet(PESSIMISTIC, SERIALIZABLE, true); } /** @throws Exception If failed. */ + @Test public void testPessimisticSerializable() throws Exception { checkDoubleGet(PESSIMISTIC, SERIALIZABLE, false); checkDoubleGet(PESSIMISTIC, SERIALIZABLE, true); } + /** @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testMvccPessimisticRepeatableReadNoPut() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + checkDoubleGet(PESSIMISTIC, REPEATABLE_READ, false); + } + + /** @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testMvccPessimisticRepeatableReadWithPut() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + checkDoubleGet(PESSIMISTIC, REPEATABLE_READ, true); + } + /** * @param concurrency Concurrency. * @param isolation Isolation. @@ -223,7 +250,7 @@ public void testPessimisticSerializable() throws Exception { private void checkDoubleGet(TransactionConcurrency concurrency, TransactionIsolation isolation, boolean put) throws Exception { IgniteEx ignite = grid(0); - IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); + IgniteCache cache = ignite.getOrCreateCache(cacheConfiguration()); Integer key = 1; @@ -308,4 +335,4 @@ private void checkDoubleGet(TransactionConcurrency concurrency, TransactionIsola ", t=" + t + (t != tx ? "tx=" + tx : "tx=''") + ']'; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java index 06e18627ab95f..602029a2f785b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java @@ -53,12 +53,13 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -69,6 +70,7 @@ /** * Multi node test for near cache. */ +@RunWith(JUnit4.class) public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 2; @@ -79,8 +81,14 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { /** Cache store. */ private static TestStore store = new TestStore(); - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + + super.setUp(); + } /** Grid counter. */ private AtomicInteger cntr = new AtomicInteger(0); @@ -103,12 +111,6 @@ public GridCacheNearMultiNodeSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); @@ -247,6 +249,7 @@ private Map, Set>> mapKeys(int cnt) { } /** Test mappings. */ + @Test public void testMappings() { mapDebug = false; @@ -307,6 +310,7 @@ public void testMappings() { } /** @throws Exception If failed. */ + @Test public void testReadThroughAndPut() throws Exception { Integer key = 100000; @@ -330,6 +334,7 @@ public void testReadThroughAndPut() throws Exception { } /** @throws Exception If failed. */ + @Test public void testReadThrough() throws Exception { ClusterNode loc = grid(0).localNode(); @@ -362,7 +367,7 @@ public void testReadThrough() throws Exception { GridCacheAdapter dhtCache = dht(G.ignite(n.id())); - String s = dhtCache.localPeek(key, null, null); + String s = dhtCache.localPeek(key, null); assert s != null : "Value is null for key: " + key; assertEquals(s, Integer.toString(key)); @@ -375,6 +380,7 @@ public void testReadThrough() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"ConstantConditions"}) + @Test public void testOptimisticWriteThrough() throws Exception { IgniteCache near = jcache(0); @@ -420,6 +426,7 @@ public void testOptimisticWriteThrough() throws Exception { } /** @throws Exception If failed. */ + @Test public void testNoTransactionSinglePutx() throws Exception { IgniteCache near = jcache(0); @@ -437,6 +444,7 @@ public void testNoTransactionSinglePutx() throws Exception { } /** @throws Exception If failed. */ + @Test public void testNoTransactionSinglePut() throws Exception { IgniteCache near = jcache(0); @@ -479,6 +487,7 @@ public void testNoTransactionSinglePut() throws Exception { } /** @throws Exception If failed. */ + @Test public void testNoTransactionWriteThrough() throws Exception { IgniteCache near = jcache(0); @@ -508,6 +517,7 @@ public void testNoTransactionWriteThrough() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"ConstantConditions"}) + @Test public void testPessimisticWriteThrough() throws Exception { IgniteCache near = jcache(0); @@ -522,7 +532,7 @@ public void testPessimisticWriteThrough() throws Exception { assertEquals("2", near.get(2)); assertEquals("3", near.get(3)); - assertNotNull(dht(primaryGrid(3)).localPeek(3, null, null)); + assertNotNull(dht(primaryGrid(3)).localPeek(3, null)); tx.commit(); } @@ -547,6 +557,7 @@ public void testPessimisticWriteThrough() throws Exception { } /** @throws Exception If failed. */ + @Test public void testConcurrentOps() throws Exception { // Don't create missing values. store.create(false); @@ -578,11 +589,13 @@ public void testConcurrentOps() throws Exception { } /** @throws Exception If failed. */ + @Test public void testBackupsLocalAffinity() throws Exception { checkBackupConsistency(2); } /** @throws Exception If failed. */ + @Test public void testBackupsRemoteAffinity() throws Exception { checkBackupConsistency(1); } @@ -609,11 +622,13 @@ private void checkBackupConsistency(int key) throws Exception { } /** @throws Exception If failed. */ + @Test public void testSingleLockLocalAffinity() throws Exception { checkSingleLock(2); } /** @throws Exception If failed. */ + @Test public void testSingleLockRemoteAffinity() throws Exception { checkSingleLock(1); } @@ -724,11 +739,13 @@ private void checkSingleLock(int key) throws Exception { } /** @throws Throwable If failed. */ + @Test public void testSingleLockReentryLocalAffinity() throws Throwable { checkSingleLockReentry(2); } /** @throws Throwable If failed. */ + @Test public void testSingleLockReentryRemoteAffinity() throws Throwable { checkSingleLockReentry(1); } @@ -791,11 +808,13 @@ private void checkSingleLockReentry(int key) throws Throwable { } /** @throws Exception If failed. */ + @Test public void testTransactionSingleGetLocalAffinity() throws Exception { checkTransactionSingleGet(2); } /** @throws Exception If failed. */ + @Test public void testTransactionSingleGetRemoteAffinity() throws Exception { checkTransactionSingleGet(1); } @@ -837,11 +856,13 @@ private void checkTransactionSingleGet(int key) throws Exception { } /** @throws Exception If failed. */ + @Test public void testTransactionSingleGetRemoveLocalAffinity() throws Exception { checkTransactionSingleGetRemove(2); } /** @throws Exception If failed. */ + @Test public void testTransactionSingleGetRemoveRemoteAffinity() throws Exception { checkTransactionSingleGetRemove(1); } @@ -951,4 +972,4 @@ boolean isEmpty() { map.remove(key); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java index d4f485aaaf2f7..635f80dd819c5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java @@ -26,12 +26,17 @@ import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -42,10 +47,18 @@ /** * Single node test for near cache. */ +@RunWith(JUnit4.class) public class GridCacheNearOneNodeSelfTest extends GridCommonAbstractTest { /** Cache store. */ private static TestStore store = new TestStore(); + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.setUp(); + } + /** * */ @@ -80,8 +93,8 @@ public GridCacheNearOneNodeSelfTest() { cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setBackups(1); cacheCfg.setAtomicityMode(TRANSACTIONAL); - cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); + cacheCfg.setNearConfiguration(new NearCacheConfiguration()); cacheCfg.setCacheStoreFactory(singletonFactory(store)); cacheCfg.setReadThrough(true); @@ -94,6 +107,7 @@ public GridCacheNearOneNodeSelfTest() { } /** @throws Exception If failed. */ + @Test public void testRemove() throws Exception { IgniteCache near = jcache(); @@ -122,6 +136,7 @@ public void testRemove() throws Exception { } /** @throws Exception If failed. */ + @Test public void testReadThrough() throws Exception { IgniteCache near = jcache(); @@ -151,7 +166,7 @@ public void testReadThrough() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings({"ConstantConditions"}) + @Test public void testOptimisticTxWriteThrough() throws Exception { IgniteCache near = jcache(); GridCacheAdapter dht = dht(); @@ -184,6 +199,7 @@ public void testOptimisticTxWriteThrough() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSingleLockPut() throws Exception { IgniteCache near = jcache(); @@ -206,6 +222,7 @@ public void testSingleLockPut() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSingleLock() throws Exception { IgniteCache near = jcache(); @@ -237,6 +254,7 @@ public void testSingleLock() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSingleLockReentry() throws Exception { IgniteCache near = jcache(); @@ -281,6 +299,7 @@ public void testSingleLockReentry() throws Exception { } /** @throws Exception If failed. */ + @Test public void testTransactionSingleGet() throws Exception { IgniteCache cache = jcache(); @@ -300,6 +319,7 @@ public void testTransactionSingleGet() throws Exception { } /** @throws Exception If failed. */ + @Test public void testTransactionSingleGetRemove() throws Exception { IgniteCache cache = jcache(); @@ -385,4 +405,4 @@ boolean isEmpty() { map.remove(key); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java index ed436d006d872..103abddb19f67 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java @@ -50,6 +50,9 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_LOCKED; @@ -58,6 +61,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitionedMultiNodeFullApiSelfTest { /** */ private static AtomicInteger cnt; @@ -175,6 +179,7 @@ protected boolean clientHasNearCache() { } /** {@inheritDoc} */ + @Test @Override public void testSize() throws Exception { IgniteCache nearCache = jcache(); @@ -204,29 +209,28 @@ protected boolean clientHasNearCache() { } /** {@inheritDoc} */ + @Test @Override public void testLoadAll() throws Exception { // Not needed for near-only cache. } /** - * TODO GG-11133. - * @throws Exception If failed. */ - public void _testReaderTtlTx() throws Exception { + @Test + public void testReaderTtlTx() throws Exception { // IgniteProcessProxy#transactions is not implemented. - if (isMultiJvm()) + if (isMultiJvm() || !txShouldBeUsed()) return; checkReaderTtl(true); } /** - * TODO GG-11133. - * @throws Exception If failed. */ - public void _testReaderTtlNoTx() throws Exception { + @Test + public void testReaderTtlNoTx() throws Exception { checkReaderTtl(false); } @@ -252,7 +256,7 @@ private void checkReaderTtl(boolean inTx) throws Exception { final String key = primaryKeysForCache(fullCache(), 1).get(0); - c.put(key, 1); + fullCache().put(key, 1); info("Finished first put."); @@ -285,6 +289,8 @@ private void checkReaderTtl(boolean inTx) throws Exception { tx.close(); } + jcache(nearIdx).get(key); // Create entry on near node. + long[] expireTimes = new long[gridCount()]; for (int i = 0; i < gridCount(); i++) { @@ -300,8 +306,8 @@ else if (i == nearIdx) if (entryTtl != null) { assertNotNull(entryTtl.get1()); assertNotNull(entryTtl.get2()); - assertEquals(ttl, (long)entryTtl.get1()); - assertTrue(entryTtl.get2() > startTime); + assertTrue("Invalid expire time [expire=" + entryTtl.get2() + ", start=" + startTime + ']', + entryTtl.get2() > startTime); expireTimes[i] = entryTtl.get2(); } } @@ -333,7 +339,6 @@ else if (i == nearIdx) if (entryTtl != null) { assertNotNull(entryTtl.get1()); assertNotNull(entryTtl.get2()); - assertEquals(ttl, (long)entryTtl.get1()); assertTrue(entryTtl.get2() > startTime); expireTimes[i] = entryTtl.get2(); } @@ -363,7 +368,6 @@ else if (i == nearIdx) if (entryTtl != null) { assertNotNull(entryTtl.get1()); assertNotNull(entryTtl.get2()); - assertEquals(ttl, (long)entryTtl.get1()); assertEquals(expireTimes[i], (long)entryTtl.get2()); } } @@ -435,6 +439,7 @@ else if (i == nearIdx) } /** {@inheritDoc} */ + @Test @Override public void testClear() throws Exception { IgniteCache nearCache = jcache(); IgniteCache primary = fullCache(); @@ -487,6 +492,7 @@ else if (i == nearIdx) } /** {@inheritDoc} */ + @Test @Override public void testLocalClearKeys() throws Exception { IgniteCache nearCache = jcache(); IgniteCache primary = fullCache(); @@ -554,6 +560,7 @@ else if (i == nearIdx) /** {@inheritDoc} */ @SuppressWarnings("BusyWait") + @Test @Override public void testLockUnlock() throws Exception { if (lockingEnabled()) { final CountDownLatch lockCnt = new CountDownLatch(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlySelfTest.java index bf8c1ca089fbe..ae94888cd29c1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlySelfTest.java @@ -22,6 +22,9 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -32,10 +35,12 @@ * Near only self test. */ @SuppressWarnings("RedundantMethodOverride") +@RunWith(JUnit4.class) public abstract class GridCacheNearOnlySelfTest extends GridCacheClientModesAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testUpdateNearOnlyReader() throws Exception { IgniteCache dhtCache = dhtCache(); @@ -114,4 +119,4 @@ public static class CasePartitionedTransactional extends GridCacheNearOnlySelfTe return TRANSACTIONAL; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java index 2124bc8ef7e11..92df08162600d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java @@ -27,11 +27,13 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -43,16 +45,19 @@ /** * Near-only cache node startup test. */ +@RunWith(JUnit4.class) public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { - /** Shared ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Near only flag. */ private boolean cilent; /** Use cache flag. */ private boolean cache = true; + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -71,42 +76,43 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheCfg); } - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setForceServerMode(true); - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); return cfg; } /** @throws Exception If failed. */ + @Test public void testStartupFirstOneNode() throws Exception { checkStartupNearNode(0, 2); } /** @throws Exception If failed. */ + @Test public void testStartupLastOneNode() throws Exception { checkStartupNearNode(1, 2); } /** @throws Exception If failed. */ + @Test public void testStartupFirstTwoNodes() throws Exception { checkStartupNearNode(0, 3); } /** @throws Exception If failed. */ + @Test public void testStartupInMiddleTwoNodes() throws Exception { checkStartupNearNode(1, 3); } /** @throws Exception If failed. */ + @Test public void testStartupLastTwoNodes() throws Exception { checkStartupNearNode(2, 3); } /** @throws Exception If failed. */ + @Test public void testKeyMapping() throws Exception { try { cache = true; @@ -129,6 +135,7 @@ public void testKeyMapping() throws Exception { } /** @throws Exception If failed. */ + @Test public void testKeyMappingOnComputeNode() throws Exception { try { cache = true; @@ -160,6 +167,7 @@ public void testKeyMappingOnComputeNode() throws Exception { } /** @throws Exception If failed. */ + @Test public void testNodeLeave() throws Exception { try { cache = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java index cbdc8551dd7f1..d55efe1a31ec1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java @@ -26,10 +26,11 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheGenericTestStore; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -40,6 +41,7 @@ * Test clear operation in NEAR_PARTITIONED transactional cache. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class GridCacheNearPartitionedClearSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 3; @@ -53,11 +55,10 @@ public class GridCacheNearPartitionedClearSelfTest extends GridCommonAbstractTes /** */ private static CacheStore store = new GridCacheGenericTestStore<>(); - /** Shared IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + startGrids(GRID_CNT); } @@ -72,12 +73,6 @@ public class GridCacheNearPartitionedClearSelfTest extends GridCommonAbstractTes cfg.setLocalHost("127.0.0.1"); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setName(CACHE_NAME); @@ -102,6 +97,7 @@ public class GridCacheNearPartitionedClearSelfTest extends GridCommonAbstractTes * * @throws Exception If failed. */ + @Test public void testClear() throws Exception { IgniteCache cache = cacheForIndex(0); @@ -151,4 +147,4 @@ private int primaryKey0(Ignite ignite, IgniteCache cache) throws Exception { private IgniteCache cacheForIndex(int idx) { return grid(idx).cache(CACHE_NAME); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java index e143260f798d2..e085bfbbc331a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java @@ -30,7 +30,11 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -42,6 +46,7 @@ * read it on B. Finally the key is updated again and we ensure that it was updated on the near node B as well. I.e. * with this test we ensures that node B is considered as near reader for that key in case put occurred during preload. */ +@RunWith(JUnit4.class) public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest { /** Test iterations count. */ private static final int REPEAT_CNT = 10; @@ -61,6 +66,11 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest { /** Cache on backup node. */ private IgniteCache cache3; + /** {@inheritDoc} */ + @Override public void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { cache1 = null; @@ -75,6 +85,7 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testNearReaderPreload() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { startUp(); @@ -198,4 +209,4 @@ private void checkCache(IgniteCache cache, int key, int expVal assert F.eq(expVal, val) : "Unexpected cache value [key=" + key + ", expected=" + expVal + ", actual=" + val + ']'; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java index cbb2032302ee2..4fbb1f026e904 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java @@ -44,11 +44,12 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -59,19 +60,22 @@ /** * Checks that readers are properly handled. */ +@RunWith(JUnit4.class) public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest { /** Number of grids. */ private int grids = 2; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Grid counter. */ - private static AtomicInteger cntr = new AtomicInteger(0); + private AtomicInteger cntr = new AtomicInteger(0); /** Test cache affinity. */ private GridCacheModuloAffinityFunction aff = new GridCacheModuloAffinityFunction(); + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -92,12 +96,6 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, cntr.getAndIncrement())); return cfg; @@ -140,6 +138,7 @@ private Ignite grid(UUID nodeId) { } /** @throws Exception If failed. */ + @Test public void testTwoNodesTwoKeysNoBackups() throws Exception { aff.backups(0); grids = 2; @@ -233,6 +232,7 @@ public void testTwoNodesTwoKeysNoBackups() throws Exception { } /** @throws Exception If failed. */ + @Test public void testTwoNodesTwoKeysOneBackup() throws Exception { aff.backups(1); grids = 2; @@ -349,6 +349,7 @@ public void testTwoNodesTwoKeysOneBackup() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPutAllManyKeysOneReader() throws Exception { aff.backups(1); grids = 4; @@ -385,6 +386,7 @@ public void testPutAllManyKeysOneReader() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPutAllManyKeysTwoReaders() throws Exception { aff.backups(1); grids = 5; @@ -428,6 +430,7 @@ public void testPutAllManyKeysTwoReaders() throws Exception { } /** @throws Exception If failed. */ + @Test public void testBackupEntryReaders() throws Exception { aff.backups(1); grids = 2; @@ -465,7 +468,7 @@ public void testBackupEntryReaders() throws Exception { } /** @throws Exception If failed. */ - @SuppressWarnings({"SizeReplaceableByIsEmpty"}) + @Test public void testImplicitLockReaders() throws Exception { grids = 3; aff.reset(grids, 1); @@ -545,6 +548,7 @@ public void testImplicitLockReaders() throws Exception { } /** @throws Exception If failed. */ + @Test public void testExplicitLockReaders() throws Exception { if (atomicityMode() == ATOMIC) return; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java index d6e3804728cb4..277e829013756 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.IgniteTxExceptionAbstractSelfTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -26,6 +27,13 @@ * Tests near cache. */ public class GridCacheNearTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return PARTITIONED; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java index 21b90e2bddfe5..f1acc3cf4611f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxForceKeyTest.java @@ -22,10 +22,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; @@ -34,16 +34,12 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheNearTxForceKeyTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setAtomicityMode(TRANSACTIONAL); @@ -63,6 +59,7 @@ public class GridCacheNearTxForceKeyTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testNearTx() throws Exception { Ignite ignite0 = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java index 07ee991ba17b8..1328fc4b89fc6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java @@ -33,13 +33,13 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -52,10 +52,8 @@ /** * Tests near transactions. */ +@RunWith(JUnit4.class) public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_CNT = 3; @@ -78,12 +76,6 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(cacheCfg); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - return cfg; } @@ -96,6 +88,7 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ @SuppressWarnings( {"unchecked"}) + @Test public void testTxCleanup() throws Exception { backups = 1; @@ -184,6 +177,7 @@ public void testTxCleanup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxReadersUpdate() throws Exception { startGridsMultiThreaded(GRID_CNT); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxPreloadSelfTest.java index caf6cc7c7e74e..0cec87e90d9dd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxPreloadSelfTest.java @@ -21,6 +21,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.IgniteTxPreloadAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -28,6 +29,13 @@ * Tests cache transaction during preloading. */ public class GridCacheNearTxPreloadSelfTest extends IgniteTxPreloadAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return PARTITIONED; @@ -42,4 +50,4 @@ public class GridCacheNearTxPreloadSelfTest extends IgniteTxPreloadAbstractTest return cfg; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java index 4bcaf88a01f8c..4d5a91fd3014c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java @@ -28,10 +28,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.GridTimer; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.NONE; @@ -39,7 +39,7 @@ /** * Partitioned affinity test. */ -@SuppressWarnings({"PointlessArithmeticExpression"}) +@RunWith(JUnit4.class) public class GridCachePartitionedAffinityExcludeNeighborsPerformanceTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRIDS = 3; @@ -50,9 +50,6 @@ public class GridCachePartitionedAffinityExcludeNeighborsPerformanceTest extends /** */ private boolean excNeighbores; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static Collection msgs = new ArrayList<>(); @@ -60,12 +57,6 @@ public class GridCachePartitionedAffinityExcludeNeighborsPerformanceTest extends @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -108,6 +99,7 @@ private static Collection nodes(Affinity aff, Obj /** * @throws Exception If failed. */ + @Test public void testCountPerformance() throws Exception { excNeighbores = false; @@ -189,6 +181,7 @@ private long checkCountPerformance0(Ignite g, int cnt) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimedPerformance() throws Exception { excNeighbores = false; @@ -253,4 +246,4 @@ private int checkTimedPerformance(long dur, String testName) throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java index b212d63ed30b3..e252a1ba7cebe 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java @@ -37,11 +37,11 @@ import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.LoggerResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -53,7 +53,7 @@ /** * Partitioned affinity test. */ -@SuppressWarnings({"PointlessArithmeticExpression"}) +@RunWith(JUnit4.class) public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest { /** Backup count. */ private static final int BACKUPS = 1; @@ -64,9 +64,6 @@ public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest /** Fail flag. */ private static AtomicBoolean failFlag = new AtomicBoolean(false); - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -77,14 +74,9 @@ public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest cacheCfg.setRebalanceMode(SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCacheConfiguration(cacheCfg); - cfg.setDiscoverySpi(spi); return cfg; } @@ -112,6 +104,7 @@ private static Collection nodes(Affinity aff, Obj } /** @throws Exception If failed. */ + @Test public void testAffinity() throws Exception { waitTopologyUpdate(); @@ -158,12 +151,12 @@ private static void partitionMap(Ignite g) { } /** @throws Exception If failed. */ - @SuppressWarnings("BusyWait") private void waitTopologyUpdate() throws Exception { GridTestUtils.waitTopologyUpdate(DEFAULT_CACHE_NAME, BACKUPS, log()); } /** @throws Exception If failed. */ + @Test public void testAffinityWithPut() throws Exception { waitTopologyUpdate(); @@ -287,4 +280,4 @@ private ListenerJob(int keyCnt, String master) { EVT_CACHE_OBJECT_REMOVED); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicOpSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicOpSelfTest.java index 5c0eefeb55691..df888da1894e4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicOpSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicOpSelfTest.java @@ -22,6 +22,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheBasicOpAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -29,6 +32,7 @@ /** * Simple cache test. */ +@RunWith(JUnit4.class) public class GridCachePartitionedBasicOpSelfTest extends GridCacheBasicOpAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -48,22 +52,26 @@ public class GridCachePartitionedBasicOpSelfTest extends GridCacheBasicOpAbstrac } /** {@inheritDoc} */ + @Test @Override public void testBasicOps() throws Exception { super.testBasicOps(); } /** {@inheritDoc} */ + @Test @Override public void testBasicOpsAsync() throws Exception { super.testBasicOpsAsync(); } /** {@inheritDoc} */ + @Test @Override public void testOptimisticTransaction() throws Exception { super.testOptimisticTransaction(); } /** {@inheritDoc} */ + @Test @Override public void testPutWithExpiration() throws Exception { super.testPutWithExpiration(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java index 91c9b22b793bd..4a1063f4f627f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java @@ -30,11 +30,12 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheTestStore; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -45,10 +46,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of grids to start. */ private static final int GRID_CNT = 3; @@ -57,6 +56,11 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + if (nearCacheConfiguration() != null) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + for (GridCacheTestStore store : stores) store.resetTimestamp(); } @@ -89,12 +93,6 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA @Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -124,6 +122,7 @@ protected NearCacheConfiguration nearCacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testPutFromPrimary() throws Exception { IgniteCache cache = jcache(0); @@ -137,6 +136,7 @@ public void testPutFromPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutFromBackup() throws Exception { IgniteCache cache = jcache(0); @@ -150,6 +150,7 @@ public void testPutFromBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutFromNear() throws Exception { IgniteCache cache = jcache(0); @@ -163,6 +164,7 @@ public void testPutFromNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsentFromPrimary() throws Exception { IgniteCache cache = jcache(0); @@ -176,6 +178,7 @@ public void testPutIfAbsentFromPrimary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsentFromBackup() throws Exception { IgniteCache cache = jcache(0); @@ -189,6 +192,7 @@ public void testPutIfAbsentFromBackup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsentFromNear() throws Exception { IgniteCache cache = jcache(0); @@ -202,6 +206,7 @@ public void testPutIfAbsentFromNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAll() throws Exception { IgniteCache cache = jcache(0); @@ -218,6 +223,7 @@ public void testPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleOperations() throws Exception { IgniteCache cache = jcache(0); @@ -279,4 +285,4 @@ static class StoreFactory implements Factory { return store; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.java index eef5aebaacc98..3c9ce6d370024 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.lang.IgniteClosure; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for local cache. */ +@RunWith(JUnit4.class) public class GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest extends GridCachePartitionedFullApiSelfTest { /** {@inheritDoc} */ @Override protected NearCacheConfiguration nearConfiguration() { @@ -49,6 +53,7 @@ public class GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest extends Grid /** * */ + @Test public void testMapKeysToNodes() { grid(0).affinity(DEFAULT_CACHE_NAME).mapKeysToNodes(Arrays.asList("1", "2")); } @@ -56,6 +61,7 @@ public void testMapKeysToNodes() { /** * */ + @Test public void testMapKeyToNode() { assert grid(0).affinity(DEFAULT_CACHE_NAME).mapKeyToNode("1") == null; } @@ -77,4 +83,4 @@ public void testMapKeyToNode() { } }; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEventSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEventSelfTest.java index 1c79db7e7a111..ce782172c2860 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEventSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEventSelfTest.java @@ -21,6 +21,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheEventAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -30,6 +31,13 @@ * Tests events. */ public class GridCachePartitionedEventSelfTest extends GridCacheEventAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { CacheConfiguration cfg = defaultCacheConfiguration(); @@ -57,4 +65,4 @@ public class GridCachePartitionedEventSelfTest extends GridCacheEventAbstractTes @Override protected boolean partitioned() { return true; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java index d6f9baff10acf..33ecded8eea8a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java @@ -30,12 +30,12 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -49,6 +49,7 @@ /** * Tests for partitioned cache automatic eviction. */ +@RunWith(JUnit4.class) public class GridCachePartitionedEvictionSelfTest extends GridCacheAbstractSelfTest { /** */ private static final boolean TEST_INFO = true; @@ -62,9 +63,6 @@ public class GridCachePartitionedEvictionSelfTest extends GridCacheAbstractSelfT /** */ private static final int KEY_CNT = 100; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected int gridCount() { return GRID_CNT; @@ -76,12 +74,6 @@ public class GridCachePartitionedEvictionSelfTest extends GridCacheAbstractSelfT c.getTransactionConfiguration().setTxSerializableEnabled(true); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -117,6 +109,7 @@ private IgniteCache cache(ClusterNode node) { * * @throws Exception If failed. */ + @Test public void testEvictionTxPessimisticReadCommitted() throws Exception { doTestEviction(PESSIMISTIC, READ_COMMITTED); } @@ -126,6 +119,7 @@ public void testEvictionTxPessimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testEvictionTxPessimisticRepeatableRead() throws Exception { doTestEviction(PESSIMISTIC, REPEATABLE_READ); } @@ -135,6 +129,7 @@ public void testEvictionTxPessimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testEvictionTxPessimisticSerializable() throws Exception { doTestEviction(PESSIMISTIC, SERIALIZABLE); } @@ -144,6 +139,7 @@ public void testEvictionTxPessimisticSerializable() throws Exception { * * @throws Exception If failed. */ + @Test public void testEvictionTxOptimisticReadCommitted() throws Exception { doTestEviction(OPTIMISTIC, READ_COMMITTED); } @@ -153,6 +149,7 @@ public void testEvictionTxOptimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testEvictionTxOptimisticRepeatableRead() throws Exception { doTestEviction(OPTIMISTIC, REPEATABLE_READ); } @@ -162,6 +159,7 @@ public void testEvictionTxOptimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testEvictionTxOptimisticSerializable() throws Exception { doTestEviction(OPTIMISTIC, SERIALIZABLE); } @@ -226,4 +224,4 @@ private void doTestEviction(TransactionConcurrency concurrency, TransactionIsola assertEquals(0, near(jcache(0)).nearSize()); assertEquals(0, near(jcache(1)).nearSize()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedExplicitLockNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedExplicitLockNodeFailureSelfTest.java index 96fb8f65bb56c..1b806deb44cd4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedExplicitLockNodeFailureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedExplicitLockNodeFailureSelfTest.java @@ -30,10 +30,11 @@ import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -43,25 +44,22 @@ /** * Tests for node failure in transactions. */ +@RunWith(JUnit4.class) public class GridCachePartitionedExplicitLockNodeFailureSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ public static final int GRID_CNT = 4; + /** {@inheritDoc} */ + @Override public void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); c.getTransactionConfiguration().setTxSerializableEnabled(true); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -84,6 +82,7 @@ public class GridCachePartitionedExplicitLockNodeFailureSelfTest extends GridCom /** @throws Exception If check failed. */ @SuppressWarnings("ErrorNotRethrown") + @Test public void testLockFromNearOrBackup() throws Exception { startGrids(GRID_CNT); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFilteredPutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFilteredPutSelfTest.java index 20c32c1ff4d7f..6c8bd925ec386 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFilteredPutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFilteredPutSelfTest.java @@ -24,12 +24,11 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,31 +36,17 @@ /** * Test filtered put. */ +@RunWith(JUnit4.class) public class GridCachePartitionedFilteredPutSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(discoverySpi()); cfg.setCacheConfiguration(cacheConfiguration()); return cfg; } - /** - * @return Discovery SPI; - */ - private DiscoverySpi discoverySpi() { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - return spi; - } - /** * @return Cache configuration. */ @@ -89,6 +74,7 @@ private CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testPutAndRollbackCheckNear() throws Exception { doPutAndRollback(); @@ -100,6 +86,7 @@ public void testPutAndRollbackCheckNear() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAndRollbackCheckDht() throws Exception { doPutAndRollback(); @@ -125,4 +112,4 @@ private void doPutAndRollback() throws Exception { assert c.localPeek(1, CachePeekMode.ONHEAP) == null; assert c.get(1) == null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java index ca12f702e1ab1..6674076a65e60 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java @@ -20,12 +20,10 @@ import javax.cache.Cache; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheAdapter; +import org.junit.Test; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -59,6 +57,7 @@ public class GridCachePartitionedFullApiSelfTest extends GridCacheAbstractFullAp /** * @throws Exception If failed. */ + @Test public void testUpdate() throws Exception { if (gridCount() > 1) { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -84,4 +83,4 @@ public void testUpdate() throws Exception { assertEquals(1, cnt); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java index 64f594084ea7e..b432fd7f5cccf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java @@ -28,11 +28,12 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.stream.StreamReceiver; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC; @@ -42,6 +43,7 @@ /** * Test for issue GG-3997 Total Hits and Misses display wrong value for in-memory database. */ +@RunWith(JUnit4.class) public class GridCachePartitionedHitsAndMissesSelfTest extends GridCommonAbstractTest { /** Amount of grids to start. */ private static final int GRID_CNT = 3; @@ -49,18 +51,10 @@ public class GridCachePartitionedHitsAndMissesSelfTest extends GridCommonAbstrac /** Count of total numbers to generate. */ private static final int CNT = 2000; - /** IP Finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - // DiscoverySpi. - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - disco.setIpFinder(IP_FINDER); - cfg.setDiscoverySpi(disco); - // Cache. cfg.setCacheConfiguration(cacheConfiguration()); @@ -98,7 +92,10 @@ protected CacheConfiguration cacheConfiguration() throws Exception { * * @throws Exception If failed. */ + @Test public void testHitsAndMisses() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.METRICS); + startGrids(GRID_CNT); awaitPartitionMapExchange(); @@ -167,4 +164,4 @@ private static class IncrementingUpdater implements StreamReceiver { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMetricsSelfTest.java index a67e01f4e667e..e946c435a1619 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMetricsSelfTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheTransactionalAbstractMetricsSelfTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -32,6 +33,13 @@ public class GridCachePartitionedMetricsSelfTest extends GridCacheTransactionalA /** */ private static final int GRID_CNT = 2; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.METRICS); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java index 6d5302f29708b..02df9fd4764a0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java @@ -49,11 +49,11 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.LoggerResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -64,7 +64,8 @@ /** * Multiple put test. */ -@SuppressWarnings({"UnusedAssignment", "TooBroadScope", "PointlessBooleanExpression", "PointlessArithmeticExpression"}) +@SuppressWarnings({"UnusedAssignment", "TooBroadScope"}) +@RunWith(JUnit4.class) public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbstractTest { /** Debug flag. */ private static final boolean DEBUG = false; @@ -81,9 +82,6 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst /** */ private static final String CNTR_KEY = "CNTR_KEY"; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static CountDownLatch startLatchMultiNode; @@ -105,12 +103,6 @@ public GridCachePartitionedMultiNodeCounterSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - // Default cache configuration. CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -189,6 +181,7 @@ public List grids(int max, Ignite... exclude) { } /** @throws Exception If failed. */ + @Test public void testMultiNearAndPrimary() throws Exception { // resetLog4j(Level.INFO, true, GridCacheTxManager.class.getName()); @@ -204,6 +197,7 @@ public void testMultiNearAndPrimary() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOneNearAndPrimary() throws Exception { // resetLog4j(Level.INFO, true, GridCacheTxManager.class.getName()); @@ -519,6 +513,7 @@ private void checkNearAndPrimary(int gridCnt, int priThreads, int nearThreads) t } /** @throws Exception If failed. */ + @Test public void testMultiNearAndPrimaryMultiNode() throws Exception { int gridCnt = 4; @@ -528,6 +523,7 @@ public void testMultiNearAndPrimaryMultiNode() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOneNearAndPrimaryMultiNode() throws Exception { int gridCnt = 2; @@ -779,4 +775,4 @@ private void onPrimary() { return S.toString(IncrementItemJob.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java index 4450eb6a380dd..ac85fcde26f6f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java @@ -32,6 +32,7 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -68,6 +69,7 @@ public Collection affinityNodes() { /** * @throws Exception If failed. */ + @Test public void testPutAllRemoveAll() throws Exception { for (int i = 0; i < gridCount(); i++) info(">>>>> Grid" + i + ": " + grid(i).localNode().id()); @@ -95,6 +97,7 @@ public void testPutAllRemoveAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutAllPutAll() throws Exception { for (int i = 0; i < gridCount(); i++) info(">>>>> Grid" + i + ": " + grid(i).localNode().id()); @@ -134,6 +137,7 @@ public void testPutAllPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutDebug() throws Exception { for (int i = 0; i < gridCount(); i++) info(">>>>> Grid" + i + ": " + grid(i).localNode().id()); @@ -168,6 +172,7 @@ public void testPutDebug() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPeekPartitionedModes() throws Exception { jcache().put("key", 1); @@ -207,6 +212,7 @@ else if (!aff.isPrimaryOrBackup(grid(i).localNode(), "key")) { /** * @throws Exception If failed. */ + @Test public void testPeekAsyncPartitionedModes() throws Exception { jcache().put("key", 1); @@ -237,6 +243,7 @@ else if (!grid(i).affinity(DEFAULT_CACHE_NAME).isPrimaryOrBackup(grid(i).localNo * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testNearDhtKeySize() throws Exception { List keys = new ArrayList<>(5); @@ -312,6 +319,7 @@ else if (ignite1 == null) /** * @throws Exception If failed. */ + @Test public void testAffinity() throws Exception { for (int i = 0; i < gridCount(); i++) info("Grid " + i + ": " + grid(i).localNode().id()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java index 3122f60b823b1..e1d77d09560e2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java @@ -21,6 +21,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheMultiNodeLockAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -28,6 +31,7 @@ /** * Test cases for multi-threaded tests. */ +@RunWith(JUnit4.class) public class GridCachePartitionedMultiNodeLockSelfTest extends GridCacheMultiNodeLockAbstractTest { /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration() { @@ -47,27 +51,32 @@ public class GridCachePartitionedMultiNodeLockSelfTest extends GridCacheMultiNod } /** {@inheritDoc} */ + @Test @Override public void testBasicLock() throws Exception { super.testBasicLock(); } /** {@inheritDoc} */ + @Test @Override public void testLockMultithreaded() throws Exception { super.testLockMultithreaded(); } /** {@inheritDoc} */ + @Test @Override public void testLockReentry() throws IgniteCheckedException { super.testLockReentry(); } /** {@inheritDoc} */ + @Test @Override public void testMultiNodeLock() throws Exception { super.testMultiNodeLock(); } /** {@inheritDoc} */ + @Test @Override public void testMultiNodeLockWithKeyLists() throws Exception { super.testMultiNodeLockWithKeyLists(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiThreadedPutGetSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiThreadedPutGetSelfTest.java index c99d482b56291..84365cd2484b0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiThreadedPutGetSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiThreadedPutGetSelfTest.java @@ -26,13 +26,13 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAlwaysEvictionPolicy; import org.apache.ignite.internal.util.typedef.CAX; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -45,6 +45,7 @@ /** * Multithreaded partition cache put get test. */ +@RunWith(JUnit4.class) public class GridCachePartitionedMultiThreadedPutGetSelfTest extends GridCommonAbstractTest { /** */ private static final boolean TEST_INFO = true; @@ -58,9 +59,6 @@ public class GridCachePartitionedMultiThreadedPutGetSelfTest extends GridCommonA /** Number of transactions per thread. */ private static final int TX_CNT = 500; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -87,12 +85,6 @@ public class GridCachePartitionedMultiThreadedPutGetSelfTest extends GridCommonA c.setCacheConfiguration(cc); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - return c; } @@ -121,6 +113,7 @@ public class GridCachePartitionedMultiThreadedPutGetSelfTest extends GridCommonA * * @throws Exception If failed. */ + @Test public void testPessimisticReadCommitted() throws Exception { doTest(PESSIMISTIC, READ_COMMITTED); } @@ -130,6 +123,7 @@ public void testPessimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testPessimisticRepeatableRead() throws Exception { doTest(PESSIMISTIC, REPEATABLE_READ); } @@ -139,6 +133,7 @@ public void testPessimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testPessimisticSerializable() throws Exception { doTest(PESSIMISTIC, SERIALIZABLE); } @@ -148,6 +143,7 @@ public void testPessimisticSerializable() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimisticReadCommitted() throws Exception { doTest(OPTIMISTIC, READ_COMMITTED); } @@ -157,6 +153,7 @@ public void testOptimisticReadCommitted() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimisticRepeatableRead() throws Exception { doTest(OPTIMISTIC, REPEATABLE_READ); } @@ -166,6 +163,7 @@ public void testOptimisticRepeatableRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimisticSerializable() throws Exception { doTest(OPTIMISTIC, SERIALIZABLE); } @@ -209,4 +207,4 @@ private void doTest(final TransactionConcurrency concurrency, final TransactionI } }, THREAD_CNT); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMvccTxMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMvccTxMultiThreadedSelfTest.java new file mode 100644 index 0000000000000..0034330865e67 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMvccTxMultiThreadedSelfTest.java @@ -0,0 +1,100 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.near; + +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.internal.processors.cache.IgniteMvccTxMultiThreadedAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; + +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; + +/** + * Tests for partitioned cache transactions. + */ +public class GridCachePartitionedMvccTxMultiThreadedSelfTest extends IgniteMvccTxMultiThreadedAbstractTest { + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + if (nearEnabled()) + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + CacheConfiguration ccfg = defaultCacheConfiguration(); + + ccfg.setCacheMode(PARTITIONED); + ccfg.setBackups(1); + + ccfg.setEvictionPolicy(null); + + ccfg.setWriteSynchronizationMode(FULL_SYNC); + + ccfg.setNearConfiguration(nearEnabled() ? new NearCacheConfiguration() : null); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** + * @return {@code True} if near cache is enabled. + */ + protected boolean nearEnabled() { + return true; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int keyCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int maxKeyValue() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int threadCount() { + return 5; + } + + /** {@inheritDoc} */ + @Override protected int iterations() { + return 1000; + } + + /** {@inheritDoc} */ + @Override protected boolean isTestDebug() { + return false; + } + + /** {@inheritDoc} */ + @Override protected boolean printMemoryStats() { + return true; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMvccTxSingleThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMvccTxSingleThreadedSelfTest.java new file mode 100644 index 0000000000000..140483912d894 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMvccTxSingleThreadedSelfTest.java @@ -0,0 +1,84 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.near; + +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.cache.IgniteMvccTxSingleThreadedAbstractTest; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheRebalanceMode.NONE; + +/** + * Tests for partitioned cache transactions. + */ +public class GridCachePartitionedMvccTxSingleThreadedSelfTest extends IgniteMvccTxSingleThreadedAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + CacheConfiguration ccfg = defaultCacheConfiguration(); + + ccfg.setCacheMode(PARTITIONED); + ccfg.setBackups(1); + ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + + ccfg.setNearConfiguration(null); + ccfg.setEvictionPolicy(null); + + ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC); + + ccfg.setRebalanceMode(NONE); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 4; + } + + /** {@inheritDoc} */ + @Override protected int keyCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int maxKeyValue() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int iterations() { + return 3000; + } + + /** {@inheritDoc} */ + @Override protected boolean isTestDebug() { + return false; + } + + /** {@inheritDoc} */ + @Override protected boolean printMemoryStats() { + return true; + } +} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMvccTxTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMvccTxTimeoutSelfTest.java new file mode 100644 index 0000000000000..aad95aab29bff --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMvccTxTimeoutSelfTest.java @@ -0,0 +1,47 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.near; + +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.cache.distributed.IgniteMvccTxTimeoutAbstractTest; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; + +/** + * Simple cache test. + */ +public class GridCachePartitionedMvccTxTimeoutSelfTest extends IgniteMvccTxTimeoutAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration c = super.getConfiguration(igniteInstanceName); + + CacheConfiguration cc = defaultCacheConfiguration(); + + cc.setCacheMode(PARTITIONED); + cc.setBackups(1); + cc.setAtomicityMode(TRANSACTIONAL); + + //cacheCfg.setPreloadMode(NONE); + + c.setCacheConfiguration(cc); + + return c; + } +} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedNodeRestartTest.java index d7a0cdda00ce5..38e9d35cb0b3e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedNodeRestartTest.java @@ -21,6 +21,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheAbstractNodeRestartSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -29,6 +32,7 @@ /** * Test node restart. */ +@RunWith(JUnit4.class) public class GridCachePartitionedNodeRestartTest extends GridCacheAbstractNodeRestartSelfTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -57,77 +61,92 @@ public class GridCachePartitionedNodeRestartTest extends GridCacheAbstractNodeRe } /** {@inheritDoc} */ + @Test @Override public void testRestart() throws Exception { super.testRestart(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutTwoNodesNoBackups() throws Throwable { super.testRestartWithPutTwoNodesNoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutTwoNodesOneBackup() throws Throwable { super.testRestartWithPutTwoNodesOneBackup(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutFourNodesNoBackups() throws Throwable { super.testRestartWithPutFourNodesNoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutFourNodesOneBackups() throws Throwable { super.testRestartWithPutFourNodesOneBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutSixNodesTwoBackups() throws Throwable { super.testRestartWithPutSixNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutEightNodesTwoBackups() throws Throwable { super.testRestartWithPutEightNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutTenNodesTwoBackups() throws Throwable { super.testRestartWithPutTenNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxEightNodesTwoBackups() throws Throwable { super.testRestartWithTxEightNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxFourNodesNoBackups() throws Throwable { super.testRestartWithTxFourNodesNoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxFourNodesOneBackups() throws Throwable { super.testRestartWithTxFourNodesOneBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxSixNodesTwoBackups() throws Throwable { super.testRestartWithTxSixNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxTenNodesTwoBackups() throws Throwable { super.testRestartWithTxTenNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxTwoNodesNoBackups() throws Throwable { super.testRestartWithTxTwoNodesNoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxTwoNodesOneBackup() throws Throwable { super.testRestartWithTxTwoNodesOneBackup(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedOptimisticTxNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedOptimisticTxNodeRestartTest.java index df9b27f771f19..75263b092bb3c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedOptimisticTxNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedOptimisticTxNodeRestartTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheAbstractNodeRestartSelfTest; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -31,6 +34,7 @@ /** * Test node restart. */ +@RunWith(JUnit4.class) public class GridCachePartitionedOptimisticTxNodeRestartTest extends GridCacheAbstractNodeRestartSelfTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { @@ -77,69 +81,84 @@ protected boolean nearEnabled() { } /** {@inheritDoc} */ + @Test @Override public void testRestart() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutTwoNodesNoBackups() throws Throwable { } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutTwoNodesOneBackup() throws Throwable { } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutFourNodesNoBackups() throws Throwable { } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutFourNodesOneBackups() throws Throwable { } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutSixNodesTwoBackups() throws Throwable { } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutEightNodesTwoBackups() throws Throwable { } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutTenNodesTwoBackups() throws Throwable { } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxEightNodesTwoBackups() throws Throwable { super.testRestartWithTxEightNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxFourNodesNoBackups() throws Throwable { super.testRestartWithTxFourNodesNoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxFourNodesOneBackups() throws Throwable { super.testRestartWithTxFourNodesOneBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxSixNodesTwoBackups() throws Throwable { super.testRestartWithTxSixNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxTenNodesTwoBackups() throws Throwable { super.testRestartWithTxTenNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxTwoNodesNoBackups() throws Throwable { super.testRestartWithTxTwoNodesNoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxTwoNodesOneBackup() throws Throwable { super.testRestartWithTxTwoNodesOneBackup(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java index 3a52d64a0de0c..862dd57ac61d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java @@ -28,6 +28,9 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -36,7 +39,7 @@ /** * Tests for replicated cache preloader. */ -@SuppressWarnings({"PublicInnerClass"}) +@RunWith(JUnit4.class) public class GridCachePartitionedPreloadLifecycleSelfTest extends GridCachePreloadLifecycleAbstractTest { /** Grid count. */ private int gridCnt = 5; @@ -57,7 +60,6 @@ public class GridCachePartitionedPreloadLifecycleSelfTest extends GridCachePrelo cc1.setRebalanceMode(preloadMode); cc1.setEvictionPolicy(null); cc1.setCacheStoreFactory(null); - cc1.setEvictionPolicy(null); // Identical configuration. CacheConfiguration cc2 = new CacheConfiguration(cc1); @@ -158,6 +160,7 @@ public void checkCache(Object[] keys) throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBean1() throws Exception { checkCache(keys(true, DFLT_KEYS.length, DFLT_KEYS)); } @@ -165,6 +168,7 @@ public void testLifecycleBean1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBean2() throws Exception { checkCache(keys(false, DFLT_KEYS.length, DFLT_KEYS)); } @@ -172,6 +176,7 @@ public void testLifecycleBean2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBean3() throws Exception { checkCache(keys(true, 500)); } @@ -179,6 +184,7 @@ public void testLifecycleBean3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBean4() throws Exception { checkCache(keys(false, 500)); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java index 96d4603fb3cc0..e63291fc09545 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java @@ -18,17 +18,19 @@ package org.apache.ignite.internal.processors.cache.distributed.near; import java.util.concurrent.atomic.AtomicInteger; +import javax.cache.Cache; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheModuloAffinityFunction; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -37,44 +39,31 @@ /** * Test that store is called correctly on puts. */ +@RunWith(JUnit4.class) public class GridCachePartitionedStorePutSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final AtomicInteger CNT = new AtomicInteger(0); /** */ - private IgniteCache cache1; + private static AtomicInteger loads; - /** */ - private IgniteCache cache2; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); - /** */ - private IgniteCache cache3; + super.beforeTestsStarted(); + } /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(discoverySpi()); cfg.setCacheConfiguration(cacheConfiguration()); cfg.setUserAttributes(F.asMap(IDX_ATTR, CNT.getAndIncrement())); return cfg; } - /** - * @return Discovery SPI. - */ - private DiscoverySpi discoverySpi() { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - return spi; - } - /** * @return Cache configuration. */ @@ -95,9 +84,9 @@ private CacheConfiguration cacheConfiguration() { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { - cache1 = startGrid(1).cache(DEFAULT_CACHE_NAME); - cache2 = startGrid(2).cache(DEFAULT_CACHE_NAME); - cache3 = startGrid(3).cache(DEFAULT_CACHE_NAME); + loads = new AtomicInteger(); + + startGridsMultiThreaded(3); } /** {@inheritDoc} */ @@ -105,21 +94,36 @@ private CacheConfiguration cacheConfiguration() { stopAllGrids(); } - /** - * @throws Exception If failed. - */ - public void testPutx() throws Throwable { - info("Putting to the first node."); + /** */ + @Test + public void testPutShouldNotTriggerLoad() { + checkPut(0); + + assertEquals(0, loads.get()); - cache1.put(0, 1); + checkPut(1); - info("Putting to the second node."); + assertEquals(0, loads.get()); - cache2.put(0, 2); + checkPut(2); - info("Putting to the third node."); + assertEquals(0, loads.get()); + } + + /** */ + public void checkPut(int idx) { + IgniteCache cache = grid(idx).cache(DEFAULT_CACHE_NAME); + + cache.put(0, 1); + + try (Transaction tx = grid(idx).transactions().txStart()) { + cache.put(1, 1); + cache.put(2, 2); + + tx.commit(); + } - cache3.put(0, 3); + assertEquals(0, loads.get()); } /** @@ -128,13 +132,13 @@ public void testPutx() throws Throwable { private static class TestStore extends CacheStoreAdapter { /** {@inheritDoc} */ @Override public Object load(Object key) { - assert false; + loads.incrementAndGet(); return null; } /** {@inheritDoc} */ - @Override public void write(javax.cache.Cache.Entry e) { + @Override public void write(Cache.Entry e) { // No-op } @@ -143,4 +147,4 @@ private static class TestStore extends CacheStoreAdapter { // No-op } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxMultiNodeSelfTest.java index fd4108c90c137..a032d6c301916 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxMultiNodeSelfTest.java @@ -20,6 +20,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.IgniteTxMultiNodeAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -27,6 +30,7 @@ /** * Test basic cache operations in transactions. */ +@RunWith(JUnit4.class) public class GridCachePartitionedTxMultiNodeSelfTest extends IgniteTxMultiNodeAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -45,37 +49,44 @@ public class GridCachePartitionedTxMultiNodeSelfTest extends IgniteTxMultiNodeAb } /** {@inheritDoc} */ + @Test @Override public void testPutOneEntryInTx() throws Exception { super.testPutOneEntryInTx(); } /** {@inheritDoc} */ + @Test @Override public void testPutOneEntryInTxMultiThreaded() throws Exception { super.testPutOneEntryInTxMultiThreaded(); } /** {@inheritDoc} */ + @Test @Override public void testPutTwoEntriesInTx() throws Exception { super.testPutTwoEntriesInTx(); } /** {@inheritDoc} */ + @Test @Override public void testPutTwoEntryInTxMultiThreaded() throws Exception { super.testPutTwoEntryInTxMultiThreaded(); } /** {@inheritDoc} */ + @Test @Override public void testRemoveInTxQueried() throws Exception { super.testRemoveInTxQueried(); } /** {@inheritDoc} */ + @Test @Override public void testRemoveInTxQueriedMultiThreaded() throws Exception { super.testRemoveInTxQueriedMultiThreaded(); } /** {@inheritDoc} */ + @Test @Override public void testRemoveInTxSimple() throws Exception { super.testRemoveInTxSimple(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxMultiThreadedSelfTest.java index a1bcd46c62024..1c09b08099fc0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxMultiThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxMultiThreadedSelfTest.java @@ -22,9 +22,6 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.IgniteTxMultiThreadedAbstractTest; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.log4j.Level; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,9 +34,6 @@ public class GridCachePartitionedTxMultiThreadedSelfTest extends IgniteTxMultiTh /** Cache debug flag. */ private static final boolean CACHE_DEBUG = false; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @SuppressWarnings({"ConstantConditions"}) @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -60,12 +54,6 @@ public class GridCachePartitionedTxMultiThreadedSelfTest extends IgniteTxMultiTh c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - if (CACHE_DEBUG) resetLog4j(Level.DEBUG, true, GridCacheProcessor.class.getPackage().getName()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java index 2e4ad92351a30..fb973ba5d181d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java @@ -30,12 +30,12 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_TX_SALVAGE_TIMEOUT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -47,6 +47,7 @@ /** * Test tx salvage. */ +@RunWith(JUnit4.class) public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 5; @@ -66,20 +67,10 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes /** Salvage timeout system property value before alteration. */ private static String salvageTimeoutOld; - /** Standard VM IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - // Discovery. - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -123,6 +114,7 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes /** * @throws Exception If failed. */ + @Test public void testOptimisticTxSalvageBeforeTimeout() throws Exception { checkSalvageBeforeTimeout(OPTIMISTIC, true); } @@ -130,6 +122,7 @@ public void testOptimisticTxSalvageBeforeTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticcTxSalvageBeforeTimeout() throws Exception { checkSalvageBeforeTimeout(PESSIMISTIC, false); } @@ -137,6 +130,7 @@ public void testPessimisticcTxSalvageBeforeTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticTxSalvageAfterTimeout() throws Exception { checkSalvageAfterTimeout(OPTIMISTIC, true); } @@ -144,6 +138,7 @@ public void testOptimisticTxSalvageAfterTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTxSalvageAfterTimeout() throws Exception { checkSalvageAfterTimeout(PESSIMISTIC, false); } @@ -263,4 +258,4 @@ private void checkTxsNotEmpty(GridCacheContext ctx, int exp) { assertEquals("Some transactions were salvaged unexpectedly", exp, size); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSingleThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSingleThreadedSelfTest.java index 17936a7383ad2..d70776c8fe8e0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSingleThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSingleThreadedSelfTest.java @@ -22,9 +22,6 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.IgniteTxSingleThreadedAbstractTest; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.log4j.Level; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -38,9 +35,6 @@ public class GridCachePartitionedTxSingleThreadedSelfTest extends IgniteTxSingle /** Cache debug flag. */ private static final boolean CACHE_DEBUG = false; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @SuppressWarnings({"ConstantConditions"}) @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -60,12 +54,6 @@ public class GridCachePartitionedTxSingleThreadedSelfTest extends IgniteTxSingle cc.setRebalanceMode(NONE); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - c.setCacheConfiguration(cc); if (CACHE_DEBUG) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxTimeoutSelfTest.java index 202476e160919..1a88ae0f77936 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxTimeoutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxTimeoutSelfTest.java @@ -19,11 +19,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.processors.cache.distributed.IgniteTxTimeoutAbstractTest; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -32,27 +28,10 @@ * Simple cache test. */ public class GridCachePartitionedTxTimeoutSelfTest extends IgniteTxTimeoutAbstractTest { - /** Transaction timeout. */ - private static final long TIMEOUT = 50; - - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TransactionConfiguration txCfg = c.getTransactionConfiguration(); - - txCfg.setTxSerializableEnabled(true); - txCfg.setDefaultTxTimeout(TIMEOUT); - - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePutArrayValueSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePutArrayValueSelfTest.java index 14a0c0f931d38..366c918cad2da 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePutArrayValueSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePutArrayValueSelfTest.java @@ -22,22 +22,35 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheInternal; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Specific test case for GG-3946 */ +@RunWith(JUnit4.class) public class GridCachePutArrayValueSelfTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { return 4; } + @Override protected void initStoreStrategy() throws IgniteCheckedException { + if (!MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.CACHE_STORE)) + return; + + super.initStoreStrategy(); + } + /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { CacheConfiguration cacheCfg = super.cacheConfiguration(igniteInstanceName); @@ -51,6 +64,7 @@ public class GridCachePutArrayValueSelfTest extends GridCacheAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testInternalKeys() throws Exception { assert gridCount() >= 2; @@ -117,4 +131,4 @@ public InternalKey(long key) { return S.toString(InternalKey.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheRendezvousAffinityClientSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheRendezvousAffinityClientSelfTest.java index 51c2fc249e728..71daeca500df3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheRendezvousAffinityClientSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheRendezvousAffinityClientSelfTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests rendezvous affinity function with CLIENT_ONLY node (GG-8768). */ +@RunWith(JUnit4.class) public class GridCacheRendezvousAffinityClientSelfTest extends GridCommonAbstractTest { /** Client node. */ private boolean client; @@ -63,6 +67,7 @@ public class GridCacheRendezvousAffinityClientSelfTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testClientNode() throws Exception { try { client = true; @@ -111,4 +116,4 @@ public void testClientNode() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheStoreUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheStoreUpdateTest.java index bf8ad78128745..6a70afa6dcaba 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheStoreUpdateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheStoreUpdateTest.java @@ -39,13 +39,18 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Check that near cache is updated when entry loaded from store. */ +@RunWith(JUnit4.class) public class GridNearCacheStoreUpdateTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "cache"; @@ -71,6 +76,9 @@ public class GridNearCacheStoreUpdateTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + srv = startGrid("server"); client = startGrid("client"); } @@ -83,6 +91,7 @@ public class GridNearCacheStoreUpdateTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testAtomicUpdateNear() throws Exception { cache = client.createCache(cacheConfiguration(), new NearCacheConfiguration()); @@ -92,6 +101,7 @@ public void testAtomicUpdateNear() throws Exception { /** * @throws Exception If fail. */ + @Test public void testTransactionAtomicUpdateNear() throws Exception { cache = client.createCache(cacheConfiguration(), new NearCacheConfiguration()); @@ -101,6 +111,7 @@ public void testTransactionAtomicUpdateNear() throws Exception { /** * @throws Exception If fail. */ + @Test public void testPessimisticRepeatableReadUpdateNear() throws Exception { cache = client.createCache(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL), new NearCacheConfiguration()); @@ -111,6 +122,7 @@ public void testPessimisticRepeatableReadUpdateNear() throws Exception { /** * @throws Exception If fail. */ + @Test public void testPessimisticReadCommittedUpdateNear() throws Exception { cache = client.createCache(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL), new NearCacheConfiguration()); @@ -121,6 +133,7 @@ public void testPessimisticReadCommittedUpdateNear() throws Exception { /** * @throws Exception If fail. */ + @Test public void testOptimisticSerializableUpdateNear() throws Exception { cache = client.createCache(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL), new NearCacheConfiguration()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java index 23b0e188c1a72..2b4945b1a4493 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java @@ -21,15 +21,14 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -37,10 +36,8 @@ /** * Test that persistent store is not used when loading invalidated entry from backup node. */ +@RunWith(JUnit4.class) public class GridPartitionedBackupLoadSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_CNT = 3; @@ -54,23 +51,11 @@ public class GridPartitionedBackupLoadSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(discoverySpi()); cfg.setCacheConfiguration(cacheConfiguration()); return cfg; } - /** - * @return Discovery SPI. - */ - private DiscoverySpi discoverySpi() { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - return spi; - } - /** * @return Cache configuration. */ @@ -91,6 +76,9 @@ private CacheConfiguration cacheConfiguration() { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-8582"); + startGridsMultiThreaded(GRID_CNT); } @@ -102,6 +90,7 @@ private CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testBackupLoad() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).put(1, 1); @@ -159,4 +148,4 @@ public Integer get(Integer key) { return map.get(key); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java index ca12a9925ca99..6939eb376694e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearOnlyTxTest.java @@ -29,7 +29,11 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -39,7 +43,15 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 2; @@ -76,6 +88,7 @@ public class IgniteCacheNearOnlyTxTest extends IgniteCacheAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNearOnlyPutMultithreaded() throws Exception { final Ignite ignite1 = ignite(1); @@ -113,6 +126,7 @@ public void testNearOnlyPutMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOptimisticTx() throws Exception { txMultithreaded(true); } @@ -120,6 +134,7 @@ public void testOptimisticTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTx() throws Exception { txMultithreaded(false); } @@ -174,6 +189,7 @@ private void txMultithreaded(final boolean optimistic) throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentTx() throws Exception { final Ignite ignite1 = ignite(1); @@ -217,4 +233,4 @@ public void testConcurrentTx() throws Exception { fut1.get(); fut2.get(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearReadCommittedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearReadCommittedTest.java index ad9bce047b2b2..3a1a55d5805f3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearReadCommittedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearReadCommittedTest.java @@ -22,7 +22,11 @@ import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -32,7 +36,15 @@ * */ @SuppressWarnings("RedundantMethodOverride") +@RunWith(JUnit4.class) public class IgniteCacheNearReadCommittedTest extends GridCacheAbstractSelfTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 2; @@ -51,6 +63,7 @@ public class IgniteCacheNearReadCommittedTest extends GridCacheAbstractSelfTest /** * @throws Exception If failed. */ + @Test public void testReadCommittedCacheCleanup() throws Exception { IgniteCache cache = ignite(0).cache(DEFAULT_CACHE_NAME); @@ -70,4 +83,4 @@ public void testReadCommittedCacheCleanup() throws Exception { assertEquals(0, cache.localSize(CachePeekMode.ALL)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearTxRollbackTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearTxRollbackTest.java index 06b625681b1ab..27e27818d62ba 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearTxRollbackTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheNearTxRollbackTest.java @@ -34,6 +34,9 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -41,6 +44,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheNearTxRollbackTest extends IgniteCacheAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -74,6 +78,7 @@ public class IgniteCacheNearTxRollbackTest extends IgniteCacheAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPutAllRollback() throws Exception { IgniteCache cache = jcache(0); @@ -135,4 +140,4 @@ private static class TestCommunicationSpi extends TcpCommunicationSpi { super.sendMessage(node, msg, ackClosure); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheMultithreadedUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheMultithreadedUpdateTest.java index 703da8a59c72b..08b702749db3f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheMultithreadedUpdateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheMultithreadedUpdateTest.java @@ -27,11 +27,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -40,10 +40,8 @@ /** * */ +@RunWith(JUnit4.class) public class NearCacheMultithreadedUpdateTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -54,8 +52,6 @@ public class NearCacheMultithreadedUpdateTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -77,6 +73,7 @@ public class NearCacheMultithreadedUpdateTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testUpdateMultithreadedTx() throws Exception { updateMultithreaded(TRANSACTIONAL, false); } @@ -84,6 +81,7 @@ public void testUpdateMultithreadedTx() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateMultithreadedTxRestart() throws Exception { updateMultithreaded(TRANSACTIONAL, true); } @@ -91,6 +89,7 @@ public void testUpdateMultithreadedTxRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateMultithreadedAtomic() throws Exception { updateMultithreaded(ATOMIC, false); } @@ -98,6 +97,7 @@ public void testUpdateMultithreadedAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateMultithreadedAtomicRestart() throws Exception { updateMultithreaded(ATOMIC, true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCachePutAllMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCachePutAllMultinodeTest.java index ca60060775b15..3af1875833627 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCachePutAllMultinodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCachePutAllMultinodeTest.java @@ -31,10 +31,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -44,10 +44,8 @@ /** * */ +@RunWith(JUnit4.class) public class NearCachePutAllMultinodeTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of grids to start. */ private static final int GRID_CNT = 3; @@ -62,12 +60,6 @@ public class NearCachePutAllMultinodeTest extends GridCommonAbstractTest { @Override protected final IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - if (!client) { CacheConfiguration cc = defaultCacheConfiguration(); @@ -112,6 +104,7 @@ public class NearCachePutAllMultinodeTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testMultithreadedPutAll() throws Exception { final AtomicInteger idx = new AtomicInteger(); @@ -163,4 +156,4 @@ static class TestFactory implements Factory { }; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheSyncUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheSyncUpdateTest.java index d25301337b7ad..a83fadea7637b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheSyncUpdateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCacheSyncUpdateTest.java @@ -24,45 +24,43 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class NearCacheSyncUpdateTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); - return cfg; + startGridsMultiThreaded(3); } /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - super.beforeTestsStarted(); + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); - startGridsMultiThreaded(3); + super.afterTestsStopped(); } /** * @throws Exception If failed. */ + @Test public void testNearCacheSyncUpdateAtomic() throws Exception { nearCacheSyncUpdateTx(ATOMIC); } @@ -70,10 +68,20 @@ public void testNearCacheSyncUpdateAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearCacheSyncUpdateTx() throws Exception { nearCacheSyncUpdateTx(TRANSACTIONAL); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187") + @Test + public void testNearCacheSyncUpdateMvccTx() throws Exception { + nearCacheSyncUpdateTx(TRANSACTIONAL_SNAPSHOT); + } + /** * @param atomicityMode Atomicity mode. * @throws Exception If failed. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NoneRebalanceModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NoneRebalanceModeSelfTest.java index 5d82f832ba920..e960762cfeead 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NoneRebalanceModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NoneRebalanceModeSelfTest.java @@ -22,6 +22,9 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.NONE; import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING; @@ -29,6 +32,7 @@ /** * Test none rebalance mode. */ +@RunWith(JUnit4.class) public class NoneRebalanceModeSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @SuppressWarnings({"ConstantConditions"}) @@ -46,12 +50,22 @@ public class NoneRebalanceModeSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + startGrid(0); } + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + /** * @throws Exception If failed. */ + @Test public void testRemoveAll() throws Exception { GridNearTransactionalCache cache = (GridNearTransactionalCache)((IgniteKernal)grid(0)).internalCache(DEFAULT_CACHE_NAME); @@ -60,4 +74,4 @@ public void testRemoveAll() throws Exception { grid(0).cache(DEFAULT_CACHE_NAME).removeAll(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/CacheManualRebalancingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/CacheManualRebalancingTest.java index 3a6ad48e3057b..0f71d13731c49 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/CacheManualRebalancingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/CacheManualRebalancingTest.java @@ -24,7 +24,6 @@ import org.apache.ignite.IgniteLogger; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.compute.ComputeTaskFuture; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; @@ -32,23 +31,22 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** */ +@RunWith(JUnit4.class) public class CacheManualRebalancingTest extends GridCommonAbstractTest { /** */ private static final String MYCACHE = "mycache"; - /** */ - public static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ public static final int NODES_CNT = 2; @@ -56,8 +54,6 @@ public class CacheManualRebalancingTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setCacheConfiguration(cacheConfiguration(), new CacheConfiguration(DEFAULT_CACHE_NAME)); return cfg; @@ -91,6 +87,7 @@ private static CacheConfiguration cacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testRebalance() throws Exception { // Fill cache with large dataset to make rebalancing slow. try (IgniteDataStreamer streamer = grid(0).dataStreamer(MYCACHE)) { @@ -104,11 +101,9 @@ public void testRebalance() throws Exception { int newNodeCacheSize; // Start manual rebalancing. - IgniteCompute compute = newNode.compute().withAsync(); + IgniteCompute compute = newNode.compute(); - compute.broadcast(new MyCallable()); - - final ComputeTaskFuture rebalanceTaskFuture = compute.future(); + final IgniteFuture rebalanceTaskFuture = compute.broadcastAsync(new MyCallable()); boolean rebalanceFinished = GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { @@ -146,7 +141,7 @@ public static class MyCallable implements IgniteRunnable { assertNotNull(cache); boolean finished; - + log.info("Start rebalancing cache: " + cacheName + ", size: " + cache.localSize()); do { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.java index 96127aa5cd0f5..67a6a0ff03073 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.java @@ -36,18 +36,17 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheRabalancingDelayedPartitionMapExchangeSelfTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Map of destination node ID to runnable with logic for real message sending. * To apply real message sending use run method */ private final ConcurrentHashMap rs = new ConcurrentHashMap<>(); @@ -119,6 +118,7 @@ public class DelayableCommunicationSpi extends TcpCommunicationSpi { /** * @throws Exception e if failed. */ + @Test public void test() throws Exception { IgniteEx ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java index 0a8698a597cd8..15830fdecc68a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheRebalancingAsyncSelfTest extends GridCacheRebalancingSyncSelfTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -43,6 +47,7 @@ public class GridCacheRebalancingAsyncSelfTest extends GridCacheRebalancingSyncS /** * @throws Exception Exception. */ + @Test public void testNodeFailedAtRebalancing() throws Exception { IgniteEx ignite = startGrid(0); @@ -65,4 +70,4 @@ public void testNodeFailedAtRebalancing() throws Exception { checkSupplyContextMapIsEmpty(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingCancelTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingCancelTest.java index 3965290480a3d..725080e10d4b1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingCancelTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingCancelTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.distributed.rebalancing; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CacheRebalanceMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; @@ -31,27 +32,23 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test cases for checking cancellation rebalancing process if some events occurs. */ +@RunWith(JUnit4.class) public class GridCacheRebalancingCancelTest extends GridCommonAbstractTest { /** */ private static final String DHT_PARTITIONED_CACHE = "cacheP"; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration dfltCfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)dfltCfg.getDiscoverySpi()).setIpFinder(ipFinder); - dfltCfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); return dfltCfg; @@ -62,6 +59,7 @@ public class GridCacheRebalancingCancelTest extends GridCommonAbstractTest { * * @throws Exception Exception. */ + @Test public void testClientNodeJoinAtRebalancing() throws Exception { final IgniteEx ignite0 = startGrid(0); @@ -71,6 +69,7 @@ public void testClientNodeJoinAtRebalancing() throws Exception { .setRebalanceMode(CacheRebalanceMode.ASYNC) .setBackups(1) .setRebalanceOrder(2) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setAffinity(new RendezvousAffinityFunction(false))); for (int i = 0; i < 2048; i++) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingOrderingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingOrderingTest.java index 43db9312af217..7638acdae881b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingOrderingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingOrderingTest.java @@ -59,6 +59,9 @@ import org.apache.ignite.services.ServiceContext; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -102,6 +105,7 @@ * * */ +@RunWith(JUnit4.class) public class GridCacheRebalancingOrderingTest extends GridCommonAbstractTest { /** {@link Random} for test key generation. */ private final static Random RANDOM = new Random(); @@ -268,6 +272,7 @@ private ServerStarter startServers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvents() throws Exception { Ignite ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionCountersMvccTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionCountersMvccTest.java new file mode 100644 index 0000000000000..4166cfcabb5df --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionCountersMvccTest.java @@ -0,0 +1,29 @@ +/* + * 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. + */ +package org.apache.ignite.internal.processors.cache.distributed.rebalancing; + +import org.apache.ignite.cache.CacheAtomicityMode; + +/** + * + */ +public class GridCacheRebalancingPartitionCountersMvccTest extends GridCacheRebalancingPartitionCountersTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionCountersTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionCountersTest.java index 258e36e531322..912b38373d09d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionCountersTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionCountersTest.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.List; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; @@ -37,10 +38,14 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheRebalancingPartitionCountersTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "cache"; @@ -61,6 +66,7 @@ public class GridCacheRebalancingPartitionCountersTest extends GridCommonAbstrac .setMaxSize(100L * 1024 * 1024)) .setWalMode(WALMode.LOG_ONLY)) .setCacheConfiguration(new CacheConfiguration(CACHE_NAME) + .setAtomicityMode(atomicityMode()) .setBackups(2) .setRebalanceBatchSize(4096) // Force to create several supply messages during rebalancing. .setAffinity( @@ -79,6 +85,13 @@ public class GridCacheRebalancingPartitionCountersTest extends GridCommonAbstrac U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); } + /** + * @return Cache atomicity mode. + */ + protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } + /** * */ @@ -93,6 +106,7 @@ private boolean contains(int[] arr, int a) { /** * Tests that after rebalancing all partition update counters have the same value on all nodes. */ + @Test public void test() throws Exception { IgniteEx ignite = (IgniteEx)startGrids(3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionDistributionTest.java index f0cbd3885ac2d..ec5d0d0b1dc64 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionDistributionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingPartitionDistributionTest.java @@ -33,11 +33,14 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.assertions.Assertion; import org.apache.ignite.testframework.junits.common.GridRollingRestartAbstractTest; - +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test the behavior of the partition rebalancing during a rolling restart. */ +@RunWith(JUnit4.class) public class GridCacheRebalancingPartitionDistributionTest extends GridRollingRestartAbstractTest { /** The maximum allowable deviation from a perfect distribution. */ private static final double MAX_DEVIATION = 0.20; @@ -60,6 +63,7 @@ public class GridCacheRebalancingPartitionDistributionTest extends GridRollingRe * The test performs rolling restart and checks no server drops out and the partitions are balanced during * redistribution. */ + @Test public void testRollingRestart() throws InterruptedException { awaitPartitionMapExchange(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncCheckDataTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncCheckDataTest.java index 8a43b65d75a70..4b5e1a8f7189c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncCheckDataTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncCheckDataTest.java @@ -21,13 +21,14 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -35,19 +36,16 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheRebalancingSyncCheckDataTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setCacheMode(REPLICATED); ccfg.setRebalanceMode(SYNC); + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); cfg.setCacheConfiguration(ccfg); @@ -57,6 +55,7 @@ public class GridCacheRebalancingSyncCheckDataTest extends GridCommonAbstractTes /** * @throws Exception If failed. */ + @Test public void testDataRebalancing() throws Exception { Ignite ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java index 0bb35d1fb7526..b3831d30b99ae 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java @@ -21,11 +21,16 @@ import java.util.List; import java.util.Map; import java.util.Random; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CacheRebalanceMode; +import org.apache.ignite.cache.query.ScanQuery; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; @@ -35,12 +40,12 @@ import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; import org.apache.ignite.internal.util.lang.GridAbsPredicateX; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.PA; @@ -51,10 +56,15 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.GridTestUtils.SF; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assume; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheRebalanceMode.NONE; @@ -62,15 +72,13 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final int TEST_SIZE = 100_000; + private static final int TEST_SIZE = SF.applyLB(100_000, 10_000); /** */ - private static final long TOPOLOGY_STILLNESS_TIME = 30_000L; + private static final long TOPOLOGY_STILLNESS_TIME = SF.applyLB(30_000, 5_000); /** partitioned cache name. */ protected static final String CACHE_NAME_DHT_PARTITIONED = "cacheP"; @@ -103,7 +111,6 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration iCfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder); ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true); TcpCommunicationSpi commSpi = new CollectingCommunicationSpi(); @@ -125,6 +132,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { cachePCfg.setRebalanceBatchSize(1); cachePCfg.setRebalanceBatchesPrefetchCount(1); cachePCfg.setRebalanceOrder(2); + cachePCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); CacheConfiguration cachePCfg2 = new CacheConfiguration<>(DEFAULT_CACHE_NAME); @@ -133,7 +141,8 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { cachePCfg2.setRebalanceMode(CacheRebalanceMode.SYNC); cachePCfg2.setBackups(1); cachePCfg2.setRebalanceOrder(2); - cachePCfg2.setRebalanceDelay(5000); + cachePCfg2.setRebalanceDelay(SF.applyLB(5000, 500)); + cachePCfg2.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); CacheConfiguration cacheRCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); @@ -142,6 +151,8 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { cacheRCfg.setRebalanceMode(CacheRebalanceMode.SYNC); cacheRCfg.setRebalanceBatchSize(1); cacheRCfg.setRebalanceBatchesPrefetchCount(Integer.MAX_VALUE); + cacheRCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + ((TcpCommunicationSpi)iCfg.getCommunicationSpi()).setSharedMemoryPort(-1);//Shmem fail fix for Integer.MAX_VALUE. CacheConfiguration cacheRCfg2 = new CacheConfiguration<>(DEFAULT_CACHE_NAME); @@ -150,6 +161,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest { cacheRCfg2.setCacheMode(CacheMode.REPLICATED); cacheRCfg2.setRebalanceMode(CacheRebalanceMode.SYNC); cacheRCfg2.setRebalanceOrder(4); + cacheRCfg2.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); iCfg.setCacheConfiguration(cachePCfg, cachePCfg2, cacheRCfg, cacheRCfg2); @@ -177,12 +189,16 @@ protected void generateData(Ignite ignite, int from, int iter) { * @param iter Iteration. */ protected void generateData(Ignite ignite, String name, int from, int iter) { - for (int i = from; i < from + TEST_SIZE; i++) { - if ((i + 1) % (TEST_SIZE / 10) == 0) - log.info("Prepared " + (i + 1) * 100 / (TEST_SIZE) + "% entries. [count=" + TEST_SIZE + - ", iteration=" + iter + ", cache=" + name + "]"); + try (IgniteDataStreamer dataStreamer = ignite.dataStreamer(name)) { + dataStreamer.allowOverwrite(true); + + for (int i = from; i < from + TEST_SIZE; i++) { + if ((i + 1) % (TEST_SIZE / 10) == 0) + log.info("Prepared " + (i + 1) * 100 / (TEST_SIZE) + "% entries. [count=" + TEST_SIZE + + ", iteration=" + iter + ", cache=" + name + "]"); - ignite.cache(name).put(i, i + name.hashCode() + iter); + dataStreamer.addData(i, i + name.hashCode() + iter); + } } } @@ -192,26 +208,46 @@ protected void generateData(Ignite ignite, String name, int from, int iter) { * @param iter Iteration. */ protected void checkData(Ignite ignite, int from, int iter) { - checkData(ignite, CACHE_NAME_DHT_PARTITIONED, from, iter); - checkData(ignite, CACHE_NAME_DHT_PARTITIONED_2, from, iter); - checkData(ignite, CACHE_NAME_DHT_REPLICATED, from, iter); - checkData(ignite, CACHE_NAME_DHT_REPLICATED_2, from, iter); + checkData(ignite, CACHE_NAME_DHT_PARTITIONED, from, iter, true); + checkData(ignite, CACHE_NAME_DHT_PARTITIONED_2, from, iter, true); + checkData(ignite, CACHE_NAME_DHT_REPLICATED, from, iter, true); + checkData(ignite, CACHE_NAME_DHT_REPLICATED_2, from, iter, true); } /** * @param ignite Ignite. + * @param name Cache name. * @param from Start from key. * @param iter Iteration. - * @param name Cache name. + * @param scan If true then "scan" query will be used instead of "get" in a loop. Should be "false" when run in + * parallel with other operations. Otherwise should be "true", because it's much faster in such situations. */ - protected void checkData(Ignite ignite, String name, int from, int iter) { - for (int i = from; i < from + TEST_SIZE; i++) { - if ((i + 1) % (TEST_SIZE / 10) == 0) - log.info("<" + name + "> Checked " + (i + 1) * 100 / (TEST_SIZE) + "% entries. [count=" + TEST_SIZE + - ", iteration=" + iter + ", cache=" + name + "]"); - - assertEquals("Value does not match [key=" + i + ", cache=" + name + ']', - ignite.cache(name).get(i), i + name.hashCode() + iter); + protected void checkData(Ignite ignite, String name, int from, int iter, boolean scan) { + IgniteCache cache = ignite.cache(name); + + if (scan) { + AtomicInteger cnt = new AtomicInteger(); + + cache.query(new ScanQuery((k, v) -> k >= from && k < from + TEST_SIZE)).forEach(entry -> { + if (cnt.incrementAndGet() % (TEST_SIZE / 10) == 0) + log.info("<" + name + "> Checked " + cnt.get() * 100 / TEST_SIZE + "% entries. [count=" + + TEST_SIZE + ", iteration=" + iter + ", cache=" + name + "]"); + + assertEquals("Value does not match [key=" + entry.getKey() + ", cache=" + name + ']', + entry.getValue().intValue(), entry.getKey() + name.hashCode() + iter); + }); + + assertEquals(TEST_SIZE, cnt.get()); + } + else { + for (int i = from; i < from + TEST_SIZE; i++) { + if ((i + 1) % (TEST_SIZE / 10) == 0) + log.info("<" + name + "> Checked " + (i + 1) * 100 / (TEST_SIZE) + "% entries. [count=" + + TEST_SIZE + ", iteration=" + iter + ", cache=" + name + "]"); + + assertEquals("Value does not match [key=" + i + ", cache=" + name + ']', + cache.get(i).intValue(), i + name.hashCode() + iter); + } } } @@ -225,6 +261,8 @@ protected void checkData(Ignite ignite, String name, int from, int iter) { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10560") + @Test public void testSimpleRebalancing() throws Exception { IgniteKernal ignite = (IgniteKernal)startGrid(0); @@ -276,6 +314,7 @@ public void testSimpleRebalancing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadRebalancing() throws Exception { final Ignite ignite = startGrid(0); @@ -309,7 +348,7 @@ public void testLoadRebalancing() throws Exception { Thread t2 = new Thread() { @Override public void run() { while (!concurrentStartFinished) - checkData(ignite, CACHE_NAME_DHT_PARTITIONED, 0, 0); + checkData(ignite, CACHE_NAME_DHT_PARTITIONED, 0, 0, false); } }; @@ -464,7 +503,10 @@ protected void awaitPartitionMessagesAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testComplexRebalancing() throws Exception { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10561", MvccFeatureChecker.forcedMvcc()); + final Ignite ignite = startGrid(0); generateData(ignite, 0, 0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java index 6d72a52b362de..07e652f25263b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java @@ -22,25 +22,25 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CacheRebalanceMode; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.thread.IgniteThread; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheRebalancingUnmarshallingFailedSelfTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** partitioned cache name. */ protected static String CACHE = "cache"; @@ -109,6 +109,7 @@ public TestKey() { cfg.setCacheMode(CacheMode.PARTITIONED); cfg.setRebalanceMode(CacheRebalanceMode.SYNC); cfg.setBackups(0); + cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); iCfg.setCacheConfiguration(cfg); @@ -118,6 +119,7 @@ public TestKey() { /** * @throws Exception e. */ + @Test public void test() throws Exception { String marshClsName = GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingWithAsyncClearingMvccTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingWithAsyncClearingMvccTest.java new file mode 100644 index 0000000000000..e08a43f9b52fe --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingWithAsyncClearingMvccTest.java @@ -0,0 +1,31 @@ +/* + * 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. + */ +package org.apache.ignite.internal.processors.cache.distributed.rebalancing; + +import org.apache.ignite.cache.CacheAtomicityMode; +import org.junit.Ignore; + +/** + * + */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-10421") +public class GridCacheRebalancingWithAsyncClearingMvccTest extends GridCacheRebalancingWithAsyncClearingTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingWithAsyncClearingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingWithAsyncClearingTest.java index 1b176ae8a07ba..fe4d685cf86b8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingWithAsyncClearingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingWithAsyncClearingTest.java @@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.PartitionLossPolicy; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; @@ -31,16 +32,20 @@ import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheRebalancingWithAsyncClearingTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "cache"; @@ -63,7 +68,8 @@ public class GridCacheRebalancingWithAsyncClearingTest extends GridCommonAbstrac .setMaxSize(100L * 1024 * 1024)) ); - cfg.setCacheConfiguration(new CacheConfiguration(CACHE_NAME) + cfg.setCacheConfiguration(new CacheConfiguration<>(CACHE_NAME) + .setAtomicityMode(atomicityMode()) .setBackups(2) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) .setIndexedTypes(Integer.class, Integer.class) @@ -92,11 +98,19 @@ public class GridCacheRebalancingWithAsyncClearingTest extends GridCommonAbstrac cleanPersistenceDir(); } + /** + * @return Atomicity mode. + */ + protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } + /** * Test that partition clearing doesn't block partitions map exchange. * * @throws Exception If failed. */ + @Test public void testPartitionClearingNotBlockExchange() throws Exception { System.setProperty(IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, "1"); @@ -189,6 +203,7 @@ public void testPartitionClearingNotBlockExchange() throws Exception { * * @throws Exception If failed. */ + @Test public void testCorrectRebalancingCurrentlyRentingPartitions() throws Exception { IgniteEx ignite = (IgniteEx) startGrids(3); ignite.cluster().active(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/IgniteRebalanceOnCachesStoppingOrDestroyingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/IgniteRebalanceOnCachesStoppingOrDestroyingTest.java new file mode 100644 index 0000000000000..e36eaa81501fc --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/IgniteRebalanceOnCachesStoppingOrDestroyingTest.java @@ -0,0 +1,325 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.rebalancing; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.TransactionConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.failure.StopNodeFailureHandler; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.managers.communication.GridIoMessage; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage; +import org.apache.ignite.internal.util.future.GridFutureAdapter; +import org.apache.ignite.internal.util.lang.IgniteThrowableConsumer; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.CU; +import org.apache.ignite.lang.IgniteRunnable; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * + */ +@RunWith(JUnit4.class) +public class IgniteRebalanceOnCachesStoppingOrDestroyingTest extends GridCommonAbstractTest { + /** */ + private static final String CACHE_1 = "cache_1"; + + /** */ + private static final String CACHE_2 = "cache_2"; + + /** */ + private static final String CACHE_3 = "cache_3"; + + /** */ + private static final String CACHE_4 = "cache_4"; + + /** */ + private static final String GROUP_1 = "group_1"; + + /** */ + private static final String GROUP_2 = "group_2"; + + /** */ + private static final int REBALANCE_BATCH_SIZE = 50 * 1024; + + /** Number of loaded keys in each cache. */ + private static final int KEYS_SIZE = 3000; + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setCommunicationSpi(new RebalanceBlockingSPI()); + + cfg.setFailureHandler(new StopNodeFailureHandler()); + + cfg.setRebalanceThreadPoolSize(4); + + cfg.setTransactionConfiguration(new TransactionConfiguration() + .setDefaultTxTimeout(1000)); + + cfg.setDataStorageConfiguration( + new DataStorageConfiguration() + .setWalMode(WALMode.LOG_ONLY) + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setPersistenceEnabled(true) + .setMaxSize(100L * 1024 * 1024))); + + return cfg; + } + + /** + * + */ + @Test + public void testStopCachesOnDeactivationFirstGroup() throws Exception { + testStopCachesOnDeactivation(GROUP_1); + } + + /** + * + */ + @Test + public void testStopCachesOnDeactivationSecondGroup() throws Exception { + testStopCachesOnDeactivation(GROUP_2); + } + + /** + * @param groupName Group name. + * @throws Exception If failed. + */ + private void testStopCachesOnDeactivation(String groupName) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10582"); + + performTest(ig -> { + ig.cluster().active(false); + + // Add to escape possible long waiting in awaitPartitionMapExchange due to {@link CacheAffinityChangeMessage}. + ig.cluster().active(true); + + return null; + }, groupName); + } + + /** + * + */ + @Test + public void testDestroySpecificCachesInDifferentCacheGroupsFirstGroup() throws Exception { + testDestroySpecificCachesInDifferentCacheGroups(GROUP_1); + } + + /** + * + */ + @Test + public void testDestroySpecificCachesInDifferentCacheGroupsSecondGroup() throws Exception { + testDestroySpecificCachesInDifferentCacheGroups(GROUP_2); + } + + /** + * @param groupName Group name. + * @throws Exception If failed. + */ + private void testDestroySpecificCachesInDifferentCacheGroups(String groupName) throws Exception { + performTest(ig -> { + ig.destroyCaches(Arrays.asList(CACHE_1, CACHE_3)); + + return null; + }, groupName); + } + + /** + * + */ + @Test + public void testDestroySpecificCacheAndCacheGroupFirstGroup() throws Exception { + testDestroySpecificCacheAndCacheGroup(GROUP_1); + } + + /** + * + */ + @Test + public void testDestroySpecificCacheAndCacheGroupSecondGroup() throws Exception { + testDestroySpecificCacheAndCacheGroup(GROUP_2); + } + + /** + * @param groupName Group name. + * @throws Exception If failed. + */ + private void testDestroySpecificCacheAndCacheGroup(String groupName) throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10582"); + + performTest(ig -> { + ig.destroyCaches(Arrays.asList(CACHE_1, CACHE_3, CACHE_4)); + + return null; + }, groupName); + } + + /** + * @param testAction Action that trigger stop or destroy of caches. + */ + private void performTest(IgniteThrowableConsumer testAction, String groupName) throws Exception { + IgniteEx ig0 = (IgniteEx)startGrids(2); + + ig0.cluster().active(true); + + stopGrid(1); + + loadData(ig0); + + IgniteEx ig1 = startGrid(1); + + RebalanceBlockingSPI commSpi = (RebalanceBlockingSPI)ig1.configuration().getCommunicationSpi(); + + // Complete all futures for groups that we don't need to wait. + commSpi.resumeRebalanceFutures.forEach((k, v) -> { + if (k != CU.cacheId(groupName)) + v.onDone(); + }); + + CountDownLatch latch = commSpi.suspendRebalanceInMiddleLatch.get(CU.cacheId(groupName)); + + assert latch != null; + + // Await some middle point rebalance for group. + latch.await(); + + testAction.accept(ig0); + + // Resume rebalance after action performed. + commSpi.resumeRebalanceFutures.get(CU.cacheId(groupName)).onDone(); + + awaitPartitionMapExchange(true, true, null, true); + + assertNull(grid(1).context().failure().failureContext()); + } + + /** + * @param ig Ig. + */ + private void loadData(Ignite ig) { + List configs = Stream.of( + F.t(CACHE_1, GROUP_1), + F.t(CACHE_2, GROUP_1), + F.t(CACHE_3, GROUP_2), + F.t(CACHE_4, GROUP_2) + ).map(names -> new CacheConfiguration<>(names.get1()) + .setGroupName(names.get2()) + .setRebalanceBatchSize(REBALANCE_BATCH_SIZE) + .setCacheMode(CacheMode.REPLICATED) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + ).collect(Collectors.toList()); + + ig.getOrCreateCaches(configs); + + configs.forEach(cfg -> { + try (IgniteDataStreamer streamer = ig.dataStreamer(cfg.getName())) { + for (int i = 0; i < KEYS_SIZE; i++) + streamer.addData(i, new byte[1024]); + + streamer.flush(); + } + }); + } + + /** + * + */ + private static class RebalanceBlockingSPI extends TcpCommunicationSpi { + /** */ + private final Map resumeRebalanceFutures = new ConcurrentHashMap<>(); + + /** */ + private final Map suspendRebalanceInMiddleLatch = new ConcurrentHashMap<>(); + + /** */ + RebalanceBlockingSPI() { + resumeRebalanceFutures.put(CU.cacheId(GROUP_1), new GridFutureAdapter()); + resumeRebalanceFutures.put(CU.cacheId(GROUP_2), new GridFutureAdapter()); + suspendRebalanceInMiddleLatch.put(CU.cacheId(GROUP_1), new CountDownLatch(3)); + suspendRebalanceInMiddleLatch.put(CU.cacheId(GROUP_2), new CountDownLatch(3)); + } + + /** {@inheritDoc} */ + @Override protected void notifyListener(UUID sndId, Message msg, IgniteRunnable msgC) { + if (msg instanceof GridIoMessage && + ((GridIoMessage)msg).message() instanceof GridDhtPartitionSupplyMessage) { + GridDhtPartitionSupplyMessage msg0 = (GridDhtPartitionSupplyMessage)((GridIoMessage)msg).message(); + + CountDownLatch latch = suspendRebalanceInMiddleLatch.get(msg0.groupId()); + + if (latch != null) { + if (latch.getCount() > 0) + latch.countDown(); + else { + resumeRebalanceFutures.get(msg0.groupId()).listen(f -> super.notifyListener(sndId, msg, msgC)); + + return; + } + } + } + + super.notifyListener(sndId, msg, msgC); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheAbstractReplicatedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheAbstractReplicatedByteArrayValuesSelfTest.java index 9fd2f29c15623..b4e58fcc4ec6b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheAbstractReplicatedByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheAbstractReplicatedByteArrayValuesSelfTest.java @@ -41,7 +41,7 @@ public abstract class GridCacheAbstractReplicatedByteArrayValuesSelfTest extends /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration0() { - CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + CacheConfiguration cfg = new CacheConfiguration(); cfg.setCacheMode(REPLICATED); cfg.setAtomicityMode(TRANSACTIONAL); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedLockSelfTest.java index 0595f7d1a3285..c37e814546ea6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedLockSelfTest.java @@ -19,12 +19,16 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.distributed.GridCacheLockAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * Test cases for multi-threaded tests. */ +@RunWith(JUnit4.class) public class GridCacheReplicatedLockSelfTest extends GridCacheLockAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -32,7 +36,8 @@ public class GridCacheReplicatedLockSelfTest extends GridCacheLockAbstractTest { } /** {@inheritDoc} */ + @Test @Override public void testLockReentrancy() throws Throwable { fail("https://issues.apache.org/jira/browse/IGNITE-835"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMetricsSelfTest.java index 16be6733a9392..374a765ba446e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMetricsSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheTransactionalAbstractMetricsSelfTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -29,6 +30,13 @@ public class GridCacheReplicatedMetricsSelfTest extends GridCacheTransactionalAb /** */ private static final int GRID_CNT = 2; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.METRICS); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeLockSelfTest.java index a34024424ea9a..42fa698c6765f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeLockSelfTest.java @@ -19,18 +19,15 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheMultiNodeLockAbstractTest; +import org.junit.Ignore; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * Test cases for multi-threaded tests. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-601") public class GridCacheReplicatedMultiNodeLockSelfTest extends GridCacheMultiNodeLockAbstractTest { - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-601"); - } - /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration() { CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -39,4 +36,4 @@ public class GridCacheReplicatedMultiNodeLockSelfTest extends GridCacheMultiNode return cacheCfg; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeSelfTest.java index f1eed3a693905..6fe1ebad96a1c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMultiNodeSelfTest.java @@ -20,18 +20,15 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheMultiNodeAbstractTest; +import org.junit.Ignore; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * Test cases for multi-threaded tests. */ +@Ignore("https://issues.apache.org/jira/browse/IGNITE-601") public class GridCacheReplicatedMultiNodeSelfTest extends GridCacheMultiNodeAbstractTest { - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-601"); - } - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -44,4 +41,4 @@ public class GridCacheReplicatedMultiNodeSelfTest extends GridCacheMultiNodeAbst return cfg; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMvccTxMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMvccTxMultiThreadedSelfTest.java new file mode 100644 index 0000000000000..2df5d45b5bfd5 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMvccTxMultiThreadedSelfTest.java @@ -0,0 +1,81 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.replicated; + +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.cache.IgniteMvccTxMultiThreadedAbstractTest; + +import static org.apache.ignite.cache.CacheMode.REPLICATED; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; + +/** + * Tests for replicated transactions. + */ +public class GridCacheReplicatedMvccTxMultiThreadedSelfTest extends IgniteMvccTxMultiThreadedAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + CacheConfiguration ccfg = defaultCacheConfiguration(); + + ccfg.setCacheMode(REPLICATED); + ccfg.setEvictionPolicy(null); + + ccfg.setWriteSynchronizationMode(FULL_SYNC); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int keyCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int maxKeyValue() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int threadCount() { + return 5; + } + + /** {@inheritDoc} */ + @Override protected int iterations() { + return 1000; + } + + /** {@inheritDoc} */ + @Override protected boolean isTestDebug() { + return false; + } + + /** {@inheritDoc} */ + @Override protected boolean printMemoryStats() { + return true; + } +} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMvccTxSingleThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMvccTxSingleThreadedSelfTest.java new file mode 100644 index 0000000000000..7e8063431aa45 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMvccTxSingleThreadedSelfTest.java @@ -0,0 +1,77 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.replicated; + +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.cache.IgniteMvccTxSingleThreadedAbstractTest; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheMode.REPLICATED; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; + +/** + * Tests for replicated transactions. + */ +public class GridCacheReplicatedMvccTxSingleThreadedSelfTest extends IgniteMvccTxSingleThreadedAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + CacheConfiguration ccfg = defaultCacheConfiguration(); + + ccfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + ccfg.setCacheMode(REPLICATED); + ccfg.setEvictionPolicy(null); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int keyCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int maxKeyValue() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected int iterations() { + return 20; + } + + /** {@inheritDoc} */ + @Override protected boolean isTestDebug() { + return false; + } + + /** {@inheritDoc} */ + @Override protected boolean printMemoryStats() { + return true; + } +} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMvccTxTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMvccTxTimeoutSelfTest.java new file mode 100644 index 0000000000000..2f953236c467b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedMvccTxTimeoutSelfTest.java @@ -0,0 +1,44 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.distributed.replicated; + +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.cache.distributed.IgniteMvccTxTimeoutAbstractTest; + +import static org.apache.ignite.cache.CacheMode.REPLICATED; + +/** + * Simple cache test. + */ +public class GridCacheReplicatedMvccTxTimeoutSelfTest extends IgniteMvccTxTimeoutAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + CacheConfiguration ccfg = defaultCacheConfiguration(); + + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + ccfg.setCacheMode(REPLICATED); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } +} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedNodeRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedNodeRestartSelfTest.java index bff8755218786..fde81ce96cfea 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedNodeRestartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedNodeRestartSelfTest.java @@ -19,6 +19,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.GridCacheAbstractNodeRestartSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -27,6 +30,7 @@ /** * Tests node restart. */ +@RunWith(JUnit4.class) public class GridCacheReplicatedNodeRestartSelfTest extends GridCacheAbstractNodeRestartSelfTest { /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration() { @@ -55,81 +59,97 @@ public class GridCacheReplicatedNodeRestartSelfTest extends GridCacheAbstractNod } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutTwoNodesNoBackups() throws Throwable { super.testRestartWithPutTwoNodesNoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutTwoNodesOneBackup() throws Throwable { // No-op. } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutFourNodesOneBackups() throws Throwable { super.testRestartWithPutFourNodesOneBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutFourNodesNoBackups() throws Throwable { // No-op. } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutSixNodesTwoBackups() throws Throwable { super.testRestartWithPutSixNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutEightNodesTwoBackups() throws Throwable { super.testRestartWithPutEightNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithPutTenNodesTwoBackups() throws Throwable { super.testRestartWithPutTenNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxTwoNodesNoBackups() throws Throwable { // No-op. } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxTwoNodesOneBackup() throws Throwable { super.testRestartWithTxTwoNodesOneBackup(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxFourNodesOneBackups() throws Throwable { super.testRestartWithTxFourNodesOneBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxFourNodesNoBackups() throws Throwable { // No-op. } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxSixNodesTwoBackups() throws Throwable { super.testRestartWithTxSixNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxEightNodesTwoBackups() throws Throwable { super.testRestartWithTxEightNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxTenNodesTwoBackups() throws Throwable { super.testRestartWithTxTenNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxPutAllTenNodesTwoBackups() throws Throwable { super.testRestartWithTxPutAllTenNodesTwoBackups(); } /** {@inheritDoc} */ + @Test @Override public void testRestartWithTxPutAllFourNodesTwoBackups() throws Throwable { super.testRestartWithTxPutAllFourNodesTwoBackups(); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxMultiNodeBasicTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxMultiNodeBasicTest.java index ae97c0b15ed4b..35b8d9bc6cb9a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxMultiNodeBasicTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxMultiNodeBasicTest.java @@ -20,6 +20,9 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.IgniteTxMultiNodeAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -27,6 +30,7 @@ /** * Test basic cache operations in transactions. */ +@RunWith(JUnit4.class) public class GridCacheReplicatedTxMultiNodeBasicTest extends IgniteTxMultiNodeAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -44,36 +48,43 @@ public class GridCacheReplicatedTxMultiNodeBasicTest extends IgniteTxMultiNodeAb } /** {@inheritDoc} */ + @Test @Override public void testPutOneEntryInTx() throws Exception { super.testPutOneEntryInTx(); } /** {@inheritDoc} */ + @Test @Override public void testPutTwoEntriesInTx() throws Exception { super.testPutTwoEntriesInTx(); } /** {@inheritDoc} */ + @Test @Override public void testPutOneEntryInTxMultiThreaded() throws Exception { super.testPutOneEntryInTxMultiThreaded(); } /** {@inheritDoc} */ + @Test @Override public void testPutTwoEntryInTxMultiThreaded() throws Exception { super.testPutTwoEntryInTxMultiThreaded(); } /** {@inheritDoc} */ + @Test @Override public void testRemoveInTxQueried() throws Exception { super.testRemoveInTxQueried(); } /** {@inheritDoc} */ + @Test @Override public void testRemoveInTxSimple() throws Exception { super.testRemoveInTxSimple(); } /** {@inheritDoc} */ + @Test @Override public void testRemoveInTxQueriedMultiThreaded() throws Exception { super.testRemoveInTxQueriedMultiThreaded(); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxMultiThreadedSelfTest.java index bcd7e582aeeee..30c79d7f49340 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxMultiThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxMultiThreadedSelfTest.java @@ -20,12 +20,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.IgniteTxMultiThreadedAbstractTest; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.log4j.Level; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -34,15 +29,6 @@ * Tests for replicated transactions. */ public class GridCacheReplicatedTxMultiThreadedSelfTest extends IgniteTxMultiThreadedAbstractTest { - /** Cache debug flag. */ - private static final boolean CACHE_DEBUG = false; - - /** Log to file flag. */ - private static final boolean LOG_TO_FILE = true; - - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -50,8 +36,6 @@ public class GridCacheReplicatedTxMultiThreadedSelfTest extends IgniteTxMultiThr TransactionConfiguration tCfg = new TransactionConfiguration(); - tCfg.setTxSerializableEnabled(true); - c.setTransactionConfiguration(tCfg); CacheConfiguration cc = defaultCacheConfiguration(); @@ -64,15 +48,6 @@ public class GridCacheReplicatedTxMultiThreadedSelfTest extends IgniteTxMultiThr c.setCacheConfiguration(cc); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - - if (CACHE_DEBUG) - resetLog4j(Level.DEBUG, LOG_TO_FILE, GridCacheProcessor.class.getPackage().getName()); - return c; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxSingleThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxSingleThreadedSelfTest.java index 68d8a93e4b44d..80b2f3b4b22fc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxSingleThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxSingleThreadedSelfTest.java @@ -19,12 +19,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.IgniteTxSingleThreadedAbstractTest; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.log4j.Level; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -33,42 +28,19 @@ * Tests for replicated transactions. */ public class GridCacheReplicatedTxSingleThreadedSelfTest extends IgniteTxSingleThreadedAbstractTest { - /** Cache debug flag. */ - private static final boolean CACHE_DEBUG = false; - - /** Log to file flag. */ - private static final boolean LOG_TO_FILE = true; - - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @SuppressWarnings({"unchecked"}) + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - - c.getTransactionConfiguration().setTxSerializableEnabled(true); - - CacheConfiguration cc = defaultCacheConfiguration(); - - cc.setCacheMode(REPLICATED); - - cc.setEvictionPolicy(null); - - cc.setWriteSynchronizationMode(FULL_SYNC); - - c.setCacheConfiguration(cc); - - TcpDiscoverySpi spi = new TcpDiscoverySpi(); + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - spi.setIpFinder(ipFinder); + CacheConfiguration ccfg = defaultCacheConfiguration(); - c.setDiscoverySpi(spi); + ccfg.setCacheMode(REPLICATED); + ccfg.setEvictionPolicy(null); + ccfg.setWriteSynchronizationMode(FULL_SYNC); - if (CACHE_DEBUG) - resetLog4j(Level.DEBUG, LOG_TO_FILE, GridCacheProcessor.class.getPackage().getName()); + cfg.setCacheConfiguration(ccfg); - return c; + return cfg; } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxTimeoutSelfTest.java index a63a302692028..9a748ba30543d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxTimeoutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedTxTimeoutSelfTest.java @@ -20,9 +20,6 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.distributed.IgniteTxTimeoutAbstractTest; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -30,31 +27,16 @@ * Simple cache test. */ public class GridCacheReplicatedTxTimeoutSelfTest extends IgniteTxTimeoutAbstractTest { - /** Transaction timeout. */ - private static final long TIMEOUT = 50; - - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - c.getTransactionConfiguration().setDefaultTxTimeout(TIMEOUT); - c.getTransactionConfiguration().setTxSerializableEnabled(true); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(REPLICATED); c.setCacheConfiguration(cc); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - c.setDiscoverySpi(spi); - return c; } } \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java index e55a43497dc42..6bdbd56d56ad1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java @@ -23,11 +23,12 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -37,10 +38,8 @@ /** * Multithreaded tests for replicated cache preloader. */ +@RunWith(JUnit4.class) public class GridCacheSyncReplicatedPreloadSelfTest extends GridCommonAbstractTest { - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * Constructs test. */ @@ -52,12 +51,6 @@ public GridCacheSyncReplicatedPreloadSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(REPLICATED); @@ -86,7 +79,11 @@ public GridCacheSyncReplicatedPreloadSelfTest() { * @throws Exception If test failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testNodeRestart() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10082"); + int keyCnt = 1000; int retries = 20; @@ -116,6 +113,7 @@ public void testNodeRestart() throws Exception { * @throws Exception If test failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testNodeRestartMultithreaded() throws Exception { final int keyCnt = 1000; final int retries = 50; @@ -157,4 +155,4 @@ public void testNodeRestartMultithreaded() throws Exception { }, threadCnt); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java index 393cfb93b0386..98d86fd6290c8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridReplicatedTxPreloadTest.java @@ -20,12 +20,16 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.distributed.IgniteTxPreloadAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * Tests cache transaction during preloading. */ +@RunWith(JUnit4.class) public class GridReplicatedTxPreloadTest extends IgniteTxPreloadAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -38,6 +42,7 @@ public class GridReplicatedTxPreloadTest extends IgniteTxPreloadAbstractTest { } /** {@inheritDoc} */ + @Test @Override public void testLocalTxPreloadingOptimistic() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-1755"); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheSyncRebalanceModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheSyncRebalanceModeSelfTest.java index 8f96639e5302d..2caf38fa3c675 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheSyncRebalanceModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheSyncRebalanceModeSelfTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheSyncRebalanceModeSelfTest extends GridCommonAbstractTest { /** Entry count. */ public static final int CNT = 100_000; @@ -60,6 +64,7 @@ public class IgniteCacheSyncRebalanceModeSelfTest extends GridCommonAbstractTest /** * @throws Exception if failed. */ + @Test public void testStaticCache() throws Exception { IgniteEx ignite = startGrid(0); @@ -85,6 +90,7 @@ public void testStaticCache() throws Exception { /** * @throws Exception if failed. */ + @Test public void testDynamicCache() throws Exception { IgniteEx ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java index 7a55c8a0bae76..f178e24c7bf80 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java @@ -28,6 +28,9 @@ import org.apache.ignite.lifecycle.LifecycleBean; import org.apache.ignite.lifecycle.LifecycleEventType; import org.apache.ignite.resources.IgniteInstanceResource; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -38,7 +41,7 @@ /** * Tests for replicated cache preloader. */ -@SuppressWarnings({"PublicInnerClass"}) +@RunWith(JUnit4.class) public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloadLifecycleAbstractTest { /** */ private static boolean quiet = true; @@ -160,6 +163,7 @@ public void checkCache(Object[] keys) throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBean1() throws Exception { checkCache(keys(true, DFLT_KEYS.length, DFLT_KEYS)); } @@ -167,6 +171,7 @@ public void testLifecycleBean1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBean2() throws Exception { checkCache(keys(false, DFLT_KEYS.length, DFLT_KEYS)); } @@ -174,6 +179,7 @@ public void testLifecycleBean2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBean3() throws Exception { checkCache(keys(true, 500)); } @@ -181,6 +187,7 @@ public void testLifecycleBean3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBean4() throws Exception { checkCache(keys(false, 500)); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java index f1140916d507d..a3413a407ff2c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java @@ -17,12 +17,9 @@ package org.apache.ignite.internal.processors.cache.distributed.replicated.preloader; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Random; import java.util.UUID; @@ -39,10 +36,7 @@ import org.apache.ignite.cache.CacheEntryEventSerializableFilter; import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.affinity.AffinityFunction; -import org.apache.ignite.cache.affinity.AffinityFunctionContext; import org.apache.ignite.cache.affinity.AffinityKeyMapper; -import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.Event; @@ -51,16 +45,18 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; +import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.P2; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.plugin.CachePluginConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.ASYNC; @@ -77,6 +73,7 @@ * Tests for replicated cache preloader. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { /** */ private CacheRebalanceMode preloadMode = ASYNC; @@ -84,9 +81,6 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { /** */ private int batchSize = 4096; - /** */ - private int poolSize = 2; - /** */ private volatile boolean extClassloadingAtCfg = false; @@ -99,9 +93,6 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { /** Disable p2p. */ private volatile boolean disableP2p = false; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static volatile CountDownLatch latch; @@ -119,11 +110,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); + cfg.setRebalanceThreadPoolSize(2); cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName)); @@ -173,7 +160,6 @@ CacheConfiguration cacheConfiguration(String igniteInstanceName) { cacheCfg.setWriteSynchronizationMode(FULL_SYNC); cacheCfg.setRebalanceMode(preloadMode); cacheCfg.setRebalanceBatchSize(batchSize); - cacheCfg.setRebalanceThreadPoolSize(poolSize); if (extClassloadingAtCfg) loadExternalClassesToCfg(cacheCfg); @@ -220,6 +206,7 @@ private void loadExternalClassesToCfg(CacheConfiguration cacheCfg) { /** * @throws Exception If failed. */ + @Test public void testSingleNode() throws Exception { preloadMode = SYNC; @@ -234,6 +221,7 @@ public void testSingleNode() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testIntegrity() throws Exception { preloadMode = SYNC; @@ -309,6 +297,7 @@ public void testIntegrity() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDeployment() throws Exception { // TODO GG-11141. if (true) @@ -387,6 +376,7 @@ public void testDeployment() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testExternalClassesAtConfiguration() throws Exception { try { extClassloadingAtCfg = true; @@ -442,6 +432,7 @@ public void testExternalClassesAtConfiguration() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testExternalClassesAtConfigurationDynamicStart() throws Exception { try { extClassloadingAtCfg = false; @@ -480,6 +471,7 @@ public void testExternalClassesAtConfigurationDynamicStart() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testExternalClassesAtConfigurationDynamicStart2() throws Exception { try { extClassloadingAtCfg = false; @@ -518,6 +510,7 @@ public void testExternalClassesAtConfigurationDynamicStart2() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testExternalClassesAtMessage() throws Exception { try { useExtClassLoader = true; @@ -570,15 +563,20 @@ public void testExternalClassesAtMessage() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testExternalClassesAtEventP2pDisabled() throws Exception { - testExternalClassesAtEvent0(true); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + testExternalClassesAtEvent0(true); } /** * @throws Exception If test failed. */ + @Test public void testExternalClassesAtEvent() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + testExternalClassesAtEvent0(false); } @@ -625,6 +623,7 @@ private void testExternalClassesAtEvent0(boolean p2p) throws Exception { /** * @throws Exception If test failed. */ + @Test public void testSync() throws Exception { preloadMode = SYNC; batchSize = 512; @@ -649,6 +648,7 @@ public void testSync() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testAsync() throws Exception { preloadMode = ASYNC; batchSize = 256; @@ -656,54 +656,34 @@ public void testAsync() throws Exception { try { IgniteCache cache1 = startGrid(1).cache(DEFAULT_CACHE_NAME); - int keyCnt = 2000; + final int keyCnt = 2000; for (int i = 0; i < keyCnt; i++) cache1.put(i, "val" + i); - IgniteCache cache2 = startGrid(2).cache(DEFAULT_CACHE_NAME); + final IgniteCache cache2 = startGrid(2).cache(DEFAULT_CACHE_NAME); int size = cache2.localSize(CachePeekMode.ALL); info("Size of cache2: " + size); - assert waitCacheSize(cache2, keyCnt, getTestTimeout()) : - "Actual cache size: " + cache2.localSize(CachePeekMode.ALL); + boolean awaitSize = GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + return cache2.localSize(CachePeekMode.ALL) >= keyCnt; + } + }, getTestTimeout()); + + assertTrue("Actual cache size: " + cache2.localSize(CachePeekMode.ALL), awaitSize); } finally { stopAllGrids(); } } - /** - * @param cache Cache. - * @param expSize Lower bound of expected size. - * @param timeout Timeout. - * @return {@code true} if success. - * @throws InterruptedException If thread was interrupted. - */ - @SuppressWarnings({"BusyWait"}) - private boolean waitCacheSize(IgniteCache cache, int expSize, long timeout) - throws InterruptedException { - assert cache != null; - assert expSize > 0; - assert timeout >= 0; - - long end = System.currentTimeMillis() + timeout; - - while (cache.localSize(CachePeekMode.ALL) < expSize) { - Thread.sleep(50); - - if (end - System.currentTimeMillis() <= 0) - break; - } - - return cache.localSize(CachePeekMode.ALL) >= expSize; - } - /** * @throws Exception If test failed. */ + @Test public void testBatchSize1() throws Exception { preloadMode = SYNC; batchSize = 1; // 1 byte but one entry should be in batch anyway. @@ -728,6 +708,7 @@ public void testBatchSize1() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testBatchSize1000() throws Exception { preloadMode = SYNC; batchSize = 1000; // 1000 bytes. @@ -752,6 +733,7 @@ public void testBatchSize1000() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testBatchSize10000() throws Exception { preloadMode = SYNC; batchSize = 10000; // 10000 bytes. @@ -777,7 +759,11 @@ public void testBatchSize10000() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMultipleNodes() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10082"); + preloadMode = ASYNC; batchSize = 256; @@ -788,7 +774,7 @@ public void testMultipleNodes() throws Exception { info("Beginning data population..."); - int cnt = 2500; + final int cnt = 2500; Map map = null; @@ -816,7 +802,7 @@ assert grid(gridIdx).cache(DEFAULT_CACHE_NAME).localSize(CachePeekMode.ALL) == c info("Cache size is OK for grid index: " + gridIdx); } - IgniteCache lastCache = startGrid(gridCnt).cache(DEFAULT_CACHE_NAME); + final IgniteCache lastCache = startGrid(gridCnt).cache(DEFAULT_CACHE_NAME); // Let preloading start. Thread.sleep(1000); @@ -828,8 +814,15 @@ assert grid(gridIdx).cache(DEFAULT_CACHE_NAME).localSize(CachePeekMode.ALL) == c stopGrid(idx); - assert waitCacheSize(lastCache, cnt, 20 * 1000) : - "Actual cache size: " + lastCache.localSize(CachePeekMode.ALL); + awaitPartitionMapExchange(true, true, null); + + boolean awaitSize = GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + return lastCache.localSize(CachePeekMode.ALL) >= cnt; + } + }, 20_000); + + assertTrue("Actual cache size: " + lastCache.localSize(CachePeekMode.ALL), awaitSize); } finally { stopAllGrids(); @@ -839,6 +832,7 @@ assert waitCacheSize(lastCache, cnt, 20 * 1000) : /** * @throws Exception If test failed. */ + @Test public void testConcurrentStartSync() throws Exception { preloadMode = SYNC; batchSize = 10000; @@ -854,6 +848,7 @@ public void testConcurrentStartSync() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testConcurrentStartAsync() throws Exception { preloadMode = ASYNC; batchSize = 10000; @@ -866,65 +861,6 @@ public void testConcurrentStartAsync() throws Exception { } } - /** - * Test affinity. - */ - @SuppressWarnings({"PublicInnerClass"}) - private static class TestAffinityFunction implements AffinityFunction { - /** {@inheritDoc} */ - @Override public int partitions() { - return 2; - } - - /** {@inheritDoc} */ - @Override public int partition(Object key) { - if (key instanceof Number) - return ((Number)key).intValue() % 2; - - return key == null ? 0 : U.safeAbs(key.hashCode() % 2); - } - - /** {@inheritDoc} */ - @Override public List> assignPartitions(AffinityFunctionContext affCtx) { - List> res = new ArrayList<>(partitions()); - - for (int part = 0; part < partitions(); part++) - res.add(nodes(part, affCtx.currentTopologySnapshot())); - - return res; - } - - /** {@inheritDoc} */ - @SuppressWarnings({"RedundantTypeArguments"}) - public List nodes(int part, Collection nodes) { - Collection col = new HashSet<>(nodes); - - if (col.size() <= 1) - return new ArrayList<>(col); - - for (Iterator iter = col.iterator(); iter.hasNext(); ) { - ClusterNode node = iter.next(); - - boolean even = node.attribute("EVEN"); - - if ((even && part != 0) || (!even && part != 1)) - iter.remove(); - } - - return new ArrayList<>(col); - } - - /** {@inheritDoc} */ - @Override public void reset() { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void removeNode(UUID nodeId) { - // No-op. - } - } - /** * */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadStartStopEventsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadStartStopEventsSelfTest.java index 07c50d3786d5c..c43f8991c9d46 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadStartStopEventsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadStartStopEventsSelfTest.java @@ -23,10 +23,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.Event; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STARTED; @@ -35,10 +35,8 @@ /** * Tests that preload start/preload stop events are fired only once for replicated cache. */ +@RunWith(JUnit4.class) public class GridCacheReplicatedPreloadStartStopEventsSelfTest extends GridCommonAbstractTest { - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); @@ -50,8 +48,6 @@ public class GridCacheReplicatedPreloadStartStopEventsSelfTest extends GridCommo @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(REPLICATED); @@ -64,6 +60,7 @@ public class GridCacheReplicatedPreloadStartStopEventsSelfTest extends GridCommo /** * @throws Exception If failed. */ + @Test public void testStartStopEvents() throws Exception { Ignite ignite = startGrid(0); @@ -92,4 +89,4 @@ else if (e.type() == EVT_CACHE_REBALANCE_STOPPED) assertTrue("Unexpected start count: " + preloadStartCnt.get(), preloadStartCnt.get() <= 1); assertTrue("Unexpected stop count: " + preloadStopCnt.get(), preloadStopCnt.get() <= 1); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/DhtAndNearEvictionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/DhtAndNearEvictionTest.java index 84434696c9179..aaab659136b28 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/DhtAndNearEvictionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/DhtAndNearEvictionTest.java @@ -25,6 +25,7 @@ import javax.cache.integration.CacheWriterException; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.eviction.lru.LruEvictionPolicyFactory; import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.configuration.CacheConfiguration; @@ -35,13 +36,18 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checking that DHT and near cache evictions work correctly when both are set. * * This is a regression test for IGNITE-9315. */ +@RunWith(JUnit4.class) public class DhtAndNearEvictionTest extends GridCommonAbstractTest { /** */ public GridStringLogger strLog; @@ -59,6 +65,13 @@ public class DhtAndNearEvictionTest extends GridCommonAbstractTest { return cfg; } + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EVICTION); + + super.beforeTestsStarted(); + } + /** */ @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -84,7 +97,10 @@ public class DhtAndNearEvictionTest extends GridCommonAbstractTest { *
  • backups=1
  • * */ + @Test public void testConcurrentWritesAndReadsWithReadThrough() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + startGrid(0); startGrid(1); @@ -97,6 +113,7 @@ public void testConcurrentWritesAndReadsWithReadThrough() throws Exception { ) .setReadThrough(true) .setCacheStoreFactory(DummyCacheStore.factoryOf()) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setBackups(1); grid(0).createCache(ccfg); @@ -136,12 +153,14 @@ public void testConcurrentWritesAndReadsWithReadThrough() throws Exception { /** * Checking rebalancing which used to be affected by IGNITE-9315. */ + @Test public void testRebalancing() throws Exception { Ignite grid0 = startGrid(0); CacheConfiguration ccfg = new CacheConfiguration("mycache") .setOnheapCacheEnabled(true) .setEvictionPolicyFactory(new LruEvictionPolicyFactory<>(500)) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setNearConfiguration( new NearCacheConfiguration() .setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(100)) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionAbstractTest.java index a6c10baec92b3..3351508b22c4f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionAbstractTest.java @@ -38,12 +38,12 @@ import org.apache.ignite.internal.util.typedef.C2; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -61,11 +61,9 @@ /** * Base class for eviction tests. */ +@RunWith(JUnit4.class) public abstract class EvictionAbstractTest> extends GridCommonAbstractTest { - /** IP finder. */ - protected static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Put entry size. */ protected static final int PUT_ENTRY_SIZE = 10; @@ -126,12 +124,6 @@ public abstract class EvictionAbstractTest> c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - c.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED); c.setIncludeProperties(); @@ -147,6 +139,7 @@ public abstract class EvictionAbstractTest> /** * @throws Exception If failed. */ + @Test public void testMaxSizePolicy() throws Exception { plcMax = 3; plcMaxMemSize = 0; @@ -158,6 +151,7 @@ public void testMaxSizePolicy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxSizePolicyWithBatch() throws Exception { plcMax = 3; plcMaxMemSize = 0; @@ -169,6 +163,7 @@ public void testMaxSizePolicyWithBatch() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxMemSizePolicy() throws Exception { plcMax = 0; plcMaxMemSize = 3 * MockEntry.ENTRY_SIZE; @@ -182,6 +177,7 @@ public void testMaxMemSizePolicy() throws Exception { * * @throws Exception If failed. */ + @Test public void testMaxMemSizePolicyWithBatch() throws Exception { plcMax = 3; plcMaxMemSize = 10 * MockEntry.ENTRY_SIZE; @@ -193,6 +189,7 @@ public void testMaxMemSizePolicyWithBatch() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxSizeMemory() throws Exception { int max = 10; @@ -206,6 +203,7 @@ public void testMaxSizeMemory() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxSizeMemoryWithBatch() throws Exception { int max = 10; @@ -219,6 +217,7 @@ public void testMaxSizeMemoryWithBatch() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxMemSizeMemory() throws Exception { int max = 10; @@ -232,6 +231,7 @@ public void testMaxMemSizeMemory() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxSizeRandom() throws Exception { plcMax = 10; plcMaxMemSize = 0; @@ -243,6 +243,7 @@ public void testMaxSizeRandom() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxSizeRandomWithBatch() throws Exception { plcMax = 10; plcMaxMemSize = 0; @@ -254,6 +255,7 @@ public void testMaxSizeRandomWithBatch() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxMemSizeRandom() throws Exception { plcMax = 0; plcMaxMemSize = 10 * MockEntry.KEY_SIZE; @@ -265,6 +267,7 @@ public void testMaxMemSizeRandom() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxSizeAllowEmptyEntries() throws Exception { plcMax = 10; plcMaxMemSize = 0; @@ -276,6 +279,7 @@ public void testMaxSizeAllowEmptyEntries() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxSizeAllowEmptyEntriesWithBatch() throws Exception { plcMax = 10; plcMaxMemSize = 0; @@ -287,6 +291,7 @@ public void testMaxSizeAllowEmptyEntriesWithBatch() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxMemSizeAllowEmptyEntries() throws Exception { plcMax = 0; plcMaxMemSize = 10 * MockEntry.KEY_SIZE; @@ -298,6 +303,7 @@ public void testMaxMemSizeAllowEmptyEntries() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxSizePut() throws Exception { plcMax = 100; plcBatchSize = 1; @@ -309,6 +315,7 @@ public void testMaxSizePut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxSizePutWithBatch() throws Exception { plcMax = 100; plcBatchSize = 2; @@ -320,6 +327,7 @@ public void testMaxSizePutWithBatch() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxMemSizePut() throws Exception { int max = 100; @@ -653,6 +661,7 @@ protected static String string(Iterable c) { } /** @throws Exception If failed. */ + @Test public void testMaxSizePartitionedNearDisabled() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -665,6 +674,7 @@ public void testMaxSizePartitionedNearDisabled() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMaxSizePartitionedNearDisabledWithBatch() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -678,6 +688,7 @@ public void testMaxSizePartitionedNearDisabledWithBatch() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMaxMemSizePartitionedNearDisabled() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -691,6 +702,7 @@ public void testMaxMemSizePartitionedNearDisabled() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedNearEnabled() throws Exception { mode = PARTITIONED; nearEnabled = true; @@ -704,6 +716,7 @@ public void testPartitionedNearEnabled() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedNearDisabledMultiThreaded() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -715,6 +728,7 @@ public void testPartitionedNearDisabledMultiThreaded() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedNearEnabledMultiThreaded() throws Exception { mode = PARTITIONED; nearEnabled = true; @@ -1028,4 +1042,4 @@ public Collection queue() { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionPolicyFactoryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionPolicyFactoryAbstractTest.java index 0662d2d3f4940..847c2cd928b5b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionPolicyFactoryAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/EvictionPolicyFactoryAbstractTest.java @@ -41,12 +41,12 @@ import org.apache.ignite.internal.util.typedef.C2; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -64,11 +64,9 @@ /** * Base class for eviction tests. */ +@RunWith(JUnit4.class) public abstract class EvictionPolicyFactoryAbstractTest> extends GridCommonAbstractTest { - /** IP finder. */ - protected static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Put entry size. */ protected static final int PUT_ENTRY_SIZE = 10; @@ -140,12 +138,6 @@ public abstract class EvictionPolicyFactoryAbstractTest c) { } /** @throws Exception If failed. */ + @Test public void testMaxSizePartitionedNearDisabled() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -693,6 +702,7 @@ public void testMaxSizePartitionedNearDisabled() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMaxSizePartitionedNearDisabledWithBatch() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -706,6 +716,7 @@ public void testMaxSizePartitionedNearDisabledWithBatch() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMaxMemSizePartitionedNearDisabled() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -719,6 +730,7 @@ public void testMaxMemSizePartitionedNearDisabled() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedNearEnabled() throws Exception { mode = PARTITIONED; nearEnabled = true; @@ -732,6 +744,7 @@ public void testPartitionedNearEnabled() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedNearDisabledMultiThreaded() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -743,6 +756,7 @@ public void testPartitionedNearDisabledMultiThreaded() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedNearEnabledMultiThreaded() throws Exception { mode = PARTITIONED; nearEnabled = true; @@ -1068,4 +1082,4 @@ public Collection queue() { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionConsistencySelfTest.java index 5ff0be23a5cf5..3512cec410d51 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionConsistencySelfTest.java @@ -35,24 +35,23 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.cache.CacheEvictableEntryImpl; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; -import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** * */ +@RunWith(JUnit4.class) public class GridCacheConcurrentEvictionConsistencySelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Default iteration count. */ private static final int ITERATION_CNT = 50000; @@ -73,7 +72,7 @@ public class GridCacheConcurrentEvictionConsistencySelfTest extends GridCommonAb IgniteConfiguration c = super.getConfiguration(igniteInstanceName); c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC); - c.getTransactionConfiguration().setDefaultTxIsolation(READ_COMMITTED); + c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ); CacheConfiguration cc = defaultCacheConfiguration(); @@ -88,13 +87,14 @@ public class GridCacheConcurrentEvictionConsistencySelfTest extends GridCommonAb c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); + return c; + } - c.setDiscoverySpi(disco); + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); - return c; + super.beforeTestsStarted(); } /** {@inheritDoc} */ @@ -105,6 +105,7 @@ public class GridCacheConcurrentEvictionConsistencySelfTest extends GridCommonAb /** * @throws Exception If failed. */ + @Test public void testPolicyConsistencyFifoLocalTwoKeys() throws Exception { FifoEvictionPolicy plc = new FifoEvictionPolicy<>(); plc.setMaxSize(1); @@ -120,6 +121,7 @@ public void testPolicyConsistencyFifoLocalTwoKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPolicyConsistencyLruLocalTwoKeys() throws Exception { LruEvictionPolicy plc = new LruEvictionPolicy<>(); plc.setMaxSize(1); @@ -135,6 +137,7 @@ public void testPolicyConsistencyLruLocalTwoKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPolicyConsistencySortedLocalTwoKeys() throws Exception { SortedEvictionPolicy plc = new SortedEvictionPolicy<>(); plc.setMaxSize(1); @@ -150,6 +153,7 @@ public void testPolicyConsistencySortedLocalTwoKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPolicyConsistencyFifoLocalFewKeys() throws Exception { FifoEvictionPolicy plc = new FifoEvictionPolicy<>(); plc.setMaxSize(POLICY_QUEUE_SIZE); @@ -164,6 +168,7 @@ public void testPolicyConsistencyFifoLocalFewKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPolicyConsistencyLruLocalFewKeys() throws Exception { LruEvictionPolicy plc = new LruEvictionPolicy<>(); plc.setMaxSize(POLICY_QUEUE_SIZE); @@ -178,6 +183,7 @@ public void testPolicyConsistencyLruLocalFewKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPolicyConsistencySortedLocalFewKeys() throws Exception { SortedEvictionPolicy plc = new SortedEvictionPolicy<>(); plc.setMaxSize(POLICY_QUEUE_SIZE); @@ -192,6 +198,7 @@ public void testPolicyConsistencySortedLocalFewKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPolicyConsistencyFifoLocal() throws Exception { FifoEvictionPolicy plc = new FifoEvictionPolicy<>(); plc.setMaxSize(POLICY_QUEUE_SIZE); @@ -206,6 +213,7 @@ public void testPolicyConsistencyFifoLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPolicyConsistencyLruLocal() throws Exception { LruEvictionPolicy plc = new LruEvictionPolicy<>(); plc.setMaxSize(POLICY_QUEUE_SIZE); @@ -220,6 +228,7 @@ public void testPolicyConsistencyLruLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPolicyConsistencySortedLocal() throws Exception { SortedEvictionPolicy plc = new SortedEvictionPolicy<>(); plc.setMaxSize(POLICY_QUEUE_SIZE); @@ -251,14 +260,21 @@ private void checkPolicyConsistency() throws Exception { int j = rnd.nextInt(keyCnt); - try (Transaction tx = ignite.transactions().txStart()) { - // Put or remove? - if (rnd.nextBoolean()) - cache.put(j, j); - else - cache.remove(j); - - tx.commit(); + while (true) { + try (Transaction tx = ignite.transactions().txStart()) { + // Put or remove? + if (rnd.nextBoolean()) + cache.put(j, j); + else + cache.remove(j); + + tx.commit(); + + break; + } + catch (Exception e) { + MvccFeatureChecker.assertMvccWriteConflict(e); + } } if (i != 0 && i % 5000 == 0) @@ -344,4 +360,4 @@ else if (plc instanceof SortedEvictionPolicy) { return Collections.emptyList(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionsSelfTest.java index 45d98bfc89e27..64dda3aaabfa5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheConcurrentEvictionsSelfTest.java @@ -22,6 +22,7 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.cache.eviction.EvictionPolicy; import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy; import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; @@ -29,24 +30,25 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils.SF; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.GridTestUtils.SF; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; -import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** * */ +@RunWith(JUnit4.class) public class GridCacheConcurrentEvictionsSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Replicated cache. */ private CacheMode mode = REPLICATED; @@ -64,9 +66,9 @@ public class GridCacheConcurrentEvictionsSelfTest extends GridCommonAbstractTest IgniteConfiguration c = super.getConfiguration(igniteInstanceName); c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC); - c.getTransactionConfiguration().setDefaultTxIsolation(READ_COMMITTED); + c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ); - CacheConfiguration cc = defaultCacheConfiguration(); + CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(mode); @@ -79,12 +81,6 @@ public class GridCacheConcurrentEvictionsSelfTest extends GridCommonAbstractTest c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - return c; } @@ -95,9 +91,17 @@ public class GridCacheConcurrentEvictionsSelfTest extends GridCommonAbstractTest plc = null; } + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.beforeTestsStarted(); + } + /** * @throws Exception If failed. */ + @Test public void testConcurrentPutsFifoLocal() throws Exception { mode = LOCAL; @@ -105,8 +109,8 @@ public void testConcurrentPutsFifoLocal() throws Exception { plc.setMaxSize(1000); this.plc = plc; - warmUpPutsCnt = 100000; - iterCnt = 100000; + warmUpPutsCnt = SF.applyLB(100_000, 10_000); + iterCnt = SF.applyLB(100_000, 10_000); checkConcurrentPuts(); } @@ -114,6 +118,7 @@ public void testConcurrentPutsFifoLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentPutsLruLocal() throws Exception { mode = LOCAL; @@ -121,8 +126,8 @@ public void testConcurrentPutsLruLocal() throws Exception { plc.setMaxSize(1000); this.plc = plc; - warmUpPutsCnt = 100000; - iterCnt = 100000; + warmUpPutsCnt = SF.applyLB(100_000, 10_000); + iterCnt = SF.applyLB(100_000, 10_000); checkConcurrentPuts(); } @@ -130,6 +135,7 @@ public void testConcurrentPutsLruLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentPutsSortedLocal() throws Exception { mode = LOCAL; @@ -137,8 +143,8 @@ public void testConcurrentPutsSortedLocal() throws Exception { plc.setMaxSize(1000); this.plc = plc; - warmUpPutsCnt = 100000; - iterCnt = 100000; + warmUpPutsCnt = SF.applyLB(100_000, 10_000); + iterCnt = SF.applyLB(100_000, 10_000); checkConcurrentPuts(); } @@ -166,21 +172,21 @@ private void checkConcurrentPuts() throws Exception { final AtomicInteger idx = new AtomicInteger(); - int threadCnt = 30; + int threadCnt = SF.applyLB(30, 8); long start = System.currentTimeMillis(); IgniteInternalFuture fut = multithreadedAsync( new Callable() { - @Override public Object call() throws Exception { + @Override public Object call() { for (int i = 0; i < iterCnt; i++) { int j = idx.incrementAndGet(); cache.put(j, j); - if (i != 0 && i % 10000 == 0) + if (i != 0 && i % 1000 == 0) // info("Puts count: " + i); - info("Stats [putsCnt=" + i + ", size=" + cache.size() + ']'); + info("Stats [putsCnt=" + i + ", size=" + cache.size(CachePeekMode.ONHEAP) + ']'); } return null; @@ -191,11 +197,13 @@ private void checkConcurrentPuts() throws Exception { fut.get(); - info("Test results [threadCnt=" + threadCnt + ", iterCnt=" + iterCnt + ", cacheSize=" + cache.size() + + info("Test results [threadCnt=" + threadCnt + ", iterCnt=" + iterCnt + ", cacheSize=" + cache.size(CachePeekMode.ONHEAP) + ", duration=" + (System.currentTimeMillis() - start) + ']'); + + assertTrue(cache.size(CachePeekMode.ONHEAP) <= 1000); } finally { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java index f28e56b6fcda2..a7fb137afaeda 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java @@ -32,23 +32,22 @@ import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * Tests that cache handles {@code setAllowEmptyEntries} flag correctly. */ +@RunWith(JUnit4.class) public abstract class GridCacheEmptyEntriesAbstractSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private EvictionPolicy plc; @@ -96,12 +95,6 @@ public abstract class GridCacheEmptyEntriesAbstractSelfTest extends GridCommonAb c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - return c; } @@ -121,6 +114,7 @@ public abstract class GridCacheEmptyEntriesAbstractSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testFifo() throws Exception { FifoEvictionPolicy plc = new FifoEvictionPolicy(); plc.setMaxSize(50); @@ -172,6 +166,9 @@ private void checkPolicy0() throws Exception { for (TransactionIsolation isolation : TransactionIsolation.values()) { txIsolation = isolation; + if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(concurrency, isolation)) + continue; + Ignite g = startGrids(); IgniteCache cache = g.cache(DEFAULT_CACHE_NAME); @@ -307,4 +304,4 @@ private void checkEmpty(IgniteCache cache) throws IgniteInterrup } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesLocalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesLocalSelfTest.java index 018cc2e699dbc..e8f171ea6dfad 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesLocalSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesLocalSelfTest.java @@ -19,10 +19,15 @@ import org.apache.ignite.Ignite; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCacheEmptyEntriesLocalSelfTest extends GridCacheEmptyEntriesAbstractSelfTest { /** {@inheritDoc} */ @Override protected Ignite startGrids() throws Exception { @@ -35,7 +40,17 @@ public class GridCacheEmptyEntriesLocalSelfTest extends GridCacheEmptyEntriesAbs } /** {@inheritDoc} */ + @Test @Override public void testFifo() throws Exception { super.testFifo(); } -} \ No newline at end of file + + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.beforeTestsStarted(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesPartitionedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesPartitionedSelfTest.java index 5d9faebd465dc..88c9fbc9a60a4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesPartitionedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesPartitionedSelfTest.java @@ -19,10 +19,15 @@ import org.apache.ignite.Ignite; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test allow empty entries flag on partitioned cache. */ +@RunWith(JUnit4.class) public class GridCacheEmptyEntriesPartitionedSelfTest extends GridCacheEmptyEntriesAbstractSelfTest { /** {@inheritDoc} */ @Override protected Ignite startGrids() throws Exception { @@ -35,7 +40,15 @@ public class GridCacheEmptyEntriesPartitionedSelfTest extends GridCacheEmptyEntr } /** {@inheritDoc} */ + @Test @Override public void testFifo() throws Exception { super.testFifo(); } -} \ No newline at end of file + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.beforeTestsStarted(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictableEntryEqualsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictableEntryEqualsSelfTest.java index 98c8b776ba386..ec00f6ebc08b0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictableEntryEqualsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictableEntryEqualsSelfTest.java @@ -26,14 +26,19 @@ import org.apache.ignite.cache.eviction.EvictionPolicy; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for EvictableEntry.equals(). */ +@RunWith(JUnit4.class) public class GridCacheEvictableEntryEqualsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testEquals() throws Exception { try (Ignite ignite = startGrid()) { CacheConfiguration cfg = new CacheConfiguration<>("test"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionFilterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionFilterSelfTest.java index b432c2d584595..bb393a431c288 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionFilterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionFilterSelfTest.java @@ -32,10 +32,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -46,10 +47,8 @@ /** * Base class for eviction tests. */ +@RunWith(JUnit4.class) public class GridCacheEvictionFilterSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Replicated cache. */ private CacheMode mode = REPLICATED; @@ -94,23 +93,21 @@ public class GridCacheEvictionFilterSelfTest extends GridCommonAbstractTest { c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - return c; } /** @throws Exception If failed. */ + @Test public void testLocal() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + mode = LOCAL; checkEvictionFilter(); } /** @throws Exception If failed. */ + @Test public void testReplicated() throws Exception { mode = REPLICATED; @@ -118,7 +115,10 @@ public void testReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitioned() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + mode = PARTITIONED; nearEnabled = true; @@ -126,6 +126,7 @@ public void testPartitioned() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitionedNearDisabled() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -190,6 +191,7 @@ private void checkEvictionFilter() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitionedMixed() throws Exception { mode = PARTITIONED; nearEnabled = false; @@ -256,4 +258,4 @@ ConcurrentMap counts() { return cnts; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionLockUnlockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionLockUnlockSelfTest.java index 55b7b63691470..d9e1b9e1cb2b1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionLockUnlockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionLockUnlockSelfTest.java @@ -30,10 +30,11 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.events.Event; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -45,10 +46,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheEvictionLockUnlockSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Evict latch. */ private static CountDownLatch evictLatch; @@ -86,16 +85,20 @@ public class GridCacheEvictionLockUnlockSelfTest extends GridCommonAbstractTest c.setCacheConfiguration(cc); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); + return c; + } - discoSpi.setIpFinder(ipFinder); + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); - c.setDiscoverySpi(discoSpi); - return c; + super.beforeTestsStarted(); } /** @throws Exception If failed. */ + @Test public void testLocal() throws Exception { mode = LOCAL; gridCnt = 1; @@ -104,6 +107,7 @@ public void testLocal() throws Exception { } /** @throws Exception If failed. */ + @Test public void testReplicated() throws Exception { mode = REPLICATED; gridCnt = 3; @@ -112,6 +116,7 @@ public void testReplicated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPartitioned() throws Exception { mode = PARTITIONED; gridCnt = 3; @@ -182,4 +187,4 @@ private static class EvictionPolicy implements org.apache.ignite.cache.eviction. entry.evict(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionTouchSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionTouchSelfTest.java index a91c5b6527e0d..cea9078246f93 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionTouchSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEvictionTouchSelfTest.java @@ -37,11 +37,12 @@ import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheGenericTestStore; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -51,10 +52,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheEvictionTouchSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private EvictionPolicy plc; @@ -99,13 +98,14 @@ public class GridCacheEvictionTouchSelfTest extends GridCommonAbstractTest { c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); + return c; + } - c.setDiscoverySpi(disco); + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); - return c; + super.beforeTestsStarted(); } /** {@inheritDoc} */ @@ -118,6 +118,7 @@ public class GridCacheEvictionTouchSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPolicyConsistency() throws Exception { FifoEvictionPolicy plc = new FifoEvictionPolicy<>(); plc.setMaxSize(500); @@ -173,6 +174,7 @@ public void testPolicyConsistency() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvictSingle() throws Exception { FifoEvictionPolicy plc = new FifoEvictionPolicy<>(); plc.setMaxSize(500); @@ -203,6 +205,7 @@ public void testEvictSingle() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvictAll() throws Exception { FifoEvictionPolicy plc = new FifoEvictionPolicy<>(); plc.setMaxSize(500); @@ -238,6 +241,7 @@ public void testEvictAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReload() throws Exception { FifoEvictionPolicy plc = new FifoEvictionPolicy<>(); plc.setMaxSize(100); @@ -269,4 +273,4 @@ public void testReload() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruEvictionPolicyFactorySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruEvictionPolicyFactorySelfTest.java index d53cb6f36c923..17af3d9641420 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruEvictionPolicyFactorySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruEvictionPolicyFactorySelfTest.java @@ -22,10 +22,14 @@ import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; import org.apache.ignite.cache.eviction.lru.LruEvictionPolicyFactory; import org.apache.ignite.internal.processors.cache.eviction.EvictionPolicyFactoryAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * LRU Eviction policy tests. */ +@RunWith(JUnit4.class) public class LruEvictionPolicyFactorySelfTest extends EvictionPolicyFactoryAbstractTest> { /** {@inheritDoc} */ @Override protected Factory> createPolicyFactory() { @@ -45,6 +49,7 @@ public class LruEvictionPolicyFactorySelfTest extends EvictionPolicyFactoryAbstr /** * @throws Exception If failed. */ + @Test public void testMiddleAccess() throws Exception { policyFactory = createPolicyFactory(); @@ -349,4 +354,4 @@ public void testMiddleAccess() throws Exception { assertTrue(policy(i).queue().size() <= plcMax + plcBatchSize); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruEvictionPolicySelfTest.java index 3c5334911ed9a..af29970400087 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruEvictionPolicySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruEvictionPolicySelfTest.java @@ -21,15 +21,20 @@ import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; import org.apache.ignite.internal.processors.cache.CacheEvictableEntryImpl; import org.apache.ignite.internal.processors.cache.eviction.EvictionAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * LRU Eviction policy tests. */ +@RunWith(JUnit4.class) public class LruEvictionPolicySelfTest extends EvictionAbstractTest> { /** * @throws Exception If failed. */ + @Test public void testMiddleAccess() throws Exception { startGrid(); @@ -350,4 +355,4 @@ public void testMiddleAccess() throws Exception { } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearEvictionPolicySelfTest.java index 27295c69ca35e..7ed7b87a1c828 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearEvictionPolicySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearEvictionPolicySelfTest.java @@ -25,13 +25,15 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; @@ -39,10 +41,8 @@ /** * LRU near eviction tests (GG-8884). */ +@RunWith(JUnit4.class) public class LruNearEvictionPolicySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Maximum size for near eviction policy. */ private static final int EVICTION_MAX_SIZE = 10; @@ -74,18 +74,13 @@ public class LruNearEvictionPolicySelfTest extends GridCommonAbstractTest { c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - return c; } /** * @throws Exception If failed. */ + @Test public void testAtomicNearEvictionMaxSize() throws Exception { atomicityMode = ATOMIC; @@ -95,12 +90,24 @@ public void testAtomicNearEvictionMaxSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransactionalNearEvictionMaxSize() throws Exception { atomicityMode = TRANSACTIONAL; checkNearEvictionMaxSize(); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187,https://issues.apache.org/jira/browse/IGNITE-7956") + @Test + public void testMvccTransactionalNearEvictionMaxSize() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + + checkNearEvictionMaxSize(); + } + /** * @throws Exception If failed. */ @@ -139,4 +146,4 @@ private void checkNearEvictionMaxSize() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearOnlyNearEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearOnlyNearEvictionPolicySelfTest.java index a329e83f56252..12502cc182326 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearOnlyNearEvictionPolicySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/LruNearOnlyNearEvictionPolicySelfTest.java @@ -26,12 +26,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -40,10 +43,8 @@ /** * LRU near eviction tests for NEAR_ONLY distribution mode (GG-8884). */ +@RunWith(JUnit4.class) public class LruNearOnlyNearEvictionPolicySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Grid count. */ private static final int GRID_COUNT = 2; @@ -84,7 +85,7 @@ public class LruNearOnlyNearEvictionPolicySelfTest extends GridCommonAbstractTes c.setCacheConfiguration(cc); } - c.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder).setForceServerMode(true)); + ((TcpDiscoverySpi)c.getDiscoverySpi()).setForceServerMode(true); cnt++; @@ -94,6 +95,7 @@ public class LruNearOnlyNearEvictionPolicySelfTest extends GridCommonAbstractTes /** * @throws Exception If failed. */ + @Test public void testPartitionedAtomicNearEvictionMaxSize() throws Exception { atomicityMode = ATOMIC; cacheMode = PARTITIONED; @@ -104,6 +106,7 @@ public void testPartitionedAtomicNearEvictionMaxSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionedTransactionalNearEvictionMaxSize() throws Exception { atomicityMode = TRANSACTIONAL; cacheMode = PARTITIONED; @@ -114,6 +117,19 @@ public void testPartitionedTransactionalNearEvictionMaxSize() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187,https://issues.apache.org/jira/browse/IGNITE-7956") + @Test + public void testPartitionedMvccTransactionalNearEvictionMaxSize() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + cacheMode = PARTITIONED; + + checkNearEvictionMaxSize(); + } + + /** + * @throws Exception If failed. + */ + @Test public void testReplicatedAtomicNearEvictionMaxSize() throws Exception { atomicityMode = ATOMIC; cacheMode = REPLICATED; @@ -124,6 +140,7 @@ public void testReplicatedAtomicNearEvictionMaxSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedTransactionalNearEvictionMaxSize() throws Exception { atomicityMode = TRANSACTIONAL; cacheMode = REPLICATED; @@ -131,6 +148,18 @@ public void testReplicatedTransactionalNearEvictionMaxSize() throws Exception { checkNearEvictionMaxSize(); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187,https://issues.apache.org/jira/browse/IGNITE-7956") + @Test + public void testReplicatedMvccTransactionalNearEvictionMaxSize() throws Exception { + atomicityMode = TRANSACTIONAL_SNAPSHOT; + cacheMode = REPLICATED; + + checkNearEvictionMaxSize(); + } + /** * @throws Exception If failed. */ @@ -174,4 +203,4 @@ private void checkNearEvictionMaxSize() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionAbstractTest.java index cb0875fb9a063..88f714815347f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionAbstractTest.java @@ -26,9 +26,6 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; @@ -36,9 +33,6 @@ * */ public class PageEvictionAbstractTest extends GridCommonAbstractTest { - /** */ - protected static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Offheap size for memory policy. */ private static final int SIZE = 20 * 1024 * 1024; @@ -86,8 +80,6 @@ protected boolean nearEnabled() { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - DataStorageConfiguration dbCfg = new DataStorageConfiguration(); DataRegionConfiguration plc = new DataRegionConfiguration(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionDataStreamerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionDataStreamerTest.java index b5aab69f5016e..ed70d8587887e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionDataStreamerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionDataStreamerTest.java @@ -34,10 +34,10 @@ public class PageEvictionDataStreamerTest extends PageEvictionMultinodeAbstractT } /** {@inheritDoc} */ - @Override protected void createCacheAndTestEvcition(CacheConfiguration cfg) throws Exception { - IgniteCache cache = clientGrid.getOrCreateCache(cfg); + @Override protected void createCacheAndTestEviction(CacheConfiguration cfg) throws Exception { + IgniteCache cache = clientGrid().getOrCreateCache(cfg); - try (IgniteDataStreamer ldr = clientGrid.dataStreamer(cfg.getName())) { + try (IgniteDataStreamer ldr = clientGrid().dataStreamer(cfg.getName())) { ldr.allowOverwrite(true); for (int i = 1; i <= ENTRIES; i++) { @@ -60,6 +60,6 @@ public class PageEvictionDataStreamerTest extends PageEvictionMultinodeAbstractT // Eviction started, no OutOfMemory occurred, success. assertTrue(resultingSize < ENTRIES); - clientGrid.destroyCache(cfg.getName()); + clientGrid().destroyCache(cfg.getName()); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMetricTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMetricTest.java index a451c36bf8d7f..9af960fbc4493 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMetricTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMetricTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class PageEvictionMetricTest extends PageEvictionAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -43,7 +47,25 @@ public class PageEvictionMetricTest extends PageEvictionAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPageEvictionMetric() throws Exception { + checkPageEvictionMetric(CacheAtomicityMode.ATOMIC); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPageEvictionMetricMvcc() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10448"); + + checkPageEvictionMetric(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + private void checkPageEvictionMetric(CacheAtomicityMode atomicityMode) throws Exception { IgniteEx ignite = startGrid(0); DataRegionMetricsImpl metrics = @@ -52,7 +74,7 @@ public void testPageEvictionMetric() throws Exception { metrics.enableMetrics(); CacheConfiguration cfg = cacheConfig("evict-metric", null, - CacheMode.PARTITIONED, CacheAtomicityMode.ATOMIC, CacheWriteSynchronizationMode.PRIMARY_SYNC); + CacheMode.PARTITIONED, atomicityMode, CacheWriteSynchronizationMode.PRIMARY_SYNC); IgniteCache cache = ignite.getOrCreateCache(cfg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeAbstractTest.java index 777c2d7e999cc..d1e731770e97e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeAbstractTest.java @@ -25,10 +25,15 @@ import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class PageEvictionMultinodeAbstractTest extends PageEvictionAbstractTest { /** Cache modes. */ private static final CacheMode[] CACHE_MODES = {CacheMode.PARTITIONED, CacheMode.REPLICATED}; @@ -41,16 +46,19 @@ public abstract class PageEvictionMultinodeAbstractTest extends PageEvictionAbst private static final CacheWriteSynchronizationMode[] WRITE_MODES = {CacheWriteSynchronizationMode.PRIMARY_SYNC, CacheWriteSynchronizationMode.FULL_SYNC, CacheWriteSynchronizationMode.FULL_ASYNC}; - /** Client grid. */ - Ignite clientGrid; - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(4, false); - clientGrid = startGrid("client"); + startGrid("client"); } + /** + * @return Client grid. + */ + Ignite clientGrid() { + return grid("client"); + } /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -70,6 +78,7 @@ public abstract class PageEvictionMultinodeAbstractTest extends PageEvictionAbst /** * @throws Exception If failed. */ + @Test public void testPageEviction() throws Exception { for (int i = 0; i < CACHE_MODES.length; i++) { for (int j = 0; j < ATOMICITY_MODES.length; j++) { @@ -78,19 +87,34 @@ public void testPageEviction() throws Exception { CacheConfiguration cfg = cacheConfig( "evict" + i + j + k, null, CACHE_MODES[i], ATOMICITY_MODES[j], WRITE_MODES[k]); - createCacheAndTestEvcition(cfg); + createCacheAndTestEviction(cfg); } } } } } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10448") + @Test + public void testPageEvictionMvcc() throws Exception { + for (int i = 0; i < CACHE_MODES.length; i++) { + CacheConfiguration cfg = cacheConfig( + "evict" + i, null, CACHE_MODES[i], CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, + CacheWriteSynchronizationMode.FULL_SYNC); + + createCacheAndTestEviction(cfg); + } + } + /** * @param cfg Config. * @throws Exception If failed. */ - protected void createCacheAndTestEvcition(CacheConfiguration cfg) throws Exception { - IgniteCache cache = clientGrid.getOrCreateCache(cfg); + protected void createCacheAndTestEviction(CacheConfiguration cfg) throws Exception { + IgniteCache cache = clientGrid().getOrCreateCache(cfg); for (int i = 1; i <= ENTRIES; i++) { ThreadLocalRandom r = ThreadLocalRandom.current(); @@ -118,6 +142,6 @@ else if (r.nextInt() % 13 == 0) // Eviction started, no OutOfMemory occurred, success. assertTrue(resultingSize < ENTRIES * 10 / 11); - clientGrid.destroyCache(cfg.getName()); + clientGrid().destroyCache(cfg.getName()); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeMixedRegionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeMixedRegionsTest.java index 9a96a642a07f3..bb36d2a84e52d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeMixedRegionsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeMixedRegionsTest.java @@ -48,7 +48,7 @@ public class PageEvictionMultinodeMixedRegionsTest extends PageEvictionMultinode super.beforeTestsStarted(); - clientGrid.active(true); + clientGrid().cluster().active(true); } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionPagesRecyclingAndReusingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionPagesRecyclingAndReusingTest.java index 9c777fbe36c80..6d8147136842b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionPagesRecyclingAndReusingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionPagesRecyclingAndReusingTest.java @@ -28,10 +28,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseList; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class PageEvictionPagesRecyclingAndReusingTest extends PageEvictionAbstractTest { /** Test timeout. */ private static final long TEST_TIMEOUT = 10 * 60 * 1000; @@ -57,6 +62,7 @@ public class PageEvictionPagesRecyclingAndReusingTest extends PageEvictionAbstra /** * @throws Exception If failed. */ + @Test public void testPagesRecyclingAndReusingAtomicReplicated() throws Exception { testPagesRecyclingAndReusing(CacheAtomicityMode.ATOMIC, CacheMode.REPLICATED); } @@ -64,6 +70,7 @@ public void testPagesRecyclingAndReusingAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPagesRecyclingAndReusingAtomicLocal() throws Exception { testPagesRecyclingAndReusing(CacheAtomicityMode.ATOMIC, CacheMode.LOCAL); } @@ -71,6 +78,7 @@ public void testPagesRecyclingAndReusingAtomicLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPagesRecyclingAndReusingTxReplicated() throws Exception { testPagesRecyclingAndReusing(CacheAtomicityMode.TRANSACTIONAL, CacheMode.REPLICATED); } @@ -78,10 +86,39 @@ public void testPagesRecyclingAndReusingTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPagesRecyclingAndReusingTxLocal() throws Exception { testPagesRecyclingAndReusing(CacheAtomicityMode.TRANSACTIONAL, CacheMode.LOCAL); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10448") + @Test + public void testPagesRecyclingAndReusingMvccTxPartitioned() throws Exception { + testPagesRecyclingAndReusing(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheMode.PARTITIONED); + } + + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10448") + @Test + public void testPagesRecyclingAndReusingMvccTxReplicated() throws Exception { + testPagesRecyclingAndReusing(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheMode.REPLICATED); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7956,https://issues.apache.org/jira/browse/IGNITE-9530") + @Test + public void testPagesRecyclingAndReusingMvccTxLocal() throws Exception { + testPagesRecyclingAndReusing(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheMode.LOCAL); + } + /** * @param atomicityMode Atomicity mode. * @param cacheMode Cache mode. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionReadThroughTest.java index ff713616c742f..e63e3143a825e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionReadThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionReadThroughTest.java @@ -29,10 +29,15 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataPageEvictionMode; import org.apache.ignite.configuration.IgniteConfiguration; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class PageEvictionReadThroughTest extends PageEvictionAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -42,6 +47,7 @@ public class PageEvictionReadThroughTest extends PageEvictionAbstractTest { /** * @throws Exception If failed. */ + @Test public void testEvictionWithReadThroughAtomicReplicated() throws Exception { testEvictionWithReadThrough(CacheAtomicityMode.ATOMIC, CacheMode.REPLICATED); } @@ -49,6 +55,7 @@ public void testEvictionWithReadThroughAtomicReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvictionWithReadThroughAtomicLocal() throws Exception { testEvictionWithReadThrough(CacheAtomicityMode.ATOMIC, CacheMode.LOCAL); } @@ -56,6 +63,7 @@ public void testEvictionWithReadThroughAtomicLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvictionWithReadThroughTxReplicated() throws Exception { testEvictionWithReadThrough(CacheAtomicityMode.TRANSACTIONAL, CacheMode.REPLICATED); } @@ -63,10 +71,38 @@ public void testEvictionWithReadThroughTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvictionWithReadThroughTxLocal() throws Exception { testEvictionWithReadThrough(CacheAtomicityMode.TRANSACTIONAL, CacheMode.LOCAL); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582,https://issues.apache.org/jira/browse/IGNITE-7956") + @Test + public void testEvictionWithReadThroughMvccTxReplicated() throws Exception { + testEvictionWithReadThrough(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheMode.REPLICATED); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582,https://issues.apache.org/jira/browse/IGNITE-7956") + @Test + public void testEvictionWithReadThroughMvccTxPartitioned() throws Exception { + testEvictionWithReadThrough(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheMode.PARTITIONED); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7956,https://issues.apache.org/jira/browse/IGNITE-8582,https://issues.apache.org/jira/browse/IGNITE-9530") + @Test + public void testEvictionWithReadThroughMvccTxLocal() throws Exception { + testEvictionWithReadThrough(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheMode.LOCAL); + } + /** * @param atomicityMode Atomicity mode. * @param cacheMode Cache mode. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionTouchOrderTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionTouchOrderTest.java index 43356490fe21e..16c4e8a5a6146 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionTouchOrderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionTouchOrderTest.java @@ -23,10 +23,15 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataPageEvictionMode; import org.apache.ignite.configuration.IgniteConfiguration; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class PageEvictionTouchOrderTest extends PageEvictionAbstractTest { /** Test entries number. */ private static final int SAFE_ENTRIES = 1000; @@ -45,6 +50,7 @@ public class PageEvictionTouchOrderTest extends PageEvictionAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTouchOrderWithFairFifoEvictionAtomicReplicated() throws Exception { testTouchOrderWithFairFifoEviction(CacheAtomicityMode.ATOMIC, CacheMode.REPLICATED); } @@ -52,6 +58,7 @@ public void testTouchOrderWithFairFifoEvictionAtomicReplicated() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testTouchOrderWithFairFifoEvictionAtomicLocal() throws Exception { testTouchOrderWithFairFifoEviction(CacheAtomicityMode.ATOMIC, CacheMode.LOCAL); } @@ -59,6 +66,7 @@ public void testTouchOrderWithFairFifoEvictionAtomicLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTouchOrderWithFairFifoEvictionTxReplicated() throws Exception { testTouchOrderWithFairFifoEviction(CacheAtomicityMode.TRANSACTIONAL, CacheMode.REPLICATED); } @@ -66,10 +74,41 @@ public void testTouchOrderWithFairFifoEvictionTxReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTouchOrderWithFairFifoEvictionTxLocal() throws Exception { testTouchOrderWithFairFifoEviction(CacheAtomicityMode.TRANSACTIONAL, CacheMode.LOCAL); } + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10448,https://issues.apache.org/jira/browse/IGNITE-7956") + @Test + public void testTouchOrderWithFairFifoEvictionMvccTxReplicated() throws Exception { + testTouchOrderWithFairFifoEviction(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheMode.REPLICATED); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10448,https://issues.apache.org/jira/browse/IGNITE-7956") + @Test + public void testTouchOrderWithFairFifoEvictionMvccTxPartitioned() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10448"); + fail("https://issues.apache.org/jira/browse/IGNITE-7956"); + + testTouchOrderWithFairFifoEviction(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheMode.PARTITIONED); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7956,https://issues.apache.org/jira/browse/IGNITE-9530") + @Test + public void testTouchOrderWithFairFifoEvictionMvccTxLocal() throws Exception { + testTouchOrderWithFairFifoEviction(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, CacheMode.LOCAL); + } + /** * @param atomicityMode Atomicity mode. * @param cacheMode Cache mode. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionWithRebalanceAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionWithRebalanceAbstractTest.java index 3ad104b031160..3d3955b976a89 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionWithRebalanceAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionWithRebalanceAbstractTest.java @@ -23,19 +23,41 @@ import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class PageEvictionWithRebalanceAbstractTest extends PageEvictionAbstractTest { /** * @throws Exception If failed. */ + @Test public void testEvictionWithRebalance() throws Exception { + checkEvictionWithRebalance(CacheAtomicityMode.ATOMIC); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10448") + @Test + public void testEvictionWithRebalanceMvcc() throws Exception { + checkEvictionWithRebalance(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT); + } + + /** + * @throws Exception If failed. + */ + public void checkEvictionWithRebalance(CacheAtomicityMode atomicityMode) throws Exception { startGridsMultiThreaded(4); CacheConfiguration cfg = cacheConfig("evict-rebalance", null, CacheMode.PARTITIONED, - CacheAtomicityMode.ATOMIC, CacheWriteSynchronizationMode.PRIMARY_SYNC); + atomicityMode, CacheWriteSynchronizationMode.PRIMARY_SYNC); IgniteCache cache = ignite(0).getOrCreateCache(cfg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/sorted/SortedEvictionPolicyPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/sorted/SortedEvictionPolicyPerformanceTest.java index 39b01ed4cc089..554bbbeffe63b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/sorted/SortedEvictionPolicyPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/sorted/SortedEvictionPolicyPerformanceTest.java @@ -30,10 +30,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * {@link SortedEvictionPolicy} performance test. */ +@RunWith(JUnit4.class) public class SortedEvictionPolicyPerformanceTest extends GridCommonAbstractTest { /** Threads. */ private static final int THREADS = 8; @@ -87,6 +91,7 @@ public class SortedEvictionPolicyPerformanceTest extends GridCommonAbstractTest /** * Tests throughput. */ + @Test public void testThroughput() throws Exception { final LongAdder cnt = new LongAdder(); final AtomicBoolean finished = new AtomicBoolean(); @@ -128,4 +133,4 @@ else if (p >= pPut && p < pGet) } }, THREADS); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheClientNearCacheExpiryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheClientNearCacheExpiryTest.java index 3417ba8513a34..4ec23fe6b8f8e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheClientNearCacheExpiryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheClientNearCacheExpiryTest.java @@ -33,6 +33,9 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -40,6 +43,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheClientNearCacheExpiryTest extends IgniteCacheAbstractTest { /** */ private static final int NODES = 3; @@ -80,6 +84,7 @@ public class IgniteCacheClientNearCacheExpiryTest extends IgniteCacheAbstractTes /** * @throws Exception If failed. */ + @Test public void testExpirationOnClient() throws Exception { Ignite ignite = grid(NODES - 1); @@ -123,4 +128,4 @@ public void testExpirationOnClient() throws Exception { for (int i = KEYS_COUNT ; i < KEYS_COUNT * 2; i++) assertNull(cache.localPeek(i)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java index c04d9d8d9663a..9baba8e17de35 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java @@ -58,6 +58,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -70,6 +73,7 @@ /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbstractTest { /** */ private static final long TTL_FOR_EXPIRE = 500L; @@ -118,6 +122,7 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs /** * @throws Exception if failed. */ + @Test public void testCreateUpdate0() throws Exception { startGrids(1); @@ -149,6 +154,7 @@ public void testCreateUpdate0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testZeroOnCreate() throws Exception { factory = CreatedExpiryPolicy.factoryOf(Duration.ZERO); @@ -176,6 +182,7 @@ private void zeroOnCreate(Integer key) throws Exception { /** * @throws Exception If failed. */ + @Test public void testZeroOnUpdate() throws Exception { factory = new FactoryBuilder.SingletonFactory<>(new TestPolicy(null, 0L, null)); @@ -207,6 +214,7 @@ private void zeroOnUpdate(Integer key) throws Exception { /** * @throws Exception If failed. */ + @Test public void testZeroOnAccess() throws Exception { factory = new FactoryBuilder.SingletonFactory<>(new TestPolicy(null, null, 0L)); @@ -252,6 +260,7 @@ public void testZeroOnAccess() throws Exception { /** * @throws Exception If failed. */ + @Test public void testZeroOnAccessEagerTtlDisabled() throws Exception { disableEagerTtl = true; @@ -277,6 +286,7 @@ private void zeroOnAccess(Integer key) throws Exception { /** * @throws Exception If failed. */ + @Test public void testEternal() throws Exception { factory = EternalExpiryPolicy.factoryOf(); @@ -298,6 +308,7 @@ public void testEternal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNullFactory() throws Exception { factory = null; // Should work as eternal. @@ -349,6 +360,7 @@ private void eternal(Integer key) throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccess() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-305"); @@ -595,6 +607,7 @@ private void accessGetAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateUpdate() throws Exception { factory = new FactoryBuilder.SingletonFactory<>(new TestPolicy(60_000L, 61_000L, null)); @@ -835,6 +848,7 @@ private void createUpdate(Integer key, @Nullable TransactionConcurrency txConcur /** * @throws Exception If failed. */ + @Test public void testNearCreateUpdate() throws Exception { if (cacheMode() != PARTITIONED) return; @@ -958,6 +972,7 @@ private void nearPutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearAccess() throws Exception { if (cacheMode() != PARTITIONED) return; @@ -1005,6 +1020,7 @@ public void testNearAccess() throws Exception { * * @throws Exception If failed. */ + @Test public void testNearExpiresOnClient() throws Exception { if (cacheMode() != PARTITIONED) return; @@ -1042,6 +1058,7 @@ public void testNearExpiresOnClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNearExpiresWithCacheStore() throws Exception { if(cacheMode() != PARTITIONED) return; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java index 61d9b4c296de6..e922537f0ca6e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java @@ -17,51 +17,54 @@ package org.apache.ignite.internal.processors.cache.expiry; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.cache.store.IgniteCacheExpiryStoreLoadSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheTtlManagerNotificationTest; import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerExpiredEventsTest; import org.apache.ignite.internal.processors.cache.IgniteCacheExpireAndUpdateConsistencyTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgniteCacheExpiryPolicyTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheExpiryPolicyTestSuite { /** * @return Cache Expiry Policy test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache Expiry Policy Test Suite"); - suite.addTestSuite(IgniteCacheLargeValueExpireTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLargeValueExpireTest.class)); - suite.addTestSuite(IgniteCacheAtomicLocalExpiryPolicyTest.class); - //suite.addTestSuite(IgniteCacheAtomicLocalOnheapExpiryPolicyTest.class); - suite.addTestSuite(IgniteCacheAtomicExpiryPolicyTest.class); - //suite.addTestSuite(IgniteCacheAtomicOnheapExpiryPolicyTest.class); - suite.addTestSuite(IgniteCacheAtomicWithStoreExpiryPolicyTest.class); - suite.addTestSuite(IgniteCacheAtomicReplicatedExpiryPolicyTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicLocalExpiryPolicyTest.class)); + //suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicLocalOnheapExpiryPolicyTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicExpiryPolicyTest.class)); + //suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicOnheapExpiryPolicyTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicWithStoreExpiryPolicyTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicReplicatedExpiryPolicyTest.class)); - suite.addTestSuite(IgniteCacheTxLocalExpiryPolicyTest.class); - suite.addTestSuite(IgniteCacheTxExpiryPolicyTest.class); - suite.addTestSuite(IgniteCacheTxWithStoreExpiryPolicyTest.class); - suite.addTestSuite(IgniteCacheTxReplicatedExpiryPolicyTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheTxLocalExpiryPolicyTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheTxExpiryPolicyTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheTxWithStoreExpiryPolicyTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheTxReplicatedExpiryPolicyTest.class)); - suite.addTestSuite(IgniteCacheAtomicExpiryPolicyWithStoreTest.class); - suite.addTestSuite(IgniteCacheTxExpiryPolicyWithStoreTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicExpiryPolicyWithStoreTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheTxExpiryPolicyWithStoreTest.class)); - suite.addTestSuite(IgniteCacheExpiryStoreLoadSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheExpiryStoreLoadSelfTest.class)); - suite.addTestSuite(IgniteCacheClientNearCacheExpiryTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheClientNearCacheExpiryTest.class)); - suite.addTestSuite(IgniteCacheEntryListenerExpiredEventsTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheEntryListenerExpiredEventsTest.class)); - suite.addTestSuite(IgniteCacheExpireAndUpdateConsistencyTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheExpireAndUpdateConsistencyTest.class)); // Eager ttl expiration tests. - suite.addTestSuite(GridCacheTtlManagerNotificationTest.class); - suite.addTestSuite(IgniteCacheOnlyOneTtlCleanupThreadExistsTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheTtlManagerNotificationTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheOnlyOneTtlCleanupThreadExistsTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java index 747cb43536739..6a74b0fd44af2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java @@ -45,10 +45,14 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheExpiryPolicyWithStoreAbstractTest extends IgniteCacheAbstractTest { /** {@inheritDoc} */ @Override protected NearCacheConfiguration nearConfiguration() { @@ -72,6 +76,7 @@ public abstract class IgniteCacheExpiryPolicyWithStoreAbstractTest extends Ignit /** * @throws Exception If failed. */ + @Test public void testLoadAll() throws Exception { IgniteCache cache = jcache(0); @@ -124,6 +129,7 @@ public void testLoadAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCache() throws Exception { IgniteCache cache = jcache(0); @@ -150,6 +156,7 @@ public void testLoadCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadThrough() throws Exception { IgniteCache cache = jcache(0); @@ -182,6 +189,7 @@ public void testReadThrough() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetReadThrough() throws Exception { getReadThrough(false, null, null); getReadThrough(true, null, null); @@ -354,4 +362,4 @@ private static class TestExpiryPolicyFactory implements Factory { }; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheLargeValueExpireTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheLargeValueExpireTest.java index 7e0b1d75c5ff9..9719af96f3133 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheLargeValueExpireTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheLargeValueExpireTest.java @@ -30,18 +30,16 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheLargeValueExpireTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int PAGE_SIZE = 1024; @@ -49,8 +47,6 @@ public class IgniteCacheLargeValueExpireTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - DataStorageConfiguration dbCfg = new DataStorageConfiguration(); dbCfg.setPageSize(1024); @@ -62,6 +58,7 @@ public class IgniteCacheLargeValueExpireTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testExpire() throws Exception { try (Ignite ignite = startGrid(0)) { checkExpire(ignite, true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheOnlyOneTtlCleanupThreadExistsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheOnlyOneTtlCleanupThreadExistsTest.java index f47de7dd79664..0c2ef8aee458c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheOnlyOneTtlCleanupThreadExistsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheOnlyOneTtlCleanupThreadExistsTest.java @@ -21,11 +21,15 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks that one and only one Ttl cleanup worker thread must exists, and only * if at least one cache with set 'eagerTtl' flag exists. */ +@RunWith(JUnit4.class) public class IgniteCacheOnlyOneTtlCleanupThreadExistsTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME1 = "cache-1"; @@ -36,6 +40,7 @@ public class IgniteCacheOnlyOneTtlCleanupThreadExistsTest extends GridCommonAbst /** * @throws Exception If failed. */ + @Test public void testOnlyOneTtlCleanupThreadExists() throws Exception { try (final Ignite g = startGrid(0)) { checkCleanupThreadExists(false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxExpiryPolicyWithStoreTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxExpiryPolicyWithStoreTest.java index f5888f88ac696..f795ec92365b6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxExpiryPolicyWithStoreTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxExpiryPolicyWithStoreTest.java @@ -21,6 +21,9 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -28,6 +31,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheTxExpiryPolicyWithStoreTest extends IgniteCacheExpiryPolicyWithStoreAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -45,6 +49,7 @@ public class IgniteCacheTxExpiryPolicyWithStoreTest extends IgniteCacheExpiryPol } /** {@inheritDoc} */ + @Test @Override public void testGetReadThrough() throws Exception { super.testGetReadThrough(); @@ -62,4 +67,4 @@ public class IgniteCacheTxExpiryPolicyWithStoreTest extends IgniteCacheExpiryPol getReadThrough(false, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE); getReadThrough(true, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoadAllAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoadAllAbstractTest.java index 6b4f9761311ca..b8d6e304289a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoadAllAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoadAllAbstractTest.java @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import javax.cache.Cache; import javax.cache.configuration.Factory; import javax.cache.integration.CacheLoader; @@ -34,11 +35,15 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; -import java.util.concurrent.ConcurrentHashMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * Test for {@link Cache#loadAll(Set, boolean, CompletionListener)}. */ +@RunWith(JUnit4.class) public abstract class IgniteCacheLoadAllAbstractTest extends IgniteCacheAbstractTest { /** */ private volatile boolean writeThrough = true; @@ -46,6 +51,13 @@ public abstract class IgniteCacheLoadAllAbstractTest extends IgniteCacheAbstract /** */ private static ConcurrentHashMap storeMap; + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { @@ -77,6 +89,7 @@ public abstract class IgniteCacheLoadAllAbstractTest extends IgniteCacheAbstract /** * @throws Exception If failed. */ + @Test public void testLoadAll() throws Exception { IgniteCache cache0 = jcache(0); @@ -259,4 +272,4 @@ private static class CacheWriterFactory implements Factory { }; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java index 5cdac5bbc97d5..c36844ad1b9f6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java @@ -38,10 +38,14 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; import org.apache.ignite.lifecycle.LifecycleAware; import org.apache.ignite.resources.IgniteInstanceResource; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheLoaderWriterAbstractTest extends IgniteCacheAbstractTest { /** */ private static AtomicInteger ldrCallCnt = new AtomicInteger(); @@ -81,6 +85,7 @@ public abstract class IgniteCacheLoaderWriterAbstractTest extends IgniteCacheAbs /** * @throws Exception If failed. */ + @Test public void testLoaderWriter() throws Exception { IgniteCache cache = jcache(0); @@ -162,6 +167,7 @@ public void testLoaderWriter() throws Exception { /** * */ + @Test public void testLoaderException() { IgniteCache cache = jcache(0); @@ -180,6 +186,7 @@ public void testLoaderException() { /** * */ + @Test public void testWriterException() { IgniteCache cache = jcache(0); @@ -198,6 +205,7 @@ public void testWriterException() { /** * @throws Exception If failed. */ + @Test public void testLoaderWriterBulk() throws Exception { Map vals = new HashMap<>(); @@ -432,4 +440,4 @@ class TestWriter implements CacheWriter, LifecycleAware { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java index 4eb6269833aa1..835d05eff76fb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java @@ -31,6 +31,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -38,6 +41,7 @@ /** * Test for configuration property {@link CacheConfiguration#isLoadPreviousValue()}. */ +@RunWith(JUnit4.class) public abstract class IgniteCacheNoLoadPreviousValueAbstractTest extends IgniteCacheAbstractTest { /** */ private Integer lastKey = 0; @@ -72,6 +76,7 @@ public abstract class IgniteCacheNoLoadPreviousValueAbstractTest extends IgniteC /** * @throws Exception If failed. */ + @Test public void testNoLoadPreviousValue() throws Exception { IgniteCache cache = jcache(0); @@ -215,4 +220,4 @@ protected Collection keys() throws Exception { return keys; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java index 37f6fce4a299c..49014a956aafd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java @@ -37,6 +37,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -44,6 +47,7 @@ /** * Test for configuration property {@link CacheConfiguration#isReadThrough}. */ +@RunWith(JUnit4.class) public abstract class IgniteCacheNoReadThroughAbstractTest extends IgniteCacheAbstractTest { /** */ private Integer lastKey = 0; @@ -86,6 +90,7 @@ public abstract class IgniteCacheNoReadThroughAbstractTest extends IgniteCacheAb /** * @throws Exception If failed. */ + @Test public void testNoReadThrough() throws Exception { IgniteCache cache = jcache(0); @@ -340,4 +345,4 @@ private static class NoReadThroughStoreFactory implements Factory { }; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java index 5ab86ec92e694..e7664ddb3dc30 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java @@ -33,6 +33,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -40,6 +43,7 @@ /** * Test for configuration property {@link CacheConfiguration#isWriteThrough}. */ +@RunWith(JUnit4.class) public abstract class IgniteCacheNoWriteThroughAbstractTest extends IgniteCacheAbstractTest { /** */ private Integer lastKey = 0; @@ -75,6 +79,7 @@ public abstract class IgniteCacheNoWriteThroughAbstractTest extends IgniteCacheA * @throws Exception If failed. */ @SuppressWarnings("UnnecessaryLocalVariable") + @Test public void testNoWriteThrough() throws Exception { IgniteCache cache = jcache(0); @@ -349,4 +354,4 @@ protected Collection keys() throws Exception { return keys; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreNodeRestartAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreNodeRestartAbstractTest.java index 9c455b6cccf43..25c20da4afb08 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreNodeRestartAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreNodeRestartAbstractTest.java @@ -22,10 +22,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheStoreNodeRestartAbstractTest extends IgniteCacheAbstractTest { /** */ protected static final String CACHE_NAME1 = "cache1"; @@ -73,6 +77,7 @@ public abstract class IgniteCacheStoreNodeRestartAbstractTest extends IgniteCach /** * @throws Exception If failed. */ + @Test public void testMarshaller() throws Exception { grid(0).cache(CACHE_NAME1).put("key1", new UserObject("key1")); @@ -113,4 +118,4 @@ public String getField() { return field; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreSessionAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreSessionAbstractTest.java index 40e36c2dbedbb..0a6d9361eed1b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreSessionAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreSessionAbstractTest.java @@ -43,12 +43,16 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheStoreSessionAbstractTest extends IgniteCacheAbstractTest { /** */ protected static volatile List expData; @@ -113,6 +117,7 @@ protected List testKeys(IgniteCache cache, int cnt) throws Exception { /** * @throws Exception If failed. */ + @Test public void testStoreSession() throws Exception { assertEquals(DEFAULT_CACHE_NAME, jcache(0).getName()); @@ -365,4 +370,4 @@ private void checkSession(String mtd) { assertEquals(exp.expCacheName, ses.cacheName()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreSessionWriteBehindAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreSessionWriteBehindAbstractTest.java index 832676d16931a..b07cea6a6ae8f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreSessionWriteBehindAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheStoreSessionWriteBehindAbstractTest.java @@ -37,10 +37,14 @@ import org.apache.ignite.resources.CacheStoreSessionResource; import org.apache.ignite.resources.IgniteInstanceResource; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public abstract class IgniteCacheStoreSessionWriteBehindAbstractTest extends IgniteCacheAbstractTest { /** */ private static final String CACHE_NAME1 = "cache1"; @@ -114,6 +118,7 @@ protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throw /** * @throws Exception If failed. */ + @Test public void testSession() throws Exception { testCache(DEFAULT_CACHE_NAME); @@ -209,7 +214,7 @@ protected class TestStore implements CacheStore { /** {@inheritDoc} */ @Override public void writeAll(Collection> entries) throws CacheWriterException { log.info("writeAll: " + entries); - + assertTrue("Unexpected entries: " + entries, entries.size() == 10 || entries.size() == 1); checkSession("writeAll"); @@ -293,4 +298,4 @@ public ExpectedData(String expMtd, String expCacheName) { this.expCacheName = expCacheName; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLoaderWriterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLoaderWriterTest.java index fc4ec781a80ba..29ba7f1f3f6e5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLoaderWriterTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLoaderWriterTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxLoaderWriterTest extends IgniteCacheLoaderWriterAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 3; @@ -47,4 +55,4 @@ public class IgniteCacheTxLoaderWriterTest extends IgniteCacheLoaderWriterAbstra @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalLoadAllTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalLoadAllTest.java index 97374bf3304e0..391fde2940edf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalLoadAllTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalLoadAllTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -28,6 +29,12 @@ * */ public class IgniteCacheTxLocalLoadAllTest extends IgniteCacheLoadAllAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } /** {@inheritDoc} */ @Override protected int gridCount() { return 1; @@ -47,4 +54,4 @@ public class IgniteCacheTxLocalLoadAllTest extends IgniteCacheLoadAllAbstractTes @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoLoadPreviousValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoLoadPreviousValueTest.java index 686b4ca310fb0..9b4afdba072a5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoLoadPreviousValueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoLoadPreviousValueTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxLocalNoLoadPreviousValueTest extends IgniteCacheNoLoadPreviousValueAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; @@ -47,4 +55,4 @@ public class IgniteCacheTxLocalNoLoadPreviousValueTest extends IgniteCacheNoLoad @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoReadThroughTest.java index 5235c9d454b1b..470e65e1b9754 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoReadThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoReadThroughTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxLocalNoReadThroughTest extends IgniteCacheNoReadThroughAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; @@ -47,4 +55,4 @@ public class IgniteCacheTxLocalNoReadThroughTest extends IgniteCacheNoReadThroug @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoWriteThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoWriteThroughTest.java index 7985c57207122..3e5ae2d75ad7e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoWriteThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxLocalNoWriteThroughTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxLocalNoWriteThroughTest extends IgniteCacheNoWriteThroughAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; @@ -47,4 +55,4 @@ public class IgniteCacheTxLocalNoWriteThroughTest extends IgniteCacheNoWriteThro @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNearEnabledNoLoadPreviousValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNearEnabledNoLoadPreviousValueTest.java index ce42e393647b7..019cf1e1e33f3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNearEnabledNoLoadPreviousValueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNearEnabledNoLoadPreviousValueTest.java @@ -18,13 +18,21 @@ package org.apache.ignite.internal.processors.cache.integration; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * */ public class IgniteCacheTxNearEnabledNoLoadPreviousValueTest extends IgniteCacheTxNoLoadPreviousValueTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected NearCacheConfiguration nearConfiguration() { return new NearCacheConfiguration(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNearEnabledNoWriteThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNearEnabledNoWriteThroughTest.java index ea12cce995bea..7a58800546d0b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNearEnabledNoWriteThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNearEnabledNoWriteThroughTest.java @@ -18,13 +18,21 @@ package org.apache.ignite.internal.processors.cache.integration; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * */ public class IgniteCacheTxNearEnabledNoWriteThroughTest extends IgniteCacheTxNoWriteThroughTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected NearCacheConfiguration nearConfiguration() { return new NearCacheConfiguration(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoLoadPreviousValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoLoadPreviousValueTest.java index ce9ef9b467ab2..fe71fe9cacc22 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoLoadPreviousValueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoLoadPreviousValueTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxNoLoadPreviousValueTest extends IgniteCacheNoLoadPreviousValueAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 3; @@ -47,4 +55,4 @@ public class IgniteCacheTxNoLoadPreviousValueTest extends IgniteCacheNoLoadPrevi @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoReadThroughTest.java index 90bc768ed60bf..b477b8821d153 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoReadThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoReadThroughTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxNoReadThroughTest extends IgniteCacheNoReadThroughAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 3; @@ -47,4 +55,4 @@ public class IgniteCacheTxNoReadThroughTest extends IgniteCacheNoReadThroughAbst @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoWriteThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoWriteThroughTest.java index 325d96994d51f..12ca66c231913 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoWriteThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxNoWriteThroughTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -28,6 +29,13 @@ * */ public class IgniteCacheTxNoWriteThroughTest extends IgniteCacheNoWriteThroughAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 3; @@ -47,4 +55,4 @@ public class IgniteCacheTxNoWriteThroughTest extends IgniteCacheNoWriteThroughAb @Override protected NearCacheConfiguration nearConfiguration() { return null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionTest.java index b9e884b9b4d84..741dd2a37d438 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionTest.java @@ -25,9 +25,13 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,7 +41,15 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheTxStoreSessionTest extends IgniteCacheStoreSessionAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 3; @@ -61,6 +73,7 @@ public class IgniteCacheTxStoreSessionTest extends IgniteCacheStoreSessionAbstra /** * @throws Exception If failed. */ + @Test public void testStoreSessionTx() throws Exception { testTxPut(jcache(0), null, null); @@ -256,6 +269,7 @@ private Transaction startTx(TransactionConcurrency concurrency, TransactionIsola /** * @throws Exception If failed. */ + @Test public void testSessionCrossCacheTx() throws Exception { IgniteCache cache0 = ignite(0).cache(DEFAULT_CACHE_NAME); @@ -292,4 +306,4 @@ public void testSessionCrossCacheTx() throws Exception { assertEquals(0, expData.size()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionWriteBehindCoalescingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionWriteBehindCoalescingTest.java index a90b4f18cf04d..cd88184eaf025 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionWriteBehindCoalescingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionWriteBehindCoalescingTest.java @@ -22,6 +22,7 @@ import javax.cache.integration.CacheWriterException; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -30,6 +31,13 @@ * parameter. */ public class IgniteCacheTxStoreSessionWriteBehindCoalescingTest extends IgniteCacheStoreSessionWriteBehindAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; @@ -85,4 +93,4 @@ private class TestNonCoalescingStore extends TestStore { entLatch.countDown(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionWriteBehindTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionWriteBehindTest.java index b72aba39b3492..533ab31c8f1de 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionWriteBehindTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheTxStoreSessionWriteBehindTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.integration; import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -25,8 +26,15 @@ * */ public class IgniteCacheTxStoreSessionWriteBehindTest extends IgniteCacheStoreSessionWriteBehindAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheAtomicLocalTckMetricsSelfTestImpl.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheAtomicLocalTckMetricsSelfTestImpl.java index 23e7a8b748ab6..f2d73eb978577 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheAtomicLocalTckMetricsSelfTestImpl.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheAtomicLocalTckMetricsSelfTestImpl.java @@ -21,14 +21,19 @@ import javax.cache.processor.EntryProcessorException; import javax.cache.processor.MutableEntry; import org.apache.ignite.IgniteCache; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Local atomic cache metrics test with tck specific. */ +@RunWith(JUnit4.class) public class GridCacheAtomicLocalTckMetricsSelfTestImpl extends GridCacheAtomicLocalMetricsSelfTest { /** * @throws Exception If failed. */ + @Test public void testEntryProcessorRemove() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -63,6 +68,7 @@ public void testEntryProcessorRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheStatistics() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -103,6 +109,7 @@ public void testCacheStatistics() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConditionReplace() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -153,6 +160,7 @@ public void testConditionReplace() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsent() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -180,4 +188,4 @@ public void testPutIfAbsent() throws Exception { assertEquals(putCount, cache.localMetrics().getCachePuts()); assertEquals(missCount, cache.localMetrics().getCacheMisses()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheDaemonNodeLocalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheDaemonNodeLocalSelfTest.java index 8578db7306232..c1ad352c9b4d9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheDaemonNodeLocalSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheDaemonNodeLocalSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.GridCacheDaemonNodeAbstractSelfTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -26,8 +27,15 @@ * Tests local cache with daemon node. */ public class GridCacheDaemonNodeLocalSelfTest extends GridCacheDaemonNodeAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.beforeTest(); + } + /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return LOCAL; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicApiSelfTest.java index d35590f07739d..84bcdd7d537b1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicApiSelfTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheBasicApiAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -27,6 +28,13 @@ * Basic API tests. */ public class GridCacheLocalBasicApiSelfTest extends GridCacheBasicApiAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -39,4 +47,4 @@ public class GridCacheLocalBasicApiSelfTest extends GridCacheBasicApiAbstractTes return cfg; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicStoreSelfTest.java index 183b456c71b00..b17dd681b7695 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicStoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalBasicStoreSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.GridCacheBasicStoreAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -26,8 +27,15 @@ * Test store with local cache. */ public class GridCacheLocalBasicStoreSelfTest extends GridCacheBasicStoreAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return LOCAL; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalByteArrayValuesSelfTest.java index a6be82b58d651..f5dc05b941e7f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalByteArrayValuesSelfTest.java @@ -26,9 +26,13 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractByteArrayValuesSelfTest; import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -40,6 +44,7 @@ /** * Byte values test for LOCAL cache. */ +@RunWith(JUnit4.class) public class GridCacheLocalByteArrayValuesSelfTest extends GridCacheAbstractByteArrayValuesSelfTest { /** Grid. */ private static Ignite ignite; @@ -55,7 +60,6 @@ public class GridCacheLocalByteArrayValuesSelfTest extends GridCacheAbstractByte CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - ccfg.setName(CACHE_REGULAR); ccfg.setAtomicityMode(TRANSACTIONAL); ccfg.setCacheMode(LOCAL); ccfg.setWriteSynchronizationMode(FULL_SYNC); @@ -67,16 +71,18 @@ public class GridCacheLocalByteArrayValuesSelfTest extends GridCacheAbstractByte /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + ignite = startGrid(1); - cache = ignite.cache(CACHE_REGULAR); + cache = ignite.cache(DEFAULT_CACHE_NAME); } /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { cache = null; - ignite = null; + stopAllGrids(); } /** @@ -84,6 +90,7 @@ public class GridCacheLocalByteArrayValuesSelfTest extends GridCacheAbstractByte * * @throws Exception If failed. */ + @Test public void testPessimistic() throws Exception { testTransaction(cache, PESSIMISTIC, KEY_1, wrap(1)); } @@ -93,6 +100,7 @@ public void testPessimistic() throws Exception { * * @throws Exception If failed. */ + @Test public void testPessimisticMixed() throws Exception { testTransactionMixed(cache, PESSIMISTIC, KEY_1, wrap(1), KEY_2, 1); } @@ -102,6 +110,7 @@ public void testPessimisticMixed() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimistic() throws Exception { testTransaction(cache, OPTIMISTIC, KEY_1, wrap(1)); } @@ -111,6 +120,7 @@ public void testOptimistic() throws Exception { * * @throws Exception If failed. */ + @Test public void testOptimisticMixed() throws Exception { testTransactionMixed(cache, OPTIMISTIC, KEY_1, wrap(1), KEY_2, 1); } @@ -121,6 +131,7 @@ public void testOptimisticMixed() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("TooBroadScope") + @Test public void testSwap() throws Exception { // TODO GG-11148. // assert cache.getConfiguration(CacheConfiguration.class).isSwapEnabled(); @@ -197,4 +208,4 @@ private void testTransactionMixed(IgniteCache cache, Transactio tx.close(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalEventSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalEventSelfTest.java index 0bf01c2f26732..02439d809afea 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalEventSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalEventSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.distributed.GridCacheEventAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -26,6 +27,14 @@ * Tests events. */ public class GridCacheLocalEventSelfTest extends GridCacheEventAbstractTest { + /** {@inheritDoc} */ + @Override public void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS); + + super.beforeTest(); + } + /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return LOCAL; @@ -35,4 +44,4 @@ public class GridCacheLocalEventSelfTest extends GridCacheEventAbstractTest { @Override protected int gridCount() { return 1; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalEvictionEventSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalEvictionEventSelfTest.java index b2d98c61c1150..f5ce88e30aa46 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalEvictionEventSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalEvictionEventSelfTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.GridCacheEvictionEventAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -27,6 +28,13 @@ * Tests local cache eviction event. */ public class GridCacheLocalEvictionEventSelfTest extends GridCacheEvictionEventAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return CacheMode.LOCAL; @@ -36,4 +44,4 @@ public class GridCacheLocalEvictionEventSelfTest extends GridCacheEvictionEventA @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalFullApiSelfTest.java index aaf69c96d432a..c55be312bb0f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalFullApiSelfTest.java @@ -27,12 +27,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfTest; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; /** * Tests for local cache. */ +@RunWith(JUnit4.class) public class GridCacheLocalFullApiSelfTest extends GridCacheAbstractFullApiSelfTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -51,6 +55,7 @@ public class GridCacheLocalFullApiSelfTest extends GridCacheAbstractFullApiSelfT /** * @throws Exception In case of error. */ + @Test public void testMapKeysToNodes() throws Exception { IgniteCache cache = jcache(); @@ -85,6 +90,7 @@ public void testMapKeysToNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalClearAsync() throws Exception { localCacheClear(true); } @@ -92,6 +98,7 @@ public void testLocalClearAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalClear() throws Exception { localCacheClear(false); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalGetAndTransformStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalGetAndTransformStoreSelfTest.java index 19b4b6116be2f..8fbec61ccafb4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalGetAndTransformStoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalGetAndTransformStoreSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.GridCacheGetAndTransformStoreAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -26,8 +27,15 @@ * Test get and transform for store with local cache. */ public class GridCacheLocalGetAndTransformStoreSelfTest extends GridCacheGetAndTransformStoreAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return LOCAL; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java index 53122c78f5391..31d7170e305cb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java @@ -23,13 +23,18 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; /** * Isolated nodes LOCAL cache self test. */ +@RunWith(JUnit4.class) public class GridCacheLocalIsolatedNodesSelfTest extends GridCommonAbstractTest { /** * @@ -40,6 +45,8 @@ public GridCacheLocalIsolatedNodesSelfTest() { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + startGrids(3); } @@ -52,6 +59,7 @@ public GridCacheLocalIsolatedNodesSelfTest() { * * @throws Exception If test failed. */ + @Test public void testIsolatedNodes() throws Exception { Ignite g1 = grid(0); UUID nid1 = g1.cluster().localNode().id(); @@ -115,4 +123,4 @@ private static class NodeIdFilter implements IgnitePredicate { } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIteratorsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIteratorsSelfTest.java index 6af80ca2a1869..6fa8edc00327b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIteratorsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIteratorsSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.GridCacheAbstractIteratorsSelfTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -40,4 +41,11 @@ public class GridCacheLocalIteratorsSelfTest extends GridCacheAbstractIteratorsS @Override protected int entryCount() { return 1000; } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.beforeTestsStarted(); + } } \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLoadAllSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLoadAllSelfTest.java index f10cefdb5ede9..638a49f848e68 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLoadAllSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLoadAllSelfTest.java @@ -27,14 +27,26 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; /** * Load-All self test. */ +@RunWith(JUnit4.class) public class GridCacheLocalLoadAllSelfTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** * */ @@ -46,6 +58,7 @@ public GridCacheLocalLoadAllSelfTest() { * * @throws Exception If test failed. */ + @Test public void testCacheGetAll() throws Exception { Ignite ignite = grid(); @@ -107,4 +120,4 @@ private static class TestStore extends CacheStoreAdapter { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLockSelfTest.java index f4160edba4aec..4bd013ef1a244 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLockSelfTest.java @@ -28,16 +28,27 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestThread; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; /** * Test cases for multi-threaded tests. */ -@SuppressWarnings({"ProhibitedExceptionThrown"}) +@RunWith(JUnit4.class) public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** Grid. */ private Ignite ignite; @@ -80,6 +91,7 @@ public GridCacheLocalLockSelfTest() { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testLockReentry() throws IgniteCheckedException { IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -125,6 +137,7 @@ public void testLockReentry() throws IgniteCheckedException { /** * @throws Exception If test failed. */ + @Test public void testLock() throws Throwable { final IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -135,7 +148,6 @@ public void testLock() throws Throwable { final Lock lock = cache.lock(1); GridTestThread t1 = new GridTestThread(new Callable() { - @SuppressWarnings({"CatchGenericClass"}) @Nullable @Override public Object call() throws Exception { info("Before lock for.key 1"); @@ -172,7 +184,6 @@ public void testLock() throws Throwable { }); GridTestThread t2 = new GridTestThread(new Callable() { - @SuppressWarnings({"CatchGenericClass"}) @Nullable @Override public Object call() throws Exception { info("Waiting for latch1..."); @@ -243,6 +254,7 @@ public void testLock() throws Throwable { /** * @throws Exception If test failed. */ + @Test public void testLockAndPut() throws Throwable { final IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -321,4 +333,4 @@ public void testLockAndPut() throws Throwable { assert !cache.isLocalLocked(1, true); assert !cache.isLocalLocked(1, false); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMetricsSelfTest.java index 16a2e3393fd75..d66799e38f4a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMetricsSelfTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheTransactionalAbstractMetricsSelfTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -30,6 +31,15 @@ public class GridCacheLocalMetricsSelfTest extends GridCacheTransactionalAbstrac /** */ private static final int GRID_CNT = 1; + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.METRICS); + + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java index f6dc5351892a5..f5b659acdabe3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java @@ -34,14 +34,26 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestThread; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; /** * Multithreaded local cache locking test. */ +@RunWith(JUnit4.class) public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** Cache. */ private IgniteCache cache; @@ -88,6 +100,7 @@ public GridCacheLocalMultithreadedSelfTest() { /** * @throws Exception If test fails. */ + @Test public void testBasicLocks() throws Throwable { GridTestUtils.runMultiThreaded(new Callable() { /** {@inheritDoc} */ @@ -114,6 +127,7 @@ public void testBasicLocks() throws Throwable { /** * @throws Exception If test fails. */ + @Test public void testMultiLocks() throws Throwable { GridTestUtils.runMultiThreaded(new Callable() { /** {@inheritDoc} */ @@ -142,6 +156,7 @@ public void testMultiLocks() throws Throwable { /** * @throws Exception If test fails. */ + @Test public void testSlidingKeysLocks() throws Throwable { final AtomicInteger cnt = new AtomicInteger(); @@ -174,6 +189,7 @@ public void testSlidingKeysLocks() throws Throwable { /** * @throws Exception If test fails. */ + @Test public void testSingleLockTimeout() throws Exception { final CountDownLatch l1 = new CountDownLatch(1); final CountDownLatch l2 = new CountDownLatch(1); @@ -240,6 +256,7 @@ public void testSingleLockTimeout() throws Exception { /** * @throws Exception If test fails. */ + @Test public void testMultiLockTimeout() throws Exception { final CountDownLatch l1 = new CountDownLatch(1); final CountDownLatch l2 = new CountDownLatch(1); @@ -350,4 +367,4 @@ public void testMultiLockTimeout() throws Exception { private String thread() { return "Thread [id=" + Thread.currentThread().getId() + ", name=" + Thread.currentThread().getName() + ']'; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java index 63a900dd1141d..ae1e2d0e62d10 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxExceptionSelfTest.java @@ -19,6 +19,7 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.IgniteTxExceptionAbstractSelfTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -26,6 +27,13 @@ * Tests local cache. */ public class GridCacheLocalTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.beforeTestsStarted(); + } + /** {@inheritDoc} */ @Override protected int gridCount() { return 1; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxMultiThreadedSelfTest.java index 388a7bfb78958..5babd8fa3457b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxMultiThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxMultiThreadedSelfTest.java @@ -21,6 +21,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.IgniteTxMultiThreadedAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -33,6 +34,11 @@ public class GridCacheLocalTxMultiThreadedSelfTest extends IgniteTxMultiThreaded /** Cache debug flag. */ private static final boolean CACHE_DEBUG = false; + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + } + /** {@inheritDoc} */ @SuppressWarnings({"ConstantConditions"}) @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -90,4 +96,4 @@ public class GridCacheLocalTxMultiThreadedSelfTest extends IgniteTxMultiThreaded @Override protected boolean printMemoryStats() { return true; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxSingleThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxSingleThreadedSelfTest.java index 83c74e201abd2..9022693c11de3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxSingleThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxSingleThreadedSelfTest.java @@ -21,6 +21,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheProcessor; import org.apache.ignite.internal.processors.cache.IgniteTxSingleThreadedAbstractTest; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -30,6 +31,11 @@ * Tests for local transactions. */ public class GridCacheLocalTxSingleThreadedSelfTest extends IgniteTxSingleThreadedAbstractTest { + /** {@inheritDoc} */ + @Override public void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + } + /** Cache debug flag. */ private static final boolean CACHE_DEBUG = false; @@ -85,4 +91,4 @@ public class GridCacheLocalTxSingleThreadedSelfTest extends IgniteTxSingleThread @Override protected boolean printMemoryStats() { return true; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxTimeoutSelfTest.java index 160e2512b180c..e7297e91b0e9a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxTimeoutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxTimeoutSelfTest.java @@ -25,11 +25,15 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionTimeoutException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; @@ -41,7 +45,15 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheLocalTxTimeoutSelfTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override public void setUp() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); + + super.setUp(); + } + /** Grid. */ private Ignite ignite; @@ -89,6 +101,7 @@ public GridCacheLocalTxTimeoutSelfTest() { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticReadCommitted() throws Exception { checkTransactionTimeout(PESSIMISTIC, READ_COMMITTED); } @@ -96,6 +109,7 @@ public void testPessimisticReadCommitted() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticRepeatableRead() throws Exception { checkTransactionTimeout(PESSIMISTIC, REPEATABLE_READ); } @@ -103,6 +117,7 @@ public void testPessimisticRepeatableRead() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testPessimisticSerializable() throws Exception { checkTransactionTimeout(PESSIMISTIC, SERIALIZABLE); } @@ -110,6 +125,7 @@ public void testPessimisticSerializable() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticReadCommitted() throws Exception { checkTransactionTimeout(OPTIMISTIC, READ_COMMITTED); } @@ -117,6 +133,7 @@ public void testOptimisticReadCommitted() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticRepeatableRead() throws Exception { checkTransactionTimeout(OPTIMISTIC, REPEATABLE_READ); } @@ -124,6 +141,7 @@ public void testOptimisticRepeatableRead() throws Exception { /** * @throws IgniteCheckedException If test failed. */ + @Test public void testOptimisticSerializable() throws Exception { checkTransactionTimeout(OPTIMISTIC, SERIALIZABLE); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java index 5d28cb7ef37a1..a72f80c811504 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.java @@ -18,10 +18,14 @@ package org.apache.ignite.internal.processors.cache.multijvm; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Multi-JVM tests. */ +@RunWith(JUnit4.class) public class GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest extends GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest { /** {@inheritDoc} */ @@ -30,7 +34,8 @@ public class GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest extends } /** {@inheritDoc} */ + @Test @Override public void testPutAllPutAll() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-1112"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheReplicatedNearOnlyMultiJvmFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheReplicatedNearOnlyMultiJvmFullApiSelfTest.java index 9b4db5b7bd791..56cc0eb45256c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheReplicatedNearOnlyMultiJvmFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/multijvm/GridCacheReplicatedNearOnlyMultiJvmFullApiSelfTest.java @@ -18,20 +18,17 @@ package org.apache.ignite.internal.processors.cache.multijvm; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedNearOnlyMultiNodeFullApiSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Multi-JVM tests. */ +@RunWith(JUnit4.class) public class GridCacheReplicatedNearOnlyMultiJvmFullApiSelfTest extends GridCacheReplicatedNearOnlyMultiNodeFullApiSelfTest { /** {@inheritDoc} */ @Override protected boolean isMultiJvm() { return true; } - - /** {@inheritDoc} */ - @Override public void testNearDhtKeySize() throws Exception { - if (isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-648"); - } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractBasicCoordinatorFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractBasicCoordinatorFailoverTest.java index c1718b5bc4d6a..6e9f9e41be1c9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractBasicCoordinatorFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractBasicCoordinatorFailoverTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.mvcc; import java.util.ArrayList; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -27,19 +28,27 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import javax.cache.Cache; import javax.cache.CacheException; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.ScanQuery; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.cluster.ClusterTopologyException; import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager; import org.apache.ignite.internal.processors.cache.distributed.TestCacheNodeExcludingFilter; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest; import org.apache.ignite.internal.processors.cache.mvcc.msg.MvccSnapshotResponse; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteBiPredicate; @@ -50,6 +59,9 @@ import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; @@ -58,6 +70,7 @@ /** * Base class for Mvcc coordinator failover test. */ +@RunWith(JUnit4.class) public abstract class CacheMvccAbstractBasicCoordinatorFailoverTest extends CacheMvccAbstractTest { /** * @param concurrency Transaction concurrency. @@ -675,4 +688,182 @@ protected void checkCoordinatorChangeActiveQueryClientFails_Simple(@Nullable Ign for (Ignite node : G.allGrids()) checkActiveQueriesCleanup(node); } + + /** + * @throws Exception If failed. + */ + @Test + public void testMultipleCoordinatorsLeft2Persistence() throws Exception { + persistence = true; + + checkCoordinatorsLeft(2, false); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMultipleCoordinatorsLeft3Persistence() throws Exception { + persistence = true; + + checkCoordinatorsLeft(3, true); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testMultipleCoordinatorsLeft4() throws Exception { + checkCoordinatorsLeft(4, true); + } + + /** + * @param num Number of coordinators to stop. + * @throws Exception If failed. + */ + @SuppressWarnings("unchecked") + private void checkCoordinatorsLeft(int num, boolean stopCrdFirst) throws Exception { + disableScheduledVacuum = true; + + final int DATA_NODES = 3; + + final int NODES = num + DATA_NODES; + + nodeAttr = CRD_ATTR; + + // Do not use startMultithreaded here. + startGrids(num); + + nodeAttr = null; + + startGridsMultiThreaded(num, DATA_NODES); + + List victims = new ArrayList<>(num); + List survivors = new ArrayList<>(DATA_NODES); + + for (int i = 0; i < NODES; i++) { + if (i < num) + victims.add(grid(i)); + else + survivors.add(grid(i)); + } + + if (log.isInfoEnabled()) { + log.info("Nodes to be stopped [" + + victims.stream(). + map(n -> n.cluster().localNode().id().toString()) + .collect(Collectors.joining(", ")) + ']'); + + log.info("Nodes not to be stopped [" + + survivors.stream(). + map(n -> n.cluster().localNode().id().toString()) + .collect(Collectors.joining(", ")) + ']'); + } + + Ignite nearNode = survivors.get(0); + + if (persistence) + nearNode.cluster().active(true); + + CacheConfiguration ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, DATA_NODES - 1, DFLT_PARTITION_COUNT) + .setNodeFilter(new CoordinatorNodeFilter()); + + IgniteCache cache = nearNode.createCache(ccfg); + + try (Transaction tx = nearNode.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + for (int key = 0; key < 10; key++) + cache.put(key, 1); + + tx.commit(); + } + + List stopThreads = victims.stream() + .map(v -> new Thread(() -> stopGrid(v.name()))) + .collect(Collectors.toList()); + + ScanQuery scan = new ScanQuery<>(); + + QueryCursor> cur = survivors.get(0).cache(DEFAULT_CACHE_NAME).query(scan); + + Iterator> it = cur.iterator(); + + assertTrue(it.hasNext()); + assertEquals(1, it.next().getValue()); + + if (log.isInfoEnabled()) + log.info("Start stopping nodes."); + + // Stop nodes and join threads. + if (stopCrdFirst) { + for (Thread t : stopThreads) + t.start(); + } + else { + // We should stop the oldest node last. + GridCachePartitionExchangeManager exch = ((IgniteEx)survivors.get(1)).context().cache().context().exchange(); + + GridDhtTopologyFuture lastFinished = exch.lastFinishedFuture(); + + for (int i = 1; i < stopThreads.size(); i++) + stopThreads.get(i).start(); + + while (lastFinished == exch.lastTopologyFuture()) + doSleep(1); + + stopThreads.get(0).start(); + } + + for (Thread t : stopThreads) + t.join(); + + if (log.isInfoEnabled()) + log.info("All nodes stopped."); + + assertTrue(it.hasNext()); + assertEquals(1, it.next().getValue()); + + for (Ignite node : survivors) { + for (int key = 0; key < 10; key++) + assertEquals(1, node.cache(DEFAULT_CACHE_NAME).get(key)); + } + + try (Transaction tx = nearNode.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + for (int key = 0; key < 10; key++) + cache.put(key, 2); + + tx.commit(); + } + catch (Exception e) { + stopAllGrids(true); + + fail(X.getFullStackTrace(e)); + } + + for (Ignite node : survivors) { + for (int key = 0; key < 10; key++) + assertEquals(2, node.cache(DEFAULT_CACHE_NAME).get(key)); + } + + try (Transaction tx = nearNode.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + for (int key = 0; key < 10; key++) + cache.put(key, 3); + + tx.commit(); + } + catch (Exception e) { + stopAllGrids(true); + + fail(X.getFullStackTrace(e)); + } + + for (Ignite node : survivors) { + for (int key = 0; key < 10; key++) + assertEquals(3, node.cache(DEFAULT_CACHE_NAME).get(key)); + } + + while (it.hasNext()) + assertEquals(1, (int)it.next().getValue()); + + cur.close(); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractCoordinatorFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractCoordinatorFailoverTest.java index 60f1a2f788bbe..eee39580a1af4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractCoordinatorFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractCoordinatorFailoverTest.java @@ -17,6 +17,11 @@ package org.apache.ignite.internal.processors.cache.mvcc; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.GET; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SCAN; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.WriteMode.PUT; @@ -28,10 +33,13 @@ /** * Mvcc cache API coordinator failover test. */ +@RunWith(JUnit4.class) public abstract class CacheMvccAbstractCoordinatorFailoverTest extends CacheMvccAbstractBasicCoordinatorFailoverTest { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testAccountsTxGet_Server_Backups0_CoordinatorFails_Persistence() throws Exception { persistence = true; @@ -42,6 +50,8 @@ public void testAccountsTxGet_Server_Backups0_CoordinatorFails_Persistence() thr /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testAccountsTxGet_SingleNode_CoordinatorFails() throws Exception { accountsTxReadAll(1, 0, 0, 1, null, true, GET, PUT, DFLT_TEST_TIME, RestartMode.RESTART_CRD); @@ -50,6 +60,8 @@ public void testAccountsTxGet_SingleNode_CoordinatorFails() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10750") + @Test public void testAccountsTxScan_Server_Backups0_CoordinatorFails() throws Exception { accountsTxReadAll(2, 0, 0, 64, null, true, SCAN, PUT, DFLT_TEST_TIME, RestartMode.RESTART_CRD); @@ -58,6 +70,7 @@ public void testAccountsTxScan_Server_Backups0_CoordinatorFails() throws Excepti /** * @throws Exception If failed. */ + @Test public void testAccountsTxScan_SingleNode_CoordinatorFails_Persistence() throws Exception { persistence = true; @@ -69,6 +82,7 @@ public void testAccountsTxScan_SingleNode_CoordinatorFails_Persistence() throws /** * @throws Exception If failed. */ + @Test public void testPutAllGetAll_Server_Backups0_RestartCoordinator_GetPut() throws Exception { putAllGetAll(RestartMode.RESTART_CRD , 2, 0, 0, 64, null, GET, PUT); @@ -77,6 +91,7 @@ public void testPutAllGetAll_Server_Backups0_RestartCoordinator_GetPut() throws /** * @throws Exception If failed. */ + @Test public void testPutAllGetAll_SingleNode_RestartCoordinator_GetPut_Persistence() throws Exception { persistence = true; @@ -87,6 +102,8 @@ public void testPutAllGetAll_SingleNode_RestartCoordinator_GetPut_Persistence() /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testUpdate_N_Objects_Servers_Backups0__PutGet_CoordinatorFails_Persistence() throws Exception { persistence = true; @@ -97,8 +114,9 @@ public void testUpdate_N_Objects_Servers_Backups0__PutGet_CoordinatorFails_Persi /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testUpdate_N_Objects_SingleNode__PutGet_CoordinatorFails() throws Exception { - updateNObjectsTest(7, 1, 0, 0, 1, DFLT_TEST_TIME, null, GET, PUT, RestartMode.RESTART_CRD); } @@ -106,6 +124,7 @@ public void testUpdate_N_Objects_SingleNode__PutGet_CoordinatorFails() throws Ex /** * @throws Exception If failed. */ + @Test public void testCoordinatorFailureSimplePessimisticTxPutGet() throws Exception { coordinatorFailureSimple(PESSIMISTIC, REPEATABLE_READ, GET, PUT); } @@ -113,6 +132,7 @@ public void testCoordinatorFailureSimplePessimisticTxPutGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadInProgressCoordinatorFailsSimple_FromClientPutGet() throws Exception { readInProgressCoordinatorFailsSimple(true, null, GET, PUT); } @@ -120,6 +140,7 @@ public void testReadInProgressCoordinatorFailsSimple_FromClientPutGet() throws E /** * @throws Exception If failed. */ + @Test public void testCoordinatorChangeActiveQueryClientFails_Simple() throws Exception { checkCoordinatorChangeActiveQueryClientFails_Simple(null, GET, PUT); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractTest.java index 5b3234762d391..3ef55b30774a0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractTest.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.processors.cache.mvcc; -import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -77,6 +76,7 @@ import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; import org.apache.ignite.internal.util.future.GridCompoundIdentityFuture; import org.apache.ignite.internal.util.lang.GridAbsPredicate; +import org.apache.ignite.internal.util.lang.GridCloseableIterator; import org.apache.ignite.internal.util.lang.GridInClosure3; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; @@ -88,9 +88,6 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; @@ -113,9 +110,6 @@ * */ public abstract class CacheMvccAbstractTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ protected static final ObjectCodec INTEGER_CODEC = new IntegerCodec(); @@ -173,8 +167,6 @@ public abstract class CacheMvccAbstractTest extends GridCommonAbstractTest { if (disableScheduledVacuum) cfg.setMvccVacuumFrequency(Integer.MAX_VALUE); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - if (testSpi) cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); @@ -687,19 +679,19 @@ else if (writeMode == WriteMode.DML) } case SQL_SUM: { - BigDecimal sum; + Long sum; if (rnd.nextBoolean()) { List> res = cache.cache.query(sumQry).getAll(); assertEquals(1, res.size()); - sum = (BigDecimal)res.get(0).get(0); + sum = (Long)res.get(0).get(0); } else { Map res = readAllByMode(cache.cache, keys, readMode, ACCOUNT_CODEC); - sum = (BigDecimal)((Map.Entry)res.entrySet().iterator().next()).getValue(); + sum = (Long)((Map.Entry)res.entrySet().iterator().next()).getValue(); } assertEquals(ACCOUNT_START_VAL * ACCOUNTS, sum.intValue()); @@ -945,6 +937,8 @@ protected void putAllGetAll( tx.commit(); + v++; + first = false; } @@ -952,10 +946,8 @@ protected void putAllGetAll( Map res = readAllByMode(cache.cache, keys, readMode, INTEGER_CODEC); for (Integer k : keys) - assertEquals("key=" + k, v, (Object)res.get(k)); + assertEquals("key=" + k, v - 1, (Object)res.get(k)); } - - v++; } catch (Exception e) { handleTxException(e); @@ -1367,6 +1359,13 @@ final void readWriteTest( } }, readers, "reader"); + GridTestUtils.runAsync(() -> { + while (System.currentTimeMillis() < stopTime) + doSleep(1000); + + stop.set(true); + }); + while (System.currentTimeMillis() < stopTime && !stop.get()) { Thread.sleep(1000); @@ -1408,8 +1407,10 @@ final void readWriteTest( Ignite srv = startGrid(idx); + cache0 = new TestCache(srv.cache(DEFAULT_CACHE_NAME)); + synchronized (caches) { - caches.set(idx, new TestCache(srv.cache(DEFAULT_CACHE_NAME))); + caches.set(idx, cache0); } awaitPartitionMapExchange(); @@ -1423,8 +1424,6 @@ final void readWriteTest( } } - stop.set(true); - Exception ex = null; try { @@ -1633,21 +1632,20 @@ private boolean checkOldVersions(boolean failIfNotCleaned) throws IgniteCheckedE if (!cctx.userCache() || !cctx.group().mvccEnabled() || F.isEmpty(cctx.group().caches()) || cctx.shared().closed(cctx)) continue; - for (Iterator it = cache.withKeepBinary().iterator(); it.hasNext(); ) { - IgniteBiTuple entry = (IgniteBiTuple)it.next(); - - KeyCacheObject key = cctx.toCacheKeyObject(entry.getKey()); + try (GridCloseableIterator it = (GridCloseableIterator)cache.withKeepBinary().iterator()) { + while (it.hasNext()) { + IgniteBiTuple entry = (IgniteBiTuple)it.next(); - List> vers = cctx.offheap().mvccAllVersions(cctx, key) - .stream().filter(t -> t.get1() != null).collect(Collectors.toList()); + KeyCacheObject key = cctx.toCacheKeyObject(entry.getKey()); - if (vers.size() > 1) { - if (failIfNotCleaned) - fail("[key=" + key.value(null, false) + "; vers=" + vers + ']'); - else { - U.closeQuiet((AutoCloseable)it); + List> vers = cctx.offheap().mvccAllVersions(cctx, key) + .stream().filter(t -> t.get1() != null).collect(Collectors.toList()); - return false; + if (vers.size() > 1) { + if (failIfNotCleaned) + fail("[key=" + key.value(null, false) + "; vers=" + vers + ']'); + else + return false; } } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccClusterRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccClusterRestartTest.java index 61d41ad2ff131..0c3e73c14aa4d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccClusterRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccClusterRestartTest.java @@ -27,11 +27,11 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -41,18 +41,14 @@ /** * */ +@RunWith(JUnit4.class) public class CacheMvccClusterRestartTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setConsistentId(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - DataStorageConfiguration storageCfg = new DataStorageConfiguration(); storageCfg.setWalMode(WALMode.LOG_ONLY); @@ -98,6 +94,7 @@ public class CacheMvccClusterRestartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRestart1() throws Exception { restart1(3, 3); } @@ -105,6 +102,7 @@ public void testRestart1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestart2() throws Exception { restart1(1, 3); } @@ -112,6 +110,7 @@ public void testRestart2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestart3() throws Exception { restart1(3, 1); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccConfigurationValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccConfigurationValidationTest.java index c67765651753c..92ec8122ccaec 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccConfigurationValidationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccConfigurationValidationTest.java @@ -36,36 +36,28 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.LOCAL; +import static org.apache.ignite.configuration.DataPageEvictionMode.RANDOM_2_LRU; +import static org.apache.ignite.configuration.DataPageEvictionMode.RANDOM_LRU; /** * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class CacheMvccConfigurationValidationTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -77,6 +69,7 @@ public class CacheMvccConfigurationValidationTest extends GridCommonAbstractTest * @throws Exception If failed. */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testMvccModeMismatchForGroup1() throws Exception { final Ignite node = startGrid(0); @@ -98,6 +91,7 @@ public void testMvccModeMismatchForGroup1() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testMvccModeMismatchForGroup2() throws Exception { final Ignite node = startGrid(0); @@ -120,6 +114,7 @@ public void testMvccModeMismatchForGroup2() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testMvccLocalCacheDisabled() throws Exception { final Ignite node1 = startGrid(1); final Ignite node2 = startGrid(2); @@ -152,6 +147,7 @@ public void testMvccLocalCacheDisabled() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testNodeRestartWithCacheModeChangedTxToMvcc() throws Exception { cleanPersistenceDir(); @@ -199,6 +195,7 @@ public void testNodeRestartWithCacheModeChangedTxToMvcc() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testNodeRestartWithCacheModeChangedMvccToTx() throws Exception { cleanPersistenceDir(); @@ -206,6 +203,7 @@ public void testNodeRestartWithCacheModeChangedMvccToTx() throws Exception { DataStorageConfiguration storageCfg = new DataStorageConfiguration(); DataRegionConfiguration regionCfg = new DataRegionConfiguration(); regionCfg.setPersistenceEnabled(true); + regionCfg.setPageEvictionMode(RANDOM_LRU); storageCfg.setDefaultDataRegionConfiguration(regionCfg); IgniteConfiguration cfg = getConfiguration("testGrid"); cfg.setDataStorageConfiguration(storageCfg); @@ -242,12 +240,48 @@ public void testNodeRestartWithCacheModeChangedMvccToTx() throws Exception { }, IgniteCheckedException.class, "Cannot start cache. Statically configured atomicity mode"); } + /** + * @throws Exception If failed. + */ + @Test + public void testMvccInMemoryEvictionDisabled() throws Exception { + final String memRegName = "in-memory-evictions"; + + // Enable in-memory eviction. + DataRegionConfiguration regionCfg = new DataRegionConfiguration(); + regionCfg.setPersistenceEnabled(false); + regionCfg.setPageEvictionMode(RANDOM_2_LRU); + regionCfg.setName(memRegName); + + DataStorageConfiguration storageCfg = new DataStorageConfiguration(); + storageCfg.setDefaultDataRegionConfiguration(regionCfg); + + IgniteConfiguration cfg = getConfiguration("testGrid"); + cfg.setDataStorageConfiguration(storageCfg); + + Ignite node = startGrid(cfg); + + CacheConfiguration ccfg1 = new CacheConfiguration("test1") + .setAtomicityMode(TRANSACTIONAL_SNAPSHOT) + .setDataRegionName(memRegName); + + try { + node.createCache(ccfg1); + + fail("In memory evictions should be disabled for MVCC caches."); + } + catch (Exception e) { + assertTrue(X.getFullStackTrace(e).contains("Data pages evictions cannot be used with TRANSACTIONAL_SNAPSHOT")); + } + } + /** * Test TRANSACTIONAL_SNAPSHOT and near cache. * * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testTransactionalSnapshotLimitations() throws Exception { assertCannotStart( mvccCacheConfig().setCacheMode(LOCAL), @@ -285,6 +319,41 @@ public void testTransactionalSnapshotLimitations() throws Exception { ); } + /** + * Checks if passed in {@code 'Throwable'} has given class in {@code 'cause'} hierarchy + * including that throwable itself and it contains passed message. + *

    + * Note that this method follows includes {@link Throwable#getSuppressed()} + * into check. + * + * @param t Throwable to check (if {@code null}, {@code false} is returned). + * @param cls Cause class to check (if {@code null}, {@code false} is returned). + * @param msg Message to check. + * @return {@code True} if one of the causing exception is an instance of passed in classes + * and it contains the passed message, {@code false} otherwise. + */ + private boolean hasCauseWithMessage(@Nullable Throwable t, Class cls, String msg) { + if (t == null) + return false; + + assert cls != null; + + for (Throwable th = t; th != null; th = th.getCause()) { + if (cls.isAssignableFrom(th.getClass()) && th.getMessage() != null && th.getMessage().contains(msg)) + return true; + + for (Throwable n : th.getSuppressed()) { + if (hasCauseWithMessage(n, cls, msg)) + return true; + } + + if (th.getCause() == th) + break; + } + + return false; + } + /** * Make sure cache cannot be started with the given configuration. * @@ -305,7 +374,7 @@ private void assertCannotStart(CacheConfiguration ccfg, String msg) throws Excep catch (Exception e) { if (msg != null) { assert e.getMessage() != null : "Error message is null"; - assert e.getMessage().contains(msg) : "Wrong error message: " + e.getMessage(); + assertTrue(hasCauseWithMessage(e, IgniteCheckedException.class, msg)); } } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccIteratorWithConcurrentTransactionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccIteratorWithConcurrentTransactionTest.java index 90c5b6e737034..db5e151c26d3e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccIteratorWithConcurrentTransactionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccIteratorWithConcurrentTransactionTest.java @@ -25,14 +25,19 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.util.lang.IgniteClosure2X; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheMvccIteratorWithConcurrentTransactionTest extends CacheMvccAbstractFeatureTest { /** * @throws Exception if failed. */ + @Test public void testScanQuery() throws Exception { doTestConsistency(clo); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccLocalEntriesWithConcurrentTransactionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccLocalEntriesWithConcurrentTransactionTest.java index f4c9781744f05..0040093db9c31 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccLocalEntriesWithConcurrentTransactionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccLocalEntriesWithConcurrentTransactionTest.java @@ -26,14 +26,19 @@ import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.internal.util.lang.IgniteClosure2X; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheMvccLocalEntriesWithConcurrentTransactionTest extends CacheMvccAbstractFeatureTest { /** * @throws Exception if failed. */ + @Test public void testLocalEntries() throws Exception { doTestConsistency(clo); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccOperationChecksTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccOperationChecksTest.java index 5aedf17089d86..9a3d44be54264 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccOperationChecksTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccOperationChecksTest.java @@ -33,6 +33,9 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -40,6 +43,7 @@ /** * */ +@RunWith(JUnit4.class) public class CacheMvccOperationChecksTest extends CacheMvccAbstractTest { /** Empty Class[]. */ private final static Class[] E = new Class[]{}; @@ -62,6 +66,7 @@ public class CacheMvccOperationChecksTest extends CacheMvccAbstractTest { /** * @throws Exception if failed. */ + @Test public void testClearOperationsUnsupported() throws Exception { checkOperationUnsupported("clear", m("Clear"), E); @@ -80,6 +85,7 @@ public void testClearOperationsUnsupported() throws Exception { /** * @throws Exception if failed. */ + @Test public void testLoadOperationsUnsupported() throws Exception { checkOperationUnsupported("loadCache", m("Load"), t(IgniteBiPredicate.class, Object[].class), P, new Object[]{ 1 }); @@ -97,6 +103,7 @@ public void testLoadOperationsUnsupported() throws Exception { /** * @throws Exception if failed. */ + @Test public void testLockOperationsUnsupported() throws Exception { checkOperationUnsupported("lock", m("Lock"), t(Object.class), 1); @@ -106,14 +113,7 @@ public void testLockOperationsUnsupported() throws Exception { /** * @throws Exception if failed. */ - public void testPeekOperationsUnsupported() throws Exception { - checkOperationUnsupported("localPeek", m("Peek"), t(Object.class, CachePeekMode[].class), 1, - new CachePeekMode[]{CachePeekMode.NEAR}); - } - - /** - * @throws Exception if failed. - */ + @Test public void testEvictOperationsUnsupported() throws Exception { checkOperationUnsupported("localEvict", m("Evict"), t(Collection.class), Collections.singleton(1)); } @@ -121,6 +121,7 @@ public void testEvictOperationsUnsupported() throws Exception { /** * @throws Exception if failed. */ + @Test public void testWithExpiryPolicyUnsupported() throws Exception { checkOperationUnsupported("withExpiryPolicy", m("withExpiryPolicy"), t(ExpiryPolicy.class), EternalExpiryPolicy.factoryOf().create()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedCoordinatorFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedCoordinatorFailoverTest.java index 3ea1c5bb35317..dcaf720faa40b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedCoordinatorFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedCoordinatorFailoverTest.java @@ -17,8 +17,16 @@ package org.apache.ignite.internal.processors.cache.mvcc; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.GET; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SCAN; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.WriteMode.PUT; @@ -28,6 +36,7 @@ /** * Coordinator failover test for partitioned caches. */ +@RunWith(JUnit4.class) public class CacheMvccPartitionedCoordinatorFailoverTest extends CacheMvccAbstractCoordinatorFailoverTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -37,6 +46,8 @@ public class CacheMvccPartitionedCoordinatorFailoverTest extends CacheMvccAbstra /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testAccountsTxGet_ClientServer_Backups2_CoordinatorFails_Persistence() throws Exception { persistence = true; @@ -47,6 +58,8 @@ public void testAccountsTxGet_ClientServer_Backups2_CoordinatorFails_Persistence /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testAccountsTxGet_Server_Backups1_CoordinatorFails() throws Exception { accountsTxReadAll(2, 0, 1, DFLT_PARTITION_COUNT, null, true, GET, PUT, DFLT_TEST_TIME, RestartMode.RESTART_CRD); @@ -55,6 +68,8 @@ public void testAccountsTxGet_Server_Backups1_CoordinatorFails() throws Exceptio /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10750") + @Test public void testAccountsTxScan_ClientServer_Backups2_CoordinatorFails() throws Exception { accountsTxReadAll(4, 2, 2, DFLT_PARTITION_COUNT, null, true, SCAN, PUT, DFLT_TEST_TIME, RestartMode.RESTART_CRD); @@ -63,6 +78,8 @@ public void testAccountsTxScan_ClientServer_Backups2_CoordinatorFails() throws E /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testAccountsTxScan_Server_Backups1_CoordinatorFails_Persistence() throws Exception { persistence = true; @@ -73,6 +90,7 @@ public void testAccountsTxScan_Server_Backups1_CoordinatorFails_Persistence() th /** * @throws Exception If failed. */ + @Test public void testPutAllGetAll_ClientServer_Backups2_RestartCoordinator_GetPut() throws Exception { putAllGetAll(RestartMode.RESTART_CRD, 4, 2, 2, DFLT_PARTITION_COUNT, null, GET, PUT); @@ -81,6 +99,7 @@ public void testPutAllGetAll_ClientServer_Backups2_RestartCoordinator_GetPut() t /** * @throws Exception If failed. */ + @Test public void testPutAllGetAll_ClientServer_Backups1_RestartCoordinator_GetPut_Persistence() throws Exception { persistence = true; @@ -91,6 +110,8 @@ public void testPutAllGetAll_ClientServer_Backups1_RestartCoordinator_GetPut_Per /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testUpdate_N_Objects_ClientServer_Backups1_PutGet_CoordinatorFails_Persistence() throws Exception { persistence = true; @@ -101,6 +122,8 @@ public void testUpdate_N_Objects_ClientServer_Backups1_PutGet_CoordinatorFails_P /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10750") + @Test public void testUpdate_N_Objects_ClientServer_Backups1__PutGet_CoordinatorFails() throws Exception { updateNObjectsTest(10, 3, 2, 1, DFLT_PARTITION_COUNT, DFLT_TEST_TIME, null, GET, PUT, RestartMode.RESTART_CRD); @@ -110,6 +133,8 @@ public void testUpdate_N_Objects_ClientServer_Backups1__PutGet_CoordinatorFails( /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testGetReadInProgressCoordinatorFails() throws Exception { readInProgressCoordinatorFails(false, false, PESSIMISTIC, REPEATABLE_READ, GET, PUT, null); } @@ -117,6 +142,7 @@ public void testGetReadInProgressCoordinatorFails() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetReadInsideTxInProgressCoordinatorFails() throws Exception { readInProgressCoordinatorFails(false, true, PESSIMISTIC, REPEATABLE_READ, GET, PUT, null); } @@ -124,6 +150,7 @@ public void testGetReadInsideTxInProgressCoordinatorFails() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetReadInProgressCoordinatorFails_ReadDelay() throws Exception { readInProgressCoordinatorFails(true, false, PESSIMISTIC, REPEATABLE_READ, GET, PUT, null); } @@ -131,6 +158,8 @@ public void testGetReadInProgressCoordinatorFails_ReadDelay() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testGetReadInsideTxInProgressCoordinatorFails_ReadDelay() throws Exception { readInProgressCoordinatorFails(true, true, PESSIMISTIC, REPEATABLE_READ, GET, PUT, null); } @@ -138,7 +167,40 @@ public void testGetReadInsideTxInProgressCoordinatorFails_ReadDelay() throws Exc /** * @throws Exception If failed. */ + @Test public void testReadInProgressCoordinatorFailsSimple_FromServerPutGet() throws Exception { readInProgressCoordinatorFailsSimple(false, null, GET, PUT); } + + /** + * @throws Exception If failed. + */ + @Test + public void testActivateDeactivateCLuster() throws Exception { + disableScheduledVacuum = true; + persistence = true; + + final int DATA_NODES = 3; + + // Do not use startMultithreaded here. + startGrids(DATA_NODES); + + Ignite near = grid(DATA_NODES - 1); + + CacheConfiguration ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, DATA_NODES - 1, DFLT_PARTITION_COUNT); + + near.cluster().active(true); + + IgniteCache cache = near.createCache(ccfg); + + cache.put(1, 1); + + near.cluster().active(false); + + stopGrid(0); + + near.cluster().active(true); + + assertEquals(1, cache.get(1)); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccProcessorLazyStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccProcessorLazyStartTest.java index 064e7bbd2a7af..00439b5acc9c6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccProcessorLazyStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccProcessorLazyStartTest.java @@ -23,11 +23,15 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for a lazy MVCC processor start. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class CacheMvccProcessorLazyStartTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -37,6 +41,7 @@ public class CacheMvccProcessorLazyStartTest extends CacheMvccAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPreconfiguredCacheMvccNotStarted() throws Exception { CacheConfiguration ccfg = cacheConfiguration(CacheMode.PARTITIONED, CacheWriteSynchronizationMode.FULL_SYNC, 0, 1); ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); @@ -60,6 +65,7 @@ public void testPreconfiguredCacheMvccNotStarted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreconfiguredCacheMvccStarted() throws Exception { CacheConfiguration ccfg = cacheConfiguration(CacheMode.PARTITIONED, CacheWriteSynchronizationMode.FULL_SYNC, 0, 1); @@ -82,6 +88,7 @@ public void testPreconfiguredCacheMvccStarted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMvccRestartedWithDynamicCache() throws Exception { persistence = true; @@ -129,6 +136,7 @@ public void testMvccRestartedWithDynamicCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMvccStartedWithDynamicCache() throws Exception { IgniteEx node1 = startGrid(1); IgniteEx node2 = startGrid(2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccProcessorTest.java index 7339a7d4db8da..657bc964875e1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccProcessorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccProcessorTest.java @@ -22,12 +22,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.mvcc.txlog.TxState; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public class CacheMvccProcessorTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -37,6 +41,7 @@ public class CacheMvccProcessorTest extends CacheMvccAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTreeWithPersistence() throws Exception { persistence = true; @@ -46,6 +51,7 @@ public void testTreeWithPersistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTreeWithoutPersistence() throws Exception { persistence = false; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccRemoteTxOnNearNodeStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccRemoteTxOnNearNodeStartTest.java index ee23e382053a8..20ca8da19c7fa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccRemoteTxOnNearNodeStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccRemoteTxOnNearNodeStartTest.java @@ -24,16 +24,16 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; -import org.apache.ignite.transactions.TransactionConcurrency; -import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** */ +@RunWith(JUnit4.class) public class CacheMvccRemoteTxOnNearNodeStartTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -45,6 +45,7 @@ public class CacheMvccRemoteTxOnNearNodeStartTest extends CacheMvccAbstractTest * when first request is sent to OWNING partition and second to MOVING partition. * @throws Exception if failed. */ + @Test public void testRemoteTxOnNearNodeIsStartedIfPartitionIsMoving() throws Exception { startGridsMultiThreaded(3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccScanQueryWithConcurrentTransactionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccScanQueryWithConcurrentTransactionTest.java index 8af6a5b9c03ab..f618b3ffbad17 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccScanQueryWithConcurrentTransactionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccScanQueryWithConcurrentTransactionTest.java @@ -28,14 +28,19 @@ import org.apache.ignite.internal.util.lang.IgniteClosure2X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheMvccScanQueryWithConcurrentTransactionTest extends CacheMvccAbstractFeatureTest { /** * @throws Exception if failed. */ + @Test public void testScanQuery() throws Exception { doTestConsistency(clo); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSizeWithConcurrentTransactionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSizeWithConcurrentTransactionTest.java index 2b8b73ed2f455..54de75552cec3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSizeWithConcurrentTransactionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSizeWithConcurrentTransactionTest.java @@ -21,14 +21,19 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.util.lang.IgniteClosure2X; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheMvccSizeWithConcurrentTransactionTest extends CacheMvccAbstractFeatureTest { /** * @throws Exception if failed. */ + @Test public void testSize() throws Exception { doTestConsistency(clo); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java index ca3c09f013731..88da2f402faa8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java @@ -93,6 +93,10 @@ import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -109,6 +113,7 @@ * TODO IGNITE-6739: test with cache groups. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class CacheMvccTransactionsTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -118,6 +123,7 @@ public class CacheMvccTransactionsTest extends CacheMvccAbstractTest { /** * @throws Exception if failed. */ + @Test public void testEmptyTx() throws Exception { Ignite node = startGrids(2); @@ -137,6 +143,7 @@ public void testEmptyTx() throws Exception { /** * @throws Exception if failed. */ + @Test public void testImplicitTxOps() throws Exception { checkTxWithAllCaches(new CI1>() { @Override public void apply(IgniteCache cache) { @@ -201,6 +208,34 @@ public void testImplicitTxOps() throws Exception { val = (Integer)checkAndGet(false, cache, key, SCAN, GET); assertNull(val); + + val = cache.getAndPutIfAbsent(key, 1); + + assertNull(val); + + val = (Integer)checkAndGet(false, cache, key, SCAN, GET); + + assertEquals((Integer)1, val); + + val = cache.getAndPutIfAbsent(key, 1); + + assertEquals((Integer)1, val); + + val = (Integer)checkAndGet(false, cache, key, SCAN, GET); + + assertEquals((Integer)1, val); + + assertFalse(cache.remove(key, 2)); + + val = (Integer)checkAndGet(false, cache, key, SCAN, GET); + + assertEquals((Integer)1, val); + + cache.remove(key, 1); + + val = (Integer)checkAndGet(false, cache, key, SCAN, GET); + + assertNull(val); } } catch (Exception e) { @@ -213,6 +248,7 @@ public void testImplicitTxOps() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTx1() throws Exception { checkTxWithAllCaches(new CI1>() { @Override public void apply(IgniteCache cache) { @@ -253,6 +289,7 @@ public void testPessimisticTx1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTx2() throws Exception { checkTxWithAllCaches(new CI1>() { @Override public void apply(IgniteCache cache) { @@ -288,6 +325,7 @@ public void testPessimisticTx2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPessimisticTx3() throws Exception { checkTxWithAllCaches(new CI1>() { @Override public void apply(IgniteCache cache) { @@ -376,6 +414,7 @@ private void checkTxWithAllCaches(IgniteInClosure> /** * @throws Exception If failed. */ + @Test public void testWithCacheGroups() throws Exception { Ignite srv0 = startGrid(0); @@ -434,6 +473,7 @@ public void testWithCacheGroups() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheRecreate() throws Exception { cacheRecreate(null); } @@ -441,6 +481,7 @@ public void testCacheRecreate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActiveQueriesCleanup() throws Exception { activeQueriesCleanup(false); } @@ -448,6 +489,7 @@ public void testActiveQueriesCleanup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActiveQueriesCleanupTx() throws Exception { activeQueriesCleanup(true); } @@ -512,6 +554,7 @@ private void activeQueriesCleanup(final boolean tx) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxReadIsolationSimple() throws Exception { Ignite srv0 = startGrids(4); @@ -598,6 +641,7 @@ public void testTxReadIsolationSimple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGetAllSimple() throws Exception { Ignite node = startGrid(0); @@ -657,6 +701,7 @@ public void testPutGetAllSimple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemoveSimple() throws Exception { putRemoveSimple(false); } @@ -664,6 +709,7 @@ public void testPutRemoveSimple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemoveSimple_LargeKeys() throws Exception { putRemoveSimple(true); } @@ -798,6 +844,7 @@ private void checkValues(Map expVals, IgniteCache accounts) { /** * @throws Exception If failed */ + @Test public void testOperationsSequenceScanConsistency_SingleNode_SinglePartition() throws Exception { operationsSequenceConsistency(1, 0, 0, 1, SCAN); } @@ -1875,6 +1971,7 @@ public void testOperationsSequenceScanConsistency_SingleNode_SinglePartition() t /** * @throws Exception If failed */ + @Test public void testOperationsSequenceScanConsistency_SingleNode() throws Exception { operationsSequenceConsistency(1, 0, 0, 64, SCAN); } @@ -1882,6 +1979,7 @@ public void testOperationsSequenceScanConsistency_SingleNode() throws Exception /** * @throws Exception If failed */ + @Test public void testOperationsSequenceScanConsistency_ClientServer_Backups0() throws Exception { operationsSequenceConsistency(4, 2, 0, 64, SCAN); } @@ -1889,6 +1987,7 @@ public void testOperationsSequenceScanConsistency_ClientServer_Backups0() throws /** * @throws Exception If failed */ + @Test public void testOperationsSequenceScanConsistency_ClientServer_Backups1() throws Exception { operationsSequenceConsistency(4, 2, 1, 64, SCAN); } @@ -1896,6 +1995,7 @@ public void testOperationsSequenceScanConsistency_ClientServer_Backups1() throws /** * @throws Exception If failed */ + @Test public void testOperationsSequenceGetConsistency_SingleNode_SinglePartition() throws Exception { operationsSequenceConsistency(1, 0, 0, 1, GET); } @@ -1903,6 +2003,7 @@ public void testOperationsSequenceGetConsistency_SingleNode_SinglePartition() th /** * @throws Exception If failed */ + @Test public void testOperationsSequenceGetConsistency_SingleNode() throws Exception { operationsSequenceConsistency(1, 0, 0, 64, GET); } @@ -1910,6 +2011,7 @@ public void testOperationsSequenceGetConsistency_SingleNode() throws Exception { /** * @throws Exception If failed */ + @Test public void testOperationsSequenceGetConsistency_ClientServer_Backups0() throws Exception { operationsSequenceConsistency(4, 2, 0, 64, GET); } @@ -1917,6 +2019,7 @@ public void testOperationsSequenceGetConsistency_ClientServer_Backups0() throws /** * @throws Exception If failed */ + @Test public void testOperationsSequenceGetConsistency_ClientServer_Backups1() throws Exception { operationsSequenceConsistency(4, 2, 1, 64, GET); } @@ -2064,11 +2167,11 @@ private void operationsSequenceConsistency( } /** - * TODO IGNITE-5935 enable when recovery is implemented. - * * @throws Exception If failed. */ - public void _testNodesRestartNoHang() throws Exception { + @Ignore("https://issues.apache.org/jira/browse/IGNITE-5935") + @Test + public void testNodesRestartNoHang() throws Exception { final int srvs = 4; final int clients = 4; final int writers = 6; @@ -2183,6 +2286,7 @@ public void _testNodesRestartNoHang() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActiveQueryCleanupOnNodeFailure() throws Exception { testSpi = true; @@ -2230,6 +2334,7 @@ public void testActiveQueryCleanupOnNodeFailure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalanceSimple() throws Exception { Ignite srv0 = startGrid(0); @@ -2309,6 +2414,7 @@ public void testRebalanceSimple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalanceWithRemovedValuesSimple() throws Exception { Ignite node = startGrid(0); @@ -2361,6 +2467,7 @@ public void testRebalanceWithRemovedValuesSimple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxPrepareFailureSimplePessimisticTx() throws Exception { testSpi = true; @@ -2434,6 +2541,8 @@ public void testTxPrepareFailureSimplePessimisticTx() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testMvccCoordinatorChangeSimple() throws Exception { Ignite srv0 = startGrid(0); @@ -2518,6 +2627,7 @@ private void checkPutGet(List cacheNames) { /** * @throws Exception If failed. */ + @Test public void testMvccCoordinatorInfoConsistency() throws Exception { for (int i = 0; i < 4; i++) { startGrid(i); @@ -2550,6 +2660,7 @@ public void testMvccCoordinatorInfoConsistency() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMvccCoordinatorInfoConsistency_Persistence() throws Exception { persistence = true; @@ -2580,6 +2691,7 @@ private void checkCoordinatorsConsistency(@Nullable Integer expNodes) { /** * @throws Exception If failed. */ + @Test public void testGetVersionRequestFailover() throws Exception { final int NODES = 5; @@ -2670,6 +2782,7 @@ public void testGetVersionRequestFailover() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadWithStreamer() throws Exception { startGridsMultiThreaded(5); @@ -2703,6 +2816,7 @@ public void testLoadWithStreamer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdate_N_Objects_SingleNode_SinglePartition_Get() throws Exception { int[] nValues = {3, 5, 10}; @@ -2716,6 +2830,7 @@ public void testUpdate_N_Objects_SingleNode_SinglePartition_Get() throws Excepti /** * @throws Exception If failed. */ + @Test public void testUpdate_N_Objects_SingleNode_Get() throws Exception { int[] nValues = {3, 5, 10}; @@ -2729,6 +2844,7 @@ public void testUpdate_N_Objects_SingleNode_Get() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdate_N_Objects_SingleNode_SinglePartition_Scan() throws Exception { int[] nValues = {3, 5, 10}; @@ -2742,6 +2858,7 @@ public void testUpdate_N_Objects_SingleNode_SinglePartition_Scan() throws Except /** * @throws Exception If failed. */ + @Test public void testUpdate_N_Objects_SingleNode_Scan() throws Exception { int[] nValues = {3, 5, 10}; @@ -2755,6 +2872,8 @@ public void testUpdate_N_Objects_SingleNode_Scan() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10750") + @Test public void testUpdate_N_Objects_ClientServer_Backups2_Get() throws Exception { int[] nValues = {3, 5, 10}; @@ -2768,6 +2887,7 @@ public void testUpdate_N_Objects_ClientServer_Backups2_Get() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdate_N_Objects_ClientServer_Backups1_Scan() throws Exception { int[] nValues = {3, 5, 10}; @@ -2781,6 +2901,8 @@ public void testUpdate_N_Objects_ClientServer_Backups1_Scan() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testImplicitPartsScan_SingleNode_SinglePartition() throws Exception { doImplicitPartsScanTest(1, 0, 0, 1, 10_000); } @@ -2788,6 +2910,8 @@ public void testImplicitPartsScan_SingleNode_SinglePartition() throws Exception /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testImplicitPartsScan_SingleNode() throws Exception { doImplicitPartsScanTest(1, 0, 0, 64, 10_000); } @@ -2795,6 +2919,8 @@ public void testImplicitPartsScan_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testImplicitPartsScan_ClientServer_Backups0() throws Exception { doImplicitPartsScanTest(4, 2, 0, 64, 10_000); } @@ -2802,6 +2928,8 @@ public void testImplicitPartsScan_ClientServer_Backups0() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testImplicitPartsScan_ClientServer_Backups1() throws Exception { doImplicitPartsScanTest(4, 2, 1, 64, 10_000); } @@ -2809,6 +2937,8 @@ public void testImplicitPartsScan_ClientServer_Backups1() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testImplicitPartsScan_ClientServer_Backups2() throws Exception { doImplicitPartsScanTest(4, 2, 2, 64, 10_000); } @@ -3007,6 +3137,7 @@ private void doImplicitPartsScanTest( /** * @throws IgniteCheckedException If failed. */ + @Test public void testSize() throws Exception { Ignite node = startGrid(0); @@ -3170,6 +3301,7 @@ public void testSize() throws Exception { /** * @throws IgniteCheckedException If failed. */ + @Test public void testInternalApi() throws Exception { Ignite node = startGrid(0); @@ -3270,9 +3402,9 @@ public void testInternalApi() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7311") + @Test public void testExpiration() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-7311"); - final IgniteEx node = startGrid(0); IgniteCache cache = node.createCache(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, 64)); @@ -3325,9 +3457,9 @@ public void testExpiration() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7311") + @Test public void testChangeExpireTime() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-7311"); - final IgniteEx node = startGrid(0); IgniteCache cache = node.createCache(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, 64)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxFailoverTest.java index 7aae61352bfc8..31969092342d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxFailoverTest.java @@ -33,21 +33,21 @@ import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Check Tx state recovery from WAL. */ +@RunWith(JUnit4.class) public class CacheMvccTxFailoverTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryVmIpFinder FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { cleanPersistenceDir(); @@ -63,7 +63,6 @@ public class CacheMvccTxFailoverTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { return super.getConfiguration(igniteInstanceName) - .setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(FINDER)) .setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setMaxSize(100_000_000L) @@ -88,6 +87,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception If fails. */ + @Test public void testSingleNodeTxMissedRollback() throws Exception { checkSingleNodeRestart(true, false, true); } @@ -95,6 +95,7 @@ public void testSingleNodeTxMissedRollback() throws Exception { /** * @throws Exception If fails. */ + @Test public void testSingleNodeTxMissedRollbackRecoverFromWAL() throws Exception { checkSingleNodeRestart(true, true, true); } @@ -102,6 +103,7 @@ public void testSingleNodeTxMissedRollbackRecoverFromWAL() throws Exception { /** * @throws Exception If fails. */ + @Test public void testSingleNodeTxMissedCommit() throws Exception { checkSingleNodeRestart(false, false, true); } @@ -109,6 +111,7 @@ public void testSingleNodeTxMissedCommit() throws Exception { /** * @throws Exception If fails. */ + @Test public void testSingleNodeTxMissedCommitRecoverFromWAL() throws Exception { checkSingleNodeRestart(false, true, true); } @@ -116,6 +119,7 @@ public void testSingleNodeTxMissedCommitRecoverFromWAL() throws Exception { /** * @throws Exception If fails. */ + @Test public void testSingleNodeRollbackedTxRecoverFromWAL() throws Exception { checkSingleNodeRestart(true, true, false); } @@ -123,6 +127,7 @@ public void testSingleNodeRollbackedTxRecoverFromWAL() throws Exception { /** * @throws Exception If fails. */ + @Test public void testSingleNodeCommitedTxRecoverFromWAL() throws Exception { checkSingleNodeRestart(false, true, false); } @@ -208,9 +213,9 @@ public void checkSingleNodeRestart(boolean rollBack, boolean recoverFromWAL, boo /** * @throws Exception If fails. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10219") + @Test public void testLostRollbackOnBackup() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-10219"); - IgniteEx node = startGrid(0); startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccVacuumTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccVacuumTest.java index 0d1b20738cf56..29bb6e7a7f693 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccVacuumTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccVacuumTest.java @@ -25,12 +25,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.worker.GridWorker; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Vacuum test. */ +@RunWith(JUnit4.class) public class CacheMvccVacuumTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -40,6 +44,7 @@ public class CacheMvccVacuumTest extends CacheMvccAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStartStopVacuumInMemory() throws Exception { Ignite node0 = startGrid(0); Ignite node1 = startGrid(1); @@ -70,6 +75,7 @@ public void testStartStopVacuumInMemory() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStopVacuumPersistence() throws Exception { persistence = true; @@ -131,6 +137,7 @@ public void testStartStopVacuumPersistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVacuumNotStartedWithoutMvcc() throws Exception { IgniteConfiguration cfg = getConfiguration("grid1"); @@ -142,6 +149,7 @@ public void testVacuumNotStartedWithoutMvcc() throws Exception { /** * @throws Exception If failed. */ + @Test public void testVacuumNotStartedWithoutMvccPersistence() throws Exception { persistence = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCachePeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCachePeekTest.java new file mode 100644 index 0000000000000..7bcce6affd38e --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCachePeekTest.java @@ -0,0 +1,166 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.mvcc; + +import java.util.concurrent.CountDownLatch; +import java.util.stream.Stream; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CachePeekMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** */ +@RunWith(JUnit4.class) +public class MvccCachePeekTest extends CacheMvccAbstractTest { + /** */ + private interface ThrowingRunnable { + /** */ + void run() throws Exception; + } + + /** */ + private IgniteCache cache; + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return CacheMode.PARTITIONED; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + startGridsMultiThreaded(3); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testPeek() throws Exception { + doWithCache(this::checkPeekSerial); + doWithCache(this::checkPeekDoesNotSeeAbortedVersions); + doWithCache(this::checkPeekDoesNotSeeActiveVersions); + doWithCache(this::checkPeekOnheap); + doWithCache(this::checkPeekNearCache); + } + + /** */ + private void doWithCache(ThrowingRunnable action) throws Exception { + cache = grid(0).getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME) + .setAtomicityMode(TRANSACTIONAL_SNAPSHOT) + .setBackups(1) + .setCacheMode(cacheMode())); + + try { + action.run(); + } + finally { + cache.destroy(); + } + } + + /** */ + private void checkPeekSerial() throws Exception { + Stream.of(primaryKey(cache), backupKey(cache)).forEach(key -> { + assertNull(cache.localPeek(key)); + + cache.put(key, 1); + + assertEquals(1, cache.localPeek(key)); + + cache.put(key, 2); + + assertEquals(2, cache.localPeek(key)); + }); + } + + /** */ + private void checkPeekDoesNotSeeAbortedVersions() throws Exception { + Integer pk = primaryKey(cache); + + cache.put(pk, 1); + + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.put(pk, 2); + + tx.rollback(); + } + + assertEquals(1, cache.localPeek(pk)); + } + + /** */ + private void checkPeekDoesNotSeeActiveVersions() throws Exception { + Integer pk = primaryKey(cache); + + cache.put(pk, 1); + + CountDownLatch writeCompleted = new CountDownLatch(1); + CountDownLatch checkCompleted = new CountDownLatch(1); + + IgniteInternalFuture fut = GridTestUtils.runAsync(() -> { + try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.put(pk, 2); + + writeCompleted.countDown(); + checkCompleted.await(); + + tx.commit(); + } + + return null; + }); + + writeCompleted.await(); + + assertEquals(1, cache.localPeek(pk)); + + checkCompleted.countDown(); + + fut.get(); + } + + /** */ + private void checkPeekOnheap() throws Exception { + Stream.of(primaryKey(cache), backupKey(cache), nearKey(cache)).forEach(key -> { + cache.put(key, 1); + + assertNull(cache.localPeek(key, CachePeekMode.ONHEAP)); + }); + } + + /** */ + private void checkPeekNearCache() throws Exception { + Stream.of(primaryKey(cache), backupKey(cache), nearKey(cache)).forEach(key -> { + cache.put(key, 1); + + assertNull(cache.localPeek(key, CachePeekMode.NEAR)); + }); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUnsupportedTxModesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUnsupportedTxModesTest.java new file mode 100644 index 0000000000000..e1b3e41193796 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUnsupportedTxModesTest.java @@ -0,0 +1,377 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.mvcc; + +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheEntryProcessor; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionException; +import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static java.util.Collections.singleton; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; +import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE; + +/** */ +@RunWith(JUnit4.class) +public class MvccUnsupportedTxModesTest extends GridCommonAbstractTest { + /** */ + private static IgniteCache cache; + /** */ + private static final CacheEntryProcessor testEntryProcessor = (entry, arguments) -> null; + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + IgniteEx ign = startGrid(0); + + cache = ign.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME) + .setAtomicityMode(TRANSACTIONAL_SNAPSHOT)); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + + /** */ + @Test + public void testGetAndPutIfAbsent() { + checkOperation(() -> cache.getAndPutIfAbsent(1, 1)); + } + + /** */ + @Test + public void testGetAndPutIfAbsentAsync() { + checkOperation(() -> cache.getAndPutIfAbsentAsync(1, 1)); + } + + /** */ + @Test + public void testGet() { + checkOperation(() -> cache.get(1)); + } + + /** */ + @Test + public void testGetAsync() { + checkOperation(() -> cache.getAsync(1)); + } + + /** */ + @Test + public void testGetEntry() { + checkOperation(() -> cache.getEntry(1)); + } + + /** */ + @Test + public void testGetEntryAsync() { + checkOperation(() -> cache.getEntryAsync(1)); + } + + /** */ + @Test + public void testGetAll() { + checkOperation(() -> cache.getAll(singleton(1))); + } + + /** */ + @Test + public void testGetAllAsync() { + checkOperation(() -> cache.getAllAsync(singleton(1))); + } + + /** */ + @Test + public void testGetEntries() { + checkOperation(() -> cache.getEntries(singleton(1))); + } + + /** */ + @Test + public void testGetEntriesAsync() { + checkOperation(() -> cache.getEntriesAsync(singleton(1))); + } + + /** */ + @Test + public void testContainsKey() { + checkOperation(() -> cache.containsKey(1)); + } + + /** */ + @Test + public void testContainsKeyAsync() { + checkOperation(() -> cache.containsKeyAsync(1)); + } + + /** */ + @Test + public void testContainsKeys() { + checkOperation(() -> cache.containsKeys(singleton(1))); + } + + /** */ + @Test + public void testContainsKeysAsync() { + checkOperation(() -> cache.containsKeysAsync(singleton(1))); + } + + /** */ + @Test + public void testPut() { + checkOperation(() -> cache.put(1, 1)); + } + + /** */ + @Test + public void testPutAsync() { + checkOperation(() -> cache.putAsync(1, 1)); + } + + /** */ + @Test + public void testGetAndPut() { + checkOperation(() -> cache.getAndPut(1, 1)); + } + + /** */ + @Test + public void testGetAndPutAsync() { + checkOperation(() -> cache.getAndPutAsync(1, 1)); + } + + /** */ + @Test + public void testPutAll() { + checkOperation(() -> cache.putAll(ImmutableMap.of(1, 1))); + } + + /** */ + @Test + public void testPutAllAsync() { + checkOperation(() -> cache.putAllAsync(ImmutableMap.of(1, 1))); + } + + /** */ + @Test + public void testPutIfAbsent() { + checkOperation(() -> cache.putIfAbsent(1, 1)); + } + + /** */ + @Test + public void testPutIfAbsentAsync() { + checkOperation(() -> cache.putIfAbsentAsync(1, 1)); + } + + /** */ + @Test + public void testRemove1() { + checkOperation(() -> cache.remove(1)); + } + + /** */ + @Test + public void testRemoveAsync1() { + checkOperation(() -> cache.removeAsync(1)); + } + + /** */ + @Test + public void testRemove2() { + checkOperation(() -> cache.remove(1, 1)); + } + + /** */ + @Test + public void testRemoveAsync2() { + checkOperation(() -> cache.removeAsync(1, 1)); + } + + /** */ + @Test + public void testGetAndRemove() { + checkOperation(() -> cache.getAndRemove(1)); + } + + /** */ + @Test + public void testGetAndRemoveAsync() { + checkOperation(() -> cache.getAndRemoveAsync(1)); + } + + /** */ + @Test + public void testReplace1() { + checkOperation(() -> cache.replace(1, 1, 1)); + } + + /** */ + @Test + public void testReplaceAsync1() { + checkOperation(() -> cache.replaceAsync(1, 1, 1)); + } + + /** */ + @Test + public void testReplace2() { + checkOperation(() -> cache.replace(1, 1)); + } + + /** */ + @Test + public void testReplaceAsync2() { + checkOperation(() -> cache.replaceAsync(1, 1)); + } + + /** */ + @Test + public void testGetAndReplace() { + checkOperation(() -> cache.getAndReplace(1, 1)); + } + + /** */ + @Test + public void testGetAndReplaceAsync() { + checkOperation(() -> cache.getAndReplaceAsync(1, 1)); + } + + /** */ + @Test + public void testRemoveAll1() { + checkOperation(() -> cache.removeAll(singleton(1))); + } + + /** */ + @Test + public void testRemoveAllAsync1() { + checkOperation(() -> cache.removeAllAsync(singleton(1))); + } + + /** */ + @Test + public void testInvoke1() { + checkOperation(() -> cache.invoke(1, testEntryProcessor)); + } + + /** */ + @Test + public void testInvokeAsync1() { + checkOperation(() -> cache.invokeAsync(1, testEntryProcessor)); + } + + /** */ + @Test + public void testInvoke2() { + checkOperation(() -> cache.invoke(1, testEntryProcessor)); + } + + /** */ + @Test + public void testInvokeAsync2() { + checkOperation(() -> cache.invokeAsync(1, testEntryProcessor)); + } + + /** */ + @Test + public void testInvokeAll1() { + checkOperation(() -> cache.invokeAll(singleton(1), testEntryProcessor)); + } + + /** */ + @Test + public void testInvokeAllAsync1() { + checkOperation(() -> cache.invokeAllAsync(singleton(1), testEntryProcessor)); + } + + /** */ + @Test + public void testInvokeAll2() { + checkOperation(() -> cache.invokeAll(singleton(1), testEntryProcessor)); + } + + /** */ + @Test + public void testInvokeAllAsync2() { + checkOperation(() -> cache.invokeAllAsync(singleton(1), testEntryProcessor)); + } + + /** */ + @Test + public void testInvokeAll3() { + checkOperation(() -> cache.invokeAll(Collections.singletonMap(1, testEntryProcessor))); + } + + /** */ + @Test + public void testInvokeAllAsync3() { + checkOperation(() -> cache.invokeAllAsync(Collections.singletonMap(1, testEntryProcessor))); + } + + /** + * @param action Action. + */ + private void checkOperation(Runnable action) { + assertNotSupportedInTx(action, OPTIMISTIC, READ_COMMITTED); + assertNotSupportedInTx(action, OPTIMISTIC, REPEATABLE_READ); + assertNotSupportedInTx(action, OPTIMISTIC, SERIALIZABLE); + + assertSupportedInTx(action, PESSIMISTIC, READ_COMMITTED); + assertSupportedInTx(action, PESSIMISTIC, REPEATABLE_READ); + assertSupportedInTx(action, PESSIMISTIC, SERIALIZABLE); + } + + /** */ + private void assertNotSupportedInTx(Runnable action, TransactionConcurrency conc, TransactionIsolation iso) { + try (Transaction ignored = grid(0).transactions().txStart(conc, iso)) { + action.run(); + + fail("Action failure is expected."); + } + catch (TransactionException e) { + assertEquals("Only pessimistic transactions are supported when MVCC is enabled.", e.getMessage()); + } + } + + /** */ + private void assertSupportedInTx(Runnable action, TransactionConcurrency conc, TransactionIsolation iso) { + try (Transaction tx = grid(0).transactions().txStart(conc, iso)) { + action.run(); + + tx.commit(); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/CheckpointReadLockFailureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/CheckpointReadLockFailureTest.java new file mode 100644 index 0000000000000..b3fede0ad2827 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/CheckpointReadLockFailureTest.java @@ -0,0 +1,127 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignite; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.failure.AbstractFailureHandler; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.FailureType; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests critical failure handling on checkpoint read lock acquisition errors. + */ +public class CheckpointReadLockFailureTest extends GridCommonAbstractTest { + /** */ + private static final AbstractFailureHandler FAILURE_HND = new AbstractFailureHandler() { + @Override protected boolean handle(Ignite ignite, FailureContext failureCtx) { + if (failureCtx.type() != FailureType.SYSTEM_CRITICAL_OPERATION_TIMEOUT) + return true; + + if (hndLatch != null) + hndLatch.countDown(); + + return false; + } + }; + + /** */ + private static volatile CountDownLatch hndLatch; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + return super.getConfiguration(igniteInstanceName) + .setFailureHandler(FAILURE_HND) + .setDataStorageConfiguration(new DataStorageConfiguration() + .setDefaultDataRegionConfiguration(new DataRegionConfiguration() + .setPersistenceEnabled(true)) + .setCheckpointFrequency(Integer.MAX_VALUE) + .setCheckpointReadLockTimeout(1)); + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + Set ignoredFailureTypes = new HashSet<>(FAILURE_HND.getIgnoredFailureTypes()); + ignoredFailureTypes.remove(FailureType.SYSTEM_CRITICAL_OPERATION_TIMEOUT); + + FAILURE_HND.setIgnoredFailureTypes(ignoredFailureTypes); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + cleanPersistenceDir(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testFailureTypeOnTimeout() throws Exception { + hndLatch = new CountDownLatch(1); + + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)ig.context().cache().context().database(); + + IgniteInternalFuture acquireWriteLock = GridTestUtils.runAsync(() -> { + db.checkpointLock.writeLock().lock(); + + try { + doSleep(Long.MAX_VALUE); + } + finally { + db.checkpointLock.writeLock().unlock(); + } + }); + + GridTestUtils.waitForCondition(() -> db.checkpointLock.writeLock().isHeldByCurrentThread(), 5000); + + IgniteInternalFuture acquireReadLock = GridTestUtils.runAsync(() -> { + db.checkpointReadLock(); + db.checkpointReadUnlock(); + }); + + assertTrue(hndLatch.await(5, TimeUnit.SECONDS)); + + acquireWriteLock.cancel(); + + acquireReadLock.get(5, TimeUnit.SECONDS); + + GridTestUtils.waitForCondition(acquireWriteLock::isCancelled, 5000); + + stopGrid(0); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteBaselineAffinityTopologyActivationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteBaselineAffinityTopologyActivationTest.java index f44e7929ec762..273a3b3d949e4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteBaselineAffinityTopologyActivationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteBaselineAffinityTopologyActivationTest.java @@ -54,12 +54,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public class IgniteBaselineAffinityTopologyActivationTest extends GridCommonAbstractTest { /** */ private String consId; @@ -117,6 +121,7 @@ public class IgniteBaselineAffinityTopologyActivationTest extends GridCommonAbst * (it is the node that once wasn't presented in branchingHistory but hasn't participated in any branching point) * joins the cluster after restart, cluster gets activated. */ + @Test public void testAutoActivationWithCompatibleOldNode() throws Exception { startGridWithConsistentId("A"); startGridWithConsistentId("B"); @@ -168,6 +173,7 @@ public void testAutoActivationWithCompatibleOldNode() throws Exception { * IgniteCluster::setBaselineTopology(long topVer) should throw an exception * when online node from current BaselineTopology is not presented in topology version. */ + @Test public void testBltChangeTopVerRemoveOnlineNodeFails() throws Exception { Ignite ignite = startGridWithConsistentId("A"); @@ -198,6 +204,7 @@ public void testBltChangeTopVerRemoveOnlineNodeFails() throws Exception { /** * Verifies that online nodes cannot be removed from BaselineTopology (this may change in future). */ + @Test public void testOnlineNodesCannotBeRemovedFromBaselineTopology() throws Exception { Ignite nodeA = startGridWithConsistentId("A"); Ignite nodeB = startGridWithConsistentId("B"); @@ -224,6 +231,7 @@ public void testOnlineNodesCannotBeRemovedFromBaselineTopology() throws Exceptio /** * */ + @Test public void testNodeFailsToJoinWithIncompatiblePreviousBaselineTopology() throws Exception { startGridWithConsistentId("A"); startGridWithConsistentId("B"); @@ -272,6 +280,7 @@ public void testNodeFailsToJoinWithIncompatiblePreviousBaselineTopology() throws * Verifies scenario when parts of grid were activated independently they are not allowed to join * into the same grid again (due to risks of incompatible data modifications). */ + @Test public void testIncompatibleBltNodeIsProhibitedToJoinCluster() throws Exception { startGridWithConsistentId("A"); startGridWithConsistentId("B"); @@ -315,6 +324,7 @@ public void testIncompatibleBltNodeIsProhibitedToJoinCluster() throws Exception /** * Test verifies that node with out-of-data but still compatible Baseline Topology is allowed to join the cluster. */ + @Test public void testNodeWithOldBltIsAllowedToJoinCluster() throws Exception { final long expectedHash1 = (long)"A".hashCode() + "B".hashCode() + "C".hashCode(); @@ -376,6 +386,7 @@ public void testNodeWithOldBltIsAllowedToJoinCluster() throws Exception { * * @throws Exception If failed. */ + @Test public void testNodeJoinsDuringPartitionMapExchange() throws Exception { startGridWithConsistentId("A"); startGridWithConsistentId("B"); @@ -477,6 +488,7 @@ private void checkBaselineTopologyOnNode( * * @throws Exception If failed. */ + @Test public void testNodeWithBltIsNotAllowedToJoinClusterDuringFirstActivation() throws Exception { Ignite nodeC = startGridWithConsistentId("C"); @@ -528,6 +540,7 @@ public void testNodeWithBltIsNotAllowedToJoinClusterDuringFirstActivation() thro * Verifies that when new node outside of baseline topology joins active cluster with BLT already set * it receives BLT from the cluster and stores it locally. */ + @Test public void testNewNodeJoinsToActiveCluster() throws Exception { Ignite nodeA = startGridWithConsistentId("A"); Ignite nodeB = startGridWithConsistentId("B"); @@ -561,6 +574,7 @@ public void testNewNodeJoinsToActiveCluster() throws Exception { /** * */ + @Test public void testRemoveNodeFromBaselineTopology() throws Exception { final long expectedActivationHash = (long)"A".hashCode() + "C".hashCode(); @@ -615,6 +629,7 @@ public void testRemoveNodeFromBaselineTopology() throws Exception { /** * */ + @Test public void testAddNodeToBaselineTopology() throws Exception { final long expectedActivationHash = (long)"A".hashCode() + "B".hashCode() + "C".hashCode() + "D".hashCode(); @@ -646,6 +661,7 @@ public void testAddNodeToBaselineTopology() throws Exception { /** * Verifies that baseline topology is removed successfully through baseline changing API. */ + @Test public void testRemoveBaselineTopology() throws Exception { BaselineTopologyVerifier verifier = new BaselineTopologyVerifier() { @Override public void verify(BaselineTopology blt) { @@ -705,6 +721,7 @@ private Ignite startGridWithConsistentId(String consId) throws Exception { * Verifies that when new node joins already active cluster and new activation request is issued, * no changes to BaselineTopology branching history happen. */ + @Test public void testActivationHashIsNotUpdatedOnMultipleActivationRequests() throws Exception { final long expectedActivationHash = (long)"A".hashCode(); @@ -731,6 +748,7 @@ public void testActivationHashIsNotUpdatedOnMultipleActivationRequests() throws * Verifies that grid is autoactivated when full BaselineTopology is preset even on one node * and then all other nodes from BaselineTopology are started. */ + @Test public void testAutoActivationWithBaselineTopologyPreset() throws Exception { Ignite ig = startGridWithConsistentId("A"); @@ -771,6 +789,7 @@ private BaselineNode createBaselineNodeWithConsId(String consId) { } /** */ + @Test public void testAutoActivationSimple() throws Exception { startGrids(3); @@ -804,6 +823,7 @@ public void testAutoActivationSimple() throws Exception { /** * */ + @Test public void testNoAutoActivationOnJoinNewNodeToInactiveCluster() throws Exception { startGrids(2); @@ -829,6 +849,7 @@ public void testNoAutoActivationOnJoinNewNodeToInactiveCluster() throws Exceptio /** * Verifies that neither BaselineTopology nor BaselineTopologyHistory are changed when cluster is deactivated. */ + @Test public void testBaselineTopologyRemainsTheSameOnClusterDeactivation() throws Exception { startGrids(2); @@ -858,6 +879,7 @@ public void testBaselineTopologyRemainsTheSameOnClusterDeactivation() throws Exc /** * */ + @Test public void testBaselineHistorySyncWithNewNode() throws Exception { final long expectedBranchingHash = "A".hashCode() + "B".hashCode() + "C".hashCode(); @@ -899,6 +921,7 @@ public void testBaselineHistorySyncWithNewNode() throws Exception { /** * */ + @Test public void testBaselineHistorySyncWithOldNodeWithCompatibleHistory() throws Exception { final long expectedBranchingHash0 = "A".hashCode() + "B".hashCode() + "C".hashCode(); @@ -955,6 +978,7 @@ public void testBaselineHistorySyncWithOldNodeWithCompatibleHistory() throws Exc /** * @throws Exception if failed. */ + @Test public void testBaselineNotDeletedOnDeactivation() throws Exception { Ignite nodeA = startGridWithConsistentId("A"); startGridWithConsistentId("B"); @@ -990,6 +1014,7 @@ public void testBaselineNotDeletedOnDeactivation() throws Exception { /** * */ + @Test public void testNodeWithBltIsProhibitedToJoinNewCluster() throws Exception { BaselineTopologyVerifier nullVerifier = new BaselineTopologyVerifier() { @Override public void verify(BaselineTopology blt) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteDataStorageMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteDataStorageMetricsSelfTest.java index 4db1de90d1f4f..8472d04408310 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteDataStorageMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteDataStorageMetricsSelfTest.java @@ -35,11 +35,11 @@ import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.PAX; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -48,10 +48,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteDataStorageMetricsSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String GROUP1 = "grp1"; @@ -92,8 +90,6 @@ public class IgniteDataStorageMetricsSelfTest extends GridCommonAbstractTest { cfg.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(false)); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setCacheConfiguration(cacheConfiguration(GROUP1, "cache", PARTITIONED, ATOMIC, 1, null), cacheConfiguration(null, "cache-np", PARTITIONED, ATOMIC, 1, "no-persistence")); @@ -141,6 +137,7 @@ private CacheConfiguration cacheConfiguration( /** * @throws Exception if failed. */ + @Test public void testPersistenceMetrics() throws Exception { final IgniteEx ig = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinaryMetadataOnClusterRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinaryMetadataOnClusterRestartTest.java index 28c1e9b2a5838..edcd99a334049 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinaryMetadataOnClusterRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinaryMetadataOnClusterRestartTest.java @@ -44,10 +44,14 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsBinaryMetadataOnClusterRestartTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "cache1"; @@ -74,6 +78,8 @@ public class IgnitePdsBinaryMetadataOnClusterRestartTest extends GridCommonAbstr @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); + cfg.setConsistentId(gridName); + if (customWorkSubDir != null) cfg.setWorkDirectory(Paths.get(U.defaultWorkDirectory(), customWorkSubDir).toString()); @@ -116,6 +122,7 @@ public class IgnitePdsBinaryMetadataOnClusterRestartTest extends GridCommonAbstr /** * @see IGNITE-7258 refer to the following JIRA for more context about the problem verified by the test. */ + @Test public void testUpdatedBinaryMetadataIsPreservedOnJoinToOldCoordinator() throws Exception { Ignite ignite0 = startGridInASeparateWorkDir("A"); Ignite ignite1 = startGridInASeparateWorkDir("B"); @@ -169,6 +176,7 @@ public void testUpdatedBinaryMetadataIsPreservedOnJoinToOldCoordinator() throws /** * @see IGNITE-7258 refer to the following JIRA for more context about the problem verified by the test. */ + @Test public void testNewBinaryMetadataIsWrittenOnOldCoordinator() throws Exception { Ignite ignite0 = startGridInASeparateWorkDir("A"); Ignite ignite1 = startGridInASeparateWorkDir("B"); @@ -223,6 +231,7 @@ public void testNewBinaryMetadataIsWrittenOnOldCoordinator() throws Exception { * * @see IGNITE-7258 refer to the following JIRA for more context about the problem verified by the test. */ + @Test public void testNewBinaryMetadataIsPropagatedToAllOutOfDataNodes() throws Exception { Ignite igniteA = startGridInASeparateWorkDir("A"); startGridInASeparateWorkDir("B"); @@ -290,6 +299,7 @@ private String binaryTypeName(BinaryObject bObj) { * * @see IGNITE-7258 refer to the following JIRA for more context about the problem verified by the test. */ + @Test public void testNodeWithIncompatibleMetadataIsProhibitedToJoinTheCluster() throws Exception { final String decimalFieldName = "decField"; @@ -358,8 +368,8 @@ private void copyIncompatibleBinaryMetadata(String fromWorkDir, ) throws Exception { String workDir = U.defaultWorkDirectory(); - Path fromFile = Paths.get(workDir, fromWorkDir, "binary_meta", "node00-" + fromConsId, fileName); - Path toFile = Paths.get(workDir, toWorkDir, "binary_meta", "node00-" + toConsId, fileName); + Path fromFile = Paths.get(workDir, fromWorkDir, "binary_meta", fromConsId, fileName); + Path toFile = Paths.get(workDir, toWorkDir, "binary_meta", toConsId, fileName); Files.copy(fromFile, toFile, StandardCopyOption.REPLACE_EXISTING); } @@ -368,6 +378,7 @@ private void copyIncompatibleBinaryMetadata(String fromWorkDir, * Test verifies that binary metadata from regular java classes is saved and restored correctly * on cluster restart. */ + @Test public void testStaticMetadataIsRestoredOnRestart() throws Exception { clientMode = false; @@ -443,6 +454,7 @@ private void examineDynamicMetadata(int nodesCount, BinaryObjectExaminer... exam * Test verifies that metadata for binary types built with BinaryObjectBuilder is saved and updated correctly * on cluster restart. */ + @Test public void testDynamicMetadataIsRestoredOnRestart() throws Exception { clientMode = false; //1: start two nodes, add single BinaryObject @@ -509,6 +521,7 @@ public void testDynamicMetadataIsRestoredOnRestart() throws Exception { /** * */ + @Test public void testBinaryEnumMetadataIsRestoredOnRestart() throws Exception { clientMode = false; @@ -550,6 +563,7 @@ public void testBinaryEnumMetadataIsRestoredOnRestart() throws Exception { /** * Test verifies that metadata is saved, stored and delivered to client nodes correctly. */ + @Test public void testMixedMetadataIsRestoredOnRestart() throws Exception { clientMode = false; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinarySortObjectFieldsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinarySortObjectFieldsTest.java index 70a0203b5ebb2..78998be885c62 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinarySortObjectFieldsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinarySortObjectFieldsTest.java @@ -23,15 +23,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.PersistentStoreConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsBinarySortObjectFieldsTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "ignitePdsBinarySortObjectFieldsTestCache"; @@ -81,9 +82,6 @@ public void setVal(Long val) { } } - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { cleanPersistenceDir(); @@ -102,8 +100,6 @@ public void setVal(Long val) { cfg.setConsistentId(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration()); return cfg; @@ -121,6 +117,7 @@ public void setVal(Long val) { /** * @throws Exception if failed. */ + @Test public void testGivenCacheWithPojoValueAndPds_WhenPut_ThenNoHangup() throws Exception { System.setProperty("IGNITE_BINARY_SORT_OBJECT_FIELDS", "true"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheAssignmentNodeRestartsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheAssignmentNodeRestartsTest.java index 032b422a60bc8..dbb3dcd545e5c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheAssignmentNodeRestartsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheAssignmentNodeRestartsTest.java @@ -41,11 +41,13 @@ import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -55,10 +57,8 @@ /** * The test validates assignment after nodes restart with enabled persistence. */ +@RunWith(JUnit4.class) public class IgnitePdsCacheAssignmentNodeRestartsTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -75,8 +75,6 @@ public class IgnitePdsCacheAssignmentNodeRestartsTest extends GridCommonAbstract .setWalMode(WALMode.LOG_ONLY) ); - ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder); - return cfg; } @@ -127,8 +125,11 @@ private CacheConfiguration cacheConfiguration(String name, /** * @throws Exception If failed. */ + @Test public void testAssignmentAfterRestarts() throws Exception { try { + Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10582", MvccFeatureChecker.forcedMvcc()); + System.setProperty(IGNITE_PDS_CHECKPOINT_TEST_SKIP_SYNC, "true"); final int gridsCnt = 5; @@ -258,4 +259,4 @@ private void checkAffinity() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheConfigurationFileConsistencyCheckTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheConfigurationFileConsistencyCheckTest.java index 74a3950239195..d3b8a81797eaa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheConfigurationFileConsistencyCheckTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheConfigurationFileConsistencyCheckTest.java @@ -39,11 +39,11 @@ import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DATA_FILENAME; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DATA_TMP_FILENAME; @@ -51,10 +51,8 @@ /** * Tests that ignite can start when caches' configurations with same name in different groups stored. */ +@RunWith(JUnit4.class) public class IgnitePdsCacheConfigurationFileConsistencyCheckTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int CACHES = 4; @@ -71,9 +69,7 @@ public class IgnitePdsCacheConfigurationFileConsistencyCheckTest extends GridCom @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - return cfg.setDiscoverySpi(new TcpDiscoverySpi() - .setIpFinder(IP_FINDER)) - .setDataStorageConfiguration(new DataStorageConfiguration() + return cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setMaxSize(200 * 1024 * 1024) .setPersistenceEnabled(true))); @@ -102,6 +98,7 @@ public class IgnitePdsCacheConfigurationFileConsistencyCheckTest extends GridCom * * @throws Exception If fails. */ + @Test public void testStartDuplicatedCacheConfigurations() throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(NODES); @@ -129,6 +126,7 @@ public void testStartDuplicatedCacheConfigurations() throws Exception { * * @throws Exception If failed. */ + @Test public void testTmpCacheConfigurationsDelete() throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(NODES); @@ -168,6 +166,7 @@ public void testTmpCacheConfigurationsDelete() throws Exception { * * @throws Exception If failed. */ + @Test public void testCorruptedCacheConfigurationsValidation() throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(NODES); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest.java index 279d3c8c4e620..801f15eaa6402 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest.java @@ -27,18 +27,16 @@ import org.apache.ignite.failure.StopNodeFailureHandler; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -46,9 +44,7 @@ public class IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest extends GridComm if ("client".equals(igniteInstanceName)) cfg.setClientMode(true).setFailureHandler(new StopNodeFailureHandler()); - return cfg.setDiscoverySpi(new TcpDiscoverySpi() - .setIpFinder(IP_FINDER)) - .setDataStorageConfiguration(new DataStorageConfiguration() + return cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setPersistenceEnabled(true))); } @@ -71,6 +67,7 @@ public class IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest extends GridComm * Tests that joining node metadata correctly handled on client. * @throws Exception If fails. */ + @Test public void testJoiningNodeBinaryMetaOnClient() throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java index 389a7feacaaff..dbbf09ffe1c73 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheRebalancingAbstractTest.java @@ -54,22 +54,20 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync; /** * Test for rebalancing and persistence integration. */ +@RunWith(JUnit4.class) public abstract class IgnitePdsCacheRebalancingAbstractTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Default cache. */ private static final String CACHE = "cache"; @@ -150,11 +148,6 @@ public abstract class IgnitePdsCacheRebalancingAbstractTest extends GridCommonAb cfg.setDataStorageConfiguration(dsCfg); - cfg.setDiscoverySpi( - new TcpDiscoverySpi() - .setIpFinder(IP_FINDER) - ); - return cfg; } @@ -211,6 +204,7 @@ protected long checkpointFrequency() { * * @throws Exception If fails. */ + @Test public void testRebalancingOnRestart() throws Exception { Ignite ignite0 = startGrid(0); @@ -262,6 +256,7 @@ public void testRebalancingOnRestart() throws Exception { * * @throws Exception If fails. */ + @Test public void testRebalancingOnRestartAfterCheckpoint() throws Exception { IgniteEx ignite0 = startGrid(0); @@ -323,6 +318,7 @@ public void testRebalancingOnRestartAfterCheckpoint() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopologyChangesWithConstantLoad() throws Exception { final long timeOut = U.currentTimeMillis() + 5 * 60 * 1000; @@ -520,6 +516,7 @@ else if (nodesCnt.get() >= maxNodesCnt) /** * @throws Exception If failed. */ + @Test public void testForceRebalance() throws Exception { testForceRebalance(CACHE); } @@ -527,6 +524,7 @@ public void testForceRebalance() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForceRebalanceClientTopology() throws Exception { filteredCacheEnabled = true; @@ -582,6 +580,7 @@ private void testForceRebalance(String cacheName) throws Exception { /** * @throws Exception If failed */ + @Test public void testPartitionCounterConsistencyOnUnstableTopology() throws Exception { final Ignite ig = startGrids(4); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheStartStopWithFreqCheckpointTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheStartStopWithFreqCheckpointTest.java new file mode 100644 index 0000000000000..b4dae392d3011 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCacheStartStopWithFreqCheckpointTest.java @@ -0,0 +1,184 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheRebalanceMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * + */ +@RunWith(JUnit4.class) +public class IgnitePdsCacheStartStopWithFreqCheckpointTest extends GridCommonAbstractTest { + /** Caches. */ + private static final int CACHES = 10; + + /** Cache name. */ + private static final String CACHE_NAME = "test"; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setConsistentId(igniteInstanceName); + + DataStorageConfiguration dsCfg = new DataStorageConfiguration() + .setWalMode(WALMode.LOG_ONLY) + .setCheckpointFrequency(1000) + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setMaxSize(512 * 1024 * 1024) + .setPersistenceEnabled(true) + ); + + cfg.setDataStorageConfiguration(dsCfg); + + CacheConfiguration[] ccfgs = new CacheConfiguration[CACHES]; + + for (int i = 0; i < ccfgs.length; i++) + ccfgs[i] = cacheConfiguration(i); + + cfg.setCacheConfiguration(ccfgs); + + return cfg; + } + + /** {@inheritDoc} */ + private CacheConfiguration cacheConfiguration(int cacheIdx) { + return new CacheConfiguration(CACHE_NAME + cacheIdx) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setCacheMode(CacheMode.REPLICATED) + .setBackups(0) + .setRebalanceMode(CacheRebalanceMode.NONE); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** + * Test checkpoint deadlock during caches start/stop process and frequent checkpoints is set. + * + * @throws Exception If failed. + */ + @Test + public void testCheckpointDeadlock() throws Exception { + IgniteEx crd = startGrid(0); + + crd.cluster().active(true); + + for (int cacheId = 0; cacheId < CACHES; cacheId++) { + IgniteCache cache = crd.getOrCreateCache(CACHE_NAME + cacheId); + + for (int key = 0; key < 4096; key++) + cache.put(key, key); + } + + forceCheckpoint(); + + final AtomicBoolean stopFlag = new AtomicBoolean(); + + IgniteInternalFuture cacheStartStopFut = GridTestUtils.runAsync(() -> { + while (!stopFlag.get()) { + List cacheNames = new ArrayList<>(); + for (int i = 0; i < CACHES / 2; i++) + cacheNames.add(CACHE_NAME + i); + + try { + // Stop cache without destroy. + crd.context().cache().dynamicDestroyCaches(cacheNames, false,false).get(); + } + catch (IgniteCheckedException e) { + throw new IgniteException("Failed to destroy cache", e); + } + + List cachesToStart = new ArrayList<>(); + for (int i = 0; i < CACHES / 2; i++) + cachesToStart.add(cacheConfiguration(i)); + + crd.getOrCreateCaches(cachesToStart); + } + }); + + U.sleep(60_000); + + log.info("Stopping caches start/stop process."); + + stopFlag.set(true); + + try { + cacheStartStopFut.get(30, TimeUnit.SECONDS); + } + catch (IgniteFutureTimeoutCheckedException e) { + U.dumpThreads(log); + + log.warning("Caches start/stop future hangs. Interrupting checkpointer..."); + + interruptCheckpointer(crd); + + // Should succeed. + cacheStartStopFut.get(); + + Assert.assertTrue("Checkpoint and exchange is probably in deadlock (see thread dump above for details).", false); + } + } + + /** + * Interrupts checkpoint thread for given node. + * + * @param node Node. + */ + private void interruptCheckpointer(IgniteEx node) { + GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) node.context().cache().context().database(); + + dbMgr.checkpointerThread().interrupt(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTest.java index 25d54abb345e3..51ff1b79b6b40 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTest.java @@ -42,11 +42,16 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Cause by https://issues.apache.org/jira/browse/IGNITE-7278 */ +@RunWith(JUnit4.class) public class IgnitePdsContinuousRestartTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 4; @@ -72,7 +77,7 @@ public IgnitePdsContinuousRestartTest() { /** * @param cancel Cancel. */ - public IgnitePdsContinuousRestartTest(boolean cancel) { + protected IgnitePdsContinuousRestartTest(boolean cancel) { this.cancel = cancel; } @@ -112,6 +117,14 @@ public IgnitePdsContinuousRestartTest(boolean cancel) { cleanPersistenceDir(); } + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10561"); + + super.beforeTest(); + } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -122,6 +135,7 @@ public IgnitePdsContinuousRestartTest(boolean cancel) { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_1000_500_1_1() throws Exception { checkRebalancingDuringLoad(1000, 500, 1, 1); } @@ -129,6 +143,7 @@ public void testRebalancingDuringLoad_1000_500_1_1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_8000_500_1_1() throws Exception { checkRebalancingDuringLoad(8000, 500, 1, 1); } @@ -136,6 +151,7 @@ public void testRebalancingDuringLoad_8000_500_1_1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_1000_20000_1_1() throws Exception { checkRebalancingDuringLoad(1000, 20000, 1, 1); } @@ -143,6 +159,7 @@ public void testRebalancingDuringLoad_1000_20000_1_1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_8000_8000_1_1() throws Exception { checkRebalancingDuringLoad(8000, 8000, 1, 1); } @@ -150,6 +167,7 @@ public void testRebalancingDuringLoad_8000_8000_1_1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_1000_500_8_1() throws Exception { checkRebalancingDuringLoad(1000, 500, 8, 1); } @@ -157,6 +175,7 @@ public void testRebalancingDuringLoad_1000_500_8_1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_8000_500_8_1() throws Exception { checkRebalancingDuringLoad(8000, 500, 8, 1); } @@ -164,6 +183,7 @@ public void testRebalancingDuringLoad_8000_500_8_1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_1000_20000_8_1() throws Exception { checkRebalancingDuringLoad(1000, 20000, 8, 1); } @@ -171,6 +191,7 @@ public void testRebalancingDuringLoad_1000_20000_8_1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_8000_8000_8_1() throws Exception { checkRebalancingDuringLoad(8000, 8000, 8, 1); } @@ -178,6 +199,7 @@ public void testRebalancingDuringLoad_8000_8000_8_1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_1000_500_8_16() throws Exception { checkRebalancingDuringLoad(1000, 500, 8, 16); } @@ -185,6 +207,7 @@ public void testRebalancingDuringLoad_1000_500_8_16() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_8000_500_8_16() throws Exception { checkRebalancingDuringLoad(8000, 500, 8, 16); } @@ -192,6 +215,7 @@ public void testRebalancingDuringLoad_8000_500_8_16() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_1000_20000_8_16() throws Exception { checkRebalancingDuringLoad(1000, 20000, 8, 16); } @@ -199,6 +223,7 @@ public void testRebalancingDuringLoad_1000_20000_8_16() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingDuringLoad_8000_8000_8_16() throws Exception { checkRebalancingDuringLoad(8000, 8000, 8, 16); } @@ -206,14 +231,18 @@ public void testRebalancingDuringLoad_8000_8000_8_16() throws Exception { /** * @throws Exception if failed. */ - public void testRebalncingDuringLoad_10_10_1_1() throws Exception { + @Test + public void testRebalancingDuringLoad_10_10_1_1() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10583"); checkRebalancingDuringLoad(10, 10, 1, 1); } /** * @throws Exception if failed. */ - public void testRebalncingDuringLoad_10_500_8_16() throws Exception { + @Test + public void testRebalancingDuringLoad_10_500_8_16() throws Exception { checkRebalancingDuringLoad(10, 500, 8, 16); } @@ -258,7 +287,16 @@ private void checkRebalancingDuringLoad( map.put(key, new Person("fn" + key, "ln" + key)); } - cache.putAll(map); + while (true) { + try { + cache.putAll(map); + + break; + } + catch (Exception e) { + MvccFeatureChecker.assertMvccWriteConflict(e); + } + } } return null; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTestWithExpiryPolicy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTestWithExpiryPolicy.java index d5b3f5527a6f0..0fa8144d11b01 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTestWithExpiryPolicy.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTestWithExpiryPolicy.java @@ -25,17 +25,12 @@ import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; /** * Cause by https://issues.apache.org/jira/browse/IGNITE-5879 */ public class IgnitePdsContinuousRestartTestWithExpiryPolicy extends IgnitePdsContinuousRestartTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * Default constructor. */ @@ -47,9 +42,6 @@ public IgnitePdsContinuousRestartTestWithExpiryPolicy() { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - discoverySpi.setIpFinder(ipFinder); - CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setName(CACHE_NAME); @@ -64,4 +56,11 @@ public IgnitePdsContinuousRestartTestWithExpiryPolicy() { return cfg; } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + + super.beforeTest(); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes.java index 110e67708af40..13f1a19f4f53a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes.java @@ -22,17 +22,11 @@ import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; /** * Adding shared group and indexes to testing. It would impact how we evict partitions. */ public class IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes extends IgnitePdsContinuousRestartTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Cache 2 singleton group name. */ public static final String CACHE_GROUP_NAME = "Group2"; @@ -47,9 +41,6 @@ public IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes() { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - discoverySpi.setIpFinder(ipFinder); - CacheConfiguration ccfg2 = new CacheConfiguration(); ccfg2.setName(CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCorruptedIndexTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCorruptedIndexTest.java index 14d0fb6d4dfb7..6f3c9e58a6b37 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCorruptedIndexTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCorruptedIndexTest.java @@ -48,10 +48,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test to reproduce corrupted indexes problem after partition file eviction and truncation. */ +@RunWith(JUnit4.class) public class IgnitePdsCorruptedIndexTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE = "cache"; @@ -123,6 +127,7 @@ public class IgnitePdsCorruptedIndexTest extends GridCommonAbstractTest { /** * */ + @Test public void testCorruption() throws Exception { final String corruptedNodeName = "corrupted"; @@ -317,16 +322,6 @@ private static boolean isPartitionFile(File file) { return file.getName().contains("part") && file.getName().endsWith("bin"); } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - FileIO delegate = delegateFactory.create(file); - - if (isPartitionFile(file)) - return new HaltOnTruncateFileIO(delegate, file); - - return delegate; - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { FileIO delegate = delegateFactory.create(file, modes); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCorruptedStoreTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCorruptedStoreTest.java index 059b5eefdcf73..25924102d88cf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCorruptedStoreTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsCorruptedStoreTest.java @@ -37,6 +37,7 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.pagemem.PageIdAllocator; import org.apache.ignite.internal.pagemem.PageIdUtils; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; @@ -53,10 +54,10 @@ import org.apache.ignite.lang.IgniteBiClosure; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; import static org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_SKIP_CRC; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR; import static org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_ID; @@ -64,6 +65,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgnitePdsCorruptedStoreTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME1 = "cache1"; @@ -150,6 +152,7 @@ private CacheConfiguration cacheConfiguration(String name) { /** * @throws Exception If test failed. */ + @Test public void testNodeInvalidatedWhenPersistenceIsCorrupted() throws Exception { Ignite ignite = startGrid(0); @@ -180,6 +183,9 @@ public void testNodeInvalidatedWhenPersistenceIsCorrupted() throws Exception { startGrid(0); } catch (IgniteCheckedException ex) { + if (X.hasCause(ex, StorageException.class, IOException.class)) + return; // Success; + throw ex; } @@ -191,6 +197,7 @@ public void testNodeInvalidatedWhenPersistenceIsCorrupted() throws Exception { * * @throws Exception In case of fail */ + @Test public void testWrongPageCRC() throws Exception { System.setProperty(IGNITE_PDS_SKIP_CRC, "true"); @@ -224,6 +231,7 @@ public void testWrongPageCRC() throws Exception { /** * Test node invalidation when meta storage is corrupted. */ + @Test public void testMetaStorageCorruption() throws Exception { IgniteEx ignite = startGrid(0); @@ -231,7 +239,7 @@ public void testMetaStorageCorruption() throws Exception { MetaStorage metaStorage = ignite.context().cache().context().database().metaStorage(); - corruptTreeRoot(ignite, (PageMemoryEx)metaStorage.pageMemory(), METASTORAGE_CACHE_ID, 0); + corruptTreeRoot(ignite, (PageMemoryEx)metaStorage.pageMemory(), METASTORAGE_CACHE_ID, PageIdAllocator.METASTORE_PARTITION); stopGrid(0); @@ -250,6 +258,7 @@ public void testMetaStorageCorruption() throws Exception { /** * Test node invalidation when cache meta is corrupted. */ + @Test public void testCacheMetaCorruption() throws Exception { IgniteEx ignite = startGrid(0); @@ -324,6 +333,7 @@ private void corruptTreeRoot(IgniteEx ignite, PageMemoryEx pageMem, int grpId, i /** * Test node invalidation when meta store is read only. */ + @Test public void testReadOnlyMetaStore() throws Exception { IgniteEx ignite0 = startGrid(0); @@ -368,6 +378,7 @@ public void testReadOnlyMetaStore() throws Exception { /** * Test node invalidation due to checkpoint error. */ + @Test public void testCheckpointFailure() throws Exception { IgniteEx ignite = startGrid(0); @@ -458,11 +469,6 @@ private static class FailingFileIOFactory implements FileIOFactory { /** Create FileIO closure. */ private volatile IgniteBiClosure createClo; - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, READ, WRITE); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... openOption) throws IOException { FileIO fileIO = null; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheAbstractTest.java index 434007ece5f8e..2fe9ca74b5cd4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheAbstractTest.java @@ -29,18 +29,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** * Base class for {@link IgnitePdsDestroyCacheTest} and {@link IgnitePdsDestroyCacheWithoutCheckpointsTest} */ public abstract class IgnitePdsDestroyCacheAbstractTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ protected static final int CACHES = 3; @@ -54,9 +48,7 @@ public abstract class IgnitePdsDestroyCacheAbstractTest extends GridCommonAbstra @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - return cfg.setDiscoverySpi(new TcpDiscoverySpi() - .setIpFinder(IP_FINDER)) - .setDataStorageConfiguration(new DataStorageConfiguration() + return cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setMaxSize(200 * 1024 * 1024) .setPersistenceEnabled(true))); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheTest.java index 99d6f01c07d5d..06e3a6a3b77c1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheTest.java @@ -18,16 +18,21 @@ package org.apache.ignite.internal.processors.cache.persistence; import org.apache.ignite.Ignite; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test correct clean up cache configuration data after destroying cache. */ +@RunWith(JUnit4.class) public class IgnitePdsDestroyCacheTest extends IgnitePdsDestroyCacheAbstractTest { /** * Test destroy non grouped caches. * * @throws Exception If failed. */ + @Test public void testDestroyCaches() throws Exception { Ignite ignite = startGrids(NODES); @@ -43,6 +48,7 @@ public void testDestroyCaches() throws Exception { * * @throws Exception If failed. */ + @Test public void testDestroyGroupCaches() throws Exception { Ignite ignite = startGrids(NODES); @@ -58,6 +64,7 @@ public void testDestroyGroupCaches() throws Exception { * * @throws Exception If failed. */ + @Test public void testDestroyCachesAbruptly() throws Exception { Ignite ignite = startGrids(NODES); @@ -67,12 +74,13 @@ public void testDestroyCachesAbruptly() throws Exception { checkDestroyCachesAbruptly(ignite); } - + /** * Test destroy group caches abruptly with checkpoints. * * @throws Exception If failed. */ + @Test public void testDestroyGroupCachesAbruptly() throws Exception { Ignite ignite = startGrids(NODES); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheWithoutCheckpointsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheWithoutCheckpointsTest.java index 1bb6f5d8de8ba..8042a767c2373 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheWithoutCheckpointsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDestroyCacheWithoutCheckpointsTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.typedef.G; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Check that cluster survives after destroy caches abruptly with disabled checkpoints. */ +@RunWith(JUnit4.class) public class IgnitePdsDestroyCacheWithoutCheckpointsTest extends IgnitePdsDestroyCacheAbstractTest { /** * {@inheritDoc} @@ -39,6 +43,7 @@ public class IgnitePdsDestroyCacheWithoutCheckpointsTest extends IgnitePdsDestro * * @throws Exception If failed. */ + @Test public void testDestroyCachesAbruptlyWithoutCheckpoints() throws Exception { Ignite ignite = startGrids(NODES); @@ -56,6 +61,7 @@ public void testDestroyCachesAbruptlyWithoutCheckpoints() throws Exception { * * @throws Exception If failed. */ + @Test public void testDestroyGroupCachesAbruptlyWithoutCheckpoints() throws Exception { Ignite ignite = startGrids(NODES); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDynamicCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDynamicCacheTest.java index 42dc56364eb56..63bf42c7ec2f6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDynamicCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDynamicCacheTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.processors.database.IgniteDbDynamicCacheSelfTest; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsDynamicCacheTest extends IgniteDbDynamicCacheSelfTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -84,6 +88,7 @@ public class IgnitePdsDynamicCacheTest extends IgniteDbDynamicCacheSelfTest { /** * @throws Exception If failed. */ + @Test public void testRestartAndCreate() throws Exception { startGrids(3); @@ -151,6 +156,7 @@ public void testRestartAndCreate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicCacheSavingOnNewNode() throws Exception { Ignite ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsExchangeDuringCheckpointTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsExchangeDuringCheckpointTest.java index f1609726e0d05..a072d45c47f6d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsExchangeDuringCheckpointTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsExchangeDuringCheckpointTest.java @@ -24,25 +24,23 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsExchangeDuringCheckpointTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Non-persistent data region name. */ private static final String NO_PERSISTENCE_REGION = "no-persistence-region"; /** * */ + @Test public void testExchangeOnNodeLeft() throws Exception { for (int i = 0; i < 5; i++) { startGrids(3); @@ -64,6 +62,7 @@ public void testExchangeOnNodeLeft() throws Exception { /** * */ + @Test public void testExchangeOnNodeJoin() throws Exception { for (int i = 0; i < 5; i++) { startGrids(2); @@ -111,12 +110,6 @@ public void testExchangeOnNodeJoin() throws Exception { cfg.setCacheConfiguration(ccfg, ccfgNp); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - return cfg; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsMarshallerMappingRestoreOnNodeStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsMarshallerMappingRestoreOnNodeStartTest.java index 27bfe28014cf5..c8c8aafcd304b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsMarshallerMappingRestoreOnNodeStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsMarshallerMappingRestoreOnNodeStartTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsMarshallerMappingRestoreOnNodeStartTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -68,6 +72,7 @@ public class IgnitePdsMarshallerMappingRestoreOnNodeStartTest extends GridCommon * Test verifies that binary metadata from regular java classes is saved and restored correctly * on cluster restart. */ + @Test public void testStaticMetadataIsRestoredOnRestart() throws Exception { startGrids(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsNoSpaceLeftOnDeviceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsNoSpaceLeftOnDeviceTest.java new file mode 100644 index 0000000000000..d53a344b6018f --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsNoSpaceLeftOnDeviceTest.java @@ -0,0 +1,154 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence; + +import java.io.File; +import java.io.IOException; +import java.nio.file.OpenOption; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.failure.StopNodeFailureHandler; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; +import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; +import org.apache.ignite.internal.processors.cache.persistence.wal.reader.StandaloneGridKernalContext; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * + */ +@RunWith(JUnit4.class) +public class IgnitePdsNoSpaceLeftOnDeviceTest extends GridCommonAbstractTest { + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + final DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration(); + + dataStorageConfiguration.getDefaultDataRegionConfiguration().setPersistenceEnabled(true).setMaxSize(1 << 24); + dataStorageConfiguration.setFileIOFactory(new FailingFileIOFactory()); + + cfg.setDataStorageConfiguration(dataStorageConfiguration); + + CacheConfiguration ccfg = new CacheConfiguration(); + + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + ccfg.setName(DEFAULT_CACHE_NAME); + ccfg.setBackups(1); + + cfg.setCacheConfiguration(ccfg); + + cfg.setFailureHandler(new StopNodeFailureHandler()); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** + * The tests to validate IGNITE-9120 + * Metadata writer does not propagate error to failure handler. + * + * @throws Exception If failed. + */ + @Test + public void testWhileWritingBinaryMetadataFile() throws Exception { + final IgniteEx ignite0 = startGrid(0); + + final IgniteEx ignite1 = startGrid(1); + + FailingFileIOFactory.setUnluckyConsistentId(ignite1.localNode().consistentId().toString()); + + ignite0.cluster().active(true); + + final IgniteCache cache = ignite0.cache(DEFAULT_CACHE_NAME); + + for (int i = 0; i < 30; i++) { + try (Transaction tx = ignite0.transactions().txStart()) { + cache.put(1, ignite0.binary().builder("test").setField("field1", i).build()); + + cache.put(1 << i, ignite0.binary().builder("test").setField("field1", i).build()); + + tx.commit(); + } + catch (Exception e) { + } + } + + waitForTopology(1); + } + + /** + * Generating error "No space left on device" when writing binary_meta file on the second node + */ + private static class FailingFileIOFactory implements FileIOFactory { + /** + * + */ + private static final long serialVersionUID = 0L; + + /** + * + */ + private final FileIOFactory delegateFactory = new RandomAccessFileIOFactory(); + + /** + * Node ConsistentId for which the error will be generated + */ + private static final AtomicReference unluckyConsistentId = new AtomicReference<>(); + + /** {@inheritDoc} */ + @Override public FileIO create(File file, OpenOption... modes) throws IOException { + if (unluckyConsistentId.get() != null + && file.getAbsolutePath().contains(unluckyConsistentId.get()) + && file.getAbsolutePath().contains(StandaloneGridKernalContext.BINARY_META_FOLDER)) + throw new IOException("No space left on device"); + + return delegateFactory.create(file, modes); + } + + /** + * Set node ConsistentId for which the error will be generated + * + * @param unluckyConsistentId Node ConsistentId. + */ + public static void setUnluckyConsistentId(String unluckyConsistentId) { + FailingFileIOFactory.unluckyConsistentId.set(unluckyConsistentId); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPageSizesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPageSizesTest.java index 353bc504d2489..885f6a3896970 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPageSizesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPageSizesTest.java @@ -30,10 +30,14 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsPageSizesTest extends GridCommonAbstractTest { /** Cache name. */ private final String cacheName = "cache"; @@ -76,6 +80,7 @@ public class IgnitePdsPageSizesTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testPageSize_1k() throws Exception { checkPageSize(1024); } @@ -83,6 +88,7 @@ public void testPageSize_1k() throws Exception { /** * @throws Exception if failed. */ + @Test public void testPageSize_2k() throws Exception { checkPageSize(2 * 1024); } @@ -90,6 +96,7 @@ public void testPageSize_2k() throws Exception { /** * @throws Exception if failed. */ + @Test public void testPageSize_4k() throws Exception { checkPageSize(4 * 1024); } @@ -97,6 +104,7 @@ public void testPageSize_4k() throws Exception { /** * @throws Exception if failed. */ + @Test public void testPageSize_8k() throws Exception { checkPageSize(8 * 1024); } @@ -104,6 +112,7 @@ public void testPageSize_8k() throws Exception { /** * @throws Exception if failed. */ + @Test public void testPageSize_16k() throws Exception { checkPageSize(16 * 1024); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPartitionFilesDestroyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPartitionFilesDestroyTest.java index 3605700d739fc..a2a4b0bd9cc8d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPartitionFilesDestroyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPartitionFilesDestroyTest.java @@ -43,18 +43,20 @@ import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR; /** * Test class to check that partition files after eviction are destroyed correctly on next checkpoint or crash recovery. */ +@RunWith(JUnit4.class) public class IgnitePdsPartitionFilesDestroyTest extends GridCommonAbstractTest { - /** Cache name. */ - private static final String CACHE = "cache"; - /** Partitions count. */ private static final int PARTS_CNT = 32; @@ -81,7 +83,7 @@ public class IgnitePdsPartitionFilesDestroyTest extends GridCommonAbstractTest { cfg.setDataStorageConfiguration(dsCfg); - CacheConfiguration ccfg = new CacheConfiguration<>(CACHE) + CacheConfiguration ccfg = defaultCacheConfiguration() .setBackups(1) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) .setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT)); @@ -93,6 +95,9 @@ public class IgnitePdsPartitionFilesDestroyTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + stopAllGrids(); cleanPersistenceDir(); @@ -119,7 +124,7 @@ public class IgnitePdsPartitionFilesDestroyTest extends GridCommonAbstractTest { private void loadData(IgniteEx ignite, int keysCnt, int multiplier) { log.info("Load data: keys=" + keysCnt); - try (IgniteDataStreamer streamer = ignite.dataStreamer(CACHE)) { + try (IgniteDataStreamer streamer = ignite.dataStreamer(DEFAULT_CACHE_NAME)) { streamer.allowOverwrite(true); for (int k = 0; k < keysCnt; k++) @@ -134,7 +139,7 @@ private void loadData(IgniteEx ignite, int keysCnt, int multiplier) { private void checkData(IgniteEx ignite, int keysCnt, int multiplier) { log.info("Check data: " + ignite.name() + ", keys=" + keysCnt); - IgniteCache cache = ignite.cache(CACHE); + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); for (int k = 0; k < keysCnt; k++) Assert.assertEquals("node = " + ignite.name() + ", key = " + k, (Integer) (k * multiplier), cache.get(k)); @@ -145,6 +150,7 @@ private void checkData(IgniteEx ignite, int keysCnt, int multiplier) { * * @throws Exception If failed. */ + @Test public void testPartitionFileDestroyAfterCheckpoint() throws Exception { IgniteEx crd = (IgniteEx) startGrids(2); @@ -177,6 +183,7 @@ public void testPartitionFileDestroyAfterCheckpoint() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitionFileDestroyAndRecreate() throws Exception { IgniteEx crd = startGrid(0); @@ -224,6 +231,7 @@ public void testPartitionFileDestroyAndRecreate() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitionFileDestroyCrashRecovery1() throws Exception { IgniteEx crd = startGrid(0); @@ -277,6 +285,7 @@ public void testPartitionFileDestroyCrashRecovery1() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitionFileDestroyCrashRecovery2() throws Exception { IgniteEx crd = startGrid(0); @@ -338,6 +347,7 @@ public void testPartitionFileDestroyCrashRecovery2() throws Exception { * * @throws Exception If failed. */ + @Test public void testDestroyWhenPartitionsAreEmpty() throws Exception { IgniteEx crd = (IgniteEx) startGrids(2); @@ -346,7 +356,7 @@ public void testDestroyWhenPartitionsAreEmpty() throws Exception { forceCheckpoint(); // Evict arbitrary partition. - List parts = crd.cachex(CACHE).context().topology().localPartitions(); + List parts = crd.cachex(DEFAULT_CACHE_NAME).context().topology().localPartitions(); for (GridDhtLocalPartition part : parts) if (part.state() != GridDhtPartitionState.EVICTED) { part.rent(false).get(); @@ -375,12 +385,12 @@ public void testDestroyWhenPartitionsAreEmpty() throws Exception { private void checkPartitionFiles(IgniteEx ignite, boolean exists) throws IgniteCheckedException { int evicted = 0; - GridDhtPartitionTopology top = ignite.cachex(CACHE).context().topology(); + GridDhtPartitionTopology top = ignite.cachex(DEFAULT_CACHE_NAME).context().topology(); for (int p = 0; p < PARTS_CNT; p++) { GridDhtLocalPartition part = top.localPartition(p); - File partFile = partitionFile(ignite, CACHE, p); + File partFile = partitionFile(ignite, DEFAULT_CACHE_NAME, p); if (exists) { if (part != null && part.state() == GridDhtPartitionState.EVICTED) @@ -449,16 +459,6 @@ private static boolean isPartitionFile(File file) { return file.getName().contains("part") && file.getName().endsWith("bin"); } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - FileIO delegate = delegateFactory.create(file); - - if (isPartitionFile(file)) - return new FailingFileIO(delegate); - - return delegate; - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { FileIO delegate = delegateFactory.create(file, modes); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPartitionsStateRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPartitionsStateRecoveryTest.java new file mode 100644 index 0000000000000..9e4398a6ec51e --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsPartitionsStateRecoveryTest.java @@ -0,0 +1,177 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence; + +import java.util.Arrays; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheRebalanceMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * + */ +@RunWith(JUnit4.class) +public class IgnitePdsPartitionsStateRecoveryTest extends GridCommonAbstractTest { + /** Partitions count. */ + private static final int PARTS_CNT = 32; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setConsistentId(igniteInstanceName); + + DataStorageConfiguration dsCfg = new DataStorageConfiguration() + .setWalMode(WALMode.LOG_ONLY) + .setWalSegmentSize(16 * 1024 * 1024) + .setCheckpointFrequency(20 * 60 * 1000) + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setMaxSize(512 * 1024 * 1024) + .setPersistenceEnabled(true) + ); + + cfg.setDataStorageConfiguration(dsCfg); + + CacheConfiguration ccfg = defaultCacheConfiguration() + .setBackups(0) + .setRebalanceMode(CacheRebalanceMode.NONE) // Disable rebalance to prevent owning MOVING partitions. + .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) + .setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT)); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + System.setProperty(GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP, "true"); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + System.clearProperty(GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP); + } + + /** + * Test checks that partition state is recovered properly if last checkpoint was skipped and there are logical updates to apply. + * + * @throws Exception If failed. + */ + @Test + public void testPartitionsStateConsistencyAfterRecovery() throws Exception { + IgniteEx ignite = startGrid(0); + + ignite.cluster().active(true); + + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); + + for (int key = 0; key < 4096; key++) + cache.put(key, key); + + forceCheckpoint(); + + for (int key = 0; key < 4096; key++) { + int[] payload = new int[4096]; + Arrays.fill(payload, key); + + cache.put(key, payload); + } + + GridDhtPartitionTopology topology = ignite.cachex(DEFAULT_CACHE_NAME).context().topology(); + + Assert.assertFalse(topology.hasMovingPartitions()); + + log.info("Stopping grid..."); + + stopGrid(0); + + ignite = startGrid(0); + + awaitPartitionMapExchange(); + + topology = ignite.cachex(DEFAULT_CACHE_NAME).context().topology(); + + Assert.assertFalse("Node restored moving partitions after join to topology.", topology.hasMovingPartitions()); + } + + /** + * Test checks that partition state is recovered properly if only logical updates exist. + * + * @throws Exception If failed. + */ + @Test + public void testPartitionsStateConsistencyAfterRecoveryNoCheckpoints() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10603"); + + IgniteEx ignite = startGrid(0); + + ignite.cluster().active(true); + + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); + + forceCheckpoint(); + + for (int key = 0; key < 4096; key++) { + int[] payload = new int[4096]; + Arrays.fill(payload, key); + + cache.put(key, payload); + } + + GridDhtPartitionTopology topology = ignite.cachex(DEFAULT_CACHE_NAME).context().topology(); + + Assert.assertFalse(topology.hasMovingPartitions()); + + log.info("Stopping grid..."); + + stopGrid(0); + + ignite = startGrid(0); + + awaitPartitionMapExchange(); + + topology = ignite.cachex(DEFAULT_CACHE_NAME).context().topology(); + + Assert.assertFalse("Node restored moving partitions after join to topology.", topology.hasMovingPartitions()); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsRecoveryAfterFileCorruptionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsRecoveryAfterFileCorruptionTest.java index 15205e0c66e90..ef8f0efa3bc78 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsRecoveryAfterFileCorruptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsRecoveryAfterFileCorruptionTest.java @@ -23,6 +23,7 @@ import java.util.Collection; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheRebalanceMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; @@ -48,18 +49,16 @@ import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * This test generates WAL & Page Store with N pages, then rewrites pages with zeroes and tries to acquire all pages. */ +@RunWith(JUnit4.class) public class IgnitePdsRecoveryAfterFileCorruptionTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Total pages. */ private static final int totalPages = 512; @@ -78,6 +77,8 @@ public class IgnitePdsRecoveryAfterFileCorruptionTest extends GridCommonAbstract ccfg.setRebalanceMode(CacheRebalanceMode.NONE); + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + cfg.setCacheConfiguration(ccfg); DataStorageConfiguration memCfg = new DataStorageConfiguration() @@ -92,11 +93,6 @@ public class IgnitePdsRecoveryAfterFileCorruptionTest extends GridCommonAbstract cfg.setDataStorageConfiguration(memCfg); - cfg.setDiscoverySpi( - new TcpDiscoverySpi() - .setIpFinder(ipFinder) - ); - return cfg; } @@ -117,6 +113,7 @@ public class IgnitePdsRecoveryAfterFileCorruptionTest extends GridCommonAbstract /** * @throws Exception if failed. */ + @Test public void testPageRecoveryAfterFileCorruption() throws Exception { IgniteEx ig = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsRemoveDuringRebalancingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsRemoveDuringRebalancingTest.java index e51901d476b78..3970565361410 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsRemoveDuringRebalancingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsRemoveDuringRebalancingTest.java @@ -33,21 +33,19 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsRemoveDuringRebalancingTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); @@ -71,11 +69,6 @@ public class IgnitePdsRemoveDuringRebalancingTest extends GridCommonAbstractTest cfg.setDataStorageConfiguration(memCfg); - cfg.setDiscoverySpi( - new TcpDiscoverySpi() - .setIpFinder(IP_FINDER) - ); - return cfg; } @@ -100,6 +93,7 @@ public class IgnitePdsRemoveDuringRebalancingTest extends GridCommonAbstractTest /** * @throws Exception if failed. */ + @Test public void testRemovesDuringRebalancing() throws Exception { IgniteEx ig = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsTaskCancelingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsTaskCancelingTest.java index b36bac0123d6e..c2c6ced642c55 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsTaskCancelingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsTaskCancelingTest.java @@ -52,14 +52,14 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test handle of task canceling with PDS enabled. */ +@RunWith(JUnit4.class) public class IgnitePdsTaskCancelingTest extends GridCommonAbstractTest { /** Slow file IO enabled. */ private static final AtomicBoolean slowFileIoEnabled = new AtomicBoolean(false); @@ -91,6 +91,9 @@ public class IgnitePdsTaskCancelingTest extends GridCommonAbstractTest { cfg.setDataStorageConfiguration(getDataStorageConfiguration()); + // Set the thread pool size according to the NUM_TASKS. + cfg.setPublicThreadPoolSize(16); + return cfg; } @@ -114,6 +117,7 @@ private DataStorageConfiguration getDataStorageConfiguration() { /** * Checks that tasks canceling does not lead to node failure. */ + @Test public void testFailNodesOnCanceledTask() throws Exception { cleanPersistenceDir(); @@ -185,6 +189,7 @@ public void testFailNodesOnCanceledTask() throws Exception { /** * Test FilePageStore with multiple interrupted threads. */ + @Test public void testFilePageStoreInterruptThreads() throws Exception { failure.set(false); @@ -287,11 +292,6 @@ private static class SlowIOFactory implements FileIOFactory { /** */ private final FileIOFactory delegateFactory = new RandomAccessFileIOFactory(); - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, READ, WRITE); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... openOption) throws IOException { final FileIO delegate = delegateFactory.create(file, openOption); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsTxCacheRebalancingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsTxCacheRebalancingTest.java index 3b324c37436fd..ebaf168d43985 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsTxCacheRebalancingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsTxCacheRebalancingTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsTxCacheRebalancingTest extends IgnitePdsCacheRebalancingAbstractTest { /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String cacheName) { @@ -52,6 +56,7 @@ public class IgnitePdsTxCacheRebalancingTest extends IgnitePdsCacheRebalancingAb /** * @throws Exception If failed. */ + @Test public void testTopologyChangesWithConstantLoadExplicitTx() throws Exception { explicitTx = true; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePersistentStoreCacheGroupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePersistentStoreCacheGroupsTest.java index 96854137617fd..cfad1036cc6c7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePersistentStoreCacheGroupsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePersistentStoreCacheGroupsTest.java @@ -19,7 +19,9 @@ import java.io.Serializable; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; @@ -37,14 +39,15 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.platform.cache.expiry.PlatformExpiryPolicy; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -54,10 +57,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgnitePersistentStoreCacheGroupsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String GROUP1 = "grp1"; @@ -95,8 +96,6 @@ public class IgnitePersistentStoreCacheGroupsTest extends GridCommonAbstractTest cfg.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(false)); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - if (ccfgs != null) { cfg.setCacheConfiguration(ccfgs); @@ -123,6 +122,7 @@ protected int entriesCount() { /** * @throws Exception If failed. */ + @Test public void testClusterRestartStaticCaches1() throws Exception { clusterRestart(1, true); } @@ -130,6 +130,7 @@ public void testClusterRestartStaticCaches1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterRestartStaticCaches2() throws Exception { clusterRestart(3, true); } @@ -137,6 +138,7 @@ public void testClusterRestartStaticCaches2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterRestartDynamicCaches1() throws Exception { clusterRestart(1, false); } @@ -144,6 +146,7 @@ public void testClusterRestartDynamicCaches1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterRestartDynamicCaches2() throws Exception { clusterRestart(3, false); } @@ -152,6 +155,7 @@ public void testClusterRestartDynamicCaches2() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testClusterRestartCachesWithH2Indexes() throws Exception { CacheConfiguration[] ccfgs1 = new CacheConfiguration[5]; @@ -215,8 +219,9 @@ public void testClusterRestartCachesWithH2Indexes() throws Exception { /** * @throws Exception If failed. */ - public void _testExpiryPolicy() throws Exception { - long ttl = 10000; + @Test + public void testExpiryPolicy() throws Exception { + long ttl = 10 * 60000; CacheConfiguration[] ccfgs1 = new CacheConfiguration[5]; @@ -232,20 +237,33 @@ public void _testExpiryPolicy() throws Exception { Ignite node = ignite(0); - node.active(true); + node.cluster().active(true); node.createCaches(Arrays.asList(ccfgs1)); ExpiryPolicy plc = new PlatformExpiryPolicy(ttl, -2, -2); + Map> expTimes = new HashMap<>(); + for (String cacheName : caches) { + Map cacheExpTimes = new HashMap<>(); + expTimes.put(cacheName, cacheExpTimes); + IgniteCache cache = node.cache(cacheName).withExpiryPolicy(plc); - for (int i = 0; i < entriesCount(); i++) - cache.put(i, cacheName + i); - } + for (int i = 0; i < entriesCount(); i++) { + Integer key = i; - long deadline = System.currentTimeMillis() + (long)(ttl * 1.2); + cache.put(key, cacheName + i); + + IgniteKernal primaryNode = (IgniteKernal)primaryCache(i, cacheName).unwrap(Ignite.class); + GridCacheEntryEx entry = primaryNode.internalCache(cacheName).entryEx(key); + entry.unswap(); + + assertTrue(entry.expireTime() > 0); + cacheExpTimes.put(key, entry.expireTime()); + } + } stopAllGrids(); @@ -253,30 +271,29 @@ public void _testExpiryPolicy() throws Exception { node = ignite(0); - node.active(true); + node.cluster().active(true); for (String cacheName : caches) { IgniteCache cache = node.cache(cacheName); - for (int i = 0; i < entriesCount(); i++) - assertEquals(cacheName + i, cache.get(i)); + for (int i = 0; i < entriesCount(); i++) { + Integer key = i; - assertEquals(entriesCount(), cache.size()); - } + assertEquals(cacheName + i, cache.get(i)); - // Wait for expiration. - Thread.sleep(Math.max(deadline - System.currentTimeMillis(), 0)); + IgniteKernal primaryNode = (IgniteKernal)primaryCache(i, cacheName).unwrap(Ignite.class); + GridCacheEntryEx entry = primaryNode.internalCache(cacheName).entryEx(key); + entry.unswap(); - for (String cacheName : caches) { - IgniteCache cache = node.cache(cacheName); - - assertEquals(0, cache.size()); + assertEquals(expTimes.get(cacheName).get(key), (Long)entry.expireTime()); + } } } /** * @throws Exception If failed. */ + @Test public void testCreateDropCache() throws Exception { ccfgs = new CacheConfiguration[]{cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1) .setIndexedTypes(Integer.class, Person.class)}; @@ -293,6 +310,7 @@ public void testCreateDropCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateDropCache1() throws Exception { CacheConfiguration ccfg1 = cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1); @@ -317,6 +335,7 @@ public void testCreateDropCache1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateDropCache2() throws Exception { CacheConfiguration ccfg1 = cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1) .setIndexedTypes(Integer.class, Person.class); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePersistentStoreDataStructuresTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePersistentStoreDataStructuresTest.java index dc4e17e657b30..04de2369094d3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePersistentStoreDataStructuresTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePersistentStoreDataStructuresTest.java @@ -22,6 +22,7 @@ import org.apache.ignite.IgniteAtomicLong; import org.apache.ignite.IgniteAtomicSequence; import org.apache.ignite.IgniteCountDownLatch; +import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLock; import org.apache.ignite.IgniteQueue; import org.apache.ignite.IgniteSemaphore; @@ -33,19 +34,17 @@ import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePersistentStoreDataStructuresTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static volatile boolean autoActivationEnabled = false; @@ -53,8 +52,6 @@ public class IgnitePersistentStoreDataStructuresTest extends GridCommonAbstractT @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - DataStorageConfiguration memCfg = new DataStorageConfiguration() .setDefaultDataRegionConfiguration( new DataRegionConfiguration().setMaxSize(200 * 1024 * 1024).setPersistenceEnabled(true)) @@ -91,6 +88,7 @@ public class IgnitePersistentStoreDataStructuresTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testQueue() throws Exception { Ignite ignite = startGrids(4); @@ -116,6 +114,7 @@ public void testQueue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomic() throws Exception { Ignite ignite = startGrids(4); @@ -141,6 +140,7 @@ public void testAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSequence() throws Exception { Ignite ignite = startGrids(4); @@ -170,6 +170,7 @@ public void testSequence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSequenceAfterAutoactivation() throws Exception { final String seqName = "testSequence"; @@ -185,10 +186,19 @@ public void testSequenceAfterAutoactivation() throws Exception { final Ignite node = startGrids(2); - IgniteInternalFuture fut = GridTestUtils.runAsync(new Runnable() { - @Override public void run() { - // Should not hang. - node.atomicSequence(seqName, 0, false); + IgniteInternalFuture fut = GridTestUtils.runAsync(() -> { + while (true) { + try { + // Should not hang. + node.atomicSequence(seqName, 0, false); + + break; + } + catch (IgniteException e) { + // Can fail on not yet activated cluster. Retry until success. + assertTrue(e.getMessage() + .contains("Can not perform the operation because the cluster is inactive")); + } } }); @@ -205,6 +215,7 @@ public void testSequenceAfterAutoactivation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSet() throws Exception { Ignite ignite = startGrids(4); @@ -236,6 +247,7 @@ public void testSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLockVolatility() throws Exception { Ignite ignite = startGrids(4); @@ -259,6 +271,7 @@ public void testLockVolatility() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSemaphoreVolatility() throws Exception { Ignite ignite = startGrids(4); @@ -282,6 +295,7 @@ public void testSemaphoreVolatility() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLatchVolatility() throws Exception { Ignite ignite = startGrids(4); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteRebalanceScheduleResendPartitionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteRebalanceScheduleResendPartitionsTest.java index bb08a8dc5631f..d52bdd81c5efb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteRebalanceScheduleResendPartitionsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteRebalanceScheduleResendPartitionsTest.java @@ -27,6 +27,7 @@ import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; @@ -44,26 +45,24 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.runAsync; /** * */ +@RunWith(JUnit4.class) public class IgniteRebalanceScheduleResendPartitionsTest extends GridCommonAbstractTest { - /** */ - public static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { IgniteConfiguration cfg = super.getConfiguration(name); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setConsistentId(name); cfg.setAutoActivationEnabled(false); @@ -79,8 +78,8 @@ public class IgniteRebalanceScheduleResendPartitionsTest extends GridCommonAbstr cfg.setCacheConfiguration( new CacheConfiguration(DEFAULT_CACHE_NAME) - .setAffinity( - new RendezvousAffinityFunction(false, 32)) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setAffinity(new RendezvousAffinityFunction(false, 32)) .setBackups(1) ); @@ -110,7 +109,11 @@ public class IgniteRebalanceScheduleResendPartitionsTest extends GridCommonAbstr * * @throws Exception If failed. */ + @Test public void test() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + Ignite ig0 = startGrids(3); ig0.cluster().active(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWalModeChangeDuringRebalancingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWalModeChangeDuringRebalancingSelfTest.java index 4dd5f51b28772..caf16cd11a9bd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWalModeChangeDuringRebalancingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWalModeChangeDuringRebalancingSelfTest.java @@ -23,12 +23,14 @@ import java.nio.MappedByteBuffer; import java.nio.file.OpenOption; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicReference; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; @@ -51,18 +53,30 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; /** * */ +@RunWith(JUnit4.class) public class LocalWalModeChangeDuringRebalancingSelfTest extends GridCommonAbstractTest { /** */ private static boolean disableWalDuringRebalancing = true; + /** */ + private static boolean enablePendingTxTracker = false; + + /** */ + private static int dfltCacheBackupCnt = 0; + /** */ private static final AtomicReference supplyMessageLatch = new AtomicReference<>(); @@ -91,10 +105,13 @@ public class LocalWalModeChangeDuringRebalancingSelfTest extends GridCommonAbstr cfg.setCacheConfiguration( new CacheConfiguration(DEFAULT_CACHE_NAME) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) // Test checks internal state before and after rebalance, so it is configured to be triggered manually - .setRebalanceDelay(-1), + .setRebalanceDelay(-1) + .setBackups(dfltCacheBackupCnt), new CacheConfiguration(REPL_CACHE) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setRebalanceDelay(-1) .setCacheMode(CacheMode.REPLICATED) ); @@ -147,6 +164,9 @@ public class LocalWalModeChangeDuringRebalancingSelfTest extends GridCommonAbstr System.setProperty(IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING, Boolean.toString(disableWalDuringRebalancing)); + System.setProperty(IgniteSystemProperties.IGNITE_PENDING_TX_TRACKER_ENABLED, + Boolean.toString(enablePendingTxTracker)); + return cfg; } @@ -184,6 +204,17 @@ public class LocalWalModeChangeDuringRebalancingSelfTest extends GridCommonAbstr cleanPersistenceDir(); disableWalDuringRebalancing = true; + enablePendingTxTracker = false; + dfltCacheBackupCnt = 0; + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + super.afterTestsStopped(); + + System.clearProperty(IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING); + + System.clearProperty(IgniteSystemProperties.IGNITE_PENDING_TX_TRACKER_ENABLED); } /** @@ -196,14 +227,22 @@ protected int getKeysCount() { /** * @throws Exception If failed. */ + @Test public void testWalDisabledDuringRebalancing() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + doTestSimple(); } /** * @throws Exception If failed. */ + @Test public void testWalNotDisabledIfParameterSetToFalse() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + disableWalDuringRebalancing = false; doTestSimple(); @@ -286,7 +325,66 @@ else if (timestamp >= rebalanceStartedTimestamp && timestamp <= rebalanceFinishe /** * @throws Exception If failed. */ + @Test + public void testWalDisabledDuringRebalancingWithPendingTxTracker() throws Exception { + enablePendingTxTracker = true; + dfltCacheBackupCnt = 2; + + Ignite ignite = startGrids(3); + + ignite.cluster().active(true); + + ignite.cluster().setBaselineTopology(3); + + IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); + + stopGrid(2); + + awaitExchange((IgniteEx)ignite); + + doLoad(cache, 4, 10_000); + + IgniteEx newIgnite = startGrid(2); + + awaitExchange(newIgnite); + + CacheGroupContext grpCtx = newIgnite.cachex(DEFAULT_CACHE_NAME).context().group(); + + assertFalse(grpCtx.walEnabled()); + + long rebalanceStartedTs = System.currentTimeMillis(); + + for (Ignite g : G.allGrids()) + g.cache(DEFAULT_CACHE_NAME).rebalance(); + + awaitPartitionMapExchange(); + + assertTrue(grpCtx.walEnabled()); + + long rebalanceFinishedTs = System.currentTimeMillis(); + + CheckpointHistory cpHist = + ((GridCacheDatabaseSharedManager)newIgnite.context().cache().context().database()).checkpointHistory(); + + assertNotNull(cpHist); + + // Ensure there was a checkpoint on WAL re-activation. + assertEquals( + 1, + cpHist.checkpoints() + .stream() + .filter(ts -> rebalanceStartedTs <= ts && ts <= rebalanceFinishedTs) + .count()); + } + + /** + * @throws Exception If failed. + */ + @Test public void testLocalAndGlobalWalStateInterdependence() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + Ignite ignite = startGrids(3); ignite.cluster().active(true); @@ -325,6 +423,7 @@ public void testLocalAndGlobalWalStateInterdependence() throws Exception { * * @throws Exception If failed. */ + @Test public void testWithExchangesMerge() throws Exception { final int nodeCnt = 4; final int keyCnt = getKeysCount(); @@ -378,14 +477,22 @@ public void testWithExchangesMerge() throws Exception { /** * @throws Exception If failed. */ + @Test public void testParallelExchangeDuringRebalance() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + doTestParallelExchange(supplyMessageLatch); } /** * @throws Exception If failed. */ + @Test public void testParallelExchangeDuringCheckpoint() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + doTestParallelExchange(fileIOLatch); } @@ -440,7 +547,11 @@ private void doTestParallelExchange(AtomicReference latchRef) th /** * @throws Exception If failed. */ + @Test public void testDataClearedAfterRestartWithDisabledWal() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + Ignite ignite = startGrid(0); ignite.cluster().active(true); @@ -481,6 +592,7 @@ public void testDataClearedAfterRestartWithDisabledWal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWalNotDisabledAfterShrinkingBaselineTopology() throws Exception { Ignite ignite = startGrids(4); @@ -531,6 +643,34 @@ private void awaitExchange(IgniteEx ig) throws IgniteCheckedException { ig.context().cache().context().exchange().lastTopologyFuture().get(); } + /** + * Put random values to cache in multiple threads until time interval given expires. + * + * @param cache Cache to modify. + * @param threadCnt Number ot threads to be used. + * @param duration Time interval in milliseconds. + * @throws Exception When something goes wrong. + */ + private void doLoad(IgniteCache cache, int threadCnt, long duration) throws Exception { + GridTestUtils.runMultiThreaded(() -> { + long stopTs = U.currentTimeMillis() + duration; + + int keysCnt = getKeysCount(); + + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + do { + try { + cache.put(rnd.nextInt(keysCnt), rnd.nextInt()); + } + catch (Exception ex) { + MvccFeatureChecker.assertMvccWriteConflict(ex); + } + } + while (U.currentTimeMillis() < stopTs); + }, threadCnt, "load-cache"); + } + /** * */ @@ -545,11 +685,6 @@ private static class TestFileIOFactory implements FileIOFactory { this.delegate = delegate; } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return new TestFileIO(delegate.create(file)); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { return new TestFileIO(delegate.create(file, modes)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest.java similarity index 81% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest.java index 4f2817f29109c..ff736373f4d6e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest.java @@ -20,6 +20,7 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; @@ -33,10 +34,11 @@ import org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.lang.String.valueOf; import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING; @@ -47,13 +49,13 @@ /** * */ -public class LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest extends GridCommonAbstractTest { - +@RunWith(JUnit4.class) +public class LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest extends GridCommonAbstractTest { /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + private final int NODES = 3; /** */ - private final int NODES = 3; + private CacheAtomicityMode atomicityMode; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { @@ -61,8 +63,6 @@ public class LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest extends Grid cfg.setConsistentId(name); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setWalPath(walPath(name)) @@ -76,8 +76,8 @@ public class LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest extends Grid cfg.setCacheConfiguration( new CacheConfiguration(DEFAULT_CACHE_NAME) - .setAffinity( - new RendezvousAffinityFunction(false, 3)) + .setAtomicityMode(atomicityMode) + .setAffinity(new RendezvousAffinityFunction(false, 3)) ); return cfg; @@ -97,15 +97,48 @@ public class LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest extends Grid super.afterTest(); System.clearProperty(IGNITE_DISABLE_WAL_DURING_REBALANCING); + + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10652") + @Test + public void testAtomic() throws Exception { + atomicityMode = CacheAtomicityMode.ATOMIC; + + check(); } /** * @throws Exception If failed. */ - public void test() throws Exception { - Ignite ig = startGrids(NODES); + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10652") + @Test + public void testTx() throws Exception { + atomicityMode = CacheAtomicityMode.TRANSACTIONAL; - ig.cluster().active(true); + check(); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10421") + @Test + public void testMvcc() throws Exception { + atomicityMode = CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + + check(); + } + + /** + * @throws Exception If failed. + */ + public void check() throws Exception { + Ignite ig = startGridsMultiThreaded(NODES); int entries = 100_000; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/MemoryPolicyInitializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/MemoryPolicyInitializationTest.java index fac021ef9b84e..82def5c4f072e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/MemoryPolicyInitializationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/MemoryPolicyInitializationTest.java @@ -27,12 +27,16 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME; /** * */ +@RunWith(JUnit4.class) public class MemoryPolicyInitializationTest extends GridCommonAbstractTest { /** */ private static final String CUSTOM_NON_DEFAULT_MEM_PLC_NAME = "custom_mem_plc"; @@ -68,6 +72,7 @@ public class MemoryPolicyInitializationTest extends GridCommonAbstractTest { /** * Verifies that expected memory policies are allocated when used doesn't provide any MemoryPolicyConfiguration. */ + @Test public void testNoConfigProvided() throws Exception { memCfg = null; @@ -84,6 +89,7 @@ public void testNoConfigProvided() throws Exception { * Verifies that expected memory policies are allocated when used provides MemoryPolicyConfiguration * with non-default custom MemoryPolicy. */ + @Test public void testCustomConfigNoDefault() throws Exception { prepareCustomNoDefaultConfig(); @@ -103,6 +109,7 @@ public void testCustomConfigNoDefault() throws Exception { * User is allowed to configure memory policy with 'default' name, * in that case Ignite instance will use this user-defined memory policy as a default one. */ + @Test public void testCustomConfigOverridesDefault() throws Exception { prepareCustomConfigWithOverridingDefault(); @@ -127,6 +134,7 @@ public void testCustomConfigOverridesDefault() throws Exception { * At the same time user still can create a memory policy with name 'default' * which although won't be used as default. */ + @Test public void testCustomConfigOverridesDefaultNameAndDeclaresDefault() throws Exception { prepareCustomConfigWithOverriddenDefaultName(); @@ -150,6 +158,7 @@ public void testCustomConfigOverridesDefaultNameAndDeclaresDefault() throws Exce * with specified default memory policy name and specified custom memory policy name * all started with correct memory policy. */ + @Test public void testCachesOnOverriddenMemoryPolicy() throws Exception { prepareCustomConfigWithOverridingDefaultAndCustom(); @@ -184,6 +193,7 @@ public void testCachesOnOverriddenMemoryPolicy() throws Exception { * with specified default memory policy name and specified custom memory policy name * all started with correct memory policy. */ + @Test public void testCachesOnUserDefinedDefaultMemoryPolicy() throws Exception { prepareCustomConfigWithOverriddenDefaultName(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/PersistenceDirectoryWarningLoggingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/PersistenceDirectoryWarningLoggingTest.java index bb55c8200ee33..2de83c2380c12 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/PersistenceDirectoryWarningLoggingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/PersistenceDirectoryWarningLoggingTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests that warning is logged when persistence store directory equals {@code System.getProperty("java.io.tmpdir")}. */ +@RunWith(JUnit4.class) public class PersistenceDirectoryWarningLoggingTest extends GridCommonAbstractTest { /** Warning message to test. */ private static final String WARN_MSG_PREFIX = "Persistence store directory is in the temp " + @@ -60,6 +64,7 @@ public class PersistenceDirectoryWarningLoggingTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testPdsDirWarningSuppressed() throws Exception { startGrid(); @@ -69,6 +74,7 @@ public void testPdsDirWarningSuppressed() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPdsDirWarningIsLogged() throws Exception { IgniteConfiguration cfg = getConfiguration("0"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/ClientAffinityAssignmentWithBaselineTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/ClientAffinityAssignmentWithBaselineTest.java index 13a98e4a7ae8c..41853617f3346 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/ClientAffinityAssignmentWithBaselineTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/ClientAffinityAssignmentWithBaselineTest.java @@ -49,16 +49,21 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR; /** * Checks that client affinity assignment cache is calculated correctly regardless of current baseline topology. */ +@RunWith(JUnit4.class) public class ClientAffinityAssignmentWithBaselineTest extends GridCommonAbstractTest { /** Nodes count. */ private static final int DEFAULT_NODES_COUNT = 5; @@ -156,6 +161,9 @@ public class ClientAffinityAssignmentWithBaselineTest extends GridCommonAbstract /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10261"); + stopAllGrids(); cleanPersistenceDir(); @@ -225,6 +233,7 @@ else if (REPLICATED_TX_CACHE_NAME.equals(cacheName)) { /** * */ + @Test public void testPartitionedAtomicCache() throws Exception { testChangingBaselineDown(PARTITIONED_ATOMIC_CACHE_NAME, false); } @@ -232,6 +241,7 @@ public void testPartitionedAtomicCache() throws Exception { /** * */ + @Test public void testPartitionedTxCache() throws Exception { testChangingBaselineDown(PARTITIONED_TX_CACHE_NAME, false); } @@ -239,6 +249,7 @@ public void testPartitionedTxCache() throws Exception { /** * Test that activation after client join won't break cache. */ + @Test public void testLateActivation() throws Exception { testChangingBaselineDown(PARTITIONED_TX_CACHE_NAME, true); } @@ -246,6 +257,7 @@ public void testLateActivation() throws Exception { /** * */ + @Test public void testReplicatedAtomicCache() throws Exception { testChangingBaselineDown(REPLICATED_ATOMIC_CACHE_NAME, false); } @@ -253,6 +265,7 @@ public void testReplicatedAtomicCache() throws Exception { /** * */ + @Test public void testReplicatedTxCache() throws Exception { testChangingBaselineDown(REPLICATED_TX_CACHE_NAME, false); } @@ -328,6 +341,7 @@ private void testChangingBaselineDown(String cacheName, boolean lateActivation) /** * Tests that rejoin of baseline node with clear LFS under load won't break cache. */ + @Test public void testRejoinWithCleanLfs() throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(DEFAULT_NODES_COUNT - 1); startGrid("flaky"); @@ -394,6 +408,7 @@ public void testRejoinWithCleanLfs() throws Exception { /** * Test that changing baseline down under cross-cache txs load won't break cache. */ + @Test public void testCrossCacheTxs() throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(DEFAULT_NODES_COUNT); @@ -455,6 +470,7 @@ public void testCrossCacheTxs() throws Exception { /** * Tests that join of non-baseline node while long transactions are running won't break dynamically started cache. */ + @Test public void testDynamicCacheLongTransactionNodeStart() throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(4); @@ -526,13 +542,14 @@ public void testDynamicCacheLongTransactionNodeStart() throws Exception { * Tests that if dynamic cache has no affinity nodes at the moment of start, * it will still work correctly when affinity nodes will appear. */ + @Test public void testDynamicCacheStartNoAffinityNodes() throws Exception { fail("IGNITE-8652"); IgniteEx ig0 = startGrid(0); ig0.cluster().active(true); - + IgniteEx client = (IgniteEx)startGrid("client"); CacheConfiguration dynamicCacheCfg = new CacheConfiguration() @@ -544,7 +561,7 @@ public void testDynamicCacheStartNoAffinityNodes() throws Exception { .setNodeFilter(new ConsistentIdNodeFilter((Serializable)ig0.localNode().consistentId())); IgniteCache dynamicCache = client.getOrCreateCache(dynamicCacheCfg); - + for (int i = 1; i < 4; i++) startGrid(i); @@ -552,29 +569,29 @@ public void testDynamicCacheStartNoAffinityNodes() throws Exception { for (int i = 0; i < ENTRIES; i++) dynamicCache.put(i, "abacaba" + i); - + AtomicBoolean releaseTx = new AtomicBoolean(false); CountDownLatch allTxsDoneLatch = new CountDownLatch(10); - + for (int i = 0; i < 10; i++) { final int i0 = i; - + GridTestUtils.runAsync(new Runnable() { @Override public void run() { try (Transaction tx = client.transactions().txStart(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)) { dynamicCache.put(i0, "txtxtxtx" + i0); - + while (!releaseTx.get()) LockSupport.parkNanos(1_000_000); - + tx.commit(); - + System.out.println("Tx #" + i0 + " committed"); } catch (Throwable t) { System.out.println("Tx #" + i0 + " failed"); - + t.printStackTrace(); } finally { @@ -583,7 +600,7 @@ public void testDynamicCacheStartNoAffinityNodes() throws Exception { } }); } - + GridTestUtils.runAsync(new Runnable() { @Override public void run() { try { @@ -608,6 +625,7 @@ public void testDynamicCacheStartNoAffinityNodes() throws Exception { /** * Tests that join of non-baseline node while long transactions are running won't break cache started on client join. */ + @Test public void testClientJoinCacheLongTransactionNodeStart() throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(4); @@ -784,7 +802,7 @@ private void startTxLoadThread( IgniteCache cache = ig.cache(cacheName).withAllowAtomicOpsInTx(); - boolean pessimistic = r.nextBoolean(); + boolean pessimistic = atomicityMode(cache) == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT || r.nextBoolean(); boolean rollback = r.nextBoolean(); @@ -860,7 +878,8 @@ private void startCrossCacheTxLoadThread( IgniteCache cache1 = ig.cache(cacheName1); IgniteCache cache2 = ig.cache(cacheName2); - boolean pessimistic = r.nextBoolean(); + boolean pessimistic = atomicityMode(cache1) == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT || + atomicityMode(cache2) == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT || r.nextBoolean(); boolean rollback = r.nextBoolean(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/IgniteAbsentEvictionNodeOutOfBaselineTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/IgniteAbsentEvictionNodeOutOfBaselineTest.java index cddd701beea46..c84f754085e67 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/IgniteAbsentEvictionNodeOutOfBaselineTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/IgniteAbsentEvictionNodeOutOfBaselineTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test absenting eviction for joined node if it is out of baseline. */ +@RunWith(JUnit4.class) public class IgniteAbsentEvictionNodeOutOfBaselineTest extends GridCommonAbstractTest { /** */ private static final String TEST_CACHE_NAME = "test"; @@ -75,6 +79,7 @@ public class IgniteAbsentEvictionNodeOutOfBaselineTest extends GridCommonAbstrac /** * Removed partitions if node is out of baseline. */ + @Test public void testPartitionsRemovedIfJoiningNodeNotInBaseline() throws Exception { //given: start 3 nodes with data Ignite ignite0 = startGrids(3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/CheckpointBufferDeadlockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/CheckpointBufferDeadlockTest.java index 3afafe691f462..de9eaf19a2f58 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/CheckpointBufferDeadlockTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/CheckpointBufferDeadlockTest.java @@ -52,25 +52,19 @@ import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; - -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CheckpointBufferDeadlockTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Max size. */ private static final int MAX_SIZE = 500 * 1024 * 1024; @@ -102,8 +96,6 @@ public class CheckpointBufferDeadlockTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setFileIOFactory(new SlowCheckpointFileIOFactory()) @@ -150,6 +142,7 @@ public class CheckpointBufferDeadlockTest extends GridCommonAbstractTest { /** * */ + @Test public void testFourCheckpointThreads() throws Exception { checkpointThreads = 4; @@ -159,6 +152,7 @@ public void testFourCheckpointThreads() throws Exception { /** * */ + @Test public void testOneCheckpointThread() throws Exception { checkpointThreads = 1; @@ -335,11 +329,6 @@ private static class SlowCheckpointFileIOFactory implements FileIOFactory { /** Delegate factory. */ private final FileIOFactory delegateFactory = new RandomAccessFileIOFactory(); - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, READ, WRITE); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... openOption) throws IOException { final FileIO delegate = delegateFactory.create(file, openOption); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/CheckpointFailingIoFactory.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/CheckpointFailingIoFactory.java new file mode 100644 index 0000000000000..2d48cd614b449 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/CheckpointFailingIoFactory.java @@ -0,0 +1,88 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.db; + +import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIODecorator; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; +import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; + +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.file.OpenOption; + +/** + * + */ +class CheckpointFailingIoFactory implements FileIOFactory { + /** */ + private volatile boolean fail; + + /** + * Will fail immediately. + */ + public CheckpointFailingIoFactory() { + this(true); + } + + /** + * @param failImmediately Fail immediately flag. + */ + public CheckpointFailingIoFactory(boolean failImmediately) { + fail = failImmediately; + } + + /** + * After this call all subsequent write calls will fail. + */ + public void startFailing() { + fail = true; + } + + /** {@inheritDoc} */ + @Override public FileIO create(File file, OpenOption... modes) throws IOException { + FileIO delegate = new RandomAccessFileIOFactory().create(file, modes); + + if (file.getName().contains("part-")) + return new FileIODecorator(delegate) { + @Override public int write(ByteBuffer srcBuf) throws IOException { + if (fail) + throw new IOException("test"); + else + return super.write(srcBuf); + } + + @Override public int write(ByteBuffer srcBuf, long position) throws IOException { + if (fail) + throw new IOException("test"); + else + return super.write(srcBuf, position); + } + + @Override public int write(byte[] buf, int off, int len) throws IOException { + if (fail) + throw new IOException("test"); + else + return super.write(buf, off, len); + } + }; + + return delegate; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteLogicalRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteLogicalRecoveryTest.java new file mode 100644 index 0000000000000..6bfebfc9a9d29 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteLogicalRecoveryTest.java @@ -0,0 +1,673 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.db; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ThreadLocalRandom; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import com.google.common.collect.Lists; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteIllegalStateException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.cache.query.annotations.QuerySqlField; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.failure.FailureHandler; +import org.apache.ignite.failure.StopNodeFailureHandler; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage; +import org.apache.ignite.internal.processors.cache.GridCacheUtils; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage; +import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; +import org.apache.ignite.internal.util.future.GridCompoundFuture; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.internal.CU; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.jetbrains.annotations.Nullable; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * A set of tests that check correctness of logical recovery performed during node start. + */ +@RunWith(JUnit4.class) +public class IgniteLogicalRecoveryTest extends GridCommonAbstractTest { + /** */ + private static final int[] EVTS_DISABLED = {}; + + /** Shared group name. */ + private static final String SHARED_GROUP_NAME = "group"; + + /** Dynamic cache prefix. */ + private static final String DYNAMIC_CACHE_PREFIX = "dynamic-cache-"; + + /** Cache prefix. */ + private static final String CACHE_PREFIX = "cache-"; + + /** Io factory. */ + private FileIOFactory ioFactory; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setIncludeEventTypes(EVTS_DISABLED); + + cfg.setConsistentId(igniteInstanceName); + + cfg.setCacheConfiguration( + cacheConfiguration(CACHE_PREFIX + 0, CacheMode.PARTITIONED, CacheAtomicityMode.ATOMIC), + cacheConfiguration(CACHE_PREFIX + 1, CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL), + cacheConfiguration(CACHE_PREFIX + 2, CacheMode.REPLICATED, CacheAtomicityMode.ATOMIC), + cacheConfiguration(CACHE_PREFIX + 3, CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL), + cacheConfiguration(CACHE_PREFIX + 4, SHARED_GROUP_NAME, CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL), + cacheConfiguration(CACHE_PREFIX + 5, SHARED_GROUP_NAME, CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL) + ); + + DataStorageConfiguration dsCfg = new DataStorageConfiguration() + .setWalMode(WALMode.LOG_ONLY) + .setCheckpointFrequency(1024 * 1024 * 1024) // Disable automatic checkpoints. + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setName("dflt") + .setInitialSize(256 * 1024 * 1024) + .setMaxSize(256 * 1024 * 1024) + .setPersistenceEnabled(true) + ); + + cfg.setDataStorageConfiguration(dsCfg); + + if (ioFactory != null) + dsCfg.setFileIOFactory(ioFactory); + + TestRecordingCommunicationSpi spi = new TestRecordingCommunicationSpi(); + + spi.record(GridDhtPartitionDemandMessage.class); + + cfg.setCommunicationSpi(spi); + + return cfg; + } + + /** + * @param name Name. + * @param cacheMode Cache mode. + * @param atomicityMode Atomicity mode. + */ + private CacheConfiguration cacheConfiguration(String name, CacheMode cacheMode, CacheAtomicityMode atomicityMode) { + return cacheConfiguration(name, null, cacheMode, atomicityMode); + } + + /** + * @param name Name. + * @param groupName Group name. + * @param cacheMode Cache mode. + * @param atomicityMode Atomicity mode. + */ + protected CacheConfiguration cacheConfiguration(String name, @Nullable String groupName, CacheMode cacheMode, CacheAtomicityMode atomicityMode) { + CacheConfiguration cfg = new CacheConfiguration<>(name) + .setGroupName(groupName) + .setCacheMode(cacheMode) + .setAtomicityMode(atomicityMode) + .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) + .setBackups(2) + .setAffinity(new RendezvousAffinityFunction(false, 32)); + + cfg.setIndexedTypes(Integer.class, Integer.class); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + System.setProperty(GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP, "true"); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + System.clearProperty(GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP); + } + + /** + * + */ + @Test + public void testRecoveryOnJoinToActiveCluster() throws Exception { + IgniteEx crd = (IgniteEx) startGridsMultiThreaded(3); + + crd.cluster().active(true); + + IgniteEx node = grid(2); + + AggregateCacheLoader cacheLoader = new AggregateCacheLoader(node); + + cacheLoader.loadByTime(5_000).get(); + + forceCheckpoint(); + + cacheLoader.loadByTime(5_000).get(); + + stopGrid(2, true); + + node = startGrid(2); + + awaitPartitionMapExchange(); + + cacheLoader.consistencyCheck(node); + + checkNoRebalanceAfterRecovery(); + + checkCacheContextsConsistencyAfterRecovery(); + } + + /** + * + */ + @Test + public void testRecoveryOnJoinToInactiveCluster() throws Exception { + IgniteEx crd = (IgniteEx) startGridsMultiThreaded(3); + + crd.cluster().active(true); + + IgniteEx node = grid(2); + + AggregateCacheLoader cacheLoader = new AggregateCacheLoader(node); + + cacheLoader.loadByTime(5_000).get(); + + forceCheckpoint(); + + cacheLoader.loadByTime(5_000).get(); + + stopGrid(2, true); + + crd.cluster().active(false); + + node = startGrid(2); + + crd.cluster().active(true); + + awaitPartitionMapExchange(); + + checkNoRebalanceAfterRecovery(); + + cacheLoader.consistencyCheck(node); + + checkCacheContextsConsistencyAfterRecovery(); + } + + /** + * + */ + @Test + public void testRecoveryOnDynamicallyStartedCaches() throws Exception { + List dynamicCaches = Lists.newArrayList( + cacheConfiguration(DYNAMIC_CACHE_PREFIX + 0, CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL), + cacheConfiguration(DYNAMIC_CACHE_PREFIX + 1, CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL), + cacheConfiguration(DYNAMIC_CACHE_PREFIX + 2, CacheMode.PARTITIONED, CacheAtomicityMode.ATOMIC), + cacheConfiguration(DYNAMIC_CACHE_PREFIX + 3, CacheMode.REPLICATED, CacheAtomicityMode.ATOMIC) + ); + + doTestWithDynamicCaches(dynamicCaches); + } + + /** + * + */ + @Test + public void testRecoveryWithMvccCaches() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10582"); + + List dynamicCaches = Lists.newArrayList( + cacheConfiguration(DYNAMIC_CACHE_PREFIX + 0, CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT), + cacheConfiguration(DYNAMIC_CACHE_PREFIX + 1, CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) + ); + + doTestWithDynamicCaches(dynamicCaches); + } + + /** + * @param dynamicCaches Dynamic caches. + */ + private void doTestWithDynamicCaches(List dynamicCaches) throws Exception { + IgniteEx crd = (IgniteEx) startGridsMultiThreaded(3); + + crd.cluster().active(true); + + IgniteEx node = grid(2); + + node.getOrCreateCaches(dynamicCaches); + + AggregateCacheLoader cacheLoader = new AggregateCacheLoader(node); + + cacheLoader.loadByTime(5_000).get(); + + forceCheckpoint(); + + cacheLoader.loadByTime(5_000).get(); + + stopGrid(2, true); + + startGrid(2); + + awaitPartitionMapExchange(); + + checkNoRebalanceAfterRecovery(); + + for (int idx = 0; idx < 3; idx++) + cacheLoader.consistencyCheck(grid(idx)); + + checkCacheContextsConsistencyAfterRecovery(); + } + + /** + * + */ + @Test + public void testRecoveryOnJoinToDifferentBlt() throws Exception { + IgniteEx crd = (IgniteEx) startGridsMultiThreaded(3); + + crd.cluster().active(true); + + IgniteEx node = grid(2); + + AggregateCacheLoader cacheLoader = new AggregateCacheLoader(node); + + cacheLoader.loadByTime(5_000).get(); + + forceCheckpoint(); + + cacheLoader.loadByTime(5_000).get(); + + stopGrid(2, true); + + resetBaselineTopology(); + + startGrid(2); + + resetBaselineTopology(); + + awaitPartitionMapExchange(); + + for (int idx = 0; idx < 3; idx++) + cacheLoader.consistencyCheck(grid(idx)); + + checkCacheContextsConsistencyAfterRecovery(); + } + + /** + * + */ + @Test + public void testRecoveryOnCrushDuringCheckpointOnNodeStart() throws Exception { + IgniteEx crd = (IgniteEx) startGridsMultiThreaded(3, false); + + crd.cluster().active(true); + + IgniteEx node = grid(2); + + AggregateCacheLoader cacheLoader = new AggregateCacheLoader(node); + + cacheLoader.loadByTime(5_000).get(); + + forceCheckpoint(); + + cacheLoader.loadByTime(5_000).get(); + + stopGrid(2, false); + + ioFactory = new CheckpointFailingIoFactory(); + + IgniteInternalFuture startNodeFut = GridTestUtils.runAsync(() -> startGrid(2)); + + try { + startNodeFut.get(); + } + catch (Exception expected) { } + + // Wait until node will leave cluster. + GridTestUtils.waitForCondition(() -> { + try { + grid(2); + } + catch (IgniteIllegalStateException e) { + return true; + } + + return false; + }, getTestTimeout()); + + ioFactory = null; + + // Start node again and check recovery. + startGrid(2); + + awaitPartitionMapExchange(); + + checkNoRebalanceAfterRecovery(); + + for (int idx = 0; idx < 3; idx++) + cacheLoader.consistencyCheck(grid(idx)); + } + + /** + * Checks that cache contexts have consistent parameters after recovery finished and nodes have joined to topology. + */ + private void checkCacheContextsConsistencyAfterRecovery() throws Exception { + IgniteEx crd = grid(0); + + Collection cacheNames = crd.cacheNames(); + + for (String cacheName : cacheNames) { + for (int nodeIdx = 1; nodeIdx < 3; nodeIdx++) { + IgniteEx node = grid(nodeIdx); + + GridCacheContext one = cacheContext(crd, cacheName); + GridCacheContext other = cacheContext(node, cacheName); + + checkCacheContextsConsistency(one, other); + } + } + } + + /** + * @return Cache context with given name from node. + */ + private GridCacheContext cacheContext(IgniteEx node, String cacheName) { + return node.cachex(cacheName).context(); + } + + /** + * Checks that cluster-wide parameters are consistent between two caches. + * + * @param one Cache context. + * @param other Cache context. + */ + private void checkCacheContextsConsistency(GridCacheContext one, GridCacheContext other) { + Assert.assertEquals(one.statisticsEnabled(), other.statisticsEnabled()); + Assert.assertEquals(one.dynamicDeploymentId(), other.dynamicDeploymentId()); + Assert.assertEquals(one.keepBinary(), other.keepBinary()); + Assert.assertEquals(one.updatesAllowed(), other.updatesAllowed()); + Assert.assertEquals(one.group().receivedFrom(), other.group().receivedFrom()); + } + + /** {@inheritDoc} */ + @Override protected FailureHandler getFailureHandler(String igniteInstanceName) { + return new StopNodeFailureHandler(); + } + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return 120 * 1000; + } + + /** + * Method checks that there were no rebalance for all caches (excluding sys cache). + */ + private void checkNoRebalanceAfterRecovery() { + int sysCacheGroupId = CU.cacheId(GridCacheUtils.UTILITY_CACHE_NAME); + + List nodes = G.allGrids(); + + for (final Ignite node : nodes) { + TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(node); + + Set mvccCaches = ((IgniteEx) node).context().cache().cacheGroups().stream() + .flatMap(group -> group.caches().stream()) + .filter(cache -> cache.config().getAtomicityMode() == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) + .map(GridCacheContext::groupId) + .collect(Collectors.toSet()); + + List rebalancedGroups = spi.recordedMessages(true).stream() + .map(msg -> (GridDhtPartitionDemandMessage) msg) + .map(GridCacheGroupIdMessage::groupId) + .filter(grpId -> grpId != sysCacheGroupId) + //TODO: remove following filter when failover for MVCC will be fixed. + .filter(grpId -> !mvccCaches.contains(grpId)) + .distinct() + .collect(Collectors.toList()); + + Assert.assertTrue("There was unexpected rebalance for some groups" + + " [node=" + node.name() + ", groups=" + rebalancedGroups + ']', rebalancedGroups.isEmpty()); + } + } + + /** + * + */ + private static class AggregateCacheLoader { + /** Ignite. */ + final IgniteEx ignite; + + /** Cache loaders. */ + final List cacheLoaders; + + /** + * @param ignite Ignite. + */ + public AggregateCacheLoader(IgniteEx ignite) { + this.ignite = ignite; + + List cacheLoaders = new ArrayList<>(); + + for (String cacheName : ignite.cacheNames()) + cacheLoaders.add(new CacheLoader(ignite, cacheName)); + + this.cacheLoaders = cacheLoaders; + } + + /** + * @param timeMillis Loading time in milliseconds. + */ + public IgniteInternalFuture loadByTime(int timeMillis) { + GridCompoundFuture loadFut = new GridCompoundFuture(); + + for (CacheLoader cacheLoader : cacheLoaders) { + long endTime = U.currentTimeMillis() + timeMillis; + + cacheLoader.stopPredicate = it -> U.currentTimeMillis() >= endTime; + + loadFut.add(GridTestUtils.runAsync(cacheLoader)); + } + + loadFut.markInitialized(); + + return loadFut; + } + + /** + * @param ignite Ignite node to check consistency from. + */ + public void consistencyCheck(IgniteEx ignite) { + for (CacheLoader cacheLoader : cacheLoaders) + cacheLoader.consistencyCheck(ignite); + } + } + + /** + * + */ + static class CacheLoader implements Runnable { + /** Keys space. */ + static final int KEYS_SPACE = 3096; + + /** Ignite. */ + final IgniteEx ignite; + + /** Stop predicate. */ + volatile Predicate stopPredicate; + + /** Cache name. */ + final String cacheName; + + /** Local cache. */ + final Map locCache = new ConcurrentHashMap<>(); + + /** + * @param ignite Ignite. + * @param cacheName Cache name. + */ + public CacheLoader(IgniteEx ignite, String cacheName) { + this.ignite = ignite; + this.cacheName = cacheName; + } + + /** {@inheritDoc} */ + @Override public void run() { + final Predicate predicate = stopPredicate; + + while (!predicate.test(ignite)) { + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + int key = rnd.nextInt(KEYS_SPACE); + + boolean remove = rnd.nextInt(100) <= 20; + + try { + IgniteCache cache = ignite.getOrCreateCache(cacheName); + + if (remove) { + cache.remove(key); + + locCache.remove(key); + } + else { + int[] payload = new int[KEYS_SPACE]; + Arrays.fill(payload, key); + + TestValue val = new TestValue(key, payload); + + cache.put(key, val); + + locCache.put(key, val); + } + + // Throttle against GC. + U.sleep(1); + } + catch (Exception ignored) { } + } + } + + /** + * + */ + public void consistencyCheck(IgniteEx ignite) { + IgniteCache cache = ignite.getOrCreateCache(cacheName); + + for (int key = 0; key < KEYS_SPACE; key++) { + TestValue expectedVal = locCache.get(key); + TestValue actualVal = cache.get(key); + + Assert.assertEquals("Consistency check failed for: " + cache.getName() + ", key=" + key, + expectedVal, actualVal); + } + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + CacheLoader loader = (CacheLoader) o; + + return Objects.equals(cacheName, loader.cacheName); + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return Objects.hash(cacheName); + } + } + + /** + * Test payload with indexed field. + */ + static class TestValue { + /** Indexed field. */ + @QuerySqlField(index = true) + private final int indexedField; + + /** Payload. */ + private final int[] payload; + + /** + * @param indexedField Indexed field. + * @param payload Payload. + */ + public TestValue(int indexedField, int[] payload) { + this.indexedField = indexedField; + this.payload = payload; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + TestValue testValue = (TestValue) o; + + return indexedField == testValue.indexedField && + Arrays.equals(payload, testValue.payload); + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + int result = Objects.hash(indexedField); + + result = 31 * result + Arrays.hashCode(payload); + + return result; + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsCacheRestoreTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsCacheRestoreTest.java index 2db3ca20d2b52..3d8d60c82597b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsCacheRestoreTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsCacheRestoreTest.java @@ -25,21 +25,18 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsCacheRestoreTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Non-persistent data region name. */ private static final String NO_PERSISTENCE_REGION = "no-persistence-region"; @@ -50,8 +47,6 @@ public class IgnitePdsCacheRestoreTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - if (ccfgs != null) { cfg.setCacheConfiguration(ccfgs); @@ -93,6 +88,7 @@ public class IgnitePdsCacheRestoreTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRestoreAndNewCache1() throws Exception { restoreAndNewCache(false); } @@ -100,6 +96,7 @@ public void testRestoreAndNewCache1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestoreAndNewCache2() throws Exception { restoreAndNewCache(true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsCacheWalDisabledOnRebalancingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsCacheWalDisabledOnRebalancingTest.java new file mode 100644 index 0000000000000..0ecde09998b8b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsCacheWalDisabledOnRebalancingTest.java @@ -0,0 +1,272 @@ +/* + * 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. + */ +package org.apache.ignite.internal.processors.cache.persistence.db; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiPredicate; +import org.apache.ignite.mxbean.CacheGroupMetricsMXBean; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR; + +/** + * Test scenarios with rebalancing, IGNITE_DISABLE_WAL_DURING_REBALANCING optimization and topology changes + * such as client nodes join/leave, server nodes from BLT leave/join, server nodes out of BLT join/leave. + */ +@RunWith(JUnit4.class) +public class IgnitePdsCacheWalDisabledOnRebalancingTest extends GridCommonAbstractTest { + /** Block message predicate to set to Communication SPI in node configuration. */ + private IgniteBiPredicate blockMessagePredicate; + + /** */ + private static final int CACHE1_PARTS_NUM = 8; + + /** */ + private static final int CACHE2_PARTS_NUM = 16; + + /** */ + private static final int CACHE3_PARTS_NUM = 32; + + /** */ + private static final int CACHE_SIZE = 2_000; + + /** */ + private static final String CACHE3_NAME = "cache3"; + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + cleanPersistenceDir(); + + System.setProperty(IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING, "true"); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + + System.clearProperty(IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + CacheConfiguration ccfg1 = new CacheConfiguration("cache1") + .setAtomicityMode(CacheAtomicityMode.ATOMIC) + .setCacheMode(CacheMode.REPLICATED) + .setAffinity(new RendezvousAffinityFunction(false, CACHE1_PARTS_NUM)); + + CacheConfiguration ccfg2 = new CacheConfiguration("cache2") + .setBackups(1) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setCacheMode(CacheMode.PARTITIONED) + .setAffinity(new RendezvousAffinityFunction(false, CACHE2_PARTS_NUM)); + + CacheConfiguration ccfg3 = new CacheConfiguration(CACHE3_NAME) + .setBackups(2) + .setAtomicityMode(CacheAtomicityMode.ATOMIC) + .setCacheMode(CacheMode.PARTITIONED) + .setAffinity(new RendezvousAffinityFunction(false, CACHE3_PARTS_NUM)); + + cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg3); + + if ("client".equals(igniteInstanceName)) + cfg.setClientMode(true); + else { + DataStorageConfiguration dsCfg = new DataStorageConfiguration() + .setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4) + .setWalMode(WALMode.LOG_ONLY) + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setPersistenceEnabled(true) + .setMaxSize(256 * 1024 * 1024)); + + cfg.setDataStorageConfiguration(dsCfg); + } + + TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi(); + commSpi.blockMessages(blockMessagePredicate); + + cfg.setCommunicationSpi(commSpi); + + + return cfg; + } + + /** + * If client joins topology during rebalancing process, rebalancing finishes successfully, + * all partitions are owned as expected when rebalancing finishes. + */ + @Test + public void testClientJoinsLeavesDuringRebalancing() throws Exception { + Ignite ig0 = startGrids(2); + + ig0.active(true); + + for (int i = 0; i < 3; i++) + fillCache(ig0.getOrCreateCache("cache" + i), CACHE_SIZE); + + String ig1Name = "node01-" + grid(1).localNode().consistentId(); + + stopGrid(1); + + cleanPersistenceFiles(ig1Name); + + int groupId = ((IgniteEx) ig0).cachex(CACHE3_NAME).context().groupId(); + + blockMessagePredicate = (node, msg) -> { + if (msg instanceof GridDhtPartitionDemandMessage) + return ((GridDhtPartitionDemandMessage) msg).groupId() == groupId; + + return false; + }; + + IgniteEx ig1 = startGrid(1); + + startGrid("client"); + + stopGrid("client"); + + CacheGroupMetricsMXBean mxBean = ig1.cachex(CACHE3_NAME).context().group().mxBean(); + + assertTrue("Unexpected moving partitions count: " + mxBean.getLocalNodeMovingPartitionsCount(), + mxBean.getLocalNodeMovingPartitionsCount() == CACHE3_PARTS_NUM); + + TestRecordingCommunicationSpi commSpi = (TestRecordingCommunicationSpi) ig1 + .configuration().getCommunicationSpi(); + + commSpi.stopBlock(); + + boolean waitResult = GridTestUtils.waitForCondition( + () -> mxBean.getLocalNodeMovingPartitionsCount() == 0, + 30_000); + + assertTrue("Failed to wait for owning all partitions, parts in moving state: " + + mxBean.getLocalNodeMovingPartitionsCount(), waitResult); + } + + /** + * If server nodes from BLT leave topology and then join again after additional keys were put to caches, + * rebalance starts. + * + * Test verifies that all moving partitions get owned after rebalance finishes. + * + * @throws Exception If failed. + */ + @Test + public void testServerNodesFromBltLeavesAndJoinsDuringRebalancing() throws Exception { + Ignite ig0 = startGridsMultiThreaded(4); + + fillCache(ig0.cache(CACHE3_NAME), CACHE_SIZE); + + List nonAffinityKeys1 = nearKeys(grid(1).cache(CACHE3_NAME), 100, CACHE_SIZE / 2); + List nonAffinityKeys2 = nearKeys(grid(2).cache(CACHE3_NAME), 100, CACHE_SIZE / 2); + + stopGrid(1); + stopGrid(2); + + Set nonAffinityKeysSet = new HashSet<>(); + + nonAffinityKeysSet.addAll(nonAffinityKeys1); + nonAffinityKeysSet.addAll(nonAffinityKeys2); + + fillCache(ig0.cache(CACHE3_NAME), nonAffinityKeysSet); + + int groupId = ((IgniteEx) ig0).cachex(CACHE3_NAME).context().groupId(); + + blockMessagePredicate = (node, msg) -> { + if (msg instanceof GridDhtPartitionDemandMessage) + return ((GridDhtPartitionDemandMessage) msg).groupId() == groupId; + + return false; + }; + + IgniteEx ig1 = startGrid(1); + + CacheGroupMetricsMXBean mxBean = ig1.cachex(CACHE3_NAME).context().group().mxBean(); + + TestRecordingCommunicationSpi commSpi = (TestRecordingCommunicationSpi) ig1 + .configuration().getCommunicationSpi(); + + startGrid(2); + + commSpi.stopBlock(); + + boolean allOwned = GridTestUtils.waitForCondition( + () -> mxBean.getLocalNodeMovingPartitionsCount() == 0, 30_000); + + assertTrue("Partitions were not owned, there are " + mxBean.getLocalNodeMovingPartitionsCount() + + " partitions in MOVING state", allOwned); + } + + /** */ + private void cleanPersistenceFiles(String igName) throws Exception { + String ig1DbPath = Paths.get(DFLT_STORE_DIR, igName).toString(); + + File igDbDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), ig1DbPath, false); + + U.delete(igDbDir); + Files.createDirectory(igDbDir.toPath()); + + String ig1DbWalPath = Paths.get(DFLT_STORE_DIR, "wal", igName).toString(); + + U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), ig1DbWalPath, false)); + } + + /** */ + private void fillCache(IgniteCache cache, int cacheSize) { + for (int i = 0; i < cacheSize; i++) + cache.put(i, "value_" + i); + } + + /** */ + private void fillCache(IgniteCache cache, Collection keys) { + for (Integer key : keys) + cache.put(key, "value_" + key); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsDataRegionMetricsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsDataRegionMetricsTest.java index 4a22a2bcd7f1d..27072a4d0f955 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsDataRegionMetricsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsDataRegionMetricsTest.java @@ -36,6 +36,7 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.pagemem.PageIdAllocator; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl; import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore; @@ -43,22 +44,25 @@ import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.nio.file.Files.newDirectoryStream; import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_DATA_REG_DEFAULT_NAME; +import static org.apache.ignite.internal.processors.cache.GridCacheUtils.UTILITY_CACHE_NAME; +import static org.apache.ignite.internal.processors.cache.mvcc.txlog.TxLog.TX_LOG_CACHE_NAME; +import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.META_STORAGE_NAME; +import static org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_ID; +import static org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_NAME; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsDataRegionMetricsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final long INIT_REGION_SIZE = 10 << 20; @@ -81,8 +85,6 @@ public class IgnitePdsDataRegionMetricsTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - DataStorageConfiguration memCfg = new DataStorageConfiguration() .setDefaultDataRegionConfiguration( new DataRegionConfiguration() @@ -94,16 +96,22 @@ public class IgnitePdsDataRegionMetricsTest extends GridCommonAbstractTest { cfg.setDataStorageConfiguration(memCfg); - CacheConfiguration ccfg = new CacheConfiguration<>() - .setName(DEFAULT_CACHE_NAME) - .setCacheMode(CacheMode.PARTITIONED) - .setBackups(1); + CacheConfiguration ccfg = cacheConfiguration(); cfg.setCacheConfiguration(ccfg); return cfg; } + /** + * @return Ignite cache configuration. + */ + protected CacheConfiguration cacheConfiguration() { + return (CacheConfiguration)new CacheConfiguration<>(DEFAULT_CACHE_NAME) + .setCacheMode(CacheMode.PARTITIONED) + .setBackups(1); + } + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -121,6 +129,7 @@ public class IgnitePdsDataRegionMetricsTest extends GridCommonAbstractTest { } /** */ + @Test public void testMemoryUsageSingleNode() throws Exception { DataRegionMetrics initMetrics = null; @@ -136,7 +145,7 @@ public void testMemoryUsageSingleNode() throws Exception { assertTrue(currMetrics.getTotalAllocatedPages() >= currMetrics.getPhysicalMemoryPages()); - final IgniteCache cache = node.getOrCreateCache(DEFAULT_CACHE_NAME); + final IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); Map map = new HashMap<>(); @@ -148,9 +157,9 @@ public void testMemoryUsageSingleNode() throws Exception { cache.putAll(map); - forceCheckpoint(); + forceCheckpoint(node); - checkMetricsConsistency(node, DEFAULT_CACHE_NAME); + checkMetricsConsistency(node); } currMetrics = getDfltRegionMetrics(node); @@ -164,13 +173,14 @@ public void testMemoryUsageSingleNode() throws Exception { } /** */ + @Test public void testMemoryUsageMultipleNodes() throws Exception { IgniteEx node0 = startGrid(0); IgniteEx node1 = startGrid(1); node0.cluster().active(true); - final IgniteCache cache = node0.getOrCreateCache(DEFAULT_CACHE_NAME); + final IgniteCache cache = node0.cache(DEFAULT_CACHE_NAME); Map map = new HashMap<>(); @@ -183,8 +193,8 @@ public void testMemoryUsageMultipleNodes() throws Exception { forceCheckpoint(); - checkMetricsConsistency(node0, DEFAULT_CACHE_NAME); - checkMetricsConsistency(node1, DEFAULT_CACHE_NAME); + checkMetricsConsistency(node0); + checkMetricsConsistency(node1); IgniteEx node2 = startGrid(2); @@ -194,9 +204,9 @@ public void testMemoryUsageMultipleNodes() throws Exception { forceCheckpoint(); - checkMetricsConsistency(node0, DEFAULT_CACHE_NAME); - checkMetricsConsistency(node1, DEFAULT_CACHE_NAME); - checkMetricsConsistency(node2, DEFAULT_CACHE_NAME); + checkMetricsConsistency(node0); + checkMetricsConsistency(node1); + checkMetricsConsistency(node2); stopGrid(1, true); @@ -206,8 +216,8 @@ public void testMemoryUsageMultipleNodes() throws Exception { forceCheckpoint(); - checkMetricsConsistency(node0, DEFAULT_CACHE_NAME); - checkMetricsConsistency(node2, DEFAULT_CACHE_NAME); + checkMetricsConsistency(node0); + checkMetricsConsistency(node2); } /** @@ -215,6 +225,7 @@ public void testMemoryUsageMultipleNodes() throws Exception { * * @throws Exception If failed. */ + @Test public void testCheckpointBufferSize() throws Exception { IgniteEx ig = startGrid(0); @@ -232,6 +243,7 @@ public void testCheckpointBufferSize() throws Exception { * * @throws Exception If failed. */ + @Test public void testUsedCheckpointBuffer() throws Exception { IgniteEx ig = startGrid(0); @@ -292,15 +304,26 @@ private static DataRegionMetrics getDfltRegionMetrics(Ignite node) { throw new RuntimeException("No metrics found for default data region"); } + /** */ + private void checkMetricsConsistency(final IgniteEx node) throws Exception { + checkMetricsConsistency(node, DEFAULT_CACHE_NAME); + checkMetricsConsistency(node, UTILITY_CACHE_NAME); + checkMetricsConsistency(node, TX_LOG_CACHE_NAME); + checkMetricsConsistency(node, METASTORAGE_CACHE_NAME); + } + /** */ private void checkMetricsConsistency(final IgniteEx node, String cacheName) throws Exception { FilePageStoreManager pageStoreMgr = (FilePageStoreManager)node.context().cache().context().pageStore(); assert pageStoreMgr != null : "Persistence is not enabled"; - File cacheWorkDir = pageStoreMgr.cacheWorkDir( - node.getOrCreateCache(cacheName).getConfiguration(CacheConfiguration.class) - ); + boolean metaStore = METASTORAGE_CACHE_NAME.equals(cacheName); + boolean txLog = TX_LOG_CACHE_NAME.equals(cacheName); + + File cacheWorkDir = metaStore ? new File(pageStoreMgr.workDir(), META_STORAGE_NAME) : + txLog ? new File(pageStoreMgr.workDir(), TX_LOG_CACHE_NAME) : + pageStoreMgr.cacheWorkDir(node.cachex(cacheName).configuration()); long totalPersistenceSize = 0; @@ -310,20 +333,23 @@ private void checkMetricsConsistency(final IgniteEx node, String cacheName) thro for (Path path : files) { File file = path.toFile(); - FilePageStore store = (FilePageStore)pageStoreMgr.getStore(CU.cacheId(cacheName), partId(file)); + FilePageStore store = (FilePageStore)pageStoreMgr.getStore(metaStore ? + METASTORAGE_CACHE_ID : CU.cacheId(cacheName), partId(file)); totalPersistenceSize += path.toFile().length() - store.headerSize(); } } - long totalAllocatedPagesFromMetrics = node.context().cache().context() - .cacheContext(CU.cacheId(DEFAULT_CACHE_NAME)) - .group() - .dataRegion() - .memoryMetrics() - .getTotalAllocatedPages(); + GridCacheSharedContext cctx = node.context().cache().context(); + + String regionName = metaStore ? GridCacheDatabaseSharedManager.METASTORE_DATA_REGION_NAME : + txLog ? TX_LOG_CACHE_NAME : + cctx.cacheContext(CU.cacheId(cacheName)).group().dataRegion().config().getName(); + + long totalAllocatedPagesFromMetrics = cctx.database().memoryMetrics(regionName).getTotalAllocatedPages(); - assertEquals(totalPersistenceSize / pageStoreMgr.pageSize(), totalAllocatedPagesFromMetrics); + assertEquals("Number of allocated pages is different than in metrics for [node=" + node.name() + ", cache=" + cacheName + "]", + totalPersistenceSize / pageStoreMgr.pageSize(), totalAllocatedPagesFromMetrics); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsMultiNodePutGetRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsMultiNodePutGetRestartTest.java index d386c172ed05b..1af977c08b9b7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsMultiNodePutGetRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsMultiNodePutGetRestartTest.java @@ -37,18 +37,16 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsMultiNodePutGetRestartTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_CNT = 3; @@ -78,8 +76,6 @@ public class IgnitePdsMultiNodePutGetRestartTest extends GridCommonAbstractTest cfg.setCacheConfiguration(ccfg); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setMarshaller(null); BinaryConfiguration bCfg = new BinaryConfiguration(); @@ -108,6 +104,7 @@ public class IgnitePdsMultiNodePutGetRestartTest extends GridCommonAbstractTest /** * @throws Exception if failed. */ + @Test public void testPutGetSimple() throws Exception { String home = U.getIgniteHome(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPageEvictionDuringPartitionClearTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPageEvictionDuringPartitionClearTest.java index 720b6045d1690..a83afd1018808 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPageEvictionDuringPartitionClearTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPageEvictionDuringPartitionClearTest.java @@ -34,11 +34,16 @@ import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsPageEvictionDuringPartitionClearTest extends GridCommonAbstractTest { /** */ public static final String CACHE_NAME = "cache"; @@ -85,7 +90,11 @@ public class IgnitePdsPageEvictionDuringPartitionClearTest extends GridCommonAbs /** * @throws Exception if failed. */ + @Test public void testPageEvictionOnNodeStart() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + for (int r = 0; r < 3; r++) { cleanPersistenceDir(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPageEvictionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPageEvictionTest.java index 3c07a164f481e..8ae0d06f0fae6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPageEvictionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPageEvictionTest.java @@ -33,18 +33,16 @@ import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsPageEvictionTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Test entry count. */ public static final int ENTRY_CNT = 1_000_000; @@ -73,11 +71,6 @@ public class IgnitePdsPageEvictionTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfg); - cfg.setDiscoverySpi( - new TcpDiscoverySpi() - .setIpFinder(IP_FINDER) - ); - cfg.setMarshaller(null); return cfg; @@ -102,6 +95,7 @@ public class IgnitePdsPageEvictionTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testPageEvictionSql() throws Exception { IgniteEx ig = grid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPartitionPreloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPartitionPreloadTest.java new file mode 100644 index 0000000000000..e9c1753b0ff21 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPartitionPreloadTest.java @@ -0,0 +1,714 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.db; + +import java.util.Collections; +import java.util.List; +import java.util.function.Predicate; +import java.util.function.Supplier; +import javax.cache.Cache; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheMode.LOCAL; + +/** + * Test partition preload for varios cache modes. + */ +@RunWith(JUnit4.class) +public class IgnitePdsPartitionPreloadTest extends GridCommonAbstractTest { + /** Test entry count. */ + public static final int ENTRY_CNT = 500; + + /** Grid count. */ + private static final int GRIDS_CNT = 3; + + /** */ + private static final String CLIENT_GRID_NAME = "client"; + + /** */ + public static final String DEFAULT_REGION = "default"; + + /** */ + private Supplier cfgFactory; + + /** */ + private static final String TEST_ATTR = "testId"; + + /** */ + private static final String NO_CACHE_NODE = "node0"; + + /** */ + private static final String PRIMARY_NODE = "node1"; + + /** */ + private static final String BACKUP_NODE = "node2"; + + /** */ + public static final String MEM = "mem"; + + /** */ + public static final int MB = 1024 * 1024; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + cfg.setClientMode(CLIENT_GRID_NAME.equals(gridName)); + + if (!cfg.isClientMode()) { + String val = "node" + getTestIgniteInstanceIndex(gridName); + cfg.setUserAttributes(Collections.singletonMap(TEST_ATTR, val)); + cfg.setConsistentId(val); + } + + DataStorageConfiguration memCfg = new DataStorageConfiguration() + .setDataRegionConfigurations(new DataRegionConfiguration().setName(MEM).setInitialSize(10 * MB)) + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration(). + setMetricsEnabled(true). + setMaxSize(50L * MB). + setPersistenceEnabled(true). + setName(DEFAULT_REGION)) + .setWalMode(WALMode.LOG_ONLY) + .setWalSegmentSize(16 * MB) + .setPageSize(1024) + .setMetricsEnabled(true); + + cfg.setDataStorageConfiguration(memCfg); + + cfg.setCacheConfiguration(cfgFactory.get()); + + return cfg; + } + + /** + * @param atomicityMode Atomicity mode. + */ + private CacheConfiguration cacheConfiguration(CacheAtomicityMode atomicityMode) { + CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); + + ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); + ccfg.setAffinity(new RendezvousAffinityFunction(false, 32)); + ccfg.setBackups(1); + ccfg.setNodeFilter(new TestIgnitePredicate()); + ccfg.setAtomicityMode(atomicityMode); + + return ccfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** */ + @Test + public void testLocalPreloadPartitionClient() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL).setDataRegionName(MEM); + + startGridsMultiThreaded(GRIDS_CNT); + + IgniteEx client = startGrid("client"); + + assertNotNull(client.cache(DEFAULT_CACHE_NAME)); + + assertFalse(client.cache(DEFAULT_CACHE_NAME).localPreloadPartition(0)); + assertFalse(grid(0).cache(DEFAULT_CACHE_NAME).localPreloadPartition(0)); + } + + /** */ + @Test + public void testLocalPreloadPartitionClientMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT).setDataRegionName(MEM); + + startGridsMultiThreaded(GRIDS_CNT); + + IgniteEx client = startGrid("client"); + + assertNotNull(client.cache(DEFAULT_CACHE_NAME)); + + assertFalse(client.cache(DEFAULT_CACHE_NAME).localPreloadPartition(0)); + assertFalse(grid(0).cache(DEFAULT_CACHE_NAME).localPreloadPartition(0)); + } + + + /** */ + @Test + public void testLocalPreloadPartitionPrimary() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.LOCAL); + } + + /** */ + @Test + public void testLocalPreloadPartitionPrimaryMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.LOCAL); + } + + /** */ + @Test + public void testLocalPreloadPartitionBackup() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition( + () -> G.allGrids().stream().filter(BackupNodePredicate.INSTANCE).findFirst().get(), PreloadMode.LOCAL); + } + + /** */ + @Test + public void testLocalPreloadPartitionBackupMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT); + + preloadPartition( + () -> G.allGrids().stream().filter(BackupNodePredicate.INSTANCE).findFirst().get(), PreloadMode.LOCAL); + } + + /** */ + @Test + public void testPreloadPartitionInMemoryRemote() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL).setDataRegionName(MEM); + + startGridsMultiThreaded(GRIDS_CNT); + + IgniteEx client = startGrid("client"); + + assertNotNull(client.cache(DEFAULT_CACHE_NAME)); + + try { + client.cache(DEFAULT_CACHE_NAME).preloadPartition(0); + + fail("Exception is expected"); + } + catch (Exception e) { + log.error("Expected", e); + } + } + + /** */ + @Test + public void testPreloadPartitionInMemoryRemoteMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT).setDataRegionName(MEM); + + startGridsMultiThreaded(GRIDS_CNT); + + IgniteEx client = startGrid("client"); + + assertNotNull(client.cache(DEFAULT_CACHE_NAME)); + + try { + client.cache(DEFAULT_CACHE_NAME).preloadPartition(0); + + fail("Exception is expected"); + } + catch (Exception e) { + log.error("Expected", e); + } + } + + /** */ + @Test + public void testPreloadPartitionInMemoryLocal() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL).setDataRegionName(MEM); + + startGridsMultiThreaded(GRIDS_CNT); + + int key = 0; + + Ignite prim = primaryNode(key, DEFAULT_CACHE_NAME); + + int part = prim.affinity(DEFAULT_CACHE_NAME).partition(key); + + try { + prim.cache(DEFAULT_CACHE_NAME).preloadPartition(part); + + fail("Exception is expected"); + } + catch (Exception e) { + log.error("Expected", e); + } + } + + /** */ + @Test + public void testPreloadPartitionInMemoryLocalMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT).setDataRegionName(MEM); + + startGridsMultiThreaded(GRIDS_CNT); + + int key = 0; + + Ignite prim = primaryNode(key, DEFAULT_CACHE_NAME); + + int part = prim.affinity(DEFAULT_CACHE_NAME).partition(key); + + try { + prim.cache(DEFAULT_CACHE_NAME).preloadPartition(part); + + fail("Exception is expected"); + } + catch (Exception e) { + log.error("Expected", e); + } + } + + /** */ + @Test + public void testPreloadPartitionTransactionalClientSync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition(() -> { + try { + return startGrid(CLIENT_GRID_NAME); + } + catch (Exception e) { + throw new RuntimeException(e); + } + }, PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalClientSyncMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT); + + preloadPartition(() -> { + try { + return startGrid(CLIENT_GRID_NAME); + } + catch (Exception e) { + throw new RuntimeException(e); + } + }, PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalClientAsync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition(() -> { + try { + return startGrid(CLIENT_GRID_NAME); + } + catch (Exception e) { + throw new RuntimeException(e); + } + }, PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalClientAsyncMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT); + + preloadPartition(() -> { + try { + return startGrid(CLIENT_GRID_NAME); + } + catch (Exception e) { + throw new RuntimeException(e); + } + }, PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalNodeFilteredSync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition(() -> grid(0), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalNodeFilteredSyncMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT); + + preloadPartition(() -> grid(0), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalNodeFilteredAsync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition(() -> grid(0), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalNodeFilteredAsyncMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition(() -> grid(0), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalPrimarySync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalPrimarySyncMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalPrimaryAsync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalPrimaryAsyncMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalBackupSync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition( + () -> G.allGrids().stream().filter(BackupNodePredicate.INSTANCE).findFirst().get(), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalBackupSyncMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT); + + preloadPartition( + () -> G.allGrids().stream().filter(BackupNodePredicate.INSTANCE).findFirst().get(), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalBackupAsync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL); + + preloadPartition( + () -> G.allGrids().stream().filter(BackupNodePredicate.INSTANCE).findFirst().get(), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionTransactionalBackupAsyncMvcc() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT); + + preloadPartition( + () -> G.allGrids().stream().filter(BackupNodePredicate.INSTANCE).findFirst().get(), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionAtomicClientSync() throws Exception { + cfgFactory = () -> cacheConfiguration(ATOMIC); + + preloadPartition(() -> { + try { + return startGrid(CLIENT_GRID_NAME); + } + catch (Exception e) { + throw new RuntimeException(e); + } + }, PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionAtomicClientAsync() throws Exception { + cfgFactory = () -> cacheConfiguration(ATOMIC); + + preloadPartition(() -> { + try { + return startGrid(CLIENT_GRID_NAME); + } + catch (Exception e) { + throw new RuntimeException(e); + } + }, PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionAtomicNodeFilteredSync() throws Exception { + cfgFactory = () -> cacheConfiguration(ATOMIC); + + preloadPartition(() -> grid(0), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionAtomicNodeFilteredAsync() throws Exception { + cfgFactory = () -> cacheConfiguration(ATOMIC); + + preloadPartition(() -> grid(0), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionAtomicPrimarySync() throws Exception { + cfgFactory = () -> cacheConfiguration(ATOMIC); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionAtomicPrimaryAsync() throws Exception { + cfgFactory = () -> cacheConfiguration(ATOMIC); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadPartitionAtomicBackupSync() throws Exception { + cfgFactory = () -> cacheConfiguration(ATOMIC); + + preloadPartition( + () -> G.allGrids().stream().filter(BackupNodePredicate.INSTANCE).findFirst().get(), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadPartitionAtomicBackupAsync() throws Exception { + cfgFactory = () -> cacheConfiguration(ATOMIC); + + preloadPartition( + () -> G.allGrids().stream().filter(BackupNodePredicate.INSTANCE).findFirst().get(), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadLocalTransactionalSync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL).setCacheMode(LOCAL); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadLocalTransactionalSyncMvcc() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT).setCacheMode(LOCAL); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.SYNC); + } + + /** */ + @Test + public void testPreloadLocalTransactionalAsync() throws Exception { + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL).setCacheMode(LOCAL); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.ASYNC); + } + + /** */ + @Test + public void testPreloadLocalTransactionalAsyncMvcc() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + cfgFactory = () -> cacheConfiguration(TRANSACTIONAL_SNAPSHOT).setCacheMode(LOCAL); + + preloadPartition( + () -> G.allGrids().stream().filter(PrimaryNodePredicate.INSTANCE).findFirst().get(), PreloadMode.ASYNC); + } + + /** + * @param execNodeFactory Test node factory. + * @param preloadMode Preload mode. + */ + private void preloadPartition(Supplier execNodeFactory, PreloadMode preloadMode) throws Exception { + Ignite crd = startGridsMultiThreaded(GRIDS_CNT); + + Ignite testNode = grid(1); + + Object consistentId = testNode.cluster().localNode().consistentId(); + + assertEquals(PRIMARY_NODE, testNode.cluster().localNode().consistentId()); + + boolean locCacheMode = testNode.cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getCacheMode() == LOCAL; + + Integer key = primaryKey(testNode.cache(DEFAULT_CACHE_NAME)); + + int preloadPart = crd.affinity(DEFAULT_CACHE_NAME).partition(key); + + int cnt = 0; + + try (IgniteDataStreamer streamer = testNode.dataStreamer(DEFAULT_CACHE_NAME)) { + int k = 0; + + while (cnt < ENTRY_CNT) { + if (testNode.affinity(DEFAULT_CACHE_NAME).partition(k) == preloadPart) { + streamer.addData(k, k); + + cnt++; + } + + k++; + } + } + + forceCheckpoint(); + + stopAllGrids(); + + startGridsMultiThreaded(GRIDS_CNT); + + testNode = G.allGrids().stream(). + filter(ignite -> PRIMARY_NODE.equals(ignite.cluster().localNode().consistentId())).findFirst().get(); + + if (!locCacheMode) + assertEquals(testNode, primaryNode(key, DEFAULT_CACHE_NAME)); + + Ignite execNode = execNodeFactory.get(); + + switch (preloadMode) { + case SYNC: + execNode.cache(DEFAULT_CACHE_NAME).preloadPartition(preloadPart); + + if (locCacheMode) { + testNode = G.allGrids().stream().filter(ignite -> + ignite.cluster().localNode().consistentId().equals(consistentId)).findFirst().get(); + } + + break; + case ASYNC: + execNode.cache(DEFAULT_CACHE_NAME).preloadPartitionAsync(preloadPart).get(); + + if (locCacheMode) { + testNode = G.allGrids().stream().filter(ignite -> + ignite.cluster().localNode().consistentId().equals(consistentId)).findFirst().get(); + } + + break; + case LOCAL: + assertTrue(execNode.cache(DEFAULT_CACHE_NAME).localPreloadPartition(preloadPart)); + + testNode = execNode; // For local preloading testNode == execNode + + break; + } + + long c0 = testNode.dataRegionMetrics(DEFAULT_REGION).getPagesRead(); + + // After partition preloading no pages should be read from store. + List> list = U.arrayList(testNode.cache(DEFAULT_CACHE_NAME).localEntries(), 1000); + + assertEquals(ENTRY_CNT, list.size()); + + assertEquals("Read pages count must be same", c0, testNode.dataRegionMetrics(DEFAULT_REGION).getPagesRead()); + } + + /** */ + private static class TestIgnitePredicate implements IgnitePredicate { + /** {@inheritDoc} */ + @Override public boolean apply(ClusterNode node) { + return !NO_CACHE_NODE.equals(node.attribute(TEST_ATTR)); + } + } + + /** */ + private static class PrimaryNodePredicate implements Predicate { + /** */ + private static final PrimaryNodePredicate INSTANCE = new PrimaryNodePredicate(); + + /** {@inheritDoc} */ + @Override public boolean test(Ignite ignite) { + return PRIMARY_NODE.equals(ignite.cluster().localNode().consistentId()); + } + } + + /** */ + private static class BackupNodePredicate implements Predicate { + /** */ + private static final BackupNodePredicate INSTANCE = new BackupNodePredicate(); + + /** {@inheritDoc} */ + @Override public boolean test(Ignite ignite) { + return BACKUP_NODE.equals(ignite.cluster().localNode().consistentId()); + } + } + + /** */ + private enum PreloadMode { + /** Sync. */ SYNC, + /** Async. */ASYNC, + /** Local. */LOCAL; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsRebalancingOnNotStableTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsRebalancingOnNotStableTopologyTest.java index 8b3c8757c57fc..0798bcbecc648 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsRebalancingOnNotStableTopologyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsRebalancingOnNotStableTopologyTest.java @@ -33,8 +33,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * We start writing to unstable cluster. @@ -42,6 +46,7 @@ * There will be entries in WAL which belongs to evicted partitions. * We should ignore them (not throw exceptions). This point is tested. */ +@RunWith(JUnit4.class) public class IgnitePdsRebalancingOnNotStableTopologyTest extends GridCommonAbstractTest { /** Checkpoint frequency. */ private static final long CHECKPOINT_FREQUENCY = 2_000_000; @@ -49,13 +54,14 @@ public class IgnitePdsRebalancingOnNotStableTopologyTest extends GridCommonAbstr /** Cluster size. */ private static final int CLUSTER_SIZE = 5; - /** */ - private static final String CACHE_NAME = "cache1"; - /** * @throws Exception When fails. */ + @Test public void test() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + Ignite ex = startGrid(0); ex.active(true); @@ -79,7 +85,7 @@ public void test() throws Exception { startLatch.countDown(); - IgniteCache cache1 = ex1.cache(CACHE_NAME); + IgniteCache cache1 = ex1.cache(DEFAULT_CACHE_NAME); int key = keyCnt.get(); @@ -139,7 +145,7 @@ public void test() throws Exception { checkTopology(CLUSTER_SIZE); - IgniteCache cache1 = ex.cache(CACHE_NAME); + IgniteCache cache1 = ex.cache(DEFAULT_CACHE_NAME); assert keyCnt.get() > 0; @@ -155,7 +161,7 @@ public void test() throws Exception { cfg.setActiveOnStart(false); - CacheConfiguration ccfg = new CacheConfiguration<>(CACHE_NAME); + CacheConfiguration ccfg = defaultCacheConfiguration(); ccfg.setPartitionLossPolicy(PartitionLossPolicy.READ_ONLY_SAFE); ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsReserveWalSegmentsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsReserveWalSegmentsTest.java index 5885b7a5ed869..c24ea69647aa1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsReserveWalSegmentsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsReserveWalSegmentsTest.java @@ -29,21 +29,18 @@ import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory; import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE; /** * Test correctness of truncating unused WAL segments. */ +@RunWith(JUnit4.class) public class IgnitePdsReserveWalSegmentsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { System.setProperty(IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, "2"); @@ -52,8 +49,6 @@ public class IgnitePdsReserveWalSegmentsTest extends GridCommonAbstractTest { cfg.setConsistentId(gridName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setAffinity(new RendezvousAffinityFunction(false, 32)); @@ -96,6 +91,7 @@ public class IgnitePdsReserveWalSegmentsTest extends GridCommonAbstractTest { * * @throws Exception if failed. */ + @Test public void testWalManagerRangeReservation() throws Exception { IgniteEx ig0 = prepareGrid(4); @@ -125,6 +121,7 @@ public void testWalManagerRangeReservation() throws Exception { * * @throws Exception if failed. */ + @Test public void testWalDoesNotTruncatedWhenSegmentReserved() throws Exception { IgniteEx ig0 = prepareGrid(4); diff --git a/modules/web-console/frontend/app/modules/branding/header-title.directive.js b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsReserveWalSegmentsWithCompactionTest.java similarity index 61% rename from modules/web-console/frontend/app/modules/branding/header-title.directive.js rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsReserveWalSegmentsWithCompactionTest.java index f67439c0a64da..bc34f2905b61c 100644 --- a/modules/web-console/frontend/app/modules/branding/header-title.directive.js +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsReserveWalSegmentsWithCompactionTest.java @@ -15,30 +15,20 @@ * limitations under the License. */ -const template = ` -

    {{::title.text}}

    -`; +package org.apache.ignite.internal.processors.cache.persistence.db; + +import org.apache.ignite.configuration.IgniteConfiguration; /** - * @param {import('./branding.service').default} branding + * */ -export default function factory(branding) { - function controller() { - const ctrl = this; +public class IgnitePdsReserveWalSegmentsWithCompactionTest extends IgnitePdsReserveWalSegmentsTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); - ctrl.text = branding.headerText; - } + cfg.getDataStorageConfiguration().setWalCompactionEnabled(true); - return { - restrict: 'E', - template, - controller, - controllerAs: 'title', - replace: true - }; + return cfg; + } } - -factory.$inject = ['IgniteBranding']; - diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsTransactionsHangTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsTransactionsHangTest.java index 36afe32e1bda2..57022a8cded02 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsTransactionsHangTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsTransactionsHangTest.java @@ -40,12 +40,13 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; @@ -53,10 +54,8 @@ /** * Checks that transactions don't hang during checkpoint creation. */ +@RunWith(JUnit4.class) public class IgnitePdsTransactionsHangTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Page cache size. */ private static final long PAGE_CACHE_SIZE = 512L * 1024 * 1024; @@ -100,10 +99,6 @@ public class IgnitePdsTransactionsHangTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - cfg.setDiscoverySpi(discoSpi); - BinaryConfiguration binaryCfg = new BinaryConfiguration(); binaryCfg.setCompactFooter(false); cfg.setBinaryConfiguration(binaryCfg); @@ -164,6 +159,7 @@ private CacheConfiguration getCacheConfiguration() { * * @throws Exception If failed. * */ + @Test public void testTransactionsDontHang() throws Exception { try { final Ignite g = startGrids(2); @@ -193,10 +189,17 @@ public void testTransactionsDontHang() throws Exception { TestEntity entity = TestEntity.newTestEntity(locRandom); - try (Transaction tx = g.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - cache.put(randomKey, entity); + while (true) { + try (Transaction tx = g.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.put(randomKey, entity); + + tx.commit(); - tx.commit(); + break; + } + catch (Exception e) { + MvccFeatureChecker.assertMvccWriteConflict(e); + } } operationCnt.increment(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWholeClusterRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWholeClusterRestartTest.java index 7db84a3d8c49b..c7375c6b4953f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWholeClusterRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWholeClusterRestartTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.configuration.WALMode; import org.apache.ignite.spi.checkpoint.noop.NoopCheckpointSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsWholeClusterRestartTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 5; @@ -45,9 +49,6 @@ public class IgnitePdsWholeClusterRestartTest extends GridCommonAbstractTest { /** */ private static final int ENTRIES_COUNT = 1_000; - /** */ - public static final String CACHE_NAME = "cache1"; - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); @@ -59,9 +60,8 @@ public class IgnitePdsWholeClusterRestartTest extends GridCommonAbstractTest { cfg.setDataStorageConfiguration(memCfg); - CacheConfiguration ccfg1 = new CacheConfiguration(); + CacheConfiguration ccfg1 = defaultCacheConfiguration(); - ccfg1.setName(CACHE_NAME); ccfg1.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); ccfg1.setRebalanceMode(CacheRebalanceMode.SYNC); ccfg1.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); @@ -97,6 +97,7 @@ public class IgnitePdsWholeClusterRestartTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testRestarts() throws Exception { startGrids(GRID_CNT); @@ -104,7 +105,7 @@ public void testRestarts() throws Exception { awaitPartitionMapExchange(); - try (IgniteDataStreamer ds = ignite(0).dataStreamer(CACHE_NAME)) { + try (IgniteDataStreamer ds = ignite(0).dataStreamer(DEFAULT_CACHE_NAME)) { for (int i = 0; i < ENTRIES_COUNT; i++) ds.addData(i, i); } @@ -131,9 +132,9 @@ public void testRestarts() throws Exception { Ignite ig = ignite(g); for (int k = 0; k < ENTRIES_COUNT; k++) - assertEquals("Failed to read [g=" + g + ", part=" + ig.affinity(CACHE_NAME).partition(k) + - ", nodes=" + ig.affinity(CACHE_NAME).mapKeyToPrimaryAndBackups(k) + ']', - k, ig.cache(CACHE_NAME).get(k)); + assertEquals("Failed to read [g=" + g + ", part=" + ig.affinity(DEFAULT_CACHE_NAME).partition(k) + + ", nodes=" + ig.affinity(DEFAULT_CACHE_NAME).mapKeyToPrimaryAndBackups(k) + ']', + k, ig.cache(DEFAULT_CACHE_NAME).get(k)); } } finally { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlTest.java index bb371dce29bca..2e89ec961fa17 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlTest.java @@ -38,14 +38,17 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.PA; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test TTL worker with persistence enabled */ +@RunWith(JUnit4.class) public class IgnitePdsWithTtlTest extends GridCommonAbstractTest { /** */ public static final String CACHE_NAME = "expirableCache"; @@ -56,11 +59,10 @@ public class IgnitePdsWithTtlTest extends GridCommonAbstractTest { /** */ public static final int ENTRIES = 100_000; - /** */ - private static final TcpDiscoveryVmIpFinder FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + super.beforeTest(); cleanPersistenceDir(); @@ -80,11 +82,6 @@ public class IgnitePdsWithTtlTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { final IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - disco.setIpFinder(FINDER); - - cfg.setDiscoverySpi(disco); - final CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setName(CACHE_NAME); ccfg.setAffinity(new RendezvousAffinityFunction(false, 32)); @@ -110,6 +107,7 @@ public class IgnitePdsWithTtlTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testTtlIsApplied() throws Exception { loadAndWaitForCleanup(false); } @@ -117,6 +115,7 @@ public void testTtlIsApplied() throws Exception { /** * @throws Exception if failed. */ + @Test public void testTtlIsAppliedAfterRestart() throws Exception { loadAndWaitForCleanup(true); } @@ -148,6 +147,7 @@ private void loadAndWaitForCleanup(boolean restartGrid) throws Exception { /** * @throws Exception if failed. */ + @Test public void testRebalancingWithTtlExpirable() throws Exception { IgniteEx srv = startGrid(0); srv.cluster().active(true); @@ -171,6 +171,7 @@ public void testRebalancingWithTtlExpirable() throws Exception { /** * @throws Exception if failed. */ + @Test public void testStartStopAfterRebalanceWithTtlExpirable() throws Exception { try { IgniteEx srv = startGrid(0); @@ -243,4 +244,4 @@ private void pringStatistics(IgniteCacheProxy cache, String msg) { cache.context().printMemoryStats(); System.out.println("}} " + msg); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlTest2.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlTest2.java new file mode 100644 index 0000000000000..6a0e39deaa9e9 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlTest2.java @@ -0,0 +1,145 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.db; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.cache.expiry.Duration; +import javax.cache.expiry.ModifiedExpiryPolicy; +import org.apache.ignite.Ignite; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.NoOpFailureHandler; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; + +@RunWith(JUnit4.class) +public class IgnitePdsWithTtlTest2 extends GridCommonAbstractTest { + /** */ + public static AtomicBoolean handleFired = new AtomicBoolean(false); + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.EXPIRATION); + + super.beforeTest(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + //protection if test failed to finish, e.g. by error + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** */ + public CacheConfiguration getCacheConfiguration(String name) { + CacheConfiguration ccfg = new CacheConfiguration(); + + ccfg.setName(name); + + ccfg.setAtomicityMode(ATOMIC); + + ccfg.setBackups(1); + + ccfg.setAffinity(new RendezvousAffinityFunction(false, 32768)); + + ccfg.setEagerTtl(true); + + ccfg.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 20))); + + return ccfg; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + final IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setDataStorageConfiguration( + new DataStorageConfiguration() + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setMaxSize(100L * 1024 * 1024) + .setPersistenceEnabled(true) + )); + + cfg.setCacheConfiguration( + getCacheConfiguration("cache_1"), + getCacheConfiguration("cache_2"), + getCacheConfiguration("cache_3"), + getCacheConfiguration("cache_4"), + getCacheConfiguration("cache_5"), + getCacheConfiguration("cache_6"), + getCacheConfiguration("cache_7"), + getCacheConfiguration("cache_8"), + getCacheConfiguration("cache_9"), + getCacheConfiguration("cache_10"), + getCacheConfiguration("cache_11"), + getCacheConfiguration("cache_12"), + getCacheConfiguration("cache_13"), + getCacheConfiguration("cache_14"), + getCacheConfiguration("cache_15"), + getCacheConfiguration("cache_16"), + getCacheConfiguration("cache_17"), + getCacheConfiguration("cache_18"), + getCacheConfiguration("cache_19"), + getCacheConfiguration("cache_20") + ); + + cfg.setFailureHandler(new CustomStopNodeOrHaltFailureHandler()); + + return cfg; + } + + /** + * @throws Exception if failed. + */ + @Test + public void testTtlIsAppliedToManyCaches() throws Exception { + handleFired.set(false); + + startGrid(0); + + assertFalse(handleFired.get()); + } + + private class CustomStopNodeOrHaltFailureHandler extends NoOpFailureHandler { + /** {@inheritDoc} */ + @Override public boolean onFailure(Ignite ignite, FailureContext failureCtx) { + boolean res = super.handle(ignite, failureCtx); + + handleFired.set(true); + + return res; + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteSequentialNodeCrashRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteSequentialNodeCrashRecoveryTest.java new file mode 100644 index 0000000000000..b4ad8c853a69e --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgniteSequentialNodeCrashRecoveryTest.java @@ -0,0 +1,339 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.db; + +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.file.OpenOption; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.FailureHandler; +import org.apache.ignite.failure.StopNodeFailureHandler; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgnitionEx; +import org.apache.ignite.internal.pagemem.FullPageId; +import org.apache.ignite.internal.pagemem.PageIdAllocator; +import org.apache.ignite.internal.pagemem.PageIdUtils; +import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIODecorator; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; +import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; +import org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage; +import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl; +import org.apache.ignite.internal.util.typedef.internal.CU; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * + */ +public class IgniteSequentialNodeCrashRecoveryTest extends GridCommonAbstractTest { + /** */ + private static final int PAGE_SIZE = 4096; + + /** */ + private FileIOFactory fileIoFactory; + + /** */ + private FailureHandler failureHnd; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + DataStorageConfiguration dsCfg = new DataStorageConfiguration() + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setMaxSize(512 * 1024 * 1024).setPersistenceEnabled(true)) + // Set large checkpoint frequency to make sure no checkpoint happens right after the node start. + .setCheckpointFrequency(getTestTimeout()) + .setPageSize(PAGE_SIZE); + + if (fileIoFactory != null) + dsCfg.setFileIOFactory(fileIoFactory); + + cfg + .setDataStorageConfiguration(dsCfg) + .setConsistentId(igniteInstanceName); + + if (failureHnd != null) + cfg.setFailureHandler(failureHnd); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testCrashOnCheckpointAfterLogicalRecovery() throws Exception { + IgniteEx g = startGrid(0); + + g.cluster().active(true); + + g.getOrCreateCache(new CacheConfiguration<>("cache") + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setAffinity(new RendezvousAffinityFunction(false, 8))); + + disableCheckpoints(g); + + { + IgniteCache cache = g.cache("cache"); + + // Now that checkpoints are disabled, put some data to the cache. + GridTestUtils.runMultiThreaded(() -> { + for (int i = 0; i < 400; i++) + cache.put(i % 100, Thread.currentThread().getName()); + }, 64, "update-thread"); + } + + Collection dirtyAfterLoad = captureDirtyPages(g); + + stopGrid(0); + + CheckpointFailingIoFactory f = (CheckpointFailingIoFactory)(fileIoFactory = new CheckpointFailingIoFactory(false)); + StopLatchFailureHandler fh = (StopLatchFailureHandler)(failureHnd = new StopLatchFailureHandler()); + + // Now start the node. Since the checkpoint was disabled, logical recovery will be performed. + g = startGrid(0); + + fileIoFactory = null; + failureHnd = null; + + // Capture dirty pages after logical recovery & updates. + Collection dirtyAfterRecoveryAndUpdates = captureDirtyPages(g); + + f.startFailing(); + + triggerCheckpoint(g); + + assertTrue("Failed to wait for checkpoint failure", fh.waitFailed()); + + // Capture pages we marked on first run and did not mark on second run. + dirtyAfterLoad.removeAll(dirtyAfterRecoveryAndUpdates); + + assertFalse(dirtyAfterLoad.isEmpty()); + + fileIoFactory = new CheckingIoFactory(dirtyAfterLoad); + + g = startGrid(0); + + { + IgniteCache cache = g.cache("cache"); + + for (int i = 0; i < 400; i++) + cache.put(100 + (i % 100), Thread.currentThread().getName()); + + for (int i = 0; i < 200; i++) + assertTrue("i=" + i, cache.containsKey(i)); + } + } + + /** + * + */ + private void disableCheckpoints(IgniteEx g) throws Exception { + GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)g.context() + .cache().context().database(); + + dbMgr.enableCheckpoints(false).get(); + } + + /** + * @param ig Ignite instance. + */ + private void triggerCheckpoint(IgniteEx ig) { + GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)ig.context() + .cache().context().database(); + + dbMgr.wakeupForCheckpoint("test-should-fail"); + } + + /** + * @param g Ignite instance. + * @throws IgniteCheckedException If failed. + */ + private Collection captureDirtyPages(IgniteEx g) throws IgniteCheckedException { + GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)g.context() + .cache().context().database(); + + // Capture a set of dirty pages. + PageMemoryImpl pageMem = (PageMemoryImpl)dbMgr.dataRegion("default").pageMemory(); + + return pageMem.dirtyPages(); + } + + /** + * + */ + private class StopLatchFailureHandler extends StopNodeFailureHandler { + /** */ + private CountDownLatch stopLatch = new CountDownLatch(1); + + /** {@inheritDoc} */ + @Override public boolean handle(Ignite ignite, FailureContext failureCtx) { + new Thread( + new Runnable() { + @Override public void run() { + U.error(ignite.log(), "Stopping local node on Ignite failure: [failureCtx=" + failureCtx + ']'); + + IgnitionEx.stop(ignite.name(), true, true); + + stopLatch.countDown(); + } + }, + "node-stopper" + ).start(); + + return true; + } + + /** + * @return {@code true} if wait succeeded. + * @throws InterruptedException If current thread was interrupted. + */ + public boolean waitFailed() throws InterruptedException { + return stopLatch.await(getTestTimeout(), TimeUnit.MILLISECONDS); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(StopNodeFailureHandler.class, this, "super", super.toString()); + } + } + + /** + * + */ + private static class CheckingIoFactory implements FileIOFactory { + /** */ + private final transient Collection forbiddenPages; + + /** + * @param forbiddenPages Forbidden pages. + */ + private CheckingIoFactory(Collection forbiddenPages) { + this.forbiddenPages = forbiddenPages; + } + + /** {@inheritDoc} */ + @Override public FileIO create(File file, OpenOption... modes) throws IOException { + FileIO delegate = new RandomAccessFileIOFactory().create(file, modes); + + if (file.getName().contains("part-")) + return new CheckingFileIO(file, delegate, forbiddenPages); + + return delegate; + } + } + + /** + * + */ + private static class CheckingFileIO extends FileIODecorator { + /** */ + private int grpId; + + /** */ + private int partId; + + /** */ + private Collection forbiddenPages; + + /** + * @param file File. + * @param delegate Delegate. + * @param forbiddenPages Forbidden pages. + */ + public CheckingFileIO(File file, FileIO delegate, Collection forbiddenPages) { + super(delegate); + this.forbiddenPages = forbiddenPages; + + String fileName = file.getName(); + + int start = fileName.indexOf("part-") + 5; + int end = fileName.indexOf(".bin"); + partId = Integer.parseInt(fileName.substring(start, end)); + + String path = file.getPath(); + + if (path.contains(File.separator + "metastorage" + File.separator)) + grpId = MetaStorage.METASTORAGE_CACHE_ID; + else { + start = path.indexOf("cache-") + 6; + end = path.indexOf(File.separator, start); + + grpId = start >= 0 ? CU.cacheId(path.substring(start, end)) : 0; + } + } + + /** {@inheritDoc} */ + @Override public int write(ByteBuffer srcBuf) throws IOException { + throw new AssertionError("Should not be called"); + } + + /** {@inheritDoc} */ + @Override public int write(ByteBuffer srcBuf, long position) throws IOException { + FullPageId fId = new FullPageId( + PageIdUtils.pageId(partId, PageIdAllocator.FLAG_DATA, (int)(position / PAGE_SIZE) - 1), + grpId); + + if (forbiddenPages.contains(fId)) + throw new AssertionError("Attempted to write invalid page on recovery: " + fId); + + return super.write(srcBuf, position); + } + + /** {@inheritDoc} */ + @Override public int write(byte[] buf, int off, int len) throws IOException { + throw new AssertionError("Should not be called"); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/SlowHistoricalRebalanceSmallHistoryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/SlowHistoricalRebalanceSmallHistoryTest.java index bd1a1a9cc3575..bb47aef925d59 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/SlowHistoricalRebalanceSmallHistoryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/SlowHistoricalRebalanceSmallHistoryTest.java @@ -22,6 +22,7 @@ import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.cluster.ClusterNode; @@ -39,18 +40,16 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class SlowHistoricalRebalanceSmallHistoryTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Slow rebalance cache name. */ private static final String SLOW_REBALANCE_CACHE = "b13813ce"; @@ -69,8 +68,6 @@ public class SlowHistoricalRebalanceSmallHistoryTest extends GridCommonAbstractT cfg.setConsistentId(name); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setWalHistorySize(WAL_HISTORY_SIZE) @@ -118,13 +115,14 @@ public class SlowHistoricalRebalanceSmallHistoryTest extends GridCommonAbstractT /** * Checks that we reserve and release the same WAL index on exchange. */ + @Test public void testReservation() throws Exception { IgniteEx ig = startGrid(0); ig.cluster().active(true); - ig.getOrCreateCache(new CacheConfiguration<>() - .setName(SLOW_REBALANCE_CACHE) + ig.getOrCreateCache(new CacheConfiguration<>(SLOW_REBALANCE_CACHE) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setAffinity(new RendezvousAffinityFunction(false, 1)) .setBackups(1) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) @@ -141,8 +139,8 @@ public void testReservation() throws Exception { resetBaselineTopology(); - IgniteCache anotherCache = ig.getOrCreateCache(new CacheConfiguration<>() - .setName(REGULAR_CACHE) + IgniteCache anotherCache = ig.getOrCreateCache(new CacheConfiguration<>(REGULAR_CACHE) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) .setAffinity(new RendezvousAffinityFunction(false, 1)) .setBackups(1) .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) @@ -193,9 +191,6 @@ public void testReservation() throws Exception { * */ private static class RebalanceBlockingSPI extends TcpCommunicationSpi { - /** */ - public static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override public void sendMessage(ClusterNode node, Message msg) throws IgniteSpiException { if (msg instanceof GridIoMessage && ((GridIoMessage)msg).message() instanceof GridDhtPartitionSupplyMessage) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/IgniteCheckpointDirtyPagesForLowLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/IgniteCheckpointDirtyPagesForLowLoadTest.java index 8baa1c301512c..49967204ad3f1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/IgniteCheckpointDirtyPagesForLowLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/IgniteCheckpointDirtyPagesForLowLoadTest.java @@ -36,11 +36,15 @@ import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test generates low load to grid in having some shared groups. Test checks if pages marked dirty after some time will * became reasonable low for 1 put. */ +@RunWith(JUnit4.class) public class IgniteCheckpointDirtyPagesForLowLoadTest extends GridCommonAbstractTest { /** Caches in group. */ private static final int CACHES_IN_GRP = 1; @@ -99,6 +103,7 @@ public class IgniteCheckpointDirtyPagesForLowLoadTest extends GridCommonAbstract /** * @throws Exception if failed. */ + @Test public void testManyCachesAndNotManyPuts() throws Exception { try { IgniteEx ignite = startGrid(0); @@ -206,4 +211,4 @@ private int waitForCurrentCheckpointPagesCounterUpdated(GridCacheDatabaseSharedM return currCpPages; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/IgniteMassLoadSandboxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/IgniteMassLoadSandboxTest.java index f38db0a832448..43948912c5199 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/IgniteMassLoadSandboxTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/checkpoint/IgniteMassLoadSandboxTest.java @@ -57,6 +57,9 @@ import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR; @@ -64,6 +67,7 @@ * Sandbox test to measure progress of grid write operations. If no progress occur during period of time, then thread * dumps are generated. */ +@RunWith(JUnit4.class) public class IgniteMassLoadSandboxTest extends GridCommonAbstractTest { /** Cache name. Random to cover external stores possible problems. */ public static final String CACHE_NAME = "partitioned" + new Random().nextInt(10000000); @@ -173,6 +177,7 @@ public class IgniteMassLoadSandboxTest extends GridCommonAbstractTest { * * @throws Exception if failed. */ + @Test public void testContinuousPutMultithreaded() throws Exception { try { // System.setProperty(IgniteSystemProperties.IGNITE_DIRTY_PAGES_PARALLEL, "true"); @@ -233,6 +238,7 @@ public void testContinuousPutMultithreaded() throws Exception { * * @throws Exception if failed. */ + @Test public void testDataStreamerContinuousPutMultithreaded() throws Exception { try { // System.setProperty(IgniteSystemProperties.IGNITE_DIRTY_PAGES_PARALLEL, "true"); @@ -309,6 +315,7 @@ public void testDataStreamerContinuousPutMultithreaded() throws Exception { * * @throws Exception if failed. */ + @Test public void testCoveredWalLogged() throws Exception { GridStringLogger log0 = null; @@ -484,6 +491,7 @@ private static boolean keepInDb(int id) { * * @throws Exception if failed. */ + @Test public void testPutRemoveMultithreaded() throws Exception { setWalArchAndWorkToSameVal = false; customWalMode = WALMode.LOG_ONLY; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/DefaultPageSizeBackwardsCompatibilityTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/DefaultPageSizeBackwardsCompatibilityTest.java index 739beb4e376e3..7709d9cf81e5f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/DefaultPageSizeBackwardsCompatibilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/DefaultPageSizeBackwardsCompatibilityTest.java @@ -18,7 +18,6 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; @@ -26,18 +25,16 @@ import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class DefaultPageSizeBackwardsCompatibilityTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Client mode. */ private boolean set2kPageSize = true; @@ -51,9 +48,6 @@ public class DefaultPageSizeBackwardsCompatibilityTest extends GridCommonAbstrac @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - discoverySpi.setIpFinder(IP_FINDER); - DataStorageConfiguration memCfg = new DataStorageConfiguration(); if (set2kPageSize) @@ -100,7 +94,8 @@ public class DefaultPageSizeBackwardsCompatibilityTest extends GridCommonAbstrac /** * @throws Exception If failed. */ - public void testStartFrom2kDefaultStore() throws Exception { + @Test + public void testStartFrom16kDefaultStore() throws Exception { startGrids(2); Ignite ig = ignite(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCacheDestroyDuringCheckpointTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCacheDestroyDuringCheckpointTest.java index 62cc244dc1346..1d95bfec22c40 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCacheDestroyDuringCheckpointTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCacheDestroyDuringCheckpointTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for cache creation/deletion with frequent checkpoints. */ +@RunWith(JUnit4.class) public class IgnitePdsCacheDestroyDuringCheckpointTest extends GridCommonAbstractTest { /** */ private static final String NAME_PREFIX = "CACHE-"; @@ -90,6 +94,7 @@ private DataStorageConfiguration createDbConfig() { /** * @throws Exception If fail. */ + @Test public void testCacheCreatePutCheckpointDestroy() throws Exception { IgniteEx ig = startGrid(0); ig.active(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCacheIntegrationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCacheIntegrationTest.java index ba9a00098e81e..c0d351fd85c4d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCacheIntegrationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCacheIntegrationTest.java @@ -38,19 +38,17 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsCacheIntegrationTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_CNT = 3; @@ -83,8 +81,6 @@ public class IgnitePdsCacheIntegrationTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfg); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setMarshaller(null); BinaryConfiguration bCfg = new BinaryConfiguration(); @@ -111,6 +107,7 @@ public class IgnitePdsCacheIntegrationTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testPutGetSimple() throws Exception { startGrids(GRID_CNT); @@ -146,6 +143,7 @@ public void testPutGetSimple() throws Exception { /** * @throws Exception if failed. */ + @Test public void testPutMultithreaded() throws Exception { startGrids(4); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCheckpointSimpleTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCheckpointSimpleTest.java index 0cfcec8450025..6957d551acb4b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCheckpointSimpleTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCheckpointSimpleTest.java @@ -24,13 +24,16 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Puts data into grid, waits for checkpoint to start and then verifies data */ +@RunWith(JUnit4.class) public class IgnitePdsCheckpointSimpleTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @@ -65,6 +68,7 @@ public class IgnitePdsCheckpointSimpleTest extends GridCommonAbstractTest { * Checks if same data can be loaded after checkpoint. * @throws Exception if failed. */ + @Test public void testRecoveryAfterCpEnd() throws Exception { IgniteEx ignite = startGrid(0); @@ -94,7 +98,7 @@ public void testRecoveryAfterCpEnd() throws Exception { * @param i key. * @return value with extra data, which allows to verify */ - @NotNull private String valueWithRedundancyForKey(int i) { + private @NotNull String valueWithRedundancyForKey(int i) { return Strings.repeat(Integer.toString(i), 10); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCheckpointSimulationWithRealCpDisabledTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCheckpointSimulationWithRealCpDisabledTest.java index 620814f85b293..051505c50aaad 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCheckpointSimulationWithRealCpDisabledTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsCheckpointSimulationWithRealCpDisabledTest.java @@ -35,6 +35,7 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheRebalanceMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; @@ -53,6 +54,8 @@ import org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord; import org.apache.ignite.internal.pagemem.wal.record.DataEntry; import org.apache.ignite.internal.pagemem.wal.record.DataRecord; +import org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry; +import org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord; import org.apache.ignite.internal.pagemem.wal.record.PageSnapshot; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.pagemem.wal.record.delta.PartitionMetaStateRecord; @@ -62,6 +65,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.mvcc.MvccVersionImpl; import org.apache.ignite.internal.processors.cache.persistence.DummyPageIO; import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager; @@ -75,20 +79,18 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** - * Test simulated chekpoints, + * Test simulated checkpoints, * Disables integrated check pointer thread */ +@RunWith(JUnit4.class) public class IgnitePdsCheckpointSimulationWithRealCpDisabledTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int TOTAL_PAGES = 1000; @@ -96,17 +98,24 @@ public class IgnitePdsCheckpointSimulationWithRealCpDisabledTest extends GridCom private static final boolean VERBOSE = false; /** Cache name. */ - private static final String cacheName = "cache"; + private static final String CACHE_NAME = "cache"; + + /** Mvcc cache name. */ + private static final String MVCC_CACHE_NAME = "mvccCache"; + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - CacheConfiguration ccfg = new CacheConfiguration(cacheName); + CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME) + .setRebalanceMode(CacheRebalanceMode.NONE); - ccfg.setRebalanceMode(CacheRebalanceMode.NONE); + CacheConfiguration mvccCfg = new CacheConfiguration(MVCC_CACHE_NAME) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) + .setRebalanceMode(CacheRebalanceMode.NONE); - cfg.setCacheConfiguration(ccfg); + cfg.setCacheConfiguration(ccfg, mvccCfg); cfg.setDataStorageConfiguration( new DataStorageConfiguration() @@ -120,12 +129,6 @@ public class IgnitePdsCheckpointSimulationWithRealCpDisabledTest extends GridCom ) ); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - return cfg; } @@ -146,10 +149,11 @@ public class IgnitePdsCheckpointSimulationWithRealCpDisabledTest extends GridCom /** * @throws Exception if failed. */ + @Test public void testCheckpointSimulationMultiThreaded() throws Exception { IgniteEx ig = startGrid(0); - ig.active(true); + ig.cluster().active(true); GridCacheSharedContext shared = ig.context().cache().context(); @@ -164,7 +168,7 @@ public void testCheckpointSimulationMultiThreaded() throws Exception { // Must put something in partition 0 in order to initialize meta page. // Otherwise we will violate page store integrity rules. - ig.cache(cacheName).put(0, 0); + ig.cache(CACHE_NAME).put(0, 0); PageMemory mem = shared.database().dataRegion(null).pageMemory(); @@ -172,7 +176,7 @@ public void testCheckpointSimulationMultiThreaded() throws Exception { try { res = runCheckpointing(ig, (PageMemoryImpl)mem, pageStore, shared.wal(), - shared.cache().cache(cacheName).context().cacheId()); + shared.cache().cache(CACHE_NAME).context().cacheId()); } catch (Throwable th) { log().error("Error while running checkpointing", th); @@ -187,7 +191,7 @@ public void testCheckpointSimulationMultiThreaded() throws Exception { ig = startGrid(0); - ig.active(true); + ig.cluster().active(true); shared = ig.context().cache().context(); @@ -203,14 +207,15 @@ public void testCheckpointSimulationMultiThreaded() throws Exception { /** * @throws Exception if failed. */ + @Test public void testGetForInitialWrite() throws Exception { IgniteEx ig = startGrid(0); - ig.active(true); + ig.cluster().active(true); GridCacheSharedContext shared = ig.context().cache().context(); - int cacheId = shared.cache().cache(cacheName).context().cacheId(); + int cacheId = shared.cache().cache(CACHE_NAME).context().cacheId(); GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)shared.database(); @@ -264,7 +269,7 @@ public void testGetForInitialWrite() throws Exception { ig = startGrid(0); - ig.active(true); + ig.cluster().active(true); shared = ig.context().cache().context(); @@ -303,13 +308,29 @@ public void testGetForInitialWrite() throws Exception { /** * @throws Exception if failed. */ + @Test public void testDataWalEntries() throws Exception { + checkDataWalEntries(false); + } + + /** + * @throws Exception if failed. + */ + @Test + public void testMvccDataWalEntries() throws Exception { + checkDataWalEntries(true); + } + + /** + * @throws Exception if failed. + */ + private void checkDataWalEntries(boolean mvcc) throws Exception { IgniteEx ig = startGrid(0); - ig.active(true); + ig.cluster().active(true); GridCacheSharedContext sharedCtx = ig.context().cache().context(); - GridCacheContext cctx = sharedCtx.cache().cache(cacheName).context(); + GridCacheContext cctx = sharedCtx.cache().cache(mvcc ? MVCC_CACHE_NAME : CACHE_NAME).context(); GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)sharedCtx.database(); IgniteWriteAheadLogManager wal = sharedCtx.wal(); @@ -332,7 +353,10 @@ public void testDataWalEntries() throws Exception { if (op != GridCacheOperation.DELETE) val = cctx.toCacheObject("value-" + i); - entries.add(new DataEntry(cctx.cacheId(), key, val, op, null, cctx.versions().next(), 0L, + entries.add(mvcc ? + new MvccDataEntry(cctx.cacheId(), key, val, op, null, cctx.versions().next(), 0L, + cctx.affinity().partition(i), i, new MvccVersionImpl(1000L, 10L, i + 1 /* Non-zero */)) : + new DataEntry(cctx.cacheId(), key, val, op, null, cctx.versions().next(), 0L, cctx.affinity().partition(i), i)); } @@ -343,17 +367,17 @@ public void testDataWalEntries() throws Exception { wal.flush(start, false); for (DataEntry entry : entries) - wal.log(new DataRecord(entry)); + wal.log(mvcc ? new MvccDataRecord((MvccDataEntry) entry) : new DataRecord(entry)); // Data will not be written to the page store. stopAllGrids(); ig = startGrid(0); - ig.active(true); + ig.cluster().active(true); sharedCtx = ig.context().cache().context(); - cctx = sharedCtx.cache().cache(cacheName).context(); + cctx = sharedCtx.cache().cache(mvcc ? MVCC_CACHE_NAME : CACHE_NAME).context(); db = (GridCacheDatabaseSharedManager)sharedCtx.database(); wal = sharedCtx.wal(); @@ -379,7 +403,10 @@ public void testDataWalEntries() throws Exception { while (idx < entries.size()) { IgniteBiTuple dataRecTup = it.next(); - assert dataRecTup.get2() instanceof DataRecord; + if (!mvcc) + assert dataRecTup.get2() instanceof DataRecord; + else + assert dataRecTup.get2() instanceof MvccDataRecord; DataRecord dataRec = (DataRecord)dataRecTup.get2(); @@ -402,6 +429,13 @@ public void testDataWalEntries() throws Exception { assertEquals(entry.nearXidVersion(), readEntry.nearXidVersion()); assertEquals(entry.partitionCounter(), readEntry.partitionCounter()); + if (mvcc) { + assert entry instanceof MvccDataEntry; + assert readEntry instanceof MvccDataEntry; + + assertEquals(((MvccDataEntry) entry).mvccVer(), ((MvccDataEntry) readEntry).mvccVer()); + } + idx++; } } @@ -410,13 +444,14 @@ public void testDataWalEntries() throws Exception { /** * @throws Exception if failed. */ + @Test public void testPageWalEntries() throws Exception { IgniteEx ig = startGrid(0); - ig.active(true); + ig.cluster().active(true); GridCacheSharedContext sharedCtx = ig.context().cache().context(); - int cacheId = sharedCtx.cache().cache(cacheName).context().cacheId(); + int cacheId = sharedCtx.cache().cache(CACHE_NAME).context().cacheId(); GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)sharedCtx.database(); PageMemory pageMem = sharedCtx.database().dataRegion(null).pageMemory(); @@ -460,7 +495,7 @@ public void testPageWalEntries() throws Exception { ig = startGrid(0); - ig.active(true); + ig.cluster().active(true); sharedCtx = ig.context().cache().context(); @@ -510,14 +545,15 @@ public void testPageWalEntries() throws Exception { /** * @throws Exception if failed. */ + @Test public void testDirtyFlag() throws Exception { IgniteEx ig = startGrid(0); - ig.active(true); + ig.cluster().active(true); GridCacheSharedContext shared = ig.context().cache().context(); - int cacheId = shared.cache().cache(cacheName).context().cacheId(); + int cacheId = shared.cache().cache(CACHE_NAME).context().cacheId(); GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)shared.database(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsDiskErrorsRecoveringTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsDiskErrorsRecoveringTest.java index bd30696a1e260..2b329c0651b4c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsDiskErrorsRecoveringTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsDiskErrorsRecoveringTest.java @@ -25,7 +25,6 @@ import java.util.Arrays; import java.util.concurrent.atomic.AtomicLong; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteException; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheRebalanceMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; @@ -39,6 +38,7 @@ import org.apache.ignite.failure.StopNodeFailureHandler; import org.apache.ignite.internal.GridKernalState; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; @@ -51,15 +51,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_MMAP; /** * Tests node recovering after disk errors during interaction with persistent storage. */ +@RunWith(JUnit4.class) public class IgnitePdsDiskErrorsRecoveringTest extends GridCommonAbstractTest { /** */ private static final int PAGE_SIZE = DataStorageConfiguration.DFLT_PAGE_SIZE; @@ -97,6 +98,8 @@ public class IgnitePdsDiskErrorsRecoveringTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + cfg.setConsistentId(igniteInstanceName); + DataStorageConfiguration dsCfg = new DataStorageConfiguration() .setDefaultDataRegionConfiguration( new DataRegionConfiguration().setMaxSize(100L * 1024 * 1024).setPersistenceEnabled(true)) @@ -125,93 +128,49 @@ public class IgnitePdsDiskErrorsRecoveringTest extends GridCommonAbstractTest { /** * Test node stopping & recovering on cache initialization fail. */ + @Test public void testRecoveringOnCacheInitFail() throws Exception { // Fail to initialize page store. 2 extra pages is needed for MetaStorage. ioFactory = new FilteringFileIOFactory(".bin", new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), 2 * PAGE_SIZE)); - final IgniteEx grid = startGrid(0); - boolean failed = false; - try { - grid.cluster().active(true); - } catch (Exception expected) { - log.warning("Expected cache error", expected); - - failed = true; - } - - Assert.assertTrue("Cache initialization must failed", failed); - - // Grid should be automatically stopped after checkpoint fail. - awaitStop(grid); - - // Grid should be successfully recovered after stopping. - ioFactory = null; - - IgniteEx recoveredGrid = startGrid(0); - recoveredGrid.active(true); - } - - /** - * Test node stopping & recovering on start marker writing fail during activation. - * - * @throws Exception If test failed. - */ - public void testRecoveringOnNodeStartMarkerWriteFail() throws Exception { - // Fail to write node start marker tmp file at the second checkpoint. Pass only initial checkpoint. - ioFactory = new FilteringFileIOFactory("started.bin" + FilePageStoreManager.TMP_SUFFIX, new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), 20)); - - IgniteEx grid = startGrid(0); - grid.cluster().active(true); - - for (int i = 0; i < 1000; i++) { - byte payload = (byte) i; - byte[] data = new byte[2048]; - Arrays.fill(data, payload); - grid.cache(CACHE_NAME).put(i, data); - } + IgniteInternalFuture startGridFut = GridTestUtils.runAsync(() -> { + try { + IgniteEx grid = startGrid(0); - stopAllGrids(); + grid.cluster().active(true); + } + catch (Exception e) { + throw new RuntimeException("Failed to start node.", e); + } + }); - boolean activationFailed = false; try { - grid = startGrid(0); - grid.cluster().active(true); + startGridFut.get(); } - catch (IgniteException e) { - log.warning("Activation test exception", e); + catch (Exception e) { + Assert.assertTrue(e.getMessage().contains("Failed to start node.")); - activationFailed = true; + failed = true; } - Assert.assertTrue("Activation must be failed", activationFailed); - - // Grid should be automatically stopped after checkpoint fail. - awaitStop(grid); + Assert.assertTrue("Cache initialization must failed", failed); // Grid should be successfully recovered after stopping. ioFactory = null; - IgniteEx recoveredGrid = startGrid(0); - recoveredGrid.cluster().active(true); - - for (int i = 0; i < 1000; i++) { - byte payload = (byte) i; - byte[] data = new byte[2048]; - Arrays.fill(data, payload); + IgniteEx grid = startGrid(0); - byte[] actualData = (byte[]) recoveredGrid.cache(CACHE_NAME).get(i); - Assert.assertArrayEquals(data, actualData); - } + grid.cluster().active(true); } - /** * Test node stopping & recovering on checkpoint begin fail. * * @throws Exception If test failed. */ + @Test public void testRecoveringOnCheckpointBeginFail() throws Exception { // Fail to write checkpoint start marker tmp file at the second checkpoint. Pass only initial checkpoint. ioFactory = new FilteringFileIOFactory("START.bin" + FilePageStoreManager.TMP_SUFFIX, new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), 20)); @@ -262,6 +221,7 @@ public void testRecoveringOnCheckpointBeginFail() throws Exception { /** * Test node stopping & recovering on checkpoint pages write fail. */ + @Test public void testRecoveringOnCheckpointWriteFail() throws Exception { // Fail write partition and index files at the second checkpoint. Pass only initial checkpoint. ioFactory = new FilteringFileIOFactory(".bin", new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), 128 * PAGE_SIZE)); @@ -311,20 +271,26 @@ public void testRecoveringOnCheckpointWriteFail() throws Exception { /** * Test node stopping & recovering on WAL writing fail with enabled MMAP (Batch allocation for WAL segments). */ + @Test public void testRecoveringOnWALWritingFail1() throws Exception { // Allow to allocate only 1 wal segment, fail on write to second. ioFactory = new FilteringFileIOFactory(".wal", new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), WAL_SEGMENT_SIZE)); + System.setProperty(IGNITE_WAL_MMAP, "true"); + doTestRecoveringOnWALWritingFail(); } /** * Test node stopping & recovering on WAL writing fail with disabled MMAP. */ + @Test public void testRecoveringOnWALWritingFail2() throws Exception { // Fail somewhere on the second wal segment. ioFactory = new FilteringFileIOFactory(".wal", new LimitedSizeFileIOFactory(new RandomAccessFileIOFactory(), (long) (1.5 * WAL_SEGMENT_SIZE))); + System.setProperty(IGNITE_WAL_MMAP, "false"); + doTestRecoveringOnWALWritingFail(); } @@ -332,18 +298,23 @@ public void testRecoveringOnWALWritingFail2() throws Exception { * Test node stopping & recovery on WAL writing fail. */ private void doTestRecoveringOnWALWritingFail() throws Exception { - final IgniteEx grid = startGrid(0); + IgniteEx grid = startGrid(0); FileWriteAheadLogManager wal = (FileWriteAheadLogManager)grid.context().cache().context().wal(); + wal.setFileIOFactory(ioFactory); grid.cluster().active(true); int failedPosition = -1; - for (int i = 0; i < 1000; i++) { + final int keysCount = 2000; + + final int dataSize = 2048; + + for (int i = 0; i < keysCount; i++) { byte payload = (byte) i; - byte[] data = new byte[2048]; + byte[] data = new byte[dataSize]; Arrays.fill(data, payload); try { @@ -357,7 +328,7 @@ private void doTestRecoveringOnWALWritingFail() throws Exception { } // We must be able to put something into cache before fail. - Assert.assertTrue(failedPosition > 0); + Assert.assertTrue("One of the cache puts must be failed", failedPosition > 0); // Grid should be automatically stopped after WAL fail. awaitStop(grid); @@ -365,15 +336,16 @@ private void doTestRecoveringOnWALWritingFail() throws Exception { ioFactory = null; // Grid should be successfully recovered after stopping. - IgniteEx recoveredGrid = startGrid(0); - recoveredGrid.cluster().active(true); + grid = startGrid(0); + + grid.cluster().active(true); for (int i = 0; i < failedPosition; i++) { byte payload = (byte) i; - byte[] data = new byte[2048]; + byte[] data = new byte[dataSize]; Arrays.fill(data, payload); - byte[] actualData = (byte[]) recoveredGrid.cache(CACHE_NAME).get(i); + byte[] actualData = (byte[]) grid.cache(CACHE_NAME).get(i); Assert.assertArrayEquals(data, actualData); } } @@ -472,11 +444,6 @@ private static class FilteringFileIOFactory implements FileIOFactory { this.pattern = pattern; } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, WRITE, READ); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { if (file.getName().endsWith(pattern)) @@ -507,11 +474,6 @@ private LimitedSizeFileIOFactory(FileIOFactory delegate, long fsSpaceBytes) { this.availableSpaceBytes = new AtomicLong(fsSpaceBytes); } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return new LimitedSizeFileIO(delegate.create(file), availableSpaceBytes); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { return new LimitedSizeFileIO(delegate.create(file, modes), availableSpaceBytes); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsNoActualWalHistoryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsNoActualWalHistoryTest.java index c2967fef1cb6d..41e027e6c6712 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsNoActualWalHistoryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsNoActualWalHistoryTest.java @@ -36,10 +36,14 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgnitePdsNoActualWalHistoryTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -98,6 +102,7 @@ public class IgnitePdsNoActualWalHistoryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testWalBig() throws Exception { try { IgniteEx ignite = startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsPageReplacementTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsPageReplacementTest.java index 2697c01d4201a..7be0625237717 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsPageReplacementTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsPageReplacementTest.java @@ -40,11 +40,15 @@ import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for page replacement (rotation with disk) process with enabled persistence. * A lot of reader threads tries to acquire page and checkpointer threads write data. */ +@RunWith(JUnit4.class) public class IgnitePdsPageReplacementTest extends GridCommonAbstractTest { /** */ private static final int NUMBER_OF_SEGMENTS = 64; @@ -113,6 +117,7 @@ private DataStorageConfiguration createDbConfig() { /** * @throws Exception If fail. */ + @Test public void testPageReplacement() throws Exception { final IgniteEx ig = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsThreadInterruptionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsThreadInterruptionTest.java index adaa764aa4ca6..4b7db7dd4d546 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsThreadInterruptionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsThreadInterruptionTest.java @@ -30,10 +30,14 @@ import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.processors.cache.persistence.file.AsyncFileIOFactory; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test what interruptions of writing threads do not affect PDS. */ +@RunWith(JUnit4.class) public class IgnitePdsThreadInterruptionTest extends GridCommonAbstractTest { /** */ private static final int PAGE_SIZE = 1 << 12; // 4096 @@ -106,6 +110,7 @@ private DataStorageConfiguration storageConfiguration() { * * @throws Exception If failed. */ + @Test public void testInterruptsOnLFSRead() throws Exception { final Ignite ignite = startGrid(); @@ -185,6 +190,7 @@ public void testInterruptsOnLFSRead() throws Exception { * * @throws Exception */ + @Test public void testInterruptsOnWALWrite() throws Exception { final Ignite ignite = startGrid(); @@ -256,4 +262,4 @@ public void testInterruptsOnWALWrite() throws Exception { log.info("Verified keys: " + verifiedKeys); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/filename/IgniteUidAsConsistentIdMigrationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/filename/IgniteUidAsConsistentIdMigrationTest.java index 6e8ef6598f1da..b3e36c9e1c543 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/filename/IgniteUidAsConsistentIdMigrationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/filename/IgniteUidAsConsistentIdMigrationTest.java @@ -36,6 +36,9 @@ import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_CONSISTENT_ID_BY_HOST_WITHOUT_PORT; import static org.apache.ignite.IgniteSystemProperties.IGNITE_DATA_STORAGE_FOLDER_BY_CONSISTENT_ID; @@ -44,6 +47,7 @@ /** * Test for new and old style persistent storage folders generation */ +@RunWith(JUnit4.class) public class IgniteUidAsConsistentIdMigrationTest extends GridCommonAbstractTest { /** Cache name for test. */ public static final String CACHE_NAME = "dummy"; @@ -160,6 +164,7 @@ private void deleteWorkFiles() throws IgniteCheckedException { * * @throws Exception if failed. */ + @Test public void testNewStyleIdIsGenerated() throws Exception { final Ignite ignite = startActivateFillDataGrid(0); @@ -174,6 +179,7 @@ public void testNewStyleIdIsGenerated() throws Exception { * * @throws Exception if failed. */ + @Test public void testNewStyleIdIsGeneratedInCustomStorePath() throws Exception { placeStorageInTemp = true; final Ignite ignite = startActivateFillDataGrid(0); @@ -196,6 +202,7 @@ public void testNewStyleIdIsGeneratedInCustomStorePath() throws Exception { * * @throws Exception if failed. */ + @Test public void testPreconfiguredConsitentIdIsApplied() throws Exception { this.configuredConsistentId = "someConfiguredConsistentId"; Ignite ignite = startActivateFillDataGrid(0); @@ -210,6 +217,7 @@ public void testPreconfiguredConsitentIdIsApplied() throws Exception { * * @throws Exception if failed */ + @Test public void testRestartOnExistingOldStyleId() throws Exception { final String expDfltConsistentId = "127.0.0.1:47500"; @@ -244,6 +252,7 @@ public void testRestartOnExistingOldStyleId() throws Exception { * * @throws Exception if failed */ + @Test public void testStartWithoutActivate() throws Exception { //start stop grid without activate startGrid(0); @@ -259,6 +268,7 @@ public void testStartWithoutActivate() throws Exception { * * @throws Exception if failed */ + @Test public void testRestartOnSameFolderWillCauseSameUuidGeneration() throws Exception { final UUID uuid; { @@ -290,6 +300,7 @@ public void testRestartOnSameFolderWillCauseSameUuidGeneration() throws Exceptio * * @throws Exception if failed */ + @Test public void testStartNodeAfterDeactivate() throws Exception { final UUID uuid; { @@ -365,6 +376,7 @@ public void testStartNodeAfterDeactivate() throws Exception { * * @throws Exception if failed */ + @Test public void testNodeIndexIncremented() throws Exception { final Ignite ignite0 = startGrid(0); final Ignite ignite1 = startGrid(1); @@ -387,6 +399,7 @@ public void testNodeIndexIncremented() throws Exception { * * @throws Exception if failed */ + @Test public void testNewStyleAlwaysSmallestNodeIndexIsCreated() throws Exception { final Ignite ignite0 = startGrid(0); final Ignite ignite1 = startGrid(1); @@ -419,6 +432,7 @@ public void testNewStyleAlwaysSmallestNodeIndexIsCreated() throws Exception { * * @throws Exception if failed */ + @Test public void testNewStyleAlwaysSmallestNodeIndexIsCreatedMultithreaded() throws Exception { final Ignite ignite0 = startGridsMultiThreaded(11); @@ -446,6 +460,7 @@ public void testNewStyleAlwaysSmallestNodeIndexIsCreatedMultithreaded() throws E * * @throws Exception if failed. */ + @Test public void testStartTwoOldStyleNodes() throws Exception { final String expDfltConsistentId1 = "127.0.0.1:47500"; @@ -495,6 +510,7 @@ public void testStartTwoOldStyleNodes() throws Exception { * * @throws Exception if failed. */ + @Test public void testStartOldStyleNodesByCompatibleProperty() throws Exception { clearPropsAfterTest = true; System.setProperty(IGNITE_DATA_STORAGE_FOLDER_BY_CONSISTENT_ID, "true"); @@ -537,6 +553,7 @@ public void testStartOldStyleNodesByCompatibleProperty() throws Exception { * * @throws Exception if failed. */ + @Test public void testStartOldStyleNoPortsNodesByCompatibleProperty() throws Exception { clearPropsAfterTest = true; System.setProperty(IGNITE_DATA_STORAGE_FOLDER_BY_CONSISTENT_ID, "true"); @@ -577,6 +594,7 @@ public void testStartOldStyleNoPortsNodesByCompatibleProperty() throws Exception * * @throws Exception if failed. */ + @Test public void testOldStyleNodeWithUnexpectedPort() throws Exception { this.configuredConsistentId = "127.0.0.1:49999"; //emulated old-style node with not appropriate consistent ID final Ignite ignite = startActivateFillDataGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/FsyncWalRolloverDoesNotBlockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/FsyncWalRolloverDoesNotBlockTest.java index aa2e90ce47716..81da76350747c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/FsyncWalRolloverDoesNotBlockTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/FsyncWalRolloverDoesNotBlockTest.java @@ -22,19 +22,17 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH; import static org.apache.ignite.configuration.WALMode.FSYNC; /** */ +@RunWith(JUnit4.class) public class FsyncWalRolloverDoesNotBlockTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static class RolloverRecord extends CheckpointRecord { /** */ @@ -47,8 +45,6 @@ private RolloverRecord() { @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { IgniteConfiguration cfg = super.getConfiguration(name); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)) .setWalMode(FSYNC) @@ -72,6 +68,7 @@ private RolloverRecord() { } /** */ + @Test public void test() throws Exception { IgniteEx ig = startGrid(0); @@ -86,4 +83,4 @@ public void test() throws Exception { ig.context().cache().context().database().checkpointReadUnlock(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteNodeStoppedDuringDisableWALTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteNodeStoppedDuringDisableWALTest.java index a744ab10c1671..f6c2de11299ef 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteNodeStoppedDuringDisableWALTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteNodeStoppedDuringDisableWALTest.java @@ -23,11 +23,9 @@ import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; -import java.util.HashMap; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; @@ -39,16 +37,16 @@ import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.persistence.filename.PdsFoldersResolver; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.nio.file.FileVisitResult.CONTINUE; import static java.nio.file.Files.walkFileTree; import static org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.CP_FILE_NAME_PATTERN; - import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.INDEX_FILE_NAME; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.META_STORAGE_NAME; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_PREFIX; @@ -59,16 +57,12 @@ /*** * */ +@RunWith(JUnit4.class) public class IgniteNodeStoppedDuringDisableWALTest extends GridCommonAbstractTest { - /** */ - public static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { IgniteConfiguration cfg = super.getConfiguration(name); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setDefaultDataRegionConfiguration( @@ -79,7 +73,7 @@ public class IgniteNodeStoppedDuringDisableWALTest extends GridCommonAbstractTes cfg.setAutoActivationEnabled(false); - cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME)); + cfg.setCacheConfiguration(defaultCacheConfiguration()); return cfg; } @@ -92,9 +86,15 @@ public class IgniteNodeStoppedDuringDisableWALTest extends GridCommonAbstractTes } /** + * Test checks that after WAL is globally disabled and node is stopped, persistent store is cleaned properly after node restart. + * * @throws Exception If failed. */ + @Test public void test() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10421"); + for (NodeStopPoint nodeStopPoint : NodeStopPoint.values()) { testStopNodeWithDisableWAL(nodeStopPoint); @@ -177,7 +177,7 @@ private void testStopNodeWithDisableWAL(NodeStopPoint nodeStopPoint) throws Exce boolean fail = false; try (WALIterator it = sharedContext.wal().replay(null)) { - dbMgr.applyUpdatesOnRecovery(it, (tup) -> true, (entry) -> true, new HashMap<>()); + dbMgr.applyUpdatesOnRecovery(it, (ptr, rec) -> true, (entry) -> true); } catch (IgniteCheckedException e) { if (nodeStopPoint.needCleanUp) @@ -190,6 +190,8 @@ private void testStopNodeWithDisableWAL(NodeStopPoint nodeStopPoint) throws Exce String msg = nodeStopPoint.toString(); + int pageSize = ig1.configuration().getDataStorageConfiguration().getPageSize(); + if (nodeStopPoint.needCleanUp) { PdsFoldersResolver foldersResolver = ((IgniteEx)ig1).context().pdsFolderResolver(); @@ -215,14 +217,14 @@ private void testStopNodeWithDisableWAL(NodeStopPoint nodeStopPoint) throws Exce if (CP_FILE_NAME_PATTERN.matcher(name).matches()) failed = true; - if (name.startsWith(PART_FILE_PREFIX)) + if (name.startsWith(PART_FILE_PREFIX) && path.toFile().length() > pageSize) failed = true; - if (name.startsWith(INDEX_FILE_NAME)) + if (name.startsWith(INDEX_FILE_NAME) && path.toFile().length() > pageSize) failed = true; if (failed) - fail(msg + " " + filePath); + fail(msg + " " + filePath + " " + path.toFile().length()); return CONTINUE; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWALTailIsReachedDuringIterationOverArchiveTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWALTailIsReachedDuringIterationOverArchiveTest.java index e3c2c6c5fab1f..e8a181b702553 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWALTailIsReachedDuringIterationOverArchiveTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWALTailIsReachedDuringIterationOverArchiveTest.java @@ -44,11 +44,11 @@ import org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory.IteratorParametersBuilder; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.nio.ByteBuffer.allocate; import static java.nio.file.StandardOpenOption.WRITE; @@ -57,10 +57,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteWALTailIsReachedDuringIterationOverArchiveTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** WAL segment size. */ private static final int WAL_SEGMENT_SIZE = 10 * 1024 * 1024; @@ -78,8 +76,6 @@ public class IgniteWALTailIsReachedDuringIterationOverArchiveTest extends GridCo ) ); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME)); return cfg; @@ -118,6 +114,7 @@ public class IgniteWALTailIsReachedDuringIterationOverArchiveTest extends GridCo /** * @throws Exception If failed. */ + @Test public void testStandAloneIterator() throws Exception { IgniteEx ig = grid(); @@ -133,6 +130,7 @@ public void testStandAloneIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWALManagerIterator() throws Exception { IgniteEx ig = grid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFlushFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFlushFailoverTest.java index 351a42cb5eb66..d3988d2a3b3fb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFlushFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFlushFailoverTest.java @@ -24,7 +24,6 @@ import java.nio.MappedByteBuffer; import java.nio.file.OpenOption; import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; @@ -44,14 +43,14 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; - -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteWalFlushFailoverTest extends GridCommonAbstractTest { /** */ private static final String TEST_CACHE = "testCache"; @@ -105,6 +104,7 @@ public class IgniteWalFlushFailoverTest extends GridCommonAbstractTest { * * @throws Exception In case of fail */ + @Test public void testErrorOnFlushByTimeout() throws Exception { flushByTimeout = true; flushingErrorTest(); @@ -115,6 +115,7 @@ public void testErrorOnFlushByTimeout() throws Exception { * * @throws Exception In case of fail */ + @Test public void testErrorOnDirectFlush() throws Exception { flushByTimeout = false; flushingErrorTest(); @@ -185,11 +186,6 @@ private static class FailingFileIOFactory implements FileIOFactory { this.fail = fail; } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, READ, WRITE); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { final FileIO delegate = delegateFactory.create(file, modes); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFlushMultiNodeFailoverAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFlushMultiNodeFailoverAbstractSelfTest.java index a28ec5fe1e74c..86ff1f3fc6ff0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFlushMultiNodeFailoverAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFlushMultiNodeFailoverAbstractSelfTest.java @@ -20,8 +20,9 @@ import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; - import java.nio.MappedByteBuffer; +import java.nio.file.OpenOption; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteSystemProperties; @@ -40,24 +41,21 @@ import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; -import org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; - -import java.nio.file.OpenOption; -import java.util.concurrent.atomic.AtomicBoolean; - -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests error recovery while node flushing */ +@RunWith(JUnit4.class) public abstract class IgniteWalFlushMultiNodeFailoverAbstractSelfTest extends GridCommonAbstractTest { /** */ private static final String TEST_CACHE = "testCache"; @@ -75,6 +73,9 @@ public abstract class IgniteWalFlushMultiNodeFailoverAbstractSelfTest extends Gr /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10550"); + super.beforeTest(); stopAllGrids(); @@ -145,6 +146,7 @@ protected boolean mmap() { * * @throws Exception In case of fail */ + @Test public void testFailWhileStart() throws Exception { failWhilePut(true); } @@ -154,6 +156,7 @@ public void testFailWhileStart() throws Exception { * * @throws Exception In case of fail */ + @Test public void testFailAfterStart() throws Exception { failWhilePut(false); } @@ -171,7 +174,7 @@ private void failWhilePut(boolean failWhileStart) throws Exception { for (int i = 0; i < ITRS; i++) { while (!Thread.currentThread().isInterrupted()) { try (Transaction tx = grid.transactions().txStart( - TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED)) { + TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)) { cache.put(i, "testValue" + i); tx.commit(); @@ -232,8 +235,6 @@ private void failWhilePut(boolean failWhileStart) throws Exception { private void setFileIOFactory(IgniteWriteAheadLogManager wal) { if (wal instanceof FileWriteAheadLogManager) ((FileWriteAheadLogManager)wal).setFileIOFactory(new FailingFileIOFactory(canFail)); - else if (wal instanceof FsyncModeFileWriteAheadLogManager) - ((FsyncModeFileWriteAheadLogManager)wal).setFileIOFactory(new FailingFileIOFactory(canFail)); else fail(wal.getClass().toString()); } @@ -256,11 +257,6 @@ private static class FailingFileIOFactory implements FileIOFactory { this.fail = fail; } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, READ, WRITE); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { final FileIO delegate = delegateFactory.create(file, modes); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFormatFileFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFormatFileFailoverTest.java index 5a1a6fa179654..617ec9a2c6f4f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFormatFileFailoverTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalFormatFileFailoverTest.java @@ -1,258 +1,260 @@ -/* - * 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. - */ - -package org.apache.ignite.internal.processors.cache.persistence.db.wal; - -import java.io.File; -import java.io.IOException; -import java.nio.file.OpenOption; -import java.util.Arrays; -import java.util.concurrent.atomic.AtomicReference; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.DataRegionConfiguration; -import org.apache.ignite.configuration.DataStorageConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.WALMode; -import org.apache.ignite.failure.FailureHandler; -import org.apache.ignite.failure.TestFailureHandler; -import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; -import org.apache.ignite.internal.processors.cache.persistence.StorageException; -import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; -import org.apache.ignite.internal.processors.cache.persistence.file.FileIODecorator; -import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; -import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; -import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; -import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.READ; -import static java.nio.file.StandardOpenOption.WRITE; - -/** - * - */ -public class IgniteWalFormatFileFailoverTest extends GridCommonAbstractTest { - /** */ - private static final String TEST_CACHE = "testCache"; - - /** */ - private static final String formatFile = "formatFile"; - - /** Fail method name reference. */ - private final AtomicReference failMtdNameRef = new AtomicReference<>(); - - /** */ - private boolean fsync; - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - cleanPersistenceDir(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - - cleanPersistenceDir(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setCacheConfiguration(new CacheConfiguration(TEST_CACHE) - .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); - - DataStorageConfiguration memCfg = new DataStorageConfiguration() - .setDefaultDataRegionConfiguration(new DataRegionConfiguration() - .setMaxSize(2048L * 1024 * 1024) - .setPersistenceEnabled(true)) - .setWalMode(fsync ? WALMode.FSYNC : WALMode.BACKGROUND) - .setWalBufferSize(1024 * 1024) - .setWalSegmentSize(512 * 1024) - .setFileIOFactory(new FailingFileIOFactory(failMtdNameRef)); - - cfg.setDataStorageConfiguration(memCfg); - - cfg.setFailureHandler(new TestFailureHandler(false)); - - return cfg; - } - - /** - * @throws Exception If failed. - */ - public void testNodeStartFailedFsync() throws Exception { - fsync = true; - - failMtdNameRef.set(formatFile); - - checkCause(GridTestUtils.assertThrows(log, () -> startGrid(0), IgniteCheckedException.class, null)); - } - - /** - * @throws Exception If failed. - */ - public void testFailureHandlerTriggeredFsync() throws Exception { - fsync = true; - - failFormatFileOnClusterActivate(); - } - - /** - * @throws Exception If failed. - */ - public void testFailureHandlerTriggered() throws Exception { - fsync = false; - - failFormatFileOnClusterActivate(); - } - - /** - * @throws Exception If failed. - */ - private void failFormatFileOnClusterActivate() throws Exception { - failMtdNameRef.set(null); - - startGrid(0); - startGrid(1); - - if (!fsync) { - setFileIOFactory(grid(0).context().cache().context().wal()); - setFileIOFactory(grid(1).context().cache().context().wal()); - } - - failMtdNameRef.set(formatFile); - - grid(0).cluster().active(true); - - checkCause(failureHandler(0).awaitFailure(2000).error()); - checkCause(failureHandler(1).awaitFailure(2000).error()); - } - - /** - * @param mtdName Method name. - */ - private static boolean isCalledFrom(String mtdName) { - return isCalledFrom(Thread.currentThread().getStackTrace(), mtdName); - } - - /** - * @param stackTrace Stack trace. - * @param mtdName Method name. - */ - private static boolean isCalledFrom(StackTraceElement[] stackTrace, String mtdName) { - return Arrays.stream(stackTrace).map(StackTraceElement::getMethodName).anyMatch(mtdName::equals); - } - - /** - * @param gridIdx Grid index. - * @return Failure handler configured for grid with given index. - */ - private TestFailureHandler failureHandler(int gridIdx) { - FailureHandler hnd = grid(gridIdx).configuration().getFailureHandler(); - - assertTrue(hnd instanceof TestFailureHandler); - - return (TestFailureHandler)hnd; - } - - /** - * @param t Throwable. - */ - private void checkCause(Throwable t) { - StorageException e = X.cause(t, StorageException.class); - - assertNotNull(e); - assertNotNull(e.getMessage()); - assertTrue(e.getMessage().contains("Failed to format WAL segment file")); - - IOException ioe = X.cause(e, IOException.class); - - assertNotNull(ioe); - assertNotNull(ioe.getMessage()); - assertTrue(ioe.getMessage().contains("No space left on device")); - - assertTrue(isCalledFrom(ioe.getStackTrace(), formatFile)); - } - - /** */ - private void setFileIOFactory(IgniteWriteAheadLogManager wal) { - if (wal instanceof FileWriteAheadLogManager) - ((FileWriteAheadLogManager)wal).setFileIOFactory(new FailingFileIOFactory(failMtdNameRef)); - else - fail(wal.getClass().toString()); - } - - /** - * Create File I/O which fails if specific method call present in stack trace. - */ - private static class FailingFileIOFactory implements FileIOFactory { - /** Serial version uid. */ - private static final long serialVersionUID = 0L; - - /** Delegate factory. */ - private final FileIOFactory delegateFactory = new RandomAccessFileIOFactory(); - - /** Fail method name reference. */ - private final AtomicReference failMtdNameRef; - - /** - * @param failMtdNameRef Fail method name reference. - */ - FailingFileIOFactory(AtomicReference failMtdNameRef) { - assertNotNull(failMtdNameRef); - - this.failMtdNameRef = failMtdNameRef; - } - - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, READ, WRITE); - } - - /** {@inheritDoc} */ - @Override public FileIO create(File file, OpenOption... modes) throws IOException { - final FileIO delegate = delegateFactory.create(file, modes); - - return new FileIODecorator(delegate) { - @Override public int write(byte[] buf, int off, int len) throws IOException { - conditionalFail(); - - return super.write(buf, off, len); - } - - @Override public void clear() throws IOException { - conditionalFail(); - - super.clear(); - } - - private void conditionalFail() throws IOException { - String failMtdName = failMtdNameRef.get(); - - if (failMtdName != null && isCalledFrom(failMtdName)) - throw new IOException("No space left on device"); - } - }; - } - } -} +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.db.wal; + +import java.io.File; +import java.io.IOException; +import java.nio.file.OpenOption; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.failure.FailureHandler; +import org.apache.ignite.failure.TestFailureHandler; +import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIODecorator; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; +import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * + */ +@RunWith(JUnit4.class) +public class IgniteWalFormatFileFailoverTest extends GridCommonAbstractTest { + /** */ + private static final String TEST_CACHE = "testCache"; + + /** */ + private static final String formatFile = "formatFile"; + + /** Fail method name reference. */ + private final AtomicReference failMtdNameRef = new AtomicReference<>(); + + /** */ + private boolean fsync; + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + cfg.setCacheConfiguration(new CacheConfiguration(TEST_CACHE) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)); + + DataStorageConfiguration memCfg = new DataStorageConfiguration() + .setDefaultDataRegionConfiguration(new DataRegionConfiguration() + .setMaxSize(2048L * 1024 * 1024) + .setPersistenceEnabled(true)) + .setWalMode(fsync ? WALMode.FSYNC : WALMode.BACKGROUND) + .setWalBufferSize(1024 * 1024) + .setWalSegmentSize(512 * 1024) + .setFileIOFactory(new FailingFileIOFactory(failMtdNameRef)); + + cfg.setDataStorageConfiguration(memCfg); + + cfg.setFailureHandler(new TestFailureHandler(false)); + + return cfg; + } + + /** + * @throws Exception If failed. + */ + @Test + public void testNodeStartFailedFsync() throws Exception { + fsync = true; + + failMtdNameRef.set(formatFile); + + checkCause(GridTestUtils.assertThrows(log, () -> startGrid(0), IgniteCheckedException.class, null)); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testFailureHandlerTriggeredFsync() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10035"); + + fsync = true; + + failFormatFileOnClusterActivate(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testFailureHandlerTriggered() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10035"); + + fsync = false; + + failFormatFileOnClusterActivate(); + } + + /** + * @throws Exception If failed. + */ + private void failFormatFileOnClusterActivate() throws Exception { + failMtdNameRef.set(null); + + startGrid(0); + startGrid(1); + + if (!fsync) { + setFileIOFactory(grid(0).context().cache().context().wal()); + setFileIOFactory(grid(1).context().cache().context().wal()); + } + + failMtdNameRef.set(formatFile); + + grid(0).cluster().active(true); + + checkCause(failureHandler(0).awaitFailure(2000).error()); + checkCause(failureHandler(1).awaitFailure(2000).error()); + } + + /** + * @param mtdName Method name. + */ + private static boolean isCalledFrom(String mtdName) { + return isCalledFrom(Thread.currentThread().getStackTrace(), mtdName); + } + + /** + * @param stackTrace Stack trace. + * @param mtdName Method name. + */ + private static boolean isCalledFrom(StackTraceElement[] stackTrace, String mtdName) { + return Arrays.stream(stackTrace).map(StackTraceElement::getMethodName).anyMatch(mtdName::equals); + } + + /** + * @param gridIdx Grid index. + * @return Failure handler configured for grid with given index. + */ + private TestFailureHandler failureHandler(int gridIdx) { + FailureHandler hnd = grid(gridIdx).configuration().getFailureHandler(); + + assertTrue(hnd instanceof TestFailureHandler); + + return (TestFailureHandler)hnd; + } + + /** + * @param t Throwable. + */ + private void checkCause(Throwable t) { + StorageException e = X.cause(t, StorageException.class); + + assertNotNull(e); + assertNotNull(e.getMessage()); + assertTrue(e.getMessage().contains("Failed to format WAL segment file")); + + IOException ioe = X.cause(e, IOException.class); + + assertNotNull(ioe); + assertNotNull(ioe.getMessage()); + assertTrue(ioe.getMessage().contains("No space left on device")); + + assertTrue(isCalledFrom(ioe.getStackTrace(), formatFile)); + } + + /** */ + private void setFileIOFactory(IgniteWriteAheadLogManager wal) { + if (wal instanceof FileWriteAheadLogManager) + ((FileWriteAheadLogManager)wal).setFileIOFactory(new FailingFileIOFactory(failMtdNameRef)); + else + fail(wal.getClass().toString()); + } + + /** + * Create File I/O which fails if specific method call present in stack trace. + */ + private static class FailingFileIOFactory implements FileIOFactory { + /** Serial version uid. */ + private static final long serialVersionUID = 0L; + + /** Delegate factory. */ + private final FileIOFactory delegateFactory = new RandomAccessFileIOFactory(); + + /** Fail method name reference. */ + private final AtomicReference failMtdNameRef; + + /** + * @param failMtdNameRef Fail method name reference. + */ + FailingFileIOFactory(AtomicReference failMtdNameRef) { + assertNotNull(failMtdNameRef); + + this.failMtdNameRef = failMtdNameRef; + } + + /** {@inheritDoc} */ + @Override public FileIO create(File file, OpenOption... modes) throws IOException { + final FileIO delegate = delegateFactory.create(file, modes); + + return new FileIODecorator(delegate) { + @Override public int write(byte[] buf, int off, int len) throws IOException { + conditionalFail(); + + return super.write(buf, off, len); + } + + @Override public void clear() throws IOException { + conditionalFail(); + + super.clear(); + } + + private void conditionalFail() throws IOException { + String failMtdName = failMtdNameRef.get(); + + if (failMtdName != null && isCalledFrom(failMtdName)) + throw new IOException("No space left on device"); + } + }; + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalHistoryReservationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalHistoryReservationsTest.java index 6d2b1f79227b5..278862e958e59 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalHistoryReservationsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalHistoryReservationsTest.java @@ -38,14 +38,19 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_WAL_REBALANCE_THRESHOLD; /** * */ +@RunWith(JUnit4.class) public class IgniteWalHistoryReservationsTest extends GridCommonAbstractTest { /** */ private volatile boolean client; @@ -106,7 +111,10 @@ public class IgniteWalHistoryReservationsTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testReservedOnExchange() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + System.setProperty(IGNITE_PDS_WAL_REBALANCE_THRESHOLD, "0"); final int entryCnt = 10_000; @@ -114,7 +122,7 @@ public void testReservedOnExchange() throws Exception { final IgniteEx ig0 = (IgniteEx)startGrids(initGridCnt + 1); - ig0.active(true); + ig0.cluster().active(true); stopGrid(initGridCnt); @@ -251,12 +259,16 @@ private void printProgress(int k) { /** * @throws Exception If failed. */ + @Test public void testRemovesArePreloadedIfHistoryIsAvailable() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10551"); + int entryCnt = 10_000; IgniteEx ig0 = (IgniteEx)startGrids(2); - ig0.active(true); + ig0.cluster().active(true); IgniteCache cache = ig0.cache("cache1"); @@ -270,6 +282,8 @@ public void testRemovesArePreloadedIfHistoryIsAvailable() throws Exception { IgniteEx ig1 = startGrid(1); + awaitPartitionMapExchange(); + IgniteCache cache1 = ig1.cache("cache1"); assertEquals(entryCnt / 2, cache.size()); @@ -286,8 +300,6 @@ public void testRemovesArePreloadedIfHistoryIsAvailable() throws Exception { } } - cache.rebalance().get(); - for (int p = 0; p < ig1.affinity("cache1").partitions(); p++) { GridDhtLocalPartition p0 = ig0.context().cache().cache("cache1").context().topology().localPartition(p); GridDhtLocalPartition p1 = ig1.context().cache().cache("cache1").context().topology().localPartition(p); @@ -300,12 +312,16 @@ public void testRemovesArePreloadedIfHistoryIsAvailable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeIsClearedIfHistoryIsUnavailable() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10551"); + int entryCnt = 10_000; IgniteEx ig0 = (IgniteEx)startGrids(2); - ig0.active(true); + ig0.cluster().active(true); IgniteCache cache = ig0.cache("cache1"); @@ -330,6 +346,8 @@ public void testNodeIsClearedIfHistoryIsUnavailable() throws Exception { IgniteEx ig1 = startGrid(1); + awaitPartitionMapExchange(); + IgniteCache cache1 = ig1.cache("cache1"); assertEquals(entryCnt / 2, cache.size()); @@ -346,8 +364,6 @@ public void testNodeIsClearedIfHistoryIsUnavailable() throws Exception { } } - cache.rebalance().get(); - for (int p = 0; p < ig1.affinity("cache1").partitions(); p++) { GridDhtLocalPartition p0 = ig0.context().cache().cache("cache1").context().topology().localPartition(p); GridDhtLocalPartition p1 = ig1.context().cache().cache("cache1").context().topology().localPartition(p); @@ -360,7 +376,11 @@ public void testNodeIsClearedIfHistoryIsUnavailable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWalHistoryPartiallyRemoved() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10551"); + int entryCnt = 10_000; IgniteEx ig0 = (IgniteEx)startGrids(2); @@ -399,7 +419,10 @@ public void testWalHistoryPartiallyRemoved() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeLeftDuringExchange() throws Exception { + MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.ENTRY_LOCK); + System.setProperty(IGNITE_PDS_WAL_REBALANCE_THRESHOLD, "0"); final int entryCnt = 10_000; @@ -407,7 +430,7 @@ public void testNodeLeftDuringExchange() throws Exception { final Ignite ig0 = startGrids(initGridCnt); - ig0.active(true); + ig0.cluster().active(true); IgniteCache cache = ig0.cache("cache1"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalIteratorExceptionDuringReadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalIteratorExceptionDuringReadTest.java index ccd889aaaaf42..36896bcea4664 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalIteratorExceptionDuringReadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalIteratorExceptionDuringReadTest.java @@ -34,19 +34,17 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteWalIteratorExceptionDuringReadTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int WAL_SEGMENT_SIZE = 1024 * 1024 * 20; @@ -54,8 +52,6 @@ public class IgniteWalIteratorExceptionDuringReadTest extends GridCommonAbstract @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setWalSegmentSize(WAL_SEGMENT_SIZE) @@ -81,6 +77,7 @@ public class IgniteWalIteratorExceptionDuringReadTest extends GridCommonAbstract /** * @throws Exception If failed. */ + @Test public void test() throws Exception { IgniteEx ig = (IgniteEx)startGrid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalIteratorSwitchSegmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalIteratorSwitchSegmentTest.java index fd78347389749..4eeb22395fa14 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalIteratorSwitchSegmentTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalIteratorSwitchSegmentTest.java @@ -47,7 +47,6 @@ import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; import org.apache.ignite.internal.processors.cache.persistence.wal.AbstractWalRecordsIterator; import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; -import org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager; import org.apache.ignite.internal.processors.cache.persistence.wal.aware.SegmentAware; import org.apache.ignite.internal.processors.cache.persistence.wal.io.FileInput; import org.apache.ignite.internal.processors.cache.persistence.wal.reader.StandaloneGridKernalContext; @@ -63,6 +62,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.METASTORE_DATA_RECORD; import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.HEADER_RECORD_SIZE; @@ -72,6 +74,7 @@ /*** * Test check correct switch segment if in the tail of segment have garbage. */ +@RunWith(JUnit4.class) public class IgniteWalIteratorSwitchSegmentTest extends GridCommonAbstractTest { /** Segment file size. */ private static final int SEGMENT_SIZE = 1024 * 1024; @@ -88,12 +91,6 @@ public class IgniteWalIteratorSwitchSegmentTest extends GridCommonAbstractTest { 2 }; - /** FileWriteAheadLogManagers for check. */ - private Class[] checkWalManagers = new Class[] { - FileWriteAheadLogManager.class, - FsyncModeFileWriteAheadLogManager.class - }; - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -113,6 +110,7 @@ public class IgniteWalIteratorSwitchSegmentTest extends GridCommonAbstractTest { * * @throws Exception If some thing failed. */ + @Test public void testCheckSerializer() throws Exception { for (int serVer : checkSerializerVers) { checkInvariantSwitchSegmentSize(serVer); @@ -169,17 +167,14 @@ private void checkInvariantSwitchSegmentSize(int serVer) throws Exception { * * @throws Exception If some thing failed. */ + @Test public void testInvariantSwitchSegment() throws Exception { for (int serVer : checkSerializerVers) { - for (Class walMgrClass : checkWalManagers) { - try { - log.info("checking wal manager " + walMgrClass + " with serializer version " + serVer); - - checkInvariantSwitchSegment(walMgrClass, serVer); - } - finally { - U.delete(Paths.get(U.defaultWorkDirectory())); - } + try { + checkInvariantSwitchSegment(serVer); + } + finally { + U.delete(Paths.get(U.defaultWorkDirectory())); } } } @@ -189,26 +184,26 @@ public void testInvariantSwitchSegment() throws Exception { * * @throws Exception If some thing failed. */ + @Test public void testSwitchReadingSegmentFromWorkToArchive() throws Exception { for (int serVer : checkSerializerVers) { - try { - checkSwitchReadingSegmentDuringIteration(FileWriteAheadLogManager.class, serVer); - } - finally { - U.delete(Paths.get(U.defaultWorkDirectory())); - } + try { + checkSwitchReadingSegmentDuringIteration(serVer); + } + finally { + U.delete(Paths.get(U.defaultWorkDirectory())); + } } } /** - * @param walMgrClass WAL manager class. * @param serVer WAL serializer version. * @throws Exception If some thing failed. */ - private void checkInvariantSwitchSegment(Class walMgrClass, int serVer) throws Exception { + private void checkInvariantSwitchSegment(int serVer) throws Exception { String workDir = U.defaultWorkDirectory(); - T2 initTup = initiate(walMgrClass, serVer, workDir); + T2 initTup = initiate(serVer, workDir); IgniteWriteAheadLogManager walMgr = initTup.get1(); @@ -271,9 +266,8 @@ private void checkInvariantSwitchSegment(Class walMgrClass, int serVer) throws E // Add more record for rollover to the next segment. recordsToWrite += 100; - for (int i = 0; i < recordsToWrite; i++) { + for (int i = 0; i < recordsToWrite; i++) walMgr.log(new MetastoreDataRecord(rec.key(), rec.value())); - } walMgr.flush(null, true); @@ -326,14 +320,13 @@ private void checkInvariantSwitchSegment(Class walMgrClass, int serVer) throws E } /** - * @param walMgrClass WAL manager class. * @param serVer WAL serializer version. * @throws Exception If some thing failed. */ - private void checkSwitchReadingSegmentDuringIteration(Class walMgrClass, int serVer) throws Exception { + private void checkSwitchReadingSegmentDuringIteration(int serVer) throws Exception { String workDir = U.defaultWorkDirectory(); - T2 initTup = initiate(walMgrClass, serVer, workDir); + T2 initTup = initiate(serVer, workDir); IgniteWriteAheadLogManager walMgr = initTup.get1(); @@ -369,8 +362,7 @@ private void checkSwitchReadingSegmentDuringIteration(Class walMgrClass, int ser () -> { // Check that switch segment works as expected and all record is reachable. try (WALIterator it = walMgr.replay(null)) { - Object handle = getFieldValueHierarchy(it, "currWalSegment"); - + Object handle = getFieldValueHierarchy(it, "currWalSegment"); FileInput in = getFieldValueHierarchy(handle, "in"); Object delegate = getFieldValueHierarchy(in.io(), "delegate"); Channel ch = getFieldValueHierarchy(delegate, "ch"); @@ -423,14 +415,12 @@ private void checkSwitchReadingSegmentDuringIteration(Class walMgrClass, int ser /*** * Initiate WAL manager. * - * @param walMgrClass WAL manager class. * @param serVer WAL serializer version. * @param workDir Work directory path. * @return Tuple of WAL manager and WAL record serializer. * @throws IgniteCheckedException If some think failed. */ private T2 initiate( - Class walMgrClass, int serVer, String workDir ) throws IgniteCheckedException { @@ -448,6 +438,7 @@ private T2 initiate( .setWalMode(WALMode.FSYNC) .setWalPath(workDir + WORK_SUB_DIR) .setWalArchivePath(workDir + ARCHIVE_SUB_DIR) + .setFileIOFactory(new RandomAccessFileIOFactory()) ); cfg.setEventStorageSpi(new NoopEventStorageSpi()); @@ -464,18 +455,9 @@ private T2 initiate( } }; - IgniteWriteAheadLogManager walMgr = null; + IgniteWriteAheadLogManager walMgr = new FileWriteAheadLogManager(kctx); - if (walMgrClass.equals(FileWriteAheadLogManager.class)) { - walMgr = new FileWriteAheadLogManager(kctx); - - GridTestUtils.setFieldValue(walMgr, "serializerVer", serVer); - } - else if (walMgrClass.equals(FsyncModeFileWriteAheadLogManager.class)) { - walMgr = new FsyncModeFileWriteAheadLogManager(kctx); - - GridTestUtils.setFieldValue(walMgr, "serializerVersion", serVer); - } + GridTestUtils.setFieldValue(walMgr, "serializerVer", serVer); GridCacheSharedContext ctx = new GridCacheSharedContext<>( kctx, diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java index 57565bfd58c48..ab4b9e057889a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceTest.java @@ -63,6 +63,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.nio.file.StandardOpenOption.CREATE; import static java.nio.file.StandardOpenOption.READ; @@ -72,6 +75,7 @@ /** * Historical WAL rebalance base test. */ +@RunWith(JUnit4.class) public class IgniteWalRebalanceTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -151,6 +155,7 @@ public class IgniteWalRebalanceTest extends GridCommonAbstractTest { * * @throws Exception if failed. */ + @Test public void testSimple() throws Exception { IgniteEx ig0 = startGrid(0); IgniteEx ig1 = startGrid(1); @@ -190,6 +195,7 @@ public void testSimple() throws Exception { * * @throws Exception If failed. */ + @Test public void testRebalanceRemoves() throws Exception { IgniteEx ig0 = startGrid(0); IgniteEx ig1 = startGrid(1); @@ -237,6 +243,7 @@ public void testRebalanceRemoves() throws Exception { * * @throws Exception If failed. */ + @Test public void testWithLocalWalChange() throws Exception { System.setProperty(IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING, "true"); @@ -326,6 +333,7 @@ else if (k % 3 == 1) * * @throws Exception If failed. */ + @Test public void testWithGlobalWalChange() throws Exception { // Prepare some data. IgniteEx crd = (IgniteEx) startGrids(3); @@ -405,6 +413,7 @@ public void testWithGlobalWalChange() throws Exception { * * @throws Exception If failed. */ + @Test public void testRebalanceCancelOnSupplyError() throws Exception { // Prepare some data. IgniteEx crd = (IgniteEx) startGrids(3); @@ -612,11 +621,6 @@ static class FailingIOFactory implements FileIOFactory { this.delegate = delegate; } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, WRITE, READ); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { FileIO delegateIO = delegate.create(file, modes); @@ -645,4 +649,4 @@ public void reset() { failRead = false; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryPPCTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryPPCTest.java index d3e6278084026..f0cff40f51716 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryPPCTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryPPCTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteWalRecoveryPPCTest extends GridCommonAbstractTest { /** */ private boolean fork; @@ -138,6 +142,7 @@ public class IgniteWalRecoveryPPCTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testWalSimple() throws Exception { try { IgniteEx ignite = startGrid(1); @@ -234,6 +239,7 @@ else if (i % 2 == 0) /** * */ + @Test public void testDynamicallyStartedNonPersistentCache() throws Exception { try { IgniteEx ignite = startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoverySeveralRestartsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoverySeveralRestartsTest.java index db20ace425b6f..cb2ea1d1e95dd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoverySeveralRestartsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoverySeveralRestartsTest.java @@ -37,10 +37,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteWalRecoverySeveralRestartsTest extends GridCommonAbstractTest { /** */ public static final int PAGE_SIZE = 1024; @@ -113,6 +117,7 @@ public class IgniteWalRecoverySeveralRestartsTest extends GridCommonAbstractTest /** * @throws Exception if failed. */ + @Test public void testWalRecoverySeveralRestarts() throws Exception { try { IgniteEx ignite = startGrid(1); @@ -168,6 +173,7 @@ public void testWalRecoverySeveralRestarts() throws Exception { /** * @throws Exception if failed. */ + @Test public void testWalRecoveryWithDynamicCache() throws Exception { try { IgniteEx ignite = startGrid(1); @@ -221,6 +227,7 @@ public void testWalRecoveryWithDynamicCache() throws Exception { /** * @throws Exception if failed. */ + @Test public void testWalRecoveryWithDynamicCacheLargeObjects() throws Exception { try { IgniteEx ignite = startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalSerializerVersionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalSerializerVersionTest.java index dcb8e7f452719..33d66c04b25bb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalSerializerVersionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalSerializerVersionTest.java @@ -43,11 +43,11 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteCallable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SERIALIZER_VERSION; import static org.apache.ignite.transactions.TransactionState.PREPARED; @@ -55,16 +55,12 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteWalSerializerVersionTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { IgniteConfiguration cfg = super.getConfiguration(name); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setPersistenceEnabled(true) @@ -76,6 +72,7 @@ public class IgniteWalSerializerVersionTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCheckDifferentSerializerVersions() throws Exception { System.setProperty(IGNITE_WAL_SERIALIZER_VERSION, "1"); @@ -127,6 +124,7 @@ public void testCheckDifferentSerializerVersions() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCheckDifferentSerializerVersionsAndLogTimestamp() throws Exception { IgniteCallable> recordsFactory = new IgniteCallable>() { @Override public List call() throws Exception { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionAfterRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionAfterRestartTest.java new file mode 100644 index 0000000000000..73933a3496e70 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionAfterRestartTest.java @@ -0,0 +1,158 @@ +/* +* 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. +*/ +package org.apache.ignite.internal.processors.cache.persistence.db.wal; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.events.WalSegmentCompactedEvent; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiTuple; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.events.EventType.EVT_WAL_SEGMENT_COMPACTED; + +/** */ +@RunWith(JUnit4.class) +public class WalCompactionAfterRestartTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(name); + + cfg.setDataStorageConfiguration(new DataStorageConfiguration() + .setDefaultDataRegionConfiguration(new DataRegionConfiguration() + .setPersistenceEnabled(true) + .setMaxSize(200L * 1024 * 1024)) + .setWalMode(WALMode.LOG_ONLY) + .setWalSegmentSize(512 * 1024) + .setWalCompactionEnabled(true) + .setMaxWalArchiveSize(2 * 512 * 1024) + ); + + CacheConfiguration ccfg = new CacheConfiguration(); + + ccfg.setName(DEFAULT_CACHE_NAME); + ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); + ccfg.setAffinity(new RendezvousAffinityFunction(false, 16)); + ccfg.setBackups(0); + + cfg.setCacheConfiguration(ccfg); + cfg.setConsistentId(name); + + cfg.setIncludeEventTypes(EVT_WAL_SEGMENT_COMPACTED); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void test() throws Exception { + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + doCachePuts(ig, 10_000); + + ig.cluster().active(false); + + stopGrid(0); + + IgniteEx ig0 = startGrid(0); + + ig0.cluster().active(true); + + List> discrepancies = Collections.synchronizedList(new ArrayList<>()); + + ig0.events().localListen(e -> { + long evtSegIdx = ((WalSegmentCompactedEvent)e).getAbsWalSegmentIdx(); + long lastCompactedIdx = ig0.context().cache().context().wal().lastCompactedSegment(); + + if (lastCompactedIdx < 0 || lastCompactedIdx > evtSegIdx) + discrepancies.add(F.t(evtSegIdx, lastCompactedIdx)); + + return true; + }, EVT_WAL_SEGMENT_COMPACTED); + + doCachePuts(ig0, 5_000); + + stopGrid(0); + + if (!discrepancies.isEmpty()) { + fail("Discrepancies (EVT_WAL_SEGMENT_COMPACTED index vs. lastCompactedSegment):" + System.lineSeparator() + + discrepancies.stream() + .map(t -> String.format("%d <-> %d", t.get1(), t.get2())) + .collect(Collectors.joining(System.lineSeparator()))); + } + } + + /** */ + private void doCachePuts(IgniteEx ig, long millis) throws IgniteCheckedException { + IgniteCache cache = ig.getOrCreateCache(DEFAULT_CACHE_NAME); + + AtomicBoolean stop = new AtomicBoolean(); + + IgniteInternalFuture putFut = GridTestUtils.runMultiThreadedAsync(() -> { + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + while (!stop.get()) + cache.put(rnd.nextInt(), "Ignite".getBytes()); + }, 4, "cache-filler"); + + U.sleep(millis); + + stop.set(true); + + putFut.get(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionSwitchOnTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionSwitchOnTest.java new file mode 100644 index 0000000000000..70183ae151313 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionSwitchOnTest.java @@ -0,0 +1,144 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.db.wal; + +import java.io.File; +import java.io.FileFilter; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; +import org.apache.ignite.internal.util.lang.GridAbsPredicate; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Load without compaction -> Stop -> Enable WAL Compaction -> Start. + */ +public class WalCompactionSwitchOnTest extends GridCommonAbstractTest { + /** Compaction enabled. */ + private boolean compactionEnabled; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setDataStorageConfiguration(new DataStorageConfiguration() + .setDefaultDataRegionConfiguration( + new DataRegionConfiguration() + .setPersistenceEnabled(true) + .setMaxSize(256 * 1024 * 1024)) + .setWalSegmentSize(512 * 1024) + .setWalSegments(100) + .setWalCompactionEnabled(compactionEnabled)); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + cleanPersistenceDir(); + } + + /** + * Load without compaction -> Stop -> Enable WAL Compaction -> Start. + * + * @throws Exception On exception. + */ + @Test + public void testWalCompactionSwitch() throws Exception { + IgniteEx ex = startGrid(0); + + ex.cluster().active(true); + + IgniteCache cache = ex.getOrCreateCache( + new CacheConfiguration() + .setName("c1") + .setGroupName("g1") + .setCacheMode(CacheMode.PARTITIONED) + ); + + for (int i = 0; i < 500; i++) + cache.put(i, i); + + File walDir = U.resolveWorkDirectory( + ex.configuration().getWorkDirectory(), + "db/wal/node00-" + ex.localNode().consistentId(), + false + ); + + forceCheckpoint(); + + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + File[] archivedFiles = walDir.listFiles(new FileFilter() { + @Override public boolean accept(File pathname) { + return pathname.getName().endsWith(".wal"); + } + }); + + return archivedFiles.length == 39; + } + }, 5000); + + stopGrid(0); + + compactionEnabled = true; + + ex = startGrid(0); + + ex.cluster().active(true); + + File archiveDir = U.resolveWorkDirectory( + ex.configuration().getWorkDirectory(), + "db/wal/archive/node00-" + ex.localNode().consistentId(), + false + ); + + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + File[] archivedFiles = archiveDir.listFiles(new FileFilter() { + @Override public boolean accept(File pathname) { + return pathname.getName().endsWith(FilePageStoreManager.ZIP_SUFFIX); + } + }); + + return archivedFiles.length == 20; + } + }, 5000); + + File[] tmpFiles = archiveDir.listFiles(new FileFilter() { + @Override public boolean accept(File pathname) { + return pathname.getName().endsWith(FilePageStoreManager.TMP_SUFFIX); + } + }); + + assertEquals(0, tmpFiles.length); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionTest.java index dcc2280f8cee0..9cf44cd2735c3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionTest.java @@ -1,19 +1,19 @@ /* -* 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. -*/ + * 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. + */ package org.apache.ignite.internal.processors.cache.persistence.db.wal; import java.io.File; @@ -21,6 +21,7 @@ import java.io.RandomAccessFile; import java.util.Arrays; import java.util.Comparator; +import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; @@ -36,20 +37,18 @@ import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_PAGE_SIZE; /** * */ +@RunWith(JUnit4.class) public class WalCompactionTest extends GridCommonAbstractTest { - /** Ip finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Wal segment size. */ private static final int WAL_SEGMENT_SIZE = 4 * 1024 * 1024; @@ -69,8 +68,6 @@ public class WalCompactionTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { IgniteConfiguration cfg = super.getConfiguration(name); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setPersistenceEnabled(true) @@ -117,6 +114,7 @@ public class WalCompactionTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testApplyingUpdatesFromCompactedWal() throws Exception { testApplyingUpdatesFromCompactedWal(false); } @@ -126,6 +124,7 @@ public void testApplyingUpdatesFromCompactedWal() throws Exception { * * @throws Exception If failed. */ + @Test public void testApplyingUpdatesFromCompactedWalWhenCompressorDisabled() throws Exception { testApplyingUpdatesFromCompactedWal(true); } @@ -221,11 +220,26 @@ else if (arr[i] != 1) { } assertFalse(fail); + + // Check compation successfully reset on blt changed. + stopAllGrids(); + + Ignite ignite = startGrids(2); + + ignite.cluster().active(true); + + resetBaselineTopology(); + + // This node will join to different blt. + startGrid(2); + + awaitPartitionMapExchange(); } /** * */ + @Test public void testCompressorToleratesEmptyWalSegmentsFsync() throws Exception { testCompressorToleratesEmptyWalSegments(WALMode.FSYNC); } @@ -233,6 +247,7 @@ public void testCompressorToleratesEmptyWalSegmentsFsync() throws Exception { /** * */ + @Test public void testCompressorToleratesEmptyWalSegmentsLogOnly() throws Exception { testCompressorToleratesEmptyWalSegments(WALMode.LOG_ONLY); } @@ -306,6 +321,7 @@ private void testCompressorToleratesEmptyWalSegments(WALMode walMode) throws Exc /** * @throws Exception If failed. */ + @Test public void testSeekingStartInCompactedSegment() throws Exception { IgniteEx ig = (IgniteEx)startGrids(3); ig.cluster().active(true); @@ -372,13 +388,12 @@ public void testSeekingStartInCompactedSegment() throws Exception { File[] cpMarkers = cpMarkersDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { - return !( - name.equals(cpMarkersToSave[0].getName()) || - name.equals(cpMarkersToSave[1].getName()) || - name.equals(cpMarkersToSave[2].getName()) || - name.equals(cpMarkersToSave[3].getName()) || - name.equals(cpMarkersToSave[4].getName()) - ); + for (File cpMarker : cpMarkersToSave) { + if (cpMarker.getName().equals(name)) + return false; + } + + return true; } }); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalDeletionArchiveAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalDeletionArchiveAbstractTest.java index f8aeb6a86c4ba..27a121c8cb4cd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalDeletionArchiveAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalDeletionArchiveAbstractTest.java @@ -23,6 +23,8 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; @@ -34,16 +36,17 @@ import org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE; /** * */ +@RunWith(JUnit4.class) public abstract class WalDeletionArchiveAbstractTest extends GridCommonAbstractTest { - /** */ - public static final String CACHE_NAME = "SomeCache"; - /** * Start grid with override default configuration via customConfigurator. */ @@ -71,6 +74,13 @@ private Ignite startGrid(Consumer customConfigurator) return ignite; } + /** */ + private CacheConfiguration cacheConfiguration() { + CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); + + return ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); + } + /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { stopAllGrids(); @@ -95,6 +105,7 @@ private Ignite startGrid(Consumer customConfigurator) /** * History size parameters consistency check. Should be set just one of wal history size or max wal archive size. */ + @Test public void testGridDoesNotStart_BecauseBothWalHistorySizeAndMaxWalArchiveSizeUsed() throws Exception { //given: wal history size and max wal archive size are both set. IgniteConfiguration configuration = getConfiguration(getTestIgniteInstanceName()); @@ -125,6 +136,7 @@ private String findSourceMessage(Throwable ex) { /** * Correct delete archived wal files. */ + @Test public void testCorrectDeletedArchivedWalFiles() throws Exception { //given: configured grid with setted max wal archive size long maxWalArchiveSize = 2 * 1024 * 1024; @@ -136,7 +148,7 @@ public void testCorrectDeletedArchivedWalFiles() throws Exception { long allowedThresholdWalArchiveSize = maxWalArchiveSize / 2; - IgniteCache cache = ignite.getOrCreateCache(CACHE_NAME); + IgniteCache cache = ignite.getOrCreateCache(cacheConfiguration()); //when: put to cache more than 2 MB for (int i = 0; i < 500; i++) @@ -165,6 +177,7 @@ public void testCorrectDeletedArchivedWalFiles() throws Exception { /** * Checkpoint triggered depends on wal size. */ + @Test public void testCheckpointStarted_WhenWalHasTooBigSizeWithoutCheckpoint() throws Exception { //given: configured grid with max wal archive size = 1MB, wal segment size = 512KB Ignite ignite = startGrid(dbCfg -> { @@ -173,7 +186,7 @@ public void testCheckpointStarted_WhenWalHasTooBigSizeWithoutCheckpoint() throws GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite); - IgniteCache cache = ignite.getOrCreateCache(CACHE_NAME); + IgniteCache cache = ignite.getOrCreateCache(cacheConfiguration()); for (int i = 0; i < 500; i++) cache.put(i, i); @@ -191,6 +204,7 @@ public void testCheckpointStarted_WhenWalHasTooBigSizeWithoutCheckpoint() throws * * @deprecated Test old removing process depends on WalHistorySize. */ + @Test public void testCheckpointHistoryRemovingByWalHistorySize() throws Exception { //given: configured grid with wal history size = 10 int walHistorySize = 10; @@ -201,7 +215,7 @@ public void testCheckpointHistoryRemovingByWalHistorySize() throws Exception { GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite); - IgniteCache cache = ignite.getOrCreateCache(CACHE_NAME); + IgniteCache cache = ignite.getOrCreateCache(cacheConfiguration()); //when: put to cache and do checkpoint int testNumberOfCheckpoint = walHistorySize * 2; @@ -225,6 +239,7 @@ public void testCheckpointHistoryRemovingByWalHistorySize() throws Exception { * Correct delete checkpoint history from memory depends on IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE. WAL files * doesn't delete because deleting was disabled. */ + @Test public void testCorrectDeletedCheckpointHistoryButKeepWalFiles() throws Exception { System.setProperty(IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, "2"); //given: configured grid with disabled WAL removing. @@ -234,7 +249,7 @@ public void testCorrectDeletedCheckpointHistoryButKeepWalFiles() throws Exceptio GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite); - IgniteCache cache = ignite.getOrCreateCache(CACHE_NAME); + IgniteCache cache = ignite.getOrCreateCache(cacheConfiguration()); //when: put to cache for (int i = 0; i < 500; i++) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalPathsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalPathsTest.java index 7141fed0807f4..d64953e578c41 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalPathsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalPathsTest.java @@ -23,8 +23,12 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** Tests equal paths to WAL storage and WAL archive. */ +@RunWith(JUnit4.class) public class WalPathsTest extends GridCommonAbstractTest { /** WalPath and WalArchivePath. */ private File walDir; @@ -67,6 +71,7 @@ private IgniteConfiguration getConfig(boolean relativePath) throws Exception { * * @throws Exception If failed. */ + @Test public void testWalStoreAndArchivePathsEquality() throws Exception { IgniteConfiguration cfg = getConfig(false); @@ -78,6 +83,7 @@ public void testWalStoreAndArchivePathsEquality() throws Exception { * * @throws Exception If failed. */ + @Test public void testWalStoreAndArchiveAbsolutAndRelativePathsEquality() throws Exception { final IgniteConfiguration cfg = getConfig(true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRecoveryTxLogicalRecordsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRecoveryTxLogicalRecordsTest.java index 261167a7d6170..9837ce6f1d6d9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRecoveryTxLogicalRecordsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRecoveryTxLogicalRecordsTest.java @@ -49,8 +49,8 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager; import org.apache.ignite.internal.processors.cache.IgniteRebalanceIterator; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtDemandedPartitionsMap; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; @@ -65,10 +65,14 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class WalRecoveryTxLogicalRecordsTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -146,6 +150,7 @@ public class WalRecoveryTxLogicalRecordsTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testWalTxSimple() throws Exception { Ignite ignite = startGrid(); @@ -221,6 +226,7 @@ public void testWalTxSimple() throws Exception { /** * @throws Exception if failed. */ + @Test public void testWalRecoveryRemoves() throws Exception { Ignite ignite = startGrid(); @@ -309,6 +315,7 @@ public void testWalRecoveryRemoves() throws Exception { /** * @throws Exception if failed. */ + @Test public void testHistoricalRebalanceIterator() throws Exception { System.setProperty(IgniteSystemProperties.IGNITE_PDS_WAL_REBALANCE_THRESHOLD, "0"); @@ -473,6 +480,7 @@ public void testHistoricalRebalanceIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWalAfterPreloading() throws Exception { Ignite ignite = startGrid(); @@ -515,6 +523,7 @@ public void testWalAfterPreloading() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRecoveryRandomPutRemove() throws Exception { try { pageSize = 1024; @@ -572,6 +581,7 @@ public void testRecoveryRandomPutRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRecoveryNoPageLost1() throws Exception { recoveryNoPageLost(false); } @@ -579,13 +589,17 @@ public void testRecoveryNoPageLost1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRecoveryNoPageLost2() throws Exception { recoveryNoPageLost(true); } /** + * Test checks that the number of pages per each page store are not changing before and after node restart. + * * @throws Exception If failed. */ + @Test public void testRecoveryNoPageLost3() throws Exception { try { pageSize = 1024; @@ -679,7 +693,7 @@ private void recoveryNoPageLost(boolean checkpoint) throws Exception { pages = allocatedPages(ignite, CACHE2_NAME); - ignite.close(); + stopGrid(0, true); } } finally { @@ -721,6 +735,7 @@ private List allocatedPages(Ignite ignite, String cacheName) throws Exc /** * @throws Exception If failed. */ + @Test public void testFreeListRecovery() throws Exception { try { pageSize = 1024; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingTest.java index 395b03ae4367c..e8e39b34aadf1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverRecordLoggingTest.java @@ -30,40 +30,33 @@ import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; import org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord; +import org.apache.ignite.internal.pagemem.wal.record.RolloverType; import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + /** * */ +@RunWith(JUnit4.class) public abstract class WalRolloverRecordLoggingTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static class RolloverRecord extends CheckpointRecord { /** */ private RolloverRecord() { super(null); } - - /** {@inheritDoc} */ - @Override public boolean rollOver() { - return true; - } } /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { IgniteConfiguration cfg = super.getConfiguration(name); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setPersistenceEnabled(true) @@ -97,6 +90,7 @@ private RolloverRecord() { } /** */ + @Test public void testAvoidInfinityWaitingOnRolloverOfSegment() throws Exception { IgniteEx ig = startGrid(0); @@ -142,7 +136,7 @@ public void testAvoidInfinityWaitingOnRolloverOfSegment() throws Exception { dbMgr.checkpointReadLock(); try { - walMgr.log(rec); + walMgr.log(rec, RolloverType.NEXT_SEGMENT); } finally { dbMgr.checkpointReadUnlock(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverTypesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverTypesTest.java new file mode 100644 index 0000000000000..aa1a65bf6780a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalRolloverTypesTest.java @@ -0,0 +1,370 @@ +/* +* 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. +*/ +package org.apache.ignite.internal.processors.cache.persistence.db.wal; + +import java.util.concurrent.ThreadLocalRandom; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; +import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord; +import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.spi.checkpoint.noop.NoopCheckpointSpi; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_ARCHIVE_PATH; +import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH; +import static org.apache.ignite.configuration.WALMode.FSYNC; +import static org.apache.ignite.configuration.WALMode.LOG_ONLY; +import static org.apache.ignite.internal.pagemem.wal.record.RolloverType.CURRENT_SEGMENT; +import static org.apache.ignite.internal.pagemem.wal.record.RolloverType.NEXT_SEGMENT; +import static org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.HEADER_RECORD_SIZE; + +/** + * + */ +@RunWith(JUnit4.class) +public class WalRolloverTypesTest extends GridCommonAbstractTest { + /** */ + private WALMode walMode; + + /** */ + private boolean disableWALArchiving; + + /** */ + private static class AdHocWALRecord extends CheckpointRecord { + /** */ + private AdHocWALRecord() { + super(null); + } + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(name); + + cfg.setDataStorageConfiguration(new DataStorageConfiguration() + .setDefaultDataRegionConfiguration(new DataRegionConfiguration() + .setPersistenceEnabled(true) + .setMaxSize(20 * 1024 * 1024)) + .setWalMode(walMode) + .setWalArchivePath(disableWALArchiving ? DFLT_WAL_PATH : DFLT_WAL_ARCHIVE_PATH) + .setWalSegmentSize(4 * 1024 * 1024)) + .setCheckpointSpi(new NoopCheckpointSpi()) + ; + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** */ + @Test + public void testCurrentSegmentTypeLogOnlyModeArchiveOn() throws Exception { + checkCurrentSegmentType(LOG_ONLY, false); + } + + /** */ + @Test + public void testCurrentSegmentTypeLogOnlyModeArchiveOff() throws Exception { + checkCurrentSegmentType(LOG_ONLY, true); + } + + /** */ + @Test + public void testCurrentSegmentTypeLogFsyncModeArchiveOn() throws Exception { + checkCurrentSegmentType(FSYNC, false); + } + + /** */ + @Test + public void testCurrentSegmentTypeLogFsyncModeArchiveOff() throws Exception { + checkCurrentSegmentType(FSYNC, true); + } + + /** */ + @Test + public void testNextSegmentTypeLogOnlyModeArchiveOn() throws Exception { + checkNextSegmentType(LOG_ONLY, false); + } + + /** */ + @Test + public void testNextSegmentTypeLogOnlyModeArchiveOff() throws Exception { + checkNextSegmentType(LOG_ONLY, true); + } + + /** */ + @Test + public void testNextSegmentTypeFsyncModeArchiveOn() throws Exception { + checkNextSegmentType(FSYNC, false); + } + + /** */ + @Test + public void testNextSegmentTypeFsyncModeArchiveOff() throws Exception { + checkNextSegmentType(FSYNC, true); + } + + /** */ + private void checkCurrentSegmentType(WALMode mode, boolean disableArch) throws Exception { + walMode = mode; + disableWALArchiving = disableArch; + + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + IgniteWriteAheadLogManager walMgr = ig.context().cache().context().wal(); + + ig.context().cache().context().database().checkpointReadLock(); + + try { + WALPointer ptr = walMgr.log(new AdHocWALRecord(), CURRENT_SEGMENT); + + assertEquals(0, ((FileWALPointer)ptr).index()); + } + finally { + ig.context().cache().context().database().checkpointReadUnlock(); + } + } + + /** */ + private void checkNextSegmentType(WALMode mode, boolean disableArch) throws Exception { + walMode = mode; + disableWALArchiving = disableArch; + + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + IgniteWriteAheadLogManager walMgr = ig.context().cache().context().wal(); + + ig.context().cache().context().database().checkpointReadLock(); + + try { + WALPointer ptr = walMgr.log(new AdHocWALRecord(), NEXT_SEGMENT); + + assertEquals(1, ((FileWALPointer)ptr).index()); + } + finally { + ig.context().cache().context().database().checkpointReadUnlock(); + } + } + + /** */ + @Test + public void testNextSegmentTypeWithCacheActivityLogOnlyModeArchiveOn() throws Exception { + checkNextSegmentTypeWithCacheActivity(LOG_ONLY, false); + } + + /** */ + @Test + public void testNextSegmentTypeWithCacheActivityLogOnlyModeArchiveOff() throws Exception { + checkNextSegmentTypeWithCacheActivity(LOG_ONLY, true); + } + + /** */ + @Test + public void testNextSegmentTypeWithCacheActivityFsyncModeArchiveOn() throws Exception { + checkNextSegmentTypeWithCacheActivity(FSYNC, false); + } + + /** */ + @Test + public void testNextSegmentTypeWithCacheActivityFsyncModeArchiveOff() throws Exception { + checkNextSegmentTypeWithCacheActivity(FSYNC, true); + } + + /** + * Under load, ensures the record gets into very beginning of the segment in {@code NEXT_SEGMENT} log mode. + */ + private void checkNextSegmentTypeWithCacheActivity(WALMode mode, boolean disableArch) throws Exception { + walMode = mode; + disableWALArchiving = disableArch; + + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + IgniteCache cache = ig.getOrCreateCache(DEFAULT_CACHE_NAME); + + final long testDuration = 30_000; + + long startTime = U.currentTimeMillis(); + + IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync( + () -> { + ThreadLocalRandom random = ThreadLocalRandom.current(); + + while (U.currentTimeMillis() - startTime < testDuration) + cache.put(random.nextInt(100), random.nextInt(100_000)); + }, + 8, "cache-put-thread"); + + IgniteWriteAheadLogManager walMgr = ig.context().cache().context().wal(); + + IgniteCacheDatabaseSharedManager dbMgr = ig.context().cache().context().database(); + + AdHocWALRecord markerRecord = new AdHocWALRecord(); + + WALPointer ptr0; + WALPointer ptr1; + + do { + try { + U.sleep(1000); + + ptr0 = walMgr.log(markerRecord); + + dbMgr.checkpointReadLock(); + + try { + ptr1 = walMgr.log(markerRecord, NEXT_SEGMENT); + } + finally { + dbMgr.checkpointReadUnlock(); + } + + assertTrue(ptr0 instanceof FileWALPointer); + assertTrue(ptr1 instanceof FileWALPointer); + + assertTrue(((FileWALPointer)ptr0).index() < ((FileWALPointer)ptr1).index()); + + assertEquals(HEADER_RECORD_SIZE, ((FileWALPointer)ptr1).fileOffset()); + } + catch (IgniteCheckedException e) { + log.error(e.getMessage(), e); + } + } + while (U.currentTimeMillis() - startTime < testDuration); + + fut.get(); + } + + /** */ + @Test + public void testCurrentSegmentTypeWithCacheActivityLogOnlyModeArchiveOn() throws Exception { + checkCurrentSegmentTypeWithCacheActivity(LOG_ONLY, false); + } + + /** */ + @Test + public void testCurrentSegmentTypeWithCacheActivityLogOnlyModeArchiveOff() throws Exception { + checkCurrentSegmentTypeWithCacheActivity(LOG_ONLY, true); + } + + /** */ + @Test + public void testCurrentSegmentTypeWithCacheActivityFsyncModeArchiveOn() throws Exception { + checkCurrentSegmentTypeWithCacheActivity(FSYNC, false); + } + + /** */ + @Test + public void testCurrentSegmentTypeWithCacheActivityFsyncModeArchiveOff() throws Exception { + checkCurrentSegmentTypeWithCacheActivity(FSYNC, true); + } + + /** + * Under load, ensures the record gets into very beginning of the segment in {@code NEXT_SEGMENT} log mode. + */ + private void checkCurrentSegmentTypeWithCacheActivity(WALMode mode, boolean disableArch) throws Exception { + walMode = mode; + disableWALArchiving = disableArch; + + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + IgniteCache cache = ig.getOrCreateCache(DEFAULT_CACHE_NAME); + + final long testDuration = 30_000; + + long startTime = U.currentTimeMillis(); + + IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync( + () -> { + ThreadLocalRandom random = ThreadLocalRandom.current(); + + while (U.currentTimeMillis() - startTime < testDuration) + cache.put(random.nextInt(100), random.nextInt(100_000)); + }, + 8, "cache-put-thread"); + + IgniteWriteAheadLogManager walMgr = ig.context().cache().context().wal(); + + IgniteCacheDatabaseSharedManager dbMgr = ig.context().cache().context().database(); + + AdHocWALRecord markerRecord = new AdHocWALRecord(); + + WALPointer ptr0; + WALPointer ptr1; + + do { + try { + U.sleep(1000); + + dbMgr.checkpointReadLock(); + + try { + ptr0 = walMgr.log(markerRecord, CURRENT_SEGMENT); + } + finally { + dbMgr.checkpointReadUnlock(); + } + + ptr1 = walMgr.log(markerRecord); + + assertTrue(ptr0 instanceof FileWALPointer); + assertTrue(ptr1 instanceof FileWALPointer); + + assertTrue(((FileWALPointer)ptr0).index() < ((FileWALPointer)ptr1).index()); + } + catch (IgniteCheckedException e) { + log.error(e.getMessage(), e); + } + } + while (U.currentTimeMillis() - startTime < testDuration); + + fut.get(); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteAbstractWalIteratorInvalidCrcTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteAbstractWalIteratorInvalidCrcTest.java index 0b53bb8252051..a855ae561ce68 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteAbstractWalIteratorInvalidCrcTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteAbstractWalIteratorInvalidCrcTest.java @@ -46,11 +46,12 @@ import org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.nio.ByteBuffer.allocate; import static java.nio.file.StandardOpenOption.WRITE; @@ -59,10 +60,8 @@ /** * */ +@RunWith(JUnit4.class) public abstract class IgniteAbstractWalIteratorInvalidCrcTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Size of inserting dummy value. */ private static final int VALUE_SIZE = 4 * 1024; @@ -82,8 +81,6 @@ public abstract class IgniteAbstractWalIteratorInvalidCrcTest extends GridCommon @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setWalSegmentSize(WAL_SEGMENT_SIZE) @@ -150,6 +147,7 @@ public abstract class IgniteAbstractWalIteratorInvalidCrcTest extends GridCommon * Test that iteration fails if one of archive segments contains record with invalid CRC. * @throws Exception If failed. */ + @Test public void testArchiveCorruptedPtr() throws Exception { doTest((archiveDescs, descs) -> archiveDescs.get(random.nextInt(archiveDescs.size())), false, true); } @@ -159,6 +157,7 @@ public void testArchiveCorruptedPtr() throws Exception { * and it is not the tail segment. * @throws Exception If failed. */ + @Test public void testNotTailCorruptedPtr() throws Exception { doTest((archiveDescs, descs) -> descs.get(random.nextInt(descs.size() - 1)), true, true); } @@ -168,6 +167,7 @@ public void testNotTailCorruptedPtr() throws Exception { * Test that iteration does not fail if tail segment in working directory contains record with invalid CRC. * @throws Exception If failed. */ + @Test public void testTailCorruptedPtr() throws Exception { doTest((archiveDescs, descs) -> descs.get(descs.size() - 1), false, false); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteDataIntegrityTests.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteDataIntegrityTests.java index 59dd3b7e7dc9b..208db7438f3fa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteDataIntegrityTests.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteDataIntegrityTests.java @@ -17,35 +17,40 @@ package org.apache.ignite.internal.processors.cache.persistence.db.wal.crc; -import junit.framework.TestCase; import java.io.EOFException; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.concurrent.ThreadLocalRandom; + import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory; import org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferExpander; +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc; import org.apache.ignite.internal.processors.cache.persistence.wal.io.FileInput; import org.apache.ignite.internal.processors.cache.persistence.wal.io.SimpleFileInput; import org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException; -import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * */ -public class IgniteDataIntegrityTests extends TestCase { +public class IgniteDataIntegrityTests { /** File input. */ private SimpleFileInput fileInput; /** Buffer expander. */ private ByteBufferExpander expBuf; - /** {@inheritDoc} */ - @Override protected void setUp() throws Exception { - super.setUp(); - + /** */ + @Before + public void setUp() throws Exception { File file = File.createTempFile("integrity", "dat"); file.deleteOnExit(); @@ -59,6 +64,7 @@ public class IgniteDataIntegrityTests extends TestCase { ); ByteBuffer buf = ByteBuffer.allocate(1024); + ThreadLocalRandom curr = ThreadLocalRandom.current(); for (int i = 0; i < 1024; i+=16) { @@ -66,7 +72,7 @@ public class IgniteDataIntegrityTests extends TestCase { buf.putInt(curr.nextInt()); buf.putInt(curr.nextInt()); buf.position(i); - buf.putInt(PureJavaCrc32.calcCrc32(buf, 12)); + buf.putInt(FastCrc.calcCrc(buf, 12)); } buf.rewind(); @@ -75,8 +81,9 @@ public class IgniteDataIntegrityTests extends TestCase { fileInput.io().force(); } - /** {@inheritDoc} */ - @Override protected void tearDown() throws Exception { + /** */ + @After + public void tearDown() throws Exception { fileInput.io().close(); expBuf.close(); } @@ -84,6 +91,7 @@ public class IgniteDataIntegrityTests extends TestCase { /** * */ + @Test public void testSuccessfulPath() throws Exception { checkIntegrity(); } @@ -91,6 +99,7 @@ public void testSuccessfulPath() throws Exception { /** * */ + @Test public void testIntegrityViolationChecking() throws Exception { toggleOneRandomBit(0, 1024 - 16); @@ -106,6 +115,7 @@ public void testIntegrityViolationChecking() throws Exception { /** * */ + @Test public void testSkipingLastCorruptedEntry() throws Exception { toggleOneRandomBit(1024 - 16, 1024); @@ -121,6 +131,7 @@ public void testSkipingLastCorruptedEntry() throws Exception { /** * */ + @Test public void testExpandBuffer() { ByteBufferExpander expBuf = new ByteBufferExpander(24, ByteOrder.nativeOrder()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgnitePureJavaCrcCompatibility.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgnitePureJavaCrcCompatibility.java new file mode 100644 index 0000000000000..4f49990c603b0 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgnitePureJavaCrcCompatibility.java @@ -0,0 +1,58 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.persistence.db.wal.crc; + +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc; +import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32; + +import java.nio.ByteBuffer; +import java.util.concurrent.ThreadLocalRandom; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * PureJavaCrc32 previous crc algo realization vs java.util.zip.crc32 test. + */ +public class IgnitePureJavaCrcCompatibility { + /** + * Test crc algo equality results. + * @throws Exception + */ + @Test + public void testAlgoEqual() throws Exception { + ByteBuffer buf = ByteBuffer.allocate(1024); + + ThreadLocalRandom curr = ThreadLocalRandom.current(); + + for (int i = 0; i < 1024; i+=16) { + buf.putInt(curr.nextInt()); + buf.putInt(curr.nextInt()); + buf.putInt(curr.nextInt()); + buf.position(i); + + buf.position(i); + int crc0 = FastCrc.calcCrc(buf, 12); + + buf.position(i); + int crc1 = PureJavaCrc32.calcCrc32(buf, 12); + + assertEquals(crc0, crc1); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteReplayWalIteratorInvalidCrcTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteReplayWalIteratorInvalidCrcTest.java index 756ef78798032..0fbc7777134bf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteReplayWalIteratorInvalidCrcTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/crc/IgniteReplayWalIteratorInvalidCrcTest.java @@ -22,10 +22,14 @@ import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; import org.apache.ignite.internal.pagemem.wal.WALIterator; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteReplayWalIteratorInvalidCrcTest extends IgniteAbstractWalIteratorInvalidCrcTest { /** {@inheritDoc} */ @NotNull @Override protected WALMode getWalMode() { @@ -49,6 +53,7 @@ public class IgniteReplayWalIteratorInvalidCrcTest extends IgniteAbstractWalIter * {@inheritDoc} * Case is not relevant to the replay iterator. */ + @Test @Override public void testNotTailCorruptedPtr() { } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java index beab13883a7e0..c167559a91803 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java @@ -38,6 +38,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import javax.cache.Cache; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; @@ -55,13 +56,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; import org.apache.ignite.events.WalSegmentArchivedEvent; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.pagemem.wal.WALIterator; import org.apache.ignite.internal.pagemem.wal.WALPointer; import org.apache.ignite.internal.pagemem.wal.record.DataEntry; import org.apache.ignite.internal.pagemem.wal.record.DataRecord; -import org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry; +import org.apache.ignite.internal.pagemem.wal.record.MarshalledDataEntry; import org.apache.ignite.internal.pagemem.wal.record.TxRecord; import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry; +import org.apache.ignite.internal.pagemem.wal.record.UnwrappedDataEntry; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.GridCacheOperation; @@ -76,20 +79,21 @@ import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.logger.NullLogger; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.Arrays.fill; import static org.apache.ignite.events.EventType.EVT_WAL_SEGMENT_ARCHIVED; import static org.apache.ignite.events.EventType.EVT_WAL_SEGMENT_COMPACTED; import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.DATA_RECORD; -import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.TX_RECORD; +import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.MVCC_DATA_RECORD; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.CREATE; import static org.apache.ignite.internal.processors.cache.GridCacheOperation.DELETE; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR; @@ -98,10 +102,8 @@ /** * Test suite for WAL segments reader and event generator. */ +@RunWith(JUnit4.class) public class IgniteWalReaderTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Wal segments count */ private static final int WAL_SEGMENTS = 10; @@ -123,9 +125,6 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest { /** Custom wal mode. */ private WALMode customWalMode; - /** Clear properties in afterTest() method. */ - private boolean clearProps; - /** Set WAL and Archive path to same value. */ private boolean setWalAndArchiveToSameVal; @@ -136,8 +135,6 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - CacheConfiguration ccfg = new CacheConfiguration<>(CACHE_NAME); ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); @@ -184,8 +181,6 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { - stopAllGrids(); - cleanPersistenceDir(); } @@ -195,13 +190,13 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest { cleanPersistenceDir(); - if (clearProps) - System.clearProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS); + System.clearProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS); } /** * @throws Exception if failed. */ + @Test public void testFillWalAndReadRecords() throws Exception { setWalAndArchiveToSameVal = false; @@ -267,7 +262,7 @@ private int iterateAndCount(WALIterator walIter) throws IgniteCheckedException { WALRecord walRecord = tup.get2(); - if (walRecord.type() == DATA_RECORD) { + if (walRecord.type() == DATA_RECORD || walRecord.type() == MVCC_DATA_RECORD) { DataRecord record = (DataRecord)walRecord; for (DataEntry entry : record.writeEntries()) { @@ -293,6 +288,7 @@ private int iterateAndCount(WALIterator walIter) throws IgniteCheckedException { * * @throws Exception if failed. */ + @Test public void testArchiveCompletedEventFired() throws Exception { assertTrue(checkWhetherWALRelatedEventFired(EVT_WAL_SEGMENT_ARCHIVED)); } @@ -302,6 +298,7 @@ public void testArchiveCompletedEventFired() throws Exception { * * @throws Exception if failed. */ + @Test public void testArchiveCompactedEventFired() throws Exception { boolean oldEnableWalCompaction = enableWalCompaction; @@ -353,6 +350,7 @@ private boolean checkWhetherWALRelatedEventFired(int evtType) throws Exception { * * @throws Exception if failure occurs. */ + @Test public void testArchiveIncompleteSegmentAfterInactivity() throws Exception { AtomicBoolean waitingForEvt = new AtomicBoolean(); @@ -399,6 +397,7 @@ public void testArchiveIncompleteSegmentAfterInactivity() throws Exception { * * @throws Exception if failed. */ + @Test public void testFillWalForExactSegmentsCount() throws Exception { customWalMode = WALMode.FSYNC; @@ -483,6 +482,7 @@ private boolean remove(Map m, Object key, Object val) { * * @throws Exception if failed. */ + @Test public void testTxFillWalAndExtractDataRecords() throws Exception { Ignite ignite0 = startGrid(); @@ -584,6 +584,7 @@ private void scanIterateAndCount( /** * @throws Exception if failed. */ + @Test public void testFillWalWithDifferentTypes() throws Exception { Ignite ig = startGrid(); @@ -778,6 +779,7 @@ else if (val12 instanceof BinaryObject) { * * @throws Exception if failed. */ + @Test public void testReadEmptyWal() throws Exception { customWalMode = WALMode.FSYNC; @@ -809,6 +811,60 @@ public void testReadEmptyWal() throws Exception { ); } + /** + * Tests WAL iterator which uses shared cache context of currently started Ignite node. + */ + @Test + public void testIteratorWithCurrentKernelContext() throws Exception { + IgniteEx ignite = startGrid(0); + + ignite.cluster().active(true); + + int cntEntries = 100; + + putDummyRecords(ignite, cntEntries); + + String workDir = U.defaultWorkDirectory(); + + IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(log); + + IteratorParametersBuilder iterParametersBuilder = + createIteratorParametersBuilder(workDir, genDbSubfolderName(ignite, 0)) + .filesOrDirs(workDir) + .binaryMetadataFileStoreDir(null) + .marshallerMappingFileStoreDir(null) + .sharedContext(ignite.context().cache().context()); + + AtomicInteger cnt = new AtomicInteger(); + + IgniteBiInClosure objConsumer = (key, val) -> { + if (val instanceof IndexedObject) { + assertEquals(key, ((IndexedObject)val).iVal); + assertEquals(key, cnt.getAndIncrement()); + } + }; + + iterateAndCountDataRecord(factory.iterator(iterParametersBuilder.copy()), objConsumer, null); + + assertEquals(cntEntries, cnt.get()); + + // Test without converting non primary types. + iterParametersBuilder.keepBinary(true); + + cnt.set(0); + + IgniteBiInClosure binObjConsumer = (key, val) -> { + if (val instanceof BinaryObject) { + assertEquals(key, ((BinaryObject)val).field("iVal")); + assertEquals(key, cnt.getAndIncrement()); + } + }; + + iterateAndCountDataRecord(factory.iterator(iterParametersBuilder.copy()), binObjConsumer, null); + + assertEquals(cntEntries, cnt.get()); + } + /** * Creates and fills cache with data. * @@ -845,6 +901,7 @@ private void createCache2(Ignite ig, CacheAtomicityMode mode) { * * @throws Exception if failed. */ + @Test public void testRemoveOperationPresentedForDataEntry() throws Exception { runRemoveOperationTest(CacheAtomicityMode.TRANSACTIONAL); } @@ -854,7 +911,11 @@ public void testRemoveOperationPresentedForDataEntry() throws Exception { * * @throws Exception if failed. */ + @Test public void testRemoveOperationPresentedForDataEntryForAtomic() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + return; + runRemoveOperationTest(CacheAtomicityMode.ATOMIC); } @@ -941,6 +1002,7 @@ private void runRemoveOperationTest(CacheAtomicityMode mode) throws Exception { * * @throws Exception if failed. */ + @Test public void testPutAllTxIntoTwoNodes() throws Exception { Ignite ignite = startGrid("node0"); Ignite ignite1 = startGrid(1); @@ -1040,9 +1102,8 @@ public void testPutAllTxIntoTwoNodes() throws Exception { * * @throws Exception if failed. */ + @Test public void testTxRecordsReadWoBinaryMeta() throws Exception { - clearProps = true; - System.setProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS, "true"); Ignite ignite = startGrid("node0"); @@ -1081,6 +1142,7 @@ public void testTxRecordsReadWoBinaryMeta() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCheckBoundsIterator() throws Exception { Ignite ignite = startGrid("node0"); @@ -1287,26 +1349,34 @@ private Map iterateAndCountDataRecord( WALRecord walRecord = tup.get2(); - if (walRecord.type() == DATA_RECORD && walRecord instanceof DataRecord) { - DataRecord dataRecord = (DataRecord)walRecord; + WALRecord.RecordType type = walRecord.type(); - if (dataRecordHnd != null) - dataRecordHnd.apply(dataRecord); + //noinspection EnumSwitchStatementWhichMissesCases + switch (type) { + case DATA_RECORD: + // Fallthrough. + case MVCC_DATA_RECORD: { + assert walRecord instanceof DataRecord; - List entries = dataRecord.writeEntries(); + DataRecord dataRecord = (DataRecord)walRecord; - for (DataEntry entry : entries) { - GridCacheVersion globalTxId = entry.nearXidVersion(); + if (dataRecordHnd != null) + dataRecordHnd.apply(dataRecord); - Object unwrappedKeyObj; - Object unwrappedValObj; + List entries = dataRecord.writeEntries(); - if (entry instanceof UnwrapDataEntry) { - UnwrapDataEntry unwrapDataEntry = (UnwrapDataEntry)entry; + for (DataEntry entry : entries) { + GridCacheVersion globalTxId = entry.nearXidVersion(); + + Object unwrappedKeyObj; + Object unwrappedValObj; + + if (entry instanceof UnwrappedDataEntry) { + UnwrappedDataEntry unwrapDataEntry = (UnwrappedDataEntry)entry; unwrappedKeyObj = unwrapDataEntry.unwrappedKey(); unwrappedValObj = unwrapDataEntry.unwrappedValue(); } - else if (entry instanceof LazyDataEntry) { + else if (entry instanceof MarshalledDataEntry) { unwrappedKeyObj = null; unwrappedValObj = null; //can't check value @@ -1314,35 +1384,43 @@ else if (entry instanceof LazyDataEntry) { else { final CacheObject val = entry.value(); - unwrappedValObj = val instanceof BinaryObject ? val : val.value(null, false); + unwrappedValObj = val instanceof BinaryObject ? val : val.value(null, false); - final CacheObject key = entry.key(); + final CacheObject key = entry.key(); - unwrappedKeyObj = key instanceof BinaryObject ? key : key.value(null, false); - } + unwrappedKeyObj = key instanceof BinaryObject ? key : key.value(null, false); + } - if (DUMP_RECORDS) - log.info("//Entry operation " + entry.op() + "; cache Id" + entry.cacheId() + "; " + - "under transaction: " + globalTxId + - //; entry " + entry + - "; Key: " + unwrappedKeyObj + - "; Value: " + unwrappedValObj); + if (DUMP_RECORDS) + log.info("//Entry operation " + entry.op() + "; cache Id" + entry.cacheId() + "; " + + "under transaction: " + globalTxId + + //; entry " + entry + + "; Key: " + unwrappedKeyObj + + "; Value: " + unwrappedValObj); - if (cacheObjHnd != null && (unwrappedKeyObj != null || unwrappedValObj != null)) - cacheObjHnd.apply(unwrappedKeyObj, unwrappedValObj); + if (cacheObjHnd != null && (unwrappedKeyObj != null || unwrappedValObj != null)) + cacheObjHnd.apply(unwrappedKeyObj, unwrappedValObj); - Integer entriesUnderTx = entriesUnderTxFound.get(globalTxId); + Integer entriesUnderTx = entriesUnderTxFound.get(globalTxId); - entriesUnderTxFound.put(globalTxId, entriesUnderTx == null ? 1 : entriesUnderTx + 1); + entriesUnderTxFound.put(globalTxId, entriesUnderTx == null ? 1 : entriesUnderTx + 1); + } } - } - else if (walRecord.type() == TX_RECORD && walRecord instanceof TxRecord) { - TxRecord txRecord = (TxRecord)walRecord; - GridCacheVersion globalTxId = txRecord.nearXidVersion(); - if (DUMP_RECORDS) - log.info("//Tx Record, state: " + txRecord.state() + - "; nearTxVersion" + globalTxId); + break; + + case TX_RECORD: + // Fallthrough + case MVCC_TX_RECORD: { + assert walRecord instanceof TxRecord; + + TxRecord txRecord = (TxRecord)walRecord; + GridCacheVersion globalTxId = txRecord.nearXidVersion(); + + if (DUMP_RECORDS) + log.info("//Tx Record, state: " + txRecord.state() + + "; nearTxVersion" + globalTxId); + } } } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/FileDownloaderTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/FileDownloaderTest.java index 6f01d93c3b487..b5c11bef768a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/FileDownloaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/FileDownloaderTest.java @@ -28,6 +28,9 @@ import org.apache.ignite.internal.util.future.GridFutureAdapter; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.runAsync; import static org.junit.Assert.*; @@ -35,6 +38,7 @@ /** * FileDownloader test */ +@RunWith(JUnit4.class) public class FileDownloaderTest extends GridCommonAbstractTest { /** */ private static final Path DOWNLOADER_PATH = new File("download").toPath(); @@ -68,6 +72,7 @@ public class FileDownloaderTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void test() throws Exception { assertTrue(UPLOADER_PATH.toFile().createNewFile()); assertTrue(!DOWNLOADER_PATH.toFile().exists()); @@ -120,4 +125,4 @@ public void test() throws Exception { assertArrayEquals(Files.readAllBytes(UPLOADER_PATH), Files.readAllBytes(DOWNLOADER_PATH)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java index 18375150d06d4..91e233b04620d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java @@ -17,26 +17,33 @@ package org.apache.ignite.internal.processors.cache.persistence.metastorage; import java.io.Serializable; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; /** * Single place to add for basic MetaStorage tests. */ public class IgniteMetaStorageBasicTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); @@ -51,12 +58,6 @@ public class IgniteMetaStorageBasicTest extends GridCommonAbstractTest { cfg.setDataStorageConfiguration(storageCfg); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - return cfg; } @@ -76,6 +77,348 @@ public class IgniteMetaStorageBasicTest extends GridCommonAbstractTest { cleanPersistenceDir(); } + /** + * + */ + @Test + public void testMetaStorageMassivePutFixed() throws Exception { + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + IgniteCacheDatabaseSharedManager db = ig.context().cache().context().database(); + + MetaStorage metaStorage = db.metaStorage(); + + assertNotNull(metaStorage); + + Random rnd = new Random(); + + db.checkpointReadLock(); + + int size; + try { + for (int i = 0; i < 10_000; i++) { + size = rnd.nextBoolean() ? 3500 : 2 * 3500; + String key = "TEST_KEY_" + (i % 1000); + + byte[] arr = new byte[size]; + rnd.nextBytes(arr); + + metaStorage.remove(key); + + metaStorage.putData(key, arr/*b.toString().getBytes()*/); + } + } + finally { + db.checkpointReadUnlock(); + } + } + + /** + * + */ + @Test + public void testMetaStorageMassivePutRandom() throws Exception { + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + IgniteCacheDatabaseSharedManager db = ig.context().cache().context().database(); + + MetaStorage metaStorage = db.metaStorage(); + + assertNotNull(metaStorage); + + Random rnd = new Random(); + + db.checkpointReadLock(); + + int size; + try { + for (int i = 0; i < 50_000; i++) { + size = 100 + rnd.nextInt(9000); + + String key = "TEST_KEY_" + (i % 2_000); + + byte[] arr = new byte[size]; + rnd.nextBytes(arr); + + metaStorage.remove(key); + + metaStorage.putData(key, arr); + } + } + finally { + db.checkpointReadUnlock(); + } + + stopGrid(); + } + + /** + * @param metaStorage Meta storage. + * @param size Size. + */ + private Map putDataToMetaStorage(MetaStorage metaStorage, int size, int from) throws IgniteCheckedException { + Map res = new HashMap<>(); + + for (Iterator> it = generateTestData(size, from).iterator(); it.hasNext(); ) { + IgniteBiTuple d = it.next(); + + metaStorage.putData(d.getKey(), d.getValue()); + + res.put(d.getKey(), d.getValue()); + } + + return res; + } + + /** + * Testing data migration between metastorage partitions (delete partition case) + */ + @Test + public void testDeletePartitionFromMetaStorageMigration() throws Exception { + final Map testData = new HashMap<>(); + + MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = true; + + try { + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + IgniteCacheDatabaseSharedManager db = ig.context().cache().context().database(); + + MetaStorage metaStorage = db.metaStorage(); + + assertNotNull(metaStorage); + + db.checkpointReadLock(); + + try { + testData.putAll(putDataToMetaStorage(metaStorage, 1_000, 0)); + } + finally { + db.checkpointReadUnlock(); + } + + db.waitForCheckpoint("Test"); + + ((GridCacheDatabaseSharedManager)db).enableCheckpoints(false); + + db.checkpointReadLock(); + + try { + testData.putAll(putDataToMetaStorage(metaStorage, 1_000, 1_000)); + } + finally { + db.checkpointReadUnlock(); + } + + stopGrid(0); + + MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = false; + + IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(0)); + + cfg.getDataStorageConfiguration().setCheckpointFrequency(3600 * 1000L); + + ig = (IgniteEx)startGrid(getTestIgniteInstanceName(0), optimize(cfg), null); + + ig.cluster().active(true); + + db = ig.context().cache().context().database(); + + metaStorage = db.metaStorage(); + + assertNotNull(metaStorage); + + db.checkpointReadLock(); + + try { + testData.putAll(putDataToMetaStorage(metaStorage, 1_000, 2_000)); + } + finally { + db.checkpointReadUnlock(); + } + + db.waitForCheckpoint("Test"); + + stopGrid(0); + + ig = startGrid(0); + + ig.cluster().active(true); + + db = ig.context().cache().context().database(); + + metaStorage = db.metaStorage(); + + assertNotNull(metaStorage); + + db.checkpointReadLock(); + try { + Collection> read = metaStorage.readAll(); + + int cnt = 0; + for (IgniteBiTuple r : read) { + byte[] test = testData.get(r.get1()); + + if (test != null) { + Assert.assertArrayEquals(r.get2(), test); + + cnt++; + } + } + + assertEquals(cnt, testData.size()); + } + finally { + db.checkpointReadUnlock(); + } + } + finally { + MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = false; + } + + } + + /** + * Testing data migration between metastorage partitions + */ + @Test + public void testMetaStorageMigration() throws Exception { + final Map testData = new HashMap<>(5_000); + + generateTestData(5_000, -1).forEach(t -> testData.put(t.get1(), t.get2())); + + MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = true; + + try { + IgniteEx ig = startGrid(0); + + ig.cluster().active(true); + + IgniteCacheDatabaseSharedManager db = ig.context().cache().context().database(); + + MetaStorage metaStorage = db.metaStorage(); + + assertNotNull(metaStorage); + + db.checkpointReadLock(); + + try { + for (Map.Entry v : testData.entrySet()) + metaStorage.putData(v.getKey(), v.getValue()); + } + finally { + db.checkpointReadUnlock(); + } + + stopGrid(0); + + MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = false; + + ig = startGrid(0); + + ig.cluster().active(true); + + db = ig.context().cache().context().database(); + + metaStorage = db.metaStorage(); + + assertNotNull(metaStorage); + + db.checkpointReadLock(); + + try { + Collection> read = metaStorage.readAll(); + + int cnt = 0; + for (IgniteBiTuple r : read) { + byte[] test = testData.get(r.get1()); + + if (test != null) { + Assert.assertArrayEquals(r.get2(), test); + + cnt++; + } + } + + assertEquals(cnt, testData.size()); + } + finally { + db.checkpointReadUnlock(); + } + } + finally { + MetaStorage.PRESERVE_LEGACY_METASTORAGE_PARTITION_ID = false; + } + } + + /** + * Testing temporary storage + */ + @Test + public void testMetaStoreMigrationTmpStorage() throws Exception { + List> data = generateTestData(2_000, -1).collect(Collectors.toList()); + + // memory + try (MetaStorage.TmpStorage tmpStorage = new MetaStorage.TmpStorage(4 * 1024 * 1024, log)) { + for (IgniteBiTuple item : data) + tmpStorage.add(item.get1(), item.get2()); + + compare(tmpStorage.stream().iterator(), data.iterator()); + } + + // file + try (MetaStorage.TmpStorage tmpStorage = new MetaStorage.TmpStorage(4 * 1024, log)) { + for (IgniteBiTuple item : data) + tmpStorage.add(item.get1(), item.get2()); + + compare(tmpStorage.stream().iterator(), data.iterator()); + } + } + + /** + * Test data generation + */ + private static Stream> generateTestData(int size, int fromKey) { + final AtomicInteger idx = new AtomicInteger(fromKey); + final Random rnd = new Random(); + + return Stream.generate(() -> { + byte[] val = new byte[1024]; + + rnd.nextBytes(val); + + return new IgniteBiTuple<>("KEY_" + (fromKey < 0 ? rnd.nextInt() : idx.getAndIncrement()), val); + }).limit(size); + } + + /** + * Compare two iterator + * + * @param it It. + * @param it1 It 1. + */ + private static void compare(Iterator> it, Iterator> it1) { + while (true) { + Assert.assertEquals(it.hasNext(), it1.hasNext()); + + if (!it.hasNext()) + break; + + IgniteBiTuple i = it.next(); + IgniteBiTuple i1 = it1.next(); + + Assert.assertEquals(i.get1(), i.get1()); + + Assert.assertArrayEquals(i.get2(), i1.get2()); + } + } + /** * Verifies that MetaStorage after massive amounts of keys stored and updated keys restores its state successfully * after restart. @@ -85,6 +428,7 @@ public class IgniteMetaStorageBasicTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testMetaStorageMassivePutUpdateRestart() throws Exception { IgniteEx ig = startGrid(0); @@ -106,6 +450,35 @@ public void testMetaStorageMassivePutUpdateRestart() throws Exception { verifyKeys(ig, KEYS_CNT, KEY_PREFIX, UPDATED_VAL_PREFIX); } + /** + * @throws Exception If fails. + */ + @Test + public void testRecoveryOfMetastorageWhenNodeNotInBaseline() throws Exception { + IgniteEx ig0 = startGrid(0); + + ig0.cluster().active(true); + + final byte KEYS_CNT = 100; + final String KEY_PREFIX = "test.key."; + final String NEW_VAL_PREFIX = "new.val."; + final String UPDATED_VAL_PREFIX = "updated.val."; + + startGrid(1); + + // Disable checkpoints in order to check whether recovery works. + forceCheckpoint(grid(1)); + disableCheckpoints(grid(1)); + + loadKeys(grid(1), KEYS_CNT, KEY_PREFIX, NEW_VAL_PREFIX, UPDATED_VAL_PREFIX); + + stopGrid(1, true); + + startGrid(1); + + verifyKeys(grid(1), KEYS_CNT, KEY_PREFIX, UPDATED_VAL_PREFIX); + } + /** */ private void loadKeys(IgniteEx ig, byte keysCnt, @@ -144,4 +517,19 @@ private void verifyKeys(IgniteEx ig, Assert.assertEquals(valPrefix + i, val); } } + + /** + * Disable checkpoints on a specific node. + * + * @param node Ignite node.h + * @throws IgniteCheckedException If failed. + */ + private void disableCheckpoints(Ignite node) throws IgniteCheckedException { + assert !node.cluster().localNode().isClient(); + + GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)node).context() + .cache().context().database(); + + dbMgr.enableCheckpoints(false).get(); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/FillFactorMetricTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/FillFactorMetricTest.java index ac65c6dcb2676..0e0b286c88917 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/FillFactorMetricTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/FillFactorMetricTest.java @@ -29,18 +29,17 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for fillFactor metrics. */ +@RunWith(JUnit4.class) public class FillFactorMetricTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String MY_DATA_REGION = "MyPolicy"; @@ -56,7 +55,6 @@ public class FillFactorMetricTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { return super.getConfiguration(igniteInstanceName) - .setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)) .setDataStorageConfiguration( new DataStorageConfiguration().setDataRegionConfigurations( new DataRegionConfiguration() @@ -95,6 +93,7 @@ protected CacheConfiguration cacheCfg() { * * @throws Exception if failed. */ + @Test public void testEmptyCachePagesFillFactor() throws Exception { startGrids(1); @@ -112,6 +111,7 @@ public void testEmptyCachePagesFillFactor() throws Exception { /** * throws if failed. */ + @Test public void testFillAndEmpty() throws Exception { final AtomicBoolean stopLoadFlag = new AtomicBoolean(); final AtomicBoolean doneFlag = new AtomicBoolean(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java index 39c7dc92d2e43..44071eaa93e07 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java @@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Predicate; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.GridKernalContext; @@ -234,6 +235,11 @@ public class NoOpPageStoreManager implements IgnitePageStoreManager { // No-op. } + /** {@inheritDoc} */ + @Override public void cleanupPageStoreIfMatch(Predicate cacheGrpPred, boolean cleanFiles) { + // No-op. + } + /** {@inheritDoc} */ @Override public boolean checkAndInitCacheWorkDir(CacheConfiguration cacheCfg) throws IgniteCheckedException { return false; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpWALManager.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpWALManager.java index 811a231524522..b482c84075e66 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpWALManager.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpWALManager.java @@ -20,13 +20,15 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager; -import org.apache.ignite.internal.processors.cache.persistence.StorageException; import org.apache.ignite.internal.pagemem.wal.WALIterator; import org.apache.ignite.internal.pagemem.wal.WALPointer; +import org.apache.ignite.internal.pagemem.wal.record.RolloverType; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; -import org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor; +import org.apache.ignite.internal.processors.cache.persistence.StorageException; +import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteFuture; +import org.jetbrains.annotations.Nullable; /** * @@ -57,18 +59,33 @@ public class NoOpWALManager implements IgniteWriteAheadLogManager { return null; } + /** {@inheritDoc} */ + @Override public WALPointer log(WALRecord entry, RolloverType rollOverType) { + return null; + } + /** {@inheritDoc} */ @Override public void flush(WALPointer ptr, boolean explicitFsync) throws IgniteCheckedException, StorageException { } + /** {@inheritDoc} */ + @Override public WALRecord read(WALPointer ptr) throws IgniteCheckedException, StorageException { + return null; + } + /** {@inheritDoc} */ @Override public WALIterator replay(WALPointer start) throws IgniteCheckedException, StorageException { return null; } /** {@inheritDoc} */ - @Override public boolean reserve(WALPointer start) throws IgniteCheckedException { + @Override public WALIterator replay(WALPointer start, @Nullable IgniteBiPredicate recordDeserializeFilter) throws IgniteCheckedException, StorageException { + return null; + } + + /** {@inheritDoc} */ + @Override public boolean reserve(WALPointer start) { return false; } @@ -102,11 +119,6 @@ public class NoOpWALManager implements IgniteWriteAheadLogManager { return false; } - /** {@inheritDoc} */ - @Override public void cleanupWalDirectories() throws IgniteCheckedException { - // No-op. - } - /** {@inheritDoc} */ @Override public void start(GridCacheSharedContext cctx) throws IgniteCheckedException { // No-op. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageIdDistributionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageIdDistributionTest.java index 2008b228c910f..5ad2f5b463835 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageIdDistributionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageIdDistributionTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.logger.java.JavaLogger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class PageIdDistributionTest extends GridCommonAbstractTest { /** */ private static final int[] CACHE_IDS = new int[] { @@ -60,6 +64,7 @@ public class PageIdDistributionTest extends GridCommonAbstractTest { /** * */ + @Test public void testDistributions() { printPageIdDistribution( CU.cacheId("partitioned"), 1024, 10_000, 32, 2.5f); @@ -140,7 +145,7 @@ private void printPageIdDistribution( } /** - * Uncomment and run this test manually to get data to plot histogram for per-element distance from ideal. + * If needed run this test manually to get data to plot histogram for per-element distance from ideal. * You can use Octave to plot the histogram: *
          *     all = csvread("histo.txt");
    @@ -149,7 +154,8 @@ private void printPageIdDistribution(
          *
          * @throws Exception If failed.
          */
    -    public void _testRealHistory() throws Exception {
    +    @Test
    +    public void testRealHistory() throws Exception {
             int capacity = CACHE_IDS.length * PARTS * PAGES;
     
             info("Capacity: " + capacity);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImplNoLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImplNoLoadTest.java
    index 36a64f3022bc7..1190899496f6b 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImplNoLoadTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImplNoLoadTest.java
    @@ -38,11 +38,15 @@
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.spi.encryption.noop.NoopEncryptionSpi;
     import org.apache.ignite.testframework.junits.GridTestKernalContext;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     import org.mockito.Mockito;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class PageMemoryImplNoLoadTest extends PageMemoryNoLoadSelfTest {
         /**
          * @return Page memory implementation.
    @@ -112,6 +116,7 @@ public class PageMemoryImplNoLoadTest extends PageMemoryNoLoadSelfTest {
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testPageHandleDeallocation() throws Exception {
             // No-op.
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImplTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImplTest.java
    index cfd9543480d29..7591dd74b2111 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImplTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImplTest.java
    @@ -53,6 +53,9 @@
     import org.apache.ignite.testframework.junits.GridTestKernalContext;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     import org.mockito.Mockito;
     
     import static org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl.CHECKPOINT_POOL_OVERFLOW_ERROR_MSG;
    @@ -60,6 +63,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class PageMemoryImplTest extends GridCommonAbstractTest {
         /** Mb. */
         private static final long MB = 1024 * 1024;
    @@ -73,6 +77,7 @@ public class PageMemoryImplTest extends GridCommonAbstractTest {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testThatAllocationTooMuchPagesCauseToOOMException() throws Exception {
             PageMemoryImpl memory = createPageMemory(PageMemoryImpl.ThrottlingPolicy.DISABLED);
     
    @@ -90,6 +95,7 @@ public void testThatAllocationTooMuchPagesCauseToOOMException() throws Exception
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCheckpointBufferOverusageDontCauseWriteLockLeak() throws Exception {
             PageMemoryImpl memory = createPageMemory(PageMemoryImpl.ThrottlingPolicy.DISABLED);
     
    @@ -143,6 +149,7 @@ public void testCheckpointBufferOverusageDontCauseWriteLockLeak() throws Excepti
          * Tests that checkpoint buffer won't be overflowed with enabled CHECKPOINT_BUFFER_ONLY throttling.
          * @throws Exception If failed.
          */
    +    @Test
         public void testCheckpointBufferCantOverflowMixedLoad() throws Exception {
             testCheckpointBufferCantOverflowWithThrottlingMixedLoad(PageMemoryImpl.ThrottlingPolicy.CHECKPOINT_BUFFER_ONLY);
         }
    @@ -151,6 +158,7 @@ public void testCheckpointBufferCantOverflowMixedLoad() throws Exception {
          * Tests that checkpoint buffer won't be overflowed with enabled SPEED_BASED throttling.
          * @throws Exception If failed.
          */
    +    @Test
         public void testCheckpointBufferCantOverflowMixedLoadSpeedBased() throws Exception {
             testCheckpointBufferCantOverflowWithThrottlingMixedLoad(PageMemoryImpl.ThrottlingPolicy.SPEED_BASED);
         }
    @@ -159,6 +167,7 @@ public void testCheckpointBufferCantOverflowMixedLoadSpeedBased() throws Excepti
          * Tests that checkpoint buffer won't be overflowed with enabled TARGET_RATIO_BASED throttling.
          * @throws Exception If failed.
          */
    +    @Test
         public void testCheckpointBufferCantOverflowMixedLoadRatioBased() throws Exception {
             testCheckpointBufferCantOverflowWithThrottlingMixedLoad(PageMemoryImpl.ThrottlingPolicy.TARGET_RATIO_BASED);
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryNoStoreLeakTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryNoStoreLeakTest.java
    index 8505a3572c62c..fdd47c1656f5f 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryNoStoreLeakTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryNoStoreLeakTest.java
    @@ -25,6 +25,9 @@
     import org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl;
     import org.apache.ignite.internal.util.typedef.internal.D;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Base scenario for memory leak:
    @@ -33,6 +36,7 @@
      * 3. IgniteCacheDatabaseSharedManager started and onActive called here. Memory allocated;
      * 4. Call active(true) again. Activation successfull, non heap memory leak introduced;
      */
    +@RunWith(JUnit4.class)
     public class PageMemoryNoStoreLeakTest extends GridCommonAbstractTest {
         /** */
         private static final int PAGE_SIZE = 4 * 1024;
    @@ -46,6 +50,7 @@ public class PageMemoryNoStoreLeakTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPageDoubleInitMemoryLeak() throws Exception {
             long initVMsize = D.getCommittedVirtualMemorySize();
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSandboxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSandboxTest.java
    index c417b07995ebb..0bfe22a1a3d73 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSandboxTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSandboxTest.java
    @@ -38,21 +38,19 @@
     import org.apache.ignite.internal.processors.cache.ratemetrics.HitRateMetrics;
     import org.apache.ignite.internal.util.typedef.internal.S;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Test to visualize and debug {@link PagesWriteThrottle}.
      * Prints puts/gets rate, number of dirty pages, pages written in current checkpoint and pages in checkpoint buffer.
      * Not intended to be part of any test suite.
      */
    +@RunWith(JUnit4.class)
     public class PagesWriteThrottleSandboxTest extends GridCommonAbstractTest {
    -    /** Ip finder. */
    -    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** Cache name. */
         private static final String CACHE_NAME = "cache1";
     
    @@ -60,9 +58,6 @@ public class PagesWriteThrottleSandboxTest extends GridCommonAbstractTest {
         @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(gridName);
     
    -        TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
    -        discoverySpi.setIpFinder(ipFinder);
    -
             DataStorageConfiguration dbCfg = new DataStorageConfiguration()
                 .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
                     .setMaxSize(4000L * 1024 * 1024)
    @@ -112,6 +107,7 @@ public class PagesWriteThrottleSandboxTest extends GridCommonAbstractTest {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testThrottle() throws Exception {
             startGrids(1).active(true);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSmokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSmokeTest.java
    index 7ff134850387b..1dae7630937c5 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSmokeTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PagesWriteThrottleSmokeTest.java
    @@ -44,23 +44,17 @@
     import org.apache.ignite.internal.processors.cache.ratemetrics.HitRateMetrics;
     import org.apache.ignite.internal.util.typedef.internal.S;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    -
    -import static java.nio.file.StandardOpenOption.CREATE;
    -import static java.nio.file.StandardOpenOption.READ;
    -import static java.nio.file.StandardOpenOption.WRITE;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class PagesWriteThrottleSmokeTest extends GridCommonAbstractTest {
    -    /** Ip finder. */
    -    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** Slow checkpoint enabled. */
         private static final AtomicBoolean slowCheckpointEnabled = new AtomicBoolean(true);
     
    @@ -71,9 +65,6 @@ public class PagesWriteThrottleSmokeTest extends GridCommonAbstractTest {
         @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(gridName);
     
    -        TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
    -        discoverySpi.setIpFinder(ipFinder);
    -
             DataStorageConfiguration dbCfg = new DataStorageConfiguration()
                 .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
                     .setMaxSize(400L * 1024 * 1024)
    @@ -127,6 +118,7 @@ public class PagesWriteThrottleSmokeTest extends GridCommonAbstractTest {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testThrottle() throws Exception {
             startGrids(2).active(true);
     
    @@ -287,11 +279,6 @@ private static class SlowCheckpointFileIOFactory implements FileIOFactory {
             /** Delegate factory. */
             private final FileIOFactory delegateFactory = new RandomAccessFileIOFactory();
     
    -        /** {@inheritDoc} */
    -        @Override public FileIO create(File file) throws IOException {
    -            return create(file, CREATE, READ, WRITE);
    -        }
    -
             /** {@inheritDoc} */
             @Override public FileIO create(File file, OpenOption... openOption) throws IOException {
                 final FileIO delegate = delegateFactory.create(file, openOption);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/AbstractNodeJoinTemplate.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/AbstractNodeJoinTemplate.java
    index 219db8d166433..3d24f1b568819 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/AbstractNodeJoinTemplate.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/AbstractNodeJoinTemplate.java
    @@ -35,9 +35,6 @@
     import org.apache.ignite.lang.IgniteCallable;
     import org.apache.ignite.lang.IgniteClosure;
     import org.apache.ignite.lang.IgniteInClosure;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.junit.Assert;
     
    @@ -293,15 +290,9 @@ protected CacheConfiguration[] allCacheConfigurations() {
                 }
             };
     
    -    /** Ip finder. */
    -    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String name) throws Exception {
             return super.getConfiguration(name)
    -            .setDiscoverySpi(
    -                new TcpDiscoverySpi()
    -                    .setIpFinder(ipFinder))
                 .setDataStorageConfiguration(
                     new DataStorageConfiguration()
                         .setDefaultDataRegionConfiguration(
    @@ -786,7 +777,9 @@ public Runnable checkCacheEmpty() {
     
                         Map caches = caches(ig);
     
    -                    Assert.assertEquals(0, caches.size());
    +                    for (GridCacheAdapter cacheAdapter : caches.values())
    +                        Assert.assertTrue("Cache should be in recovery mode: " + cacheAdapter.context(),
    +                            cacheAdapter.context().isRecoveryMode());
                     }
                 });
             }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateCacheTest.java
    index 938b3c81b1650..13517ef49e21d 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateCacheTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateCacheTest.java
    @@ -23,14 +23,19 @@
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
     import org.apache.ignite.internal.util.typedef.F;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteChangeGlobalStateCacheTest extends IgniteChangeGlobalStateAbstractTest {
         /**
          *
          */
    +    @Test
         public void testCheckValueAfterActivation(){
             String cacheName = "my-cache";
     
    @@ -64,6 +69,7 @@ public void testCheckValueAfterActivation(){
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMoreKeyValueAfterActivate() throws Exception {
             String cacheName = "my-cache";
     
    @@ -117,6 +123,7 @@ public void testMoreKeyValueAfterActivate() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testDeActivateAndActivateCacheValue() throws Exception {
             String chName = "myCache";
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java
    index 16be316154b21..dd0bb0982c7e9 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java
    @@ -20,10 +20,14 @@
     import org.apache.ignite.Ignite;
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.IgniteDataStreamer;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteChangeGlobalStateDataStreamerTest extends IgniteChangeGlobalStateAbstractTest {
         /** {@inheritDoc} */
         @Override protected int backUpNodes() {
    @@ -38,6 +42,7 @@ public class IgniteChangeGlobalStateDataStreamerTest extends IgniteChangeGlobalS
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeActivateAndActivateDataStreamer() throws Exception {
             Ignite ig1 = primary(0);
             Ignite ig2 = primary(1);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStructureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStructureTest.java
    index 8902a36ea5622..ef0f18fc922be 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStructureTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStructureTest.java
    @@ -27,16 +27,21 @@
     import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
     import org.apache.ignite.internal.util.typedef.F;
     import org.apache.ignite.internal.util.typedef.internal.U;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.testframework.GridTestUtils.runAsync;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteChangeGlobalStateDataStructureTest extends IgniteChangeGlobalStateAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeActivateAndActivateAtomicLong() throws Exception {
             String lName = "myLong";
     
    @@ -108,6 +113,7 @@ public void testDeActivateAndActivateAtomicLong() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeActivateAndActivateCountDownLatch() throws Exception {
             final AtomicInteger cnt = new AtomicInteger();
     
    @@ -202,6 +208,7 @@ public void testDeActivateAndActivateCountDownLatch() throws Exception {
         /**
          *
          */
    +    @Test
         public void testDeActivateAndActivateAtomicSequence(){
             String seqName = "mySeq";
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateFailOverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateFailOverTest.java
    index 1ef269e555c20..9a7acf8f31cc0 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateFailOverTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateFailOverTest.java
    @@ -26,6 +26,9 @@
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.internal.IgniteInternalFuture;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.lang.Thread.sleep;
     import static org.apache.ignite.testframework.GridTestUtils.runAsync;
    @@ -33,6 +36,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalStateAbstractTest {
         /** {@inheritDoc} */
         @Override protected int primaryNodes() {
    @@ -57,6 +61,7 @@ public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalState
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActivateDeActivateOnFixTopology() throws Exception {
             final Ignite igB1 = backUp(0);
             final Ignite igB2 = backUp(1);
    @@ -143,6 +148,7 @@ public void testActivateDeActivateOnFixTopology() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActivateDeActivateOnJoiningNode() throws Exception {
             final Ignite igB1 = backUp(0);
             final Ignite igB2 = backUp(1);
    @@ -276,6 +282,7 @@ public void testActivateDeActivateOnJoiningNode() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActivateDeActivateOnFixTopologyWithPutValues() throws Exception {
             final Ignite igB1 = backUp(0);
             final Ignite igB2 = backUp(1);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateServiceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateServiceTest.java
    index e6c9ae5976e03..e2b1476dc95d0 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateServiceTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateServiceTest.java
    @@ -25,10 +25,14 @@
     import org.apache.ignite.services.ServiceConfiguration;
     import org.apache.ignite.services.ServiceContext;
     import org.apache.ignite.services.ServiceDescriptor;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteChangeGlobalStateServiceTest extends IgniteChangeGlobalStateAbstractTest {
         /** {@inheritDoc} */
         @Override protected int backUpClientNodes() {
    @@ -48,6 +52,7 @@ public class IgniteChangeGlobalStateServiceTest extends IgniteChangeGlobalStateA
         /**
          *
          */
    +    @Test
         public void testDeployService() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-6629");
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateTest.java
    index 9152ab90319df..7b7430e78167a 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateTest.java
    @@ -32,6 +32,9 @@
     import org.apache.ignite.internal.IgniteInternalFuture;
     import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
     import org.apache.ignite.internal.util.typedef.F;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
     import static org.apache.ignite.testframework.GridTestUtils.runAsync;
    @@ -39,10 +42,12 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstractTest {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testStopPrimaryAndActivateFromServerNode() throws Exception {
             Ignite ig1P = primary(0);
             Ignite ig2P = primary(1);
    @@ -72,6 +77,7 @@ public void testStopPrimaryAndActivateFromServerNode() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testStopPrimaryAndActivateFromClientNode() throws Exception {
             Ignite ig1P = primary(0);
             Ignite ig2P = primary(1);
    @@ -113,6 +119,7 @@ public void testStopPrimaryAndActivateFromClientNode() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testConcurrentActivateFromClientNodeAndServerNode() throws Exception {
             final Ignite ig1B = backUp(0);
             final Ignite ig2B = backUp(1);
    @@ -210,6 +217,7 @@ public void testConcurrentActivateFromClientNodeAndServerNode() throws Exception
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testConcurrentActivateFromServerNode() throws Exception {
             final Ignite ig1B = backUp(0);
             final Ignite ig2B = backUp(1);
    @@ -265,6 +273,7 @@ public void testConcurrentActivateFromServerNode() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActiveAndInActiveAtTheSameTimeCluster() throws Exception {
             Ignite ig1P = primary(0);
             Ignite ig2P = primary(1);
    @@ -302,6 +311,7 @@ public void testActiveAndInActiveAtTheSameTimeCluster() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActivateOnAlreadyActivatedCluster() throws Exception {
             Ignite ig1P = primary(0);
             Ignite ig2P = primary(1);
    @@ -359,6 +369,7 @@ public void testActivateOnAlreadyActivatedCluster() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTryUseCacheInActiveCluster() throws Exception {
             Ignite ig1B = backUp(0);
             Ignite ig2B = backUp(1);
    @@ -401,6 +412,7 @@ private void checkExceptionTryUseCache(final Ignite ig) {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTryUseServiceInActiveCluster() throws Exception {
             Ignite ig1B = backUp(0);
             Ignite ig2B = backUp(1);
    @@ -443,6 +455,7 @@ private void checkExceptionTryUseService(final Ignite ig) {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTryUseDataStructureInActiveCluster() throws Exception {
             Ignite ig1B = backUp(0);
             Ignite ig2B = backUp(1);
    @@ -485,6 +498,7 @@ private void checkExceptionTryUseDataStructure(final Ignite ig){
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFailGetLock() throws Exception {
             Ignite ig1P = primary(0);
             Ignite ig2P = primary(1);
    @@ -542,8 +556,9 @@ public void testFailGetLock() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActivateAfterFailGetLock() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-1094");
    +        fail("https://issues.apache.org/jira/browse/IGNITE-10723");
     
             Ignite ig1P = primary(0);
             Ignite ig2P = primary(1);
    @@ -618,6 +633,7 @@ public void testActivateAfterFailGetLock() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testDeActivateFromServerNode() throws Exception {
             Ignite ig1 = primary(0);
             Ignite ig2 = primary(1);
    @@ -637,6 +653,7 @@ public void testDeActivateFromServerNode() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testDeActivateFromClientNode() throws Exception {
             Ignite ig1 = primary(0);
             Ignite ig2 = primary(1);
    @@ -664,6 +681,7 @@ public void testDeActivateFromClientNode() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testDeActivateCheckCacheDestroy() throws Exception {
             String chName = "myCache";
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteNoParrallelClusterIsAllowedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteNoParrallelClusterIsAllowedTest.java
    index 5c986eea23cff..60386f11beb29 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteNoParrallelClusterIsAllowedTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteNoParrallelClusterIsAllowedTest.java
    @@ -19,19 +19,19 @@
     
     import junit.framework.AssertionFailedError;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteNoParrallelClusterIsAllowedTest extends IgniteChangeGlobalStateAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder vmIpFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testSimple() throws Exception {
             startPrimaryNodes(primaryNodes());
     
    @@ -76,7 +76,7 @@ private void tryToStartBackupClusterWhatShouldFail() {
                 while (true) {
                     String message = e.getMessage();
     
    -                if (message.contains("Failed to acquire file lock during"))
    +                if (message.contains("Failed to acquire file lock ["))
                         break;
     
                     if (e.getCause() != null)
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
    index 6900af87d2f39..9a793d4bbfad1 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
    @@ -46,28 +46,24 @@
     import org.apache.ignite.plugin.PluginContext;
     import org.apache.ignite.plugin.PluginProvider;
     import org.apache.ignite.plugin.PluginValidationException;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.jetbrains.annotations.Nullable;
     import org.junit.Assert;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteStandByClusterTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder vmIpFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /**
          *
          */
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(vmIpFinder));
    -
             cfg.setDataStorageConfiguration(new DataStorageConfiguration()
                 .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
                     .setMaxSize(100L * 1024 * 1024)
    @@ -81,6 +77,7 @@ public class IgniteStandByClusterTest extends GridCommonAbstractTest {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testStartDynamicCachesAfterActivation() throws Exception {
             final String cacheName0 = "cache0";
             final String cacheName = "cache";
    @@ -146,6 +143,7 @@ public void testStartDynamicCachesAfterActivation() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testStaticCacheStartAfterActivationWithCacheFilter() throws Exception {
             String cache1 = "cache1";
             String cache2 = "cache2";
    @@ -213,6 +211,7 @@ public void testStaticCacheStartAfterActivationWithCacheFilter() throws Exceptio
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testSimple() throws Exception {
             IgniteEx ig = startGrid(0);
     
    @@ -238,6 +237,7 @@ public void testSimple() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testJoinDaemonAndDaemonStop() throws Exception {
             IgniteEx ig = startGrid(0);
     
    @@ -258,6 +258,7 @@ public void testJoinDaemonAndDaemonStop() throws Exception {
         /**
          * Check that daemon node does not move cluster to compatibility mode.
          */
    +    @Test
         public void testJoinDaemonToBaseline() throws Exception {
             Ignite ignite0 = startGrid(0);
     
    @@ -279,6 +280,7 @@ public void testJoinDaemonToBaseline() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testCheckStatusFromDaemon() throws Exception {
             IgniteEx ig = startGrid(0);
     
    @@ -309,6 +311,7 @@ public void testCheckStatusFromDaemon() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testRestartCluster() throws Exception {
             IgniteEx ig1 = startGrid(getConfiguration("node1"));
             IgniteEx ig2 = startGrid(getConfiguration("node2"));
    @@ -344,6 +347,7 @@ public void testRestartCluster() throws Exception {
         /**
          * @throws Exception if fail.
          */
    +    @Test
         public void testActivateDeActivateCallbackForPluginProviders() throws Exception {
             IgniteEx ig1 = startGrid(getConfiguration("node1"));
             IgniteEx ig2 = startGrid(getConfiguration("node2"));
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToActiveCluster.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToActiveCluster.java
    index 8e90e78337500..628316cfc128d 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToActiveCluster.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToActiveCluster.java
    @@ -24,10 +24,14 @@
     import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
     import org.apache.ignite.internal.util.typedef.internal.CU;
     import org.junit.Assert;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
         /** {@inheritDoc} */
         @Override public JoinNodeTestPlanBuilder withOutConfigurationTemplate() throws Exception {
    @@ -193,26 +197,31 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
         // Server node join.
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinWithOutConfiguration() throws Exception {
             withOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationOnJoin() throws Exception {
             staticCacheConfigurationOnJoinTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationInCluster() throws Exception {
             staticCacheConfigurationInClusterTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationSameOnBoth() throws Exception {
             staticCacheConfigurationSameOnBothTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationDifferentOnBoth() throws Exception {
             staticCacheConfigurationDifferentOnBothTemplate().execute();
         }
    @@ -220,16 +229,19 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
         // Client node join.
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientWithOutConfiguration() throws Exception {
             joinClientWithOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationOnJoin() throws Exception {
             joinClientStaticCacheConfigurationOnJoinTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationInCluster() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-5518");
     
    @@ -237,6 +249,7 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationSameOnBoth() throws Exception {
             joinClientStaticCacheConfigurationSameOnBothTemplate().execute();
         }
    @@ -244,6 +257,7 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
         /**
          *
          */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationDifferentOnBoth() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-5518");
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToInActiveCluster.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToInActiveCluster.java
    index 59e0691ea4e6a..db762a86fc43e 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToInActiveCluster.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToInActiveCluster.java
    @@ -18,10 +18,14 @@
     package org.apache.ignite.internal.processors.cache.persistence.standbycluster.join;
     
     import org.apache.ignite.internal.processors.cache.persistence.standbycluster.AbstractNodeJoinTemplate;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class JoinActiveNodeToInActiveCluster extends AbstractNodeJoinTemplate {
         /** {@inheritDoc} */
         @Override public JoinNodeTestPlanBuilder withOutConfigurationTemplate() throws Exception {
    @@ -153,26 +157,31 @@ public class JoinActiveNodeToInActiveCluster extends AbstractNodeJoinTemplate {
         // Server node join.
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinWithOutConfiguration() throws Exception {
             withOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationOnJoin() throws Exception {
             staticCacheConfigurationOnJoinTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationInCluster() throws Exception {
             staticCacheConfigurationInClusterTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationSameOnBoth() throws Exception {
             staticCacheConfigurationSameOnBothTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationDifferentOnBoth() throws Exception {
             staticCacheConfigurationDifferentOnBothTemplate().execute();
         }
    @@ -180,16 +189,19 @@ public class JoinActiveNodeToInActiveCluster extends AbstractNodeJoinTemplate {
         // Client node join.
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientWithOutConfiguration() throws Exception {
             joinClientWithOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationOnJoin() throws Exception {
             joinClientStaticCacheConfigurationOnJoinTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationInCluster() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-5518");
     
    @@ -197,11 +209,13 @@ public class JoinActiveNodeToInActiveCluster extends AbstractNodeJoinTemplate {
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationSameOnBoth() throws Exception {
             joinClientStaticCacheConfigurationSameOnBothTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationDifferentOnBoth() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-5518");
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinInActiveNodeToActiveCluster.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinInActiveNodeToActiveCluster.java
    index d9b0dd4a48327..2ed470fbd38c3 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinInActiveNodeToActiveCluster.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinInActiveNodeToActiveCluster.java
    @@ -24,10 +24,14 @@
     import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
     import org.apache.ignite.internal.util.typedef.internal.CU;
     import org.junit.Assert;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class JoinInActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
         /** {@inheritDoc} */
         @Override public JoinNodeTestPlanBuilder withOutConfigurationTemplate() throws Exception {
    @@ -192,26 +196,31 @@ public class JoinInActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
         // Server node join.
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinWithOutConfiguration() throws Exception {
             withOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationOnJoin() throws Exception {
             staticCacheConfigurationOnJoinTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationInCluster() throws Exception {
             staticCacheConfigurationInClusterTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationSameOnBoth() throws Exception {
             staticCacheConfigurationSameOnBothTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationDifferentOnBoth() throws Exception {
             staticCacheConfigurationDifferentOnBothTemplate().execute();
         }
    @@ -219,26 +228,31 @@ public class JoinInActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
         // Client node join.
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientWithOutConfiguration() throws Exception {
             joinClientWithOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationOnJoin() throws Exception {
             joinClientStaticCacheConfigurationOnJoinTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationInCluster() throws Exception {
             joinClientStaticCacheConfigurationInClusterTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationSameOnBoth() throws Exception {
             joinClientStaticCacheConfigurationSameOnBothTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationDifferentOnBoth() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-5518");
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinInActiveNodeToInActiveCluster.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinInActiveNodeToInActiveCluster.java
    index dabd0a38f3dc0..d77564d61a614 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinInActiveNodeToInActiveCluster.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinInActiveNodeToInActiveCluster.java
    @@ -18,10 +18,14 @@
     package org.apache.ignite.internal.processors.cache.persistence.standbycluster.join;
     
     import org.apache.ignite.internal.processors.cache.persistence.standbycluster.AbstractNodeJoinTemplate;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class JoinInActiveNodeToInActiveCluster extends AbstractNodeJoinTemplate {
         /** {@inheritDoc} */
         @Override public JoinNodeTestPlanBuilder withOutConfigurationTemplate() throws Exception {
    @@ -153,26 +157,31 @@ public class JoinInActiveNodeToInActiveCluster extends AbstractNodeJoinTemplate
         // Server node join.
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinWithOutConfiguration() throws Exception {
             withOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationOnJoin() throws Exception {
             staticCacheConfigurationOnJoinTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationInCluster() throws Exception {
             staticCacheConfigurationInClusterTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationSameOnBoth() throws Exception {
             staticCacheConfigurationSameOnBothTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testStaticCacheConfigurationDifferentOnBoth() throws Exception {
             staticCacheConfigurationDifferentOnBothTemplate().execute();
         }
    @@ -180,16 +189,19 @@ public class JoinInActiveNodeToInActiveCluster extends AbstractNodeJoinTemplate
         // Client node join.
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientWithOutConfiguration() throws Exception {
             joinClientWithOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationOnJoin() throws Exception {
             joinClientStaticCacheConfigurationOnJoinTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationInCluster() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-5518");
     
    @@ -197,11 +209,13 @@ public class JoinInActiveNodeToInActiveCluster extends AbstractNodeJoinTemplate
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationSameOnBoth() throws Exception {
             joinClientStaticCacheConfigurationSameOnBothTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationDifferentOnBoth() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-5518");
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/persistence/JoinActiveNodeToActiveClusterWithPersistence.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/persistence/JoinActiveNodeToActiveClusterWithPersistence.java
    index 1ccfb7d3d7008..cd655809ab2f5 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/persistence/JoinActiveNodeToActiveClusterWithPersistence.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/persistence/JoinActiveNodeToActiveClusterWithPersistence.java
    @@ -20,10 +20,14 @@
     import org.apache.ignite.internal.processors.cache.persistence.standbycluster.join.JoinActiveNodeToActiveCluster;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.processors.cache.persistence.standbycluster.AbstractNodeJoinTemplate;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class JoinActiveNodeToActiveClusterWithPersistence extends JoinActiveNodeToActiveCluster {
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration cfg(String name) throws Exception {
    @@ -67,21 +71,25 @@ private AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder persistent(AbstractNode
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinWithOutConfiguration() throws Exception {
             withOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientWithOutConfiguration() throws Exception {
             joinClientWithOutConfigurationTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationDifferentOnBoth() throws Exception {
             staticCacheConfigurationDifferentOnBothTemplate().execute();
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testJoinClientStaticCacheConfigurationInCluster() throws Exception {
             staticCacheConfigurationInClusterTemplate().execute();
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectTest.java
    index d2244d450ebd8..28bcbb16b68b1 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectTest.java
    @@ -19,14 +19,19 @@
     
     import java.util.concurrent.CountDownLatch;
     import org.apache.ignite.internal.IgniteEx;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteStandByClientReconnectTest extends IgniteAbstractStandByClientReconnectTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActiveClientReconnectToActiveCluster() throws Exception {
             CountDownLatch activateLatch = new CountDownLatch(1);
     
    @@ -108,6 +113,7 @@ public void testActiveClientReconnectToActiveCluster() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActiveClientReconnectToInActiveCluster() throws Exception {
             CountDownLatch activateLatch = new CountDownLatch(1);
     
    @@ -188,6 +194,7 @@ public void testActiveClientReconnectToInActiveCluster() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInActiveClientReconnectToActiveCluster() throws Exception {
             CountDownLatch activateLatch = new CountDownLatch(1);
     
    @@ -245,6 +252,7 @@ public void testInActiveClientReconnectToActiveCluster() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInActiveClientReconnectToInActiveCluster() throws Exception {
             startNodes(null);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectToNewClusterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectToNewClusterTest.java
    index c1f672b29af5d..a9abff134fbe5 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectToNewClusterTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectToNewClusterTest.java
    @@ -22,14 +22,19 @@
     import java.util.Set;
     import java.util.concurrent.CountDownLatch;
     import org.apache.ignite.internal.IgniteEx;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteStandByClientReconnectToNewClusterTest extends IgniteAbstractStandByClientReconnectTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActiveClientReconnectsToActiveCluster() throws Exception {
             CountDownLatch activateLatch = new CountDownLatch(1);
     
    @@ -109,6 +114,7 @@ public void testActiveClientReconnectsToActiveCluster() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testActiveClientReconnectsToInactiveCluster() throws Exception {
             startNodes(null);
     
    @@ -189,6 +195,7 @@ public void testActiveClientReconnectsToInactiveCluster() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInactiveClientReconnectsToActiveCluster() throws Exception {
             CountDownLatch activateLatch = new CountDownLatch(1);
     
    @@ -250,6 +257,7 @@ public void testInactiveClientReconnectsToActiveCluster() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInactiveClientReconnectsToInactiveCluster() throws Exception {
             startNodes(null);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/TrackingPageIOTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/TrackingPageIOTest.java
    index cacea48c5289c..e4f0fe9588e9e 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/TrackingPageIOTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/TrackingPageIOTest.java
    @@ -25,17 +25,22 @@
     import java.util.Set;
     import java.util.TreeSet;
     import java.util.concurrent.ThreadLocalRandom;
    -import junit.framework.TestCase;
     import org.apache.ignite.internal.pagemem.PageIdAllocator;
     import org.apache.ignite.internal.pagemem.PageIdUtils;
     import org.apache.ignite.internal.processors.cache.persistence.snapshot.TrackingPageIsCorruptedException;
     import org.apache.ignite.internal.util.GridUnsafe;
     import org.jetbrains.annotations.NotNull;
    +import org.junit.Test;
    +
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertTrue;
    +import static org.junit.Assert.fail;
     
     /**
      *
      */
    -public class TrackingPageIOTest extends TestCase {
    +public class TrackingPageIOTest {
         /** Page size. */
         public static final int PAGE_SIZE = 4096;
     
    @@ -46,6 +51,7 @@ public class TrackingPageIOTest extends TestCase {
         /**
          *
          */
    +    @Test
         public void testBasics() throws Exception {
             ByteBuffer buf = createBuffer();
     
    @@ -72,6 +78,7 @@ public void testBasics() throws Exception {
         /**
          *
          */
    +    @Test
         public void testMarkingRandomly() throws Exception {
             ByteBuffer buf = createBuffer();
     
    @@ -82,6 +89,7 @@ public void testMarkingRandomly() throws Exception {
         /**
          *
          */
    +    @Test
         public void testZeroingRandomly() throws Exception {
             ByteBuffer buf = createBuffer();
     
    @@ -142,6 +150,7 @@ private void checkMarkingRandomly(ByteBuffer buf, int backupId, boolean testZero
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFindNextChangedPage() throws Exception {
             ByteBuffer buf = createBuffer();
     
    @@ -197,6 +206,7 @@ else if (setIdx.contains(pageId))
         /**
          *
          */
    +    @Test
         public void testMerging() throws Exception {
             ByteBuffer buf = createBuffer();
     
    @@ -235,6 +245,7 @@ public void testMerging() throws Exception {
         /**
          *
          */
    +    @Test
         public void testMerging_MarksShouldBeDropForSuccessfulBackup() throws Exception {
             ByteBuffer buf = createBuffer();
     
    @@ -303,6 +314,7 @@ private void generateMarking(
          *
          * @throws Exception if failed.
          */
    +    @Test
         public void testThatWeDontFailIfSnapshotTagWasLost() throws Exception {
             ByteBuffer buf = createBuffer();
     
    @@ -356,4 +368,4 @@ public void testThatWeDontFailIfSnapshotTagWasLost() throws Exception {
                 assertFalse(io.wasChanged(buf, id, oldTag, oldTag - 1, PAGE_SIZE));
             }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalDeltaConsistencyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalDeltaConsistencyTest.java
    index 7f872fd005cb7..3b324d58ec1ef 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalDeltaConsistencyTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/AbstractWalDeltaConsistencyTest.java
    @@ -18,6 +18,7 @@
     package org.apache.ignite.internal.processors.cache.persistence.wal;
     
     import org.apache.ignite.Ignite;
    +import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.DataRegionConfiguration;
     import org.apache.ignite.configuration.DataStorageConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
    @@ -46,6 +47,22 @@ public abstract class AbstractWalDeltaConsistencyTest extends GridCommonAbstract
             return cfg;
         }
     
    +    /**
    +     * @param name Cache name.
    +     * @return Cache configuration.
    +     */
    +    @SuppressWarnings("unchecked")
    +    protected   CacheConfiguration cacheConfiguration(String name) {
    +        return defaultCacheConfiguration().setName(name);
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override protected void afterTestsStopped() throws Exception {
    +        stopAllGrids();
    +
    +        super.afterTestsStopped();
    +    }
    +
         /**
          * Check page memory on each checkpoint.
          */
    @@ -76,6 +93,8 @@ protected boolean checkPagesOnCheckpoint() {
         protected DataStorageConfiguration getDataStorageConfiguration() {
             return new DataStorageConfiguration()
                 .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
    +                .setInitialSize(256 * 1024 * 1024)
    +                .setMaxSize(256 * 1024 * 1024)
                     .setPersistenceEnabled(true)
                     .setName("dflt-plc"));
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/CpTriggeredWalDeltaConsistencyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/CpTriggeredWalDeltaConsistencyTest.java
    index 781111cea1cdf..ca68ec66a29b4 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/CpTriggeredWalDeltaConsistencyTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/CpTriggeredWalDeltaConsistencyTest.java
    @@ -19,25 +19,37 @@
     
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.internal.IgniteEx;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Checkpoint triggered WAL delta records consistency test.
      */
    +@RunWith(JUnit4.class)
     public class CpTriggeredWalDeltaConsistencyTest extends AbstractWalDeltaConsistencyTest {
         /** {@inheritDoc} */
         @Override protected boolean checkPagesOnCheckpoint() {
             return true;
         }
     
    +    /** {@inheritDoc} */
    +    @Override protected void afterTest() throws Exception {
    +        stopAllGrids();
    +
    +        super.afterTest();
    +    }
    +
         /**
    -     *
    +     * @throws Exception If failed.
          */
    +    @Test
         public final void testPutRemoveCacheDestroy() throws Exception {
             IgniteEx ignite = startGrid(0);
     
             ignite.cluster().active(true);
     
    -        IgniteCache cache0 = ignite.getOrCreateCache("cache0");
    +        IgniteCache cache0 = ignite.createCache(cacheConfiguration("cache0"));
     
             for (int i = 0; i < 3_000; i++)
                 cache0.put(i, "Cache value " + i);
    @@ -49,7 +61,7 @@ public final void testPutRemoveCacheDestroy() throws Exception {
                 cache0.remove(i);
     
             for (int i = 5; i >= 0; i--) {
    -            IgniteCache cache1 = ignite.getOrCreateCache("cache1");
    +            IgniteCache cache1 = ignite.getOrCreateCache(cacheConfiguration("cache1"));
     
                 for (int j = 0; j < 300; j++)
                     cache1.put(j + i * 100, "Cache value " + j);
    @@ -59,7 +71,5 @@ public final void testPutRemoveCacheDestroy() throws Exception {
             }
     
             forceCheckpoint();
    -
    -        stopAllGrids();
         }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/ExplicitWalDeltaConsistencyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/ExplicitWalDeltaConsistencyTest.java
    index 1b9a18a8de1e6..2cd8259f6bfc8 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/ExplicitWalDeltaConsistencyTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/ExplicitWalDeltaConsistencyTest.java
    @@ -20,20 +20,33 @@
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.processors.cache.persistence.wal.memtracker.PageMemoryTrackerPluginProvider;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * WAL delta records consistency test with explicit checks.
      */
    +@RunWith(JUnit4.class)
     public class ExplicitWalDeltaConsistencyTest extends AbstractWalDeltaConsistencyTest {
    +    /** {@inheritDoc} */
    +    @Override protected void afterTest() throws Exception {
    +        stopAllGrids();
    +
    +        super.afterTest();
    +    }
    +
         /**
    -     *
    +     * @throws Exception If failed.
          */
    +    @Test
         public final void testPutRemoveAfterCheckpoint() throws Exception {
             IgniteEx ignite = startGrid(0);
     
             ignite.cluster().active(true);
     
    -        IgniteCache cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
    +        IgniteCache cache = ignite.createCache(cacheConfiguration(DEFAULT_CACHE_NAME));
     
             for (int i = 0; i < 5_000; i++)
                 cache.put(i, "Cache value " + i);
    @@ -55,30 +68,34 @@ public final void testPutRemoveAfterCheckpoint() throws Exception {
                 cache.remove(i);
     
             assertTrue(PageMemoryTrackerPluginProvider.tracker(ignite).checkPages(true));
    -
    -        stopAllGrids();
         }
     
         /**
    -     *
    +     * @throws Exception If failed.
          */
    +    @Test
         public final void testNotEmptyPds() throws Exception {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            fail("https://issues.apache.org/jira/browse/IGNITE-10822");
    +
             IgniteEx ignite = startGrid(0);
     
             ignite.cluster().active(true);
     
    -        IgniteCache cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
    +        IgniteCache cache = ignite.createCache(cacheConfiguration(DEFAULT_CACHE_NAME));
     
             for (int i = 0; i < 3_000; i++)
                 cache.put(i, "Cache value " + i);
     
    +        forceCheckpoint();
    +
             stopGrid(0);
     
             ignite = startGrid(0);
     
             ignite.cluster().active(true);
     
    -        cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
    +        cache = ignite.getOrCreateCache(cacheConfiguration(DEFAULT_CACHE_NAME));
     
             for (int i = 2_000; i < 5_000; i++)
                 cache.put(i, "Changed cache value " + i);
    @@ -87,7 +104,5 @@ public final void testNotEmptyPds() throws Exception {
                 cache.remove(i);
     
             assertTrue(PageMemoryTrackerPluginProvider.tracker(ignite).checkPages(true));
    -
    -        stopAllGrids();
         }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/SegmentedRingByteBufferTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/SegmentedRingByteBufferTest.java
    index 87f3fa781daef..032a357e6ea70 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/SegmentedRingByteBufferTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/SegmentedRingByteBufferTest.java
    @@ -39,6 +39,9 @@
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer.BufferMode.DIRECT;
     import static org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBuffer.BufferMode.ONHEAP;
    @@ -46,10 +49,12 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class SegmentedRingByteBufferTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAligned() throws Exception {
             doTestAligned(ONHEAP);
         }
    @@ -57,6 +62,7 @@ public void testAligned() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAlignedDirect() throws Exception {
             doTestAligned(DIRECT);
         }
    @@ -64,6 +70,7 @@ public void testAlignedDirect() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNotAligned() throws Exception {
             doTestNotAligned(ONHEAP);
         }
    @@ -71,6 +78,7 @@ public void testNotAligned() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNotAlignedDirect() throws Exception {
             doTestNotAligned(DIRECT);
         }
    @@ -78,6 +86,7 @@ public void testNotAlignedDirect() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoOverflowMultiThreaded() throws Exception {
             doTestNoOverflowMultiThreaded(ONHEAP);
         }
    @@ -85,6 +94,7 @@ public void testNoOverflowMultiThreaded() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoOverflowMultiThreadedDirect() throws Exception {
             doTestNoOverflowMultiThreaded(DIRECT);
         }
    @@ -92,6 +102,7 @@ public void testNoOverflowMultiThreadedDirect() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiThreaded() throws Exception {
             doTestMultiThreaded(ONHEAP);
         }
    @@ -99,6 +110,7 @@ public void testMultiThreaded() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiThreadedDirect() throws Exception {
             doTestMultiThreaded(DIRECT);
         }
    @@ -106,6 +118,7 @@ public void testMultiThreadedDirect() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiThreaded2() throws Exception {
             doTestMultiThreaded2(ONHEAP);
         }
    @@ -113,6 +126,7 @@ public void testMultiThreaded2() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiThreadedDirect2() throws Exception {
             doTestMultiThreaded2(DIRECT);
         }
    @@ -782,4 +796,4 @@ public int size() {
                 return res;
             }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/SysPropWalDeltaConsistencyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/SysPropWalDeltaConsistencyTest.java
    index db9f10448b1fa..bf32501605901 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/SysPropWalDeltaConsistencyTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/SysPropWalDeltaConsistencyTest.java
    @@ -21,10 +21,14 @@
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.processors.cache.persistence.wal.memtracker.PageMemoryTrackerPluginProvider;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * WAL delta records consistency test enabled by system property.
      */
    +@RunWith(JUnit4.class)
     public class SysPropWalDeltaConsistencyTest extends AbstractWalDeltaConsistencyTest {
         /** {@inheritDoc} */
         @Override protected void beforeTestsStarted() throws Exception {
    @@ -40,6 +44,13 @@ public class SysPropWalDeltaConsistencyTest extends AbstractWalDeltaConsistencyT
             System.clearProperty(PageMemoryTrackerPluginProvider.IGNITE_ENABLE_PAGE_MEMORY_TRACKER);
         }
     
    +    /** {@inheritDoc} */
    +    @Override protected void afterTest() throws Exception {
    +        stopAllGrids();
    +
    +        super.afterTest();
    +    }
    +
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    @@ -50,14 +61,15 @@ public class SysPropWalDeltaConsistencyTest extends AbstractWalDeltaConsistencyT
         }
     
         /**
    -     *
    +     * @throws Exception If failed.
          */
    +    @Test
         public final void testPutRemoveMultinode() throws Exception {
             IgniteEx ignite0 = startGrid(0);
     
             ignite0.cluster().active(true);
     
    -        IgniteCache cache0 = ignite0.getOrCreateCache("cache0");
    +        IgniteCache cache0 = ignite0.createCache(cacheConfiguration("cache0"));
     
             for (int i = 0; i < 3_000; i++)
                 cache0.put(i, "Cache value " + i);
    @@ -70,13 +82,11 @@ public final void testPutRemoveMultinode() throws Exception {
             for (int i = 1_000; i < 4_000; i++)
                 cache0.remove(i);
     
    -        IgniteCache cache1 = ignite1.getOrCreateCache("cache1");
    +        IgniteCache cache1 = ignite1.createCache(cacheConfiguration("cache1"));
     
             for (int i = 0; i < 1_000; i++)
                 cache1.put(i, "Cache value " + i);
     
             forceCheckpoint();
    -
    -        stopAllGrids();
         }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAwareTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAwareTest.java
    index c1948c753e5bf..0bd9fcb853e40 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAwareTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/aware/SegmentAwareTest.java
    @@ -17,28 +17,33 @@
     package org.apache.ignite.internal.processors.cache.persistence.wal.aware;
     
     import java.util.concurrent.CountDownLatch;
    -import junit.framework.TestCase;
     import org.apache.ignite.IgniteCheckedException;
     import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
     import org.apache.ignite.internal.IgniteInternalFuture;
     import org.apache.ignite.internal.IgniteInterruptedCheckedException;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.junit.Test;
     
     import static org.hamcrest.CoreMatchers.is;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
     import static org.junit.Assert.assertThat;
    +import static org.junit.Assert.assertTrue;
    +import static org.junit.Assert.fail;
     
     /**
      * Test for {@link SegmentAware}.
      */
    -public class SegmentAwareTest extends TestCase {
    +public class SegmentAwareTest {
         /**
          * Checking to avoid deadlock SegmentArchivedStorage.markAsMovedToArchive -> SegmentLockStorage.locked <->
          * SegmentLockStorage.releaseWorkSegment -> SegmentArchivedStorage.onSegmentUnlocked
          *
          * @throws IgniteCheckedException if failed.
          */
    +    @Test
         public void testAvoidDeadlockArchiverAndLockStorage() throws IgniteCheckedException {
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             int iterationCnt = 100_000;
             int segmentToHandle = 1;
    @@ -73,9 +78,10 @@ public void testAvoidDeadlockArchiverAndLockStorage() throws IgniteCheckedExcept
         /**
          * Waiting finished when work segment is set.
          */
    +    @Test
         public void testFinishAwaitSegment_WhenExactWaitingSegmentWasSet() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             IgniteInternalFuture future = awaitThread(() -> aware.awaitSegment(5));
     
    @@ -89,9 +95,10 @@ public void testFinishAwaitSegment_WhenExactWaitingSegmentWasSet() throws Ignite
         /**
          * Waiting finished when work segment greater than expected is set.
          */
    +    @Test
         public void testFinishAwaitSegment_WhenGreaterThanWaitingSegmentWasSet() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             IgniteInternalFuture future = awaitThread(() -> aware.awaitSegment(5));
     
    @@ -105,9 +112,10 @@ public void testFinishAwaitSegment_WhenGreaterThanWaitingSegmentWasSet() throws
         /**
          * Waiting finished when work segment is set.
          */
    +    @Test
         public void testFinishAwaitSegment_WhenNextSegmentEqualToWaitingOne() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             IgniteInternalFuture future = awaitThread(() -> aware.awaitSegment(5));
     
    @@ -127,9 +135,10 @@ public void testFinishAwaitSegment_WhenNextSegmentEqualToWaitingOne() throws Ign
         /**
          * Waiting finished when interrupt was triggered.
          */
    +    @Test
         public void testFinishAwaitSegment_WhenInterruptWasCall() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             IgniteInternalFuture future = awaitThread(() -> aware.awaitSegment(5));
     
    @@ -143,9 +152,10 @@ public void testFinishAwaitSegment_WhenInterruptWasCall() throws IgniteCheckedEx
         /**
          * Waiting finished when next work segment triggered.
          */
    +    @Test
         public void testFinishWaitSegmentForArchive_WhenWorkSegmentIncremented() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             aware.curAbsWalIdx(5);
             aware.setLastArchivedAbsoluteIndex(4);
    @@ -162,9 +172,10 @@ public void testFinishWaitSegmentForArchive_WhenWorkSegmentIncremented() throws
         /**
          * Waiting finished when work segment is set.
          */
    +    @Test
         public void testFinishWaitSegmentForArchive_WhenWorkSegmentGreaterValue() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             aware.curAbsWalIdx(5);
             aware.setLastArchivedAbsoluteIndex(4);
    @@ -181,9 +192,10 @@ public void testFinishWaitSegmentForArchive_WhenWorkSegmentGreaterValue() throws
         /**
          * Waiting finished when interrupt was triggered.
          */
    +    @Test
         public void testFinishWaitSegmentForArchive_WhenInterruptWasCall() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             aware.curAbsWalIdx(5);
             aware.setLastArchivedAbsoluteIndex(4);
    @@ -200,9 +212,10 @@ public void testFinishWaitSegmentForArchive_WhenInterruptWasCall() throws Ignite
         /**
          * Should correct calculate next segment.
          */
    +    @Test
         public void testCorrectCalculateNextSegmentIndex() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             aware.curAbsWalIdx(5);
     
    @@ -216,9 +229,10 @@ public void testCorrectCalculateNextSegmentIndex() throws IgniteCheckedException
         /**
          * Waiting finished when segment archived.
          */
    +    @Test
         public void testFinishWaitNextAbsoluteIndex_WhenMarkAsArchivedFirstSegment() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(2);
    +        SegmentAware aware = new SegmentAware(2, false);
     
             aware.curAbsWalIdx(1);
             aware.setLastArchivedAbsoluteIndex(-1);
    @@ -235,9 +249,10 @@ public void testFinishWaitNextAbsoluteIndex_WhenMarkAsArchivedFirstSegment() thr
         /**
          * Waiting finished when segment archived.
          */
    +    @Test
         public void testFinishWaitNextAbsoluteIndex_WhenSetToArchivedFirst() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(2);
    +        SegmentAware aware = new SegmentAware(2, false);
     
             aware.curAbsWalIdx(1);
             aware.setLastArchivedAbsoluteIndex(-1);
    @@ -254,9 +269,10 @@ public void testFinishWaitNextAbsoluteIndex_WhenSetToArchivedFirst() throws Igni
         /**
          * Waiting finished when force interrupt was triggered.
          */
    +    @Test
         public void testFinishWaitNextAbsoluteIndex_WhenOnlyForceInterruptWasCall() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(2);
    +        SegmentAware aware = new SegmentAware(2, false);
     
             aware.curAbsWalIdx(2);
             aware.setLastArchivedAbsoluteIndex(-1);
    @@ -279,9 +295,10 @@ public void testFinishWaitNextAbsoluteIndex_WhenOnlyForceInterruptWasCall() thro
         /**
          * Waiting finished when segment archived.
          */
    +    @Test
         public void testFinishSegmentArchived_WhenSetExactWaitingSegment() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             IgniteInternalFuture future = awaitThread(() -> aware.awaitSegmentArchived(5));
     
    @@ -295,9 +312,10 @@ public void testFinishSegmentArchived_WhenSetExactWaitingSegment() throws Ignite
         /**
          * Waiting finished when segment archived.
          */
    -    public void testFinishSegmentArchived_WhenMarkExactWatingSegment() throws IgniteCheckedException, InterruptedException {
    +    @Test
    +    public void testFinishSegmentArchived_WhenMarkExactWaitingSegment() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             IgniteInternalFuture future = awaitThread(() -> aware.awaitSegmentArchived(5));
     
    @@ -311,9 +329,10 @@ public void testFinishSegmentArchived_WhenMarkExactWatingSegment() throws Ignite
         /**
          * Waiting finished when segment archived.
          */
    -    public void testFinishSegmentArchived_WhenSetGreaterThanWatingSegment() throws IgniteCheckedException, InterruptedException {
    +    @Test
    +    public void testFinishSegmentArchived_WhenSetGreaterThanWaitingSegment() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             IgniteInternalFuture future = awaitThread(() -> aware.awaitSegmentArchived(5));
     
    @@ -327,9 +346,10 @@ public void testFinishSegmentArchived_WhenSetGreaterThanWatingSegment() throws I
         /**
          * Waiting finished when segment archived.
          */
    -    public void testFinishSegmentArchived_WhenMarkGreaterThanWatingSegment() throws IgniteCheckedException, InterruptedException {
    +    @Test
    +    public void testFinishSegmentArchived_WhenMarkGreaterThanWaitingSegment() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             IgniteInternalFuture future = awaitThread(() -> aware.awaitSegmentArchived(5));
     
    @@ -343,9 +363,10 @@ public void testFinishSegmentArchived_WhenMarkGreaterThanWatingSegment() throws
         /**
          * Waiting finished when interrupt was triggered.
          */
    +    @Test
         public void testFinishSegmentArchived_WhenInterruptWasCall() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             aware.curAbsWalIdx(5);
             aware.setLastArchivedAbsoluteIndex(4);
    @@ -362,9 +383,10 @@ public void testFinishSegmentArchived_WhenInterruptWasCall() throws IgniteChecke
         /**
          * Waiting finished when release work segment.
          */
    +    @Test
         public void testMarkAsMovedToArchive_WhenReleaseLockedSegment() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             aware.checkCanReadArchiveOrReserveWorkSegment(5);
     
    @@ -380,9 +402,10 @@ public void testMarkAsMovedToArchive_WhenReleaseLockedSegment() throws IgniteChe
         /**
          * Waiting finished and increment archived segment when interrupt was call.
          */
    +    @Test
         public void testMarkAsMovedToArchive_WhenInterruptWasCall() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
             aware.checkCanReadArchiveOrReserveWorkSegment(5);
     
             IgniteInternalFuture future = awaitThread(() -> aware.markAsMovedToArchive(5));
    @@ -400,11 +423,12 @@ public void testMarkAsMovedToArchive_WhenInterruptWasCall() throws IgniteChecked
         /**
          * Waiting finished when segment archived.
          */
    +    @Test
         public void testFinishWaitSegmentToCompress_WhenSetLastArchivedSegment() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, true);
     
    -        aware.lastCompressedIdx(5);
    +        aware.onSegmentCompressed(5);
     
             IgniteInternalFuture future = awaitThread(aware::waitNextSegmentToCompress);
     
    @@ -418,11 +442,12 @@ public void testFinishWaitSegmentToCompress_WhenSetLastArchivedSegment() throws
         /**
          * Waiting finished when segment archived.
          */
    +    @Test
         public void testFinishWaitSegmentToCompress_WhenMarkLastArchivedSegment() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, true);
     
    -        aware.lastCompressedIdx(5);
    +        aware.onSegmentCompressed(5);
     
             IgniteInternalFuture future = awaitThread(aware::waitNextSegmentToCompress);
     
    @@ -436,28 +461,24 @@ public void testFinishWaitSegmentToCompress_WhenMarkLastArchivedSegment() throws
         /**
          * Next segment for compress based on truncated archive idx.
          */
    +    @Test
         public void testCorrectCalculateNextCompressSegment() throws IgniteCheckedException, InterruptedException {
    -        //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, true);
     
    -        aware.lastCompressedIdx(5);
             aware.setLastArchivedAbsoluteIndex(6);
    -        aware.lastTruncatedArchiveIdx(7);
    -
    -        //when:
    -        long segmentToCompress = aware.waitNextSegmentToCompress();
     
    -        //then: segment to compress greater than truncated archive idx
    -        assertEquals(8, segmentToCompress);
    +        for (int exp = 0; exp <= 6; exp++)
    +            assertEquals(exp, aware.waitNextSegmentToCompress());
         }
     
         /**
          * Waiting finished when interrupt was call.
          */
    +    @Test
         public void testFinishWaitSegmentToCompress_WhenInterruptWasCall() throws IgniteCheckedException, InterruptedException {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    -        aware.lastCompressedIdx(5);
    +        SegmentAware aware = new SegmentAware(10, true);
    +        aware.onSegmentCompressed(5);
     
             IgniteInternalFuture future = awaitThread(aware::waitNextSegmentToCompress);
     
    @@ -468,12 +489,37 @@ public void testFinishWaitSegmentToCompress_WhenInterruptWasCall() throws Ignite
             assertTrue(future.get(20) instanceof IgniteInterruptedCheckedException);
         }
     
    +    /**
    +     * Tests that {@link SegmentAware#onSegmentCompressed} returns segments in proper order.
    +     */
    +    @Test
    +    public void testLastCompressedIdxProperOrdering() throws IgniteInterruptedCheckedException {
    +        SegmentAware aware = new SegmentAware(10, true);
    +
    +        for (int i = 0; i < 5; i++) {
    +            aware.setLastArchivedAbsoluteIndex(i);
    +            aware.waitNextSegmentToCompress();
    +        }
    +
    +        aware.onSegmentCompressed(0);
    +
    +        aware.onSegmentCompressed(4);
    +        assertEquals(0, aware.lastCompressedIdx());
    +        aware.onSegmentCompressed(1);
    +        assertEquals(1, aware.lastCompressedIdx());
    +        aware.onSegmentCompressed(3);
    +        assertEquals(1, aware.lastCompressedIdx());
    +        aware.onSegmentCompressed(2);
    +        assertEquals(4, aware.lastCompressedIdx());
    +    }
    +
         /**
          * Segment reserve correctly.
          */
    +    @Test
         public void testReserveCorrectly() {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             //when: reserve one segment twice and one segment once.
             aware.reserve(5);
    @@ -514,9 +560,10 @@ public void testReserveCorrectly() {
         /**
          * Should fail when release unreserved segment.
          */
    +    @Test
         public void testAssertFail_WhenReleaseUnreservedSegment() {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             aware.reserve(5);
             try {
    @@ -533,9 +580,10 @@ public void testAssertFail_WhenReleaseUnreservedSegment() {
         /**
          * Segment locked correctly.
          */
    +    @Test
         public void testReserveWorkSegmentCorrectly() {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             //when: lock one segment twice.
             aware.checkCanReadArchiveOrReserveWorkSegment(5);
    @@ -566,9 +614,10 @@ public void testReserveWorkSegmentCorrectly() {
         /**
          * Should fail when release unlocked segment.
          */
    +    @Test
         public void testAssertFail_WhenReleaseUnreservedWorkSegment() {
             //given: thread which awaited segment.
    -        SegmentAware aware = new SegmentAware(10);
    +        SegmentAware aware = new SegmentAware(10, false);
     
             aware.checkCanReadArchiveOrReserveWorkSegment(5);
             try {
    @@ -636,4 +685,4 @@ interface Waiter {
              */
             void await() throws IgniteInterruptedCheckedException;
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTracker.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTracker.java
    index 09cacfbb2c5cc..6944e215fce45 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTracker.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTracker.java
    @@ -31,8 +31,6 @@
     import java.util.concurrent.locks.ReentrantLock;
     import org.apache.ignite.IgniteCheckedException;
     import org.apache.ignite.IgniteLogger;
    -import org.apache.ignite.configuration.WALMode;
    -import org.apache.ignite.spi.encryption.EncryptionSpi;
     import org.apache.ignite.internal.GridKernalContext;
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.mem.DirectMemoryProvider;
    @@ -47,29 +45,33 @@
     import org.apache.ignite.internal.pagemem.wal.WALPointer;
     import org.apache.ignite.internal.pagemem.wal.record.PageSnapshot;
     import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
    -import org.apache.ignite.internal.pagemem.wal.record.delta.InitNewPageRecord;
     import org.apache.ignite.internal.pagemem.wal.record.delta.PageDeltaRecord;
    -import org.apache.ignite.internal.pagemem.wal.record.delta.RecycleRecord;
     import org.apache.ignite.internal.processors.cache.CacheGroupContext;
     import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
     import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
    +import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils;
    +import org.apache.ignite.internal.processors.cache.mvcc.txlog.TxLog;
     import org.apache.ignite.internal.processors.cache.persistence.DataRegion;
     import org.apache.ignite.internal.processors.cache.persistence.DbCheckpointListener;
     import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
     import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
     import org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage;
    -import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx;
     import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl;
    +import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
     import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager;
    -import org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager;
    +import org.apache.ignite.internal.processors.cache.tree.AbstractDataLeafIO;
     import org.apache.ignite.internal.util.GridUnsafe;
     import org.apache.ignite.internal.util.typedef.internal.CU;
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.lang.IgnitePredicate;
     import org.apache.ignite.plugin.IgnitePlugin;
     import org.apache.ignite.plugin.PluginContext;
    +import org.apache.ignite.spi.encryption.EncryptionSpi;
     import org.mockito.Mockito;
     
    +import static org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.T_CACHE_ID_DATA_REF_MVCC_LEAF;
    +import static org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.T_DATA_REF_MVCC_LEAF;
    +
     /**
      * Page memory tracker.
      *
    @@ -150,40 +152,21 @@ public class PageMemoryTracker implements IgnitePlugin {
          */
         IgniteWriteAheadLogManager createWalManager() {
             if (isEnabled()) {
    -            if (ctx.igniteConfiguration().getDataStorageConfiguration().getWalMode() == WALMode.FSYNC) {
    -                return new FsyncModeFileWriteAheadLogManager(gridCtx) {
    -                    @Override public WALPointer log(WALRecord record) throws IgniteCheckedException {
    -                        WALPointer res = super.log(record);
    -
    -                        applyWalRecord(record);
    -
    -                        return res;
    -                    }
    -
    -                    @Override public void resumeLogging(WALPointer lastPtr) throws IgniteCheckedException {
    -                        super.resumeLogging(lastPtr);
    +            return new FileWriteAheadLogManager(gridCtx) {
    +                @Override public WALPointer log(WALRecord record) throws IgniteCheckedException {
    +                    WALPointer res = super.log(record);
     
    -                        emptyPds = (lastPtr == null);
    -                    }
    -                };
    -            }
    -            else {
    -                return new FileWriteAheadLogManager(gridCtx) {
    -                    @Override public WALPointer log(WALRecord record) throws IgniteCheckedException {
    -                        WALPointer res = super.log(record);
    -
    -                        applyWalRecord(record);
    +                    applyWalRecord(record);
     
    -                        return res;
    -                    }
    +                    return res;
    +                }
     
    -                    @Override public void resumeLogging(WALPointer lastPtr) throws IgniteCheckedException {
    -                        super.resumeLogging(lastPtr);
    +                @Override public void resumeLogging(WALPointer lastPtr) throws IgniteCheckedException {
    +                    super.resumeLogging(lastPtr);
     
    -                        emptyPds = (lastPtr == null);
    -                    }
    -                };
    -            }
    +                    emptyPds = (lastPtr == null);
    +                }
    +            };
             }
     
             return null;
    @@ -434,8 +417,6 @@ private void applyWalRecord(WALRecord record) throws IgniteCheckedException {
                 try {
                     PageUtils.putBytes(page.address(), 0, snapshot.pageData());
     
    -                page.fullPageId(fullPageId);
    -
                     page.changeHistory().clear();
     
                     page.changeHistory().add(record);
    @@ -459,12 +440,6 @@ else if (record instanceof PageDeltaRecord) {
                 try {
                     deltaRecord.applyDelta(pageMemoryMock, page.address());
     
    -                // Set new fullPageId after recycle or after new page init, because pageId tag is changed.
    -                if (record instanceof RecycleRecord)
    -                    page.fullPageId(new FullPageId(((RecycleRecord)record).newPageId(), grpId));
    -                else if (record instanceof InitNewPageRecord)
    -                    page.fullPageId(new FullPageId(((InitNewPageRecord)record).newPageId(), grpId));
    -
                     page.changeHistory().add(record);
                 }
                 finally {
    @@ -475,18 +450,7 @@ else if (record instanceof InitNewPageRecord)
                 return;
     
             // Increment statistics.
    -        AtomicInteger statCnt = stats.get(record.type());
    -
    -        if (statCnt == null) {
    -            statCnt = new AtomicInteger();
    -
    -            AtomicInteger oldCnt = stats.putIfAbsent(record.type(), statCnt);
    -
    -            if (oldCnt != null)
    -                statCnt = oldCnt;
    -        }
    -
    -        statCnt.incrementAndGet();
    +        stats.computeIfAbsent(record.type(), r -> new AtomicInteger()).incrementAndGet();
         }
     
         /**
    @@ -499,6 +463,9 @@ private long pageStoreAllocatedPages() {
     
             long totalAllocated = pageStoreMgr.pagesAllocated(MetaStorage.METASTORAGE_CACHE_ID);
     
    +        if (MvccUtils.mvccEnabled(gridCtx))
    +            totalAllocated += pageStoreMgr.pagesAllocated(TxLog.TX_LOG_CACHE_ID);
    +
             for (CacheGroupContext ctx : gridCtx.cache().cacheGroups())
                 totalAllocated += pageStoreMgr.pagesAllocated(ctx.groupId());
     
    @@ -522,15 +489,6 @@ public boolean checkPages(boolean checkAll) throws IgniteCheckedException {
             synchronized (pageAllocatorMux) {
                 long totalAllocated = pageStoreAllocatedPages();
     
    -            long metaId = ((PageMemoryEx)cacheProc.context().database().metaStorage().pageMemory()).metaPageId(
    -                MetaStorage.METASTORAGE_CACHE_ID);
    -
    -            // Meta storage meta page is counted as allocated, but never used in current implementation.
    -            // This behavior will be fixed by https://issues.apache.org/jira/browse/IGNITE-8735
    -            if (!pages.containsKey(new FullPageId(metaId, MetaStorage.METASTORAGE_CACHE_ID))
    -                && pages.containsKey(new FullPageId(metaId + 1, MetaStorage.METASTORAGE_CACHE_ID)))
    -                totalAllocated--;
    -
                 log.info(">>> Total tracked pages: " + pages.size());
                 log.info(">>> Total allocated pages: " + totalAllocated);
     
    @@ -555,6 +513,8 @@ public boolean checkPages(boolean checkAll) throws IgniteCheckedException {
     
                 if (fullPageId.groupId() == MetaStorage.METASTORAGE_CACHE_ID)
                     pageMem = cacheProc.context().database().metaStorage().pageMemory();
    +            else if (fullPageId.groupId() == TxLog.TX_LOG_CACHE_ID)
    +                pageMem = cacheProc.context().database().dataRegion(TxLog.TX_LOG_CACHE_NAME).pageMemory();
                 else {
                     CacheGroupContext ctx = cacheProc.cacheGroup(fullPageId.groupId());
     
    @@ -576,7 +536,7 @@ public boolean checkPages(boolean checkAll) throws IgniteCheckedException {
                 long rmtPage = pageMem.acquirePage(fullPageId.groupId(), fullPageId.pageId());
     
                 try {
    -                long rmtPageAddr = pageMem.readLock(fullPageId.groupId(), fullPageId.pageId(), rmtPage);
    +                long rmtPageAddr = pageMem.readLockForce(fullPageId.groupId(), fullPageId.pageId(), rmtPage);
     
                     try {
                         page.lock();
    @@ -589,20 +549,8 @@ public boolean checkPages(boolean checkAll) throws IgniteCheckedException {
     
                                 dumpHistory(page);
                             }
    -                        else {
    -                            ByteBuffer locBuf = GridUnsafe.wrapPointer(page.address(), pageSize);
    -                            ByteBuffer rmtBuf = GridUnsafe.wrapPointer(rmtPageAddr, pageSize);
    -
    -                            if (!locBuf.equals(rmtBuf)) {
    -                                res = false;
    -
    -                                log.error("Page buffers are not equals: " + fullPageId);
    -
    -                                dumpDiff(locBuf, rmtBuf);
    -
    -                                dumpHistory(page);
    -                            }
    -                        }
    +                        else if (!comparePages(fullPageId, page, rmtPageAddr))
    +                            res = false;
     
                             if (!res && !checkAll)
                                 return false;
    @@ -624,6 +572,52 @@ public boolean checkPages(boolean checkAll) throws IgniteCheckedException {
             return res;
         }
     
    +    /**
    +     * Compare pages content.
    +     *
    +     * @param fullPageId Full page ID.
    +     * @param expectedPage Expected page.
    +     * @param actualPageAddr Actual page address.
    +     * @return {@code True} if pages are equals, {@code False} otherwise.
    +     * @throws IgniteCheckedException If fails.
    +     */
    +    private boolean comparePages(FullPageId fullPageId, DirectMemoryPage expectedPage, long actualPageAddr) throws IgniteCheckedException {
    +        long expPageArrd = expectedPage.address();
    +
    +        GridCacheProcessor cacheProc = gridCtx.cache();
    +
    +        ByteBuffer locBuf = GridUnsafe.wrapPointer(expPageArrd, pageSize);
    +        ByteBuffer rmtBuf = GridUnsafe.wrapPointer(actualPageAddr, pageSize);
    +
    +        PageIO pageIo = PageIO.getPageIO(actualPageAddr);
    +
    +        if (pageIo.getType() == T_DATA_REF_MVCC_LEAF || pageIo.getType() == T_CACHE_ID_DATA_REF_MVCC_LEAF) {
    +            assert cacheProc.cacheGroup(fullPageId.groupId()).mvccEnabled();
    +
    +            AbstractDataLeafIO io = (AbstractDataLeafIO)pageIo;
    +
    +            int cnt = io.getCount(actualPageAddr);
    +
    +            // Reset lock info as there is no sense to log it into WAL.
    +            for (int i = 0; i < cnt; i++) {
    +                io.setMvccLockCoordinatorVersion(expPageArrd, i, io.getMvccLockCoordinatorVersion(actualPageAddr, i));
    +                io.setMvccLockCounter(expPageArrd, i, io.getMvccLockCounter(actualPageAddr, i));
    +            }
    +        }
    +
    +        if (!locBuf.equals(rmtBuf)) {
    +            log.error("Page buffers are not equals: " + fullPageId);
    +
    +            dumpDiff(locBuf, rmtBuf);
    +
    +            dumpHistory(expectedPage);
    +
    +            return false;
    +        }
    +
    +        return true;
    +    }
    +
         /**
          * Dump statistics to log.
          */
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTrackerPluginProvider.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTrackerPluginProvider.java
    index c5f83b5ef68dd..cad3b0269dd75 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTrackerPluginProvider.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTrackerPluginProvider.java
    @@ -20,12 +20,16 @@
     import java.io.Serializable;
     import java.util.UUID;
     import org.apache.ignite.Ignite;
    +import org.apache.ignite.IgniteCheckedException;
     import org.apache.ignite.IgniteLogger;
     import org.apache.ignite.cluster.ClusterNode;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.GridKernalContext;
    +import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager;
     import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager;
    +import org.apache.ignite.internal.processors.cache.persistence.DatabaseLifecycleListener;
    +import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
     import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
     import org.apache.ignite.internal.util.typedef.internal.CU;
     import org.apache.ignite.plugin.CachePluginContext;
    @@ -43,7 +47,7 @@
      * PageMemory tracker plugin provider.
      */
     public class PageMemoryTrackerPluginProvider implements PluginProvider,
    -    IgniteChangeGlobalStateSupport {
    +    IgniteChangeGlobalStateSupport, DatabaseLifecycleListener {
         /** System property name to implicitly enable page memory tracker . */
         public static final String IGNITE_ENABLE_PAGE_MEMORY_TRACKER = "IGNITE_ENABLE_PAGE_MEMORY_TRACKER";
     
    @@ -132,7 +136,7 @@ else if (IgnitePageStoreManager.class.equals(cls))
     
         /** {@inheritDoc} */
         @Override public void start(PluginContext ctx) {
    -        // No-op
    +        ((IgniteEx)ctx.grid()).context().internalSubscriptionProcessor().registerDatabaseListener(this);
         }
     
         /** {@inheritDoc} */
    @@ -197,4 +201,15 @@ public static PageMemoryTracker tracker(Ignite ignite) {
                 return null;
             }
         }
    +
    +    @Override public void beforeBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException {
    +        if (plugin != null) {
    +            try {
    +                plugin.start();
    +            }
    +            catch (Exception e) {
    +                log.error("Can't start plugin", e);
    +            }
    +        }
    +    }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java
    index cf660c8b86832..89ab63a1b9308 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java
    @@ -21,6 +21,8 @@
     import java.io.IOException;
     import java.nio.file.OpenOption;
     import java.nio.file.StandardOpenOption;
    +import java.util.List;
    +import java.util.Random;
     import java.util.concurrent.atomic.AtomicInteger;
     import org.apache.ignite.Ignite;
     import org.apache.ignite.IgniteCheckedException;
    @@ -30,27 +32,32 @@
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager;
     import org.apache.ignite.internal.pagemem.wal.WALIterator;
    +import org.apache.ignite.internal.pagemem.wal.WALPointer;
    +import org.apache.ignite.internal.pagemem.wal.record.RolloverType;
     import org.apache.ignite.internal.pagemem.wal.record.SnapshotRecord;
    +import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
     import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
     import org.apache.ignite.internal.processors.cache.persistence.file.FileIO;
     import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIO;
     import org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory;
    +import org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor;
    +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer;
     import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
    +import org.apache.ignite.lang.IgniteBiTuple;
    +import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory.IteratorParametersBuilder;
     
     /**
      * The test check, that StandaloneWalRecordsIterator correctly close file descriptors associated with WAL files.
      */
    +@RunWith(JUnit4.class)
     public class StandaloneWalRecordsIteratorTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String name) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(name);
    @@ -61,9 +68,6 @@ public class StandaloneWalRecordsIteratorTest extends GridCommonAbstractTest {
                         new DataRegionConfiguration()
                             .setPersistenceEnabled(true)
                     )
    -        ).setDiscoverySpi(
    -            new TcpDiscoverySpi()
    -                .setIpFinder(IP_FINDER)
             );
     
             return cfg;
    @@ -88,11 +92,9 @@ public class StandaloneWalRecordsIteratorTest extends GridCommonAbstractTest {
         }
     
         /**
    -     * Check correct closing file descriptors.
          *
    -     * @throws Exception if test failed.
          */
    -    public void testCorrectClosingFileDescriptors() throws Exception {
    +    private String createWalFiles() throws Exception {
             IgniteEx ig = (IgniteEx)startGrid();
     
             String archiveWalDir = getArchiveWalDirPath(ig);
    @@ -108,7 +110,7 @@ public void testCorrectClosingFileDescriptors() throws Exception {
                 sharedMgr.checkpointReadLock();
     
                 try {
    -                walMgr.log(new SnapshotRecord(i, false));
    +                walMgr.log(new SnapshotRecord(i, false), RolloverType.NEXT_SEGMENT);
                 }
                 finally {
                     sharedMgr.checkpointReadUnlock();
    @@ -117,8 +119,19 @@ public void testCorrectClosingFileDescriptors() throws Exception {
     
             stopGrid();
     
    +        return archiveWalDir;
    +    }
    +
    +    /**
    +     * Check correct closing file descriptors.
    +     *
    +     * @throws Exception if test failed.
    +     */
    +    @Test
    +    public void testCorrectClosingFileDescriptors() throws Exception {
    +
             // Iterate by all archived WAL segments.
    -        createWalIterator(archiveWalDir).forEach(x -> {
    +        createWalIterator(createWalFiles()).forEach(x -> {
             });
     
             assertTrue("At least one WAL file must be opened!", CountedFileIO.getCountOpenedWalFiles() > 0);
    @@ -126,6 +139,63 @@ public void testCorrectClosingFileDescriptors() throws Exception {
             assertTrue("All WAL files must be closed at least ones!", CountedFileIO.getCountOpenedWalFiles() <= CountedFileIO.getCountClosedWalFiles());
         }
     
    +    /**
    +     * Check correct check bounds.
    +     *
    +     * @throws Exception if test failed.
    +     */
    +    @Test
    +    public void testStrictBounds() throws Exception {
    +        String dir = createWalFiles();
    +
    +        FileWALPointer lowBound = null, highBound = null;
    +
    +        for (IgniteBiTuple p : createWalIterator(dir, null, null, false)) {
    +            if (lowBound == null)
    +                lowBound = (FileWALPointer) p.get1();
    +
    +            highBound = (FileWALPointer) p.get1();
    +        }
    +
    +        assertNotNull(lowBound);
    +
    +        assertNotNull(highBound);
    +
    +        createWalIterator(dir, lowBound, highBound, true);
    +
    +        final FileWALPointer lBound = lowBound;
    +        final FileWALPointer hBound = highBound;
    +
    +        //noinspection ThrowableNotThrown
    +        GridTestUtils.assertThrows(log, () -> {
    +            createWalIterator(dir, new FileWALPointer(lBound.index() - 1, 0, 0), hBound, true);
    +
    +            return 0;
    +        } , IgniteCheckedException.class, null);
    +
    +        //noinspection ThrowableNotThrown
    +        GridTestUtils.assertThrows(log, () -> {
    +            createWalIterator(dir, lBound, new FileWALPointer(hBound.index() + 1, 0, 0), true);
    +
    +            return 0;
    +        }, IgniteCheckedException.class, null);
    +
    +        List walFiles = listWalFiles(dir);
    +
    +        assertNotNull(walFiles);
    +
    +        assertTrue(!walFiles.isEmpty());
    +
    +        assertTrue(walFiles.get(new Random().nextInt(walFiles.size())).file().delete());
    +
    +        //noinspection ThrowableNotThrown
    +        GridTestUtils.assertThrows(log, () -> {
    +            createWalIterator(dir, lBound, hBound, true);
    +
    +            return 0;
    +        }, IgniteCheckedException.class, null);
    +    }
    +
         /**
          * Creates WALIterator associated with files inside walDir.
          *
    @@ -141,6 +211,41 @@ private WALIterator createWalIterator(String walDir) throws IgniteCheckedExcepti
             return new IgniteWalIteratorFactory(log).iterator(params.filesOrDirs(walDir));
         }
     
    +
    +    /**
    +     * @param walDir Wal directory.
    +     */
    +    private List listWalFiles(String walDir) throws IgniteCheckedException {
    +        IteratorParametersBuilder params = new IteratorParametersBuilder();
    +
    +        params.ioFactory(new RandomAccessFileIOFactory());
    +
    +        return new IgniteWalIteratorFactory(log).resolveWalFiles(params.filesOrDirs(walDir));
    +    }
    +
    +    /**
    +     * @param walDir Wal directory.
    +     * @param lowBound Low bound.
    +     * @param highBound High bound.
    +     * @param strictCheck Strict check.
    +     */
    +    private WALIterator createWalIterator(String walDir, FileWALPointer lowBound, FileWALPointer highBound, boolean strictCheck)
    +                    throws IgniteCheckedException {
    +        IteratorParametersBuilder params = new IteratorParametersBuilder();
    +
    +        params.ioFactory(new RandomAccessFileIOFactory()).
    +            filesOrDirs(walDir).
    +            strictBoundsCheck(strictCheck);
    +
    +        if (lowBound != null)
    +            params.from(lowBound);
    +
    +        if (lowBound != null)
    +            params.to(highBound);
    +
    +        return new IgniteWalIteratorFactory(log).iterator(params);
    +    }
    +
         /**
          * Evaluate path to directory with WAL archive.
          *
    @@ -160,11 +265,6 @@ private String getArchiveWalDirPath(Ignite ignite) throws IgniteCheckedException
          *
          */
         private static class CountedFileIOFactory extends RandomAccessFileIOFactory {
    -        /** {@inheritDoc} */
    -        @Override public FileIO create(File file) throws IOException {
    -            return create(file, StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE);
    -        }
    -
             /** {@inheritDoc} */
             @Override public FileIO create(File file, OpenOption... modes) throws IOException {
                 return new CountedFileIO(file, modes);
    @@ -213,4 +313,4 @@ public CountedFileIO(File file, OpenOption... modes) throws IOException {
              */
             public static int getCountClosedWalFiles() { return WAL_CLOSE_COUNTER.get(); }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/CacheScanQueryFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/CacheScanQueryFailoverTest.java
    index 0633138f0c245..f5f13e4c161fe 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/CacheScanQueryFailoverTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/CacheScanQueryFailoverTest.java
    @@ -32,6 +32,9 @@
     import org.apache.ignite.lang.IgniteClosure;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheMode.LOCAL;
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
    @@ -39,6 +42,7 @@
     /**
      * ScanQuery failover test. Tests scenario where user supplied closures throw unhandled errors.
      */
    +@RunWith(JUnit4.class)
     public class CacheScanQueryFailoverTest extends GridCommonAbstractTest {
         /** */
         private static final String LOCAL_CACHE_NAME = "local";
    @@ -85,6 +89,7 @@ public class CacheScanQueryFailoverTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testScanQueryWithFailedClosures() throws Exception {
             Ignite srv = startGrids(4);
             Ignite client = startGrid("client");
    @@ -103,6 +108,7 @@ public void testScanQueryWithFailedClosures() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testScanQueryOverLocalCacheWithFailedClosures() throws Exception {
             Ignite srv = startGrids(4);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
    index 53acd22acecf1..54916bf4c29e1 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
    @@ -40,24 +40,21 @@
     import org.apache.ignite.lang.IgniteCallable;
     import org.apache.ignite.lang.IgniteClosure;
     import org.apache.ignite.resources.IgniteInstanceResource;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Test for scan query with transformer.
      */
    +@RunWith(JUnit4.class)
     public class GridCacheQueryTransformerSelfTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
             cfg.setMarshaller(null);
     
             return cfg;
    @@ -80,6 +77,7 @@ public class GridCacheQueryTransformerSelfTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testGetKeys() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -111,6 +109,7 @@ public void testGetKeys() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testGetKeysFiltered() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -148,6 +147,7 @@ public void testGetKeysFiltered() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testGetObjectField() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -179,6 +179,7 @@ public void testGetObjectField() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testGetObjectFieldPartitioned() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -219,6 +220,7 @@ public void testGetObjectFieldPartitioned() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testGetObjectFieldFiltered() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -256,6 +258,7 @@ public void testGetObjectFieldFiltered() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testKeepBinary() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -289,6 +292,7 @@ public void testKeepBinary() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testKeepBinaryFiltered() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -328,6 +332,7 @@ public void testKeepBinaryFiltered() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocal() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -369,6 +374,7 @@ public void testLocal() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalFiltered() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -416,6 +422,7 @@ public void testLocalFiltered() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalKeepBinary() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -457,6 +464,7 @@ public void testLocalKeepBinary() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalKeepBinaryFiltered() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -504,6 +512,7 @@ public void testLocalKeepBinaryFiltered() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testUnsupported() throws Exception {
             final IgniteCache cache = grid().createCache("test-cache");
     
    @@ -592,6 +601,7 @@ public void testUnsupported() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPageSize() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    @@ -629,6 +639,7 @@ public void testPageSize() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalInjection() throws Exception {
             IgniteCache cache = grid().createCache("test-cache");
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCircularQueueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCircularQueueTest.java
    index a07bd64d80581..e7449be7d17b7 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCircularQueueTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCircularQueueTest.java
    @@ -20,13 +20,18 @@
     import java.util.ArrayDeque;
     import org.apache.ignite.internal.util.GridRandom;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      */
    +@RunWith(JUnit4.class)
     public class GridCircularQueueTest extends GridCommonAbstractTest {
         /**
          *
          */
    +    @Test
         public void testQueue() {
             GridCacheQueryManager.CircularQueue q = new GridCacheQueryManager.CircularQueue<>(4);
     
    @@ -115,4 +120,4 @@ private void check(GridCacheQueryManager.CircularQueue q, ArrayDeque d) {
             for (Object o : d)
                 assertEquals(q.get(i++), o);
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IgniteCacheQueryCacheDestroySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IgniteCacheQueryCacheDestroySelfTest.java
    index d0d392b50b604..d97ad29f80fc0 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IgniteCacheQueryCacheDestroySelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IgniteCacheQueryCacheDestroySelfTest.java
    @@ -37,10 +37,14 @@
     import org.apache.ignite.lang.IgniteBiPredicate;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * The test for the destruction of the cache during the execution of the query
      */
    +@RunWith(JUnit4.class)
     public class IgniteCacheQueryCacheDestroySelfTest extends GridCommonAbstractTest {
         /** */
         private static final String CACHE_NAME = "cache";
    @@ -55,6 +59,7 @@ public class IgniteCacheQueryCacheDestroySelfTest extends GridCommonAbstractTest
         /**
          * The main test code.
          */
    +    @Test
         public void testQueue() throws Throwable {
             startGridsMultiThreaded(GRID_CNT);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
    index 5f2e2edaccaf0..33dd0c5c6f8d9 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
    @@ -26,12 +26,10 @@
     import java.util.TreeMap;
     import java.util.concurrent.Callable;
     import javax.cache.Cache;
    -import junit.framework.TestCase;
     import org.apache.ignite.Ignite;
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.IgniteSystemProperties;
     import org.apache.ignite.IgniteTransactions;
    -import org.apache.ignite.Ignition;
     import org.apache.ignite.binary.BinaryObject;
     import org.apache.ignite.cache.CacheAtomicityMode;
     import org.apache.ignite.cache.query.QueryCursor;
    @@ -42,41 +40,32 @@
     import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
     import org.apache.ignite.spi.IgniteSpiAdapter;
     import org.apache.ignite.spi.IgniteSpiException;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.spi.indexing.IndexingQueryFilter;
     import org.apache.ignite.spi.indexing.IndexingSpi;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
     import org.apache.ignite.transactions.TransactionState;
     import org.jetbrains.annotations.NotNull;
     import org.jetbrains.annotations.Nullable;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Indexing Spi query only test
      */
    -public class IndexingSpiQuerySelfTest extends TestCase {
    -    public static final String CACHE_NAME = "test-cache";
    +@RunWith(JUnit4.class)
    +public class IndexingSpiQuerySelfTest extends GridCommonAbstractTest {
    +    private IndexingSpi indexingSpi;
     
         /** {@inheritDoc} */
    -    @Override public void tearDown() throws Exception {
    -        Ignition.stopAll(true);
    -    }
    -
    -    /**
    -     * @return Configuration.
    -     */
    -    protected IgniteConfiguration configuration() {
    -        IgniteConfiguration cfg = new IgniteConfiguration();
    +    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    +        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(ipFinder);
    -
    -        cfg.setDiscoverySpi(disco);
    +        cfg.setIndexingSpi(indexingSpi);
     
             return cfg;
         }
    @@ -86,17 +75,23 @@ protected  CacheConfiguration cacheConfiguration(String cacheName) {
             return new CacheConfiguration<>(cacheName);
         }
     
    +    /** {@inheritDoc} */
    +    @Override protected void afterTest() throws Exception {
    +        super.afterTest();
    +
    +        stopAllGrids();
    +    }
    +
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testSimpleIndexingSpi() throws Exception {
    -        IgniteConfiguration cfg = configuration();
    -
    -        cfg.setIndexingSpi(new MyIndexingSpi());
    +        indexingSpi = new MyIndexingSpi();
     
    -        Ignite ignite = Ignition.start(cfg);
    +        Ignite ignite = startGrid(0);
     
    -        CacheConfiguration ccfg = cacheConfiguration(CACHE_NAME);
    +        CacheConfiguration ccfg = cacheConfiguration(DEFAULT_CACHE_NAME);
     
             IgniteCache cache = ignite.createCache(ccfg);
     
    @@ -112,14 +107,13 @@ public void testSimpleIndexingSpi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testIndexingSpiWithDisabledQueryProcessor() throws Exception {
    -        IgniteConfiguration cfg = configuration();
    +        indexingSpi = new MyIndexingSpi();
     
    -        cfg.setIndexingSpi(new MyIndexingSpi());
    +        Ignite ignite = startGrid(0);
     
    -        Ignite ignite = Ignition.start(cfg);
    -
    -        CacheConfiguration ccfg = cacheConfiguration(CACHE_NAME);
    +        CacheConfiguration ccfg = cacheConfiguration(DEFAULT_CACHE_NAME);
     
             IgniteCache cache = ignite.createCache(ccfg);
     
    @@ -135,14 +129,13 @@ public void testIndexingSpiWithDisabledQueryProcessor() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBinaryIndexingSpi() throws Exception {
    -        IgniteConfiguration cfg = configuration();
    -
    -        cfg.setIndexingSpi(new MyBinaryIndexingSpi());
    +        indexingSpi = new MyBinaryIndexingSpi();
     
    -        Ignite ignite = Ignition.start(cfg);
    +        Ignite ignite = startGrid(0);
     
    -        CacheConfiguration ccfg = cacheConfiguration(CACHE_NAME);
    +        CacheConfiguration ccfg = cacheConfiguration(DEFAULT_CACHE_NAME);
     
             IgniteCache cache = ignite.createCache(ccfg);
     
    @@ -165,46 +158,48 @@ public void testBinaryIndexingSpi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonBinaryIndexingSpi() throws Exception {
             System.setProperty(IgniteSystemProperties.IGNITE_UNWRAP_BINARY_FOR_INDEXING_SPI, "true");
     
    -        IgniteConfiguration cfg = configuration();
    -
    -        cfg.setIndexingSpi(new MyIndexingSpi());
    +        try {
    +            indexingSpi = new MyIndexingSpi();
     
    -        Ignite ignite = Ignition.start(cfg);
    +            Ignite ignite = startGrid(0);
     
    -        CacheConfiguration ccfg = cacheConfiguration(CACHE_NAME);
    +            CacheConfiguration ccfg = cacheConfiguration(DEFAULT_CACHE_NAME);
     
    -        IgniteCache cache = ignite.createCache(ccfg);
    +            IgniteCache cache = ignite.createCache(ccfg);
     
    -        for (int i = 0; i < 10; i++) {
    -            PersonKey key = new PersonKey(i);
    +            for (int i = 0; i < 10; i++) {
    +                PersonKey key = new PersonKey(i);
     
    -            cache.put(key, new Person("John Doe " + i));
    -        }
    +                cache.put(key, new Person("John Doe " + i));
    +            }
     
    -        QueryCursor> cursor = cache.query(
    -            new SpiQuery().setArgs(new PersonKey(2), new PersonKey(5)));
    +            QueryCursor> cursor = cache.query(
    +                new SpiQuery().setArgs(new PersonKey(2), new PersonKey(5)));
     
    -        for (Cache.Entry entry : cursor)
    -            System.out.println(entry);
    +            for (Cache.Entry entry : cursor)
    +                System.out.println(entry);
     
    -        cache.remove(new PersonKey(9));
    +            cache.remove(new PersonKey(9));
    +        }
    +        finally {
    +            System.clearProperty(IgniteSystemProperties.IGNITE_UNWRAP_BINARY_FOR_INDEXING_SPI);
    +        }
         }
     
         /**
          * @throws Exception If failed.
          */
    -    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
    +    @Test
         public void testIndexingSpiFailure() throws Exception {
    -        IgniteConfiguration cfg = configuration();
    -
    -        cfg.setIndexingSpi(new MyBrokenIndexingSpi());
    +        indexingSpi = new MyBrokenIndexingSpi();
     
    -        Ignite ignite = Ignition.start(cfg);
    +        Ignite ignite = startGrid(0);
     
    -        CacheConfiguration ccfg = cacheConfiguration(CACHE_NAME);
    +        CacheConfiguration ccfg = cacheConfiguration(DEFAULT_CACHE_NAME);
     
             ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
     
    @@ -369,4 +364,4 @@ static class Person implements Serializable {
                 this.name = name;
             }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
    index e59deed2eb767..1cf3e90f7a48a 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryTxSelfTest.java
    @@ -17,6 +17,11 @@
     
     package org.apache.ignite.internal.processors.cache.query;
     
    +import java.util.Collection;
    +import java.util.Iterator;
    +import java.util.concurrent.Callable;
    +import java.util.concurrent.atomic.AtomicInteger;
    +import javax.cache.Cache;
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.IgniteTransactions;
     import org.apache.ignite.cache.CacheAtomicityMode;
    @@ -36,62 +41,72 @@
     import org.apache.ignite.transactions.TransactionIsolation;
     import org.apache.ignite.transactions.TransactionState;
     import org.jetbrains.annotations.Nullable;
    -
    -import java.util.Collection;
    -import java.util.Iterator;
    -import java.util.concurrent.Callable;
    -import java.util.concurrent.atomic.AtomicInteger;
    -import javax.cache.Cache;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Indexing Spi transactional query test
      */
    +@RunWith(JUnit4.class)
     public class IndexingSpiQueryTxSelfTest extends GridCacheAbstractSelfTest {
    -    /** */
    -    private static AtomicInteger cnt;
    -
         /** {@inheritDoc} */
         @Override protected int gridCount() {
             return 4;
         }
     
    -    /** {@inheritDoc} */
    -    @Override protected void beforeTestsStarted() throws Exception {
    -        cnt = new AtomicInteger();
    -
    -        super.beforeTestsStarted();
    -    }
    -
         /** {@inheritDoc} */
         @SuppressWarnings("unchecked")
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
             ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
     
    -        if (cnt.getAndIncrement() == 0)
    -            cfg.setClientMode(true);
    -        else {
    -            cfg.setIndexingSpi(new MyBrokenIndexingSpi());
    +        cfg.setClientMode("client".equals(igniteInstanceName));
    +        cfg.setIndexingSpi(new MyBrokenIndexingSpi());
     
    -            CacheConfiguration ccfg = cacheConfiguration(igniteInstanceName);
    -            ccfg.setName("test-cache");
    -            ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    +        CacheConfiguration ccfg = cacheConfiguration(igniteInstanceName);
    +        ccfg.setName(DEFAULT_CACHE_NAME);
    +        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
     
    -            ccfg.setIndexedTypes(Integer.class, Integer.class);
    +        ccfg.setIndexedTypes(Integer.class, Integer.class);
    +
    +        cfg.setCacheConfiguration(ccfg);
     
    -            cfg.setCacheConfiguration(ccfg);
    -        }
             return cfg;
         }
     
    +    /** */
    +    @Test
    +    public void testIndexingSpiWithTxClient() throws Exception {
    +        IgniteEx client = startGrid("client");
    +
    +        assertNotNull(client.cache(DEFAULT_CACHE_NAME));
    +
    +        doTestIndexingSpiWithTx(client, 0);
    +    }
    +
    +    /** */
    +    @Test
    +    public void testIndexingSpiWithTxLocal() throws Exception {
    +        IgniteEx ignite = (IgniteEx)primaryNode(0, DEFAULT_CACHE_NAME);
    +
    +        doTestIndexingSpiWithTx(ignite, 0);
    +    }
    +
    +    /** */
    +    @Test
    +    public void testIndexingSpiWithTxNotLocal() throws Exception {
    +        IgniteEx ignite = (IgniteEx)primaryNode(0, DEFAULT_CACHE_NAME);
    +
    +        doTestIndexingSpiWithTx(ignite, 1);
    +    }
    +
         /**
          * @throws Exception If failed.
          */
         @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
    -    public void testIndexingSpiWithTx() throws Exception {
    -        IgniteEx ignite = grid(0);
    -
    -        final IgniteCache cache = ignite.cache("test-cache");
    +    private void doTestIndexingSpiWithTx(IgniteEx ignite, int key) throws Exception {
    +        final IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME);
     
             final IgniteTransactions txs = ignite.transactions();
     
    @@ -104,7 +119,7 @@ public void testIndexingSpiWithTx() throws Exception {
                             Transaction tx;
     
                             try (Transaction tx0 = tx = txs.txStart(concurrency, isolation)) {
    -                            cache.put(1, 1);
    +                            cache.put(key, key);
     
                                 tx0.commit();
                             }
    @@ -114,6 +129,8 @@ public void testIndexingSpiWithTx() throws Exception {
                             return null;
                         }
                     }, IgniteTxHeuristicCheckedException.class);
    +
    +                checkFutures();
                 }
             }
         }
    @@ -135,7 +152,7 @@ private static class MyBrokenIndexingSpi extends IgniteSpiAdapter implements Ind
             /** {@inheritDoc} */
             @Override public Iterator> query(@Nullable String cacheName, Collection params,
                 @Nullable IndexingQueryFilter filters) throws IgniteSpiException {
    -           return null;
    +            return null;
             }
     
             /** {@inheritDoc} */
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/ScanQueryOffheapExpiryPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/ScanQueryOffheapExpiryPolicySelfTest.java
    index a3b1d4169dbea..83d82966e0aaf 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/ScanQueryOffheapExpiryPolicySelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/ScanQueryOffheapExpiryPolicySelfTest.java
    @@ -29,6 +29,9 @@
     import javax.cache.expiry.CreatedExpiryPolicy;
     import javax.cache.expiry.Duration;
     import java.util.concurrent.TimeUnit;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CachePeekMode.OFFHEAP;
     import static org.apache.ignite.cache.CachePeekMode.ONHEAP;
    @@ -36,6 +39,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class ScanQueryOffheapExpiryPolicySelfTest extends GridCommonAbstractTest {
     
         /** Nodes count. */
    @@ -74,6 +78,7 @@ public class ScanQueryOffheapExpiryPolicySelfTest extends GridCommonAbstractTest
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testEntriesMovedFromOnHeap() throws Exception {
             Ignite ignite0 = grid(0);
             Ignite ignite1 = grid(1);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousBatchAckTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousBatchAckTest.java
    index 400ae283155da..78b621ed6966a 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousBatchAckTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousBatchAckTest.java
    @@ -36,11 +36,11 @@
     import org.apache.ignite.lang.IgniteRunnable;
     import org.apache.ignite.plugin.extensions.communication.Message;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    @@ -53,10 +53,8 @@
     /**
      * Continuous queries tests.
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousBatchAckTest extends GridCommonAbstractTest implements Serializable {
    -    /** IP finder. */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         protected static final String CLIENT = "_client";
     
    @@ -87,12 +85,6 @@ else if (igniteInstanceName.endsWith(SERVER2))
             else
                 cfg.setCommunicationSpi(new FailedTcpCommunicationSpi(false, false));
     
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(disco);
    -
             return cfg;
         }
     
    @@ -118,6 +110,7 @@ else if (igniteInstanceName.endsWith(SERVER2))
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartition() throws Exception {
             checkBackupAcknowledgeMessage(cacheConfiguration(PARTITIONED, 1, ATOMIC, false));
         }
    @@ -125,6 +118,7 @@ public void testPartition() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionWithFilter() throws Exception {
             filterOn.set(true);
     
    @@ -134,6 +128,7 @@ public void testPartitionWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionNoBackups() throws Exception {
             checkBackupAcknowledgeMessage(cacheConfiguration(PARTITIONED, 0, ATOMIC, false));
         }
    @@ -141,6 +136,7 @@ public void testPartitionNoBackups() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionTx() throws Exception {
             checkBackupAcknowledgeMessage(cacheConfiguration(PARTITIONED, 1, TRANSACTIONAL, false));
         }
    @@ -148,6 +144,7 @@ public void testPartitionTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionTxWithFilter() throws Exception {
             filterOn.set(true);
     
    @@ -157,6 +154,7 @@ public void testPartitionTxWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionTxNoBackup() throws Exception {
             checkBackupAcknowledgeMessage(cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL, false));
         }
    @@ -164,6 +162,7 @@ public void testPartitionTxNoBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionTxNoBackupWithFilter() throws Exception {
             filterOn.set(true);
     
    @@ -173,6 +172,7 @@ public void testPartitionTxNoBackupWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicated() throws Exception {
             checkBackupAcknowledgeMessage(cacheConfiguration(REPLICATED, 1, ATOMIC, false));
         }
    @@ -180,6 +180,7 @@ public void testReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedTx() throws Exception {
             checkBackupAcknowledgeMessage(cacheConfiguration(REPLICATED, 1, TRANSACTIONAL, false));
         }
    @@ -187,6 +188,7 @@ public void testReplicatedTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedTxWithFilter() throws Exception {
             filterOn.set(true);
     
    @@ -198,6 +200,7 @@ public void testReplicatedTxWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionMvccTx() throws Exception {
             checkBackupAcknowledgeMessage(cacheConfiguration(PARTITIONED, 1, TRANSACTIONAL_SNAPSHOT, false));
         }
    @@ -205,6 +208,7 @@ public void testPartitionMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionMvccTxWithFilter() throws Exception {
             filterOn.set(true);
     
    @@ -214,6 +218,7 @@ public void testPartitionMvccTxWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionMvccTxNoBackup() throws Exception {
             checkBackupAcknowledgeMessage(cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL_SNAPSHOT, false));
         }
    @@ -221,6 +226,7 @@ public void testPartitionMvccTxNoBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionMvccTxNoBackupWithFilter() throws Exception {
             filterOn.set(true);
     
    @@ -230,6 +236,7 @@ public void testPartitionMvccTxNoBackupWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedMvccTx() throws Exception {
             checkBackupAcknowledgeMessage(cacheConfiguration(REPLICATED, 1, TRANSACTIONAL_SNAPSHOT, false));
         }
    @@ -237,6 +244,7 @@ public void testReplicatedMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedMvccTxWithFilter() throws Exception {
             filterOn.set(true);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousBatchForceServerModeAckTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousBatchForceServerModeAckTest.java
    index 35a1fe49beeae..289d5fd0beb65 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousBatchForceServerModeAckTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousBatchForceServerModeAckTest.java
    @@ -19,17 +19,11 @@
     
     import java.io.Serializable;
     import org.apache.ignite.configuration.IgniteConfiguration;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     
     /**
      * Continuous queries tests.
      */
     public class CacheContinuousBatchForceServerModeAckTest extends CacheContinuousBatchAckTest implements Serializable {
    -    /** IP finder. */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** {@inheritDoc} */
         @SuppressWarnings("unchecked")
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    @@ -41,40 +35,13 @@ public class CacheContinuousBatchForceServerModeAckTest extends CacheContinuousB
                 FailedTcpCommunicationSpi spi = new FailedTcpCommunicationSpi(true, false);
     
                 cfg.setCommunicationSpi(spi);
    -
    -            TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -            disco.setForceServerMode(true);
    -
    -            disco.setIpFinder(IP_FINDER);
    -
    -            cfg.setDiscoverySpi(disco);
             }
    -        else if (igniteInstanceName.endsWith(SERVER2)) {
    +        else if (igniteInstanceName.endsWith(SERVER2))
                 cfg.setCommunicationSpi(new FailedTcpCommunicationSpi(false, true));
     
    -            TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -            disco.setIpFinder(IP_FINDER);
    -
    -            cfg.setDiscoverySpi(disco);
    -        }
    -        else {
    +        else
                 cfg.setCommunicationSpi(new FailedTcpCommunicationSpi(false, false));
     
    -            TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -            disco.setIpFinder(IP_FINDER);
    -
    -            cfg.setDiscoverySpi(disco);
    -        }
    -
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(disco);
    -
             return cfg;
         }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverMvccTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverMvccTxSelfTest.java
    new file mode 100644
    index 0000000000000..0aa9cd1912707
    --- /dev/null
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverMvccTxSelfTest.java
    @@ -0,0 +1,55 @@
    +/*
    + * 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.
    + */
    +package org.apache.ignite.internal.processors.cache.query.continuous;
    +
    +import org.apache.ignite.cache.CacheAtomicityMode;
    +import org.apache.ignite.cache.CacheMode;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
    +
    +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
    +import static org.apache.ignite.cache.CacheMode.PARTITIONED;
    +
    +/**
    + *
    + */
    +@RunWith(JUnit4.class)
    +public class CacheContinuousQueryAsyncFailoverMvccTxSelfTest  extends CacheContinuousQueryFailoverAbstractSelfTest {
    +    /** {@inheritDoc} */
    +    @Override protected CacheMode cacheMode() {
    +        return PARTITIONED;
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override protected CacheAtomicityMode atomicityMode() {
    +        return TRANSACTIONAL_SNAPSHOT;
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override protected boolean asyncCallback() {
    +        return true;
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7311")
    +    @Test
    +    @Override public void testBackupQueueEvict() throws Exception {
    +        // No-op.
    +    }
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverTxSelfTest.java
    index 0417022cdbeb7..8f0bd0e0d4633 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverTxSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFailoverTxSelfTest.java
    @@ -41,9 +41,4 @@ public class CacheContinuousQueryAsyncFailoverTxSelfTest extends CacheContinuous
         @Override protected boolean asyncCallback() {
             return true;
         }
    -
    -    /** {@inheritDoc} */
    -    @Override public void testNoEventLossOnTopologyChange() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-4015");
    -    }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFilterListenerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFilterListenerTest.java
    index 328b023aac0ab..5ebf3be525118 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFilterListenerTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFilterListenerTest.java
    @@ -47,12 +47,12 @@
     import org.apache.ignite.lang.IgniteAsyncCallback;
     import org.apache.ignite.lang.IgniteBiInClosure;
     import org.apache.ignite.resources.IgniteInstanceResource;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.SECONDS;
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
    @@ -67,10 +67,8 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstractTest {
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int NODES = 5;
     
    @@ -84,8 +82,6 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    -
             cfg.setClientMode(client);
     
             MemoryEventStorageSpi storeSpi = new MemoryEventStorageSpi();
    @@ -114,6 +110,7 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerTx() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL), true, true, false);
         }
    @@ -121,6 +118,7 @@ public void testNonDeadLockInListenerTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerTxJCacheApi() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL), true, true, true);
         }
    @@ -128,6 +126,7 @@ public void testNonDeadLockInListenerTxJCacheApi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerMvccTx() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
         }
    @@ -135,6 +134,7 @@ public void testNonDeadLockInListenerMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerMvccTxJCacheApi() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, true);
         }
    @@ -142,6 +142,7 @@ public void testNonDeadLockInListenerMvccTxJCacheApi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerAtomic() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, ATOMIC), true, true, false);
         }
    @@ -149,6 +150,7 @@ public void testNonDeadLockInListenerAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerAtomicJCacheApi() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, ATOMIC), true, true, true);
         }
    @@ -156,6 +158,7 @@ public void testNonDeadLockInListenerAtomicJCacheApi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerReplicatedAtomic() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, ATOMIC), true, true, false);
         }
    @@ -163,6 +166,7 @@ public void testNonDeadLockInListenerReplicatedAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerReplicatedAtomicJCacheApi() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, ATOMIC), true, true, true);
         }
    @@ -170,6 +174,7 @@ public void testNonDeadLockInListenerReplicatedAtomicJCacheApi() throws Exceptio
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerReplicatedAtomicOffHeapValues() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, ATOMIC), true, true, false);
         }
    @@ -177,6 +182,7 @@ public void testNonDeadLockInListenerReplicatedAtomicOffHeapValues() throws Exce
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerAtomicWithoutBackup() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 0, ATOMIC), true, true, false);
         }
    @@ -184,6 +190,7 @@ public void testNonDeadLockInListenerAtomicWithoutBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerAtomicWithoutBackupJCacheApi() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 0, ATOMIC), true, true, true);
         }
    @@ -191,6 +198,7 @@ public void testNonDeadLockInListenerAtomicWithoutBackupJCacheApi() throws Excep
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListener() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL), true, true, false);
         }
    @@ -198,6 +206,7 @@ public void testNonDeadLockInListener() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerReplicated() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL), true, true, false);
         }
    @@ -205,6 +214,7 @@ public void testNonDeadLockInListenerReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerReplicatedJCacheApi() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL), true, true, true);
         }
    @@ -212,6 +222,7 @@ public void testNonDeadLockInListenerReplicatedJCacheApi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerMvcc() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
         }
    @@ -219,6 +230,7 @@ public void testNonDeadLockInListenerMvcc() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerReplicatedMvcc() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
         }
    @@ -226,6 +238,7 @@ public void testNonDeadLockInListenerReplicatedMvcc() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInListenerReplicatedJCacheApiMvcc() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), true, true, true);
         }
    @@ -237,6 +250,7 @@ public void testNonDeadLockInListenerReplicatedJCacheApiMvcc() throws Exception
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterTx() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL), true, true, false);
         }
    @@ -244,6 +258,7 @@ public void testNonDeadLockInFilterTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterTxJCacheApi() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL), true, true, true);
         }
    @@ -251,6 +266,7 @@ public void testNonDeadLockInFilterTxJCacheApi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterMvccTx() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
         }
    @@ -258,6 +274,7 @@ public void testNonDeadLockInFilterMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterMvccTxJCacheApi() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, true);
         }
    @@ -265,6 +282,7 @@ public void testNonDeadLockInFilterMvccTxJCacheApi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterAtomic() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, ATOMIC), true, true, false);
         }
    @@ -272,6 +290,7 @@ public void testNonDeadLockInFilterAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterAtomicJCacheApi() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, ATOMIC), true, true, true);
         }
    @@ -279,6 +298,7 @@ public void testNonDeadLockInFilterAtomicJCacheApi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterReplicatedAtomic() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(REPLICATED, 2, ATOMIC), true, true, false);
         }
    @@ -286,6 +306,7 @@ public void testNonDeadLockInFilterReplicatedAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterAtomicWithoutBackup() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 0, ATOMIC), true, true, false);
         }
    @@ -293,6 +314,7 @@ public void testNonDeadLockInFilterAtomicWithoutBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilter() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL), true, true, false);
         }
    @@ -300,6 +322,7 @@ public void testNonDeadLockInFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterReplicated() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL), true, true, false);
         }
    @@ -307,6 +330,7 @@ public void testNonDeadLockInFilterReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterReplicatedJCacheApi() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL), true, true, false);
         }
    @@ -314,6 +338,7 @@ public void testNonDeadLockInFilterReplicatedJCacheApi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterMvcc() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
         }
    @@ -321,6 +346,7 @@ public void testNonDeadLockInFilterMvcc() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterReplicatedMvcc() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
         }
    @@ -328,6 +354,7 @@ public void testNonDeadLockInFilterReplicatedMvcc() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterReplicatedJCacheApiMvcc() throws Exception {
             testNonDeadLockInFilter(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
         }
    @@ -339,6 +366,7 @@ public void testNonDeadLockInFilterReplicatedJCacheApiMvcc() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterTxSyncFilter() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL), false, true, false);
         }
    @@ -346,6 +374,7 @@ public void testNonDeadLockInFilterTxSyncFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterMvccTxSyncFilter() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), false, true, false);
         }
    @@ -353,6 +382,7 @@ public void testNonDeadLockInFilterMvccTxSyncFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterAtomicSyncFilter() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, ATOMIC), false, true, false);
         }
    @@ -360,6 +390,7 @@ public void testNonDeadLockInFilterAtomicSyncFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterReplicatedAtomicSyncFilter() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, ATOMIC), false, true, false);
         }
    @@ -367,6 +398,7 @@ public void testNonDeadLockInFilterReplicatedAtomicSyncFilter() throws Exception
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterAtomicWithoutBackupSyncFilter() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 0, ATOMIC), false, true, false);
         }
    @@ -374,6 +406,7 @@ public void testNonDeadLockInFilterAtomicWithoutBackupSyncFilter() throws Except
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterSyncFilter() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL), false, true, false);
         }
    @@ -381,6 +414,7 @@ public void testNonDeadLockInFilterSyncFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterReplicatedSyncFilter() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL), false, true, false);
         }
    @@ -388,6 +422,7 @@ public void testNonDeadLockInFilterReplicatedSyncFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterSyncFilterMvcc() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), false, true, false);
         }
    @@ -395,6 +430,7 @@ public void testNonDeadLockInFilterSyncFilterMvcc() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonDeadLockInFilterReplicatedSyncFilterMvcc() throws Exception {
             testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), false, true, false);
         }
    @@ -479,7 +515,7 @@ else if (!val.equals(val0))
                                 try {
                                     assertEquals(val, val0);
     
    -                                if (cache0.getConfiguration(CacheConfiguration.class).getAtomicityMode() != ATOMIC) {
    +                                if (atomicityMode(cache0) != ATOMIC) {
                                         boolean committed = false;
     
                                         while (!committed && !Thread.currentThread().isInterrupted()) {
    @@ -635,7 +671,7 @@ else if (!val.equals(val0))
                                 try {
                                     assertEquals(val, val0);
     
    -                                if (cache0.getConfiguration(CacheConfiguration.class).getAtomicityMode() != ATOMIC) {
    +                                if (atomicityMode(cache0) != ATOMIC) {
                                         boolean committed = false;
     
                                         while (!committed && !Thread.currentThread().isInterrupted()) {
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java
    index 93a9a0daddf50..0f52b43630afa 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java
    @@ -39,12 +39,13 @@
     import org.apache.ignite.internal.util.lang.GridAbsPredicate;
     import org.apache.ignite.internal.util.typedef.T2;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    @@ -56,10 +57,8 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private boolean client;
     
    @@ -67,8 +66,6 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    -
             cfg.setClientMode(client);
     
             return cfg;
    @@ -84,6 +81,7 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentUpdatePartitionAtomic() throws Exception {
             concurrentUpdatePartition(ATOMIC, false);
         }
    @@ -91,6 +89,7 @@ public void testConcurrentUpdatePartitionAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentUpdatePartitionTx() throws Exception {
             concurrentUpdatePartition(TRANSACTIONAL, false);
         }
    @@ -98,6 +97,7 @@ public void testConcurrentUpdatePartitionTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentUpdatePartitionMvccTx() throws Exception {
             concurrentUpdatePartition(TRANSACTIONAL_SNAPSHOT, false);
         }
    @@ -105,6 +105,7 @@ public void testConcurrentUpdatePartitionMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentUpdatePartitionAtomicCacheGroup() throws Exception {
             concurrentUpdatePartition(ATOMIC, true);
         }
    @@ -112,6 +113,7 @@ public void testConcurrentUpdatePartitionAtomicCacheGroup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentUpdatePartitionTxCacheGroup() throws Exception {
             concurrentUpdatePartition(TRANSACTIONAL, true);
         }
    @@ -119,6 +121,7 @@ public void testConcurrentUpdatePartitionTxCacheGroup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentUpdatePartitionMvccTxCacheGroup() throws Exception {
             concurrentUpdatePartition(TRANSACTIONAL_SNAPSHOT, true);
         }
    @@ -274,6 +277,7 @@ private T2 startListener(IgniteCache
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentUpdatesAndQueryStartAtomic() throws Exception {
             concurrentUpdatesAndQueryStart(ATOMIC, false);
         }
    @@ -281,6 +285,7 @@ public void testConcurrentUpdatesAndQueryStartAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentUpdatesAndQueryStartTx() throws Exception {
             concurrentUpdatesAndQueryStart(TRANSACTIONAL, false);
         }
    @@ -288,6 +293,7 @@ public void testConcurrentUpdatesAndQueryStartTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentUpdatesAndQueryStartMvccTx() throws Exception {
             concurrentUpdatesAndQueryStart(TRANSACTIONAL_SNAPSHOT, false);
         }
    @@ -295,20 +301,24 @@ public void testConcurrentUpdatesAndQueryStartMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    -    public void _testConcurrentUpdatesAndQueryStartAtomicCacheGroup() throws Exception {
    +    @Test
    +    public void testConcurrentUpdatesAndQueryStartAtomicCacheGroup() throws Exception {
             concurrentUpdatesAndQueryStart(ATOMIC, true);
         }
     
         /**
          * @throws Exception If failed.
          */
    -    public void _testConcurrentUpdatesAndQueryStartTxCacheGroup() throws Exception {
    +    @Test
    +    public void testConcurrentUpdatesAndQueryStartTxCacheGroup() throws Exception {
             concurrentUpdatesAndQueryStart(TRANSACTIONAL, true);
         }
     
         /**
          * @throws Exception If failed.
          */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-10755")
    +    @Test
         public void testConcurrentUpdatesAndQueryStartMvccTxCacheGroup() throws Exception {
             concurrentUpdatesAndQueryStart(TRANSACTIONAL_SNAPSHOT, true);
         }
    @@ -329,24 +339,24 @@ private void concurrentUpdatesAndQueryStart(CacheAtomicityMode atomicityMode, bo
     
             if (cacheGrp) {
                 for (int i = 0; i < 3; i++) {
    -                CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME + i);
    +                CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME + i);
     
                     ccfg.setGroupName("testGroup");
                     ccfg.setWriteSynchronizationMode(FULL_SYNC);
                     ccfg.setAtomicityMode(atomicityMode);
     
    -                IgniteCache cache = client.createCache(ccfg);
    +                IgniteCache cache = client.createCache(ccfg);
     
                     caches.add(cache.getName());
                 }
             }
             else {
    -            CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    +            CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
     
                 ccfg.setWriteSynchronizationMode(FULL_SYNC);
                 ccfg.setAtomicityMode(atomicityMode);
     
    -            IgniteCache cache = client.createCache(ccfg);
    +            IgniteCache cache = client.createCache(ccfg);
     
                 caches.add(cache.getName());
             }
    @@ -476,7 +486,7 @@ private void concurrentUpdatesAndQueryStart(CacheAtomicityMode atomicityMode, bo
     
                             return evtCnt.get() >= THREADS * UPDATES;
                         }
    -                }, 5000);
    +                }, 30000);
     
                     assertEquals(THREADS * UPDATES, qry.get1().get());
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryCounterAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryCounterAbstractTest.java
    index 4ec8151b85d92..9ec0b233ced19 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryCounterAbstractTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryCounterAbstractTest.java
    @@ -45,14 +45,14 @@
     import org.apache.ignite.internal.util.typedef.T2;
     import org.apache.ignite.lang.IgniteBiInClosure;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.jetbrains.annotations.NotNull;
     import org.jetbrains.annotations.Nullable;
     import java.util.concurrent.ConcurrentHashMap;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    @@ -63,14 +63,12 @@
     /**
      * Continuous queries counter tests.
      */
    +@RunWith(JUnit4.class)
     public abstract class CacheContinuousQueryCounterAbstractTest extends GridCommonAbstractTest
         implements Serializable {
         /** */
         protected static final String CACHE_NAME = "test_cache";
     
    -    /** IP finder. */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** Latch timeout. */
         protected static final long LATCH_TIMEOUT = 5000;
     
    @@ -87,12 +85,6 @@ public abstract class CacheContinuousQueryCounterAbstractTest extends GridCommon
             if (igniteInstanceName.equals(NO_CACHE_IGNITE_INSTANCE_NAME))
                 cfg.setClientMode(true);
     
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(disco);
    -
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
     
             return cfg;
    @@ -177,6 +169,7 @@ protected CacheAtomicityMode atomicityMode() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAllEntries() throws Exception {
             IgniteCache cache = grid(0).cache(CACHE_NAME);
     
    @@ -234,7 +227,7 @@ public void testAllEntries() throws Exception {
                 assertEquals(2, vals.size());
                 assertEquals(2, (int)vals.get(0).get1());
                 assertEquals(1L, (long)vals.get(0).get2());
    -            assertNull(vals.get(1).get1());
    +            assertEquals(2, (int)vals.get(1).get1());
     
                 vals = map.get(3);
     
    @@ -248,6 +241,7 @@ public void testAllEntries() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTwoQueryListener() throws Exception {
             if (cacheMode() == LOCAL)
                 return;
    @@ -353,8 +347,8 @@ private void checkEvents(Map>> evnts, long iter)
             assertEquals(1L, (long)val.get(0).get1());
     
             // Check remove 1
    +        assertEquals(1L, (long)val.get(1).get1());
             assertEquals(iter * 2 + 2, (long)val.get(1).get2());
    -        assertNull(val.get(1).get1());
     
             val = evnts.get(2);
     
    @@ -365,8 +359,8 @@ private void checkEvents(Map>> evnts, long iter)
             assertEquals(2L, (long)val.get(0).get1());
     
             // Check remove 2
    +        assertEquals(2L, (long)val.get(1).get1());
             assertEquals(iter * 2 + 2, (long)val.get(1).get2());
    -        assertNull(val.get(1).get1());
     
             val = evnts.get(3);
     
    @@ -377,13 +371,14 @@ private void checkEvents(Map>> evnts, long iter)
             assertEquals(3L, (long)val.get(0).get1());
     
             // Check remove 3
    +        assertEquals(3L, (long)val.get(1).get1());
             assertEquals(iter * 2 + 2, (long)val.get(1).get2());
    -        assertNull(val.get(1).get1());
         }
     
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRestartQuery() throws Exception {
             IgniteCache cache = grid(0).cache(CACHE_NAME);
     
    @@ -442,6 +437,7 @@ public void testRestartQuery() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testEntriesByFilter() throws Exception {
             IgniteCache cache = grid(0).cache(CACHE_NAME);
     
    @@ -509,7 +505,7 @@ public void testEntriesByFilter() throws Exception {
                 assertEquals((int)vals.get(1).get1(), 4);
                 assertEquals((long)vals.get(1).get1(), (long)vals.get(1).get2());
     
    -            assertNull(vals.get(2).get1());
    +            assertEquals(4, (long)vals.get(2).get1());
                 assertEquals(5, (long)vals.get(2).get2());
     
                 assertEquals((int)vals.get(3).get1(), 10);
    @@ -526,7 +522,7 @@ public void testEntriesByFilter() throws Exception {
                 assertEquals((int)vals.get(1).get1(), 4);
                 assertEquals((long)vals.get(1).get1(), (long)vals.get(1).get2());
     
    -            assertNull(vals.get(2).get1());
    +            assertEquals(4, (long)vals.get(2).get1());
                 assertEquals(5, (long)vals.get(2).get2());
     
                 assertEquals((int)vals.get(3).get1(), 40);
    @@ -537,6 +533,7 @@ public void testEntriesByFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLoadCache() throws Exception {
             IgniteCache cache = grid(0).cache(CACHE_NAME);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEventBufferTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEventBufferTest.java
    index 382f16692175c..c86ac65a81f81 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEventBufferTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryEventBufferTest.java
    @@ -28,15 +28,20 @@
     import javax.cache.event.EventType;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
     @SuppressWarnings("unchecked")
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryEventBufferTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBuffer1() throws Exception {
             testBuffer(1);
         }
    @@ -44,6 +49,7 @@ public void testBuffer1() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBuffer2() throws Exception {
             for (int i = 0; i < 10; i++) {
                 log.info("Iteration: " + i);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
    index 789504cdf685c..79aedd198bd9d 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
    @@ -46,6 +46,9 @@
     import java.util.concurrent.CountDownLatch;
     import java.util.concurrent.atomic.AtomicBoolean;
     import java.util.concurrent.atomic.AtomicInteger;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
    @@ -59,6 +62,7 @@
     /**
      * Continuous queries execute in primary node tests.
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryExecuteInPrimaryTest extends GridCommonAbstractTest
         implements Serializable {
     
    @@ -100,6 +104,7 @@ protected CacheConfiguration cacheConfiguration(
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(ATOMIC, LOCAL);
     
    @@ -110,6 +115,7 @@ public void testLocalCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(ATOMIC, REPLICATED);
     
    @@ -120,6 +126,7 @@ public void testReplicatedCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionedCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(ATOMIC, PARTITIONED);
     
    @@ -130,6 +137,7 @@ public void testPartitionedCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTransactionLocalCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(TRANSACTIONAL, LOCAL);
     
    @@ -140,6 +148,7 @@ public void testTransactionLocalCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTransactionReplicatedCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(TRANSACTIONAL, REPLICATED);
     
    @@ -150,6 +159,7 @@ public void testTransactionReplicatedCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTransactionPartitionedCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(TRANSACTIONAL, PARTITIONED);
     
    @@ -160,6 +170,7 @@ public void testTransactionPartitionedCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTransactionLocalCache() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-9530");
     
    @@ -172,6 +183,7 @@ public void testMvccTransactionLocalCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTransactionReplicatedCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(TRANSACTIONAL_SNAPSHOT, REPLICATED);
     
    @@ -182,6 +194,7 @@ public void testMvccTransactionReplicatedCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTransactionPartitionedCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(TRANSACTIONAL_SNAPSHOT, PARTITIONED);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterRandomOperationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterRandomOperationTest.java
    index d216d4f88ad58..7fadb3b3eb3b4 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterRandomOperationTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterRandomOperationTest.java
    @@ -58,6 +58,9 @@
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
     import org.jetbrains.annotations.NotNull;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static java.util.concurrent.TimeUnit.SECONDS;
    @@ -75,6 +78,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheContinuousQueryRandomOperationsTest {
         /** */
         private static final int NODES = 5;
    @@ -91,6 +95,7 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInternalQuery() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 1,
    @@ -276,7 +281,7 @@ private void randomUpdate(
     
             Transaction tx = null;
     
    -        CacheAtomicityMode atomicityMode = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode();
    +        CacheAtomicityMode atomicityMode = atomicityMode(cache);
     
             boolean mvccEnabled = atomicityMode == TRANSACTIONAL_SNAPSHOT;
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
    index 0fef7b21b183f..40adcef26fb56 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
    @@ -74,8 +74,8 @@
     import org.apache.ignite.internal.IgniteKernal;
     import org.apache.ignite.internal.managers.communication.GridIoMessage;
     import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
    -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology;
     import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap;
    +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology;
     import org.apache.ignite.internal.processors.continuous.GridContinuousHandler;
     import org.apache.ignite.internal.processors.continuous.GridContinuousMessage;
     import org.apache.ignite.internal.processors.continuous.GridContinuousProcessor;
    @@ -87,6 +87,7 @@
     import org.apache.ignite.internal.util.typedef.PAX;
     import org.apache.ignite.internal.util.typedef.T2;
     import org.apache.ignite.internal.util.typedef.T3;
    +import org.apache.ignite.internal.util.typedef.X;
     import org.apache.ignite.internal.util.typedef.internal.CU;
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.lang.IgniteAsyncCallback;
    @@ -98,12 +99,14 @@
     import org.apache.ignite.spi.IgniteSpiException;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
     import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.apache.ignite.transactions.TransactionRollbackException;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static java.util.concurrent.TimeUnit.MINUTES;
    @@ -111,14 +114,14 @@
     import static org.apache.ignite.cache.CacheMode.REPLICATED;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
     import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
    +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
    +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridCommonAbstractTest {
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int BACKUP_ACK_THRESHOLD = 100;
     
    @@ -136,7 +139,6 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
             ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
     
             TestCommunicationSpi commSpi = new TestCommunicationSpi();
     
    @@ -211,6 +213,7 @@ protected NearCacheConfiguration nearCacheConfiguration() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFirstFilteredEvent() throws Exception {
             this.backups = 2;
     
    @@ -255,6 +258,7 @@ public void testFirstFilteredEvent() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRebalanceVersion() throws Exception {
             Ignite ignite0 = startGrid(0);
     
    @@ -307,6 +311,7 @@ public void testRebalanceVersion() throws Exception {
          *
          * @throws Exception If fail.
          */
    +    @Test
         public void testRebalance() throws Exception {
             for (int iter = 0; iter < 5; iter++) {
                 log.info("Iteration: " + iter);
    @@ -422,6 +427,7 @@ private void waitRebalanceFinished(Ignite ignite, long topVer, int minorVer) thr
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testOneBackup() throws Exception {
             checkBackupQueue(1, false);
         }
    @@ -429,6 +435,7 @@ public void testOneBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testOneBackupClientUpdate() throws Exception {
             checkBackupQueue(1, true);
         }
    @@ -436,6 +443,7 @@ public void testOneBackupClientUpdate() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testUpdatePartitionCounter() throws Exception {
             this.backups = 2;
     
    @@ -521,7 +529,7 @@ private void checkPartCounter(int nodes, int killedNodeIdx, Map u
                 Affinity aff = grid(i).affinity(DEFAULT_CACHE_NAME);
     
                 CachePartitionPartialCountersMap act = grid(i).cachex(DEFAULT_CACHE_NAME).context().topology()
    -                .localUpdateCounters(false, false);
    +                .localUpdateCounters(false);
     
                 for (Map.Entry e : updCntrs.entrySet()) {
                     if (aff.mapPartitionToPrimaryAndBackups(e.getKey()).contains(grid(i).localNode())) {
    @@ -536,6 +544,7 @@ private void checkPartCounter(int nodes, int killedNodeIdx, Map u
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testStartStopQuery() throws Exception {
             this.backups = 1;
     
    @@ -640,6 +649,7 @@ public void testStartStopQuery() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLeftPrimaryAndBackupNodes() throws Exception {
             if (cacheMode() == REPLICATED)
                 return;
    @@ -760,6 +770,8 @@ public void testLeftPrimaryAndBackupNodes() throws Exception {
                 }
             }, 5000L);
     
    +        awaitPartitionMapExchange();
    +
             for (; keyIter < keys.size(); keyIter++) {
                 int key = keys.get(keyIter);
     
    @@ -784,7 +796,18 @@ public void testLeftPrimaryAndBackupNodes() throws Exception {
                         expEvts.add(new T3<>((Object)key, (Object)val, (Object)key));
                 }
     
    -            clnCache.put(key, val);
    +            boolean updated = false;
    +
    +            while (!updated) {
    +                try {
    +                    clnCache.put(key, val);
    +
    +                    updated = true;
    +                }
    +                catch (Exception ignore) {
    +                    assertEquals(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, atomicityMode());
    +                }
    +            }
     
                 filtered = !filtered;
             }
    @@ -797,6 +820,7 @@ public void testLeftPrimaryAndBackupNodes() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoteFilter() throws Exception {
             this.backups = 2;
     
    @@ -909,6 +933,7 @@ public void testRemoteFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testThreeBackups() throws Exception {
             if (cacheMode() == REPLICATED)
                 return;
    @@ -977,8 +1002,8 @@ private void checkBackupQueue(int backups, boolean updateFromClient) throws Exce
                     T2 t = updates.get(key);
     
                     if (updateFromClient) {
    -                    if (atomicityMode() == CacheAtomicityMode.TRANSACTIONAL) {
    -                        try (Transaction tx = qryClient.transactions().txStart()) {
    +                    if (atomicityMode() != CacheAtomicityMode.ATOMIC) {
    +                        try (Transaction tx = qryClient.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
                                 qryClientCache.put(key, key);
     
                                 tx.commit();
    @@ -993,8 +1018,8 @@ private void checkBackupQueue(int backups, boolean updateFromClient) throws Exce
                             qryClientCache.put(key, key);
                     }
                     else {
    -                    if (atomicityMode() == CacheAtomicityMode.TRANSACTIONAL) {
    -                        try (Transaction tx = ignite.transactions().txStart()) {
    +                    if (atomicityMode() != CacheAtomicityMode.ATOMIC) {
    +                        try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
                                 cache.put(key, key);
     
                                 tx.commit();
    @@ -1335,6 +1360,7 @@ private List testKeys(IgniteCache cache, int parts) thr
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBackupQueueCleanupClientQuery() throws Exception {
             startGridsMultiThreaded(2);
     
    @@ -1408,6 +1434,7 @@ public void testBackupQueueCleanupClientQuery() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBackupQueueEvict() throws Exception {
             startGridsMultiThreaded(2);
     
    @@ -1480,6 +1507,7 @@ public void testBackupQueueEvict() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBackupQueueCleanupServerQuery() throws Exception {
             Ignite qryClient = startGridsMultiThreaded(2);
     
    @@ -1556,6 +1584,7 @@ private Collection backupQueue(Ignite ignite) {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFailoverStartStopBackup() throws Exception {
             failoverStartStopFilter(2);
         }
    @@ -1563,6 +1592,7 @@ public void testFailoverStartStopBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testStartStop() throws Exception {
             this.backups = 2;
     
    @@ -1755,18 +1785,30 @@ private void failoverStartStopFilter(int backups) throws Exception {
                     if (filtered)
                         val = -val;
     
    -                if (processorPut && prevVal != null) {
    -                    qryClnCache.invoke(key, new CacheEntryProcessor() {
    -                        @Override public Void process(MutableEntry entry,
    -                            Object... arguments) throws EntryProcessorException {
    -                            entry.setValue(arguments[0]);
    +                boolean updated = false;
     
    -                            return null;
    +                while (!updated) {
    +                    try {
    +                        if (processorPut && prevVal != null) {
    +                            qryClnCache.invoke(key, new CacheEntryProcessor() {
    +                                @Override public Void process(MutableEntry entry,
    +                                    Object... arguments) throws EntryProcessorException {
    +                                    entry.setValue(arguments[0]);
    +
    +                                    return null;
    +                                }
    +                            }, val);
                             }
    -                    }, val);
    +                        else
    +                            qryClnCache.put(key, val);
    +
    +                        updated = true;
    +                    }
    +                    catch (CacheException e) {
    +                        assertTrue(X.hasCause(e, TransactionRollbackException.class));
    +                        assertSame(atomicityMode(), CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT);
    +                    }
                     }
    -                else
    -                    qryClnCache.put(key, val);
     
                     processorPut = !processorPut;
     
    @@ -1870,6 +1912,7 @@ private void failoverStartStopFilter(int backups) throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiThreadedFailover() throws Exception {
             this.backups = 2;
     
    @@ -2020,7 +2063,20 @@ public void testMultiThreadedFailover() throws Exception {
     
                             Integer val = valCntr.incrementAndGet();
     
    -                        Integer prevVal = (Integer)qryClnCache.getAndPut(key, val);
    +                        Integer prevVal = null;
    +
    +                        boolean updated = false;
    +
    +                        while (!updated) {
    +                            try {
    +                                prevVal = (Integer)qryClnCache.getAndPut(key, val);
    +
    +                                updated = true;
    +                            }
    +                            catch (CacheException e) {
    +                                assertSame(atomicityMode(), CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT);
    +                            }
    +                        }
     
                             expEvts.get(threadId).add(new T3<>((Object)key, (Object)val, (Object)prevVal));
     
    @@ -2064,6 +2120,7 @@ public void testMultiThreadedFailover() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiThreaded() throws Exception {
             this.backups = 2;
     
    @@ -2114,7 +2171,19 @@ public void testMultiThreaded() throws Exception {
                     @Override public Object call() throws Exception {
                         Integer val0 = val.getAndIncrement();
     
    -                    cache.put(key, val0);
    +                    boolean updated = false;
    +
    +                    while (!updated) {
    +                        try {
    +                            cache.put(key, val0);
    +
    +                            updated = true;
    +                        }
    +                        catch (CacheException e) {
    +                            assertTrue(X.hasCause(e, TransactionRollbackException.class));
    +                            assertSame(atomicityMode(), CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT);
    +                        }
    +                    }
     
                         return null;
                     }
    @@ -2245,6 +2314,7 @@ private boolean checkEvents(boolean logAll,
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoEventLossOnTopologyChange() throws Exception {
             final int batchLoadSize = 2000;
     
    diff --git a/modules/web-console/frontend/app/modules/branding/powered-by-apache.directive.js b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverMvccTxReplicatedSelfTest.java
    similarity index 66%
    rename from modules/web-console/frontend/app/modules/branding/powered-by-apache.directive.js
    rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverMvccTxReplicatedSelfTest.java
    index 3f8b3deb5bfc9..2576d23f6839a 100644
    --- a/modules/web-console/frontend/app/modules/branding/powered-by-apache.directive.js
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverMvccTxReplicatedSelfTest.java
    @@ -14,26 +14,18 @@
      * See the License for the specific language governing permissions and
      * limitations under the License.
      */
    +package org.apache.ignite.internal.processors.cache.query.continuous;
     
    -import template from './powered-by-apache.pug';
    +import org.apache.ignite.cache.CacheMode;
    +
    +import static org.apache.ignite.cache.CacheMode.REPLICATED;
     
     /**
    - * @param {import('./branding.service').default} branding
    + *
      */
    -export default function factory(branding) {
    -    function controller() {
    -        const ctrl = this;
    -
    -        ctrl.show = branding.showIgniteLogo;
    +public class CacheContinuousQueryFailoverMvccTxReplicatedSelfTest extends CacheContinuousQueryFailoverMvccTxSelfTest {
    +    /** {@inheritDoc} */
    +    @Override protected CacheMode cacheMode() {
    +        return REPLICATED;
         }
    -
    -    return {
    -        restrict: 'E',
    -        template,
    -        controller,
    -        controllerAs: 'poweredBy'
    -    };
    -}
    -
    -factory.$inject = ['IgniteBranding'];
    -
    +}
    \ No newline at end of file
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverMvccTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverMvccTxSelfTest.java
    new file mode 100644
    index 0000000000000..4fab9c8dce195
    --- /dev/null
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverMvccTxSelfTest.java
    @@ -0,0 +1,50 @@
    +/*
    + * 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.
    + */
    +package org.apache.ignite.internal.processors.cache.query.continuous;
    +
    +import org.apache.ignite.cache.CacheAtomicityMode;
    +import org.apache.ignite.cache.CacheMode;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
    +
    +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
    +import static org.apache.ignite.cache.CacheMode.PARTITIONED;
    +
    +/**
    + *
    + */
    +@RunWith(JUnit4.class)
    +public class CacheContinuousQueryFailoverMvccTxSelfTest extends CacheContinuousQueryFailoverAbstractSelfTest {
    +    /** {@inheritDoc} */
    +    @Override protected CacheMode cacheMode() {
    +        return PARTITIONED;
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override protected CacheAtomicityMode atomicityMode() {
    +        return TRANSACTIONAL_SNAPSHOT;
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7311")
    +    @Test
    +    @Override public void testBackupQueueEvict() throws Exception {
    +        // No-op.
    +    }
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxSelfTest.java
    index cd916e4217001..789a105e02b05 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxSelfTest.java
    @@ -36,9 +36,4 @@ public class CacheContinuousQueryFailoverTxSelfTest extends CacheContinuousQuery
         @Override protected CacheAtomicityMode atomicityMode() {
             return TRANSACTIONAL;
         }
    -
    -    /** {@inheritDoc} */
    -    @Override public void testNoEventLossOnTopologyChange() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-4015");
    -    }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryLostPartitionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryLostPartitionTest.java
    index 150d94d954409..9cfe4d96a54f7 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryLostPartitionTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryLostPartitionTest.java
    @@ -29,11 +29,11 @@
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.util.typedef.PA;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static javax.cache.configuration.FactoryBuilder.factoryOf;
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
    @@ -46,10 +46,8 @@
     /**
      * Test from https://issues.apache.org/jira/browse/IGNITE-2384.
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryLostPartitionTest extends GridCommonAbstractTest {
    -    /** */
    -    static public TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** Cache name. */
         public static final String CACHE_NAME = "test_cache";
     
    @@ -80,6 +78,7 @@ public class CacheContinuousQueryLostPartitionTest extends GridCommonAbstractTes
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxEvent() throws Exception {
             testEvent(TX_CACHE_NAME, false);
         }
    @@ -87,6 +86,7 @@ public void testTxEvent() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxEvent() throws Exception {
             testEvent(MVCC_TX_CACHE_NAME, false);
         }
    @@ -94,6 +94,7 @@ public void testMvccTxEvent() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicEvent() throws Exception {
             testEvent(CACHE_NAME, false);
         }
    @@ -101,6 +102,7 @@ public void testAtomicEvent() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxClientEvent() throws Exception {
             testEvent(TX_CACHE_NAME, true);
         }
    @@ -108,6 +110,7 @@ public void testTxClientEvent() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxClientEvent() throws Exception {
             testEvent(MVCC_TX_CACHE_NAME, true);
         }
    @@ -115,6 +118,7 @@ public void testMvccTxClientEvent() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicClientEvent() throws Exception {
             testEvent(CACHE_NAME, true);
         }
    @@ -215,11 +219,6 @@ private AllEventListener registerCacheListener(IgniteCache ccfg = cacheConfiguration(PARTITIONED, 1, ATOMIC, FULL_SYNC);
    +
    +        doTest(ccfg, true);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testTxOneBackupFilter() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, TRANSACTIONAL, FULL_SYNC);
    +
    +        doTest(ccfg, false);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testTxOneBackupFilterPrimary() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, TRANSACTIONAL, PRIMARY_SYNC);
    +
    +        doTest(ccfg, false);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testTxOneBackup() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, TRANSACTIONAL, FULL_SYNC);
    +
    +        doTest(ccfg, true);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
         public void testAtomicTwoBackups() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, ATOMIC, FULL_SYNC);
     
    @@ -145,6 +183,7 @@ public void testAtomicTwoBackups() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxTwoBackupsFilter() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL, FULL_SYNC);
     
    @@ -154,6 +193,7 @@ public void testTxTwoBackupsFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxTwoBackupsFilterPrimary() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL, PRIMARY_SYNC);
     
    @@ -163,6 +203,7 @@ public void testTxTwoBackupsFilterPrimary() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxReplicatedFilter() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED, 0, TRANSACTIONAL, FULL_SYNC);
     
    @@ -172,6 +213,7 @@ public void testTxReplicatedFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxTwoBackup() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL, FULL_SYNC);
     
    @@ -181,6 +223,7 @@ public void testTxTwoBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxReplicated() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED, 2, TRANSACTIONAL, FULL_SYNC);
     
    @@ -190,6 +233,7 @@ public void testTxReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxReplicatedPrimary() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED, 2, TRANSACTIONAL, PRIMARY_SYNC);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java
    index f2889dfd02b3d..52cad3114da25 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java
    @@ -35,10 +35,10 @@
     import org.apache.ignite.cache.query.QueryCursor;
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    @@ -50,10 +50,8 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest {
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int NODES = 5;
     
    @@ -64,8 +62,6 @@ public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    -
             cfg.setClientMode(client);
             cfg.setPeerClassLoadingEnabled(true);
     
    @@ -93,6 +89,7 @@ public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -105,6 +102,7 @@ public void testAtomicClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomic() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -117,6 +115,7 @@ public void testAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicReplicated() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -129,6 +128,7 @@ public void testAtomicReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicReplicatedClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -141,6 +141,7 @@ public void testAtomicReplicatedClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTx() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -152,6 +153,7 @@ public void testTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -164,6 +166,7 @@ public void testTxClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxReplicated() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -176,6 +179,7 @@ public void testTxReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxReplicatedClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -188,6 +192,7 @@ public void testTxReplicatedClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTx() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -199,6 +204,7 @@ public void testMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -211,6 +217,7 @@ public void testMvccTxClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxReplicated() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -223,6 +230,7 @@ public void testMvccTxReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxReplicatedClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOrderingEventTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOrderingEventTest.java
    index 1ad45dd8c1b53..274b1c38fefeb 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOrderingEventTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOrderingEventTest.java
    @@ -52,13 +52,13 @@
     import org.apache.ignite.lang.IgniteAsyncCallback;
     import org.apache.ignite.resources.IgniteInstanceResource;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    @@ -73,6 +73,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryOrderingEventTest extends GridCommonAbstractTest {
         /** */
         public static final int LISTENER_CNT = 3;
    @@ -80,9 +81,6 @@ public class CacheContinuousQueryOrderingEventTest extends GridCommonAbstractTes
         /** */
         public static final int KEYS = 10;
     
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int NODES = 5;
     
    @@ -99,7 +97,6 @@ public class CacheContinuousQueryOrderingEventTest extends GridCommonAbstractTes
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
     
             cfg.setClientMode(client);
    @@ -133,6 +130,7 @@ public class CacheContinuousQueryOrderingEventTest extends GridCommonAbstractTes
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicOnheapTwoBackup() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, ATOMIC, PRIMARY_SYNC);
     
    @@ -142,6 +140,7 @@ public void testAtomicOnheapTwoBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxOnheapTwoBackup() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL, FULL_SYNC);
     
    @@ -151,6 +150,7 @@ public void testTxOnheapTwoBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxOnheapWithoutBackup() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL, PRIMARY_SYNC);
     
    @@ -160,6 +160,7 @@ public void testTxOnheapWithoutBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxOnheapWithoutBackupFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL, FULL_SYNC);
     
    @@ -169,6 +170,7 @@ public void testTxOnheapWithoutBackupFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxOnheapTwoBackup() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
     
    @@ -178,6 +180,7 @@ public void testMvccTxOnheapTwoBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxOnheapWithoutBackup() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL_SNAPSHOT, PRIMARY_SYNC);
     
    @@ -187,6 +190,7 @@ public void testMvccTxOnheapWithoutBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxOnheapWithoutBackupFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
     
    @@ -198,6 +202,7 @@ public void testMvccTxOnheapWithoutBackupFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicOnheapTwoBackupAsync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, ATOMIC, PRIMARY_SYNC);
     
    @@ -207,6 +212,7 @@ public void testAtomicOnheapTwoBackupAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicOnheapTwoBackupAsyncFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, ATOMIC, FULL_SYNC);
     
    @@ -216,6 +222,7 @@ public void testAtomicOnheapTwoBackupAsyncFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicReplicatedAsync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED, 0, ATOMIC, PRIMARY_SYNC);
     
    @@ -225,6 +232,7 @@ public void testAtomicReplicatedAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicReplicatedAsyncFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED, 0, ATOMIC, FULL_SYNC);
     
    @@ -234,6 +242,7 @@ public void testAtomicReplicatedAsyncFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicOnheapWithoutBackupAsync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, ATOMIC, PRIMARY_SYNC);
     
    @@ -243,6 +252,7 @@ public void testAtomicOnheapWithoutBackupAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxOnheapTwoBackupAsync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL, PRIMARY_SYNC);
     
    @@ -252,6 +262,7 @@ public void testTxOnheapTwoBackupAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxOnheapAsync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL, PRIMARY_SYNC);
     
    @@ -261,6 +272,7 @@ public void testTxOnheapAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxOnheapAsyncFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL, FULL_SYNC);
     
    @@ -270,6 +282,7 @@ public void testTxOnheapAsyncFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxOnheapTwoBackupAsync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT, PRIMARY_SYNC);
     
    @@ -279,6 +292,7 @@ public void testMvccTxOnheapTwoBackupAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxOnheapAsync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL_SNAPSHOT, PRIMARY_SYNC);
     
    @@ -288,6 +302,7 @@ public void testMvccTxOnheapAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxOnheapAsyncFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
     
    @@ -355,8 +370,7 @@ protected void doOrderingTest(
     
                             QueryTestKey key = new QueryTestKey(rnd.nextInt(KEYS));
     
    -                        boolean startTx = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() !=
    -                            ATOMIC && rnd.nextBoolean();
    +                        boolean startTx = atomicityMode(cache) != ATOMIC && rnd.nextBoolean();
     
                             Transaction tx = null;
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
    index af92c31e4a814..c6f0fefdfca0c 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
    @@ -68,14 +68,15 @@
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.lang.IgniteClosure;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static java.util.concurrent.TimeUnit.SECONDS;
    @@ -99,10 +100,8 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstractTest {
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int NODES = 5;
     
    @@ -122,7 +121,6 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
     
             cfg.setClientMode(client);
    @@ -144,6 +142,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFilterAndFactoryProvided() throws Exception {
             final CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -188,6 +187,7 @@ public void testFilterAndFactoryProvided() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -200,6 +200,7 @@ public void testAtomicClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomic() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -212,6 +213,7 @@ public void testAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicAllNodes() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -224,6 +226,7 @@ public void testAtomicAllNodes() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicReplicated() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -236,6 +239,7 @@ public void testAtomicReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicReplicatedAllNodes() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -248,6 +252,7 @@ public void testAtomicReplicatedAllNodes() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicReplicatedClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -260,6 +265,7 @@ public void testAtomicReplicatedClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicNoBackups() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -272,6 +278,7 @@ public void testAtomicNoBackups() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicNoBackupsAllNodes() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -284,6 +291,7 @@ public void testAtomicNoBackupsAllNodes() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicNoBackupsClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -296,6 +304,7 @@ public void testAtomicNoBackupsClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTx() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -308,6 +317,7 @@ public void testTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxAllNodes() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -320,6 +330,7 @@ public void testTxAllNodes() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxExplicit() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -332,6 +343,7 @@ public void testTxExplicit() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTx() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -344,6 +356,7 @@ public void testMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxAllNodes() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -356,6 +369,7 @@ public void testMvccTxAllNodes() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxExplicit() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -368,6 +382,7 @@ public void testMvccTxExplicit() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveAtomicWithoutBackup() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -380,6 +395,7 @@ public void testDoubleRemoveAtomicWithoutBackup() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveAtomicWithoutBackupWithStore() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -392,6 +408,7 @@ public void testDoubleRemoveAtomicWithoutBackupWithStore() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveAtomic() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -404,6 +421,7 @@ public void testDoubleRemoveAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveAtomicWithStore() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -416,6 +434,7 @@ public void testDoubleRemoveAtomicWithStore() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveTx() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -428,6 +447,7 @@ public void testDoubleRemoveTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveTxWithStore() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -440,6 +460,7 @@ public void testDoubleRemoveTxWithStore() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveReplicatedTx() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -452,6 +473,7 @@ public void testDoubleRemoveReplicatedTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveReplicatedTxWithStore() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -464,6 +486,7 @@ public void testDoubleRemoveReplicatedTxWithStore() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveMvccTx() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -476,9 +499,9 @@ public void testDoubleRemoveMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582")
    +    @Test
         public void testDoubleRemoveMvccTxWithStore() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-8582");
    -
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
                 TRANSACTIONAL_SNAPSHOT,
    @@ -490,6 +513,7 @@ public void testDoubleRemoveMvccTxWithStore() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveReplicatedMvccTx() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -502,9 +526,9 @@ public void testDoubleRemoveReplicatedMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582")
    +    @Test
         public void testDoubleRemoveReplicatedMvccTxWithStore() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-8582");
    -
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
                 TRANSACTIONAL_SNAPSHOT,
    @@ -516,6 +540,7 @@ public void testDoubleRemoveReplicatedMvccTxWithStore() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveReplicatedAtomic() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -528,6 +553,7 @@ public void testDoubleRemoveReplicatedAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDoubleRemoveReplicatedAtomicWithStore() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -823,6 +849,7 @@ private void checkSingleEvent(
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -835,6 +862,7 @@ public void testTxClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxClientExplicit() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -847,6 +875,7 @@ public void testTxClientExplicit() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxReplicated() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -859,6 +888,7 @@ public void testTxReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxReplicatedClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -871,6 +901,7 @@ public void testTxReplicatedClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxNoBackups() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -883,6 +914,7 @@ public void testTxNoBackups() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxNoBackupsAllNodes() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -895,6 +927,7 @@ public void testTxNoBackupsAllNodes() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxNoBackupsExplicit() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -907,6 +940,7 @@ public void testTxNoBackupsExplicit() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxNoBackupsClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -919,6 +953,7 @@ public void testTxNoBackupsClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -931,6 +966,7 @@ public void testMvccTxClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxClientExplicit() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 1,
    @@ -943,6 +979,7 @@ public void testMvccTxClientExplicit() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxReplicated() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -955,6 +992,7 @@ public void testMvccTxReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxReplicatedClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(REPLICATED,
                 0,
    @@ -967,6 +1005,7 @@ public void testMvccTxReplicatedClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxNoBackups() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -979,6 +1018,7 @@ public void testMvccTxNoBackups() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxNoBackupsAllNodes() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -991,6 +1031,7 @@ public void testMvccTxNoBackupsAllNodes() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxNoBackupsExplicit() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -1003,6 +1044,7 @@ public void testMvccTxNoBackupsExplicit() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxNoBackupsClient() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,
                 0,
    @@ -1174,7 +1216,7 @@ private void randomUpdate(
     
             Transaction tx = null;
     
    -        CacheAtomicityMode atomicityMode = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode();
    +        CacheAtomicityMode atomicityMode = atomicityMode(cache);
     
             boolean mvccEnabled = atomicityMode == TRANSACTIONAL_SNAPSHOT;
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryVariationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryVariationsTest.java
    index fc86a35c16ed3..44d51d013142e 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryVariationsTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryVariationsTest.java
    @@ -65,6 +65,9 @@
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
     import org.jetbrains.annotations.Nullable;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static java.util.concurrent.TimeUnit.SECONDS;
    @@ -80,6 +83,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousQueryVariationsTest extends IgniteCacheConfigVariationsAbstractTest {
         /** */
         private static final int ITERATION_CNT = 20;
    @@ -105,6 +109,7 @@ public class CacheContinuousQueryVariationsTest extends IgniteCacheConfigVariati
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationJCacheApiKeepBinary() throws Exception {
             testRandomOperation(true, false, false, false, true);
         }
    @@ -112,6 +117,7 @@ public void testRandomOperationJCacheApiKeepBinary() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationJCacheApiAsyncCallback() throws Exception {
             testRandomOperation(true, false, false, true, false);
         }
    @@ -119,6 +125,7 @@ public void testRandomOperationJCacheApiAsyncCallback() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationJCacheApiWithFilter() throws Exception {
             testRandomOperation(true, false, true, false, false);
         }
    @@ -126,6 +133,7 @@ public void testRandomOperationJCacheApiWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationJCacheApiWithFilterAsyncCallback() throws Exception {
             testRandomOperation(true, false, true, true, false);
         }
    @@ -133,6 +141,7 @@ public void testRandomOperationJCacheApiWithFilterAsyncCallback() throws Excepti
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationJCacheApiSyncWithFilter() throws Exception {
             testRandomOperation(true, true, true, false, false);
         }
    @@ -140,6 +149,7 @@ public void testRandomOperationJCacheApiSyncWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperation() throws Exception {
             testRandomOperation(true, true, false, false, false);
         }
    @@ -147,6 +157,7 @@ public void testRandomOperation() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationWithKeepBinary() throws Exception {
             testRandomOperation(true, true, false, false, true);
         }
    @@ -154,6 +165,7 @@ public void testRandomOperationWithKeepBinary() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationWithAsyncCallback() throws Exception {
             testRandomOperation(true, true, false, true, false);
         }
    @@ -161,6 +173,7 @@ public void testRandomOperationWithAsyncCallback() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationWithFilter() throws Exception {
             testRandomOperation(true, true, true, false, false);
         }
    @@ -168,6 +181,7 @@ public void testRandomOperationWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationWithFilterWithKeepBinary() throws Exception {
             testRandomOperation(true, true, true, false, true);
         }
    @@ -175,6 +189,7 @@ public void testRandomOperationWithFilterWithKeepBinary() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomOperationWithFilterAsyncCallback() throws Exception {
             testRandomOperation(true, true, true, true, false);
         }
    @@ -623,6 +638,7 @@ private void checkNoEvent(List>> evtsQueues)
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoveRemoveScenario() throws Exception {
             runInAllDataModes(new TestRunnable() {
                 @Override public void run() throws Exception {
    @@ -717,7 +733,7 @@ public void testRemoveRemoveScenario() throws Exception {
                             while (evts.size() != 10) {
                                 Thread.sleep(100);
                             }
    -                        
    +
                             evts.clear();
     
                             log.info("Finish iteration: " + i);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerFailoverTest.java
    index 241dc2ac5c166..8360129f49a70 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerFailoverTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerFailoverTest.java
    @@ -36,10 +36,10 @@
     import org.apache.ignite.lang.IgniteClosure;
     import org.apache.ignite.lang.IgniteOutClosure;
     import org.apache.ignite.resources.LoggerResource;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.SECONDS;
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
    @@ -48,10 +48,8 @@
     
     /**
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousWithTransformerFailoverTest extends GridCommonAbstractTest {
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private boolean client;
     
    @@ -59,8 +57,6 @@ public class CacheContinuousWithTransformerFailoverTest extends GridCommonAbstra
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    -
             CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
     
             ccfg.setCacheMode(PARTITIONED);
    @@ -83,6 +79,7 @@ public class CacheContinuousWithTransformerFailoverTest extends GridCommonAbstra
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testServerNodeLeft() throws Exception {
             startGrids(3);
     
    @@ -150,6 +147,7 @@ public void testServerNodeLeft() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTransformerException() throws Exception {
             try {
                 startGrids(1);
    @@ -204,6 +202,7 @@ public void testTransformerException() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testCrossCallback() throws Exception {
             startGrids(2);
             try {
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerReplicatedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerReplicatedSelfTest.java
    index 60e2f80eabfd4..5c831267f244e 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerReplicatedSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerReplicatedSelfTest.java
    @@ -47,11 +47,15 @@
     import org.apache.ignite.lang.IgniteClosure;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     
     /**
      */
    +@RunWith(JUnit4.class)
     public class CacheContinuousWithTransformerReplicatedSelfTest extends GridCommonAbstractTest {
         /** */
         private static final int DFLT_ENTRY_CNT = 10;
    @@ -144,6 +148,7 @@ protected Ignite gridToRunQuery() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformer() throws Exception {
             runContinuousQueryWithTransformer(SKIP_EVT_FILTER, DFLT_ENTRY_CNT, SKIP_KEEP_BINARY, false);
         }
    @@ -151,6 +156,7 @@ public void testContinuousWithTransformer() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerAsync() throws Exception {
             runContinuousQueryWithTransformer(SKIP_EVT_FILTER, DFLT_ENTRY_CNT, SKIP_KEEP_BINARY, true);
         }
    @@ -158,6 +164,7 @@ public void testContinuousWithTransformerAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerAndRegularListener() throws Exception {
             runContinuousQueryWithTransformer(SKIP_EVT_FILTER, DFLT_ENTRY_CNT, SKIP_KEEP_BINARY, false);
         }
    @@ -165,6 +172,7 @@ public void testContinuousWithTransformerAndRegularListener() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerAndRegularListenerAsync() throws Exception {
             runContinuousQueryWithTransformer(SKIP_EVT_FILTER, DFLT_ENTRY_CNT, SKIP_KEEP_BINARY, true);
         }
    @@ -172,6 +180,7 @@ public void testContinuousWithTransformerAndRegularListenerAsync() throws Except
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerWithFilter() throws Exception {
             runContinuousQueryWithTransformer(ADD_EVT_FILTER, DFLT_ENTRY_CNT / 2, SKIP_KEEP_BINARY, false);
         }
    @@ -179,6 +188,7 @@ public void testContinuousWithTransformerWithFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerWithFilterAsync() throws Exception {
             runContinuousQueryWithTransformer(ADD_EVT_FILTER, DFLT_ENTRY_CNT / 2, SKIP_KEEP_BINARY, true);
         }
    @@ -186,6 +196,7 @@ public void testContinuousWithTransformerWithFilterAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerAndRegularListenerWithFilter() throws Exception {
             runContinuousQueryWithTransformer(ADD_EVT_FILTER, DFLT_ENTRY_CNT / 2, KEEP_BINARY, false);
         }
    @@ -193,6 +204,7 @@ public void testContinuousWithTransformerAndRegularListenerWithFilter() throws E
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerAndRegularListenerWithFilterAsync() throws Exception {
             runContinuousQueryWithTransformer(ADD_EVT_FILTER, DFLT_ENTRY_CNT / 2, KEEP_BINARY, true);
         }
    @@ -200,6 +212,7 @@ public void testContinuousWithTransformerAndRegularListenerWithFilterAsync() thr
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerKeepBinary() throws Exception {
             runContinuousQueryWithTransformer(SKIP_EVT_FILTER, DFLT_ENTRY_CNT, KEEP_BINARY, false);
         }
    @@ -207,6 +220,7 @@ public void testContinuousWithTransformerKeepBinary() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerKeepBinaryAsync() throws Exception {
             runContinuousQueryWithTransformer(SKIP_EVT_FILTER, DFLT_ENTRY_CNT, KEEP_BINARY, true);
         }
    @@ -214,6 +228,7 @@ public void testContinuousWithTransformerKeepBinaryAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerAndRegularListenerKeepBinary() throws Exception {
             runContinuousQueryWithTransformer(SKIP_EVT_FILTER, DFLT_ENTRY_CNT, KEEP_BINARY, false);
         }
    @@ -221,6 +236,7 @@ public void testContinuousWithTransformerAndRegularListenerKeepBinary() throws E
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerAndRegularListenerKeepBinaryAsync() throws Exception {
             runContinuousQueryWithTransformer(SKIP_EVT_FILTER, DFLT_ENTRY_CNT, KEEP_BINARY, true);
         }
    @@ -228,6 +244,7 @@ public void testContinuousWithTransformerAndRegularListenerKeepBinaryAsync() thr
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerWithFilterKeepBinary() throws Exception {
             runContinuousQueryWithTransformer(ADD_EVT_FILTER, DFLT_ENTRY_CNT / 2, KEEP_BINARY, false);
         }
    @@ -235,6 +252,7 @@ public void testContinuousWithTransformerWithFilterKeepBinary() throws Exception
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerWithFilterKeepBinaryAsync() throws Exception {
             runContinuousQueryWithTransformer(ADD_EVT_FILTER, DFLT_ENTRY_CNT / 2, KEEP_BINARY, true);
         }
    @@ -242,6 +260,7 @@ public void testContinuousWithTransformerWithFilterKeepBinaryAsync() throws Exce
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerAndRegularListenerWithFilterKeepBinary() throws Exception {
             runContinuousQueryWithTransformer(ADD_EVT_FILTER, DFLT_ENTRY_CNT / 2, KEEP_BINARY, false);
         }
    @@ -249,6 +268,7 @@ public void testContinuousWithTransformerAndRegularListenerWithFilterKeepBinary(
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousWithTransformerAndRegularListenerWithFilterKeepBinaryAsync() throws Exception {
             runContinuousQueryWithTransformer(ADD_EVT_FILTER, DFLT_ENTRY_CNT / 2, KEEP_BINARY, true);
         }
    @@ -256,6 +276,7 @@ public void testContinuousWithTransformerAndRegularListenerWithFilterKeepBinaryA
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTransformerReturnNull() throws Exception {
             Ignite ignite = gridToRunQuery();
     
    @@ -305,6 +326,7 @@ public void testTransformerReturnNull() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testExpired() throws Exception {
             Ignite ignite = gridToRunQuery();
     
    @@ -492,10 +514,10 @@ private static class LocalEventListener implements EventListener {
             /** {@inheritDoc} */
             @Override public void onUpdated(Iterable events) throws CacheEntryListenerException {
                 for (String evt : events) {
    +                cnt.incrementAndGet();
    +
                     if (evt.startsWith(SARAH_CONNOR))
                         cntLatch.countDown();
    -
    -                cnt.incrementAndGet();
                 }
             }
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java
    index 435ccc05eeb31..fda585b4b16c9 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java
    @@ -34,17 +34,19 @@
     import org.apache.ignite.configuration.NearCacheConfiguration;
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
     import org.jetbrains.annotations.NotNull;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
     import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
    @@ -56,6 +58,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheEntryProcessorExternalizableFailedTest extends GridCommonAbstractTest {
         /** */
         private static final int EXPECTED_VALUE = 42;
    @@ -63,9 +66,6 @@ public class CacheEntryProcessorExternalizableFailedTest extends GridCommonAbstr
         /** */
         private static final int WRONG_VALUE = -1;
     
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int NODES = 3;
     
    @@ -73,19 +73,18 @@ public class CacheEntryProcessorExternalizableFailedTest extends GridCommonAbstr
         public static final int ITERATION_CNT = 1;
     
         /** */
    -    public static final int KEYS = 10;
    +    public static final int KEY = 10;
     
         /** */
         private boolean client;
     
         /** */
    -    private boolean failOnWrite = false;
    +    private boolean failOnWrite;
     
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
     
             cfg.setClientMode(client);
    @@ -104,6 +103,13 @@ public class CacheEntryProcessorExternalizableFailedTest extends GridCommonAbstr
             startGrid(getServerNodeCount());
         }
     
    +    /** {@inheritDoc} */
    +    @Override protected void afterTestsStopped() throws Exception {
    +        stopAllGrids();
    +
    +        super.afterTestsStopped();
    +    }
    +
         /** {@inheritDoc} */
         @Override protected void beforeTest() throws Exception {
             super.beforeTest();
    @@ -121,6 +127,7 @@ private int getServerNodeCount() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testOptimisticFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
     
    @@ -142,6 +149,165 @@ public void testOptimisticFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
    +    public void testOptimistic() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +
    +        failOnWrite = true;
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testOptimisticWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +
    +        failOnWrite = true;
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testOptimisticFullSyncWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +
    +        failOnWrite = true;
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testOptimisticOnePhaseCommit() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +
    +        failOnWrite = true;
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testOptimisticOnePhaseCommitWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +
    +        failOnWrite = true;
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testOptimisticOnePhaseCommitFullSync() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +
    +        failOnWrite = true;
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testOptimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +
    +        failOnWrite = true;
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
         public void testPessimisticOnePhaseCommit() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1);
     
    @@ -163,9 +329,10 @@ public void testPessimisticOnePhaseCommit() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticOnePhaseCommitWithNearCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1)
    -            .setNearConfiguration(new NearCacheConfiguration());
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
             doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
     
    @@ -185,6 +352,7 @@ public void testPessimisticOnePhaseCommitWithNearCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticOnePhaseCommitFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1);
     
    @@ -206,9 +374,10 @@ public void testPessimisticOnePhaseCommitFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1)
    -            .setNearConfiguration(new NearCacheConfiguration());
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
             doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
     
    @@ -228,6 +397,7 @@ public void testPessimisticOnePhaseCommitFullSyncWithNearCache() throws Exceptio
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimistic() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2);
     
    @@ -249,9 +419,10 @@ public void testPessimistic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticWithNearCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2)
    -            .setNearConfiguration(new NearCacheConfiguration());
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
             doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
     
    @@ -271,6 +442,7 @@ public void testPessimisticWithNearCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
     
    @@ -292,63 +464,81 @@ public void testPessimisticFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    -    public void testOptimisticOnePhaseCommit() throws Exception {
    -        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1);
    +    @Test
    +    public void testPessimisticFullSyncWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
     
             failOnWrite = true;
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
         }
     
         /**
          * @throws Exception If failed.
          */
    -    public void testOptimisticOnePhaseCommitFullSync() throws Exception {
    -        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1);
    +    @Test
    +    public void testMvccPessimisticOnePhaseCommit() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1).setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +        failOnWrite = true;
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
     
    -        failOnWrite = true;
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
    +    public void testMvccPessimisticOnePhaseCommitWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1).setAtomicityMode(TRANSACTIONAL_SNAPSHOT)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +        failOnWrite = true;
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
         }
     
         /**
          * @throws Exception If failed.
          */
    -    public void testOptimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
    -        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1)
    -            .setNearConfiguration(new NearCacheConfiguration());
    +    public void testMvccPessimisticOnePhaseCommitFullSync() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1).setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +        failOnWrite = true;
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
     
    -        failOnWrite = true;
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
    +    public void testMvccPessimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1).setAtomicityMode(TRANSACTIONAL_SNAPSHOT)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
    -        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
     
    -        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
    +        failOnWrite = true;
     
             doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
         }
    @@ -356,20 +546,29 @@ public void testOptimisticOnePhaseCommitFullSyncWithNearCache() throws Exception
         /**
          * @throws Exception If failed.
          */
    -    public void testOptimistic() throws Exception {
    -        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2);
    +    @Test
    +    public void testMvccPessimistic() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2).setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +        failOnWrite = true;
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
     
    -        failOnWrite = true;
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
    +    public void testMvccPessimisticWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2).setAtomicityMode(TRANSACTIONAL_SNAPSHOT)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
    -        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
     
    -        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
    +        failOnWrite = true;
     
             doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
         }
    @@ -377,20 +576,29 @@ public void testOptimistic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    -    public void testOptimisticFullSyncWithNearCache() throws Exception {
    -        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
    +    @Test
    +    public void testMvccPessimisticFullSync() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2).setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +        failOnWrite = true;
     
    -        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
     
    -        failOnWrite = true;
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
    +    public void testMvccPessimisticFullSyncWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2).setAtomicityMode(TRANSACTIONAL_SNAPSHOT)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
    -        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
     
    -        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
    +        failOnWrite = true;
     
             doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
         }
    @@ -399,6 +607,7 @@ public void testOptimisticFullSyncWithNearCache() throws Exception {
          * @param ccfg Cache configuration.
          * @throws Exception If failed.
          */
    +    @SuppressWarnings("unchecked")
         private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency txConcurrency,
             TransactionIsolation txIsolation) throws Exception {
             IgniteEx cln = grid(getServerNodeCount());
    @@ -412,28 +621,19 @@ private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency tx
             else
                 clnCache = cln.cache(ccfg.getName());
     
    -        putKeys(clnCache, EXPECTED_VALUE);
    +        clnCache.put(KEY, EXPECTED_VALUE);
     
             try {
                 // Explicit tx.
                 for (int i = 0; i < ITERATION_CNT; i++) {
    -                try (final Transaction tx = cln.transactions().txStart(txConcurrency, txIsolation)) {
    -                    putKeys(clnCache, WRONG_VALUE);
    -
    -                    clnCache.invoke(KEYS, createEntryProcessor());
    -
    -                    GridTestUtils.assertThrowsWithCause(new Callable() {
    -                        @Override public Object call() throws Exception {
    -                            tx.commit();
    -
    -                            return null;
    -                        }
    -                    }, UnsupportedOperationException.class);
    -                }
    +                if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT)
    +                    checkExplicitMvccInvoke(cln, clnCache, txConcurrency, txIsolation);
    +                else
    +                    checkExplicitTxInvoke(cln, clnCache, txConcurrency, txIsolation);
     
                     assertNull(cln.transactions().tx());
     
    -                checkKeys(clnCache, EXPECTED_VALUE);
    +                assertEquals(EXPECTED_VALUE, clnCache.get(KEY));
                 }
     
                 // From affinity node.
    @@ -443,32 +643,24 @@ private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency tx
     
                 // Explicit tx.
                 for (int i = 0; i < ITERATION_CNT; i++) {
    -                try (final Transaction tx = grid.transactions().txStart(txConcurrency, txIsolation)) {
    -                    putKeys(cache, WRONG_VALUE);
    -
    -                    cache.invoke(KEYS, createEntryProcessor());
    -
    -                    GridTestUtils.assertThrowsWithCause(new Callable() {
    -                        @Override public Object call() throws Exception {
    -                            tx.commit();
    -
    -                            return null;
    -                        }
    -                    }, UnsupportedOperationException.class);
    -                }
    +                if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT)
    +                    checkExplicitMvccInvoke(cln, clnCache, txConcurrency, txIsolation);
    +                else
    +                    checkExplicitTxInvoke(cln, clnCache, txConcurrency, txIsolation);
     
                     assertNull(cln.transactions().tx());
     
    -                checkKeys(cache, EXPECTED_VALUE);
    +                assertEquals(EXPECTED_VALUE, cache.get(KEY));
                 }
     
                 final IgniteCache clnCache0 = clnCache;
     
                 // Implicit tx.
                 for (int i = 0; i < ITERATION_CNT; i++) {
    +                //noinspection ThrowableNotThrown
                     GridTestUtils.assertThrowsWithCause(new Callable() {
                         @Override public Object call() throws Exception {
    -                        clnCache0.invoke(KEYS, createEntryProcessor());
    +                        clnCache0.invoke(KEY, createEntryProcessor());
     
                             return null;
                         }
    @@ -477,7 +669,7 @@ private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency tx
                     assertNull(cln.transactions().tx());
                 }
     
    -            checkKeys(clnCache, EXPECTED_VALUE);
    +            assertEquals(EXPECTED_VALUE, clnCache.get(KEY));
             }
             catch (Exception e) {
                 e.printStackTrace();
    @@ -488,33 +680,61 @@ private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency tx
         }
     
         /**
    -     * @return Entry processor.
    +     * @param node Ignite node.
    +     * @param cache Node cache.
    +     * @param txConcurrency Transaction concurrency.
    +     * @param txIsolation TransactionIsolation.
          */
    -    @NotNull private EntryProcessor createEntryProcessor() {
    -        return failOnWrite ? new ExternalizableFailedWriteEntryProcessor() :
    -            new ExternalizableFailedReadEntryProcessor();
    +    @SuppressWarnings({"unchecked", "ThrowableNotThrown"})
    +    private void checkExplicitTxInvoke(Ignite node, IgniteCache cache, TransactionConcurrency txConcurrency,
    +        TransactionIsolation txIsolation) {
    +        try (final Transaction tx = node.transactions().txStart(txConcurrency, txIsolation)) {
    +            cache.put(KEY, WRONG_VALUE);
    +
    +            cache.invoke(KEY, createEntryProcessor());
    +
    +            GridTestUtils.assertThrowsWithCause(new Callable() {
    +                @Override public Object call() throws Exception {
    +                    tx.commit();
    +
    +                    return null;
    +                }
    +            }, UnsupportedOperationException.class);
    +        }
         }
     
    -    /**
    -     * @param cache Cache.
    -     * @param val Value.
    -     */
    -    private void putKeys(IgniteCache cache, int val) {
    -        cache.put(KEYS, val);
    +    @SuppressWarnings({"unchecked", "ThrowableNotThrown"})
    +    private void checkExplicitMvccInvoke(Ignite node, IgniteCache cache, TransactionConcurrency txConcurrency,
    +        TransactionIsolation txIsolation) {
    +        try (final Transaction tx = node.transactions().txStart(txConcurrency, txIsolation)) {
    +            cache.put(KEY, WRONG_VALUE);
    +
    +            GridTestUtils.assertThrowsWithCause(new Callable() {
    +                @Override public Object call() throws Exception {
    +                    cache.invoke(KEY, createEntryProcessor());
    +
    +                    fail("Should never happened.");
    +
    +                    tx.commit();
    +
    +                    return null;
    +                }
    +            }, UnsupportedOperationException.class);
    +        }
         }
     
         /**
    -     * @param cache Cache.
    -     * @param expVal Expected value.
    +     * @return Entry processor.
          */
    -    private void checkKeys(IgniteCache cache, int expVal) {
    -        assertEquals(expVal, cache.get(KEYS));
    +    private @NotNull EntryProcessor createEntryProcessor() {
    +        return failOnWrite ? new ExternalizableFailedWriteEntryProcessor() :
    +            new ExternalizableFailedReadEntryProcessor();
         }
     
         /**
          * @return Cache configuration.
          */
    -    private CacheConfiguration cacheConfiguration(CacheWriteSynchronizationMode wrMode, int backup) {
    +    private CacheConfiguration cacheConfiguration(CacheWriteSynchronizationMode wrMode, int backup) {
             return new CacheConfiguration("test-cache-" + wrMode + "-" + backup)
                 .setAtomicityMode(TRANSACTIONAL)
                 .setWriteSynchronizationMode(FULL_SYNC)
    @@ -525,7 +745,7 @@ private CacheConfiguration cacheConfiguration(CacheWriteSynchronizationMode wrMo
          *
          */
         private static class ExternalizableFailedWriteEntryProcessor implements EntryProcessor,
    -        Externalizable{
    +        Externalizable {
             /** */
             public ExternalizableFailedWriteEntryProcessor() {
                 // No-op.
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java
    index 693668556ffb9..2f48cf7ae6a89 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java
    @@ -32,16 +32,19 @@
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.marshaller.jdk.JdkMarshaller;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
     import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
    @@ -53,6 +56,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheEntryProcessorNonSerializableTest extends GridCommonAbstractTest {
         /** */
         private static final int EXPECTED_VALUE = 42;
    @@ -60,9 +64,6 @@ public class CacheEntryProcessorNonSerializableTest extends GridCommonAbstractTe
         /** */
         private static final int WRONG_VALUE = -1;
     
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int NODES = 3;
     
    @@ -70,7 +71,7 @@ public class CacheEntryProcessorNonSerializableTest extends GridCommonAbstractTe
         public static final int ITERATION_CNT = 1;
     
         /** */
    -    public static final int KEYS = 10;
    +    private static final int KEY = 10;
     
         /** */
         private boolean client;
    @@ -79,7 +80,6 @@ public class CacheEntryProcessorNonSerializableTest extends GridCommonAbstractTe
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
     
             cfg.setClientMode(client);
    @@ -100,6 +100,13 @@ public class CacheEntryProcessorNonSerializableTest extends GridCommonAbstractTe
             startGrid(getServerNodeCount());
         }
     
    +    /** {@inheritDoc} */
    +    @Override protected void afterTestsStopped() throws Exception {
    +        stopAllGrids();
    +
    +        super.afterTestsStopped();
    +    }
    +
         /**
          * @return Server nodes.
          */
    @@ -110,6 +117,7 @@ private int getServerNodeCount() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticOnePhaseCommit() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1);
     
    @@ -123,9 +131,10 @@ public void testPessimisticOnePhaseCommit() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticOnePhaseCommitWithNearCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1)
    -            .setNearConfiguration(new NearCacheConfiguration());
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
             doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
     
    @@ -137,6 +146,7 @@ public void testPessimisticOnePhaseCommitWithNearCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticOnePhaseCommitFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1);
     
    @@ -150,9 +160,10 @@ public void testPessimisticOnePhaseCommitFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1)
    -            .setNearConfiguration(new NearCacheConfiguration());
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
             doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
     
    @@ -164,6 +175,7 @@ public void testPessimisticOnePhaseCommitFullSyncWithNearCache() throws Exceptio
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimistic() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2);
     
    @@ -177,9 +189,10 @@ public void testPessimistic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticWithNearCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2)
    -            .setNearConfiguration(new NearCacheConfiguration());
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
             doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
     
    @@ -191,6 +204,7 @@ public void testPessimisticWithNearCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPessimisticFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
     
    @@ -204,6 +218,107 @@ public void testPessimisticFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
    +    public void testPessimisticFullSyncWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
    +    }
    +
    +    /**
    +     */
    +    @Test
    +    public void testMvccPessimisticOnePhaseCommit() {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1).setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
    +    public void testMvccPessimisticOnePhaseCommitWithNearCache() {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1).setAtomicityMode(TRANSACTIONAL_SNAPSHOT)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     */
    +    @Test
    +    public void testMvccPessimisticOnePhaseCommitFullSync() {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1).setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
    +    public void testMvccPessimisticOnePhaseCommitFullSyncWithNearCache() {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1).setAtomicityMode(TRANSACTIONAL_SNAPSHOT)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     */
    +    @Test
    +    public void testMvccPessimistic() {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2).setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
    +    public void testMvccPessimisticWithNearCache() {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2).setAtomicityMode(TRANSACTIONAL_SNAPSHOT)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     */
    +    @Test
    +    public void testMvccPessimisticFullSync() {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2).setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
    +    public void testMvccPessimisticFullSyncWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2).setAtomicityMode(TRANSACTIONAL_SNAPSHOT)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    +
    +        doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
         public void testOptimisticOnePhaseCommit() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1);
     
    @@ -217,6 +332,22 @@ public void testOptimisticOnePhaseCommit() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
    +    public void testOptimisticOnePhaseCommitWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 1)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
         public void testOptimisticOnePhaseCommitFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1);
     
    @@ -230,9 +361,10 @@ public void testOptimisticOnePhaseCommitFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testOptimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1)
    -            .setNearConfiguration(new NearCacheConfiguration());
    +            .setNearConfiguration(new NearCacheConfiguration<>());
     
             doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
     
    @@ -244,6 +376,7 @@ public void testOptimisticOnePhaseCommitFullSyncWithNearCache() throws Exception
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testOptimistic() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2);
     
    @@ -257,6 +390,22 @@ public void testOptimistic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
    +    public void testOptimisticWithNearCache() throws Exception {
    +        CacheConfiguration ccfg = cacheConfiguration(PRIMARY_SYNC, 2)
    +            .setNearConfiguration(new NearCacheConfiguration<>());
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, READ_COMMITTED);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, REPEATABLE_READ);
    +
    +        doTestInvokeTest(ccfg, OPTIMISTIC, SERIALIZABLE);
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
         public void testOptimisticFullSync() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
     
    @@ -270,6 +419,7 @@ public void testOptimisticFullSync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testOptimisticFullSyncWithNearCache() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 2);
     
    @@ -282,10 +432,13 @@ public void testOptimisticFullSyncWithNearCache() throws Exception {
     
         /**
          * @param ccfg Cache configuration.
    -     * @throws Exception If failed.
          */
    +    @SuppressWarnings({"unchecked", "ThrowableNotThrown"})
         private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency txConcurrency,
    -        TransactionIsolation txIsolation) throws Exception {
    +        TransactionIsolation txIsolation) {
    +        if (ccfg.getNearConfiguration() != null)
    +            MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE);
    +
             IgniteEx cln = grid(getServerNodeCount());
     
             grid(0).createCache(ccfg);
    @@ -297,26 +450,17 @@ private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency tx
             else
                 clnCache = cln.cache(ccfg.getName());
     
    -        putKeys(clnCache, EXPECTED_VALUE);
    +        clnCache.put(KEY, EXPECTED_VALUE);
     
             try {
                 // Explicit tx.
                 for (int i = 0; i < ITERATION_CNT; i++) {
    -                try (final Transaction tx = cln.transactions().txStart(txConcurrency, txIsolation)) {
    -                    putKeys(clnCache, WRONG_VALUE);
    -
    -                    clnCache.invoke(KEYS, new NonSerialazibleEntryProcessor());
    -
    -                    GridTestUtils.assertThrowsWithCause(new Callable() {
    -                        @Override public Object call() throws Exception {
    -                            tx.commit();
    +                if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT)
    +                    checkMvccInvoke(cln, clnCache, txConcurrency, txIsolation);
    +                else
    +                    checkTxInvoke(cln, clnCache, txConcurrency, txIsolation);
     
    -                            return null;
    -                        }
    -                    }, NotSerializableException.class);
    -                }
    -
    -                checkKeys(clnCache, EXPECTED_VALUE);
    +                assertEquals(EXPECTED_VALUE, clnCache.get(KEY));
                 }
     
                 // From affinity node.
    @@ -326,21 +470,12 @@ private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency tx
     
                 // Explicit tx.
                 for (int i = 0; i < ITERATION_CNT; i++) {
    -                try (final Transaction tx = grid.transactions().txStart(txConcurrency, txIsolation)) {
    -                    putKeys(cache, WRONG_VALUE);
    -
    -                    cache.invoke(KEYS, new NonSerialazibleEntryProcessor());
    +                if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT)
    +                    checkMvccInvoke(grid, cache, txConcurrency, txIsolation);
    +                else
    +                    checkTxInvoke(grid, cache, txConcurrency, txIsolation);
     
    -                    GridTestUtils.assertThrowsWithCause(new Callable() {
    -                        @Override public Object call() throws Exception {
    -                            tx.commit();
    -
    -                            return null;
    -                        }
    -                    }, NotSerializableException.class);
    -                }
    -
    -                checkKeys(cache, EXPECTED_VALUE);
    +                assertEquals(EXPECTED_VALUE, cache.get(KEY));
                 }
     
                 final IgniteCache clnCache0 = clnCache;
    @@ -348,15 +483,15 @@ private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency tx
                 // Implicit tx.
                 for (int i = 0; i < ITERATION_CNT; i++) {
                     GridTestUtils.assertThrowsWithCause(new Callable() {
    -                    @Override public Object call() throws Exception {
    -                        clnCache0.invoke(KEYS, new NonSerialazibleEntryProcessor());
    +                    @Override public Object call() {
    +                        clnCache0.invoke(KEY, new NonSerialazibleEntryProcessor());
     
                             return null;
                         }
                     }, NotSerializableException.class);
                 }
     
    -            checkKeys(clnCache, EXPECTED_VALUE);
    +            assertEquals(EXPECTED_VALUE, clnCache.get(KEY));
             }
             finally {
                 grid(0).destroyCache(ccfg.getName());
    @@ -364,25 +499,59 @@ private void doTestInvokeTest(CacheConfiguration ccfg, TransactionConcurrency tx
         }
     
         /**
    -     * @param cache Cache.
    -     * @param val Value.
    +     * @param node Grid node.
    +     * @param cache Node cache.
    +     * @param txConcurrency Transaction concurrency.
    +     * @param txIsolation Transaction isolation.
          */
    -    private void putKeys(IgniteCache cache, int val) {
    -        cache.put(KEYS, val);
    +    @SuppressWarnings({"unchecked", "ThrowableNotThrown"})
    +    private void checkTxInvoke(Ignite node, IgniteCache cache, TransactionConcurrency txConcurrency,
    +        TransactionIsolation txIsolation) {
    +        try (final Transaction tx = node.transactions().txStart(txConcurrency, txIsolation)) {
    +            cache.put(KEY, WRONG_VALUE);
    +
    +            cache.invoke(KEY, new NonSerialazibleEntryProcessor());
    +
    +            GridTestUtils.assertThrowsWithCause(new Callable() {
    +                @Override public Object call() {
    +                    tx.commit();
    +
    +                    return null;
    +                }
    +            }, NotSerializableException.class);
    +        }
         }
     
         /**
    -     * @param cache Cache.
    -     * @param expVal Expected value.
    +     * @param node Grid node.
    +     * @param cache Node cache.
    +     * @param txConcurrency Transaction concurrency.
    +     * @param txIsolation Transaction isolation.
          */
    -    private void checkKeys(IgniteCache cache, int expVal) {
    -        assertEquals(expVal, cache.get(KEYS));
    +    @SuppressWarnings({"unchecked", "ThrowableNotThrown"})
    +    private void checkMvccInvoke(Ignite node, IgniteCache cache, TransactionConcurrency txConcurrency,
    +        TransactionIsolation txIsolation) {
    +        try (final Transaction tx = node.transactions().txStart(txConcurrency, txIsolation)) {
    +            cache.put(KEY, WRONG_VALUE);
    +
    +            GridTestUtils.assertThrowsWithCause(new Callable() {
    +                @Override public Object call() {
    +                    cache.invoke(KEY, new NonSerialazibleEntryProcessor());
    +
    +                    fail("Should never happened.");
    +
    +                    tx.commit();
    +
    +                    return null;
    +                }
    +            }, NotSerializableException.class);
    +        }
         }
     
         /**
          * @return Cache configuration.
          */
    -    private CacheConfiguration cacheConfiguration(CacheWriteSynchronizationMode wrMode, int backup) {
    +    private CacheConfiguration cacheConfiguration(CacheWriteSynchronizationMode wrMode, int backup) {
             return new CacheConfiguration("test-cache-" + wrMode + "-" + backup)
                 .setAtomicityMode(TRANSACTIONAL)
                 .setWriteSynchronizationMode(FULL_SYNC)
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationNearEnabledTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationNearEnabledTest.java
    index 0684d1f579548..a45617e9eb9ad 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationNearEnabledTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationNearEnabledTest.java
    @@ -21,10 +21,15 @@
     import org.apache.ignite.cache.CacheMode;
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.NearCacheConfiguration;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheKeepBinaryIterationNearEnabledTest extends CacheKeepBinaryIterationTest {
         /** {@inheritDoc} */
         @Override protected CacheConfiguration cacheConfiguration(
    @@ -40,12 +45,16 @@ public class CacheKeepBinaryIterationNearEnabledTest extends CacheKeepBinaryIter
         }
     
         /** {@inheritDoc} */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
         @Override public void testMvccTxOnHeap() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-7187");
    +        // No-op.
         }
     
         /** {@inheritDoc} */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7187")
    +    @Test
         @Override public void testMvccTxOnHeapLocalEntries() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-7187");
    +        // No-op.
         }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationStoreEnabledTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationStoreEnabledTest.java
    index 910ce4ab0b6c6..af1f582afcf21 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationStoreEnabledTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationStoreEnabledTest.java
    @@ -24,10 +24,14 @@
     import org.apache.ignite.cache.CacheWriteSynchronizationMode;
     import org.apache.ignite.cache.store.CacheStoreAdapter;
     import org.apache.ignite.configuration.CacheConfiguration;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheKeepBinaryIterationStoreEnabledTest extends CacheKeepBinaryIterationTest {
         /** Cache store. */
         private static TestStore store = new TestStore();
    @@ -51,11 +55,13 @@ public class CacheKeepBinaryIterationStoreEnabledTest extends CacheKeepBinaryIte
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testMvccTxOnHeap() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-8582");
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testMvccTxOnHeapLocalEntries() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-8582");
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationTest.java
    index 842b6f4ef17a9..c41467f8c4d06 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationTest.java
    @@ -32,11 +32,11 @@
     import org.apache.ignite.internal.util.tostring.GridToStringInclude;
     import org.apache.ignite.internal.util.typedef.internal.S;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.config.GridTestProperties;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    @@ -47,10 +47,8 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheKeepBinaryIterationTest extends GridCommonAbstractTest {
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int NODES = 3;
     
    @@ -65,7 +63,6 @@ public class CacheKeepBinaryIterationTest extends GridCommonAbstractTest {
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
     
             return cfg;
    @@ -81,6 +78,7 @@ public class CacheKeepBinaryIterationTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicOnHeap() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, ATOMIC);
     
    @@ -93,6 +91,7 @@ public void testAtomicOnHeap() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxOnHeap() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,1, TRANSACTIONAL);
     
    @@ -105,6 +104,7 @@ public void testTxOnHeap() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxOnHeap() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED,1, TRANSACTIONAL_SNAPSHOT);
     
    @@ -117,6 +117,7 @@ public void testMvccTxOnHeap() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAtomicOnHeapLocalEntries() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, ATOMIC);
     
    @@ -129,6 +130,7 @@ public void testAtomicOnHeapLocalEntries() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxOnHeapLocalEntries() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, TRANSACTIONAL);
     
    @@ -141,6 +143,7 @@ public void testTxOnHeapLocalEntries() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMvccTxOnHeapLocalEntries() throws Exception {
             CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, 1, TRANSACTIONAL_SNAPSHOT);
     
    @@ -394,4 +397,4 @@ public QueryTestValue(Integer val) {
                 return S.toString(QueryTestValue.class, this);
             }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ClientReconnectContinuousQueryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ClientReconnectContinuousQueryTest.java
    index 9ec25d343e48c..bbdbb1e1f2399 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ClientReconnectContinuousQueryTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ClientReconnectContinuousQueryTest.java
    @@ -38,10 +38,14 @@
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class ClientReconnectContinuousQueryTest extends GridCommonAbstractTest {
         /** Client index. */
         private static final int CLIENT_IDX = 1;
    @@ -102,6 +106,7 @@ protected CacheAtomicityMode atomicityMode() {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testClientReconnect() throws Exception {
             try {
                 startGrids(2);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryMarshallerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryMarshallerTest.java
    index 44dcc1cd63f4c..4da0074d42cf5 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryMarshallerTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryMarshallerTest.java
    @@ -40,10 +40,14 @@
     import org.apache.ignite.custom.DummyEventFilterFactory;
     import org.apache.ignite.lang.IgniteBiPredicate;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Checks that Optimized Marshaller is not used on any stage of Continuous Query handling.
      */
    +@RunWith(JUnit4.class)
     public class ContinuousQueryMarshallerTest extends GridCommonAbstractTest {
         /** */
         public static final String CACHE_NAME = "test-cache";
    @@ -65,6 +69,7 @@ public class ContinuousQueryMarshallerTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoteFilterFactoryClient() throws Exception {
             check("server", "client");
         }
    @@ -72,6 +77,7 @@ public void testRemoteFilterFactoryClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoteFilterFactoryServer() throws Exception {
             check("server1", "server2");
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryPeerClassLoadingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryPeerClassLoadingTest.java
    index 73d8d0d99fe76..72fa404d3ea85 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryPeerClassLoadingTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryPeerClassLoadingTest.java
    @@ -29,10 +29,14 @@
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.custom.DummyEventFilterFactory;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Checks if filter factory correctly deployed on all nodes.
      */
    +@RunWith(JUnit4.class)
     public class ContinuousQueryPeerClassLoadingTest extends GridCommonAbstractTest {
         /** */
         public static final String CACHE_NAME = "test-cache";
    @@ -55,6 +59,7 @@ public class ContinuousQueryPeerClassLoadingTest extends GridCommonAbstractTest
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoteFilterFactoryClient() throws Exception {
             check("server", "client1", "client2");
         }
    @@ -62,6 +67,7 @@ public void testRemoteFilterFactoryClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoteFilterFactoryServer1() throws Exception {
             check("server1", "server2", "client");
         }
    @@ -69,6 +75,7 @@ public void testRemoteFilterFactoryServer1() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoteFilterFactoryServer2() throws Exception {
             check("server1", "server2", "server3");
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryReassignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryReassignmentTest.java
    new file mode 100644
    index 0000000000000..15d7125a30fac
    --- /dev/null
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryReassignmentTest.java
    @@ -0,0 +1,161 @@
    +/*
    + * 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.
    + */
    +
    +package org.apache.ignite.internal.processors.cache.query.continuous;
    +
    +import java.util.concurrent.atomic.AtomicInteger;
    +import javax.cache.configuration.FactoryBuilder;
    +import javax.cache.event.CacheEntryEvent;
    +import org.apache.ignite.Ignite;
    +import org.apache.ignite.IgniteCache;
    +import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
    +import org.apache.ignite.cache.query.ContinuousQuery;
    +import org.apache.ignite.configuration.CacheConfiguration;
    +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
    +
    +import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
    +
    +/**
    + *
    + */
    +@RunWith(JUnit4.class)
    +public class ContinuousQueryReassignmentTest extends GridCommonAbstractTest {
    +    /** {@inheritDoc} */
    +    @Override protected void afterTest() throws Exception {
    +        stopAllGrids();
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override public boolean isDebug() {
    +        return true;
    +    }
    +
    +    /**
    +     *
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testContinuousQueryNotCalledOnReassignment() throws Exception {
    +        testContinuousQueryNotCalledOnReassignment(false);
    +    }
    +
    +    /**
    +     * @throws Exception if failed.
    +     */
    +    @Test
    +    public void testLocalContinuousQueryNotCalledOnReassignment() throws Exception {
    +        testContinuousQueryNotCalledOnReassignment(true);
    +    }
    +
    +    /**
    +     * @param loc If {@code true}, then local continuous query will be tested.
    +     * @throws Exception If failed.
    +     */
    +    private void testContinuousQueryNotCalledOnReassignment(boolean loc) throws Exception {
    +        Ignite lsnrNode = startGrid(1);
    +        Ignite victim = startGrid(2);
    +
    +        awaitPartitionMapExchange();
    +
    +        CacheConfiguration cacheCfg = new CacheConfiguration<>("cache");
    +        cacheCfg.setBackups(1);
    +        IgniteCache cache = lsnrNode.getOrCreateCache(cacheCfg);
    +
    +        AtomicInteger updCntr = new AtomicInteger();
    +
    +        listenToUpdates(cache, loc, updCntr, null);
    +
    +        // Subscribe on all nodes to receive all updates.
    +        if (loc)
    +            listenToUpdates(victim.cache("cache"), true, updCntr, null);
    +
    +        int updates = 1000;
    +
    +        for (int i = 0; i < updates; i++)
    +            cache.put(i, Integer.toString(i));
    +
    +        assertTrue(
    +            "Failed to wait for continuous query updates. Exp: " + updates + "; actual: " + updCntr.get(),
    +            waitForCondition(() -> updCntr.get() == updates, 10000));
    +
    +        victim.close();
    +
    +        assertFalse("Continuous query is called on reassignment.",
    +            waitForCondition(() -> updCntr.get() > updates, 2000));
    +    }
    +
    +    /**
    +     * @throws Exception If failed.
    +     */
    +    @Test
    +    public void testContinuousQueryWithRemoteFilterNotCalledOnReassignment() throws Exception {
    +        Ignite lsnrNode = startGrid(1);
    +        Ignite victim = startGrid(2);
    +
    +        awaitPartitionMapExchange();
    +
    +        CacheConfiguration cacheCfg = new CacheConfiguration<>("cache");
    +        cacheCfg.setBackups(1);
    +        IgniteCache cache = lsnrNode.getOrCreateCache(cacheCfg);
    +
    +        AtomicInteger updCntr = new AtomicInteger();
    +
    +        CacheEntryEventSerializableFilter filter = (e) -> e.getKey() % 2 == 0;
    +
    +        listenToUpdates(cache, false, updCntr, filter);
    +
    +        int updates = 1000;
    +
    +        for (int i = 0; i < updates; i++)
    +            cache.put(i, Integer.toString(i));
    +
    +        assertTrue(
    +            "Failed to wait for continuous query updates. Exp: " + updates + "; actual: " + updCntr.get(),
    +            waitForCondition(() -> updCntr.get() == updates / 2, 10000));
    +
    +        victim.close();
    +
    +        assertFalse("Continuous query is called on reassignment.",
    +            waitForCondition(() -> updCntr.get() > updates / 2, 2000));
    +    }
    +
    +    /**
    +     * Register a continuous query, that counts updates on the provided cache.
    +     *
    +     * @param cache Cache.
    +     * @param loc If {@code true}, then local continuous query will be registered.
    +     * @param updCntr Update counter.
    +     * @param rmtFilter Remote filter.
    +     */
    +    private void listenToUpdates(IgniteCache cache, boolean loc, AtomicInteger updCntr,
    +        CacheEntryEventSerializableFilter rmtFilter) {
    +
    +        ContinuousQuery cq = new ContinuousQuery<>();
    +        cq.setLocal(loc);
    +        cq.setLocalListener((evts) -> {
    +            for (CacheEntryEvent e : evts)
    +                updCntr.incrementAndGet();
    +        });
    +        if (rmtFilter != null)
    +            cq.setRemoteFilterFactory(FactoryBuilder.factoryOf(rmtFilter));
    +
    +        cache.query(cq);
    +    }
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java
    index 226302ff9d616..74f924853f521 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java
    @@ -36,10 +36,14 @@
     import java.net.MalformedURLException;
     import java.net.URL;
     import java.net.URLClassLoader;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class ContinuousQueryRemoteFilterMissingInClassPathSelfTest extends GridCommonAbstractTest {
         /** URL of classes. */
         private static final URL[] URLS;
    @@ -97,6 +101,7 @@ public class ContinuousQueryRemoteFilterMissingInClassPathSelfTest extends GridC
         /**
          * @throws Exception If fail.
          */
    +    @Test
         public void testWarningMessageOnClientNode() throws Exception {
             ldr = new URLClassLoader(URLS, getClass().getClassLoader());
     
    @@ -121,6 +126,7 @@ public void testWarningMessageOnClientNode() throws Exception {
         /**
          * @throws Exception If fail.
          */
    +    @Test
         public void testNoWarningMessageOnClientNode() throws Exception {
             ldr = new URLClassLoader(URLS, getClass().getClassLoader());
     
    @@ -143,6 +149,7 @@ public void testNoWarningMessageOnClientNode() throws Exception {
         /**
          * @throws Exception If fail.
          */
    +    @Test
         public void testExceptionOnServerNode() throws Exception {
             ldr = new URLClassLoader(URLS, getClass().getClassLoader());
     
    @@ -168,6 +175,7 @@ public void testExceptionOnServerNode() throws Exception {
         /**
          * @throws Exception If fail.
          */
    +    @Test
         public void testNoExceptionOnServerNode() throws Exception {
             ldr = new URLClassLoader(URLS, getClass().getClassLoader());
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
    index 707ef4aead403..7e665842cd06b 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
    @@ -67,12 +67,12 @@
     import org.apache.ignite.lang.IgniteBiInClosure;
     import org.apache.ignite.lang.IgnitePredicate;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.jetbrains.annotations.Nullable;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static java.util.concurrent.TimeUnit.SECONDS;
    @@ -91,10 +91,8 @@
     /**
      * Continuous queries tests.
      */
    +@RunWith(JUnit4.class)
     public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommonAbstractTest implements Serializable {
    -    /** IP finder. */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** Latch timeout. */
         protected static final long LATCH_TIMEOUT = 5000;
     
    @@ -131,12 +129,6 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo
             else
                 cfg.setClientMode(true);
     
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(disco);
    -
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
     
             return cfg;
    @@ -265,7 +257,7 @@ protected void cacheRemove(IgniteCache cache, Integer key) {
         /**
          * @throws Exception If failed.
          */
    -    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
    +    @Test
         public void testIllegalArguments() throws Exception {
             final ContinuousQuery q = new ContinuousQuery<>();
     
    @@ -308,6 +300,7 @@ public void testIllegalArguments() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAllEntries() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -374,6 +367,7 @@ public void testAllEntries() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFilterException() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -400,6 +394,7 @@ public void testFilterException() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTwoQueryListener() throws Exception {
             if (cacheMode() == LOCAL)
                 return;
    @@ -455,6 +450,7 @@ public void testTwoQueryListener() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBackupCleanerTaskFinalize() throws Exception {
             final String CACHE_NAME = "LOCAL_CACHE";
     
    @@ -479,6 +475,7 @@ public void testBackupCleanerTaskFinalize() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRestartQuery() throws Exception {
             if (cacheMode() == LOCAL)
                 return;
    @@ -532,6 +529,7 @@ public void testRestartQuery() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testEntriesByFilter() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -601,6 +599,7 @@ public void testEntriesByFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalNodeOnly() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -672,6 +671,7 @@ public void testLocalNodeOnly() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBuffering() throws Exception {
             if (grid(0).cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getCacheMode() != PARTITIONED)
                 return;
    @@ -757,6 +757,7 @@ public void testBuffering() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTimeInterval() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -837,6 +838,7 @@ public void testTimeInterval() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInitialQuery() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -882,6 +884,7 @@ public void testInitialQuery() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInitialQueryAndUpdates() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -944,6 +947,7 @@ public void testInitialQueryAndUpdates() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLoadCache() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -977,6 +981,7 @@ public void testLoadCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInternalKey() throws Exception {
             if (atomicityMode() == ATOMIC)
                 return;
    @@ -1017,6 +1022,7 @@ public void testInternalKey() throws Exception {
          * @throws Exception If failed.
          */
         @SuppressWarnings("TryFinallyCanBeTryWithResources")
    +    @Test
         public void testNodeJoinWithoutCache() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -1049,6 +1055,7 @@ public void testNodeJoinWithoutCache() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testEvents() throws Exception {
             final AtomicInteger cnt = new AtomicInteger();
             final CountDownLatch latch = new CountDownLatch(50);
    @@ -1144,6 +1151,7 @@ public void testEvents() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testExpired() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME).
                 withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, 1000)));
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicSelfTest.java
    index 36754ec54dca8..bb397b418b559 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicSelfTest.java
    @@ -19,12 +19,16 @@
     
     import org.apache.ignite.cache.CacheAtomicityMode;
     import org.apache.ignite.configuration.NearCacheConfiguration;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     
     /**
      * Continuous queries tests for atomic cache.
      */
    +@RunWith(JUnit4.class)
     public class GridCacheContinuousQueryAtomicSelfTest extends GridCacheContinuousQueryPartitionedSelfTest {
         /** {@inheritDoc} */
         @Override protected CacheAtomicityMode atomicityMode() {
    @@ -37,7 +41,8 @@ public class GridCacheContinuousQueryAtomicSelfTest extends GridCacheContinuousQ
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testInternalKey() throws Exception {
             // No-op.
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
    index 9dca5eaaa49e7..d56c52f0efb17 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
    @@ -48,11 +48,11 @@
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.lang.IgniteFuture;
     import org.apache.ignite.lang.IgniteInClosure;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.Executors.newSingleThreadExecutor;
     import static java.util.concurrent.TimeUnit.MINUTES;
    @@ -62,10 +62,8 @@
      *
      */
     @SuppressWarnings("unchecked")
    +@RunWith(JUnit4.class)
     public class GridCacheContinuousQueryConcurrentTest extends GridCommonAbstractTest {
    -    /** */
    -    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int NODES = 2;
     
    @@ -87,8 +85,6 @@ public class GridCacheContinuousQueryConcurrentTest extends GridCommonAbstractTe
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    -
             cfg.setPeerClassLoadingEnabled(false);
     
             if (igniteInstanceName.endsWith(String.valueOf(NODES)))
    @@ -100,6 +96,7 @@ public class GridCacheContinuousQueryConcurrentTest extends GridCommonAbstractTe
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedTx() throws Exception {
             testRegistration(cacheConfiguration(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL, 1));
         }
    @@ -107,6 +104,7 @@ public void testReplicatedTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedMvccTx() throws Exception {
             testRegistration(cacheConfiguration(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, 1));
         }
    @@ -114,6 +112,7 @@ public void testReplicatedMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRestartReplicated() throws Exception {
             testRestartRegistration(cacheConfiguration(CacheMode.REPLICATED, CacheAtomicityMode.ATOMIC, 2));
         }
    @@ -121,6 +120,7 @@ public void testRestartReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRestartPartition() throws Exception {
             testRestartRegistration(cacheConfiguration(CacheMode.PARTITIONED, CacheAtomicityMode.ATOMIC, 2));
         }
    @@ -128,6 +128,7 @@ public void testRestartPartition() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRestartPartitionTx() throws Exception {
             testRestartRegistration(cacheConfiguration(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL, 2));
         }
    @@ -135,6 +136,7 @@ public void testRestartPartitionTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRestartPartitionMvccTx() throws Exception {
             testRestartRegistration(cacheConfiguration(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, 2));
         }
    @@ -142,6 +144,7 @@ public void testRestartPartitionMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedAtomic() throws Exception {
             testRegistration(cacheConfiguration(CacheMode.REPLICATED, CacheAtomicityMode.ATOMIC, 2));
         }
    @@ -149,6 +152,7 @@ public void testReplicatedAtomic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionTx() throws Exception {
             testRegistration(cacheConfiguration(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL, 2));
         }
    @@ -156,6 +160,7 @@ public void testPartitionTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionMvccTx() throws Exception {
             testRegistration(cacheConfiguration(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, 2));
         }
    @@ -163,6 +168,7 @@ public void testPartitionMvccTx() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionAtomic() throws Exception {
             testRegistration(cacheConfiguration(CacheMode.PARTITIONED, CacheAtomicityMode.ATOMIC, 2));
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryMultiNodesFilteringTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryMultiNodesFilteringTest.java
    index 0eb2e87ee4192..27734c03ecff2 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryMultiNodesFilteringTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryMultiNodesFilteringTest.java
    @@ -50,11 +50,11 @@
     import org.apache.ignite.internal.util.typedef.PA;
     import org.apache.ignite.lang.IgnitePredicate;
     import org.apache.ignite.resources.IgniteInstanceResource;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
    @@ -63,10 +63,8 @@
     
     /** */
     @SuppressWarnings("unchecked")
    +@RunWith(JUnit4.class)
     public class GridCacheContinuousQueryMultiNodesFilteringTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int SERVER_GRIDS_COUNT = 6;
     
    @@ -89,6 +87,7 @@ public class GridCacheContinuousQueryMultiNodesFilteringTest extends GridCommonA
         }
     
         /** */
    +    @Test
         public void testFiltersAndListeners() throws Exception {
             for (int i = 1; i <= SERVER_GRIDS_COUNT; i++)
                 startGrid(i, false);
    @@ -146,6 +145,7 @@ public void testFiltersAndListeners() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testWithNodeFilter() throws Exception {
             List qryCursors = new ArrayList<>();
     
    @@ -251,8 +251,6 @@ private Ignite startGrid(final int idx, boolean isClientMode) throws Exception {
     
             IgniteConfiguration cfg = optimize(getConfiguration(igniteInstanceName)).setClientMode(isClientMode);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -
             cfg.setUserAttributes(Collections.singletonMap("idx", idx));
     
             Ignite node = startGrid(igniteInstanceName, cfg);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryNodesFilteringTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryNodesFilteringTest.java
    index e444a72f4341c..2b3e12f20f003 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryNodesFilteringTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryNodesFilteringTest.java
    @@ -31,18 +31,16 @@
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.lang.IgnitePredicate;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridStringLogger;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /** */
     @SuppressWarnings("unused")
    +@RunWith(JUnit4.class)
     public class GridCacheContinuousQueryNodesFilteringTest extends GridCommonAbstractTest implements Serializable {
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final String ENTRY_FILTER_CLS_NAME = "org.apache.ignite.tests.p2p.CacheDeploymentEntryEventFilter";
     
    @@ -51,7 +49,7 @@ public class GridCacheContinuousQueryNodesFilteringTest extends GridCommonAbstra
          *
          * @throws Exception if failed.
          */
    -    @SuppressWarnings("EmptyTryBlock")
    +    @Test
         public void testNodeWithoutAttributeExclusion() throws Exception {
             try (Ignite node1 = startNodeWithCache()) {
                 try (Ignite node2 = startGrid("node2", getConfiguration("node2", false, null))) {
    @@ -65,6 +63,7 @@ public void testNodeWithoutAttributeExclusion() throws Exception {
          *
          * @throws Exception if failed.
          */
    +    @Test
         public void testNodeWithAttributeFailure() throws Exception {
             try (Ignite node1 = startNodeWithCache()) {
                 GridStringLogger log = new GridStringLogger();
    @@ -129,8 +128,6 @@ private Ignite startNodeWithCache() throws Exception {
         private IgniteConfiguration getConfiguration(String name, boolean setAttr, GridStringLogger log) throws Exception {
             IgniteConfiguration cfg = optimize(getConfiguration(name));
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -
             if (setAttr)
                 cfg.setUserAttributes(Collections.singletonMap("node-type", "data"));
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionedOnlySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionedOnlySelfTest.java
    index 8cf26acb669e6..fe282a845aaeb 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionedOnlySelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionedOnlySelfTest.java
    @@ -19,12 +19,16 @@
     
     import org.apache.ignite.cache.CacheMode;
     import org.apache.ignite.configuration.NearCacheConfiguration;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
     
     /**
      * Continuous queries tests for partitioned cache.
      */
    +@RunWith(JUnit4.class)
     public class GridCacheContinuousQueryPartitionedOnlySelfTest extends GridCacheContinuousQueryAbstractSelfTest {
         /** {@inheritDoc} */
         @Override protected NearCacheConfiguration nearConfiguration() {
    @@ -42,7 +46,8 @@ public class GridCacheContinuousQueryPartitionedOnlySelfTest extends GridCacheCo
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testInternalKey() throws Exception {
             // Disabled since data structures are not allowed in partitioned only mode.
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicSelfTest.java
    index 4432eae0f3a26..27fb0fdd44dc6 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicSelfTest.java
    @@ -18,12 +18,16 @@
     package org.apache.ignite.internal.processors.cache.query.continuous;
     
     import org.apache.ignite.cache.CacheAtomicityMode;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     
     /**
      * Continuous queries tests for replicated atomic cache.
      */
    +@RunWith(JUnit4.class)
     public class GridCacheContinuousQueryReplicatedAtomicSelfTest extends GridCacheContinuousQueryReplicatedSelfTest {
         /** {@inheritDoc} */
         @Override protected CacheAtomicityMode atomicityMode() {
    @@ -31,7 +35,8 @@ public class GridCacheContinuousQueryReplicatedAtomicSelfTest extends GridCacheC
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testInternalKey() throws Exception {
             // No-op.
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedSelfTest.java
    index 863bc804c1124..b4043b0b2c3ed 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedSelfTest.java
    @@ -27,6 +27,9 @@
     import org.apache.ignite.cache.CacheMode;
     import org.apache.ignite.cache.query.ContinuousQuery;
     import org.apache.ignite.cache.query.QueryCursor;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static org.apache.ignite.cache.CacheMode.REPLICATED;
    @@ -34,6 +37,7 @@
     /**
      * Continuous queries tests for replicated cache.
      */
    +@RunWith(JUnit4.class)
     public class GridCacheContinuousQueryReplicatedSelfTest extends GridCacheContinuousQueryAbstractSelfTest {
         /** {@inheritDoc} */
         @Override protected CacheMode cacheMode() {
    @@ -48,6 +52,7 @@ public class GridCacheContinuousQueryReplicatedSelfTest extends GridCacheContinu
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoteNodeCallback() throws Exception {
             IgniteCache cache1 = grid(0).cache(DEFAULT_CACHE_NAME);
             IgniteCache cache2 = grid(1).cache(DEFAULT_CACHE_NAME);
    @@ -87,6 +92,7 @@ public void testRemoteNodeCallback() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testCrossCallback() throws Exception {
             // Prepare.
             IgniteCache cache1 = grid(0).cache(DEFAULT_CACHE_NAME);
    @@ -132,4 +138,4 @@ public void testCrossCallback() throws Exception {
                 assert latch2.await(LATCH_TIMEOUT, MILLISECONDS);
             }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java
    index d02c6ff67fcb3..ab6a76ce1fab1 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java
    @@ -21,7 +21,6 @@
     import java.util.concurrent.CountDownLatch;
     import java.util.concurrent.TimeUnit;
     import java.util.concurrent.atomic.AtomicInteger;
    -import javax.cache.Cache;
     import javax.cache.event.CacheEntryEvent;
     import javax.cache.event.CacheEntryListenerException;
     import javax.cache.event.CacheEntryUpdatedListener;
    @@ -33,19 +32,16 @@
     import org.apache.ignite.cache.query.ContinuousQuery;
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Test for replicated cache with one node.
      */
    -@SuppressWarnings("Duplicates")
    +@RunWith(JUnit4.class)
     public class GridCacheContinuousQueryReplicatedTxOneNodeTest extends GridCommonAbstractTest {
    -    /** IP finder. */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    @@ -63,12 +59,6 @@ public class GridCacheContinuousQueryReplicatedTxOneNodeTest extends GridCommonA
     
             cfg.setCacheConfiguration(cacheCfg);
     
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(disco);
    -
             return cfg;
         }
     
    @@ -89,6 +79,7 @@ protected CacheMode cacheMode() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocal() throws Exception {
             if (cacheMode() == CacheMode.REPLICATED)
                 doTest(true);
    @@ -97,6 +88,7 @@ public void testLocal() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDistributed() throws Exception {
             doTest(false);
         }
    @@ -104,6 +96,7 @@ public void testDistributed() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalOneNode() throws Exception {
             doTestOneNode(true);
         }
    @@ -111,6 +104,7 @@ public void testLocalOneNode() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDistributedOneNode() throws Exception {
             doTestOneNode(false);
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxSelfTest.java
    index 91b6b9ccdf309..84b006c82ddf2 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxSelfTest.java
    @@ -20,12 +20,16 @@
     import org.apache.ignite.cache.CacheAtomicityMode;
     import org.apache.ignite.cache.CacheMode;
     import org.apache.ignite.configuration.NearCacheConfiguration;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
     
     /**
      * Continuous queries tests for atomic cache.
      */
    +@RunWith(JUnit4.class)
     public class GridCacheContinuousQueryTxSelfTest extends GridCacheContinuousQueryPartitionedSelfTest {
         /** {@inheritDoc} */
         @Override protected CacheAtomicityMode atomicityMode() {
    @@ -43,7 +47,8 @@ public class GridCacheContinuousQueryTxSelfTest extends GridCacheContinuousQuery
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testInternalKey() throws Exception {
             // No-op.
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryBackupQueueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryBackupQueueTest.java
    index a8f0d71cede3c..dc9dd576b94b1 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryBackupQueueTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryBackupQueueTest.java
    @@ -39,11 +39,11 @@
     import org.apache.ignite.internal.IgniteKernal;
     import org.apache.ignite.internal.processors.continuous.GridContinuousHandler;
     import org.apache.ignite.internal.processors.continuous.GridContinuousProcessor;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
    @@ -52,10 +52,8 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteCacheContinuousQueryBackupQueueTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** Keys count. */
         private static final int KEYS_COUNT = 1024;
     
    @@ -89,8 +87,6 @@ public class IgniteCacheContinuousQueryBackupQueueTest extends GridCommonAbstrac
     
             cfg.setClientMode(client);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    -
             DataStorageConfiguration memCfg = new DataStorageConfiguration();
             memCfg.setPageSize(16 * 1024);
     
    @@ -130,6 +126,7 @@ protected CacheAtomicityMode atomicityMode() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBackupQueue() throws Exception {
             final CacheEventListener lsnr = new CacheEventListener();
     
    @@ -153,6 +150,7 @@ public void testBackupQueue() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testManyQueryBackupQueue() throws Exception {
             List qryCursors = new ArrayList<>();
     
    @@ -185,6 +183,7 @@ public void testManyQueryBackupQueue() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBackupQueueAutoUnsubscribeFalse() throws Exception {
             try {
                 client = true;
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryClientReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryClientReconnectTest.java
    index 906cc7d8d190c..f8613964de114 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryClientReconnectTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryClientReconnectTest.java
    @@ -30,6 +30,9 @@
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.IgniteClientReconnectAbstractTest;
     import org.apache.ignite.resources.LoggerResource;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.SECONDS;
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
    @@ -39,6 +42,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteCacheContinuousQueryClientReconnectTest extends IgniteClientReconnectAbstractTest {
         /** {@inheritDoc} */
         @Override protected int serverCount() {
    @@ -75,6 +79,7 @@ protected CacheAtomicityMode atomicMode() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReconnectClient() throws Exception {
             Ignite client = grid(serverCount());
     
    @@ -118,6 +123,7 @@ public void testReconnectClient() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReconnectClientAndLeftRouter() throws Exception {
             if (!tcpDiscovery())
                 return;
    @@ -187,4 +193,4 @@ private static class CacheEventListener implements CacheEntryUpdatedListener cache = jcache();
     
    @@ -177,6 +186,7 @@ public void testWriteThrough() throws Exception {
         }
     
         /** @throws Exception If test failed. */
    +    @Test
         public void testReadThrough() throws Exception {
             IgniteCache cache = jcache();
     
    @@ -269,6 +279,7 @@ public void testReadThrough() throws Exception {
         }
     
         /** @throws Exception If failed. */
    +    @Test
         public void testMultithreaded() throws Exception {
             final ConcurrentMap> perThread = new ConcurrentHashMap<>();
     
    @@ -277,7 +288,6 @@ public void testMultithreaded() throws Exception {
             final IgniteCache cache = jcache();
     
             IgniteInternalFuture fut = multithreadedAsync(new Runnable() {
    -            @SuppressWarnings({"NullableProblems"})
                 @Override public void run() {
                     // Initialize key set for this thread.
                     Set set = new HashSet<>();
    @@ -354,4 +364,4 @@ private void checkLastMethod(@Nullable String mtd) {
             }
         }
     
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreLocalTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreLocalTest.java
    index 59dd4b41930bf..f35b674156ed0 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreLocalTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreLocalTest.java
    @@ -18,13 +18,21 @@
     package org.apache.ignite.internal.processors.cache.store;
     
     import org.apache.ignite.cache.CacheMode;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     
     /**
      * Tests {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore} in grid configuration.
      */
     public class GridCacheWriteBehindStoreLocalTest extends GridCacheWriteBehindStoreAbstractTest {
    +    /** {@inheritDoc} */
    +    @Override public void setUp() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE);
    +
    +        super.setUp();
    +    }
    +
         /** {@inheritDoc} */
         @Override protected CacheMode cacheMode() {
             return CacheMode.LOCAL;
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreMultithreadedSelfTest.java
    index 4fce452a327f1..0820c5c8a46a7 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreMultithreadedSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreMultithreadedSelfTest.java
    @@ -23,16 +23,21 @@
     import java.util.Set;
     import org.apache.ignite.internal.IgniteInterruptedCheckedException;
     import org.apache.ignite.internal.util.typedef.internal.U;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Multithreaded tests for {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore}.
      */
    +@RunWith(JUnit4.class)
     public class GridCacheWriteBehindStoreMultithreadedSelfTest extends GridCacheWriteBehindStoreAbstractSelfTest {
         /**
          * This test performs complex set of operations on store with coalescing from multiple threads.
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testPutGetRemoveWithCoalescing() throws Exception {
             testPutGetRemove(true);
         }
    @@ -42,6 +47,7 @@ public void testPutGetRemoveWithCoalescing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testPutGetRemoveWithoutCoalescing() throws Exception {
             testPutGetRemove(false);
         }
    @@ -86,6 +92,7 @@ private void testPutGetRemove(boolean writeCoalescing) throws Exception {
          *
          * @throws Exception if failed.
          */
    +    @Test
         public void testStoreFailureWithCoalescing() throws Exception {
             testStoreFailure(true);
         }
    @@ -95,6 +102,7 @@ public void testStoreFailureWithCoalescing() throws Exception {
          *
          * @throws Exception if failed.
          */
    +    @Test
         public void testStoreFailureWithoutCoalescing() throws Exception {
             testStoreFailure(false);
         }
    @@ -162,6 +170,7 @@ private void testStoreFailure(boolean writeCoalescing) throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testFlushFromTheSameThreadWithCoalescing() throws Exception {
             testFlushFromTheSameThread(true);
         }
    @@ -172,6 +181,7 @@ public void testFlushFromTheSameThreadWithCoalescing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testFlushFromTheSameThreadWithoutCoalescing() throws Exception {
             testFlushFromTheSameThread(false);
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
    index de61058f0a4b8..cdcc69d7413b7 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
    @@ -32,11 +32,12 @@
     import org.apache.ignite.internal.IgniteInterruptedCheckedException;
     import org.apache.ignite.internal.processors.cache.GridCacheTestStore;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
     import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
    @@ -45,13 +46,11 @@
     /**
      * Tests write-behind store with near and dht commit option.
      */
    +@RunWith(JUnit4.class)
     public class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest extends GridCommonAbstractTest {
         /** Grids to start. */
         private static final int GRID_CNT = 5;
     
    -    /** Ip finder. */
    -    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** Flush frequency. */
         public static final int WRITE_BEHIND_FLUSH_FREQ = 1000;
     
    @@ -66,12 +65,6 @@ public class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest extends GridC
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
     
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(ipFinder);
    -
    -        c.setDiscoverySpi(disco);
    -
             CacheConfiguration cc = defaultCacheConfiguration();
     
             cc.setCacheMode(CacheMode.PARTITIONED);
    @@ -92,6 +85,11 @@ public class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest extends GridC
             return c;
         }
     
    +    /** {@inheritDoc} */
    +    @Override protected void beforeTest() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);
    +    }
    +
         /** {@inheritDoc} */
         @Override protected void afterTestsStopped() throws Exception {
             stores = null;
    @@ -114,6 +112,7 @@ private void prepare() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testSingleWritesOnDhtNode() throws Exception {
             checkSingleWrites();
         }
    @@ -121,6 +120,7 @@ public void testSingleWritesOnDhtNode() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBatchWritesOnDhtNode() throws Exception {
             checkBatchWrites();
         }
    @@ -128,6 +128,7 @@ public void testBatchWritesOnDhtNode() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTxWritesOnDhtNode() throws Exception {
             checkTxWrites();
         }
    @@ -213,4 +214,4 @@ private void checkWrites() throws IgniteInterruptedCheckedException {
             for (int i = 0; i < 100; i++)
                 assertTrue(allKeys.contains(i));
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
    index 538f13540ca9f..9a03b166b8e89 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
    @@ -29,16 +29,21 @@
     import org.apache.ignite.internal.util.typedef.F;
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.jsr166.ConcurrentLinkedHashMap;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * This class provides basic tests for {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore}.
      */
    +@RunWith(JUnit4.class)
     public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStoreAbstractSelfTest {
         /**
          * Tests correct store (with write coalescing) shutdown when underlying store fails.
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testShutdownWithFailureWithCoalescing() throws Exception {
             testShutdownWithFailure(true);
         }
    @@ -48,6 +53,7 @@ public void testShutdownWithFailureWithCoalescing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testShutdownWithFailureWithoutCoalescing() throws Exception {
             testShutdownWithFailure(false);
         }
    @@ -93,6 +99,7 @@ private void testShutdownWithFailure(final boolean writeCoalescing) throws Excep
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testSimpleStoreWithCoalescing() throws Exception {
             testSimpleStore(true);
         }
    @@ -102,6 +109,7 @@ public void testSimpleStoreWithCoalescing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testSimpleStoreWithoutCoalescing() throws Exception {
             testSimpleStore(false);
         }
    @@ -112,6 +120,7 @@ public void testSimpleStoreWithoutCoalescing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testSimpleStoreFlushFrequencyWithoutCoalescing() throws Exception {
             initStore(1, false);
     
    @@ -177,6 +186,7 @@ private void testSimpleStore(boolean writeCoalescing) throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testValuePropagationWithCoalescing() throws Exception {
             testValuePropagation(true);
         }
    @@ -187,6 +197,7 @@ public void testValuePropagationWithCoalescing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testValuePropagationWithoutCoalescing() throws Exception {
             testValuePropagation(false);
         }
    @@ -234,6 +245,7 @@ private void testValuePropagation(boolean writeCoalescing) throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousPutWithCoalescing() throws Exception {
             testContinuousPut(true);
         }
    @@ -243,6 +255,7 @@ public void testContinuousPutWithCoalescing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testContinuousPutWithoutCoalescing() throws Exception {
             testContinuousPut(false);
         }
    @@ -320,6 +333,7 @@ private void testContinuousPut(boolean writeCoalescing) throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testShutdownWithCoalescing() throws Exception {
             testShutdown(true);
         }
    @@ -330,6 +344,7 @@ public void testShutdownWithCoalescing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testShutdownWithoutCoalescing() throws Exception {
             testShutdown(false);
         }
    @@ -390,6 +405,7 @@ private void testShutdown(boolean writeCoalescing) throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testBatchApplyWithCoalescing() throws Exception {
             testBatchApply(true);
         }
    @@ -400,6 +416,7 @@ public void testBatchApplyWithCoalescing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testBatchApplyWithoutCoalescing() throws Exception {
             testBatchApply(false);
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgniteCacheWriteBehindNoUpdateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgniteCacheWriteBehindNoUpdateSelfTest.java
    index ce26c2ce96b5d..49acd92cb04b4 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgniteCacheWriteBehindNoUpdateSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgniteCacheWriteBehindNoUpdateSelfTest.java
    @@ -39,10 +39,14 @@
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteCacheWriteBehindNoUpdateSelfTest extends GridCommonAbstractTest {
         /** */
         private static final String THROTTLES_CACHE_NAME = "test";
    @@ -83,6 +87,7 @@ public class IgniteCacheWriteBehindNoUpdateSelfTest extends GridCommonAbstractTe
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testEntryProcessorNoUpdate() throws Exception {
             IgniteCache cache = ignite(0).cache(THROTTLES_CACHE_NAME);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgnteCacheClientWriteBehindStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgnteCacheClientWriteBehindStoreAbstractTest.java
    index a64104ea56ed6..25be9d26d0bab 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgnteCacheClientWriteBehindStoreAbstractTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgnteCacheClientWriteBehindStoreAbstractTest.java
    @@ -28,11 +28,28 @@
     import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest;
     import org.apache.ignite.internal.util.lang.GridAbsPredicate;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Tests that write behind store is updated if client does not have store.
      */
    +@RunWith(JUnit4.class)
     public abstract class IgnteCacheClientWriteBehindStoreAbstractTest extends IgniteCacheAbstractTest {
    +    /** {@inheritDoc} */
    +    @Override protected void beforeTestsStarted() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);
    +
    +        super.beforeTestsStarted();
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override protected void beforeTest() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);
    +    }
    +
         /** {@inheritDoc} */
         @Override protected int gridCount() {
             return 3;
    @@ -83,6 +100,7 @@ public abstract class IgnteCacheClientWriteBehindStoreAbstractTest extends Ignit
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testClientWithoutStore() throws Exception {
             Ignite client = grid(2);
     
    @@ -103,4 +121,4 @@ public void testClientWithoutStore() throws Exception {
     
             assertEquals(1000, storeMap.size());
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgnteCacheClientWriteBehindStoreNonCoalescingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgnteCacheClientWriteBehindStoreNonCoalescingTest.java
    index 4ffa973ff90e6..a515007b339b7 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgnteCacheClientWriteBehindStoreNonCoalescingTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/IgnteCacheClientWriteBehindStoreNonCoalescingTest.java
    @@ -40,12 +40,16 @@
     import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
     import org.apache.ignite.lang.IgniteBiInClosure;
     import org.apache.ignite.lang.IgniteFuture;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     
     /**
      * This class provides non write coalescing tests for {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore}.
      */
    +@RunWith(JUnit4.class)
     public class IgnteCacheClientWriteBehindStoreNonCoalescingTest extends IgniteCacheAbstractTest {
         /** {@inheritDoc} */
         @Override protected int gridCount() {
    @@ -83,6 +87,7 @@ public class IgnteCacheClientWriteBehindStoreNonCoalescingTest extends IgniteCac
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonCoalescingIncrementing() throws Exception {
             Ignite ignite = grid(0);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/AbstractTransactionIntergrityTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/AbstractTransactionIntergrityTest.java
    index fe27e6e119d24..cb05af6b25be4 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/AbstractTransactionIntergrityTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/AbstractTransactionIntergrityTest.java
    @@ -33,6 +33,7 @@
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.IgniteException;
     import org.apache.ignite.cache.CacheMode;
    +import org.apache.ignite.cache.affinity.Affinity;
     import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
     import org.apache.ignite.cache.query.annotations.QuerySqlField;
     import org.apache.ignite.cluster.ClusterNode;
    @@ -40,15 +41,12 @@
     import org.apache.ignite.configuration.DataRegionConfiguration;
     import org.apache.ignite.configuration.DataStorageConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
    +import org.apache.ignite.configuration.WALMode;
     import org.apache.ignite.failure.FailureHandler;
     import org.apache.ignite.failure.StopNodeFailureHandler;
     import org.apache.ignite.internal.IgniteEx;
    -import org.apache.ignite.internal.TestRecordingCommunicationSpi;
     import org.apache.ignite.internal.util.typedef.G;
     import org.apache.ignite.lang.IgniteUuid;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.jetbrains.annotations.NotNull;
    @@ -66,14 +64,11 @@
      * This test can be extended to emulate failover scenarios during transactional operations on the grid.
      */
     public class AbstractTransactionIntergrityTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** Count of accounts in one thread. */
         private static final int DFLT_ACCOUNTS_CNT = 32;
     
         /** Count of threads and caches. */
    -    private static final int DFLT_TX_THREADS_CNT = 20;
    +    private static final int DFLT_TX_THREADS_CNT = Runtime.getRuntime().availableProcessors();
     
         /** Count of nodes to start. */
         private static final int DFLT_NODES_CNT = 3;
    @@ -126,16 +121,6 @@ protected boolean persistent() {
             return true;
         }
     
    -    /**
    -     * @return Flag enables cross-node transactions,
    -     *         when primary partitions participating in transaction spreaded across several cluster nodes.
    -     */
    -    protected boolean crossNodeTransactions() {
    -        // Commit error during cross node transactions breaks transaction integrity
    -        // TODO: https://issues.apache.org/jira/browse/IGNITE-9086
    -        return false;
    -    }
    -
         /** {@inheritDoc} */
         @Override protected FailureHandler getFailureHandler(String igniteInstanceName) {
             return new StopNodeFailureHandler();
    @@ -147,15 +132,14 @@ protected boolean crossNodeTransactions() {
     
             cfg.setConsistentId(name);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -        cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
    -        cfg.setLocalHost("127.0.0.1");
    -
             cfg.setDataStorageConfiguration(new DataStorageConfiguration()
                 .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
    -                .setMaxSize(256 * 1024 * 1024)
    -                .setPersistenceEnabled(persistent()))
    -        );
    +                    .setPersistenceEnabled(persistent())
    +                    .setMaxSize(50 * 1024 * 1024)
    +            )
    +            .setWalSegmentSize(16 * 1024 * 1024)
    +            .setPageSize(1024)
    +            .setWalMode(WALMode.LOG_ONLY));
     
             CacheConfiguration[] cacheConfigurations = new CacheConfiguration[txThreadsCount()];
     
    @@ -178,6 +162,8 @@ protected boolean crossNodeTransactions() {
     
             cfg.setCacheConfiguration(cacheConfigurations);
     
    +        cfg.setFailureDetectionTimeout(30_000);
    +
             return cfg;
         }
     
    @@ -219,8 +205,11 @@ protected boolean crossNodeTransactions() {
     
         /**
          * Test transfer amount.
    +     *
    +     * @param failoverScenario Scenario.
    +     * @param colocatedAccounts {@code True} to use colocated on same primary node accounts.
          */
    -    public void doTestTransferAmount(FailoverScenario failoverScenario) throws Exception {
    +    public void doTestTransferAmount(FailoverScenario failoverScenario, boolean colocatedAccounts) throws Exception {
             failoverScenario.beforeNodesStarted();
     
             //given: started some nodes with client.
    @@ -230,26 +219,26 @@ public void doTestTransferAmount(FailoverScenario failoverScenario) throws Excep
     
             igniteClient.cluster().active(true);
     
    -        int[] initAmount = new int[txThreadsCount()];
    +        int[] initAmounts = new int[txThreadsCount()];
             completedTxs = new ConcurrentLinkedHashMap[txThreadsCount()];
     
             //and: fill all accounts on all caches and calculate total amount for every cache.
             for (int cachePrefixIdx = 0; cachePrefixIdx < txThreadsCount(); cachePrefixIdx++) {
                 IgniteCache cache = igniteClient.getOrCreateCache(cacheName(cachePrefixIdx));
     
    -            AtomicInteger coinsCounter = new AtomicInteger();
    +            AtomicInteger coinsCntr = new AtomicInteger();
     
                 try (Transaction tx = igniteClient.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
                     for (int accountId = 0; accountId < accountsCount(); accountId++) {
    -                    Set initialAmount = generateCoins(coinsCounter, 5);
    +                    Set initAmount = generateCoins(coinsCntr, 5);
     
    -                    cache.put(accountId, new AccountState(accountId, tx.xid(), initialAmount));
    +                    cache.put(accountId, new AccountState(accountId, tx.xid(), initAmount));
                     }
     
                     tx.commit();
                 }
     
    -            initAmount[cachePrefixIdx] = coinsCounter.get();
    +            initAmounts[cachePrefixIdx] = coinsCntr.get();
                 completedTxs[cachePrefixIdx] = new ConcurrentLinkedHashMap();
             }
     
    @@ -259,7 +248,8 @@ public void doTestTransferAmount(FailoverScenario failoverScenario) throws Excep
             ArrayList transferThreads = new ArrayList<>();
     
             for (int i = 0; i < txThreadsCount(); i++) {
    -            transferThreads.add(new TransferAmountTxThread(firstTransactionDone, igniteClient, cacheName(i), i));
    +            transferThreads.add(new TransferAmountTxThread(firstTransactionDone,
    +                igniteClient, cacheName(i), i, colocatedAccounts));
     
                 transferThreads.get(i).start();
             }
    @@ -268,13 +258,12 @@ public void doTestTransferAmount(FailoverScenario failoverScenario) throws Excep
     
             failoverScenario.afterFirstTransaction();
     
    -        for (Thread thread : transferThreads) {
    +        for (Thread thread : transferThreads)
                 thread.join();
    -        }
     
             failoverScenario.afterTransactionsFinished();
     
    -        consistencyCheck(initAmount);
    +        consistencyCheck(initAmounts);
         }
     
         /**
    @@ -385,11 +374,11 @@ public AccountState addCoins(IgniteUuid txId, Set coinsToAdd) {
     
             /**
              * @param txId Transaction id.
    -         * @param coinsToRemove Coins to remove from current account.
    +         * @param coinsToRmv Coins to remove from current account.
              * @return Account state with removed coins.
              */
    -        public AccountState removeCoins(IgniteUuid txId, Set coinsToRemove) {
    -            return new AccountState(accId, txId, Sets.difference(coins, coinsToRemove).immutableCopy());
    +        public AccountState removeCoins(IgniteUuid txId, Set coinsToRmv) {
    +            return new AccountState(accId, txId, Sets.difference(coins, coinsToRmv).immutableCopy());
             }
     
             /** {@inheritDoc} */
    @@ -418,11 +407,11 @@ public AccountState removeCoins(IgniteUuid txId, Set coinsToRemove) {
         /**
          * @param coinsNum Coins number.
          */
    -    private Set generateCoins(AtomicInteger coinsCounter, int coinsNum) {
    +    private Set generateCoins(AtomicInteger coinsCntr, int coinsNum) {
             Set res = new HashSet<>();
     
             for (int i = 0; i < coinsNum; i++)
    -            res.add(coinsCounter.incrementAndGet());
    +            res.add(coinsCntr.incrementAndGet());
     
             return res;
         }
    @@ -479,23 +468,35 @@ public TxState(AccountState before1, AccountState before2, AccountState after1,
         private class TransferAmountTxThread extends Thread {
             /** */
             private CountDownLatch firstTransactionLatch;
    +
             /** */
             private IgniteEx ignite;
    +
             /** */
             private String cacheName;
    +
             /** */
    -        private int txIndex;
    +        private int workerIdx;
    +
             /** */
             private Random random = new Random();
     
    +        /** */
    +        private final boolean colocatedAccounts;
    +
             /**
              * @param ignite Ignite.
              */
    -        private TransferAmountTxThread(CountDownLatch firstTransactionLatch, final IgniteEx ignite, String cacheName, int txIndex) {
    +        private TransferAmountTxThread(CountDownLatch firstTransactionLatch,
    +            final IgniteEx ignite,
    +            String cacheName,
    +            int workerIdx,
    +            boolean colocatedAccounts) {
                 this.firstTransactionLatch = firstTransactionLatch;
                 this.ignite = ignite;
                 this.cacheName = cacheName;
    -            this.txIndex = txIndex;
    +            this.workerIdx = workerIdx;
    +            this.colocatedAccounts = colocatedAccounts;
             }
     
             /** {@inheritDoc} */
    @@ -514,7 +515,6 @@ private TransferAmountTxThread(CountDownLatch firstTransactionLatch, final Ignit
             /**
              * @throws IgniteException if fails
              */
    -        @SuppressWarnings("unchecked")
             private void updateInTransaction(IgniteCache cache) throws IgniteException {
                 int accIdFrom;
                 int accIdTo;
    @@ -526,11 +526,16 @@ private void updateInTransaction(IgniteCache cache) throw
                     if (accIdFrom == accIdTo)
                         continue;
     
    -                ClusterNode primaryForAccFrom = ignite.cachex(cacheName).affinity().mapKeyToNode(accIdFrom);
    -                ClusterNode primaryForAccTo = ignite.cachex(cacheName).affinity().mapKeyToNode(accIdTo);
    +                Affinity affinity = ignite.affinity(cacheName);
    +
    +                ClusterNode primaryForAccFrom = affinity.mapKeyToNode(accIdFrom);
    +                assertNotNull(primaryForAccFrom);
    +
    +                ClusterNode primaryForAccTo = affinity.mapKeyToNode(accIdTo);
    +                assertNotNull(primaryForAccTo);
     
                     // Allows only transaction between accounts that primary on the same node if corresponding flag is enabled.
    -                if (!crossNodeTransactions() && !primaryForAccFrom.id().equals(primaryForAccTo.id()))
    +                if (colocatedAccounts && !primaryForAccFrom.id().equals(primaryForAccTo.id()))
                         continue;
     
                     break;
    @@ -541,7 +546,10 @@ private void updateInTransaction(IgniteCache cache) throw
     
                 try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
                     acctFrom = cache.get(accIdFrom);
    +                assertNotNull(acctFrom);
    +
                     acctTo = cache.get(accIdTo);
    +                assertNotNull(acctTo);
     
                     Set coinsToTransfer = acctFrom.coinsToTransfer(random);
     
    @@ -553,24 +561,9 @@ private void updateInTransaction(IgniteCache cache) throw
     
                     tx.commit();
     
    -                completedTxs[txIndex].put(tx.xid(), new TxState(acctFrom, acctTo, nextFrom, nextTo, coinsToTransfer));
    +                completedTxs[workerIdx].put(tx.xid(), new TxState(acctFrom, acctTo, nextFrom, nextTo, coinsToTransfer));
                 }
             }
    -
    -        /**
    -         * @param curr current
    -         * @return random value
    -         */
    -        private long getNextAccountId(long curr) {
    -            long randomVal;
    -
    -            do {
    -                randomVal = random.nextInt(accountsCount());
    -            }
    -            while (curr == randomVal);
    -
    -            return randomVal;
    -        }
         }
     
         /**
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/AtomicOperationsInTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/AtomicOperationsInTxTest.java
    index b58dbe00df7bc..e02ca25349719 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/AtomicOperationsInTxTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/AtomicOperationsInTxTest.java
    @@ -32,6 +32,9 @@
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CachePeekMode.ALL;
    @@ -39,6 +42,7 @@
     /**
      * Checks how operations under atomic cache works inside a transaction.
      */
    +@RunWith(JUnit4.class)
     public class AtomicOperationsInTxTest extends GridCommonAbstractTest {
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    @@ -71,6 +75,7 @@ public class AtomicOperationsInTxTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testEnablingAtomicOperationDuringTransaction() throws Exception {
             GridTestUtils.assertThrows(log, (Callable)() -> {
                 try (Transaction tx = grid(0).transactions().txStart()) {
    @@ -85,6 +90,7 @@ public void testEnablingAtomicOperationDuringTransaction() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAllowedAtomicOperations() throws Exception {
             checkOperations(true);
         }
    @@ -92,6 +98,7 @@ public void testAllowedAtomicOperations() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNotAllowedAtomicOperations() throws Exception {
             checkOperations(false);
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/DepthFirstSearchTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/DepthFirstSearchTest.java
    index 3d1064cddc695..6f19932695c4f 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/DepthFirstSearchTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/DepthFirstSearchTest.java
    @@ -26,17 +26,20 @@
     import java.util.Map;
     import java.util.Random;
     import java.util.Set;
    -import junit.framework.TestCase;
     import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
     import org.apache.ignite.internal.util.typedef.F;
     import org.apache.ignite.internal.util.typedef.internal.U;
    +import org.junit.Test;
     
     import static org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.findCycle;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertNull;
    +import static org.junit.Assert.fail;
     
     /**
      * DFS test for search cycle in wait-for-graph.
      */
    -public class DepthFirstSearchTest extends TestCase {
    +public class DepthFirstSearchTest {
         /** Tx 1. */
         private static final GridCacheVersion T1 = new GridCacheVersion(1, 0, 0);
     
    @@ -62,6 +65,7 @@ public class DepthFirstSearchTest extends TestCase {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoCycle() throws Exception {
             assertNull(findCycle(Collections.>emptyMap(), T1));
     
    @@ -115,6 +119,7 @@ public void testNoCycle() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFindCycle2() throws Exception {
             Map> wfg = new HashMap>() {{
                 put(T1, Collections.singleton(T2));
    @@ -180,6 +185,7 @@ public void testFindCycle2() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFindCycle3() throws Exception {
             Map> wfg = new HashMap>() {{
                 put(T1, Collections.singleton(T2));
    @@ -240,6 +246,7 @@ public void testFindCycle3() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFindCycle4() throws Exception {
             Map> wfg = new HashMap>() {{
                 put(T1, Collections.singleton(T2));
    @@ -255,6 +262,7 @@ public void testFindCycle4() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRandomNoExceptions() throws Exception {
             int maxNodesCnt = 100;
             int minNodesCnt = 10;
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TransactionIntegrityWithPrimaryIndexCorruptionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TransactionIntegrityWithPrimaryIndexCorruptionTest.java
    index 3260607023a92..486ae2262f027 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TransactionIntegrityWithPrimaryIndexCorruptionTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TransactionIntegrityWithPrimaryIndexCorruptionTest.java
    @@ -17,27 +17,46 @@
     
     package org.apache.ignite.internal.processors.cache.transactions;
     
    +import java.util.Collection;
    +import java.util.Queue;
    +import java.util.concurrent.ConcurrentLinkedQueue;
     import java.util.function.BiFunction;
    +import java.util.function.Consumer;
     import java.util.function.Supplier;
     import org.apache.ignite.IgniteCheckedException;
     import org.apache.ignite.IgniteIllegalStateException;
     import org.apache.ignite.Ignition;
    -import org.apache.ignite.cluster.ClusterNode;
     import org.apache.ignite.internal.IgniteEx;
    -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
    +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
    +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology;
     import org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree;
     import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
     import org.apache.ignite.internal.processors.cache.persistence.tree.util.PageHandler;
     import org.apache.ignite.internal.processors.cache.tree.SearchRow;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
    +
    +import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING;
     
     /**
      * Test cases that check transaction data integrity after transaction commit failed.
      */
    +@RunWith(JUnit4.class)
     public class TransactionIntegrityWithPrimaryIndexCorruptionTest extends AbstractTransactionIntergrityTest {
         /** Corruption enabled flag. */
         private static volatile boolean corruptionEnabled;
     
    +    /** {@inheritDoc} */
    +    @Override protected void beforeTest() throws Exception {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            fail("https://issues.apache.org/jira/browse/IGNITE-10470");
    +
    +        super.beforeTest();
    +    }
    +
         /** {@inheritDoc} */
         @Override protected void afterTest() throws Exception {
             corruptionEnabled = false;
    @@ -45,81 +64,108 @@ public class TransactionIntegrityWithPrimaryIndexCorruptionTest extends Abstract
             super.afterTest();
         }
     
    -    /** {@inheritDoc} */
    -    @Override protected long getTestTimeout() {
    -        return 60 * 1000L;
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitPrimaryColocatedThrowsError() throws Exception {
    +        doTestTransferAmount0(true, true, () -> new AssertionError("Test"));
         }
     
    -    /**
    -     * Throws a test {@link AssertionError} during tx commit from {@link BPlusTree} and checks after that data is consistent.
    -     */
    -    public void testPrimaryIndexCorruptionDuringCommitOnPrimaryNode1() throws Exception {
    -        doTestTransferAmount(new IndexCorruptionFailoverScenario(
    -            true,
    -            (hnd, tree) -> hnd instanceof BPlusTree.Search,
    -            failoverPredicate(true, () -> new AssertionError("Test")))
    -        );
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitPrimaryColocatedThrowsUnchecked() throws Exception {
    +        doTestTransferAmount0(true, true, () -> new RuntimeException("Test"));
         }
     
    -    /**
    -     * Throws a test {@link RuntimeException} during tx commit from {@link BPlusTree} and checks after that data is consistent.
    -     */
    -    public void testPrimaryIndexCorruptionDuringCommitOnPrimaryNode2() throws Exception {
    -        doTestTransferAmount(new IndexCorruptionFailoverScenario(
    -            true,
    -            (hnd, tree) -> hnd instanceof BPlusTree.Search,
    -            failoverPredicate(true, () -> new RuntimeException("Test")))
    -        );
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitPrimaryColocatedThrowsChecked() throws Exception {
    +        doTestTransferAmount0(true, true, () -> new IgniteCheckedException("Test"));
         }
     
    -    /**
    -     * Throws a test {@link AssertionError} during tx commit from {@link BPlusTree} and checks after that data is consistent.
    -     */
    -    public void testPrimaryIndexCorruptionDuringCommitOnBackupNode() throws Exception {
    -        doTestTransferAmount(new IndexCorruptionFailoverScenario(
    -            true,
    -            (hnd, tree) -> hnd instanceof BPlusTree.Search,
    -            failoverPredicate(false, () -> new AssertionError("Test")))
    -        );
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitPrimaryNonColocatedThrowsError() throws Exception {
    +        doTestTransferAmount0(false, true, () -> new AssertionError("Test"));
         }
     
    -    /**
    -     * Throws a test {@link IgniteCheckedException} during tx commit from {@link BPlusTree} and checks after that data is consistent.
    -     */
    -    public void testPrimaryIndexCorruptionDuringCommitOnPrimaryNode3() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-9082");
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitPrimaryNonColocatedThrowsUnchecked() throws Exception {
    +        doTestTransferAmount0(false, true, () -> new RuntimeException("Test"));
    +    }
     
    -        doTestTransferAmount(new IndexCorruptionFailoverScenario(
    -            false,
    -            (hnd, tree) -> hnd instanceof BPlusTree.Search,
    -            failoverPredicate(true, () -> new IgniteCheckedException("Test")))
    -        );
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitPrimaryNonColocatedThrowsChecked() throws Exception {
    +        doTestTransferAmount0(false, true, () -> new IgniteCheckedException("Test"));
    +    }
    +
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitBackupColocatedThrowsError() throws Exception {
    +        doTestTransferAmount0(true, false, () -> new AssertionError("Test"));
    +    }
    +
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitBackupColocatedThrowsUnchecked() throws Exception {
    +        doTestTransferAmount0(true, false, () -> new RuntimeException("Test"));
    +    }
    +
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitBackupColocatedThrowsChecked() throws Exception {
    +        doTestTransferAmount0(true, false, () -> new IgniteCheckedException("Test"));
    +    }
    +
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitBackupNonColocatedThrowsError() throws Exception {
    +        doTestTransferAmount0(false, false, () -> new AssertionError("Test"));
    +    }
    +
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitBackupNonColocatedThrowsUnchecked() throws Exception {
    +        doTestTransferAmount0(false, false, () -> new RuntimeException("Test"));
    +    }
    +
    +    /** */
    +    @Test
    +    public void testPrimaryIndexCorruptionDuringCommitBackupNonColocatedThrowsChecked() throws Exception {
    +        doTestTransferAmount0(false, false, () -> new IgniteCheckedException("Test"));
         }
     
         /**
          * Creates failover predicate which generates error during transaction commmit.
          *
    -     * @param failOnPrimary If {@code true} index should be failed on transaction primary node.
    +     * @param failOnPrimary If {@code true} index should be failed on transaction primary node, otherwise on backup.
          * @param errorSupplier Supplier to create various errors.
    +     * @param errorConsumer Consumer to track unexpected errors while committing.
          */
         private BiFunction failoverPredicate(
             boolean failOnPrimary,
    -        Supplier errorSupplier
    +        Supplier errorSupplier,
    +        Consumer errorConsumer
         ) {
             return (ignite, row) -> {
    -            int cacheId = row.cacheId();
    -            int partId = row.key().partition();
    -
    -            final ClusterNode locNode = ignite.localNode();
    -            final AffinityTopologyVersion curTopVer = ignite.context().discovery().topologyVersionEx();
    -
    -            // Throw exception if current node is primary for given row.
    -            return ignite.cachesx(c -> c.context().cacheId() == cacheId)
    -                .stream()
    -                .filter(c -> c.context().affinity().primaryByPartition(locNode, partId, curTopVer) == failOnPrimary)
    -                .map(c -> errorSupplier.get())
    -                .findFirst()
    -                .orElse(null);
    +            try {
    +                int cacheId = row.cacheId();
    +                int partId = row.key().partition();
    +
    +                GridDhtPartitionTopology top = ignite.context().cache().cacheGroup(cacheId).topology();
    +
    +                GridDhtLocalPartition part = top.localPartition(partId);
    +
    +                assertTrue("Illegal partition state for mapped tx: " + part, part != null && part.state() == OWNING);
    +
    +                return part.primary(top.readyTopologyVersion()) == failOnPrimary ? errorSupplier.get() : null;
    +            }
    +            catch (Throwable e) {
    +                errorConsumer.accept(e);
    +
    +                throw e;
    +            }
             };
         }
     
    @@ -130,68 +176,65 @@ class IndexCorruptionFailoverScenario implements FailoverScenario {
             /** Failed node index. */
             static final int failedNodeIdx = 1;
     
    -        /** Is node stopping expected after failover. */
    -        private final boolean nodeStoppingExpected;
    -
    -        /** Predicate that will choose an instance of {@link BPlusTree} and page operation
    -         * to make further failover in this tree using {@link #failoverPredicate}. */
    -        private final BiFunction treeCorruptionPredicate;
    +        /**
    +         * Predicate that will choose an instance of {@link BPlusTree} and page operation to make further failover in
    +         * this tree using {@link #failoverPred}.
    +         */
    +        private final BiFunction treeCorruptionPred;
     
             /** Function that may return error during row insertion into {@link BPlusTree}. */
    -        private final BiFunction failoverPredicate;
    +        private final BiFunction failoverPred;
     
             /**
    -         * @param nodeStoppingExpected Node stopping expected.
    -         * @param treeCorruptionPredicate Tree corruption predicate.
    -         * @param failoverPredicate Failover predicate.
    +         * @param treeCorruptionPred Tree corruption predicate.
    +         * @param failoverPred Failover predicate.
              */
             IndexCorruptionFailoverScenario(
    -            boolean nodeStoppingExpected,
    -            BiFunction treeCorruptionPredicate,
    -            BiFunction failoverPredicate
    +            BiFunction treeCorruptionPred,
    +            BiFunction failoverPred
             ) {
    -            this.nodeStoppingExpected = nodeStoppingExpected;
    -            this.treeCorruptionPredicate = treeCorruptionPredicate;
    -            this.failoverPredicate = failoverPredicate;
    +            this.treeCorruptionPred = treeCorruptionPred;
    +            this.failoverPred = failoverPred;
             }
     
             /** {@inheritDoc} */
             @Override public void beforeNodesStarted() {
                 BPlusTree.pageHndWrapper = (tree, hnd) -> {
    -                final IgniteEx locIgnite = (IgniteEx) Ignition.localIgnite();
    +                final IgniteEx locIgnite = (IgniteEx)Ignition.localIgnite();
     
    -                if (!locIgnite.name().endsWith(String.valueOf(failedNodeIdx)))
    +                if (getTestIgniteInstanceIndex(locIgnite.name()) != failedNodeIdx)
                         return hnd;
     
    -                if (treeCorruptionPredicate.apply(hnd, tree)) {
    -                    log.info("Created corrupted tree handler for -> " + hnd + " " + tree);
    -
    -                    PageHandler delegate = (PageHandler) hnd;
    +                if (treeCorruptionPred.apply(hnd, tree)) {
    +                    PageHandler delegate = (PageHandler)hnd;
     
                         return new PageHandler() {
    -                        @Override public BPlusTree.Result run(int cacheId, long pageId, long page, long pageAddr, PageIO io, Boolean walPlc, BPlusTree.Get arg, int lvl) throws IgniteCheckedException {
    -                            log.info("Invoked " + " " + cacheId + " " + arg.toString() + " for BTree (" + corruptionEnabled + ") -> " + arg.row() + " / " + arg.row().getClass());
    +                        @Override public BPlusTree.Result run(int cacheId, long pageId, long page, long pageAddr, PageIO io,
    +                            Boolean walPlc, BPlusTree.Get arg, int lvl) throws IgniteCheckedException {
    +                            log.info("Invoked [cachedId=" + cacheId + ", hnd=" + arg.toString() +
    +                                ", corruption=" + corruptionEnabled + ", row=" + arg.row() + ", rowCls=" + arg.row().getClass() + ']');
     
                                 if (corruptionEnabled && (arg.row() instanceof SearchRow)) {
    -                                SearchRow row = (SearchRow) arg.row();
    +                                SearchRow row = (SearchRow)arg.row();
     
                                     // Store cacheId to search row explicitly, as it can be zero if there is one cache in a group.
    -                                Throwable res = failoverPredicate.apply(locIgnite, new SearchRow(cacheId, row.key()));
    +                                Throwable res = failoverPred.apply(locIgnite, new SearchRow(cacheId, row.key()));
     
                                     if (res != null) {
                                         if (res instanceof Error)
    -                                        throw (Error) res;
    +                                        throw (Error)res;
                                         else if (res instanceof RuntimeException)
    -                                        throw (RuntimeException) res;
    +                                        throw (RuntimeException)res;
                                         else if (res instanceof IgniteCheckedException)
    -                                        throw (IgniteCheckedException) res;
    +                                        throw (IgniteCheckedException)res;
                                     }
                                 }
     
                                 return delegate.run(cacheId, pageId, page, pageAddr, io, walPlc, arg, lvl);
                             }
     
    -                        @Override public boolean releaseAfterWrite(int cacheId, long pageId, long page, long pageAddr, BPlusTree.Get g, int lvl) {
    +                        @Override public boolean releaseAfterWrite(int cacheId, long pageId, long page, long pageAddr,
    +                            BPlusTree.Get g, int lvl) {
                                 return g.canRelease(pageId, lvl);
                             }
                         };
    @@ -212,27 +255,68 @@ else if (res instanceof IgniteCheckedException)
                 // Disable index corruption.
                 BPlusTree.pageHndWrapper = (tree, hnd) -> hnd;
     
    -            if (nodeStoppingExpected) {
    -                // Wait until node with corrupted index will left cluster.
    -                GridTestUtils.waitForCondition(() -> {
    -                    try {
    -                        grid(failedNodeIdx);
    -                    }
    -                    catch (IgniteIllegalStateException e) {
    -                        return true;
    -                    }
    +            // Wait until node with corrupted index will left cluster.
    +            GridTestUtils.waitForCondition(() -> {
    +                try {
    +                    grid(failedNodeIdx);
    +                }
    +                catch (IgniteIllegalStateException e) {
    +                    return true;
    +                }
     
    -                    return false;
    -                }, getTestTimeout());
    +                return false;
    +            }, getTestTimeout());
     
    -                // Failed node should be stopped.
    -                GridTestUtils.assertThrows(log, () -> grid(failedNodeIdx), IgniteIllegalStateException.class, "");
    +            // Failed node should be stopped.
    +            GridTestUtils.assertThrows(log, () -> grid(failedNodeIdx), IgniteIllegalStateException.class, null);
     
    -                // Re-start failed node.
    -                startGrid(failedNodeIdx);
    +            // Re-start failed node.
    +            startGrid(failedNodeIdx);
     
    -                awaitPartitionMapExchange();
    -            }
    +            awaitPartitionMapExchange();
    +        }
    +    }
    +
    +    /**
    +     * Test transfer amount with extended error recording.
    +     *
    +     * @param colocatedAccount Colocated account.
    +     * @param failOnPrimary {@code True} if fail on primary, else on backup.
    +     * @param supplier Fail reason supplier.
    +     * @throws Exception If failover predicate execution is failed.
    +     */
    +    private void doTestTransferAmount0(boolean colocatedAccount, boolean failOnPrimary, Supplier supplier) throws Exception {
    +        ErrorTracker errTracker = new ErrorTracker();
    +
    +        doTestTransferAmount(
    +            new IndexCorruptionFailoverScenario(
    +                (hnd, tree) -> hnd instanceof BPlusTree.Search,
    +                failoverPredicate(failOnPrimary, supplier, errTracker)),
    +            colocatedAccount
    +        );
    +
    +        for (Throwable throwable : errTracker.errors())
    +            log.error("Recorded error", throwable);
    +
    +        if (!errTracker.errors().isEmpty())
    +            fail("Test run has error");
    +    }
    +
    +    /** */
    +    private static class ErrorTracker implements Consumer {
    +        /** Queue. */
    +        private final Queue q = new ConcurrentLinkedQueue<>();
    +
    +        /** {@inheritDoc} */
    +        @Override public void accept(Throwable throwable) {
    +            q.add(throwable);
    +        }
    +
    +        /**
    +         * @return Recorded errors.
    +         */
    +        public Collection errors() {
    +            return q;
             }
         }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TransactionIntegrityWithSystemWorkerDeathTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TransactionIntegrityWithSystemWorkerDeathTest.java
    index 25aae4b2a1b47..a4dd7c0fbd16f 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TransactionIntegrityWithSystemWorkerDeathTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TransactionIntegrityWithSystemWorkerDeathTest.java
    @@ -26,10 +26,14 @@
     import org.apache.ignite.internal.worker.WorkersControlMXBeanImpl;
     import org.apache.ignite.mxbean.WorkersControlMXBean;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TransactionIntegrityWithSystemWorkerDeathTest extends AbstractTransactionIntergrityTest {
         /** {@inheritDoc}. */
         @Override protected long getTestTimeout() {
    @@ -41,9 +45,8 @@ public class TransactionIntegrityWithSystemWorkerDeathTest extends AbstractTrans
             return false;
         }
     
    -    /**
    -     *
    -     */
    +    /** */
    +    @Test
         public void testFailoverWithDiscoWorkerTermination() throws Exception {
             doTestTransferAmount(new FailoverScenario() {
                 static final int failedNodeIdx = 1;
    @@ -83,7 +86,7 @@ public void testFailoverWithDiscoWorkerTermination() throws Exception {
     
                     awaitPartitionMapExchange();
                 }
    -        });
    +        }, true);
         }
     
         /**
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDataConsistencyOnCommitFailureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDataConsistencyOnCommitFailureTest.java
    new file mode 100644
    index 0000000000000..4c88fad4a2dd3
    --- /dev/null
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDataConsistencyOnCommitFailureTest.java
    @@ -0,0 +1,241 @@
    +/*
    + * 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.
    + */
    +
    +package org.apache.ignite.internal.processors.cache.transactions;
    +
    +import java.util.UUID;
    +import java.util.function.Supplier;
    +import org.apache.ignite.Ignite;
    +import org.apache.ignite.IgniteCheckedException;
    +import org.apache.ignite.IgniteTransactions;
    +import org.apache.ignite.cache.CacheAtomicityMode;
    +import org.apache.ignite.cache.CacheMode;
    +import org.apache.ignite.cache.CacheWriteSynchronizationMode;
    +import org.apache.ignite.configuration.CacheConfiguration;
    +import org.apache.ignite.configuration.IgniteConfiguration;
    +import org.apache.ignite.internal.IgniteEx;
    +import org.apache.ignite.internal.managers.communication.GridIoPolicy;
    +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
    +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
    +import org.apache.ignite.internal.util.typedef.G;
    +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.apache.ignite.testsuites.IgniteIgnore;
    +import org.apache.ignite.transactions.Transaction;
    +import org.apache.ignite.transactions.TransactionConcurrency;
    +import org.apache.ignite.transactions.TransactionIsolation;
    +import org.jetbrains.annotations.Nullable;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
    +import org.mockito.Mockito;
    +import org.mockito.invocation.InvocationOnMock;
    +import org.mockito.stubbing.Answer;
    +
    +/**
    + * Tests data consistency if transaction is failed due to heuristic exception on originating node.
    + */
    +@RunWith(JUnit4.class)
    +public class TxDataConsistencyOnCommitFailureTest extends GridCommonAbstractTest {
    +    /** */
    +    public static final int KEY = 0;
    +
    +    /** */
    +    public static final String CLIENT = "client";
    +
    +    /** */
    +    private int nodesCnt;
    +
    +    /** */
    +    private int backups;
    +
    +    /** {@inheritDoc} */
    +    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    +        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    +
    +        cfg.setClientMode(igniteInstanceName.startsWith(CLIENT));
    +
    +        cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME).
    +            setCacheMode(CacheMode.PARTITIONED).
    +            setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).
    +            setBackups(backups).
    +            setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC));
    +
    +        return cfg;
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override protected void afterTest() throws Exception {
    +        super.afterTest();
    +
    +        stopAllGrids();
    +    }
    +
    +    /** */
    +    @Test
    +    public void testCommitErrorOnNearNode2PC() throws Exception {
    +        nodesCnt = 3;
    +
    +        backups = 2;
    +
    +        doTestCommitError(() -> {
    +            try {
    +                return startGrid("client");
    +            }
    +            catch (Exception e) {
    +                throw new RuntimeException(e);
    +            }
    +        });
    +    }
    +
    +    /** */
    +    @Test
    +    public void testCommitErrorOnNearNode1PC() throws Exception {
    +        nodesCnt = 2;
    +
    +        backups = 1;
    +
    +        doTestCommitError(() -> {
    +            try {
    +                return startGrid("client");
    +            }
    +            catch (Exception e) {
    +                throw new RuntimeException(e);
    +            }
    +        });
    +    }
    +
    +    /** */
    +    @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-9806", forceFailure = false)
    +    @Test
    +    public void testCommitErrorOnColocatedNode2PC() throws Exception {
    +        nodesCnt = 3;
    +
    +        backups = 2;
    +
    +        doTestCommitError(() -> primaryNode(KEY, DEFAULT_CACHE_NAME));
    +    }
    +
    +    /**
    +     * @param factory Factory.
    +     */
    +    private void doTestCommitError(Supplier factory) throws Exception {
    +        Ignite crd = startGridsMultiThreaded(nodesCnt);
    +
    +        crd.cache(DEFAULT_CACHE_NAME).put(KEY, KEY);
    +
    +        Ignite ignite = factory.get();
    +
    +        if (ignite == null)
    +            ignite = startGrid("client");
    +
    +        assertNotNull(ignite.cache(DEFAULT_CACHE_NAME));
    +
    +        injectMockedTxManager(ignite);
    +
    +        checkKey();
    +
    +        IgniteTransactions transactions = ignite.transactions();
    +
    +        try(Transaction tx = transactions.txStart(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, 0, 1)) {
    +            assertNotNull(transactions.tx());
    +
    +            ignite.cache(DEFAULT_CACHE_NAME).put(KEY, KEY + 1);
    +
    +            tx.commit();
    +
    +            fail();
    +        }
    +        catch (Exception t) {
    +            // No-op.
    +        }
    +
    +        checkKey();
    +
    +        checkFutures();
    +    }
    +
    +    /**
    +     * @param ignite Ignite.
    +     */
    +    private void injectMockedTxManager(Ignite ignite) {
    +        IgniteEx igniteEx = (IgniteEx)ignite;
    +
    +        GridCacheSharedContext ctx = igniteEx.context().cache().context();
    +
    +        IgniteTxManager tm = ctx.tm();
    +
    +        IgniteTxManager mockTm = Mockito.spy(tm);
    +
    +        MockGridNearTxLocal locTx = new MockGridNearTxLocal(ctx, false, false, false, GridIoPolicy.SYSTEM_POOL,
    +            TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, 0, true, null, 1, null, 0, null);
    +
    +        Mockito.doAnswer(new Answer() {
    +            @Override public GridNearTxLocal answer(InvocationOnMock invocation) throws Throwable {
    +                mockTm.onCreated(null, locTx);
    +
    +                return locTx;
    +            }
    +        }).when(mockTm).
    +            newTx(locTx.implicit(), locTx.implicitSingle(), null, locTx.concurrency(),
    +                locTx.isolation(), locTx.timeout(), locTx.storeEnabled(), null, locTx.size(), locTx.label());
    +
    +        ctx.setTxManager(mockTm);
    +    }
    +
    +    /** */
    +    private void checkKey() {
    +        for (Ignite ignite : G.allGrids()) {
    +            if (!ignite.configuration().isClientMode())
    +                assertNotNull(ignite.cache(DEFAULT_CACHE_NAME).localPeek(KEY));
    +        }
    +    }
    +
    +    /** */
    +    private static class MockGridNearTxLocal extends GridNearTxLocal {
    +        /** Empty constructor. */
    +        public MockGridNearTxLocal() {
    +        }
    +
    +        /**
    +         * @param ctx Context.
    +         * @param implicit Implicit.
    +         * @param implicitSingle Implicit single.
    +         * @param sys System.
    +         * @param plc Policy.
    +         * @param concurrency Concurrency.
    +         * @param isolation Isolation.
    +         * @param timeout Timeout.
    +         * @param storeEnabled Store enabled.
    +         * @param mvccOp Mvcc op.
    +         * @param txSize Tx size.
    +         * @param subjId Subj id.
    +         * @param taskNameHash Task name hash.
    +         * @param lb Label.
    +         */
    +        public MockGridNearTxLocal(GridCacheSharedContext ctx, boolean implicit, boolean implicitSingle, boolean sys,
    +            byte plc, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout,
    +            boolean storeEnabled, Boolean mvccOp, int txSize, @Nullable UUID subjId, int taskNameHash, @Nullable String lb) {
    +            super(ctx, implicit, implicitSingle, sys, plc, concurrency, isolation, timeout, storeEnabled, mvccOp,
    +                txSize, subjId, taskNameHash, lb);
    +        }
    +
    +        /** {@inheritDoc} */
    +        @Override public void userCommit() throws IgniteCheckedException {
    +            throw new IgniteCheckedException("Force failure");
    +        }
    +    }
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockCauseTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockCauseTest.java
    index 8f5ee30c44e67..714154a9794c1 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockCauseTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockCauseTest.java
    @@ -40,10 +40,14 @@
     import java.util.concurrent.TimeUnit;
     import java.util.concurrent.atomic.AtomicBoolean;
     import java.util.concurrent.atomic.AtomicReference;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxDeadlockCauseTest extends GridCommonAbstractTest {
         /** */
         private CacheConfiguration ccfg;
    @@ -84,6 +88,7 @@ public class TxDeadlockCauseTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCause() throws Exception {
             startGrids(1);
     
    @@ -96,6 +101,7 @@ public void testCause() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCauseSeveralNodes() throws Exception {
             startGrids(2);
     
    @@ -108,6 +114,7 @@ public void testCauseSeveralNodes() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCauseNear() throws Exception {
             ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME)
                     .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
    @@ -124,6 +131,7 @@ public void testCauseNear() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCauseSeveralNodesNear() throws Exception {
             ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME)
                     .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
    @@ -146,6 +154,7 @@ public void testCauseSeveralNodesNear() throws Exception {
          *              instead of {@link IgniteCache#get(java.lang.Object)} and {@link IgniteCache#put(java.lang.Object, java.lang.Object)} operations sequence.
          * @throws Exception If failed.
          */
    +    @Test
         public void testCauseObject(int nodes, final int keysCnt, final long timeout, final TransactionIsolation isolation, final boolean oneOp) throws Exception {
             final Ignite ignite = grid(new Random().nextInt(nodes));
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java
    index 1a48cec75fb5c..df31a722bfd10 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionMessageMarshallingTest.java
    @@ -33,10 +33,14 @@
     import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
     import org.apache.ignite.internal.processors.cache.KeyCacheObject;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxDeadlockDetectionMessageMarshallingTest extends GridCommonAbstractTest {
         /** Topic. */
         private static final String TOPIC = "mytopic";
    @@ -57,6 +61,7 @@ public class TxDeadlockDetectionMessageMarshallingTest extends GridCommonAbstrac
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMessageUnmarshallWithoutCacheContext() throws Exception {
             try {
                 Ignite ignite = startGrid(0);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionNoHangsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionNoHangsTest.java
    index 3f1639a5edf02..bffed6b57cc15 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionNoHangsTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionNoHangsTest.java
    @@ -35,6 +35,9 @@
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.IgniteSystemProperties.IGNITE_TX_DEADLOCK_DETECTION_MAX_ITERS;
     import static org.apache.ignite.IgniteSystemProperties.IGNITE_TX_DEADLOCK_DETECTION_TIMEOUT;
    @@ -46,6 +49,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxDeadlockDetectionNoHangsTest extends GridCommonAbstractTest {
         /** Nodes count. */
         private static final int NODES_CNT = 3;
    @@ -105,6 +109,7 @@ public class TxDeadlockDetectionNoHangsTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoHangsPessimistic() throws Exception {
             assertTrue(grid(0).context().cache().context().tm().deadlockDetectionEnabled());
     
    @@ -126,6 +131,7 @@ public void testNoHangsPessimistic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoHangsOptimistic() throws Exception {
             assertTrue(grid(0).context().cache().context().tm().deadlockDetectionEnabled());
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
    index 6cf65c8fd4f33..f9bd4879fefd7 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
    @@ -48,6 +48,9 @@
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionDeadlockException;
     import org.apache.ignite.transactions.TransactionTimeoutException;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.internal.util.typedef.X.hasCause;
     import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
    @@ -56,6 +59,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
         /** Nodes count. */
         private static final int NODES_CNT = 3;
    @@ -102,6 +106,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoHangs() throws Exception {
             final AtomicBoolean stop = new AtomicBoolean();
     
    @@ -182,6 +187,7 @@ public void testNoHangs() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoDeadlockSimple() throws Exception {
             final AtomicInteger threadCnt = new AtomicInteger();
     
    @@ -236,6 +242,7 @@ public void testNoDeadlockSimple() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoDeadlock() throws Exception {
             for (int i = 2; i <= 10; i++) {
                 final int threads = i;
    @@ -310,6 +317,7 @@ public void testNoDeadlock() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFailedTxLocksRequest() throws Exception {
             doTestFailedMessage(TxLocksRequest.class);
         }
    @@ -317,6 +325,7 @@ public void testFailedTxLocksRequest() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFailedTxLocksResponse() throws Exception {
             doTestFailedMessage(TxLocksResponse.class);
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionUnmasrhalErrorsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionUnmasrhalErrorsTest.java
    index 0cadafefe31be..5b5dddb61a2b9 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionUnmasrhalErrorsTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionUnmasrhalErrorsTest.java
    @@ -38,6 +38,9 @@
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionDeadlockException;
     import org.apache.ignite.transactions.TransactionTimeoutException;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.internal.util.typedef.X.hasCause;
     import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
    @@ -47,6 +50,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxDeadlockDetectionUnmasrhalErrorsTest extends GridCommonAbstractTest {
         /** Nodes count. */
         private static final int NODES_CNT = 2;
    @@ -86,6 +90,7 @@ public class TxDeadlockDetectionUnmasrhalErrorsTest extends GridCommonAbstractTe
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlockCacheObjectContext() throws Exception {
             IgniteCache cache0 = null;
             IgniteCache cache1 = null;
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxLabelTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxLabelTest.java
    index d89ba0b6554ec..516c08a0c203a 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxLabelTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxLabelTest.java
    @@ -18,16 +18,35 @@
     package org.apache.ignite.internal.processors.cache.transactions;
     
     import org.apache.ignite.Ignite;
    -import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
    +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Tests transaction labels.
      */
    -public class TxLabelTest extends GridCacheAbstractSelfTest {
    +@RunWith(JUnit4.class)
    +public class TxLabelTest extends GridCommonAbstractTest {
    +    /** {@inheritDoc} */
    +    @Override protected void beforeTestsStarted() throws Exception {
    +        super.beforeTestsStarted();
    +
    +        startGrid(0).getOrCreateCache(defaultCacheConfiguration());
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override protected void afterTestsStopped() throws Exception {
    +        stopAllGrids();
    +
    +        super.afterTestsStopped();
    +    }
    +
         /**
          * Tests transaction labels.
          */
    +    @Test
         public void testLabel() {
             testLabel0(grid(0), "lbl0");
             testLabel0(grid(0), "lbl1");
    @@ -55,9 +74,4 @@ private void testLabel0(Ignite ignite, String lbl) {
                 tx.commit();
             }
         }
    -
    -    /** {@inheritDoc} */
    -    @Override protected int gridCount() {
    -        return 1;
    -    }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxMultiCacheAsyncOpsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxMultiCacheAsyncOpsTest.java
    index 89f20ec52b4fd..cca0bee251c14 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxMultiCacheAsyncOpsTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxMultiCacheAsyncOpsTest.java
    @@ -26,6 +26,9 @@
     import org.apache.ignite.lang.IgniteFuture;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
    @@ -33,6 +36,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxMultiCacheAsyncOpsTest extends GridCommonAbstractTest {
         /** Grid count. */
         public static final int GRID_COUNT = 3;
    @@ -77,6 +81,7 @@ private CacheConfiguration cacheConfiguration(int idx) {
         /**
          *
          */
    +    @Test
         public void testCommitAfterAsyncPut() {
             CacheConfiguration[] caches = cacheConfigurations();
     
    @@ -106,6 +111,7 @@ public void testCommitAfterAsyncPut() {
         /**
          *
          */
    +    @Test
         public void testCommitAfterAsyncGet() {
             CacheConfiguration[] caches = cacheConfigurations();
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOnCachesStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOnCachesStartTest.java
    index 24044040cac8b..5e4d1ac4ac2b6 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOnCachesStartTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOnCachesStartTest.java
    @@ -24,38 +24,26 @@
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.cache.CacheAtomicityMode;
     import org.apache.ignite.configuration.CacheConfiguration;
    -import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.IgniteInternalFuture;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *  Tests transactions closes correctly while other caches start and stop.
      *  Tests possible {@link NullPointerException} in {@link TransactionProxyImpl#leave} due to race while
      *  {@link org.apache.ignite.internal.processors.cache.GridCacheTtlManager} initializes (IGNITE-7972).
      */
    +@RunWith(JUnit4.class)
     public class TxOnCachesStartTest extends GridCommonAbstractTest {
         /** */
         private static int NUM_CACHES = 100;
     
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
    -    /** {@inheritDoc} */
    -    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    -        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    -
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -
    -        return cfg;
    -    }
    -
         /** {@inheritDoc} */
         @Override protected void beforeTest() throws Exception {
             super.beforeTest();
    @@ -73,6 +61,7 @@ public class TxOnCachesStartTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTransactionCloseOnCachesStartAndStop() throws Exception {
             Ignite srv =  startGrids(5);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionCrossCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionCrossCacheTest.java
    index 056b093f7fba6..680e69b9e294b 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionCrossCacheTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionCrossCacheTest.java
    @@ -39,6 +39,9 @@
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionDeadlockException;
     import org.apache.ignite.transactions.TransactionTimeoutException;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.internal.util.typedef.X.hasCause;
     import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
    @@ -47,6 +50,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxOptimisticDeadlockDetectionCrossCacheTest extends GridCommonAbstractTest {
         /** {@inheritDoc} */
         @SuppressWarnings("unchecked")
    @@ -83,6 +87,7 @@ public class TxOptimisticDeadlockDetectionCrossCacheTest extends GridCommonAbstr
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlock() throws Exception {
             startGrids(2);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
    index 19fb4c9d7cb78..4818d821b10aa 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
    @@ -52,11 +52,13 @@
     import org.apache.ignite.spi.IgniteSpiException;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
     import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionDeadlockException;
     import org.apache.ignite.transactions.TransactionTimeoutException;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
     import static org.apache.ignite.cache.CacheMode.REPLICATED;
    @@ -69,10 +71,8 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxOptimisticDeadlockDetectionTest extends AbstractDeadlockDetectionTest {
    -    /** Ip finder. */
    -    private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** Cache name. */
         private static final String CACHE_NAME = "cache";
     
    @@ -93,15 +93,8 @@ public class TxOptimisticDeadlockDetectionTest extends AbstractDeadlockDetection
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    -
    -        discoSpi.setIpFinder(IP_FINDER);
    -
    -        if (isDebug()) {
    -            discoSpi.failureDetectionTimeoutEnabled(false);
    -
    -            cfg.setDiscoverySpi(discoSpi);
    -        }
    +        if (isDebug())
    +            ((TcpDiscoverySpi)cfg.getDiscoverySpi()).failureDetectionTimeoutEnabled(false);
     
             TcpCommunicationSpi commSpi = new TestCommunicationSpi();
     
    @@ -109,8 +102,6 @@ public class TxOptimisticDeadlockDetectionTest extends AbstractDeadlockDetection
     
             cfg.setClientMode(client);
     
    -        cfg.setDiscoverySpi(discoSpi);
    -
             return cfg;
         }
     
    @@ -131,6 +122,7 @@ public class TxOptimisticDeadlockDetectionTest extends AbstractDeadlockDetection
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlocksPartitioned() throws Exception {
             for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
                 doTestDeadlocks(createCache(PARTITIONED, syncMode, false), ORDINAL_START_KEY);
    @@ -141,6 +133,7 @@ public void testDeadlocksPartitioned() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlocksPartitionedNear() throws Exception {
             for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
                 doTestDeadlocks(createCache(PARTITIONED, syncMode, true), ORDINAL_START_KEY);
    @@ -151,6 +144,7 @@ public void testDeadlocksPartitionedNear() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlocksReplicated() throws Exception {
             for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
                 doTestDeadlocks(createCache(REPLICATED, syncMode, false), ORDINAL_START_KEY);
    @@ -161,6 +155,7 @@ public void testDeadlocksReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlocksPartitionedNearTxOnPrimary() throws Exception {
             for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
                 doTestDeadlocksTxOnPrimary(createCache(PARTITIONED, syncMode, true),  ORDINAL_START_KEY);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticOnPartitionExchangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticOnPartitionExchangeTest.java
    index 369e75506b69f..9be8c7d139362 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticOnPartitionExchangeTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticOnPartitionExchangeTest.java
    @@ -50,6 +50,9 @@
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionIsolation;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
    @@ -65,6 +68,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxOptimisticOnPartitionExchangeTest extends GridCommonAbstractTest {
         /** Nodes count. */
         private static final int NODES_CNT = 3;
    @@ -106,6 +110,7 @@ public class TxOptimisticOnPartitionExchangeTest extends GridCommonAbstractTest
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConsistencyOnPartitionExchange() throws Exception {
             doTest(SERIALIZABLE, true);
             doTest(READ_COMMITTED, true);
    @@ -312,4 +317,4 @@ private void sendMessage(
                 super.sendMessage(node, msg, ackC);
             }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticPrepareOnUnstableTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticPrepareOnUnstableTopologyTest.java
    index cb371cf2cc583..3fde7deab4589 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticPrepareOnUnstableTopologyTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticPrepareOnUnstableTopologyTest.java
    @@ -17,26 +17,27 @@
     
     package org.apache.ignite.internal.processors.cache.transactions;
     
    -import java.util.ArrayList;
    -import java.util.Collection;
     import java.util.TreeMap;
     import java.util.concurrent.ThreadLocalRandom;
     import java.util.concurrent.TimeUnit;
    +import java.util.concurrent.atomic.AtomicBoolean;
     import org.apache.ignite.Ignite;
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.IgniteEx;
    +import org.apache.ignite.internal.IgniteInternalFuture;
     import org.apache.ignite.internal.IgniteKernal;
    -import org.apache.ignite.internal.util.typedef.G;
    +import org.apache.ignite.internal.util.future.GridCompoundFuture;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
    +import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
    @@ -45,36 +46,24 @@
     /**
      * Tests optimistic prepare on unstable topology.
      */
    +@RunWith(JUnit4.class)
     public class TxOptimisticPrepareOnUnstableTopologyTest extends GridCommonAbstractTest {
         /** */
         public static final String CACHE_NAME = "part_cache";
     
    -    /** IP finder. */
    -    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    +    /** */
    +    private static final int STARTUP_DELAY = 500;
     
         /** */
    -    private volatile boolean run = true;
    +    private static final int GRID_CNT = 4;
     
         /** */
         private boolean client;
     
    -    /** {@inheritDoc} */
    -    @Override protected void afterTestsStopped() throws Exception {
    -        stopAllGrids();
    -
    -        assertEquals(0, G.allGrids().size());
    -    }
    -
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
     
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(ipFinder);
    -
    -        c.setDiscoverySpi(disco);
    -
             CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
     
             ccfg.setName(CACHE_NAME);
    @@ -93,6 +82,7 @@ public class TxOptimisticPrepareOnUnstableTopologyTest extends GridCommonAbstrac
         /**
          *
          */
    +    @Test
         public void testPrepareOnUnstableTopology() throws Exception {
             for (TransactionIsolation isolation : TransactionIsolation.values()) {
                 doPrepareOnUnstableTopology(4, false, isolation, 0);
    @@ -110,58 +100,42 @@ public void testPrepareOnUnstableTopology() throws Exception {
          */
         private void doPrepareOnUnstableTopology(int keys, boolean testClient, TransactionIsolation isolation,
             long timeout) throws Exception {
    -        Collection threads = new ArrayList<>();
    -
    -        try {
    -            // Start grid 1.
    -            IgniteEx grid1 = startGrid(0);
    -
    -            assertFalse(grid1.configuration().isClientMode());
    -
    -            threads.add(runCacheOperations(grid1, isolation, timeout, keys));
    -
    -            TimeUnit.SECONDS.sleep(3L);
    -
    -            client = testClient; // If test client start on node in client mode.
    -
    -            // Start grid 2.
    -            IgniteEx grid2 = startGrid(1);
    -
    -            assertEquals((Object)testClient, grid2.configuration().isClientMode());
    -
    -            client = false;
    +        GridCompoundFuture compFut = new GridCompoundFuture<>();
     
    -            threads.add(runCacheOperations(grid2, isolation, timeout, keys));
    +        AtomicBoolean stopFlag = new AtomicBoolean();
     
    -            TimeUnit.SECONDS.sleep(3L);
    -
    -            // Start grid 3.
    -            IgniteEx grid3 = startGrid(2);
    +        try {
    +            int clientIdx = testClient ? 1 : -1;
     
    -            assertFalse(grid3.configuration().isClientMode());
    +            try {
    +                for (int i = 0; i < GRID_CNT; i++) {
    +                    client = (clientIdx == i);
     
    -            if (testClient)
    -                log.info("Started client node: " + grid3.name());
    +                    IgniteEx grid = startGrid(i);
     
    -            threads.add(runCacheOperations(grid3, isolation, timeout, keys));
    +                    assertEquals(client, grid.configuration().isClientMode().booleanValue());
     
    -            TimeUnit.SECONDS.sleep(3L);
    +                    client = false;
     
    -            // Start grid 4.
    -            IgniteEx grid4 = startGrid(3);
    +                    IgniteInternalFuture fut = runCacheOperationsAsync(grid, stopFlag, isolation, timeout, keys);
     
    -            assertFalse(grid4.configuration().isClientMode());
    +                    compFut.add(fut);
     
    -            threads.add(runCacheOperations(grid4, isolation, timeout, keys));
    +                    U.sleep(STARTUP_DELAY);
    +                }
    +            }
    +            finally {
    +                stopFlag.set(true);
    +            }
     
    -            TimeUnit.SECONDS.sleep(3L);
    +            compFut.markInitialized();
     
    -            stopThreads(threads);
    +            compFut.get();
     
    -            for (int i = 0; i < 4; i++) {
    +            for (int i = 0; i < GRID_CNT; i++) {
                     IgniteTxManager tm = ((IgniteKernal)grid(i)).internalCache(CACHE_NAME).context().tm();
     
    -                assertEquals("txMap is not empty:" + i, 0, tm.idMapSize());
    +                assertEquals("txMap is not empty: " + i, 0, tm.idMapSize());
                 }
             }
             finally {
    @@ -169,65 +143,51 @@ private void doPrepareOnUnstableTopology(int keys, boolean testClient, Transacti
             }
         }
     
    -    /**
    -     * @param threads Thread which will be stopped.
    -     */
    -    private void stopThreads(Iterable threads) {
    -        try {
    -            run = false;
    -
    -            for (Thread thread : threads)
    -                thread.join();
    -        }
    -        catch (Exception e) {
    -            U.error(log(), "Couldn't stop threads.", e);
    -        }
    -    }
    -
         /**
          * @param node Node.
          * @param isolation Isolation.
          * @param timeout Timeout.
          * @param keys Number of keys.
    -     * @return Running thread.
    +     * @return Future representing pending completion of the operation.
          */
    -    @SuppressWarnings("TypeMayBeWeakened")
    -    private Thread runCacheOperations(Ignite node, TransactionIsolation isolation, long timeout, final int keys) {
    -        Thread t = new Thread() {
    -            @Override public void run() {
    -                while (run) {
    -                    TreeMap vals = generateValues(keys);
    -
    -                    try {
    -                        try (Transaction tx = node.transactions().txStart(TransactionConcurrency.OPTIMISTIC, isolation,
    -                            timeout, keys)){
    -
    -                            IgniteCache cache = node.cache(CACHE_NAME);
    -
    -                            // Put or remove.
    -                            if (ThreadLocalRandom.current().nextDouble(1) < 0.65)
    -                                cache.putAll(vals);
    -                            else
    -                                cache.removeAll(vals.keySet());
    -
    -                            tx.commit();
    -                        }
    -                        catch (Exception e) {
    -                            U.error(log(), "Failed cache operation.", e);
    -                        }
    -
    -                        U.sleep(100);
    +    private IgniteInternalFuture runCacheOperationsAsync(
    +        Ignite node,
    +        AtomicBoolean stopFlag,
    +        TransactionIsolation isolation,
    +        long timeout,
    +        final int keys
    +    ) {
    +        return GridTestUtils.runAsync(() -> {
    +            while (!stopFlag.get()) {
    +                TreeMap vals = generateValues(keys);
    +
    +                try {
    +                    try (Transaction tx = node.transactions().txStart(TransactionConcurrency.OPTIMISTIC, isolation,
    +                        timeout, keys)) {
    +
    +                        IgniteCache cache = node.cache(CACHE_NAME);
    +
    +                        // Put or remove.
    +                        if (ThreadLocalRandom.current().nextDouble(1) < 0.65)
    +                            cache.putAll(vals);
    +                        else
    +                            cache.removeAll(vals.keySet());
    +
    +                        tx.commit();
                         }
    -                    catch (Exception e){
    -                        U.error(log(), "Failed unlock.", e);
    +                    catch (Exception e) {
    +                        U.error(log(), "Failed cache operation.", e);
                         }
    +
    +                    U.sleep(100);
    +                }
    +                catch (Exception e) {
    +                    U.error(log(), "Failed unlock.", e);
                     }
                 }
    -        };
    -
    -        t.start();
     
    -        return t;
    +            return null;
    +        });
         }
     
         /**
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionCrossCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionCrossCacheTest.java
    index b6bd7fbf4f093..5a397556e993b 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionCrossCacheTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionCrossCacheTest.java
    @@ -37,6 +37,9 @@
     import org.apache.ignite.transactions.TransactionDeadlockException;
     import org.apache.ignite.transactions.TransactionTimeoutException;
     import org.jetbrains.annotations.NotNull;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.internal.util.typedef.X.hasCause;
     import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
    @@ -45,6 +48,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxPessimisticDeadlockDetectionCrossCacheTest extends GridCommonAbstractTest {
         /** Nodes count. */
         private static final int NODES_CNT = 2;
    @@ -75,6 +79,7 @@ public class TxPessimisticDeadlockDetectionCrossCacheTest extends GridCommonAbst
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlockNoNear() throws Exception {
             doTestDeadlock(false, false);
         }
    @@ -82,6 +87,7 @@ public void testDeadlockNoNear() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlockOneNear() throws Exception {
             doTestDeadlock(false, true);
         }
    @@ -89,6 +95,7 @@ public void testDeadlockOneNear() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlockAnotherNear() throws Exception {
             doTestDeadlock(true, false);
             doTestDeadlock(false, true);
    @@ -97,6 +104,7 @@ public void testDeadlockAnotherNear() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlockBothNear() throws Exception {
             doTestDeadlock(true, true);
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java
    index 88bebb29fc9de..3d03f8cb51506 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java
    @@ -48,6 +48,9 @@
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionDeadlockException;
     import org.apache.ignite.transactions.TransactionTimeoutException;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheMode.LOCAL;
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
    @@ -61,6 +64,7 @@
     /**
      * Tests deadlock detection for pessimistic transactions.
      */
    +@RunWith(JUnit4.class)
     public class TxPessimisticDeadlockDetectionTest extends AbstractDeadlockDetectionTest {
         /** Cache name. */
         private static final String CACHE_NAME = "cache";
    @@ -119,6 +123,7 @@ public class TxPessimisticDeadlockDetectionTest extends AbstractDeadlockDetectio
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlocksPartitioned() throws Exception {
             for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
                 doTestDeadlocks(createCache(PARTITIONED, syncMode, false), ORDINAL_START_KEY);
    @@ -129,6 +134,7 @@ public void testDeadlocksPartitioned() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlocksPartitionedNear() throws Exception {
             for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
                 doTestDeadlocks(createCache(PARTITIONED, syncMode, true), ORDINAL_START_KEY);
    @@ -139,6 +145,7 @@ public void testDeadlocksPartitionedNear() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlocksReplicated() throws Exception {
             for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
                 doTestDeadlocks(createCache(REPLICATED, syncMode, false), ORDINAL_START_KEY);
    @@ -149,6 +156,7 @@ public void testDeadlocksReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlocksLocal() throws Exception {
             for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
                 IgniteCache cache = null;
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncNearCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncNearCacheTest.java
    index 5caa1a06325b8..dc115e1dc62d6 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncNearCacheTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncNearCacheTest.java
    @@ -17,6 +17,8 @@
     
     package org.apache.ignite.internal.processors.cache.transactions;
     
    +import org.apache.ignite.testframework.MvccFeatureChecker;
    +
     /**
      * Tests an ability to async rollback near transactions.
      */
    @@ -25,4 +27,11 @@ public class TxRollbackAsyncNearCacheTest extends TxRollbackAsyncTest {
         @Override protected boolean nearCacheEnabled() {
             return true;
         }
    +
    +    /** {@inheritDoc} */
    +    @Override public void setUp() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE);
    +
    +        super.setUp();
    +    }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncTest.java
    index 4ca8ba37c34ba..5d37f1387db4d 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncTest.java
    @@ -51,12 +51,12 @@
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.IgniteFutureCancelledCheckedException;
     import org.apache.ignite.internal.IgniteInternalFuture;
    -import org.apache.ignite.internal.IgniteInterruptedCheckedException;
     import org.apache.ignite.internal.IgniteKernal;
     import org.apache.ignite.internal.TestRecordingCommunicationSpi;
     import org.apache.ignite.internal.processors.cache.GridCacheContext;
     import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
     import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockRequest;
    +import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxEnlistRequest;
     import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest;
     import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
     import org.apache.ignite.internal.util.future.GridFutureAdapter;
    @@ -79,13 +79,17 @@
     import org.apache.ignite.lang.IgnitePredicate;
     import org.apache.ignite.lang.IgniteUuid;
     import org.apache.ignite.plugin.extensions.communication.Message;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
    +import org.apache.ignite.testframework.GridTestUtils.SF;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
     import org.apache.ignite.transactions.TransactionRollbackException;
    +import org.junit.Assume;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.lang.Thread.interrupted;
     import static java.lang.Thread.yield;
    @@ -96,7 +100,6 @@
     import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
     import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
     import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
    -import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
     import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
     import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
     import static org.apache.ignite.transactions.TransactionState.ROLLED_BACK;
    @@ -104,6 +107,7 @@
     /**
      * Tests an ability to async rollback near transactions.
      */
    +@RunWith(JUnit4.class)
     public class TxRollbackAsyncTest extends GridCommonAbstractTest {
         /** */
         public static final int DURATION = 60_000;
    @@ -111,9 +115,6 @@ public class TxRollbackAsyncTest extends GridCommonAbstractTest {
         /** */
         private static final String CACHE_NAME = "test";
     
    -    /** IP finder. */
    -    private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int GRID_CNT = 3;
     
    @@ -127,8 +128,6 @@ public class TxRollbackAsyncTest extends GridCommonAbstractTest {
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -
             cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
     
             boolean client = igniteInstanceName.startsWith("client");
    @@ -165,10 +164,11 @@ protected boolean nearCacheEnabled() {
         }
     
         /**
    -     *
          * @return {@code True} if persistence must be enabled for test.
          */
    -    protected boolean persistenceEnabled() { return false; }
    +    protected boolean persistenceEnabled() {
    +        return false;
    +    }
     
         /** {@inheritDoc} */
         @Override protected void beforeTest() throws Exception {
    @@ -210,7 +210,10 @@ private Ignite startClient() throws Exception {
         /**
          *
          */
    +    @Test
         public void testRollbackSimple() throws Exception {
    +        Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-7952", MvccFeatureChecker.forcedMvcc());
    +
             startClient();
     
             for (Ignite ignite : G.allGrids()) {
    @@ -225,7 +228,7 @@ public void testRollbackSimple() throws Exception {
          */
         private void testRollbackSimple0(Ignite near) throws Exception {
             // Normal rollback after put.
    -        Transaction tx = near.transactions().txStart(PESSIMISTIC, READ_COMMITTED);
    +        Transaction tx = near.transactions().txStart(PESSIMISTIC, REPEATABLE_READ);
     
             near.cache(CACHE_NAME).put(0, 0);
     
    @@ -314,6 +317,7 @@ private void testRollbackSimple0(Ignite near) throws Exception {
         /**
          *
          */
    +    @Test
         public void testSynchronousRollback() throws Exception {
             Ignite client = startClient();
     
    @@ -339,22 +343,21 @@ public void testSynchronousRollback() throws Exception {
         }
     
         /**
    -     *
          * @param holdLockNode Node holding the write lock.
          * @param tryLockNode Node trying to acquire lock.
          * @param useTimeout {@code True} if need to start tx with timeout.
    -     *
          * @throws Exception If failed.
          */
    -    private void testSynchronousRollback0(Ignite holdLockNode, final Ignite tryLockNode, final boolean useTimeout) throws Exception {
    -        final CountDownLatch keyLocked = new CountDownLatch(1);
    +    private void testSynchronousRollback0(Ignite holdLockNode, final Ignite tryLockNode,
    +        final boolean useTimeout) throws Exception {
    +        final GridFutureAdapter keyLocked = new GridFutureAdapter<>();
     
             CountDownLatch waitCommit = new CountDownLatch(1);
     
             // Used for passing tx instance to rollback thread.
             IgniteInternalFuture lockFut = lockInTx(holdLockNode, keyLocked, waitCommit, 0);
     
    -        U.awaitQuiet(keyLocked);
    +        keyLocked.get();
     
             final int txCnt = 1000;
     
    @@ -377,8 +380,6 @@ private void testSynchronousRollback0(Ignite holdLockNode, final Ignite tryLockN
     
             IgniteInternalFuture txFut = multithreadedAsync(new Runnable() {
                 @Override public void run() {
    -                U.awaitQuiet(keyLocked);
    -
                     for (int i = 0; i < txCnt; i++) {
                         GridNearTxLocal tx0 = ctx.tm().threadLocalTx(cctx);
     
    @@ -390,7 +391,7 @@ private void testSynchronousRollback0(Ignite holdLockNode, final Ignite tryLockN
                             txReadyFut.onDone(tx);
     
                             // Will block on lock request until rolled back asynchronously.
    -                        Object o = tryLockNode.cache(CACHE_NAME).get(0);
    +                        Object o = tryLockNode.cache(CACHE_NAME).getAndPut(0, 0);
     
                             assertNull(o); // If rolled back by close, previous get will return null.
                         }
    @@ -409,7 +410,7 @@ private void testSynchronousRollback0(Ignite holdLockNode, final Ignite tryLockN
     
                     int proc = 1;
     
    -                while(true) {
    +                while (true) {
                         try {
                             Transaction tx = txReadyFut.get();
     
    @@ -465,6 +466,7 @@ private void testSynchronousRollback0(Ignite holdLockNode, final Ignite tryLockN
         /**
          *
          */
    +    @Test
         public void testEnlistManyRead() throws Exception {
             testEnlistMany(false, REPEATABLE_READ, PESSIMISTIC);
         }
    @@ -472,6 +474,7 @@ public void testEnlistManyRead() throws Exception {
         /**
          *
          */
    +    @Test
         public void testEnlistManyWrite() throws Exception {
             testEnlistMany(true, REPEATABLE_READ, PESSIMISTIC);
         }
    @@ -479,22 +482,30 @@ public void testEnlistManyWrite() throws Exception {
         /**
          *
          */
    +    @Test
         public void testEnlistManyReadOptimistic() throws Exception {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            return; // Optimistic transactions are not supported by MVCC.
    +
             testEnlistMany(false, SERIALIZABLE, OPTIMISTIC);
         }
     
         /**
          *
          */
    +    @Test
         public void testEnlistManyWriteOptimistic() throws Exception {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            return; // Optimistic transactions are not supported by MVCC.
    +
             testEnlistMany(true, SERIALIZABLE, OPTIMISTIC);
         }
     
    -
         /**
          *
          */
    -    private void testEnlistMany(boolean write, TransactionIsolation isolation, TransactionConcurrency conc) throws Exception {
    +    private void testEnlistMany(boolean write, TransactionIsolation isolation,
    +        TransactionConcurrency conc) throws Exception {
             final Ignite client = startClient();
     
             Map entries = new HashMap<>();
    @@ -504,7 +515,7 @@ private void testEnlistMany(boolean write, TransactionIsolation isolation, Trans
     
             IgniteInternalFuture fut = null;
     
    -        try(Transaction tx = client.transactions().txStart(conc, isolation, 0, 0)) {
    +        try (Transaction tx = client.transactions().txStart(conc, isolation, 0, 0)) {
                 fut = rollbackAsync(tx, 200);
     
                 if (write)
    @@ -530,14 +541,21 @@ private void testEnlistMany(boolean write, TransactionIsolation isolation, Trans
         /**
          * Rollback tx while near lock request is delayed.
          */
    +    @Test
         public void testRollbackDelayNearLockRequest() throws Exception {
    +        Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9470", MvccFeatureChecker.forcedMvcc());
    +
             final Ignite client = startClient();
     
             final Ignite prim = primaryNode(0, CACHE_NAME);
     
             final TestRecordingCommunicationSpi spi = (TestRecordingCommunicationSpi)client.configuration().getCommunicationSpi();
     
    -        spi.blockMessages(GridNearLockRequest.class, prim.name());
    +        boolean mvcc = MvccFeatureChecker.forcedMvcc();
    +
    +        Class msgCls = mvcc ? GridNearTxEnlistRequest.class : GridNearLockRequest.class;
    +
    +        spi.blockMessages(msgCls, prim.name());
     
             final IgniteInternalFuture rollbackFut = runAsync(new Callable() {
                 @Override public Void call() throws Exception {
    @@ -549,13 +567,13 @@ public void testRollbackDelayNearLockRequest() throws Exception {
                 }
             }, "tx-rollback-thread");
     
    -        try(final Transaction tx = client.transactions().txStart()) {
    +        try (final Transaction tx = client.transactions().txStart()) {
                 client.cache(CACHE_NAME).put(0, 0);
     
                 fail();
             }
             catch (CacheException e) {
    -            assertTrue(X.hasCause(e, TransactionRollbackException.class));
    +            assertTrue(X.getFullStackTrace(e),X.hasCause(e, TransactionRollbackException.class));
             }
     
             rollbackFut.get();
    @@ -570,6 +588,7 @@ public void testRollbackDelayNearLockRequest() throws Exception {
         /**
          * Tests rollback with concurrent commit.
          */
    +    @Test
         public void testRollbackDelayFinishRequest() throws Exception {
             final Ignite client = startClient();
     
    @@ -608,7 +627,7 @@ public void testRollbackDelayFinishRequest() throws Exception {
                 }
             }, "tx-rollback-thread");
     
    -        try(final Transaction tx = client.transactions().txStart()) {
    +        try (final Transaction tx = client.transactions().txStart()) {
                 txRef.set(tx);
     
                 client.cache(CACHE_NAME).put(0, 0);
    @@ -629,7 +648,10 @@ public void testRollbackDelayFinishRequest() throws Exception {
         /**
          *
          */
    +    @Test
         public void testMixedAsyncRollbackTypes() throws Exception {
    +        Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10434", MvccFeatureChecker.forcedMvcc());
    +
             final Ignite client = startClient();
     
             final AtomicBoolean stop = new AtomicBoolean();
    @@ -660,6 +682,8 @@ public void testMixedAsyncRollbackTypes() throws Exception {
             for (Ignite ignite : G.allGrids())
                 perNodeTxs.put(ignite, new ArrayBlockingQueue<>(1000));
     
    +        boolean mvcc = MvccFeatureChecker.forcedMvcc();
    +
             IgniteInternalFuture txFut = multithreadedAsync(() -> {
                 while (!stop.get()) {
                     int nodeId = r.nextInt(GRID_CNT + 1);
    @@ -667,8 +691,8 @@ public void testMixedAsyncRollbackTypes() throws Exception {
                     // Choose random node to start tx on.
                     Ignite node = nodeId == GRID_CNT || nearCacheEnabled() ? client : grid(nodeId);
     
    -                TransactionConcurrency conc = TC_VALS[r.nextInt(TC_VALS.length)];
    -                TransactionIsolation isolation = TI_VALS[r.nextInt(TI_VALS.length)];
    +                TransactionConcurrency conc = mvcc ? PESSIMISTIC : TC_VALS[r.nextInt(TC_VALS.length)];
    +                TransactionIsolation isolation = mvcc ? REPEATABLE_READ :TI_VALS[r.nextInt(TI_VALS.length)];
     
                     // Timeout is necessary otherwise deadlock is possible due to randomness of lock acquisition.
                     long timeout = r.nextInt(50) + 50;
    @@ -761,8 +785,8 @@ public void testMixedAsyncRollbackTypes() throws Exception {
                     Transaction tx;
     
                     // Rollback all transaction
    -                while((tx = nodeQ.poll()) != null) {
    -                    rolledBack.add(1);
    +                while ((tx = nodeQ.poll()) != null) {
    +                    rolledBack.increment();
     
                         doSleep(r.nextInt(50)); // Add random sleep to increase completed txs count.
     
    @@ -795,8 +819,8 @@ public void testMixedAsyncRollbackTypes() throws Exception {
             for (BlockingQueue queue : perNodeTxs.values()) {
                 Transaction tx;
     
    -            while((tx = queue.poll()) != null) {
    -                rolledBack.add(1);
    +            while ((tx = queue.poll()) != null) {
    +                rolledBack.increment();
     
                     rollbackClo.apply(tx);
                 }
    @@ -813,8 +837,9 @@ public void testMixedAsyncRollbackTypes() throws Exception {
         /**
          * Tests proxy object returned by {@link IgniteTransactions#localActiveTransactions()}
          */
    +    @Test
         public void testRollbackProxy() throws Exception {
    -        final CountDownLatch keyLocked = new CountDownLatch(1);
    +        final GridFutureAdapter keyLocked = new GridFutureAdapter<>();
     
             CountDownLatch waitCommit = new CountDownLatch(1);
     
    @@ -822,7 +847,7 @@ public void testRollbackProxy() throws Exception {
     
             IgniteInternalFuture lockFut = lockInTx(ig, keyLocked, waitCommit, 0);
     
    -        U.awaitQuiet(keyLocked);
    +        keyLocked.get();
     
             Collection txs = ig.transactions().localActiveTransactions();
     
    @@ -901,6 +926,7 @@ public void testRollbackProxy() throws Exception {
         /**
          *
          */
    +    @Test
         public void testRollbackOnTopologyLockPessimistic() throws Exception {
             final Ignite client = startClient();
     
    @@ -942,12 +968,12 @@ public void testRollbackOnTopologyLockPessimistic() throws Exception {
                 @Override public boolean apply(Event evt) {
                     runAsync(new Runnable() {
                         @Override public void run() {
    -                        try(Transaction tx = crd.transactions().withLabel("testLbl").txStart()) {
    +                        try (Transaction tx = crd.transactions().withLabel("testLbl").txStart()) {
                                 // Wait for node start.
                                 waitForCondition(new GridAbsPredicate() {
                                     @Override public boolean apply() {
                                         return crd.cluster().topologyVersion() != GRID_CNT +
    -                                        /** client node */ 1  + /** stop server node */ 1 + /** start server node */ 1;
    +                                        /** client node */1 + /** stop server node */1 + /** start server node */1;
                                     }
                                 }, 10_000);
     
    @@ -1020,30 +1046,31 @@ public void testRollbackOnTopologyLockPessimistic() throws Exception {
          * Locks entry in tx and delays commit until signalled.
          *
          * @param node Near node.
    -     * @param keyLocked Latch for notifying until key is locked.
    +     * @param keyLocked Future to be done when key is locked.
          * @param waitCommit Latch for waiting until commit is allowed.
          * @param timeout Timeout.
    -     *
          * @return tx completion future.
          */
    -    private IgniteInternalFuture lockInTx(final Ignite node, final CountDownLatch keyLocked,
    +    private IgniteInternalFuture lockInTx(final Ignite node, final GridFutureAdapter keyLocked,
             final CountDownLatch waitCommit, final int timeout) throws Exception {
             return multithreadedAsync(new Runnable() {
                 @Override public void run() {
    -                Transaction tx = node.transactions().withLabel(LABEL).txStart(PESSIMISTIC, REPEATABLE_READ, timeout, 1);
    +                try {
    +                    Transaction tx = node.transactions().withLabel(LABEL).txStart(PESSIMISTIC, REPEATABLE_READ, timeout, 1);
     
    -                node.cache(CACHE_NAME).put(0, 0);
    +                    node.cache(CACHE_NAME).put(0, 0);
     
    -                keyLocked.countDown();
    +                    keyLocked.onDone();
     
    -                try {
                         U.await(waitCommit);
    +
    +                    tx.commit();
                     }
    -                catch (IgniteInterruptedCheckedException e) {
    -                    fail("Lock thread was interrupted while waiting");
    -                }
    +                catch (Throwable e) {
    +                    keyLocked.onDone(e);
     
    -                tx.commit();
    +                    throw new RuntimeException(e);
    +                }
                 }
             }, 1, "tx-lock-thread");
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncWithPersistenceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncWithPersistenceTest.java
    index a11dca7cf83e6..8d24f05313dd4 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncWithPersistenceTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackAsyncWithPersistenceTest.java
    @@ -17,6 +17,9 @@
     
     package org.apache.ignite.internal.processors.cache.transactions;
     
    +import org.apache.ignite.testframework.MvccFeatureChecker;
    +import org.junit.Test;
    +
     import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS;
     
     /**
    @@ -53,5 +56,14 @@ public class TxRollbackAsyncWithPersistenceTest extends TxRollbackAsyncTest {
     
             cleanPersistenceDir();
         }
    +
    +    /** {@inheritDoc} */
    +    @Test
    +    @Override public void testSynchronousRollback() throws Exception {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            fail("https://issues.apache.org/jira/browse/IGNITE-10785");
    +
    +        super.testSynchronousRollback();
    +    }
     }
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnIncorrectParamsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnIncorrectParamsTest.java
    index 8aafa8b091ba9..2d886a46b7a02 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnIncorrectParamsTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnIncorrectParamsTest.java
    @@ -28,20 +28,32 @@
     import org.apache.ignite.lang.IgniteBiPredicate;
     import org.apache.ignite.lang.IgnitePredicate;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.events.EventType.EVT_TX_STARTED;
     
     /**
      * Tests transaction rollback on incorrect tx params.
      */
    +@RunWith(JUnit4.class)
     public class TxRollbackOnIncorrectParamsTest extends GridCommonAbstractTest {
    +    /** {@inheritDoc} */
    +    @Override protected void beforeTest() throws Exception {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            fail("https://issues.apache.org/jira/browse/IGNITE-10415");
    +    }
    +
         /**
          *
          */
    +    @Test
         public void testTimeoutSetLocalGuarantee() throws Exception {
             Ignite ignite = startGrid(0);
     
    @@ -61,14 +73,14 @@ public void testTimeoutSetLocalGuarantee() throws Exception {
             IgniteCache cache = ignite.getOrCreateCache(defaultCacheConfiguration());
     
             try (Transaction tx = ignite.transactions().txStart(
    -            TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ, 200, 2)) {
    +            TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, 200, 2)) {
                 cache.put(1, 1);
     
                 tx.commit();
             }
     
             try (Transaction tx = ignite.transactions().txStart(
    -            TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ, 100, 2)) {
    +            TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, 100, 2)) {
                 cache.put(1, 2);
     
                 tx.commit();
    @@ -94,6 +106,7 @@ public void testTimeoutSetLocalGuarantee() throws Exception {
         /**
          *
          */
    +    @Test
         public void testLabelFilledLocalGuarantee() throws Exception {
             Ignite ignite = startGrid(0);
     
    @@ -133,6 +146,7 @@ public void testLabelFilledLocalGuarantee() throws Exception {
         /**
          *
          */
    +    @Test
         public void testLabelFilledRemoteGuarantee() throws Exception {
             Ignite ignite = startGrid(0);
             Ignite remote = startGrid(1);
    @@ -193,6 +207,7 @@ public void testLabelFilledRemoteGuarantee() throws Exception {
         /**
          *
          */
    +    @Test
         public void testTimeoutSetRemoteGuarantee() throws Exception {
             Ignite ignite = startGrid(0);
             Ignite remote = startGrid(1);
    @@ -216,14 +231,14 @@ public void testTimeoutSetRemoteGuarantee() throws Exception {
                 EVT_TX_STARTED);
     
             try (Transaction tx = ignite.transactions().txStart(
    -            TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ, 100, 2)) {
    +            TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, 100, 2)) {
                 cacheLocal.put(1, 1);
     
                 tx.commit();
             }
     
             try (Transaction tx = remote.transactions().txStart(
    -            TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ, 100, 2)) {
    +            TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, 100, 2)) {
                 cacheRemote.put(1, 2);
     
                 tx.commit();
    @@ -255,6 +270,7 @@ public void testTimeoutSetRemoteGuarantee() throws Exception {
         /**
          *
          */
    +    @Test
         public void testRollbackInsideLocalListenerAfterRemoteFilter() throws Exception {
             Ignite ignite = startGrid(0);
             Ignite remote = startGrid(1);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutOnePhaseCommitTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutOnePhaseCommitTest.java
    new file mode 100644
    index 0000000000000..27551d9af3d69
    --- /dev/null
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutOnePhaseCommitTest.java
    @@ -0,0 +1,215 @@
    +/*
    + * 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.
    + */
    +
    +package org.apache.ignite.internal.processors.cache.transactions;
    +
    +import java.util.concurrent.CountDownLatch;
    +import java.util.concurrent.TimeUnit;
    +import org.apache.ignite.Ignite;
    +import org.apache.ignite.IgniteCheckedException;
    +import org.apache.ignite.configuration.CacheConfiguration;
    +import org.apache.ignite.configuration.IgniteConfiguration;
    +import org.apache.ignite.internal.IgniteEx;
    +import org.apache.ignite.internal.IgniteInternalFuture;
    +import org.apache.ignite.internal.IgniteInterruptedCheckedException;
    +import org.apache.ignite.internal.TestRecordingCommunicationSpi;
    +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareResponse;
    +import org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2;
    +import org.apache.ignite.internal.util.typedef.X;
    +import org.apache.ignite.internal.util.typedef.internal.U;
    +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.apache.ignite.transactions.Transaction;
    +import org.apache.ignite.transactions.TransactionConcurrency;
    +import org.apache.ignite.transactions.TransactionTimeoutException;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
    +
    +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
    +import static org.apache.ignite.testframework.GridTestUtils.runAsync;
    +import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
    +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
    +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
    +
    +/**
    + * Tests rollback on timeout scenarios for one-phase commit protocol.
    + */
    +@RunWith(JUnit4.class)
    +public class TxRollbackOnTimeoutOnePhaseCommitTest extends GridCommonAbstractTest {
    +    /** */
    +    private static final int GRID_CNT = 2;
    +
    +    /** {@inheritDoc} */
    +    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    +        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    +
    +        cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
    +
    +        boolean client = igniteInstanceName.startsWith("client");
    +
    +        cfg.setClientMode(client);
    +
    +        if (!client) {
    +            CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    +
    +            ccfg.setAtomicityMode(TRANSACTIONAL);
    +            ccfg.setBackups(1);
    +            ccfg.setWriteSynchronizationMode(FULL_SYNC);
    +            ccfg.setOnheapCacheEnabled(false);
    +
    +            cfg.setCacheConfiguration(ccfg);
    +        }
    +
    +        return cfg;
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override protected void beforeTest() throws Exception {
    +        super.beforeTest();
    +
    +        startGridsMultiThreaded(GRID_CNT);
    +
    +        startGrid("client");
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Override protected void afterTest() throws Exception {
    +        super.afterTest();
    +
    +        stopAllGrids();
    +    }
    +
    +    /** */
    +    @Test
    +    public void testRollbackOnTimeoutPartitionDesyncPessimistic() throws Exception {
    +        doTestRollbackOnTimeoutPartitionDesync(PESSIMISTIC);
    +    }
    +
    +    /** */
    +    @Test
    +    public void testRollbackOnTimeoutPartitionDesyncOptimistic() throws Exception {
    +        doTestRollbackOnTimeoutPartitionDesync(OPTIMISTIC);
    +    }
    +
    +    /** */
    +    @Test
    +    public void testUnlockOptimistic() throws IgniteCheckedException {
    +        IgniteEx client = grid("client");
    +
    +        assertNotNull(client.cache(DEFAULT_CACHE_NAME));
    +
    +        int key = 0;
    +
    +        CountDownLatch lock = new CountDownLatch(1);
    +        CountDownLatch finish = new CountDownLatch(1);
    +
    +        IgniteInternalFuture fut = runAsync(() -> {
    +            try (Transaction tx = client.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, 0, 1)) {
    +                client.cache(DEFAULT_CACHE_NAME).put(key, key + 1);
    +
    +                lock.countDown();
    +
    +                try {
    +                    assertTrue(U.await(finish, 30, TimeUnit.SECONDS));
    +                }
    +                catch (IgniteInterruptedCheckedException e) {
    +                    fail();
    +                }
    +
    +                tx.commit();
    +            }
    +        });
    +
    +        try (Transaction tx = client.transactions().txStart(OPTIMISTIC, REPEATABLE_READ, 200, 1)) {
    +            try {
    +                assertTrue(U.await(lock, 30, TimeUnit.SECONDS));
    +            }
    +            catch (IgniteInterruptedCheckedException e) {
    +                fail();
    +            }
    +
    +            client.cache(DEFAULT_CACHE_NAME).put(key, key);
    +
    +            tx.commit();
    +
    +            // fail(); // TODO IGNITE-10027 throw timeout exception for optimistic timeout.
    +        }
    +        catch (Exception e) {
    +            assertTrue(e.getClass().getName(), X.hasCause(e, TransactionTimeoutException.class));
    +        }
    +
    +        assertNull(client.cache(DEFAULT_CACHE_NAME).get(key));
    +
    +        finish.countDown();
    +
    +        fut.get();
    +
    +        assertEquals(1, client.cache(DEFAULT_CACHE_NAME).get(key));
    +    }
    +
    +    /** */
    +    private void doTestRollbackOnTimeoutPartitionDesync(TransactionConcurrency concurrency) throws Exception {
    +        IgniteEx client = grid("client");
    +
    +        assertNotNull(client.cache(DEFAULT_CACHE_NAME));
    +
    +        int key = 0;
    +
    +        Ignite primary = primaryNode(key, DEFAULT_CACHE_NAME);
    +        Ignite backup = backupNode(key, DEFAULT_CACHE_NAME);
    +
    +        TestRecordingCommunicationSpi backupSpi = TestRecordingCommunicationSpi.spi(backup);
    +        backupSpi.blockMessages(GridDhtTxPrepareResponse.class, primary.name());
    +
    +        IgniteInternalFuture fut = runAsync(() -> {
    +            try {
    +                backupSpi.waitForBlocked(1, 5000);
    +            }
    +            catch (InterruptedException e) {
    +                fail();
    +            }
    +
    +            doSleep(500);
    +
    +            backupSpi.stopBlock();
    +        });
    +
    +        try (Transaction tx = client.transactions().txStart(concurrency, REPEATABLE_READ, 500, 1)) {
    +            client.cache(DEFAULT_CACHE_NAME).put(key, key);
    +
    +            tx.commit();
    +        }
    +        catch (Exception e) {
    +            assertTrue(e.getClass().getName(), X.hasCause(e, TransactionTimeoutException.class));
    +        }
    +
    +        fut.get();
    +
    +        IdleVerifyResultV2 res = idleVerify(client, DEFAULT_CACHE_NAME);
    +
    +        if (res.hasConflicts()) {
    +            StringBuilder b = new StringBuilder();
    +
    +            res.print(b::append);
    +
    +            fail(b.toString());
    +        }
    +
    +        checkFutures();
    +    }
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutTest.java
    index ccf4c8aa88ee6..fb20162e5efa2 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTimeoutTest.java
    @@ -22,7 +22,6 @@
     import java.util.List;
     import java.util.Map;
     import java.util.Random;
    -import java.util.UUID;
     import java.util.concurrent.CountDownLatch;
     import java.util.concurrent.ThreadLocalRandom;
     import java.util.concurrent.atomic.AtomicBoolean;
    @@ -37,8 +36,6 @@
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.configuration.NearCacheConfiguration;
    -import org.apache.ignite.events.Event;
    -import org.apache.ignite.events.EventType;
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
     import org.apache.ignite.internal.IgniteInternalFuture;
    @@ -54,32 +51,25 @@
     import org.apache.ignite.internal.util.typedef.G;
     import org.apache.ignite.internal.util.typedef.X;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.internal.visor.VisorTaskArgument;
    -import org.apache.ignite.internal.visor.tx.VisorTxInfo;
    -import org.apache.ignite.internal.visor.tx.VisorTxOperation;
    -import org.apache.ignite.internal.visor.tx.VisorTxTask;
    -import org.apache.ignite.internal.visor.tx.VisorTxTaskArg;
    -import org.apache.ignite.internal.visor.tx.VisorTxTaskResult;
    -import org.apache.ignite.lang.IgniteBiPredicate;
    -import org.apache.ignite.lang.IgniteClosure;
     import org.apache.ignite.lang.IgniteInClosure;
    -import org.apache.ignite.lang.IgnitePredicate;
     import org.apache.ignite.plugin.extensions.communication.Message;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
    +import org.apache.ignite.testframework.GridTestUtils.SF;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionDeadlockException;
     import org.apache.ignite.transactions.TransactionIsolation;
     import org.apache.ignite.transactions.TransactionTimeoutException;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.lang.Thread.sleep;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
     import static org.apache.ignite.testframework.GridTestUtils.runAsync;
    -import static org.apache.ignite.testframework.GridTestUtils.runAsync;
     import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
     import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
     import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
    @@ -89,9 +79,10 @@
     /**
      * Tests an ability to eagerly rollback timed out transactions.
      */
    +@RunWith(JUnit4.class)
     public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest {
         /** */
    -    private static final long DURATION = 60 * 1000L;
    +    private static final long DURATION = SF.apply(60 * 1000);
     
         /** */
         private static final long TX_MIN_TIMEOUT = 1;
    @@ -99,9 +90,6 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest {
         /** */
         private static final String CACHE_NAME = "test";
     
    -    /** IP finder. */
    -    private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int GRID_CNT = 3;
     
    @@ -111,8 +99,6 @@ public class TxRollbackOnTimeoutTest extends GridCommonAbstractTest {
     
             cfg.setConsistentId(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -
             cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
     
             boolean client = "client".equals(igniteInstanceName);
    @@ -144,6 +130,9 @@ protected boolean nearCacheEnabled() {
     
         /** {@inheritDoc} */
         @Override protected void beforeTest() throws Exception {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            fail("https://issues.apache.org/jira/browse/IGNITE-7388");
    +
             super.beforeTest();
     
             startGridsMultiThreaded(GRID_CNT);
    @@ -184,6 +173,7 @@ protected void validateDeadlockException(Exception e) {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLockAndConcurrentTimeout() throws Exception {
             startClient();
     
    @@ -251,6 +241,7 @@ private void lock(final Ignite node, final boolean retry) throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testWaitingTxUnblockedOnTimeout() throws Exception {
             waitingTxUnblockedOnTimeout(grid(0), grid(0));
     
    @@ -274,6 +265,7 @@ public void testWaitingTxUnblockedOnTimeout() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testWaitingTxUnblockedOnThreadDeath() throws Exception {
             waitingTxUnblockedOnThreadDeath(grid(0), grid(0));
     
    @@ -297,6 +289,7 @@ public void testWaitingTxUnblockedOnThreadDeath() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeadlockUnblockedOnTimeout() throws Exception {
             deadlockUnblockedOnTimeout(ignite(0), ignite(1));
     
    @@ -375,6 +368,7 @@ private void deadlockUnblockedOnTimeout(final Ignite node1, final Ignite node2)
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testTimeoutRemoval() throws Exception {
             IgniteEx client = (IgniteEx)startClient();
     
    @@ -406,6 +400,7 @@ public void testTimeoutRemoval() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testSimple() throws Exception {
             for (TransactionConcurrency concurrency : TransactionConcurrency.values())
                 for (TransactionIsolation isolation : TransactionIsolation.values()) {
    @@ -417,6 +412,7 @@ public void testSimple() throws Exception {
         /**
          * Test timeouts with random values and different tx configurations.
          */
    +    @Test
         public void testRandomMixedTxConfigurations() throws Exception {
             final Ignite client = startClient();
     
    @@ -521,6 +517,7 @@ public void testRandomMixedTxConfigurations() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testTimeoutOnPrimaryDHTNode() throws Exception {
             final ClusterNode n0 = grid(0).affinity(CACHE_NAME).mapKeyToNode(0);
     
    @@ -535,6 +532,7 @@ public void testTimeoutOnPrimaryDHTNode() throws Exception {
         /**
          *
          */
    +    @Test
         public void testLockRelease() throws Exception {
             final Ignite client = startClient();
     
    @@ -596,6 +594,7 @@ public void testLockRelease() throws Exception {
         /**
          *
          */
    +    @Test
         public void testEnlistManyRead() throws Exception {
             testEnlistMany(false);
         }
    @@ -603,6 +602,7 @@ public void testEnlistManyRead() throws Exception {
         /**
          *
          */
    +    @Test
         public void testEnlistManyWrite() throws Exception {
             testEnlistMany(true);
         }
    @@ -610,6 +610,7 @@ public void testEnlistManyWrite() throws Exception {
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxRemapOptimisticReadCommitted() throws Exception {
             doTestRollbackOnTimeoutTxRemap(OPTIMISTIC, READ_COMMITTED, true);
         }
    @@ -617,6 +618,7 @@ public void testRollbackOnTimeoutTxRemapOptimisticReadCommitted() throws Excepti
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxRemapOptimisticRepeatableRead() throws Exception {
             doTestRollbackOnTimeoutTxRemap(OPTIMISTIC, REPEATABLE_READ, true);
         }
    @@ -624,6 +626,7 @@ public void testRollbackOnTimeoutTxRemapOptimisticRepeatableRead() throws Except
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxRemapOptimisticSerializable() throws Exception {
             doTestRollbackOnTimeoutTxRemap(OPTIMISTIC, SERIALIZABLE, true);
         }
    @@ -631,6 +634,7 @@ public void testRollbackOnTimeoutTxRemapOptimisticSerializable() throws Exceptio
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxRemapPessimisticReadCommitted() throws Exception {
             doTestRollbackOnTimeoutTxRemap(PESSIMISTIC, READ_COMMITTED, true);
         }
    @@ -638,6 +642,7 @@ public void testRollbackOnTimeoutTxRemapPessimisticReadCommitted() throws Except
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxRemapPessimisticRepeatableRead() throws Exception {
             doTestRollbackOnTimeoutTxRemap(PESSIMISTIC, REPEATABLE_READ, true);
         }
    @@ -645,6 +650,7 @@ public void testRollbackOnTimeoutTxRemapPessimisticRepeatableRead() throws Excep
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxRemapPessimisticSerializable() throws Exception {
             doTestRollbackOnTimeoutTxRemap(PESSIMISTIC, SERIALIZABLE, true);
         }
    @@ -652,6 +658,7 @@ public void testRollbackOnTimeoutTxRemapPessimisticSerializable() throws Excepti
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxServerRemapOptimisticReadCommitted() throws Exception {
             doTestRollbackOnTimeoutTxRemap(OPTIMISTIC, READ_COMMITTED, false);
         }
    @@ -659,6 +666,7 @@ public void testRollbackOnTimeoutTxServerRemapOptimisticReadCommitted() throws E
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxServerRemapOptimisticRepeatableRead() throws Exception {
             doTestRollbackOnTimeoutTxRemap(OPTIMISTIC, REPEATABLE_READ, false);
         }
    @@ -666,6 +674,7 @@ public void testRollbackOnTimeoutTxServerRemapOptimisticRepeatableRead() throws
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxServerRemapOptimisticSerializable() throws Exception {
             doTestRollbackOnTimeoutTxRemap(OPTIMISTIC, SERIALIZABLE, false);
         }
    @@ -673,6 +682,7 @@ public void testRollbackOnTimeoutTxServerRemapOptimisticSerializable() throws Ex
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxServerRemapPessimisticReadCommitted() throws Exception {
             doTestRollbackOnTimeoutTxRemap(PESSIMISTIC, READ_COMMITTED, false);
         }
    @@ -680,6 +690,7 @@ public void testRollbackOnTimeoutTxServerRemapPessimisticReadCommitted() throws
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxServerRemapPessimisticRepeatableRead() throws Exception {
             doTestRollbackOnTimeoutTxRemap(PESSIMISTIC, REPEATABLE_READ, false);
         }
    @@ -687,6 +698,7 @@ public void testRollbackOnTimeoutTxServerRemapPessimisticRepeatableRead() throws
         /**
          *
          */
    +    @Test
         public void testRollbackOnTimeoutTxServerRemapPessimisticSerializable() throws Exception {
             doTestRollbackOnTimeoutTxRemap(PESSIMISTIC, SERIALIZABLE, false);
         }
    @@ -819,7 +831,12 @@ private void testEnlistMany(boolean write) throws Exception {
                 tx.commit();
             }
             catch (Throwable t) {
    -            assertTrue(X.hasCause(t, TransactionTimeoutException.class));
    +            boolean timedOut = X.hasCause(t, TransactionTimeoutException.class);
    +
    +            if (!timedOut)
    +                log.error("Got unexpected exception", t);
    +
    +            assertTrue(timedOut);
             }
     
             assertEquals(0, client.cache(CACHE_NAME).size());
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTopologyChangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTopologyChangeTest.java
    index 13c5e41c27cb3..797a6397a8cb9 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTopologyChangeTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxRollbackOnTopologyChangeTest.java
    @@ -36,10 +36,13 @@
     import org.apache.ignite.internal.processors.cache.GridCacheFuture;
     import org.apache.ignite.internal.util.typedef.G;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
    +import org.junit.Assume;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.lang.Thread.yield;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    @@ -50,6 +53,7 @@
     /**
      * Tests an ability to rollback transactions on topology change.
      */
    +@RunWith(JUnit4.class)
     public class TxRollbackOnTopologyChangeTest extends GridCommonAbstractTest {
         /** */
         public static final int ROLLBACK_TIMEOUT = 500;
    @@ -57,9 +61,6 @@ public class TxRollbackOnTopologyChangeTest extends GridCommonAbstractTest {
         /** */
         private static final String CACHE_NAME = "test";
     
    -    /** IP finder. */
    -    private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int SRV_CNT = 6;
     
    @@ -79,8 +80,6 @@ public class TxRollbackOnTopologyChangeTest extends GridCommonAbstractTest {
             cfg.setTransactionConfiguration(new TransactionConfiguration().
                 setTxTimeoutOnPartitionMapExchange(ROLLBACK_TIMEOUT));
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -
             cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
     
             cfg.setClientMode(getTestIgniteInstanceIndex(igniteInstanceName) >= SRV_CNT);
    @@ -98,6 +97,9 @@ public class TxRollbackOnTopologyChangeTest extends GridCommonAbstractTest {
     
         /** {@inheritDoc} */
         @Override protected void beforeTest() throws Exception {
    +        Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9322",
    +            MvccFeatureChecker.forcedMvcc()); //Won't start nodes if the only test mutes.
    +
             super.beforeTest();
     
             startGridsMultiThreaded(TOTAL_CNT);
    @@ -113,6 +115,7 @@ public class TxRollbackOnTopologyChangeTest extends GridCommonAbstractTest {
         /**
          * Tests rollbacks on topology change.
          */
    +    @Test
         public void testRollbackOnTopologyChange() throws Exception {
             final AtomicBoolean stop = new AtomicBoolean();
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxStateChangeEventTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxStateChangeEventTest.java
    index 01c87aed7ba5b..c09569b149a60 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxStateChangeEventTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxStateChangeEventTest.java
    @@ -21,15 +21,22 @@
     import org.apache.ignite.Ignite;
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.IgniteEvents;
    +import org.apache.ignite.IgniteTransactions;
    +import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.events.Event;
     import org.apache.ignite.events.TransactionStateChangedEvent;
    +import org.apache.ignite.internal.IgniteInterruptedCheckedException;
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.lang.IgnitePredicate;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
     import org.apache.ignite.transactions.TransactionState;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.events.EventType.EVTS_TX;
     import static org.apache.ignite.events.EventType.EVT_TX_COMMITTED;
    @@ -41,6 +48,7 @@
     /**
      * Tests transaction state change event.
      */
    +@RunWith(JUnit4.class)
     public class TxStateChangeEventTest extends GridCommonAbstractTest {
         /** Label. */
         private final String lb = "testLabel";
    @@ -66,21 +74,23 @@ public class TxStateChangeEventTest extends GridCommonAbstractTest {
         /**
          *
          */
    +    @Test
         public void testLocal() throws Exception {
    -        test(true);
    +        check(true);
         }
     
         /**
          *
          */
    +    @Test
         public void testRemote() throws Exception {
    -        test(false);
    +        check(false);
         }
     
         /**
          *
          */
    -    private void test(boolean loc) throws Exception {
    +    private void check(boolean loc) throws Exception {
             Ignite ignite = startGrids(5);
     
             final IgniteEvents evts = loc ? ignite.events() : grid(3).events();
    @@ -104,27 +114,51 @@ private void test(boolean loc) throws Exception {
                     },
                     EVTS_TX);
     
    -        IgniteCache cache = ignite.getOrCreateCache(defaultCacheConfiguration().setBackups(2));
    +        IgniteTransactions txs = ignite.transactions();
     
    -        // create & commit
    -        try (Transaction tx = ignite.transactions().withLabel(lb).txStart(
    -            TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE, timeout, 3)) {
    -            cache.put(1, 1);
    +        IgniteCache cache = ignite.getOrCreateCache(getCacheConfig());
     
    -            tx.commit();
    +        checkCommit(txs, cache);
    +
    +        if (!MvccFeatureChecker.forcedMvcc())
    +            checkSuspendResume(txs, cache);
    +
    +        checkRollback(txs, cache);
    +    }
    +
    +    /** */
    +    @SuppressWarnings("unchecked")
    +    private CacheConfiguration getCacheConfig() {
    +        return defaultCacheConfiguration().setBackups(2);
    +    }
    +
    +    /**
    +     * @param txs Transaction manager.
    +     * @param cache Ignite cache.
    +     */
    +    private void checkRollback(IgniteTransactions txs, IgniteCache cache) {
    +        // create & rollback (pessimistic)
    +        try (Transaction tx = txs.withLabel(lb).txStart(
    +            TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, timeout, 3)) {
    +            cache.put(4, 5);
             }
     
             assertTrue(
                 creation.get() &&
    -                commit.get() &&
    -                !rollback.get() &&
    +                !commit.get() &&
    +                rollback.get() &&
                     !suspend.get() &&
                     !resume.get());
    +    }
     
    -        clear();
    -
    +    /**
    +     * @param txs Transaction manager.
    +     * @param cache Ignite cache.
    +     */
    +    private void checkSuspendResume(IgniteTransactions txs,
    +        IgniteCache cache) throws IgniteInterruptedCheckedException {
             // create & suspend & resume & commit
    -        try (Transaction tx = ignite.transactions().withLabel(lb).txStart(
    +        try (Transaction tx = txs.withLabel(lb).txStart(
                 TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE, timeout, 3)) {
                 cache.put(2, 7);
     
    @@ -145,19 +179,29 @@ private void test(boolean loc) throws Exception {
                     resume.get());
     
             clear();
    +    }
     
    -        // create & rollback (pessimistic)
    -        try (Transaction tx = ignite.transactions().withLabel(lb).txStart(
    -            TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE, timeout, 3)) {
    -            cache.put(4, 5);
    +    /**
    +     * @param txs Transaction manager.
    +     * @param cache Ignite cache.
    +     */
    +    private void checkCommit(IgniteTransactions txs, IgniteCache cache) {
    +        // create & commit
    +        try (Transaction tx = txs.withLabel(lb).txStart(
    +            TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ, timeout, 3)) {
    +            cache.put(1, 1);
    +
    +            tx.commit();
             }
     
             assertTrue(
                 creation.get() &&
    -                !commit.get() &&
    -                rollback.get() &&
    +                commit.get() &&
    +                !rollback.get() &&
                     !suspend.get() &&
                     !resume.get());
    +
    +        clear();
         }
     
         /**
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxWithSmallTimeoutAndContentionOneKeyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxWithSmallTimeoutAndContentionOneKeyTest.java
    index 62f46352391bf..7ce79a556743a 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxWithSmallTimeoutAndContentionOneKeyTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxWithSmallTimeoutAndContentionOneKeyTest.java
    @@ -37,13 +37,15 @@
     import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecordV2;
     import org.apache.ignite.internal.processors.cache.verify.PartitionKeyV2;
     import org.apache.ignite.internal.util.typedef.internal.SB;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.transactions.Transaction;
     import org.apache.ignite.transactions.TransactionConcurrency;
     import org.apache.ignite.transactions.TransactionIsolation;
    +import org.junit.Assume;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.testframework.GridTestUtils.runAsync;
     import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
    @@ -56,10 +58,8 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class TxWithSmallTimeoutAndContentionOneKeyTest extends GridCommonAbstractTest {
    -    /** */
    -    public static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int TIME_TO_EXECUTE = 30 * 1000;
     
    @@ -72,8 +72,6 @@ public class TxWithSmallTimeoutAndContentionOneKeyTest extends GridCommonAbstrac
     
             cfg.setConsistentId("NODE_" + name.substring(name.length() - 1));
     
    -        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
    -
             cfg.setDataStorageConfiguration(
                 new DataStorageConfiguration()
                     .setDefaultDataRegionConfiguration(
    @@ -112,6 +110,9 @@ public class TxWithSmallTimeoutAndContentionOneKeyTest extends GridCommonAbstrac
          * @return Random transaction type.
          */
         protected TransactionConcurrency transactionConcurrency() {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            return PESSIMISTIC;
    +
             ThreadLocalRandom random = ThreadLocalRandom.current();
     
             return random.nextBoolean() ? OPTIMISTIC : PESSIMISTIC;
    @@ -121,6 +122,9 @@ protected TransactionConcurrency transactionConcurrency() {
          * @return Random transaction isolation level.
          */
         protected TransactionIsolation transactionIsolation(){
    +        if (MvccFeatureChecker.forcedMvcc())
    +            return REPEATABLE_READ;
    +
             ThreadLocalRandom random = ThreadLocalRandom.current();
     
             switch (random.nextInt(3)) {
    @@ -149,7 +153,10 @@ protected long randomTimeOut() {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void test() throws Exception {
    +        Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10455", MvccFeatureChecker.forcedMvcc());
    +
             startGrids(4);
     
             client = true;
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
    index 16ea84857840a..731970507ba74 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
    @@ -28,10 +28,14 @@
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.cache.CacheEntry;
     import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Versioned entry abstract test.
      */
    +@RunWith(JUnit4.class)
     public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractSelfTest {
         /** Entries number to store in a cache. */
         private static final int ENTRIES_NUM = 500;
    @@ -54,6 +58,7 @@ public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractS
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInvoke() throws Exception {
             Cache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -71,6 +76,7 @@ public void testInvoke() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testInvokeAll() throws Exception {
             Cache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -95,6 +101,7 @@ public void testInvokeAll() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalPeek() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -107,6 +114,7 @@ public void testLocalPeek() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testVersionComparision() throws Exception {
             IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -142,4 +150,4 @@ private void checkVersionedEntry(CacheEntry entry) {
             assertNotNull(entry.getKey());
             assertNotNull(entry.getValue());
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalTransactionalSelfTest.java
    index d7fc93809848d..1797bbea40232 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalTransactionalSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryLocalTransactionalSelfTest.java
    @@ -19,6 +19,7 @@
     
     import org.apache.ignite.cache.CacheAtomicityMode;
     import org.apache.ignite.cache.CacheMode;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     
     /**
      *
    @@ -38,4 +39,12 @@ public class CacheVersionedEntryLocalTransactionalSelfTest extends CacheVersione
         @Override protected CacheAtomicityMode atomicityMode() {
             return CacheAtomicityMode.TRANSACTIONAL;
         }
    -}
    \ No newline at end of file
    +
    +    /** {@inheritDoc} */
    +    @Override public void setUp() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE);
    +
    +        super.setUp();
    +    }
    +
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorRemoteTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorRemoteTest.java
    index 5fd84165fc477..6513d963f5930 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorRemoteTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorRemoteTest.java
    @@ -31,11 +31,15 @@
     import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.testframework.junits.common.GridCommonTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Tests execution of anonymous closures on remote nodes.
      */
     @GridCommonTest(group = "Closure Processor")
    +@RunWith(JUnit4.class)
     public class GridClosureProcessorRemoteTest extends GridCommonAbstractTest {
         /** Number of grids started for tests. Should not be less than 2. */
         public static final int NODES_CNT = 2;
    @@ -67,6 +71,7 @@ public class GridClosureProcessorRemoteTest extends GridCommonAbstractTest {
         /**
          * @throws Exception Thrown in case of failure.
          */
    +    @Test
         public void testAnonymousBroadcast() throws Exception {
             Ignite g = grid(0);
     
    @@ -91,6 +96,7 @@ public void testAnonymousBroadcast() throws Exception {
         /**
          * @throws Exception Thrown in case of failure.
          */
    +    @Test
         public void testAnonymousUnicast() throws Exception {
             Ignite g = grid(0);
     
    @@ -118,6 +124,7 @@ public void testAnonymousUnicast() throws Exception {
          *
          * @throws Exception Thrown in case of failure.
          */
    +    @Test
         public void testAnonymousUnicastRequest() throws Exception {
             Ignite g = grid(0);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorSelfTest.java
    index fef74e8f4d145..b851d0663b527 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorSelfTest.java
    @@ -41,18 +41,19 @@
     import org.apache.ignite.lang.IgniteRunnable;
     import org.apache.ignite.resources.IgniteInstanceResource;
     import org.apache.ignite.resources.LoggerResource;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.testframework.junits.common.GridCommonTest;
     import org.jetbrains.annotations.Nullable;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Tests for {@link GridClosureProcessor}.
      */
     @GridCommonTest(group = "Closure Processor")
    +@RunWith(JUnit4.class)
     public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
         /** Number of grids started for tests. Should not be less than 2. */
         private static final int NODES_CNT = 2;
    @@ -63,19 +64,10 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
         /** Timeout used in timed tests. */
         private static final long JOB_TIMEOUT = 100;
     
    -    /** IP finder. */
    -    private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    -
    -        discoSpi.setIpFinder(ipFinder);
    -
    -        cfg.setDiscoverySpi(discoSpi);
    -
             cfg.setCacheConfiguration();
     
             return cfg;
    @@ -314,6 +306,7 @@ private IgnitePredicate singleNodePredicate(final int idx) {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRunAsyncSingle() throws Exception {
             IgniteRunnable job = new ClosureTestRunnable();
     
    @@ -340,6 +333,7 @@ public void testRunAsyncSingle() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRunAsyncMultiple() throws Exception {
             Collection jobs = F.asList(new ClosureTestRunnable(), new ClosureTestRunnable());
     
    @@ -354,6 +348,7 @@ public void testRunAsyncMultiple() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCallAsyncSingle() throws Exception {
             IgniteCallable job = new ClosureTestCallable();
     
    @@ -382,6 +377,7 @@ public void testCallAsyncSingle() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCallAsyncErrorNoFailover() throws Exception {
             IgniteCompute comp = compute(grid(0).cluster().forPredicate(F.notEqualTo(grid(0).localNode())));
     
    @@ -400,6 +396,7 @@ public void testCallAsyncErrorNoFailover() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testWithName() throws Exception {
             grid(0).compute().withName("TestTaskName").call(new ClosureTestCallable());
         }
    @@ -407,6 +404,7 @@ public void testWithName() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testWithTimeout() throws Exception {
             Collection jobs = F.asList(new TestCallableTimeout());
     
    @@ -438,6 +436,7 @@ public void testWithTimeout() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCallAsyncMultiple() throws Exception {
             Collection jobs = F.asList(new ClosureTestCallable(), new ClosureTestCallable());
     
    @@ -457,6 +456,7 @@ public void testCallAsyncMultiple() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReduceAsync() throws Exception {
             Collection jobs = F.asList(new ClosureTestCallable(), new ClosureTestCallable());
     
    @@ -477,6 +477,7 @@ public void testReduceAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReducerError() throws Exception {
             final Ignite g = grid(0);
     
    @@ -508,4 +509,4 @@ public void testReducerError() throws Exception {
                 }
             }, IgniteException.class, null);
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureSerializationTest.java
    index c6d14d81231c5..84970d0fd5ca5 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureSerializationTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureSerializationTest.java
    @@ -31,10 +31,14 @@
     import org.apache.ignite.resources.JobContextResource;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Tests handling of job result serialization error.
      */
    +@RunWith(JUnit4.class)
     public class GridClosureSerializationTest extends GridCommonAbstractTest {
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception {
    @@ -56,7 +60,8 @@ public class GridClosureSerializationTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    -    @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "Convert2Lambda"})
    +    @SuppressWarnings({"Convert2Lambda"})
    +    @Test
         public void testSerializationFailure() throws Exception {
             final IgniteEx ignite0 = grid(0);
             final IgniteEx ignite1 = grid(1);
    @@ -77,7 +82,8 @@ public void testSerializationFailure() throws Exception {
         /**
          * @throws Exception If failed.
          */
    -    @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "Convert2Lambda"})
    +    @SuppressWarnings({"Convert2Lambda"})
    +    @Test
         public void testExceptionSerializationFailure() throws Exception {
             final IgniteEx ignite0 = grid(0);
             final IgniteEx ignite1 = grid(1);
    @@ -98,7 +104,8 @@ public void testExceptionSerializationFailure() throws Exception {
         /**
          * @throws Exception If failed.
          */
    -    @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "Convert2Lambda"})
    +    @SuppressWarnings({"Convert2Lambda"})
    +    @Test
         public void testAttributesSerializationFailure() throws Exception {
             final IgniteEx ignite0 = grid(0);
             final IgniteEx ignite1 = grid(1);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridAddressResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridAddressResolverSelfTest.java
    index 2b706d5c2cf03..d29f062b0be93 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridAddressResolverSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridAddressResolverSelfTest.java
    @@ -30,11 +30,15 @@
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.testframework.junits.common.GridCommonTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Address Resolver test.
      */
     @GridCommonTest(group = "Kernal Self")
    +@RunWith(JUnit4.class)
     public class GridAddressResolverSelfTest extends GridCommonAbstractTest {
         /** */
         private final InetSocketAddress addr0 = new InetSocketAddress("test0.com", 5000);
    @@ -76,6 +80,7 @@ public class GridAddressResolverSelfTest extends GridCommonAbstractTest {
         }
     
         /** */
    +    @Test
         public void test() throws Exception {
             startGrid(0);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
    index 58c41b5165bfb..c73dd27025a18 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
    @@ -24,12 +24,16 @@
     import org.apache.ignite.lang.IgniteProductVersion;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.ignite.testframework.junits.common.GridCommonTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     import org.mockito.Mockito;
     
     /**
      * Update notifier test.
      */
     @GridCommonTest(group = "Kernal Self")
    +@RunWith(JUnit4.class)
     public class GridUpdateNotifierSelfTest extends GridCommonAbstractTest {
         /** */
         private String updateStatusParams;
    @@ -64,6 +68,7 @@ public class GridUpdateNotifierSelfTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNotifier() throws Exception {
             String nodeVer = IgniteProperties.get("ignite.version");
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
    index dc24156919be1..4bea890a0c802 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
    @@ -18,38 +18,22 @@
     package org.apache.ignite.internal.processors.compute;
     
     import org.apache.ignite.Ignite;
    -import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.lang.IgniteFuture;
     import org.apache.ignite.lang.IgniteInClosure;
     import org.apache.ignite.lang.IgniteRunnable;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Manual test to reproduce IGNITE-4053
      */
    +@RunWith(JUnit4.class)
     public class GridComputeJobExecutionErrorToLogManualTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private static final int GRID_CNT = 2;
     
    -    /** {@inheritDoc} */
    -    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    -        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    -
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(ipFinder);
    -
    -        cfg.setDiscoverySpi(disco);
    -
    -        return cfg;
    -    }
    -
         /** {@inheritDoc} */
         @Override protected void beforeTestsStarted() throws Exception {
             startGridsMultiThreaded(GRID_CNT, true);
    @@ -58,6 +42,7 @@ public class GridComputeJobExecutionErrorToLogManualTest extends GridCommonAbstr
         /**
          * @throws Exception If fails.
          */
    +    @Test
         public void testRuntimeException() throws Exception {
             Ignite ignite = grid(0);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java
    index d1fbb341373f4..3e6736ed06deb 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java
    @@ -50,11 +50,15 @@
     import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest;
     import org.jetbrains.annotations.Nullable;
     import org.junit.Assert;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Full API compute test.
      */
     @SuppressWarnings("unchecked")
    +@RunWith(JUnit4.class)
     public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariationsAbstractTest {
         /** Max job count. */
         private static final int MAX_JOB_COUNT = 10;
    @@ -177,6 +181,7 @@ protected void runTest(final Factory[] factories, final ComputeTest test) throws
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testExecuteTaskClass() throws Exception {
             runTest(jobFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -201,6 +206,7 @@ public void testExecuteTaskClass() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testExecuteTaskClassAsync() throws Exception {
             runTest(jobFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -225,6 +231,7 @@ public void testExecuteTaskClassAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testExecuteTask() throws Exception {
             runTest(jobFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -248,6 +255,7 @@ public void testExecuteTask() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testExecuteTaskAsync() throws Exception {
             runTest(jobFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -271,6 +279,7 @@ public void testExecuteTaskAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBroadcastClosure() throws Exception {
             runTest(closureFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -294,6 +303,7 @@ public void testBroadcastClosure() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBroadcastClosureAsync() throws Exception {
             runTest(closureFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -317,6 +327,7 @@ public void testBroadcastClosureAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBroadcastCallable() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -346,6 +357,7 @@ public void testBroadcastCallable() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBroadcastCallableAsync() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -375,6 +387,7 @@ public void testBroadcastCallableAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBroadcastRunnable() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -389,6 +402,7 @@ public void testBroadcastRunnable() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testBroadcastRunnableAsync() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -405,6 +419,7 @@ public void testBroadcastRunnableAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRun() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -427,6 +442,7 @@ public void testRun() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRunAsync() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -453,6 +469,7 @@ public void testRunAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testApplyAsync() throws Exception {
             runTest(closureFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -480,6 +497,7 @@ public void testApplyAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testApply() throws Exception {
             runTest(closureFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -499,6 +517,7 @@ public void testApply() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testApplyForCollection() throws Exception {
             runTest(closureFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -524,6 +543,7 @@ public void testApplyForCollection() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testApplyForCollectionAsync() throws Exception {
             runTest(closureFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -550,6 +570,7 @@ public void testApplyForCollectionAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testApplyForCollectionWithReducer() throws Exception {
             runTest(closureFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -585,6 +606,7 @@ public void testApplyForCollectionWithReducer() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testApplyForCollectionWithReducerAsync() throws Exception {
             runTest(closureFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -620,6 +642,7 @@ public void testApplyForCollectionWithReducerAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCallAsync() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -648,6 +671,7 @@ public void testCallAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCall() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -668,6 +692,7 @@ public void testCall() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCallCollection() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -690,6 +715,7 @@ public void testCallCollection() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCallCollectionAsync() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -712,6 +738,7 @@ public void testCallCollectionAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCallCollectionWithReducer() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -746,6 +773,7 @@ public void testCallCollectionWithReducer() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCallCollectionWithReducerAsync() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -780,6 +808,7 @@ public void testCallCollectionWithReducerAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAffinityCall() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -806,6 +835,7 @@ public void testAffinityCall() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAffinityCallAsync() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -834,6 +864,7 @@ public void testAffinityCallAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiCacheAffinityCall() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -861,6 +892,7 @@ public void testMultiCacheAffinityCall() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiCacheAffinityCallAsync() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -890,6 +922,7 @@ public void testMultiCacheAffinityCallAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiCacheByPartIdAffinityCall() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -917,6 +950,7 @@ public void testMultiCacheByPartIdAffinityCall() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiCacheByPartIdAffinityCallAsync() throws Exception {
             runTest(callableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -946,6 +980,7 @@ public void testMultiCacheByPartIdAffinityCallAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAffinityRun() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -965,6 +1000,7 @@ public void testAffinityRun() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAffinityRunAsync() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -986,6 +1022,7 @@ public void testAffinityRunAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiCacheAffinityRun() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -1006,6 +1043,7 @@ public void testMultiCacheAffinityRun() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiCacheAffinityRunAsync() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -1028,6 +1066,7 @@ public void testMultiCacheAffinityRunAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiCacheByPartIdAffinityRun() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -1048,6 +1087,7 @@ public void testMultiCacheByPartIdAffinityRun() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultiCacheByPartIdAffinityRunAsync() throws Exception {
             runTest(runnableFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -1070,6 +1110,7 @@ public void testMultiCacheByPartIdAffinityRunAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDeployExecuteByName() throws Exception {
             runTest(jobFactories, new ComputeTest() {
                 @Override public void test(Factory factory, Ignite ignite) throws Exception {
    @@ -1127,7 +1168,8 @@ public interface ComputeTest {
              * @param ignite Ignite instance to use.
              * @throws Exception If failed.
              */
    -        public void test(Factory factory, Ignite ignite) throws Exception;
    +        @Test
    +    public void test(Factory factory, Ignite ignite) throws Exception;
         }
     
         /**
    @@ -2469,4 +2511,4 @@ private static void writeJobState(ObjectOutput out, boolean isVal, byte bVal, ch
                 out.writeObject(eVal);
             }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorConfigurationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorConfigurationSelfTest.java
    index 2277100067848..64689105ed0af 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorConfigurationSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorConfigurationSelfTest.java
    @@ -21,34 +21,20 @@
     import org.apache.ignite.Ignition;
     import org.apache.ignite.configuration.ExecutorConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Tests custom executor configuration.
      */
    +@RunWith(JUnit4.class)
     public class IgniteComputeCustomExecutorConfigurationSelfTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
    -    /** {@inheritDoc} */
    -    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    -        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    -
    -        TcpDiscoverySpi disco = new TcpDiscoverySpi();
    -
    -        disco.setIpFinder(ipFinder);
    -
    -        cfg.setDiscoverySpi(disco);
    -
    -        return cfg;
    -    }
    -
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConfigurations() throws Exception {
             try {
                 checkStartWithInvalidConfiguration(getConfiguration("node0")
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorSelfTest.java
    index 18c52c0b5d94f..b59fdcfdb2024 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeCustomExecutorSelfTest.java
    @@ -36,12 +36,16 @@
     import org.apache.ignite.lang.IgniteRunnable;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.jetbrains.annotations.Nullable;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Tests custom executor named pools.
      *
      * https://issues.apache.org/jira/browse/IGNITE-4699
      */
    +@RunWith(JUnit4.class)
     public class IgniteComputeCustomExecutorSelfTest extends GridCommonAbstractTest {
         /** */
         private static final int GRID_CNT = 2;
    @@ -96,6 +100,7 @@ private ExecutorConfiguration createExecConfiguration(String name) {
         /**
          * @throws Exception If fails.
          */
    +    @Test
         public void testInvalidCustomExecutor() throws Exception {
             grid(0).compute().withExecutor("invalid").broadcast(new IgniteRunnable() {
                 @Override public void run() {
    @@ -107,6 +112,7 @@ public void testInvalidCustomExecutor() throws Exception {
         /**
          * @throws Exception If fails.
          */
    +    @Test
         public void testAllComputeApiByCustomExecutor() throws Exception {
             IgniteCompute comp = grid(0).compute().withExecutor(EXEC_NAME0);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/PublicThreadpoolStarvationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/PublicThreadpoolStarvationTest.java
    index dd9e0d5090df8..c99b55a1c7b5c 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/PublicThreadpoolStarvationTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/PublicThreadpoolStarvationTest.java
    @@ -25,6 +25,9 @@
     import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
     import org.apache.ignite.lang.IgniteRunnable;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
    @@ -33,6 +36,7 @@
      * Test to validate https://issues.apache.org/jira/browse/IGNITE-4239
      * Jobs hang when a lot of jobs calculate cache.
      */
    +@RunWith(JUnit4.class)
     public class PublicThreadpoolStarvationTest extends GridCacheAbstractSelfTest {
         /** Cache size. */
         private static final int CACHE_SIZE = 10;
    @@ -113,6 +117,7 @@ private void fillCaches() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCacheSizeOnPublicThreadpoolStarvation() throws Exception {
             grid(0).compute().run(new IgniteRunnable() {
                 @Override public void run() {
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
    index 1a7abd45fa921..01dcb7edf06e6 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
    @@ -49,10 +49,11 @@
     import org.apache.ignite.lang.IgnitePredicate;
     import org.apache.ignite.resources.IgniteInstanceResource;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static java.util.concurrent.TimeUnit.SECONDS;
    @@ -67,6 +68,7 @@
     /**
      * Event consume test.
      */
    +@RunWith(JUnit4.class)
     public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
         /** */
         private static final String PRJ_PRED_CLS_NAME = "org.apache.ignite.tests.p2p.GridEventConsumeProjectionPredicate";
    @@ -80,9 +82,6 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
         /** Number of created consumes per thread in multithreaded test. */
         private static final int CONSUME_CNT = 500;
     
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** Consume latch. */
         private static volatile CountDownLatch consumeLatch;
     
    @@ -99,12 +98,6 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        TcpDiscoverySpi disc = new TcpDiscoverySpi();
    -
    -        disc.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(disc);
    -
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
     
             if (include)
    @@ -174,6 +167,7 @@ private Collection localRoutines(GridContinuousProcessor proc)
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testApi() throws Exception {
             try {
                 grid(0).events().stopRemoteListen(null);
    @@ -251,6 +245,7 @@ public void testApi() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testApiAsyncOld() throws Exception {
             IgniteEvents evtAsync = grid(0).events().withAsync();
     
    @@ -341,6 +336,7 @@ public void testApiAsyncOld() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testApiAsync() throws Exception {
             IgniteEvents evt = grid(0).events();
     
    @@ -420,6 +416,7 @@ public void testApiAsync() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAllEvents() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -460,6 +457,7 @@ public void testAllEvents() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testEventsByType() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -501,6 +499,7 @@ public void testEventsByType() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testEventsByFilter() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -545,6 +544,7 @@ public void testEventsByFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testEventsByTypeAndFilter() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -591,6 +591,7 @@ public void testEventsByTypeAndFilter() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoteProjection() throws Exception {
             final Collection nodeIds = new ConcurrentSkipListSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -632,6 +633,7 @@ public void testRemoteProjection() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testProjectionWithLocalNode() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -673,6 +675,7 @@ public void testProjectionWithLocalNode() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalNodeOnly() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -716,6 +719,7 @@ public void testLocalNodeOnly() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testStopByCallback() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -757,6 +761,7 @@ public void testStopByCallback() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testStopRemoteListen() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -807,6 +812,7 @@ public void testStopRemoteListen() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testStopLocalListenByCallback() throws Exception {
             final AtomicInteger cnt = new AtomicInteger();
             final CountDownLatch latch = new CountDownLatch(1);
    @@ -842,6 +848,7 @@ public void testStopLocalListenByCallback() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNodeJoin() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -893,6 +900,7 @@ public void testNodeJoin() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNodeJoinWithProjection() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -947,9 +955,9 @@ public void testNodeJoinWithProjection() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-585")
    +    @Test
         public void testNodeJoinWithP2P() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-585");
    -
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
             final CountDownLatch latch = new CountDownLatch(GRID_CNT + 1);
    @@ -995,6 +1003,7 @@ public void testNodeJoinWithP2P() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testResources() throws Exception {
             final Collection nodeIds = new HashSet<>();
             final AtomicInteger cnt = new AtomicInteger();
    @@ -1049,6 +1058,7 @@ public void testResources() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMasterNodeLeave() throws Exception {
             final CountDownLatch latch = new CountDownLatch(GRID_CNT);
     
    @@ -1088,6 +1098,7 @@ public void testMasterNodeLeave() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMasterNodeLeaveNoAutoUnsubscribe() throws Exception {
             Ignite g = startGrid("anotherGrid");
     
    @@ -1145,7 +1156,8 @@ public void testMasterNodeLeaveNoAutoUnsubscribe() throws Exception {
         /**
          * @throws Exception If failed.
          */
    -    public void _testMultithreadedWithNodeRestart() throws Exception {
    +    @Test
    +    public void testMultithreadedWithNodeRestart() throws Exception {
             final AtomicBoolean stop = new AtomicBoolean();
             final BlockingQueue> queue = new LinkedBlockingQueue<>();
             final Collection started = new GridConcurrentHashSet<>();
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridMessageListenSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridMessageListenSelfTest.java
    index f5691e563e38c..ce520b3ae8c8b 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridMessageListenSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridMessageListenSelfTest.java
    @@ -39,12 +39,16 @@
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.jetbrains.annotations.Nullable;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.SECONDS;
     
     /**
      * Message listen test.
      */
    +@RunWith(JUnit4.class)
     public class GridMessageListenSelfTest extends GridCommonAbstractTest {
         /** */
         private static final int GRID_CNT = 3;
    @@ -142,6 +146,7 @@ public class GridMessageListenSelfTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNullTopic() throws Exception {
             latch = new CountDownLatch(MSG_CNT * GRID_CNT);
     
    @@ -161,6 +166,7 @@ public void testNullTopic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonNullTopic() throws Exception {
             latch = new CountDownLatch(MSG_CNT * GRID_CNT);
     
    @@ -180,6 +186,7 @@ public void testNonNullTopic() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testStopListen() throws Exception {
             latch = new CountDownLatch(GRID_CNT);
     
    @@ -205,6 +212,7 @@ public void testStopListen() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testProjection() throws Exception {
             latch = new CountDownLatch(MSG_CNT * (GRID_CNT - 1));
     
    @@ -224,6 +232,7 @@ public void testProjection() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNodeJoin() throws Exception {
             latch = new CountDownLatch(MSG_CNT * (GRID_CNT + 1));
     
    @@ -256,6 +265,7 @@ public void testNodeJoin() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNodeJoinWithProjection() throws Exception {
             latch = new CountDownLatch(MSG_CNT * GRID_CNT);
     
    @@ -295,6 +305,7 @@ public void testNodeJoinWithProjection() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNullTopicWithDeployment() throws Exception {
             Class cls = getExternalClassLoader().loadClass(LSNR_CLS_NAME);
     
    @@ -314,6 +325,7 @@ public void testNullTopicWithDeployment() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNonNullTopicWithDeployment() throws Exception {
             ClassLoader ldr = getExternalClassLoader();
     
    @@ -338,6 +350,7 @@ public void testNonNullTopicWithDeployment() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testListenActor() throws Exception {
             latch = new CountDownLatch(MSG_CNT * (GRID_CNT + 1));
     
    @@ -491,4 +504,4 @@ private Actor(UUID sourceNodeId) {
                 latch.countDown();
             }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/IgniteNoCustomEventsOnNodeStart.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/IgniteNoCustomEventsOnNodeStart.java
    index dc151a62bd418..63d6f4b76579b 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/IgniteNoCustomEventsOnNodeStart.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/IgniteNoCustomEventsOnNodeStart.java
    @@ -21,18 +21,17 @@
     import org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage;
     import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage;
     import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Sanity test to verify there are no unnecessary messages on node start.
      */
    +@RunWith(JUnit4.class)
     public class IgniteNoCustomEventsOnNodeStart extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private boolean client;
     
    @@ -43,11 +42,6 @@ public class IgniteNoCustomEventsOnNodeStart extends GridCommonAbstractTest {
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        TestTcpDiscoverySpi discoSpi = new TestTcpDiscoverySpi();
    -        discoSpi.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(discoSpi);
    -
             cfg.setClientMode(client);
     
             return cfg;
    @@ -56,6 +50,7 @@ public class IgniteNoCustomEventsOnNodeStart extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNoCustomEventsOnStart() throws Exception {
             failed = false;
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
    index 6b694c9d92e13..4574dc3f3a0bf 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
    @@ -77,6 +77,10 @@
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.jetbrains.annotations.Nullable;
     import org.jsr166.ConcurrentLinkedHashMap;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.internal.pagemem.PageIdUtils.effectivePageId;
     import static org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.rnd;
    @@ -86,6 +90,7 @@
     
     /**
      */
    +@RunWith(JUnit4.class)
     public class BPlusTreeSelfTest extends GridCommonAbstractTest {
         /** */
         private static final short LONG_INNER_IO = 30000;
    @@ -216,6 +221,7 @@ protected ReuseList createReuseList(int cacheId, PageMemory pageMem, long rootId
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testFind() throws IgniteCheckedException {
             TestTree tree = createTestTree(true);
             TreeMap map = new TreeMap<>();
    @@ -234,6 +240,7 @@ public void testFind() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testRetries() throws IgniteCheckedException {
             TestTree tree = createTestTree(true);
     
    @@ -251,9 +258,34 @@ public void testRetries() throws IgniteCheckedException {
             }
         }
     
    +    /**
    +     * @throws Exception if failed.
    +     */
    +    @Test
    +    public void testIsEmpty() throws Exception {
    +        TestTree tree = createTestTree(true);
    +
    +        assertTrue(tree.isEmpty());
    +
    +        for (long i = 1; i <= 500; i++) {
    +            tree.put(i);
    +
    +            assertFalse(tree.isEmpty());
    +        }
    +
    +        for (long i = 1; i <= 500; i++) {
    +            assertFalse(tree.isEmpty());
    +
    +            tree.remove(i);
    +        }
    +
    +        assertTrue(tree.isEmpty());
    +    }
    +
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testFindWithClosure() throws IgniteCheckedException {
             TestTree tree = createTestTree(true);
             TreeMap map = new TreeMap<>();
    @@ -350,6 +382,7 @@ private void checkCursor(GridCursor cursor, Iterator iterator) throw
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_1_20_mm_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 20;
    @@ -362,6 +395,7 @@ public void testPutRemove_1_20_mm_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_1_20_mm_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 20;
    @@ -374,6 +408,7 @@ public void testPutRemove_1_20_mm_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_1_20_pm_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 20;
    @@ -386,6 +421,7 @@ public void testPutRemove_1_20_pm_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_1_20_pm_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 20;
    @@ -398,6 +434,7 @@ public void testPutRemove_1_20_pm_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_1_20_pp_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 20;
    @@ -410,6 +447,7 @@ public void testPutRemove_1_20_pp_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_1_20_pp_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 20;
    @@ -422,6 +460,7 @@ public void testPutRemove_1_20_pp_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_1_20_mp_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 20;
    @@ -434,6 +473,7 @@ public void testPutRemove_1_20_mp_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_1_20_mp_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 20;
    @@ -447,6 +487,7 @@ public void testPutRemove_1_20_mp_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_2_40_mm_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 2;
             CNT = 40;
    @@ -459,6 +500,7 @@ public void testPutRemove_2_40_mm_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_2_40_mm_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 2;
             CNT = 40;
    @@ -471,6 +513,7 @@ public void testPutRemove_2_40_mm_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_2_40_pm_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 2;
             CNT = 40;
    @@ -483,6 +526,7 @@ public void testPutRemove_2_40_pm_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_2_40_pm_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 2;
             CNT = 40;
    @@ -495,6 +539,7 @@ public void testPutRemove_2_40_pm_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_2_40_pp_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 2;
             CNT = 40;
    @@ -507,6 +552,7 @@ public void testPutRemove_2_40_pp_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_2_40_pp_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 2;
             CNT = 40;
    @@ -519,6 +565,7 @@ public void testPutRemove_2_40_pp_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_2_40_mp_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 2;
             CNT = 40;
    @@ -531,6 +578,7 @@ public void testPutRemove_2_40_mp_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_2_40_mp_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 2;
             CNT = 40;
    @@ -544,6 +592,7 @@ public void testPutRemove_2_40_mp_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_3_60_mm_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 3;
             CNT = 60;
    @@ -556,6 +605,7 @@ public void testPutRemove_3_60_mm_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_3_60_mm_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 3;
             CNT = 60;
    @@ -568,6 +618,7 @@ public void testPutRemove_3_60_mm_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_3_60_pm_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 3;
             CNT = 60;
    @@ -580,6 +631,7 @@ public void testPutRemove_3_60_pm_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_3_60_pm_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 3;
             CNT = 60;
    @@ -592,6 +644,7 @@ public void testPutRemove_3_60_pm_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_3_60_pp_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 3;
             CNT = 60;
    @@ -604,6 +657,7 @@ public void testPutRemove_3_60_pp_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_3_60_pp_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 3;
             CNT = 60;
    @@ -616,6 +670,7 @@ public void testPutRemove_3_60_pp_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_3_60_mp_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 3;
             CNT = 60;
    @@ -628,6 +683,7 @@ public void testPutRemove_3_60_mp_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testPutRemove_3_60_mp_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 3;
             CNT = 60;
    @@ -744,6 +800,7 @@ private void checkIterateC(TestTree tree, long lower, long upper, TestTreeRowClo
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testRandomInvoke_1_30_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 30;
    @@ -754,6 +811,7 @@ public void testRandomInvoke_1_30_1() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testRandomInvoke_1_30_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 30;
    @@ -865,6 +923,7 @@ else if (rnd % 3 == 0) {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testRandomPutRemove_1_30_0() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 30;
    @@ -875,6 +934,7 @@ public void testRandomPutRemove_1_30_0() throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testRandomPutRemove_1_30_1() throws IgniteCheckedException {
             MAX_PER_PAGE = 1;
             CNT = 30;
    @@ -885,6 +945,7 @@ public void testRandomPutRemove_1_30_1() throws IgniteCheckedException {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassiveRemove3_false() throws Exception {
             MAX_PER_PAGE = 3;
     
    @@ -894,6 +955,7 @@ public void testMassiveRemove3_false() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassiveRemove3_true() throws Exception {
             MAX_PER_PAGE = 3;
     
    @@ -903,6 +965,7 @@ public void testMassiveRemove3_true() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassiveRemove2_false() throws Exception {
             MAX_PER_PAGE = 2;
     
    @@ -912,6 +975,7 @@ public void testMassiveRemove2_false() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassiveRemove2_true() throws Exception {
             MAX_PER_PAGE = 2;
     
    @@ -921,6 +985,7 @@ public void testMassiveRemove2_true() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassiveRemove1_false() throws Exception {
             MAX_PER_PAGE = 1;
     
    @@ -930,6 +995,7 @@ public void testMassiveRemove1_false() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassiveRemove1_true() throws Exception {
             MAX_PER_PAGE = 1;
     
    @@ -1004,6 +1070,7 @@ private void doTestMassiveRemove(final boolean canGetRow) throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassivePut1_true() throws Exception {
             MAX_PER_PAGE = 1;
     
    @@ -1013,6 +1080,7 @@ public void testMassivePut1_true() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassivePut1_false() throws Exception {
             MAX_PER_PAGE = 1;
     
    @@ -1022,12 +1090,14 @@ public void testMassivePut1_false() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassivePut2_true() throws Exception {
             MAX_PER_PAGE = 2;
     
             doTestMassivePut(true);
         }
     
    +    @Test
         public void testMassivePut2_false() throws Exception {
             MAX_PER_PAGE = 2;
     
    @@ -1037,12 +1107,14 @@ public void testMassivePut2_false() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMassivePut3_true() throws Exception {
             MAX_PER_PAGE = 3;
     
             doTestMassivePut(true);
         }
     
    +    @Test
         public void testMassivePut3_false() throws Exception {
             MAX_PER_PAGE = 3;
     
    @@ -1175,6 +1247,7 @@ private void assertEqualContents(IgniteTree tree, Map map
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testEmptyCursors() throws IgniteCheckedException {
             MAX_PER_PAGE = 5;
     
    @@ -1205,6 +1278,7 @@ private void doTestCursor(boolean canGetRow) throws IgniteCheckedException {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testCursorConcurrentMerge() throws IgniteCheckedException {
             MAX_PER_PAGE = 5;
     
    @@ -1280,6 +1354,7 @@ public void testCursorConcurrentMerge() throws IgniteCheckedException {
          *
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testSizeForPutRmvSequential() throws IgniteCheckedException {
             MAX_PER_PAGE = 5;
     
    @@ -1369,6 +1444,7 @@ public void testSizeForPutRmvSequential() throws IgniteCheckedException {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testSizeForRandomPutRmvMultithreaded_5_4() throws Exception {
             MAX_PER_PAGE = 5;
             CNT = 10_000;
    @@ -1376,6 +1452,7 @@ public void testSizeForRandomPutRmvMultithreaded_5_4() throws Exception {
             doTestSizeForRandomPutRmvMultithreaded(4);
         }
     
    +    @Test
         public void testSizeForRandomPutRmvMultithreaded_3_256() throws Exception {
             MAX_PER_PAGE = 3;
             CNT = 10_000;
    @@ -1492,6 +1569,7 @@ private void doTestSizeForRandomPutRmvMultithreaded(final int rmvPutSlidingWindo
          *
          * @see #doTestSizeForRandomPutRmvMultithreadedAsync doTestSizeForRandomPutRmvMultithreadedAsync() for details.
          */
    +    @Test
         public void testSizeForRandomPutRmvMultithreadedAsync_16() throws Exception {
             doTestSizeForRandomPutRmvMultithreadedAsync(16);
         }
    @@ -1502,6 +1580,7 @@ public void testSizeForRandomPutRmvMultithreadedAsync_16() throws Exception {
          *
          * @see #doTestSizeForRandomPutRmvMultithreadedAsync doTestSizeForRandomPutRmvMultithreadedAsync() for details.
          */
    +    @Test
         public void testSizeForRandomPutRmvMultithreadedAsync_3() throws Exception {
             doTestSizeForRandomPutRmvMultithreadedAsync(3);
         }
    @@ -1671,6 +1750,7 @@ public void doTestSizeForRandomPutRmvMultithreadedAsync(final int rmvPutSlidingW
          *
          * @throws Exception if test failed
          */
    +    @Test
         public void testPutSizeLivelock() throws Exception {
             MAX_PER_PAGE = 5;
             CNT = 800;
    @@ -1803,6 +1883,7 @@ public void testPutSizeLivelock() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testPutRmvSizeSinglePageContention() throws Exception {
             MAX_PER_PAGE = 10;
             CNT = 20_000;
    @@ -1924,6 +2005,7 @@ public void testPutRmvSizeSinglePageContention() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testPutRmvFindSizeMultithreaded() throws Exception {
             MAX_PER_PAGE = 5;
             CNT = 60_000;
    @@ -2061,6 +2143,7 @@ public void testPutRmvFindSizeMultithreaded() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTestRandomPutRemoveMultithreaded_1_30_0() throws Exception {
             MAX_PER_PAGE = 1;
             CNT = 30;
    @@ -2071,6 +2154,7 @@ public void testTestRandomPutRemoveMultithreaded_1_30_0() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTestRandomPutRemoveMultithreaded_1_30_1() throws Exception {
             MAX_PER_PAGE = 1;
             CNT = 30;
    @@ -2081,6 +2165,7 @@ public void testTestRandomPutRemoveMultithreaded_1_30_1() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTestRandomPutRemoveMultithreaded_2_50_0() throws Exception {
             MAX_PER_PAGE = 2;
             CNT = 50;
    @@ -2091,6 +2176,7 @@ public void testTestRandomPutRemoveMultithreaded_2_50_0() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTestRandomPutRemoveMultithreaded_2_50_1() throws Exception {
             MAX_PER_PAGE = 2;
             CNT = 50;
    @@ -2101,6 +2187,7 @@ public void testTestRandomPutRemoveMultithreaded_2_50_1() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTestRandomPutRemoveMultithreaded_3_70_0() throws Exception {
             MAX_PER_PAGE = 3;
             CNT = 70;
    @@ -2111,6 +2198,7 @@ public void testTestRandomPutRemoveMultithreaded_3_70_0() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTestRandomPutRemoveMultithreaded_3_70_1() throws Exception {
             MAX_PER_PAGE = 3;
             CNT = 70;
    @@ -2121,6 +2209,7 @@ public void testTestRandomPutRemoveMultithreaded_3_70_1() throws Exception {
         /**
          * @throws IgniteCheckedException If failed.
          */
    +    @Test
         public void testFindFirstAndLast() throws IgniteCheckedException {
             MAX_PER_PAGE = 5;
     
    @@ -2147,6 +2236,7 @@ public void testFindFirstAndLast() throws IgniteCheckedException {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testIterate() throws Exception {
             MAX_PER_PAGE = 5;
     
    @@ -2177,6 +2267,7 @@ public void testIterate() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testIterateConcurrentPutRemove() throws Exception {
             iterateConcurrentPutRemove();
         }
    @@ -2184,9 +2275,9 @@ public void testIterateConcurrentPutRemove() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-7265")
    +    @Test
         public void testIterateConcurrentPutRemove_1() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-7265");
    -
             MAX_PER_PAGE = 1;
     
             iterateConcurrentPutRemove();
    @@ -2195,6 +2286,7 @@ public void testIterateConcurrentPutRemove_1() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testIterateConcurrentPutRemove_5() throws Exception {
             MAX_PER_PAGE = 5;
     
    @@ -2204,6 +2296,7 @@ public void testIterateConcurrentPutRemove_5() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testIteratePutRemove_10() throws Exception {
             MAX_PER_PAGE = 10;
     
    @@ -2349,6 +2442,7 @@ private void iterateConcurrentPutRemove() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testConcurrentGrowDegenerateTreeAndConcurrentRemove() throws Exception {
             //calculate tree size when split happens
             final TestTree t = createTestTree(true);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListImplSelfTest.java
    index 74f80df5bfaa1..2f78c566d7840 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListImplSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListImplSelfTest.java
    @@ -52,10 +52,14 @@
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.jetbrains.annotations.Nullable;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class CacheFreeListImplSelfTest extends GridCommonAbstractTest {
         /** */
         private static final int CPUS = Runtime.getRuntime().availableProcessors();
    @@ -79,6 +83,7 @@ public class CacheFreeListImplSelfTest extends GridCommonAbstractTest {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteSingleThreaded_1024() throws Exception {
             checkInsertDeleteSingleThreaded(1024);
         }
    @@ -86,6 +91,7 @@ public void testInsertDeleteSingleThreaded_1024() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteSingleThreaded_2048() throws Exception {
             checkInsertDeleteSingleThreaded(2048);
         }
    @@ -93,6 +99,7 @@ public void testInsertDeleteSingleThreaded_2048() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteSingleThreaded_4096() throws Exception {
             checkInsertDeleteSingleThreaded(4096);
         }
    @@ -100,6 +107,7 @@ public void testInsertDeleteSingleThreaded_4096() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteSingleThreaded_8192() throws Exception {
             checkInsertDeleteSingleThreaded(8192);
         }
    @@ -107,6 +115,7 @@ public void testInsertDeleteSingleThreaded_8192() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteSingleThreaded_16384() throws Exception {
             checkInsertDeleteSingleThreaded(16384);
         }
    @@ -114,6 +123,7 @@ public void testInsertDeleteSingleThreaded_16384() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteMultiThreaded_1024() throws Exception {
             checkInsertDeleteMultiThreaded(1024);
         }
    @@ -121,6 +131,7 @@ public void testInsertDeleteMultiThreaded_1024() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteMultiThreaded_2048() throws Exception {
             checkInsertDeleteMultiThreaded(2048);
         }
    @@ -128,6 +139,7 @@ public void testInsertDeleteMultiThreaded_2048() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteMultiThreaded_4096() throws Exception {
             checkInsertDeleteMultiThreaded(4096);
         }
    @@ -135,6 +147,7 @@ public void testInsertDeleteMultiThreaded_4096() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteMultiThreaded_8192() throws Exception {
             checkInsertDeleteMultiThreaded(8192);
         }
    @@ -142,6 +155,7 @@ public void testInsertDeleteMultiThreaded_8192() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testInsertDeleteMultiThreaded_16384() throws Exception {
             checkInsertDeleteMultiThreaded(16384);
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/DataRegionMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/DataRegionMetricsSelfTest.java
    index 122f50e964629..a62b89123f46c 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/DataRegionMetricsSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/DataRegionMetricsSelfTest.java
    @@ -23,12 +23,16 @@
     import org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl;
     import org.apache.ignite.internal.processors.cache.ratemetrics.HitRateMetrics;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.lang.Thread.sleep;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class DataRegionMetricsSelfTest extends GridCommonAbstractTest {
         /** */
         private DataRegionMetricsImpl memMetrics;
    @@ -61,6 +65,7 @@ public class DataRegionMetricsSelfTest extends GridCommonAbstractTest {
          * Test for allocationRate metric in single-threaded mode.
          * @throws Exception if any happens during test.
          */
    +    @Test
         public void testAllocationRateSingleThreaded() throws Exception {
             threadsCnt = 1;
             memMetrics.rateTimeInterval(RATE_TIME_INTERVAL_2);
    @@ -84,6 +89,7 @@ public void testAllocationRateSingleThreaded() throws Exception {
          * Test for allocationRate metric in multi-threaded mode with short silent period in the middle of the test.
          * @throws Exception if any happens during test.
          */
    +    @Test
         public void testAllocationRateMultiThreaded() throws Exception {
             threadsCnt = 4;
             memMetrics.rateTimeInterval(RATE_TIME_INTERVAL_1);
    @@ -123,6 +129,7 @@ public void testAllocationRateMultiThreaded() throws Exception {
          * Test verifies that allocationRate calculation algorithm survives setting new values to rateTimeInterval parameter.
          * @throws Exception if any happens during test.
          */
    +    @Test
         public void testAllocationRateTimeIntervalConcurrentChange() throws Exception {
             threadsCnt = 5;
             memMetrics.rateTimeInterval(RATE_TIME_INTERVAL_1);
    @@ -153,6 +160,7 @@ public void testAllocationRateTimeIntervalConcurrentChange() throws Exception {
          *
          * @throws Exception if any happens during test.
          */
    +    @Test
         public void testAllocationRateSubintervalsConcurrentChange() throws Exception {
             threadsCnt = 5;
             memMetrics.rateTimeInterval(RATE_TIME_INTERVAL_1);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
    index 9a23502b25725..82a3428983e29 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbAbstractTest.java
    @@ -29,9 +29,6 @@
     import org.apache.ignite.internal.cluster.IgniteClusterEx;
     import org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree;
     import org.apache.ignite.internal.util.typedef.internal.S;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
    @@ -43,9 +40,6 @@
      *
      */
     public abstract class IgniteDbAbstractTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /**
          * @return Node count.
          */
    @@ -138,11 +132,6 @@ public abstract class IgniteDbAbstractTest extends GridCommonAbstractTest {
             if (!client)
                 cfg.setCacheConfiguration(ccfg, ccfg2, ccfg3, ccfg4, ccfg5);
     
    -        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    -
    -        discoSpi.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(discoSpi);
             cfg.setMarshaller(null);
     
             configure(cfg);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbDynamicCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbDynamicCacheSelfTest.java
    index 126ed5ffbe86a..f1870de2aa508 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbDynamicCacheSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbDynamicCacheSelfTest.java
    @@ -29,11 +29,16 @@
     import org.apache.ignite.configuration.DataStorageConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.util.typedef.internal.U;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteDbDynamicCacheSelfTest extends GridCommonAbstractTest {
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    @@ -79,6 +84,7 @@ public class IgniteDbDynamicCacheSelfTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCreate() throws Exception {
             int iterations = 200;
     
    @@ -112,7 +118,11 @@ public void testCreate() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMultipleDynamicCaches() throws Exception {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            fail("https://issues.apache.org/jira/browse/IGNITE-10421");
    +
             int caches = 10;
     
             int entries = 10;
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
    index 81b5515f29044..9047609c3f5c8 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbMemoryLeakAbstractTest.java
    @@ -26,12 +26,16 @@
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
     import org.apache.ignite.internal.processors.cache.persistence.DataStructure;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.IgniteSystemProperties.getInteger;
     
     /**
      * Base class for memory leaks tests.
      */
    +@RunWith(JUnit4.class)
     public abstract class IgniteDbMemoryLeakAbstractTest extends IgniteDbAbstractTest {
         /** */
         private static final int CONCURRENCY_LEVEL = 16;
    @@ -173,6 +177,7 @@ protected static int nextInt() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testMemoryLeak() throws Exception {
             final IgniteEx ignite = grid(0);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
    index 84455bab45f83..f9fb312852239 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetAbstractTest.java
    @@ -36,7 +36,6 @@
     import org.apache.ignite.cache.query.ScanQuery;
     import org.apache.ignite.cache.query.SqlFieldsQuery;
     import org.apache.ignite.cache.query.SqlQuery;
    -import org.apache.ignite.configuration.DataStorageConfiguration;
     import org.apache.ignite.configuration.NearCacheConfiguration;
     import org.apache.ignite.internal.IgniteEx;
     import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
    @@ -45,11 +44,16 @@
     import org.apache.ignite.internal.util.typedef.PA;
     import org.apache.ignite.internal.util.typedef.X;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.junit.Assert;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public abstract class IgniteDbPutGetAbstractTest extends IgniteDbAbstractTest {
         /** */
         private static final int KEYS_COUNT = 20_000;
    @@ -78,6 +82,7 @@ private  IgniteCache cache(String name) throws Exception {
         /**
          *
          */
    +    @Test
         public void testGradualRandomPutAllRemoveAll() throws Exception {
             IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -138,6 +143,7 @@ private void doPutRemoveAll(Random rnd, IgniteCache cache, Map
         /**
          *
          */
    +    @Test
         public void testRandomRemove() throws Exception {
             IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -177,6 +183,7 @@ public void testRandomRemove() throws Exception {
     
         /**
          */
    +    @Test
         public void testRandomPut() throws Exception {
             IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -205,6 +212,7 @@ public void testRandomPut() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testPutGetSimple() throws Exception {
             IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -229,6 +237,7 @@ public void testPutGetSimple() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testPutGetLarge() throws Exception {
             IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -271,6 +280,7 @@ public void testPutGetLarge() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPutGetLargeKeys() throws Exception {
             IgniteCache cache = ignite(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -319,6 +329,7 @@ private int[] randomInts(final int size) {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testPutGetOverwrite() throws Exception {
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -347,6 +358,7 @@ public void testPutGetOverwrite() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testOverwriteNormalSizeAfterSmallerSize() throws Exception {
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -371,6 +383,7 @@ public void testOverwriteNormalSizeAfterSmallerSize() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testPutDoesNotTriggerRead() throws Exception {
             IgniteEx ig = grid(0);
     
    @@ -382,6 +395,7 @@ public void testPutDoesNotTriggerRead() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testPutGetMultipleObjects() throws Exception {
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -455,7 +469,11 @@ public void testPutGetMultipleObjects() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testSizeClear() throws Exception {
    +        if (MvccFeatureChecker.forcedMvcc())
    +            fail("https://issues.apache.org/jira/browse/IGNITE-7952");
    +
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
             GridCacheAdapter internalCache = internalCache(cache);
    @@ -491,6 +509,7 @@ public void testSizeClear() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testBounds() throws Exception {
             IgniteEx ig = ig();
     
    @@ -549,6 +568,7 @@ public void testBounds() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testMultithreadedPut() throws Exception {
             IgniteEx ig = ig();
     
    @@ -613,6 +633,7 @@ public void testMultithreadedPut() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testPutGetRandomUniqueMultipleObjects() throws Exception {
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -680,6 +701,7 @@ private static int[] generateUniqueRandomKeys(int cnt, Random rnd) {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPutPrimaryUniqueSecondaryDuplicates() throws Exception {
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -724,6 +746,7 @@ public void testPutPrimaryUniqueSecondaryDuplicates() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testPutGetRandomNonUniqueMultipleObjects() throws Exception {
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -770,6 +793,7 @@ public void testPutGetRandomNonUniqueMultipleObjects() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testPutGetRemoveMultipleForward() throws Exception {
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -860,6 +884,7 @@ public void _testRandomPutGetRemove() throws Exception {
                 assertEquals(map.get(key), cache.get(key));
         }
     
    +    @Test
         public void testPutGetRemoveMultipleBackward() throws Exception {
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -904,6 +929,7 @@ public void testPutGetRemoveMultipleBackward() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testIndexOverwrite() throws Exception {
             final IgniteCache cache = cache(DEFAULT_CACHE_NAME);
     
    @@ -947,6 +973,7 @@ public void testIndexOverwrite() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testObjectKey() throws Exception {
             IgniteEx ig = ig();
     
    @@ -992,6 +1019,7 @@ public void testObjectKey() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testIterators() throws Exception {
             IgniteEx ignite = ig();
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetWithCacheStoreTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetWithCacheStoreTest.java
    index 8cca7f40e6ac1..b6eb70864a4dd 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetWithCacheStoreTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbPutGetWithCacheStoreTest.java
    @@ -31,7 +31,11 @@
     import org.apache.ignite.configuration.IgniteReflectionFactory;
     import org.apache.ignite.configuration.WALMode;
     import org.apache.ignite.internal.IgniteEx;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    @@ -39,6 +43,7 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IgniteDbPutGetWithCacheStoreTest extends GridCommonAbstractTest {
         /** */
         private static Map storeMap = new ConcurrentHashMap<>();
    @@ -76,6 +81,13 @@ public class IgniteDbPutGetWithCacheStoreTest extends GridCommonAbstractTest {
             return cfg;
         }
     
    +    /** {@inheritDoc} */
    +    @Override protected void beforeTest() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);
    +
    +        super.beforeTest();
    +    }
    +
         /** {@inheritDoc} */
         @Override protected void afterTest() throws Exception {
             cleanPersistenceDir();
    @@ -93,6 +105,7 @@ public class IgniteDbPutGetWithCacheStoreTest extends GridCommonAbstractTest {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testWriteThrough() throws Exception {
             checkWriteThrough(ATOMIC);
             checkWriteThrough(TRANSACTIONAL);
    @@ -101,6 +114,7 @@ public void testWriteThrough() throws Exception {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testReadThrough() throws Exception {
             checkReadThrough(ATOMIC);
             checkReadThrough(TRANSACTIONAL);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeTinyPutGetTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeTinyPutGetTest.java
    index 53d299e1cf9c7..a61f3f11253d4 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeTinyPutGetTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IgniteDbSingleNodeTinyPutGetTest.java
    @@ -19,20 +19,23 @@
     
     import org.apache.ignite.IgniteCache;
     import org.apache.ignite.internal.IgniteEx;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Test for
      */
    +@RunWith(JUnit4.class)
     public class IgniteDbSingleNodeTinyPutGetTest extends IgniteDbSingleNodePutGetTest {
         /** {@inheritDoc} */
         @Override protected boolean isLargePage() {
             return true;
         }
     
    -    /**
    -     * @throws Exception If fail.
    -     */
    -    public void testPutGetTiny() throws Exception {
    +    /** */
    +    @Test
    +    public void testPutGetTiny() {
             IgniteEx ig = grid(0);
     
             IgniteCache cache = ig.cache("tiny");
    @@ -45,82 +48,98 @@ public void testPutGetTiny() throws Exception {
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testGradualRandomPutAllRemoveAll() {
             // No-op
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testRandomRemove() {
             // No-op
         }
     
         /** {@inheritDoc} */
    +    @Test
         @Override public void testRandomPut() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutGetSimple() throws Exception {
    +    @Test
    +    @Override public void testPutGetSimple() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutGetLarge() throws Exception {
    +    @Test
    +    @Override public void testPutGetLarge() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutGetOverwrite() throws Exception {
    +    @Test
    +    @Override public void testPutGetOverwrite() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testOverwriteNormalSizeAfterSmallerSize() throws Exception {
    +    @Test
    +    @Override public void testOverwriteNormalSizeAfterSmallerSize() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutDoesNotTriggerRead() throws Exception {
    +    @Test
    +    @Override public void testPutDoesNotTriggerRead() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutGetMultipleObjects() throws Exception {
    +    @Test
    +    @Override public void testPutGetMultipleObjects() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testSizeClear() throws Exception {
    +    @Test
    +    @Override public void testSizeClear() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testBounds() throws Exception {
    +    @Test
    +    @Override public void testBounds() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testMultithreadedPut() throws Exception {
    +    @Test
    +    @Override public void testMultithreadedPut() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutGetRandomUniqueMultipleObjects() throws Exception {
    +    @Test
    +    @Override public void testPutGetRandomUniqueMultipleObjects() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutPrimaryUniqueSecondaryDuplicates() throws Exception {
    +    @Test
    +    @Override public void testPutPrimaryUniqueSecondaryDuplicates() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutGetRandomNonUniqueMultipleObjects() throws Exception {
    +    @Test
    +    @Override public void testPutGetRandomNonUniqueMultipleObjects() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutGetRemoveMultipleForward() throws Exception {
    +    @Test
    +    @Override public void testPutGetRemoveMultipleForward() {
             // No-op
         }
     
    @@ -130,22 +149,26 @@ public void testPutGetTiny() throws Exception {
         }
     
         /** {@inheritDoc} */
    -    @Override public void testPutGetRemoveMultipleBackward() throws Exception {
    +    @Test
    +    @Override public void testPutGetRemoveMultipleBackward() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testIndexOverwrite() throws Exception {
    +    @Test
    +    @Override public void testIndexOverwrite() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testObjectKey() throws Exception {
    +    @Test
    +    @Override public void testObjectKey() {
             // No-op
         }
     
         /** {@inheritDoc} */
    -    @Override public void testIterators() throws Exception {
    +    @Test
    +    @Override public void testIterators() {
             // No-op
         }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IndexStorageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IndexStorageSelfTest.java
    index bbdcd383ed9de..78c83b6abd760 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IndexStorageSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/IndexStorageSelfTest.java
    @@ -35,10 +35,14 @@
     import org.apache.ignite.internal.processors.cache.persistence.RootPage;
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class IndexStorageSelfTest extends GridCommonAbstractTest {
         /** Make sure page is small enough to trigger multiple pages in a linked list. */
         private static final int PAGE_SIZE = 1024;
    @@ -57,6 +61,7 @@ public class IndexStorageSelfTest extends GridCommonAbstractTest {
         /**
          * @throws Exception if failed.
          */
    +    @Test
         public void testMetaIndexAllocation() throws Exception {
             metaAllocation();
         }
    @@ -96,15 +101,24 @@ private void metaAllocation() throws Exception {
                     IndexStorageImpl metaStore = storeMap.get(cacheId);
     
                     if (metaStore == null) {
    -                    metaStore = new IndexStorageImpl(mem, null, new AtomicLong(), cacheId,
    -                        PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX,
    -                        null, mem.allocatePage(cacheId, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX), true,
    -                            null);
    +                    metaStore = new IndexStorageImpl(
    +                        mem,
    +                        null,
    +                        new AtomicLong(),
    +                        cacheId,
    +                        false,
    +                        PageIdAllocator.INDEX_PARTITION,
    +                        PageMemory.FLAG_IDX,
    +                        null,
    +                        mem.allocatePage(cacheId, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX),
    +                        true,
    +                        null
    +                    );
     
                         storeMap.put(cacheId, metaStore);
                     }
     
    -                final RootPage rootPage = metaStore.getOrAllocateForTree(idxName);
    +                final RootPage rootPage = metaStore.allocateIndex(idxName);
     
                     assertTrue(rootPage.isAllocated());
     
    @@ -118,7 +132,7 @@ private void metaAllocation() throws Exception {
                         String idxName = entry.getKey();
                         FullPageId rootPageId = entry.getValue().pageId();
     
    -                    final RootPage rootPage = storeMap.get(cacheId).getOrAllocateForTree(idxName);
    +                    final RootPage rootPage = storeMap.get(cacheId).allocateIndex(idxName);
     
                         assertEquals("Invalid root page ID restored [cacheId=" + cacheId + ", idxName=" + idxName + ']',
                             rootPageId, rootPage.pageId());
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/SwapPathConstructionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/SwapPathConstructionSelfTest.java
    index 5910a35efdc56..5872c3185e0db 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/SwapPathConstructionSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/SwapPathConstructionSelfTest.java
    @@ -31,11 +31,15 @@
     import org.apache.ignite.internal.processors.cache.persistence.DataRegion;
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Test verifies correct construction of swap file path {@link DataRegionConfiguration#setSwapPath(String)}
      * when absolute or relative paths are provided via configuration.
      */
    +@RunWith(JUnit4.class)
     public class SwapPathConstructionSelfTest extends GridCommonAbstractTest {
         /** */
         private DataStorageConfiguration memCfg;
    @@ -78,6 +82,7 @@ private void cleanUpSwapDir() {
         /**
          * Verifies relative swap file path construction. Directory with swap files is cleaned up during after-test phase.
          */
    +    @Test
         public void testRelativeSwapFilePath() throws Exception {
             memCfg = createMemoryConfiguration(true);
     
    @@ -94,6 +99,7 @@ public void testRelativeSwapFilePath() throws Exception {
          * Verifies absolute swap file path construction. System tmp directory is used to allocate swap files,
          * so no clean up is needed.
          */
    +    @Test
         public void testAbsoluteSwapFilePath() throws Exception {
             memCfg = createMemoryConfiguration(false);
     
    diff --git a/modules/web-console/frontend/app/modules/navbar/navbar.directive.js b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorMvccPersistenceSelfTest.java
    similarity index 75%
    rename from modules/web-console/frontend/app/modules/navbar/navbar.directive.js
    rename to modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorMvccPersistenceSelfTest.java
    index e400cf7d2f54a..9360cab60284e 100644
    --- a/modules/web-console/frontend/app/modules/navbar/navbar.directive.js
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorMvccPersistenceSelfTest.java
    @@ -15,18 +15,14 @@
      * limitations under the License.
      */
     
    -export default function factory(IgniteNavbar) {
    -    function controller() {
    -        const ctrl = this;
    +package org.apache.ignite.internal.processors.datastreamer;
     
    -        ctrl.items = IgniteNavbar;
    +/**
    + *
    + */
    +public class DataStreamProcessorMvccPersistenceSelfTest extends DataStreamProcessorMvccSelfTest {
    +    /** {@inheritDoc} */
    +    @Override public boolean persistenceEnabled() {
    +        return true;
         }
    -
    -    return {
    -        restrict: 'A',
    -        controller,
    -        controllerAs: 'navbar'
    -    };
     }
    -
    -factory.$inject = ['IgniteNavbar'];
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorMvccSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorMvccSelfTest.java
    index ca8be09a18bc2..6d37b9b22ee2d 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorMvccSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorMvccSelfTest.java
    @@ -20,12 +20,17 @@
     import org.apache.ignite.cache.CacheAtomicityMode;
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
    +import org.junit.Ignore;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
     
     /**
      * Check DataStreamer with Mvcc enabled.
      */
    +@RunWith(JUnit4.class)
     public class DataStreamProcessorMvccSelfTest extends DataStreamProcessorSelfTest {
         /** {@inheritDoc} */
         @SuppressWarnings("unchecked")
    @@ -51,19 +56,30 @@ public class DataStreamProcessorMvccSelfTest extends DataStreamProcessorSelfTest
         }
     
         /** {@inheritDoc} */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-8582")
    +    @Test
         @Override public void testUpdateStore() throws Exception {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-8582");
    -
             super.testUpdateStore();
         }
     
         /** {@inheritDoc} */
    -    @Override public void testFlushTimeout() {
    -        fail("https://issues.apache.org/jira/browse/IGNITE-9321");
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-9321")
    +    @Test
    +    @Override public void testFlushTimeout() throws Exception {
    +        super.testFlushTimeout();
    +    }
    +
    +    /** {@inheritDoc} */
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-9530")
    +    @Test
    +    @Override public void testLocal() throws Exception {
    +        super.testLocal();
         }
     
         /** {@inheritDoc} */
    -    @Override public void testLocal() {
    -        // Do not check local caches with MVCC enabled.
    +    @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752")
    +    @Test
    +    @Override public void testTryFlush() throws Exception {
    +        super.testTryFlush();
         }
     }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorPersistenceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorPersistenceSelfTest.java
    new file mode 100644
    index 0000000000000..7ce4fdd28e9d3
    --- /dev/null
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorPersistenceSelfTest.java
    @@ -0,0 +1,28 @@
    +/*
    + * 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.
    + */
    +
    +package org.apache.ignite.internal.processors.datastreamer;
    +
    +/**
    + *
    + */
    +public class DataStreamProcessorPersistenceSelfTest extends DataStreamProcessorSelfTest {
    +    /** {@inheritDoc} */
    +    @Override public boolean persistenceEnabled() {
    +        return true;
    +    }
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorSelfTest.java
    index 536d73e271d59..f49d2beefae92 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamProcessorSelfTest.java
    @@ -42,9 +42,12 @@
     import org.apache.ignite.cache.store.CacheStoreAdapter;
     import org.apache.ignite.cluster.ClusterNode;
     import org.apache.ignite.configuration.CacheConfiguration;
    +import org.apache.ignite.configuration.DataRegionConfiguration;
    +import org.apache.ignite.configuration.DataStorageConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.configuration.IgniteReflectionFactory;
     import org.apache.ignite.configuration.NearCacheConfiguration;
    +import org.apache.ignite.configuration.WALMode;
     import org.apache.ignite.events.Event;
     import org.apache.ignite.internal.IgniteInternalFuture;
     import org.apache.ignite.internal.IgniteKernal;
    @@ -52,23 +55,24 @@
     import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
     import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
     import org.apache.ignite.internal.util.lang.GridAbsPredicate;
    +import org.apache.ignite.internal.util.typedef.G;
     import org.apache.ignite.internal.util.typedef.internal.CU;
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.lang.IgniteClosure;
     import org.apache.ignite.lang.IgniteFuture;
     import org.apache.ignite.lang.IgniteFutureCancelledException;
     import org.apache.ignite.lang.IgnitePredicate;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.stream.StreamReceiver;
     import org.apache.ignite.testframework.GridTestUtils;
    +import org.apache.ignite.testframework.MvccFeatureChecker;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.jetbrains.annotations.Nullable;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static java.util.concurrent.TimeUnit.MILLISECONDS;
     import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
    -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
     import static org.apache.ignite.cache.CacheMode.LOCAL;
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
     import static org.apache.ignite.cache.CacheMode.REPLICATED;
    @@ -78,13 +82,11 @@
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class DataStreamProcessorSelfTest extends GridCommonAbstractTest {
         /** */
         private static ConcurrentHashMap storeMap;
     
    -    /** */
    -    private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private CacheMode mode = PARTITIONED;
     
    @@ -97,6 +99,13 @@ public class DataStreamProcessorSelfTest extends GridCommonAbstractTest {
         /** */
         private TestStore store;
     
    +    @Override protected void beforeTest() throws Exception {
    +        super.beforeTest();
    +
    +        if (persistenceEnabled())
    +            cleanPersistenceDir();
    +    }
    +
         /** {@inheritDoc} */
         @Override public void afterTest() throws Exception {
             super.afterTest();
    @@ -104,6 +113,13 @@ public class DataStreamProcessorSelfTest extends GridCommonAbstractTest {
             useCache = false;
         }
     
    +    /**
    +     * @return {@code True} if persistent store is enabled for test.
    +     */
    +    public boolean persistenceEnabled() {
    +        return false;
    +    }
    +
         /** {@inheritDoc} */
         @SuppressWarnings({"IfMayBeConditional", "unchecked"})
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    @@ -111,13 +127,6 @@ public class DataStreamProcessorSelfTest extends GridCommonAbstractTest {
     
             cfg.setPeerClassLoadingEnabled(false);
     
    -        TcpDiscoverySpi spi = new TcpDiscoverySpi();
    -
    -        spi.setForceServerMode(true);
    -        spi.setIpFinder(ipFinder);
    -
    -        cfg.setDiscoverySpi(spi);
    -
             cfg.setIncludeProperties();
     
             if (useCache) {
    @@ -141,6 +150,12 @@ public class DataStreamProcessorSelfTest extends GridCommonAbstractTest {
                 }
     
                 cfg.setCacheConfiguration(cc);
    +
    +            if (persistenceEnabled())
    +                cfg.setDataStorageConfiguration(new DataStorageConfiguration()
    +                    .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
    +                            .setPersistenceEnabled(true))
    +                    .setWalMode(WALMode.LOG_ONLY));
             }
             else {
                 cfg.setCacheConfiguration();
    @@ -168,7 +183,10 @@ protected boolean customKeepBinary() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitioned() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE);
    +
             mode = PARTITIONED;
     
             checkDataStreamer();
    @@ -177,6 +195,7 @@ public void testPartitioned() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testColocated() throws Exception {
             mode = PARTITIONED;
             nearEnabled = false;
    @@ -187,6 +206,7 @@ public void testColocated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicated() throws Exception {
             mode = REPLICATED;
     
    @@ -196,7 +216,10 @@ public void testReplicated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocal() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE);
    +
             mode = LOCAL;
     
             try {
    @@ -226,6 +249,8 @@ private void checkDataStreamer() throws Exception {
     
                 Ignite igniteWithoutCache = startGrid(1);
     
    +            afterGridStarted();
    +
                 final IgniteDataStreamer ldr = igniteWithoutCache.dataStreamer(DEFAULT_CACHE_NAME);
     
                 ldr.receiver(DataStreamerCacheUpdaters.batchedSorted());
    @@ -312,6 +337,7 @@ private void checkDataStreamer() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionedIsolated() throws Exception {
             mode = PARTITIONED;
     
    @@ -321,6 +347,7 @@ public void testPartitionedIsolated() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedIsolated() throws Exception {
             mode = REPLICATED;
     
    @@ -334,11 +361,9 @@ private void checkIsolatedDataStreamer() throws Exception {
             try {
                 useCache = true;
     
    -            Ignite g1 = startGrid(0);
    -            startGrid(1);
    -            startGrid(2);
    +            Ignite g1 = startGridsMultiThreaded(3);
     
    -            awaitPartitionMapExchange();
    +            afterGridStarted();
     
                 IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME);
     
    @@ -415,6 +440,7 @@ private void checkIsolatedDataStreamer() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testPrimitiveArrays() throws Exception {
             try {
                 useCache = true;
    @@ -423,6 +449,8 @@ public void testPrimitiveArrays() throws Exception {
                 Ignite g1 = startGrid(1);
                 startGrid(2); // Reproduced only for several nodes in topology (if marshalling is used).
     
    +            afterGridStarted();
    +
                 List arrays = Arrays.asList(
                     new byte[] {1}, new boolean[] {true, false}, new char[] {2, 3}, new short[] {3, 4},
                     new int[] {4, 5}, new long[] {5, 6}, new float[] {6, 7}, new double[] {7, 8});
    @@ -446,6 +474,7 @@ public void testPrimitiveArrays() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testReplicatedMultiThreaded() throws Exception {
             mode = REPLICATED;
     
    @@ -455,6 +484,7 @@ public void testReplicatedMultiThreaded() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testPartitionedMultiThreaded() throws Exception {
             mode = PARTITIONED;
     
    @@ -471,20 +501,17 @@ public void testPartitionedMultiThreaded() throws Exception {
         protected void checkLoaderMultithreaded(int nodesCntNoCache, int nodesCntCache)
             throws Exception {
             try {
    -            // Start all required nodes.
    -            int idx = 1;
    -
                 useCache = true;
     
    -            for (int i = 0; i < nodesCntCache; i++)
    -                startGrid(idx++);
    +            startGridsMultiThreaded(nodesCntCache);
     
                 useCache = false;
     
    -            for (int i = 0; i < nodesCntNoCache; i++)
    -                startGrid(idx++);
    +            startGridsMultiThreaded(nodesCntCache, nodesCntNoCache);
     
    -            Ignite g1 = grid(idx - 1);
    +            Ignite g1 = grid(nodesCntCache + nodesCntNoCache - 1);
    +
    +            afterGridStarted();
     
                 // Get and configure loader.
                 final IgniteDataStreamer ldr = g1.dataStreamer(DEFAULT_CACHE_NAME);
    @@ -584,12 +611,15 @@ protected void checkLoaderMultithreaded(int nodesCntNoCache, int nodesCntCache)
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLoaderApi() throws Exception {
             useCache = true;
     
             try {
                 Ignite g1 = startGrid(1);
     
    +            afterGridStarted();
    +
                 IgniteDataStreamer ldr = g1.dataStreamer(DEFAULT_CACHE_NAME);
     
                 ldr.close(false);
    @@ -738,15 +768,17 @@ private static  IgniteClosure removeClosure(@Nullable final T exp) {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFlush() throws Exception {
    -        // Local caches are not allowed with MVCC enabled.
    -        mode = getCacheAtomicityMode() != TRANSACTIONAL_SNAPSHOT ? LOCAL : PARTITIONED;
    +        mode = PARTITIONED;
     
             useCache = true;
     
             try {
                 Ignite g = startGrid();
     
    +            afterGridStarted();
    +
                 final IgniteCache c = g.cache(DEFAULT_CACHE_NAME);
     
                 final IgniteDataStreamer ldr = g.dataStreamer(DEFAULT_CACHE_NAME);
    @@ -791,15 +823,17 @@ public Void call() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testTryFlush() throws Exception {
    -        // Local caches are not allowed with MVCC enabled.
    -        mode = getCacheAtomicityMode() != TRANSACTIONAL_SNAPSHOT ? LOCAL : PARTITIONED;
    +        mode = PARTITIONED;
     
             useCache = true;
     
             try {
                 Ignite g = startGrid();
     
    +            afterGridStarted();
    +
                 IgniteCache c = g.cache(DEFAULT_CACHE_NAME);
     
                 IgniteDataStreamer ldr = g.dataStreamer(DEFAULT_CACHE_NAME);
    @@ -827,15 +861,19 @@ public void testTryFlush() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testFlushTimeout() throws Exception {
    -        // Local caches are not allowed with MVCC enabled.
    -        mode = getCacheAtomicityMode() != TRANSACTIONAL_SNAPSHOT ? LOCAL : PARTITIONED;
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_EVENTS);
    +
    +        mode = PARTITIONED;
     
             useCache = true;
     
             try {
                 Ignite g = startGrid();
     
    +            afterGridStarted();
    +
                 final CountDownLatch latch = new CountDownLatch(9);
     
                 g.events().localListen(new IgnitePredicate() {
    @@ -879,7 +917,10 @@ public void testFlushTimeout() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testUpdateStore() throws Exception {
    +        MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);
    +
             storeMap = new ConcurrentHashMap<>();
     
             try {
    @@ -887,10 +928,9 @@ public void testUpdateStore() throws Exception {
     
                 useCache = true;
     
    -            Ignite ignite = startGrid(1);
    +            Ignite ignite = startGridsMultiThreaded(3);
     
    -            startGrid(2);
    -            startGrid(3);
    +            afterGridStarted();
     
                 for (int i = 0; i < 1000; i++)
                     storeMap.put(i, i);
    @@ -941,20 +981,22 @@ public void testUpdateStore() throws Exception {
             }
             finally {
                 storeMap = null;
    +
    +            stopAllGrids();
             }
         }
     
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCustomUserUpdater() throws Exception {
             useCache = true;
     
             try {
    -            Ignite ignite = startGrid(1);
    +            Ignite ignite = startGridsMultiThreaded(3);
     
    -            startGrid(2);
    -            startGrid(3);
    +            afterGridStarted();
     
                 try (IgniteDataStreamer ldr = ignite.dataStreamer(DEFAULT_CACHE_NAME)) {
                     ldr.allowOverwrite(true);
    @@ -983,12 +1025,15 @@ public void testCustomUserUpdater() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testLocalDataStreamerDedicatedThreadPool() throws Exception {
             try {
                 useCache = true;
     
                 Ignite ignite = startGrid(1);
     
    +            afterGridStarted();
    +
                 final IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME);
     
                 try (IgniteDataStreamer ldr = ignite.dataStreamer(DEFAULT_CACHE_NAME)) {
    @@ -1025,6 +1070,7 @@ public void testLocalDataStreamerDedicatedThreadPool() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemoteDataStreamerDedicatedThreadPool() throws Exception {
             try {
                 useCache = true;
    @@ -1035,6 +1081,8 @@ public void testRemoteDataStreamerDedicatedThreadPool() throws Exception {
     
                 Ignite client = startGrid(0);
     
    +            afterGridStarted();
    +
                 final IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME);
     
                 try (IgniteDataStreamer ldr = client.dataStreamer(DEFAULT_CACHE_NAME)) {
    @@ -1100,6 +1148,19 @@ protected StreamReceiver getStreamReceiver() {
             return new TestDataReceiver();
         }
     
    +    /**
    +     * Activates grid if necessary and wait for partition map exchange.
    +     */
    +    private void afterGridStarted() throws InterruptedException {
    +        G.allGrids().stream()
    +            .filter(g -> !g.cluster().node().isClient())
    +            .findAny()
    +            .filter(g -> !g.cluster().active())
    +            .ifPresent(g -> g.cluster().active(true));
    +
    +        awaitPartitionMapExchange();
    +    }
    +
         /**
          *
          */
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerClientReconnectAfterClusterRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerClientReconnectAfterClusterRestartTest.java
    index 239647c58529b..468e8ce8200e6 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerClientReconnectAfterClusterRestartTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerClientReconnectAfterClusterRestartTest.java
    @@ -25,17 +25,16 @@
     import org.apache.ignite.events.Event;
     import org.apache.ignite.events.EventType;
     import org.apache.ignite.lang.IgnitePredicate;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      * Tests DataStreamer reconnect behaviour when client nodes arrives at the same or different topVer than it left.
      */
    +@RunWith(JUnit4.class)
     public class DataStreamerClientReconnectAfterClusterRestartTest extends GridCommonAbstractTest {
    -    /** */
    -    public static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private boolean clientMode;
     
    @@ -43,8 +42,6 @@ public class DataStreamerClientReconnectAfterClusterRestartTest extends GridComm
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -
             cfg.setCacheConfiguration(new CacheConfiguration<>("test"));
     
             cfg.setClientMode(clientMode);
    @@ -53,21 +50,25 @@ public class DataStreamerClientReconnectAfterClusterRestartTest extends GridComm
         }
     
         /** */
    +    @Test
         public void testOneClient() throws Exception {
             clusterRestart(false, false);
         }
     
         /** */
    +    @Test
         public void testOneClientAllowOverwrite() throws Exception {
             clusterRestart(false, true);
         }
     
         /** */
    +    @Test
         public void testTwoClients() throws Exception {
             clusterRestart(true, false);
         }
     
         /** */
    +    @Test
         public void testTwoClientsAllowOverwrite() throws Exception {
             clusterRestart(true, true);
         }
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java
    index e4c7660386394..1844e06aa4b1b 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImplSelfTest.java
    @@ -50,15 +50,15 @@
     import org.apache.ignite.lang.IgniteInClosure;
     import org.apache.ignite.plugin.extensions.communication.Message;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.apache.log4j.Appender;
     import org.apache.log4j.Logger;
     import org.apache.log4j.SimpleLayout;
     import org.apache.log4j.WriterAppender;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
    @@ -66,10 +66,8 @@
     /**
      * Tests for {@code IgniteDataStreamerImpl}.
      */
    +@RunWith(JUnit4.class)
     public class DataStreamerImplSelfTest extends GridCommonAbstractTest {
    -    /** IP finder. */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** Number of keys to load via data streamer. */
         private static final int KEYS_COUNT = 1000;
     
    @@ -96,11 +94,6 @@ public class DataStreamerImplSelfTest extends GridCommonAbstractTest {
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    -        discoSpi.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(discoSpi);
    -
             cfg.setCommunicationSpi(new StaleTopologyCommunicationSpi());
     
             if (cnt < MAX_CACHE_COUNT)
    @@ -114,6 +107,7 @@ public class DataStreamerImplSelfTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCloseWithCancellation() throws Exception {
             cnt = 0;
     
    @@ -142,6 +136,7 @@ public void testCloseWithCancellation() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testNullPointerExceptionUponDataStreamerClosing() throws Exception {
             cnt = 0;
     
    @@ -189,6 +184,7 @@ public void testNullPointerExceptionUponDataStreamerClosing() throws Exception {
          *
          * @throws Exception If failed.
          */
    +    @Test
         public void testAddDataFromMap() throws Exception {
             cnt = 0;
     
    @@ -225,6 +221,7 @@ public void testAddDataFromMap() throws Exception {
          *
          * @throws Exception If fail.
          */
    +    @Test
         public void testNoDataNodesOnClose() throws Exception {
             boolean failed = false;
     
    @@ -254,6 +251,7 @@ public void testNoDataNodesOnClose() throws Exception {
          *
          * @throws Exception If fail.
          */
    +    @Test
         public void testNoDataNodesOnFlush() throws Exception {
             boolean failed = false;
     
    @@ -296,6 +294,7 @@ public void testNoDataNodesOnFlush() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testAllOperationFinishedBeforeFutureCompletion() throws Exception {
             cnt = 0;
     
    @@ -348,6 +347,7 @@ public void testAllOperationFinishedBeforeFutureCompletion() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testRemapOnTopologyChangeDuringUpdatePreparation() throws Exception {
             cnt = 0;
     
    @@ -430,6 +430,7 @@ public void testRemapOnTopologyChangeDuringUpdatePreparation() throws Exception
          *
          * @throws Exception if failed
          */
    +    @Test
         public void testRetryWhenTopologyMismatch() throws Exception {
             final int KEY = 1;
             final String VAL = "1";
    @@ -465,6 +466,7 @@ public void testRetryWhenTopologyMismatch() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testClientEventsNotCausingRemaps() throws Exception {
             Ignite ignite = startGrids(2);
     
    @@ -493,6 +495,7 @@ public void testClientEventsNotCausingRemaps() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testServerEventsCauseRemaps() throws Exception {
             Ignite ignite = startGrids(2);
     
    @@ -525,6 +528,7 @@ public void testServerEventsCauseRemaps() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testDataStreamerWaitsUntilDynamicCacheStartIsFinished() throws Exception {
             final Ignite ignite0 = startGrids(2);
             final Ignite ignite1 = grid(1);
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java
    index 6d7b367727b9a..8a008f71a8b96 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultiThreadedSelfTest.java
    @@ -29,21 +29,19 @@
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.lang.IgniteFuture;
     import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
     
     /**
      * Tests for DataStreamer.
      */
    +@RunWith(JUnit4.class)
     public class DataStreamerMultiThreadedSelfTest extends GridCommonAbstractTest {
    -    /** IP finder. */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private boolean dynamicCache;
     
    @@ -53,11 +51,6 @@ public class DataStreamerMultiThreadedSelfTest extends GridCommonAbstractTest {
     
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
     
    -        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    -        discoSpi.setIpFinder(IP_FINDER);
    -
    -        cfg.setDiscoverySpi(discoSpi);
    -
             if (!dynamicCache)
                 cfg.setCacheConfiguration(cacheConfiguration());
     
    @@ -84,6 +77,7 @@ private CacheConfiguration cacheConfiguration() {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testStartStopIgnites() throws Exception {
             startStopIgnites();
         }
    @@ -91,6 +85,7 @@ public void testStartStopIgnites() throws Exception {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testStartStopIgnitesDynamicCache() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-1602");
     
    @@ -141,4 +136,4 @@ private void startStopIgnites() throws Exception {
                 stopAllGrids();
             }
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultinodeCreateCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultinodeCreateCacheTest.java
    index 3725288fdd938..c3cc212ff0c86 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultinodeCreateCacheTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerMultinodeCreateCacheTest.java
    @@ -25,24 +25,21 @@
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.IgniteInternalFuture;
     import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.GridTestUtils;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class DataStreamerMultinodeCreateCacheTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** {@inheritDoc} */
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -
             ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setSocketTimeout(50);
             ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setAckTimeout(50);
     
    @@ -57,6 +54,7 @@ public class DataStreamerMultinodeCreateCacheTest extends GridCommonAbstractTest
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testCreateCacheAndStream() throws Exception {
             fail("https://issues.apache.org/jira/browse/IGNITE-1603");
     
    @@ -99,4 +97,4 @@ public void testCreateCacheAndStream() throws Exception {
     
             fut.get(2 * 60_000);
         }
    -}
    \ No newline at end of file
    +}
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerTimeoutTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerTimeoutTest.java
    index 6e88adf1d54e1..f11f10db48772 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerTimeoutTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerTimeoutTest.java
    @@ -30,6 +30,9 @@
     import org.apache.ignite.internal.util.typedef.internal.U;
     import org.apache.ignite.stream.StreamReceiver;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
    @@ -37,6 +40,7 @@
     /**
      * Test timeout for Data streamer.
      */
    +@RunWith(JUnit4.class)
     public class DataStreamerTimeoutTest extends GridCommonAbstractTest {
         /** Cache name. */
         public static final String CACHE_NAME = "cacheName";
    @@ -79,6 +83,7 @@ private CacheConfiguration cacheConfiguration() {
          * Test timeout on {@code DataStreamer.addData()} method
          * @throws Exception If fail.
          */
    +    @Test
         public void testTimeoutOnCloseMethod() throws Exception {
             failOn = 1;
     
    @@ -109,6 +114,7 @@ public void testTimeoutOnCloseMethod() throws Exception {
          *
          * @throws Exception If fail.
          */
    +    @Test
         public void testTimeoutOnAddData() throws Exception {
             failOn = 1;
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerUpdateAfterLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerUpdateAfterLoadTest.java
    index bdfc1168f7e1f..d2040013fe8a3 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerUpdateAfterLoadTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerUpdateAfterLoadTest.java
    @@ -25,21 +25,19 @@
     import org.apache.ignite.cache.CacheAtomicityMode;
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
     import org.jetbrains.annotations.NotNull;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
     
     /**
      *
      */
    +@RunWith(JUnit4.class)
     public class DataStreamerUpdateAfterLoadTest extends GridCommonAbstractTest {
    -    /** */
    -    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
    -
         /** */
         private boolean client;
     
    @@ -50,8 +48,6 @@ public class DataStreamerUpdateAfterLoadTest extends GridCommonAbstractTest {
         @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
             IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
     
    -        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    -
             cfg.setClientMode(client);
     
             return cfg;
    @@ -71,6 +67,7 @@ public class DataStreamerUpdateAfterLoadTest extends GridCommonAbstractTest {
         /**
          * @throws Exception If failed.
          */
    +    @Test
         public void testUpdateAfterLoad() throws Exception {
             Ignite ignite0 = ignite(0);
     
    diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/IgniteDataStreamerPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/IgniteDataStreamerPerformanceTest.java
    index f7c82942270ac..4fb5b9016fc2f 100644
    --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/IgniteDataStreamerPerformanceTest.java
    +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/datastreamer/IgniteDataStreamerPerformanceTest.java
    @@ -25,10 +25,10 @@
     import org.apache.ignite.configuration.CacheConfiguration;
     import org.apache.ignite.configuration.IgniteConfiguration;
     import org.apache.ignite.internal.util.typedef.internal.U;
    -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
    -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
     import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.JUnit4;
     
     import static org.apache.ignite.cache.CacheMode.PARTITIONED;
     import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
    @@ -41,10 +41,8 @@
      * 

    * Disable assertions and give at least 2 GB heap to run this test. */ +@RunWith(JUnit4.class) public class IgniteDataStreamerPerformanceTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_CNT = 3; @@ -61,12 +59,6 @@ public class IgniteDataStreamerPerformanceTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - cfg.setIncludeProperties(); cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED); @@ -115,6 +107,7 @@ public class IgniteDataStreamerPerformanceTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPerformance() throws Exception { doTest(); } @@ -195,4 +188,4 @@ private void doTest() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java index 2e8269cbb164d..bfc259a82c931 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java @@ -59,6 +59,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.igfs.IgfsMode.PRIMARY; import static org.apache.ignite.igfs.IgfsMode.PROXY; @@ -66,7 +69,8 @@ /** * Test fo regular igfs operations. */ -@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ConstantConditions"}) +@SuppressWarnings({"ConstantConditions"}) +@RunWith(JUnit4.class) public abstract class IgfsAbstractSelfTest extends IgfsAbstractBaseSelfTest { /** * Constructor. @@ -82,6 +86,7 @@ protected IgfsAbstractSelfTest(IgfsMode mode) { * * @throws Exception If failed. */ + @Test public void testExists() throws Exception { create(igfs, paths(DIR), null); @@ -93,6 +98,7 @@ public void testExists() throws Exception { * * @throws Exception If failed. */ + @Test public void testExistsPathDoesNotExist() throws Exception { assert !igfs.exists(DIR); } @@ -102,6 +108,7 @@ public void testExistsPathDoesNotExist() throws Exception { * * @throws Exception If failed. */ + @Test public void testListFiles() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); @@ -124,6 +131,7 @@ public void testListFiles() throws Exception { * * @throws Exception If failed. */ + @Test public void testListFilesPathDoesNotExist() throws Exception { Collection paths = null; @@ -142,6 +150,7 @@ public void testListFilesPathDoesNotExist() throws Exception { * * @throws Exception If failed. */ + @Test public void testInfo() throws Exception { create(igfs, paths(DIR), null); @@ -157,6 +166,7 @@ public void testInfo() throws Exception { * * @throws Exception If failed. */ + @Test public void testInfoPathDoesNotExist() throws Exception { IgfsFile info = null; @@ -176,6 +186,7 @@ public void testInfoPathDoesNotExist() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameFile() throws Exception { create(igfs, paths(DIR, SUBDIR), paths(FILE)); @@ -190,6 +201,7 @@ public void testRenameFile() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameFileParentRoot() throws Exception { IgfsPath file1 = new IgfsPath("/file1"); IgfsPath file2 = new IgfsPath("/file2"); @@ -208,6 +220,7 @@ public void testRenameFileParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameDirectory() throws Exception { create(igfs, paths(DIR, SUBDIR), null); @@ -222,6 +235,7 @@ public void testRenameDirectory() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameDirectoryParentRoot() throws Exception { IgfsPath dir1 = new IgfsPath("/dir1"); IgfsPath dir2 = new IgfsPath("/dir2"); @@ -240,6 +254,7 @@ public void testRenameDirectoryParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFile() throws Exception { create(igfs, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); @@ -254,6 +269,7 @@ public void testMoveFile() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileDestinationRoot() throws Exception { create(igfs, paths(DIR, SUBDIR), paths(FILE)); @@ -268,6 +284,7 @@ public void testMoveFileDestinationRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileSourceParentRoot() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); @@ -285,6 +302,7 @@ public void testMoveFileSourceParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFile() throws Exception { create(igfs, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); @@ -299,6 +317,7 @@ public void testMoveRenameFile() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileDestinationRoot() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); @@ -315,6 +334,7 @@ public void testMoveRenameFileDestinationRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileSourceParentRoot() throws Exception { IgfsPath file = new IgfsPath("/" + FILE_NEW.name()); @@ -332,6 +352,7 @@ public void testMoveRenameFileSourceParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectory() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); @@ -346,6 +367,7 @@ public void testMoveDirectory() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectoryDestinationRoot() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), null); @@ -360,6 +382,7 @@ public void testMoveDirectoryDestinationRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectorySourceParentRoot() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name()); @@ -377,6 +400,7 @@ public void testMoveDirectorySourceParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectory() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); @@ -391,6 +415,7 @@ public void testMoveRenameDirectory() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectoryDestinationRoot() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name()); @@ -407,6 +432,7 @@ public void testMoveRenameDirectoryDestinationRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectorySourceParentRoot() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR_NEW.name()); @@ -423,6 +449,7 @@ public void testMoveRenameDirectorySourceParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameSourceDoesNotExist() throws Exception { create(igfs, paths(DIR, DIR_NEW), null); @@ -443,6 +470,7 @@ public void testMoveRenameSourceDoesNotExist() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testMkdirs() throws Exception { if (!propertiesSupported()) return; @@ -520,6 +548,7 @@ public void testMkdirs() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testMkdirsParentRoot() throws Exception { Map props = null; @@ -546,6 +575,7 @@ public void testMkdirsParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelete() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); @@ -559,6 +589,7 @@ public void testDelete() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeleteParentRoot() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); @@ -572,6 +603,7 @@ public void testDeleteParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeleteDirectoryNotEmpty() throws Exception { create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); checkExist(igfs, igfsSecondary, SUBDIR, SUBSUBDIR, FILE); @@ -594,6 +626,7 @@ public void testDeleteDirectoryNotEmpty() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testUpdate() throws Exception { if(!propertiesSupported()) return; @@ -616,6 +649,7 @@ public void testUpdate() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testUpdateParentRoot() throws Exception { if(!propertiesSupported()) return; @@ -637,6 +671,7 @@ public void testUpdateParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdatePathDoesNotExist() throws Exception { final Map props = properties("owner", "group", "0555"); @@ -651,6 +686,7 @@ public void testUpdatePathDoesNotExist() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testFormat() throws Exception { if (mode == PROXY) return; @@ -721,6 +757,7 @@ public void testFormat() throws Exception { * * @throws Exception If failed. */ + @Test public void testRootPropertiesPersistAfterFormat() throws Exception { if(!propertiesSupported()) return; @@ -761,6 +798,7 @@ private void checkRootPropertyUpdate(String prop, String setVal, String expGetVa * * @throws Exception If failed. */ + @Test public void testOpen() throws Exception { create(igfs, paths(DIR, SUBDIR), null); @@ -777,6 +815,7 @@ public void testOpen() throws Exception { * * @throws Exception If failed. */ + @Test public void testOpenDoesNotExist() throws Exception { igfsSecondary.delete(FILE.toString(), false); @@ -800,6 +839,7 @@ public void testOpenDoesNotExist() throws Exception { * * @throws Exception If failed. */ + @Test public void testSetTimes() throws Exception { createFile(igfs, FILE, true, chunk); @@ -908,7 +948,8 @@ private void checkSetTimes(IgfsPath path) throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings({"ConstantConditions", "EmptyTryBlock", "UnusedDeclaration"}) + @SuppressWarnings({"ConstantConditions", "EmptyTryBlock"}) + @Test public void testCreate() throws Exception { create(igfs, paths(DIR, SUBDIR), null); @@ -993,6 +1034,7 @@ public void testCreate() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateParentRoot() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); @@ -1006,6 +1048,7 @@ public void testCreateParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateNoClose() throws Exception { if (mode != PRIMARY) return; @@ -1035,6 +1078,7 @@ public void testCreateNoClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateRenameNoClose() throws Exception { if (dual) return; @@ -1060,6 +1104,7 @@ public void testCreateRenameNoClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateRenameParentNoClose() throws Exception { if (dual) return; @@ -1085,6 +1130,7 @@ public void testCreateRenameParentNoClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateDeleteNoClose() throws Exception { if (mode != PRIMARY) return; @@ -1139,6 +1185,7 @@ public void testCreateDeleteNoClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateDeleteParentNoClose() throws Exception { if (mode != PRIMARY) return; @@ -1193,6 +1240,7 @@ public void testCreateDeleteParentNoClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateUpdateNoClose() throws Exception { if (dual) return; @@ -1223,6 +1271,7 @@ public void testCreateUpdateNoClose() throws Exception { * * @throws Exception On error. */ + @Test public void testSimpleWrite() throws Exception { IgfsPath path = new IgfsPath("/file1"); @@ -1258,6 +1307,7 @@ public void testSimpleWrite() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateConsistency() throws Exception { final AtomicInteger ctr = new AtomicInteger(); final AtomicReference err = new AtomicReference<>(); @@ -1300,6 +1350,7 @@ public void testCreateConsistency() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateConsistencyMultithreaded() throws Exception { final AtomicBoolean stop = new AtomicBoolean(); @@ -1378,7 +1429,8 @@ public void testCreateConsistencyMultithreaded() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings({"TryFinallyCanBeTryWithResources", "EmptyTryBlock"}) + @SuppressWarnings({"EmptyTryBlock"}) + @Test public void testAppend() throws Exception { if (appendSupported()) { create(igfs, paths(DIR, SUBDIR), null); @@ -1519,6 +1571,7 @@ public void testAppend() throws Exception { * * @throws Exception If failed. */ + @Test public void testAppendParentRoot() throws Exception { if (appendSupported()) { IgfsPath file = new IgfsPath("/" + FILE.name()); @@ -1536,6 +1589,7 @@ public void testAppendParentRoot() throws Exception { * * @throws Exception If failed. */ + @Test public void testAppendNoClose() throws Exception { if (mode != PRIMARY) return; @@ -1570,6 +1624,7 @@ public Object call() throws Exception { * * @throws Exception If failed. */ + @Test public void testAppendRenameNoClose() throws Exception { if (dual) return; @@ -1598,6 +1653,7 @@ public void testAppendRenameNoClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testAppendRenameParentNoClose() throws Exception { if (dual) return; @@ -1626,6 +1682,7 @@ public void testAppendRenameParentNoClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testAppendDeleteNoClose() throws Exception { if (mode != PRIMARY) return; @@ -1681,6 +1738,7 @@ public boolean apply() { * * @throws Exception If failed. */ + @Test public void testAppendDeleteParentNoClose() throws Exception { if (mode != PRIMARY) return; @@ -1736,6 +1794,7 @@ public boolean apply() { * * @throws Exception If failed. */ + @Test public void testAppendUpdateNoClose() throws Exception { if (dual) return; @@ -1767,6 +1826,7 @@ public void testAppendUpdateNoClose() throws Exception { * * @throws Exception If failed. */ + @Test public void testAppendConsistency() throws Exception { if (appendSupported()) { final AtomicInteger ctr = new AtomicInteger(); @@ -1818,6 +1878,7 @@ public void run() { * * @throws Exception If failed. */ + @Test public void testAppendConsistencyMultithreaded() throws Exception { if (appendSupported()) { final AtomicBoolean stop = new AtomicBoolean(); @@ -1891,6 +1952,7 @@ public void run() { * * @throws Exception If failed. */ + @Test public void testStop() throws Exception { create(igfs, paths(DIR, SUBDIR), null); @@ -1911,6 +1973,7 @@ public void testStop() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentMkdirsDelete() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { final CyclicBarrier barrier = new CyclicBarrier(2); @@ -1959,6 +2022,7 @@ public void testConcurrentMkdirsDelete() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentRenameDeleteSource() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { final CyclicBarrier barrier = new CyclicBarrier(2); @@ -2023,6 +2087,7 @@ public void testConcurrentRenameDeleteSource() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentRenameDeleteDestination() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { final CyclicBarrier barrier = new CyclicBarrier(2); @@ -2079,6 +2144,7 @@ public void testConcurrentRenameDeleteDestination() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentRenames() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { final CyclicBarrier barrier = new CyclicBarrier(2); @@ -2139,6 +2205,7 @@ public void testConcurrentRenames() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentDeletes() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { final CyclicBarrier barrier = new CyclicBarrier(2); @@ -2186,6 +2253,7 @@ public void testConcurrentDeletes() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeadlocksRename() throws Exception { checkDeadlocksRepeat(5, 2, 2, 2, RENAME_CNT, 0, 0, 0, 0); } @@ -2195,6 +2263,7 @@ public void testDeadlocksRename() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeadlocksDelete() throws Exception { checkDeadlocksRepeat(5, 2, 2, 2, 0, DELETE_CNT, 0, 0, 0); } @@ -2204,6 +2273,7 @@ public void testDeadlocksDelete() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeadlocksUpdate() throws Exception { checkDeadlocksRepeat(5, 2, 2, 2, 0, 0, UPDATE_CNT, 0, 0); } @@ -2213,6 +2283,7 @@ public void testDeadlocksUpdate() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeadlocksMkdirs() throws Exception { checkDeadlocksRepeat(5, 2, 2, 2, 0, 0, 0, MKDIRS_CNT, 0); } @@ -2222,6 +2293,7 @@ public void testDeadlocksMkdirs() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeadlocksDeleteRename() throws Exception { checkDeadlocksRepeat(5, 2, 2, 2, RENAME_CNT, DELETE_CNT, 0, 0, 0); } @@ -2231,6 +2303,7 @@ public void testDeadlocksDeleteRename() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeadlocksDeleteMkdirsRename() throws Exception { checkDeadlocksRepeat(5, 2, 2, 2, RENAME_CNT, DELETE_CNT, 0, MKDIRS_CNT, 0); } @@ -2240,6 +2313,7 @@ public void testDeadlocksDeleteMkdirsRename() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeadlocksDeleteMkdirs() throws Exception { checkDeadlocksRepeat(5, 2, 2, 2, 0, DELETE_CNT, 0, MKDIRS_CNT, 0); } @@ -2249,6 +2323,7 @@ public void testDeadlocksDeleteMkdirs() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeadlocksCreate() throws Exception { checkDeadlocksRepeat(5, 2, 2, 2, 0, 0, 0, 0, CREATE_CNT); } @@ -2258,6 +2333,7 @@ public void testDeadlocksCreate() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeadlocks() throws Exception { checkDeadlocksRepeat(5, 2, 2, 2, RENAME_CNT, DELETE_CNT, UPDATE_CNT, MKDIRS_CNT, CREATE_CNT); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAttributesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAttributesSelfTest.java index b430a8ceca8f8..5ff9b0a6df920 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAttributesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAttributesSelfTest.java @@ -27,6 +27,9 @@ import java.util.HashMap; import java.util.Map; import org.apache.ignite.igfs.IgfsMode; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC; import static org.apache.ignite.igfs.IgfsMode.PRIMARY; @@ -35,10 +38,12 @@ /** * {@link IgfsAttributes} test case. */ +@RunWith(JUnit4.class) public class IgfsAttributesSelfTest extends IgfsCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSerialization() throws Exception { Map pathModes = new HashMap<>(); @@ -79,4 +84,4 @@ private boolean eq(IgfsAttributes attr1, IgfsAttributes attr2) throws Exception return true; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java index ff9c51a56a4e8..1b3c6a21017cb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBackupFailoverSelfTest.java @@ -37,6 +37,9 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -53,6 +56,7 @@ * Tests IGFS behavioral guarantees if some nodes on the cluster are synchronously or asynchronously stopped. * The operations to check are read, write or both. */ +@RunWith(JUnit4.class) public class IgfsBackupFailoverSelfTest extends IgfsCommonAbstractTest { /** Directory. */ protected static final IgfsPath DIR = new IgfsPath("/dir"); @@ -205,6 +209,7 @@ private IgfsPath filePath(int j) { * * @throws Exception On error. */ + @Test public void testReadFailoverAfterStopMultipleNodes() throws Exception { final IgfsImpl igfs0 = nodeDatas[0].igfsImpl; @@ -259,6 +264,7 @@ public void testReadFailoverAfterStopMultipleNodes() throws Exception { * * @throws Exception On error. */ + @Test public void testReadFailoverWhileStoppingMultipleNodes() throws Exception { final IgfsImpl igfs0 = nodeDatas[0].igfsImpl; @@ -340,6 +346,7 @@ public void testReadFailoverWhileStoppingMultipleNodes() throws Exception { * * @throws Exception On error. */ + @Test public void testWriteFailoverAfterStopMultipleNodes() throws Exception { final IgfsImpl igfs0 = nodeDatas[0].igfsImpl; @@ -434,6 +441,7 @@ public void testWriteFailoverAfterStopMultipleNodes() throws Exception { * * @throws Exception */ + @Test public void testWriteFailoverWhileStoppingMultipleNodes() throws Exception { final IgfsImpl igfs0 = nodeDatas[0].igfsImpl; @@ -598,4 +606,4 @@ protected static int doWithRetries(int attempts, Callable clo) throws Exce @Override protected long getTestTimeout() { return 20 * 60 * 1000; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java index 9012e0e27f4ad..e3894e0f35716 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java @@ -41,6 +41,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -50,6 +53,7 @@ /** * Test to check for system pool starvation due to {@link IgfsBlocksMessage}. */ +@RunWith(JUnit4.class) public class IgfsBlockMessageSystemPoolStarvationSelfTest extends IgfsCommonAbstractTest { /** First node name. */ private static final String NODE_1_NAME = "node1"; @@ -106,6 +110,7 @@ public class IgfsBlockMessageSystemPoolStarvationSelfTest extends IgfsCommonAbst * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testStarvation() throws Exception { // 1. Create two IGFS file to make all system threads busy. CountDownLatch fileWriteLatch = new CountDownLatch(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java index 44418cedfee19..f86a9f0111fe6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java @@ -44,6 +44,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -54,7 +57,8 @@ /** * Tests for IGFS per-block LR eviction policy. */ -@SuppressWarnings({"ConstantConditions", "ThrowableResultOfMethodCallIgnored"}) +@SuppressWarnings({"ConstantConditions"}) +@RunWith(JUnit4.class) public class IgfsCachePerBlockLruEvictionPolicySelfTest extends IgfsCommonAbstractTest { /** Primary IGFS name. */ private static final String IGFS_PRIMARY = "igfs-primary"; @@ -243,6 +247,7 @@ private void start() throws Exception { * * @throws Exception If failed. */ + @Test public void testFilePrimary() throws Exception { start(); @@ -267,6 +272,7 @@ public void testFilePrimary() throws Exception { * * @throws Exception If failed. */ + @Test public void testFileDual() throws Exception { start(); @@ -297,6 +303,7 @@ public void testFileDual() throws Exception { * * @throws Exception If failed. */ + @Test public void testFileDualExclusion() throws Exception { start(); @@ -324,6 +331,7 @@ public void testFileDualExclusion() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameDifferentExcludeSettings() throws Exception { start(); @@ -351,6 +359,7 @@ public void testRenameDifferentExcludeSettings() throws Exception { * * @throws Exception If failed. */ + @Test public void testBlockCountEviction() throws Exception { start(); @@ -386,6 +395,7 @@ public void testBlockCountEviction() throws Exception { * * @throws Exception If failed. */ + @Test public void testDataSizeEviction() throws Exception { start(); @@ -493,4 +503,4 @@ private void checkEvictionPolicy(final int curBlocks, final long curBytes) }, 5000) : "Unexpected counts [expectedBlocks=" + curBlocks + ", actualBlocks=" + evictPlc.getCurrentBlocks() + ", expectedBytes=" + curBytes + ", currentBytes=" + curBytes + ']'; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCacheSelfTest.java index f8f3a0c421ffd..2bb221630d7cc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCacheSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCacheSelfTest.java @@ -33,6 +33,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -41,6 +44,7 @@ /** * Tests ensuring that IGFS data and meta caches are not "visible" through public API. */ +@RunWith(JUnit4.class) public class IgfsCacheSelfTest extends IgfsCommonAbstractTest { /** Regular cache name. */ private static final String CACHE_NAME = "cache"; @@ -100,6 +104,7 @@ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { * * @throws Exception If failed. */ + @Test public void testCache() throws Exception { final Ignite g = grid(); @@ -133,4 +138,4 @@ public void testCache() throws Exception { assert g.cache(CACHE_NAME) != null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java index c07f0baf15bf8..d21c8b1ea58e5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java @@ -32,9 +32,6 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,6 +42,9 @@ import java.util.Collection; import java.util.Collections; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -54,10 +54,8 @@ /** * {@link IgfsDataManager} test case. */ +@RunWith(JUnit4.class) public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest { - /** Test IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Groups count for data blocks. */ private static final int DATA_BLOCK_GROUP_CNT = 2; @@ -90,12 +88,6 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setMetaCacheConfiguration(cacheConfiguration("meta")); @@ -151,6 +143,7 @@ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testDataStoring() throws Exception { for (int i = 0; i < 10; i++) { IgfsPath path = IgfsPath.ROOT; @@ -235,6 +228,7 @@ public void testDataStoring() throws Exception { * * @throws Exception If failed. */ + @Test public void testDataStoringRemainder() throws Exception { final int blockSize = IGFS_BLOCK_SIZE; @@ -326,6 +320,7 @@ public void testDataStoringRemainder() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDataStoringFlush() throws Exception { final int blockSize = IGFS_BLOCK_SIZE; final int writesCnt = 64; @@ -400,6 +395,7 @@ public void testDataStoringFlush() throws Exception { * * @throws Exception If failed. */ + @Test public void testAffinity() throws Exception { final int blockSize = 10; final int grpSize = blockSize * DATA_BLOCK_GROUP_CNT; @@ -453,6 +449,7 @@ public void testAffinity() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAffinity2() throws Exception { int blockSize = BLOCK_SIZE; @@ -488,6 +485,7 @@ public void testAffinity2() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAffinityFileMap() throws Exception { int blockSize = BLOCK_SIZE; @@ -616,4 +614,4 @@ private void expectsAffinityFail(final IgfsEntryInfo info, final long start, fin } }, IgfsException.class, msg); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java index bc3ef3194dd0d..e0a8cd8a7332e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java @@ -32,15 +32,15 @@ import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.CyclicBarrier; - -import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC; -import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC; -import static org.apache.ignite.igfs.IgfsMode.PROXY; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for IGFS working in mode when remote file system exists: DUAL_SYNC, DUAL_ASYNC. */ @SuppressWarnings("ConstantConditions") +@RunWith(JUnit4.class) public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest { /** * Constructor. @@ -56,6 +56,7 @@ protected IgfsDualAbstractSelfTest(IgfsMode mode) { * * @throws Exception If failed. */ + @Test public void testExistsPathMissing() throws Exception { create(igfsSecondary, paths(DIR), null); @@ -67,6 +68,7 @@ public void testExistsPathMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testListFilesPathMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); @@ -89,6 +91,7 @@ public void testListFilesPathMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testInfoPathMissing() throws Exception { create(igfsSecondary, paths(DIR), null); create(igfs, null, null); @@ -105,6 +108,7 @@ public void testInfoPathMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameFileSourceMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE)); create(igfs, paths(DIR), null); @@ -121,6 +125,7 @@ public void testRenameFileSourceMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameFileSourceMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE)); create(igfs, null, null); @@ -137,6 +142,7 @@ public void testRenameFileSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameFileParentRootSourceMissing() throws Exception { IgfsPath file1 = new IgfsPath("/file1"); IgfsPath file2 = new IgfsPath("/file2"); @@ -155,6 +161,7 @@ public void testRenameFileParentRootSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameDirectorySourceMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), null); create(igfs, paths(DIR), null); @@ -170,6 +177,7 @@ public void testRenameDirectorySourceMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameDirectorySourceMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), null); create(igfs, null, null); @@ -186,6 +194,7 @@ public void testRenameDirectorySourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testRenameDirectoryParentRootSourceMissing() throws Exception { IgfsPath dir1 = new IgfsPath("/dir1"); IgfsPath dir2 = new IgfsPath("/dir2"); @@ -204,6 +213,7 @@ public void testRenameDirectoryParentRootSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileSourceMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); @@ -220,6 +230,7 @@ public void testMoveFileSourceMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileSourceMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR_NEW, SUBDIR_NEW), paths(FILE)); @@ -236,6 +247,7 @@ public void testMoveFileSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileDestinationMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR, SUBDIR, DIR_NEW), paths(FILE)); @@ -252,6 +264,7 @@ public void testMoveFileDestinationMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileDestinationMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR, SUBDIR), paths(FILE)); @@ -268,6 +281,7 @@ public void testMoveFileDestinationMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileSourceAndDestinationMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR, DIR_NEW), null); @@ -284,6 +298,7 @@ public void testMoveFileSourceAndDestinationMissingPartially() throws Exception * * @throws Exception If failed. */ + @Test public void testMoveFileSourceAndDestinationMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, null, null); @@ -300,6 +315,7 @@ public void testMoveFileSourceAndDestinationMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileDestinationRootSourceMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE)); create(igfs, paths(DIR), null); @@ -316,6 +332,7 @@ public void testMoveFileDestinationRootSourceMissingPartially() throws Exception * * @throws Exception If failed. */ + @Test public void testMoveFileDestinationRootSourceMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE)); create(igfs, null, null); @@ -332,6 +349,7 @@ public void testMoveFileDestinationRootSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileSourceParentRootSourceMissing() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); @@ -349,6 +367,7 @@ public void testMoveFileSourceParentRootSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveFileSourceParentRootDestinationMissingPartially() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); @@ -367,6 +386,7 @@ public void testMoveFileSourceParentRootDestinationMissingPartially() throws Exc * * @throws Exception If failed. */ + @Test public void testMoveFileSourceParentRootDestinationMissing() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); @@ -385,6 +405,7 @@ public void testMoveFileSourceParentRootDestinationMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileSourceMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); @@ -401,6 +422,7 @@ public void testMoveRenameFileSourceMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileSourceMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR_NEW, SUBDIR_NEW), paths(FILE)); @@ -417,6 +439,7 @@ public void testMoveRenameFileSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileDestinationMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR, SUBDIR, DIR_NEW), paths(FILE)); @@ -433,6 +456,7 @@ public void testMoveRenameFileDestinationMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileDestinationMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR, SUBDIR), paths(FILE)); @@ -449,6 +473,7 @@ public void testMoveRenameFileDestinationMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileSourceAndDestinationMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, paths(DIR, DIR_NEW), null); @@ -465,6 +490,7 @@ public void testMoveRenameFileSourceAndDestinationMissingPartially() throws Exce * * @throws Exception If failed. */ + @Test public void testMoveRenameFileSourceAndDestinationMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE)); create(igfs, null, null); @@ -481,6 +507,7 @@ public void testMoveRenameFileSourceAndDestinationMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileDestinationRootSourceMissingPartially() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); @@ -499,6 +526,7 @@ public void testMoveRenameFileDestinationRootSourceMissingPartially() throws Exc * * @throws Exception If failed. */ + @Test public void testMoveRenameFileDestinationRootSourceMissing() throws Exception { IgfsPath file = new IgfsPath("/" + FILE.name()); @@ -517,6 +545,7 @@ public void testMoveRenameFileDestinationRootSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileSourceParentRootSourceMissing() throws Exception { IgfsPath file = new IgfsPath("/" + FILE_NEW.name()); @@ -534,6 +563,7 @@ public void testMoveRenameFileSourceParentRootSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameFileSourceParentRootDestinationMissingPartially() throws Exception { IgfsPath file = new IgfsPath("/" + FILE_NEW.name()); @@ -552,6 +582,7 @@ public void testMoveRenameFileSourceParentRootDestinationMissingPartially() thro * * @throws Exception If failed. */ + @Test public void testMoveRenameFileSourceParentRootDestinationMissing() throws Exception { IgfsPath file = new IgfsPath("/" + FILE_NEW.name()); @@ -570,6 +601,7 @@ public void testMoveRenameFileSourceParentRootDestinationMissing() throws Except * * @throws Exception If failed. */ + @Test public void testMoveDirectorySourceMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR, DIR_NEW, SUBDIR_NEW), null); @@ -586,6 +618,7 @@ public void testMoveDirectorySourceMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectorySourceMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR_NEW, SUBDIR_NEW), null); @@ -603,6 +636,7 @@ public void testMoveDirectorySourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectoryDestinationMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW), null); @@ -619,6 +653,7 @@ public void testMoveDirectoryDestinationMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectoryDestinationMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), null); @@ -635,6 +670,7 @@ public void testMoveDirectoryDestinationMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectorySourceAndDestinationMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR, DIR_NEW), null); @@ -651,6 +687,7 @@ public void testMoveDirectorySourceAndDestinationMissingPartially() throws Excep * * @throws Exception If failed. */ + @Test public void testMoveDirectorySourceAndDestinationMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, null, null); @@ -667,6 +704,7 @@ public void testMoveDirectorySourceAndDestinationMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectoryDestinationRootSourceMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR), null); create(igfs, paths(DIR), null); @@ -683,6 +721,7 @@ public void testMoveDirectoryDestinationRootSourceMissingPartially() throws Exce * * @throws Exception If failed. */ + @Test public void testMoveDirectoryDestinationRootSourceMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR), null); create(igfs, null, null); @@ -699,6 +738,7 @@ public void testMoveDirectoryDestinationRootSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectorySourceParentRootSourceMissing() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name()); @@ -716,6 +756,7 @@ public void testMoveDirectorySourceParentRootSourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveDirectorySourceParentRootDestinationMissingPartially() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name()); @@ -734,6 +775,7 @@ public void testMoveDirectorySourceParentRootDestinationMissingPartially() throw * * @throws Exception If failed. */ + @Test public void testMoveDirectorySourceParentRootDestinationMissing() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name()); @@ -752,6 +794,7 @@ public void testMoveDirectorySourceParentRootDestinationMissing() throws Excepti * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectorySourceMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR, DIR_NEW, SUBDIR_NEW), null); @@ -768,6 +811,7 @@ public void testMoveRenameDirectorySourceMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectorySourceMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR_NEW, SUBDIR_NEW), null); @@ -785,6 +829,7 @@ public void testMoveRenameDirectorySourceMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectoryDestinationMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW), null); @@ -801,6 +846,7 @@ public void testMoveRenameDirectoryDestinationMissingPartially() throws Exceptio * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectoryDestinationMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR, SUBDIR, SUBSUBDIR), null); @@ -817,6 +863,7 @@ public void testMoveRenameDirectoryDestinationMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectorySourceAndDestinationMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, paths(DIR, DIR_NEW), null); @@ -833,6 +880,7 @@ public void testMoveRenameDirectorySourceAndDestinationMissingPartially() throws * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectorySourceAndDestinationMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null); create(igfs, null, null); @@ -849,6 +897,7 @@ public void testMoveRenameDirectorySourceAndDestinationMissing() throws Exceptio * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectoryDestinationRootSourceMissingPartially() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name()); @@ -867,6 +916,7 @@ public void testMoveRenameDirectoryDestinationRootSourceMissingPartially() throw * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectoryDestinationRootSourceMissing() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name()); @@ -885,6 +935,7 @@ public void testMoveRenameDirectoryDestinationRootSourceMissing() throws Excepti * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectorySourceParentRootSourceMissing() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR_NEW.name()); @@ -902,6 +953,7 @@ public void testMoveRenameDirectorySourceParentRootSourceMissing() throws Except * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectorySourceParentRootDestinationMissingPartially() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR_NEW.name()); @@ -920,6 +972,7 @@ public void testMoveRenameDirectorySourceParentRootDestinationMissingPartially() * * @throws Exception If failed. */ + @Test public void testMoveRenameDirectorySourceParentRootDestinationMissing() throws Exception { IgfsPath dir = new IgfsPath("/" + SUBSUBDIR_NEW.name()); @@ -938,6 +991,7 @@ public void testMoveRenameDirectorySourceParentRootDestinationMissing() throws E * * @throws Exception If failed. */ + @Test public void testMkdirsParentPathMissingPartially() throws Exception { Map props = null; @@ -968,6 +1022,7 @@ public void testMkdirsParentPathMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testMkdrisParentPathMissing() throws Exception { Map props = null; @@ -999,6 +1054,7 @@ public void testMkdrisParentPathMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeletePathMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); create(igfs, paths(DIR), null); @@ -1014,6 +1070,7 @@ public void testDeletePathMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeletePathMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); create(igfs, null, null); @@ -1029,6 +1086,7 @@ public void testDeletePathMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeleteParentRootPathMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE)); create(igfs, null, null); @@ -1043,6 +1101,7 @@ public void testDeleteParentRootPathMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdatePathMissingPartially() throws Exception { if(!propertiesSupported()) return; @@ -1074,6 +1133,7 @@ public void testUpdatePathMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdatePathMissing() throws Exception { if(!propertiesSupported()) return; @@ -1105,6 +1165,7 @@ public void testUpdatePathMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdateParentRootPathMissing() throws Exception { doUpdateParentRootPathMissing(properties("owner", "group", "0555")); } @@ -1135,6 +1196,7 @@ protected void doUpdateParentRootPathMissing(Map props) throws E * * @throws Exception If failed. */ + @Test public void testOpenMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), null); create(igfs, null, null); @@ -1149,6 +1211,7 @@ public void testOpenMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateParentMissingPartially() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), null); create(igfs, paths(DIR), null); @@ -1165,6 +1228,7 @@ public void testCreateParentMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testSetPropertiesOnPartiallyMissingDirectory() throws Exception { if (!propertiesSupported()) return; @@ -1185,6 +1249,7 @@ public void testSetPropertiesOnPartiallyMissingDirectory() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateParentMissing() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), null); create(igfs, null, null); @@ -1200,6 +1265,7 @@ public void testCreateParentMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testSetPropertiesOnMissingDirectory() throws Exception { if (!propertiesSupported()) return; @@ -1223,6 +1289,7 @@ public void testSetPropertiesOnMissingDirectory() throws Exception { * * @throws Exception If failed. */ + @Test public void testAppendParentMissingPartially() throws Exception { if (!appendSupported()) return; @@ -1244,6 +1311,7 @@ public void testAppendParentMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testAppendParentMissing() throws Exception { if (!appendSupported()) return; @@ -1265,6 +1333,7 @@ public void testAppendParentMissing() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentRenameDeleteSourceRemote() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { final CyclicBarrier barrier = new CyclicBarrier(2); @@ -1321,6 +1390,7 @@ public void testConcurrentRenameDeleteSourceRemote() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentRenameDeleteDestinationRemote() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { final CyclicBarrier barrier = new CyclicBarrier(2); @@ -1373,6 +1443,7 @@ public void testConcurrentRenameDeleteDestinationRemote() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentRenamesRemote() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { final CyclicBarrier barrier = new CyclicBarrier(2); @@ -1433,6 +1504,7 @@ public void testConcurrentRenamesRemote() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentDeletesRemote() throws Exception { for (int i = 0; i < REPEAT_CNT; i++) { final CyclicBarrier barrier = new CyclicBarrier(2); @@ -1526,6 +1598,7 @@ private T2 checkParentListingTime(IgfsSecondaryFileSystem fs, IgfsPa * * @throws Exception On error. */ + @Test public void testAccessAndModificationTimeUpwardsPropagation() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE, FILE2)); @@ -1552,6 +1625,7 @@ public void testAccessAndModificationTimeUpwardsPropagation() throws Exception { * * @throws Exception If failed. */ + @Test public void testSetTimesMissingPartially() throws Exception { if (!timesSupported()) return; @@ -1589,6 +1663,7 @@ public void testSetTimesMissingPartially() throws Exception { * * @throws Exception If failed. */ + @Test public void testSecondarySize() throws Exception { igfs.mkdirs(SUBDIR); @@ -1614,4 +1689,4 @@ public static boolean propertiesContains(Map allProps, Map(Arrays.asList(new T2<>( new IgfsPath("/a/b/c/d"), PROXY), new T2<>(new IgfsPath("/a/P/"), PRIMARY), new T2<>(new IgfsPath("/a/b/"), DUAL_ASYNC)))); @@ -49,6 +56,7 @@ public class IgfsModeResolverSelfTest extends TestCase { /** * @throws Exception If failed. */ + @Test public void testCanContain() throws Exception { for (IgfsMode m: IgfsMode.values()) { // Each mode can contain itself: @@ -68,6 +76,7 @@ public void testCanContain() throws Exception { /** * @throws Exception If failed. */ + @Test public void testResolve() throws Exception { assertEquals(DUAL_SYNC, reslvr.resolveMode(IgfsPath.ROOT)); assertEquals(DUAL_SYNC, reslvr.resolveMode(new IgfsPath("/a"))); @@ -89,6 +98,7 @@ public void testResolve() throws Exception { /** * @throws Exception If failed. */ + @Test public void testModesValidation() throws Exception { // Another mode inside PRIMARY directory: try { @@ -148,6 +158,7 @@ public void testModesValidation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDualParentsWithPrimaryChild() throws Exception { Set set = new HashSet<>(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java index 0720d55792be0..0a43c1d2e4cf0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java @@ -39,6 +39,9 @@ import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -51,6 +54,7 @@ /** * IGFS modes self test. */ +@RunWith(JUnit4.class) public class IgfsModesSelfTest extends IgfsCommonAbstractTest { /** Grid instance hosting primary IGFS. */ private IgniteEx grid; @@ -220,6 +224,7 @@ final void pathModes(IgniteBiTuple... modes) { * * @throws Exception If failed. */ + @Test public void testModeDefaultIsNotSet() throws Exception { setSecondaryFs = true; @@ -233,6 +238,7 @@ public void testModeDefaultIsNotSet() throws Exception { * * @throws Exception If failed. */ + @Test public void testModeDefaultIsSet() throws Exception { mode = DUAL_SYNC; @@ -248,6 +254,7 @@ public void testModeDefaultIsSet() throws Exception { * * @throws Exception If failed. */ + @Test public void testModeSecondaryNoUri() throws Exception { mode = PROXY; @@ -269,6 +276,7 @@ public void testModeSecondaryNoUri() throws Exception { * * @throws Exception If failed. */ + @Test public void testPathMode() throws Exception { pathModes(F.t("/dir1", PROXY), F.t("/dir2", DUAL_SYNC), F.t("/dir3", PRIMARY), F.t("/dir4", PRIMARY)); @@ -297,6 +305,7 @@ public void testPathMode() throws Exception { * * @throws Exception If failed. */ + @Test public void testPathModeSwitchToPrimary() throws Exception { mode = DUAL_SYNC; @@ -314,6 +323,7 @@ public void testPathModeSwitchToPrimary() throws Exception { * * @throws Exception If failed. */ + @Test public void testPathModeSecondaryNoCfg() throws Exception { pathModes(F.t("dir", PROXY)); @@ -335,6 +345,7 @@ public void testPathModeSecondaryNoCfg() throws Exception { * * @throws Exception If failed. */ + @Test public void testPropagationPrimary() throws Exception { mode = PRIMARY; @@ -346,6 +357,7 @@ public void testPropagationPrimary() throws Exception { * * @throws Exception If failed. */ + @Test public void testPropagationDualSync() throws Exception { mode = DUAL_SYNC; @@ -357,6 +369,7 @@ public void testPropagationDualSync() throws Exception { * * @throws Exception If failed. */ + @Test public void testPropagationDualAsync() throws Exception { mode = DUAL_ASYNC; @@ -485,4 +498,4 @@ private void checkPropagation() throws Exception { assert !igfsSecondary.exists(dir); assert !igfsSecondary.exists(file); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsOneClientNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsOneClientNodeTest.java index a55f607883703..dfd70d6ec8273 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsOneClientNodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsOneClientNodeTest.java @@ -30,6 +30,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -37,6 +40,7 @@ /** * Test for igfs with one node in client mode. */ +@RunWith(JUnit4.class) public class IgfsOneClientNodeTest extends GridCommonAbstractTest { /** Regular cache name. */ private static final String CACHE_NAME = "cache"; @@ -94,6 +98,7 @@ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { /** * @throws Exception If failed. */ + @Test public void testStartIgfs() throws Exception { final IgfsImpl igfs = (IgfsImpl) grid(0).fileSystem("igfs"); @@ -124,4 +129,4 @@ public void testStartIgfs() throws Exception { } }, IgfsException.class, "Failed to execute operation because there are no IGFS metadata nodes."); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryMultiNodeSelfTest.java index f004d4069bbe2..0969cfd4b987a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryMultiNodeSelfTest.java @@ -17,9 +17,14 @@ package org.apache.ignite.internal.processors.igfs; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + /** * Multinode test for PRIMARY mode. */ +@RunWith(JUnit4.class) public class IgfsPrimaryMultiNodeSelfTest extends IgfsPrimarySelfTest { /** {@inheritDoc} */ @Override protected int nodeCount() { @@ -29,7 +34,8 @@ public class IgfsPrimaryMultiNodeSelfTest extends IgfsPrimarySelfTest { /** * @throws Exception If failed. */ + @Test @Override public void testCreateConsistencyMultithreaded() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-8823"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryRelaxedConsistencyMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryRelaxedConsistencyMultiNodeSelfTest.java index d35237cacd0fb..a3f11a28a664f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryRelaxedConsistencyMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryRelaxedConsistencyMultiNodeSelfTest.java @@ -17,19 +17,24 @@ package org.apache.ignite.internal.processors.igfs; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + /** * Tests for PRIMARY mode and relaxed consistency model. */ +@RunWith(JUnit4.class) public class IgfsPrimaryRelaxedConsistencyMultiNodeSelfTest extends IgfsPrimaryRelaxedConsistencySelfTest { /** {@inheritDoc} */ @Override protected int nodeCount() { return 4; } - @Override - public void testCreateConsistencyMultithreaded() throws Exception { + @Test + @Override public void testCreateConsistencyMultithreaded() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-8823"); super.testCreateConsistencyMultithreaded(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java index 0ba3bcb221393..3a3c397c9e5a8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java @@ -17,6 +17,17 @@ package org.apache.ignite.internal.processors.igfs; +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.atomic.AtomicInteger; +import javax.cache.Cache; import org.apache.commons.io.IOUtils; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; @@ -40,24 +51,12 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - -import javax.cache.Cache; -import java.security.SecureRandom; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.atomic.AtomicInteger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -67,10 +66,8 @@ /** * Tests for {@link IgfsProcessor}. */ +@RunWith(JUnit4.class) public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest { - /** Test IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Random numbers generator. */ protected final SecureRandom rnd = new SecureRandom(); @@ -114,13 +111,6 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setMetaCacheConfiguration(cacheConfiguration("meta")); @@ -165,6 +155,7 @@ public String igfsName() { } /** @throws Exception If failed. */ + @Test public void testigfsEnabled() throws Exception { IgniteFileSystem igfs = grid(0).fileSystem(igfsName()); @@ -176,6 +167,7 @@ public void testigfsEnabled() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdateProperties() throws Exception { IgfsPath p = path("/tmp/my"); @@ -209,6 +201,7 @@ public void testUpdateProperties() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreate() throws Exception { IgfsPath path = path("/file"); @@ -219,7 +212,7 @@ public void testCreate() throws Exception { for (int i = 0; i < nodesCount(); i++) { IgfsEntryInfo fileInfo = - (IgfsEntryInfo)grid(i).cachex(metaCacheName).localPeek(info.fileId(), null, null); + (IgfsEntryInfo)grid(i).cachex(metaCacheName).localPeek(info.fileId(), null); assertNotNull(fileInfo); assertNotNull(fileInfo.listing()); @@ -235,6 +228,7 @@ public void testCreate() throws Exception { * * @throws Exception In case of any exception. */ + @Test public void testMakeListDeleteDirs() throws Exception { assertListDir("/"); @@ -293,6 +287,7 @@ public void testMakeListDeleteDirs() throws Exception { * @throws Exception In case of any exception. */ @SuppressWarnings("TooBroadScope") + @Test public void testMakeListDeleteDirsMultithreaded() throws Exception { assertListDir("/"); @@ -343,6 +338,7 @@ public void testMakeListDeleteDirsMultithreaded() throws Exception { } /** @throws Exception If failed. */ + @Test public void testBasicOps() throws Exception { // Create directories. igfs.mkdirs(path("/A/B1/C1")); @@ -423,6 +419,7 @@ public void testBasicOps() throws Exception { * * @throws Exception If failed. */ + @Test public void testSize() throws Exception { IgfsPath dir1 = path("/dir1"); IgfsPath subDir1 = path("/dir1/subdir1"); @@ -469,6 +466,7 @@ private > List sorted(Collection col) { } /** @throws Exception If failed. */ + @Test public void testRename() throws Exception { // Create directories. igfs.mkdirs(path("/A/B1/C1")); @@ -616,6 +614,7 @@ private IgfsPath path(long i) { } /** @throws Exception If failed. */ + @Test public void testCreateOpenAppend() throws Exception { // Error - path points to root directory. assertCreateFails("/", false); @@ -676,6 +675,7 @@ public void testCreateOpenAppend() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("BusyWait") + @Test public void testDeleteCacheConsistency() throws Exception { IgfsPath path = new IgfsPath("/someFile"); @@ -735,21 +735,25 @@ public void testDeleteCacheConsistency() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreateAppendLongData1() throws Exception { checkCreateAppendLongData(123, 1024, 100); } /** @throws Exception If failed. */ + @Test public void testCreateAppendLongData2() throws Exception { checkCreateAppendLongData(123 + 1024, 1024, 100); } /** @throws Exception If failed. */ + @Test public void testCreateAppendLongData3() throws Exception { checkCreateAppendLongData(123, 1024, 1000); } /** @throws Exception If failed. */ + @Test public void testCreateAppendLongData4() throws Exception { checkCreateAppendLongData(123 + 1024, 1024, 1000); } @@ -759,6 +763,7 @@ public void testCreateAppendLongData4() throws Exception { * * @throws Exception If failed. */ + @Test public void testFormatNonEmpty() throws Exception { String dirPath = "/A/B/C"; @@ -793,6 +798,7 @@ public void testFormatNonEmpty() throws Exception { * * @throws Exception If failed. */ + @Test public void testFormatEmpty() throws Exception { igfs.clear(); } @@ -989,4 +995,4 @@ private void assertListDir(String path, String... item) { assertEquals(Arrays.asList(item), names); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java index 7484c59fbb2e6..925c86f98e48a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java @@ -27,15 +27,15 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC; @@ -50,10 +50,8 @@ *

    * Tests starting with "testRemote" are checking {@link IgfsProcessor#checkIgfsOnRemoteNode(org.apache.ignite.cluster.ClusterNode)}. */ +@RunWith(JUnit4.class) public class IgfsProcessorValidationSelfTest extends IgfsCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Grid #1 config. */ private IgniteConfiguration g1Cfg; @@ -72,12 +70,6 @@ public class IgfsProcessorValidationSelfTest extends IgfsCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - g1IgfsCfg1.setName("g1IgfsCfg1"); g1IgfsCfg2.setName("g1IgfsCfg2"); @@ -114,6 +106,7 @@ private T[] concat(T[] first, T[] second, Class cls) { /** * @throws Exception If failed. */ + @Test public void testLocalIfAffinityMapperIsWrongClass() throws Exception { for (FileSystemConfiguration igfsCfg : g1Cfg.getFileSystemConfiguration()) { @@ -130,6 +123,7 @@ public void testLocalIfAffinityMapperIsWrongClass() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalIfIgfsConfigsHaveDuplicatedNames() throws Exception { String igfsCfgName = "igfs-cfg"; @@ -142,6 +136,7 @@ public void testLocalIfIgfsConfigsHaveDuplicatedNames() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalIfQueryIndexingEnabledForDataCache() throws Exception { g1IgfsCfg1.setDataCacheConfiguration(dataCache(1024)); g1IgfsCfg1.getDataCacheConfiguration().setIndexedTypes(Integer.class, String.class); @@ -152,6 +147,7 @@ public void testLocalIfQueryIndexingEnabledForDataCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalIfQueryIndexingEnabledForMetaCache() throws Exception { g1IgfsCfg1.setMetaCacheConfiguration(metaCache()); @@ -163,7 +159,7 @@ public void testLocalIfQueryIndexingEnabledForMetaCache() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("NullableProblems") + @Test public void testLocalNullIgfsNameIsNotSupported() throws Exception { try { g1IgfsCfg1.setName(null); @@ -186,6 +182,7 @@ public void testLocalNullIgfsNameIsNotSupported() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalIfNonPrimaryModeAndHadoopFileSystemUriIsNull() throws Exception { g1IgfsCfg2.setDefaultMode(PROXY); @@ -195,6 +192,7 @@ public void testLocalIfNonPrimaryModeAndHadoopFileSystemUriIsNull() throws Excep /** * @throws Exception If failed. */ + @Test public void testRemoteIfDataBlockSizeDiffers() throws Exception { IgniteConfiguration g2Cfg = getConfiguration("g2"); @@ -212,6 +210,7 @@ public void testRemoteIfDataBlockSizeDiffers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoteIfAffinityMapperGroupSizeDiffers() throws Exception { IgniteConfiguration g2Cfg = getConfiguration("g2"); @@ -227,6 +226,7 @@ public void testRemoteIfAffinityMapperGroupSizeDiffers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoteIfDefaultModeDiffers() throws Exception { IgniteConfiguration g2Cfg = getConfiguration("g2"); @@ -249,6 +249,7 @@ public void testRemoteIfDefaultModeDiffers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoteIfPathModeDiffers() throws Exception { IgniteConfiguration g2Cfg = getConfiguration("g2"); @@ -268,6 +269,7 @@ public void testRemoteIfPathModeDiffers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testZeroEndpointTcpPort() throws Exception { checkInvalidPort(0); } @@ -275,6 +277,7 @@ public void testZeroEndpointTcpPort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNegativeEndpointTcpPort() throws Exception { checkInvalidPort(-1); } @@ -282,6 +285,7 @@ public void testNegativeEndpointTcpPort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTooBigEndpointTcpPort() throws Exception { checkInvalidPort(65536); } @@ -289,6 +293,7 @@ public void testTooBigEndpointTcpPort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPreConfiguredCache() throws Exception { FileSystemConfiguration igfsCfg1 = new FileSystemConfiguration(g1IgfsCfg1); igfsCfg1.setName("igfs"); @@ -335,6 +340,7 @@ private void checkInvalidPort(int port) throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvalidEndpointThreadCount() throws Exception { final String failMsg = "IGFS endpoint thread count must be positive"; @@ -404,4 +410,4 @@ private CacheConfiguration metaCache() { return metaCache; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemInjectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemInjectionSelfTest.java index 1e24610d938ef..fb12e880bedd4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemInjectionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryFileSystemInjectionSelfTest.java @@ -40,6 +40,9 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -48,6 +51,7 @@ /** * Tests for resource injection to secondary file system. */ +@RunWith(JUnit4.class) public class IgfsSecondaryFileSystemInjectionSelfTest extends GridCommonAbstractTest { /** IGFS name. */ protected static final String IGFS_NAME = "igfs-test"; @@ -93,7 +97,7 @@ public class IgfsSecondaryFileSystemInjectionSelfTest extends GridCommonAbstract /** * @throws Exception If failed. */ - @SuppressWarnings({"UnusedDeclaration"}) + @Test public void testInjectPrimaryByField() throws Exception { secondary = new TestBaseSecondaryFsMock() { @FileSystemResource @@ -120,7 +124,7 @@ public void testInjectPrimaryByField() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"UnusedDeclaration"}) + @Test public void testInjectPrimaryByMethods() throws Exception { secondary = new TestBaseSecondaryFsMock() { /** Ignite instance. */ @@ -171,7 +175,7 @@ void setIgniteInst(Ignite ig) { /** * */ - private static abstract class TestBaseSecondaryFsMock implements IgfsSecondaryFileSystem { + private abstract static class TestBaseSecondaryFsMock implements IgfsSecondaryFileSystem { /** {@inheritDoc} */ @Override public boolean exists(IgfsPath path) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest.java index 0d65bb87aa7ec..b987752781d59 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest.java @@ -37,10 +37,10 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.configuration.FileSystemConfiguration.DFLT_MGMT_PORT; @@ -48,10 +48,8 @@ /** * Base test class for {@link IgfsServer} checking IPC endpoint registrations. */ +@RunWith(JUnit4.class) public abstract class IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest extends IgfsCommonAbstractTest { - /** IP finder. */ - protected static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - private static final AtomicInteger mgmtPort = new AtomicInteger(DFLT_MGMT_PORT); /** {@inheritDoc} */ @@ -62,6 +60,7 @@ public abstract class IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest e /** * @throws Exception If failed. */ + @Test public void testLoopbackEndpointsRegistration() throws Exception { IgniteConfiguration cfg = gridConfiguration(); @@ -81,6 +80,7 @@ public void testLoopbackEndpointsRegistration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoopbackEndpointsCustomHostRegistration() throws Exception { IgniteConfiguration cfg = gridConfigurationManyIgfsCaches(2); @@ -130,11 +130,6 @@ else if (record.clazz() == IpcServerTcpEndpoint.class) protected IgniteConfiguration gridConfiguration() throws Exception { IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName()); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setName("partitioned"); @@ -165,11 +160,6 @@ protected IgniteConfiguration gridConfiguration() throws Exception { IgniteConfiguration gridConfigurationManyIgfsCaches(int cacheCtn) throws Exception { IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName()); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - List cachesCfg = new ArrayList<>(); for (int i = 0; i < cacheCtn; ++i) { @@ -263,4 +253,4 @@ protected FileSystemConfiguration igfsConfiguration(@Nullable IgfsIpcEndpointTyp return igfsConfiguration; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationOnLinuxAndMacSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationOnLinuxAndMacSelfTest.java index 030c852e520fd..2ec7a38ef6a66 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationOnLinuxAndMacSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationOnLinuxAndMacSelfTest.java @@ -22,16 +22,21 @@ import org.apache.ignite.igfs.IgfsIpcEndpointType; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.T2; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link IgfsServer} that checks all IPC endpoint registration types * permitted for Linux and Mac OS. */ +@RunWith(JUnit4.class) public class IgfsServerManagerIpcEndpointRegistrationOnLinuxAndMacSelfTest extends IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testLoopbackAndShmemEndpointsRegistration() throws Exception { IgniteConfiguration cfg = gridConfigurationManyIgfsCaches(3); @@ -51,4 +56,4 @@ public void testLoopbackAndShmemEndpointsRegistration() throws Exception { assertEquals(4, res.get1().intValue()); assertEquals(2, res.get2().intValue()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationOnWindowsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationOnWindowsSelfTest.java index b16beb124a5ee..0ac420dde422d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationOnWindowsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationOnWindowsSelfTest.java @@ -25,16 +25,21 @@ import org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryServerEndpoint; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link IgfsServerManager} that checks shmem IPC endpoint registration * forbidden for Windows. */ +@RunWith(JUnit4.class) public class IgfsServerManagerIpcEndpointRegistrationOnWindowsSelfTest extends IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testShmemEndpointsRegistration() throws Exception { Throwable e = GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -50,4 +55,4 @@ public void testShmemEndpointsRegistration() throws Exception { assert e.getCause().getCause().getMessage().contains(" should not be configured on Windows (configure " + IpcServerTcpEndpoint.class.getSimpleName() + ")"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java index d37cd9c6ec83c..112c12ea218fb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java @@ -52,6 +52,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -61,6 +64,7 @@ /** * {@link IgfsAttributes} test case. */ +@RunWith(JUnit4.class) public class IgfsSizeSelfTest extends IgfsCommonAbstractTest { /** How many grids to start. */ private static final int GRID_CNT = 3; @@ -77,9 +81,6 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest { /** IGFS name. */ private static final String IGFS_NAME = "test"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** IGFS management port */ private static int mgmtPort; @@ -143,11 +144,6 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest { igfsCfg.setMetaCacheConfiguration(metaCfg); igfsCfg.setDataCacheConfiguration(dataCfg); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); cfg.setFileSystemConfiguration(igfsCfg); if (memIgfsdDataPlcSetter != null) @@ -173,6 +169,7 @@ private void startUp() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitioned() throws Exception { cacheMode = PARTITIONED; nearEnabled = true; @@ -185,6 +182,7 @@ public void testPartitioned() throws Exception { * * @throws Exception If failed. */ + @Test public void testColocated() throws Exception { cacheMode = PARTITIONED; nearEnabled = false; @@ -197,6 +195,7 @@ public void testColocated() throws Exception { * * @throws Exception If failed. */ + @Test public void testReplicated() throws Exception { cacheMode = REPLICATED; @@ -208,6 +207,7 @@ public void testReplicated() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitionedOversize() throws Exception { cacheMode = PARTITIONED; nearEnabled = true; @@ -220,6 +220,7 @@ public void testPartitionedOversize() throws Exception { * * @throws Exception If failed. */ + @Test public void testColocatedOversize() throws Exception { cacheMode = PARTITIONED; nearEnabled = false; @@ -232,6 +233,7 @@ public void testColocatedOversize() throws Exception { * * @throws Exception If failed. */ + @Test public void testReplicatedOversize() throws Exception { cacheMode = REPLICATED; @@ -243,6 +245,7 @@ public void testReplicatedOversize() throws Exception { * * @throws Exception If failed. */ + @Test public void testPartitionedPreload() throws Exception { cacheMode = PARTITIONED; nearEnabled = true; @@ -255,6 +258,7 @@ public void testPartitionedPreload() throws Exception { * * @throws Exception If failed. */ + @Test public void testColocatedPreload() throws Exception { cacheMode = PARTITIONED; nearEnabled = false; @@ -709,4 +713,4 @@ private int length() { return len; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java index 46fdae578abca..6b39ff69e59f1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java @@ -28,14 +28,14 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -47,10 +47,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgfsStartCacheTest extends IgfsCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** * @param igfs If {@code true} created IGFS configuration. * @param idx Node index. @@ -59,12 +57,6 @@ public class IgfsStartCacheTest extends IgfsCommonAbstractTest { private IgniteConfiguration config(boolean igfs, int idx) { IgniteConfiguration cfg = new IgniteConfiguration(); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - if (igfs) { FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); @@ -106,6 +98,7 @@ private IgniteConfiguration config(boolean igfs, int idx) { /** * @throws Exception If failed. */ + @Test public void testCacheStart() throws Exception { Ignite g0 = G.start(config(true, 0)); @@ -165,4 +158,4 @@ private void checkCache(GridCacheAdapter cache) { assertTrue(cache.context().systemTx()); assertEquals(SYSTEM_POOL, cache.context().ioPolicy()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java index 115cd2ea551f6..20f3fdcd0fdab 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java @@ -35,9 +35,6 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,6 +49,9 @@ import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicInteger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -62,10 +62,8 @@ /** * Tests for IGFS streams content. */ +@RunWith(JUnit4.class) public class IgfsStreamsSelfTest extends IgfsCommonAbstractTest { - /** Test IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Group size. */ public static final int CFG_GRP_SIZE = 128; @@ -113,12 +111,6 @@ public class IgfsStreamsSelfTest extends IgfsCommonAbstractTest { cfg.setCacheConfiguration(); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setMetaCacheConfiguration(cacheConfiguration("meta")); @@ -159,6 +151,7 @@ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { * * @throws Exception In case of exception. */ + @Test public void testCreateFile() throws Exception { IgfsPath path = new IgfsPath("/asdf"); @@ -172,6 +165,7 @@ public void testCreateFile() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreateFileColocated() throws Exception { IgfsPath path = new IgfsPath("/colocated"); @@ -210,6 +204,7 @@ public void testCreateFileColocated() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreateFileFragmented() throws Exception { IgfsEx impl = (IgfsEx)grid(0).fileSystem("igfs"); String metaCacheName = grid(0).igfsx("igfs").configuration().getMetaCacheConfiguration().getName(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java index f95907763b9e1..55e0fd1f9faa0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java @@ -40,9 +40,6 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.JobContextResource; import org.apache.ignite.resources.TaskSessionResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import java.io.IOException; import java.io.OutputStreamWriter; @@ -50,6 +47,9 @@ import java.util.Collections; import java.util.List; import java.util.Random; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -60,6 +60,7 @@ /** * Tests for {@link IgfsTask}. */ +@RunWith(JUnit4.class) public class IgfsTaskSelfTest extends IgfsCommonAbstractTest { /** Predefined words dictionary. */ private static final String[] DICTIONARY = new String[] {"word0", "word1", "word2", "word3", "word4", "word5", @@ -68,9 +69,6 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest { /** File path. */ private static final IgfsPath FILE = new IgfsPath("/file"); - /** Shared IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Block size: 64 Kb. */ private static final int BLOCK_SIZE = 64 * 1024; @@ -131,11 +129,6 @@ private IgniteConfiguration config(int idx) { IgniteConfiguration cfg = new IgniteConfiguration(); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); cfg.setFileSystemConfiguration(igfsCfg); cfg.setIgniteInstanceName("node-" + idx); @@ -149,6 +142,7 @@ private IgniteConfiguration config(int idx) { * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testTask() throws Exception { String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)]; @@ -168,6 +162,7 @@ public void testTask() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testTaskAsync() throws Exception { String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)]; @@ -287,4 +282,4 @@ private static class Job implements IgfsJob, Serializable { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsAbstractRecordResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsAbstractRecordResolverSelfTest.java index 0395e211ae997..750acfed84789 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsAbstractRecordResolverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsAbstractRecordResolverSelfTest.java @@ -30,9 +30,6 @@ import org.apache.ignite.igfs.IgfsPath; import org.apache.ignite.igfs.mapreduce.IgfsFileRange; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -48,9 +45,6 @@ public class IgfsAbstractRecordResolverSelfTest extends GridCommonAbstractTest { /** File path. */ protected static final IgfsPath FILE = new IgfsPath("/file"); - /** Shared IP finder. */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** IGFS. */ protected static IgniteFileSystem igfs; @@ -84,11 +78,6 @@ public class IgfsAbstractRecordResolverSelfTest extends GridCommonAbstractTest { cfg.setIgniteInstanceName("grid"); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); cfg.setFileSystemConfiguration(igfsCfg); Ignite g = G.start(cfg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsByteDelimiterRecordResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsByteDelimiterRecordResolverSelfTest.java index 9564a1899d911..d2e78c9434231 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsByteDelimiterRecordResolverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsByteDelimiterRecordResolverSelfTest.java @@ -21,16 +21,21 @@ import org.apache.ignite.igfs.mapreduce.IgfsFileRange; import org.apache.ignite.igfs.mapreduce.records.IgfsByteDelimiterRecordResolver; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Byte delimiter split resolver self test. */ +@RunWith(JUnit4.class) public class IgfsByteDelimiterRecordResolverSelfTest extends IgfsAbstractRecordResolverSelfTest { /** * Test split resolution when there are no delimiters in the file. * * @throws Exception If failed. */ + @Test public void testNoDelimiters() throws Exception { byte[] delim = wrap(2); byte[] data = array(F.t(wrap(1), 8)); @@ -47,6 +52,7 @@ public void testNoDelimiters() throws Exception { * * @throws Exception If failed. */ + @Test public void testHeadDelimiter() throws Exception { byte[] delim = array(F.t(wrap(2), 8)); byte[] data = array(F.t(delim, 1), F.t(wrap(1), 8)); @@ -73,6 +79,7 @@ public void testHeadDelimiter() throws Exception { * * @throws Exception If failed. */ + @Test public void testEndDelimiter() throws Exception { byte[] delim = array(F.t(wrap(2), 8)); byte[] data = array(F.t(wrap(1), 8), F.t(delim, 1)); @@ -99,6 +106,7 @@ public void testEndDelimiter() throws Exception { * * @throws Exception If failed. */ + @Test public void testMiddleDelimiter() throws Exception { byte[] delim = array(F.t(wrap(2), 8)); byte[] data = array(F.t(wrap(1), 8), F.t(delim, 1), F.t(wrap(1), 8)); @@ -139,6 +147,7 @@ public void testMiddleDelimiter() throws Exception { * * @throws Exception If failed. */ + @Test public void testTwoHeadDelimiters() throws Exception { byte[] delim = array(F.t(wrap(2), 8)); byte[] data = array(F.t(delim, 2), F.t(wrap(1), 8)); @@ -179,6 +188,7 @@ public void testTwoHeadDelimiters() throws Exception { * * @throws Exception If failed. */ + @Test public void testTwoTailDelimiters() throws Exception { byte[] delim = array(F.t(wrap(2), 8)); byte[] data = array(F.t(wrap(1), 8), F.t(delim, 2)); @@ -219,6 +229,7 @@ public void testTwoTailDelimiters() throws Exception { * * @throws Exception If failed. */ + @Test public void testHeadAndTailDelimiters() throws Exception { byte[] delim = array(F.t(wrap(2), 8)); byte[] data = array(F.t(delim, 1), F.t(wrap(1), 8), F.t(delim, 1)); @@ -259,6 +270,7 @@ public void testHeadAndTailDelimiters() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelimiterStartsWithTheSameBytesAsLastPreviousDataByte() throws Exception { byte[] delim = array(F.t(wrap(1, 1, 2), 1)); byte[] data = array(F.t(wrap(1), 1), F.t(delim, 1), F.t(wrap(1), 1)); @@ -332,4 +344,4 @@ public void assertSplitNull(long suggestedStart, long suggestedLen, byte[] data, private IgfsByteDelimiterRecordResolver resolver(byte[]... delims) { return new IgfsByteDelimiterRecordResolver(delims); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsFixedLengthRecordResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsFixedLengthRecordResolverSelfTest.java index d869d5c9cac7e..6e07f85905b84 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsFixedLengthRecordResolverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsFixedLengthRecordResolverSelfTest.java @@ -21,16 +21,21 @@ import org.apache.ignite.igfs.mapreduce.IgfsFileRange; import org.apache.ignite.igfs.mapreduce.records.IgfsFixedLengthRecordResolver; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Fixed length split resolver self test. */ +@RunWith(JUnit4.class) public class IgfsFixedLengthRecordResolverSelfTest extends IgfsAbstractRecordResolverSelfTest { /** * Test split resolver. * * @throws Exception If failed. */ + @Test public void testResolver() throws Exception { byte[] data = array(F.t(wrap(1), 24)); @@ -144,4 +149,4 @@ public void assertSplitNull(long suggestedStart, long suggestedLen, byte[] data, private IgfsFixedLengthRecordResolver resolver(int len) { return new IgfsFixedLengthRecordResolver(len); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsNewLineDelimiterRecordResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsNewLineDelimiterRecordResolverSelfTest.java index d0050614945fe..8ea1afa46d3e3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsNewLineDelimiterRecordResolverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsNewLineDelimiterRecordResolverSelfTest.java @@ -21,6 +21,9 @@ import org.apache.ignite.igfs.mapreduce.IgfsFileRange; import org.apache.ignite.igfs.mapreduce.records.IgfsNewLineRecordResolver; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.igfs.mapreduce.records.IgfsNewLineRecordResolver.SYM_CR; import static org.apache.ignite.igfs.mapreduce.records.IgfsNewLineRecordResolver.SYM_LF; @@ -28,12 +31,14 @@ /** * New line split resolver self test. */ +@RunWith(JUnit4.class) public class IgfsNewLineDelimiterRecordResolverSelfTest extends IgfsAbstractRecordResolverSelfTest { /** * Test new line delimtier record resovler. * * @throws Exception If failed. */ + @Test public void test() throws Exception{ byte[] data = array(F.t(wrap(1), 8), F.t(wrap(SYM_LF), 1), F.t(wrap(1), 8), F.t(wrap(SYM_CR, SYM_LF), 1), F.t(wrap(1), 8)); @@ -127,4 +132,4 @@ public void assertSplitNull(long suggestedStart, long suggestedLen, byte[] data) private IgfsNewLineRecordResolver resolver() { return IgfsNewLineRecordResolver.NEW_LINE; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsStringDelimiterRecordResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsStringDelimiterRecordResolverSelfTest.java index cc4c2db6d979b..6539e5b342d35 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsStringDelimiterRecordResolverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/split/IgfsStringDelimiterRecordResolverSelfTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.igfs.mapreduce.records.IgfsByteDelimiterRecordResolver; import org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * String delimiter split resolver self-test. */ +@RunWith(JUnit4.class) public class IgfsStringDelimiterRecordResolverSelfTest extends IgfsAbstractRecordResolverSelfTest { /** Charset used in tests. */ private static final Charset UTF8 = Charset.forName("UTF-8"); @@ -36,6 +40,7 @@ public class IgfsStringDelimiterRecordResolverSelfTest extends IgfsAbstractRecor * * @throws Exception If failed. */ + @Test public void testResolver() throws Exception { String delim = "aaaaaaaa"; @@ -134,4 +139,4 @@ public void assertSplitNull(long suggestedStart, long suggestedLen, byte[] data, private IgfsStringDelimiterRecordResolver resolver(String... delims) { return new IgfsStringDelimiterRecordResolver(UTF8, delims); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/jobmetrics/GridJobMetricsProcessorLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/jobmetrics/GridJobMetricsProcessorLoadTest.java index c75f002340c79..1fab2355a37f2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/jobmetrics/GridJobMetricsProcessorLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/jobmetrics/GridJobMetricsProcessorLoadTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid job metrics processor load test. */ +@RunWith(JUnit4.class) public class GridJobMetricsProcessorLoadTest extends GridCommonAbstractTest { /** */ private static final int THREADS_CNT = 10; @@ -55,6 +59,7 @@ public GridJobMetricsProcessorLoadTest() { /** * @throws Exception if failed. */ + @Test public void testJobMetricsMultiThreaded() throws Exception { GridTestUtils.runMultiThreaded(new Runnable() { @Override public void run() { @@ -86,4 +91,4 @@ public void testJobMetricsMultiThreaded() throws Exception { ctx.jobMetric().getJobMetrics(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/messaging/IgniteMessagingConfigVariationFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/messaging/IgniteMessagingConfigVariationFullApiTest.java index 33a8a7392cbff..339c9f22eaf96 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/messaging/IgniteMessagingConfigVariationFullApiTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/messaging/IgniteMessagingConfigVariationFullApiTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.cluster.ClusterGroup; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * The test checks process messaging. */ +@RunWith(JUnit4.class) public class IgniteMessagingConfigVariationFullApiTest extends IgniteConfigVariationsAbstractTest { /** * Message topic. @@ -55,6 +59,7 @@ public class IgniteMessagingConfigVariationFullApiTest extends IgniteConfigVaria /** * @throws Exception If failed. */ + @Test public void testLocalServer() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -66,6 +71,7 @@ public void testLocalServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalServerAsync() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -77,6 +83,7 @@ public void testLocalServerAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalListener() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -88,6 +95,7 @@ public void testLocalListener() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerClientMessage() throws Exception { if (!testsCfg.withClients()) return; @@ -102,6 +110,7 @@ public void testServerClientMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerClientMessageAsync() throws Exception { if (!testsCfg.withClients()) return; @@ -116,6 +125,7 @@ public void testServerClientMessageAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientClientMessage() throws Exception { if (!testsCfg.withClients()) return; @@ -130,6 +140,7 @@ public void testClientClientMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientClientMessageAsync() throws Exception { if (!testsCfg.withClients()) return; @@ -144,6 +155,7 @@ public void testClientClientMessageAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientServerMessage() throws Exception { if (!testsCfg.withClients()) return; @@ -158,6 +170,7 @@ public void testClientServerMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientServerMessageAsync() throws Exception { if (!testsCfg.withClients()) return; @@ -172,6 +185,7 @@ public void testClientServerMessageAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollectionMessage() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -183,6 +197,7 @@ public void testCollectionMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOrderedMessage() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -194,6 +209,7 @@ public void testOrderedMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientServerOrderedMessage() throws Exception { if (!testsCfg.withClients()) return; @@ -208,6 +224,7 @@ public void testClientServerOrderedMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientClientOrderedMessage() throws Exception { if (!testsCfg.withClients()) return; @@ -222,6 +239,7 @@ public void testClientClientOrderedMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerClientOrderedMessage() throws Exception { if (!testsCfg.withClients()) return; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java index cabeb496857f2..93439d28e8630 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java @@ -27,11 +27,15 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * ODBC configuration validation tests. */ @SuppressWarnings("deprecation") +@RunWith(JUnit4.class) public class OdbcConfigurationValidationSelfTest extends GridCommonAbstractTest { /** Node index generator. */ private static final AtomicInteger NODE_IDX_GEN = new AtomicInteger(); @@ -46,6 +50,7 @@ public class OdbcConfigurationValidationSelfTest extends GridCommonAbstractTest * * @throws Exception If failed. */ + @Test public void testAddressDefault() throws Exception { check(new OdbcConfiguration(), true); } @@ -55,6 +60,7 @@ public void testAddressDefault() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddressHostOnly() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1"), true); } @@ -64,6 +70,7 @@ public void testAddressHostOnly() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddressHostAndPort() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999"), true); @@ -76,6 +83,7 @@ public void testAddressHostAndPort() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddressHostAndPortRange() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), true); check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), true); @@ -89,6 +97,7 @@ public void testAddressHostAndPortRange() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddressInvalidHost() throws Exception { check(new OdbcConfiguration().setEndpointAddress("126.0.0.1"), false); } @@ -98,6 +107,7 @@ public void testAddressInvalidHost() throws Exception { * * @throws Exception If failed. */ + @Test public void testAddressInvalidFormat() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:"), false); @@ -121,6 +131,7 @@ public void testAddressInvalidFormat() throws Exception { * * @throws Exception If failed. */ + @Test public void testConnectionParams() throws Exception { check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000") .setSocketSendBufferSize(4 * 1024), true); @@ -140,6 +151,7 @@ public void testConnectionParams() throws Exception { * * @throws Exception If failed. */ + @Test public void testThreadPoolSize() throws Exception { check(new OdbcConfiguration().setThreadPoolSize(0), false); check(new OdbcConfiguration().setThreadPoolSize(-1), false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java index c08c40ca98c01..6df2ad5e715ad 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java @@ -23,14 +23,19 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Escape sequence parser tests. */ +@RunWith(JUnit4.class) public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest { /** * Test simple cases. */ + @Test public void testTrivial() { check( "select * from table;", @@ -41,6 +46,7 @@ public void testTrivial() { /** * Test escape sequence series. */ + @Test public void testSimpleFunction() throws Exception { check( "test()", @@ -76,6 +82,7 @@ public void testSimpleFunction() throws Exception { /** * Test escape sequence for explicit data type conversion */ + @Test public void testConvertFunction() throws Exception { check( "CONVERT ( CURDATE(), CHAR )", @@ -207,6 +214,7 @@ public void testConvertFunction() throws Exception { /** * Test simple nested escape sequences. Depth = 2. */ + @Test public void testNestedFunction() throws Exception { check( "func1(field1, func2(field2))", @@ -227,6 +235,7 @@ public void testNestedFunction() throws Exception { /** * Test nested escape sequences. Depth > 2. */ + @Test public void testDeepNestedFunction() { check( "func1(func2(func3(field1)))", @@ -252,6 +261,7 @@ public void testDeepNestedFunction() { /** * Test series of nested escape sequences. */ + @Test public void testNestedFunctionMixed() { check( "func1(func2(field1), func3(field2))", @@ -272,6 +282,7 @@ public void testNestedFunctionMixed() { /** * Test invalid escape sequence. */ + @Test public void testFailedOnInvalidFunctionSequence() { checkFail("{fnfunc1()}"); @@ -283,6 +294,7 @@ public void testFailedOnInvalidFunctionSequence() { /** * Test escape sequences with additional whitespace characters */ + @Test public void testFunctionEscapeSequenceWithWhitespaces() throws Exception { check("func1()", "{ fn func1()}"); @@ -296,6 +308,7 @@ public void testFunctionEscapeSequenceWithWhitespaces() throws Exception { /** * Test guid escape sequences */ + @Test public void testGuidEscapeSequence() { check( "CAST('12345678-9abc-def0-1234-123456789abc' AS UUID)", @@ -316,6 +329,7 @@ public void testGuidEscapeSequence() { /** * Test invalid escape sequence. */ + @Test public void testFailedOnInvalidGuidSequence() { checkFail("select {guid'12345678-9abc-def0-1234-123456789abc'}"); @@ -341,6 +355,7 @@ public void testFailedOnInvalidGuidSequence() { /** * Test escape sequences with additional whitespace characters */ + @Test public void testGuidEscapeSequenceWithWhitespaces() throws Exception { check( "CAST('12345678-9abc-def0-1234-123456789abc' AS UUID)", @@ -361,6 +376,7 @@ public void testGuidEscapeSequenceWithWhitespaces() throws Exception { /** * Test date escape sequences */ + @Test public void testDateEscapeSequence() throws Exception { check( "'2016-08-26'", @@ -381,6 +397,7 @@ public void testDateEscapeSequence() throws Exception { /** * Test date escape sequences with additional whitespace characters */ + @Test public void testDateEscapeSequenceWithWhitespaces() throws Exception { check("'2016-08-26'", "{ d '2016-08-26'}"); @@ -392,6 +409,7 @@ public void testDateEscapeSequenceWithWhitespaces() throws Exception { /** * Test invalid escape sequence. */ + @Test public void testFailedOnInvalidDateSequence() { checkFail("{d'2016-08-26'}"); @@ -411,6 +429,7 @@ public void testFailedOnInvalidDateSequence() { /** * Test date escape sequences */ + @Test public void testTimeEscapeSequence() throws Exception { check("'13:15:08'", "{t '13:15:08'}"); @@ -423,6 +442,7 @@ public void testTimeEscapeSequence() throws Exception { /** * Test date escape sequences with additional whitespace characters */ + @Test public void testTimeEscapeSequenceWithWhitespaces() throws Exception { check("'13:15:08'", "{ t '13:15:08'}"); @@ -434,6 +454,7 @@ public void testTimeEscapeSequenceWithWhitespaces() throws Exception { /** * Test invalid escape sequence. */ + @Test public void testFailedOnInvalidTimeSequence() { checkFail("{t'13:15:08'}"); @@ -453,6 +474,7 @@ public void testFailedOnInvalidTimeSequence() { /** * Test timestamp escape sequences */ + @Test public void testTimestampEscapeSequence() throws Exception { check( "'2016-08-26 13:15:08'", @@ -478,6 +500,7 @@ public void testTimestampEscapeSequence() throws Exception { /** * Test timestamp escape sequences with additional whitespace characters */ + @Test public void testTimestampEscapeSequenceWithWhitespaces() throws Exception { check("'2016-08-26 13:15:08'", "{ ts '2016-08-26 13:15:08'}" @@ -495,6 +518,7 @@ public void testTimestampEscapeSequenceWithWhitespaces() throws Exception { /** * Test invalid escape sequence. */ + @Test public void testFailedOnInvalidTimestampSequence() { checkFail("{ts '2016-08-26 13:15:08,12345'}"); @@ -523,6 +547,7 @@ public void testFailedOnInvalidTimestampSequence() { /** * Test escape sequence series. */ + @Test public void testOuterJoinFunction() throws Exception { check( "t OUTER JOIN t2 ON t.id=t2.id", @@ -543,6 +568,7 @@ public void testOuterJoinFunction() throws Exception { /** * Test simple nested escape sequences. Depth = 2. */ + @Test public void testNestedOuterJoin() throws Exception { check( "t OUTER JOIN (t2 OUTER JOIN t3 ON t2.id=t3.id) ON t.id=t2.id", @@ -563,6 +589,7 @@ public void testNestedOuterJoin() throws Exception { /** * Test nested escape sequences. Depth > 2. */ + @Test public void testDeepNestedOuterJoin() { check( "t OUTER JOIN (t2 OUTER JOIN (t3 OUTER JOIN t4 ON t3.id=t4.id) ON t2.id=t3.id) ON t.id=t2.id", @@ -588,6 +615,7 @@ public void testDeepNestedOuterJoin() { /** * Test invalid escape sequence. */ + @Test public void testFailedOnInvalidOuterJoinSequence() { checkFail("{ojt OUTER JOIN t2 ON t.id=t2.id}"); @@ -599,6 +627,7 @@ public void testFailedOnInvalidOuterJoinSequence() { /** * Test escape sequences with additional whitespace characters */ + @Test public void testOuterJoinSequenceWithWhitespaces() throws Exception { check( "t OUTER JOIN t2 ON t.id=t2.id", @@ -619,6 +648,7 @@ public void testOuterJoinSequenceWithWhitespaces() throws Exception { /** * Test non-escape sequences. */ + @Test public void testNonEscapeSequence() throws Exception { check("'{fn test()}'", "'{fn test()}'"); @@ -676,6 +706,7 @@ public void testNonEscapeSequence() throws Exception { /** * Test escape sequence series. */ + @Test public void testSimpleCallProc() throws Exception { check( "CALL test()", @@ -711,6 +742,7 @@ public void testSimpleCallProc() throws Exception { /** * Test simple nested escape sequences. Depth = 2. */ + @Test public void testNestedCallProc() throws Exception { check( "CALL func1(field1, CALL func2(field2))", @@ -731,6 +763,7 @@ public void testNestedCallProc() throws Exception { /** * Test nested escape sequences. Depth > 2. */ + @Test public void testDeepNestedCallProc() { check( "CALL func1(CALL func2(CALL func3(field1)))", @@ -756,6 +789,7 @@ public void testDeepNestedCallProc() { /** * Test series of nested escape sequences. */ + @Test public void testNestedCallProcMixed() { check( "CALL func1(CALL func2(field1), CALL func3(field2))", @@ -776,6 +810,7 @@ public void testNestedCallProcMixed() { /** * Test invalid escape sequence. */ + @Test public void testFailedOnInvalidCallProcSequence() { checkFail("{callfunc1()}"); @@ -787,6 +822,7 @@ public void testFailedOnInvalidCallProcSequence() { /** * Test escape sequences with additional whitespace characters */ + @Test public void testCallProcEscapeSequenceWithWhitespaces() throws Exception { check("CALL func1()", "{ call func1()}"); @@ -800,6 +836,7 @@ public void testCallProcEscapeSequenceWithWhitespaces() throws Exception { /** * Test escape sequence series. */ + @Test public void testLikeEscapeSequence() throws Exception { check( "ESCAPE '\\'", @@ -850,6 +887,7 @@ public void testLikeEscapeSequence() throws Exception { /** * Test escape sequences with additional whitespace characters */ + @Test public void testLikeEscapeSequenceWithWhitespaces() throws Exception { check("ESCAPE '\\'", "{ '\\' }"); check("ESCAPE '\\'", "{ escape '\\'}"); @@ -864,6 +902,7 @@ public void testLikeEscapeSequenceWithWhitespaces() throws Exception { /** * Test invalid escape sequence. */ + @Test public void testLikeOnInvalidLikeEscapeSequence() { checkFail("LIKE 'AAA's'"); checkFail("LIKE 'AAA\'s'"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/port/GridPortProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/port/GridPortProcessorSelfTest.java index 9d5d52bd4c29b..5b6a2acb0da02 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/port/GridPortProcessorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/port/GridPortProcessorSelfTest.java @@ -22,6 +22,9 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.spi.IgnitePortProtocol.TCP; import static org.apache.ignite.spi.IgnitePortProtocol.UDP; @@ -29,6 +32,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridPortProcessorSelfTest extends GridCommonAbstractTest { /** */ private GridTestKernalContext ctx; @@ -52,6 +56,7 @@ public class GridPortProcessorSelfTest extends GridCommonAbstractTest { /** * @throws Exception If any exception occurs. */ + @Test public void testA() throws Exception { Class cls1 = TcpCommunicationSpi.class; @@ -81,6 +86,7 @@ public void testA() throws Exception { /** * @throws Exception If any exception occurs. */ + @Test public void testB() throws Exception { final AtomicInteger ai = new AtomicInteger(); @@ -126,4 +132,4 @@ public void testB() throws Exception { assertEquals(i, ai.get()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java index c94ebd8003c02..08ec39fe831d8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java @@ -47,10 +47,14 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import javax.cache.processor.EntryProcessorException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests command handler directly. */ +@RunWith(JUnit4.class) public class GridCacheCommandHandlerSelfTest extends GridCommonAbstractTest { /** * Constructor. @@ -102,6 +106,7 @@ protected CacheAtomicityMode atomicityMode(){ * * @throws Exception If failed. */ + @Test public void testCacheGetFailsSyncNotify() throws Exception { GridRestCommandHandler hnd = new TestableCacheCommandHandler(grid().context(), "getAsync"); @@ -128,7 +133,7 @@ public void testCacheGetFailsSyncNotify() throws Exception { * * @throws Exception In case of any exception. */ - @SuppressWarnings("NullableProblems") + @Test public void testAppendPrepend() throws Exception { assertEquals("as" + "df", testAppend("as", "df", true)); assertEquals("df" + "as", testAppend("as", "df", false)); @@ -217,6 +222,7 @@ private T testAppend(T curVal, T newVal, boolean append) throws IgniteChecke * * @throws Exception If failed. */ + @Test public void testCacheClear() throws Exception { GridRestCommandHandler hnd = new GridCacheCommandHandler(((IgniteKernal)grid()).context()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java index 7f0a6de4144d7..bb31ce25c429c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandlerTest.java @@ -31,10 +31,14 @@ import org.apache.ignite.internal.processors.rest.request.GridRestLogRequest; import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * REST log command handler tests. */ +@RunWith(JUnit4.class) public class GridLogCommandHandlerTest extends GridCommonAbstractTest { /** */ private String igniteHome = System.getProperty("user.dir"); @@ -69,6 +73,7 @@ public class GridLogCommandHandlerTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSupportedCommands() throws Exception { GridLogCommandHandler cmdHandler = new GridLogCommandHandler(newContext()); @@ -81,6 +86,7 @@ public void testSupportedCommands() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUnSupportedCommands() throws Exception { GridLogCommandHandler cmdHandler = new GridLogCommandHandler(newContext()); @@ -93,6 +99,7 @@ public void testUnSupportedCommands() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHandleAsync() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); @@ -114,6 +121,7 @@ public void testHandleAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHandleAsyncForNonExistingLines() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); @@ -135,6 +143,7 @@ public void testHandleAsyncForNonExistingLines() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHandleAsyncFromAndToNotSet() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); @@ -153,6 +162,7 @@ public void testHandleAsyncFromAndToNotSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHandleAsyncPathNotSet() throws Exception { GridTestKernalContext ctx = newContext(); ctx.config().setIgniteHome(igniteHome); @@ -172,6 +182,7 @@ public void testHandleAsyncPathNotSet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHandleAsyncPathIsOutsideIgniteHome() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); @@ -193,6 +204,7 @@ public void testHandleAsyncPathIsOutsideIgniteHome() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHandleAsyncFromGreaterThanTo() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); @@ -214,6 +226,7 @@ public void testHandleAsyncFromGreaterThanTo() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHandleAsyncFromEqualTo() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/query/GridQueryCommandHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/query/GridQueryCommandHandlerTest.java index f0ff25a2c72f3..0d8fe5c7a4d51 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/query/GridQueryCommandHandlerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/query/GridQueryCommandHandlerTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.Collection; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * REST query command handler tests. */ +@RunWith(JUnit4.class) public class GridQueryCommandHandlerTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -51,6 +55,7 @@ public class GridQueryCommandHandlerTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSupportedCommands() throws Exception { GridTestKernalContext ctx = newContext(grid().configuration()); @@ -72,6 +77,7 @@ public void testSupportedCommands() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUnsupportedCommands() throws Exception { GridTestKernalContext ctx = newContext(grid().configuration()); @@ -87,6 +93,7 @@ public void testUnsupportedCommands() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNullCache() throws Exception { QueryCommandHandler cmdHnd = new QueryCommandHandler(grid().context()); @@ -116,6 +123,7 @@ public void testNullCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNullPageSize() throws Exception { grid().getOrCreateCache(getName()); @@ -151,6 +159,7 @@ public void testNullPageSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQuery() throws Exception { grid().getOrCreateCache(getName()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/top/CacheTopologyCommandHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/top/CacheTopologyCommandHandlerTest.java index 5d7dfd709c210..cebd96d1b8706 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/top/CacheTopologyCommandHandlerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/top/CacheTopologyCommandHandlerTest.java @@ -33,10 +33,14 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheTopologyCommandHandlerTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration() throws Exception { @@ -70,6 +74,7 @@ public class CacheTopologyCommandHandlerTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTopologyCommandOnDynamicCacheCreateDestroy() throws Exception { GridRestTopologyRequest req = new GridRestTopologyRequest(); req.command(GridRestCommand.TOPOLOGY); @@ -80,6 +85,7 @@ public void testTopologyCommandOnDynamicCacheCreateDestroy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeCommandOnDynamicCacheCreateDestroy1() throws Exception { Ignite node = startGrid(); @@ -93,6 +99,7 @@ public void testNodeCommandOnDynamicCacheCreateDestroy1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeCommandOnDynamicCacheCreateDestroy2() throws Exception { Ignite node = startGrid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ClosureServiceClientsNodesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ClosureServiceClientsNodesTest.java index edb01822996e0..9715288f2d983 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ClosureServiceClientsNodesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ClosureServiceClientsNodesTest.java @@ -36,15 +36,16 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; import org.apache.ignite.services.ServiceDescriptor; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that compute and service run only on server nodes by default. */ +@RunWith(JUnit4.class) public class ClosureServiceClientsNodesTest extends GridCommonAbstractTest { /** Number of grids started for tests. */ private static final int NODES_CNT = 4; @@ -55,17 +56,12 @@ public class ClosureServiceClientsNodesTest extends GridCommonAbstractTest { /** Test singleton service name. */ private static final String SINGLETON_NAME = "testSingleton"; - /** IP finder. */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setMarshaller(new BinaryMarshaller()); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setCacheConfiguration(); if (igniteInstanceName.equals(getTestIgniteInstanceName(CLIENT_IDX))) @@ -83,6 +79,7 @@ public class ClosureServiceClientsNodesTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDefaultClosure() throws Exception { Set srvNames = new HashSet<>(NODES_CNT - 1); @@ -117,6 +114,7 @@ public void testDefaultClosure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientClosure() throws Exception { for (int i = 0 ; i < NODES_CNT; i++) { log.info("Iteration: " + i); @@ -144,6 +142,7 @@ public void testClientClosure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomClosure() throws Exception { for (int i = 0 ; i < NODES_CNT; i++) { log.info("Iteration: " + i); @@ -167,6 +166,7 @@ public void testCustomClosure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultService() throws Exception { UUID clientNodeId = grid(CLIENT_IDX).cluster().localNode().id(); @@ -208,6 +208,7 @@ public void testDefaultService() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientService() throws Exception { UUID clientNodeId = grid(CLIENT_IDX).cluster().localNode().id(); @@ -268,4 +269,4 @@ private static class TestService implements Service { log.info("Executing test service."); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java index 1d6cbaeac590e..cf56a2d6b2016 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java @@ -22,18 +22,16 @@ import org.apache.ignite.Ignite; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridServiceClientNodeTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -41,8 +39,6 @@ public class GridServiceClientNodeTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientFailureDetectionTimeout(30000); cfg.setClientMode(client); @@ -61,6 +57,7 @@ public class GridServiceClientNodeTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDeployFromClient() throws Exception { startGrids(3); @@ -74,6 +71,7 @@ public void testDeployFromClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployFromClientAfterRouterStop1() throws Exception { startGrid(0); @@ -102,6 +100,7 @@ public void testDeployFromClientAfterRouterStop1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployFromClientAfterRouterStop2() throws Exception { startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceContinuousQueryRedeployTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceContinuousQueryRedeployTest.java index 2437b47f70e5f..e4157e2290fbf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceContinuousQueryRedeployTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceContinuousQueryRedeployTest.java @@ -39,11 +39,15 @@ import org.apache.ignite.services.ServiceContext; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests whether concurrent service cancel and registering ContinuousQuery doesn't causes * service redeployment. */ +@RunWith(JUnit4.class) public class GridServiceContinuousQueryRedeployTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "TEST_CACHE"; @@ -62,6 +66,7 @@ public class GridServiceContinuousQueryRedeployTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testServiceRedeploymentAfterCancel() throws Exception { final Ignite ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFutureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFutureSelfTest.java index ad93c6aabb5d0..f2563d2741717 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFutureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentCompoundFutureSelfTest.java @@ -28,12 +28,17 @@ import org.apache.ignite.services.ServiceConfiguration; import org.apache.ignite.services.ServiceDeploymentException; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class GridServiceDeploymentCompoundFutureSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testWaitForCompletionOnFailingFuture() throws Exception { GridServiceDeploymentCompoundFuture compFut = new GridServiceDeploymentCompoundFuture(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java index d987ce6264f7c..d5df8281325fb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceDeploymentExceptionPropagationTest.java @@ -23,11 +23,16 @@ import org.apache.ignite.services.ServiceContext; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class GridServiceDeploymentExceptionPropagationTest extends GridCommonAbstractTest { /** */ @SuppressWarnings("unused") + @Test public void testExceptionPropagation() throws Exception { try (Ignite srv = startGrid("server")) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServicePackagePrivateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServicePackagePrivateSelfTest.java index c085192fdb0ca..c87b8de8b1558 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServicePackagePrivateSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServicePackagePrivateSelfTest.java @@ -22,14 +22,19 @@ import org.apache.ignite.internal.processors.service.inner.MyService; import org.apache.ignite.internal.processors.service.inner.MyServiceFactory; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for package-private service implementation. */ +@RunWith(JUnit4.class) public class GridServicePackagePrivateSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPackagePrivateService() throws Exception { try { Ignite server = startGrid("server"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java index 8e8a2fee42f23..7f546ea917e21 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java @@ -41,24 +41,22 @@ import org.apache.ignite.services.ServiceConfiguration; import org.apache.ignite.services.ServiceContext; import org.apache.ignite.services.ServiceDescriptor; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link GridAffinityProcessor}. */ @GridCommonTest(group = "Service Processor") +@RunWith(JUnit4.class) public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbstractTest { /** Cache name. */ public static final String CACHE_NAME = "testServiceCache"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Random generator. */ private static final Random RAND = new Random(); @@ -66,12 +64,6 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - c.setDiscoverySpi(discoSpi); - ServiceConfiguration[] svcs = services(); if (svcs != null) @@ -155,6 +147,7 @@ protected Ignite randomGrid() { /** * @throws Exception If failed. */ + @Test public void testSameConfigurationOld() throws Exception { String name = "dupServiceOld"; @@ -184,6 +177,7 @@ public void testSameConfigurationOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSameConfiguration() throws Exception { String name = "dupServiceOld"; @@ -209,6 +203,7 @@ public void testSameConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentConfigurationOld() throws Exception { String name = "dupServiceOld"; @@ -242,6 +237,7 @@ public void testDifferentConfigurationOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentConfiguration() throws Exception { String name = "dupService"; @@ -271,6 +267,7 @@ public void testDifferentConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetServiceByName() throws Exception { String name = "serviceByName"; @@ -290,6 +287,7 @@ public void testGetServiceByName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetServicesByName() throws Exception { final String name = "servicesByName"; @@ -316,6 +314,7 @@ public void testGetServicesByName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOnEachNodeOld() throws Exception { Ignite g = randomGrid(); @@ -348,6 +347,7 @@ public void testDeployOnEachNodeOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOnEachNode() throws Exception { Ignite g = randomGrid(); @@ -376,6 +376,7 @@ public void testDeployOnEachNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeploySingletonOld() throws Exception { Ignite g = randomGrid(); @@ -408,6 +409,7 @@ public void testDeploySingletonOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeploySingleton() throws Exception { Ignite g = randomGrid(); @@ -436,6 +438,7 @@ public void testDeploySingleton() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityDeployOld() throws Exception { Ignite g = randomGrid(); @@ -465,6 +468,7 @@ public void testAffinityDeployOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityDeploy() throws Exception { Ignite g = randomGrid(); @@ -490,6 +494,7 @@ public void testAffinityDeploy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployMultiple1Old() throws Exception { Ignite g = randomGrid(); @@ -522,6 +527,7 @@ public void testDeployMultiple1Old() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployMultiple1() throws Exception { Ignite g = randomGrid(); @@ -550,6 +556,7 @@ public void testDeployMultiple1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployMultiple2Old() throws Exception { Ignite g = randomGrid(); @@ -584,6 +591,7 @@ public void testDeployMultiple2Old() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployMultiple2() throws Exception { Ignite g = randomGrid(); @@ -614,6 +622,7 @@ public void testDeployMultiple2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCancelSingleton() throws Exception { Ignite g = randomGrid(); @@ -649,6 +658,7 @@ public void testCancelSingleton() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCancelSingletonAsync() throws Exception { Ignite g = randomGrid(); @@ -684,6 +694,7 @@ public void testCancelSingletonAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCancelEachNode() throws Exception { Ignite g = randomGrid(); @@ -719,6 +730,7 @@ public void testCancelEachNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCancelAsyncEachNode() throws Exception { Ignite g = randomGrid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorBatchDeploySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorBatchDeploySelfTest.java index f0e2e71595c5f..b77144cf0e9fd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorBatchDeploySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorBatchDeploySelfTest.java @@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.ignite.Ignite; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteNodeAttributes; import org.apache.ignite.lang.IgniteFuture; @@ -37,16 +36,18 @@ import org.apache.ignite.services.ServiceConfiguration; import org.apache.ignite.services.ServiceDeploymentException; import org.apache.ignite.services.ServiceDescriptor; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.runAsync; /** * Test for deployment of multiple configurations at a time. */ +@RunWith(JUnit4.class) public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractTest { /** Number of services to be deployed. */ private static final int NUM_SERVICES = 100; @@ -57,22 +58,6 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT /** Client node name. */ private static final String CLIENT_NODE_NAME = "client"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - c.setDiscoverySpi(discoSpi); - - return c; - } - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { for (int i = 0; i < NUM_NODES; i++) @@ -91,6 +76,7 @@ public class GridServiceProcessorBatchDeploySelfTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testDeployAll() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); @@ -110,6 +96,7 @@ public void testDeployAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployAllAsync() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); @@ -129,11 +116,10 @@ public void testDeployAllAsync() throws Exception { } /** - * TODO: enable when IGNITE-6259 is fixed. - * * @throws Exception If failed. */ - public void _testDeployAllTopologyChange() throws Exception { + @Test + public void testDeployAllTopologyChange() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); final AtomicBoolean finished = new AtomicBoolean(); @@ -141,7 +127,7 @@ public void _testDeployAllTopologyChange() throws Exception { IgniteInternalFuture topChangeFut = runTopChanger(finished); try { - int numServices = 500; + int numServices = 50; int batchSize = 5; CountDownLatch latch = new CountDownLatch(numServices); @@ -171,7 +157,7 @@ public void _testDeployAllTopologyChange() throws Exception { from = to; } - assertTrue(latch.await(30, TimeUnit.SECONDS)); + assertTrue(latch.await(120, TimeUnit.SECONDS)); assertDeployedServices(client, cfgs); } @@ -183,11 +169,10 @@ public void _testDeployAllTopologyChange() throws Exception { } /** - * TODO: enable when IGNITE-6259 is fixed. - * * @throws Exception If failed. */ - public void _testDeployAllTopologyChangeFail() throws Exception { + @Test + public void testDeployAllTopologyChangeFail() throws Exception { final Ignite client = grid(CLIENT_NODE_NAME); final AtomicBoolean finished = new AtomicBoolean(); @@ -195,7 +180,7 @@ public void _testDeployAllTopologyChangeFail() throws Exception { IgniteInternalFuture topChangeFut = runTopChanger(finished); try { - int numServices = 500; + int numServices = 200; int batchSize = 5; CountDownLatch latch = new CountDownLatch(numServices); @@ -248,7 +233,7 @@ public void _testDeployAllTopologyChangeFail() throws Exception { from = to; } - assertTrue(latch.await(30, TimeUnit.SECONDS)); + assertTrue(latch.await(120, TimeUnit.SECONDS)); cfgs.removeAll(failingCfgs); @@ -264,6 +249,7 @@ public void _testDeployAllTopologyChangeFail() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployAllFail() throws Exception { deployAllFail(false); } @@ -271,6 +257,7 @@ public void testDeployAllFail() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployAllAsyncFail() throws Exception { deployAllFail(true); } @@ -302,6 +289,7 @@ private void deployAllFail(boolean async) throws Exception { /** * @throws Exception If failed. */ + @Test public void testClashingNames() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); @@ -328,6 +316,7 @@ public void testClashingNames() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClashingNamesFail() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); @@ -360,6 +349,7 @@ public void testClashingNamesFail() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClashingNameDifferentConfig() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); @@ -394,6 +384,7 @@ public void testClashingNameDifferentConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCancelAll() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); @@ -415,6 +406,7 @@ public void testCancelAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCancelAllAsync() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); @@ -436,11 +428,11 @@ public void testCancelAllAsync() throws Exception { } /** - * TODO: enable when IGNITE-6259 is fixed. - * * @throws Exception If failed. */ - public void _testCancelAllTopologyChange() throws Exception { + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10021") + @Test + public void testCancelAllTopologyChange() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); int numServices = 500; @@ -490,6 +482,7 @@ public void _testCancelAllTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCancelAllClashingNames() throws Exception { Ignite client = grid(CLIENT_NODE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java index e43d02934ddc2..d328db2ba201f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.services.ServiceConfiguration; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Single node services test. */ +@RunWith(JUnit4.class) public class GridServiceProcessorMultiNodeConfigSelfTest extends GridServiceProcessorAbstractSelfTest { /** Cluster singleton name. */ private static final String CLUSTER_SINGLE = "serviceConfigSingleton"; @@ -144,6 +148,7 @@ public class GridServiceProcessorMultiNodeConfigSelfTest extends GridServiceProc /** * @throws Exception If failed. */ + @Test public void testSingletonUpdateTopology() throws Exception { checkSingletonUpdateTopology(CLUSTER_SINGLE); } @@ -151,6 +156,7 @@ public void testSingletonUpdateTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOnEachNodeUpdateTopology() throws Exception { checkDeployOnEachNodeUpdateTopology(NODE_SINGLE); } @@ -158,6 +164,7 @@ public void testDeployOnEachNodeUpdateTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOnEachNodeButClientUpdateTopology() throws Exception { checkDeployOnEachNodeButClientUpdateTopology(NODE_SINGLE_BUT_CLIENT); } @@ -165,6 +172,7 @@ public void testDeployOnEachNodeButClientUpdateTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAll() throws Exception { checkSingletonUpdateTopology(CLUSTER_SINGLE); @@ -182,6 +190,7 @@ public void testAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityUpdateTopology() throws Exception { Ignite g = randomGrid(); @@ -204,6 +213,7 @@ public void testAffinityUpdateTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployLimits() throws Exception { final Ignite g = randomGrid(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java index 517f061d32323..ed331fa18dea0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Single node services test. */ +@RunWith(JUnit4.class) public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorAbstractSelfTest { /** {@inheritDoc} */ @Override protected int nodeCount() { @@ -38,6 +42,7 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA /** * @throws Exception If failed. */ + @Test public void testSingletonUpdateTopology() throws Exception { String name = "serviceSingletonUpdateTopology"; @@ -82,6 +87,7 @@ public void testSingletonUpdateTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAffinityDeployUpdateTopology() throws Exception { Ignite g = randomGrid(); @@ -120,6 +126,7 @@ public void testAffinityDeployUpdateTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOnEachNodeButClientUpdateTopology() throws Exception { // Prestart client node. Ignite client = startGrid("client", getConfiguration("client").setClientMode(true)); @@ -185,6 +192,7 @@ public void testDeployOnEachNodeButClientUpdateTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOnEachProjectionNodeUpdateTopology() throws Exception { // Prestart client node. Ignite client = startGrid("client", getConfiguration("client").setClientMode(true)); @@ -252,6 +260,7 @@ public void testDeployOnEachProjectionNodeUpdateTopology() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOnEachNodeUpdateTopology() throws Exception { // Prestart client node. Ignite client = startGrid("client", getConfiguration("client").setClientMode(true)); @@ -329,6 +338,7 @@ public void testDeployOnEachNodeUpdateTopology() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testDeployLimits() throws Exception { final String name = "serviceWithLimitsUpdateTopology"; @@ -390,4 +400,4 @@ public void testDeployLimits() throws Exception { stopExtraNodes(extraNodes); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorProxySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorProxySelfTest.java index 97d5f05e9e52b..0a5c7beb57716 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorProxySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorProxySelfTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Service proxy test. */ +@RunWith(JUnit4.class) public class GridServiceProcessorProxySelfTest extends GridServiceProcessorAbstractSelfTest { /** {@inheritDoc} */ @Override protected int nodeCount() { @@ -42,6 +46,7 @@ public class GridServiceProcessorProxySelfTest extends GridServiceProcessorAbstr /** * @throws Exception If failed. */ + @Test public void testNodeSingletonProxy() throws Exception { String name = "testNodeSingletonProxy"; @@ -74,6 +79,7 @@ public void testNodeSingletonProxy() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testException() throws Exception { String name = "errorService"; @@ -96,6 +102,7 @@ public void testException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterSingletonProxy() throws Exception { String name = "testClusterSingletonProxy"; @@ -114,6 +121,7 @@ public void testClusterSingletonProxy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultiNodeProxy() throws Exception { Ignite ignite = randomGrid(); @@ -139,6 +147,7 @@ public void testMultiNodeProxy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeSingletonRemoteNotStickyProxy() throws Exception { String name = "testNodeSingletonRemoteNotStickyProxy"; @@ -177,6 +186,7 @@ public void testNodeSingletonRemoteNotStickyProxy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeSingletonRemoteStickyProxy() throws Exception { String name = "testNodeSingletonRemoteStickyProxy"; @@ -212,6 +222,7 @@ public void testNodeSingletonRemoteStickyProxy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingletonProxyInvocation() throws Exception { final String name = "testProxyInvocationFromSeveralNodes"; @@ -234,6 +245,7 @@ public void testSingletonProxyInvocation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalProxyInvocation() throws Exception { final String name = "testLocalProxyInvocation"; @@ -274,6 +286,7 @@ public void testLocalProxyInvocation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoteNotStickProxyInvocation() throws Exception { final String name = "testRemoteNotStickProxyInvocation"; @@ -309,6 +322,7 @@ public void testRemoteNotStickProxyInvocation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemoteStickyProxyInvocation() throws Exception { final String name = "testRemoteStickyProxyInvocation"; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorSingleNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorSingleNodeSelfTest.java index 202b4b6316e39..e2e5a5d62f318 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorSingleNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorSingleNodeSelfTest.java @@ -19,10 +19,14 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Single node services test. */ +@RunWith(JUnit4.class) public class GridServiceProcessorSingleNodeSelfTest extends GridServiceProcessorAbstractSelfTest { /** {@inheritDoc} */ @Override protected int nodeCount() { @@ -33,6 +37,7 @@ public class GridServiceProcessorSingleNodeSelfTest extends GridServiceProcessor /** * @throws Exception If failed. */ + @Test public void testNodeSingletonNotDeployedProxy() throws Exception { String name = "testNodeSingletonNotDeployedProxy"; @@ -55,4 +60,4 @@ public void testNodeSingletonNotDeployedProxy() throws Exception { info("Got expected exception: " + e.getMessage()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java index 8eefa20454883..d17b0150e29f9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java @@ -37,10 +37,14 @@ import org.apache.ignite.services.ServiceContext; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests that {@link GridServiceProcessor} completes deploy/undeploy futures during node stop. */ +@RunWith(JUnit4.class) public class GridServiceProcessorStopSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { @@ -52,6 +56,7 @@ public class GridServiceProcessorStopSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStopDuringDeployment() throws Exception { final CountDownLatch depLatch = new CountDownLatch(1); @@ -98,6 +103,7 @@ public void testStopDuringDeployment() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopDuringHangedDeployment() throws Exception { final CountDownLatch depLatch = new CountDownLatch(1); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java index 5fdcdc49e5224..74af77bcb2a37 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyClientReconnectSelfTest.java @@ -26,24 +26,20 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Service proxy test with client reconnect. */ +@RunWith(JUnit4.class) public class GridServiceProxyClientReconnectSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setClientMode(igniteInstanceName.contains("client")); return cfg; @@ -57,6 +53,7 @@ public class GridServiceProxyClientReconnectSelfTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testClientReconnect() throws Exception { startGrid("server"); @@ -93,6 +90,7 @@ public void testClientReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectLongServiceInit() throws Exception { startGrid("server"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyNodeStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyNodeStopSelfTest.java index 93d063d5dd35b..014fcb9e826cd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyNodeStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProxyNodeStopSelfTest.java @@ -20,31 +20,19 @@ import java.util.concurrent.Callable; import org.apache.ignite.Ignite; import org.apache.ignite.Ignition; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.service.inner.MyService; import org.apache.ignite.internal.processors.service.inner.MyServiceFactory; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for service proxy after client node stopped. */ +@RunWith(JUnit4.class) public class GridServiceProxyNodeStopSelfTest extends GridCommonAbstractTest { - /** */ - private final static TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -53,6 +41,7 @@ public class GridServiceProxyNodeStopSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testProxyHashCode() throws Exception { Ignite server = startGrid("server"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceReassignmentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceReassignmentSelfTest.java index e44c8eabde0c7..532728b290f1f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceReassignmentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceReassignmentSelfTest.java @@ -30,10 +30,14 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests service reassignment. */ +@RunWith(JUnit4.class) public class GridServiceReassignmentSelfTest extends GridServiceProcessorAbstractSelfTest { /** */ private static final String SERVICE_NAME = "testService"; @@ -46,6 +50,7 @@ public class GridServiceReassignmentSelfTest extends GridServiceProcessorAbstrac /** * @throws Exception If failed. */ + @Test public void testClusterSingleton() throws Exception { checkReassigns(1, 1); } @@ -53,6 +58,7 @@ public void testClusterSingleton() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeSingleton() throws Exception { checkReassigns(0, 1); } @@ -60,6 +66,7 @@ public void testNodeSingleton() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLimited1() throws Exception { checkReassigns(5, 2); } @@ -67,6 +74,7 @@ public void testLimited1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLimited2() throws Exception { checkReassigns(7, 3); } @@ -249,4 +257,4 @@ private int nextRandomIdx(Iterable startedGrids, Random rnd) { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceSerializationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceSerializationSelfTest.java index 7c0b03dc8df8b..92a7449d4a85e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceSerializationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceSerializationSelfTest.java @@ -26,34 +26,23 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.Ignite; import org.apache.ignite.Ignition; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.thread.IgniteThread; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Service serialization test. */ +@RunWith(JUnit4.class) public class GridServiceSerializationSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - - return cfg; - } - /** * @throws Exception If failed. */ + @Test public void testServiceSerialization() throws Exception { try { Ignite server = startGridsMultiThreaded(3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceConfigVariationsFullApiTest.java index 160014ce163f8..87af35444409e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceConfigVariationsFullApiTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceConfigVariationsFullApiTest.java @@ -39,10 +39,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.configvariations.Parameters; import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Full API services test. */ +@RunWith(JUnit4.class) public class IgniteServiceConfigVariationsFullApiTest extends IgniteConfigVariationsAbstractTest { /** Test service name. */ private static final String SERVICE_NAME = "testService"; @@ -84,6 +88,7 @@ public class IgniteServiceConfigVariationsFullApiTest extends IgniteConfigVariat * * @throws Exception If failed. */ + @Test public void testNodeSingletonDeploy() throws Exception { runInAllDataModes(new ServiceTestRunnable(true, new DeployClosure() { @Override public void run(IgniteServices services, String svcName, TestService svc) throws Exception { @@ -100,6 +105,7 @@ public void testNodeSingletonDeploy() throws Exception { * * @throws Exception If failed. */ + @Test public void testClusterSingletonDeploy() throws Exception { runInAllDataModes(new ServiceTestRunnable(false, new DeployClosure() { @Override public void run(IgniteServices services, String svcName, TestService svc) throws Exception { @@ -116,6 +122,7 @@ public void testClusterSingletonDeploy() throws Exception { * * @throws Exception If failed. */ + @Test public void testKeyAffinityDeploy() throws Exception { runInAllDataModes(new ServiceTestRunnable(false, new DeployClosure() { @Override public void run(IgniteServices services, String svcName, TestService svc) { @@ -136,6 +143,7 @@ public void testKeyAffinityDeploy() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleDeploy() throws Exception { runInAllDataModes(new ServiceTestRunnable(true, new DeployClosure() { @Override public void run(IgniteServices services, String svcName, TestService svc) { @@ -149,6 +157,7 @@ public void testMultipleDeploy() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeploy() throws Exception { runInAllDataModes(new ServiceTestRunnable(false, new DeployClosure() { @Override public void run(IgniteServices services, String svcName, TestService svc) throws Exception { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest.java index 000ed20d328c2..f61f5b44a2fa4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest.java @@ -27,16 +27,17 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestExternalClassLoader; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests that not all nodes in cluster need user's service definition (only nodes according to filter). */ +@RunWith(JUnit4.class) public class IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest extends GridCommonAbstractTest { /** */ private static final String NOOP_SERVICE_CLS_NAME = "org.apache.ignite.tests.p2p.NoopService"; @@ -44,9 +45,6 @@ public class IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest extends G /** */ private static final String NOOP_SERVICE_2_CLS_NAME = "org.apache.ignite.tests.p2p.NoopService2"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int GRID_CNT = 6; @@ -90,12 +88,6 @@ public class IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest extends G cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setMarshaller(marshaller()); cfg.setUserAttributes(Collections.singletonMap(NODE_NAME_ATTR, igniteInstanceName)); @@ -151,6 +143,7 @@ protected Marshaller marshaller() { /** * @throws Exception If failed. */ + @Test public void testServiceDeployment1() throws Exception { startGrid(0).services().deploy(serviceConfig(true)); @@ -173,6 +166,7 @@ public void testServiceDeployment1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServiceDeployment2() throws Exception { for (int i = 0 ; i < 4; i++) startGrid(i); @@ -190,6 +184,7 @@ public void testServiceDeployment2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServiceDeployment3() throws Exception { startGrid(0).services().deploy(serviceConfig(true)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.java index 7f087210c2655..119cc5fd50a7d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.java @@ -25,21 +25,19 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests that not all nodes in cluster need user's service definition (only nodes according to filter). */ +@RunWith(JUnit4.class) public class IgniteServiceDeploymentClassLoadingDefaultMarshallerTest extends GridCommonAbstractTest { /** */ private static final String NOOP_SERVICE_CLS_NAME = "org.apache.ignite.tests.p2p.NoopService"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int SERVER_NODE = 0; @@ -67,12 +65,6 @@ public class IgniteServiceDeploymentClassLoadingDefaultMarshallerTest extends Gr cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setMarshaller(marshaller()); cfg.setUserAttributes(Collections.singletonMap(NODE_NAME_ATTR, igniteInstanceName)); @@ -124,6 +116,7 @@ protected Marshaller marshaller() { /** * @throws Exception If failed. */ + @Test public void testServiceDeployment1() throws Exception { startGrid(SERVER_NODE); @@ -141,6 +134,7 @@ public void testServiceDeployment1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServiceDeployment2() throws Exception { startGrid(SERVER_NODE); @@ -154,6 +148,7 @@ public void testServiceDeployment2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServiceDeployment3() throws Exception { startGrid(SERVER_NODE_WITH_EXT_CLASS_LOADER).services().deploy(serviceConfig()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDynamicCachesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDynamicCachesSelfTest.java index 7e5a18ddae955..790beb3a9b375 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDynamicCachesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDynamicCachesSelfTest.java @@ -21,40 +21,24 @@ import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteServices; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteServiceDynamicCachesSelfTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 4; - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrids(GRID_CNT); @@ -63,6 +47,7 @@ public class IgniteServiceDynamicCachesSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDeployCalledAfterCacheStart() throws Exception { String cacheName = "cache"; @@ -108,6 +93,7 @@ public void testDeployCalledAfterCacheStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployCalledBeforeCacheStart() throws Exception { String cacheName = "cache"; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceProxyTimeoutInitializedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceProxyTimeoutInitializedTest.java index 17e583d399278..4e56b5831e2e2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceProxyTimeoutInitializedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceProxyTimeoutInitializedTest.java @@ -42,10 +42,14 @@ import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests service proxy timeouts. */ +@RunWith(JUnit4.class) public class IgniteServiceProxyTimeoutInitializedTest extends GridCommonAbstractTest { /** */ private static Service srvc; @@ -102,7 +106,8 @@ public class IgniteServiceProxyTimeoutInitializedTest extends GridCommonAbstract * * @throws Exception If fail. */ - @SuppressWarnings({"Convert2Lambda", "ThrowableResultOfMethodCallIgnored"}) + @SuppressWarnings({"Convert2Lambda"}) + @Test public void testUnavailableService() throws Exception { srvc = new TestWaitServiceImpl(); @@ -142,7 +147,8 @@ public void testUnavailableService() throws Exception { * * @throws Exception If fail. */ - @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "Convert2Lambda"}) + @SuppressWarnings({"Convert2Lambda"}) + @Test public void testServiceException() throws Exception { srvc = new HangServiceImpl(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceReassignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceReassignmentTest.java index e74b27de99caa..c118d6d9595d3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceReassignmentTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceReassignmentTest.java @@ -32,20 +32,18 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceConfiguration; import org.apache.ignite.services.ServiceContext; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteServiceReassignmentTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private ServiceConfiguration srvcCfg; @@ -59,8 +57,6 @@ public class IgniteServiceReassignmentTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - if (srvcCfg != null) cfg.setServiceConfiguration(srvcCfg); @@ -87,6 +83,7 @@ public class IgniteServiceReassignmentTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNodeRestart1() throws Exception { srvcCfg = serviceConfiguration(); @@ -129,6 +126,7 @@ public void testNodeRestart1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeRestart2() throws Exception { startGrids(3); @@ -157,6 +155,7 @@ public void testNodeRestart2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeRestartRandom() throws Exception { final int NODES = 5; @@ -190,6 +189,7 @@ public void testNodeRestartRandom() throws Exception { /** * @throws Exception If failed. */ + @Test public void testZombieAssignmentsCleanup() throws Exception { useStrLog = true; @@ -246,6 +246,7 @@ public void testZombieAssignmentsCleanup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeStopWhileThereAreCacheActivitiesInServiceProcessor() throws Exception { final int nodesCnt = 2; final int maxSvc = 1024; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnActivationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnActivationTest.java index 52d706b920dca..cb60f396b6b41 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnActivationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOnActivationTest.java @@ -28,16 +28,14 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.services.ServiceConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class ServiceDeploymentOnActivationTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String SERVICE_NAME = "test-service"; @@ -61,10 +59,6 @@ public class ServiceDeploymentOnActivationTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi(); - discoverySpi.setIpFinder(IP_FINDER); - cfg.setDiscoverySpi(discoverySpi); - cfg.setClientMode(client); if (srvcCfg != null) @@ -101,6 +95,7 @@ public class ServiceDeploymentOnActivationTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testServersWithPersistence() throws Exception { persistence = true; @@ -110,6 +105,7 @@ public void testServersWithPersistence() throws Exception { /** * @throws Exception if failed. */ + @Test public void testClientsWithPersistence() throws Exception { persistence = true; @@ -119,6 +115,7 @@ public void testClientsWithPersistence() throws Exception { /** * @throws Exception if failed. */ + @Test public void testServersWithoutPersistence() throws Exception { persistence = false; @@ -128,6 +125,7 @@ public void testServersWithoutPersistence() throws Exception { /** * @throws Exception if failed. */ + @Test public void testClientsWithoutPersistence() throws Exception { persistence = false; @@ -137,6 +135,7 @@ public void testClientsWithoutPersistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServersStaticConfigWithPersistence() throws Exception { persistence = true; @@ -146,6 +145,7 @@ public void testServersStaticConfigWithPersistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientsStaticConfigWithPersistence() throws Exception { persistence = true; @@ -155,6 +155,7 @@ public void testClientsStaticConfigWithPersistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServersStaticConfigWithoutPersistence() throws Exception { persistence = false; @@ -164,7 +165,8 @@ public void testServersStaticConfigWithoutPersistence() throws Exception { /** * @throws Exception If failed. */ - public void _testClientsStaticConfigWithoutPersistence() throws Exception { + @Test + public void testClientsStaticConfigWithoutPersistence() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-8279"); persistence = false; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java index 878ec0d43c5db..779835e4f2627 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServiceDeploymentOutsideBaselineTest.java @@ -32,17 +32,15 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.services.ServiceConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class ServiceDeploymentOutsideBaselineTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String SERVICE_NAME = "test-service"; @@ -56,10 +54,6 @@ public class ServiceDeploymentOutsideBaselineTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi(); - discoverySpi.setIpFinder(IP_FINDER); - cfg.setDiscoverySpi(discoverySpi); - if (persistence) { cfg.setDataStorageConfiguration( new DataStorageConfiguration() @@ -93,6 +87,7 @@ public class ServiceDeploymentOutsideBaselineTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testDeployOutsideBaseline() throws Exception { checkDeploymentFromOutsideNode(true, false); } @@ -100,6 +95,7 @@ public void testDeployOutsideBaseline() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOutsideBaselineNoPersistence() throws Exception { checkDeploymentFromOutsideNode(false, false); } @@ -107,6 +103,7 @@ public void testDeployOutsideBaselineNoPersistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOutsideBaselineStatic() throws Exception { checkDeploymentFromOutsideNode(true, true); } @@ -114,6 +111,7 @@ public void testDeployOutsideBaselineStatic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployOutsideBaselineStaticNoPersistence() throws Exception { checkDeploymentFromOutsideNode(false, true); } @@ -121,6 +119,7 @@ public void testDeployOutsideBaselineStaticNoPersistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployFromNodeAddedToBlt() throws Exception { checkDeployWithNodeAddedToBlt(true); } @@ -128,6 +127,7 @@ public void testDeployFromNodeAddedToBlt() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployToNodeAddedToBlt() throws Exception { checkDeployWithNodeAddedToBlt(false); } @@ -135,6 +135,7 @@ public void testDeployToNodeAddedToBlt() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployFromNodeRemovedFromBlt() throws Exception { checkDeployFromNodeRemovedFromBlt(true, false); } @@ -142,6 +143,7 @@ public void testDeployFromNodeRemovedFromBlt() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployFromNodeRemovedFromBltStatic() throws Exception { checkDeployFromNodeRemovedFromBlt(true, true); } @@ -149,6 +151,7 @@ public void testDeployFromNodeRemovedFromBltStatic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployToNodeRemovedFromBlt() throws Exception { checkDeployFromNodeRemovedFromBlt(false, false); } @@ -156,6 +159,7 @@ public void testDeployToNodeRemovedFromBlt() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStaticDeployFromEachPersistentNodes() throws Exception { checkDeployFromEachNodes(true, true); } @@ -163,6 +167,7 @@ public void testStaticDeployFromEachPersistentNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployFromEachNodes() throws Exception { checkDeployFromEachNodes(false, false); } @@ -170,6 +175,7 @@ public void testDeployFromEachNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStaticDeployFromEachNodes() throws Exception { checkDeployFromEachNodes(false, true); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java index 33a1993670bb6..d1b1ff6468bda 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java @@ -31,11 +31,11 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -44,10 +44,8 @@ /** * */ +@RunWith(JUnit4.class) public class ServicePredicateAccessCacheTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static CountDownLatch latch; @@ -55,8 +53,6 @@ public class ServicePredicateAccessCacheTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setMarshaller(new BinaryMarshaller()); cfg.setPeerClassLoadingEnabled(false); @@ -72,6 +68,7 @@ public class ServicePredicateAccessCacheTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPredicateAccessCache() throws Exception { final Ignite ignite0 = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/SystemCacheNotConfiguredTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/SystemCacheNotConfiguredTest.java index a76eb22585a64..3883e97512b4b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/SystemCacheNotConfiguredTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/SystemCacheNotConfiguredTest.java @@ -25,21 +25,19 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceConfiguration; import org.apache.ignite.services.ServiceContext; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests if system cache was started before deploying of service. */ +@RunWith(JUnit4.class) public class SystemCacheNotConfiguredTest extends GridCommonAbstractTest { /** */ private final ByteArrayOutputStream errContent = new ByteArrayOutputStream(); - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private final PrintStream originalErr = System.err; @@ -52,11 +50,6 @@ public class SystemCacheNotConfiguredTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi(); - - discoverySpi.setIpFinder(ipFinder); - cfg.setDiscoverySpi(discoverySpi); - if("server".equals(igniteInstanceName)) cfg.setServiceConfiguration(serviceConfiguration()); @@ -66,6 +59,7 @@ public class SystemCacheNotConfiguredTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void test() throws Exception { captureErr(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessorSelfTest.java index 606b10252b19a..c31e4cf113b5b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/timeout/GridTimeoutProcessorSelfTest.java @@ -27,12 +27,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; /** * Timeout processor tests. */ +@RunWith(JUnit4.class) public class GridTimeoutProcessorSelfTest extends GridCommonAbstractTest { /** Random number generator. */ private static final Random RAND = new Random(); @@ -66,6 +70,7 @@ public class GridTimeoutProcessorSelfTest extends GridCommonAbstractTest { * * @throws Exception If test failed. */ + @Test public void testTimeouts() throws Exception { int max = 100; @@ -136,6 +141,7 @@ public void testTimeouts() throws Exception { * * @throws Exception If test failed. */ + @Test public void testTimeoutsMultithreaded() throws Exception { final int max = 100; @@ -212,6 +218,7 @@ public void testTimeoutsMultithreaded() throws Exception { * * @throws Exception If test failed. */ + @Test public void testTimeoutObjectAdapterMultithreaded() throws Exception { final int max = 100; @@ -272,6 +279,7 @@ public void testTimeoutObjectAdapterMultithreaded() throws Exception { * * @throws Exception If test failed. */ + @Test public void testTimeoutNeverCalled() throws Exception { int max = 100; @@ -331,6 +339,7 @@ public void testTimeoutNeverCalled() throws Exception { * * @throws Exception If test failed. */ + @Test public void testTimeoutNeverCalledMultithreaded() throws Exception { int threads = 20; @@ -395,6 +404,7 @@ public void testTimeoutNeverCalledMultithreaded() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testAddRemoveInterleaving() throws Exception { final AtomicInteger callCnt = new AtomicInteger(0); @@ -517,6 +527,7 @@ public void testAddRemoveInterleaving() throws Exception { * * @throws Exception If test failed. */ + @Test public void testTimeoutCallOnce() throws Exception { ctx.timeout().addTimeoutObject(new GridTimeoutObject() { /** Timeout ID. */ @@ -558,6 +569,7 @@ public void testTimeoutCallOnce() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testTimeoutSameEndTime() throws Exception { final CountDownLatch latch = new CountDownLatch(2); @@ -631,6 +643,7 @@ public void testTimeoutSameEndTime() throws Exception { * * @throws Exception If test failed. */ + @Test public void testCancelingWithClearedInterruptedFlag() throws Exception { final CountDownLatch onTimeoutCalled = new CountDownLatch(1); @@ -652,4 +665,4 @@ public void testCancelingWithClearedInterruptedFlag() throws Exception { onTimeoutCalled.await(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/product/GridProductVersionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/product/GridProductVersionSelfTest.java index 92990deb62703..58b3f97a39682 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/product/GridProductVersionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/product/GridProductVersionSelfTest.java @@ -19,6 +19,9 @@ import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteVersionUtils.BUILD_TSTAMP; import static org.apache.ignite.internal.IgniteVersionUtils.REV_HASH_STR; @@ -28,10 +31,12 @@ /** * Versions test. */ +@RunWith(JUnit4.class) public class GridProductVersionSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testFromString() throws Exception { IgniteProductVersion ver = IgniteProductVersion.fromString("1.2.3"); @@ -138,4 +143,4 @@ public void testFromString() throws Exception { IgniteProductVersion.fromString(VER_STR + '-' + BUILD_TSTAMP + '-' + REV_HASH_STR); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserBulkLoadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserBulkLoadSelfTest.java index b6716ffbf6a8f..60e489ed13d71 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserBulkLoadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserBulkLoadSelfTest.java @@ -17,11 +17,17 @@ package org.apache.ignite.internal.sql; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + /** * Tests for SQL parser: COPY command. */ +@RunWith(JUnit4.class) public class SqlParserBulkLoadSelfTest extends SqlParserAbstractSelfTest { /** Tests for COPY command. */ + @Test public void testCopy() { assertParseError(null, "copy grom 'any.file' into Person (_key, age, firstName, lastName) format csv", diff --git a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java index 465e8d15c9204..774a73bf01f98 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.internal.sql.command.SqlCreateIndexCommand; import org.apache.ignite.internal.sql.command.SqlIndexColumn; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.sql.SqlKeyword.INLINE_SIZE; import static org.apache.ignite.internal.sql.SqlKeyword.PARALLEL; @@ -33,7 +36,8 @@ /** * Tests for SQL parser: CREATE INDEX. */ -@SuppressWarnings({"UnusedReturnValue", "ThrowableNotThrown"}) +@SuppressWarnings({"UnusedReturnValue"}) +@RunWith(JUnit4.class) public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest { /** Default properties */ private static final Map DEFAULT_PROPS = getProps(null, null); @@ -43,6 +47,7 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest { * * @throws Exception If failed. */ + @Test public void testCreateIndex() throws Exception { // Base. parseValidate(null, "CREATE INDEX idx ON tbl(a)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserDropIndexSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserDropIndexSelfTest.java index a0af3a62d9d7b..a6d668e26aad6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserDropIndexSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserDropIndexSelfTest.java @@ -18,16 +18,21 @@ package org.apache.ignite.internal.sql; import org.apache.ignite.internal.sql.command.SqlDropIndexCommand; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for SQL parser: CREATE INDEX. */ +@RunWith(JUnit4.class) public class SqlParserDropIndexSelfTest extends SqlParserAbstractSelfTest { /** * Tests for DROP INDEX command. * * @throws Exception If failed. */ + @Test public void testDropIndex() throws Exception { // Base. parseValidate(null, "DROP INDEX idx", null, "IDX"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserSetStreamingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserSetStreamingSelfTest.java index 7e699f6adabb7..2b448ebcf8624 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserSetStreamingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserSetStreamingSelfTest.java @@ -19,14 +19,19 @@ import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.sql.command.SqlSetStreamingCommand; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for SQL parser: SET STREAMING. */ +@RunWith(JUnit4.class) public class SqlParserSetStreamingSelfTest extends SqlParserAbstractSelfTest { /** * */ + @Test public void testParseSetStreaming() { parseValidate("set streaming on", true, false, 2048, 0, 0, 0, false); parseValidate("set streaming 1", true, false, 2048, 0, 0, 0, false); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserTransactionalKeywordsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserTransactionalKeywordsSelfTest.java index 103bb97925cc6..f2e12cfdaf7dd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserTransactionalKeywordsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserTransactionalKeywordsSelfTest.java @@ -21,14 +21,19 @@ import org.apache.ignite.internal.sql.command.SqlCommand; import org.apache.ignite.internal.sql.command.SqlCommitTransactionCommand; import org.apache.ignite.internal.sql.command.SqlRollbackTransactionCommand; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for processing of keywords BEGIN, COMMIT, ROLLBACK, START. */ +@RunWith(JUnit4.class) public class SqlParserTransactionalKeywordsSelfTest extends SqlParserAbstractSelfTest { /** * Test parsing of different forms of BEGIN/START. */ + @Test public void testBegin() { assertBegin("begin"); assertBegin("BEGIN"); @@ -44,6 +49,7 @@ public void testBegin() { /** * Test parsing of different forms of COMMIT. */ + @Test public void testCommit() { assertCommit("commit"); assertCommit("COMMIT transaction"); @@ -54,6 +60,7 @@ public void testCommit() { /** * Test parsing of different forms of ROLLBACK. */ + @Test public void testRollback() { assertRollback("rollback"); assertRollback("ROLLBACK transaction"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserUserSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserUserSelfTest.java index d3296f7908282..ec5b37d92c5b5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserUserSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserUserSelfTest.java @@ -20,17 +20,22 @@ import org.apache.ignite.internal.sql.command.SqlAlterUserCommand; import org.apache.ignite.internal.sql.command.SqlCreateUserCommand; import org.apache.ignite.internal.sql.command.SqlDropUserCommand; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for SQL parser: CREATE INDEX. */ -@SuppressWarnings({"UnusedReturnValue", "ThrowableNotThrown"}) +@SuppressWarnings({"UnusedReturnValue"}) +@RunWith(JUnit4.class) public class SqlParserUserSelfTest extends SqlParserAbstractSelfTest { /** * Tests for CREATE USER command. * * @throws Exception If failed. */ + @Test public void testCreateUser() throws Exception { // Base. parseValidateCreate("CREATE USER test WITH PASSWORD 'test'", "TEST", "test"); @@ -51,6 +56,7 @@ public void testCreateUser() throws Exception { * * @throws Exception If failed. */ + @Test public void testAlterUser() throws Exception { // Base. parseValidateAlter("ALTER USER test WITH PASSWORD 'test'", "TEST", "test"); @@ -71,6 +77,7 @@ public void testAlterUser() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropUser() throws Exception { // Base. parseValidateDrop("DROP USER test", "TEST"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/GridArraysSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/GridArraysSelfTest.java index 1cab527794c87..7e032fb28de60 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/GridArraysSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/GridArraysSelfTest.java @@ -19,6 +19,9 @@ import java.util.Arrays; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.util.GridArrays.clearTail; import static org.apache.ignite.internal.util.GridArrays.remove; @@ -26,12 +29,14 @@ /** */ +@RunWith(JUnit4.class) public class GridArraysSelfTest extends GridCommonAbstractTest { /** */ private static final String[] EMPTY = {}; /** */ + @Test public void testSet() { String[] arr = set(EMPTY, 4, "aa"); @@ -71,6 +76,7 @@ public void testSet() { /** */ + @Test public void testClearTail() { String[] arr = new String[10]; @@ -105,6 +111,7 @@ public void testClearTail() { /** */ + @Test public void testRemoveLong() { long[] arr = {0,1,2,3,4,5,6}; @@ -117,6 +124,7 @@ public void testRemoveLong() { /** */ + @Test public void testRemove() { Integer[] arr = {0,1,2,3,4,5,6}; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/GridCleanerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/GridCleanerTest.java index deb87b0a89faa..e024c7c88c8bf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/GridCleanerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/GridCleanerTest.java @@ -17,15 +17,16 @@ package org.apache.ignite.internal.util; -import junit.framework.TestCase; +import org.junit.Test; /** * Grid cleaner tests. */ -public class GridCleanerTest extends TestCase { +public class GridCleanerTest { /** * @throws Exception If failed. */ + @Test public void testCreate() throws Exception { Object cleaner = GridCleaner.create(this, new Runnable() { @Override public void run() { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/GridHandleTableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/GridHandleTableSelfTest.java index bd6105fa58a98..ccbe84fd32c3c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/GridHandleTableSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/GridHandleTableSelfTest.java @@ -18,14 +18,19 @@ package org.apache.ignite.internal.util; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link GridHandleTable}. */ +@RunWith(JUnit4.class) public class GridHandleTableSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testGrow() throws Exception { GridHandleTable table = new GridHandleTable(8, 2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithUndefinedIgniteHomeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithUndefinedIgniteHomeSelfTest.java index cb0beed3888f0..f5f989f226a45 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithUndefinedIgniteHomeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/GridStartupWithUndefinedIgniteHomeSelfTest.java @@ -30,6 +30,8 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.After; +import org.junit.Test; import static org.apache.ignite.IgniteSystemProperties.IGNITE_HOME; import static org.apache.ignite.internal.util.IgniteUtils.nullifyHomeDirectory; @@ -42,7 +44,7 @@ * independent from {@link GridCommonAbstractTest} stuff. * 2. Do not replace native Java asserts with JUnit ones - test won't fall on TeamCity. */ -public class GridStartupWithUndefinedIgniteHomeSelfTest extends TestCase { +public class GridStartupWithUndefinedIgniteHomeSelfTest { /** */ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); @@ -50,7 +52,8 @@ public class GridStartupWithUndefinedIgniteHomeSelfTest extends TestCase { private static final int GRID_COUNT = 2; /** {@inheritDoc} */ - @Override protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { // Next grid in the same VM shouldn't use cached values produced by these tests. nullifyHomeDirectory(); @@ -60,6 +63,7 @@ public class GridStartupWithUndefinedIgniteHomeSelfTest extends TestCase { /** * @throws Exception If failed. */ + @Test public void testStartStopWithUndefinedIgniteHome() throws Exception { IgniteUtils.nullifyHomeDirectory(); @@ -77,7 +81,7 @@ public void testStartStopWithUndefinedIgniteHome() throws Exception { IgniteLogger log = new JavaLogger(); - log.info(">>> Test started: " + getName()); + log.info(">>> Test started: start-stop"); log.info("Grid start-stop test count: " + GRID_COUNT); for (int i = 0; i < GRID_COUNT; i++) { @@ -103,4 +107,4 @@ public void testStartStopWithUndefinedIgniteHome() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteDevOnlyLogTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteDevOnlyLogTest.java index 9a829473b7395..de3ba71cdd01e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteDevOnlyLogTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteDevOnlyLogTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Testing logging via {@link IgniteUtils#warnDevOnly(IgniteLogger, Object)}. */ +@RunWith(JUnit4.class) public class IgniteDevOnlyLogTest extends GridCommonAbstractTest { /** */ private List additionalArgs; @@ -55,6 +59,7 @@ public class IgniteDevOnlyLogTest extends GridCommonAbstractTest { } /** Check that dev-only messages appear in the log. */ + @Test public void testDevOnlyQuietMessage() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-9328"); @@ -72,6 +77,7 @@ public void testDevOnlyQuietMessage() throws Exception { } /** Check that dev-only messages appear in the log. */ + @Test public void testDevOnlyVerboseMessage() throws Exception { additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_QUIET + "=false"); @@ -91,6 +97,7 @@ public void testDevOnlyVerboseMessage() throws Exception { * doesn't print anything if {@link org.apache.ignite.IgniteSystemProperties#IGNITE_DEV_ONLY_LOGGING_DISABLED} * is set to {@code true}. */ + @Test public void testDevOnlyDisabledProperty() throws Exception { additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_DEV_ONLY_LOGGING_DISABLED + "=true"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteExceptionRegistrySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteExceptionRegistrySelfTest.java index 81b7522014960..18aaded687335 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteExceptionRegistrySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteExceptionRegistrySelfTest.java @@ -24,11 +24,15 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class IgniteExceptionRegistrySelfTest extends GridCommonAbstractTest { /** */ private IgniteExceptionRegistry registry = IgniteExceptionRegistry.get(); @@ -36,6 +40,7 @@ public class IgniteExceptionRegistrySelfTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testOnException() throws Exception { awaitPartitionMapExchange(); @@ -90,6 +95,7 @@ public void testOnException() throws Exception { /** * @throws Exception if failed. */ + @Test public void testMultiThreadedMaxSize() throws Exception { final int maxSize = 10; @@ -108,4 +114,4 @@ public void testMultiThreadedMaxSize() throws Exception { assert maxSize + 1 >= size && maxSize - 1 <= size; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java index 61a076ed65f34..cefce1ebd8a2f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java @@ -38,20 +38,32 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; -import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Random; import java.util.UUID; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.IgniteInterruptedException; import org.apache.ignite.cluster.ClusterGroup; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.compute.ComputeJob; import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.processors.igfs.IgfsUtils; import org.apache.ignite.internal.util.lang.GridPeerDeployAware; +import org.apache.ignite.internal.util.lang.IgniteThrowableConsumer; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; @@ -64,13 +76,19 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static java.util.Arrays.asList; import static org.junit.Assert.assertArrayEquals; /** * Grid utils tests. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class IgniteUtilsSelfTest extends GridCommonAbstractTest { /** */ public static final int[] EMPTY = new int[0]; @@ -89,6 +107,7 @@ private String text120() { /** * */ + @Test public void testIsPow2() { assertTrue(U.isPow2(1)); assertTrue(U.isPow2(2)); @@ -113,6 +132,7 @@ public void testIsPow2() { /** * @throws Exception If failed. */ + @Test public void testAllLocalIps() throws Exception { Collection ips = U.allLocalIps(); @@ -122,6 +142,7 @@ public void testAllLocalIps() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAllLocalMACs() throws Exception { Collection macs = U.allLocalMACs(); @@ -133,6 +154,7 @@ public void testAllLocalMACs() throws Exception { * * @throws Exception If failed. */ + @Test public void testAllLocalMACsMultiThreaded() throws Exception { GridTestUtils.runMultiThreaded(new Runnable() { @Override public void run() { @@ -148,6 +170,7 @@ public void testAllLocalMACsMultiThreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByteArray2String() throws Exception { assertEquals("{0x0A,0x14,0x1E,0x28,0x32,0x3C,0x46,0x50,0x5A}", U.byteArray2String(new byte[]{10, 20, 30, 40, 50, 60, 70, 80, 90}, "0x%02X", ",0x%02X")); @@ -156,6 +179,7 @@ public void testByteArray2String() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFormatMins() throws Exception { printFormatMins(0); printFormatMins(1); @@ -183,6 +207,7 @@ private void printFormatMins(long mins) { /** * @throws Exception If failed. */ + @Test public void testDownloadUrlFromHttp() throws Exception { GridEmbeddedHttpServer srv = null; try { @@ -206,6 +231,7 @@ public void testDownloadUrlFromHttp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDownloadUrlFromHttps() throws Exception { GridEmbeddedHttpServer srv = null; try { @@ -229,6 +255,7 @@ public void testDownloadUrlFromHttps() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDownloadUrlFromLocalFile() throws Exception { File file = new File(System.getProperty("java.io.tmpdir") + File.separator + "url-http.file"); @@ -242,6 +269,7 @@ public void testDownloadUrlFromLocalFile() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOs() throws Exception { System.out.println("OS string: " + U.osString()); System.out.println("JDK string: " + U.jdkString()); @@ -268,6 +296,7 @@ public void testOs() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJavaSerialization() throws Exception { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream objOut = new ObjectOutputStream(byteOut); @@ -286,6 +315,7 @@ public void testJavaSerialization() throws Exception { /** * */ + @Test public void testHidePassword() { Collection uriList = new ArrayList<>(); @@ -329,7 +359,7 @@ private SelfReferencedJob(Ignite ignite) throws IgniteCheckedException { arr = new SelfReferencedJob[] {this, this}; - col = Arrays.asList(this, this, this); + col = asList(this, this, this); newContext(); @@ -355,6 +385,7 @@ private SelfReferencedJob(Ignite ignite) throws IgniteCheckedException { /** * @throws Exception If test fails. */ + @Test public void testDetectPeerDeployAwareInfiniteRecursion() throws Exception { Ignite g = startGrid(1); @@ -386,51 +417,10 @@ private static ComputeJob job(final Runnable r) { }; } - /** - * - * @throws Exception If failed. - */ - public void testParseIsoDate() throws Exception { - Calendar cal = U.parseIsoDate("2009-12-08T13:30:44.000Z"); - - assert cal.get(Calendar.YEAR) == 2009; - assert cal.get(Calendar.MONTH) == 11; - assert cal.get(Calendar.DAY_OF_MONTH) == 8; - assert cal.get(Calendar.HOUR_OF_DAY) == 13; - assert cal.get(Calendar.MINUTE) == 30; - assert cal.get(Calendar.SECOND) == 44; - assert cal.get(Calendar.MILLISECOND) == 0; - assert cal.get(Calendar.ZONE_OFFSET) == 0 : - "Unexpected value: " + cal.get(Calendar.ZONE_OFFSET); - - cal = U.parseIsoDate("2009-12-08T13:30:44.000+03:00"); - - assert cal.get(Calendar.YEAR) == 2009; - assert cal.get(Calendar.MONTH) == 11; - assert cal.get(Calendar.DAY_OF_MONTH) == 8; - assert cal.get(Calendar.HOUR_OF_DAY) == 13; - assert cal.get(Calendar.MINUTE) == 30; - assert cal.get(Calendar.SECOND) == 44; - assert cal.get(Calendar.MILLISECOND) == 0; - assert cal.get(Calendar.ZONE_OFFSET) == 3 * 60 * 60 * 1000 : - "Unexpected value: " + cal.get(Calendar.ZONE_OFFSET); - - cal = U.parseIsoDate("2009-12-08T13:30:44.000+0300"); - - assert cal.get(Calendar.YEAR) == 2009; - assert cal.get(Calendar.MONTH) == 11; - assert cal.get(Calendar.DAY_OF_MONTH) == 8; - assert cal.get(Calendar.HOUR_OF_DAY) == 13; - assert cal.get(Calendar.MINUTE) == 30; - assert cal.get(Calendar.SECOND) == 44; - assert cal.get(Calendar.MILLISECOND) == 0; - assert cal.get(Calendar.ZONE_OFFSET) == 3 * 60 * 60 * 1000 : - "Unexpected value: " + cal.get(Calendar.ZONE_OFFSET); - } - /** * @throws Exception If test failed. */ + @Test public void testPeerDeployAware0() throws Exception { Collection col = new ArrayList<>(); @@ -499,6 +489,7 @@ public void testPeerDeployAware0() throws Exception { /** * Test UUID to bytes array conversion. */ + @Test public void testsGetBytes() { for (int i = 0; i < 100; i++) { UUID id = UUID.randomUUID(); @@ -515,6 +506,7 @@ public void testsGetBytes() { * */ @SuppressWarnings("ZeroLengthArrayAllocation") + @Test public void testReadByteArray() { assertTrue(Arrays.equals(new byte[0], U.readByteArray(ByteBuffer.allocate(0)))); assertTrue(Arrays.equals(new byte[0], U.readByteArray(ByteBuffer.allocate(0), ByteBuffer.allocate(0)))); @@ -556,6 +548,7 @@ public void testReadByteArray() { * */ @SuppressWarnings("ZeroLengthArrayAllocation") + @Test public void testHashCodeFromBuffers() { assertEquals(Arrays.hashCode(new byte[0]), U.hashCode(ByteBuffer.allocate(0))); assertEquals(Arrays.hashCode(new byte[0]), U.hashCode(ByteBuffer.allocate(0), ByteBuffer.allocate(0))); @@ -580,6 +573,7 @@ public void testHashCodeFromBuffers() { /** * Test annotation look up. */ + @Test public void testGetAnnotations() { assert U.getAnnotation(A1.class, Ann1.class) != null; assert U.getAnnotation(A2.class, Ann1.class) != null; @@ -594,6 +588,7 @@ public void testGetAnnotations() { /** * */ + @Test public void testUnique() { int[][][] arrays = new int[][][]{ new int[][]{EMPTY, EMPTY, EMPTY}, @@ -620,6 +615,7 @@ public void testUnique() { /** * */ + @Test public void testDifference() { int[][][] arrays = new int[][][]{ new int[][]{EMPTY, EMPTY, EMPTY}, @@ -643,6 +639,7 @@ public void testDifference() { /** * */ + @Test public void testCopyIfExceeded() { int[][] arrays = new int[][]{new int[]{13, 14, 17, 11}, new int[]{13}, EMPTY}; @@ -660,6 +657,7 @@ public void testCopyIfExceeded() { /** * */ + @Test public void testIsIncreasingArray() { assertTrue(U.isIncreasingArray(EMPTY, 0)); assertTrue(U.isIncreasingArray(new int[]{Integer.MIN_VALUE, -10, 1, 13, Integer.MAX_VALUE}, 5)); @@ -678,6 +676,7 @@ public void testIsIncreasingArray() { /** * */ + @Test public void testIsNonDecreasingArray() { assertTrue(U.isNonDecreasingArray(EMPTY, 0)); assertTrue(U.isNonDecreasingArray(new int[]{Integer.MIN_VALUE, -10, 1, 13, Integer.MAX_VALUE}, 5)); @@ -696,6 +695,7 @@ public void testIsNonDecreasingArray() { /** * Test InetAddress Comparator. */ + @Test public void testInetAddressesComparator() { List ips = new ArrayList() { { @@ -720,6 +720,7 @@ public void testInetAddressesComparator() { } + @Test public void testMD5Calculation() throws Exception { String md5 = U.calculateMD5(new ByteArrayInputStream("Corrupted information.".getBytes())); @@ -729,6 +730,7 @@ public void testMD5Calculation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testResolveLocalAddresses() throws Exception { InetAddress inetAddress = InetAddress.getByName("0.0.0.0"); @@ -750,6 +752,7 @@ public void testResolveLocalAddresses() throws Exception { /** * */ + @Test public void testToSocketAddressesNoDuplicates() { Collection addrs = new ArrayList<>(); @@ -805,6 +808,7 @@ private static void checkString(String s0) throws Exception { * * @throws Exception If failed. */ + @Test public void testLongStringWriteUTF() throws Exception { checkString(null); checkString(""); @@ -826,6 +830,7 @@ public void testLongStringWriteUTF() throws Exception { /** * */ + @Test public void testCeilPow2() throws Exception { assertEquals(2, U.ceilPow2(2)); assertEquals(4, U.ceilPow2(3)); @@ -852,6 +857,7 @@ public void testCeilPow2() throws Exception { /** * */ + @Test public void testIsOldestNodeVersionAtLeast() { IgniteProductVersion v240 = IgniteProductVersion.fromString("2.4.0"); IgniteProductVersion v241 = IgniteProductVersion.fromString("2.4.1"); @@ -870,10 +876,306 @@ public void testIsOldestNodeVersionAtLeast() { TcpDiscoveryNode node250ts = new TcpDiscoveryNode(); node250ts.version(v250ts); - assertTrue(U.isOldestNodeVersionAtLeast(v240, Arrays.asList(node240, node241, node250, node250ts))); - assertFalse(U.isOldestNodeVersionAtLeast(v241, Arrays.asList(node240, node241, node250, node250ts))); - assertTrue(U.isOldestNodeVersionAtLeast(v250, Arrays.asList(node250, node250ts))); - assertTrue(U.isOldestNodeVersionAtLeast(v250ts, Arrays.asList(node250, node250ts))); + assertTrue(U.isOldestNodeVersionAtLeast(v240, asList(node240, node241, node250, node250ts))); + assertFalse(U.isOldestNodeVersionAtLeast(v241, asList(node240, node241, node250, node250ts))); + assertTrue(U.isOldestNodeVersionAtLeast(v250, asList(node250, node250ts))); + assertTrue(U.isOldestNodeVersionAtLeast(v250ts, asList(node250, node250ts))); + } + + /** + * + */ + @Test + public void testDoInParallel() throws Throwable { + CyclicBarrier barrier = new CyclicBarrier(3); + + ExecutorService executorService = Executors.newFixedThreadPool(3); + + try { + IgniteUtils.doInParallel(3, + executorService, + asList(1, 2, 3), + i -> { + try { + barrier.await(1, TimeUnit.SECONDS); + } + catch (Exception e) { + throw new IgniteCheckedException(e); + } + + return null; + } + ); + } finally { + executorService.shutdownNow(); + } + } + + /** + * + */ + @Test + public void testDoInParallelBatch() { + CyclicBarrier barrier = new CyclicBarrier(3); + + ExecutorService executorService = Executors.newFixedThreadPool(3); + + try { + IgniteUtils.doInParallel(2, + executorService, + asList(1, 2, 3), + i -> { + try { + barrier.await(400, TimeUnit.MILLISECONDS); + } + catch (Exception e) { + throw new IgniteCheckedException(e); + } + + return null; + } + ); + + fail("Should throw timeout exception"); + } + catch (Exception e) { + assertTrue(e.toString(), X.hasCause(e, TimeoutException.class)); + } finally { + executorService.shutdownNow(); + } + } + + /** + * Test optimal splitting on batch sizes. + */ + @Test + public void testOptimalBatchSize() { + assertArrayEquals(new int[]{1}, IgniteUtils.calculateOptimalBatchSizes(1, 1)); + + assertArrayEquals(new int[]{2}, IgniteUtils.calculateOptimalBatchSizes(1, 2)); + + assertArrayEquals(new int[]{1, 1, 1, 1}, IgniteUtils.calculateOptimalBatchSizes(6, 4)); + + assertArrayEquals(new int[]{1}, IgniteUtils.calculateOptimalBatchSizes(4, 1)); + + assertArrayEquals(new int[]{1, 1}, IgniteUtils.calculateOptimalBatchSizes(4, 2)); + + assertArrayEquals(new int[]{1, 1, 1}, IgniteUtils.calculateOptimalBatchSizes(4, 3)); + + assertArrayEquals(new int[]{1, 1, 1, 1}, IgniteUtils.calculateOptimalBatchSizes(4, 4)); + + assertArrayEquals(new int[]{2, 1, 1, 1}, IgniteUtils.calculateOptimalBatchSizes(4, 5)); + + assertArrayEquals(new int[]{2, 2, 1, 1}, IgniteUtils.calculateOptimalBatchSizes(4, 6)); + + assertArrayEquals(new int[]{2, 2, 2, 1}, IgniteUtils.calculateOptimalBatchSizes(4, 7)); + + assertArrayEquals(new int[]{2, 2, 2, 2}, IgniteUtils.calculateOptimalBatchSizes(4, 8)); + + assertArrayEquals(new int[]{3, 2, 2, 2}, IgniteUtils.calculateOptimalBatchSizes(4, 9)); + + assertArrayEquals(new int[]{3, 3, 2, 2}, IgniteUtils.calculateOptimalBatchSizes(4, 10)); + } + + /** + * Test parallel execution in order. + */ + @Test + public void testDoInParallelResultsOrder() throws IgniteCheckedException { + ExecutorService executorService = Executors.newFixedThreadPool(4); + + try { + for(int parallelism = 1; parallelism < 16; parallelism++) + for(int size = 0; size < 10_000; size++) + testOrder(executorService, size, parallelism); + } finally { + executorService.shutdownNow(); + } + } + + /** + * Test parallel execution steal job. + */ + @Test + public void testDoInParallelWithStealingJob() throws IgniteCheckedException { + // Pool size should be less that input data collection. + ExecutorService executorService = Executors.newFixedThreadPool(1); + + CountDownLatch mainThreadLatch = new CountDownLatch(1); + CountDownLatch poolThreadLatch = new CountDownLatch(1); + + // Busy one thread from the pool. + executorService.submit(new Runnable() { + @Override + public void run() { + try { + poolThreadLatch.await(); + } + catch (InterruptedException e) { + throw new IgniteInterruptedException(e); + } + } + }); + + List data = asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); + + AtomicInteger taskProcessed = new AtomicInteger(); + + long threadId = Thread.currentThread().getId(); + + AtomicInteger curThreadCnt = new AtomicInteger(); + AtomicInteger poolThreadCnt = new AtomicInteger(); + + Collection res = U.doInParallel(10, + executorService, + data, + new IgniteThrowableConsumer() { + @Override public Integer accept(Integer cnt) throws IgniteInterruptedCheckedException { + // Release thread in pool in the middle of range. + if (taskProcessed.getAndIncrement() == (data.size() / 2) - 1) { + poolThreadLatch.countDown(); + + try { + // Await thread in thread pool complete task. + mainThreadLatch.await(); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + + throw new IgniteInterruptedCheckedException(e); + } + } + + // Increment if executed in current thread. + if (Thread.currentThread().getId() == threadId) + curThreadCnt.incrementAndGet(); + else { + poolThreadCnt.incrementAndGet(); + + if (taskProcessed.get() == data.size()) + mainThreadLatch.countDown(); + } + + return -cnt; + } + }); + + Assert.assertEquals(curThreadCnt.get() + poolThreadCnt.get(), data.size()); + Assert.assertEquals(5, curThreadCnt.get()); + Assert.assertEquals(5, poolThreadCnt.get()); + Assert.assertEquals(asList(0, -1, -2, -3, -4, -5, -6, -7, -8, -9), res); + } + + /** + * Test parallel execution steal job. + */ + @Test + public void testDoInParallelWithStealingJobRunTaskInExecutor() throws Exception { + // Pool size should be less that input data collection. + ExecutorService executorService = Executors.newFixedThreadPool(2); + + Future f1 = executorService.submit(()-> runTask(executorService)); + Future f2 = executorService.submit(()-> runTask(executorService)); + Future f3 = executorService.submit(()-> runTask(executorService)); + + f1.get(); + f2.get(); + f3.get(); + } + + /** + * + * @param executorService Executor service. + */ + private void runTask(ExecutorService executorService) { + List data = asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); + + long threadId = Thread.currentThread().getId(); + + AtomicInteger curThreadCnt = new AtomicInteger(); + + Collection res; + + try { + res = U.doInParallel(10, + executorService, + data, + new IgniteThrowableConsumer() { + @Override public Integer accept(Integer cnt) { + if (Thread.currentThread().getId() == threadId) + curThreadCnt.incrementAndGet(); + + return -cnt; + } + }); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + + Assert.assertTrue(curThreadCnt.get() > 0); + Assert.assertEquals(asList(0, -1, -2, -3, -4, -5, -6, -7, -8, -9), res); + } + + /** + * Template method to test parallel execution + * @param executorService ExecutorService. + * @param size Size. + * @param parallelism Parallelism. + * @throws IgniteCheckedException Exception. + */ + private void testOrder(ExecutorService executorService, int size, int parallelism) throws IgniteCheckedException { + List list = new ArrayList<>(); + for(int i = 0; i < size; i++) + list.add(i); + + Collection results = IgniteUtils.doInParallel( + parallelism, + executorService, + list, + i -> i * 2 + ); + + assertEquals(list.size(), results.size()); + + final int[] i = {0}; + results.forEach(new Consumer() { + @Override public void accept(Integer integer) { + assertEquals(2 * list.get(i[0]), integer.intValue()); + i[0]++; + } + }); + } + + /** + * + */ + @Test + public void testDoInParallelException() { + String expectedException = "ExpectedException"; + + ExecutorService executorService = Executors.newFixedThreadPool(1); + + try { + IgniteUtils.doInParallel( + 1, + executorService, + asList(1, 2, 3), + i -> { + if (Integer.valueOf(1).equals(i)) + throw new IgniteCheckedException(expectedException); + + return null; + } + ); + + fail("Should throw ParallelExecutionException"); + } + catch (IgniteCheckedException e) { + assertEquals(expectedException, e.getMessage()); + } finally { + executorService.shutdownNow(); + } } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/StripedExecutorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/StripedExecutorTest.java index 9a4bf0619c4df..0b4123a3bf652 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/StripedExecutorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/StripedExecutorTest.java @@ -20,10 +20,14 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.logger.java.JavaLogger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class StripedExecutorTest extends GridCommonAbstractTest { /** */ private StripedExecutor stripedExecSvc; @@ -44,6 +48,7 @@ public class StripedExecutorTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCompletedTasks() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable()); @@ -56,6 +61,7 @@ public void testCompletedTasks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStripesCompletedTasks() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable()); @@ -72,6 +78,7 @@ public void testStripesCompletedTasks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStripesActiveStatuses() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable(true)); @@ -88,6 +95,7 @@ public void testStripesActiveStatuses() throws Exception { /** * @throws Exception If failed. */ + @Test public void testActiveStripesCount() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable(true)); @@ -100,6 +108,7 @@ public void testActiveStripesCount() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStripesQueueSizes() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(0, new TestRunnable(true)); @@ -120,6 +129,7 @@ public void testStripesQueueSizes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueueSize() throws Exception { stripedExecSvc.execute(1, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable(true)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridCompoundFutureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridCompoundFutureSelfTest.java index a6021332e7e9e..4d8756958ca46 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridCompoundFutureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridCompoundFutureSelfTest.java @@ -25,14 +25,19 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests compound future contracts. */ +@RunWith(JUnit4.class) public class GridCompoundFutureSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testMarkInitialized() throws Exception { GridCompoundFuture fut = new GridCompoundFuture<>(); @@ -53,6 +58,7 @@ public void testMarkInitialized() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCompleteOnReducer() throws Exception { GridCompoundFuture fut = new GridCompoundFuture<>(CU.boolReducer()); @@ -85,6 +91,7 @@ public void testCompleteOnReducer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCompleteOnException() throws Exception { GridCompoundFuture fut = new GridCompoundFuture<>(CU.boolReducer()); @@ -117,6 +124,7 @@ public void testCompleteOnException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentCompletion() throws Exception { GridCompoundFuture fut = new GridCompoundFuture<>(CU.boolReducer()); @@ -149,6 +157,7 @@ public void testConcurrentCompletion() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentRandomCompletion() throws Exception { GridCompoundFuture fut = new GridCompoundFuture<>(CU.boolReducer()); @@ -187,4 +196,4 @@ else if (op == 8) assertTrue(fut.isDone()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridEmbeddedFutureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridEmbeddedFutureSelfTest.java index 314acceaba3c7..4d3134935612c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridEmbeddedFutureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridEmbeddedFutureSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.lang.IgniteBiClosure; import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.configuration.CacheConfiguration.DFLT_MAX_CONCURRENT_ASYNC_OPS; @@ -33,6 +36,7 @@ /** * Tests grid embedded future use cases. */ +@RunWith(JUnit4.class) public class GridEmbeddedFutureSelfTest extends GridCommonAbstractTest { /** * Test kernal context. @@ -47,6 +51,7 @@ public class GridEmbeddedFutureSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testFutureChain() throws Exception { GridFutureAdapter fut = new GridFutureAdapter<>(); @@ -70,6 +75,7 @@ public void testFutureChain() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ErrorNotRethrown") + @Test public void testFutureCompletesCorrectly() throws Exception { List list = Arrays.asList( null, @@ -137,4 +143,4 @@ public void testFutureCompletesCorrectly() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureAdapterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureAdapterSelfTest.java index 89f3a0309c3fc..e954afcc655aa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureAdapterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureAdapterSelfTest.java @@ -35,14 +35,19 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests grid future adapter use cases. */ +@RunWith(JUnit4.class) public class GridFutureAdapterSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testOnDone() throws Exception { GridFutureAdapter fut = new GridFutureAdapter<>(); @@ -92,6 +97,7 @@ public void testOnDone() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOnCancelled() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -119,6 +125,7 @@ public void testOnCancelled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testListenSyncNotify() throws Exception { GridFutureAdapter fut = new GridFutureAdapter<>(); @@ -170,6 +177,7 @@ public void testListenSyncNotify() throws Exception { /** * @throws Exception If failed. */ + @Test public void testListenNotify() throws Exception { GridTestKernalContext ctx = new GridTestKernalContext(log); @@ -228,6 +236,7 @@ public void testListenNotify() throws Exception { * * @throws Exception In case of any exception. */ + @Test public void testChaining() throws Exception { checkChaining(null); @@ -326,6 +335,7 @@ private void checkChaining(ExecutorService exec) throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { GridFutureAdapter unfinished = new GridFutureAdapter<>(); GridFutureAdapter finished = new GridFutureAdapter<>(); @@ -371,4 +381,4 @@ public void testGet() throws Exception { } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureQueueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureQueueTest.java index 4b6d81c2da114..595e0cd3d605b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureQueueTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFutureQueueTest.java @@ -181,4 +181,4 @@ public void testQueue(long time, int writers) throws Exception { System.gc(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/IgniteFutureImplTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/future/IgniteFutureImplTest.java index 3a06cf4420bc6..7c08863e93161 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/IgniteFutureImplTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/IgniteFutureImplTest.java @@ -37,10 +37,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteFutureImplTest extends GridCommonAbstractTest { /** Context thread name. */ private static final String CTX_THREAD_NAME = "test-async"; @@ -73,6 +77,7 @@ public class IgniteFutureImplTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testFutureGet() throws Exception { GridFutureAdapter fut0 = new GridFutureAdapter<>(); @@ -92,6 +97,7 @@ public void testFutureGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFutureException() throws Exception { GridFutureAdapter fut0 = new GridFutureAdapter<>(); @@ -131,6 +137,7 @@ public void testFutureException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFutureIgniteException() throws Exception { GridFutureAdapter fut0 = new GridFutureAdapter<>(); @@ -154,6 +161,7 @@ public void testFutureIgniteException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testListeners() throws Exception { GridFutureAdapter fut0 = new GridFutureAdapter<>(); @@ -198,6 +206,7 @@ public void testListeners() throws Exception { /** * @throws Exception If failed. */ + @Test public void testListenersOnError() throws Exception { { GridFutureAdapter fut0 = new GridFutureAdapter<>(); @@ -265,6 +274,7 @@ public void testListenersOnError() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAsyncListeners() throws Exception { GridFutureAdapter fut0 = new GridFutureAdapter<>(); @@ -306,6 +316,7 @@ private void checkAsyncListener(IgniteFutureImpl fut) throws Interrupted /** * @throws Exception If failed. */ + @Test public void testAsyncListenersOnError() throws Exception { checkAsyncListenerOnError(new IgniteException("Test exception")); checkAsyncListenerOnError(new IgniteCheckedException("Test checked exception")); @@ -385,6 +396,7 @@ private void checkAsyncListenerOnError(Exception err0, IgniteFutureImpl /** * @throws Exception If failed. */ + @Test public void testChain() throws Exception { GridFutureAdapter fut0 = new GridFutureAdapter<>(); @@ -426,6 +438,7 @@ public void testChain() throws Exception { /** * @throws Exception If failed. */ + @Test public void testChainError() throws Exception { { GridFutureAdapter fut0 = new GridFutureAdapter<>(); @@ -575,6 +588,7 @@ public void testChainError() throws Exception { /** * @throws Exception If failed. */ + @Test public void testChainAsync() throws Exception { GridFutureAdapter fut0 = new GridFutureAdapter<>(); @@ -647,6 +661,7 @@ private TestClosure(CountDownLatch latch) { /** * @throws Exception If failed. */ + @Test public void testChainAsyncOnError() throws Exception { checkChainedOnError(new IgniteException("Test exception")); checkChainedOnError(new IgniteCheckedException("Test checked exception")); @@ -805,4 +820,4 @@ protected IgniteFutureImpl createFuture(IgniteInternalFuture fut) { protected Class expectedException() { return IgniteException.class; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/nio/GridNioEmbeddedFutureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/future/nio/GridNioEmbeddedFutureSelfTest.java index b7b69662f3925..0b26d4f7c96f2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/nio/GridNioEmbeddedFutureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/nio/GridNioEmbeddedFutureSelfTest.java @@ -20,16 +20,21 @@ import org.apache.ignite.internal.util.nio.GridNioEmbeddedFuture; import org.apache.ignite.internal.util.nio.GridNioFutureImpl; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; /** * Test for NIO embedded future. */ +@RunWith(JUnit4.class) public class GridNioEmbeddedFutureSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNioEmbeddedFuture() throws Exception { // Original future. final GridNioFutureImpl origFut = new GridNioFutureImpl<>(null); @@ -57,4 +62,4 @@ public void testNioEmbeddedFuture() throws Exception { // Wait for embedded future completes. assertEquals(new Integer(100), embFut.get(1, SECONDS)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/nio/GridNioFutureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/future/nio/GridNioFutureSelfTest.java index 44a1effe89f4c..86f19eb311eb5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/nio/GridNioFutureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/nio/GridNioFutureSelfTest.java @@ -30,14 +30,19 @@ import org.apache.ignite.internal.util.typedef.CI1; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for NIO future. */ +@RunWith(JUnit4.class) public class GridNioFutureSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testOnDone() throws Exception { GridNioFutureImpl fut = new GridNioFutureImpl<>(null); @@ -87,6 +92,7 @@ public void testOnDone() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOnCancelled() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -114,6 +120,7 @@ public void testOnCancelled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testListenSyncNotify() throws Exception { GridNioFutureImpl fut = new GridNioFutureImpl<>(null); @@ -165,6 +172,7 @@ public void testListenSyncNotify() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { GridNioFutureImpl unfinished = new GridNioFutureImpl<>(null); GridNioFutureImpl finished = new GridNioFutureImpl<>(null); @@ -210,4 +218,4 @@ public void testGet() throws Exception { } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java index f3ff7810c0f64..7f3c8b99f3c4b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java @@ -19,7 +19,9 @@ import java.io.ByteArrayInputStream; import java.util.Random; -import junit.framework.TestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import static org.apache.ignite.GridTestIoUtils.getCharByByteLE; import static org.apache.ignite.GridTestIoUtils.getDoubleByByteLE; @@ -28,11 +30,12 @@ import static org.apache.ignite.GridTestIoUtils.getLongByByteLE; import static org.apache.ignite.GridTestIoUtils.getShortByByteLE; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; /** * Grid unsafe data input/output byte order sanity tests. */ -public class GridUnsafeDataInputOutputByteOrderSelfTest extends TestCase { +public class GridUnsafeDataInputOutputByteOrderSelfTest { /** Array length. */ private static final int ARR_LEN = 16; @@ -48,15 +51,17 @@ public class GridUnsafeDataInputOutputByteOrderSelfTest extends TestCase { /** In. */ private GridUnsafeDataInput in; - /** {@inheritDoc} */ - @Override protected void setUp() throws Exception { + /** */ + @Before + public void setUp() throws Exception { out = new GridUnsafeDataOutput(16 * 8+ LEN_BYTES); in = new GridUnsafeDataInput(); in.inputStream(new ByteArrayInputStream(out.internalArray())); } - /** {@inheritDoc} */ - @Override public void tearDown() throws Exception { + /** */ + @After + public void tearDown() throws Exception { in.close(); out.close(); } @@ -64,6 +69,7 @@ public class GridUnsafeDataInputOutputByteOrderSelfTest extends TestCase { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { short val = (short)RND.nextLong(); @@ -76,6 +82,7 @@ public void testShort() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShortArray() throws Exception { short[] arr = new short[ARR_LEN]; @@ -95,6 +102,7 @@ public void testShortArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testChar() throws Exception { char val = (char)RND.nextLong(); @@ -107,6 +115,7 @@ public void testChar() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCharArray() throws Exception { char[] arr = new char[ARR_LEN]; @@ -126,6 +135,7 @@ public void testCharArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInt() throws Exception { int val = RND.nextInt(); @@ -138,6 +148,7 @@ public void testInt() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIntArray() throws Exception { int[] arr = new int[ARR_LEN]; @@ -157,6 +168,7 @@ public void testIntArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { long val = RND.nextLong(); @@ -169,6 +181,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLongArray() throws Exception { long[] arr = new long[ARR_LEN]; @@ -188,6 +201,7 @@ public void testLongArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloat() throws Exception { float val = RND.nextFloat(); @@ -200,6 +214,7 @@ public void testFloat() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFloatArray() throws Exception { float[] arr = new float[ARR_LEN]; @@ -219,6 +234,7 @@ public void testFloatArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDouble() throws Exception { double val = RND.nextDouble(); @@ -231,6 +247,7 @@ public void testDouble() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDoubleArray() throws Exception { double[] arr = new double[ARR_LEN]; @@ -246,4 +263,4 @@ public void testDoubleArray() throws Exception { assertArrayEquals(arr, in.readDoubleArray(), 0); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutputArraySizingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutputArraySizingSelfTest.java index 7e59a6a8250ba..42546204865dc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutputArraySizingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutputArraySizingSelfTest.java @@ -20,12 +20,16 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK; /** * Test for {@link GridUnsafeDataOutput}. */ +@RunWith(JUnit4.class) public class GridUnsafeDataOutputArraySizingSelfTest extends GridCommonAbstractTest { /** Small array. */ private static final byte[] SMALL = new byte[32]; @@ -49,7 +53,7 @@ public class GridUnsafeDataOutputArraySizingSelfTest extends GridCommonAbstractT /** * @throws Exception If failed. */ - @SuppressWarnings("BusyWait") + @Test public void testSmall() throws Exception { final GridUnsafeDataOutput out = new GridUnsafeDataOutput(512); @@ -63,6 +67,7 @@ public void testSmall() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBig() throws Exception { GridUnsafeDataOutput out = new GridUnsafeDataOutput(512); @@ -76,6 +81,7 @@ public void testBig() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("BusyWait") + @Test public void testChanged1() throws Exception { GridUnsafeDataOutput out = new GridUnsafeDataOutput(512); @@ -94,7 +100,7 @@ public void testChanged1() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("BusyWait") + @Test public void testChanged2() throws Exception { final GridUnsafeDataOutput out = new GridUnsafeDataOutput(512); @@ -148,4 +154,4 @@ private static class WriteAndCheckPredicate implements GridAbsPredicate { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java index 0c5f5644e89b5..4ed193738c19e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryCrashDetectionSelfTest.java @@ -36,10 +36,14 @@ import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test shared memory endpoints crash detection. */ +@RunWith(JUnit4.class) public class IpcSharedMemoryCrashDetectionSelfTest extends GridCommonAbstractTest { /** Timeout in ms between read/write attempts in busy-wait loops. */ public static final int RW_SLEEP_TIMEOUT = 50; @@ -70,6 +74,7 @@ public class IpcSharedMemoryCrashDetectionSelfTest extends GridCommonAbstractTes /** * @throws Exception If failed. */ + @Test public void testIgfsServerClientInteractionsUponClientKilling() throws Exception { // Run server endpoint. IpcSharedMemoryServerEndpoint srv = new IpcSharedMemoryServerEndpoint(U.defaultWorkDirectory()); @@ -112,6 +117,7 @@ public void testIgfsServerClientInteractionsUponClientKilling() throws Exception /** * @throws Exception If failed. */ + @Test public void testIgfsClientServerInteractionsUponServerKilling() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-1386"); @@ -163,6 +169,7 @@ public void testIgfsClientServerInteractionsUponServerKilling() throws Exception /** * @throws Exception If failed. */ + @Test public void testClientThrowsCorrectExceptionUponServerKilling() throws Exception { info("Shared memory IDs before starting server-client interactions: " + IpcSharedMemoryUtils.sharedMemoryIds()); @@ -520,4 +527,4 @@ public void shmemIds(String shmemIds) { }); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryNativeLoaderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryNativeLoaderSelfTest.java index bca9401cf3a1c..57f5216016360 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryNativeLoaderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryNativeLoaderSelfTest.java @@ -21,21 +21,23 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.Collections; -import junit.framework.TestCase; import org.apache.ignite.internal.util.GridJavaProcess; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * Test shared memory native loader. */ -public class IpcSharedMemoryNativeLoaderSelfTest extends TestCase { - +public class IpcSharedMemoryNativeLoaderSelfTest { /** * Test {@link IpcSharedMemoryNativeLoader#load()} in case, when native library path was * already loaded, but corrupted. * * @throws Exception If failed. */ + @Test public void testLoadWithCorruptedLibFile() throws Exception { if (U.isWindows()) return; @@ -76,4 +78,4 @@ private void readStreams(Process proc) throws IOException { while ((s = errOut.readLine()) != null) System.out.println("ERR>>>>>> " + s); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemorySpaceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemorySpaceSelfTest.java index a06d0203736db..d63921e76ce5c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemorySpaceSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemorySpaceSelfTest.java @@ -30,10 +30,14 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IpcSharedMemorySpaceSelfTest extends GridCommonAbstractTest { /** */ public static final int DATA_LEN = 1024 * 1024; @@ -59,6 +63,7 @@ public class IpcSharedMemorySpaceSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testBasicOperations() throws Exception { File tokFile = new File(IgniteSystemProperties.getString("java.io.tmpdir"), UUID.randomUUID().toString()); @@ -155,6 +160,7 @@ public void testBasicOperations() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForceClose() throws Exception { File tokFile = new File(IgniteSystemProperties.getString("java.io.tmpdir"), getTestIgniteInstanceName()); @@ -196,6 +202,7 @@ public void testForceClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadAfterClose() throws Exception { File tokFile = new File(IgniteSystemProperties.getString("java.io.tmpdir"), getTestIgniteInstanceName()); @@ -234,6 +241,7 @@ public void testReadAfterClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteAfterClose() throws Exception { File tokFile = new File(IgniteSystemProperties.getString("java.io.tmpdir"), getTestIgniteInstanceName()); @@ -266,4 +274,4 @@ public void testWriteAfterClose() throws Exception { assert !tokFile.exists(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryUtilsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryUtilsSelfTest.java index 8b2aa413d3b25..1b031e45be35f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryUtilsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryUtilsSelfTest.java @@ -21,10 +21,14 @@ import java.util.Collection; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IpcSharedMemoryUtilsSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -36,6 +40,7 @@ public class IpcSharedMemoryUtilsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPid() throws Exception { int pid = IpcSharedMemoryUtils.pid(); @@ -50,6 +55,7 @@ public void testPid() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIdsGet() throws Exception { File tokFile = new File(IgniteSystemProperties.getString("java.io.tmpdir"), getTestIgniteInstanceName()); @@ -80,4 +86,4 @@ public void testIdsGet() throws Exception { assertFalse(IpcSharedMemoryUtils.sharedMemoryIds().contains(shmemId)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBufferSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBufferSelfTest.java index 03b5169ec2fd7..5a57c0a133d26 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBufferSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBufferSelfTest.java @@ -22,18 +22,21 @@ import java.util.Arrays; import java.util.List; import java.util.Random; -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * Tests for {@link GridNioDelimitedBuffer}. */ -public class GridNioDelimitedBufferSelfTest extends TestCase { +public class GridNioDelimitedBufferSelfTest { /** */ private static final String ASCII = "ASCII"; /** * Tests simple delimiter (excluded from alphabet) */ + @Test public void testReadZString() throws Exception { Random rnd = new Random(); @@ -81,6 +84,7 @@ public void testReadZString() throws Exception { /** * Tests compound delimiter (included to alphabet) */ + @Test public void testDelim() throws Exception { byte[] delim = "aabb".getBytes(ASCII); @@ -111,4 +115,4 @@ public void testDelim() throws Exception { assertEquals(strs, res); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSelfTest.java index e623467319a1c..d4065907db558 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSelfTest.java @@ -52,12 +52,16 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; /** * Tests for new NIO server. */ +@RunWith(JUnit4.class) public class GridNioSelfTest extends GridCommonAbstractTest { /** Message count in test without reconnect. */ private static final int MSG_CNT = 2000; @@ -103,6 +107,7 @@ public class GridNioSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSimpleMessages() throws Exception { final Collection sesSet = new GridConcurrentHashSet<>(); @@ -159,6 +164,7 @@ public void testSimpleMessages() throws Exception { * * @throws Exception if failed. */ + @Test public void testServerShutdown() throws Exception { GridNioServerListener lsnr = new GridNioServerListenerAdapter() { @Override public void onConnected(GridNioSession ses) { @@ -214,6 +220,7 @@ public void testServerShutdown() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCorrectSocketClose() throws Exception { final AtomicReference err = new AtomicReference<>(); @@ -259,6 +266,7 @@ public void testCorrectSocketClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testThroughput() throws Exception { GridNioServerListener lsnr = new GridNioServerListenerAdapter() { @Override public void onConnected(GridNioSession ses) { @@ -339,6 +347,7 @@ public void testThroughput() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCloseSession() throws Exception { final AtomicReference err = new AtomicReference<>(); @@ -414,6 +423,7 @@ public void testCloseSession() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSendAfterServerStop() throws Exception { final AtomicReference sesRef = new AtomicReference<>(); @@ -631,6 +641,7 @@ protected GridNioServer.Builder serverBuilder(int port, /** * @throws Exception If test failed. */ + @Test public void testSendReceive() throws Exception { CountDownLatch latch = new CountDownLatch(10); @@ -665,6 +676,7 @@ public void testSendReceive() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testAsyncSendReceive() throws Exception { CountDownLatch latch = new CountDownLatch(10); @@ -703,6 +715,7 @@ public void testAsyncSendReceive() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMultiThreadedSendReceive() throws Exception { CountDownLatch latch = new CountDownLatch(MSG_CNT * THREAD_CNT); @@ -749,6 +762,7 @@ public void testMultiThreadedSendReceive() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentConnects() throws Exception { final CyclicBarrier barrier = new CyclicBarrier(THREAD_CNT); @@ -846,6 +860,7 @@ public void testConcurrentConnects() throws Exception { /** * @throws Exception if test failed. */ + @Test public void testDeliveryDuration() throws Exception { idProvider.set(1); @@ -913,6 +928,7 @@ public void testDeliveryDuration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSessionIdleTimeout() throws Exception { final int sesCnt = 20; @@ -975,6 +991,7 @@ public void testSessionIdleTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWriteTimeout() throws Exception { final int sesCnt = 20; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKeySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKeySelfTest.java index 71950eec98a31..d825ae8c725e9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKeySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKeySelfTest.java @@ -22,14 +22,19 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link GridNioSessionMetaKey}. */ +@RunWith(JUnit4.class) public class GridNioSessionMetaKeySelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNextRandomKey() throws Exception { AtomicInteger keyGen = U.staticField(GridNioSessionMetaKey.class, "keyGen"); @@ -54,4 +59,4 @@ public void testNextRandomKey() throws Exception { keyGen.set(initVal); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSslSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSslSelfTest.java index 1c4aa27d86281..034beb07d2682 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSslSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSslSelfTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.internal.util.nio.ssl.GridNioSslFilter; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for new NIO server with SSL enabled. */ +@RunWith(JUnit4.class) public class GridNioSslSelfTest extends GridNioSelfTest { /** Test SSL context. */ private static SSLContext sslCtx; @@ -75,13 +79,15 @@ public class GridNioSslSelfTest extends GridNioSelfTest { } /** {@inheritDoc} */ + @Test @Override public void testWriteTimeout() throws Exception { // Skip base test because it enables "skipWrite" mode in the GridNioServer // which makes SSL handshake impossible. } /** {@inheritDoc} */ + @Test @Override public void testAsyncSendReceive() throws Exception { // No-op, do not want to mess with SSL channel. } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridRoundTripTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridRoundTripTest.java index d83fde6654e0e..91ae5a2e4de60 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridRoundTripTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridRoundTripTest.java @@ -26,13 +26,13 @@ import java.net.ServerSocket; import java.net.Socket; import java.util.Random; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; /** * Tests pure round trip time on network. */ -public class GridRoundTripTest extends TestCase { +public class GridRoundTripTest { /** Communication port. */ public static final int PORT = 47600; @@ -43,6 +43,7 @@ public class GridRoundTripTest extends TestCase { * @throws IOException If error occurs. * @throws InterruptedException If interrupted */ + @Test public void testRunServer() throws IOException, InterruptedException { final ServerSocket sock = new ServerSocket(); @@ -74,6 +75,7 @@ public void testRunServer() throws IOException, InterruptedException { * Runs client test */ @SuppressWarnings("InfiniteLoopStatement") + @Test public void testRunClient() { Socket sock = new Socket(); @@ -228,4 +230,4 @@ private static byte[] createMessage(int len) { return res; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java index 9af3f8c11467a..731a190d45dfe 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/IgniteExceptionInNioWorkerSelfTest.java @@ -24,21 +24,19 @@ import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteExceptionInNioWorkerSelfTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 4; - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -49,10 +47,6 @@ public class IgniteExceptionInNioWorkerSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfg); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); commSpi.setSharedMemoryPort(-1); @@ -65,6 +59,7 @@ public class IgniteExceptionInNioWorkerSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testBrokenMessage() throws Exception { startGrids(GRID_CNT); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java index 588857583fd79..7563b334ef21f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/impl/GridNioFilterChainSelfTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests filter chain event processing. */ +@RunWith(JUnit4.class) public class GridNioFilterChainSelfTest extends GridCommonAbstractTest { /** Session opened event meta name. */ private static final int OPENED_META_NAME = 11; @@ -66,6 +70,7 @@ public class GridNioFilterChainSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testChainEvents() throws Exception { final AtomicReference connectedEvt = new AtomicReference<>(); final AtomicReference disconnectedEvt = new AtomicReference<>(); @@ -400,4 +405,4 @@ public MockNioSession(InetSocketAddress locAddr, InetSocketAddress rmtAddr) { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapAbstractSelfTest.java index b0c6037ddb0fd..6c9518ff86044 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapAbstractSelfTest.java @@ -33,10 +33,14 @@ import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.concurrent.ConcurrentHashMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests off-heap map. */ +@RunWith(JUnit4.class) public abstract class GridOffHeapMapAbstractSelfTest extends GridCommonAbstractTest { /** Random. */ private static final Random RAND = new Random(); @@ -140,6 +144,7 @@ private int hash(int h) { /** * @throws Exception If failed. */ + @Test public void testInsert() throws Exception { map = newMap(); @@ -160,6 +165,7 @@ public void testInsert() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRehash() throws Exception { initCap = 10; @@ -197,6 +203,7 @@ public void testRehash() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { map = newMap(); @@ -217,6 +224,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPut1() throws Exception { map = newMap(); @@ -237,6 +245,7 @@ public void testPut1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPut2() throws Exception { map = newMap(); @@ -265,6 +274,7 @@ public void testPut2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { map = newMap(); @@ -294,6 +304,7 @@ public void testRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemovex() throws Exception { map = newMap(); @@ -322,6 +333,7 @@ public void testRemovex() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIterator() throws Exception { initCap = 10; @@ -394,6 +406,7 @@ public void testIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorMultithreaded() throws Exception { initCap = 10; @@ -468,6 +481,7 @@ public void testIteratorMultithreaded() throws Exception { /** * */ + @Test public void testInsertLoad() { map = newMap(); @@ -502,6 +516,7 @@ public void testInsertLoad() { /** * */ + @Test public void testPutLoad() { map = newMap(); @@ -537,6 +552,7 @@ public void testPutLoad() { /** * */ + @Test public void testLru1() { lruStripes = 1; mem = 10; @@ -579,6 +595,7 @@ public void testLru1() { /** * */ + @Test public void testLru2() { mem = 1000 + 64 * 16; // Add segment size. @@ -616,6 +633,7 @@ public void testLru2() { /** * @throws Exception If failed. */ + @Test public void testLruMultithreaded() throws Exception { mem = 1000 + 64 * 16; // Add segment size. @@ -667,6 +685,7 @@ public void testLruMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorAfterRehash() throws Exception { mem = 0; initCap = 10; @@ -737,6 +756,7 @@ public void testIteratorAfterRehash() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreadedOps() throws Exception { mem = 1512; // Small enough for evictions. @@ -824,4 +844,4 @@ public void testMultithreadedOps() throws Exception { assertEquals(zeroAllocated, map.allocatedSize()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapPerformanceAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapPerformanceAbstractTest.java index f7388e8399fb0..c1bef7185c508 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapPerformanceAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapPerformanceAbstractTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.internal.util.typedef.T3; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests off-heap map. */ +@RunWith(JUnit4.class) public abstract class GridOffHeapMapPerformanceAbstractTest extends GridCommonAbstractTest { /** Random. */ private static final Random RAND = new Random(); @@ -133,6 +137,7 @@ private String string() { /** * Test plain hash map. */ + @Test public void testHashMapPutRemove() { Map map = new HashMap<>(LOAD_CNT); @@ -187,6 +192,7 @@ public void testHashMapPutRemove() { /** * */ + @Test public void testInsertRemoveLoad() { info("Starting insert performance test..."); @@ -240,6 +246,7 @@ public void testInsertRemoveLoad() { /** * */ + @Test public void testPutRemoveLoad() { info("Starting put performance test..."); @@ -288,4 +295,4 @@ public void testPutRemoveLoad() { rmv = cnt % 3 == 0; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMapAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMapAbstractSelfTest.java index 9447970c23635..241c6542b5699 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMapAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMapAbstractSelfTest.java @@ -33,10 +33,14 @@ import org.apache.ignite.internal.util.lang.GridTuple; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests off-heap map. */ +@RunWith(JUnit4.class) public abstract class GridOffHeapPartitionedMapAbstractSelfTest extends GridCommonAbstractTest { /** Random. */ private static final Random RAND = new Random(); @@ -143,6 +147,7 @@ private byte[] bytes(int len) { /** * @throws Exception If failed. */ + @Test public void testInsert() throws Exception { map = newMap(); @@ -165,6 +170,7 @@ public void testInsert() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRehash() throws Exception { initCap = 10; @@ -203,6 +209,7 @@ public void testRehash() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPointerAfterRehash() throws Exception { initCap = 10; @@ -245,7 +252,7 @@ public void testPointerAfterRehash() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("unchecked") + @Test public void testPutRandomKeys() throws Exception { map = newMap(); @@ -275,6 +282,7 @@ public void testPutRandomKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGet() throws Exception { map = newMap(); @@ -297,6 +305,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPut1() throws Exception { map = newMap(); @@ -319,6 +328,7 @@ public void testPut1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPut2() throws Exception { map = newMap(); @@ -349,6 +359,7 @@ public void testPut2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemove() throws Exception { map = newMap(); @@ -380,6 +391,7 @@ public void testRemove() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRemovex() throws Exception { map = newMap(); @@ -410,6 +422,7 @@ public void testRemovex() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIterator() throws Exception { initCap = 10; @@ -483,6 +496,7 @@ public void testIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorMultithreaded() throws Exception { initCap = 10; @@ -580,6 +594,7 @@ public void testIteratorMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIteratorRemoveMultithreaded() throws Exception { initCap = 10; @@ -637,6 +652,7 @@ public void testIteratorRemoveMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionIterator() throws Exception { initCap = 10; @@ -711,6 +727,7 @@ public void testPartitionIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPartitionIteratorMultithreaded() throws Exception { initCap = 10; @@ -786,6 +803,7 @@ public void testPartitionIteratorMultithreaded() throws Exception { /** * */ + @Test public void testInsertLoad() { mem = 0; // Disable LRU. @@ -826,6 +844,7 @@ public void testInsertLoad() { /** * */ + @Test public void testPutLoad() { mem = 0; // Disable LRU. @@ -867,6 +886,7 @@ public void testPutLoad() { /** * */ + @Test public void testLru1() { lruStripes = 1; mem = 10; @@ -911,6 +931,7 @@ public void testLru1() { /** * */ + @Test public void testLru2() { mem = 1000 + 64 * 16 * parts; // Add segment size. @@ -950,6 +971,7 @@ public void testLru2() { /** * @throws Exception If failed. */ + @Test public void testLruMultithreaded() throws Exception { mem = 1000 + 64 * 16 * parts; // Add segment size. @@ -1009,6 +1031,7 @@ public void testLruMultithreaded() throws Exception { * */ @SuppressWarnings("TooBroadScope") + @Test public void testValuePointerEvict() { mem = 90; @@ -1076,6 +1099,7 @@ public void testValuePointerEvict() { * */ @SuppressWarnings("TooBroadScope") + @Test public void testValuePointerEnableEviction() { mem = 90; @@ -1142,6 +1166,7 @@ public void testValuePointerEnableEviction() { /** * */ + @Test public void testValuePointerRemove() { map = newMap(); @@ -1155,4 +1180,4 @@ public void testValuePointerRemove() { assertNull(map.valuePointer(1, k.hashCode(), k.getBytes())); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMapPerformanceAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMapPerformanceAbstractTest.java index 86432fc0d4f36..0a504a64916f4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMapPerformanceAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMapPerformanceAbstractTest.java @@ -29,11 +29,15 @@ import org.apache.ignite.internal.util.typedef.T3; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Performance test for partitioned offheap hash map. */ @SuppressWarnings({"unchecked", "NonThreadSafeLazyInitialization"}) +@RunWith(JUnit4.class) public abstract class GridOffHeapPartitionedMapPerformanceAbstractTest extends GridCommonAbstractTest { /** */ protected static final int LOAD_CNT = 256; @@ -108,6 +112,7 @@ protected GridOffHeapPartitionedMapPerformanceAbstractTest() { /** * @throws Exception If failed. */ + @Test public void testPuts() throws Exception { info("Warming up..."); @@ -121,6 +126,7 @@ public void testPuts() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutsConcurrentMap() throws Exception { info("Warming up..."); @@ -134,6 +140,7 @@ public void testPutsConcurrentMap() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemoves() throws Exception { info("Warming up..."); @@ -147,6 +154,7 @@ public void testPutRemoves() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutRemovesConcurrentMap() throws Exception { info("Warming up..."); @@ -427,4 +435,4 @@ private T3 randomKey(Random rnd) { private GridByteArrayWrapper randomKeyWrapper(Random rnd) { return wrappers[rnd.nextInt(keys.length)]; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemorySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemorySelfTest.java index 47b0684f7ef07..d2be2de0ebe30 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemorySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemorySelfTest.java @@ -23,12 +23,17 @@ import java.util.Collection; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests unsafe memory. */ +@RunWith(JUnit4.class) public class GridUnsafeMemorySelfTest extends GridCommonAbstractTest { /** */ + @Test public void testBuffers() { ByteBuffer b1 = GridUnsafe.allocateBuffer(10); ByteBuffer b2 = GridUnsafe.allocateBuffer(20); @@ -64,6 +69,7 @@ public void testBuffers() { /** * @throws Exception If failed. */ + @Test public void testBytes() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(64); @@ -90,6 +96,7 @@ public void testBytes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByte() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(64); @@ -120,6 +127,7 @@ public void testByte() throws Exception { /** * @throws Exception If failed. */ + @Test public void testShort() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(64); @@ -142,6 +150,7 @@ public void testShort() throws Exception { /** * */ + @Test public void testFloat() { GridUnsafeMemory mem = new GridUnsafeMemory(64); @@ -164,6 +173,7 @@ public void testFloat() { /** * */ + @Test public void testDouble() { GridUnsafeMemory mem = new GridUnsafeMemory(64); @@ -187,6 +197,7 @@ public void testDouble() { /** * @throws Exception If failed. */ + @Test public void testInt() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(64); @@ -223,6 +234,7 @@ public void testInt() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLong() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(64); @@ -258,6 +270,7 @@ public void testLong() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCompare1() throws Exception { checkCompare("123"); } @@ -265,6 +278,7 @@ public void testCompare1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCompare2() throws Exception { checkCompare("1234567890"); } @@ -272,6 +286,7 @@ public void testCompare2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCompare3() throws Exception { checkCompare("12345678901234567890"); } @@ -310,6 +325,7 @@ public void checkCompare(String s) throws Exception { /** * @throws Exception If failed. */ + @Test public void testOutOfMemory() throws Exception { int cap = 64; int block = 9; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeStripedLruSefTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeStripedLruSefTest.java index 76ccceb56915b..57b7778a6e859 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeStripedLruSefTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeStripedLruSefTest.java @@ -21,11 +21,15 @@ import java.util.HashSet; import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Striped LRU test. */ @SuppressWarnings("FieldCanBeLocal") +@RunWith(JUnit4.class) public class GridUnsafeStripedLruSefTest extends GridCommonAbstractTest { /** Number of stripes. */ private short stripes = 1; @@ -65,6 +69,7 @@ private void init() { /** * */ + @Test public void testOffer1() { checkOffer(1000); } @@ -72,6 +77,7 @@ public void testOffer1() { /** * */ + @Test public void testOffer2() { stripes = 11; @@ -95,6 +101,7 @@ private void checkOffer(int cnt) { /** * */ + @Test public void testRemove1() { checkRemove(1000); } @@ -102,6 +109,7 @@ public void testRemove1() { /** * */ + @Test public void testRemove2() { stripes = 35; @@ -130,6 +138,7 @@ private void checkRemove(int cnt) { /** * */ + @Test public void testPoll1() { checkPoll(1000); } @@ -137,6 +146,7 @@ public void testPoll1() { /** * */ + @Test public void testPoll2() { stripes = 20; @@ -180,6 +190,7 @@ private void checkPoll(int cnt) { /** * @throws Exception If failed. */ + @Test public void testLruMultithreaded() throws Exception { checkLruMultithreaded(1000000); } @@ -226,4 +237,4 @@ private void checkLruMultithreaded(final int cnt) throws Exception { assertEquals(0, lru.size()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/CircularStringBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/CircularStringBuilderSelfTest.java index b927863d66c46..c90cec179e94d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/CircularStringBuilderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/CircularStringBuilderSelfTest.java @@ -19,15 +19,20 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class CircularStringBuilderSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCSBPrimitive() throws Exception { CircularStringBuilder csb = new CircularStringBuilder(1); csb.append((String)null); @@ -43,6 +48,7 @@ public void testCSBPrimitive() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCSBOverflow() throws Exception { testSB(3, "1234", 2, "234"); testSB(4, "1234", 2, "1234"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java index d249914ccb3bc..5d897a5306e51 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java @@ -20,35 +20,33 @@ import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.concurrent.CyclicBarrier; import java.util.concurrent.locks.ReadWriteLock; import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteSystemProperties; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl; -import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_TO_STRING_COLLECTION_LIMIT; +import static org.apache.ignite.IgniteSystemProperties.IGNITE_TO_STRING_MAX_LENGTH; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; - -import static org.apache.ignite.IgniteSystemProperties.IGNITE_TO_STRING_COLLECTION_LIMIT; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_TO_STRING_MAX_LENGTH; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link GridToStringBuilder}. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class GridToStringBuilderSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testToString() throws Exception { TestClass1 obj = new TestClass1(); @@ -63,6 +61,7 @@ public void testToString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testToStringWithAdditions() throws Exception { TestClass1 obj = new TestClass1(); @@ -80,6 +79,7 @@ public void testToStringWithAdditions() throws Exception { /** * @throws Exception If failed. */ + @Test public void testToStringCheckSimpleListRecursionPrevention() throws Exception { ArrayList list1 = new ArrayList<>(); ArrayList list2 = new ArrayList<>(); @@ -87,162 +87,31 @@ public void testToStringCheckSimpleListRecursionPrevention() throws Exception { list2.add(list1); list1.add(list2); - info(GridToStringBuilder.toString(ArrayList.class, list1)); - info(GridToStringBuilder.toString(ArrayList.class, list2)); - } - - /** - * @throws Exception If failed. - */ - public void testToStringCheckSimpleMapRecursionPrevention() throws Exception { - HashMap map1 = new HashMap<>(); - HashMap map2 = new HashMap<>(); - - map1.put("2", map2); - map2.put("1", map1); - info(GridToStringBuilder.toString(HashMap.class, map1)); - info(GridToStringBuilder.toString(HashMap.class, map2)); + GridToStringBuilder.toString(ArrayList.class, list1); + GridToStringBuilder.toString(ArrayList.class, list2); } /** * @throws Exception If failed. */ - public void testToStringCheckListAdvancedRecursionPrevention() throws Exception { + @Ignore("https://issues.apache.org/jira/browse/IGNITE-602") + @Test + public void testToStringCheckAdvancedRecursionPrevention() throws Exception { ArrayList list1 = new ArrayList<>(); ArrayList list2 = new ArrayList<>(); list2.add(list1); list1.add(list2); - info(GridToStringBuilder.toString(ArrayList.class, list1, "name", list2)); - info(GridToStringBuilder.toString(ArrayList.class, list2, "name", list1)); - } - - /** - * @throws Exception If failed. - */ - public void testToStringCheckMapAdvancedRecursionPrevention() throws Exception { - HashMap map1 = new HashMap<>(); - HashMap map2 = new HashMap<>(); - - map1.put("2", map2); - map2.put("1", map1); - - info(GridToStringBuilder.toString(HashMap.class, map1, "name", map2)); - info(GridToStringBuilder.toString(HashMap.class, map2, "name", map1)); - } - - /** - * @throws Exception If failed. - */ - public void testToStringCheckObjectRecursionPrevention() throws Exception { - Node n1 = new Node(); - Node n2 = new Node(); - Node n3 = new Node(); - Node n4 = new Node(); - - n1.name = "n1"; - n2.name = "n2"; - n3.name = "n3"; - n4.name = "n4"; - - n1.next = n2; - n2.next = n3; - n3.next = n4; - n4.next = n3; - - n1.nodes = new Node[4]; - n2.nodes = n1.nodes; - n3.nodes = n1.nodes; - n4.nodes = n1.nodes; - - n1.nodes[0] = n1; - n1.nodes[1] = n2; - n1.nodes[2] = n3; - n1.nodes[3] = n4; - - String expN1 = n1.toString(); - String expN2 = n2.toString(); - String expN3 = n3.toString(); - String expN4 = n4.toString(); - - info(expN1); - info(expN2); - info(expN3); - info(expN4); - info(GridToStringBuilder.toString("Test", "Appended vals", n1)); - - CyclicBarrier bar = new CyclicBarrier(4); - - IgniteInternalFuture fut1 = GridTestUtils.runAsync(new BarrierCallable(bar, n1, expN1)); - IgniteInternalFuture fut2 = GridTestUtils.runAsync(new BarrierCallable(bar, n2, expN2)); - IgniteInternalFuture fut3 = GridTestUtils.runAsync(new BarrierCallable(bar, n3, expN3)); - IgniteInternalFuture fut4 = GridTestUtils.runAsync(new BarrierCallable(bar, n4, expN4)); - - fut1.get(3_000); - fut2.get(3_000); - fut3.get(3_000); - fut4.get(3_000); - } - - /** - * Test class. - */ - private static class Node { - /** */ - @GridToStringInclude - String name; - - /** */ - @GridToStringInclude - Node next; - - /** */ - @GridToStringInclude - Node[] nodes; - - /** {@inheritDoc} */ - @Override public String toString() { - return GridToStringBuilder.toString(Node.class, this); - } - } - - /** - * Test class. - */ - private static class BarrierCallable implements Callable { - /** */ - CyclicBarrier bar; - - /** */ - Object obj; - - /** Expected value of {@code toString()} method. */ - String exp; - - /** */ - private BarrierCallable(CyclicBarrier bar, Object obj, String exp) { - this.bar = bar; - this.obj = obj; - this.exp = exp; - } - - /** {@inheritDoc} */ - @Override public String call() throws Exception { - for (int i = 0; i < 10; i++) { - bar.await(); - - assertEquals(exp, obj.toString()); - } - - return null; - } + GridToStringBuilder.toString(ArrayList.class, list1, "name", list2); + GridToStringBuilder.toString(ArrayList.class, list2, "name", list1); } /** * JUnit. */ + @Test public void testToStringPerformance() { TestClass1 obj = new TestClass1(); @@ -277,45 +146,14 @@ private void testArr(V v, int limit) throws Exception { Arrays.fill(arrOf, v); T[] arr = Arrays.copyOf(arrOf, limit); - checkArrayOverflow(arrOf, arr, limit); - } - - /** - * Test array print. - * - * @throws Exception if failed. - */ - public void testArrLimitWithRecursion() throws Exception { - int limit = IgniteSystemProperties.getInteger(IGNITE_TO_STRING_COLLECTION_LIMIT, 100); - - ArrayList[] arrOf = new ArrayList[limit + 1]; - Arrays.fill(arrOf, new ArrayList()); - ArrayList[] arr = Arrays.copyOf(arrOf, limit); - - arrOf[0].add(arrOf); - arr[0].add(arr); - - checkArrayOverflow(arrOf, arr, limit); - } - - /** - * @param arrOf Array. - * @param arr Array copy. - * @param limit Array limit. - */ - private void checkArrayOverflow(Object[] arrOf, Object[] arr, int limit) { - String arrStr = GridToStringBuilder.arrayToString(arr); - String arrOfStr = GridToStringBuilder.arrayToString(arrOf); + String arrStr = GridToStringBuilder.arrayToString(arr.getClass(), arr); + String arrOfStr = GridToStringBuilder.arrayToString(arrOf.getClass(), arrOf); // Simulate overflow StringBuilder resultSB = new StringBuilder(arrStr); resultSB.deleteCharAt(resultSB.length()-1); resultSB.append("... and ").append(arrOf.length - limit).append(" more]"); - - arrStr = resultSB.toString(); - - info(arrOfStr); - info(arrStr); + arrStr = resultSB.toString(); assertTrue("Collection limit error in array of type " + arrOf.getClass().getName() + " error, normal arr: <" + arrStr + ">, overflowed arr: <" + arrOfStr + ">", arrStr.equals(arrOfStr)); @@ -324,6 +162,7 @@ private void checkArrayOverflow(Object[] arrOf, Object[] arr, int limit) { /** * @throws Exception If failed. */ + @Test public void testToStringCollectionLimits() throws Exception { int limit = IgniteSystemProperties.getInteger(IGNITE_TO_STRING_COLLECTION_LIMIT, 100); @@ -332,190 +171,113 @@ public void testToStringCollectionLimits() throws Exception { for (Object val : vals) testArr(val, limit); - int[] intArr1 = new int[0]; - - assertEquals("[]", GridToStringBuilder.arrayToString(intArr1)); - assertEquals("null", GridToStringBuilder.arrayToString(null)); - - int[] intArr2 = {1, 2, 3}; - - assertEquals("[1, 2, 3]", GridToStringBuilder.arrayToString(intArr2)); - - Object[] intArr3 = {2, 3, 4}; - - assertEquals("[2, 3, 4]", GridToStringBuilder.arrayToString(intArr3)); - byte[] byteArr = new byte[1]; - byteArr[0] = 1; - assertEquals(Arrays.toString(byteArr), GridToStringBuilder.arrayToString(byteArr)); + assertEquals(Arrays.toString(byteArr), GridToStringBuilder.arrayToString(byteArr.getClass(), byteArr)); byteArr = Arrays.copyOf(byteArr, 101); assertTrue("Can't find \"... and 1 more\" in overflowed array string!", - GridToStringBuilder.arrayToString(byteArr).contains("... and 1 more")); + GridToStringBuilder.arrayToString(byteArr.getClass(), byteArr).contains("... and 1 more")); boolean[] boolArr = new boolean[1]; - boolArr[0] = true; - assertEquals(Arrays.toString(boolArr), GridToStringBuilder.arrayToString(boolArr)); + assertEquals(Arrays.toString(boolArr), GridToStringBuilder.arrayToString(boolArr.getClass(), boolArr)); boolArr = Arrays.copyOf(boolArr, 101); assertTrue("Can't find \"... and 1 more\" in overflowed array string!", - GridToStringBuilder.arrayToString(boolArr).contains("... and 1 more")); + GridToStringBuilder.arrayToString(boolArr.getClass(), boolArr).contains("... and 1 more")); short[] shortArr = new short[1]; - shortArr[0] = 100; - assertEquals(Arrays.toString(shortArr), GridToStringBuilder.arrayToString(shortArr)); + assertEquals(Arrays.toString(shortArr), GridToStringBuilder.arrayToString(shortArr.getClass(), shortArr)); shortArr = Arrays.copyOf(shortArr, 101); assertTrue("Can't find \"... and 1 more\" in overflowed array string!", - GridToStringBuilder.arrayToString(shortArr).contains("... and 1 more")); + GridToStringBuilder.arrayToString(shortArr.getClass(), shortArr).contains("... and 1 more")); int[] intArr = new int[1]; - intArr[0] = 10000; - assertEquals(Arrays.toString(intArr), GridToStringBuilder.arrayToString(intArr)); + assertEquals(Arrays.toString(intArr), GridToStringBuilder.arrayToString(intArr.getClass(), intArr)); intArr = Arrays.copyOf(intArr, 101); assertTrue("Can't find \"... and 1 more\" in overflowed array string!", - GridToStringBuilder.arrayToString(intArr).contains("... and 1 more")); + GridToStringBuilder.arrayToString(intArr.getClass(), intArr).contains("... and 1 more")); long[] longArr = new long[1]; - longArr[0] = 10000000; - assertEquals(Arrays.toString(longArr), GridToStringBuilder.arrayToString(longArr)); + assertEquals(Arrays.toString(longArr), GridToStringBuilder.arrayToString(longArr.getClass(), longArr)); longArr = Arrays.copyOf(longArr, 101); assertTrue("Can't find \"... and 1 more\" in overflowed array string!", - GridToStringBuilder.arrayToString(longArr).contains("... and 1 more")); + GridToStringBuilder.arrayToString(longArr.getClass(), longArr).contains("... and 1 more")); float[] floatArr = new float[1]; - floatArr[0] = 1.f; - assertEquals(Arrays.toString(floatArr), GridToStringBuilder.arrayToString(floatArr)); + assertEquals(Arrays.toString(floatArr), GridToStringBuilder.arrayToString(floatArr.getClass(), floatArr)); floatArr = Arrays.copyOf(floatArr, 101); assertTrue("Can't find \"... and 1 more\" in overflowed array string!", - GridToStringBuilder.arrayToString(floatArr).contains("... and 1 more")); + GridToStringBuilder.arrayToString(floatArr.getClass(), floatArr).contains("... and 1 more")); double[] doubleArr = new double[1]; - doubleArr[0] = 1.; - assertEquals(Arrays.toString(doubleArr), GridToStringBuilder.arrayToString(doubleArr)); + assertEquals(Arrays.toString(doubleArr), GridToStringBuilder.arrayToString(doubleArr.getClass(), doubleArr)); doubleArr = Arrays.copyOf(doubleArr, 101); assertTrue("Can't find \"... and 1 more\" in overflowed array string!", - GridToStringBuilder.arrayToString(doubleArr).contains("... and 1 more")); + GridToStringBuilder.arrayToString(doubleArr.getClass(), doubleArr).contains("... and 1 more")); - char[] cArr = new char[1]; - - cArr[0] = 'a'; - assertEquals(Arrays.toString(cArr), GridToStringBuilder.arrayToString(cArr)); - cArr = Arrays.copyOf(cArr, 101); + char[] charArr = new char[1]; + charArr[0] = 'a'; + assertEquals(Arrays.toString(charArr), GridToStringBuilder.arrayToString(charArr.getClass(), charArr)); + charArr = Arrays.copyOf(charArr, 101); assertTrue("Can't find \"... and 1 more\" in overflowed array string!", - GridToStringBuilder.arrayToString(cArr).contains("... and 1 more")); + GridToStringBuilder.arrayToString(charArr.getClass(), charArr).contains("... and 1 more")); Map strMap = new TreeMap<>(); List strList = new ArrayList<>(limit+1); - TestClass1 testCls = new TestClass1(); - - testCls.strMap = strMap; - testCls.strListIncl = strList; - - for (int i = 0; i < limit; i++) { - strMap.put("k" + i, "v"); - strList.add("e"); - } - - checkColAndMap(testCls); - } - - /** - * @throws Exception If failed. - */ - public void testToStringColAndMapLimitWithRecursion() throws Exception { - int limit = IgniteSystemProperties.getInteger(IGNITE_TO_STRING_COLLECTION_LIMIT, 100); - Map strMap = new TreeMap<>(); - List strList = new ArrayList<>(limit+1); - TestClass1 testClass = new TestClass1(); testClass.strMap = strMap; testClass.strListIncl = strList; - Map m = new TreeMap(); - m.put("m", strMap); - - List l = new ArrayList(); - l.add(strList); - - strMap.put("k0", m); - strList.add(l); - - for (int i = 1; i < limit; i++) { + for (int i = 0; i < limit; i++) { strMap.put("k" + i, "v"); strList.add("e"); } + String testClassStr = GridToStringBuilder.toString(TestClass1.class, testClass); - checkColAndMap(testClass); - } - - /** - * @param testCls Class with collection and map included in toString(). - */ - private void checkColAndMap(TestClass1 testCls) { - String testClsStr = GridToStringBuilder.toString(TestClass1.class, testCls); + strMap.put("kz", "v"); // important to add last element in TreeMap here + strList.add("e"); - testCls.strMap.put("kz", "v"); // important to add last element in TreeMap here - testCls.strListIncl.add("e"); + String testClassStrOf = GridToStringBuilder.toString(TestClass1.class, testClass); - String testClsStrOf = GridToStringBuilder.toString(TestClass1.class, testCls); + String testClassStrOfR = testClassStrOf.replaceAll("... and 1 more",""); - String testClsStrOfR = testClsStrOf.replaceAll("... and 1 more",""); + assertTrue("Collection limit error in Map or List, normal: <" + testClassStr + ">, overflowed: <" + +"testClassStrOf", testClassStr.length() == testClassStrOfR.length()); - info(testClsStr); - info(testClsStrOf); - info(testClsStrOfR); - - assertTrue("Collection limit error in Map or List, normal: <" + testClsStr + ">, overflowed: <" - + testClsStrOf + ">", testClsStr.length() == testClsStrOfR.length()); } /** * @throws Exception If failed. */ + @Test public void testToStringSizeLimits() throws Exception { int limit = IgniteSystemProperties.getInteger(IGNITE_TO_STRING_MAX_LENGTH, 10_000); int tailLen = limit / 10 * 2; - StringBuilder sb = new StringBuilder(limit + 10); - - for (int i = 0; i < limit - 100; i++) + for (int i = 0; i < limit - 100; i++) { sb.append('a'); - + } String actual = GridToStringBuilder.toString(TestClass2.class, new TestClass2(sb.toString())); - String exp = "TestClass2 [str=" + sb + ", nullArr=null]"; - - assertEquals(exp, actual); + String expected = "TestClass2 [str=" + sb.toString() + ", nullArr=null]"; + assertEquals(expected, actual); - for (int i = 0; i < 110; i++) + for (int i = 0; i < 110; i++) { sb.append('b'); - + } actual = GridToStringBuilder.toString(TestClass2.class, new TestClass2(sb.toString())); - exp = "TestClass2 [str=" + sb + ", nullArr=null]"; - - assertEquals(exp.substring(0, limit - tailLen), actual.substring(0, limit - tailLen)); - assertEquals(exp.substring(exp.length() - tailLen), actual.substring(actual.length() - tailLen)); - + expected = "TestClass2 [str=" + sb.toString() + ", nullArr=null]"; + assertEquals(expected.substring(0, limit - tailLen), actual.substring(0, limit - tailLen)); + assertEquals(expected.substring(expected.length() - tailLen), actual.substring(actual.length() - tailLen)); assertTrue(actual.contains("... and")); assertTrue(actual.contains("skipped ...")); } - /** - * - */ - public void testObjectPlusStringToString() { - IgniteTxKey k = new IgniteTxKey(new KeyCacheObjectImpl(1, null, 1), 123); - - info(k.toString()); - - assertTrue("Wrong string: " + k, k.toString().startsWith("IgniteTxKey [")); - } - /** * Test class. */ @@ -647,7 +409,7 @@ private static class TestClass2{ /** * @param str String. */ - TestClass2(String str) { + public TestClass2(String str) { this.str = str; } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveAbstractTest.java index 3907e85400ad8..adacd772fba20 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveAbstractTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.SensitiveInfoTestLoggerProxy; import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for property {@link IgniteSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE}. */ +@RunWith(JUnit4.class) public abstract class IncludeSensitiveAbstractTest extends GridCacheAbstractSelfTest { /** Number of test entries */ private static final int ENTRY_CNT = 10; @@ -96,6 +100,7 @@ protected void commitTx() { * * @throws Exception If failed. */ + @Test public void test() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); diff --git a/modules/core/src/test/java/org/apache/ignite/jvmtest/FileIOTest.java b/modules/core/src/test/java/org/apache/ignite/jvmtest/FileIOTest.java index eb1f8d5c487ef..0d048023e5df2 100644 --- a/modules/core/src/test/java/org/apache/ignite/jvmtest/FileIOTest.java +++ b/modules/core/src/test/java/org/apache/ignite/jvmtest/FileIOTest.java @@ -21,14 +21,14 @@ import java.io.RandomAccessFile; import java.util.Arrays; import java.util.UUID; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; /** * Java file IO test. */ -public class FileIOTest extends TestCase { +public class FileIOTest { /** File path. */ private static final String FILE_PATH = "/test-java-file.tmp"; @@ -38,6 +38,7 @@ public class FileIOTest extends TestCase { /** * @throws Exception If failed. */ + @Test public void testReadLineFromBinaryFile() throws Exception { File file = new File(FILE_PATH); @@ -79,6 +80,7 @@ public void testReadLineFromBinaryFile() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleFilesCreation() throws Exception { File parent = new File(TMP_DIR, "testMultipleFilesCreation"); @@ -127,6 +129,7 @@ public void testMultipleFilesCreation() throws Exception { /** * */ + @Test public void testGetAbsolutePath() { for (int i = 0; i < 1000000; i++) { new File("/" + UUID.randomUUID().toString()).getAbsolutePath(); @@ -136,4 +139,4 @@ public void testGetAbsolutePath() { new File("/Users").getAbsolutePath(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/jvmtest/FileLocksTest.java b/modules/core/src/test/java/org/apache/ignite/jvmtest/FileLocksTest.java index b376f0bae009a..b70e19868e9da 100644 --- a/modules/core/src/test/java/org/apache/ignite/jvmtest/FileLocksTest.java +++ b/modules/core/src/test/java/org/apache/ignite/jvmtest/FileLocksTest.java @@ -21,18 +21,19 @@ import java.io.RandomAccessFile; import java.nio.channels.FileLock; import javax.swing.JOptionPane; -import junit.framework.TestCase; +import org.junit.Test; /** * Java file locks test. */ -public class FileLocksTest extends TestCase { +public class FileLocksTest { /** File path (on Windows file will be created under the root directory of the current drive). */ private static final String LOCK_FILE_PATH = "/test-java-file-lock-tmp.bin"; /** * @throws Exception If failed. */ + @Test public void testWriteLocks() throws Exception { final File file = new File(LOCK_FILE_PATH); @@ -77,6 +78,7 @@ public void testWriteLocks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadLocks() throws Exception { final File file = new File(LOCK_FILE_PATH); @@ -118,4 +120,4 @@ public void testReadLocks() throws Exception { thread.join(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/jvmtest/LinkedHashMapTest.java b/modules/core/src/test/java/org/apache/ignite/jvmtest/LinkedHashMapTest.java index 536784e341def..f4fd673be1130 100644 --- a/modules/core/src/test/java/org/apache/ignite/jvmtest/LinkedHashMapTest.java +++ b/modules/core/src/test/java/org/apache/ignite/jvmtest/LinkedHashMapTest.java @@ -19,14 +19,15 @@ import java.util.LinkedHashMap; import java.util.Map; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.X; +import org.junit.Test; /** * Test for {@link LinkedHashMap}. */ -public class LinkedHashMapTest extends TestCase { +public class LinkedHashMapTest { /** @throws Exception If failed. */ + @Test public void testAccessOrder1() throws Exception { X.println(">>> testAccessOrder1 <<<"); @@ -52,6 +53,7 @@ public void testAccessOrder1() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAccessOrder2() throws Exception { X.println(">>> testAccessOrder2 <<<"); @@ -69,6 +71,7 @@ public void testAccessOrder2() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAccessOrder3() throws Exception { X.println(">>> testAccessOrder3 <<<"); @@ -84,4 +87,4 @@ public void testAccessOrder3() throws Exception { X.println("State after get: " + map); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/jvmtest/NetworkFailureTest.java b/modules/core/src/test/java/org/apache/ignite/jvmtest/NetworkFailureTest.java index c331ce97e781d..3a5e4da39c29f 100644 --- a/modules/core/src/test/java/org/apache/ignite/jvmtest/NetworkFailureTest.java +++ b/modules/core/src/test/java/org/apache/ignite/jvmtest/NetworkFailureTest.java @@ -26,20 +26,21 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import javax.swing.JOptionPane; -import junit.framework.TestCase; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; /** * */ -public class NetworkFailureTest extends TestCase { +public class NetworkFailureTest { /** * @throws Exception If failed. */ + @Test public void testNetworkFailure() throws Exception { final AtomicBoolean done = new AtomicBoolean(); @@ -141,6 +142,7 @@ public void testNetworkFailure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadTimeout() throws Exception { final InetAddress addr = InetAddress.getByName("192.168.3.10"); @@ -223,6 +225,7 @@ public void testReadTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSocketCloseOnTimeout() throws Exception { final AtomicBoolean done = new AtomicBoolean(); @@ -323,6 +326,7 @@ public void testSocketCloseOnTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionTime() throws Exception { X.println("Unexistent host."); checkConnection(InetAddress.getByName("192.168.0.222")); @@ -370,4 +374,4 @@ private Socket openSocket(InetAddress addr, int port) throws IOException { return sock; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/jvmtest/QueueSizeCounterMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/jvmtest/QueueSizeCounterMultiThreadedTest.java index bf3557f9e0f67..3349e804cccd0 100644 --- a/modules/core/src/test/java/org/apache/ignite/jvmtest/QueueSizeCounterMultiThreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/jvmtest/QueueSizeCounterMultiThreadedTest.java @@ -23,20 +23,20 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import junit.framework.TestCase; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; /** * Test to check strange assertion in eviction manager. */ -public class QueueSizeCounterMultiThreadedTest extends TestCase { +public class QueueSizeCounterMultiThreadedTest { /** * @throws Exception If failed. */ - @SuppressWarnings({"LockAcquiredButNotSafelyReleased"}) + @Test public void testQueueSizeCounter() throws Exception { final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); @@ -50,7 +50,6 @@ public void testQueueSizeCounter() throws Exception { IgniteInternalFuture fut1 = GridTestUtils.runMultiThreadedAsync( new Callable() { - @SuppressWarnings( {"BusyWait"}) @Nullable @Override public Object call() throws Exception { int cleanUps = 0; @@ -101,4 +100,4 @@ public void testQueueSizeCounter() throws Exception { fut1.get(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/jvmtest/ReadWriteLockMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/jvmtest/ReadWriteLockMultiThreadedTest.java index 666a5a1941561..d57dcc860dff5 100644 --- a/modules/core/src/test/java/org/apache/ignite/jvmtest/ReadWriteLockMultiThreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/jvmtest/ReadWriteLockMultiThreadedTest.java @@ -20,20 +20,21 @@ import java.util.concurrent.Callable; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import junit.framework.TestCase; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; /** * JDK read write lock test. */ -public class ReadWriteLockMultiThreadedTest extends TestCase { +public class ReadWriteLockMultiThreadedTest { /** * @throws Exception If failed. */ @SuppressWarnings({"LockAcquiredButNotSafelyReleased"}) + @Test public void testReadThenWriteLockAcquire() throws Exception { ReadWriteLock lock = new ReentrantReadWriteLock(); @@ -45,6 +46,7 @@ public void testReadThenWriteLockAcquire() throws Exception { /** * */ + @Test public void testNotOwnedLockRelease() { ReadWriteLock lock = new ReentrantReadWriteLock(); @@ -55,6 +57,7 @@ public void testNotOwnedLockRelease() { * @throws Exception If failed. */ @SuppressWarnings({"LockAcquiredButNotSafelyReleased"}) + @Test public void testWriteLockAcquire() throws Exception { final ReadWriteLock lock = new ReentrantReadWriteLock(); @@ -124,6 +127,7 @@ public void testWriteLockAcquire() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"LockAcquiredButNotSafelyReleased"}) + @Test public void testReadLockAcquire() throws Exception { final ReadWriteLock lock = new ReentrantReadWriteLock(); @@ -169,6 +173,7 @@ public void testReadLockAcquire() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"LockAcquiredButNotSafelyReleased"}) + @Test public void testTryWriteLock() throws Exception { final ReadWriteLock lock = new ReentrantReadWriteLock(); @@ -204,4 +209,4 @@ public void testTryWriteLock() throws Exception { fut.get(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/jvmtest/RegExpTest.java b/modules/core/src/test/java/org/apache/ignite/jvmtest/RegExpTest.java index 9b8c4bd11949f..6add401663bc0 100644 --- a/modules/core/src/test/java/org/apache/ignite/jvmtest/RegExpTest.java +++ b/modules/core/src/test/java/org/apache/ignite/jvmtest/RegExpTest.java @@ -19,17 +19,18 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; /** * Java reg exp test. */ -public class RegExpTest extends TestCase { +public class RegExpTest { /** * @throws Exception If failed. */ + @Test public void testRegExp() throws Exception { String normal = "swap-spaces/space1/b53b3a3d6ab90ce0268229151c9bde11|b53b3a3d6ab90ce0268229151c9bde11|1315392441288"; @@ -53,4 +54,4 @@ public void testRegExp() throws Exception { assert normal.matches(ptrn); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/jvmtest/ServerSocketMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/jvmtest/ServerSocketMultiThreadedTest.java index f6fe7dbb49d1b..e677ea7f8d15b 100644 --- a/modules/core/src/test/java/org/apache/ignite/jvmtest/ServerSocketMultiThreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/jvmtest/ServerSocketMultiThreadedTest.java @@ -24,11 +24,11 @@ import java.util.concurrent.Callable; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.atomic.AtomicInteger; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; /** * Java server socket test. @@ -37,7 +37,7 @@ * BindException or SocketException may be thrown. Purpose of this test is * to find some explanation to that. */ -public class ServerSocketMultiThreadedTest extends TestCase { +public class ServerSocketMultiThreadedTest { /** */ private static final int THREADS_CNT = 10; @@ -47,6 +47,7 @@ public class ServerSocketMultiThreadedTest extends TestCase { /** * @throws Exception If failed. */ + @Test public void testConcurrentBind() throws Exception { final AtomicInteger bindExCnt = new AtomicInteger(); final AtomicInteger sockExCnt = new AtomicInteger(); @@ -100,4 +101,4 @@ public void testConcurrentBind() throws Exception { X.println("Test stats [bindExCnt=" + bindExCnt.get() + ", sockExCnt=" + sockExCnt.get() + ", okCnt=" + okCnt + ']'); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridByteArrayListSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridByteArrayListSelfTest.java index aad28ea828a58..f99277ce845cf 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/GridByteArrayListSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/GridByteArrayListSelfTest.java @@ -25,15 +25,20 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridByteArrayListSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testCapacity() { int cap = 10; @@ -64,6 +69,7 @@ public void testCapacity() { /** * */ + @Test public void testAddSetByte() { GridByteArrayList list = new GridByteArrayList(10); @@ -83,6 +89,7 @@ public void testAddSetByte() { /** * */ + @Test public void testAddSetInteger() { GridByteArrayList list = new GridByteArrayList(10); @@ -118,6 +125,7 @@ public void testAddSetInteger() { /** * */ + @Test public void testAddByteArray() { GridByteArrayList list = new GridByteArrayList(3); @@ -140,6 +148,7 @@ public void testAddByteArray() { /** * */ + @Test public void testAddByteBuffer() { GridByteArrayList list = new GridByteArrayList(3); @@ -167,6 +176,7 @@ public void testAddByteBuffer() { * */ @SuppressWarnings({"ErrorNotRethrown"}) + @Test public void testBounds() { GridByteArrayList list = new GridByteArrayList(3); @@ -201,6 +211,7 @@ public void testBounds() { /** * @throws Exception If failed. */ + @Test public void testRead() throws Exception { GridByteArrayList list = new GridByteArrayList(10); @@ -212,4 +223,4 @@ public void testRead() throws Exception { assert Arrays.equals(list.array(), arr); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java index 5afd75f680baa..9122c8e72bd1c 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/GridFuncPerformanceTest.java @@ -23,11 +23,15 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * GridFunc performance test. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridFuncPerformanceTest extends GridCommonAbstractTest { /** * Creates test. @@ -39,6 +43,7 @@ public GridFuncPerformanceTest() { /** * */ + @Test public void testTransformingIteratorPerformance() { // Warmup. testBody(); @@ -99,4 +104,4 @@ private long testBody() { return duration; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterLoadTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterLoadTest.java index f411f31a37dab..bc4c55e86a1a5 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterLoadTest.java @@ -22,11 +22,15 @@ import org.apache.ignite.internal.processors.cache.eviction.GridCacheMockEntry; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Check how much memory and time required to fill 1_000_000 entries with meta. * Do not include this test to suits. */ +@RunWith(JUnit4.class) public class GridMetadataAwareAdapterLoadTest extends GridCommonAbstractTest { /** Creates test. */ public GridMetadataAwareAdapterLoadTest() { @@ -40,6 +44,7 @@ public GridMetadataAwareAdapterLoadTest() { * * @throws Exception */ + @Test public void test() throws Exception { String[] dic = new String[1_000_000]; diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterSelfTest.java index f202fa97c8542..b38be9817e30a 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/GridMetadataAwareAdapterSelfTest.java @@ -21,11 +21,15 @@ import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridMetadataAwareAdapterSelfTest extends GridCommonAbstractTest { /** Creates test. */ public GridMetadataAwareAdapterSelfTest() { @@ -36,6 +40,7 @@ public GridMetadataAwareAdapterSelfTest() { * Junit. */ @SuppressWarnings({"AssertWithSideEffects"}) + @Test public void test() { GridMetadataAwareAdapter ma = new GridMetadataAwareAdapter(); diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridSetWrapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridSetWrapperSelfTest.java index 7cddf27c056b5..be662dae6bb1b 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/GridSetWrapperSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/GridSetWrapperSelfTest.java @@ -27,19 +27,25 @@ import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Set wrapper test. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridSetWrapperSelfTest extends GridCommonAbstractTest { /** @throws Exception If failed. */ + @Test public void testEmptySet() throws Exception { checkCollectionEmptiness(new GridSetWrapper<>(new HashMap())); } /** @throws Exception If failed. */ + @Test public void testMultipleValuesSet() throws Exception { Set set = new GridSetWrapper<>(new HashMap()); @@ -76,6 +82,7 @@ public void testMultipleValuesSet() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetRemove() throws Exception { Collection set = new GridSetWrapper<>(new HashMap()); @@ -117,6 +124,7 @@ public void testSetRemove() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetRemoveAll() throws Exception { Collection set = new GridSetWrapper<>(new HashMap()); @@ -138,6 +146,7 @@ public void testSetRemoveAll() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetClear() throws Exception { Collection set = new GridSetWrapper<>(new HashMap()); @@ -156,6 +165,7 @@ public void testSetClear() throws Exception { } /** @throws Exception If failed. */ + @Test public void testIterator() throws Exception { Set set = new GridSetWrapper<>(new HashMap()); @@ -227,4 +237,4 @@ private void checkCollectionEmptiness(Collection c) throws Exception { info("Caught expected exception: " + e); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridTupleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridTupleSelfTest.java index 77be70c229cea..ae67a4db9f01d 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/GridTupleSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/GridTupleSelfTest.java @@ -27,11 +27,15 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridTupleSelfTest extends GridCommonAbstractTest { /** Creates test. */ public GridTupleSelfTest() { @@ -41,6 +45,7 @@ public GridTupleSelfTest() { /** * JUnit. */ + @Test public void testGridTupleAsIterable() { String str = "A test string"; @@ -71,6 +76,7 @@ public void testGridTupleAsIterable() { /** * JUnit. */ + @Test public void testGridTuple2AsIterable() { String str1 = "A test string 1"; String str2 = "A test string 2"; @@ -103,6 +109,7 @@ public void testGridTuple2AsIterable() { /** * JUnit. */ + @Test public void testGridTuple2AsMap() { String str1 = "A test string 1"; String str2 = "A test string 2"; @@ -141,6 +148,7 @@ public void testGridTuple2AsMap() { /** * JUnit. */ + @Test public void testGridTuple3AsIterable() { String str1 = "A test string 1"; String str2 = "A test string 2"; diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridXSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridXSelfTest.java index 8fd6df638668d..952f0b325c806 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/GridXSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/GridXSelfTest.java @@ -24,15 +24,20 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link X}. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridXSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testHasCause() { ConnectException conEx = new ConnectException(); @@ -55,6 +60,7 @@ public void testHasCause() { /** * Tests string presentation of given time. */ + @Test public void testTimeSpan() { assertEquals(X.timeSpan2DHMSM(86400001L), "1 day, 00:00:00.001"); @@ -68,6 +74,7 @@ public void testTimeSpan() { /** * */ + @Test public void testShallowClone() { // Single not cloneable object Object obj = new Object(); @@ -117,6 +124,7 @@ public void testShallowClone() { * */ @SuppressWarnings({"StringEquality"}) + @Test public void testDeepCloner() { // Single not cloneable object Object obj = new Object(); @@ -272,4 +280,4 @@ private static class TestCycledChild extends TestCycled { @SuppressWarnings({"unused"}) private final TestCycled anotherCycle = this; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/IgniteUuidSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/IgniteUuidSelfTest.java index a3d82cbeb88cd..4091e1b679cfb 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/IgniteUuidSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/IgniteUuidSelfTest.java @@ -30,11 +30,15 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link org.apache.ignite.lang.IgniteUuid}. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class IgniteUuidSelfTest extends GridCommonAbstractTest { /** Sample size. */ private static final int NUM = 100000; @@ -42,6 +46,7 @@ public class IgniteUuidSelfTest extends GridCommonAbstractTest { /** * JUnit. */ + @Test public void testToString() { IgniteUuid id1 = IgniteUuid.randomUuid(); @@ -73,6 +78,7 @@ public void testToString() { /** * JUnit. */ + @Test public void testGridUuid() { IgniteUuid id1 = IgniteUuid.randomUuid(); IgniteUuid id2 = IgniteUuid.randomUuid(); @@ -95,6 +101,7 @@ public void testGridUuid() { /** * JUnit. */ + @Test public void testGridUuidPerformance() { long start = System.currentTimeMillis(); @@ -121,6 +128,7 @@ public void testGridUuidPerformance() { * * @throws Exception If failed. */ + @Test public void testSerializationPerformance() throws Exception { UuidBean[] uids = new UuidBean[NUM]; @@ -330,4 +338,4 @@ private UuidBean(UUID uid) { /** {@inheritDoc} */ @Override public String toString() { return S.toString(UuidBean.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedConcurrentLinkedHashMapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedConcurrentLinkedHashMapSelfTest.java index 8ce7ae37038f9..acfd481408a55 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedConcurrentLinkedHashMapSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedConcurrentLinkedHashMapSelfTest.java @@ -21,10 +21,14 @@ import java.util.Map; import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link GridBoundedConcurrentLinkedHashMap}. */ +@RunWith(JUnit4.class) public class GridBoundedConcurrentLinkedHashMapSelfTest extends GridCommonAbstractTest { /** Bound. */ private static final int MAX = 3; @@ -32,6 +36,7 @@ public class GridBoundedConcurrentLinkedHashMapSelfTest extends GridCommonAbstra /** * @throws Exception If failed. */ + @Test public void testBound() throws Exception { Map map = new GridBoundedConcurrentLinkedHashMap<>(MAX); diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedConcurrentOrderedMapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedConcurrentOrderedMapSelfTest.java index 05ba4959caf4e..2c33ccf9f9a19 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedConcurrentOrderedMapSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedConcurrentOrderedMapSelfTest.java @@ -23,15 +23,20 @@ import org.apache.ignite.internal.util.typedef.CI2; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link GridBoundedConcurrentOrderedMap}. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridBoundedConcurrentOrderedMapSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testEvictionSingleElement() { SortedMap m = new GridBoundedConcurrentOrderedMap<>(1); @@ -52,6 +57,7 @@ public void testEvictionSingleElement() { /** * */ + @Test public void testEvictionListener() { GridBoundedConcurrentOrderedMap m = new GridBoundedConcurrentOrderedMap<>(1); @@ -78,4 +84,4 @@ public void testEvictionListener() { assertEquals(10, m.lastKey().intValue()); assertEquals(10, evicted.get()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedPriorityQueueSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedPriorityQueueSelfTest.java index bcaecc4adcd10..489a14fdd94a7 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedPriorityQueueSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridBoundedPriorityQueueSelfTest.java @@ -26,11 +26,15 @@ import org.apache.ignite.internal.util.GridBoundedPriorityQueue; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link GridBoundedPriorityQueue}. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridBoundedPriorityQueueSelfTest extends GridCommonAbstractTest { /** Queue items comparator. */ private static final Comparator CMP = new Comparator() { @@ -45,6 +49,7 @@ public class GridBoundedPriorityQueueSelfTest extends GridCommonAbstractTest { /** * Test eviction in bounded priority queue. */ + @Test public void testEviction() { GridBoundedPriorityQueue queue = new GridBoundedPriorityQueue<>(3, CMP); diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridCircularBufferPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridCircularBufferPerformanceTest.java index c0fc4864472b9..7e510d5397c76 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridCircularBufferPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridCircularBufferPerformanceTest.java @@ -27,14 +27,19 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.util.deque.FastSizeDeque; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCircularBufferPerformanceTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testThroughput() throws Exception { int size = 256 * 1024; @@ -74,6 +79,7 @@ public void testThroughput() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDequeueThroughput() throws Exception { final FastSizeDeque buf = new FastSizeDeque<>(new ConcurrentLinkedDeque<>()); @@ -117,6 +123,7 @@ public void testDequeueThroughput() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArrayBlockingQueueThroughput() throws Exception { final int size = 256 * 1024; @@ -158,6 +165,7 @@ public void testArrayBlockingQueueThroughput() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAdderThroughput() throws Exception { final int size = 256 * 1024; @@ -194,6 +202,7 @@ public void testAdderThroughput() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicLongThroughput() throws Exception { final int size = 256 * 1024; @@ -226,4 +235,4 @@ public void testAtomicLongThroughput() throws Exception { info("Buffer: " + buf); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridCircularBufferSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridCircularBufferSelfTest.java index 50d351b30cd28..93e98481b3bee 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridCircularBufferSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridCircularBufferSelfTest.java @@ -23,14 +23,19 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.internal.util.GridCircularBuffer; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridCircularBufferSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testCreation() { try { GridCircularBuffer buf = new GridCircularBuffer<>(-2); @@ -73,6 +78,7 @@ public void testCreation() { /** * @throws Exception If failed. */ + @Test public void testSingleThreaded() throws Exception { int size = 8; int iterCnt = size * 10; @@ -107,6 +113,7 @@ public void testSingleThreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMutliThreaded() throws Exception { int size = 32 * 1024; @@ -135,6 +142,7 @@ public void testMutliThreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMutliThreaded2() throws Exception { int size = 256 * 1024; @@ -173,4 +181,4 @@ public void testMutliThreaded2() throws Exception { info("Buffer: " + buf); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentLinkedHashMapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentLinkedHashMapSelfTest.java index 7bcbd07b3becf..98524dcdf832f 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentLinkedHashMapSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentLinkedHashMapSelfTest.java @@ -27,6 +27,9 @@ import java.util.concurrent.ThreadLocalRandom; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jsr166.ConcurrentLinkedHashMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.jsr166.ConcurrentLinkedHashMap.QueuePolicy.PER_SEGMENT_Q; import static org.jsr166.ConcurrentLinkedHashMap.QueuePolicy.PER_SEGMENT_Q_OPTIMIZED_RMV; @@ -34,6 +37,7 @@ /** * This class tests basic contracts of {@code ConcurrentLinkedHashMap}. */ +@RunWith(JUnit4.class) public class GridConcurrentLinkedHashMapSelfTest extends GridCommonAbstractTest { /** */ private static final int KEYS_UPPER_BOUND = 1000; @@ -47,6 +51,7 @@ public class GridConcurrentLinkedHashMapSelfTest extends GridCommonAbstractTest /** * */ + @Test public void testInsertionOrder() { testOrder(false); } @@ -54,6 +59,7 @@ public void testInsertionOrder() { /** * */ + @Test public void testInsertionOrderWithUpdate() { testOrder(true); } @@ -61,6 +67,7 @@ public void testInsertionOrderWithUpdate() { /** * */ + @Test public void testEvictionInsert() { final int mapSize = 1000; @@ -159,6 +166,7 @@ private void testOrder(boolean update) { * Tests iterator when concurrent modifications remove and add the same keys to the map. * */ + @Test public void testIteratorDuplicates() { Map tst = new ConcurrentLinkedHashMap<>(); @@ -187,6 +195,7 @@ public void testIteratorDuplicates() { /** * @throws Exception If failed. */ + @Test public void testRehash() throws Exception { Map map = new ConcurrentLinkedHashMap<>(10); @@ -204,6 +213,7 @@ public void testRehash() throws Exception { /** * */ + @Test public void testDescendingMethods() { ConcurrentLinkedHashMap tst = new ConcurrentLinkedHashMap<>(); @@ -273,6 +283,7 @@ public void testDescendingMethods() { /** * */ + @Test public void testIterationInPerSegmentModes() { checkIteration(PER_SEGMENT_Q); checkIteration(PER_SEGMENT_Q_OPTIMIZED_RMV); diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentWeakHashSetSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentWeakHashSetSelfTest.java index 9a6d3caa5da4b..cc40347b9e01d 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentWeakHashSetSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConcurrentWeakHashSetSelfTest.java @@ -28,11 +28,15 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link GridConcurrentWeakHashSet}. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridConcurrentWeakHashSetSelfTest extends GridCommonAbstractTest { /** Time to wait after {@link System#gc} method call. */ private static final long WAIT_TIME = 3000; @@ -43,6 +47,7 @@ public class GridConcurrentWeakHashSetSelfTest extends GridCommonAbstractTest { /** * @throws Exception Thrown if test failed. */ + @Test public void testA() throws Exception { Collection set = new GridConcurrentWeakHashSet<>(); @@ -129,6 +134,7 @@ public void testA() throws Exception { * @throws Exception Thrown if test failed. */ @SuppressWarnings({"UnusedAssignment"}) + @Test public void testB() throws Exception { Collection set = new GridConcurrentWeakHashSet<>(); @@ -198,6 +204,7 @@ public void testB() throws Exception { /** * @throws Exception Thrown if test failed. */ + @Test public void testC() throws Exception { final Collection set = new GridConcurrentWeakHashSet<>(); @@ -243,6 +250,7 @@ public void testC() throws Exception { /** * @throws Exception Thrown if test failed. */ + @Test public void testD() throws Exception { final Collection set = new GridConcurrentWeakHashSet<>(); @@ -396,4 +404,4 @@ private SampleBean(int num) { return S.toString(SampleBean.class, this); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConsistentHashSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConsistentHashSelfTest.java index 98d7b988acae9..765b34921d915 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConsistentHashSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridConsistentHashSelfTest.java @@ -32,12 +32,16 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Consistent hash test. */ @SuppressWarnings({"AssertWithSideEffects"}) @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridConsistentHashSelfTest extends GridCommonAbstractTest { /** */ private static final int NODES = 20; @@ -103,6 +107,7 @@ private void clean(GridConsistentHash hash) { * * @throws Exception In case of any exception. */ + @Test public void testCollisions() throws Exception { Map> map = new HashMap<>(); @@ -154,6 +159,7 @@ public void testCollisions() throws Exception { * * @throws Exception In case of any exception. */ + @Test public void testTreeSetRestrictions() throws Exception { // Constructs hash without explicit node's comparator. GridConsistentHash hash = new GridConsistentHash<>(); @@ -187,6 +193,7 @@ public void testTreeSetRestrictions() throws Exception { /** * */ + @Test public void testOneNode() { GridConsistentHash hash = new GridConsistentHash<>(); @@ -204,6 +211,7 @@ public void testOneNode() { /** * */ + @Test public void testHistory() { for (int i = NODES; i-- > 0; ) { GridConsistentHash hash = new GridConsistentHash<>(); @@ -338,4 +346,4 @@ private String[] keys(int cnt) { return keys; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanIdentitySetSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanIdentitySetSelfTest.java index 0cfe0c8f296c5..b0643e2456c41 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanIdentitySetSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanIdentitySetSelfTest.java @@ -21,17 +21,22 @@ import org.apache.ignite.internal.util.GridLeanIdentitySet; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link org.apache.ignite.internal.util.GridLeanMap}. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridLeanIdentitySetSelfTest extends GridCommonAbstractTest { /** * JUnit. * * @throws Exception If failed. */ + @Test public void testAddSizeContainsClear() throws Exception { Set set = new GridLeanIdentitySet<>(); @@ -59,4 +64,4 @@ public void testAddSizeContainsClear() throws Exception { assert set.isEmpty(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanMapPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanMapPerformanceTest.java index 3528cb0add75f..fa8a0f6c3a408 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanMapPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanMapPerformanceTest.java @@ -20,10 +20,14 @@ import java.util.Map; import org.apache.ignite.internal.util.GridLeanMap; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Performance test for {@link GridLeanMap}. */ +@RunWith(JUnit4.class) public class GridLeanMapPerformanceTest extends GridCommonAbstractTest { /** */ private static final int RUN_CNT = 5; @@ -34,6 +38,7 @@ public class GridLeanMapPerformanceTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPerformance() throws Exception { long avgDur = 0; @@ -80,4 +85,4 @@ private void iterate(Map map) throws Exception { for (Integer v : map.values()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanMapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanMapSelfTest.java index 2b49858f03f37..4dddf47f3687b 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanMapSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridLeanMapSelfTest.java @@ -25,17 +25,22 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link GridLeanMap}. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridLeanMapSelfTest extends GridCommonAbstractTest { /** * JUnit. * * @throws Exception If failed. */ + @Test public void testDefaultMap() throws Exception { Map map = new GridLeanMap<>(); @@ -102,7 +107,7 @@ public void testDefaultMap() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) + @Test public void testEmptyMap() throws Exception { Map map = new GridLeanMap<>(0); @@ -169,6 +174,7 @@ public void testEmptyMap() throws Exception { * * @throws Exception If failed. */ + @Test public void testOneEntryMap() throws Exception { Map map = new GridLeanMap<>(0); @@ -224,6 +230,7 @@ public void testOneEntryMap() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapPutSameKey() throws Exception { Map map = new GridLeanMap<>(0); @@ -242,6 +249,7 @@ public void testMapPutSameKey() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleEntriesMap() throws Exception { Map map = new GridLeanMap<>(0); @@ -333,6 +341,7 @@ public void testMultipleEntriesMap() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapRemove() throws Exception { Map map = new GridLeanMap<>(0); @@ -387,6 +396,7 @@ public void testMapRemove() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapClear() throws Exception { Map map = new GridLeanMap<>(); @@ -408,6 +418,7 @@ public void testMapClear() throws Exception { * * @throws Exception If failed. */ + @Test public void testEntrySet() throws Exception { Map map = new GridLeanMap<>(); @@ -460,6 +471,7 @@ public void testEntrySet() throws Exception { * * @throws Exception If failed. */ + @Test public void testWithInitSize1() throws Exception { // Batch mode. Map map = new GridLeanMap<>(4); @@ -528,6 +540,7 @@ public void testWithInitSize1() throws Exception { * * @throws Exception If failed. */ + @Test public void testWithInitSize2() throws Exception { // Batch mode. Map map = new GridLeanMap<>(10); @@ -657,4 +670,4 @@ else if (map.size() == 5) else checkImpl(map, "LeanHashMap"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridListSetSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridListSetSelfTest.java index 6dbff65569aac..f7a93cc51ba74 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridListSetSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridListSetSelfTest.java @@ -25,15 +25,20 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link GridListSet}. */ @GridCommonTest(group = "Lang") +@RunWith(JUnit4.class) public class GridListSetSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testUnsorted() { GridListSet set = new GridListSet<>(); @@ -91,6 +96,7 @@ public void testUnsorted() { /** * */ + @Test public void testSortedNotStrict() { GridListSet set = new GridListSet<>(new Comparator() { @Override public int compare(V1 o1, V1 o2) { @@ -153,6 +159,7 @@ public void testSortedNotStrict() { /** * */ + @Test public void testSortedStrict() { List vals = new ArrayList<>(); @@ -286,4 +293,4 @@ private V2(int val, int other) { return S.toString(V2.class, this, super.toString()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridStripedLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridStripedLockSelfTest.java index f6fb545769740..14d546565fa74 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/GridStripedLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/GridStripedLockSelfTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.internal.util.GridStripedLock; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridStripedLockSelfTest extends GridCommonAbstractTest { /** */ private static final int STRIPE_COUNT = 16; @@ -54,6 +58,7 @@ public class GridStripedLockSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testIntLocking() throws Exception { GridTestUtils.runMultiThreaded(new Runnable() { @Override public void run() { @@ -87,6 +92,7 @@ public void testIntLocking() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLongLocking() throws Exception { GridTestUtils.runMultiThreaded(new Runnable() { @Override public void run() { @@ -120,6 +126,7 @@ public void testLongLocking() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectLocking() throws Exception { GridTestUtils.runMultiThreaded(new Runnable() { @Override public void run() { @@ -197,4 +204,4 @@ private Iterable testObjects(final int cnt) { } }; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/lang/utils/IgniteOffheapReadWriteLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/utils/IgniteOffheapReadWriteLockSelfTest.java index c5ebe6a771bd0..91c353dc24045 100644 --- a/modules/core/src/test/java/org/apache/ignite/lang/utils/IgniteOffheapReadWriteLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/lang/utils/IgniteOffheapReadWriteLockSelfTest.java @@ -29,11 +29,15 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings("BusyWait") +@RunWith(JUnit4.class) public class IgniteOffheapReadWriteLockSelfTest extends GridCommonAbstractTest { /** */ private static final int TAG_0 = 1; @@ -44,6 +48,7 @@ public class IgniteOffheapReadWriteLockSelfTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testConcurrentUpdatesSingleLock() throws Exception { final int numPairs = 100; final Pair[] data = new Pair[numPairs]; @@ -139,6 +144,7 @@ public void testConcurrentUpdatesSingleLock() throws Exception { /** * @throws Exception if failed. */ + @Test public void testConcurrentUpdatesMultipleLocks() throws Exception { final int numPairs = 100; final Pair[] data = new Pair[numPairs]; @@ -225,6 +231,7 @@ public void testConcurrentUpdatesMultipleLocks() throws Exception { /** * @throws Exception if failed. */ + @Test public void testLockUpgradeMultipleLocks() throws Exception { final int numPairs = 100; final Pair[] data = new Pair[numPairs]; @@ -312,6 +319,7 @@ public void testLockUpgradeMultipleLocks() throws Exception { /** * @throws Exception if failed. */ + @Test public void testTagIdUpdateWait() throws Exception { checkTagIdUpdate(true); } @@ -319,6 +327,7 @@ public void testTagIdUpdateWait() throws Exception { /** * @throws Exception if failed. */ + @Test public void testTagIdUpdateContinuous() throws Exception { checkTagIdUpdate(false); } diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/GridCacheMultiNodeLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/GridCacheMultiNodeLoadTest.java index 35c3405cdd51b..3e648c74495cd 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/GridCacheMultiNodeLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/GridCacheMultiNodeLoadTest.java @@ -21,10 +21,10 @@ import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -33,6 +33,7 @@ /** * Multi-node cache test. */ +@RunWith(JUnit4.class) public class GridCacheMultiNodeLoadTest extends GridCommonAbstractTest { /** Cache name. */ public static final String CACHE_NAME = "partitioned"; @@ -43,20 +44,11 @@ public class GridCacheMultiNodeLoadTest extends GridCommonAbstractTest { /** Grid 1. */ private static Ignite ignite1; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(CACHE_NAME); @@ -97,7 +89,8 @@ public class GridCacheMultiNodeLoadTest extends GridCommonAbstractTest { /** * @throws Exception If test failed. */ + @Test public void testMany() throws Exception { ignite1.compute().execute(GridCacheLoadPopulationTask.class, null); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheWriteBehindStoreLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheWriteBehindStoreLoadTest.java index c01d113fb0589..86ef6d304c404 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheWriteBehindStoreLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheWriteBehindStoreLoadTest.java @@ -31,12 +31,16 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * Basic store test. */ +@RunWith(JUnit4.class) public class GridCacheWriteBehindStoreLoadTest extends GridCommonAbstractTest { /** Flush frequency. */ private static final int WRITE_FROM_BEHIND_FLUSH_FREQUENCY = 1000; @@ -125,6 +129,7 @@ protected CacheMode cacheMode() { /** * @throws Exception If failed. */ + @Test public void testLoadCacheSequentialKeys() throws Exception { rndKeys = false; @@ -136,6 +141,7 @@ public void testLoadCacheSequentialKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheRandomKeys() throws Exception { rndKeys = true; @@ -199,4 +205,4 @@ private void loadCache() throws Exception { @Override protected long getTestTimeout() { return 0; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark0.java b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark0.java index 58fc166aeb602..0197579eea54d 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark0.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark0.java @@ -42,17 +42,18 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.communication.CommunicationSpi; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.managers.communication.GridIoPolicy.PUBLIC_POOL; /** * */ +@RunWith(JUnit4.class) public class GridIoManagerBenchmark0 extends GridCommonAbstractTest { /** */ public static final int CONCUR_MSGS = 10 * 1024; @@ -63,9 +64,6 @@ public class GridIoManagerBenchmark0 extends GridCommonAbstractTest { /** */ private static final long TEST_TIMEOUT = 3 * 60 * 1000; - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(2); @@ -75,12 +73,6 @@ public class GridIoManagerBenchmark0 extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - c.setDiscoverySpi(discoSpi); - c.setCommunicationSpi(getCommunication()); return c; @@ -103,7 +95,7 @@ private static String generateTestString(int len) { /** * @throws Exception If failed. */ - @SuppressWarnings("deprecation") + @Test public void testThroughput() throws Exception { final IgniteKernal sndKernal = (IgniteKernal)grid(0); final IgniteKernal rcvKernal = (IgniteKernal)grid(1); @@ -199,7 +191,7 @@ public void testThroughput() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("deprecation") + @Test public void testLatency() throws Exception { final IgniteKernal sndKernal = (IgniteKernal)grid(0); final IgniteKernal rcvKernal = (IgniteKernal)grid(1); @@ -295,7 +287,7 @@ public void testLatency() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("deprecation") + @Test public void testVariableLoad() throws Exception { final IgniteKernal sndKernal = (IgniteKernal)grid(0); final IgniteKernal rcvKernal = (IgniteKernal)grid(1); @@ -469,4 +461,4 @@ private CommunicationSpi getCommunication() { @Override protected long getTestTimeout() { return TEST_TIMEOUT + 60 * 1000; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTcpCommunicationBenchmark.java b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTcpCommunicationBenchmark.java index b62094977c3ce..b94cccad4c61e 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTcpCommunicationBenchmark.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTcpCommunicationBenchmark.java @@ -583,4 +583,4 @@ // @Override protected long getTestTimeout() { // return TEST_TIMEOUT + 60 * 1000; // } -//} \ No newline at end of file +//} diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/datastructures/GridCachePartitionedAtomicLongLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/datastructures/GridCachePartitionedAtomicLongLoadTest.java index 30172724e7378..3ce01d10df15f 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/datastructures/GridCachePartitionedAtomicLongLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/datastructures/GridCachePartitionedAtomicLongLoadTest.java @@ -29,11 +29,11 @@ import org.apache.ignite.configuration.AtomicConfiguration; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -43,13 +43,11 @@ /** * Load test for atomic long. */ +@RunWith(JUnit4.class) public class GridCachePartitionedAtomicLongLoadTest extends GridCommonAbstractTest { /** Test duration. */ private static final long DURATION = 8 * 60 * 60 * 1000; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final AtomicInteger idx = new AtomicInteger(); @@ -84,18 +82,13 @@ public class GridCachePartitionedAtomicLongLoadTest extends GridCommonAbstractTe c.setCacheConfiguration(cc); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - return c; } /** * @throws Exception If failed. */ + @Test public void testLoad() throws Exception { startGrid(); @@ -139,4 +132,4 @@ private class AtomicCallable implements Callable { return true; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java index 2d1aaa48d770a..804cd936bc89d 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java @@ -31,11 +31,15 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Multi-splits load test. */ @GridCommonTest(group = "Load Test") +@RunWith(JUnit4.class) public class GridMultiSplitsLoadTest extends GridCommonAbstractTest { /** */ public GridMultiSplitsLoadTest() { @@ -89,6 +93,7 @@ private int getThreadCount() { * * @throws Exception If task execution failed. */ + @Test public void testLoad() throws Exception { final Ignite ignite = G.ignite(getTestIgniteInstanceName()); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsRedeployLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsRedeployLoadTest.java index 0cb089569829e..db7bf138979f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsRedeployLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsRedeployLoadTest.java @@ -27,11 +27,15 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Multi splits redeploy load test. */ @GridCommonTest(group = "Load Test") +@RunWith(JUnit4.class) public class GridMultiSplitsRedeployLoadTest extends GridCommonAbstractTest { /** Load test task type ID. */ public static final String TASK_TYPE_ID = GridLoadTestTask.class.getName(); @@ -75,6 +79,7 @@ private int getThreadCount() { * * @throws Exception If task execution failed. */ + @Test public void testLoad() throws Exception { final Ignite ignite = G.ignite(getTestIgniteInstanceName()); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java index aac3c301f037f..18343f36fb73c 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java @@ -29,11 +29,15 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Base class for single split on new nodes tests. */ @GridCommonTest(group = "Load Test") +@RunWith(JUnit4.class) public abstract class GridSingleSplitsNewNodesAbstractLoadTest extends GridCommonAbstractTest { /** * @param cfg Current configuration. @@ -88,6 +92,7 @@ protected int getNodeCount() { * * @throws Exception If task execution failed. */ + @Test public void testLoad() throws Exception { final Ignite ignite = startGrid(getTestIgniteInstanceName()); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/redeploy/GridSingleSplitsRedeployLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/redeploy/GridSingleSplitsRedeployLoadTest.java index 057a1c82a3601..85b1b2752f4ef 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/redeploy/GridSingleSplitsRedeployLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/redeploy/GridSingleSplitsRedeployLoadTest.java @@ -33,11 +33,15 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Single splits redeploy load test. */ @GridCommonTest(group = "Load Test") +@RunWith(JUnit4.class) public class GridSingleSplitsRedeployLoadTest extends GridCommonAbstractTest { /** Load test task type ID. */ public static final String TASK_NAME = "org.apache.ignite.tests.p2p.SingleSplitTestTask"; @@ -91,6 +95,7 @@ private int getThreadCount() { * * @throws Exception If task execution failed. */ + @Test public void testLoad() throws Exception { final Ignite ignite = G.ignite(getTestIgniteInstanceName()); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/session/GridSessionLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/session/GridSessionLoadTest.java index d46158b743409..0b1957b060ea0 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/session/GridSessionLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/session/GridSessionLoadTest.java @@ -26,11 +26,15 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Session load test. */ @GridCommonTest(group = "Load Test") +@RunWith(JUnit4.class) public class GridSessionLoadTest extends GridCommonAbstractTest { /** */ public GridSessionLoadTest() { @@ -59,7 +63,7 @@ private int getThreadCount() { /** * @throws Exception If failed. */ - @SuppressWarnings("unchecked") + @Test public void testSessionLoad() throws Exception { final Ignite ignite = G.ignite(getTestIgniteInstanceName()); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/stealing/GridStealingLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/stealing/GridStealingLoadTest.java index ace423aa3c4d6..6bfdd36105a74 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/stealing/GridStealingLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/stealing/GridStealingLoadTest.java @@ -32,11 +32,15 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridCommonTest(group = "Load Test") +@RunWith(JUnit4.class) public class GridStealingLoadTest extends GridCommonAbstractTest { /** */ public GridStealingLoadTest() { @@ -86,7 +90,7 @@ private int getThreadCount() { /** * @throws Exception If failed. */ - @SuppressWarnings("unchecked") + @Test public void testStealingLoad() throws Exception { final Ignite ignite = grid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java index c8cf9aae7bb08..55c4c4574fc5d 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java @@ -48,6 +48,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager; import org.apache.ignite.internal.processors.plugin.CachePluginManager; +import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.testframework.junits.GridTestKernalContext; import static org.apache.ignite.testframework.junits.GridAbstractTest.defaultCacheConfiguration; @@ -88,8 +89,11 @@ public GridCacheTestContext(GridTestKernalContext ctx) throws Exception { null, CacheType.USER, AffinityTopologyVersion.ZERO, + IgniteUuid.randomUuid(), true, true, + false, + false, new GridCacheEventManager(), new CacheOsStoreManager(null, new CacheConfiguration()), new GridCacheEvictionManager(), diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridHashMapLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridHashMapLoadTest.java index 7d4f90e3c93e2..7b2ddb6535ec9 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridHashMapLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridHashMapLoadTest.java @@ -28,15 +28,20 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests hashmap load. */ @SuppressWarnings("InfiniteLoopStatement") +@RunWith(JUnit4.class) public class GridHashMapLoadTest extends GridCommonAbstractTest { /** * */ + @Test public void testHashMapLoad() { Map map = new HashMap<>(5 * 1024 * 1024); @@ -53,6 +58,7 @@ public void testHashMapLoad() { /** * */ + @Test public void testConcurrentHashMapLoad() { Map map = new ConcurrentHashMap<>(5 * 1024 * 1024); @@ -69,6 +75,7 @@ public void testConcurrentHashMapLoad() { /** * @throws Exception If failed. */ + @Test public void testMapEntry() throws Exception { Map map = new HashMap<>(5 * 1024 * 1024); diff --git a/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java b/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java index d9ec810d32586..4687ca992c9c2 100644 --- a/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java @@ -18,17 +18,19 @@ package org.apache.ignite.logger.java; import java.util.UUID; -import junit.framework.TestCase; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.logger.LoggerNodeIdAware; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; /** * Java logger test. */ @GridCommonTest(group = "Logger") -public class JavaLoggerTest extends TestCase { +public class JavaLoggerTest { /** */ @SuppressWarnings({"FieldCanBeLocal"}) private IgniteLogger log; @@ -36,6 +38,7 @@ public class JavaLoggerTest extends TestCase { /** * @throws Exception If failed. */ + @Test public void testLogInitialize() throws Exception { log = new JavaLogger(); @@ -65,4 +68,4 @@ public void testLogInitialize() throws Exception { // Ensure we don't get pattern, only actual file name is allowed here. assert !log.fileName().contains("%"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java index 51e71960173bf..44da9e4ad7568 100644 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshaller; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Multi-JVM test for dynamic proxy serialization. */ +@RunWith(JUnit4.class) public class DynamicProxySerializationMultiJvmSelfTest extends GridCommonAbstractTest { /** */ private static Callable marshFactory; @@ -58,6 +62,7 @@ public class DynamicProxySerializationMultiJvmSelfTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testBinaryMarshaller() throws Exception { marshFactory = new Callable() { @Override public Marshaller call() throws Exception { @@ -71,6 +76,7 @@ public void testBinaryMarshaller() throws Exception { /** * @throws Exception If failed. */ + @Test public void testToBinary() throws Exception { marshFactory = new Callable() { @Override public Marshaller call() throws Exception { @@ -90,6 +96,7 @@ public void testToBinary() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBinaryField() throws Exception { marshFactory = new Callable() { @Override public Marshaller call() throws Exception { diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java index 05a8924d6186e..10100e215cc1a 100644 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java @@ -74,6 +74,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.thread.IgniteThread; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.events.EventType.EVTS_CACHE; @@ -81,6 +84,7 @@ /** * Common test for marshallers. */ +@RunWith(JUnit4.class) public abstract class GridMarshallerAbstractTest extends GridCommonAbstractTest implements Serializable { /** */ private static final String CACHE_NAME = "namedCache"; @@ -157,6 +161,7 @@ protected GridMarshallerAbstractTest() { /** * @throws Exception If failed. */ + @Test public void testDefaultCache() throws Exception { IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); @@ -187,6 +192,7 @@ public void testDefaultCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNamedCache() throws Exception { IgniteCache cache = grid().cache(CACHE_NAME); @@ -219,6 +225,7 @@ public void testNamedCache() throws Exception { * * @throws Exception If test failed. */ + @Test public void testMarshalling() throws Exception { GridMarshallerTestBean inBean = newTestBean(new Object()); @@ -246,6 +253,7 @@ public void testMarshalling() throws Exception { * * @throws Exception If test failed. */ + @Test public void testMarshallingAnonymousClassInstance() throws Exception { final Ignite g = grid(); @@ -283,6 +291,7 @@ public void testMarshallingAnonymousClassInstance() throws Exception { * * @throws Exception If test failed. */ + @Test public void testMarshallingLocalClassInstance() throws Exception { /** * Local class. @@ -320,6 +329,7 @@ class LocalRunnable implements Runnable, Serializable { * * @throws Exception If test failed. */ + @Test public void testMarshallingNestedClassInstance() throws Exception { GridMarshallerTestBean inBean = newTestBean(new NestedClass()); @@ -347,6 +357,7 @@ public void testMarshallingNestedClassInstance() throws Exception { * * @throws Exception If test failed. */ + @Test public void testMarshallingStaticNestedClassInstance() throws Exception { GridMarshallerTestBean inBean = newTestBean(new StaticNestedClass()); @@ -374,6 +385,7 @@ public void testMarshallingStaticNestedClassInstance() throws Exception { * * @throws Exception If test failed. */ + @Test public void testMarshallingNullObject() throws Exception { GridMarshallerTestBean inBean = newTestBean(null); @@ -397,6 +409,7 @@ public void testMarshallingNullObject() throws Exception { * @throws IgniteCheckedException If marshalling failed. */ @SuppressWarnings({"ZeroLengthArrayAllocation"}) + @Test public void testMarshallingArrayOfPrimitives() throws IgniteCheckedException { char[] inChars = "vasya".toCharArray(); @@ -429,6 +442,7 @@ public void testMarshallingArrayOfPrimitives() throws IgniteCheckedException { * * @throws Exception If test failed. */ + @Test public void testExternalClassesMarshalling() throws Exception { ClassLoader tstClsLdr = new GridTestClassLoader( Collections.singletonMap("org/apache/ignite/p2p/p2p.properties", "resource=loaded"), @@ -452,6 +466,7 @@ public void testExternalClassesMarshalling() throws Exception { * * @throws Exception If test failed. */ + @Test public void testGridKernalMarshalling() throws Exception { GridMarshallerTestBean inBean = newTestBean(grid()); @@ -477,6 +492,7 @@ public void testGridKernalMarshalling() throws Exception { * * @throws Exception If test failed. */ + @Test public void testSubgridMarshalling() throws Exception { final Ignite ignite = grid(); @@ -507,6 +523,7 @@ public void testSubgridMarshalling() throws Exception { * * @throws Exception If test failed. */ + @Test public void testLoggerMarshalling() throws Exception { GridMarshallerTestBean inBean = newTestBean(grid().log()); @@ -532,6 +549,7 @@ public void testLoggerMarshalling() throws Exception { * @throws Exception If test failed. */ @SuppressWarnings("unchecked") + @Test public void testNodeLocalMarshalling() throws Exception { ConcurrentMap loc = grid().cluster().nodeLocalMap(); @@ -568,6 +586,7 @@ public void testNodeLocalMarshalling() throws Exception { * * @throws Exception If test failed. */ + @Test public void testExecutorServiceMarshalling() throws Exception { ExecutorService inSrvc = grid().executorService(); @@ -599,6 +618,7 @@ public void testExecutorServiceMarshalling() throws Exception { * * @throws Exception If test failed. */ + @Test public void testKernalContext() throws Exception { GridMarshallerTestBean inBean = newTestBean(GridKernalTestUtils.context(grid())); @@ -621,6 +641,7 @@ public void testKernalContext() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScheduler() throws Exception { IgniteScheduler scheduler = grid().scheduler(); @@ -653,6 +674,7 @@ public void testScheduler() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCompute() throws Exception { IgniteConfiguration cfg = optimize(getConfiguration("g1")); @@ -693,6 +715,7 @@ public void testCompute() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvents() throws Exception { IgniteConfiguration cfg = optimize(getConfiguration("g1")); @@ -735,6 +758,7 @@ public void testEvents() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMessaging() throws Exception { IgniteConfiguration cfg = optimize(getConfiguration("g1")); @@ -771,6 +795,7 @@ public void testMessaging() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServices() throws Exception { IgniteConfiguration cfg = optimize(getConfiguration("g1")); @@ -878,6 +903,7 @@ private static class StaticNestedClass implements Serializable { /** * @throws Exception If failed. */ + @Test public void testReadArray() throws Exception { byte[] arr = new byte[10]; @@ -894,6 +920,7 @@ public void testReadArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadFully() throws Exception { byte[] arr = new byte[10]; @@ -952,4 +979,4 @@ private ReadArrayTestClass(byte[] arr, boolean fully) { in.read(arr); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerMappingConsistencyTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerMappingConsistencyTest.java index ba39e366e9f85..4350824ac016d 100644 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerMappingConsistencyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerMappingConsistencyTest.java @@ -27,15 +27,16 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridMarshallerMappingConsistencyTest extends GridCommonAbstractTest { /** Test cache name. */ private static final String CACHE_NAME = "cache"; @@ -45,9 +46,6 @@ public class GridMarshallerMappingConsistencyTest extends GridCommonAbstractTest File.separatorChar + "work" + File.separatorChar + "test"; - /** Ip finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration igniteCfg = super.getConfiguration(igniteInstanceName); @@ -64,11 +62,6 @@ public class GridMarshallerMappingConsistencyTest extends GridCommonAbstractTest igniteCfg.setWorkDirectory(WORK_DIR + File.separator + igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(ipFinder); - - igniteCfg.setDiscoverySpi(discoSpi); - return igniteCfg; } @@ -101,6 +94,7 @@ private void clearWorkDir() throws IOException { * * @throws Exception If failed. */ + @Test public void testMappingsPersistedOnJoin() throws Exception { Ignite g1 = startGrid(1); Ignite g2 = startGrid(2); @@ -140,6 +134,7 @@ public void testMappingsPersistedOnJoin() throws Exception { * * @throws Exception If failed. */ + @Test public void testPersistedMappingsSharedOnJoin() throws Exception { Ignite g1 = startGrid(1); startGrid(2); diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerPerformanceTest.java index c4e29c5ddfa9a..3a7df77146118 100644 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerPerformanceTest.java @@ -45,10 +45,14 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteOutClosure; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Marshallers benchmark. */ +@RunWith(JUnit4.class) public class GridMarshallerPerformanceTest extends GridCommonAbstractTest { /** Number of iterations per test. */ private static final int ITER_CNT = 1 * 1000 * 1000; @@ -64,6 +68,7 @@ public class GridMarshallerPerformanceTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSerialization() throws Exception { final ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -112,6 +117,7 @@ public void testSerialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGridMarshaller() throws Exception { final GridTuple tuple = new GridTuple<>(); @@ -135,6 +141,7 @@ public void testGridMarshaller() throws Exception { /** * @throws Exception If failed. */ + @Test public void testByteBuffer() throws Exception { final ByteBuffer buf = ByteBuffer.allocate(1024); @@ -160,6 +167,7 @@ public void testByteBuffer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testKryo() throws Exception { final Kryo kryo = new Kryo(); @@ -524,4 +532,4 @@ static TestObject read(ByteBuffer buf) { list.equals(obj.list) && map.equals(obj.map); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java index da474df82365e..a7661b7b68909 100644 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java @@ -37,6 +37,9 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.nio.file.Files.readAllBytes; import static org.apache.ignite.internal.MarshallerPlatformIds.JAVA_ID; @@ -44,6 +47,7 @@ /** * Test marshaller context. */ +@RunWith(JUnit4.class) public class MarshallerContextSelfTest extends GridCommonAbstractTest { /** */ private GridTestKernalContext ctx; @@ -71,6 +75,7 @@ public class MarshallerContextSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testClassName() throws Exception { MarshallerContextImpl marshCtx = new MarshallerContextImpl(null, null); @@ -96,6 +101,7 @@ public void testClassName() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultiplatformMappingsCollecting() throws Exception { String nonJavaClassName = "random.platform.Mapping"; @@ -132,6 +138,7 @@ public void testMultiplatformMappingsCollecting() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultiplatformMappingsDistributing() throws Exception { String nonJavaClassName = "random.platform.Mapping"; @@ -155,6 +162,7 @@ public void testMultiplatformMappingsDistributing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOnUpdated() throws Exception { File workDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", false); MarshallerContextImpl ctx = new MarshallerContextImpl(null, null); @@ -187,6 +195,7 @@ public void testOnUpdated() throws Exception { * Tests that there is a null value inserted in allCaches list * if platform ids passed to marshaller cache were not sequential (like 0, 2). */ + @Test public void testCacheStructure0() throws Exception { MarshallerContextImpl ctx = new MarshallerContextImpl(null, null); @@ -220,6 +229,7 @@ public void testCacheStructure0() throws Exception { * Tests that there are no null values in allCaches list * if platform ids passed to marshaller context were sequential. */ + @Test public void testCacheStructure1() throws Exception { MarshallerContextImpl ctx = new MarshallerContextImpl(null, null); diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerEnumDeadlockMultiJvmTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerEnumDeadlockMultiJvmTest.java index 7042c03221d5f..2ff810601dbba 100644 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerEnumDeadlockMultiJvmTest.java +++ b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerEnumDeadlockMultiJvmTest.java @@ -30,10 +30,14 @@ import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Contains test of Enum marshalling with various {@link Marshaller}s. See IGNITE-8547 for details. */ +@RunWith(JUnit4.class) public class MarshallerEnumDeadlockMultiJvmTest extends GridCommonAbstractTest { /** */ private Factory marshFactory; @@ -44,6 +48,7 @@ public class MarshallerEnumDeadlockMultiJvmTest extends GridCommonAbstractTest { } /** */ + @Test public void testJdkMarshaller() throws Exception { marshFactory = new JdkMarshallerFactory(); @@ -51,6 +56,7 @@ public void testJdkMarshaller() throws Exception { } /** */ + @Test public void testOptimizedMarshaller() throws Exception { marshFactory = new OptimizedMarshallerFactory(); @@ -58,6 +64,7 @@ public void testOptimizedMarshaller() throws Exception { } /** */ + @Test public void testBinaryMarshaller() throws Exception { marshFactory = new BinaryMarshallerFactory(); diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingNoPeerClassLoadingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingNoPeerClassLoadingSelfTest.java index 4338947de5658..e5620007f3f97 100644 --- a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingNoPeerClassLoadingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingNoPeerClassLoadingSelfTest.java @@ -27,11 +27,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.P2; import org.apache.ignite.testframework.config.GridTestProperties; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for Messaging public API with disabled * peer class loading. */ +@RunWith(JUnit4.class) public class GridMessagingNoPeerClassLoadingSelfTest extends GridMessagingSelfTest { /** */ private static CountDownLatch rcvLatch; @@ -52,6 +56,7 @@ public class GridMessagingNoPeerClassLoadingSelfTest extends GridMessagingSelfTe * * @throws Exception If error occurs. */ + @Test @Override public void testSendMessageWithExternalClassLoader() throws Exception { URL[] urls = new URL[] { new URL(GridTestProperties.getProperty("p2p.uri.cls")) }; @@ -92,4 +97,4 @@ unmarshal it (peer class loading is disabled.) */ assertFalse(rcvLatch.await(3, TimeUnit.SECONDS)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java index a7c452122d566..867fd7c74980f 100644 --- a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java @@ -38,7 +38,6 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteMessaging; import org.apache.ignite.cluster.ClusterGroup; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.DiscoverySpiTestListener; import org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi; import org.apache.ignite.internal.processors.continuous.StartRoutineDiscoveryMessage; @@ -50,19 +49,20 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; /** * Various tests for Messaging public API. */ +@RunWith(JUnit4.class) public class GridMessagingSelfTest extends GridCommonAbstractTest implements Serializable { /** */ private static final String MSG_1 = "MSG-1"; @@ -91,9 +91,6 @@ public class GridMessagingSelfTest extends GridCommonAbstractTest implements Ser /** */ public static final String EXT_RESOURCE_CLS_NAME = "org.apache.ignite.tests.p2p.TestUserResource"; - /** Shared IP finder. */ - private final transient TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ protected static CountDownLatch rcvLatch; @@ -199,20 +196,12 @@ public TestMessage() { ignite2 = null; } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** * Tests simple message sending-receiving. * * @throws Exception If error occurs. */ + @Test public void testSendReceiveMessage() throws Exception { final Collection rcvMsgs = new GridConcurrentHashSet<>(); @@ -262,6 +251,7 @@ public void testSendReceiveMessage() throws Exception { * @throws Exception If error occurs. */ @SuppressWarnings("TooBroadScope") + @Test public void testStopLocalListen() throws Exception { final AtomicInteger msgCnt1 = new AtomicInteger(); @@ -374,6 +364,7 @@ public void testStopLocalListen() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testSendReceiveMessageWithStringTopic() throws Exception { final Collection rcvMsgs = new GridConcurrentHashSet<>(); @@ -497,6 +488,7 @@ public void testSendReceiveMessageWithStringTopic() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testSendReceiveMessageWithEnumTopic() throws Exception { final Collection rcvMsgs = new GridConcurrentHashSet<>(); @@ -621,6 +613,7 @@ public void testSendReceiveMessageWithEnumTopic() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testRemoteListen() throws Exception { final Collection rcvMsgs = new GridConcurrentHashSet<>(); @@ -658,6 +651,7 @@ public void testRemoteListen() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("TooBroadScope") + @Test public void testStopRemoteListen() throws Exception { final AtomicInteger msgCnt1 = new AtomicInteger(); @@ -751,6 +745,7 @@ public void testStopRemoteListen() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testRemoteListenOrderedMessages() throws Exception { List msgs = Arrays.asList( new TestMessage(MSG_1), @@ -795,7 +790,6 @@ public void testRemoteListenOrderedMessages() throws Exception { assertFalse(error.get()); - //noinspection AssertEqualsBetweenInconvertibleTypes assertEquals(msgs, Arrays.asList(rcvMsgs.toArray())); } @@ -805,6 +799,7 @@ public void testRemoteListenOrderedMessages() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testRemoteListenWithIntTopic() throws Exception { final Collection rcvMsgs = new GridConcurrentHashSet<>(); @@ -944,6 +939,7 @@ public void testRemoteListenWithIntTopic() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testSendMessageWithExternalClassLoader() throws Exception { URL[] urls = new URL[] {new URL(GridTestProperties.getProperty("p2p.uri.cls"))}; @@ -988,7 +984,7 @@ public void testSendMessageWithExternalClassLoader() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings("ConstantConditions") + @Test public void testNullMessages() throws Exception { assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1026,6 +1022,7 @@ public void testNullMessages() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAsyncOld() throws Exception { final AtomicInteger msgCnt = new AtomicInteger(); @@ -1138,6 +1135,7 @@ public void testAsyncOld() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAsync() throws Exception { final AtomicInteger msgCnt = new AtomicInteger(); @@ -1214,6 +1212,7 @@ public void testAsync() throws Exception { * * @throws Exception If an error occurred. */ + @Test public void testRemoteListenForOldest() throws Exception { remoteListenForOldest(ignite1); diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java index d51a5dd7c60e4..5222e35e8bdb3 100644 --- a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java +++ b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java @@ -29,22 +29,19 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteMessaging; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteBiPredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest implements Serializable { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Threads number for multi-thread tests. */ private static final int THREADS = 10; @@ -54,15 +51,6 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme /** */ private final String msgStr = "message"; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -75,6 +63,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme * * @throws Exception If failed. */ + @Test public void testSendDefaultMode() throws Exception { Ignite ignite1 = startGrid(1); @@ -91,6 +80,7 @@ public void testSendDefaultMode() throws Exception { * * @throws Exception If failed. */ + @Test public void testSendAsyncMode() throws Exception { Ignite ignite1 = startGrid(1); @@ -107,6 +97,7 @@ public void testSendAsyncMode() throws Exception { * * @throws Exception If failed. */ + @Test public void testSendDefaultMode2Nodes() throws Exception { Ignite ignite1 = startGrid(1); Ignite ignite2 = startGrid(2); @@ -124,6 +115,7 @@ public void testSendDefaultMode2Nodes() throws Exception { * * @throws Exception If failed. */ + @Test public void testSendAsyncMode2Node() throws Exception { Ignite ignite1 = startGrid(1); Ignite ignite2 = startGrid(2); @@ -141,6 +133,7 @@ public void testSendAsyncMode2Node() throws Exception { * * @throws Exception If failed. */ + @Test public void testSendOrderedDefaultMode() throws Exception { Ignite ignite1 = startGrid(1); @@ -159,6 +152,7 @@ public void testSendOrderedDefaultMode() throws Exception { * * @throws Exception If failed. */ + @Test public void testSendOrderedDefaultMode2Node() throws Exception { Ignite ignite1 = startGrid(1); Ignite ignite2 = startGrid(2); @@ -176,6 +170,7 @@ public void testSendOrderedDefaultMode2Node() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSendOrderedDefaultModeMultiThreads() throws Exception { Ignite ignite = startGrid(1); @@ -185,6 +180,7 @@ public void testSendOrderedDefaultModeMultiThreads() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSendOrderedDefaultModeMultiThreadsWith2Node() throws Exception { Ignite ignite1 = startGrid(1); Ignite ignite2 = startGrid(2); diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingWithClientTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingWithClientTest.java index b96728fe822a8..c26fab2da6329 100644 --- a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingWithClientTest.java +++ b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingWithClientTest.java @@ -32,18 +32,17 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteMessagingWithClientTest extends GridCommonAbstractTest implements Serializable { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Message topic. */ private enum TOPIC { /** */ @@ -62,8 +61,6 @@ private enum TOPIC { ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); } - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - return cfg; } @@ -77,6 +74,7 @@ private enum TOPIC { /** * @throws Exception If failed. */ + @Test public void testMessageSendWithClientJoin() throws Exception { startGrid(0); @@ -162,4 +160,4 @@ private static class RemoteListener implements IgniteBiPredicate { return true; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/DeploymentClassLoaderCallableTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/DeploymentClassLoaderCallableTest.java index 9c0e4462f7970..ca75752377815 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/DeploymentClassLoaderCallableTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/DeploymentClassLoaderCallableTest.java @@ -25,9 +25,13 @@ import org.apache.ignite.testframework.GridTestExternalClassLoader; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class DeploymentClassLoaderCallableTest extends GridCommonAbstractTest { /** */ private static final String RUN_CLS = "org.apache.ignite.tests.p2p.compute.ExternalCallable"; @@ -47,6 +51,7 @@ public class DeploymentClassLoaderCallableTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testDeploymentFromSecondAndThird() throws Exception { try { startGrid(1); @@ -67,6 +72,7 @@ public void testDeploymentFromSecondAndThird() throws Exception { /** * @throws Exception if failed. */ + @Test public void testDeploymentFromEach() throws Exception { try { final Ignite ignite1 = startGrid(1); @@ -87,6 +93,7 @@ public void testDeploymentFromEach() throws Exception { /** * @throws Exception if failed. */ + @Test public void testDeploymentFromOne() throws Exception { try { startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployContinuousModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployContinuousModeSelfTest.java index 865fff4b2917c..a7b035f753fef 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployContinuousModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployContinuousModeSelfTest.java @@ -18,6 +18,9 @@ package org.apache.ignite.p2p; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.configuration.DeploymentMode.CONTINUOUS; @@ -25,13 +28,15 @@ * Continuous deployment mode test. */ @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridMultinodeRedeployContinuousModeSelfTest extends GridAbstractMultinodeRedeployTest { /** * Test GridDeploymentMode.CONTINUOUS mode. * * @throws Throwable if error occur. */ + @Test public void testContinuousMode() throws Throwable { processTest(CONTINUOUS); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployIsolatedModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployIsolatedModeSelfTest.java index 25cb8affad57b..cfcc055197c27 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployIsolatedModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployIsolatedModeSelfTest.java @@ -18,6 +18,9 @@ package org.apache.ignite.p2p; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.configuration.DeploymentMode.ISOLATED; @@ -25,13 +28,15 @@ * Isolated deployment mode test. */ @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridMultinodeRedeployIsolatedModeSelfTest extends GridAbstractMultinodeRedeployTest { /** * Test GridDeploymentMode.ISOLATED mode. * * @throws Throwable if error occur. */ + @Test public void testIsolatedMode() throws Throwable { processTest(ISOLATED); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployPrivateModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployPrivateModeSelfTest.java index 708e62d6c71b7..bad6f5bde0fa8 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployPrivateModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeployPrivateModeSelfTest.java @@ -18,6 +18,9 @@ package org.apache.ignite.p2p; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.configuration.DeploymentMode.PRIVATE; @@ -25,13 +28,15 @@ * Private deployment mode test. */ @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridMultinodeRedeployPrivateModeSelfTest extends GridAbstractMultinodeRedeployTest { /** * Test GridDeploymentMode.PRIVATE mode. * * @throws Throwable if error occur. */ + @Test public void testPrivateMode() throws Throwable { processTest(PRIVATE); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeploySharedModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeploySharedModeSelfTest.java index 93df50b54aff8..ade643f136011 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeploySharedModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridMultinodeRedeploySharedModeSelfTest.java @@ -18,6 +18,9 @@ package org.apache.ignite.p2p; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.configuration.DeploymentMode.SHARED; @@ -25,13 +28,15 @@ * Shared deployment mode test. */ @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridMultinodeRedeploySharedModeSelfTest extends GridAbstractMultinodeRedeployTest { /** * Test GridDeploymentMode.SHARED mode. * * @throws Throwable if error occur. */ + @Test public void testSharedMode() throws Throwable { processTest(SHARED); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java index 7b2333fe4eff8..8f2aa7ebb57b6 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java @@ -35,6 +35,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.lang.IgniteProductVersion.fromString; @@ -42,6 +45,7 @@ * P2P test. */ @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PClassLoadingSelfTest extends GridCommonAbstractTest { /** */ private final ClassLoader tstClsLdr; @@ -60,7 +64,8 @@ public GridP2PClassLoadingSelfTest() { /** * @throws Exception If failed. */ - @SuppressWarnings({"serial", "ConstantConditions"}) + @SuppressWarnings({"ConstantConditions"}) + @Test public void testClassLoading() throws Exception { ComputeTask task = (ComputeTask)tstClsLdr.loadClass(GridP2PTestTask.class.getName()).newInstance(); @@ -110,7 +115,6 @@ private static class TestGridNode extends GridMetadataAwareAdapter implements Cl } /** {@inheritDoc} */ - @SuppressWarnings("unchecked") @Nullable @Override public T attribute(String name) { return null; } @@ -160,4 +164,4 @@ private static class TestGridNode extends GridMetadataAwareAdapter implements Cl return id().hashCode(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PContinuousDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PContinuousDeploymentSelfTest.java index 28dab3fe5374b..f15e121ea140e 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PContinuousDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PContinuousDeploymentSelfTest.java @@ -25,10 +25,10 @@ import org.apache.ignite.events.EventType; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -38,10 +38,8 @@ /** * Tests for continuous deployment with cache and changing topology. */ +@RunWith(JUnit4.class) public class GridP2PContinuousDeploymentSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of grids cache. */ private static final int GRID_CNT = 2; @@ -71,12 +69,6 @@ public class GridP2PContinuousDeploymentSelfTest extends GridCommonAbstractTest else cfg.setCacheConfiguration(cacheConfiguration()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setPeerClassLoadingEnabled(true); if (clientMode) @@ -114,6 +106,7 @@ protected CacheConfiguration cacheConfiguration() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testDeployment() throws Exception { startGridsMultiThreaded(GRID_CNT); @@ -139,6 +132,7 @@ public void testDeployment() throws Exception { * * @throws Exception If failed. */ + @Test public void testServerJoinWithP2PClassDeployedInCluster() throws Exception { startGrids(GRID_CNT); @@ -176,4 +170,4 @@ public void testServerJoinWithP2PClassDeployedInCluster() throws Exception { awaitPartitionMapExchange(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PDifferentClassLoaderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PDifferentClassLoaderSelfTest.java index 3af720fd24a65..3551ad9fca0ec 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PDifferentClassLoaderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PDifferentClassLoaderSelfTest.java @@ -27,12 +27,16 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test P2P deployment tasks which loaded from different class loaders. */ @SuppressWarnings({"ProhibitedExceptionDeclared", "ProhibitedExceptionThrown"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PDifferentClassLoaderSelfTest extends GridCommonAbstractTest { /** * Class Name of task 1. @@ -125,6 +129,7 @@ private void processTest(boolean isSameTask, boolean expectEquals) throws Except * * @throws Exception if error occur. */ + @Test public void testPrivateMode() throws Exception { depMode = DeploymentMode.PRIVATE; @@ -136,6 +141,7 @@ public void testPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testIsolatedMode() throws Exception { depMode = DeploymentMode.ISOLATED; @@ -147,6 +153,7 @@ public void testIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -158,6 +165,7 @@ public void testContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { depMode = DeploymentMode.SHARED; @@ -169,6 +177,7 @@ public void testSharedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testRedeployPrivateMode() throws Exception { depMode = DeploymentMode.PRIVATE; @@ -180,6 +189,7 @@ public void testRedeployPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testRedeployIsolatedMode() throws Exception { depMode = DeploymentMode.ISOLATED; @@ -191,6 +201,7 @@ public void testRedeployIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testRedeployContinuousMode() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -202,6 +213,7 @@ public void testRedeployContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testRedeploySharedMode() throws Exception { depMode = DeploymentMode.SHARED; @@ -221,4 +233,4 @@ private boolean isNotSame(int[] m1, int[] m2) { return m1[0] != m2[0] && m1[1] != m2[1]; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PDoubleDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PDoubleDeploymentSelfTest.java index f384090da289a..01ade5823bd3c 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PDoubleDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PDoubleDeploymentSelfTest.java @@ -22,25 +22,23 @@ import org.apache.ignite.compute.ComputeTask; import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestClassLoader; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PDoubleDeploymentSelfTest extends GridCommonAbstractTest { /** Deployment mode. */ private DeploymentMode depMode; - /** IP finder. */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -52,12 +50,6 @@ public class GridP2PDoubleDeploymentSelfTest extends GridCommonAbstractTest { // Test requires SHARED mode to test local deployment priority over p2p. cfg.setDeploymentMode(depMode); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCacheConfiguration(); return cfg; @@ -114,6 +106,7 @@ private void processTestBothNodesDeploy(DeploymentMode depMode) throws Exception /** * @throws Exception if error occur. */ + @Test public void testPrivateMode() throws Exception { processTestBothNodesDeploy(DeploymentMode.PRIVATE); } @@ -121,6 +114,7 @@ public void testPrivateMode() throws Exception { /** * @throws Exception if error occur. */ + @Test public void testIsolatedMode() throws Exception { processTestBothNodesDeploy(DeploymentMode.ISOLATED); } @@ -128,6 +122,7 @@ public void testIsolatedMode() throws Exception { /** * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { processTestBothNodesDeploy(DeploymentMode.CONTINUOUS); } @@ -135,7 +130,8 @@ public void testContinuousMode() throws Exception { /** * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { processTestBothNodesDeploy(DeploymentMode.SHARED); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PHotRedeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PHotRedeploymentSelfTest.java index 620bf24f33341..65c257f7f5730 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PHotRedeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PHotRedeploymentSelfTest.java @@ -24,12 +24,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings({"JUnitTestClassNamingConvention", "ProhibitedExceptionDeclared"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PHotRedeploymentSelfTest extends GridCommonAbstractTest { /** Task name. */ private static final String TASK_NAME = "org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1"; @@ -164,6 +168,7 @@ private void processTestClassLoaderHotRedeployment(DeploymentMode depMode) throw * * @throws Exception if error occur. */ + @Test public void testSameClassLoaderIsolatedMode() throws Exception { processTestHotRedeployment(DeploymentMode.PRIVATE); } @@ -173,6 +178,7 @@ public void testSameClassLoaderIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSameClassLoaderIsolatedClassLoaderMode() throws Exception { processTestHotRedeployment(DeploymentMode.ISOLATED); } @@ -182,6 +188,7 @@ public void testSameClassLoaderIsolatedClassLoaderMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSameClassLoaderContinuousMode() throws Exception { processTestHotRedeployment(DeploymentMode.CONTINUOUS); } @@ -191,6 +198,7 @@ public void testSameClassLoaderContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSameClassLoaderSharedMode() throws Exception { processTestHotRedeployment(DeploymentMode.SHARED); } @@ -200,6 +208,7 @@ public void testSameClassLoaderSharedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testNewClassLoaderHotRedeploymentPrivateMode() throws Exception { processTestClassLoaderHotRedeployment(DeploymentMode.PRIVATE); } @@ -209,6 +218,7 @@ public void testNewClassLoaderHotRedeploymentPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testNewClassLoaderHotRedeploymentIsolatedMode() throws Exception { processTestClassLoaderHotRedeployment(DeploymentMode.ISOLATED); } @@ -218,6 +228,7 @@ public void testNewClassLoaderHotRedeploymentIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testNewClassLoaderHotRedeploymentContinuousMode() throws Exception { processTestClassLoaderHotRedeployment(DeploymentMode.CONTINUOUS); } @@ -227,7 +238,8 @@ public void testNewClassLoaderHotRedeploymentContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testNewClassLoaderHotRedeploymentSharedMode() throws Exception { processTestClassLoaderHotRedeployment(DeploymentMode.SHARED); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PJobClassLoaderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PJobClassLoaderSelfTest.java index 0120a31e066a2..431fb0d8cf3ec 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PJobClassLoaderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PJobClassLoaderSelfTest.java @@ -30,12 +30,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test to make sure that if job executes on the same node, it reuses the same class loader as task. */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PJobClassLoaderSelfTest extends GridCommonAbstractTest { /** * Current deployment mode. Used in {@link #getConfiguration(String)}. @@ -74,6 +78,7 @@ private void processTest(DeploymentMode depMode) throws Exception { * * @throws Exception if error occur. */ + @Test public void testPrivateMode() throws Exception { processTest(DeploymentMode.PRIVATE); } @@ -83,6 +88,7 @@ public void testPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testIsolatedMode() throws Exception { processTest(DeploymentMode.ISOLATED); } @@ -92,6 +98,7 @@ public void testIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { processTest(DeploymentMode.CONTINUOUS); } @@ -101,6 +108,7 @@ public void testContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { processTest(DeploymentMode.SHARED); } @@ -144,4 +152,4 @@ public Serializable execute() { return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PLocalDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PLocalDeploymentSelfTest.java index ca2aeb6df3e30..a33d16f424d9b 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PLocalDeploymentSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PLocalDeploymentSelfTest.java @@ -43,6 +43,9 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_REMOVED_ENTRIES_TTL; import static org.apache.ignite.spi.deployment.local.LocalDeploymentSpi.IGNITE_DEPLOYMENT_ADDITIONAL_CHECK; @@ -52,6 +55,7 @@ */ @SuppressWarnings({"ProhibitedExceptionDeclared", "ObjectEquality"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PLocalDeploymentSelfTest extends GridCommonAbstractTest { /** * Current deployment mode. Used in {@link #getConfiguration(String)}. @@ -105,6 +109,7 @@ private void processSharedModeTest(DeploymentMode depMode) throws Exception { * @throws Exception if error occur. */ @SuppressWarnings({"unchecked"}) + @Test public void testLocalDeployment() throws Exception { depMode = DeploymentMode.PRIVATE; @@ -182,6 +187,7 @@ private void processIsolatedModeTest(DeploymentMode depMode) throws Exception { * * @throws Exception if error occur. */ + @Test public void testPrivateMode() throws Exception { processIsolatedModeTest(DeploymentMode.PRIVATE); } @@ -191,6 +197,7 @@ public void testPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testIsolatedMode() throws Exception { processIsolatedModeTest(DeploymentMode.ISOLATED); } @@ -200,6 +207,7 @@ public void testIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { processSharedModeTest(DeploymentMode.CONTINUOUS); } @@ -209,6 +217,7 @@ public void testContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { processSharedModeTest(DeploymentMode.SHARED); } @@ -216,6 +225,7 @@ public void testSharedMode() throws Exception { /** * Tests concurrent deployment using delegating classloader for the task. */ + @Test public void testConcurrentDeploymentWithDelegatingClassloader() throws Exception { depMode = DeploymentMode.SHARED; @@ -368,4 +378,4 @@ public static class DeployementTestJob extends ComputeJobAdapter { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PMissedResourceCacheSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PMissedResourceCacheSizeSelfTest.java index d5ecde90f3e79..65a80d3d6504f 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PMissedResourceCacheSizeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PMissedResourceCacheSizeSelfTest.java @@ -26,18 +26,19 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.Event; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestExternalClassLoader; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PMissedResourceCacheSizeSelfTest extends GridCommonAbstractTest { /** Task name. */ private static final String TASK_NAME1 = "org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1"; @@ -57,9 +58,6 @@ public class GridP2PMissedResourceCacheSizeSelfTest extends GridCommonAbstractTe /** */ private int missedRsrcCacheSize; - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -73,12 +71,6 @@ public class GridP2PMissedResourceCacheSizeSelfTest extends GridCommonAbstractTe cfg.setCacheConfiguration(); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - return cfg; } @@ -227,6 +219,7 @@ private void processSize0Test(DeploymentMode depMode) throws Exception { * * @throws Exception if error occur. */ + @Test public void testSize0PrivateMode() throws Exception { processSize0Test(DeploymentMode.PRIVATE); } @@ -236,6 +229,7 @@ public void testSize0PrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSize0IsolatedMode() throws Exception { processSize0Test(DeploymentMode.ISOLATED); } @@ -245,6 +239,7 @@ public void testSize0IsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSize0ContinuousMode() throws Exception { processSize0Test(DeploymentMode.CONTINUOUS); } @@ -254,6 +249,7 @@ public void testSize0ContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSize0SharedMode() throws Exception { processSize0Test(DeploymentMode.SHARED); } @@ -262,6 +258,7 @@ public void testSize0SharedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSize2PrivateMode() throws Exception { // processSize2Test(GridDeploymentMode.PRIVATE); } @@ -271,6 +268,7 @@ public void testSize2PrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSize2IsolatedMode() throws Exception { // processSize2Test(GridDeploymentMode.ISOLATED); } @@ -280,6 +278,7 @@ public void testSize2IsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSize2ContinuousMode() throws Exception { // processSize2Test(GridDeploymentMode.CONTINUOUS); } @@ -289,7 +288,8 @@ public void testSize2ContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSize2SharedMode() throws Exception { // processSize2Test(GridDeploymentMode.SHARED); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PNodeLeftSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PNodeLeftSelfTest.java index bc0d787dfe3c0..3735cc0aa0434 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PNodeLeftSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PNodeLeftSelfTest.java @@ -26,12 +26,16 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test P2P class loading in SHARED_CLASSLOADER_UNDEPLOY mode. */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PNodeLeftSelfTest extends GridCommonAbstractTest { /** */ private static final ClassLoader urlClsLdr1; @@ -105,6 +109,7 @@ private void processTest(boolean isExpectUndeploy) throws Exception { * * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -116,9 +121,10 @@ public void testContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { depMode = DeploymentMode.SHARED; processTest(true); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PRecursionTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PRecursionTaskSelfTest.java index a35409d5db825..879e6fd987186 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PRecursionTaskSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PRecursionTaskSelfTest.java @@ -32,12 +32,16 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PRecursionTaskSelfTest extends GridCommonAbstractTest { /** * Current deployment mode. Used in {@link #getConfiguration(String)}. @@ -85,6 +89,7 @@ private void processTest(DeploymentMode depMode) throws Exception { * * @throws Exception if error occur. */ + @Test public void testPrivateMode() throws Exception { processTest(DeploymentMode.PRIVATE); } @@ -94,6 +99,7 @@ public void testPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testIsolatedMode() throws Exception { processTest(DeploymentMode.ISOLATED); } @@ -103,6 +109,7 @@ public void testIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { processTest(DeploymentMode.CONTINUOUS); } @@ -112,6 +119,7 @@ public void testContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { processTest(DeploymentMode.SHARED); } diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PRemoteClassLoadersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PRemoteClassLoadersSelfTest.java index 623c962dcf2af..f761e25560d37 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PRemoteClassLoadersSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PRemoteClassLoadersSelfTest.java @@ -37,12 +37,16 @@ import org.apache.ignite.testframework.GridTestClassLoader; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PRemoteClassLoadersSelfTest extends GridCommonAbstractTest { /** Current deployment mode. Used in {@link #getConfiguration(String)}. */ private DeploymentMode depMode; @@ -178,6 +182,7 @@ Collections.EMPTY_MAP, getClass().getClassLoader(), * * @throws Exception if error occur. */ + @Test public void testSameClassLoaderPrivateMode() throws Exception { processTestSameRemoteClassLoader(DeploymentMode.PRIVATE); } @@ -187,6 +192,7 @@ public void testSameClassLoaderPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSameClassLoaderIsolatedMode() throws Exception { processTestSameRemoteClassLoader(DeploymentMode.ISOLATED); } @@ -196,6 +202,7 @@ public void testSameClassLoaderIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testDifferentClassLoaderPrivateMode() throws Exception { processTestDifferentRemoteClassLoader(DeploymentMode.PRIVATE); } @@ -205,6 +212,7 @@ public void testDifferentClassLoaderPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testDifferentClassLoaderIsolatedMode() throws Exception { processTestDifferentRemoteClassLoader(DeploymentMode.ISOLATED); } @@ -289,4 +297,4 @@ public static class GridP2PRemoteTestTask extends ComputeTaskAdapter 0 : "Result of execution is: " + res + " for more information see GridP2PTestJob"; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PTimeoutSelfTest.java index 56aab0eedeb64..0cd4e7bfca506 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PTimeoutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PTimeoutSelfTest.java @@ -28,12 +28,16 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PTimeoutSelfTest extends GridCommonAbstractTest { /** Current deployment mode. Used in {@link #getConfiguration(String)}. */ private DeploymentMode depMode; @@ -138,6 +142,7 @@ private void processFilterTest(DeploymentMode depMode) throws Exception { * * @throws Exception if error occur. */ + @Test public void testPrivateMode() throws Exception { processTest(DeploymentMode.PRIVATE); } @@ -147,6 +152,7 @@ public void testPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testIsolatedMode() throws Exception { processTest(DeploymentMode.ISOLATED); } @@ -156,6 +162,7 @@ public void testIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { processTest(DeploymentMode.CONTINUOUS); } @@ -165,6 +172,7 @@ public void testContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { processTest(DeploymentMode.SHARED); } @@ -174,6 +182,7 @@ public void testSharedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testFilterPrivateMode() throws Exception { processFilterTest(DeploymentMode.PRIVATE); } @@ -183,6 +192,7 @@ public void testFilterPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testFilterIsolatedMode() throws Exception { processFilterTest(DeploymentMode.ISOLATED); } @@ -192,6 +202,7 @@ public void testFilterIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testFilterContinuousMode() throws Exception { processFilterTest(DeploymentMode.CONTINUOUS); } @@ -201,7 +212,8 @@ public void testFilterContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testFilterSharedMode() throws Exception { processFilterTest(DeploymentMode.SHARED); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PUndeploySelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PUndeploySelfTest.java index 4eae06479d5dd..42eae7d8f3e14 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PUndeploySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PUndeploySelfTest.java @@ -31,12 +31,16 @@ import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PUndeploySelfTest extends GridCommonAbstractTest { /** Current deployment mode. Used in {@link #getConfiguration(String)}. */ private DeploymentMode depMode; @@ -171,6 +175,7 @@ private void processTestUndeployP2PTasks(DeploymentMode depMode) throws Exceptio * * @throws Exception if error occur. */ + @Test public void testUndeployLocalPrivateMode() throws Exception { processTestUndeployLocalTasks(DeploymentMode.PRIVATE); } @@ -180,6 +185,7 @@ public void testUndeployLocalPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testUndeployLocalIsolatedMode() throws Exception { processTestUndeployLocalTasks(DeploymentMode.ISOLATED); } @@ -189,6 +195,7 @@ public void testUndeployLocalIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testUndeployLocalContinuousMode() throws Exception { processTestUndeployLocalTasks(DeploymentMode.CONTINUOUS); } @@ -198,6 +205,7 @@ public void testUndeployLocalContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testUndeployLocalSharedMode() throws Exception { processTestUndeployLocalTasks(DeploymentMode.SHARED); } @@ -207,6 +215,7 @@ public void testUndeployLocalSharedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testUndeployP2PPrivateMode() throws Exception { processTestUndeployP2PTasks(DeploymentMode.PRIVATE); } @@ -216,6 +225,7 @@ public void testUndeployP2PPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testUndeployP2PIsolatedMode() throws Exception { processTestUndeployP2PTasks(DeploymentMode.ISOLATED); } @@ -225,6 +235,7 @@ public void testUndeployP2PIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testUndeployP2PContinuousMode() throws Exception { processTestUndeployP2PTasks(DeploymentMode.CONTINUOUS); } @@ -234,7 +245,8 @@ public void testUndeployP2PContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testUndeployP2PSharedMode() throws Exception { processTestUndeployP2PTasks(DeploymentMode.SHARED); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/P2PScanQueryUndeployTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/P2PScanQueryUndeployTest.java index 73ce917d12cd6..b16fa98b1e837 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/P2PScanQueryUndeployTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/P2PScanQueryUndeployTest.java @@ -44,8 +44,12 @@ import org.apache.ignite.testframework.GridTestExternalClassLoader; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class P2PScanQueryUndeployTest extends GridCommonAbstractTest { /** Predicate classname. */ private static final String PREDICATE_CLASSNAME = "org.apache.ignite.tests.p2p.AlwaysTruePredicate"; @@ -108,6 +112,7 @@ public class P2PScanQueryUndeployTest extends GridCommonAbstractTest { * * @throws Exception if test failed. */ + @Test public void testAfterClientDisconnect() throws Exception { ClassLoader extClsLdr = new GridTestExternalClassLoader(new URL[] {new URL(GridTestProperties.getProperty("p2p.uri.cls"))}); diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/P2PStreamingClassLoaderTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/P2PStreamingClassLoaderTest.java index a5418132369d7..cc38f045c28b5 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/P2PStreamingClassLoaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/P2PStreamingClassLoaderTest.java @@ -27,9 +27,13 @@ import org.apache.ignite.stream.StreamTransformer; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class P2PStreamingClassLoaderTest extends GridCommonAbstractTest { /** */ private static final String ENTRY_PROCESSOR_CLASS_NAME = "org.apache.ignite.tests.p2p.NoopCacheEntryProcessor"; @@ -91,6 +95,7 @@ private void processTest() throws Exception { * * @throws Exception if error occur. */ + @Test public void testPrivateMode() throws Exception { depMode = DeploymentMode.PRIVATE; @@ -102,6 +107,7 @@ public void testPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testContinuousMode() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -113,6 +119,7 @@ public void testContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testSharedMode() throws Exception { depMode = DeploymentMode.SHARED; diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/SharedDeploymentTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/SharedDeploymentTest.java index cc0340e6c2bb8..e35468ab7eb91 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/SharedDeploymentTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/SharedDeploymentTest.java @@ -27,9 +27,13 @@ import java.lang.reflect.Constructor; import java.net.URL; import java.util.Collection; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class SharedDeploymentTest extends GridCommonAbstractTest { /** */ private static final String RUN_CLS = "org.apache.ignite.tests.p2p.compute.ExternalCallable"; @@ -50,6 +54,7 @@ public class SharedDeploymentTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testDeploymentFromSecondAndThird() throws Exception { try { startGrid(1); diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformDefaultJavaObjectFactorySelfTest.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformDefaultJavaObjectFactorySelfTest.java index 45fda4fab70b2..851c4829dabbd 100644 --- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformDefaultJavaObjectFactorySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformDefaultJavaObjectFactorySelfTest.java @@ -29,11 +29,14 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Dedicated tests for {@link PlatformDefaultJavaObjectFactory}. */ -@SuppressWarnings("ThrowableResultOfMethodCallIgnored") +@RunWith(JUnit4.class) public class PlatformDefaultJavaObjectFactorySelfTest extends GridCommonAbstractTest { /** Name of the class. */ private static final String CLS_NAME = TestJavaObject.class.getName(); @@ -44,6 +47,7 @@ public class PlatformDefaultJavaObjectFactorySelfTest extends GridCommonAbstract /** * Test normal object creation. */ + @Test public void testNormal() { final PlatformDefaultJavaObjectFactory factory = new PlatformDefaultJavaObjectFactory(); @@ -77,6 +81,7 @@ public void testNormal() { /** * Test object creation with boxed property. */ + @Test public void testBoxedProperty() { final PlatformDefaultJavaObjectFactory factory = new PlatformDefaultJavaObjectFactory(); @@ -90,6 +95,7 @@ public void testBoxedProperty() { /** * Test object creation without properties. */ + @Test public void testNoProperties() { final PlatformDefaultJavaObjectFactory factory = new PlatformDefaultJavaObjectFactory(); @@ -103,6 +109,7 @@ public void testNoProperties() { /** * Test object creation with invalid property name. */ + @Test public void testInvalidPropertyName() { final PlatformDefaultJavaObjectFactory factory = new PlatformDefaultJavaObjectFactory(); @@ -118,6 +125,7 @@ public void testInvalidPropertyName() { /** * Test object creation with invalid property value. */ + @Test public void testInvalidPropertyValue() { final PlatformDefaultJavaObjectFactory factory = new PlatformDefaultJavaObjectFactory(); @@ -133,6 +141,7 @@ public void testInvalidPropertyValue() { /** * Test object creation without default constructor. */ + @Test public void testNoDefaultConstructor() { final PlatformDefaultJavaObjectFactory factory = new PlatformDefaultJavaObjectFactory(); @@ -148,6 +157,7 @@ public void testNoDefaultConstructor() { /** * Test object creation with null class name. */ + @Test public void testNullClassName() { final PlatformDefaultJavaObjectFactory factory = new PlatformDefaultJavaObjectFactory(); @@ -171,6 +181,7 @@ public void testNullClassName() { /** * Test object creation with invalid class name. */ + @Test public void testInvalidClassName() { final PlatformDefaultJavaObjectFactory factory = new PlatformDefaultJavaObjectFactory(); diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformJavaObjectFactoryProxySelfTest.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformJavaObjectFactoryProxySelfTest.java index 832af7ca219dd..38ad669cd278f 100644 --- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformJavaObjectFactoryProxySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformJavaObjectFactoryProxySelfTest.java @@ -33,11 +33,14 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Dedicated tests for {@link PlatformJavaObjectFactoryProxy}. */ -@SuppressWarnings("ThrowableResultOfMethodCallIgnored") +@RunWith(JUnit4.class) public class PlatformJavaObjectFactoryProxySelfTest extends GridCommonAbstractTest { /** Name of the class. */ private static final String CLS_NAME = TestJavaObject.class.getName(); @@ -64,6 +67,7 @@ public class PlatformJavaObjectFactoryProxySelfTest extends GridCommonAbstractTe /** * Test normal object creation using default factory. */ + @Test public void testDefaultFactoryNormal() { Map props = new HashMap<>(); @@ -96,6 +100,7 @@ public void testDefaultFactoryNormal() { /** * Test normal object creation using custom factory. */ + @Test public void testCustomFactoryNormal() { Map props = new HashMap<>(); @@ -130,6 +135,7 @@ public void testCustomFactoryNormal() { /** * Test object creation with boxed property. */ + @Test public void testCustomFactoryBoxedProperty() { PlatformJavaObjectFactoryProxy proxy = proxyForCustom(NO_DFLT_CTOR_FACTORY_CLS_NAME, Collections.singletonMap("fIntBoxed", (Object)1)); @@ -142,6 +148,7 @@ public void testCustomFactoryBoxedProperty() { /** * Test object creation without properties. */ + @Test public void testCustomFactoryNoProperties() { PlatformJavaObjectFactoryProxy proxy = proxyForCustom(NO_DFLT_CTOR_FACTORY_CLS_NAME, Collections.emptyMap()); @@ -154,6 +161,7 @@ public void testCustomFactoryNoProperties() { /** * Test object creation with invalid property name. */ + @Test public void testCustomFactoryInvalidPropertyName() { final PlatformJavaObjectFactoryProxy proxy = proxyForCustom(NO_DFLT_CTOR_FACTORY_CLS_NAME, Collections.singletonMap("invalid", (Object)1)); @@ -168,6 +176,7 @@ public void testCustomFactoryInvalidPropertyName() { /** * Test object creation with invalid property value. */ + @Test public void testCustomFactoryInvalidPropertyValue() { final PlatformJavaObjectFactoryProxy proxy = proxyForCustom(NO_DFLT_CTOR_FACTORY_CLS_NAME, Collections.singletonMap("fInt", (Object)1L)); @@ -182,6 +191,7 @@ public void testCustomFactoryInvalidPropertyValue() { /** * Test object creation with null class name. */ + @Test public void testCustomFactoryNullClassName() { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { @@ -199,6 +209,7 @@ public void testCustomFactoryNullClassName() { /** * Test object creation with invalid class name. */ + @Test public void testCustomFactoryInvalidClassName() { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { diff --git a/modules/core/src/test/java/org/apache/ignite/plugin/security/SecurityPermissionSetBuilderTest.java b/modules/core/src/test/java/org/apache/ignite/plugin/security/SecurityPermissionSetBuilderTest.java index 0ac7bc739f179..f6dd03992857d 100644 --- a/modules/core/src/test/java/org/apache/ignite/plugin/security/SecurityPermissionSetBuilderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/plugin/security/SecurityPermissionSetBuilderTest.java @@ -25,11 +25,17 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.plugin.security.SecurityPermission.ADMIN_VIEW; +import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_CREATE; +import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_DESTROY; import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_PUT; import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_READ; import static org.apache.ignite.plugin.security.SecurityPermission.CACHE_REMOVE; +import static org.apache.ignite.plugin.security.SecurityPermission.JOIN_AS_SERVER; import static org.apache.ignite.plugin.security.SecurityPermission.SERVICE_DEPLOY; import static org.apache.ignite.plugin.security.SecurityPermission.SERVICE_INVOKE; import static org.apache.ignite.plugin.security.SecurityPermission.EVENTS_ENABLE; @@ -40,10 +46,12 @@ /** * Test for check correct work {@link SecurityPermissionSetBuilder permission builder} */ +@RunWith(JUnit4.class) public class SecurityPermissionSetBuilderTest extends GridCommonAbstractTest { /** */ - @SuppressWarnings({"ThrowableNotThrown", "ArraysAsListWithZeroOrOneArgument"}) + @SuppressWarnings({"ThrowableNotThrown"}) + @Test public void testPermissionBuilder() { SecurityBasicPermissionSet exp = new SecurityBasicPermissionSet(); @@ -65,7 +73,7 @@ public void testPermissionBuilder() { exp.setServicePermissions(permSrvc); - exp.setSystemPermissions(permissions(ADMIN_VIEW, EVENTS_ENABLE)); + exp.setSystemPermissions(permissions(ADMIN_VIEW, EVENTS_ENABLE, JOIN_AS_SERVER, CACHE_CREATE, CACHE_DESTROY)); final SecurityPermissionSetBuilder permsBuilder = new SecurityPermissionSetBuilder(); @@ -80,7 +88,7 @@ public void testPermissionBuilder() { assertThrows(log, new Callable() { @Override public Object call() throws Exception { - permsBuilder.appendTaskPermissions("task", CACHE_READ); + permsBuilder.appendTaskPermissions("task", CACHE_READ, JOIN_AS_SERVER); return null; } }, IgniteException.class, @@ -93,7 +101,7 @@ public void testPermissionBuilder() { return null; } }, IgniteException.class, - "you can assign permission only start with [EVENTS_, ADMIN_], but you try TASK_EXECUTE" + "you can assign permission only start with [EVENTS_, ADMIN_, CACHE_CREATE, CACHE_DESTROY, JOIN_AS_SERVER], but you try TASK_EXECUTE" ); assertThrows(log, new Callable() { @@ -102,7 +110,16 @@ public void testPermissionBuilder() { return null; } }, IgniteException.class, - "you can assign permission only start with [EVENTS_, ADMIN_], but you try SERVICE_INVOKE" + "you can assign permission only start with [EVENTS_, ADMIN_, CACHE_CREATE, CACHE_DESTROY, JOIN_AS_SERVER], but you try SERVICE_INVOKE" + ); + + assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + permsBuilder.appendCachePermissions("cache", CACHE_CREATE); + return null; + } + }, IgniteException.class, + "CACHE_CREATE should be assigned as system permission, not cache permission" ); permsBuilder @@ -116,7 +133,9 @@ public void testPermissionBuilder() { .appendServicePermissions("service2", SERVICE_INVOKE) .appendServicePermissions("service2", SERVICE_INVOKE) .appendSystemPermissions(ADMIN_VIEW) - .appendSystemPermissions(ADMIN_VIEW, EVENTS_ENABLE); + .appendSystemPermissions(ADMIN_VIEW, EVENTS_ENABLE) + .appendSystemPermissions(JOIN_AS_SERVER) + .appendSystemPermissions(CACHE_CREATE, CACHE_DESTROY); SecurityPermissionSet actual = permsBuilder.build(); diff --git a/modules/core/src/test/java/org/apache/ignite/services/ServiceThreadPoolSelfTest.java b/modules/core/src/test/java/org/apache/ignite/services/ServiceThreadPoolSelfTest.java index 40efdfaa91d4f..f0ebd69be992e 100644 --- a/modules/core/src/test/java/org/apache/ignite/services/ServiceThreadPoolSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/services/ServiceThreadPoolSelfTest.java @@ -20,27 +20,16 @@ import org.apache.ignite.Ignite; import org.apache.ignite.Ignition; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test verifying that services thread pool is properly used. */ +@RunWith(JUnit4.class) public class ServiceThreadPoolSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -49,6 +38,7 @@ public class ServiceThreadPoolSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDefaultPoolSize() throws Exception { Ignite ignite = startGrid("grid", new IgniteConfiguration()); @@ -61,6 +51,7 @@ public void testDefaultPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInheritedPoolSize() throws Exception { Ignite ignite = startGrid("grid", new IgniteConfiguration().setPublicThreadPoolSize(42)); @@ -73,6 +64,7 @@ public void testInheritedPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomPoolSize() throws Exception { Ignite ignite = startGrid("grid", new IgniteConfiguration().setServiceThreadPoolSize(42)); @@ -85,6 +77,7 @@ public void testCustomPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExecution() throws Exception { startGrid(0); // Server. diff --git a/modules/core/src/test/java/org/apache/ignite/session/GridSessionCancelSiblingsFromFutureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/session/GridSessionCancelSiblingsFromFutureSelfTest.java index 68a6771e334ff..8074d75efbb1e 100644 --- a/modules/core/src/test/java/org/apache/ignite/session/GridSessionCancelSiblingsFromFutureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/session/GridSessionCancelSiblingsFromFutureSelfTest.java @@ -45,12 +45,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test of session siblings cancellation from future. */ @SuppressWarnings({"CatchGenericClass"}) @GridCommonTest(group = "Task Session") +@RunWith(JUnit4.class) public class GridSessionCancelSiblingsFromFutureSelfTest extends GridCommonAbstractTest { /** */ private static final int WAIT_TIME = 20000; @@ -95,6 +99,7 @@ public GridSessionCancelSiblingsFromFutureSelfTest() { /** * @throws Exception if failed */ + @Test public void testCancelSiblings() throws Exception { refreshInitialData(); @@ -105,6 +110,7 @@ public void testCancelSiblings() throws Exception { /** * @throws Exception if failed */ + @Test public void testMultiThreaded() throws Exception { refreshInitialData(); @@ -284,4 +290,4 @@ private static class GridTaskSessionTestTask extends ComputeTaskSplitAdapter { return results.get(0).getData(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/session/GridSessionJobWaitTaskAttributeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/session/GridSessionJobWaitTaskAttributeSelfTest.java index e7490e963104e..4c12eae257bb8 100644 --- a/modules/core/src/test/java/org/apache/ignite/session/GridSessionJobWaitTaskAttributeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/session/GridSessionJobWaitTaskAttributeSelfTest.java @@ -43,12 +43,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings({"CatchGenericClass"}) @GridCommonTest(group = "Task Session") +@RunWith(JUnit4.class) public class GridSessionJobWaitTaskAttributeSelfTest extends GridCommonAbstractTest { /** */ public static final int SPLIT_COUNT = 5; @@ -79,6 +83,7 @@ public GridSessionJobWaitTaskAttributeSelfTest() { /** * @throws Exception if failed. */ + @Test public void testSetAttribute() throws Exception { for (int i = 0; i < EXEC_COUNT; i++) checkTask(i); @@ -87,6 +92,7 @@ public void testSetAttribute() throws Exception { /** * @throws Exception if failed. */ + @Test public void testMultiThreaded() throws Exception { final GridThreadSerialNumber sNum = new GridThreadSerialNumber(); @@ -221,4 +227,4 @@ private static class GridTaskSessionTestTask extends ComputeTaskSplitAdapter getAttributes() { return attrs; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetTaskAttributeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetTaskAttributeSelfTest.java index ec8d5a3bf7579..d4764e959ed36 100644 --- a/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetTaskAttributeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetTaskAttributeSelfTest.java @@ -39,12 +39,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings({"CatchGenericClass"}) @GridCommonTest(group = "Task Session") +@RunWith(JUnit4.class) public class GridSessionSetTaskAttributeSelfTest extends GridCommonAbstractTest { /** */ public static final int SPLIT_COUNT = 5; @@ -60,6 +64,7 @@ public GridSessionSetTaskAttributeSelfTest() { /** * @throws Exception if failed. */ + @Test public void testSetAttribute() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -72,6 +77,7 @@ public void testSetAttribute() throws Exception { /** * @throws Exception if failed. */ + @Test public void testMultiThreaded() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); @@ -200,4 +206,4 @@ private static class GridTaskSessionTestTask extends ComputeTaskSplitAdapter SPI implementation class. */ +@RunWith(JUnit4.class) public abstract class GridSpiStartStopAbstractTest extends GridSpiAbstractTest { /** */ public static final int COUNT = 5; @@ -42,6 +46,7 @@ protected int getCount() { /** * @throws Exception If test failed. */ + @Test public void testStartStop() throws Exception { info("Spi start-stop test [count=" + getCount() + ", spi=" + getSpiClass().getSimpleName() + ']'); @@ -67,6 +72,7 @@ public void testStartStop() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testStop() throws Exception { IgniteSpi spi = getSpiClass().newInstance(); @@ -76,4 +82,4 @@ public void testStop() throws Exception { spi.spiStop(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/GridTcpSpiForwardingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/GridTcpSpiForwardingSelfTest.java index 5d8e31631b530..f877c23a0c433 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/GridTcpSpiForwardingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/GridTcpSpiForwardingSelfTest.java @@ -40,10 +40,14 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link TcpDiscoverySpi} and {@link TcpCommunicationSpi}. */ +@RunWith(JUnit4.class) public class GridTcpSpiForwardingSelfTest extends GridCommonAbstractTest { /** */ private static final int locPort1 = 47500; @@ -142,6 +146,7 @@ else if (getTestIgniteInstanceName(1).equals(igniteInstanceName)) { /** * @throws Exception If any error occurs. */ + @Test public void testCustomResolver() throws Exception { final Map> map = new HashMap<>(); @@ -162,6 +167,7 @@ public void testCustomResolver() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBasicResolverMapPorts() throws Exception { Map map = new HashMap<>(); @@ -178,6 +184,7 @@ public void testBasicResolverMapPorts() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBasicResolverMapAddress() throws Exception { Map map = new HashMap<>(); @@ -193,6 +200,7 @@ public void testBasicResolverMapAddress() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBasicResolverErrors() throws Exception { GridTestUtils.assertThrows( log, diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/GridCheckpointSpiAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/GridCheckpointSpiAbstractTest.java index 489f53ebab0a1..92cf0b4a9235a 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/GridCheckpointSpiAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/GridCheckpointSpiAbstractTest.java @@ -19,12 +19,15 @@ import org.apache.ignite.GridTestIoUtils; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid checkpoint SPI abstract test. * @param Concrete SPI class. */ -@SuppressWarnings({"CatchGenericClass"}) +@RunWith(JUnit4.class) public abstract class GridCheckpointSpiAbstractTest extends GridSpiAbstractTest { /** */ @@ -36,6 +39,7 @@ public abstract class GridCheckpointSpiAbstractTest /** * @throws Exception Thrown in case of any errors. */ + @Test public void testSaveLoadRemoveWithoutExpire() throws Exception { String dataPrefix = "Test check point data "; @@ -86,6 +90,7 @@ public void testSaveLoadRemoveWithoutExpire() throws Exception { /** * @throws Exception Thrown in case of any errors. */ + @Test public void testSaveWithExpire() throws Exception { // Save states. for (int i = 0; i < CHECK_POINT_COUNT; i++) { @@ -112,6 +117,7 @@ public void testSaveWithExpire() throws Exception { /** * @throws Exception Thrown in case of any errors. */ + @Test public void testDuplicates() throws Exception { int idx1 = 1; int idx2 = 2; @@ -138,4 +144,4 @@ public void testDuplicates() throws Exception { assert finalSerState == null : "Checkpoint state should not be loaded with key: " + CHECK_POINT_KEY_PREFIX; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiConfigSelfTest.java index a933333f36196..af0dcdd6a7ed5 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiConfigSelfTest.java @@ -19,17 +19,22 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid cache checkpoint SPI config self test. */ @GridSpiTest(spi = CacheCheckpointSpi.class, group = "Checkpoint SPI") +@RunWith(JUnit4.class) public class CacheCheckpointSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new CacheCheckpointSpi(), "cacheName", null); checkNegativeSpiProperty(new CacheCheckpointSpi(), "cacheName", ""); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiSecondCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiSecondCacheSelfTest.java index 43977834a005d..e75f6cebc77fb 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiSecondCacheSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiSecondCacheSelfTest.java @@ -20,10 +20,10 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -31,10 +31,8 @@ /** * Test for cache checkpoint SPI with second cache configured. */ +@RunWith(JUnit4.class) public class CacheCheckpointSpiSecondCacheSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Checkpoints cache name. */ private static final String CP_CACHE = "checkpoints"; @@ -47,12 +45,6 @@ public CacheCheckpointSpiSecondCacheSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg1 = defaultCacheConfiguration(); cacheCfg1.setName(DEFAULT_CACHE_NAME); @@ -79,6 +71,7 @@ public CacheCheckpointSpiSecondCacheSelfTest() { /** * @throws Exception If failed. */ + @Test public void testSecondCachePutRemove() throws Exception { IgniteCache data = grid().cache(DEFAULT_CACHE_NAME); IgniteCache cp = grid().cache(CP_CACHE); @@ -101,4 +94,4 @@ public void testSecondCachePutRemove() throws Exception { assertEquals("1", cp.get(1)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/jdbc/JdbcCheckpointSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/jdbc/JdbcCheckpointSpiConfigSelfTest.java index 1affc9cb64ae3..53d28de207b2e 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/jdbc/JdbcCheckpointSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/jdbc/JdbcCheckpointSpiConfigSelfTest.java @@ -21,6 +21,9 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.hsqldb.jdbc.jdbcDataSource; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.spi.checkpoint.jdbc.JdbcCheckpointSpi.DFLT_CHECKPOINT_TABLE_NAME; import static org.apache.ignite.spi.checkpoint.jdbc.JdbcCheckpointSpi.DFLT_EXPIRE_DATE_FIELD_NAME; @@ -33,10 +36,12 @@ * Grid jdbc checkpoint SPI config self test. */ @GridSpiTest(spi = JdbcCheckpointSpi.class, group = "Checkpoint SPI") +@RunWith(JUnit4.class) public class JdbcCheckpointSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new JdbcCheckpointSpi(), "dataSource", null); @@ -79,4 +84,4 @@ public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(spi, "expireDateFieldType", null); checkNegativeSpiProperty(spi, "expireDateFieldType", ""); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiConfigSelfTest.java index 983a35860fc9d..54757f01096b1 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiConfigSelfTest.java @@ -20,17 +20,22 @@ import java.util.LinkedList; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid shared file system checkpoint SPI config self test. */ @GridSpiTest(spi = SharedFsCheckpointSpi.class, group = "Checkpoint SPI") +@RunWith(JUnit4.class) public class GridSharedFsCheckpointSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new SharedFsCheckpointSpi(), "directoryPaths", null); checkNegativeSpiProperty(new SharedFsCheckpointSpi(), "directoryPaths", new LinkedList()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultiThreadedSelfTest.java index 85c19bcd6e789..df1e6f42f1f41 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultiThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultiThreadedSelfTest.java @@ -31,11 +31,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests SPI in multi-threaded environment. */ @GridSpiTest(spi = SharedFsCheckpointSpi.class, group = "Checkpoint SPI") +@RunWith(JUnit4.class) public class GridSharedFsCheckpointSpiMultiThreadedSelfTest extends GridSpiAbstractTest { /** */ @@ -65,6 +69,7 @@ public Collection getDirectoryPaths() { * * @throws Exception If failed. */ + @Test public void testSpi() throws Exception { final AtomicInteger writeFinished = new AtomicInteger(); @@ -198,4 +203,4 @@ void deleteFolder(File f) { @Override protected void afterTestsStopped() throws Exception { deleteFolder(new File(U.getIgniteHome(), PATH)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java index 2eea7c16d5dd5..22bd4cf920196 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/sharedfs/GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.java @@ -27,11 +27,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests multiple shared directories. */ @GridSpiTest(spi = SharedFsCheckpointSpi.class, group = "Checkpoint SPI") +@RunWith(JUnit4.class) public class GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest extends GridSpiAbstractTest { /** */ @@ -59,6 +63,7 @@ public Collection getDirectoryPaths() { /** * @throws Exception If failed. */ + @Test public void testMultipleSharedDirectories() throws Exception { String data = "Test check point data."; @@ -117,4 +122,4 @@ public void testMultipleSharedDirectories() throws Exception { assert error : "Check point should not be saved."; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/collision/fifoqueue/GridFifoQueueCollisionSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/collision/fifoqueue/GridFifoQueueCollisionSpiConfigSelfTest.java index 5b5cdb201a6ad..fb0a298c07503 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/collision/fifoqueue/GridFifoQueueCollisionSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/collision/fifoqueue/GridFifoQueueCollisionSpiConfigSelfTest.java @@ -19,17 +19,22 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Unit tests for {@link FifoQueueCollisionSpi} config. */ @GridSpiTest(spi = FifoQueueCollisionSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridFifoQueueCollisionSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new FifoQueueCollisionSpi(), "parallelJobsNumber", 0); checkNegativeSpiProperty(new FifoQueueCollisionSpi(), "waitingJobsNumber", -1); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/collision/fifoqueue/GridFifoQueueCollisionSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/collision/fifoqueue/GridFifoQueueCollisionSpiSelfTest.java index 1195bcb69e9f1..ec0f57161b40f 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/collision/fifoqueue/GridFifoQueueCollisionSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/collision/fifoqueue/GridFifoQueueCollisionSpiSelfTest.java @@ -26,15 +26,20 @@ import org.apache.ignite.spi.collision.GridTestCollisionTaskSession; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Unit tests for {@link FifoQueueCollisionSpi}. */ @GridSpiTest(spi = FifoQueueCollisionSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridFifoQueueCollisionSpiSelfTest extends GridSpiAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCollision0() throws Exception { int activeCnt = 2; @@ -67,6 +72,7 @@ public void testCollision0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollision1() throws Exception { getSpi().setParallelJobsNumber(32); @@ -95,6 +101,7 @@ public void testCollision1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollision2() throws Exception { getSpi().setParallelJobsNumber(3); @@ -116,6 +123,7 @@ public void testCollision2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollision3() throws Exception { getSpi().setParallelJobsNumber(15); @@ -175,4 +183,4 @@ private GridCollisionTestContext createContext(int activeNum, int passiveNum) { return new GridCollisionTestContext(activeJobs, passiveJobs); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiAttributesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiAttributesSelfTest.java index 2eea92abd73f0..da1b80d017159 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiAttributesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiAttributesSelfTest.java @@ -34,6 +34,9 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SPI_CLASS; import static org.apache.ignite.spi.collision.jobstealing.JobStealingCollisionSpi.WAIT_JOBS_THRESHOLD_NODE_ATTR; @@ -42,6 +45,7 @@ * Job stealing attributes test. */ @GridSpiTest(spi = JobStealingCollisionSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridJobStealingCollisionSpiAttributesSelfTest extends GridSpiAbstractTest { /** */ private static GridTestNode rmtNode; @@ -129,6 +133,7 @@ private void addSpiDependency(GridTestNode node) throws Exception { /** * @throws Exception If test failed. */ + @Test public void testSameAttribute() throws Exception { List waitCtxs = Collections.emptyList(); @@ -162,6 +167,7 @@ public void testSameAttribute() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testEmptyRemoteAttribute() throws Exception { List waitCtxs = Collections.emptyList(); @@ -189,6 +195,7 @@ public void testEmptyRemoteAttribute() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testEmptyLocalAttribute() throws Exception { // Collision SPI does not allow to send more than 1 message in a // certain period of time (see getMessageExpireTime() method). @@ -221,6 +228,7 @@ public void testEmptyLocalAttribute() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDiffAttribute() throws Exception { List waitCtxs = Collections.emptyList(); @@ -254,6 +262,7 @@ public void testDiffAttribute() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testBothEmptyAttribute() throws Exception { // Collision SPI does not allow to send more than 1 message in a // certain period of time (see getMessageExpireTime() method). @@ -281,6 +290,7 @@ public void testBothEmptyAttribute() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testIsStealingOff() throws Exception { // Collision SPI does not allow to send more than 1 message in a // certain period of time (see getMessageExpireTime() method). @@ -309,6 +319,7 @@ public void testIsStealingOff() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testIsStealingOn() throws Exception { // Collision SPI does not allow to send more than 1 message in a // certain period of time (see getMessageExpireTime() method). @@ -333,4 +344,4 @@ public void testIsStealingOn() throws Exception { // Message should not be sent to remote node because stealing is on assert msg != null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiConfigSelfTest.java index 177275451b37b..d7db2a77925e8 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiConfigSelfTest.java @@ -19,19 +19,24 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Job stealing collision SPI config test. */ @GridSpiTest(spi = JobStealingCollisionSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridJobStealingCollisionSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new JobStealingCollisionSpi(), "messageExpireTime", 0); checkNegativeSpiProperty(new JobStealingCollisionSpi(), "waitJobsThreshold", -1); checkNegativeSpiProperty(new JobStealingCollisionSpi(), "activeJobsThreshold", -1); checkNegativeSpiProperty(new JobStealingCollisionSpi(), "maximumStealingAttempts", 0); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiCustomTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiCustomTopologySelfTest.java index 2b88dbb9db807..f061cbbc467e2 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiCustomTopologySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiCustomTopologySelfTest.java @@ -38,6 +38,9 @@ import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SPI_CLASS; import static org.apache.ignite.spi.collision.jobstealing.JobStealingCollisionSpi.THIEF_NODE_ATTR; @@ -46,6 +49,7 @@ * Job stealing collision SPI topology test. */ @GridSpiTest(spi = JobStealingCollisionSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridJobStealingCollisionSpiCustomTopologySelfTest extends GridSpiAbstractTest { /** */ @@ -125,6 +129,7 @@ private void checkNoAction(GridTestCollisionJobContext ctx) { /** * @throws Exception If test failed. */ + @Test public void testThiefNodeNotInTopology() throws Exception { List waitCtxs = new ArrayList<>(2); @@ -177,4 +182,4 @@ private GridTestTaskSession createTaskSession(final ClusterNode node) { } }; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiSelfTest.java index 05e0cee707687..5e3354873c4ab 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/collision/jobstealing/GridJobStealingCollisionSpiSelfTest.java @@ -40,6 +40,9 @@ import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SPI_CLASS; import static org.apache.ignite.spi.collision.jobstealing.JobStealingCollisionSpi.STEALING_ATTEMPT_COUNT_ATTR; @@ -50,6 +53,7 @@ * Job stealing SPI test. */ @GridSpiTest(spi = JobStealingCollisionSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridJobStealingCollisionSpiSelfTest extends GridSpiAbstractTest { /** */ public GridJobStealingCollisionSpiSelfTest() { @@ -148,6 +152,7 @@ private void checkNoAction(GridTestCollisionJobContext ctx) { /** * @throws Exception If test failed. */ + @Test public void testTwoPassiveJobs() throws Exception { final List waitCtxs = new ArrayList<>(2); final List activeCtxs = new ArrayList<>(1); @@ -184,6 +189,7 @@ public void testTwoPassiveJobs() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testOnePassiveOneActiveJobs() throws Exception { List waitCtxs = new ArrayList<>(1); @@ -217,6 +223,7 @@ public void testOnePassiveOneActiveJobs() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMultiplePassiveOneActive() throws Exception { List waitCtxs = new ArrayList<>(2); @@ -254,6 +261,7 @@ public void testMultiplePassiveOneActive() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMultiplePassiveZeroActive() throws Exception { final List waitCtxs = new ArrayList<>(2); final List activeCtxs = new ArrayList<>(2); @@ -309,6 +317,7 @@ public GridTestTaskSession createTaskSession() { /** * @throws Exception If test failed. */ + @Test public void testOnePassiveZeroActive() throws Exception { List waitCtxs = new ArrayList<>(1); @@ -335,6 +344,7 @@ public void testOnePassiveZeroActive() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testZeroPassiveOneActive() throws Exception { Collection empty = Collections.emptyList(); @@ -362,6 +372,7 @@ public void testZeroPassiveOneActive() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testZeroPassiveZeroActive() throws Exception { Collection empty = Collections.emptyList(); @@ -383,6 +394,7 @@ public void testZeroPassiveZeroActive() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMaxHopsExceeded() throws Exception { Collection waitCtxs = new ArrayList<>(2); @@ -424,4 +436,4 @@ public void testMaxHopsExceeded() throws Exception { assert msg == null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiConfigSelfTest.java index a303da89dd7d9..53bb96f36689b 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiConfigSelfTest.java @@ -19,16 +19,21 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Priority queue collision SPI config test. */ @GridSpiTest(spi = PriorityQueueCollisionSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridPriorityQueueCollisionSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new PriorityQueueCollisionSpi(), "parallelJobsNumber", 0); checkNegativeSpiProperty(new PriorityQueueCollisionSpi(), "waitingJobsNumber", -1); @@ -36,4 +41,4 @@ public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new PriorityQueueCollisionSpi(), "priorityAttributeKey", null); checkNegativeSpiProperty(new PriorityQueueCollisionSpi(), "jobPriorityAttributeKey", null); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiSelfTest.java index 9484dec8842ea..4f2a3fe6dbd84 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/collision/priorityqueue/GridPriorityQueueCollisionSpiSelfTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.spi.collision.priorityqueue.PriorityQueueCollisionSpi.DFLT_JOB_PRIORITY_ATTRIBUTE_KEY; import static org.apache.ignite.spi.collision.priorityqueue.PriorityQueueCollisionSpi.DFLT_PARALLEL_JOBS_NUM; @@ -39,6 +42,7 @@ * Priority queue collision SPI test. */ @GridSpiTest(spi = PriorityQueueCollisionSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridPriorityQueueCollisionSpiSelfTest extends GridSpiAbstractTest { /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { @@ -49,6 +53,7 @@ public class GridPriorityQueueCollisionSpiSelfTest extends GridSpiAbstractTest

    activeJobs = makeContextList(null); List passiveJobs = makeContextList(null); @@ -115,6 +121,7 @@ public void testCollision() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollision0() throws Exception { List activeJobs = makeContextList(null); List passiveJobs = makeContextList(null); @@ -137,7 +144,7 @@ public void testCollision0() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"RedundantTypeArguments"}) + @Test public void testCollision1() throws Exception { List activeJobs = makeContextList(null); List passiveJobs = makeContextList(null); @@ -176,6 +183,7 @@ public void testCollision1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollision2() throws Exception { List activeJobs = makeContextList(null); List passiveJobs = makeContextList(null); @@ -198,6 +206,7 @@ public void testCollision2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollision3() throws Exception { List activeJobs = makeContextList(null); List passiveJobs = makeContextList(null); @@ -220,6 +229,7 @@ public void testCollision3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollisionEmpty() throws Exception { Collection activeJobs = new ArrayList<>(); Collection passiveJobs = new ArrayList<>(); @@ -233,6 +243,7 @@ public void testCollisionEmpty() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollisionWithoutPriorityAttribute() throws Exception { List activeJobs = makeContextList(null); List passiveJobs = makeContextList(null); @@ -242,7 +253,7 @@ public void testCollisionWithoutPriorityAttribute() throws Exception { ((GridTestCollisionTaskSession)ctx.getTaskSession()).setPriorityAttributeKey("bad-attr-name"); ((GridTestCollisionJobContext)ctx).setJobContext(new GridTestJobContext() { - @SuppressWarnings({"unchecked", "RedundantTypeArguments"}) + @SuppressWarnings({"RedundantTypeArguments"}) @Override public V getAttribute(K key) { if (DFLT_JOB_PRIORITY_ATTRIBUTE_KEY.equals(key)) return null; @@ -279,6 +290,7 @@ public void testCollisionWithoutPriorityAttribute() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollisionWithWrongPriorityAttribute() throws Exception { List activeJobs = makeContextList(null); List passiveJobs = makeContextList(null); @@ -335,6 +347,7 @@ public void testCollisionWithWrongPriorityAttribute() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testCollision4() throws Exception { List activeJobs = makeContextList(null, false); List passiveJobs = makeContextList(null, false); @@ -380,6 +393,7 @@ public void testCollision4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollision5() throws Exception { List activeJobs = makeContextList(null, false); List passiveJobs = makeContextList(null, false); @@ -439,4 +453,4 @@ private List makeContextList(@Nullable String attrKey, bool private List makeContextList(@Nullable String attrKey) { return makeContextList(attrKey, true); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java index e51dac8655222..26cd67f9687e9 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java @@ -44,6 +44,9 @@ import org.apache.ignite.testframework.junits.IgniteMock; import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS; @@ -51,7 +54,7 @@ * Super class for all communication self tests. * @param Type of communication SPI. */ -@SuppressWarnings({"JUnitAbstractTestClassNamingConvention"}) +@RunWith(JUnit4.class) public abstract class GridAbstractCommunicationSelfTest extends GridSpiAbstractTest { /** */ private static long msgId = 1; @@ -89,7 +92,6 @@ public abstract class GridAbstractCommunicationSelfTest { /** */ private final UUID locNodeId; @@ -153,6 +155,7 @@ protected GridAbstractCommunicationSelfTest() { /** * @throws Exception If failed. */ + @Test public void testSendToOneNode() throws Exception { info(">>> Starting send to one node test. <<<"); @@ -195,7 +198,7 @@ public void testSendToOneNode() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("WaitWithoutCorrespondingNotify") + @Test public void testSendToManyNodes() throws Exception { msgDestMap.clear(); @@ -380,4 +383,4 @@ private void startSpis() throws Exception { for (IgniteTestResources rsrcs : spiRsrcs) rsrcs.stopThreads(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java index 8ddfd440b7ac7..1a50244c5479e 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java @@ -43,10 +43,10 @@ import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -54,10 +54,8 @@ /** * Messaging test. */ +@RunWith(JUnit4.class) public class GridCacheMessageSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Sample count. */ private static final int SAMPLE_CNT = 1; @@ -106,12 +104,6 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - cfg.setIncludeEventTypes((int[])null); cfg.setFailureHandler(new TestFailureHandler()); @@ -137,6 +129,7 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSendMessage() throws Exception { try { startGridsMultiThreaded(2); @@ -151,6 +144,7 @@ public void testSendMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSendBadMessage() throws Exception { try { startGrids(2); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java index 951971d1bb254..11dd9a9158754 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java @@ -35,12 +35,12 @@ import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.communication.CommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestThread; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC; @@ -48,10 +48,8 @@ /** * Special cases for GG-2329. */ +@RunWith(JUnit4.class) public class GridCacheDhtLockBackupSelfTest extends GridCommonAbstractTest { - /** Ip-finder. */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Communication spi for grid start. */ private CommunicationSpi commSpi; @@ -69,12 +67,6 @@ public GridCacheDhtLockBackupSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration()); cfg.setMarshaller(marsh); @@ -102,7 +94,7 @@ protected CacheConfiguration cacheConfiguration() { /** * @throws Exception If test failed. */ - @SuppressWarnings({"TooBroadScope"}) + @Test public void testLock() throws Exception { final int kv = 1; diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiAbstractTest.java index e89a4c828fb75..eda8d8e8a6ea9 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiAbstractTest.java @@ -36,10 +36,14 @@ import org.apache.ignite.spi.communication.CommunicationSpi; import org.apache.ignite.spi.communication.GridAbstractCommunicationSelfTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link TcpCommunicationSpi} */ +@RunWith(JUnit4.class) abstract class GridTcpCommunicationSpiAbstractTest extends GridAbstractCommunicationSelfTest { /** */ private static final int SPI_COUNT = 3; @@ -82,6 +86,7 @@ protected GridTcpCommunicationSpiAbstractTest(boolean useShmem) { } /** {@inheritDoc} */ + @Test @Override public void testSendToManyNodes() throws Exception { super.testSendToManyNodes(); @@ -98,6 +103,7 @@ protected GridTcpCommunicationSpiAbstractTest(boolean useShmem) { /** * */ + @Test public void testCheckConnection1() { for (int i = 0; i < 100; i++) { for (Map.Entry> entry : spis.entrySet()) { @@ -120,6 +126,7 @@ public void testCheckConnection1() { /** * @throws Exception If failed. */ + @Test public void testCheckConnection2() throws Exception { final int THREADS = spis.size(); @@ -193,4 +200,4 @@ public void testCheckConnection2() throws Exception { fail("Failed to wait when clients are closed."); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java index ce96c5574e292..8683ef8ef1c9c 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java @@ -39,6 +39,7 @@ import org.apache.ignite.internal.IgniteNodeAttributes; import org.apache.ignite.internal.managers.communication.GridIoMessageFactory; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.nio.GridCommunicationClient; import org.apache.ignite.internal.util.nio.GridNioServer; @@ -58,12 +59,15 @@ import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.eclipse.jetty.util.ConcurrentHashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridSpiTest(spi = TcpCommunicationSpi.class, group = "Communication SPI") +@RunWith(JUnit4.class) public class GridTcpCommunicationSpiConcurrentConnectSelfTest extends GridSpiAbstractTest { /** */ @@ -125,7 +129,7 @@ private static class MessageListener implements CommunicationListener { private final AtomicInteger cntr = new AtomicInteger(); /** */ - private final ConcurrentHashSet msgIds = new ConcurrentHashSet<>(); + private final GridConcurrentHashSet msgIds = new GridConcurrentHashSet<>(); /** * @param latch Latch. @@ -160,6 +164,7 @@ private static class MessageListener implements CommunicationListener { /** * @throws Exception If failed. */ + @Test public void testTwoThreads() throws Exception { concurrentConnect(2, 10, ITERS, false, false); } @@ -167,6 +172,7 @@ public void testTwoThreads() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreaded() throws Exception { int threads = Runtime.getRuntime().availableProcessors() * 5; @@ -176,6 +182,7 @@ public void testMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreaded_10Connections() throws Exception { connectionsPerNode = 10; @@ -185,6 +192,7 @@ public void testMultithreaded_10Connections() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreaded_NoPairedConnections() throws Exception { pairedConnections = false; @@ -194,6 +202,7 @@ public void testMultithreaded_NoPairedConnections() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultithreaded_10ConnectionsNoPaired() throws Exception { pairedConnections = false; connectionsPerNode = 10; @@ -204,6 +213,7 @@ public void testMultithreaded_10ConnectionsNoPaired() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithLoad() throws Exception { int threads = Runtime.getRuntime().availableProcessors() * 5; @@ -213,6 +223,7 @@ public void testWithLoad() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomSleep() throws Exception { concurrentConnect(4, 1, ITERS, true, false); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConfigSelfTest.java index 7bea716929148..2dcd6ba0bad11 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConfigSelfTest.java @@ -20,6 +20,9 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.getFreeCommPort; @@ -27,10 +30,12 @@ * TCP communication SPI config test. */ @GridSpiTest(spi = TcpCommunicationSpi.class, group = "Communication SPI") +@RunWith(JUnit4.class) public class GridTcpCommunicationSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new TcpCommunicationSpi(), "localPort", 1023); checkNegativeSpiProperty(new TcpCommunicationSpi(), "localPort", 65636); @@ -55,6 +60,7 @@ public void testNegativeConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalPortRange() throws Exception { IgniteConfiguration cfg = getConfiguration(); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiLanLoadTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiLanLoadTest.java index 93a159755b0d2..21aec783a62e8 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiLanLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiLanLoadTest.java @@ -41,11 +41,14 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Class for multithreaded {@link TcpCommunicationSpi} test. */ -@SuppressWarnings({"JUnitAbstractTestClassNamingConvention"}) +@RunWith(JUnit4.class) public class GridTcpCommunicationSpiLanLoadTest extends GridSpiAbstractTest { /** Connection idle timeout */ public static final int IDLE_CONN_TIMEOUT = 2000; @@ -86,7 +89,6 @@ public GridTcpCommunicationSpiLanLoadTest() { /** * Accumulating listener. */ - @SuppressWarnings({"deprecation"}) private class MessageListener implements CommunicationListener { /** Node id of local node. */ private final UUID locNodeId; @@ -140,6 +142,7 @@ public int remoteMessageCount() { /** * @throws Exception If failed. */ + @Test public void testRunReceiver() throws Exception { info(">>> Starting receiving SPI. <<<"); @@ -155,6 +158,7 @@ public void testRunReceiver() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRunSender() throws Exception { reject = true; @@ -265,7 +269,6 @@ private MBeanServer getMBeanServer() throws Exception { } /** {@inheritDoc} */ - @SuppressWarnings({"NullableProblems"}) @Override protected void afterTestsStopped() throws Exception { spi.setListener(null); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java index d610bc3c04d53..7df40f8852bc2 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java @@ -61,13 +61,16 @@ import org.apache.ignite.testframework.junits.GridTestKernalContext; import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS; /** * Class for multithreaded {@link TcpCommunicationSpi} test. */ -@SuppressWarnings({"JUnitAbstractTestClassNamingConvention"}) +@RunWith(JUnit4.class) public class GridTcpCommunicationSpiMultithreadedSelfTest extends GridSpiAbstractTest { /** Connection idle timeout */ public static final int IDLE_CONN_TIMEOUT = 2000; @@ -126,7 +129,6 @@ public GridTcpCommunicationSpiMultithreadedSelfTest() { /** * Accumulating listener. */ - @SuppressWarnings({"deprecation"}) private static class MessageListener implements CommunicationListener { /** Node id of local node. */ private final UUID locNodeId; @@ -194,6 +196,7 @@ public int remoteMessageCount() { /** * @throws Exception If failed. */ + @Test public void testSendToRandomNodesMultithreaded() throws Exception { info(">>> Starting send to random nodes multithreaded test. <<<"); @@ -279,6 +282,7 @@ public void testSendToRandomNodesMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFlowSend() throws Exception { reject = true; @@ -389,6 +393,7 @@ public void testFlowSend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPassThroughPerformance() throws Exception { reject = true; diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java index 1467c29a58b5d..22d1075cd2518 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java @@ -29,6 +29,7 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.managers.communication.GridIoMessageFactory; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.nio.GridNioRecoveryDescriptor; import org.apache.ignite.internal.util.nio.GridNioServer; @@ -49,12 +50,15 @@ import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.eclipse.jetty.util.ConcurrentHashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridSpiTest(spi = TcpCommunicationSpi.class, group = "Communication SPI") +@RunWith(JUnit4.class) public class GridTcpCommunicationSpiRecoveryAckSelfTest extends GridSpiAbstractTest { /** */ private static final Collection spiRsrcs = new ArrayList<>(); @@ -92,7 +96,7 @@ public GridTcpCommunicationSpiRecoveryAckSelfTest() { /** */ private class TestListener implements CommunicationListener { /** */ - private ConcurrentHashSet msgIds = new ConcurrentHashSet<>(); + private GridConcurrentHashSet msgIds = new GridConcurrentHashSet<>(); /** */ private AtomicInteger rcvCnt = new AtomicInteger(); @@ -121,6 +125,7 @@ private class TestListener implements CommunicationListener { /** * @throws Exception If failed. */ + @Test public void testAckOnIdle() throws Exception { checkAck(10, 2000, 9); } @@ -128,6 +133,7 @@ public void testAckOnIdle() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAckOnCount() throws Exception { checkAck(10, 60_000, 10); } @@ -238,6 +244,7 @@ private void checkAck(int ackCnt, int idleTimeout, int msgPerIter) throws Except /** * @throws Exception If failed. */ + @Test public void testQueueOverflow() throws Exception { for (int i = 0; i < 3; i++) { try { @@ -338,7 +345,6 @@ private void checkOverflow() throws Exception { * @return Session. * @throws Exception If failed. */ - @SuppressWarnings("unchecked") private GridNioSession communicationSession(TcpCommunicationSpi spi) throws Exception { final GridNioServer srv = U.field(spi, "nioSrvr"); @@ -499,4 +505,4 @@ private void stopSpis() throws Exception { nodes.clear(); spiRsrcs.clear(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest.java index b1aa11902ca10..6dfbbf028a823 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest.java @@ -18,10 +18,14 @@ package org.apache.ignite.spi.communication.tcp; import org.apache.ignite.configuration.IgniteConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest extends GridTcpCommunicationSpiRecoverySelfTest { /** {@inheritDoc} */ @Override protected TcpCommunicationSpi getSpi(int idx) { @@ -46,10 +50,11 @@ public class GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest extends Gri /** * @throws Exception if failed. */ + @Test public void testFailureDetectionEnabled() throws Exception { for (TcpCommunicationSpi spi: spis) { assertTrue(spi.failureDetectionTimeoutEnabled()); assertTrue(spi.failureDetectionTimeout() == IgniteConfiguration.DFLT_FAILURE_DETECTION_TIMEOUT); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java index d2e18c02c0b19..3232ba3d0e864 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java @@ -34,6 +34,7 @@ import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.managers.communication.GridIoMessageFactory; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.nio.GridNioServer; import org.apache.ignite.internal.util.nio.GridNioSession; @@ -54,13 +55,16 @@ import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.eclipse.jetty.util.ConcurrentHashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings("unchecked") @GridSpiTest(spi = TcpCommunicationSpi.class, group = "Communication SPI") +@RunWith(JUnit4.class) public class GridTcpCommunicationSpiRecoverySelfTest extends GridSpiAbstractTest { /** */ private static final Collection spiRsrcs = new ArrayList<>(); @@ -105,7 +109,6 @@ public GridTcpCommunicationSpiRecoverySelfTest() { } /** */ - @SuppressWarnings({"deprecation"}) private class TestListener implements CommunicationListener { /** */ private boolean block; @@ -114,7 +117,7 @@ private class TestListener implements CommunicationListener { private CountDownLatch blockLatch; /** */ - private ConcurrentHashSet msgIds = new ConcurrentHashSet<>(); + private GridConcurrentHashSet msgIds = new GridConcurrentHashSet<>(); /** */ private AtomicInteger rcvCnt = new AtomicInteger(); @@ -198,6 +201,7 @@ protected long awaitForSocketWriteTimeout() { /** * @throws Exception If failed. */ + @Test public void testBlockListener() throws Exception { // Test listener throws exception and stops selector thread, so must restart SPI. for (int i = 0; i < ITERS; i++) { @@ -217,7 +221,6 @@ public void testBlockListener() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("BusyWait") private void checkBlockListener() throws Exception { TcpCommunicationSpi spi0 = spis.get(0); TcpCommunicationSpi spi1 = spis.get(1); @@ -287,6 +290,7 @@ private void checkBlockListener() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlockRead1() throws Exception { createSpis(); @@ -405,6 +409,7 @@ public void testBlockRead1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlockRead2() throws Exception { createSpis(); @@ -540,6 +545,7 @@ public void testBlockRead2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlockRead3() throws Exception { createSpis(); @@ -671,7 +677,6 @@ private boolean waitForSessionsCount(TcpCommunicationSpi spi, int cnt) throws Ig * @return Session. * @throws Exception If failed. */ - @SuppressWarnings("unchecked") private GridNioSession communicationSession(TcpCommunicationSpi spi, boolean in) throws Exception { final GridNioServer srv = U.field(spi, "nioSrvr"); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiTcpFailureDetectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiTcpFailureDetectionSelfTest.java index 88b25cdf7e64a..9e75a2c69bdfc 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiTcpFailureDetectionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiTcpFailureDetectionSelfTest.java @@ -19,10 +19,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.communication.CommunicationSpi; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridTcpCommunicationSpiTcpFailureDetectionSelfTest extends GridTcpCommunicationSpiTcpSelfTest { /** */ private final static int SPI_COUNT = 4; @@ -63,6 +67,7 @@ public class GridTcpCommunicationSpiTcpFailureDetectionSelfTest extends GridTcpC /** * @throws Exception if failed. */ + @Test public void testFailureDetectionEnabled() throws Exception { assertTrue(spis[0].failureDetectionTimeoutEnabled()); assertTrue(spis[0].failureDetectionTimeout() == IgniteConfiguration.DFLT_FAILURE_DETECTION_TIMEOUT); @@ -72,4 +77,4 @@ public void testFailureDetectionEnabled() throws Exception { assertEquals(0, spis[i].failureDetectionTimeout()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java index 1c2bf04d1a07a..e3045612b5f99 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteTcpCommunicationRecoveryAckClosureSelfTest.java @@ -30,6 +30,7 @@ import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.managers.communication.GridIoMessageFactory; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.nio.GridNioRecoveryDescriptor; import org.apache.ignite.internal.util.nio.GridNioServer; @@ -52,12 +53,15 @@ import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; -import org.eclipse.jetty.util.ConcurrentHashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridSpiTest(spi = TcpCommunicationSpi.class, group = "Communication SPI") +@RunWith(JUnit4.class) public class IgniteTcpCommunicationRecoveryAckClosureSelfTest extends GridSpiAbstractTest { /** */ @@ -96,7 +100,7 @@ public IgniteTcpCommunicationRecoveryAckClosureSelfTest() { /** */ private class TestListener implements CommunicationListener { /** */ - private ConcurrentHashSet msgIds = new ConcurrentHashSet<>(); + private GridConcurrentHashSet msgIds = new GridConcurrentHashSet<>(); /** */ private AtomicInteger rcvCnt = new AtomicInteger(); @@ -123,6 +127,7 @@ private class TestListener implements CommunicationListener { /** * @throws Exception If failed. */ + @Test public void testAckOnIdle() throws Exception { checkAck(10, 2000, 9); } @@ -130,6 +135,7 @@ public void testAckOnIdle() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAckOnCount() throws Exception { checkAck(10, 60_000, 10); } @@ -257,6 +263,7 @@ private void checkAck(int ackCnt, int idleTimeout, int msgPerIter) throws Except /** * @throws Exception If failed. */ + @Test public void testQueueOverflow() throws Exception { for (int i = 0; i < 3; i++) { try { @@ -389,7 +396,6 @@ private void checkOverflow() throws Exception { * @return Session. * @throws Exception If failed. */ - @SuppressWarnings("unchecked") private GridNioSession communicationSession(TcpCommunicationSpi spi) throws Exception { final GridNioServer srv = U.field(spi, "nioSrvr"); @@ -550,4 +556,4 @@ private void stopSpis() throws Exception { nodes.clear(); spiRsrcs.clear(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java index 08cf1f7305f66..13dd557fb013d 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java @@ -37,22 +37,20 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; /** * */ +@RunWith(JUnit4.class) public class TcpCommunicationSpiDropNodesTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Nodes count. */ private static final int NODES_CNT = 4; @@ -73,11 +71,7 @@ public class TcpCommunicationSpiDropNodesTest extends GridCommonAbstractTest { spi.setIdleConnectionTimeout(100); spi.setSharedMemoryPort(-1); - TcpDiscoverySpi discoSpi = (TcpDiscoverySpi) cfg.getDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - cfg.setCommunicationSpi(spi); - cfg.setDiscoverySpi(discoSpi); return cfg; } @@ -111,6 +105,7 @@ public class TcpCommunicationSpiDropNodesTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testOneNode() throws Exception { pred = new IgniteBiPredicate() { @Override public boolean apply(ClusterNode locNode, ClusterNode rmtNode) { @@ -187,6 +182,7 @@ public boolean apply(Event event) { /** * @throws Exception If failed. */ + @Test public void testTwoNodesEachOther() throws Exception { pred = new IgniteBiPredicate() { @Override public boolean apply(ClusterNode locNode, ClusterNode rmtNode) { diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java index 00b1d90258cf2..54fae831b1a67 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java @@ -40,20 +40,19 @@ import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; /** * Tests that faulty client will be failed if connection can't be established. */ +@RunWith(JUnit4.class) public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Predicate. */ private static final IgnitePredicate PRED = new IgnitePredicate() { @Override public boolean apply(ClusterNode node) { @@ -79,13 +78,9 @@ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest spi.setIdleConnectionTimeout(100); spi.setSharedMemoryPort(-1); - TcpDiscoverySpi discoSpi = (TcpDiscoverySpi) cfg.getDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - discoSpi.setClientReconnectDisabled(true); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setClientReconnectDisabled(true); cfg.setCommunicationSpi(spi); - cfg.setDiscoverySpi(discoSpi); return cfg; } @@ -119,6 +114,7 @@ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testNoServerOnHost() throws Exception { testFailClient(null); } @@ -126,6 +122,7 @@ public void testNoServerOnHost() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotAcceptedConnection() throws Exception { testFailClient(new FakeServer()); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiHalfOpenedConnectionTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiHalfOpenedConnectionTest.java index 3e10f942c4459..ccbd9d26fef7a 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiHalfOpenedConnectionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiHalfOpenedConnectionTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests case when connection is closed only for one side, when other is not notified. */ +@RunWith(JUnit4.class) public class TcpCommunicationSpiHalfOpenedConnectionTest extends GridCommonAbstractTest { /** Client spi. */ private TcpCommunicationSpi clientSpi; @@ -66,6 +70,7 @@ public class TcpCommunicationSpiHalfOpenedConnectionTest extends GridCommonAbstr /** * @throws Exception If failed. */ + @Test public void testReconnect() throws Exception { pairedConnections = false; @@ -75,6 +80,7 @@ public void testReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectPaired() throws Exception { pairedConnections = true; diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiSkipMessageSendTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiSkipMessageSendTest.java index 2c17f957e27fb..e3d3b63a729ee 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiSkipMessageSendTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiSkipMessageSendTest.java @@ -48,10 +48,14 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests that the client will be segmented in time and won't hang due to canceling compute jobs. */ +@RunWith(JUnit4.class) public class TcpCommunicationSpiSkipMessageSendTest extends GridCommonAbstractTest { /** */ private static final CountDownLatch COMPUTE_JOB_STARTED = new CountDownLatch(1); @@ -105,6 +109,7 @@ public class TcpCommunicationSpiSkipMessageSendTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testClientSegmented() throws Exception { startGrid("server"); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationStatisticsTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationStatisticsTest.java index 377d1ebb9b766..4707cf1d80f14 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationStatisticsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationStatisticsTest.java @@ -42,18 +42,16 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.GridTestMessage; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for TcpCommunicationSpi statistics. */ +@RunWith(JUnit4.class) public class TcpCommunicationStatisticsTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Mutex. */ final private Object mux = new Object(); @@ -100,8 +98,6 @@ private class SynchronizedCommunicationSpi extends TcpCommunicationSpi { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER).setForceServerMode(true)); - TcpCommunicationSpi spi = new SynchronizedCommunicationSpi(); cfg.setCommunicationSpi(spi); @@ -134,6 +130,7 @@ private TcpCommunicationSpiMBean mbean(int nodeIdx) throws MalformedObjectNameEx * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testStatistics() throws Exception { startGrids(2); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/deployment/local/GridLocalDeploymentSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/deployment/local/GridLocalDeploymentSpiSelfTest.java index 14833640606de..ecca16ab7c3aa 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/deployment/local/GridLocalDeploymentSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/deployment/local/GridLocalDeploymentSpiSelfTest.java @@ -35,11 +35,15 @@ import org.apache.ignite.spi.deployment.DeploymentResource; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Local deployment SPI test. */ @GridSpiTest(spi = LocalDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridLocalDeploymentSpiSelfTest extends GridSpiAbstractTest { /** */ private static Map>>> tasks = @@ -87,6 +91,7 @@ private void checkUndeployed(Class> taskCls) { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testDeploy() throws Exception { String taskName = "GridDeploymentTestTask"; @@ -114,6 +119,7 @@ public void testDeploy() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testRedeploy() throws Exception { String taskName = "GridDeploymentTestTask"; diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryRandomStartStopTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryRandomStartStopTest.java index 3614987323014..c11377b587b4d 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryRandomStartStopTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryRandomStartStopTest.java @@ -30,11 +30,15 @@ import org.apache.ignite.events.Event; import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Base discovery random start-stop test class. * @param Discovery spi type. */ +@RunWith(JUnit4.class) public abstract class AbstractDiscoveryRandomStartStopTest extends GridSpiAbstractTest { /** */ private static final int DFLT_MAX_INTERVAL = 10; @@ -152,6 +156,7 @@ private class Waiter extends Thread { * @throws Exception If failed. */ @SuppressWarnings({"BusyWait"}) + @Test public void testDiscovery() throws Exception { Random rand = new Random(); @@ -215,4 +220,4 @@ private void toggleState() throws Exception { return attrs; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java index 3e0fb894a3b72..471dc0ba60a95 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java @@ -47,6 +47,9 @@ import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED; import static org.apache.ignite.lang.IgniteProductVersion.fromString; @@ -55,7 +58,7 @@ * Base discovery self-test class. * @param SPI implementation class. */ -@SuppressWarnings({"JUnitAbstractTestClassNamingConvention"}) +@RunWith(JUnit4.class) public abstract class AbstractDiscoverySelfTest extends GridSpiAbstractTest { /** */ private static final String HTTP_ADAPTOR_MBEAN_NAME = "mbeanAdaptor:protocol=HTTP"; @@ -91,6 +94,7 @@ protected AbstractDiscoverySelfTest() { * @throws Exception If failed. */ @SuppressWarnings({"UnconditionalWait"}) + @Test public void testDiscovery() throws Exception { assert spis.size() > 1; assert spiStartTime > 0; @@ -180,6 +184,7 @@ public boolean isMetricsUpdated() { * @throws Exception If failed. */ @SuppressWarnings({"UnconditionalWait"}) + @Test public void testMetrics() throws Exception { Collection listeners = new ArrayList<>(); @@ -232,6 +237,7 @@ public void testMetrics() throws Exception { * * @throws Exception If test failed. */ + @Test public void testLocalMetricsUpdate() throws Exception { AtomicInteger[] locUpdCnts = new AtomicInteger[getSpiCount()]; @@ -291,6 +297,7 @@ private boolean isContainsNodeId(Iterable nodes, UUID nodeId) { /** * Checks that physical address of local node is equal to local.ip property. */ + @Test public void testLocalNode() { for (DiscoverySpi spi : spis) { ClusterNode loc = spi.getLocalNode(); @@ -304,6 +311,7 @@ public void testLocalNode() { /** * Check that "test.node.prop" is present on all nodes. */ + @Test public void testNodeAttributes() { for (DiscoverySpi spi : spis) { assert !spi.getRemoteNodes().isEmpty() : "No remote nodes found in Spi."; @@ -339,6 +347,7 @@ else if (!"true".equals(attr)) { /** * Checks that each spi can pings all other. */ + @Test public void testPing() { for (DiscoverySpi spi : spis) { for (IgniteTestResources rscrs : spiRsrcs) { @@ -357,6 +366,7 @@ public void testPing() { * * @throws Exception If failed. */ + @Test public void testNodeSerialize() throws Exception { for (DiscoverySpi spi : spis) { ClusterNode node = spi.getLocalNode(); @@ -554,4 +564,4 @@ private static class NullOutputStream extends OutputStream { // No-op } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryTest.java index 2c2d99a1698a6..7876524c0a268 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoveryTest.java @@ -29,12 +29,15 @@ import org.apache.ignite.events.Event; import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Base discovery test class. * @param SPI implementation class. */ -@SuppressWarnings({"JUnitAbstractTestClassNamingConvention"}) +@RunWith(JUnit4.class) public abstract class AbstractDiscoveryTest extends GridSpiAbstractTest { /** */ @SuppressWarnings({"ClassExplicitlyExtendsThread"}) @@ -47,7 +50,6 @@ private class Pinger extends Thread { private boolean isCanceled; /** {@inheritDoc} */ - @SuppressWarnings({"UnusedCatchParameter"}) @Override public void run() { Random rnd = new Random(); @@ -127,6 +129,7 @@ private class DiscoveryListener implements GridLocalEventListener { /** * @throws Exception If failed. */ + @Test public void testDiscovery() throws Exception { GridLocalEventListener discoLsnr = new DiscoveryListener(); @@ -154,4 +157,4 @@ public void testDiscovery() throws Exception { return attrs; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AuthenticationRestartTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AuthenticationRestartTest.java index cf1836ad0af75..d7fc2a1f783f1 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AuthenticationRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AuthenticationRestartTest.java @@ -25,6 +25,9 @@ import org.apache.ignite.spi.discovery.tcp.TestReconnectPluginProvider; import org.apache.ignite.spi.discovery.tcp.TestReconnectProcessor; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; @@ -32,6 +35,7 @@ * Checks whether client is able to reconnect to restarted cluster with * enabled security. */ +@RunWith(JUnit4.class) public class AuthenticationRestartTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -62,6 +66,7 @@ public class AuthenticationRestartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testClientReconnect() throws Exception { stopGrid("server"); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeSelfTest.java index 25de2c74b1d3b..a6a64d87c01f6 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeSelfTest.java @@ -21,11 +21,15 @@ import org.apache.ignite.internal.ClusterMetricsSnapshot; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid discovery metrics test. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class ClusterMetricsSnapshotSerializeSelfTest extends GridCommonAbstractTest { /** Metrics serialized by Ignite 1.0 */ private static final byte[] METRICS_V1 = {0, 0, 0, 22, 0, 0, 0, 8, 64, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 15, 64, @@ -47,6 +51,7 @@ public ClusterMetricsSnapshotSerializeSelfTest() { } /** */ + @Test public void testMetricsSize() { byte[] data = new byte[ClusterMetricsSnapshot.METRICS_SIZE]; @@ -62,6 +67,7 @@ public void testMetricsSize() { } /** */ + @Test public void testSerialization() { byte[] data = new byte[ClusterMetricsSnapshot.METRICS_SIZE]; @@ -83,6 +89,7 @@ public void testSerialization() { /** * Checks compatibility with old serialized metrics. */ + @Test public void testMetricsCompatibility() { ClusterMetrics metrics = ClusterMetricsSnapshot.deserialize(METRICS_V1, 0); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/FilterDataForClientNodeDiscoveryTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/FilterDataForClientNodeDiscoveryTest.java index 9a45d2d68d5be..c3e2dd7285541 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/FilterDataForClientNodeDiscoveryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/FilterDataForClientNodeDiscoveryTest.java @@ -28,18 +28,17 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class FilterDataForClientNodeDiscoveryTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Join servers count. */ private int joinSrvCnt; @@ -56,6 +55,7 @@ public class FilterDataForClientNodeDiscoveryTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testDataBag() throws Exception { startGrid(configuration(0, false)); startGrid(configuration(1, false)); @@ -73,6 +73,7 @@ public void testDataBag() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDiscoveryServerOnlyCustomMessage() throws Exception { startGrid(configuration(0, false)); startGrid(configuration(1, false)); @@ -120,7 +121,7 @@ private IgniteConfiguration configuration(int nodeIdx, boolean client) throws Ex TcpDiscoverySpi testSpi = new TestDiscoverySpi(); - testSpi.setIpFinder(IP_FINDER); + testSpi.setIpFinder(sharedStaticIpFinder); cfg.setDiscoverySpi(testSpi); @@ -216,4 +217,4 @@ private static class MessageForServer implements DiscoveryServerOnlyCustomMessag return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/IgniteDiscoveryCacheReuseSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/IgniteDiscoveryCacheReuseSelfTest.java index 75bcbb1db73ef..3659e69fbd7ae 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/IgniteDiscoveryCacheReuseSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/IgniteDiscoveryCacheReuseSelfTest.java @@ -18,7 +18,6 @@ package org.apache.ignite.spi.discovery; import org.apache.ignite.Ignite; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.managers.discovery.DiscoCache; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -26,28 +25,17 @@ import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests discovery cache reuse between topology events. */ +@RunWith(JUnit4.class) public class IgniteDiscoveryCacheReuseSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -60,6 +48,7 @@ public class IgniteDiscoveryCacheReuseSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testDiscoCacheReuseOnNodeJoin() throws Exception { startGridsMultiThreaded(2); @@ -109,4 +98,4 @@ private void assertDiscoCacheReuse(AffinityTopologyVersion v1, AffinityTopologyV assertEquals("Discovery caches are not equal", alives1, alives2); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/LongClientConnectToClusterTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/LongClientConnectToClusterTest.java new file mode 100644 index 0000000000000..3e4873907633a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/LongClientConnectToClusterTest.java @@ -0,0 +1,178 @@ +/* + * 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. + */ + +package org.apache.ignite.spi.discovery; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.events.EventType; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl; +import org.apache.ignite.lang.IgniteFuture; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.jetbrains.annotations.Nullable; +import java.io.IOException; +import java.io.OutputStream; +import java.net.Socket; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Test client connects to two nodes cluster during time more than the + * {@link org.apache.ignite.configuration.IgniteConfiguration#clientFailureDetectionTimeout}. + */ +@RunWith(JUnit4.class) +public class LongClientConnectToClusterTest extends GridCommonAbstractTest { + /** Client instance name. */ + public static final String CLIENT_INSTANCE_NAME = "client"; + /** Client metrics update count. */ + private static volatile int clientMetricsUpdateCnt; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + TcpDiscoverySpi discoSpi = getTestIgniteInstanceName(0).equals(igniteInstanceName) + ? new DelayedTcpDiscoverySpi() + : getTestIgniteInstanceName(1).equals(igniteInstanceName) + ? new UpdateMetricsInterceptorTcpDiscoverySpi() + : new TcpDiscoverySpi(); + + return super.getConfiguration(igniteInstanceName) + .setClientMode(igniteInstanceName.startsWith(CLIENT_INSTANCE_NAME)) + .setClientFailureDetectionTimeout(1_000) + .setMetricsUpdateFrequency(500) + .setDiscoverySpi(discoSpi + .setReconnectCount(1) + .setLocalAddress("127.0.0.1") + .setIpFinder(new TcpDiscoveryVmIpFinder() + .setAddresses(Collections.singletonList(igniteInstanceName.startsWith(CLIENT_INSTANCE_NAME) + ? "127.0.0.1:47501" + : "127.0.0.1:47500..47502")))); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + startGrids(2); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** + * Test method. + * + * @throws Exception If failed. + */ + @Test + public void testClientConnectToCluster() throws Exception { + clientMetricsUpdateCnt = 0; + + IgniteEx client = startGrid(CLIENT_INSTANCE_NAME); + + assertTrue(clientMetricsUpdateCnt > 0); + + assertTrue(client.localNode().isClient()); + + assertEquals(client.cluster().nodes().size(), 3); + } + + /** Discovery SPI which intercept TcpDiscoveryClientMetricsUpdateMessage. */ + private static class UpdateMetricsInterceptorTcpDiscoverySpi extends TcpDiscoverySpi { + /** */ + private class DiscoverySpiListenerWrapper implements DiscoverySpiListener { + /** */ + private DiscoverySpiListener delegate; + + /** + * @param delegate Delegate. + */ + private DiscoverySpiListenerWrapper(DiscoverySpiListener delegate) { + this.delegate = delegate; + } + + /** {@inheritDoc} */ + @Override public IgniteFuture onDiscovery( + int type, + long topVer, + ClusterNode node, + Collection topSnapshot, + @Nullable Map> topHist, + @Nullable DiscoverySpiCustomMessage spiCustomMsg + ) { + if (EventType.EVT_NODE_METRICS_UPDATED == type) { + log.info("Metrics update message catched from node " + node); + + assertFalse(locNode.isClient()); + + if (node.isClient()) + clientMetricsUpdateCnt++; + } + + if (delegate != null) + return delegate.onDiscovery(type, topVer, node, topSnapshot, topHist, spiCustomMsg); + + return new IgniteFinishedFutureImpl<>(); + } + + /** {@inheritDoc} */ + @Override public void onLocalNodeInitialized(ClusterNode locNode) { + if (delegate != null) + delegate.onLocalNodeInitialized(locNode); + } + } + + /** {@inheritDoc} */ + @Override public void setListener(@Nullable DiscoverySpiListener lsnr) { + super.setListener(new DiscoverySpiListenerWrapper(lsnr)); + } + } + + /** Discovery SPI delayed TcpDiscoveryNodeAddFinishedMessage. */ + private static class DelayedTcpDiscoverySpi extends TcpDiscoverySpi { + /** Delay message period millis. */ + public static final int DELAY_MSG_PERIOD_MILLIS = 2_000; + + /** {@inheritDoc} */ + @Override protected void writeToSocket(ClusterNode node, Socket sock, OutputStream out, + TcpDiscoveryAbstractMessage msg, long timeout) throws IOException, IgniteCheckedException { + if (msg instanceof TcpDiscoveryNodeAddFinishedMessage && msg.topologyVersion() == 3) { + log.info("Catched discovery message: " + msg); + + try { + Thread.sleep(DELAY_MSG_PERIOD_MILLIS); + } + catch (InterruptedException e) { + log.error("Interrupt on DelayedTcpDiscoverySpi.", e); + + Thread.currentThread().interrupt(); + } + } + + super.writeToSocket(node, sock, out, msg, timeout); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java index 448c9af9223cd..69081c1c4f0b3 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/DiscoveryUnmarshalVulnerabilityTest.java @@ -32,6 +32,9 @@ import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_BLACKLIST; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_WHITELIST; @@ -39,6 +42,7 @@ /** * Tests for whitelist and blacklist ot avoiding deserialization vulnerability. */ +@RunWith(JUnit4.class) public class DiscoveryUnmarshalVulnerabilityTest extends GridCommonAbstractTest { /** Marshaller. */ private static final JdkMarshaller MARSH = new JdkMarshaller(); @@ -61,6 +65,7 @@ public class DiscoveryUnmarshalVulnerabilityTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testNoLists() throws Exception { testExploit(true); } @@ -68,6 +73,7 @@ public void testNoLists() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWhiteListIncluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_included.txt").getPath(); @@ -79,6 +85,7 @@ public void testWhiteListIncluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWhiteListExcluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_excluded.txt").getPath(); @@ -90,6 +97,7 @@ public void testWhiteListExcluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlackListIncluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_included.txt").getPath(); @@ -101,6 +109,7 @@ public void testBlackListIncluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlackListExcluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_excluded.txt").getPath(); @@ -112,6 +121,7 @@ public void testBlackListExcluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBothListIncluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_included.txt").getPath(); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientConnectTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientConnectTest.java index 2ed55a1fcc4df..784078f938518 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientConnectTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientConnectTest.java @@ -34,12 +34,13 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * We emulate that client receive message about joining to topology earlier than some server nodes in topology. @@ -47,10 +48,8 @@ * To emulate this we connect client to second node in topology and pause sending message about joining finishing to * third node. */ +@RunWith(JUnit4.class) public class IgniteClientConnectTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Latch to stop message sending. */ private final CountDownLatch latch = new CountDownLatch(1); @@ -71,7 +70,7 @@ public class IgniteClientConnectTest extends GridCommonAbstractTest { disco.setIpFinder(ipFinder); } else - disco.setIpFinder(ipFinder); + disco.setIpFinder(sharedStaticIpFinder); disco.setJoinTimeout(2 * 60_000); disco.setSocketTimeout(1000); @@ -94,6 +93,7 @@ public class IgniteClientConnectTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testClientConnectToBigTopology() throws Exception { Ignite ignite = startGrids(3); @@ -160,4 +160,4 @@ TcpDiscoveryImpl discovery() { return impl; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java index 2878110a9cfb3..26dea8398d9f3 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java @@ -38,10 +38,11 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -52,6 +53,7 @@ /** * Client reconnect test in multi threaded mode while cache operations are in progress. */ +@RunWith(JUnit4.class) public class IgniteClientReconnectMassiveShutdownTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 14; @@ -62,17 +64,12 @@ public class IgniteClientReconnectMassiveShutdownTest extends GridCommonAbstract /** */ private static volatile boolean clientMode; - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setClientMode(clientMode); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder)); - ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); return cfg; @@ -95,13 +92,15 @@ public class IgniteClientReconnectMassiveShutdownTest extends GridCommonAbstract /** * @throws Exception If any error occurs. */ - public void _testMassiveServersShutdown1() throws Exception { + @Test + public void testMassiveServersShutdown1() throws Exception { massiveServersShutdown(StopType.FAIL_EVENT); } /** * @throws Exception If any error occurs. */ + @Test public void testMassiveServersShutdown2() throws Exception { massiveServersShutdown(StopType.SIMULATE_FAIL); } @@ -109,7 +108,8 @@ public void testMassiveServersShutdown2() throws Exception { /** * @throws Exception If any error occurs. */ - public void _testMassiveServersShutdown3() throws Exception { + @Test + public void testMassiveServersShutdown3() throws Exception { massiveServersShutdown(StopType.CLOSE); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java index f14e0b1cf70ce..e44b0a54994e1 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java @@ -23,17 +23,16 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.spi.IgniteSpiException; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi}. */ +@RunWith(JUnit4.class) public class TcpClientDiscoveryMarshallerCheckSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean testFooter; @@ -65,10 +64,6 @@ public class TcpClientDiscoveryMarshallerCheckSelfTest extends GridCommonAbstrac cfg.setClientMode(true); cfg.setMarshaller(new BinaryMarshaller()); } - - TcpDiscoverySpi spi = new TcpDiscoverySpi().setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); } return cfg; @@ -82,6 +77,7 @@ public class TcpClientDiscoveryMarshallerCheckSelfTest extends GridCommonAbstrac /** * @throws Exception If failed. */ + @Test public void testMarshallerInConsistency() throws Exception { startGrid(0); @@ -101,6 +97,7 @@ public void testMarshallerInConsistency() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInconsistentCompactFooterSingle() throws Exception { clientServerInconsistentConfigFail(false, 1, 1); } @@ -108,6 +105,7 @@ public void testInconsistentCompactFooterSingle() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInconsistentCompactFooterMulti() throws Exception { clientServerInconsistentConfigFail(true, 2, 10); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiCoordinatorChangeTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiCoordinatorChangeTest.java new file mode 100644 index 0000000000000..be76afde2db6c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiCoordinatorChangeTest.java @@ -0,0 +1,126 @@ +/* + * 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. + */ + +package org.apache.ignite.spi.discovery.tcp; + +import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.ignite.Ignite; +import org.apache.ignite.Ignition; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.events.Event; +import org.apache.ignite.events.EventType; +import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * This class tests that a client is able to connect to another server node without leaving the cluster. + */ +@RunWith(JUnit4.class) +public class TcpClientDiscoverySpiCoordinatorChangeTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + /** + * Checks that a client node doesn't fail because of coordinator change. + * + * @throws Exception If test fails. + */ + @Test + public void testClientNotFailed() throws Exception { + TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + // Start server A. + Ignite srvA = startNode("server-a", ipFinder, false); + + // Start the client. + Ignite client = startNode("client", ipFinder, true); + + AtomicBoolean clientReconnectState = getClientReconnectState(client); + + // Start server B. + Ignite srvB = startNode("server-b", ipFinder, false); + + // Stop server A. + srvA.close(); + + // Will throw an exception if the client is disconnected. + client.getOrCreateCache("CACHE-NAME"); + + // Check that the client didn't disconnect/reconnect quickly. + assertFalse("Client node was failed and reconnected to the cluster.", clientReconnectState.get()); + + // Stop the client. + client.close(); + + // Stop server B. + srvB.close(); + } + + /** + * @param instanceName Instance name. + * @param ipFinder IP-finder. + * @param clientMode Client mode flag. + * @return Started node. + * @throws Exception If a node was not started. + */ + private Ignite startNode(String instanceName, TcpDiscoveryIpFinder ipFinder, boolean clientMode) throws Exception { + IgniteConfiguration cfg = getConfiguration(instanceName) + .setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder)) + .setClientMode(clientMode); + + return Ignition.start(cfg); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String instanceName) throws Exception { + return super.getConfiguration(instanceName) + .setMetricsUpdateFrequency(Integer.MAX_VALUE) + .setClientFailureDetectionTimeout(Integer.MAX_VALUE) + .setFailureDetectionTimeout(Integer.MAX_VALUE); + } + + /** + * @param ignite Client node. + * @return Client reconnect state. + */ + private AtomicBoolean getClientReconnectState(Ignite ignite) { + final AtomicBoolean reconnectState = new AtomicBoolean(false); + + ignite.events().localListen( + new IgnitePredicate() { + @Override public boolean apply(Event evt) { + if (evt.type() == EventType.EVT_CLIENT_NODE_RECONNECTED) + reconnectState.set(true); + + return true; + } + }, + EventType.EVT_CLIENT_NODE_RECONNECTED + ); + + return reconnectState; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java index c167a902d23dd..01494cea24ec1 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java @@ -43,12 +43,16 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryPingRequest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; /** * Client-based discovery SPI test with failure detection timeout enabled. */ +@RunWith(JUnit4.class) public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscoverySpiSelfTest { /** */ private final static int FAILURE_AWAIT_TIME = 7_000; @@ -110,6 +114,7 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov /** * @throws Exception in case of error. */ + @Test public void testFailureDetectionTimeoutEnabled() throws Exception { startServerNodes(1); startClientNodes(1); @@ -130,6 +135,7 @@ public void testFailureDetectionTimeoutEnabled() throws Exception { /** * @throws Exception in case of error. */ + @Test public void testFailureTimeoutWorkabilityAvgTimeout() throws Exception { failureThreshold = 3000; @@ -144,6 +150,7 @@ public void testFailureTimeoutWorkabilityAvgTimeout() throws Exception { /** * @throws Exception in case of error. */ + @Test public void testFailureTimeoutWorkabilitySmallTimeout() throws Exception { failureThreshold = 500; @@ -160,6 +167,7 @@ public void testFailureTimeoutWorkabilitySmallTimeout() throws Exception { * * @throws Exception in case of error. */ + @Test public void testFailureTimeoutServerClient() throws Exception { failureThreshold = 3000; clientFailureDetectionTimeout = 2000; @@ -213,6 +221,7 @@ public void testFailureTimeoutServerClient() throws Exception { * * @throws Exception in case of error. */ + @Test public void testFailureTimeout3Server() throws Exception { failureThreshold = 1000; clientFailureDetectionTimeout = 10000; @@ -319,6 +328,7 @@ private void checkFailureThresholdWorkability() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectOnCoordinatorRouterFail1() throws Exception { clientReconnectOnCoordinatorRouterFail(1); } @@ -326,6 +336,7 @@ public void testClientReconnectOnCoordinatorRouterFail1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectOnCoordinatorRouterFail2() throws Exception { clientReconnectOnCoordinatorRouterFail(2); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiMulticastTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiMulticastTest.java index e19b121aebdb7..ec44dee4cb1ac 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiMulticastTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiMulticastTest.java @@ -30,6 +30,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED; @@ -38,6 +41,7 @@ /** * */ +@RunWith(JUnit4.class) public class TcpClientDiscoverySpiMulticastTest extends GridCommonAbstractTest { /** */ private boolean forceSrv; @@ -95,6 +99,7 @@ public class TcpClientDiscoverySpiMulticastTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testClientStartsFirst() throws Exception { IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable() { @Override public Ignite call() throws Exception { @@ -149,6 +154,7 @@ else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED) { /** * @throws Exception If failed. */ + @Test public void testJoinWithMulticast() throws Exception { joinWithMulticast(); } @@ -156,6 +162,7 @@ public void testJoinWithMulticast() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinWithMulticastForceServer() throws Exception { forceSrv = true; @@ -218,4 +225,4 @@ private void assertSpi(Ignite ignite, boolean client) { else assertFalse(addrSnds.isEmpty()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java index c85e94e6c3889..b52f00bdd8627 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java @@ -73,6 +73,9 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.MINUTES; @@ -86,6 +89,7 @@ /** * Client-based discovery tests. */ +@RunWith(JUnit4.class) public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { /** */ private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); @@ -299,6 +303,7 @@ protected long failureDetectionTimeout() { /** * @throws Exception If failed. */ + @Test public void testJoinTimeout() throws Exception { clientIpFinder = new TcpDiscoveryVmIpFinder(); joinTimeout = 1000; @@ -320,6 +325,7 @@ public void testJoinTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientToClientPing() throws Exception { startGrid("server-p1"); Ignite c1 = startGrid("client-p1"); @@ -335,6 +341,7 @@ public void testClientToClientPing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNodeJoin() throws Exception { startServerNodes(3); startClientNodes(3); @@ -357,6 +364,7 @@ public void testClientNodeJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNodeLeave() throws Exception { startServerNodes(3); startClientNodes(3); @@ -379,6 +387,7 @@ public void testClientNodeLeave() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNodeFail() throws Exception { startServerNodes(3); startClientNodes(3); @@ -401,6 +410,7 @@ public void testClientNodeFail() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerNodeJoin() throws Exception { startServerNodes(3); startClientNodes(3); @@ -423,6 +433,7 @@ public void testServerNodeJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerNodeLeave() throws Exception { startServerNodes(3); startClientNodes(3); @@ -445,6 +456,7 @@ public void testServerNodeLeave() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServerNodeFail() throws Exception { startServerNodes(3); startClientNodes(3); @@ -469,6 +481,7 @@ public void testServerNodeFail() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPing() throws Exception { startServerNodes(2); startClientNodes(1); @@ -487,6 +500,7 @@ public void testPing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPingFailedNodeFromClient() throws Exception { startServerNodes(2); startClientNodes(1); @@ -518,6 +532,7 @@ public void testPingFailedNodeFromClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPingFailedClientNode() throws Exception { startServerNodes(2); startClientNodes(1); @@ -547,6 +562,7 @@ public void testPingFailedClientNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectOnRouterFail() throws Exception { clientsPerSrv = 1; @@ -575,6 +591,7 @@ public void testClientReconnectOnRouterFail() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientReconnectOnRouterSuspend() throws Exception { reconnectAfterSuspend(false); } @@ -584,6 +601,7 @@ public void testClientReconnectOnRouterSuspend() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientReconnectOnRouterSuspendTopologyChange() throws Exception { clientFailureDetectionTimeout = 20_000; @@ -665,6 +683,7 @@ private void reconnectAfterSuspend(boolean changeTop) throws Exception { /** * @throws Exception if failed. */ + @Test public void testClientReconnectHistoryMissingOnRouter() throws Exception { clientFailureDetectionTimeout = 60000; netTimeout = 60000; @@ -712,6 +731,7 @@ public void testClientReconnectHistoryMissingOnRouter() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectAfterPause() throws Exception { startServerNodes(2); startClientNodes(1); @@ -740,6 +760,7 @@ public void testReconnectAfterPause() throws Exception { /** * @throws Exception if failed. */ + @Test public void testReconnectAfterMassiveTopologyChange() throws Exception { clientIpFinder = IP_FINDER; @@ -790,6 +811,7 @@ public void testReconnectAfterMassiveTopologyChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectOnNetworkProblem() throws Exception { clientsPerSrv = 1; @@ -815,6 +837,7 @@ public void testClientReconnectOnNetworkProblem() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectOneServerOneClient() throws Exception { clientsPerSrv = 1; @@ -840,6 +863,7 @@ public void testClientReconnectOneServerOneClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectTopologyChange1() throws Exception { clientFailureDetectionTimeout = 100000; @@ -884,6 +908,7 @@ public void testClientReconnectTopologyChange1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectTopologyChange2() throws Exception { clientFailureDetectionTimeout = 100000; @@ -928,6 +953,7 @@ public void testClientReconnectTopologyChange2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetMissedMessagesOnReconnect() throws Exception { clientsPerSrv = 1; @@ -965,6 +991,7 @@ public void testGetMissedMessagesOnReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientSegmentation() throws Exception { clientsPerSrv = 1; @@ -1014,6 +1041,7 @@ public void testClientSegmentation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNodeJoinOneServer() throws Exception { startServerNodes(1); @@ -1031,6 +1059,7 @@ public void testClientNodeJoinOneServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNodeLeaveOneServer() throws Exception { startServerNodes(1); startClientNodes(1); @@ -1053,6 +1082,7 @@ public void testClientNodeLeaveOneServer() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientNodeFailOneServer() throws Exception { startServerNodes(1); startClientNodes(1); @@ -1073,6 +1103,7 @@ public void testClientNodeFailOneServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientAndRouterFail() throws Exception { startServerNodes(2); startClientNodes(2); @@ -1105,6 +1136,7 @@ public void testClientAndRouterFail() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMetrics() throws Exception { startServerNodes(3); startClientNodes(3); @@ -1165,6 +1197,7 @@ private boolean checkMetrics(int srvCnt, int clientCnt, int execJobsCnt) { /** * @throws Exception If failed. */ + @Test public void testDataExchangeFromServer() throws Exception { testDataExchange("server-0"); } @@ -1172,6 +1205,7 @@ public void testDataExchangeFromServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDataExchangeFromClient() throws Exception { testDataExchange("client-0"); } @@ -1216,6 +1250,7 @@ private void testDataExchange(String masterName) throws Exception { /** * @throws Exception If failed. */ + @Test public void testDataExchangeFromServer2() throws Exception { startServerNodes(2); @@ -1246,6 +1281,7 @@ public void testDataExchangeFromServer2() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testDuplicateId() throws Exception { startServerNodes(2); @@ -1267,6 +1303,7 @@ public void testDuplicateId() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testTimeoutWaitingNodeAddedMessage() throws Exception { longSockTimeouts = true; @@ -1310,6 +1347,7 @@ public void testTimeoutWaitingNodeAddedMessage() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testGridStartTime() throws Exception { startServerNodes(2); @@ -1332,6 +1370,7 @@ public void testGridStartTime() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinError() throws Exception { startServerNodes(1); @@ -1349,6 +1388,7 @@ public void testJoinError() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinError2() throws Exception { startServerNodes(1); @@ -1367,6 +1407,7 @@ public void testJoinError2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinError3() throws Exception { startServerNodes(1); @@ -1384,6 +1425,7 @@ public void testJoinError3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinErrorMissedAddFinishedMessage1() throws Exception { missedAddFinishedMessage(true); } @@ -1391,6 +1433,7 @@ public void testJoinErrorMissedAddFinishedMessage1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinErrorMissedAddFinishedMessage2() throws Exception { missedAddFinishedMessage(false); } @@ -1449,6 +1492,7 @@ private void missedAddFinishedMessage(boolean singleSrv) throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientMessageWorkerStartSingleServer() throws Exception { clientMessageWorkerStart(1, 1); } @@ -1456,6 +1500,7 @@ public void testClientMessageWorkerStartSingleServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientMessageWorkerStartTwoServers1() throws Exception { clientMessageWorkerStart(2, 1); } @@ -1463,6 +1508,7 @@ public void testClientMessageWorkerStartTwoServers1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientMessageWorkerStartTwoServers2() throws Exception { clientMessageWorkerStart(2, 2); } @@ -1527,6 +1573,7 @@ private void clientMessageWorkerStart(int srvs, int connectTo) throws Exception /** * @throws Exception If failed. */ + @Test public void testJoinMutlithreaded() throws Exception { startServerNodes(1); @@ -1550,6 +1597,7 @@ public void testJoinMutlithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectAfterFail() throws Exception { reconnectAfterFail(false); } @@ -1557,6 +1605,7 @@ public void testReconnectAfterFail() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectAfterFailTopologyChanged() throws Exception { reconnectAfterFail(true); } @@ -1678,6 +1727,7 @@ else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED) { /** * @throws Exception If failed. */ + @Test public void testReconnectAfterFailConcurrentJoin() throws Exception { startServerNodes(1); @@ -1750,6 +1800,7 @@ else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED) { /** * @throws Exception If failed. */ + @Test public void testClientFailReconnectDisabled() throws Exception { reconnectDisabled = true; @@ -1791,6 +1842,7 @@ public void testClientFailReconnectDisabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectSegmentedAfterJoinTimeoutServerFailed() throws Exception { reconnectSegmentedAfterJoinTimeout(true); } @@ -1798,6 +1850,7 @@ public void testReconnectSegmentedAfterJoinTimeoutServerFailed() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testReconnectSegmentedAfterJoinTimeoutNetworkError() throws Exception { reconnectSegmentedAfterJoinTimeout(false); } @@ -1898,6 +1951,7 @@ else if (evt.type() == EVT_NODE_SEGMENTED) { /** * @throws Exception If failed. */ + @Test public void testReconnectClusterRestart() throws Exception { netTimeout = 3000; joinTimeout = 60_000; @@ -1970,6 +2024,7 @@ else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED) { /** * @throws Exception If failed. */ + @Test public void testDisconnectAfterNetworkTimeout() throws Exception { netTimeout = 5000; joinTimeout = 60_000; @@ -2055,6 +2110,7 @@ else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED) { /** * @throws Exception If failed. */ + @Test public void testForceClientReconnect() throws Exception { startServerNodes(1); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryUnresolvedHostTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryUnresolvedHostTest.java index 4dc1604bd389f..78be17048fead 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryUnresolvedHostTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryUnresolvedHostTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.spi.IgniteSpiOperationTimeoutHelper; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Client-based discovery SPI test with unresolved server hosts. */ +@RunWith(JUnit4.class) public class TcpClientDiscoveryUnresolvedHostTest extends GridCommonAbstractTest { /** */ TestTcpDiscoverySpi spi; @@ -58,6 +62,7 @@ public class TcpClientDiscoveryUnresolvedHostTest extends GridCommonAbstractTest * * @throws Exception in case of error. */ + @Test public void test() throws Exception { try { startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryClientSuspensionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryClientSuspensionSelfTest.java index a519d25d4114f..4dafa9cd8106b 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryClientSuspensionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryClientSuspensionSelfTest.java @@ -23,27 +23,20 @@ import org.apache.ignite.Ignition; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for missed client metrics update messages. */ +@RunWith(JUnit4.class) public class TcpDiscoveryClientSuspensionSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setMetricsUpdateFrequency(100); cfg.setClientFailureDetectionTimeout(1000); @@ -73,6 +66,7 @@ public class TcpDiscoveryClientSuspensionSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testOneServer() throws Exception { doTestClientSuspension(1); } @@ -80,6 +74,7 @@ public void testOneServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTwoServers() throws Exception { doTestClientSuspension(2); } @@ -87,6 +82,7 @@ public void testTwoServers() throws Exception { /** * @throws Exception If failed. */ + @Test public void testThreeServers() throws Exception { doTestClientSuspension(3); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java index a66fe71f2aa8c..3538d160e23a8 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryConcurrentStartTest.java @@ -20,22 +20,21 @@ import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link TcpDiscoverySpi}. */ +@RunWith(JUnit4.class) public class TcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest { /** */ private static final int TOP_SIZE = 3; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static volatile boolean client; @@ -43,8 +42,6 @@ public class TcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder)); - cfg.setCacheConfiguration(); cfg.setClientMode(client); @@ -65,6 +62,7 @@ public class TcpDiscoveryConcurrentStartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testConcurrentStart() throws Exception { for (int i = 0; i < 10; i++) { try { @@ -79,6 +77,7 @@ public void testConcurrentStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartClients() throws Exception { for (int i = 0; i < 20; i++) { try { @@ -108,4 +107,4 @@ public void testConcurrentStartClients() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIpFinderCleanerTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIpFinderCleanerTest.java new file mode 100644 index 0000000000000..4a48cdd5babcc --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIpFinderCleanerTest.java @@ -0,0 +1,165 @@ +/* + * 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. + */ + +package org.apache.ignite.spi.discovery.tcp; + +import java.net.InetSocketAddress; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.Ignite; +import org.apache.ignite.Ignition; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests IP finder cleaner. + */ +public class TcpDiscoveryIpFinderCleanerTest extends GridCommonAbstractTest { + /** */ + private static final long IP_FINDER_CLEAN_FREQ = 1000; + + /** */ + private static final long NODE_STOPPING_TIMEOUT = 20000; + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + /** + * Checks the node stops gracefully even if {@link TcpDiscoveryIpFinder} ignores {@link InterruptedException}. + * + * @throws Exception If failed. + */ + @Test + public void testNodeStops() throws Exception { + CustomIpFinder ipFinder = new CustomIpFinder(true); + + Ignite ignite = Ignition.start(getConfiguration(ipFinder)); + + try { + if (!ipFinder.suspend().await(IP_FINDER_CLEAN_FREQ * 5, TimeUnit.MILLISECONDS)) + fail("Failed to suspend IP finder."); + + if (!stopNodeAsync(ignite).await(NODE_STOPPING_TIMEOUT, TimeUnit.MILLISECONDS)) + fail("Node was not stopped."); + } + finally { + ipFinder.interruptCleanerThread(); + } + } + + /** + * @param ipFinder IP finder. + * @return Grid test configuration. + * @throws Exception If failed. + */ + private IgniteConfiguration getConfiguration(TcpDiscoveryIpFinder ipFinder) throws Exception { + TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi() + .setIpFinder(ipFinder) + .setIpFinderCleanFrequency(IP_FINDER_CLEAN_FREQ); + + return getConfiguration() + .setDiscoverySpi(discoverySpi); + } + + /** + * Stop the node asynchronously. + * + * @param node Ignite instance. + * @return Latch to signal when the node is stopped completely. + */ + private static CountDownLatch stopNodeAsync(final Ignite node) { + final CountDownLatch latch = new CountDownLatch(1); + + GridTestUtils.runAsync(new Runnable() { + @Override public void run() { + try { + node.close(); + } + finally { + latch.countDown(); + } + } + }); + + return latch; + } + + /** + * Custom IP finder. + */ + private static class CustomIpFinder extends TcpDiscoveryVmIpFinder { + /** */ + private volatile boolean suspendFinderAndResetInterruptedFlag; + + /** */ + private final CountDownLatch suspended = new CountDownLatch(1); + + /** */ + private volatile Thread cleanerThread; + + /** {@inheritDoc} */ + public CustomIpFinder(boolean shared) { + super(shared); + } + + /** {@inheritDoc} */ + @Override public synchronized Collection getRegisteredAddresses() { + if (suspendFinderAndResetInterruptedFlag) { + cleanerThread = Thread.currentThread(); + + suspended.countDown(); + + try { + new CountDownLatch(1).await(); + } + catch (InterruptedException ignore) { + suspendFinderAndResetInterruptedFlag = false; + } + } + + return super.getRegisteredAddresses(); + } + + /** + * Suspend IP finder in {@link CustomIpFinder#getRegisteredAddresses()} method. + * + * @return Latch to signal when IP finder is suspended. + */ + public CountDownLatch suspend() { + suspendFinderAndResetInterruptedFlag = true; + + return suspended; + } + + /** + * Interrupt IP finder cleaner thread. + */ + public void interruptCleanerThread() { + if (cleanerThread != null) + cleanerThread.interrupt(); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMarshallerCheckSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMarshallerCheckSelfTest.java index 696225c495d5c..778b6d0106507 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMarshallerCheckSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMarshallerCheckSelfTest.java @@ -22,13 +22,15 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.spi.IgniteSpiException; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link TcpDiscoverySpi}. */ +@RunWith(JUnit4.class) public class TcpDiscoveryMarshallerCheckSelfTest extends GridCommonAbstractTest { /** */ private static boolean sameMarsh; @@ -36,19 +38,10 @@ public class TcpDiscoveryMarshallerCheckSelfTest extends GridCommonAbstractTest /** */ private static boolean flag; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - cfg.setLocalHost("127.0.0.1"); if (flag) @@ -72,6 +65,7 @@ public class TcpDiscoveryMarshallerCheckSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testMarshallerInConsistency() throws Exception { sameMarsh = false; @@ -93,10 +87,11 @@ public void testMarshallerInConsistency() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMarshallerConsistency() throws Exception { sameMarsh = true; startGrid(1); startGrid(2); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java index 70d5078832c30..fcc76f269a325 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java @@ -54,10 +54,11 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_JOB_MAPPED; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; @@ -68,6 +69,7 @@ /** * Test for {@link TcpDiscoverySpi}. */ +@RunWith(JUnit4.class) public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 5; @@ -96,9 +98,6 @@ private static boolean client() { return client != null ? client : clientFlagGlobal; } - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * @throws Exception If fails. */ @@ -107,10 +106,11 @@ public TcpDiscoveryMultiThreadedTest() throws Exception { } /** {@inheritDoc} */ - @SuppressWarnings({"IfMayBeConditional"}) @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + cfg.setConsistentId(igniteInstanceName); + UUID id = nodeId.get(); if (id != null) { @@ -122,10 +122,8 @@ public TcpDiscoveryMultiThreadedTest() throws Exception { if (client()) cfg.setClientMode(true); - cfg.setDiscoverySpi(new TcpDiscoverySpi(). - setIpFinder(ipFinder). - setJoinTimeout(60_000). - setNetworkTimeout(10_000)); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setJoinTimeout(60_000); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setNetworkTimeout(10_000); int[] evts = {EVT_NODE_FAILED, EVT_NODE_LEFT}; @@ -171,6 +169,7 @@ public TcpDiscoveryMultiThreadedTest() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testMultiThreadedClientsRestart() throws Exception { final AtomicBoolean done = new AtomicBoolean(); @@ -219,6 +218,7 @@ public void testMultiThreadedClientsRestart() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testMultiThreadedClientsServersRestart() throws Throwable { fail("https://issues.apache.org/jira/browse/IGNITE-1123"); @@ -228,7 +228,10 @@ public void testMultiThreadedClientsServersRestart() throws Throwable { /** * @throws Exception If any error occurs. */ - public void _testMultiThreadedServersRestart() throws Throwable { + @Test + public void testMultiThreadedServersRestart() throws Throwable { + fail("https://issues.apache.org/jira/browse/IGNITE-1123"); + multiThreadedClientsServersRestart(GRID_CNT * 2, 0); } @@ -423,6 +426,7 @@ else if (X.hasCause(e, ClusterTopologyCheckedException.class)) /** * @throws Exception If any error occurs. */ + @Test public void testTopologyVersion() throws Exception { clientFlagGlobal = false; @@ -447,6 +451,7 @@ public void testTopologyVersion() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testMultipleStartOnCoordinatorStop() throws Exception{ for (int k = 0; k < 3; k++) { log.info("Iteration: " + k); @@ -496,7 +501,10 @@ public void testMultipleStartOnCoordinatorStop() throws Exception{ /** * @throws Exception If failed. */ - public void _testCustomEventOnJoinCoordinatorStop() throws Exception { + @Test + public void testCustomEventOnJoinCoordinatorStop() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10198"); + for (int k = 0; k < 10; k++) { log.info("Iteration: " + k); @@ -513,11 +521,13 @@ public void _testCustomEventOnJoinCoordinatorStop() throws Exception { IgniteInternalFuture fut1 = GridTestUtils.runAsync(new Callable() { @Override public Void call() throws Exception { - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + String cacheName = DEFAULT_CACHE_NAME + "-tmp"; Ignite ignite = ignite(START_NODES - 1); while (!stop.get()) { + CacheConfiguration ccfg = new CacheConfiguration(cacheName); + ignite.createCache(ccfg); ignite.destroyCache(ccfg.getName()); @@ -590,7 +600,10 @@ public void _testCustomEventOnJoinCoordinatorStop() throws Exception { /** * @throws Exception If failed. */ - public void _testClientContinuousQueryCoordinatorStop() throws Exception { + @Test + public void testClientContinuousQueryCoordinatorStop() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10198"); + for (int k = 0; k < 10; k++) { log.info("Iteration: " + k); @@ -659,7 +672,10 @@ public void _testClientContinuousQueryCoordinatorStop() throws Exception { /** * @throws Exception If failed. */ - public void _testCustomEventNodeRestart() throws Exception { + @Test + public void testCustomEventNodeRestart() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-10249"); + clientFlagGlobal = false; Ignite ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeAttributesUpdateOnReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeAttributesUpdateOnReconnectTest.java index 56dc4ece5f4fc..25b14a92bfe96 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeAttributesUpdateOnReconnectTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeAttributesUpdateOnReconnectTest.java @@ -32,12 +32,16 @@ import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteClientReconnectAbstractTest.reconnectClientNode; /** * Checks whether on client reconnect node attributes from kernal context are sent. */ +@RunWith(JUnit4.class) public class TcpDiscoveryNodeAttributesUpdateOnReconnectTest extends GridCommonAbstractTest { /** */ private volatile String rejoinAttr; @@ -85,6 +89,7 @@ public class TcpDiscoveryNodeAttributesUpdateOnReconnectTest extends GridCommonA /** * @throws Exception If failed. */ + @Test public void testReconnect() throws Exception { Ignite srv = startGrid("server"); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConfigConsistentIdSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConfigConsistentIdSelfTest.java index 3f80746edac8a..f7c066ddf55e9 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConfigConsistentIdSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConfigConsistentIdSelfTest.java @@ -19,25 +19,22 @@ import java.io.Serializable; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link IgniteConfiguration#consistentId}. */ +@RunWith(JUnit4.class) public class TcpDiscoveryNodeConfigConsistentIdSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setLocalHost("0.0.0.0"); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder)); - cfg.setConsistentId(igniteInstanceName); return cfg; @@ -56,6 +53,7 @@ public class TcpDiscoveryNodeConfigConsistentIdSelfTest extends GridCommonAbstra /** * @throws Exception If failed. */ + @Test public void testConsistentId() throws Exception { Object id0 = grid(0).localNode().consistentId(); Serializable id1 = grid(0).configuration().getConsistentId(); @@ -72,4 +70,4 @@ public void testConsistentId() throws Exception { assertEquals(id0, grid(0).localNode().consistentId()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java index b9d7682df5129..5a3f3109ace2f 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java @@ -20,25 +20,22 @@ import org.apache.ignite.Ignite; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link TcpDiscoveryNode#consistentId()} */ +@RunWith(JUnit4.class) public class TcpDiscoveryNodeConsistentIdSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setLocalHost("0.0.0.0"); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder)); - return cfg; } @@ -55,6 +52,7 @@ public class TcpDiscoveryNodeConsistentIdSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testConsistentId() throws Exception { Object id0 = grid(0).localNode().consistentId(); @@ -77,4 +75,4 @@ public void testConsistentId() throws Exception { private int getDiscoveryPort(Ignite ignite) { return ((TcpDiscoveryNode) ignite.cluster().localNode()).discoveryPort(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryPendingMessageDeliveryTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryPendingMessageDeliveryTest.java index 9b3dfeea2e93d..c7b975703f255 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryPendingMessageDeliveryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryPendingMessageDeliveryTest.java @@ -24,27 +24,28 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.managers.discovery.CustomMessageWrapper; import org.apache.ignite.internal.managers.discovery.DiscoCache; import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.eclipse.jetty.util.ConcurrentHashSet; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class TcpDiscoveryPendingMessageDeliveryTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private volatile boolean blockMsgs; @@ -72,10 +73,12 @@ public class TcpDiscoveryPendingMessageDeliveryTest extends GridCommonAbstractTe disco = new DyingDiscoverySpi(); else if (igniteInstanceName.startsWith("listener")) disco = new ListeningDiscoverySpi(); + else if (igniteInstanceName.startsWith("receiver")) + disco = new DyingThreadDiscoverySpi(); else disco = new TcpDiscoverySpi(); - disco.setIpFinder(IP_FINDER); + disco.setIpFinder(sharedStaticIpFinder); cfg.setDiscoverySpi(disco); return cfg; @@ -84,6 +87,7 @@ else if (igniteInstanceName.startsWith("listener")) /** * @throws Exception If failed. */ + @Test public void testPendingMessagesOverflow() throws Exception { Ignite coord = startGrid("coordinator"); TcpDiscoverySpi coordDisco = (TcpDiscoverySpi)coord.configuration().getDiscoverySpi(); @@ -139,6 +143,7 @@ public void testPendingMessagesOverflow() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomMessageInSingletonCluster() throws Exception { Ignite coord = startGrid("coordinator"); TcpDiscoverySpi coordDisco = (TcpDiscoverySpi)coord.configuration().getDiscoverySpi(); @@ -184,6 +189,48 @@ public void testCustomMessageInSingletonCluster() throws Exception { }, 10000)); } + /** + * @throws Exception If failed. + */ + @Test + public void testDeliveryAllFailedMessagesInCorrectOrder() throws Exception { + IgniteEx coord = startGrid("coordinator"); + TcpDiscoverySpi coordDisco = (TcpDiscoverySpi)coord.configuration().getDiscoverySpi(); + + Set sentEnsuredMsgs = new GridConcurrentHashSet<>(); + coordDisco.addSendMessageListener(msg -> { + if (coordDisco.ensured(msg)) + sentEnsuredMsgs.add(msg); + }); + + //Node which receive message but will not send it further around the ring. + IgniteEx receiver = startGrid("receiver"); + + //Node which will be failed first. + IgniteEx dummy = startGrid("dummy"); + + //Node which should received all fail message in any way. + startGrid("listener"); + + sentEnsuredMsgs.clear(); + receivedEnsuredMsgs.clear(); + + blockMsgs = true; + + log.info("Sending fail node messages"); + + coord.context().discovery().failNode(dummy.localNode().id(), "Dummy node failed"); + coord.context().discovery().failNode(receiver.localNode().id(), "Receiver node failed"); + + boolean delivered = GridTestUtils.waitForCondition(() -> { + log.info("Waiting for messages delivery"); + + return receivedEnsuredMsgs.equals(sentEnsuredMsgs); + }, 5000); + + assertTrue("Sent: " + sentEnsuredMsgs + "; received: " + receivedEnsuredMsgs, delivered); + } + /** * @param disco Discovery SPI. * @param id Message id. @@ -192,6 +239,17 @@ private void sendDummyCustomMessage(TcpDiscoverySpi disco, IgniteUuid id) { disco.sendCustomEvent(new CustomMessageWrapper(new DummyCustomDiscoveryMessage(id))); } + /** + * Discovery SPI, that makes a thread to die when {@code blockMsgs} is set to {@code true}. + */ + private class DyingThreadDiscoverySpi extends TcpDiscoverySpi { + /** {@inheritDoc} */ + @Override protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) { + if (blockMsgs) + throw new RuntimeException("Thread is dying"); + } + } + /** * Discovery SPI, that makes a node stop sending messages when {@code blockMsgs} is set to {@code true}. */ diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryRestartTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryRestartTest.java index cacefa58c14e0..fd7d9eec7f87f 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryRestartTest.java @@ -30,13 +30,15 @@ import org.apache.ignite.events.DiscoveryEvent; import org.apache.ignite.events.Event; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.util.GridConcurrentHashSet; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.eclipse.jetty.util.ConcurrentHashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; import static org.apache.ignite.events.EventType.EVT_NODE_JOINED; @@ -45,10 +47,8 @@ /** * */ +@RunWith(JUnit4.class) public class TcpDiscoveryRestartTest extends GridCommonAbstractTest { - /** */ - private TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static AtomicReference err; @@ -56,12 +56,6 @@ public class TcpDiscoveryRestartTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - int[] evts = {EVT_NODE_JOINED, EVT_NODE_FAILED, EVT_NODE_LEFT}; cfg.setIncludeEventTypes(evts); @@ -83,6 +77,7 @@ public class TcpDiscoveryRestartTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRestart() throws Exception { err = new AtomicReference<>(); @@ -90,7 +85,7 @@ public void testRestart() throws Exception { startGrids(NODE_CNT); - final ConcurrentHashSet nodeIds = new ConcurrentHashSet<>(); + final GridConcurrentHashSet nodeIds = new GridConcurrentHashSet<>(); final AtomicInteger id = new AtomicInteger(NODE_CNT); @@ -172,10 +167,10 @@ private void failed(String msg) { */ private class TestEventListener implements IgnitePredicate { /** */ - private final ConcurrentHashSet joinIds = new ConcurrentHashSet<>(); + private final GridConcurrentHashSet joinIds = new GridConcurrentHashSet<>(); /** */ - private final ConcurrentHashSet leftIds = new ConcurrentHashSet<>(); + private final GridConcurrentHashSet leftIds = new GridConcurrentHashSet<>(); /** {@inheritDoc} */ @Override public boolean apply(Event evt) { @@ -211,4 +206,4 @@ void checkEvents(final UUID nodeId) throws Exception { assertTrue("No left event: " + nodeId, leftIds.contains(nodeId)); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySegmentationPolicyTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySegmentationPolicyTest.java index 4c66d2463ab55..5e944f8d42449 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySegmentationPolicyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySegmentationPolicyTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for segmentation policy and failure handling in {@link TcpDiscoverySpi}. */ +@RunWith(JUnit4.class) public class TcpDiscoverySegmentationPolicyTest extends GridCommonAbstractTest { /** Nodes count. */ private static final int NODES_CNT = 3; @@ -59,6 +63,7 @@ public class TcpDiscoverySegmentationPolicyTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStopOnSegmentation() throws Exception { startGrids(NODES_CNT); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java index 1aae8fbc3133a..c57e0fde4e827 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java @@ -92,6 +92,9 @@ import org.eclipse.jetty.util.ConcurrentHashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.events.EventType.EVT_JOB_MAPPED; @@ -108,6 +111,7 @@ /** * Test for {@link TcpDiscoverySpi}. */ +@RunWith(JUnit4.class) public class TcpDiscoverySelfTest extends GridCommonAbstractTest { /** */ private TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); @@ -245,6 +249,7 @@ else if (igniteInstanceName.contains("testNodeShutdownOnRingMessageWorkerFailure /** * @throws Exception If any error occurs. */ + @Test public void testSingleNodeStartStop() throws Exception { try { startGrid(1); @@ -257,6 +262,7 @@ public void testSingleNodeStartStop() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testThreeNodesStartStop() throws Exception { try { IgniteEx ignite1 = startGrid(1); @@ -309,6 +315,7 @@ public void testThreeNodesStartStop() throws Exception { /** * @throws Exception If any errors occur. */ + @Test public void testNodeConnectMessageSize() throws Exception { try { Ignite g1 = startGrid(1); @@ -340,6 +347,7 @@ public void testNodeConnectMessageSize() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testPing() throws Exception { try { startGrid(1); @@ -370,6 +378,7 @@ public void testPing() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testFailureDetectionOnNodePing1() throws Exception { try { Ignite g1 = startGrid("testFailureDetectionOnNodePingCoordinator"); @@ -386,6 +395,7 @@ public void testFailureDetectionOnNodePing1() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testFailureDetectionOnNodePing2() throws Exception { try { startGrid("testFailureDetectionOnNodePingCoordinator"); @@ -402,6 +412,7 @@ public void testFailureDetectionOnNodePing2() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testFailureDetectionOnNodePing3() throws Exception { try { Ignite g1 = startGrid("testFailureDetectionOnNodePingCoordinator"); @@ -451,6 +462,7 @@ private void testFailureDetectionOnNodePing(Ignite pingingNode, Ignite failedNod /** * @throws Exception If any error occurs. */ + @Test public void testPingInterruptedOnNodeFailed() throws Exception { try { final Ignite pingingNode = startGrid("testPingInterruptedOnNodeFailedPingingNode"); @@ -528,6 +540,7 @@ public void testPingInterruptedOnNodeFailed() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testPingInterruptedOnNodeLeft() throws Exception { try { final Ignite pingingNode = startGrid("testPingInterruptedOnNodeFailedPingingNode"); @@ -583,6 +596,7 @@ public void testPingInterruptedOnNodeLeft() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testNodeAdded() throws Exception { try { final Ignite g1 = startGrid(1); @@ -624,6 +638,7 @@ public void testNodeAdded() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testOrdinaryNodeLeave() throws Exception { try { Ignite g1 = startGrid(1); @@ -659,6 +674,7 @@ public void testOrdinaryNodeLeave() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testCoordinatorNodeLeave() throws Exception { try { startGrid(1); @@ -703,6 +719,7 @@ public void testCoordinatorNodeLeave() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testOrdinaryNodeFailure() throws Exception { try { Ignite g1 = startGrid(1); @@ -737,6 +754,7 @@ public void testOrdinaryNodeFailure() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testCoordinatorNodeFailure() throws Exception { try { Ignite g1 = startGrid(1); @@ -766,6 +784,7 @@ public void testCoordinatorNodeFailure() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testMetricsSending() throws Exception { final AtomicBoolean stopping = new AtomicBoolean(); @@ -855,6 +874,7 @@ else if (id.equals(g2.cluster().localNode().id())) /** * @throws Exception If any error occurs. */ + @Test public void testFailBeforeNodeAddedSent() throws Exception { try { Ignite g1 = startGrid(1); @@ -900,6 +920,7 @@ else if (evt.type() == EVT_NODE_FAILED) /** * @throws Exception If any error occurs. */ + @Test public void testFailBeforeNodeLeftSent() throws Exception { try { startGrid(1); @@ -941,6 +962,7 @@ public void testFailBeforeNodeLeftSent() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testIpFinderCleaning() throws Exception { try { ipFinder.registerAddresses(Arrays.asList(new InetSocketAddress("1.1.1.1", 1024), @@ -988,6 +1010,7 @@ public void testIpFinderCleaning() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testNonSharedIpFinder() throws Exception { try { GridTestUtils.runMultiThreadedAsync(new Callable() { @@ -1011,6 +1034,7 @@ public void testNonSharedIpFinder() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testMulticastIpFinder() throws Exception { try { for (int i = 0; i < 5; i++) { @@ -1043,6 +1067,7 @@ public void testMulticastIpFinder() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testInvalidAddressIpFinder() throws Exception { ipFinder.setShared(false); @@ -1069,6 +1094,7 @@ public void testInvalidAddressIpFinder() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testJoinTimeout() throws Exception { try { // This start will fail as expected. @@ -1090,6 +1116,7 @@ public void testJoinTimeout() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testJoinTimeoutForIpFinder() throws Exception { try { // This start will fail as expected. @@ -1124,6 +1151,7 @@ public void testJoinTimeoutForIpFinder() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDirtyIpFinder() throws Exception { try { // Dirty IP finder @@ -1143,6 +1171,7 @@ public void testDirtyIpFinder() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testDuplicateId() throws Exception { try { // Random ID. @@ -1174,6 +1203,7 @@ public void testDuplicateId() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testLoopbackProblemFirstNodeOnLoopback() throws Exception { // On Windows and Mac machines two nodes can reside on the same port // (if one node has localHost="127.0.0.1" and another has localHost="0.0.0.0"). @@ -1206,6 +1236,7 @@ public void testLoopbackProblemFirstNodeOnLoopback() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testLoopbackProblemSecondNodeOnLoopback() throws Exception { if (U.isWindows() || U.isMacOs()) return; @@ -1235,6 +1266,7 @@ public void testLoopbackProblemSecondNodeOnLoopback() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testGridStartTime() throws Exception { try { startGridsMultiThreaded(5); @@ -1281,6 +1313,7 @@ public void testGridStartTime() throws Exception { /** * @throws Exception If failed */ + @Test public void testCustomEventRace1_1() throws Exception { try { customEventRace1(true, false); @@ -1293,6 +1326,7 @@ public void testCustomEventRace1_1() throws Exception { /** * @throws Exception If failed */ + @Test public void testCustomEventRace1_2() throws Exception { try { customEventRace1(false, false); @@ -1305,6 +1339,7 @@ public void testCustomEventRace1_2() throws Exception { /** * @throws Exception If failed */ + @Test public void testCustomEventRace1_3() throws Exception { try { customEventRace1(true, true); @@ -1406,6 +1441,7 @@ private void customEventRace1(final boolean cacheStartFrom1, boolean stopCrd) th /** * @throws Exception If failed */ + @Test public void testCustomEventCoordinatorFailure1() throws Exception { try { customEventCoordinatorFailure(true); @@ -1418,6 +1454,7 @@ public void testCustomEventCoordinatorFailure1() throws Exception { /** * @throws Exception If failed */ + @Test public void testCustomEventCoordinatorFailure2() throws Exception { try { customEventCoordinatorFailure(false); @@ -1430,6 +1467,7 @@ public void testCustomEventCoordinatorFailure2() throws Exception { /** * @throws Exception If failed */ + @Test public void testNodeShutdownOnRingMessageWorkerFailure() throws Exception { try { final TestMessageWorkerFailureSpi1 spi0 = new TestMessageWorkerFailureSpi1( @@ -1480,6 +1518,7 @@ public void testNodeShutdownOnRingMessageWorkerFailure() throws Exception { /** * @throws Exception If failed */ + @Test public void testNoRingMessageWorkerAbnormalFailureOnSegmentation() throws Exception { try { TestMessageWorkerFailureSpi1 spi1 = new TestMessageWorkerFailureSpi1( @@ -1563,6 +1602,7 @@ public void testNoRingMessageWorkerAbnormalFailureOnSegmentation() throws Except /** * @throws Exception If failed */ + @Test public void testNodeShutdownOnRingMessageWorkerStartNotFinished() throws Exception { try { Ignite ignite0 = startGrid(0); @@ -1672,6 +1712,7 @@ private void customEventCoordinatorFailure(boolean twoNodes) throws Exception { * * @throws Exception If failed. */ + @Test public void testFailedNodes1() throws Exception { try { final int FAIL_ORDER = 3; @@ -1716,6 +1757,7 @@ public void testFailedNodes1() throws Exception { * * @throws Exception If failed. */ + @Test public void testFailedNodes2() throws Exception { try { final int FAIL_ORDER = 3; @@ -1760,6 +1802,7 @@ public void testFailedNodes2() throws Exception { * * @throws Exception If failed. */ + @Test public void testFailedNodes3() throws Exception { try { nodeSpi.set(createFailedNodeSpi(-1)); @@ -1793,6 +1836,7 @@ public void testFailedNodes3() throws Exception { * * @throws Exception If failed. */ + @Test public void testFailedNodes4() throws Exception { try { final int FAIL_ORDER = 3; @@ -1836,6 +1880,7 @@ public void testFailedNodes4() throws Exception { * * @throws Exception If failed. */ + @Test public void testFailedNodes5() throws Exception { try { ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -1892,6 +1937,7 @@ public void testFailedNodes5() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomEventAckNotSend() throws Exception { try { TestCustomerEventAckSpi spi0 = new TestCustomerEventAckSpi(); @@ -1920,6 +1966,7 @@ public void testCustomEventAckNotSend() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDiscoveryEventsDiscard() throws Exception { try { TestEventDiscardSpi spi = new TestEventDiscardSpi(); @@ -1954,6 +2001,7 @@ public void testDiscoveryEventsDiscard() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoExtraNodeFailedMessage() throws Exception { try { final int NODES = 10; @@ -2002,6 +2050,7 @@ public void testNoExtraNodeFailedMessage() throws Exception { /** * Test verifies Ignite nodes don't exchange system types on discovery phase but only user types. */ + @Test public void testSystemMarshallerTypesFilteredOut() throws Exception { try { nodeSpi.set(new TestTcpDiscoveryMarshallerDataSpi()); @@ -2035,6 +2084,7 @@ public void testSystemMarshallerTypesFilteredOut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDuplicatedDiscoveryDataRemoved() throws Exception { try { TestDiscoveryDataDuplicateSpi.checkNodeAdded = false; @@ -2092,6 +2142,7 @@ public void testDuplicatedDiscoveryDataRemoved() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFailedNodeRestoreConnection() throws Exception { try { TestRestoreConnectedSpi.startTest = false; diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySnapshotHistoryTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySnapshotHistoryTest.java index b55473ca80d80..65303a946195a 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySnapshotHistoryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySnapshotHistoryTest.java @@ -26,12 +26,16 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.Collections; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.DFLT_TOP_HISTORY_SIZE; /** * Tests for topology snapshots history. */ +@RunWith(JUnit4.class) public class TcpDiscoverySnapshotHistoryTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -52,6 +56,7 @@ public class TcpDiscoverySnapshotHistoryTest extends GridCommonAbstractTest { /** * @throws Exception If any error occurs. */ + @Test public void testHistorySupported() throws Exception { try { final Ignite g = startGrid(); @@ -72,6 +77,7 @@ public void testHistorySupported() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testSettingNewTopologyHistorySize() throws Exception { try { final Ignite g = startGrid(); @@ -96,6 +102,7 @@ public void testSettingNewTopologyHistorySize() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testNodeAdded() throws Exception { try { // Add grid #1 @@ -129,6 +136,7 @@ public void testNodeAdded() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testNodeAddedAndRemoved() throws Exception { try { // Add grid #1 @@ -174,4 +182,4 @@ private static void assertTopVer(long expTopVer, Ignite... ignites) { for (Ignite g : ignites) assertEquals("Grid has wrong topology version.", expTopVer, g.cluster().topologyVersion()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java index ea1bb27db088a..850ca1fa11fd2 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java @@ -21,15 +21,20 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridSpiTest(spi = TcpDiscoverySpi.class, group = "Discovery SPI") +@RunWith(JUnit4.class) public class TcpDiscoverySpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new TcpDiscoverySpi(), "ipFinder", null); checkNegativeSpiProperty(new TcpDiscoverySpi(), "ipFinderCleanFrequency", 0); @@ -47,6 +52,7 @@ public void testNegativeConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalPortRange() throws Exception { try { IgniteConfiguration cfg = getConfiguration(); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java index a760e2e06b87d..56324a79b4725 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryConnectionCheckMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryPingRequest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelfTest { /** */ private static final int SPI_COUNT = 6; @@ -84,6 +88,7 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf /** * @throws Exception In case of error. */ + @Test public void testFailureDetectionTimeoutEnabled() throws Exception { assertTrue(firstSpi().failureDetectionTimeoutEnabled()); assertTrue(secondSpi().failureDetectionTimeoutEnabled()); @@ -102,6 +107,7 @@ public void testFailureDetectionTimeoutEnabled() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testFailureDetectionTimeoutDisabled() throws Exception { for (int i = 2; i < spis.size(); i++) { assertFalse(((TcpDiscoverySpi)spis.get(i)).failureDetectionTimeoutEnabled()); @@ -113,6 +119,7 @@ public void testFailureDetectionTimeoutDisabled() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testFailureDetectionOnSocketOpen() throws Exception { try { ClusterNode node = secondSpi().getLocalNode(); @@ -139,6 +146,7 @@ public void testFailureDetectionOnSocketOpen() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testFailureDetectionOnSocketWrite() throws Exception { try { ClusterNode node = secondSpi().getLocalNode(); @@ -161,6 +169,7 @@ public void testFailureDetectionOnSocketWrite() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testConnectionCheckMessage() throws Exception { TestTcpDiscoverySpi nextSpi = null; diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBeanTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBeanTest.java index 53ddfa015f31b..3a4d7cfad03e2 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBeanTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBeanTest.java @@ -27,10 +27,14 @@ import javax.management.MBeanServer; import javax.management.ObjectName; import java.lang.management.ManagementFactory; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests TcpDiscoverySpiMBean. */ +@RunWith(JUnit4.class) public class TcpDiscoverySpiMBeanTest extends GridCommonAbstractTest { /** */ private GridStringLogger strLog = new GridStringLogger(); @@ -54,6 +58,7 @@ public class TcpDiscoverySpiMBeanTest extends GridCommonAbstractTest { * * @throws Exception if fails. */ + @Test public void testMBean() throws Exception { startGrids(3); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiRandomStartStopTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiRandomStartStopTest.java index 7edfa6b4e0bc5..b2570bb86c386 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiRandomStartStopTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiRandomStartStopTest.java @@ -18,8 +18,6 @@ package org.apache.ignite.spi.discovery.tcp; import org.apache.ignite.spi.discovery.AbstractDiscoveryRandomStartStopTest; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.spi.GridSpiTest; /** @@ -28,18 +26,8 @@ @GridSpiTest(spi = TcpDiscoverySpi.class, group = "Discovery SPI") public class TcpDiscoverySpiRandomStartStopTest extends AbstractDiscoveryRandomStartStopTest { - /** */ - private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected int getMaxInterval() { return 10; } - - /** {@inheritDoc} */ - @Override protected void spiConfigure(TcpDiscoverySpi spi) throws Exception { - super.spiConfigure(spi); - - spi.setIpFinder(ipFinder); - } } \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiReconnectDelayTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiReconnectDelayTest.java index 89df32c98f81e..7d9daf9fb7a18 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiReconnectDelayTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiReconnectDelayTest.java @@ -36,6 +36,9 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientReconnectMessage; import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED; @@ -47,6 +50,7 @@ /** * Test for {@link TcpDiscoverySpi#setReconnectDelay(int)}. */ +@RunWith(JUnit4.class) public class TcpDiscoverySpiReconnectDelayTest extends GridCommonAbstractTest { /** Time to wait for events. */ private static final int EVT_TIMEOUT = 120000; @@ -61,11 +65,13 @@ public class TcpDiscoverySpiReconnectDelayTest extends GridCommonAbstractTest { //region Client joins after failNode() /** */ + @Test public void testClientJoinAfterFailureShortTimeout() throws Exception { checkClientJoinAfterNodeFailure(5, 500); } /** */ + @Test public void testClientJoinAfterFailureLongTimeout() throws Exception { checkClientJoinAfterNodeFailure(3, 5000); } @@ -157,11 +163,13 @@ else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED) //region Client joins after brakeConnection() /** */ + @Test public void testClientJoinAfterSocketClosedShortTimeout() throws Exception { checkClientJoinAfterSocketClosed(5, 500); } /** */ + @Test public void testClientJoinAfterSocketClosedLongTimeout() throws Exception { checkClientJoinAfterSocketClosed(3, 5000); } @@ -221,21 +229,25 @@ private void checkClientJoinAfterSocketClosed(int numOfFailedRequests, int recon //region Client joins at start /** */ + @Test public void testClientJoinAtStartShortTimeout() throws Exception { checkClientJoinAtStart(5, 500); } /** */ + @Test public void testClientJoinAtStartLongTimeout() throws Exception { checkClientJoinAtStart(3, 5000); } /** */ + @Test public void testServerJoinAtStartShortTimeout() throws Exception { checkServerJoinAtStart(5, 500); } /** */ + @Test public void testServerJoinAtStartLongTimeout() throws Exception { checkServerJoinAtStart(3, 5000); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiWildcardSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiWildcardSelfTest.java index 3d2f2431ff61e..7651d396eb277 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiWildcardSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiWildcardSelfTest.java @@ -18,17 +18,16 @@ package org.apache.ignite.spi.discovery.tcp; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class TcpDiscoverySpiWildcardSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 5; @@ -36,11 +35,6 @@ public class TcpDiscoverySpiWildcardSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); cfg.setLocalHost(null); return cfg; @@ -49,6 +43,7 @@ public class TcpDiscoverySpiWildcardSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTopology() throws Exception { try { startGridsMultiThreaded(NODES); @@ -60,4 +55,4 @@ public void testTopology() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslParametersTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslParametersTest.java index f2fc2780de9ef..7d0dfddb2a691 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslParametersTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslParametersTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.ssl.SslContextFactory; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests cases when node connects to cluster with different set of cipher suites. */ +@RunWith(JUnit4.class) public class TcpDiscoverySslParametersTest extends GridCommonAbstractTest { /** */ @@ -59,6 +63,7 @@ public class TcpDiscoverySslParametersTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSameCipherSuite() throws Exception { checkDiscoverySuccess( new String[][] { @@ -80,6 +85,7 @@ public void testSameCipherSuite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOneCommonCipherSuite() throws Exception { checkDiscoverySuccess( new String[][] { @@ -99,6 +105,7 @@ public void testOneCommonCipherSuite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoCommonCipherSuite() throws Exception { checkDiscoveryFailure( new String[][] { @@ -117,6 +124,7 @@ public void testNoCommonCipherSuite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNonExistentCipherSuite() throws Exception { checkDiscoveryFailure( new String[][] { @@ -138,6 +146,7 @@ public void testNonExistentCipherSuite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoCommonProtocols() throws Exception { checkDiscoveryFailure( null, @@ -157,6 +166,7 @@ public void testNoCommonProtocols() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNonExistentProtocol() throws Exception { checkDiscoveryFailure( null, @@ -177,6 +187,7 @@ public void testNonExistentProtocol() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSameProtocols() throws Exception { checkDiscoverySuccess(null, new String[][] { @@ -195,6 +206,7 @@ public void testSameProtocols() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOneCommonProtocol() throws Exception { checkDiscoverySuccess(null, new String[][] { diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java index ca34f779760cf..6803dddd38954 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java @@ -29,11 +29,15 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests cases when node connects to cluster with different SSL configuration. * Exception with meaningful message should be thrown. */ +@RunWith(JUnit4.class) public class TcpDiscoverySslSecuredUnsecuredTest extends GridCommonAbstractTest { /** */ private volatile TcpDiscoverySpi spi; @@ -66,6 +70,7 @@ public class TcpDiscoverySslSecuredUnsecuredTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testSecuredUnsecuredServerConnection() throws Exception { checkConnection("plain-server", "ssl-server"); } @@ -73,6 +78,7 @@ public void testSecuredUnsecuredServerConnection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUnsecuredSecuredServerConnection() throws Exception { checkConnection("ssl-server", "plain-server"); } @@ -80,6 +86,7 @@ public void testUnsecuredSecuredServerConnection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSecuredClientUnsecuredServerConnection() throws Exception { checkConnection("plain-server", "ssl-client"); } @@ -87,6 +94,7 @@ public void testSecuredClientUnsecuredServerConnection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUnsecuredClientSecuredServerConnection() throws Exception { checkConnection("ssl-server", "plain-client"); } @@ -94,6 +102,7 @@ public void testUnsecuredClientSecuredServerConnection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPlainServerNodesRestart() throws Exception { checkNodesRestart("plain-server-1", "plain-server-2"); } @@ -101,6 +110,7 @@ public void testPlainServerNodesRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSslServerNodesRestart() throws Exception { checkNodesRestart("ssl-server-1", "ssl-server-2"); } @@ -108,6 +118,7 @@ public void testSslServerNodesRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPlainClientNodesRestart() throws Exception { checkNodesRestart("plain-server", "plain-client"); } @@ -115,6 +126,7 @@ public void testPlainClientNodesRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSslClientNodesRestart() throws Exception { checkNodesRestart("ssl-server", "ssl-client"); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslTrustedUntrustedTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslTrustedUntrustedTest.java index e1c6755380d48..1357b1d7be6d6 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslTrustedUntrustedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslTrustedUntrustedTest.java @@ -22,11 +22,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests cases when node connects to cluster with different SSL configuration. * Exception with meaningful message should be thrown. */ +@RunWith(JUnit4.class) public class TcpDiscoverySslTrustedUntrustedTest extends GridCommonAbstractTest { /** */ private volatile String keyStore; @@ -50,6 +54,7 @@ public class TcpDiscoverySslTrustedUntrustedTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testSameKey() throws Exception { checkDiscoverySuccess("node01", "trustone", "node01", "trustone"); } @@ -57,6 +62,7 @@ public void testSameKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentKeys() throws Exception { checkDiscoverySuccess("node02", "trusttwo", "node03", "trusttwo"); } @@ -64,6 +70,7 @@ public void testDifferentKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBothTrusts() throws Exception { checkDiscoverySuccess("node01", "trustboth", "node02", "trustboth", "node03", "trustboth"); } @@ -71,6 +78,7 @@ public void testBothTrusts() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDifferentCa() throws Exception { checkDiscoveryFailure("node01", "trustone", "node02", "trusttwo"); } @@ -78,6 +86,7 @@ public void testDifferentCa() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWrongCa() throws Exception { checkDiscoveryFailure("node02", "trustone", "node03", "trustone"); } @@ -85,6 +94,7 @@ public void testWrongCa() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMismatchingCaSecond() throws Exception { checkDiscoveryFailure("node01", "trustboth", "node03", "trusttwo"); } @@ -92,6 +102,7 @@ public void testMismatchingCaSecond() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMismatchingCaFirst() throws Exception { checkDiscoveryFailure("node02", "trusttwo", "node01", "trustboth"); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryWithWrongServerTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryWithWrongServerTest.java index ffd0d030c643e..50e4cf255aa0a 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryWithWrongServerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryWithWrongServerTest.java @@ -36,10 +36,14 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestThread; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Client-based discovery SPI test with non-Ignite servers. */ +@RunWith(JUnit4.class) public class TcpDiscoveryWithWrongServerTest extends GridCommonAbstractTest { /** Non-Ignite Server port #1. */ private final static int SERVER_PORT = 47500; @@ -123,6 +127,7 @@ private void stopTcpThreads() throws IOException { * * @throws Exception in case of error. */ + @Test public void testWrongHandshakeResponse() throws Exception { startTcpThread(new SomeResponseWorker(), SERVER_PORT); startTcpThread(new SomeResponseWorker(), LAST_SERVER_PORT); @@ -135,6 +140,7 @@ public void testWrongHandshakeResponse() throws Exception { * * @throws Exception in case of error. */ + @Test public void testNoHandshakeResponse() throws Exception { startTcpThread(new NoResponseWorker(), SERVER_PORT); startTcpThread(new NoResponseWorker(), LAST_SERVER_PORT); @@ -147,6 +153,7 @@ public void testNoHandshakeResponse() throws Exception { * * @throws Exception in case of error. */ + @Test public void testDisconnectOnRequest() throws Exception { startTcpThread(new DisconnectOnRequestWorker(), SERVER_PORT); startTcpThread(new DisconnectOnRequestWorker(), LAST_SERVER_PORT); @@ -159,6 +166,7 @@ public void testDisconnectOnRequest() throws Exception { * * @throws Exception in case of error. */ + @Test public void testEarlyDisconnect() throws Exception { startTcpThread(new EarlyDisconnectWorker(), SERVER_PORT); startTcpThread(new EarlyDisconnectWorker(), LAST_SERVER_PORT); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinderAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinderAbstractSelfTest.java index 465b38dbe7859..f57266555f2d0 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinderAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinderAbstractSelfTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Abstract test for ip finder. */ +@RunWith(JUnit4.class) public abstract class TcpDiscoveryIpFinderAbstractSelfTest extends GridCommonAbstractTest { /** */ @@ -64,6 +68,7 @@ protected TcpDiscoveryIpFinderAbstractSelfTest() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testIpFinder() throws Exception { finder.initializeLocalAddresses(Arrays.asList(new InetSocketAddress(InetAddress.getLocalHost(), 1000))); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/jdbc/TcpDiscoveryJdbcIpFinderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/jdbc/TcpDiscoveryJdbcIpFinderSelfTest.java index 37352e16e8e2a..9d4e4d347bcfc 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/jdbc/TcpDiscoveryJdbcIpFinderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/jdbc/TcpDiscoveryJdbcIpFinderSelfTest.java @@ -20,10 +20,14 @@ import com.mchange.v2.c3p0.ComboPooledDataSource; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * JDBC IP finder self test. */ +@RunWith(JUnit4.class) public class TcpDiscoveryJdbcIpFinderSelfTest extends TcpDiscoveryIpFinderAbstractSelfTest { /** */ @@ -66,6 +70,7 @@ public TcpDiscoveryJdbcIpFinderSelfTest() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInitSchemaFlag() throws Exception { initSchema = false; @@ -87,4 +92,4 @@ public void testInitSchemaFlag() throws Exception { dataSrc.close(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinderSelfTest.java index 29ed595f38189..a7a2f888fda5d 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinderSelfTest.java @@ -22,10 +22,14 @@ import java.util.Collections; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAbstractSelfTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * GridTcpDiscoveryMulticastIpFinder test. */ +@RunWith(JUnit4.class) public class TcpDiscoveryMulticastIpFinderSelfTest extends TcpDiscoveryIpFinderAbstractSelfTest { /** @@ -48,7 +52,8 @@ public TcpDiscoveryMulticastIpFinderSelfTest() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"TooBroadScope", "BusyWait"}) + @SuppressWarnings({"TooBroadScope"}) + @Test public void testExchange() throws Exception { String locAddr = null; @@ -131,4 +136,4 @@ private void checkRequestAddresses(TcpDiscoveryMulticastIpFinder ipFinder, int e assertEquals(exp, ipFinder.getRegisteredAddresses().size()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinderSelfTest.java index e065c8f376c33..152a9c055ce21 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinderSelfTest.java @@ -24,10 +24,14 @@ import java.util.List; import java.util.UUID; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * GridTcpDiscoverySharedFsIpFinder test. */ +@RunWith(JUnit4.class) public class TcpDiscoverySharedFsIpFinderSelfTest extends TcpDiscoveryIpFinderAbstractSelfTest { /** @@ -60,6 +64,7 @@ public TcpDiscoverySharedFsIpFinderSelfTest() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testUniqueNames() throws Exception { InetSocketAddress node1 = new InetSocketAddress("10.7.7.7", 4343); InetAddress ia = InetAddress.getByAddress("localhost", new byte[] {10, 7, 7, 7}); @@ -77,4 +82,4 @@ public void testUniqueNames() throws Exception { finder.close(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinderSelfTest.java index acc12c29142e2..9ca8e218237a4 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinderSelfTest.java @@ -27,12 +27,14 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAbstractSelfTest; import org.apache.ignite.testframework.GridTestUtils; - -import static org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryObjectsAbstractSelfTest.IP_FINDER; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * GridTcpDiscoveryVmIpFinder test. */ +@RunWith(JUnit4.class) public class TcpDiscoveryVmIpFinderSelfTest extends TcpDiscoveryIpFinderAbstractSelfTest { /** @@ -56,6 +58,7 @@ public TcpDiscoveryVmIpFinderSelfTest() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testAddressesInitialization() throws Exception { TcpDiscoveryVmIpFinder finder = ipFinder(); @@ -125,6 +128,7 @@ public void testAddressesInitialization() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testIpV6AddressesInitialization() throws Exception { TcpDiscoveryVmIpFinder finder = ipFinder(); @@ -202,30 +206,31 @@ public void testIpV6AddressesInitialization() throws Exception { /** * */ + @Test public void testUnregistration() throws Exception { Ignition.start(config("server1", false, false)); - int srvSize = IP_FINDER.getRegisteredAddresses().size(); + int srvSize = sharedStaticIpFinder.getRegisteredAddresses().size(); Ignition.start(config("server2", false, false)); Ignition.start(config("client1", true, false)); - assertEquals(2 * srvSize, IP_FINDER.getRegisteredAddresses().size()); + assertEquals(2 * srvSize, sharedStaticIpFinder.getRegisteredAddresses().size()); Ignition.start(config("client2", true, false)); Ignition.start(config("client3", true, false)); - assertEquals(2 * srvSize, IP_FINDER.getRegisteredAddresses().size()); + assertEquals(2 * srvSize, sharedStaticIpFinder.getRegisteredAddresses().size()); Ignition.start(config("client4", true, true)); - assertEquals(3 * srvSize, IP_FINDER.getRegisteredAddresses().size()); + assertEquals(3 * srvSize, sharedStaticIpFinder.getRegisteredAddresses().size()); Ignition.stop("client1", true); Ignition.stop("client2", true); Ignition.stop("client3", true); - assertEquals(3 * srvSize, IP_FINDER.getRegisteredAddresses().size()); + assertEquals(3 * srvSize, sharedStaticIpFinder.getRegisteredAddresses().size()); Ignition.stop("client4", true); @@ -246,7 +251,7 @@ public void testUnregistration() throws Exception { assertTrue(res); - assertTrue(3 * srvSize >= IP_FINDER.getRegisteredAddresses().size()); + assertTrue(3 * srvSize >= sharedStaticIpFinder.getRegisteredAddresses().size()); } /** @@ -262,10 +267,10 @@ private static IgniteConfiguration config(String name, boolean client, boolean f TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setForceServerMode(forceServerMode); - disco.setIpFinder(IP_FINDER); + disco.setIpFinder(sharedStaticIpFinder); cfg.setDiscoverySpi(disco); return cfg; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/encryption/KeystoreEncryptionSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/encryption/KeystoreEncryptionSpiSelfTest.java index dd3b164df834e..573c5c27acc05 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/encryption/KeystoreEncryptionSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/encryption/KeystoreEncryptionSpiSelfTest.java @@ -18,20 +18,24 @@ package org.apache.ignite.spi.encryption; import java.nio.ByteBuffer; -import junit.framework.TestCase; import org.apache.ignite.IgniteException; import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey; import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.ignite.internal.encryption.AbstractEncryptionTest.KEYSTORE_PASSWORD; import static org.apache.ignite.internal.encryption.AbstractEncryptionTest.KEYSTORE_PATH; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** */ -public class KeystoreEncryptionSpiSelfTest extends TestCase { +public class KeystoreEncryptionSpiSelfTest { /** @throws Exception If failed. */ + @Test public void testCantStartWithEmptyParam() throws Exception { GridTestUtils.assertThrowsWithCause(() -> { EncryptionSpi encSpi = new KeystoreEncryptionSpi(); @@ -41,6 +45,7 @@ public void testCantStartWithEmptyParam() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCantStartWithoutPassword() throws Exception { GridTestUtils.assertThrowsWithCause(() -> { KeystoreEncryptionSpi encSpi = new KeystoreEncryptionSpi(); @@ -52,6 +57,7 @@ public void testCantStartWithoutPassword() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCantStartKeystoreDoesntExists() throws Exception { GridTestUtils.assertThrowsWithCause(() -> { KeystoreEncryptionSpi encSpi = new KeystoreEncryptionSpi(); @@ -64,11 +70,12 @@ public void testCantStartKeystoreDoesntExists() throws Exception { } /** @throws Exception If failed. */ + @Test public void testEncryptDecrypt() throws Exception { EncryptionSpi encSpi = spi(); KeystoreEncryptionKey k = GridTestUtils.getFieldValue(encSpi, "masterKey"); - + assertNotNull(k); assertNotNull(k.key()); @@ -79,7 +86,7 @@ public void testEncryptDecrypt() throws Exception { assertNotNull(cipherText); assertEquals(encSpi.encryptedSize(plainText.length), cipherText.length); - + byte[] decryptedText = encSpi.decrypt(cipherText, k); assertNotNull(decryptedText); @@ -89,9 +96,10 @@ public void testEncryptDecrypt() throws Exception { } /** @throws Exception If failed. */ + @Test public void testKeyEncryptDecrypt() throws Exception { EncryptionSpi encSpi = spi(); - + KeystoreEncryptionKey k = (KeystoreEncryptionKey)encSpi.create(); assertNotNull(k); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageMultiThreadedSelfTest.java index f4395e8cccbb9..af99a0a5fecd4 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageMultiThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageMultiThreadedSelfTest.java @@ -25,15 +25,20 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Memory event storage load test. */ @GridSpiTest(spi = MemoryEventStorageSpi.class, group = "EventStorage SPI") +@RunWith(JUnit4.class) public class GridMemoryEventStorageMultiThreadedSelfTest extends GridSpiAbstractTest { /** * @throws Exception If test failed */ + @Test public void testMultiThreaded() throws Exception { GridTestUtils.runMultiThreaded(new Callable() { @Override public Object call() throws Exception { @@ -50,4 +55,4 @@ public void testMultiThreaded() throws Exception { assert evts.size() <= 10000 : "Incorrect number of events: " + evts.size(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageSpiConfigSelfTest.java index 3c82ffdb0c317..44b4c0af3fcad 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageSpiConfigSelfTest.java @@ -19,17 +19,22 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Memory event storage SPI config test. */ @GridSpiTest(spi = MemoryEventStorageSpi.class, group = "Event Storage SPI") +@RunWith(JUnit4.class) public class GridMemoryEventStorageSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new MemoryEventStorageSpi(), "expireCount", 0); checkNegativeSpiProperty(new MemoryEventStorageSpi(), "expireAgeMs", 0); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageSpiSelfTest.java index 0eb2df8be3c53..14cadb2b2f5ca 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/eventstorage/memory/GridMemoryEventStorageSpiSelfTest.java @@ -25,6 +25,9 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED; @@ -32,6 +35,7 @@ * Tests for {@link MemoryEventStorageSpi}. */ @GridSpiTest(spi = MemoryEventStorageSpi.class, group = "Event Storage SPI") +@RunWith(JUnit4.class) public class GridMemoryEventStorageSpiSelfTest extends GridSpiAbstractTest { /** */ private static final int EXPIRE_CNT = 100; @@ -55,6 +59,7 @@ public long getExpireAgeMs() { /** * @throws Exception If failed. */ + @Test public void testMemoryEventStorage() throws Exception { MemoryEventStorageSpi spi = getSpi(); @@ -101,7 +106,7 @@ public void testMemoryEventStorage() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"NullableProblems"}) + @Test public void testFilter() throws Exception { MemoryEventStorageSpi spi = getSpi(); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/always/GridAlwaysFailoverSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/always/GridAlwaysFailoverSpiConfigSelfTest.java index 20d2fda21fb1b..8be996b54b481 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/always/GridAlwaysFailoverSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/always/GridAlwaysFailoverSpiConfigSelfTest.java @@ -19,16 +19,21 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Always-failover SPI config test. */ @GridSpiTest(spi = AlwaysFailoverSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridAlwaysFailoverSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new AlwaysFailoverSpi(), "maximumFailoverAttempts", -1); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/always/GridAlwaysFailoverSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/always/GridAlwaysFailoverSpiSelfTest.java index 98f2b077e7344..c22a277539fb8 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/always/GridAlwaysFailoverSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/always/GridAlwaysFailoverSpiSelfTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.testframework.GridTestNode; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.spi.failover.always.AlwaysFailoverSpi.FAILED_NODE_LIST_ATTR; @@ -36,10 +39,12 @@ * Always-failover SPI test. */ @GridSpiTest(spi = AlwaysFailoverSpi.class, group = "Failover SPI") +@RunWith(JUnit4.class) public class GridAlwaysFailoverSpiSelfTest extends GridSpiAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSingleNode() throws Exception { AlwaysFailoverSpi spi = getSpi(); @@ -57,7 +62,7 @@ public void testSingleNode() throws Exception { /** * @throws Exception If test failed. */ - @SuppressWarnings("unchecked") + @Test public void testTwoNodes() throws Exception { AlwaysFailoverSpi spi = getSpi(); @@ -79,6 +84,7 @@ public void testTwoNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxAttempts() throws Exception { AlwaysFailoverSpi spi = getSpi(); @@ -119,4 +125,4 @@ private void checkFailedNodes(ComputeJobResult res, int cnt) { assert failedNodes != null; assert failedNodes.size() == cnt; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiConfigSelfTest.java index 2e91bba4c8917..f6ab3a5ff25a6 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiConfigSelfTest.java @@ -19,16 +19,21 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Job stealing failover SPI config test. */ @GridSpiTest(spi = JobStealingFailoverSpi.class, group = "Collision SPI") +@RunWith(JUnit4.class) public class GridJobStealingFailoverSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new JobStealingFailoverSpi(), "maximumFailoverAttempts", -1); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiOneNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiOneNodeSelfTest.java index abee6c52ab3b7..6ce79bfe885b2 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiOneNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiOneNodeSelfTest.java @@ -30,11 +30,15 @@ import org.apache.ignite.testframework.GridTestNode; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Job stealing failover SPI test for one node. */ @GridSpiTest(spi = JobStealingFailoverSpi.class, group = "Failover SPI") +@RunWith(JUnit4.class) public class GridJobStealingFailoverSpiOneNodeSelfTest extends GridSpiAbstractTest { /** {@inheritDoc} */ @Override protected GridSpiTestContext initSpiContext() throws Exception { @@ -69,6 +73,7 @@ private ClusterNode addSpiDependency(GridTestNode node) throws Exception { /** * @throws Exception If test failed. */ + @Test public void testFailover() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); @@ -86,6 +91,7 @@ public void testFailover() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNoFailover() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); @@ -96,4 +102,4 @@ public void testNoFailover() throws Exception { assert other == null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiSelfTest.java index 9a91375c8f129..4f7bc31ab0af6 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiSelfTest.java @@ -31,6 +31,9 @@ import org.apache.ignite.testframework.GridTestNode; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SPI_CLASS; import static org.apache.ignite.spi.collision.jobstealing.JobStealingCollisionSpi.THIEF_NODE_ATTR; @@ -41,6 +44,7 @@ * Self test for {@link JobStealingFailoverSpi} SPI. */ @GridSpiTest(spi = JobStealingFailoverSpi.class, group = "Failover SPI") +@RunWith(JUnit4.class) public class GridJobStealingFailoverSpiSelfTest extends GridSpiAbstractTest { /** {@inheritDoc} */ @Override protected GridSpiTestContext initSpiContext() throws Exception { @@ -76,6 +80,7 @@ private void addSpiDependency(GridTestNode node) throws Exception { /** * @throws Exception If test failed. */ + @Test public void testFailover() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); @@ -96,6 +101,7 @@ public void testFailover() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMaxHopsExceeded() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); @@ -115,6 +121,7 @@ public void testMaxHopsExceeded() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMaxHopsExceededThiefNotSet() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); @@ -132,6 +139,7 @@ public void testMaxHopsExceededThiefNotSet() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testNonZeroFailoverCount() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); @@ -154,6 +162,7 @@ public void testNonZeroFailoverCount() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testThiefNotInTopology() throws Exception { ClusterNode rmt = new GridTestNode(UUID.randomUUID()); @@ -175,6 +184,7 @@ public void testThiefNotInTopology() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testThiefEqualsVictim() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); @@ -196,6 +206,7 @@ public void testThiefEqualsVictim() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testThiefIdNotSet() throws Exception { ClusterNode rmt = getSpiContext().remoteNodes().iterator().next(); @@ -227,4 +238,4 @@ private void checkAttributes(ComputeJobContext ctx, ClusterNode failed, int fail assert failedSet.contains(failed.id()); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiSelfTest.java index d1767cb6864c5..d2baefea9b538 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiSelfTest.java @@ -27,15 +27,20 @@ import org.apache.ignite.testframework.GridTestNode; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Never failover SPI test. */ @GridSpiTest(spi = NeverFailoverSpi.class, group = "Failover SPI") +@RunWith(JUnit4.class) public class GridNeverFailoverSpiSelfTest extends GridSpiAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAlwaysNull() throws Exception { List nodes = new ArrayList<>(); @@ -46,4 +51,4 @@ public void testAlwaysNull() throws Exception { assert getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), new GridTestJobResult(node)), nodes) == null; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java index 7bbd2cb55abd1..9eb96ad65203a 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java @@ -19,17 +19,22 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridSpiTest(spi = AdaptiveLoadBalancingSpi.class, group = "LoadBalancing SPI") +@RunWith(JUnit4.class) public class GridAdaptiveLoadBalancingSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new AdaptiveLoadBalancingSpi(), "loadProbe", null); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java index 77dd26aac880c..58c4f4a47c76a 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java @@ -30,11 +30,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests adaptive load balancing SPI. */ @GridSpiTest(spi = AdaptiveLoadBalancingSpi.class, group = "Load Balancing SPI") +@RunWith(JUnit4.class) public class GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest extends GridSpiAbstractTest { /** */ private static final int RMT_NODE_CNT = 10; @@ -72,6 +76,7 @@ public AdaptiveLoadProbe getLoadProbe() { /** * @throws Exception If failed. */ + @Test public void testWeights() throws Exception { // Seal it. List nodes = new ArrayList<>(getSpiContext().remoteNodes()); @@ -99,4 +104,4 @@ public void testWeights() throws Exception { ", cnts[i+1]=" + cnts[i + 1] + ']'; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java index 3a377497c82d6..3675bb041950b 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java @@ -30,11 +30,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests adaptive load balancing SPI. */ @GridSpiTest(spi = AdaptiveLoadBalancingSpi.class, group = "Load Balancing SPI") +@RunWith(JUnit4.class) public class GridAdaptiveLoadBalancingSpiSelfTest extends GridSpiAbstractTest { /** {@inheritDoc} */ @Override protected GridSpiTestContext initSpiContext() throws Exception { @@ -65,6 +69,7 @@ public AdaptiveLoadProbe getLoadProbe() { * @throws Exception If failed. */ @SuppressWarnings({"ObjectEquality"}) + @Test public void testSingleNodeZeroWeight() throws Exception { GridTestNode node = (GridTestNode)getSpiContext().nodes().iterator().next(); @@ -90,6 +95,7 @@ public void testSingleNodeZeroWeight() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"ObjectEquality"}) + @Test public void testSingleNodeSameSession() throws Exception { GridTestNode node = (GridTestNode)getSpiContext().nodes().iterator().next(); @@ -115,6 +121,7 @@ public void testSingleNodeSameSession() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"ObjectEquality"}) + @Test public void testSingleNodeDifferentSession() throws Exception { GridTestNode node = (GridTestNode)getSpiContext().nodes().iterator().next(); @@ -135,4 +142,4 @@ public void testSingleNodeDifferentSession() throws Exception { assert pick1 == pick2; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/internal/GridInternalTasksLoadBalancingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/internal/GridInternalTasksLoadBalancingSelfTest.java index 26f4a3b98c828..59c1df6036ef8 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/internal/GridInternalTasksLoadBalancingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/internal/GridInternalTasksLoadBalancingSelfTest.java @@ -42,10 +42,14 @@ import org.apache.ignite.spi.loadbalancing.LoadBalancingSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that will start two nodes with custom load balancing SPI and execute {@link GridInternal} task on it. */ +@RunWith(JUnit4.class) public class GridInternalTasksLoadBalancingSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 2; @@ -82,6 +86,7 @@ public class GridInternalTasksLoadBalancingSelfTest extends GridCommonAbstractTe * * @throws Exception In case of error. */ + @Test public void testInternalTaskBalancing() throws Exception { customLoadBalancer = true; @@ -113,6 +118,7 @@ public void testInternalTaskBalancing() throws Exception { * * @throws Exception In case of error. */ + @Test public void testInternalTaskDefaultBalancing() throws Exception { customLoadBalancer = false; diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java index 79b1db46ae28a..f786d4e1e2f77 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java @@ -33,11 +33,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Multithreaded tests for global load balancer. */ @GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") +@RunWith(JUnit4.class) public class GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest extends GridSpiAbstractTest { /** Thread count. */ @@ -73,6 +77,7 @@ public boolean getPerTask() { * * @throws Exception If failed. */ + @Test public void testMultipleTaskSessionsMultithreaded() throws Exception { final RoundRobinLoadBalancingSpi spi = getSpi(); @@ -126,4 +131,4 @@ public void testMultipleTaskSessionsMultithreaded() throws Exception { } }, THREAD_CNT, "balancer-test-worker"); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java index 9fd0e6ea9672a..5bbe8b2f939f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java @@ -24,17 +24,22 @@ import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests Round Robin load balancing for single node. */ @GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI", triggerDiscovery = true) +@RunWith(JUnit4.class) public class GridRoundRobinLoadBalancingSpiLocalNodeSelfTest extends GridSpiAbstractTest { /** * @throws Exception If failed. */ @SuppressWarnings({"ObjectEquality"}) + @Test public void testLocalNode() throws Exception { assert getDiscoverySpi().getRemoteNodes().isEmpty(); @@ -51,4 +56,4 @@ public void testLocalNode() throws Exception { assert node == locNode; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java index 4eaba9b46ee99..fe18aec547786 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.testframework.GridSpiTestContext; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_TASK_FAILED; import static org.apache.ignite.events.EventType.EVT_TASK_FINISHED; @@ -37,6 +40,7 @@ * Tests round robin load balancing SPI. */ @GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") +@RunWith(JUnit4.class) public class GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest extends GridSpiAbstractTest { /** {@inheritDoc} */ @@ -60,6 +64,7 @@ public class GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest * @throws Exception If test failed. */ @SuppressWarnings({"ObjectEquality"}) + @Test public void testMultipleNodes() throws Exception { List allNodes = (List)getSpiContext().nodes(); @@ -89,6 +94,7 @@ public void testMultipleNodes() throws Exception { * @throws Exception If test failed. */ @SuppressWarnings({"ObjectEquality"}) + @Test public void testMultipleTasks() throws Exception { ComputeTaskSession ses1 = new GridTestTaskSession(IgniteUuid.randomUuid()); ComputeTaskSession ses2 = new GridTestTaskSession(IgniteUuid.randomUuid()); @@ -135,4 +141,4 @@ public void testMultipleTasks() throws Exception { getSpiContext().triggerEvent(new TaskEvent( null, null, EVT_TASK_FAILED, ses2.getId(), null, null, false, null)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java index 90f04bdacd140..788536de00b08 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java @@ -33,6 +33,9 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_TASK_FAILED; import static org.apache.ignite.events.EventType.EVT_TASK_FINISHED; @@ -42,6 +45,7 @@ * Tests round robin load balancing. */ @GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") +@RunWith(JUnit4.class) public class GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest extends GridSpiAbstractTest { /** @@ -70,6 +74,7 @@ public boolean getPerTask() { /** * @throws Exception If test failed. */ + @Test public void testMultipleNodes() throws Exception { List allNodes = (List)getSpiContext().nodes(); @@ -85,6 +90,7 @@ public void testMultipleNodes() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testMultipleTaskSessions() throws Exception { ComputeTaskSession ses1 = new GridTestTaskSession(IgniteUuid.randomUuid()); ComputeTaskSession ses2 = new GridTestTaskSession(IgniteUuid.randomUuid()); @@ -106,6 +112,7 @@ public void testMultipleTaskSessions() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testBalancingOneNode() throws Exception { ComputeTaskSession ses = new GridTestTaskSession(); @@ -120,6 +127,7 @@ public void testBalancingOneNode() throws Exception { } /** */ + @Test public void testNodeNotInTopology() throws Exception { ComputeTaskSession ses = new GridTestTaskSession(); @@ -134,4 +142,4 @@ public void testNodeNotInTopology() throws Exception { assertTrue(e.getMessage().contains("Task topology does not have alive nodes")); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java index 3159e04c68093..b8a87a79148d7 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.spi.loadbalancing.roundrobin.GridRoundRobinTestUtils.checkCyclicBalancing; @@ -36,6 +39,7 @@ * Tests round robin load balancing with topology changes. */ @GridSpiTest(spi = RoundRobinLoadBalancingSpi.class, group = "Load Balancing SPI") +@RunWith(JUnit4.class) public class GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest extends GridSpiAbstractTest { /** @@ -57,6 +61,7 @@ public class GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest /** * @throws Exception If failed. */ + @Test public void testTopologyChange() throws Exception { ComputeTaskSession ses = new GridTestTaskSession(IgniteUuid.randomUuid()); @@ -107,4 +112,4 @@ public void testTopologyChange() throws Exception { checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java index 2ed7813b81511..36e1e5a442d81 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java @@ -19,17 +19,22 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridSpiTest(spi = WeightedRandomLoadBalancingSpi.class, group = "Load Balancing SPI") +@RunWith(JUnit4.class) public class GridWeightedRandomLoadBalancingSpiConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new WeightedRandomLoadBalancingSpi(), "nodeWeight", 0); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java index 3c1e95756208f..90f28077b48a5 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java @@ -27,17 +27,22 @@ import org.apache.ignite.testframework.GridTestNode; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Weighted random load balancing SPI. */ @GridSpiTest(spi = WeightedRandomLoadBalancingSpi.class, group = "Load Balancing SPI") +@RunWith(JUnit4.class) public class GridWeightedRandomLoadBalancingSpiSelfTest extends GridSpiAbstractTest { /** * @throws Exception If failed. */ @SuppressWarnings({"ObjectEquality"}) + @Test public void testSingleNode() throws Exception { List nodes = Collections.singletonList((ClusterNode)new GridTestNode(UUID.randomUUID())); @@ -54,6 +59,7 @@ public void testSingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleNodes() throws Exception { List nodes = new ArrayList<>(); @@ -68,4 +74,4 @@ public void testMultipleNodes() throws Exception { assert node != null; assert nodes.contains(node); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java index 2a83d6fdd7801..e751be0de45c5 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java @@ -31,6 +31,9 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.spi.loadbalancing.weightedrandom.WeightedRandomLoadBalancingSpi.NODE_WEIGHT_ATTR_NAME; @@ -38,6 +41,7 @@ * {@link WeightedRandomLoadBalancingSpi} self test. */ @GridSpiTest(spi = WeightedRandomLoadBalancingSpi.class, group = "Load Balancing SPI") +@RunWith(JUnit4.class) public class GridWeightedRandomLoadBalancingSpiWeightedSelfTest extends GridSpiAbstractTest { /** @@ -51,6 +55,7 @@ public boolean getUseWeights() { /** * @throws Exception If test failed. */ + @Test public void testWeights() throws Exception { List nodes = new ArrayList<>(); @@ -85,4 +90,4 @@ public void testWeights() throws Exception { info("Node counts: " + Arrays.toString(cnts)); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java b/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java index 9284b8a327c2a..146a939b35143 100644 --- a/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java +++ b/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java @@ -35,6 +35,7 @@ import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.IgnitionListener; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteVersionUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; @@ -61,7 +62,7 @@ public final class GridRandomCommandLineLoader { private static final String IGNITE_PROG_NAME = "IGNITE_PROG_NAME"; /** Copyright text. Ant processed. */ - private static final String COPYRIGHT = "2018 Copyright(C) Apache Software Foundation."; + private static final String COPYRIGHT = IgniteVersionUtils.COPYRIGHT; /** Version. Ant processed. */ private static final String VER = "x.x.x"; diff --git a/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineLoaderTest.java b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineLoaderTest.java index 612479bb94642..3cb3d4597cc97 100644 --- a/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineLoaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineLoaderTest.java @@ -30,6 +30,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_RESTART_CODE; @@ -37,6 +40,7 @@ * Command line loader test. */ @GridCommonTest(group = "Loaders") +@RunWith(JUnit4.class) public class GridCommandLineLoaderTest extends GridCommonAbstractTest { /** */ private static final String GRID_CFG_PATH = "/modules/core/src/test/config/loaders/grid-cfg.xml"; @@ -44,6 +48,7 @@ public class GridCommandLineLoaderTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testLoader() throws Exception { String path = U.getIgniteHome() + GRID_CFG_PATH; diff --git a/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineTransformerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineTransformerSelfTest.java index 6fa0b0929e7d0..d08ed6bdb236d 100644 --- a/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineTransformerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineTransformerSelfTest.java @@ -20,14 +20,19 @@ import java.util.concurrent.Callable; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * GridCommandLineTransformer test. */ +@RunWith(JUnit4.class) public class GridCommandLineTransformerSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTransformIfNoArguments() throws Exception { assertEquals( "\"INTERACTIVE=0\" \"QUIET=-DIGNITE_QUIET=true\" \"NO_PAUSE=0\" " + @@ -38,6 +43,7 @@ public void testTransformIfNoArguments() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformIfArgumentIsnull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @SuppressWarnings("NullArgumentToVariableArgMethod") @@ -53,6 +59,7 @@ public void testTransformIfArgumentIsnull() throws Exception { * * @throws Exception If failed. */ + @Test public void testTransformIfUnsupportedOptions() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -64,6 +71,7 @@ public void testTransformIfUnsupportedOptions() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformIfUnsupportedJvmOptions() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -87,6 +95,7 @@ public void testTransformIfUnsupportedJvmOptions() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformIfSeveralArgumentsWithoutDashPrefix() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -98,6 +107,7 @@ public void testTransformIfSeveralArgumentsWithoutDashPrefix() throws Exception /** * @throws Exception If failed. */ + @Test public void testTransformIfOnlyPathToConfigSpecified() throws Exception { assertEquals( "\"INTERACTIVE=0\" \"QUIET=-DIGNITE_QUIET=true\" \"NO_PAUSE=0\" \"NO_JMX=0\" " + @@ -108,6 +118,7 @@ public void testTransformIfOnlyPathToConfigSpecified() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransformIfAllSupportedArguments() throws Exception { assertEquals( "\"INTERACTIVE=1\" \"QUIET=-DIGNITE_QUIET=false\" \"NO_PAUSE=1\" \"NO_JMX=1\" " + @@ -116,4 +127,4 @@ public void testTransformIfAllSupportedArguments() throws Exception { CommandLineTransformer.transform("-i", "-np", "-v", "-J-Xmx1g", "-J-Xms1m", "-nojmx", "\"c:\\path to\\русский каталог\"")); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/startup/properties/NotStringSystemPropertyTest.java b/modules/core/src/test/java/org/apache/ignite/startup/properties/NotStringSystemPropertyTest.java index 5e108a6e02f70..f2cbf98cd2bd0 100644 --- a/modules/core/src/test/java/org/apache/ignite/startup/properties/NotStringSystemPropertyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/startup/properties/NotStringSystemPropertyTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * The test checks start of Ignite with non-string properties. */ +@RunWith(JUnit4.class) public class NotStringSystemPropertyTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration optimize(IgniteConfiguration cfg) throws IgniteCheckedException { @@ -38,6 +42,7 @@ public class NotStringSystemPropertyTest extends GridCommonAbstractTest { /** * @throws Exception If fail. */ + @Test public void testGridStart() throws Exception { Some some = new Some(0, "prop"); diff --git a/modules/core/src/test/java/org/apache/ignite/startup/servlet/GridServletLoaderTest.java b/modules/core/src/test/java/org/apache/ignite/startup/servlet/GridServletLoaderTest.java index 3345aed830af1..05941d6bb9e14 100644 --- a/modules/core/src/test/java/org/apache/ignite/startup/servlet/GridServletLoaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/startup/servlet/GridServletLoaderTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Servlet loader test. @@ -58,6 +61,7 @@ * {@code JAVA_OPTS="${JAVA_OPTS} "-Dcom.sun.management.jmxremote.port=1097" "-Dcom.sun.management.jmxremote.ssl=false" "-Dcom.sun.management.jmxremote.authenticate=false" "} */ @GridCommonTest(group = "Loaders") +@RunWith(JUnit4.class) public class GridServletLoaderTest extends GridCommonAbstractTest { /** */ public static final int JMX_RMI_CONNECTOR_PORT = 1097; @@ -68,7 +72,7 @@ public class GridServletLoaderTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ - @SuppressWarnings({"unchecked"}) + @Test public void testLoader() throws Exception { JMXConnector jmx = null; @@ -174,4 +178,4 @@ private static JMXConnector getJMXConnector(String host, int port) throws IOExce // Wait for 5 minutes. return 5 * 60 * 1000; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java index 90ef8d7bd70dc..0b8f5d66b910e 100644 --- a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerSelfTest.java @@ -43,24 +43,22 @@ import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.stream.StreamSingleTupleExtractor; import org.apache.ignite.stream.StreamMultipleTupleExtractor; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; /** * Tests {@link SocketStreamer}. */ +@RunWith(JUnit4.class) public class SocketStreamerSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Grid count. */ private final static int GRID_CNT = 3; @@ -81,12 +79,6 @@ public class SocketStreamerSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfg); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - return cfg; } @@ -103,6 +95,7 @@ public class SocketStreamerSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSizeBasedDefaultConverter() throws Exception { test(null, null, new Runnable() { @Override public void run() { @@ -131,6 +124,7 @@ public void testSizeBasedDefaultConverter() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleEntriesFromOneMessage() throws Exception { test(null, null, new Runnable() { @Override public void run() { @@ -162,6 +156,7 @@ public void testMultipleEntriesFromOneMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSizeBasedCustomConverter() throws Exception { SocketMessageConverter converter = new SocketMessageConverter() { @Override public Message convert(byte[] msg) { @@ -201,6 +196,7 @@ public void testSizeBasedCustomConverter() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDelimiterBasedDefaultConverter() throws Exception { test(null, DELIM, new Runnable() { @Override public void run() { @@ -226,6 +222,7 @@ public void testDelimiterBasedDefaultConverter() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDelimiterBasedCustomConverter() throws Exception { SocketMessageConverter converter = new SocketMessageConverter() { @Override public Message convert(byte[] msg) { @@ -263,8 +260,8 @@ public void testDelimiterBasedCustomConverter() throws Exception { * @param converter Converter. * @param r Runnable.. */ - private void test(@Nullable SocketMessageConverter converter, - @Nullable byte[] delim, + private void test(@Nullable SocketMessageConverter converter, + @Nullable byte[] delim, Runnable r, boolean oneMessagePerTuple) throws Exception { SocketStreamer sockStmr = null; @@ -389,4 +386,4 @@ private static class Message implements Serializable { this.values = values; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerUnmarshalVulnerabilityTest.java b/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerUnmarshalVulnerabilityTest.java index dadc5b6f31c19..4044ddd7f9e15 100644 --- a/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerUnmarshalVulnerabilityTest.java +++ b/modules/core/src/test/java/org/apache/ignite/stream/socket/SocketStreamerUnmarshalVulnerabilityTest.java @@ -41,6 +41,9 @@ import org.apache.ignite.stream.StreamSingleTupleExtractor; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_BLACKLIST; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHALLER_WHITELIST; @@ -48,6 +51,7 @@ /** * Tests for whitelist and blacklist ot avoiding deserialization vulnerability. */ +@RunWith(JUnit4.class) public class SocketStreamerUnmarshalVulnerabilityTest extends GridCommonAbstractTest { /** Shared value. */ private static final AtomicBoolean SHARED = new AtomicBoolean(); @@ -83,6 +87,7 @@ public class SocketStreamerUnmarshalVulnerabilityTest extends GridCommonAbstract /** * @throws Exception If failed. */ + @Test public void testNoLists() throws Exception { testExploit(true); } @@ -90,6 +95,7 @@ public void testNoLists() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWhiteListIncluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_included.txt").getPath(); @@ -101,6 +107,7 @@ public void testWhiteListIncluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWhiteListExcluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_excluded.txt").getPath(); @@ -112,6 +119,7 @@ public void testWhiteListExcluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlackListIncluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_included.txt").getPath(); @@ -123,6 +131,7 @@ public void testBlackListIncluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBlackListExcluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_excluded.txt").getPath(); @@ -134,6 +143,7 @@ public void testBlackListExcluded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBothListIncluded() throws Exception { String path = U.resolveIgnitePath("modules/core/src/test/config/class_list_exploit_included.txt").getPath(); diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridStringLogger.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridStringLogger.java index 9056dd65c1349..0b09d3e3c41ad 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridStringLogger.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridStringLogger.java @@ -26,7 +26,10 @@ /** * Logger which logs to string buffer. + * + * @deprecated Use {@link ListeningTestLogger} instead. */ +@Deprecated public class GridStringLogger implements IgniteLogger { /** Initial string builder capacity in bytes */ private static final int INITIAL = 1024 * 33; diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java index 73293cee5fac0..a5e92843e7223 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java @@ -64,8 +64,7 @@ import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; -import junit.framework.Test; -import junit.framework.TestCase; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; @@ -105,6 +104,7 @@ import org.apache.ignite.spi.discovery.DiscoverySpiListener; import org.apache.ignite.ssl.SslContextFactory; import org.apache.ignite.testframework.config.GridTestProperties; +import org.apache.ignite.testframework.junits.GridAbstractTest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -181,17 +181,22 @@ public static DiscoverySpiListener wrap(DiscoverySpiListener delegate, Discovery } } + /** Test parameters scale factor util. */ + public static final class SF extends ScaleFactorUtil { + + } + /** */ private static final Map, String> addrs = new HashMap<>(); /** */ - private static final Map, Integer> mcastPorts = new HashMap<>(); + private static final Map, Integer> mcastPorts = new HashMap<>(); /** */ - private static final Map, Integer> discoPorts = new HashMap<>(); + private static final Map, Integer> discoPorts = new HashMap<>(); /** */ - private static final Map, Integer> commPorts = new HashMap<>(); + private static final Map, Integer> commPorts = new HashMap<>(); /** */ private static int[] addr; @@ -598,7 +603,7 @@ public static void assertOneToOne(Iterable it, IgnitePredicate... ps) * @param cls Class. * @return Next multicast port. */ - public static synchronized int getNextMulticastPort(Class cls) { + public static synchronized int getNextMulticastPort(Class cls) { Integer portRet = mcastPorts.get(cls); if (portRet != null) @@ -645,7 +650,7 @@ public static synchronized int getNextMulticastPort(Class cls) { * @param cls Class. * @return Next communication port. */ - public static synchronized int getNextCommPort(Class cls) { + public static synchronized int getNextCommPort(Class cls) { Integer portRet = commPorts.get(cls); if (portRet != null) @@ -672,7 +677,7 @@ public static synchronized int getNextCommPort(Class cls) { * @param cls Class. * @return Next discovery port. */ - public static synchronized int getNextDiscoPort(Class cls) { + public static synchronized int getNextDiscoPort(Class cls) { Integer portRet = discoPorts.get(cls); if (portRet != null) @@ -1556,7 +1561,7 @@ public static void setFieldValue(Object obj, Class cls, String fieldName, Object @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") @Nullable public static T invoke(Object obj, String mtd, Object... params) throws Exception { Class cls = obj.getClass(); - + do { // We cannot resolve method by parameter classes due to some of parameters can be null. // Search correct method among all methods collection. @@ -2004,12 +2009,12 @@ public static String fullSimpleName(@NotNull Class cls) { * @param test Test. * @param ignoredTests Tests to ignore. If test contained in the collection it is not included in suite */ - public static void addTestIfNeeded(@NotNull final TestSuite suite, @NotNull final Class test, + public static void addTestIfNeeded(@NotNull final TestSuite suite, @NotNull final Class test, @Nullable final Collection ignoredTests) { if (ignoredTests != null && ignoredTests.contains(test)) return; - suite.addTestSuite(test); + suite.addTest(new JUnit4TestAdapter(test)); } /** @@ -2047,4 +2052,49 @@ public static void mergeExchangeWaitVersion(Ignite node, long topVer, List merge ((IgniteEx)node).context().cache().context().exchange().mergeExchangesTestWaitVersion( new AffinityTopologyVersion(topVer, 0), mergedEvts); } + + /** Test parameters scale factor util. */ + private static class ScaleFactorUtil { + /** Test speed scale factor property name. */ + private static final String TEST_SCALE_FACTOR_PROPERTY = "TEST_SCALE_FACTOR"; + + /** Min test scale factor value. */ + private static final double MIN_TEST_SCALE_FACTOR_VALUE = 0.1; + + /** Max test scale factor value. */ + private static final double MAX_TEST_SCALE_FACTOR_VALUE = 1.0; + + /** Test speed scale factor. */ + private static final double TEST_SCALE_FACTOR_VALUE = readScaleFactor(); + + /** */ + private static double readScaleFactor() { + double scaleFactor = Double.parseDouble(System.getProperty(TEST_SCALE_FACTOR_PROPERTY, "1.0")); + + scaleFactor = Math.max(scaleFactor, MIN_TEST_SCALE_FACTOR_VALUE); + scaleFactor = Math.min(scaleFactor, MAX_TEST_SCALE_FACTOR_VALUE); + + return scaleFactor; + } + + /** */ + public static int apply(int val) { + return (int) Math.round(TEST_SCALE_FACTOR_VALUE * val); + } + + /** */ + public static int apply(int val, int lowerBound, int upperBound) { + return applyUB(applyLB(val, lowerBound), upperBound); + } + + /** Apply scale factor with lower bound */ + public static int applyLB(int val, int lowerBound) { + return Math.max(apply(val), lowerBound); + } + + /** Apply scale factor with upper bound */ + public static int applyUB(int val, int upperBound) { + return Math.min(apply(val), upperBound); + } + } } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/ListeningTestLogger.java b/modules/core/src/test/java/org/apache/ignite/testframework/ListeningTestLogger.java new file mode 100644 index 0000000000000..1b05f4cb642f1 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testframework/ListeningTestLogger.java @@ -0,0 +1,205 @@ +/* + * 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. + */ + +package org.apache.ignite.testframework; + +import java.util.Collection; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.function.Consumer; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.internal.util.typedef.X; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Implementation of {@link org.apache.ignite.IgniteLogger} that performs any actions when certain message is logged. + * It can be useful in tests to ensure that a specific message was (or was not) printed to the log. + */ +public class ListeningTestLogger implements IgniteLogger { + /** + * If set to {@code true}, enables debug and trace log messages processing. + */ + private final boolean dbg; + + /** + * Logger to echo all messages, limited by {@code dbg} flag. + */ + private final IgniteLogger echo; + + /** + * Registered log messages listeners. + */ + private final Collection> lsnrs = new CopyOnWriteArraySet<>(); + + /** + * Default constructor. + */ + public ListeningTestLogger() { + this(false); + } + + /** + * @param dbg If set to {@code true}, enables debug and trace log messages processing. + */ + public ListeningTestLogger(boolean dbg) { + this(dbg, null); + } + + /** + * @param dbg If set to {@code true}, enables debug and trace log messages processing. + * @param echo Logger to echo all messages, limited by {@code dbg} flag. + */ + public ListeningTestLogger(boolean dbg, @Nullable IgniteLogger echo) { + this.dbg = dbg; + this.echo = echo; + } + + /** + * Registers message listener. + * + * @param lsnr Message listener. + */ + public void registerListener(@NotNull LogListener lsnr) { + lsnr.reset(); + + lsnrs.add(lsnr); + } + + /** + * Registers message listener. + *

    + * NOTE listener is executed in the thread causing the logging, so it is not recommended to throw any exceptions + * from it. Use {@link LogListener} to create message predicates with assertions. + * + * @param lsnr Message listener. + * @see LogListener + */ + public void registerListener(@NotNull Consumer lsnr) { + lsnrs.add(lsnr); + } + + /** + * Unregisters message listener. + * + * @param lsnr Message listener. + */ + public void unregisterListener(@NotNull Consumer lsnr) { + lsnrs.remove(lsnr); + } + + /** + * Clears all listeners. + */ + public void clearListeners() { + lsnrs.clear(); + } + + /** {@inheritDoc} */ + @Override public ListeningTestLogger getLogger(Object ctgr) { + return this; + } + + /** {@inheritDoc} */ + @Override public void trace(String msg) { + if (!dbg) + return; + + if (echo != null) + echo.trace(msg); + + applyListeners(msg); + } + + /** {@inheritDoc} */ + @Override public void debug(String msg) { + if (!dbg) + return; + + if (echo != null) + echo.debug(msg); + + applyListeners(msg); + } + + /** {@inheritDoc} */ + @Override public void info(String msg) { + if (echo != null) + echo.info(msg); + + applyListeners(msg); + } + + /** {@inheritDoc} */ + @Override public void warning(String msg, @Nullable Throwable t) { + if (echo != null) + echo.warning(msg, t); + + applyListeners(msg); + + if (t != null) + applyListeners(X.getFullStackTrace(t)); + } + + /** {@inheritDoc} */ + @Override public void error(String msg, @Nullable Throwable t) { + if (echo != null) + echo.error(msg, t); + + applyListeners(msg); + + if (t != null) + applyListeners(X.getFullStackTrace(t)); + } + + /** {@inheritDoc} */ + @Override public boolean isTraceEnabled() { + return dbg; + } + + /** {@inheritDoc} */ + @Override public boolean isDebugEnabled() { + return dbg; + } + + /** {@inheritDoc} */ + @Override public boolean isInfoEnabled() { + return true; + } + + /** {@inheritDoc} */ + @Override public boolean isQuiet() { + return false; + } + + /** {@inheritDoc} */ + @Override public String fileName() { + return null; + } + + /** + * Applies listeners whose pattern is found in the message. + * + * @param msg Message to check. + */ + private void applyListeners(String msg) { + if (msg == null) + return; + + for (Consumer lsnr : lsnrs) + lsnr.accept(msg); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/LogListener.java b/modules/core/src/test/java/org/apache/ignite/testframework/LogListener.java new file mode 100644 index 0000000000000..485e3fae98b35 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testframework/LogListener.java @@ -0,0 +1,389 @@ +/* + * 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. + */ + +package org.apache.ignite.testframework; + +import java.time.temporal.ValueRange; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.jetbrains.annotations.NotNull; + +/** + * The basic listener for custom log contents checking in {@link ListeningTestLogger}.

    + * + * Supports {@link #matches(String) substring}, {@link #matches(Pattern) regular expression} or + * {@link #matches(Predicate) predicate} listeners and the following optional modifiers: + *

      + *
    • {@link Builder#times times()} sets the exact number of occurrences
    • + *
    • {@link Builder#atLeast atLeast()} sets the minimum number of occurrences
    • + *
    • {@link Builder#atMost atMost()} sets the maximum number of occurrences
    • + *
    + * {@link Builder#atLeast atLeast()} and {@link Builder#atMost atMost()} can be used together.

    + * + * If the expected number of occurrences is not specified for the listener, + * then at least one occurence is expected by default. In other words:
    + *
    + * {@code LogListener.matches(msg).build();}
    + *
    + * is equivalent to
    + *
    + * {@code LogListener.matches(msg).atLeast(1).build();}
    + * 
    + * + * If only the expected maximum number of occurrences is specified, then + * the minimum number of entries for successful validation is zero. In other words:
    + *
    + * {@code LogListener.matches(msg).atMost(10).build();}
    + *
    + * is equivalent to
    + *
    + * {@code LogListener.matches(msg).atLeast(0).atMost(10).build();}
    + * 
    + */ +public abstract class LogListener implements Consumer { + /** + * Checks that all conditions are met. + * + * @return {@code True} if all conditions are met. + */ + public abstract boolean check(); + + /** + * Reset listener state. + */ + abstract void reset(); + + /** + * Creates new listener builder. + * + * @param substr Substring to search for in a log message. + * @return Log message listener builder. + */ + public static Builder matches(String substr) { + return new Builder().andMatches(substr); + } + + /** + * Creates new listener builder. + * + * @param regexp Regular expression to search for in a log message. + * @return Log message listener builder. + */ + public static Builder matches(Pattern regexp) { + return new Builder().andMatches(regexp); + } + + /** + * Creates new listener builder. + * + * @param pred Log message predicate. + * @return Log message listener builder. + */ + public static Builder matches(Predicate pred) { + return new Builder().andMatches(pred); + } + + /** + * Log listener builder. + */ + public static class Builder { + /** */ + private final CompositeMessageListener lsnr = new CompositeMessageListener(); + + /** */ + private Node prev; + + /** + * Add new substring predicate. + * + * @param substr Substring. + * @return current builder instance. + */ + public Builder andMatches(String substr) { + addLast(new Node(msg -> { + if (substr.isEmpty()) + return msg.isEmpty() ? 1 : 0; + + int cnt = 0; + + for (int idx = 0; (idx = msg.indexOf(substr, idx)) != -1; idx++) + ++cnt; + + return cnt; + })); + + return this; + } + + /** + * Add new regular expression predicate. + * + * @param regexp Regular expression. + * @return current builder instance. + */ + public Builder andMatches(Pattern regexp) { + addLast(new Node(msg -> { + int cnt = 0; + + Matcher matcher = regexp.matcher(msg); + + while (matcher.find()) + ++cnt; + + return cnt; + })); + + return this; + } + + /** + * Add new log message predicate. + * + * @param pred Log message predicate. + * @return current builder instance. + */ + public Builder andMatches(Predicate pred) { + addLast(new Node(msg -> pred.test(msg) ? 1 : 0)); + + return this; + } + + /** + * Set expected number of matches.
    + * Each log message may contain several matches that will be counted, + * except {@code Predicate} which can have only one match for message. + * + * @param n Expected number of matches. + * @return current builder instance. + */ + public Builder times(int n) { + if (prev != null) + prev.cnt = n; + + return this; + } + + /** + * Set expected minimum number of matches.
    + * Each log message may contain several matches that will be counted, + * except {@code Predicate} which can have only one match for message. + * + * @param n Expected number of matches. + * @return current builder instance. + */ + public Builder atLeast(int n) { + if (prev != null) { + prev.min = n; + + prev.cnt = null; + } + + return this; + } + + /** + * Set expected maximum number of matches.
    + * Each log message may contain several matches that will be counted, + * except {@code Predicate} which can have only one match for message. + * + * @param n Expected number of matches. + * @return current builder instance. + */ + public Builder atMost(int n) { + if (prev != null) { + prev.max = n; + + prev.cnt = null; + } + + return this; + } + + /** + * Constructs message listener. + * + * @return Log message listener. + */ + public LogListener build() { + addLast(null); + + return lsnr.lsnrs.size() == 1 ? lsnr.lsnrs.get(0) : lsnr; + } + + /** + * @param node Log listener attributes. + */ + private void addLast(Node node) { + if (prev != null) + lsnr.add(prev.listener()); + + prev = node; + } + + /** */ + private Builder() {} + + /** + * Mutable attributes for log listener. + */ + static final class Node { + /** */ + final Function func; + + /** */ + Integer min; + + /** */ + Integer max; + + /** */ + Integer cnt; + + /** */ + Node(Function func) { + this.func = func; + } + + /** */ + LogMessageListener listener() { + ValueRange range; + + if (cnt != null) + range = ValueRange.of(cnt, cnt); + else if (min == null && max == null) + range = ValueRange.of(1, Integer.MAX_VALUE); + else + range = ValueRange.of(min == null ? 0 : min, max == null ? Integer.MAX_VALUE : max); + + return new LogMessageListener(func, range); + } + } + } + + /** */ + private static class LogMessageListener extends LogListener { + /** */ + private final Function func; + + /** */ + private final AtomicReference err = new AtomicReference<>(); + + /** */ + private final AtomicInteger matches = new AtomicInteger(); + + /** */ + private final ValueRange exp; + + /** + * @param exp Expected occurrences. + * @param func Function of counting matches in the message. + */ + private LogMessageListener(@NotNull Function func, @NotNull ValueRange exp) { + this.func = func; + this.exp = exp; + } + + /** {@inheritDoc} */ + @Override public void accept(String msg) { + if (err.get() != null) + return; + + try { + int cnt = func.apply(msg); + + if (cnt > 0) + matches.addAndGet(cnt); + } + catch (Throwable t) { + err.compareAndSet(null, t); + + if (t instanceof VirtualMachineError) + throw t; + } + } + + /** {@inheritDoc} */ + @Override public boolean check() { + errCheck(); + + int matchesCnt = matches.get(); + + return exp.isValidIntValue(matchesCnt); + } + + /** {@inheritDoc} */ + @Override void reset() { + matches.set(0); + } + + /** + * Check that there were no runtime errors. + */ + private void errCheck() { + Throwable t = err.get(); + + if (t instanceof Error) + throw (Error)t; + + if (t instanceof RuntimeException) + throw (RuntimeException)t; + + assert t == null : t; + } + } + + /** */ + private static class CompositeMessageListener extends LogListener { + /** */ + private final List lsnrs = new ArrayList<>(); + + /** {@inheritDoc} */ + @Override public boolean check() { + for (LogMessageListener lsnr : lsnrs) + if (!lsnr.check()) + return false; + + return true; + } + + /** {@inheritDoc} */ + @Override void reset() { + for (LogMessageListener lsnr : lsnrs) + lsnr.reset(); + } + + /** {@inheritDoc} */ + @Override public void accept(String msg) { + for (LogMessageListener lsnr : lsnrs) + lsnr.accept(msg); + } + + /** + * @param lsnr Listener. + */ + private void add(LogMessageListener lsnr) { + lsnrs.add(lsnr); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/MvccFeatureChecker.java b/modules/core/src/test/java/org/apache/ignite/testframework/MvccFeatureChecker.java new file mode 100644 index 0000000000000..b3b64f9b286ea --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testframework/MvccFeatureChecker.java @@ -0,0 +1,162 @@ +/* + * 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. + */ + +package org.apache.ignite.testframework; + +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.internal.processors.query.IgniteSQLException; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS; +import static org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode.TRANSACTION_SERIALIZATION_ERROR; +import static org.junit.Assert.fail; + +/** + * Provides checks for features supported when FORCE_MVCC mode is on. + */ +public class MvccFeatureChecker { + /** */ + private static final boolean FORCE_MVCC = + IgniteSystemProperties.getBoolean(IGNITE_FORCE_MVCC_MODE_IN_TESTS, false); + + /** */ + public enum Feature { + CACHE_STORE, + NEAR_CACHE, + LOCAL_CACHE, + ENTRY_LOCK, + CACHE_EVENTS, + EVICTION, + EXPIRATION, + METRICS, + INTERCEPTOR + } + + /** + * Fails if feature is not supported. + * + * @param f feature. + * @throws AssertionError If failed. + */ + public static void failIfNotSupported(Feature f) { + if (!forcedMvcc()) + return; + + validateFeature(f); + } + + /** + * @return {@code True} if Mvcc mode is forced. + */ + public static boolean forcedMvcc() { + return FORCE_MVCC; + } + + /** + * Check if feature is supported. + * + * @param f Feature. + * @return {@code True} if feature is supported, {@code False} otherwise. + */ + public static boolean isSupported(Feature f) { + try { + validateFeature(f); + + return true; + } + catch (AssertionError ignore) { + return false; + } + } + + /** + * Check if Tx mode is supported. + * + * @param conc Transaction concurrency. + * @param iso Transaction isolation. + * @return {@code True} if feature is supported, {@code False} otherwise. + */ + public static boolean isSupported(TransactionConcurrency conc, TransactionIsolation iso) { + return conc == TransactionConcurrency.PESSIMISTIC && + iso == TransactionIsolation.REPEATABLE_READ; + } + + + /** + * Check if Cache mode is supported. + * + * @param mode Cache mode. + * @return {@code True} if feature is supported, {@code False} otherwise. + */ + public static boolean isSupported(CacheMode mode) { + return mode != CacheMode.LOCAL || isSupported(Feature.LOCAL_CACHE); + } + + /** + * TODO proper exception handling after https://issues.apache.org/jira/browse/IGNITE-9470 + * Checks if given exception was caused by MVCC write conflict. + * + * @param e Exception. + */ + public static void assertMvccWriteConflict(Exception e) { + IgniteSQLException sqlEx = X.cause(e, IgniteSQLException.class); + + if (sqlEx == null || sqlEx.statusCode() != TRANSACTION_SERIALIZATION_ERROR) + fail("Unexpected exception: " + X.getFullStackTrace(e)); + } + + /** + * Fails if feature is not supported in Mvcc mode. + * + * @param feature Mvcc feature. + * @throws AssertionError If failed. + */ + @SuppressWarnings("fallthrough") + private static void validateFeature(Feature feature) { + switch (feature) { + case NEAR_CACHE: + fail("https://issues.apache.org/jira/browse/IGNITE-7187"); + + case LOCAL_CACHE: + fail("https://issues.apache.org/jira/browse/IGNITE-9530"); + + case CACHE_STORE: + fail("https://issues.apache.org/jira/browse/IGNITE-8582"); + + case ENTRY_LOCK: + fail("https://issues.apache.org/jira/browse/IGNITE-9324"); + + case CACHE_EVENTS: + fail("https://issues.apache.org/jira/browse/IGNITE-9321"); + + case EVICTION: + fail("https://issues.apache.org/jira/browse/IGNITE-7956"); + + case EXPIRATION: + fail("https://issues.apache.org/jira/browse/IGNITE-7311"); + + case METRICS: + fail("https://issues.apache.org/jira/browse/IGNITE-9224"); + + case INTERCEPTOR: + fail("https://issues.apache.org/jira/browse/IGNITE-9323"); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java index 4a60671fee594..e4159c6ae6834 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java @@ -18,6 +18,8 @@ package org.apache.ignite.testframework.configvariations; import java.util.Arrays; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestResult; import junit.framework.TestSuite; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; @@ -200,7 +202,7 @@ private TestSuite build(int[] igniteCfgVariation, @Nullable int[] cacheCfgVariat addedSuite = createMultiNodeTestSuite((Class)cls, testCfg, testedNodeCnt, withClients, skipWaitPartMapExchange); else - addedSuite = new IgniteConfigVariationsTestSuite(cls, testCfg); + addedSuite = makeTestSuite(cls, testCfg); return addedSuite; } @@ -227,12 +229,28 @@ private static TestSuite createMultiNodeTestSuite(Class cls, + VariationsTestsConfig cfg) { + TestSuite res = new TestSuite(cls.getSimpleName()); + + res.addTest(new JUnit4TestAdapter(cls) { + @Override public void run(TestResult tr) { + IgniteConfigVariationsAbstractTest.injectTestsConfiguration(cfg); + + super.run(tr); + } + }); + + return res; + } + /** * @return {@code this} for chaining. */ diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/IgniteConfigVariationsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/IgniteConfigVariationsTestSuite.java deleted file mode 100644 index d953c271eb309..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/IgniteConfigVariationsTestSuite.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - */ - -package org.apache.ignite.testframework.configvariations; - -import junit.framework.Test; -import junit.framework.TestResult; -import junit.framework.TestSuite; -import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest; - -/** - * Configuration variations test suite. - */ -public class IgniteConfigVariationsTestSuite extends TestSuite { - /** */ - protected final VariationsTestsConfig cfg; - - /** - * @param cls Test class. - * @param cfg Configuration. - */ - public IgniteConfigVariationsTestSuite(Class cls, - VariationsTestsConfig cfg) { - super(cls); - - this.cfg = cfg; - } - - /** {@inheritDoc} */ - @Override public void runTest(Test test, TestResult res) { - if (test instanceof IgniteConfigVariationsAbstractTest) - ((IgniteConfigVariationsAbstractTest)test).setTestsConfiguration(cfg); - - super.runTest(test, res); - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java index 91c6c93741a2b..633333eb5e387 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java @@ -48,7 +48,7 @@ public class VariationsTestsConfig { private boolean stopCache; /** */ - private boolean awaitPartMapExchange = true; + private boolean awaitPartMapExchange; /** */ private boolean withClients; @@ -88,7 +88,7 @@ public VariationsTestsConfig( boolean withClients, boolean awaitPartMapExchange ) { - A.ensure(gridCnt >= 1, "Grids count cannot be less then 1."); + A.ensure(gridCnt >= 1, "Grids count cannot be less than 1."); this.factory = factory; this.desc = desc; diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java index 13387de72e6fe..5491a4f6ab953 100755 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java @@ -17,7 +17,34 @@ package org.apache.ignite.testframework.junits; -import junit.framework.TestCase; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.Proxy; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import javax.cache.configuration.Factory; +import javax.cache.configuration.FactoryBuilder; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; @@ -76,10 +103,10 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.MvccFeatureChecker; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.configvariations.VariationsTestsConfig; import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger; @@ -93,40 +120,22 @@ import org.apache.log4j.PatternLayout; import org.apache.log4j.Priority; import org.apache.log4j.RollingFileAppender; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestRule; +import org.junit.runners.model.Statement; +import org.junit.runners.model.TestClass; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; -import javax.cache.configuration.Factory; -import javax.cache.configuration.FactoryBuilder; -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Proxy; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - import static org.apache.ignite.IgniteSystemProperties.IGNITE_CLIENT_CACHE_CHANGE_MESSAGE_TIMEOUT; import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.GridKernalState.DISCONNECTED; import static org.apache.ignite.testframework.config.GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER; @@ -140,10 +149,7 @@ "ProhibitedExceptionDeclared", "JUnitTestCaseWithNonTrivialConstructors" }) -public abstract class GridAbstractTest extends TestCase { - /** Persistence in tests allowed property. */ - public static final String PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY = "PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY"; - +public abstract class GridAbstractTest extends JUnit3TestLegacySupport { /************************************************************** * DO NOT REMOVE TRANSIENT - THIS OBJECT MIGHT BE TRANSFERRED * * TO ANOTHER NODE. * @@ -159,6 +165,9 @@ public abstract class GridAbstractTest extends TestCase { setAddresses(Collections.singleton("127.0.0.1:47500..47509")); }}; + /** Shared static IP finder which is used in configuration at nodes startup for all test methods in class. */ + protected static TcpDiscoveryIpFinder sharedStaticIpFinder; + /** */ private static final int DFLT_TOP_WAIT_TIMEOUT = 2000; @@ -168,6 +177,23 @@ public abstract class GridAbstractTest extends TestCase { /** */ protected static final String DEFAULT_CACHE_NAME = "default"; + /** Lock to maintain integrity of {@link TestCounters} and of {@link IgniteConfigVariationsAbstractTest}. */ + private final Lock runSerializer = new ReentrantLock(); + + /** Manages test execution and reporting. */ + @Rule public transient TestRule runRule = (base, description) -> new Statement() { + @Override public void evaluate() throws Throwable { + runSerializer.lock(); + try { + assert getName() != null : "getName returned null"; + + runTestCase(base); + } finally { + runSerializer.unlock(); + } + } + }; + /** */ private transient boolean startGrid; @@ -183,9 +209,6 @@ public abstract class GridAbstractTest extends TestCase { /** Timestamp for tests. */ private static long ts = System.currentTimeMillis(); - /** Starting Ignite instance name. */ - protected static final ThreadLocal startingIgniteInstanceName = new ThreadLocal<>(); - /** Force failure flag. */ private boolean forceFailure; @@ -198,11 +221,8 @@ public abstract class GridAbstractTest extends TestCase { /** Number of tests. */ private int testCnt; - /** - * - */ - private static final boolean PERSISTENCE_ALLOWED = - IgniteSystemProperties.getBoolean(PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, true); + /** Lazily initialized current test method. */ + private volatile Method currTestMtd; /** * @@ -399,8 +419,8 @@ protected void time(String name, Runnable r) { } /** - * Runs given code in multiple threads and synchronously waits for all threads to complete. - * If any thread failed, exception will be thrown out of this method. + * Runs given code in multiple threads and synchronously waits for all threads to complete. If any thread failed, + * exception will be thrown out of this method. * * @param r Runnable. * @param threadNum Thread number. @@ -501,7 +521,8 @@ protected IgniteInternalFuture multithreadedAsync(Callable c, int threadNu * @throws Exception If failed. * @return Future. */ - protected IgniteInternalFuture multithreadedAsync(Callable c, int threadNum, String threadName) throws Exception { + protected IgniteInternalFuture multithreadedAsync(Callable c, int threadNum, + String threadName) throws Exception { return GridTestUtils.runMultiThreadedAsync(c, threadNum, threadName); } @@ -531,46 +552,21 @@ protected GridTestKernalContext newContext(IgniteConfiguration cfg) throws Ignit } /** - * Called before execution of every test method in class. - * - * @throws Exception If failed. {@link #afterTest()} will be called in this case. - */ - protected void beforeTest() throws Exception { - // No-op. - } - - /** - * Called after execution of every test method in class or - * if {@link #beforeTest()} failed without test method execution. - * - * @throws Exception If failed. - */ - protected void afterTest() throws Exception { - // No-op. - } - - /** - * Called before execution of all test methods in class. - * - * @throws Exception If failed. {@link #afterTestsStopped()} will be called in this case. + * Will clean and re-create marshaller directory from scratch. */ - protected void beforeTestsStarted() throws Exception { - // Will clean and re-create marshaller directory from scratch. + private void resolveWorkDirectory() throws Exception { U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", true); U.resolveWorkDirectory(U.defaultWorkDirectory(), "binary_meta", true); } /** - * Called after execution of all test methods in class or - * if {@link #beforeTestsStarted()} failed without execution of any test methods. - * - * @throws Exception If failed. + * {@inheritDoc} + *

    + * Do not annotate with Before in overriding methods.

    + * @deprecated This method is deprecated. Instead of invoking or overriding it, it is recommended to make your own + * method with {@code @Before} annotation. */ - protected void afterTestsStopped() throws Exception { - // No-op. - } - - /** {@inheritDoc} */ + @Deprecated @Override protected void setUp() throws Exception { stopGridErr = false; @@ -601,10 +597,12 @@ protected void afterTestsStopped() throws Exception { } if (isFirstTest()) { + sharedStaticIpFinder = new TcpDiscoveryVmIpFinder(true); + info(">>> Starting test class: " + testClassDescription() + " <<<"); - if(isSafeTopology()) - assert G.allGrids().isEmpty() : "Not all Ignite instances stopped before tests execution"; + if (isSafeTopology()) + assert G.allGrids().isEmpty() : "Not all Ignite instances stopped before tests execution:" + G.allGrids(); if (startGrid) { IgniteConfiguration cfg = optimize(getConfiguration()); @@ -618,6 +616,8 @@ protected void afterTestsStopped() throws Exception { if (!jvmIds.isEmpty()) log.info("Next processes of IgniteNodeRunner were killed: " + jvmIds); + resolveWorkDirectory(); + beforeTestsStarted(); } catch (Exception | Error t) { @@ -670,6 +670,34 @@ protected String testClassDescription() { return GridTestUtils.fullSimpleName(getClass()); } + /** + * @return Current test method. + * @throws NoSuchMethodError If method wasn't found for some reason. + */ + @NotNull protected Method currentTestMethod() { + if (currTestMtd == null) { + try { + currTestMtd = getClass().getMethod(getName()); + } + catch (NoSuchMethodException e) { + throw new NoSuchMethodError("Current test method is not found: " + getName()); + } + } + + return currTestMtd; + } + + /** + * Search for the annotation of the given type in current test method. + * + * @param annotationCls Type of annotation to look for. + * @param Annotation type. + * @return Instance of annotation if it is present in test method. + */ + @Nullable protected A currentTestAnnotation(Class annotationCls) { + return currentTestMethod().getAnnotation(annotationCls); + } + /** * @return Started grid. * @throws Exception If anything failed. @@ -736,9 +764,6 @@ protected Ignite startGridsMultiThreaded(int cnt) throws Exception { * @throws Exception If failed. */ protected final Ignite startGridsMultiThreaded(int init, int cnt) throws Exception { - if (isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-648"); - assert init >= 0; assert cnt > 0; @@ -887,11 +912,8 @@ private void validateConfiguration(IgniteConfiguration cfg) { */ protected Ignite startGrid(String igniteInstanceName, IgniteConfiguration cfg, GridSpringResourceContext ctx) throws Exception { - - checkConfiguration(cfg); - if (!isRemoteJvm(igniteInstanceName)) { - startingIgniteInstanceName.set(igniteInstanceName); + IgniteUtils.setCurrentIgniteName(igniteInstanceName); try { String cfgProcClsName = System.getProperty(IGNITE_CFG_PREPROCESSOR_CLS); @@ -927,37 +949,13 @@ protected Ignite startGrid(String igniteInstanceName, IgniteConfiguration cfg, G return node; } finally { - startingIgniteInstanceName.set(null); + IgniteUtils.setCurrentIgniteName(null); } } else return startRemoteGrid(igniteInstanceName, null, ctx); } - /** - * @param cfg Config. - */ - protected void checkConfiguration(IgniteConfiguration cfg) { - if (cfg == null) - return; - - if (!PERSISTENCE_ALLOWED) { - String errorMsg = "PERSISTENCE IS NOT ALLOWED IN THIS SUITE, PUT YOUR TEST TO ANOTHER ONE!"; - - DataStorageConfiguration dsCfg = cfg.getDataStorageConfiguration(); - - if (dsCfg != null) { - assertFalse(errorMsg, dsCfg.getDefaultDataRegionConfiguration().isPersistenceEnabled()); - - DataRegionConfiguration[] dataRegionConfigurations = dsCfg.getDataRegionConfigurations(); - - if (dataRegionConfigurations != null) - for (DataRegionConfiguration dataRegionConfiguration : dataRegionConfigurations) - assertFalse(errorMsg, dataRegionConfiguration.isPersistenceEnabled()); - } - } - } - /** * Starts new grid at another JVM with given name. * @@ -983,7 +981,7 @@ protected Ignite startRemoteGrid(String igniteInstanceName, IgniteConfiguration */ protected Ignite startGridWithSpringCtx(String gridName, boolean client, String cfgUrl) throws Exception { IgniteBiTuple, ? extends GridSpringResourceContext> cfgMap = - IgnitionEx.loadConfigurations(cfgUrl); + IgnitionEx.loadConfigurations(cfgUrl); IgniteConfiguration cfg = F.first(cfgMap.get1()); @@ -1054,8 +1052,6 @@ protected Ignite startRemoteGrid(String igniteInstanceName, IgniteConfiguration if (cfg == null) cfg = optimize(getConfiguration(igniteInstanceName)); - checkConfiguration(cfg); - if (locNode != null) { DiscoverySpi discoverySpi = locNode.configuration().getDiscoverySpi(); @@ -1066,7 +1062,7 @@ protected Ignite startRemoteGrid(String igniteInstanceName, IgniteConfiguration m.setAccessible(true); - cfg.setDiscoverySpi((DiscoverySpi) m.invoke(discoverySpi)); + cfg.setDiscoverySpi((DiscoverySpi)m.invoke(discoverySpi)); resetDiscovery = false; } @@ -1094,8 +1090,6 @@ protected List additionalRemoteJvmArgs() { * @throws IgniteCheckedException On error. */ protected IgniteConfiguration optimize(IgniteConfiguration cfg) throws IgniteCheckedException { - checkConfiguration(cfg); - if (cfg.getLocalHost() == null) { if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi) { cfg.setLocalHost("127.0.0.1"); @@ -1528,15 +1522,13 @@ protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi) ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setJoinTimeout(getTestTimeout()); - if (isMultiJvm()) - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(LOCAL_IP_FINDER); - return cfg; } /** * Create instance of {@link BinaryMarshaller} suitable for use * without starting a grid upon an empty {@link IgniteConfiguration}. + * * @return Binary marshaller. * @throws IgniteCheckedException if failed. */ @@ -1547,6 +1539,7 @@ protected BinaryMarshaller createStandaloneBinaryMarshaller() throws IgniteCheck /** * Create instance of {@link BinaryMarshaller} suitable for use * without starting a grid upon given {@link IgniteConfiguration}. + * * @return Binary marshaller. * @throws IgniteCheckedException if failed. */ @@ -1634,10 +1627,10 @@ protected String home() throws IgniteCheckedException { /** * This method should be overridden by subclasses to change configuration parameters. * - * @return Grid configuration used for starting of grid. * @param igniteInstanceName Ignite instance name. * @param rsrcs Resources. * @throws Exception If failed. + * @return Grid configuration used for starting of grid. */ @SuppressWarnings("deprecation") protected IgniteConfiguration getConfiguration(String igniteInstanceName, IgniteTestResources rsrcs) @@ -1679,18 +1672,13 @@ protected IgniteConfiguration getConfiguration(String igniteInstanceName, Ignite // Set metrics update interval to 1 second to speed up tests. cfg.setMetricsUpdateFrequency(1000); - String mcastAddr = GridTestUtils.getNextMulticastGroup(getClass()); + if (!isMultiJvm()) { + assert sharedStaticIpFinder != null : "Shared static IP finder should be initialized at this point."; - TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder(); - - ipFinder.setAddresses(Collections.singleton("127.0.0.1:" + TcpDiscoverySpi.DFLT_PORT)); - - if (!F.isEmpty(mcastAddr)) { - ipFinder.setMulticastGroup(mcastAddr); - ipFinder.setMulticastPort(GridTestUtils.getNextMulticastPort(getClass())); + discoSpi.setIpFinder(sharedStaticIpFinder); } - - discoSpi.setIpFinder(ipFinder); + else + discoSpi.setIpFinder(LOCAL_IP_FINDER); cfg.setDiscoverySpi(discoSpi); @@ -1710,8 +1698,6 @@ protected IgniteConfiguration getConfiguration(String igniteInstanceName, Ignite cfg.setFailureHandler(getFailureHandler(igniteInstanceName)); - checkConfiguration(cfg); - return cfg; } @@ -1728,11 +1714,14 @@ protected FailureHandler getFailureHandler(String igniteInstanceName) { /** * @return New cache configuration with modified defaults. */ + @SuppressWarnings("unchecked") public static CacheConfiguration defaultCacheConfiguration() { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - cfg.setAtomicityMode(TRANSACTIONAL); - cfg.setNearConfiguration(new NearCacheConfiguration()); + if (MvccFeatureChecker.forcedMvcc()) + cfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT); + else + cfg.setAtomicityMode(TRANSACTIONAL).setNearConfiguration(new NearCacheConfiguration<>()); cfg.setWriteSynchronizationMode(FULL_SYNC); cfg.setEvictionPolicy(null); @@ -1755,7 +1744,14 @@ protected static ClassLoader getExternalClassLoader() { } } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + *

    + * Do not annotate with After in overriding methods.

    + * @deprecated This method is deprecated. Instead of invoking or overriding it, it is recommended to make your own + * method with {@code @After} annotation. + */ + @Deprecated @Override protected void tearDown() throws Exception { long dur = System.currentTimeMillis() - ts; @@ -1994,7 +1990,7 @@ public static R executeOnLocalOrRemoteJvm(Ignite ignite, final TestIgniteCal * @param cache Cache. * @param job Job. */ - public static R executeOnLocalOrRemoteJvm(IgniteCache cache, TestCacheCallable job) { + public static R executeOnLocalOrRemoteJvm(IgniteCache cache, TestCacheCallable job) { Ignite ignite = cache.unwrap(Ignite.class); if (!isMultiJvmObject(ignite)) @@ -2053,7 +2049,7 @@ public static R executeRemotely(IgniteCacheProcessProxy cache, @Override public R call() throws Exception { Ignite ignite = Ignition.ignite(id); - IgniteCache cache = ignite.cache(cacheName); + IgniteCache cache = ignite.cache(cacheName); return job.call(ignite, cache); } @@ -2082,14 +2078,16 @@ protected synchronized TestCounters getTestCounters(IgniteConfiguration cfg) thr } /** {@inheritDoc} */ - @SuppressWarnings({"ProhibitedExceptionDeclared"}) - @Override protected void runTest() throws Throwable { + @Override void runTest(Statement testRoutine) throws Throwable { final AtomicReference ex = new AtomicReference<>(); Thread runner = new IgniteThread(getTestIgniteInstanceName(), "test-runner", new Runnable() { @Override public void run() { try { - runTestInternal(); + if (forceFailure) + fail("Forced failure: " + forceFailureMsg); + + testRoutine.evaluate(); } catch (Throwable e) { IgniteClosure hnd = errorHandler(); @@ -2106,7 +2104,7 @@ protected synchronized TestCounters getTestCounters(IgniteConfiguration cfg) thr if (runner.isAlive()) { U.error(log, "Test has been timed out and will be interrupted (threads dump will be taken before interruption) [" + - "test=" + getName() + ", timeout=" + getTestTimeout() + ']'); + "test=" + getName() + ", timeout=" + getTestTimeout() + ']'); List nodes = IgnitionEx.allGridsx(); @@ -2124,7 +2122,7 @@ protected synchronized TestCounters getTestCounters(IgniteConfiguration cfg) thr U.join(runner, log); throw new TimeoutException("Test has been timed out [test=" + getName() + ", timeout=" + - getTestTimeout() + ']' ); + getTestTimeout() + ']'); } Throwable t = ex.get(); @@ -2139,8 +2137,7 @@ protected synchronized TestCounters getTestCounters(IgniteConfiguration cfg) thr } /** - * @return Error handler to process all uncaught exceptions of the test run - * ({@code null} by default). + * @return Error handler to process all uncaught exceptions of the test run ({@code null} by default). */ protected IgniteClosure errorHandler() { return null; @@ -2166,17 +2163,6 @@ public void forceTestCount(int cnt) { forceTestCnt = true; } - /** - * @throws Throwable If failed. - */ - @SuppressWarnings({"ProhibitedExceptionDeclared"}) - private void runTestInternal() throws Throwable { - if (forceFailure) - fail("Forced failure: " + forceFailureMsg); - else - super.runTest(); - } - /** * @return Test case timeout. */ @@ -2199,7 +2185,7 @@ private long getDefaultTestTimeout() { /** * @param store Store. */ - protected Factory singletonFactory(T store) { + protected static Factory singletonFactory(T store) { return notSerializableProxy(new FactoryBuilder.SingletonFactory<>(store), Factory.class); } @@ -2207,7 +2193,7 @@ protected Factory singletonFactory(T store) { * @param obj Object that should be wrap proxy * @return Created proxy. */ - protected T notSerializableProxy(final T obj) { + protected static T notSerializableProxy(final T obj) { Class cls = (Class)obj.getClass(); Class[] interfaces = (Class[])cls.getInterfaces(); @@ -2225,7 +2211,7 @@ protected T notSerializableProxy(final T obj) { * @param itfClses Interfaces that should be implemented by proxy (vararg parameter) * @return Created proxy. */ - protected T notSerializableProxy(final T obj, Class itfCls, Class ... itfClses) { + protected static T notSerializableProxy(final T obj, Class itfCls, Class... itfClses) { Class[] itfs = Arrays.copyOf(itfClses, itfClses.length + 3); itfs[itfClses.length] = itfCls; @@ -2248,7 +2234,7 @@ protected T notSerializableProxy(final T obj, Class itfCls, Class * @param obj Object that must not be changed after serialization/deserialization. * @return An object to return from writeReplace() */ - private Object supressSerialization(Object obj) { + private static Object supressSerialization(Object obj) { SerializableProxy res = new SerializableProxy(UUID.randomUUID()); serializedObj.put(res.uuid, obj); @@ -2286,7 +2272,7 @@ private void awaitTopologyChange() throws IgniteInterruptedCheckedException { AffinityTopologyVersion exchVer = ctx.cache().context().exchange().readyAffinityVersion(); if (!topVer.equals(exchVer)) { - info("Topology version mismatch [node=" + g.name() + + info("Topology version mismatch [node=" + g.name() + ", exchVer=" + exchVer + ", topVer=" + topVer + ']'); @@ -2301,6 +2287,7 @@ private void awaitTopologyChange() throws IgniteInterruptedCheckedException { } } } + /** * @param expSize Expected nodes number. * @throws Exception If failed. @@ -2316,7 +2303,7 @@ protected void waitForTopology(final int expSize) throws Exception { return false; } - for (Ignite node: nodes) { + for (Ignite node : nodes) { try { IgniteFuture reconnectFut = node.cluster().clientReconnectFuture(); @@ -2354,7 +2341,7 @@ public static void doSleep(long millis) { U.sleep(millis); } catch (Exception e) { - throw new IgniteException(); + throw new IgniteException(e); } } @@ -2363,7 +2350,7 @@ public static void doSleep(long millis) { * @param cacheName Cache name. * @return Cache group ID for given cache name. */ - protected final int groupIdForCache(Ignite node, String cacheName) { + protected static final int groupIdForCache(Ignite node, String cacheName) { for (CacheGroupContext grp : ((IgniteKernal)node).context().cache().cacheGroups()) { if (grp.hasCache(cacheName)) return grp.groupId(); @@ -2484,6 +2471,12 @@ public ExecuteRemotelyTask(TestIgniteIdxCallable job, int idx) { /** * Test counters. + * + * TODO IGNITE-10179 Try to make this class go away since its primary (possibly even only) purpose appears to + * support methods isFirstTest() and isLastTest() which in turn look like JUnit 3-specific workaround for + * functionality that is natively available in JUnit 4 via BeforeClass and AfterClass annotations. Along the way, + * find out if this will allow to get rid of runSerializer lock which is introduced with sole purpose to + * maintain integrity of TestCounters. */ protected class TestCounters { /** */ @@ -2600,19 +2593,16 @@ public int getNumberOfTests() { if (this0.forceTestCnt) cnt = this0.testCnt; - else { - cnt = 0; - - for (Method m : this0.getClass().getMethods()) - if (m.getName().startsWith("test") && Modifier.isPublic(m.getModifiers()) && m.getParameterCount() == 0) - cnt++; - } + else + cnt = (int)new TestClass(this0.getClass()) + .getAnnotatedMethods(Test.class) + .stream() + .filter(method -> method.getAnnotation(Ignore.class) == null) + .count(); numOfTests = cnt; } - countTestCases(); - return numOfTests; } } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java index 0e454a366473d..2bbead2c2cca0 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java @@ -38,6 +38,7 @@ import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.testframework.configvariations.VariationsTestsConfig; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.runners.model.Statement; /** * Common abstract test for Ignite tests based on configurations variations. @@ -55,25 +56,38 @@ public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstr /** */ private static final File workDir = new File(U.getIgniteHome() + File.separator + "workOfConfigVariationsTests"); - /** */ - protected VariationsTestsConfig testsCfg; + /** Dummy initial stub to just let people launch test classes not from suite. */ + protected VariationsTestsConfig testsCfg = new VariationsTestsConfig(null, "Dummy config", false, null, 1, false); /** */ protected volatile DataMode dataMode = DataMode.PLANE_OBJECT; + /** See {@link IgniteConfigVariationsAbstractTest#injectTestsConfiguration} */ + private static VariationsTestsConfig testsCfgInjected; + + /** + * @param testsCfgInjected Tests configuration. + */ + public static void injectTestsConfiguration(VariationsTestsConfig testsCfgInjected) { + IgniteConfigVariationsAbstractTest.testsCfgInjected = testsCfgInjected; + } + /** - * @param testsCfg Tests configuration. + * {@inheritDoc} + *

    + * IMPL NOTE when this override was introduced, alternative was to replace multiple usages of instance member + * {@code testsCfg} splattered all over the project with those of static one {@code testsCfgInjected} - kind + * of cumbersome, risky and potentially redundant change given the chance of later migration to JUnit 5 and + * further rework to use dynamic test parameters that would likely cause removal of the static member.

    */ - public void setTestsConfiguration(VariationsTestsConfig testsCfg) { - assert this.testsCfg == null : "Test config must be set only once [oldTestCfg=" + this.testsCfg - + ", newTestCfg=" + testsCfg + "]"; + @Override protected void runTestCase(Statement testRoutine) throws Throwable { + testsCfg = testsCfgInjected; - this.testsCfg = testsCfg; + super.runTestCase(testRoutine); } /** {@inheritDoc} */ - @Override - protected boolean isSafeTopology() { + @Override protected boolean isSafeTopology() { return false; } @@ -158,6 +172,8 @@ private void memoryUsage() { /** {@inheritDoc} */ @Override protected String testDescription() { + assert testsCfg != null: "Tests should be run using test suite."; + return super.testDescription() + '-' + testsCfg.description() + '-' + testsCfg.gridCount() + "-node(s)"; } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/JUnit3TestLegacySupport.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/JUnit3TestLegacySupport.java new file mode 100644 index 0000000000000..709b39c6d6e2d --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/JUnit3TestLegacySupport.java @@ -0,0 +1,134 @@ +/* + * 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. + */ + +package org.apache.ignite.testframework.junits; + +import junit.framework.Assert; // IMPL NOTE some old tests expect inherited deprecated assertions. +import org.junit.Rule; +import org.junit.rules.TestName; +import org.junit.runners.model.Statement; + +/** + * Supports compatibility with old tests that expect specific threading behavior of JUnit 3 TestCase class, + * inherited deprecated assertions and specific old interface for GridTestUtils. + */ +@SuppressWarnings({"TransientFieldInNonSerializableClass", "ExtendsUtilityClass", "deprecation"}) +public abstract class JUnit3TestLegacySupport extends Assert { + /** + * Supports obtaining test name for JUnit4 framework in a way that makes it available for legacy methods invoked + * from {@code runTest(Statement)}. + */ + @Rule public transient TestName nameRule = new TestName(); + + /** + * Gets the name of the currently executed test case. + * + * @return Name of the currently executed test case. + */ + public String getName() { + return nameRule.getMethodName(); + } + + /** This method is called before a test is executed. */ + abstract void setUp() throws Exception; + + /** Runs test code in between {@code setUp} and {@code tearDown}. */ + abstract void runTest(Statement testRoutine) throws Throwable; + + /** This method is called after a test is executed. */ + abstract void tearDown() throws Exception; + + /** + * Runs the bare test sequence like in JUnit 3 class TestCase. + * + * @throws Throwable if any exception is thrown + */ + protected void runTestCase(Statement testRoutine) throws Throwable { + Throwable e = null; + setUp(); + try { + runTest(testRoutine); + } catch (Throwable running) { + e = running; + } finally { + try { + tearDown(); + } catch (Throwable tearingDown) { + if (e == null) e = tearingDown; + } + } + if (e != null) throw e; + } + + /** + * Called before execution of every test method in class. + *

    + * Do not annotate with Before in overriding methods.

    + * + * @throws Exception If failed. {@link #afterTest()} will be called in this case. + * @deprecated This method is deprecated. Instead of invoking or overriding it, it is recommended to make your own + * method with {@code @Before} annotation. + */ + @Deprecated + protected void beforeTest() throws Exception { + // No-op. + } + + /** + * Called after execution of every test method in class or if {@link #beforeTest()} failed without test method + * execution. + *

    + * Do not annotate with After in overriding methods.

    + * + * @throws Exception If failed. + * @deprecated This method is deprecated. Instead of invoking or overriding it, it is recommended to make your own + * method with {@code @After} annotation. + */ + @Deprecated + protected void afterTest() throws Exception { + // No-op. + } + + /** + * Called before execution of all test methods in class. + *

    + * Do not annotate with BeforeClass in overriding methods.

    + * + * @throws Exception If failed. {@link #afterTestsStopped()} will be called in this case. + * @deprecated This method is deprecated. Instead of invoking or overriding it, it is recommended to make your own + * method with {@code @BeforeClass} annotation. + */ + @Deprecated + protected void beforeTestsStarted() throws Exception { + // No-op. + } + + /** + * Called after execution of all test methods in class or + * if {@link #beforeTestsStarted()} failed without execution of any test methods. + *

    + * Do not annotate with AfterClass in overriding methods.

    + * + * @throws Exception If failed. + * @deprecated This method is deprecated. Instead of invoking or overriding it, it is recommended to make your own + * method with {@code @AfterClass} annotation. + */ + @Deprecated + protected void afterTestsStopped() throws Exception { + // No-op. + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java index 22d93763abf8f..fd8ad188f5b91 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java @@ -45,10 +45,14 @@ import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionState; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Abstract cache store test. */ +@RunWith(JUnit4.class) public abstract class GridAbstractCacheStoreSelfTest> extends GridCommonAbstractTest { /** */ @@ -72,6 +76,7 @@ protected GridAbstractCacheStoreSelfTest() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStore() throws Exception { // Create dummy transaction Transaction tx = new DummyTx(); @@ -105,6 +110,7 @@ public void testStore() throws Exception { /** * @throws IgniteCheckedException if failed. */ + @Test public void testRollback() throws IgniteCheckedException { Transaction tx = new DummyTx(); @@ -190,6 +196,7 @@ public void testRollback() throws IgniteCheckedException { /** * @throws IgniteCheckedException if failed. */ + @Test public void testAllOpsWithTXNoCommit() throws IgniteCheckedException { doTestAllOps(new DummyTx(), false); } @@ -197,6 +204,7 @@ public void testAllOpsWithTXNoCommit() throws IgniteCheckedException { /** * @throws IgniteCheckedException if failed. */ + @Test public void testAllOpsWithTXCommit() throws IgniteCheckedException { doTestAllOps(new DummyTx(), true); } @@ -204,6 +212,7 @@ public void testAllOpsWithTXCommit() throws IgniteCheckedException { /** * @throws IgniteCheckedException if failed. */ + @Test public void testAllOpsWithoutTX() throws IgniteCheckedException { doTestAllOps(null, false); } @@ -306,6 +315,7 @@ private void doTestAllOps(@Nullable Transaction tx, boolean commit) { /** * @throws Exception If failed. */ + @Test public void testSimpleMultithreading() throws Exception { final Random rnd = new Random(); diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractExamplesTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractExamplesTest.java index 1e6c84ee1f27a..3c305fac291ab 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractExamplesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractExamplesTest.java @@ -75,4 +75,4 @@ protected final void startRemoteNodes() throws Exception { protected String defaultConfig() { return DFLT_CFG; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java index 35c0b069b1d14..703d59bec051d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.Ignite; import org.apache.ignite.lifecycle.LifecycleAware; import org.apache.ignite.resources.CacheNameResource; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Base class for tests against {@link LifecycleAware} support. */ +@RunWith(JUnit4.class) public abstract class GridAbstractLifecycleAwareSelfTest extends GridCommonAbstractTest { /** */ protected Collection lifecycleAwares = new ArrayList<>(); @@ -107,6 +111,7 @@ protected void afterGridStart(Ignite ignite) { /** * @throws Exception If failed. */ + @Test public void testLifecycleAware() throws Exception { Ignite ignite = startGrid(); @@ -131,4 +136,4 @@ public void testLifecycleAware() throws Exception { lifecycleAwares.clear(); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java index 7e98ec763e3aa..62434953fc943 100755 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java @@ -47,6 +47,7 @@ import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteMessaging; import org.apache.ignite.Ignition; +import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.cache.affinity.AffinityFunction; @@ -316,7 +317,9 @@ protected static GridDhtCacheAdapter dht(IgniteCache cache) { * @return DHT cache. */ protected GridDhtCacheAdapter dht() { - return this.near().dht(); + GridCacheAdapter internalCache = ((IgniteKernal)grid()).internalCache(DEFAULT_CACHE_NAME); + + return internalCache.isNear() ? internalCache.context().near().dht() : internalCache.context().dht(); } /** @@ -324,7 +327,9 @@ protected GridDhtCacheAdapter dht() { * @return DHT cache. */ protected GridDhtCacheAdapter dht(int idx) { - return this.near(idx).dht(); + GridCacheAdapter internalCache = ((IgniteKernal)grid(idx)).internalCache(DEFAULT_CACHE_NAME); + + return internalCache.isNear() ? internalCache.context().near().dht() : internalCache.context().dht(); } /** @@ -333,7 +338,9 @@ protected GridDhtCacheAdapter dht(int idx) { * @return DHT cache. */ protected GridDhtCacheAdapter dht(int idx, String cache) { - return this.near(idx, cache).dht(); + GridCacheAdapter internalCache = ((IgniteKernal)grid(idx)).internalCache(cache); + + return internalCache.isNear() ? internalCache.context().near().dht() : internalCache.context().dht(); } /** @@ -394,6 +401,14 @@ protected static GridDhtColocatedCache colocated(IgniteCache return ((IgniteKernal)cache.unwrap(Ignite.class)).internalCache(cache.getName()).context().colocated(); } + /** + * @param cache Ignite cache. + * @return CacheAtomicityMode for given cache. + */ + public static CacheAtomicityMode atomicityMode(IgniteCache cache) { + return ((CacheConfiguration)cache.getConfiguration(CacheConfiguration.class)).getAtomicityMode(); + } + /** * @param cache Cache. * @param keys Keys. @@ -481,7 +496,7 @@ protected GridNearCacheAdapter near(int idx, String cache) { } /** {@inheritDoc} */ - @Override protected void setUp() throws Exception { + @Override public void setUp() throws Exception { // Disable SSL hostname verifier. HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String s, SSLSession sslSes) { @@ -495,7 +510,7 @@ protected GridNearCacheAdapter near(int idx, String cache) { } /** {@inheritDoc} */ - @Override protected void tearDown() throws Exception { + @Override public void tearDown() throws Exception { getTestCounters().incrementStopped(); super.tearDown(); @@ -670,7 +685,7 @@ protected void awaitPartitionMapExchange( if (readyVer.topologyVersion() > 0 && c.context().started()) { // Must map on updated version of topology. - Collection affNodes = + List affNodes = dht.context().affinity().assignment(readyVer).idealAssignment().get(p); int affNodesCnt = affNodes.size(); @@ -684,8 +699,13 @@ protected void awaitPartitionMapExchange( GridDhtLocalPartition loc = top.localPartition(p, readyVer, false); + boolean notPrimary = !affNodes.isEmpty() && + !exchMgr.rebalanceTopologyVersion().equals(AffinityTopologyVersion.NONE) && + !affNodes.get(0).equals(dht.context().affinity().primaryByPartition(p, readyVer)); + if (affNodesCnt != ownerNodesCnt || !affNodes.containsAll(owners) || - (waitEvicts && loc != null && loc.state() != GridDhtPartitionState.OWNING)) { + (waitEvicts && loc != null && loc.state() != GridDhtPartitionState.OWNING) || + notPrimary) { if (i % 50 == 0) LT.warn(log(), "Waiting for topology map update [" + "igniteInstanceName=" + g.name() + @@ -1384,7 +1404,7 @@ protected static V dhtPeek(IgniteCache cache, K key) throws IgniteC * @param key Key. */ protected static V localPeek(GridCacheAdapter cache, K key) throws IgniteCheckedException { - return cache.localPeek(key, null, null); + return cache.localPeek(key, null); } /** @@ -1392,7 +1412,7 @@ protected static V localPeek(GridCacheAdapter cache, K key) throws * @param key Key. */ protected static V localPeekOnHeap(GridCacheAdapter cache, K key) throws IgniteCheckedException { - return cache.localPeek(key, new CachePeekMode[] {CachePeekMode.ONHEAP}, null); + return cache.localPeek(key, new CachePeekMode[] {CachePeekMode.ONHEAP}); } /** @@ -1996,17 +2016,26 @@ protected void checkFutures() { final Collection> futs = ig.context().cache().context().mvcc().activeFutures(); - for (GridCacheFuture fut : futs) - log.info("Waiting for future: " + fut); + boolean hasFutures = false; + + for (GridCacheFuture fut : futs) { + if (!fut.isDone()) { + log.error("Expecting no active future [node=" + ig.localNode().id() + ", fut=" + fut + ']'); + + hasFutures = true; + } + } - assertTrue("Expecting no active futures: node=" + ig.localNode().id(), futs.isEmpty()); + if (hasFutures) + fail("Some mvcc futures are not finished"); Collection txs = ig.context().cache().context().tm().activeTransactions(); for (IgniteInternalTx tx : txs) - log.info("Waiting for tx: " + tx); + log.error("Expecting no active transaction [node=" + ig.localNode().id() + ", tx=" + tx + ']'); - assertTrue("Expecting no active transactions: node=" + ig.localNode().id(), txs.isEmpty()); + if (!txs.isEmpty()) + fail("Some transaction are not finished"); } } } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java index f81d103712c2e..ecf119b098b5f 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java @@ -687,6 +687,21 @@ private IgniteCacheProcessProxy(String name, boolean async, ExpiryPolicy plc, Ig throw new UnsupportedOperationException("Method should be supported."); } + /** {@inheritDoc} */ + @Override public void preloadPartition(int partId) { + throw new UnsupportedOperationException("Method should be supported."); + } + + /** {@inheritDoc} */ + @Override public IgniteFuture preloadPartitionAsync(int partId) { + throw new UnsupportedOperationException("Method should be supported."); + } + + /** {@inheritDoc} */ + @Override public boolean localPreloadPartition(int partition) { + throw new UnsupportedOperationException("Method should be supported."); + } + /** {@inheritDoc} */ @Override public IgniteCache withAllowAtomicOpsInTx() { return this; diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java index b6f7f8945adc4..ccd4e9eaa4c58 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java @@ -31,6 +31,7 @@ import javax.cache.CacheException; import org.apache.ignite.DataRegionMetrics; import org.apache.ignite.DataRegionMetricsAdapter; +import org.apache.ignite.DataStorageMetrics; import org.apache.ignite.DataStorageMetricsAdapter; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteAtomicLong; @@ -54,8 +55,8 @@ import org.apache.ignite.IgniteSemaphore; import org.apache.ignite.IgniteServices; import org.apache.ignite.IgniteSet; +import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.IgniteTransactions; -import org.apache.ignite.DataStorageMetrics; import org.apache.ignite.Ignition; import org.apache.ignite.MemoryMetrics; import org.apache.ignite.PersistenceMetrics; @@ -265,7 +266,8 @@ protected Collection filteredJvmArgs() throws Exception { (marsh != null && arg.startsWith("-D" + IgniteTestResources.MARSH_CLASS_NAME)) || arg.startsWith("--add-opens") || arg.startsWith("--add-exports") || arg.startsWith("--add-modules") || arg.startsWith("--patch-module") || arg.startsWith("--add-reads") || - arg.startsWith("-XX:+IgnoreUnrecognizedVMOptions")) + arg.startsWith("-XX:+IgnoreUnrecognizedVMOptions") || + arg.startsWith(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS)) filteredJvmArgs.add(arg); } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java index 101d0163d469f..426c5816e7af6 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java @@ -126,7 +126,7 @@ private void resetTestData() throws Exception { /** * @throws Exception If failed. */ - @Override protected final void setUp() throws Exception { + @Override public final void setUp() throws Exception { // Need to change classloader here, although it also handled in the parent class // the current test initialisation procedure doesn't allow us to setUp the parent first. cl = Thread.currentThread().getContextClassLoader(); @@ -490,7 +490,7 @@ protected UUID getNodeId() throws Exception { /** * @throws Exception If failed. */ - @Override protected final void tearDown() throws Exception { + @Override public final void tearDown() throws Exception { getTestCounters().incrementStopped(); boolean wasLast = isLastTest(); @@ -730,4 +730,4 @@ private static class SecurityPermissionSetImpl implements SecurityPermissionSet return null; } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/test/ConfigVariationsTestSuiteBuilderTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/test/ConfigVariationsTestSuiteBuilderTest.java index 93f0168bd3573..631f0337dcd2f 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/test/ConfigVariationsTestSuiteBuilderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/test/ConfigVariationsTestSuiteBuilderTest.java @@ -18,22 +18,23 @@ package org.apache.ignite.testframework.test; import java.util.concurrent.atomic.AtomicInteger; -import junit.framework.TestCase; import junit.framework.TestSuite; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * */ -public class ConfigVariationsTestSuiteBuilderTest extends TestCase { - /** - * @throws Exception If failed. - */ - public void testDefaults() throws Exception { +public class ConfigVariationsTestSuiteBuilderTest { + /** */ + @Test + public void testDefaults() { TestSuite dfltSuite = new ConfigVariationsTestSuiteBuilder("testSuite", NoopTest.class).build(); assertEquals(4, dfltSuite.countTestCases()); @@ -55,11 +56,10 @@ public void testDefaults() throws Exception { assertEquals(4 * 4 * 2 * 3, dfltCacheSuite.countTestCases()); } - /** - * @throws Exception If failed. - */ + /** */ @SuppressWarnings("serial") - public void testIgniteConfigFilter() throws Exception { + @Test + public void testIgniteConfigFilter() { TestSuite dfltSuite = new ConfigVariationsTestSuiteBuilder("testSuite", NoopTest.class).build(); final AtomicInteger cnt = new AtomicInteger(); @@ -75,11 +75,10 @@ public void testIgniteConfigFilter() throws Exception { assertEquals(dfltSuite.countTestCases() / 2, filteredSuite.countTestCases()); } - /** - * @throws Exception If failed. - */ + /** */ @SuppressWarnings("serial") - public void testCacheConfigFilter() throws Exception { + @Test + public void testCacheConfigFilter() { TestSuite dfltSuite = new ConfigVariationsTestSuiteBuilder("testSuite", NoopTest.class) .withBasicCacheParams() .build(); @@ -98,14 +97,11 @@ public void testCacheConfigFilter() throws Exception { assertEquals(dfltSuite.countTestCases() / 2, filteredSuite.countTestCases()); } - /** - * - */ - private static class NoopTest extends IgniteConfigVariationsAbstractTest { - /** - * @throws Exception If failed. - */ - public void test1() throws Exception { + /** */ + public static class NoopTest extends IgniteConfigVariationsAbstractTest { + /** */ + @Test + public void test1() { // No-op. } } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/test/ListeningTestLoggerTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/test/ListeningTestLoggerTest.java new file mode 100644 index 0000000000000..0be0a00398442 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testframework/test/ListeningTestLoggerTest.java @@ -0,0 +1,438 @@ +/* + * 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. + */ + +package org.apache.ignite.testframework.test; + +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Pattern; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteVersionUtils; +import org.apache.ignite.logger.NullLogger; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.ListeningTestLogger; +import org.apache.ignite.testframework.LogListener; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; + +/** + * Test. + */ +@SuppressWarnings("ThrowableNotThrown") +public class ListeningTestLoggerTest extends GridCommonAbstractTest { + /** */ + private final ListeningTestLogger log = new ListeningTestLogger(false, super.log); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setGridLogger(log); + + return cfg; + } + + /** + * Basic example of using listening logger - checks that all running instances of Ignite print product version. + * + * @throws Exception If failed. + */ + @Test + public void testIgniteVersionLogging() throws Exception { + int gridCnt = 4; + + LogListener lsnr = LogListener.matches(IgniteVersionUtils.VER_STR).atLeast(gridCnt).build(); + + log.registerListener(lsnr); + + try { + startGridsMultiThreaded(gridCnt); + + assertTrue(lsnr.check()); + } finally { + stopAllGrids(); + } + } + + /** + * Checks that re-register works fine. + */ + @Test + public void testUnregister() { + String msg = "catch me"; + + LogListener lsnr1 = LogListener.matches(msg).times(1).build(); + LogListener lsnr2 = LogListener.matches(msg).times(2).build(); + + log.registerListener(lsnr1); + log.registerListener(lsnr2); + + log.info(msg); + + log.unregisterListener(lsnr1); + + log.info(msg); + + assertTrue(lsnr1.check()); + assertTrue(lsnr2.check()); + + // Repeat these steps to ensure that the state is cleared during registration. + log.registerListener(lsnr1); + log.registerListener(lsnr2); + + log.info(msg); + + log.unregisterListener(lsnr1); + + log.info(msg); + + assertTrue(lsnr1.check()); + assertTrue(lsnr2.check()); + } + + /** + * Ensures that listener will be re-registered only once. + */ + @Test + public void testRegister() { + AtomicInteger cntr = new AtomicInteger(); + + LogListener lsnr3 = LogListener.matches(m -> cntr.incrementAndGet() > 0).build(); + + log.registerListener(lsnr3); + log.registerListener(lsnr3); + + log.info("1"); + + assertEquals(1, cntr.get()); + } + + /** + * Checks basic API. + */ + @Test + public void testBasicApi() { + LogListener lsnr = LogListener.matches(Pattern.compile("a[a-z]+")) + .andMatches("Exception message.").andMatches(".java:").build(); + + log.registerListener(lsnr); + + log.info("Something new."); + + assertFalse(lsnr.check()); + + log.error("There was an error.", new RuntimeException("Exception message.")); + + assertTrue(lsnr.check()); + } + + /** + * Checks blank lines matching. + */ + @Test + public void testEmptyLine() { + LogListener emptyLineLsnr = LogListener.matches("").build(); + + log.registerListener(emptyLineLsnr); + + log.info(""); + + assertTrue(emptyLineLsnr.check()); + } + + /** */ + @Test + public void testPredicateExceptions() { + LogListener lsnr = LogListener.matches(msg -> { + assertFalse(msg.contains("Target")); + + return true; + }).build(); + + log.registerListener(lsnr); + + log.info("Ignored message."); + log.info("Target message."); + + assertThrowsWithCause(lsnr::check, AssertionError.class); + + // Check custom exception. + LogListener lsnr2 = LogListener.matches(msg -> { + throw new IllegalStateException("Illegal state"); + }).build(); + + log.registerListener(lsnr2); + + log.info("1"); + log.info("2"); + + assertThrowsWithCause(lsnr2::check, IllegalStateException.class); + } + + /** + * Validates listener range definition. + */ + @Test + public void testRange() { + String msg = "range"; + + LogListener lsnr2 = LogListener.matches(msg).times(2).build(); + LogListener lsnr2_3 = LogListener.matches(msg).atLeast(2).atMost(3).build(); + + log.registerListener(lsnr2); + log.registerListener(lsnr2_3); + + log.info(msg); + log.info(msg); + + assertTrue(lsnr2.check()); + assertTrue(lsnr2_3.check()); + + log.info(msg); + + assertFalse(lsnr2.check()); + + assertTrue(lsnr2_3.check()); + + log.info(msg); + + assertFalse(lsnr2_3.check()); + } + + /** + * Checks that substring was not found in the log messages. + */ + @Test + public void testNotPresent() { + String msg = "vacuum"; + + LogListener notPresent = LogListener.matches(msg).times(0).build(); + + log.registerListener(notPresent); + + log.info("1"); + + assertTrue(notPresent.check()); + + log.info(msg); + + assertFalse(notPresent.check()); + } + + /** + * Checks that the substring is found at least twice. + */ + @Test + public void testAtLeast() { + String msg = "at least"; + + LogListener atLeast2 = LogListener.matches(msg).atLeast(2).build(); + + log.registerListener(atLeast2); + + log.info(msg); + + assertFalse(atLeast2.check()); + + log.info(msg); + + assertTrue(atLeast2.check()); + } + + /** + * Checks that the substring is found no more than twice. + */ + @Test + public void testAtMost() { + String msg = "at most"; + + LogListener atMost2 = LogListener.matches(msg).atMost(2).build(); + + log.registerListener(atMost2); + + assertTrue(atMost2.check()); + + log.info(msg); + log.info(msg); + + assertTrue(atMost2.check()); + + log.info(msg); + + assertFalse(atMost2.check()); + } + + /** + * Checks that only last value is taken into account. + */ + @Test + public void testMultiRange() { + String msg = "multi range"; + + LogListener atMost3 = LogListener.matches(msg).times(1).times(2).atMost(3).build(); + + log.registerListener(atMost3); + + for (int i = 0; i < 6; i++) { + if (i < 4) + assertTrue(atMost3.check()); + else + assertFalse(atMost3.check()); + + log.info(msg); + } + + LogListener lsnr4 = LogListener.matches(msg).atLeast(2).atMost(3).times(4).build(); + + log.registerListener(lsnr4); + + for (int i = 1; i < 6; i++) { + log.info(msg); + + if (i == 4) + assertTrue(lsnr4.check()); + else + assertFalse(lsnr4.check()); + } + } + + /** + * Checks that matches are counted for each message. + */ + @Test + public void testMatchesPerMessage() { + LogListener lsnr = LogListener.matches("aa").times(4).build(); + + log.registerListener(lsnr); + + log.info("aabaab"); + log.info("abaaab"); + + assertTrue(lsnr.check()); + + LogListener newLineLsnr = LogListener.matches("\n").times(5).build(); + + log.registerListener(newLineLsnr); + + log.info("\n1\n2\n\n3\n"); + + assertTrue(newLineLsnr.check()); + + LogListener regexpLsnr = LogListener.matches(Pattern.compile("(?i)hi|hello")).times(3).build(); + + log.registerListener(regexpLsnr); + + log.info("Hi! Hello!"); + log.info("Hi folks"); + + assertTrue(regexpLsnr.check()); + } + + /** + * Check thread safety. + * + * @throws Exception If failed. + */ + @Test + public void testMultithreaded() throws Exception { + int iterCnt = 50_000; + int threadCnt = 6; + int total = threadCnt * iterCnt; + int rndNum = ThreadLocalRandom.current().nextInt(iterCnt); + + ListeningTestLogger log = new ListeningTestLogger(); + + LogListener lsnr = LogListener.matches("abba").times(total) + .andMatches(Pattern.compile("(?i)abba")).times(total * 2) + .andMatches("ab").times(total) + .andMatches("ba").times(total) + .build(); + + LogListener mtLsnr = LogListener.matches("abba").build(); + + log.registerListener(lsnr); + + GridTestUtils.runMultiThreaded(() -> { + for (int i = 0; i < iterCnt; i++) { + if (rndNum == i) + log.registerListener(mtLsnr); + + log.info("It is the abba(ABBA) message."); + } + }, threadCnt, "test-listening-log"); + + assertTrue(lsnr.check()); + assertTrue(mtLsnr.check()); + } + + /** + * Check "echo" logger. + */ + @Test + public void testEchoLogger() { + IgniteLogger echo = new StringLogger(); + + ListeningTestLogger log = new ListeningTestLogger(true, echo); + + log.error("1"); + log.warning("2"); + log.info("3"); + log.debug("4"); + log.trace("5"); + + assertEquals("12345", echo.toString()); + } + + /** */ + private static class StringLogger extends NullLogger { + /** */ + private final StringBuilder buf = new StringBuilder(); + + /** {@inheritDoc} */ + @Override public void trace(String msg) { + buf.append(msg); + } + + /** {@inheritDoc} */ + @Override public void debug(String msg) { + buf.append(msg); + } + + /** {@inheritDoc} */ + @Override public void info(String msg) { + buf.append(msg); + } + + /** {@inheritDoc} */ + @Override public void warning(String msg, Throwable t) { + buf.append(msg); + } + + /** {@inheritDoc} */ + @Override public void error(String msg, Throwable t) { + buf.append(msg); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return buf.toString(); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/test/ParametersTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/test/ParametersTest.java index 736db1283915a..fd145b500b4c4 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/test/ParametersTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/test/ParametersTest.java @@ -19,22 +19,25 @@ import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.configvariations.ConfigParameter; import org.apache.ignite.testframework.configvariations.Parameters; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * Test. */ -public class ParametersTest extends TestCase { +public class ParametersTest { /** */ private static final String DEFAULT_CACHE_NAME = "default"; /** * @throws Exception If failed. */ + @Test public void testEnumVariations() throws Exception { ConfigParameter[] modes = Parameters.enumParameters("setCacheMode", CacheMode.class); @@ -60,7 +63,7 @@ public void testEnumVariations() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("unchecked") + @Test public void testEnumVariationsWithNull() throws Exception { ConfigParameter[] cfgParam = Parameters.enumParameters(true, "setCacheMode", CacheMode.class); diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/test/VariationsIteratorTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/test/VariationsIteratorTest.java index d8ac2b39d2b4d..a21cb6c87ee39 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/test/VariationsIteratorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/test/VariationsIteratorTest.java @@ -20,16 +20,20 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; import org.apache.ignite.testframework.configvariations.VariationsIterator; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * Test start iterator. */ -public class VariationsIteratorTest extends TestCase { +public class VariationsIteratorTest { /** * @throws Exception If failed. */ + @Test public void test1() throws Exception { Object[][] arr = new Object[][] { {0, 1}, @@ -43,7 +47,7 @@ public void test1() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("PointlessArithmeticExpression") + @Test public void test2() throws Exception { Object[][] arr = new Object[][] { {0}, @@ -58,7 +62,7 @@ public void test2() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("PointlessArithmeticExpression") + @Test public void test3() throws Exception { Object[][] arr = new Object[][] { {0, 1, 2, 3, 4, 5}, @@ -73,7 +77,7 @@ public void test3() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("PointlessArithmeticExpression") + @Test public void test4() throws Exception { Object[][] arr = new Object[][]{ {0,1,2}, @@ -91,6 +95,7 @@ public void test4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimple() throws Exception { Object[][] arr = new Object[][] { {0}, @@ -102,6 +107,7 @@ public void testSimple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimple2() throws Exception { Object[][] arr = new Object[][] { {0}, diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java index ac2bed36d3a58..b5e841892d778 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java @@ -18,6 +18,7 @@ package org.apache.ignite.testsuites; import java.util.Set; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.GridSuppressedExceptionSelfTest; import org.apache.ignite.failure.FailureHandlerTriggeredTest; @@ -42,6 +43,7 @@ import org.apache.ignite.internal.IgniteSlowClientDetectionSelfTest; import org.apache.ignite.internal.MarshallerContextLockingSelfTest; import org.apache.ignite.internal.TransactionsMXBeanImplTest; +import org.apache.ignite.internal.managers.IgniteDiagnosticMessagesMultipleConnectionsTest; import org.apache.ignite.internal.managers.IgniteDiagnosticMessagesTest; import org.apache.ignite.internal.processors.affinity.GridAffinityProcessorMemoryLeakTest; import org.apache.ignite.internal.processors.affinity.GridAffinityProcessorRendezvousSelfTest; @@ -85,33 +87,32 @@ import org.apache.ignite.spi.GridSpiLocalHostInjectionTest; import org.apache.ignite.startup.properties.NotStringSystemPropertyTest; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.GridAbstractTest; import org.apache.ignite.testframework.test.ConfigVariationsTestSuiteBuilderTest; +import org.apache.ignite.testframework.test.ListeningTestLoggerTest; import org.apache.ignite.testframework.test.ParametersTest; import org.apache.ignite.testframework.test.VariationsIteratorTest; import org.apache.ignite.util.AttributeNodeFilterSelfTest; import org.jetbrains.annotations.Nullable; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Basic test suite. */ -public class IgniteBasicTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteBasicTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** * @param ignoredTests Tests don't include in the execution. Providing null means nothing to exclude. * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite(@Nullable final Set ignoredTests) throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); - + public static TestSuite suite(@Nullable final Set ignoredTests) { TestSuite suite = new TestSuite("Ignite Basic Test Suite"); suite.addTest(IgniteMarshallerSelfTestSuite.suite(ignoredTests)); @@ -127,95 +128,98 @@ public static TestSuite suite(@Nullable final Set ignoredTests) throws Ex suite.addTest(IgnitePlatformsTestSuite.suite()); - suite.addTest(new TestSuite(GridSelfTest.class)); - suite.addTest(new TestSuite(ClusterGroupHostsSelfTest.class)); - suite.addTest(new TestSuite(IgniteMessagingWithClientTest.class)); - suite.addTest(new TestSuite(IgniteMessagingSendAsyncTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClusterGroupHostsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteMessagingWithClientTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteMessagingSendAsyncTest.class)); GridTestUtils.addTestIfNeeded(suite, ClusterGroupSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, GridMessagingSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, GridMessagingNoPeerClassLoadingSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, GridReleaseTypeSelfTest.class, ignoredTests); - suite.addTestSuite(GridProductVersionSelfTest.class); - suite.addTestSuite(GridAffinityProcessorRendezvousSelfTest.class); - suite.addTestSuite(GridAffinityProcessorMemoryLeakTest.class); - suite.addTestSuite(GridClosureProcessorSelfTest.class); - suite.addTestSuite(GridClosureProcessorRemoteTest.class); - suite.addTestSuite(GridClosureSerializationTest.class); - suite.addTestSuite(ClosureServiceClientsNodesTest.class); - suite.addTestSuite(GridStartStopSelfTest.class); - suite.addTestSuite(GridProjectionForCachesSelfTest.class); - suite.addTestSuite(GridProjectionForCachesOnDaemonNodeSelfTest.class); - suite.addTestSuite(GridSpiLocalHostInjectionTest.class); - suite.addTestSuite(GridLifecycleBeanSelfTest.class); - suite.addTestSuite(GridStopWithCancelSelfTest.class); - suite.addTestSuite(GridReduceSelfTest.class); - suite.addTestSuite(GridEventConsumeSelfTest.class); - suite.addTestSuite(GridSuppressedExceptionSelfTest.class); - suite.addTestSuite(GridLifecycleAwareSelfTest.class); - suite.addTestSuite(GridMessageListenSelfTest.class); - suite.addTestSuite(GridFailFastNodeFailureDetectionSelfTest.class); - suite.addTestSuite(IgniteSlowClientDetectionSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridProductVersionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAffinityProcessorRendezvousSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAffinityProcessorMemoryLeakTest.class)); + suite.addTest(new JUnit4TestAdapter(GridClosureProcessorSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridClosureProcessorRemoteTest.class)); + suite.addTest(new JUnit4TestAdapter(GridClosureSerializationTest.class)); + suite.addTest(new JUnit4TestAdapter(ClosureServiceClientsNodesTest.class)); + suite.addTest(new JUnit4TestAdapter(GridStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridProjectionForCachesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridProjectionForCachesOnDaemonNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSpiLocalHostInjectionTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLifecycleBeanSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridStopWithCancelSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridReduceSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridEventConsumeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSuppressedExceptionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLifecycleAwareSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMessageListenSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFailFastNodeFailureDetectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSlowClientDetectionSelfTest.class)); GridTestUtils.addTestIfNeeded(suite, IgniteDaemonNodeMarshallerCacheTest.class, ignoredTests); - suite.addTestSuite(IgniteMarshallerCacheConcurrentReadWriteTest.class); - suite.addTestSuite(GridNodeMetricsLogSelfTest.class); - suite.addTestSuite(GridLocalIgniteSerializationTest.class); - suite.addTestSuite(GridMBeansTest.class); - suite.addTestSuite(TransactionsMXBeanImplTest.class); - suite.addTestSuite(SetTxTimeoutOnPartitionMapExchangeTest.class); - - suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class); - suite.addTestSuite(IgniteLocalNodeMapBeforeStartTest.class); - suite.addTestSuite(OdbcConfigurationValidationSelfTest.class); - suite.addTestSuite(OdbcEscapeSequenceSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteMarshallerCacheConcurrentReadWriteTest.class)); + suite.addTest(new JUnit4TestAdapter(GridNodeMetricsLogSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLocalIgniteSerializationTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMBeansTest.class)); + suite.addTest(new JUnit4TestAdapter(TransactionsMXBeanImplTest.class)); + suite.addTest(new JUnit4TestAdapter(SetTxTimeoutOnPartitionMapExchangeTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteExceptionInNioWorkerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteLocalNodeMapBeforeStartTest.class)); + suite.addTest(new JUnit4TestAdapter(OdbcConfigurationValidationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(OdbcEscapeSequenceSelfTest.class)); GridTestUtils.addTestIfNeeded(suite, DynamicProxySerializationMultiJvmSelfTest.class, ignoredTests); // Tests against configuration variations framework. - suite.addTestSuite(ParametersTest.class); - suite.addTestSuite(VariationsIteratorTest.class); - suite.addTestSuite(ConfigVariationsTestSuiteBuilderTest.class); - suite.addTestSuite(NotStringSystemPropertyTest.class); + suite.addTest(new JUnit4TestAdapter(ParametersTest.class)); + suite.addTest(new JUnit4TestAdapter(VariationsIteratorTest.class)); + suite.addTest(new JUnit4TestAdapter(ConfigVariationsTestSuiteBuilderTest.class)); + suite.addTest(new JUnit4TestAdapter(NotStringSystemPropertyTest.class)); - suite.addTestSuite(MarshallerContextLockingSelfTest.class); - suite.addTestSuite(MarshallerContextSelfTest.class); + suite.addTest(new JUnit4TestAdapter(MarshallerContextLockingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(MarshallerContextSelfTest.class)); - suite.addTestSuite(SecurityPermissionSetBuilderTest.class); + suite.addTest(new JUnit4TestAdapter(SecurityPermissionSetBuilderTest.class)); - suite.addTestSuite(AttributeNodeFilterSelfTest.class); + suite.addTest(new JUnit4TestAdapter(AttributeNodeFilterSelfTest.class)); // Basic DB data structures. - suite.addTestSuite(BPlusTreeSelfTest.class); - suite.addTestSuite(BPlusTreeFakeReuseSelfTest.class); - suite.addTestSuite(BPlusTreeReuseSelfTest.class); - suite.addTestSuite(IndexStorageSelfTest.class); - suite.addTestSuite(CacheFreeListImplSelfTest.class); - suite.addTestSuite(DataRegionMetricsSelfTest.class); - suite.addTestSuite(SwapPathConstructionSelfTest.class); + suite.addTest(new JUnit4TestAdapter(BPlusTreeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BPlusTreeFakeReuseSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BPlusTreeReuseSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IndexStorageSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheFreeListImplSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DataRegionMetricsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SwapPathConstructionSelfTest.class)); - suite.addTestSuite(IgniteMarshallerCacheFSRestoreTest.class); - suite.addTestSuite(IgniteMarshallerCacheClassNameConflictTest.class); - suite.addTestSuite(IgniteMarshallerCacheClientRequestsMappingOnMissTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteMarshallerCacheFSRestoreTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteMarshallerCacheClassNameConflictTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteMarshallerCacheClientRequestsMappingOnMissTest.class)); - suite.addTestSuite(IgniteDiagnosticMessagesTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteDiagnosticMessagesTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDiagnosticMessagesMultipleConnectionsTest.class)); - suite.addTestSuite(IgniteRejectConnectOnNodeStopTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteRejectConnectOnNodeStopTest.class)); - suite.addTestSuite(GridCleanerTest.class); + suite.addTest(new JUnit4TestAdapter(GridCleanerTest.class)); - suite.addTestSuite(ClassSetTest.class); + suite.addTest(new JUnit4TestAdapter(ClassSetTest.class)); // Basic failure handlers. - suite.addTestSuite(FailureHandlerTriggeredTest.class); - suite.addTestSuite(StopNodeFailureHandlerTest.class); - suite.addTestSuite(StopNodeOrHaltFailureHandlerTest.class); - suite.addTestSuite(OomFailureHandlerTest.class); - suite.addTestSuite(TransactionIntegrityWithSystemWorkerDeathTest.class); + suite.addTest(new JUnit4TestAdapter(FailureHandlerTriggeredTest.class)); + suite.addTest(new JUnit4TestAdapter(StopNodeFailureHandlerTest.class)); + suite.addTest(new JUnit4TestAdapter(StopNodeOrHaltFailureHandlerTest.class)); + suite.addTest(new JUnit4TestAdapter(OomFailureHandlerTest.class)); + suite.addTest(new JUnit4TestAdapter(TransactionIntegrityWithSystemWorkerDeathTest.class)); + + suite.addTest(new JUnit4TestAdapter(AtomicOperationsInTxTest.class)); - suite.addTestSuite(AtomicOperationsInTxTest.class); + suite.addTest(new JUnit4TestAdapter(CacheRebalanceConfigValidationTest.class)); - suite.addTestSuite(CacheRebalanceConfigValidationTest.class); + suite.addTest(new JUnit4TestAdapter(ListeningTestLoggerTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java index 68085db0e25b7..54a60ddf9b728 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java @@ -18,11 +18,15 @@ package org.apache.ignite.testsuites; import java.util.Set; + +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.failure.FailureHandlingConfigurationTest; import org.apache.ignite.failure.IoomFailureHandlerTest; +import org.apache.ignite.failure.SystemWorkersBlockingTest; import org.apache.ignite.failure.SystemWorkersTerminationTest; import org.apache.ignite.internal.ClusterBaselineNodesMetricsSelfTest; +import org.apache.ignite.internal.GridNodeMetricsLogPdsSelfTest; import org.apache.ignite.internal.encryption.EncryptedCacheBigEntryTest; import org.apache.ignite.internal.encryption.EncryptedCacheCreateTest; import org.apache.ignite.internal.encryption.EncryptedCacheDestroyTest; @@ -30,54 +34,59 @@ import org.apache.ignite.internal.encryption.EncryptedCacheNodeJoinTest; import org.apache.ignite.internal.encryption.EncryptedCachePreconfiguredRestartTest; import org.apache.ignite.internal.encryption.EncryptedCacheRestartTest; -import org.apache.ignite.internal.GridNodeMetricsLogPdsSelfTest; +import org.apache.ignite.internal.processors.cache.persistence.CheckpointReadLockFailureTest; import org.apache.ignite.internal.processors.service.ServiceDeploymentOnActivationTest; import org.apache.ignite.internal.processors.service.ServiceDeploymentOutsideBaselineTest; import org.apache.ignite.marshaller.GridMarshallerMappingConsistencyTest; +import org.apache.ignite.util.GridCommandHandlerSslTest; import org.apache.ignite.util.GridCommandHandlerTest; import org.apache.ignite.util.GridInternalTaskUnusedWalSegmentsTest; import org.jetbrains.annotations.Nullable; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Basic test suite. */ +@RunWith(AllTests.class) public class IgniteBasicWithPersistenceTestSuite extends TestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** * @param ignoredTests Tests don't include in the execution. Providing null means nothing to exclude. * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite(@Nullable final Set ignoredTests) throws Exception { + public static TestSuite suite(@Nullable final Set ignoredTests) { TestSuite suite = new TestSuite("Ignite Basic With Persistence Test Suite"); - suite.addTestSuite(IoomFailureHandlerTest.class); - suite.addTestSuite(ClusterBaselineNodesMetricsSelfTest.class); - suite.addTestSuite(ServiceDeploymentOnActivationTest.class); - suite.addTestSuite(ServiceDeploymentOutsideBaselineTest.class); - suite.addTestSuite(GridMarshallerMappingConsistencyTest.class); - suite.addTestSuite(SystemWorkersTerminationTest.class); - suite.addTestSuite(FailureHandlingConfigurationTest.class); + suite.addTest(new JUnit4TestAdapter(IoomFailureHandlerTest.class)); + suite.addTest(new JUnit4TestAdapter(ClusterBaselineNodesMetricsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentOnActivationTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceDeploymentOutsideBaselineTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMarshallerMappingConsistencyTest.class)); + suite.addTest(new JUnit4TestAdapter(SystemWorkersTerminationTest.class)); + suite.addTest(new JUnit4TestAdapter(FailureHandlingConfigurationTest.class)); + suite.addTest(new JUnit4TestAdapter(SystemWorkersBlockingTest.class)); + suite.addTest(new JUnit4TestAdapter(CheckpointReadLockFailureTest.class)); - suite.addTestSuite(GridCommandHandlerTest.class); - suite.addTestSuite(GridInternalTaskUnusedWalSegmentsTest.class); + suite.addTest(new JUnit4TestAdapter(GridCommandHandlerTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCommandHandlerSslTest.class)); + suite.addTest(new JUnit4TestAdapter(GridInternalTaskUnusedWalSegmentsTest.class)); - suite.addTestSuite(GridNodeMetricsLogPdsSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridNodeMetricsLogPdsSelfTest.class)); - suite.addTestSuite(EncryptedCacheBigEntryTest.class); - suite.addTestSuite(EncryptedCacheCreateTest.class); - suite.addTestSuite(EncryptedCacheDestroyTest.class); - suite.addTestSuite(EncryptedCacheGroupCreateTest.class); - suite.addTestSuite(EncryptedCacheNodeJoinTest.class); - suite.addTestSuite(EncryptedCacheRestartTest.class); - suite.addTestSuite(EncryptedCachePreconfiguredRestartTest.class); + suite.addTest(new JUnit4TestAdapter(EncryptedCacheBigEntryTest.class)); + suite.addTest(new JUnit4TestAdapter(EncryptedCacheCreateTest.class)); + suite.addTest(new JUnit4TestAdapter(EncryptedCacheDestroyTest.class)); + suite.addTest(new JUnit4TestAdapter(EncryptedCacheGroupCreateTest.class)); + suite.addTest(new JUnit4TestAdapter(EncryptedCacheNodeJoinTest.class)); + suite.addTest(new JUnit4TestAdapter(EncryptedCacheRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(EncryptedCachePreconfiguredRestartTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheTestSuite.java index 170bb33c9ba41..195771a0e3b11 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheTestSuite.java @@ -17,15 +17,16 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import java.util.HashSet; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheEntryMemorySizeSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheMvccSelfTest; import org.apache.ignite.internal.processors.cache.binary.CacheKeepBinaryWithInterceptorTest; -import org.apache.ignite.internal.processors.cache.expiry.IgniteCacheAtomicLocalExpiryPolicyTest; import org.apache.ignite.internal.processors.cache.binary.GridBinaryCacheEntryMemorySizeSelfTest; import org.apache.ignite.internal.processors.cache.binary.datastreaming.DataStreamProcessorBinarySelfTest; +import org.apache.ignite.internal.processors.cache.binary.datastreaming.DataStreamProcessorPersistenceBinarySelfTest; import org.apache.ignite.internal.processors.cache.binary.datastreaming.GridDataStreamerImplSelfTest; import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheAffinityRoutingBinarySelfTest; import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheAtomicPartitionedOnlyBinaryDataStreamerMultiNodeSelfTest; @@ -34,23 +35,31 @@ import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheAtomicPartitionedOnlyBinaryMultithreadedSelfTest; import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinariesNearPartitionedByteArrayValuesSelfTest; import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinariesPartitionedOnlyByteArrayValuesSelfTest; -import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSelfTest; +import org.apache.ignite.internal.processors.cache.expiry.IgniteCacheAtomicLocalExpiryPolicyTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Cache suite with binary marshaller. */ -public class IgniteBinaryCacheTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteBinaryCacheTestSuite { /** * @return Suite. - * @throws Exception In case of error. */ - public static TestSuite suite() throws Exception { - TestSuite suite = new TestSuite("Binary Cache Test Suite"); + public static TestSuite suite() { + return suite(new HashSet<>()); + } - HashSet ignoredTests = new HashSet<>(); + /** + * @param ignoredTests Tests to ignore. + * @return Test suite. + */ + public static TestSuite suite(Collection ignoredTests) { + TestSuite suite = new TestSuite("Binary Cache Test Suite"); // Tests below have a special version for Binary Marshaller - ignoredTests.add(DataStreamProcessorSelfTest.class); ignoredTests.add(GridCacheAffinityRoutingSelfTest.class); ignoredTests.add(IgniteCacheAtomicLocalExpiryPolicyTest.class); ignoredTests.add(GridCacheEntryMemorySizeSelfTest.class); @@ -60,23 +69,21 @@ public static TestSuite suite() throws Exception { suite.addTest(IgniteCacheTestSuite.suite(ignoredTests)); - // TODO GG-11148 - // suite.addTestSuite(GridCacheMemoryModeBinarySelfTest.class); - - suite.addTestSuite(GridCacheBinariesPartitionedOnlyByteArrayValuesSelfTest.class); - suite.addTestSuite(GridCacheBinariesNearPartitionedByteArrayValuesSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheBinariesPartitionedOnlyByteArrayValuesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheBinariesNearPartitionedByteArrayValuesSelfTest.class, ignoredTests); - suite.addTestSuite(GridDataStreamerImplSelfTest.class); - suite.addTestSuite(DataStreamProcessorBinarySelfTest.class); - suite.addTestSuite(GridCacheAtomicPartitionedOnlyBinaryDataStreamerMultiNodeSelfTest.class); - suite.addTestSuite(GridCacheAtomicPartitionedOnlyBinaryDataStreamerMultithreadedSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, GridDataStreamerImplSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, DataStreamProcessorBinarySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, DataStreamProcessorPersistenceBinarySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicPartitionedOnlyBinaryDataStreamerMultiNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicPartitionedOnlyBinaryDataStreamerMultithreadedSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheAtomicPartitionedOnlyBinaryMultiNodeSelfTest.class); - suite.addTestSuite(GridCacheAtomicPartitionedOnlyBinaryMultithreadedSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicPartitionedOnlyBinaryMultiNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicPartitionedOnlyBinaryMultithreadedSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheAffinityRoutingBinarySelfTest.class); - suite.addTestSuite(GridBinaryCacheEntryMemorySizeSelfTest.class); - suite.addTestSuite(CacheKeepBinaryWithInterceptorTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheAffinityRoutingBinarySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridBinaryCacheEntryMemorySizeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheKeepBinaryWithInterceptorTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsCacheTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsCacheTestSuite3.java index 0007813ac92c3..1b77812d828e9 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsCacheTestSuite3.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsCacheTestSuite3.java @@ -17,10 +17,14 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest; import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryTransactionalEntryProcessorDeploymentSelfTest; +import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.config.GridTestProperties; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * IgniteBinaryObjectsCacheTestSuite3 is kept together with {@link IgniteCacheTestSuite3} @@ -38,19 +42,27 @@ * In future this suite may be merged with {@link IgniteCacheTestSuite3} * */ +@RunWith(AllTests.class) public class IgniteBinaryObjectsCacheTestSuite3 { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { + return suite(null); + } + + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { GridTestProperties.setProperty(GridTestProperties.ENTRY_PROCESSOR_CLASS_NAME, "org.apache.ignite.tests.p2p.CacheDeploymentBinaryEntryProcessor"); - TestSuite suite = IgniteCacheTestSuite3.suite(); + TestSuite suite = IgniteCacheTestSuite3.suite(ignoredTests); - suite.addTestSuite(GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.class); - suite.addTestSuite(GridCacheBinaryTransactionalEntryProcessorDeploymentSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheBinaryTransactionalEntryProcessorDeploymentSelfTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsComputeGridTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsComputeGridTestSuite.java index 4820d455683f5..84d0461f3d840 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsComputeGridTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsComputeGridTestSuite.java @@ -17,9 +17,9 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.GridComputationBinarylizableClosuresSelfTest; -import org.apache.ignite.testframework.junits.GridAbstractTest; /** * @@ -30,11 +30,9 @@ public class IgniteBinaryObjectsComputeGridTestSuite { * @throws Exception If failed. */ public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); - TestSuite suite = IgniteComputeGridTestSuite.suite(); - suite.addTestSuite(GridComputationBinarylizableClosuresSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridComputationBinarylizableClosuresSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java index c7d87444f5317..761c1f8670379 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.binary.BinaryArrayIdentityResolverSelfTest; import org.apache.ignite.internal.binary.BinaryBasicIdMapperSelfTest; @@ -78,91 +79,93 @@ import org.apache.ignite.internal.processors.cache.binary.local.GridCacheBinaryObjectsLocalOnheapSelfTest; import org.apache.ignite.internal.processors.cache.binary.local.GridCacheBinaryObjectsLocalSelfTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteBinaryMetadataUpdateChangingTopologySelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test for binary objects stored in cache. */ -public class IgniteBinaryObjectsTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteBinaryObjectsTestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Binary Objects Test Suite"); - suite.addTestSuite(BinarySimpleNameTestPropertySelfTest.class); - - suite.addTestSuite(BinaryBasicIdMapperSelfTest.class); - suite.addTestSuite(BinaryBasicNameMapperSelfTest.class); - - suite.addTestSuite(BinaryTreeSelfTest.class); - suite.addTestSuite(BinaryMarshallerSelfTest.class); - suite.addTestSuite(BinaryObjectExceptionSelfTest.class); - - suite.addTestSuite(BinarySerialiedFieldComparatorSelfTest.class); - suite.addTestSuite(BinaryArrayIdentityResolverSelfTest.class); - - suite.addTestSuite(BinaryConfigurationConsistencySelfTest.class); - suite.addTestSuite(BinaryConfigurationCustomSerializerSelfTest.class); - suite.addTestSuite(GridBinaryMarshallerCtxDisabledSelfTest.class); - suite.addTestSuite(BinaryObjectBuilderDefaultMappersSelfTest.class); - suite.addTestSuite(BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.class); - suite.addTestSuite(BinaryObjectBuilderAdditionalSelfTest.class); - //suite.addTestSuite(BinaryFieldExtractionSelfTest.class); - suite.addTestSuite(BinaryFieldsHeapSelfTest.class); - suite.addTestSuite(BinaryFieldsOffheapSelfTest.class); - suite.addTestSuite(BinaryFooterOffsetsHeapSelfTest.class); - suite.addTestSuite(BinaryFooterOffsetsOffheapSelfTest.class); - suite.addTestSuite(BinaryEnumsSelfTest.class); - suite.addTestSuite(GridDefaultBinaryMappersBinaryMetaDataSelfTest.class); - suite.addTestSuite(GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.class); - suite.addTestSuite(GridBinaryAffinityKeySelfTest.class); - suite.addTestSuite(GridBinaryWildcardsSelfTest.class); - suite.addTestSuite(BinaryObjectToStringSelfTest.class); - suite.addTestSuite(BinaryObjectTypeCompatibilityTest.class); + suite.addTest(new JUnit4TestAdapter(BinarySimpleNameTestPropertySelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(BinaryBasicIdMapperSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryBasicNameMapperSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(BinaryTreeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryMarshallerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryObjectExceptionSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(BinarySerialiedFieldComparatorSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryArrayIdentityResolverSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(BinaryConfigurationConsistencySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryConfigurationCustomSerializerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridBinaryMarshallerCtxDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryObjectBuilderDefaultMappersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryObjectBuilderAdditionalSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(BinaryFieldExtractionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryFieldsHeapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryFieldsOffheapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryFooterOffsetsHeapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryFooterOffsetsOffheapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryEnumsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridDefaultBinaryMappersBinaryMetaDataSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridBinaryAffinityKeySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridBinaryWildcardsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryObjectToStringSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryObjectTypeCompatibilityTest.class)); // Tests for objects with non-compact footers. - suite.addTestSuite(BinaryMarshallerNonCompactSelfTest.class); - suite.addTestSuite(BinaryObjectBuilderNonCompactDefaultMappersSelfTest.class); - suite.addTestSuite(BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.class); - suite.addTestSuite(BinaryObjectBuilderAdditionalNonCompactSelfTest.class); - suite.addTestSuite(BinaryFieldsHeapNonCompactSelfTest.class); - suite.addTestSuite(BinaryFieldsOffheapNonCompactSelfTest.class); - suite.addTestSuite(BinaryFooterOffsetsHeapNonCompactSelfTest.class); - suite.addTestSuite(BinaryFooterOffsetsOffheapNonCompactSelfTest.class); - - suite.addTestSuite(GridCacheBinaryObjectsLocalSelfTest.class); - //suite.addTestSuite(GridCacheBinaryObjectsLocalOnheapSelfTest.class); - suite.addTestSuite(GridCacheBinaryObjectsAtomicLocalSelfTest.class); - suite.addTestSuite(GridCacheBinaryObjectsReplicatedSelfTest.class); - suite.addTestSuite(GridCacheBinaryObjectsPartitionedSelfTest.class); - suite.addTestSuite(GridCacheBinaryObjectsPartitionedNearDisabledSelfTest.class); - //suite.addTestSuite(GridCacheBinaryObjectsPartitionedNearDisabledOnheapSelfTest.class); - //suite.addTestSuite(GridCacheBinaryObjectsPartitionedOnheapSelfTest.class); - suite.addTestSuite(GridCacheBinaryObjectsAtomicSelfTest.class); - //suite.addTestSuite(GridCacheBinaryObjectsAtomicOnheapSelfTest.class); - suite.addTestSuite(GridCacheBinaryObjectsAtomicNearDisabledSelfTest.class); - //suite.addTestSuite(GridCacheBinaryObjectsAtomicNearDisabledOnheapSelfTest.class); - - suite.addTestSuite(GridCacheBinaryStoreObjectsSelfTest.class); - suite.addTestSuite(GridCacheBinaryStoreBinariesDefaultMappersSelfTest.class); - suite.addTestSuite(GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.class); - - suite.addTestSuite(GridCacheClientNodeBinaryObjectMetadataTest.class); - suite.addTestSuite(GridCacheBinaryObjectMetadataExchangeMultinodeTest.class); - suite.addTestSuite(BinaryMetadataUpdatesFlowTest.class); - suite.addTestSuite(GridCacheClientNodeBinaryObjectMetadataMultinodeTest.class); - suite.addTestSuite(IgniteBinaryMetadataUpdateChangingTopologySelfTest.class); - - suite.addTestSuite(BinaryTxCacheLocalEntriesSelfTest.class); - suite.addTestSuite(BinaryAtomicCacheLocalEntriesSelfTest.class); + suite.addTest(new JUnit4TestAdapter(BinaryMarshallerNonCompactSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryObjectBuilderNonCompactDefaultMappersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryObjectBuilderAdditionalNonCompactSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryFieldsHeapNonCompactSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryFieldsOffheapNonCompactSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryFooterOffsetsHeapNonCompactSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryFooterOffsetsOffheapNonCompactSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsLocalSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsLocalOnheapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsAtomicLocalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsPartitionedNearDisabledSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsPartitionedNearDisabledOnheapSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsPartitionedOnheapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsAtomicSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsAtomicOnheapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsAtomicNearDisabledSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectsAtomicNearDisabledOnheapSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryStoreObjectsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryStoreBinariesDefaultMappersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheClientNodeBinaryObjectMetadataTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectMetadataExchangeMultinodeTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryMetadataUpdatesFlowTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheClientNodeBinaryObjectMetadataMultinodeTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteBinaryMetadataUpdateChangingTopologySelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(BinaryTxCacheLocalEntriesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryAtomicCacheLocalEntriesSelfTest.class)); // Byte order - suite.addTestSuite(BinaryHeapStreamByteOrderSelfTest.class); - suite.addTestSuite(BinaryAbstractOutputStreamTest.class); - suite.addTestSuite(BinaryOffheapStreamByteOrderSelfTest.class); + suite.addTest(new JUnit4TestAdapter(BinaryHeapStreamByteOrderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryAbstractOutputStreamTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryOffheapStreamByteOrderSelfTest.class)); - suite.addTestSuite(GridCacheBinaryObjectUserClassloaderSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheBinaryObjectUserClassloaderSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java index 318f87ec07d28..69d3b60e33881 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java @@ -21,11 +21,14 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.cache.IgniteMarshallerCacheClassNameConflictTest; import org.apache.ignite.testframework.config.GridTestProperties; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Basic test suite. */ -public class IgniteBinarySimpleNameMapperBasicTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteBinarySimpleNameMapperBasicTestSuite { /** * @return Test suite. * @throws Exception Thrown in case of the failure. diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java index bbf4297af8b46..dc362b8726701 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java @@ -20,16 +20,18 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.testframework.config.GridTestProperties; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Cache full API suite with binary marshaller and simple name mapper. */ -public class IgniteBinarySimpleNameMapperCacheFullApiTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteBinarySimpleNameMapperCacheFullApiTestSuite { /** * @return Suite. - * @throws Exception In case of error. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true"); diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBasicConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBasicConfigVariationsFullApiTestSuite.java index 85a8f59ad5184..af7b42612642f 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBasicConfigVariationsFullApiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBasicConfigVariationsFullApiTestSuite.java @@ -20,16 +20,18 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.IgniteCacheConfigVariationsFullApiTest; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cache API. */ -public class IgniteCacheBasicConfigVariationsFullApiTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheBasicConfigVariationsFullApiTestSuite { /** * @return Cache API test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return new ConfigVariationsTestSuiteBuilder( "Cache New Full API Test Suite", IgniteCacheConfigVariationsFullApiTest.class) diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBlockExchangeOnReadOperationsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBlockExchangeOnReadOperationsTestSuite.java new file mode 100644 index 0000000000000..a7c839c7859da --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBlockExchangeOnReadOperationsTestSuite.java @@ -0,0 +1,54 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.Set; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.internal.processors.cache.distributed.CacheBlockOnGetAllTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheBlockOnScanTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheBlockOnSingleGetTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * Test suite. + */ +@RunWith(AllTests.class) +public class IgniteCacheBlockExchangeOnReadOperationsTestSuite { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + return suite(null); + } + + /** + * @param ignoredTests Tests to ignore. + * @return Test suite. + */ + public static TestSuite suite(Set ignoredTests) { + TestSuite suite = new TestSuite("Do Not Block Read Operations Test Suite"); + + suite.addTest(new JUnit4TestAdapter(CacheBlockOnSingleGetTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheBlockOnGetAllTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheBlockOnScanTest.class)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java index 6bbf0fe652baf..184e85dd18ef4 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheDataStructuresSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.AtomicCacheAffinityConfigurationTest; import org.apache.ignite.internal.processors.cache.datastructures.GridCacheQueueCleanupSelfTest; @@ -26,7 +27,6 @@ import org.apache.ignite.internal.processors.cache.datastructures.IgniteClientDiscoveryDataStructuresTest; import org.apache.ignite.internal.processors.cache.datastructures.IgniteDataStructureUniqueNameTest; import org.apache.ignite.internal.processors.cache.datastructures.IgniteDataStructureWithJobTest; -import org.apache.ignite.internal.processors.cache.datastructures.IgniteDataStructuresNoClassOnServerTest; import org.apache.ignite.internal.processors.cache.datastructures.IgniteSequenceInternalCleanupTest; import org.apache.ignite.internal.processors.cache.datastructures.SemaphoreFailoverNoWaitingAcquirerTest; import org.apache.ignite.internal.processors.cache.datastructures.SemaphoreFailoverSafeReleasePermitsTest; @@ -45,7 +45,6 @@ import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedAtomicQueueMultiNodeSelfTest; import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedAtomicQueueRotativeMultiNodeTest; import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedAtomicReferenceApiSelfTest; -import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedAtomicReferenceMultiNodeTest; import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedAtomicSequenceMultiThreadedTest; import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedAtomicSequenceTxSelfTest; import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedAtomicSetFailoverSelfTest; @@ -70,7 +69,6 @@ import org.apache.ignite.internal.processors.cache.datastructures.partitioned.IgnitePartitionedSemaphoreSelfTest; import org.apache.ignite.internal.processors.cache.datastructures.partitioned.IgnitePartitionedSetNoBackupsSelfTest; import org.apache.ignite.internal.processors.cache.datastructures.replicated.GridCacheReplicatedAtomicReferenceApiSelfTest; -import org.apache.ignite.internal.processors.cache.datastructures.replicated.GridCacheReplicatedAtomicReferenceMultiNodeTest; import org.apache.ignite.internal.processors.cache.datastructures.replicated.GridCacheReplicatedAtomicStampedApiSelfTest; import org.apache.ignite.internal.processors.cache.datastructures.replicated.GridCacheReplicatedDataStructuresFailoverSelfTest; import org.apache.ignite.internal.processors.cache.datastructures.replicated.GridCacheReplicatedQueueApiSelfTest; @@ -84,106 +82,108 @@ import org.apache.ignite.internal.processors.cache.datastructures.replicated.IgniteReplicatedLockSelfTest; import org.apache.ignite.internal.processors.cache.datastructures.replicated.IgniteReplicatedSemaphoreSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheAtomicReplicatedNodeRestartSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cache data structures. */ -public class IgniteCacheDataStructuresSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheDataStructuresSelfTestSuite { /** * @return Cache test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Cache Data Structures Test Suite"); // Data structures. - suite.addTest(new TestSuite(GridCachePartitionedQueueFailoverDataConsistencySelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicQueueFailoverDataConsistencySelfTest.class)); - - suite.addTest(new TestSuite(GridCacheLocalSequenceApiSelfTest.class)); - suite.addTest(new TestSuite(GridCacheLocalSetSelfTest.class)); - suite.addTest(new TestSuite(GridCacheLocalAtomicSetSelfTest.class)); - suite.addTest(new TestSuite(GridCacheLocalQueueApiSelfTest.class)); - suite.addTest(new TestSuite(GridCacheLocalAtomicQueueApiSelfTest.class)); - suite.addTest(new TestSuite(IgniteLocalCountDownLatchSelfTest.class)); - suite.addTest(new TestSuite(IgniteLocalSemaphoreSelfTest.class)); - suite.addTest(new TestSuite(IgniteLocalLockSelfTest.class)); - - suite.addTest(new TestSuite(GridCacheReplicatedSequenceApiSelfTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedSequenceMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedQueueApiSelfTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedQueueMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedQueueRotativeMultiNodeTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedSetSelfTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedDataStructuresFailoverSelfTest.class)); - suite.addTest(new TestSuite(IgniteReplicatedCountDownLatchSelfTest.class)); - suite.addTest(new TestSuite(IgniteReplicatedSemaphoreSelfTest.class)); - suite.addTest(new TestSuite(IgniteReplicatedLockSelfTest.class)); - suite.addTest(new TestSuite(IgniteCacheAtomicReplicatedNodeRestartSelfTest.class)); - - suite.addTest(new TestSuite(GridCachePartitionedSequenceApiSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedSequenceMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedQueueApiSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicQueueApiSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedQueueMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicQueueMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCacheQueueClientDisconnectTest.class)); - - suite.addTest(new TestSuite(GridCachePartitionedQueueCreateMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicQueueCreateMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedSetSelfTest.class)); - suite.addTest(new TestSuite(IgnitePartitionedSetNoBackupsSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicSetSelfTest.class)); - suite.addTest(new TestSuite(IgnitePartitionedCountDownLatchSelfTest.class)); - suite.addTest(new TestSuite(IgniteDataStructureWithJobTest.class)); - suite.addTest(new TestSuite(IgnitePartitionedSemaphoreSelfTest.class)); - suite.addTest(new TestSuite(SemaphoreFailoverSafeReleasePermitsTest.class)); - suite.addTest(new TestSuite(SemaphoreFailoverNoWaitingAcquirerTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedQueueFailoverDataConsistencySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicQueueFailoverDataConsistencySelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheLocalSequenceApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheLocalSetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheLocalAtomicSetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheLocalQueueApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheLocalAtomicQueueApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteLocalCountDownLatchSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteLocalSemaphoreSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteLocalLockSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedSequenceApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedSequenceMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedQueueApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedQueueMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedQueueRotativeMultiNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedSetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedDataStructuresFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteReplicatedCountDownLatchSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteReplicatedSemaphoreSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteReplicatedLockSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicReplicatedNodeRestartSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedSequenceApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedSequenceMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedQueueApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicQueueApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedQueueMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicQueueMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheQueueClientDisconnectTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedQueueCreateMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicQueueCreateMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedSetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePartitionedSetNoBackupsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicSetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePartitionedCountDownLatchSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDataStructureWithJobTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePartitionedSemaphoreSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SemaphoreFailoverSafeReleasePermitsTest.class)); + suite.addTest(new JUnit4TestAdapter(SemaphoreFailoverNoWaitingAcquirerTest.class)); // TODO IGNITE-3141, enabled when fixed. - // suite.addTest(new TestSuite(IgnitePartitionedLockSelfTest.class)); + // suite.addTest(new JUnit4TestAdapter(IgnitePartitionedLockSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedSetFailoverSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicSetFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedSetFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicSetFailoverSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedQueueRotativeMultiNodeTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicQueueRotativeMultiNodeTest.class)); - suite.addTest(new TestSuite(GridCacheQueueCleanupSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedQueueRotativeMultiNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicQueueRotativeMultiNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheQueueCleanupSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedQueueEntryMoveSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedQueueEntryMoveSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedDataStructuresFailoverSelfTest.class)); - suite.addTest(new TestSuite(GridCacheQueueMultiNodeConsistencySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedDataStructuresFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheQueueMultiNodeConsistencySelfTest.class)); - suite.addTest(new TestSuite(IgniteLocalAtomicLongApiSelfTest.class)); - suite.addTest(new TestSuite(IgnitePartitionedAtomicLongApiSelfTest.class)); - suite.addTest(new TestSuite(IgniteReplicatedAtomicLongApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteLocalAtomicLongApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePartitionedAtomicLongApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteReplicatedAtomicLongApiSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicSequenceMultiThreadedTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicSequenceTxSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicSequenceMultiThreadedTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicSequenceTxSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicStampedApiSelfTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedAtomicStampedApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicStampedApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedAtomicStampedApiSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicReferenceApiSelfTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedAtomicReferenceApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicReferenceApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedAtomicReferenceApiSelfTest.class)); - //suite.addTest(new TestSuite(GridCachePartitionedAtomicReferenceMultiNodeTest.class)); - //suite.addTest(new TestSuite(GridCacheReplicatedAtomicReferenceMultiNodeTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicReferenceMultiNodeTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedAtomicReferenceMultiNodeTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedNodeRestartTxSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedQueueJoinedNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNodeRestartTxSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedQueueJoinedNodeSelfTest.class)); - suite.addTest(new TestSuite(IgniteDataStructureUniqueNameTest.class)); - //suite.addTest(new TestSuite(IgniteDataStructuresNoClassOnServerTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDataStructureUniqueNameTest.class)); + //suite.addTest(new JUnit4TestAdapter(IgniteDataStructuresNoClassOnServerTest.class)); - suite.addTest(new TestSuite(IgniteClientDataStructuresTest.class)); - suite.addTest(new TestSuite(IgniteClientDiscoveryDataStructuresTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientDataStructuresTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientDiscoveryDataStructuresTest.class)); - suite.addTest(new TestSuite(IgnitePartitionedQueueNoBackupsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePartitionedQueueNoBackupsTest.class)); - suite.addTest(new TestSuite(IgniteSequenceInternalCleanupTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSequenceInternalCleanupTest.class)); - suite.addTestSuite(AtomicCacheAffinityConfigurationTest.class); + suite.addTest(new JUnit4TestAdapter(AtomicCacheAffinityConfigurationTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheEvictionSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheEvictionSelfTestSuite.java index ad9658d3593ca..66808900581da 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheEvictionSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheEvictionSelfTestSuite.java @@ -17,10 +17,12 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.GridCachePreloadingEvictionsSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearEvictionSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearEvictionSelfTest; +import org.apache.ignite.internal.processors.cache.eviction.DhtAndNearEvictionTest; import org.apache.ignite.internal.processors.cache.eviction.GridCacheConcurrentEvictionConsistencySelfTest; import org.apache.ignite.internal.processors.cache.eviction.GridCacheConcurrentEvictionsSelfTest; import org.apache.ignite.internal.processors.cache.eviction.GridCacheEmptyEntriesLocalSelfTest; @@ -29,7 +31,6 @@ import org.apache.ignite.internal.processors.cache.eviction.GridCacheEvictionFilterSelfTest; import org.apache.ignite.internal.processors.cache.eviction.GridCacheEvictionLockUnlockSelfTest; import org.apache.ignite.internal.processors.cache.eviction.GridCacheEvictionTouchSelfTest; -import org.apache.ignite.internal.processors.cache.eviction.DhtAndNearEvictionTest; import org.apache.ignite.internal.processors.cache.eviction.fifo.FifoEvictionPolicyFactorySelfTest; import org.apache.ignite.internal.processors.cache.eviction.fifo.FifoEvictionPolicySelfTest; import org.apache.ignite.internal.processors.cache.eviction.lru.LruEvictionPolicyFactorySelfTest; @@ -49,53 +50,57 @@ import org.apache.ignite.internal.processors.cache.eviction.paged.RandomLruPageEvictionWithRebalanceTest; import org.apache.ignite.internal.processors.cache.eviction.sorted.SortedEvictionPolicyFactorySelfTest; import org.apache.ignite.internal.processors.cache.eviction.sorted.SortedEvictionPolicySelfTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cache eviction. */ -public class IgniteCacheEvictionSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheEvictionSelfTestSuite { /** + * @param ignoredTests Ignored tests. * @return Cache eviction test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("Ignite Cache Eviction Test Suite"); - suite.addTest(new TestSuite(FifoEvictionPolicySelfTest.class)); - suite.addTest(new TestSuite(SortedEvictionPolicySelfTest.class)); - suite.addTest(new TestSuite(LruEvictionPolicySelfTest.class)); - suite.addTest(new TestSuite(FifoEvictionPolicyFactorySelfTest.class)); - suite.addTest(new TestSuite(SortedEvictionPolicyFactorySelfTest.class)); - suite.addTest(new TestSuite(LruEvictionPolicyFactorySelfTest.class)); - suite.addTest(new TestSuite(LruNearEvictionPolicySelfTest.class)); - suite.addTest(new TestSuite(LruNearOnlyNearEvictionPolicySelfTest.class)); - suite.addTest(new TestSuite(GridCacheNearEvictionSelfTest.class)); - suite.addTest(new TestSuite(GridCacheAtomicNearEvictionSelfTest.class)); - suite.addTest(new TestSuite(GridCacheEvictionFilterSelfTest.class)); - suite.addTest(new TestSuite(GridCacheConcurrentEvictionsSelfTest.class)); - suite.addTest(new TestSuite(GridCacheConcurrentEvictionConsistencySelfTest.class)); - suite.addTest(new TestSuite(GridCacheEvictionTouchSelfTest.class)); - suite.addTest(new TestSuite(GridCacheEvictionLockUnlockSelfTest.class)); - suite.addTest(new TestSuite(GridCachePreloadingEvictionsSelfTest.class)); - suite.addTest(new TestSuite(GridCacheEmptyEntriesPartitionedSelfTest.class)); - suite.addTest(new TestSuite(GridCacheEmptyEntriesLocalSelfTest.class)); - suite.addTest(new TestSuite(GridCacheEvictableEntryEqualsSelfTest.class)); + GridTestUtils.addTestIfNeeded(suite, FifoEvictionPolicySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, SortedEvictionPolicySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, LruEvictionPolicySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, FifoEvictionPolicyFactorySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, SortedEvictionPolicyFactorySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, LruEvictionPolicyFactorySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, LruNearEvictionPolicySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, LruNearOnlyNearEvictionPolicySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearEvictionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicNearEvictionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheEvictionFilterSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheConcurrentEvictionsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheConcurrentEvictionConsistencySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheEvictionTouchSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheEvictionLockUnlockSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePreloadingEvictionsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheEmptyEntriesPartitionedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheEmptyEntriesLocalSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheEvictableEntryEqualsSelfTest.class, ignoredTests); - suite.addTest(new TestSuite(RandomLruPageEvictionMultinodeTest.class)); - suite.addTest(new TestSuite(RandomLruNearEnabledPageEvictionMultinodeTest.class)); - suite.addTest(new TestSuite(Random2LruPageEvictionMultinodeTest.class)); - suite.addTest(new TestSuite(Random2LruNearEnabledPageEvictionMultinodeTest.class)); - suite.addTest(new TestSuite(RandomLruPageEvictionWithRebalanceTest.class)); - suite.addTest(new TestSuite(Random2LruPageEvictionWithRebalanceTest.class)); - suite.addTest(new TestSuite(PageEvictionTouchOrderTest.class)); - suite.addTest(new TestSuite(PageEvictionReadThroughTest.class)); - suite.addTest(new TestSuite(PageEvictionDataStreamerTest.class)); + GridTestUtils.addTestIfNeeded(suite, RandomLruPageEvictionMultinodeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, RandomLruNearEnabledPageEvictionMultinodeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, Random2LruPageEvictionMultinodeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, Random2LruNearEnabledPageEvictionMultinodeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, RandomLruPageEvictionWithRebalanceTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, Random2LruPageEvictionWithRebalanceTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, PageEvictionTouchOrderTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, PageEvictionReadThroughTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, PageEvictionDataStreamerTest.class, ignoredTests); - suite.addTest(new TestSuite(PageEvictionMetricTest.class)); + GridTestUtils.addTestIfNeeded(suite, PageEvictionMetricTest.class, ignoredTests); - suite.addTest(new TestSuite(PageEvictionPagesRecyclingAndReusingTest.class)); + GridTestUtils.addTestIfNeeded(suite, PageEvictionPagesRecyclingAndReusingTest.class, ignoredTests); - suite.addTest(new TestSuite(DhtAndNearEvictionTest.class)); + GridTestUtils.addTestIfNeeded(suite, DhtAndNearEvictionTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java index 99dd828246a0c..8baa8fa323aef 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java @@ -18,6 +18,7 @@ package org.apache.ignite.testsuites; import java.util.Set; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.GridCacheIncrementTransformTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheAtomicNodeJoinTest; @@ -40,11 +41,14 @@ import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteChangingBaselineDownCacheRemoveFailoverTest; import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteChangingBaselineUpCacheRemoveFailoverTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheFailoverTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheFailoverTestSuite { /** * @return Ignite Cache Failover test suite. * @throws Exception Thrown in case of the failure. @@ -61,36 +65,36 @@ public static TestSuite suite() throws Exception { public static TestSuite suite(Set ignoredTests) throws Exception { TestSuite suite = new TestSuite("Cache Failover Test Suite"); - suite.addTestSuite(GridCacheAtomicInvalidPartitionHandlingSelfTest.class); - suite.addTestSuite(GridCacheAtomicClientInvalidPartitionHandlingSelfTest.class); - suite.addTestSuite(GridCacheRebalancingPartitionDistributionTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicInvalidPartitionHandlingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicClientInvalidPartitionHandlingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheRebalancingPartitionDistributionTest.class)); GridTestUtils.addTestIfNeeded(suite, GridCacheIncrementTransformTest.class, ignoredTests); // Failure consistency tests. - suite.addTestSuite(GridCacheAtomicRemoveFailureTest.class); - suite.addTestSuite(GridCacheAtomicClientRemoveFailureTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicRemoveFailureTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicClientRemoveFailureTest.class)); - suite.addTestSuite(GridCacheDhtAtomicRemoveFailureTest.class); - suite.addTestSuite(GridCacheDhtRemoveFailureTest.class); - suite.addTestSuite(GridCacheDhtClientRemoveFailureTest.class); - suite.addTestSuite(GridCacheNearRemoveFailureTest.class); - suite.addTestSuite(GridCacheAtomicNearRemoveFailureTest.class); - suite.addTestSuite(IgniteChangingBaselineUpCacheRemoveFailoverTest.class); - suite.addTestSuite(IgniteChangingBaselineDownCacheRemoveFailoverTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheDhtAtomicRemoveFailureTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheDhtRemoveFailureTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheDhtClientRemoveFailureTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheNearRemoveFailureTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicNearRemoveFailureTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteChangingBaselineUpCacheRemoveFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteChangingBaselineDownCacheRemoveFailoverTest.class)); - suite.addTestSuite(IgniteCacheAtomicNodeJoinTest.class); - suite.addTestSuite(IgniteCacheTxNodeJoinTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicNodeJoinTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheTxNodeJoinTest.class)); - suite.addTestSuite(IgniteCacheTxNearDisabledPutGetRestartTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheTxNearDisabledPutGetRestartTest.class)); - suite.addTestSuite(IgniteCacheSizeFailoverTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheSizeFailoverTest.class)); - suite.addTestSuite(IgniteAtomicLongChangingTopologySelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteAtomicLongChangingTopologySelfTest.class)); - suite.addTestSuite(GridCacheTxNodeFailureSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheTxNodeFailureSelfTest.class)); - suite.addTestSuite(AtomicPutAllChangingTopologyTest.class); + suite.addTest(new JUnit4TestAdapter(AtomicPutAllChangingTopologyTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java index 9cb374134e379..ecc6c2590e2a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.CacheGetFromJobTest; import org.apache.ignite.internal.processors.cache.distributed.CacheAsyncOperationsFailoverAtomicTest; @@ -32,41 +33,41 @@ import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedFailoverSelfTest; import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteChangingBaselineDownCachePutAllFailoverTest; import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteChangingBaselineUpCachePutAllFailoverTest; -import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteStableBaselineCachePutAllFailoverTest; -import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteStableBaselineCacheRemoveFailoverTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ +@RunWith(AllTests.class) public class IgniteCacheFailoverTestSuite2 { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache Failover Test Suite2"); - suite.addTestSuite(GridCachePartitionedTxSalvageSelfTest.class); - suite.addTestSuite(CacheGetFromJobTest.class); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedTxSalvageSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheGetFromJobTest.class)); - suite.addTestSuite(GridCacheAtomicFailoverSelfTest.class); - suite.addTestSuite(GridCacheAtomicReplicatedFailoverSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicReplicatedFailoverSelfTest.class)); - suite.addTestSuite(GridCachePartitionedFailoverSelfTest.class); - suite.addTestSuite(GridCacheColocatedFailoverSelfTest.class); - suite.addTestSuite(GridCacheReplicatedFailoverSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheColocatedFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedFailoverSelfTest.class)); - suite.addTestSuite(IgniteCacheCrossCacheTxFailoverTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheCrossCacheTxFailoverTest.class)); - suite.addTestSuite(CacheAsyncOperationsFailoverAtomicTest.class); - suite.addTestSuite(CacheAsyncOperationsFailoverTxTest.class); + suite.addTest(new JUnit4TestAdapter(CacheAsyncOperationsFailoverAtomicTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheAsyncOperationsFailoverTxTest.class)); - suite.addTestSuite(CachePutAllFailoverAtomicTest.class); - suite.addTestSuite(CachePutAllFailoverTxTest.class); - //suite.addTestSuite(IgniteStableBaselineCachePutAllFailoverTest.class); - //suite.addTestSuite(IgniteStableBaselineCacheRemoveFailoverTest.class); - suite.addTestSuite(IgniteChangingBaselineDownCachePutAllFailoverTest.class); - suite.addTestSuite(IgniteChangingBaselineUpCachePutAllFailoverTest.class); + suite.addTest(new JUnit4TestAdapter(CachePutAllFailoverAtomicTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePutAllFailoverTxTest.class)); + //suite.addTest(new JUnit4TestAdapter(IgniteStableBaselineCachePutAllFailoverTest.class)); + //suite.addTest(new JUnit4TestAdapter(IgniteStableBaselineCacheRemoveFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteChangingBaselineDownCachePutAllFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteChangingBaselineUpCachePutAllFailoverTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java index f1cf2676b7531..6c53c8c6ecea4 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite3.java @@ -17,25 +17,28 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.distributed.CacheGetInsideLockChangingTopologyTest; import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryAtomicSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryTransactionalSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheFailoverTestSuite3 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheFailoverTestSuite3 { /** * @return Ignite Cache Failover test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache Failover Test Suite3"); - suite.addTestSuite(IgniteCachePutRetryAtomicSelfTest.class); - suite.addTestSuite(IgniteCachePutRetryTransactionalSelfTest.class); - suite.addTestSuite(CacheGetInsideLockChangingTopologyTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCachePutRetryAtomicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePutRetryTransactionalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheGetInsideLockChangingTopologyTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuiteSsl.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuiteSsl.java index 99a1463deca5b..fafefb5f0bb3e 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuiteSsl.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuiteSsl.java @@ -17,24 +17,27 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.spi.communication.tcp.IgniteCacheSslStartStopSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheFailoverTestSuiteSsl extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheFailoverTestSuiteSsl { /** * @return Ignite Cache Failover test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache Failover Test Suite SSL"); // Disable SSL test with old JDK because of https://bugs.openjdk.java.net/browse/JDK-8013809. if (!IgniteUtils.isHotSpot() || IgniteUtils.isJavaVersionAtLeast("1.7.0_65")) - suite.addTestSuite(IgniteCacheSslStartStopSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheSslStartStopSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiMultiJvmSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiMultiJvmSelfTestSuite.java index daab8c6f2196e..b62e9ba5a341d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiMultiJvmSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiMultiJvmSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.multijvm.GridCacheAtomicClientOnlyMultiJvmFullApiSelfTest; import org.apache.ignite.internal.processors.cache.multijvm.GridCacheAtomicClientOnlyMultiJvmP2PDisabledFullApiSelfTest; @@ -42,52 +43,54 @@ import org.apache.ignite.internal.processors.cache.multijvm.GridCacheReplicatedMultiJvmP2PDisabledFullApiSelfTest; import org.apache.ignite.internal.processors.cache.multijvm.GridCacheReplicatedNearOnlyMultiJvmFullApiSelfTest; import org.apache.ignite.internal.processors.cache.multijvm.GridCacheReplicatedOnheapMultiJvmFullApiSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Multi-JVM test suite. */ -public class IgniteCacheFullApiMultiJvmSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheFullApiMultiJvmSelfTestSuite { /** * @return Multi-JVM tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache Full API Multi Jvm Test Suite"); System.setProperty("H2_JDBC_CONNECTIONS", "500"); // Multi-node. - suite.addTestSuite(GridCacheReplicatedMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedMultiJvmP2PDisabledFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedAtomicMultiJvmFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedMultiJvmP2PDisabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedAtomicMultiJvmFullApiSelfTest.class)); - suite.addTestSuite(GridCachePartitionedMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedCopyOnReadDisabledMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicCopyOnReadDisabledMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedMultiJvmP2PDisabledFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicMultiJvmP2PDisabledFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedCopyOnReadDisabledMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicCopyOnReadDisabledMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMultiJvmP2PDisabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicMultiJvmP2PDisabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicNearEnabledMultiJvmFullApiSelfTest.class)); - suite.addTestSuite(GridCachePartitionedNearDisabledMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledMultiJvmP2PDisabledFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledMultiJvmP2PDisabledFullApiSelfTest.class)); - suite.addTestSuite(GridCacheNearOnlyMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCacheNearOnlyMultiJvmP2PDisabledFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedNearOnlyMultiJvmFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheNearOnlyMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheNearOnlyMultiJvmP2PDisabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedNearOnlyMultiJvmFullApiSelfTest.class)); - suite.addTestSuite(GridCacheAtomicClientOnlyMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicClientOnlyMultiJvmP2PDisabledFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicClientOnlyMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicClientOnlyMultiJvmP2PDisabledFullApiSelfTest.class)); - suite.addTestSuite(GridCacheAtomicNearOnlyMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicNearOnlyMultiJvmP2PDisabledFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicNearOnlyMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicNearOnlyMultiJvmP2PDisabledFullApiSelfTest.class)); - suite.addTestSuite(GridCacheAtomicOnheapMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledAtomicOnheapMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledOnheapMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedOnheapMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedOnheapMultiJvmFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicOnheapMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledAtomicOnheapMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledOnheapMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedOnheapMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedOnheapMultiJvmFullApiSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java index 7d40a6ad4243a..3875475e612f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.GridCacheClearSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAtomicFullApiSelfTest; @@ -78,103 +79,101 @@ import org.apache.ignite.internal.processors.cache.local.GridCacheLocalFullApiMultithreadedSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalFullApiSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalWithGroupFullApiSelfTest; -import org.apache.ignite.internal.processors.cache.persistence.standbycluster.extended.GridActivateExtensionTest; -import org.apache.ignite.testframework.junits.GridAbstractTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cache API. */ -public class IgniteCacheFullApiSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheFullApiSelfTestSuite { /** * @return Cache API test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); - + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache Full API Test Suite"); // One node. - suite.addTestSuite(GridCacheLocalFullApiSelfTest.class); - suite.addTestSuite(GridCacheLocalAtomicFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedFilteredPutSelfTest.class); - suite.addTestSuite(GridCacheReplicatedAtomicFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicNearEnabledFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicOnheapFullApiSelfTest.class); - - suite.addTestSuite(GridCachePartitionedOnheapFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedAtomicOnheapFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledOnheapFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledAtomicOnheapFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheLocalFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheLocalAtomicFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedFilteredPutSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedAtomicFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicNearEnabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicOnheapFullApiSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedOnheapFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicOnheapFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledOnheapFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledAtomicOnheapFullApiSelfTest.class)); // No primary. - suite.addTestSuite(GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearOnlyNoPrimaryFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearOnlyNoPrimaryFullApiSelfTest.class)); // Multi-node. - suite.addTestSuite(GridCacheReplicatedMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedMultiNodeP2PDisabledFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedAtomicMultiNodeFullApiSelfTest.class); - - suite.addTestSuite(GridCachePartitionedMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedCopyOnReadDisabledMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicCopyOnReadDisabledMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedMultiNodeP2PDisabledFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicMultiNodeP2PDisabledFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.class); - suite.addTestSuite(CachePartitionedMultiNodeLongTxTimeoutFullApiTest.class); - suite.addTestSuite(CachePartitionedMultiNodeLongTxTimeout2FullApiTest.class); - suite.addTestSuite(CachePartitionedNearEnabledMultiNodeLongTxTimeoutFullApiTest.class); - - suite.addTestSuite(GridCachePartitionedNearDisabledMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledMultiNodeP2PDisabledFullApiSelfTest.class); - - suite.addTestSuite(GridCacheNearOnlyMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCacheNearOnlyMultiNodeP2PDisabledFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedNearOnlyMultiNodeFullApiSelfTest.class); - - suite.addTestSuite(GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicClientOnlyMultiNodeP2PDisabledFullApiSelfTest.class); - - suite.addTestSuite(GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicNearOnlyMultiNodeP2PDisabledFullApiSelfTest.class); - - suite.addTestSuite(CacheReplicatedRendezvousAffinityExcludeNeighborsMultiNodeFullApiSelfTest.class); - suite.addTestSuite(CacheReplicatedRendezvousAffinityMultiNodeFullApiSelfTest.class); - - suite.addTestSuite(GridCacheNearReloadAllSelfTest.class); - suite.addTestSuite(GridCacheColocatedReloadAllSelfTest.class); - suite.addTestSuite(GridCacheAtomicReloadAllSelfTest.class); - suite.addTestSuite(GridCacheNearTxMultiNodeSelfTest.class); - suite.addTestSuite(GridCachePartitionedMultiNodeCounterSelfTest.class); - - suite.addTestSuite(GridCachePartitionedOnheapMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedAtomicOnheapMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledOnheapMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledAtomicOnheapMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicOnheapMultiNodeFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedMultiNodeP2PDisabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedAtomicMultiNodeFullApiSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedCopyOnReadDisabledMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicCopyOnReadDisabledMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMultiNodeP2PDisabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicMultiNodeP2PDisabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePartitionedMultiNodeLongTxTimeoutFullApiTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePartitionedMultiNodeLongTxTimeout2FullApiTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePartitionedNearEnabledMultiNodeLongTxTimeoutFullApiTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledMultiNodeP2PDisabledFullApiSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheNearOnlyMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheNearOnlyMultiNodeP2PDisabledFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedNearOnlyMultiNodeFullApiSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicClientOnlyMultiNodeP2PDisabledFullApiSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicNearOnlyMultiNodeP2PDisabledFullApiSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(CacheReplicatedRendezvousAffinityExcludeNeighborsMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheReplicatedRendezvousAffinityMultiNodeFullApiSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheNearReloadAllSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheColocatedReloadAllSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicReloadAllSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheNearTxMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMultiNodeCounterSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedOnheapMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicOnheapMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledOnheapMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledAtomicOnheapMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicOnheapMultiNodeFullApiSelfTest.class)); // Multithreaded. - suite.addTestSuite(GridCacheLocalFullApiMultithreadedSelfTest.class); - suite.addTestSuite(GridCacheReplicatedFullApiMultithreadedSelfTest.class); - suite.addTestSuite(GridCachePartitionedFullApiMultithreadedSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheLocalFullApiMultithreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedFullApiMultithreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedFullApiMultithreadedSelfTest.class)); // Other. - suite.addTestSuite(GridCacheClearSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheClearSelfTest.class)); - suite.addTestSuite(GridCacheLocalWithGroupFullApiSelfTest.class); - suite.addTestSuite(GridCacheLocalAtomicWithGroupFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicMultiNodeWithGroupFullApiSelfTest.class); - suite.addTestSuite(GridCacheAtomicNearEnabledMultiNodeWithGroupFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedMultiNodeWithGroupFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledMultiNodeWithGroupFullApiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheLocalWithGroupFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheLocalAtomicWithGroupFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicMultiNodeWithGroupFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicNearEnabledMultiNodeWithGroupFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMultiNodeWithGroupFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledMultiNodeWithGroupFullApiSelfTest.class)); - //suite.addTestSuite(GridActivateExtensionTest.class); + //suite.addTest(new JUnit4TestAdapter(GridActivateExtensionTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheIteratorsSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheIteratorsSelfTestSuite.java index 6fb3b486cb1a5..ee2feeec1cccb 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheIteratorsSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheIteratorsSelfTestSuite.java @@ -17,26 +17,31 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedIteratorsSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedIteratorsSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalIteratorsSelfTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Cache iterators test suite. */ -public class IgniteCacheIteratorsSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheIteratorsSelfTestSuite { /** + * @param ignoredTests Ignored tests. * @return Cache iterators test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("Cache Iterators Test Suite"); - suite.addTest(new TestSuite(GridCacheLocalIteratorsSelfTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedIteratorsSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedIteratorsSelfTest.class)); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalIteratorsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheReplicatedIteratorsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedIteratorsSelfTest.class, ignoredTests); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheLoadConsistencyTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheLoadConsistencyTestSuite.java index cd0be9ce23b4c..ef4423995cea5 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheLoadConsistencyTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheLoadConsistencyTestSuite.java @@ -17,25 +17,28 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.distributed.CacheNearDisabledAtomicInvokeRestartSelfTest; import org.apache.ignite.internal.processors.cache.distributed.CacheNearDisabledTransactionalInvokeRestartSelfTest; import org.apache.ignite.internal.processors.cache.distributed.CacheNearDisabledTransactionalWriteReadRestartSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheLoadConsistencyTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheLoadConsistencyTestSuite { /** * @return Ignite Cache Failover test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache Load Consistency Test Suite"); - suite.addTestSuite(CacheNearDisabledAtomicInvokeRestartSelfTest.class); - suite.addTestSuite(CacheNearDisabledTransactionalInvokeRestartSelfTest.class); - suite.addTestSuite(CacheNearDisabledTransactionalWriteReadRestartSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheNearDisabledAtomicInvokeRestartSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheNearDisabledTransactionalInvokeRestartSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheNearDisabledTransactionalWriteReadRestartSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMetricsSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMetricsSelfTestSuite.java index b6dcb21af8595..88ad48029db8a 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMetricsSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMetricsSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.TransactionMetricsMxBeanImplTest; import org.apache.ignite.internal.processors.cache.CacheGroupsMetricsRebalanceTest; @@ -38,45 +39,49 @@ import org.apache.ignite.internal.processors.cache.local.GridCacheAtomicLocalTckMetricsSelfTestImpl; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalAtomicMetricsNoReadThroughSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalMetricsSelfTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cache metrics. */ -public class IgniteCacheMetricsSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheMetricsSelfTestSuite { /** + * @param ignoredTests Ignored tests. * @return Cache metrics test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("Cache Metrics Test Suite"); - suite.addTestSuite(GridCacheLocalMetricsSelfTest.class); - suite.addTestSuite(GridCacheLocalAtomicMetricsNoReadThroughSelfTest.class); - suite.addTestSuite(GridCacheNearMetricsSelfTest.class); - suite.addTestSuite(GridCacheNearAtomicMetricsSelfTest.class); - suite.addTestSuite(GridCacheReplicatedMetricsSelfTest.class); - suite.addTestSuite(GridCachePartitionedMetricsSelfTest.class); - suite.addTestSuite(GridCachePartitionedHitsAndMissesSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalMetricsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalAtomicMetricsNoReadThroughSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearMetricsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearAtomicMetricsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheReplicatedMetricsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedMetricsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedHitsAndMissesSelfTest.class, ignoredTests); // Atomic cache. - suite.addTestSuite(GridCacheAtomicLocalMetricsSelfTest.class); - suite.addTestSuite(GridCacheAtomicLocalMetricsNoStoreSelfTest.class); - suite.addTestSuite(GridCacheAtomicReplicatedMetricsSelfTest.class); - suite.addTestSuite(GridCacheAtomicPartitionedMetricsSelfTest.class); - suite.addTestSuite(GridCacheAtomicPartitionedTckMetricsSelfTestImpl.class); - suite.addTestSuite(GridCacheAtomicLocalTckMetricsSelfTestImpl.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicLocalMetricsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicLocalMetricsNoStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicReplicatedMetricsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicPartitionedMetricsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicPartitionedTckMetricsSelfTestImpl.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicLocalTckMetricsSelfTestImpl.class, ignoredTests); - suite.addTestSuite(CacheGroupsMetricsRebalanceTest.class); - suite.addTestSuite(CacheValidatorMetricsTest.class); - suite.addTestSuite(CacheMetricsEntitiesCountTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheGroupsMetricsRebalanceTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheValidatorMetricsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheMetricsEntitiesCountTest.class, ignoredTests); // Cluster wide metrics. - suite.addTestSuite(CacheMetricsForClusterGroupSelfTest.class); - suite.addTestSuite(OffheapCacheMetricsForClusterGroupSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheMetricsForClusterGroupSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, OffheapCacheMetricsForClusterGroupSelfTest.class, ignoredTests); - suite.addTestSuite(TransactionMetricsMxBeanImplTest.class); + GridTestUtils.addTestIfNeeded(suite, TransactionMetricsMxBeanImplTest.class, ignoredTests); - suite.addTestSuite(GridEvictionPolicyMBeansTest.class); + GridTestUtils.addTestIfNeeded(suite, GridEvictionPolicyMBeansTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite.java index cf12d24c5189a..b426e7cbdfa31 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccClusterRestartTest; import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccConfigurationValidationTest; @@ -33,11 +34,17 @@ import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccTransactionsTest; import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccTxFailoverTest; import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccVacuumTest; +import org.apache.ignite.internal.processors.cache.mvcc.MvccCachePeekTest; +import org.apache.ignite.internal.processors.cache.mvcc.MvccUnsupportedTxModesTest; +import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorMvccPersistenceSelfTest; import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorMvccSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ +@RunWith(AllTests.class) public class IgniteCacheMvccTestSuite extends TestSuite { /** * @return Test suite. @@ -46,28 +53,33 @@ public static TestSuite suite() { TestSuite suite = new TestSuite("IgniteCache MVCC Test Suite"); // Basic tests. - suite.addTestSuite(CacheMvccTransactionsTest.class); - suite.addTestSuite(CacheMvccProcessorTest.class); - suite.addTestSuite(CacheMvccVacuumTest.class); - suite.addTestSuite(CacheMvccConfigurationValidationTest.class); + suite.addTest(new JUnit4TestAdapter(CacheMvccTransactionsTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccProcessorTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccVacuumTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccConfigurationValidationTest.class)); - suite.addTestSuite(DataStreamProcessorMvccSelfTest.class); - suite.addTestSuite(CacheMvccOperationChecksTest.class); + suite.addTest(new JUnit4TestAdapter(DataStreamProcessorMvccSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DataStreamProcessorMvccPersistenceSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccOperationChecksTest.class)); - suite.addTestSuite(CacheMvccRemoteTxOnNearNodeStartTest.class); + suite.addTest(new JUnit4TestAdapter(CacheMvccRemoteTxOnNearNodeStartTest.class)); + + suite.addTest(new JUnit4TestAdapter(MvccUnsupportedTxModesTest.class)); + + suite.addTest(new JUnit4TestAdapter(MvccCachePeekTest.class)); // Concurrent ops tests. - suite.addTestSuite(CacheMvccIteratorWithConcurrentTransactionTest.class); - suite.addTestSuite(CacheMvccLocalEntriesWithConcurrentTransactionTest.class); - suite.addTestSuite(CacheMvccScanQueryWithConcurrentTransactionTest.class); - suite.addTestSuite(CacheMvccSizeWithConcurrentTransactionTest.class); + suite.addTest(new JUnit4TestAdapter(CacheMvccIteratorWithConcurrentTransactionTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccLocalEntriesWithConcurrentTransactionTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccScanQueryWithConcurrentTransactionTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccSizeWithConcurrentTransactionTest.class)); // Failover tests. - suite.addTestSuite(CacheMvccTxFailoverTest.class); - suite.addTestSuite(CacheMvccClusterRestartTest.class); - suite.addTestSuite(CacheMvccPartitionedCoordinatorFailoverTest.class); - suite.addTestSuite(CacheMvccReplicatedCoordinatorFailoverTest.class); - suite.addTestSuite(CacheMvccProcessorLazyStartTest.class); + suite.addTest(new JUnit4TestAdapter(CacheMvccTxFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccClusterRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccPartitionedCoordinatorFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccReplicatedCoordinatorFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccProcessorLazyStartTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite1.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite1.java new file mode 100755 index 0000000000000..ae3680d29136d --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite1.java @@ -0,0 +1,249 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import java.util.Set; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.IgniteCacheEntryProcessorSequentialCallTest; +import org.apache.ignite.cache.IgniteWarmupClosureSelfTest; +import org.apache.ignite.cache.store.CacheStoreReadFromBackupTest; +import org.apache.ignite.cache.store.GridCacheBalancingStoreSelfTest; +import org.apache.ignite.cache.store.GridStoreLoadCacheTest; +import org.apache.ignite.cache.store.StoreResourceInjectionSelfTest; +import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreTest; +import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreSelfTest; +import org.apache.ignite.cache.store.jdbc.JdbcTypesDefaultTransformerTest; +import org.apache.ignite.internal.managers.communication.IgniteCommunicationBalanceMultipleConnectionsTest; +import org.apache.ignite.internal.managers.communication.IgniteCommunicationBalancePairedConnectionsTest; +import org.apache.ignite.internal.managers.communication.IgniteCommunicationBalanceTest; +import org.apache.ignite.internal.managers.communication.IgniteCommunicationSslBalanceTest; +import org.apache.ignite.internal.managers.communication.IgniteIoTestMessagesTest; +import org.apache.ignite.internal.managers.communication.IgniteVariousConnectionNumberTest; +import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest; +import org.apache.ignite.internal.processors.cache.CacheDeferredDeleteQueueTest; +import org.apache.ignite.internal.processors.cache.CacheDeferredDeleteSanitySelfTest; +import org.apache.ignite.internal.processors.cache.CacheMvccTxFastFinishTest; +import org.apache.ignite.internal.processors.cache.CacheNamesSelfTest; +import org.apache.ignite.internal.processors.cache.CacheNamesWithSpecialCharactersTest; +import org.apache.ignite.internal.processors.cache.CacheTxFastFinishTest; +import org.apache.ignite.internal.processors.cache.DataStorageConfigurationValidationTest; +import org.apache.ignite.internal.processors.cache.GridCacheAffinityApiSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheAffinityMapperSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheAsyncOperationsLimitSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheConcurrentMapSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheConfigurationConsistencySelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheConfigurationValidationSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheLifecycleAwareSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheMissingCommitVersionSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheMvccManagerSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheMvccMultiThreadedUpdateSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheMvccPartitionedSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheMvccSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheOffHeapAtomicMultiThreadedUpdateSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheOffHeapMultiThreadedUpdateSelfTest; +import org.apache.ignite.internal.processors.cache.GridCachePartitionedLocalStoreSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheReplicatedLocalStoreSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheStopSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheTcpClientDiscoveryMultiThreadedTest; +import org.apache.ignite.internal.processors.cache.GridDataStorageConfigurationConsistencySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalWithStoreInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicNearEnabledInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicStopBusySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicWithStoreInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicLocalTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicReplicatedTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheEntryProcessorCallTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheManyAsyncOperationsTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheMvccTxInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheMvccTxNearEnabledInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheTxInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheTxNearEnabledInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteClientAffinityAssignmentSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteIncompleteCacheObjectSelfTest; +import org.apache.ignite.internal.processors.cache.binary.CacheKeepBinaryWithInterceptorTest; +import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheAffinityRoutingBinarySelfTest; +import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheAtomicPartitionedOnlyBinaryDataStreamerMultiNodeSelfTest; +import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheAtomicPartitionedOnlyBinaryDataStreamerMultithreadedSelfTest; +import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheAtomicPartitionedOnlyBinaryMultiNodeSelfTest; +import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheAtomicPartitionedOnlyBinaryMultithreadedSelfTest; +import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinariesNearPartitionedByteArrayValuesSelfTest; +import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinariesPartitionedOnlyByteArrayValuesSelfTest; +import org.apache.ignite.internal.processors.cache.context.IgniteCacheAtomicExecutionContextTest; +import org.apache.ignite.internal.processors.cache.context.IgniteCacheContinuousExecutionContextTest; +import org.apache.ignite.internal.processors.cache.context.IgniteCacheIsolatedExecutionContextTest; +import org.apache.ignite.internal.processors.cache.context.IgniteCacheP2PDisableExecutionContextTest; +import org.apache.ignite.internal.processors.cache.context.IgniteCachePrivateExecutionContextTest; +import org.apache.ignite.internal.processors.cache.context.IgniteCacheReplicatedExecutionContextTest; +import org.apache.ignite.internal.processors.cache.context.IgniteCacheSharedExecutionContextTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheAtomicNearUpdateTopologyChangeTest; +import org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheAtomicMessageRecovery10ConnectionsTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheAtomicMessageRecoveryPairedConnectionsTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheAtomicMessageRecoveryTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheConnectionRecovery10ConnectionsTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheConnectionRecoveryTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheMessageRecoveryIdleConnectionTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheMessageWriteTimeoutTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAtomicNearCacheSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionsStateValidatorSelfTest; +import org.apache.ignite.internal.processors.cache.expiry.IgniteCacheAtomicLocalExpiryPolicyTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheEntryProcessorExternalizableFailedTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheEntryProcessorNonSerializableTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * Test suite. + */ +@RunWith(AllTests.class) +public class IgniteCacheMvccTestSuite1 { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + TestSuite suite = new TestSuite("IgniteCache Mvcc Test Suite part 1"); + + Set ignoredTests = new HashSet<>(); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(CacheKeepBinaryWithInterceptorTest.class); + ignoredTests.add(CacheEntryProcessorNonSerializableTest.class); + ignoredTests.add(CacheEntryProcessorExternalizableFailedTest.class); + ignoredTests.add(IgniteCacheEntryProcessorSequentialCallTest.class); + ignoredTests.add(IgniteCacheEntryProcessorCallTest.class); + ignoredTests.add(GridCacheConfigurationConsistencySelfTest.class); + ignoredTests.add(IgniteCacheMessageRecoveryIdleConnectionTest.class); + ignoredTests.add(IgniteCacheConnectionRecoveryTest.class); + ignoredTests.add(IgniteCacheConnectionRecovery10ConnectionsTest.class); + ignoredTests.add(CacheDeferredDeleteSanitySelfTest.class); + ignoredTests.add(CacheDeferredDeleteQueueTest.class); + ignoredTests.add(GridCacheStopSelfTest.class); + ignoredTests.add(GridCacheBinariesNearPartitionedByteArrayValuesSelfTest.class); + ignoredTests.add(GridCacheBinariesPartitionedOnlyByteArrayValuesSelfTest.class); + + // Atomic caches. + ignoredTests.add(IgniteCacheEntryListenerAtomicTest.class); + ignoredTests.add(IgniteCacheEntryListenerAtomicReplicatedTest.class); + ignoredTests.add(IgniteCacheEntryListenerAtomicLocalTest.class); + ignoredTests.add(IgniteCacheAtomicLocalExpiryPolicyTest.class); + ignoredTests.add(IgniteCacheAtomicInvokeTest.class); + ignoredTests.add(IgniteCacheAtomicNearEnabledInvokeTest.class); + ignoredTests.add(IgniteCacheAtomicWithStoreInvokeTest.class); + ignoredTests.add(IgniteCacheAtomicLocalInvokeTest.class); + ignoredTests.add(IgniteCacheAtomicLocalWithStoreInvokeTest.class); + ignoredTests.add(GridCachePartitionedLocalStoreSelfTest.class); + ignoredTests.add(GridCacheReplicatedLocalStoreSelfTest.class); + ignoredTests.add(CacheStoreReadFromBackupTest.class); + + ignoredTests.add(IgniteCacheAtomicExecutionContextTest.class); + ignoredTests.add(IgniteCacheReplicatedExecutionContextTest.class); + ignoredTests.add(IgniteCacheContinuousExecutionContextTest.class); + ignoredTests.add(IgniteCacheIsolatedExecutionContextTest.class); + ignoredTests.add(IgniteCacheP2PDisableExecutionContextTest.class); + ignoredTests.add(IgniteCachePrivateExecutionContextTest.class); + ignoredTests.add(IgniteCacheSharedExecutionContextTest.class); + + ignoredTests.add(IgniteCacheAtomicStopBusySelfTest.class); + ignoredTests.add(GridCacheAtomicNearCacheSelfTest.class); + ignoredTests.add(CacheAtomicNearUpdateTopologyChangeTest.class); + ignoredTests.add(GridCacheOffHeapAtomicMultiThreadedUpdateSelfTest.class); + ignoredTests.add(IgniteCacheAtomicMessageRecoveryTest.class); + ignoredTests.add(IgniteCacheAtomicMessageRecoveryPairedConnectionsTest.class); + ignoredTests.add(IgniteCacheAtomicMessageRecovery10ConnectionsTest.class); + + ignoredTests.add(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearPartitionedAtomic.class); + ignoredTests.add(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearReplicatedAtomic.class); + ignoredTests.add(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientPartitionedAtomic.class); + ignoredTests.add(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientReplicatedAtomic.class); + + ignoredTests.add(GridCacheAtomicPartitionedOnlyBinaryDataStreamerMultiNodeSelfTest.class); + ignoredTests.add(GridCacheAtomicPartitionedOnlyBinaryDataStreamerMultithreadedSelfTest.class); + ignoredTests.add(GridCacheAtomicPartitionedOnlyBinaryMultiNodeSelfTest.class); + ignoredTests.add(GridCacheAtomicPartitionedOnlyBinaryMultithreadedSelfTest.class); + + // Irrelevant tests. + ignoredTests.add(GridCacheMvccSelfTest.class); // This is about MvccCandidate, but not TxSnapshot. + ignoredTests.add(GridCacheMvccPartitionedSelfTest.class); // This is about MvccCandidate, but not TxSnapshot. + ignoredTests.add(GridCacheMvccManagerSelfTest.class); // This is about MvccCandidate, but not TxSnapshot. + ignoredTests.add(GridCacheMissingCommitVersionSelfTest.class); // Mvcc tx states resides in TxLog. + + // Other non-Tx test. + ignoredTests.add(GridCacheAffinityRoutingSelfTest.class); + ignoredTests.add(GridCacheAffinityRoutingBinarySelfTest.class); + ignoredTests.add(IgniteClientAffinityAssignmentSelfTest.class); + ignoredTests.add(GridCacheConcurrentMapSelfTest.class); + ignoredTests.add(CacheAffinityCallSelfTest.class); + ignoredTests.add(GridCacheAffinityMapperSelfTest.class); + ignoredTests.add(GridCacheAffinityApiSelfTest.class); + + ignoredTests.add(CacheNamesSelfTest.class); + ignoredTests.add(CacheNamesWithSpecialCharactersTest.class); + ignoredTests.add(GridCacheConfigurationValidationSelfTest.class); + + ignoredTests.add(GridDataStorageConfigurationConsistencySelfTest.class); + ignoredTests.add(DataStorageConfigurationValidationTest.class); + ignoredTests.add(JdbcTypesDefaultTransformerTest.class); + ignoredTests.add(GridCacheJdbcBlobStoreSelfTest.class); + ignoredTests.add(CacheJdbcPojoStoreTest.class); + ignoredTests.add(GridCacheBalancingStoreSelfTest.class); + ignoredTests.add(GridStoreLoadCacheTest.class); + + ignoredTests.add(IgniteWarmupClosureSelfTest.class); + ignoredTests.add(StoreResourceInjectionSelfTest.class); + ignoredTests.add(GridCacheAsyncOperationsLimitSelfTest.class); + ignoredTests.add(IgniteCacheManyAsyncOperationsTest.class); + ignoredTests.add(GridCacheLifecycleAwareSelfTest.class); + ignoredTests.add(IgniteCacheMessageWriteTimeoutTest.class); + ignoredTests.add(GridCachePartitionsStateValidatorSelfTest.class); + ignoredTests.add(IgniteVariousConnectionNumberTest.class); + ignoredTests.add(IgniteIncompleteCacheObjectSelfTest.class); + + ignoredTests.add(IgniteCommunicationBalanceTest.class); + ignoredTests.add(IgniteCommunicationBalancePairedConnectionsTest.class); + ignoredTests.add(IgniteCommunicationBalanceMultipleConnectionsTest.class); + ignoredTests.add(IgniteCommunicationSslBalanceTest.class); + ignoredTests.add(IgniteIoTestMessagesTest.class); + + ignoredTests.add(GridCacheTcpClientDiscoveryMultiThreadedTest.class); + + // Skip classes which Mvcc implementations are added in this method below. + ignoredTests.add(GridCacheOffHeapMultiThreadedUpdateSelfTest.class); // See GridCacheMvccMultiThreadedUpdateSelfTest. + ignoredTests.add(CacheTxFastFinishTest.class); // See CacheMvccTxFastFinishTest. + ignoredTests.add(IgniteCacheTxInvokeTest.class); // See IgniteCacheMvccTxInvokeTest. + ignoredTests.add(IgniteCacheTxNearEnabledInvokeTest.class); // See IgniteCacheMvccTxNearEnabledInvokeTest. + + suite.addTest(IgniteBinaryCacheTestSuite.suite(ignoredTests)); + + // Add Mvcc clones. + suite.addTest(new JUnit4TestAdapter(GridCacheMvccMultiThreadedUpdateSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheMvccTxFastFinishTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheMvccTxInvokeTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheMvccTxNearEnabledInvokeTest.class)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite2.java new file mode 100644 index 0000000000000..67d717dcfbc5b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite2.java @@ -0,0 +1,201 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.affinity.rendezvous.ClusterNodeAttributeAffinityBackupFilterSelfTest; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionBackupFilterSelfTest; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionExcludeNeighborsSelfTest; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionSelfTest; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionStandardHashSelfTest; +import org.apache.ignite.internal.IgniteReflectionFactorySelfTest; +import org.apache.ignite.internal.processors.cache.CacheComparatorTest; +import org.apache.ignite.internal.processors.cache.CacheConfigurationLeakTest; +import org.apache.ignite.internal.processors.cache.CacheEnumOperationsSingleNodeTest; +import org.apache.ignite.internal.processors.cache.CacheEnumOperationsTest; +import org.apache.ignite.internal.processors.cache.CacheExchangeMessageDuplicatedStateTest; +import org.apache.ignite.internal.processors.cache.CacheGroupLocalConfigurationSelfTest; +import org.apache.ignite.internal.processors.cache.CacheOptimisticTransactionsWithFilterSingleServerTest; +import org.apache.ignite.internal.processors.cache.CacheOptimisticTransactionsWithFilterTest; +import org.apache.ignite.internal.processors.cache.GridCacheAtomicMessageCountSelfTest; +import org.apache.ignite.internal.processors.cache.GridCachePartitionedProjectionAffinitySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteAtomicCacheEntryProcessorNodeJoinTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheNoSyncForGetTest; +import org.apache.ignite.internal.processors.cache.IgniteCachePartitionMapUpdateTest; +import org.apache.ignite.internal.processors.cache.IgniteClientCacheStartFailoverTest; +import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheAndNodeStop; +import org.apache.ignite.internal.processors.cache.IgniteNearClientCacheCloseTest; +import org.apache.ignite.internal.processors.cache.IgniteOnePhaseCommitInvokeTest; +import org.apache.ignite.internal.processors.cache.IgniteOnePhaseCommitNearReadersTest; +import org.apache.ignite.internal.processors.cache.MemoryPolicyConfigValidationTest; +import org.apache.ignite.internal.processors.cache.NonAffinityCoordinatorDynamicStartStopTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTestAllowOverwrite; +import org.apache.ignite.internal.processors.cache.distributed.CachePartitionStateTest; +import org.apache.ignite.internal.processors.cache.distributed.GridCachePartitionedNearDisabledMvccTxMultiThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.GridCachePartitionedNearDisabledTxMultiThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.GridCacheTransformEventSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheClientNodePartitionsExchangeTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheServerNodeConcurrentStart; +import org.apache.ignite.internal.processors.cache.distributed.dht.CachePartitionPartialCountersMapSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedMvccTxSingleThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedOptimisticTransactionSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedTxSingleThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtAtomicEvictionNearReadersSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadOnheapSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedUnloadEventsSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePartitionedBackupNodeFailureRecoveryTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearEvictionEventSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearMultiNodeSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearReadersSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearClientHitTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearJobExecutionSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearMultiGetSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearTxForceKeyTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedAffinitySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedAtomicGetAndTransformStoreSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiThreadedPutGetSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMvccTxMultiThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMvccTxSingleThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMvccTxTimeoutSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxMultiThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxSingleThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxTimeoutSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheRendezvousAffinityClientSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.NearCacheSyncUpdateTest; +import org.apache.ignite.internal.processors.cache.distributed.near.NoneRebalanceModeSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedJobExecutionTest; +import org.apache.ignite.internal.processors.cache.local.GridCacheLocalAtomicBasicStoreSelfTest; +import org.apache.ignite.internal.processors.cache.local.GridCacheLocalAtomicGetAndTransformStoreSelfTest; +import org.apache.ignite.internal.processors.cache.persistence.MemoryPolicyInitializationTest; +import org.apache.ignite.internal.processors.continuous.IgniteNoCustomEventsOnNodeStart; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * Test suite. + */ +@RunWith(AllTests.class) +public class IgniteCacheMvccTestSuite2 { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + HashSet ignoredTests = new HashSet<>(128); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(GridCacheTransformEventSelfTest.class); + ignoredTests.add(IgniteClientCacheStartFailoverTest.class); + ignoredTests.add(IgniteNearClientCacheCloseTest.class); + ignoredTests.add(IgniteCacheNoSyncForGetTest.class); + ignoredTests.add(CacheEnumOperationsSingleNodeTest.class); + ignoredTests.add(CacheEnumOperationsTest.class); + ignoredTests.add(NearCacheSyncUpdateTest.class); + ignoredTests.add(GridCacheNearMultiGetSelfTest.class); + + // Irrelevant Tx tests. + ignoredTests.add(GridCacheColocatedOptimisticTransactionSelfTest.class); + ignoredTests.add(CacheOptimisticTransactionsWithFilterSingleServerTest.class); + ignoredTests.add(CacheOptimisticTransactionsWithFilterTest.class); + + // Irrelevant Tx tests. + ignoredTests.add(IgniteOnePhaseCommitInvokeTest.class); + ignoredTests.add(IgniteOnePhaseCommitNearReadersTest.class); + ignoredTests.add(GridCacheDhtPreloadOnheapSelfTest.class); + ignoredTests.add(GridCachePartitionedMultiThreadedPutGetSelfTest.class); // On-heap test. + + // Atomic cache tests. + ignoredTests.add(GridCacheLocalAtomicBasicStoreSelfTest.class); + ignoredTests.add(GridCacheLocalAtomicGetAndTransformStoreSelfTest.class); + ignoredTests.add(GridCacheAtomicNearMultiNodeSelfTest.class); + ignoredTests.add(GridCacheAtomicNearReadersSelfTest.class); + ignoredTests.add(GridCachePartitionedAtomicGetAndTransformStoreSelfTest.class); + ignoredTests.add(GridCacheAtomicNearEvictionEventSelfTest.class); + ignoredTests.add(GridCacheAtomicMessageCountSelfTest.class); + ignoredTests.add(IgniteAtomicCacheEntryProcessorNodeJoinTest.class); + ignoredTests.add(GridCacheDhtAtomicEvictionNearReadersSelfTest.class); + ignoredTests.add(GridCacheNearClientHitTest.class); + ignoredTests.add(GridCacheNearTxForceKeyTest.class); + ignoredTests.add(CacheLoadingConcurrentGridStartSelfTest.class); + ignoredTests.add(CacheLoadingConcurrentGridStartSelfTestAllowOverwrite.class); + ignoredTests.add(IgniteCachePartitionedBackupNodeFailureRecoveryTest.class); + + // Other non-tx tests. + ignoredTests.add(RendezvousAffinityFunctionSelfTest.class); + ignoredTests.add(RendezvousAffinityFunctionExcludeNeighborsSelfTest.class); + ignoredTests.add(RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest.class); + ignoredTests.add(RendezvousAffinityFunctionStandardHashSelfTest.class); + ignoredTests.add(GridCachePartitionedAffinitySelfTest.class); + ignoredTests.add(GridCacheRendezvousAffinityClientSelfTest.class); + ignoredTests.add(GridCachePartitionedProjectionAffinitySelfTest.class); + ignoredTests.add(RendezvousAffinityFunctionBackupFilterSelfTest.class); + ignoredTests.add(ClusterNodeAttributeAffinityBackupFilterSelfTest.class); + ignoredTests.add(NonAffinityCoordinatorDynamicStartStopTest.class); + + ignoredTests.add(NoneRebalanceModeSelfTest.class); + ignoredTests.add(IgniteCachePartitionMapUpdateTest.class); + ignoredTests.add(IgniteCacheClientNodePartitionsExchangeTest.class); + ignoredTests.add(IgniteCacheServerNodeConcurrentStart.class); + + ignoredTests.add(GridCachePartitionedUnloadEventsSelfTest.class); + + ignoredTests.add(IgniteNoCustomEventsOnNodeStart.class); + ignoredTests.add(CacheExchangeMessageDuplicatedStateTest.class); + ignoredTests.add(IgniteDynamicCacheAndNodeStop.class); + + ignoredTests.add(GridCacheReplicatedJobExecutionTest.class); + ignoredTests.add(GridCacheNearJobExecutionSelfTest.class); + + ignoredTests.add(CacheConfigurationLeakTest.class); + ignoredTests.add(MemoryPolicyConfigValidationTest.class); + ignoredTests.add(MemoryPolicyInitializationTest.class); + ignoredTests.add(CacheGroupLocalConfigurationSelfTest.class); + + ignoredTests.add(CachePartitionStateTest.class); + ignoredTests.add(CacheComparatorTest.class); + ignoredTests.add(CachePartitionPartialCountersMapSelfTest.class); + ignoredTests.add(IgniteReflectionFactorySelfTest.class); + + // Skip classes which Mvcc implementations are added in this method below. + // TODO IGNITE-10175: refactor these tests (use assume) to support both mvcc and non-mvcc modes after moving to JUnit4/5. + ignoredTests.add(GridCachePartitionedTxSingleThreadedSelfTest.class); // See GridCachePartitionedMvccTxSingleThreadedSelfTest + ignoredTests.add(GridCacheColocatedTxSingleThreadedSelfTest.class); // See GridCacheColocatedMvccTxSingleThreadedSelfTest + ignoredTests.add(GridCachePartitionedTxMultiThreadedSelfTest.class); // See GridCachePartitionedMvccTxMultiThreadedSelfTest + ignoredTests.add(GridCachePartitionedNearDisabledTxMultiThreadedSelfTest.class); // See GridCachePartitionedNearDisabledMvccTxMultiThreadedSelfTest + ignoredTests.add(GridCachePartitionedTxTimeoutSelfTest.class); // See GridCachePartitionedMvccTxTimeoutSelfTest + + TestSuite suite = new TestSuite("IgniteCache Mvcc Test Suite part 2"); + + suite.addTest(IgniteCacheTestSuite2.suite(ignoredTests)); + + // Add Mvcc clones. + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMvccTxSingleThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheColocatedMvccTxSingleThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMvccTxMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledMvccTxMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMvccTxTimeoutSelfTest.class)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite3.java new file mode 100644 index 0000000000000..da9db3c384b39 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite3.java @@ -0,0 +1,137 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.processors.cache.CacheInterceptorPartitionCounterLocalSanityTest; +import org.apache.ignite.internal.processors.cache.CacheInterceptorPartitionCounterRandomOperationsTest; +import org.apache.ignite.internal.processors.cache.GridCacheAtomicEntryProcessorDeploymentSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheEntryVersionSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheInterceptorAtomicNearEnabledSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheInterceptorAtomicRebalanceTest; +import org.apache.ignite.internal.processors.cache.GridCacheInterceptorAtomicReplicatedSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheInterceptorAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheInterceptorAtomicWithStoreReplicatedSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheInterceptorAtomicWithStoreSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheInterceptorLocalAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheInterceptorLocalAtomicWithStoreSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheValueBytesPreloadingSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheVersionSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheVersionTopologyChangeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheGroupsTest; +import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheAsyncOperationsTest; +import org.apache.ignite.internal.processors.cache.distributed.GridCacheMixedModeSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheClientOnlySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteTxReentryColocatedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheValueConsistencyAtomicNearEnabledSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheValueConsistencyAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearOnlySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteTxReentryNearSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedAtomicGetAndTransformStoreSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedMvccTxMultiThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedMvccTxSingleThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedMvccTxTimeoutSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxMultiThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxSingleThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxTimeoutSelfTest; +import org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStoreMultithreadedSelfTest; +import org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStoreSelfTest; +import org.apache.ignite.internal.processors.cache.store.IgnteCacheClientWriteBehindStoreAtomicTest; +import org.apache.ignite.internal.processors.cache.store.IgnteCacheClientWriteBehindStoreNonCoalescingTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * Test suite. + */ +@RunWith(AllTests.class) +public class IgniteCacheMvccTestSuite3 { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + HashSet ignoredTests = new HashSet<>(); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(GridCacheEntryVersionSelfTest.class); + ignoredTests.add(GridCacheVersionTopologyChangeTest.class); + ignoredTests.add(CacheAsyncOperationsTest.class); + ignoredTests.add(CacheInterceptorPartitionCounterLocalSanityTest.class); + ignoredTests.add(CacheInterceptorPartitionCounterRandomOperationsTest.class); + ignoredTests.add(IgniteCacheGroupsTest.class); + + // Atomic caches + ignoredTests.add(GridCacheValueConsistencyAtomicSelfTest.class); + ignoredTests.add(GridCacheValueConsistencyAtomicNearEnabledSelfTest.class); + ignoredTests.add(GridCacheReplicatedAtomicGetAndTransformStoreSelfTest.class); + ignoredTests.add(GridCacheAtomicEntryProcessorDeploymentSelfTest.class); + ignoredTests.add(GridCacheValueBytesPreloadingSelfTest.class); + ignoredTests.add(GridCacheBinaryAtomicEntryProcessorDeploymentSelfTest.class); + + ignoredTests.add(GridCacheClientOnlySelfTest.CasePartitionedAtomic.class); + ignoredTests.add(GridCacheClientOnlySelfTest.CaseReplicatedAtomic.class); + ignoredTests.add(GridCacheNearOnlySelfTest.CasePartitionedAtomic.class); + ignoredTests.add(GridCacheNearOnlySelfTest.CaseReplicatedAtomic.class); + + ignoredTests.add(IgnteCacheClientWriteBehindStoreAtomicTest.class); + ignoredTests.add(IgnteCacheClientWriteBehindStoreNonCoalescingTest.class); + + ignoredTests.add(GridCacheInterceptorLocalAtomicSelfTest.class); + ignoredTests.add(GridCacheInterceptorLocalAtomicWithStoreSelfTest.class); + ignoredTests.add(GridCacheInterceptorAtomicSelfTest.class); + ignoredTests.add(GridCacheInterceptorAtomicNearEnabledSelfTest.class); + ignoredTests.add(GridCacheInterceptorAtomicWithStoreSelfTest.class); + ignoredTests.add(GridCacheInterceptorAtomicReplicatedSelfTest.class); + ignoredTests.add(GridCacheInterceptorAtomicWithStoreReplicatedSelfTest.class); + ignoredTests.add(GridCacheInterceptorAtomicRebalanceTest.class); + + // Irrelevant tx tests + ignoredTests.add(IgniteTxReentryNearSelfTest.class); + ignoredTests.add(IgniteTxReentryColocatedSelfTest.class); + + // Other non-tx tests + ignoredTests.add(GridCacheWriteBehindStoreSelfTest.class); + ignoredTests.add(GridCacheWriteBehindStoreMultithreadedSelfTest.class); + + ignoredTests.add(GridCacheVersionSelfTest.class); + ignoredTests.add(GridCacheMixedModeSelfTest.class); + + // Skip classes which Mvcc implementations are added in this method below. + // TODO IGNITE-10175: refactor these tests (use assume) to support both mvcc and non-mvcc modes after moving to JUnit4/5. + ignoredTests.add(GridCacheReplicatedTxSingleThreadedSelfTest.class); // See GridCacheReplicatedMvccTxSingleThreadedSelfTest + ignoredTests.add(GridCacheReplicatedTxMultiThreadedSelfTest.class); // See GridCacheReplicatedMvccTxMultiThreadedSelfTest + ignoredTests.add(GridCacheReplicatedTxTimeoutSelfTest.class); // See GridCacheReplicatedMvccTxTimeoutSelfTest + + TestSuite suite = new TestSuite("IgniteCache Mvcc Test Suite part 3"); + + suite.addTest(IgniteBinaryObjectsCacheTestSuite3.suite(ignoredTests)); + + // Add Mvcc clones. + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedMvccTxSingleThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedMvccTxMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedMvccTxTimeoutSelfTest.class)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite4.java new file mode 100644 index 0000000000000..22cacc4cb56a1 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite4.java @@ -0,0 +1,201 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.store.CacheStoreListenerRWThroughDisabledAtomicCacheTest; +import org.apache.ignite.internal.processors.cache.CacheConnectionLeakStoreTxTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticReadCommittedSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticRepeatableReadSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticSerializableSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticReadCommittedSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticRepeatableReadSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticSerializableSelfTest; +import org.apache.ignite.internal.processors.cache.CacheOffheapMapEntrySelfTest; +import org.apache.ignite.internal.processors.cache.CacheReadThroughAtomicRestartSelfTest; +import org.apache.ignite.internal.processors.cache.CacheReadThroughLocalAtomicRestartSelfTest; +import org.apache.ignite.internal.processors.cache.CacheReadThroughReplicatedAtomicRestartSelfTest; +import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeDynamicStartAtomicTest; +import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeStaticStartAtomicTest; +import org.apache.ignite.internal.processors.cache.CacheTxNotAllowReadFromBackupTest; +import org.apache.ignite.internal.processors.cache.GridCacheMultinodeUpdateAtomicNearEnabledSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheMultinodeUpdateAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheVersionMultinodeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicCopyOnReadDisabledTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalPeekModesTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalStoreValueTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicNearEnabledStoreValueTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicNearPeekModesTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicPeekModesTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicReplicatedPeekModesTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicStoreValueTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheConfigurationDefaultTemplateTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheContainsKeyAtomicTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheInvokeReadThroughSingleNodeTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheInvokeReadThroughTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheStartTest; +import org.apache.ignite.internal.processors.cache.IgniteClientCacheInitializationFailTest; +import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheStartNoExchangeTimeoutTest; +import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheStartSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheStartStopConcurrentTest; +import org.apache.ignite.internal.processors.cache.IgniteDynamicClientCacheStartSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteExchangeFutureHistoryTest; +import org.apache.ignite.internal.processors.cache.IgniteInternalCacheTypesTest; +import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteSystemCacheOnClientTest; +import org.apache.ignite.internal.processors.cache.MarshallerCacheJobRunNodeRestartTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheDiscoveryDataConcurrentJoinTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheGetFutureHangsSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheGroupsPreloadTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClassOnServerNodeTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheResultIsNotNullOnPartitionLossTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheCreatePutTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheFailedUpdateResponseTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheReadFromBackupTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheSingleGetMessageTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCrossCacheMvccTxSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCrossCacheTxSelfTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicLoadAllTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicLoaderWriterTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicLocalLoadAllTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicLocalNoLoadPreviousValueTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicLocalNoReadThroughTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicLocalNoWriteThroughTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicNearEnabledNoLoadPreviousValueTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicNearEnabledNoReadThroughTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicNearEnabledNoWriteThroughTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicNoLoadPreviousValueTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicNoReadThroughTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicNoWriteThroughTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicStoreSessionTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheAtomicStoreSessionWriteBehindTest; +import org.apache.ignite.internal.processors.cache.integration.IgniteCacheJdbcBlobStoreNodeRestartTest; +import org.apache.ignite.internal.processors.cache.version.CacheVersionedEntryLocalAtomicSwapDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.version.CacheVersionedEntryPartitionedAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.version.CacheVersionedEntryReplicatedAtomicSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * + */ +@RunWith(AllTests.class) +public class IgniteCacheMvccTestSuite4 { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + HashSet ignoredTests = new HashSet<>(128); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(GridCacheVersionMultinodeTest.class); + ignoredTests.add(IgniteCacheCreatePutTest.class); + ignoredTests.add(IgniteClientCacheInitializationFailTest.class); + ignoredTests.add(IgniteCacheFailedUpdateResponseTest.class); + ignoredTests.add(CacheGetEntryPessimisticRepeatableReadSelfTest.class); + ignoredTests.add(CacheTxNotAllowReadFromBackupTest.class); + ignoredTests.add(CacheOffheapMapEntrySelfTest.class); + ignoredTests.add(CacheGroupsPreloadTest.class); + ignoredTests.add(CacheConnectionLeakStoreTxTest.class); + ignoredTests.add(IgniteCacheInvokeReadThroughTest.class); + ignoredTests.add(IgniteCacheInvokeReadThroughSingleNodeTest.class); + ignoredTests.add(IgniteDynamicCacheStartSelfTest.class); + ignoredTests.add(IgniteDynamicClientCacheStartSelfTest.class); + ignoredTests.add(IgniteDynamicCacheStartNoExchangeTimeoutTest.class); + ignoredTests.add(IgniteCacheSingleGetMessageTest.class); + ignoredTests.add(IgniteCacheReadFromBackupTest.class); + + // Optimistic tx tests. + ignoredTests.add(CacheGetEntryOptimisticReadCommittedSelfTest.class); + ignoredTests.add(CacheGetEntryOptimisticRepeatableReadSelfTest.class); + ignoredTests.add(CacheGetEntryOptimisticSerializableSelfTest.class); + + // Irrelevant Tx tests. + ignoredTests.add(CacheGetEntryPessimisticReadCommittedSelfTest.class); + ignoredTests.add(CacheGetEntryPessimisticSerializableSelfTest.class); + + // Atomic cache tests. + ignoredTests.add(GridCacheMultinodeUpdateAtomicSelfTest.class); + ignoredTests.add(GridCacheMultinodeUpdateAtomicNearEnabledSelfTest.class); + ignoredTests.add(IgniteCacheAtomicLoadAllTest.class); + ignoredTests.add(IgniteCacheAtomicLocalLoadAllTest.class); + ignoredTests.add(IgniteCacheAtomicLoaderWriterTest.class); + ignoredTests.add(IgniteCacheAtomicStoreSessionTest.class); + ignoredTests.add(IgniteCacheAtomicStoreSessionWriteBehindTest.class); + ignoredTests.add(IgniteCacheAtomicNoReadThroughTest.class); + ignoredTests.add(IgniteCacheAtomicNearEnabledNoReadThroughTest.class); + ignoredTests.add(IgniteCacheAtomicLocalNoReadThroughTest.class); + ignoredTests.add(IgniteCacheAtomicNoLoadPreviousValueTest.class); + ignoredTests.add(IgniteCacheAtomicNearEnabledNoLoadPreviousValueTest.class); + ignoredTests.add(IgniteCacheAtomicLocalNoLoadPreviousValueTest.class); + ignoredTests.add(IgniteCacheAtomicNoWriteThroughTest.class); + ignoredTests.add(IgniteCacheAtomicNearEnabledNoWriteThroughTest.class); + ignoredTests.add(IgniteCacheAtomicLocalNoWriteThroughTest.class); + ignoredTests.add(IgniteCacheAtomicPeekModesTest.class); + ignoredTests.add(IgniteCacheAtomicNearPeekModesTest.class); + ignoredTests.add(IgniteCacheAtomicReplicatedPeekModesTest.class); + ignoredTests.add(IgniteCacheAtomicLocalPeekModesTest.class); + ignoredTests.add(IgniteCacheAtomicCopyOnReadDisabledTest.class); + ignoredTests.add(IgniteCacheAtomicLocalStoreValueTest.class); + ignoredTests.add(IgniteCacheAtomicStoreValueTest.class); + ignoredTests.add(IgniteCacheAtomicNearEnabledStoreValueTest.class); + ignoredTests.add(CacheStoreListenerRWThroughDisabledAtomicCacheTest.class); + ignoredTests.add(CacheStoreUsageMultinodeStaticStartAtomicTest.class); + ignoredTests.add(CacheStoreUsageMultinodeDynamicStartAtomicTest.class); + ignoredTests.add(IgniteStartCacheInTransactionAtomicSelfTest.class); + ignoredTests.add(CacheReadThroughReplicatedAtomicRestartSelfTest.class); + ignoredTests.add(CacheReadThroughLocalAtomicRestartSelfTest.class); + ignoredTests.add(CacheReadThroughAtomicRestartSelfTest.class); + ignoredTests.add(CacheVersionedEntryLocalAtomicSwapDisabledSelfTest.class); + ignoredTests.add(CacheVersionedEntryPartitionedAtomicSelfTest.class); + ignoredTests.add(CacheGetFutureHangsSelfTest.class); + ignoredTests.add(IgniteCacheContainsKeyAtomicTest.class); + ignoredTests.add(CacheVersionedEntryReplicatedAtomicSelfTest.class); + ignoredTests.add(CacheResultIsNotNullOnPartitionLossTest.class); + + // Other non-tx tests. + ignoredTests.add(IgniteDynamicCacheStartStopConcurrentTest.class); + ignoredTests.add(IgniteCacheConfigurationDefaultTemplateTest.class); + ignoredTests.add(IgniteCacheStartTest.class); + ignoredTests.add(CacheDiscoveryDataConcurrentJoinTest.class); + ignoredTests.add(IgniteCacheJdbcBlobStoreNodeRestartTest.class); + ignoredTests.add(IgniteInternalCacheTypesTest.class); + ignoredTests.add(IgniteExchangeFutureHistoryTest.class); + ignoredTests.add(CacheNoValueClassOnServerNodeTest.class); + ignoredTests.add(IgniteSystemCacheOnClientTest.class); + ignoredTests.add(MarshallerCacheJobRunNodeRestartTest.class); + + // Skip classes which Mvcc implementations are added in this method below. + // TODO IGNITE-10175: refactor these tests (use assume) to support both mvcc and non-mvcc modes after moving to JUnit4/5. + ignoredTests.add(IgniteCrossCacheTxSelfTest.class); + + TestSuite suite = new TestSuite("IgniteCache Mvcc Test Suite part 4"); + + suite.addTest(IgniteCacheTestSuite4.suite(ignoredTests)); + + // Add Mvcc clones. + suite.addTest(new JUnit4TestAdapter(IgniteCrossCacheMvccTxSelfTest.class)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite5.java new file mode 100644 index 0000000000000..91f0b71fdeda0 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite5.java @@ -0,0 +1,97 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import junit.framework.TestSuite; +import org.apache.ignite.GridCacheAffinityBackupsSelfTest; +import org.apache.ignite.IgniteCacheAffinitySelfTest; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.affinity.AffinityClientNodeSelfTest; +import org.apache.ignite.cache.affinity.AffinityDistributionLoggingTest; +import org.apache.ignite.cache.affinity.AffinityHistoryCleanupTest; +import org.apache.ignite.cache.affinity.local.LocalAffinityFunctionTest; +import org.apache.ignite.internal.GridCachePartitionExchangeManagerHistSizeTest; +import org.apache.ignite.internal.processors.cache.CacheSerializableTransactionsTest; +import org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTest; +import org.apache.ignite.internal.processors.cache.ClusterStatePartitionedSelfTest; +import org.apache.ignite.internal.processors.cache.ClusterStateReplicatedSelfTest; +import org.apache.ignite.internal.processors.cache.ConcurrentCacheStartTest; +import org.apache.ignite.internal.processors.cache.EntryVersionConsistencyReadThroughTest; +import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest; +import org.apache.ignite.internal.processors.cache.PartitionsExchangeOnDiscoveryHistoryOverflowTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentNodeJoinValidationTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheTxIteratorSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.NotMappedPartitionInTxTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.IgniteCacheAtomicProtocolTest; +import org.apache.ignite.internal.processors.cache.distributed.rebalancing.CacheManualRebalancingTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheSyncRebalanceModeSelfTest; +import org.apache.ignite.internal.processors.cache.store.IgniteCacheWriteBehindNoUpdateSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * Test suite. + */ +@RunWith(AllTests.class) +public class IgniteCacheMvccTestSuite5 { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + HashSet ignoredTests = new HashSet<>(128); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(IgniteCacheStoreCollectionTest.class); + ignoredTests.add(EntryVersionConsistencyReadThroughTest.class); + ignoredTests.add(ClusterReadOnlyModeTest.class); + ignoredTests.add(NotMappedPartitionInTxTest.class); + ignoredTests.add(IgniteCacheTxIteratorSelfTest.class); + + // Irrelevant Tx tests. + ignoredTests.add(CacheSerializableTransactionsTest.class); + ignoredTests.add(IgniteCachePutStackOverflowSelfTest.class); + ignoredTests.add(IgniteCacheAtomicProtocolTest.class); + + // Other non-tx tests. + ignoredTests.add(CacheLateAffinityAssignmentNodeJoinValidationTest.class); + ignoredTests.add(IgniteCacheWriteBehindNoUpdateSelfTest.class); + ignoredTests.add(IgniteCacheSyncRebalanceModeSelfTest.class); + ignoredTests.add(ClusterStatePartitionedSelfTest.class); + ignoredTests.add(ClusterStateReplicatedSelfTest.class); + ignoredTests.add(CacheManualRebalancingTest.class); + ignoredTests.add(GridCacheAffinityBackupsSelfTest.class); + ignoredTests.add(IgniteCacheAffinitySelfTest.class); + ignoredTests.add(AffinityClientNodeSelfTest.class); + ignoredTests.add(LocalAffinityFunctionTest.class); + ignoredTests.add(AffinityHistoryCleanupTest.class); + ignoredTests.add(AffinityDistributionLoggingTest.class); + ignoredTests.add(PartitionsExchangeOnDiscoveryHistoryOverflowTest.class); + ignoredTests.add(GridCachePartitionExchangeManagerHistSizeTest.class); + ignoredTests.add(ConcurrentCacheStartTest.class); + + TestSuite suite = new TestSuite("IgniteCache Mvcc Test Suite part 5"); + + suite.addTest(IgniteCacheTestSuite5.suite(ignoredTests)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite6.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite6.java new file mode 100644 index 0000000000000..f5bf0e3dc6cea --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite6.java @@ -0,0 +1,96 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import java.util.Set; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.processors.cache.PartitionedAtomicCacheGetsDistributionTest; +import org.apache.ignite.internal.processors.cache.PartitionedMvccTxPessimisticCacheGetsDistributionTest; +import org.apache.ignite.internal.processors.cache.PartitionedTransactionalOptimisticCacheGetsDistributionTest; +import org.apache.ignite.internal.processors.cache.PartitionedTransactionalPessimisticCacheGetsDistributionTest; +import org.apache.ignite.internal.processors.cache.PartitionsExchangeCoordinatorFailoverTest; +import org.apache.ignite.internal.processors.cache.ReplicatedAtomicCacheGetsDistributionTest; +import org.apache.ignite.internal.processors.cache.ReplicatedMvccTxPessimisticCacheGetsDistributionTest; +import org.apache.ignite.internal.processors.cache.ReplicatedTransactionalOptimisticCacheGetsDistributionTest; +import org.apache.ignite.internal.processors.cache.ReplicatedTransactionalPessimisticCacheGetsDistributionTest; +import org.apache.ignite.internal.processors.cache.datastructures.IgniteExchangeLatchManagerCoordinatorFailTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheExchangeMergeTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheParallelStartTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteCache150ClientsTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteOptimisticTxSuspendResumeTest; +import org.apache.ignite.internal.processors.cache.transactions.TxOptimisticOnPartitionExchangeTest; +import org.apache.ignite.internal.processors.cache.transactions.TxOptimisticPrepareOnUnstableTopologyTest; +import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTimeoutOnePhaseCommitTest; +import org.apache.ignite.internal.processors.cache.transactions.TxStateChangeEventTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * Test suite. + */ +@RunWith(AllTests.class) +public class IgniteCacheMvccTestSuite6 { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + Set ignoredTests = new HashSet<>(); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(TxStateChangeEventTest.class); + + // Atomic cache tests. + ignoredTests.add(ReplicatedAtomicCacheGetsDistributionTest.class); + ignoredTests.add(PartitionedAtomicCacheGetsDistributionTest.class); + + // Irrelevant Tx tests. + ignoredTests.add(IgniteOptimisticTxSuspendResumeTest.class); + ignoredTests.add(TxOptimisticPrepareOnUnstableTopologyTest.class); + ignoredTests.add(ReplicatedTransactionalOptimisticCacheGetsDistributionTest.class); + ignoredTests.add(PartitionedTransactionalOptimisticCacheGetsDistributionTest.class); + ignoredTests.add(TxOptimisticOnPartitionExchangeTest.class); + + ignoredTests.add(TxRollbackOnTimeoutOnePhaseCommitTest.class); + + // Other non-tx tests. + ignoredTests.add(CacheExchangeMergeTest.class); + ignoredTests.add(IgniteExchangeLatchManagerCoordinatorFailTest.class); + ignoredTests.add(PartitionsExchangeCoordinatorFailoverTest.class); + ignoredTests.add(CacheParallelStartTest.class); + ignoredTests.add(IgniteCache150ClientsTest.class); + + // Skip tests that has Mvcc clones. + ignoredTests.add(PartitionedTransactionalPessimisticCacheGetsDistributionTest.class); // See PartitionedMvccTxPessimisticCacheGetsDistributionTest. + ignoredTests.add(ReplicatedTransactionalPessimisticCacheGetsDistributionTest.class); //See ReplicatedMvccTxPessimisticCacheGetsDistributionTest + + TestSuite suite = new TestSuite("IgniteCache Mvcc Test Suite part 6"); + + suite.addTest(IgniteCacheTestSuite6.suite(ignoredTests)); + + // Add mvcc versions for skipped tests. + suite.addTest(new JUnit4TestAdapter(PartitionedMvccTxPessimisticCacheGetsDistributionTest.class)); + suite.addTest(new JUnit4TestAdapter(ReplicatedMvccTxPessimisticCacheGetsDistributionTest.class)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite7.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite7.java new file mode 100644 index 0000000000000..83d5cd32a089a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite7.java @@ -0,0 +1,86 @@ +/* + * 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. + */ +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.processors.authentication.Authentication1kUsersNodeRestartTest; +import org.apache.ignite.internal.processors.authentication.AuthenticationConfigurationClusterTest; +import org.apache.ignite.internal.processors.authentication.AuthenticationOnNotActiveClusterTest; +import org.apache.ignite.internal.processors.authentication.AuthenticationProcessorNPEOnStartTest; +import org.apache.ignite.internal.processors.authentication.AuthenticationProcessorNodeRestartTest; +import org.apache.ignite.internal.processors.authentication.AuthenticationProcessorSelfTest; +import org.apache.ignite.internal.processors.cache.CacheDataRegionConfigurationTest; +import org.apache.ignite.internal.processors.cache.CacheGroupMetricsMBeanTest; +import org.apache.ignite.internal.processors.cache.MvccCacheGroupMetricsMBeanTest; +import org.apache.ignite.internal.processors.cache.distributed.Cache64kPartitionsTest; +import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingPartitionCountersMvccTest; +import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingPartitionCountersTest; +import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingWithAsyncClearingMvccTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.PageEvictionMultinodeMixedRegionsTest; +import org.apache.ignite.internal.processors.cache.persistence.db.CheckpointBufferDeadlockTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * + */ +@RunWith(AllTests.class) +public class IgniteCacheMvccTestSuite7 { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + HashSet ignoredTests = new HashSet<>(128); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(PageEvictionMultinodeMixedRegionsTest.class); + + // Other non-tx tests. + ignoredTests.add(CheckpointBufferDeadlockTest.class);// + ignoredTests.add(AuthenticationConfigurationClusterTest.class);// + ignoredTests.add(AuthenticationProcessorSelfTest.class); + ignoredTests.add(AuthenticationOnNotActiveClusterTest.class); + ignoredTests.add(AuthenticationProcessorNodeRestartTest.class); + ignoredTests.add(AuthenticationProcessorNPEOnStartTest.class); + ignoredTests.add(Authentication1kUsersNodeRestartTest.class); + ignoredTests.add(CacheDataRegionConfigurationTest.class); + ignoredTests.add(Cache64kPartitionsTest.class); + + // Skip classes which Mvcc implementations are added in this method below. + // TODO IGNITE-10175: refactor these tests (use assume) to support both mvcc and non-mvcc modes after moving to JUnit4/5. + ignoredTests.add(CacheGroupMetricsMBeanTest.class); // See MvccCacheGroupMetricsMBeanTest + ignoredTests.add(GridCacheRebalancingPartitionCountersTest.class); // See GridCacheRebalancingPartitionCountersMvccTest + + TestSuite suite = new TestSuite("IgniteCache Mvcc Test Suite part 7"); + + suite.addTest(IgniteCacheTestSuite7.suite(ignoredTests)); + + // Add Mvcc clones. + suite.addTest(new JUnit4TestAdapter(MvccCacheGroupMetricsMBeanTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheRebalancingPartitionCountersMvccTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheRebalancingWithAsyncClearingMvccTest.class)); + + + return suite; + } + +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite8.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite8.java new file mode 100644 index 0000000000000..28732af2e640a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite8.java @@ -0,0 +1,135 @@ +/* + * 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. + */ +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorNearPartitionedAtomicCacheGroupsTest; +import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorNearPartitionedAtomicCacheTest; +import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorPartitionedAtomicCacheGroupsTest; +import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorPartitionedAtomicCacheTest; +import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorReplicatedAtomicCacheGroupsTest; +import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorReplicatedAtomicCacheTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearEvictionSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicPartitionedMetricsSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicPartitionedTckMetricsSelfTestImpl; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheMvccNearEvictionSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearAtomicMetricsSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearEvictionSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRabalancingDelayedPartitionMapExchangeSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheAtomicReplicatedMetricsSelfTest; +import org.apache.ignite.internal.processors.cache.eviction.GridCacheEvictableEntryEqualsSelfTest; +import org.apache.ignite.internal.processors.cache.eviction.fifo.FifoEvictionPolicyFactorySelfTest; +import org.apache.ignite.internal.processors.cache.eviction.fifo.FifoEvictionPolicySelfTest; +import org.apache.ignite.internal.processors.cache.eviction.lru.LruEvictionPolicyFactorySelfTest; +import org.apache.ignite.internal.processors.cache.eviction.lru.LruEvictionPolicySelfTest; +import org.apache.ignite.internal.processors.cache.eviction.lru.LruNearEvictionPolicySelfTest; +import org.apache.ignite.internal.processors.cache.eviction.lru.LruNearOnlyNearEvictionPolicySelfTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.PageEvictionDataStreamerTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.PageEvictionMetricTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.PageEvictionPagesRecyclingAndReusingTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.PageEvictionReadThroughTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.PageEvictionTouchOrderTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.Random2LruNearEnabledPageEvictionMultinodeTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.Random2LruPageEvictionMultinodeTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.Random2LruPageEvictionWithRebalanceTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.RandomLruNearEnabledPageEvictionMultinodeTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.RandomLruPageEvictionMultinodeTest; +import org.apache.ignite.internal.processors.cache.eviction.paged.RandomLruPageEvictionWithRebalanceTest; +import org.apache.ignite.internal.processors.cache.eviction.sorted.SortedEvictionPolicyFactorySelfTest; +import org.apache.ignite.internal.processors.cache.eviction.sorted.SortedEvictionPolicySelfTest; +import org.apache.ignite.internal.processors.cache.local.GridCacheAtomicLocalMetricsNoStoreSelfTest; +import org.apache.ignite.internal.processors.cache.local.GridCacheAtomicLocalMetricsSelfTest; +import org.apache.ignite.internal.processors.cache.local.GridCacheAtomicLocalTckMetricsSelfTestImpl; +import org.apache.ignite.internal.processors.cache.local.GridCacheLocalAtomicMetricsNoReadThroughSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * + */ +@RunWith(AllTests.class) +public class IgniteCacheMvccTestSuite8 { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + HashSet ignoredTests = new HashSet<>(128); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(LruNearEvictionPolicySelfTest.class); + ignoredTests.add(LruNearOnlyNearEvictionPolicySelfTest.class); + ignoredTests.add(RandomLruPageEvictionMultinodeTest.class); + ignoredTests.add(RandomLruNearEnabledPageEvictionMultinodeTest.class); + ignoredTests.add(PageEvictionDataStreamerTest.class); + ignoredTests.add(Random2LruPageEvictionMultinodeTest.class); + ignoredTests.add(Random2LruNearEnabledPageEvictionMultinodeTest.class); + ignoredTests.add(RandomLruPageEvictionWithRebalanceTest.class); + ignoredTests.add(Random2LruPageEvictionWithRebalanceTest.class); + ignoredTests.add(PageEvictionTouchOrderTest.class); + ignoredTests.add(PageEvictionReadThroughTest.class); + ignoredTests.add(PageEvictionMetricTest.class); + ignoredTests.add(PageEvictionPagesRecyclingAndReusingTest.class); + + // Irrelevant Tx tests. + ignoredTests.add(GridCacheEvictableEntryEqualsSelfTest.class); + + // Atomic cache tests. + ignoredTests.add(GridCacheLocalAtomicMetricsNoReadThroughSelfTest.class); + ignoredTests.add(GridCacheNearAtomicMetricsSelfTest.class); + ignoredTests.add(GridCacheAtomicLocalMetricsSelfTest.class); + ignoredTests.add(GridCacheAtomicLocalMetricsNoStoreSelfTest.class); + ignoredTests.add(GridCacheAtomicReplicatedMetricsSelfTest.class); + ignoredTests.add(GridCacheAtomicPartitionedMetricsSelfTest.class); + ignoredTests.add(GridCacheAtomicPartitionedTckMetricsSelfTestImpl.class); + ignoredTests.add(GridCacheAtomicLocalTckMetricsSelfTestImpl.class); + ignoredTests.add(IgniteTopologyValidatorPartitionedAtomicCacheTest.class); + ignoredTests.add(IgniteTopologyValidatorNearPartitionedAtomicCacheTest.class); + ignoredTests.add(IgniteTopologyValidatorReplicatedAtomicCacheTest.class); + ignoredTests.add(IgniteTopologyValidatorNearPartitionedAtomicCacheGroupsTest.class); + ignoredTests.add(IgniteTopologyValidatorPartitionedAtomicCacheGroupsTest.class); + ignoredTests.add(IgniteTopologyValidatorReplicatedAtomicCacheGroupsTest.class); + + // Other non-tx tests. + ignoredTests.add(FifoEvictionPolicySelfTest.class); + ignoredTests.add(SortedEvictionPolicySelfTest.class); + ignoredTests.add(LruEvictionPolicySelfTest.class); + ignoredTests.add(FifoEvictionPolicyFactorySelfTest.class); + ignoredTests.add(SortedEvictionPolicyFactorySelfTest.class); + ignoredTests.add(LruEvictionPolicyFactorySelfTest.class); + ignoredTests.add(GridCacheAtomicNearEvictionSelfTest.class); + ignoredTests.add(GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.class); + + // Skip classes which Mvcc implementations are added in this method below. + // TODO IGNITE-10175: refactor these tests (use assume) to support both mvcc and non-mvcc modes after moving to JUnit4/5. + ignoredTests.add(GridCacheNearEvictionSelfTest.class); // See GridCacheMvccNearEvictionSelfTest + + TestSuite suite = new TestSuite("IgniteCache Mvcc Test Suite part 8"); + + suite.addTest(IgniteCacheTestSuite8.suite(ignoredTests)); + + // Add Mvcc clones. + suite.addTest(new JUnit4TestAdapter(GridCacheMvccNearEvictionSelfTest.class)); + + return suite; + } + +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite9.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite9.java new file mode 100644 index 0000000000000..ce9533fd90577 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccTestSuite9.java @@ -0,0 +1,60 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.Collection; +import java.util.HashSet; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.processors.cache.IgniteCacheGetCustomCollectionsSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheLoadRebalanceEvictionSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheAtomicPrimarySyncBackPressureTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteTxConcurrentRemoveObjectsTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * Test suite. + */ +@RunWith(AllTests.class) +public class IgniteCacheMvccTestSuite9 { + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + Collection ignoredTests = new HashSet<>(); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(IgniteTxConcurrentRemoveObjectsTest.class); + + // Atomic caches. + ignoredTests.add(CacheAtomicPrimarySyncBackPressureTest.class); + + // Other non-tx tests. + ignoredTests.add(IgniteCacheGetCustomCollectionsSelfTest.class); + ignoredTests.add(IgniteCacheLoadRebalanceEvictionSelfTest.class); + + TestSuite suite = new TestSuite("IgniteCache Mvcc Test Suite part 9"); + + suite.addTest(IgniteCacheTestSuite9.suite(ignoredTests)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheNearOnlySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheNearOnlySelfTestSuite.java index 087007e9fb120..eb163a2d18615 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheNearOnlySelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheNearOnlySelfTestSuite.java @@ -17,34 +17,46 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheClientOnlySelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearOnlySelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearOnlyTopologySelfTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for near-only cache. */ +@RunWith(AllTests.class) public class IgniteCacheNearOnlySelfTestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { + return suite(null); + } + + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("Near-only cache test suite."); - suite.addTest(new TestSuite(GridCacheClientOnlySelfTest.CasePartitionedAtomic.class)); - suite.addTest(new TestSuite(GridCacheClientOnlySelfTest.CasePartitionedTransactional.class)); - suite.addTest(new TestSuite(GridCacheClientOnlySelfTest.CaseReplicatedAtomic.class)); - suite.addTest(new TestSuite(GridCacheClientOnlySelfTest.CaseReplicatedTransactional.class)); + GridTestUtils.addTestIfNeeded(suite,GridCacheClientOnlySelfTest.CasePartitionedAtomic.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheClientOnlySelfTest.CasePartitionedTransactional.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheClientOnlySelfTest.CaseReplicatedAtomic.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheClientOnlySelfTest.CaseReplicatedTransactional.class, ignoredTests); - suite.addTest(new TestSuite(GridCacheNearOnlyTopologySelfTest.class)); + GridTestUtils.addTestIfNeeded(suite,GridCacheNearOnlyTopologySelfTest.class, ignoredTests); - suite.addTest(new TestSuite(GridCacheNearOnlySelfTest.CasePartitionedAtomic.class)); - suite.addTest(new TestSuite(GridCacheNearOnlySelfTest.CasePartitionedTransactional.class)); - suite.addTest(new TestSuite(GridCacheNearOnlySelfTest.CaseReplicatedAtomic.class)); - suite.addTest(new TestSuite(GridCacheNearOnlySelfTest.CaseReplicatedTransactional.class)); + GridTestUtils.addTestIfNeeded(suite,GridCacheNearOnlySelfTest.CasePartitionedAtomic.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheNearOnlySelfTest.CasePartitionedTransactional.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheNearOnlySelfTest.CaseReplicatedAtomic.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheNearOnlySelfTest.CaseReplicatedTransactional.class, ignoredTests); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheP2pUnmarshallingErrorTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheP2pUnmarshallingErrorTestSuite.java index dfc96dca72337..00effea08c76f 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheP2pUnmarshallingErrorTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheP2pUnmarshallingErrorTestSuite.java @@ -24,25 +24,26 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingRebalanceErrorTest; import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingTxErrorTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Checks behavior on exception while unmarshalling key. */ -public class IgniteCacheP2pUnmarshallingErrorTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheP2pUnmarshallingErrorTestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** * @param ignoredTests Tests don't include in the execution. * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite(Set ignoredTests) throws Exception { + public static TestSuite suite(Set ignoredTests) { TestSuite suite = new TestSuite("P2p Unmarshalling Test Suite"); GridTestUtils.addTestIfNeeded(suite, IgniteCacheP2pUnmarshallingErrorTest.class, ignoredTests); @@ -52,4 +53,4 @@ public static TestSuite suite(Set ignoredTests) throws Exception { return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java index 9040ea575f1d5..6c0b3a2395681 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.IgniteCacheCreateRestartSelfTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheNearRestartRollbackSelfTest; @@ -24,26 +25,28 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedNodeRestartTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedOptimisticTxNodeRestartTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedNodeRestartSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Cache stability test suite on changing topology. */ -public class IgniteCacheRestartTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheRestartTestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache Restart Test Suite"); - suite.addTestSuite(GridCachePartitionedNodeRestartTest.class); - suite.addTestSuite(GridCachePartitionedOptimisticTxNodeRestartTest.class); - suite.addTestSuite(GridCacheReplicatedNodeRestartSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledOptimisticTxNodeRestartTest.class); - suite.addTestSuite(IgniteCacheNearRestartRollbackSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNodeRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedOptimisticTxNodeRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedNodeRestartSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledOptimisticTxNodeRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheNearRestartRollbackSelfTest.class)); - suite.addTestSuite(IgniteCacheCreateRestartSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheCreateRestartSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java index 6a4c4878b17a7..e6d0f5bdd3cc1 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheRestartTestSuite2.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.internal.IgniteProperties; @@ -27,29 +28,31 @@ import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheAtomicNodeRestartTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheGetRestartTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheAtomicReplicatedNodeRestartSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Cache stability test suite on changing topology. */ -public class IgniteCacheRestartTestSuite2 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheRestartTestSuite2 { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache Restart Test Suite2"); - suite.addTestSuite(IgniteCacheAtomicNodeRestartTest.class); - suite.addTestSuite(IgniteCacheAtomicReplicatedNodeRestartSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicNodeRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicReplicatedNodeRestartSelfTest.class)); - suite.addTestSuite(IgniteCacheAtomicPutAllFailoverSelfTest.class); - suite.addTestSuite(IgniteCachePutAllRestartTest.class); - suite.addTestSuite(GridCachePutAllFailoverSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicPutAllFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePutAllRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePutAllFailoverSelfTest.class)); // TODO IGNITE-4768. - //suite.addTestSuite(IgniteBinaryMetadataUpdateNodeRestartTest.class); + //suite.addTest(new JUnit4TestAdapter(IgniteBinaryMetadataUpdateNodeRestartTest.class)); - suite.addTestSuite(IgniteCacheGetRestartTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheGetRestartTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTcpClientDiscoveryTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTcpClientDiscoveryTestSuite.java index e0efda43e4a8c..db3e0ec30e72b 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTcpClientDiscoveryTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTcpClientDiscoveryTestSuite.java @@ -17,31 +17,51 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.GridCacheTcpClientDiscoveryMultiThreadedTest; -import org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +import static org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientPartitionedAtomic; +import static org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientPartitionedTransactional; +import static org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientReplicatedAtomic; +import static org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientReplicatedTransactional; +import static org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearPartitionedAtomic; +import static org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearPartitionedTransactional; +import static org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearReplicatedAtomic; +import static org.apache.ignite.internal.processors.cache.distributed.GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearReplicatedTransactional; /** * Tests a cache with TcpClientDiscovery SPI being enabled. */ +@RunWith(AllTests.class) public class IgniteCacheTcpClientDiscoveryTestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { + return suite(null); + } + + /** + * @param ignoredTests Tests to ignore. + * @return Test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("Cache + TcpClientDiscovery SPI test suite."); - suite.addTest(new TestSuite(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearPartitionedAtomic.class)); - suite.addTest(new TestSuite(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearPartitionedTransactional.class)); - suite.addTest(new TestSuite(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearReplicatedAtomic.class)); - suite.addTest(new TestSuite(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseNearReplicatedTransactional.class)); - suite.addTest(new TestSuite(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientPartitionedAtomic.class)); - suite.addTest(new TestSuite(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientPartitionedTransactional.class)); - suite.addTest(new TestSuite(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientReplicatedAtomic.class)); - suite.addTest(new TestSuite(GridCacheClientModesTcpClientDiscoveryAbstractTest.CaseClientReplicatedTransactional.class)); - suite.addTest(new TestSuite(GridCacheTcpClientDiscoveryMultiThreadedTest.class)); + GridTestUtils.addTestIfNeeded(suite, CaseNearPartitionedAtomic.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CaseNearPartitionedTransactional.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CaseNearReplicatedAtomic.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CaseNearReplicatedTransactional.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CaseClientPartitionedAtomic.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CaseClientPartitionedTransactional.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CaseClientReplicatedAtomic.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CaseClientReplicatedTransactional.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheTcpClientDiscoveryMultiThreadedTest.class, ignoredTests); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java index d6c1f96a56b97..d1b581a2b7b84 100755 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java @@ -17,10 +17,12 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.cache.IgniteCacheEntryProcessorSequentialCallTest; import org.apache.ignite.cache.IgniteWarmupClosureSelfTest; import org.apache.ignite.cache.store.CacheStoreReadFromBackupTest; +import org.apache.ignite.cache.store.CacheStoreWriteErrorTest; import org.apache.ignite.cache.store.CacheTransactionalStoreReadFromBackupTest; import org.apache.ignite.cache.store.GridCacheBalancingStoreSelfTest; import org.apache.ignite.cache.store.GridCacheLoadOnlyStoreAdapterSelfTest; @@ -35,10 +37,6 @@ import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreMultithreadedSelfTest; import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreSelfTest; import org.apache.ignite.cache.store.jdbc.JdbcTypesDefaultTransformerTest; -import org.apache.ignite.internal.IgniteInternalCacheRemoveTest; -import org.apache.ignite.internal.managers.IgniteDiagnosticMessagesMultipleConnectionsTest; -import org.apache.ignite.internal.managers.IgniteDiagnosticMessagesTest; -import org.apache.ignite.internal.managers.communication.GridIoManagerSelfTest; import org.apache.ignite.internal.managers.communication.IgniteCommunicationBalanceMultipleConnectionsTest; import org.apache.ignite.internal.managers.communication.IgniteCommunicationBalancePairedConnectionsTest; import org.apache.ignite.internal.managers.communication.IgniteCommunicationBalanceTest; @@ -47,7 +45,6 @@ import org.apache.ignite.internal.managers.communication.IgniteVariousConnectionNumberTest; import org.apache.ignite.internal.processors.cache.BinaryMetadataRegistrationInsideEntryProcessorTest; import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest; -import org.apache.ignite.internal.processors.cache.CacheAtomicSingleMessageCountSelfTest; import org.apache.ignite.internal.processors.cache.CacheDeferredDeleteQueueTest; import org.apache.ignite.internal.processors.cache.CacheDeferredDeleteSanitySelfTest; import org.apache.ignite.internal.processors.cache.CacheFutureExceptionSelfTest; @@ -60,25 +57,16 @@ import org.apache.ignite.internal.processors.cache.GridCacheAffinityMapperSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheAsyncOperationsLimitSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheAtomicUsersAffinityMapperSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheClearAllSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheClearLocallySelfTest; import org.apache.ignite.internal.processors.cache.GridCacheColocatedTxStoreExceptionSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheConcurrentGetCacheOnClientTest; import org.apache.ignite.internal.processors.cache.GridCacheConcurrentMapSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheConfigurationConsistencySelfTest; import org.apache.ignite.internal.processors.cache.GridCacheConfigurationValidationSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheEntryMemorySizeSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheFullTextQueryMultithreadedSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheKeyCheckNearEnabledSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheKeyCheckSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheLeakTest; import org.apache.ignite.internal.processors.cache.GridCacheLifecycleAwareSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheLocalTxStoreExceptionSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheMissingCommitVersionSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheMixedPartitionExchangeSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheMultiUpdateLockSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheMvccFlagsTest; import org.apache.ignite.internal.processors.cache.GridCacheMvccManagerSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheMvccPartitionedSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheMvccSelfTest; @@ -89,17 +77,10 @@ import org.apache.ignite.internal.processors.cache.GridCachePartitionedLocalStoreSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheReplicatedLocalStoreSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheReplicatedTxStoreExceptionSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheReplicatedUsersAffinityMapperSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheReturnValueTransferSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheSlowTxWarnTest; import org.apache.ignite.internal.processors.cache.GridCacheStopSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheStorePutxSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheStoreValueBytesSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheSwapPreloadSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheTtlManagerLoadTest; import org.apache.ignite.internal.processors.cache.GridCacheTtlManagerSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheTxPartitionedLocalStoreSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheTxUsersAffinityMapperSelfTest; import org.apache.ignite.internal.processors.cache.GridDataStorageConfigurationConsistencySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicInvokeTest; import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicLocalInvokeTest; @@ -107,7 +88,6 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicNearEnabledInvokeTest; import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicStopBusySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicWithStoreInvokeTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryEntryProcessorSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicLocalTest; import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicReplicatedTest; import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicTest; @@ -118,27 +98,19 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheEntryProcessorCallTest; import org.apache.ignite.internal.processors.cache.IgniteCacheManyAsyncOperationsTest; import org.apache.ignite.internal.processors.cache.IgniteCacheNearLockValueSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheObjectPutSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheSerializationSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheStartStopLoadTest; import org.apache.ignite.internal.processors.cache.IgniteCacheTransactionalStopBusySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheTxInvokeTest; import org.apache.ignite.internal.processors.cache.IgniteCacheTxLocalInvokeTest; import org.apache.ignite.internal.processors.cache.IgniteCacheTxNearEnabledInvokeTest; -import org.apache.ignite.internal.processors.cache.IgniteCachingProviderSelfTest; import org.apache.ignite.internal.processors.cache.IgniteClientAffinityAssignmentSelfTest; import org.apache.ignite.internal.processors.cache.IgniteIncompleteCacheObjectSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteOnePhaseCommitNearSelfTest; import org.apache.ignite.internal.processors.cache.IgnitePutAllLargeBatchSelfTest; import org.apache.ignite.internal.processors.cache.IgnitePutAllUpdateNonPreloadedPartitionSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteStaticCacheStartSelfTest; import org.apache.ignite.internal.processors.cache.IgniteTxConfigCacheSelfTest; -import org.apache.ignite.internal.processors.cache.InterceptorWithKeepBinaryCacheFullApiTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheAtomicExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheContinuousExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheIsolatedExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheP2PDisableExecutionContextTest; -import org.apache.ignite.internal.processors.cache.context.IgniteCachePartitionedExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCachePrivateExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheReplicatedExecutionContextTest; import org.apache.ignite.internal.processors.cache.context.IgniteCacheSharedExecutionContextTest; @@ -163,10 +135,12 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionsStateValidatorSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheGetStoreErrorSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearTxExceptionSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedStorePutSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxExceptionSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalTxExceptionSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheEntryProcessorExternalizableFailedTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheEntryProcessorNonSerializableTest; +import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorPersistenceSelfTest; import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSelfTest; import org.apache.ignite.internal.processors.datastreamer.DataStreamerClientReconnectAfterClusterRestartTest; import org.apache.ignite.internal.processors.datastreamer.DataStreamerImplSelfTest; @@ -175,67 +149,62 @@ import org.apache.ignite.internal.processors.datastreamer.DataStreamerTimeoutTest; import org.apache.ignite.internal.processors.datastreamer.DataStreamerUpdateAfterLoadTest; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.GridAbstractTest; - -import java.util.Set; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTestSuite { /** * @return IgniteCache test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** * @param ignoredTests Tests to ignore. * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite(Set ignoredTests) throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); - + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("IgniteCache Test Suite"); - suite.addTestSuite(IgniteCacheEntryListenerAtomicTest.class); - suite.addTestSuite(IgniteCacheEntryListenerAtomicReplicatedTest.class); - suite.addTestSuite(IgniteCacheEntryListenerAtomicLocalTest.class); - suite.addTestSuite(IgniteCacheEntryListenerTxTest.class); - suite.addTestSuite(IgniteCacheEntryListenerTxReplicatedTest.class); - suite.addTestSuite(IgniteCacheEntryListenerTxLocalTest.class); - suite.addTestSuite(IgniteCacheEntryListenerEagerTtlDisabledTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryListenerAtomicTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryListenerAtomicReplicatedTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryListenerAtomicLocalTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryListenerTxTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryListenerTxReplicatedTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryListenerTxLocalTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryListenerEagerTtlDisabledTest.class, ignoredTests); - suite.addTestSuite(IgniteClientAffinityAssignmentSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteClientAffinityAssignmentSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteCacheAtomicInvokeTest.class); - suite.addTestSuite(IgniteCacheAtomicNearEnabledInvokeTest.class); - suite.addTestSuite(IgniteCacheAtomicWithStoreInvokeTest.class); - suite.addTestSuite(IgniteCacheAtomicLocalInvokeTest.class); - suite.addTestSuite(IgniteCacheAtomicLocalWithStoreInvokeTest.class); - suite.addTestSuite(IgniteCacheTxInvokeTest.class); - suite.addTestSuite(CacheEntryProcessorNonSerializableTest.class); - suite.addTestSuite(CacheEntryProcessorExternalizableFailedTest.class); - suite.addTestSuite(IgniteCacheEntryProcessorCallTest.class); - suite.addTestSuite(IgniteCacheTxNearEnabledInvokeTest.class); - suite.addTestSuite(IgniteCacheTxLocalInvokeTest.class); - suite.addTestSuite(IgniteCrossCacheTxStoreSelfTest.class); - suite.addTestSuite(IgniteCacheEntryProcessorSequentialCallTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicInvokeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicNearEnabledInvokeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicWithStoreInvokeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicLocalInvokeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicLocalWithStoreInvokeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheTxInvokeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheEntryProcessorNonSerializableTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheEntryProcessorExternalizableFailedTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryProcessorCallTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheTxNearEnabledInvokeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheTxLocalInvokeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCrossCacheTxStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryProcessorSequentialCallTest.class, ignoredTests); // TODO GG-11148: include test when implemented. // Test fails due to incorrect handling of CacheConfiguration#getCopyOnRead() and // CacheObjectContext#storeValue() properties. Heap storage should be redesigned in this ticket. //GridTestUtils.addTestIfNeeded(suite, CacheEntryProcessorCopySelfTest.class, ignoredTests); - suite.addTestSuite(IgnitePutAllLargeBatchSelfTest.class); - suite.addTestSuite(IgnitePutAllUpdateNonPreloadedPartitionSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePutAllLargeBatchSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePutAllUpdateNonPreloadedPartitionSelfTest.class, ignoredTests); // User's class loader tests. GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicExecutionContextTest.class, ignoredTests); - GridTestUtils.addTestIfNeeded(suite, IgniteCachePartitionedExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, IgniteCacheReplicatedExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, IgniteCacheTxExecutionContextTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, IgniteCacheContinuousExecutionContextTest.class, ignoredTests); @@ -245,151 +214,147 @@ public static TestSuite suite(Set ignoredTests) throws Exception { GridTestUtils.addTestIfNeeded(suite, IgniteCacheSharedExecutionContextTest.class, ignoredTests); // Warmup closure tests. - suite.addTestSuite(IgniteWarmupClosureSelfTest.class); - - // Swap tests. - suite.addTestSuite(GridCacheSwapPreloadSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWarmupClosureSelfTest.class, ignoredTests); // Common tests. - suite.addTestSuite(CacheNamesSelfTest.class); - suite.addTestSuite(CacheNamesWithSpecialCharactersTest.class); - suite.addTestSuite(GridCacheConcurrentMapSelfTest.class); - suite.addTestSuite(GridCacheAffinityMapperSelfTest.class); - suite.addTestSuite(CacheAffinityCallSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheNamesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheNamesWithSpecialCharactersTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheConcurrentMapSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAffinityMapperSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheAffinityCallSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, GridCacheAffinityRoutingSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, GridCacheMvccSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheMvccPartitionedSelfTest.class); - suite.addTestSuite(GridCacheMvccManagerSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheMvccPartitionedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheMvccManagerSelfTest.class, ignoredTests); // TODO GG-11141. - // suite.addTestSuite(GridCacheP2PUndeploySelfTest.class); - suite.addTestSuite(GridCacheConfigurationValidationSelfTest.class); - suite.addTestSuite(GridCacheConfigurationConsistencySelfTest.class); - suite.addTestSuite(GridDataStorageConfigurationConsistencySelfTest.class); - suite.addTestSuite(DataStorageConfigurationValidationTest.class); - suite.addTestSuite(GridCacheJdbcBlobStoreSelfTest.class); - suite.addTestSuite(GridCacheJdbcBlobStoreMultithreadedSelfTest.class); - suite.addTestSuite(JdbcTypesDefaultTransformerTest.class); - suite.addTestSuite(CacheJdbcPojoStoreTest.class); - suite.addTestSuite(CacheJdbcPojoStoreBinaryMarshallerSelfTest.class); - suite.addTestSuite(CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinarySelfTest.class); - suite.addTestSuite(CacheJdbcPojoStoreBinaryMarshallerWithSqlEscapeSelfTest.class); - suite.addTestSuite(CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinaryWithSqlEscapeSelfTest.class); - suite.addTestSuite(CacheJdbcPojoStoreMultitreadedSelfTest.class); - suite.addTestSuite(GridCacheBalancingStoreSelfTest.class); - suite.addTestSuite(GridCacheAffinityApiSelfTest.class); - suite.addTestSuite(GridCacheStoreValueBytesSelfTest.class); + // GridTestUtils.addTestIfNeeded(suite,GridCacheP2PUndeploySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheConfigurationValidationSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheConfigurationConsistencySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridDataStorageConfigurationConsistencySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, DataStorageConfigurationValidationTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheJdbcBlobStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheJdbcBlobStoreMultithreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, JdbcTypesDefaultTransformerTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheJdbcPojoStoreTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheJdbcPojoStoreBinaryMarshallerSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinarySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheJdbcPojoStoreBinaryMarshallerWithSqlEscapeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheJdbcPojoStoreBinaryMarshallerStoreKeepBinaryWithSqlEscapeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheJdbcPojoStoreMultitreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheBalancingStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAffinityApiSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheStoreValueBytesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, DataStreamProcessorPersistenceSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, DataStreamProcessorSelfTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, DataStreamerUpdateAfterLoadTest.class, ignoredTests); - suite.addTestSuite(DataStreamerMultiThreadedSelfTest.class); - suite.addTestSuite(DataStreamerMultinodeCreateCacheTest.class); - suite.addTestSuite(DataStreamerImplSelfTest.class); - suite.addTestSuite(DataStreamerTimeoutTest.class); - suite.addTestSuite(DataStreamerClientReconnectAfterClusterRestartTest.class); + GridTestUtils.addTestIfNeeded(suite, DataStreamerMultiThreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, DataStreamerMultinodeCreateCacheTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, DataStreamerImplSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, DataStreamerTimeoutTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, DataStreamerClientReconnectAfterClusterRestartTest.class, ignoredTests); GridTestUtils.addTestIfNeeded(suite, GridCacheEntryMemorySizeSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheClearAllSelfTest.class); - suite.addTestSuite(GridCacheObjectToStringSelfTest.class); - suite.addTestSuite(GridCacheLoadOnlyStoreAdapterSelfTest.class); - suite.addTestSuite(GridCacheGetStoreErrorSelfTest.class); - suite.addTestSuite(StoreResourceInjectionSelfTest.class); - suite.addTestSuite(CacheFutureExceptionSelfTest.class); - suite.addTestSuite(GridCacheAsyncOperationsLimitSelfTest.class); - suite.addTestSuite(IgniteCacheManyAsyncOperationsTest.class); - suite.addTestSuite(GridCacheTtlManagerSelfTest.class); - // TODO: ignite-4534 -// suite.addTestSuite(GridCacheTtlManagerEvictionSelfTest.class); - suite.addTestSuite(GridCacheLifecycleAwareSelfTest.class); - suite.addTestSuite(IgniteCacheAtomicStopBusySelfTest.class); - suite.addTestSuite(IgniteCacheTransactionalStopBusySelfTest.class); - suite.addTestSuite(GridCacheAtomicNearCacheSelfTest.class); - suite.addTestSuite(CacheAtomicNearUpdateTopologyChangeTest.class); - suite.addTestSuite(CacheTxNearUpdateTopologyChangeTest.class); - suite.addTestSuite(GridCacheStorePutxSelfTest.class); - suite.addTestSuite(GridCacheOffHeapMultiThreadedUpdateSelfTest.class); - suite.addTestSuite(GridCacheOffHeapAtomicMultiThreadedUpdateSelfTest.class); - suite.addTestSuite(GridCacheColocatedTxStoreExceptionSelfTest.class); - suite.addTestSuite(GridCacheReplicatedTxStoreExceptionSelfTest.class); - suite.addTestSuite(GridCacheLocalTxStoreExceptionSelfTest.class); - suite.addTestSuite(GridCacheNearTxStoreExceptionSelfTest.class); - suite.addTestSuite(GridCacheMissingCommitVersionSelfTest.class); - suite.addTestSuite(GridCacheEntrySetIterationPreloadingSelfTest.class); - suite.addTestSuite(GridCacheMixedPartitionExchangeSelfTest.class); - suite.addTestSuite(IgniteCacheAtomicMessageRecoveryTest.class); - suite.addTestSuite(IgniteCacheAtomicMessageRecoveryPairedConnectionsTest.class); - suite.addTestSuite(IgniteCacheAtomicMessageRecovery10ConnectionsTest.class); - suite.addTestSuite(IgniteCacheTxMessageRecoveryTest.class); - suite.addTestSuite(IgniteCacheMessageWriteTimeoutTest.class); - suite.addTestSuite(IgniteCacheMessageRecoveryIdleConnectionTest.class); - suite.addTestSuite(IgniteCacheConnectionRecoveryTest.class); - suite.addTestSuite(IgniteCacheConnectionRecovery10ConnectionsTest.class); - suite.addTestSuite(GridCacheGlobalLoadTest.class); - suite.addTestSuite(GridCachePartitionedLocalStoreSelfTest.class); - suite.addTestSuite(GridCacheReplicatedLocalStoreSelfTest.class); - suite.addTestSuite(GridCacheTxPartitionedLocalStoreSelfTest.class); - suite.addTestSuite(IgniteCacheSystemTransactionsSelfTest.class); - suite.addTestSuite(CacheDeferredDeleteSanitySelfTest.class); - suite.addTestSuite(CacheDeferredDeleteQueueTest.class); - suite.addTestSuite(GridCachePartitionsStateValidatorSelfTest.class); - suite.addTestSuite(GridCachePartitionsStateValidationTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheClearAllSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheObjectToStringSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLoadOnlyStoreAdapterSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheGetStoreErrorSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, StoreResourceInjectionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheFutureExceptionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAsyncOperationsLimitSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheManyAsyncOperationsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheTtlManagerSelfTest.class, ignoredTests); +// GridTestUtils.addTestIfNeeded(suite, GridCacheTtlManagerEvictionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLifecycleAwareSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicStopBusySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheTransactionalStopBusySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicNearCacheSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheAtomicNearUpdateTopologyChangeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheTxNearUpdateTopologyChangeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedStorePutSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheOffHeapMultiThreadedUpdateSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheOffHeapAtomicMultiThreadedUpdateSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheColocatedTxStoreExceptionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheReplicatedTxStoreExceptionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalTxStoreExceptionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearTxStoreExceptionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheMissingCommitVersionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheEntrySetIterationPreloadingSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheMixedPartitionExchangeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicMessageRecoveryTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicMessageRecoveryPairedConnectionsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheAtomicMessageRecovery10ConnectionsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheTxMessageRecoveryTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheMessageWriteTimeoutTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheMessageRecoveryIdleConnectionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheConnectionRecoveryTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheConnectionRecovery10ConnectionsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheGlobalLoadTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedLocalStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheReplicatedLocalStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheTxPartitionedLocalStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheSystemTransactionsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheDeferredDeleteSanitySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheDeferredDeleteQueueTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionsStateValidatorSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionsStateValidationTest.class, ignoredTests); - suite.addTest(IgniteCacheTcpClientDiscoveryTestSuite.suite()); + suite.addTest(IgniteCacheTcpClientDiscoveryTestSuite.suite(ignoredTests)); // Heuristic exception handling. - suite.addTestSuite(GridCacheColocatedTxExceptionSelfTest.class); - suite.addTestSuite(GridCacheReplicatedTxExceptionSelfTest.class); - suite.addTestSuite(GridCacheLocalTxExceptionSelfTest.class); - suite.addTestSuite(GridCacheNearTxExceptionSelfTest.class); - suite.addTestSuite(GridCacheStopSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheColocatedTxExceptionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheReplicatedTxExceptionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalTxExceptionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearTxExceptionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheStopSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteCacheNearLockValueSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheNearLockValueSelfTest.class, ignoredTests); - suite.addTestSuite(CachePutEventListenerErrorSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, CachePutEventListenerErrorSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteTxConfigCacheSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteTxConfigCacheSelfTest.class, ignoredTests); - suite.addTestSuite(CacheTxFastFinishTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheTxFastFinishTest.class, ignoredTests); - //suite.addTestSuite(GridIoManagerSelfTest.class); - suite.addTestSuite(IgniteVariousConnectionNumberTest.class); - suite.addTestSuite(IgniteCommunicationBalanceTest.class); - suite.addTestSuite(IgniteCommunicationBalancePairedConnectionsTest.class); - suite.addTestSuite(IgniteCommunicationBalanceMultipleConnectionsTest.class); - suite.addTestSuite(IgniteCommunicationSslBalanceTest.class); - suite.addTestSuite(IgniteIoTestMessagesTest.class); - suite.addTestSuite(IgniteDiagnosticMessagesTest.class); - suite.addTestSuite(IgniteDiagnosticMessagesMultipleConnectionsTest.class); + //GridTestUtils.addTestIfNeeded(suite,GridIoManagerSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteVariousConnectionNumberTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCommunicationBalanceTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCommunicationBalancePairedConnectionsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCommunicationBalanceMultipleConnectionsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCommunicationSslBalanceTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteIoTestMessagesTest.class, ignoredTests); - suite.addTestSuite(IgniteIncompleteCacheObjectSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteIncompleteCacheObjectSelfTest.class, ignoredTests); - suite.addTestSuite(GridStoreLoadCacheTest.class); - suite.addTestSuite(CacheStoreReadFromBackupTest.class); - suite.addTestSuite(CacheTransactionalStoreReadFromBackupTest.class); + GridTestUtils.addTestIfNeeded(suite, GridStoreLoadCacheTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheStoreReadFromBackupTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheStoreWriteErrorTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheTransactionalStoreReadFromBackupTest.class, ignoredTests); - //suite.addTestSuite(CacheAtomicSingleMessageCountSelfTest.class); - //suite.addTestSuite(GridCacheAtomicUsersAffinityMapperSelfTest.class); - //suite.addTestSuite(GridCacheClearLocallySelfTest.class); - //suite.addTestSuite(GridCacheConcurrentGetCacheOnClientTest.class); - //suite.addTestSuite(GridCacheFullTextQueryMultithreadedSelfTest.class); - //suite.addTestSuite(GridCacheKeyCheckNearEnabledSelfTest.class); - //suite.addTestSuite(GridCacheKeyCheckSelfTest.class); - //suite.addTestSuite(GridCacheLeakTest.class); - //suite.addTestSuite(GridCacheMultiUpdateLockSelfTest.class); - //suite.addTestSuite(GridCacheMvccFlagsTest.class); - //suite.addTestSuite(GridCacheReplicatedUsersAffinityMapperSelfTest.class); - //suite.addTestSuite(GridCacheReturnValueTransferSelfTest.class); - //suite.addTestSuite(GridCacheSlowTxWarnTest.class); - //suite.addTestSuite(GridCacheTtlManagerLoadTest.class); - //suite.addTestSuite(GridCacheTxUsersAffinityMapperSelfTest.class); - //suite.addTestSuite(IgniteInternalCacheRemoveTest.class); - //suite.addTestSuite(IgniteCacheBinaryEntryProcessorSelfTest.class); - //suite.addTestSuite(IgniteCacheObjectPutSelfTest.class); - //suite.addTestSuite(IgniteCacheSerializationSelfTest.class); - //suite.addTestSuite(IgniteCacheStartStopLoadTest.class); - //suite.addTestSuite(IgniteCachingProviderSelfTest.class); - //suite.addTestSuite(IgniteOnePhaseCommitNearSelfTest.class); - //suite.addTestSuite(IgniteStaticCacheStartSelfTest.class); - //suite.addTestSuite(InterceptorWithKeepBinaryCacheFullApiTest.class); + //GridTestUtils.addTestIfNeeded(suite,CacheAtomicSingleMessageCountSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheAtomicUsersAffinityMapperSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheClearLocallySelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheConcurrentGetCacheOnClientTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheFullTextQueryMultithreadedSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheKeyCheckNearEnabledSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheKeyCheckSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheLeakTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheMultiUpdateLockSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheMvccFlagsTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedUsersAffinityMapperSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheReturnValueTransferSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheSlowTxWarnTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheTtlManagerLoadTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheTxUsersAffinityMapperSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteInternalCacheRemoveTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCacheBinaryEntryProcessorSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCacheObjectPutSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCacheSerializationSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCacheStartStopLoadTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCachingProviderSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteOnePhaseCommitNearSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteStaticCacheStartSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,InterceptorWithKeepBinaryCacheFullApiTest.class, ignoredTests); - suite.addTestSuite(BinaryMetadataRegistrationInsideEntryProcessorTest.class); + GridTestUtils.addTestIfNeeded(suite, BinaryMetadataRegistrationInsideEntryProcessorTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java index b8eb276af589c..fc86e479bf9d2 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java @@ -17,13 +17,12 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; - import org.apache.ignite.cache.affinity.rendezvous.ClusterNodeAttributeAffinityBackupFilterSelfTest; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionBackupFilterSelfTest; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionExcludeNeighborsSelfTest; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest; -import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionSelfTest; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionStandardHashSelfTest; import org.apache.ignite.internal.IgniteReflectionFactorySelfTest; import org.apache.ignite.internal.processors.cache.CacheComparatorTest; @@ -67,23 +66,18 @@ import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheClientNodeChangingTopologyTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheClientNodePartitionsExchangeTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheServerNodeConcurrentStart; +import org.apache.ignite.internal.processors.cache.distributed.dht.CacheGetReadFromBackupFailoverTest; import org.apache.ignite.internal.processors.cache.distributed.dht.CachePartitionPartialCountersMapSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedDebugTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedOptimisticTransactionSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedPreloadRestartSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedPrimarySyncSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedTxSingleThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtAtomicEvictionNearReadersSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtEntrySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtEntrySetSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtEvictionNearReadersSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtEvictionsDisabledSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtMappingSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtMultiBackupTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadBigDataSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadDelayedSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadMessageCountTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadMultiThreadedSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadOnheapSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadPutGetSelfTest; @@ -91,14 +85,10 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadStartStopSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtPreloadUnloadSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledLockSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledMetricsSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedTopologyChangeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedUnloadEventsSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheClearDuringRebalanceTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheContainsKeyColocatedSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePartitionedBackupNodeFailureRecoveryTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCrossCacheTxNearEnabledSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteTxConsistencyColocatedRestartSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearEvictionEventSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearMultiNodeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicNearReadersSelfTest; @@ -120,9 +110,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedBasicOpSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedBasicStoreMultiNodeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedBasicStoreSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedEntryLockSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedEventSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedEvictionSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedExplicitLockNodeFailureSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedGetAndTransformStoreSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedLoadCacheSelfTest; @@ -131,30 +119,20 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiNodeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiThreadedPutGetSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedNearDisabledBasicStoreMultiNodeSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedNestedTxTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedNodeFailureSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedPreloadLifecycleSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedStorePutSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxConcurrentGetTest; -import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxMultiNodeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxReadTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxSingleThreadedSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxTimeoutSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheRendezvousAffinityClientSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheStoreUpdateTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridPartitionedBackupLoadSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheContainsKeyNearSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheNearTxRollbackTest; -import org.apache.ignite.internal.processors.cache.distributed.near.NearCacheMultithreadedUpdateTest; -import org.apache.ignite.internal.processors.cache.distributed.near.NearCachePutAllMultinodeTest; import org.apache.ignite.internal.processors.cache.distributed.near.NearCacheSyncUpdateTest; import org.apache.ignite.internal.processors.cache.distributed.near.NoneRebalanceModeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedJobExecutionTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalAtomicBasicStoreSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalAtomicGetAndTransformStoreSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalBasicApiSelfTest; -import org.apache.ignite.internal.processors.cache.local.GridCacheLocalBasicStoreMultithreadedSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalBasicStoreSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalEventSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalEvictionEventSelfTest; @@ -164,197 +142,212 @@ import org.apache.ignite.internal.processors.cache.local.GridCacheLocalLockSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalMultithreadedSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalTxMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.local.GridCacheLocalTxReadTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalTxSingleThreadedSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalTxTimeoutSelfTest; import org.apache.ignite.internal.processors.cache.persistence.MemoryPolicyInitializationTest; import org.apache.ignite.internal.processors.continuous.IgniteNoCustomEventsOnNodeStart; -import org.apache.ignite.testframework.junits.GridAbstractTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheTestSuite2 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTestSuite2 { /** * @return IgniteCache test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); + public static TestSuite suite() { + return suite(null); + } + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("IgniteCache Test Suite part 2"); // Local cache. - suite.addTestSuite(GridCacheLocalBasicApiSelfTest.class); - suite.addTestSuite(GridCacheLocalBasicStoreSelfTest.class); - //suite.addTestSuite(GridCacheLocalBasicStoreMultithreadedSelfTest.class); - suite.addTestSuite(GridCacheLocalAtomicBasicStoreSelfTest.class); - suite.addTestSuite(GridCacheLocalGetAndTransformStoreSelfTest.class); - suite.addTestSuite(GridCacheLocalAtomicGetAndTransformStoreSelfTest.class); - suite.addTestSuite(GridCacheLocalLoadAllSelfTest.class); - suite.addTestSuite(GridCacheLocalLockSelfTest.class); - suite.addTestSuite(GridCacheLocalMultithreadedSelfTest.class); - suite.addTestSuite(GridCacheLocalTxSingleThreadedSelfTest.class); - //suite.addTestSuite(GridCacheLocalTxReadTest.class); - suite.addTestSuite(GridCacheLocalTxTimeoutSelfTest.class); - suite.addTestSuite(GridCacheLocalEventSelfTest.class); - suite.addTestSuite(GridCacheLocalEvictionEventSelfTest.class); - suite.addTestSuite(GridCacheVariableTopologySelfTest.class); - suite.addTestSuite(GridCacheLocalTxMultiThreadedSelfTest.class); - suite.addTestSuite(GridCacheTransformEventSelfTest.class); - suite.addTestSuite(GridCacheLocalIsolatedNodesSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalBasicApiSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalBasicStoreSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheLocalBasicStoreMultithreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalAtomicBasicStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalGetAndTransformStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalAtomicGetAndTransformStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalLoadAllSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalLockSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalMultithreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalTxSingleThreadedSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheLocalTxReadTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalTxTimeoutSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalEventSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalEvictionEventSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalTxMultiThreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheLocalIsolatedNodesSelfTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, GridCacheTransformEventSelfTest.class, ignoredTests); // Partitioned cache. - suite.addTestSuite(GridCachePartitionedGetSelfTest.class); - suite.addTest(new TestSuite(GridCachePartitionedBasicApiTest.class)); - suite.addTest(new TestSuite(GridCacheNearMultiGetSelfTest.class)); - suite.addTest(new TestSuite(NoneRebalanceModeSelfTest.class)); - suite.addTest(new TestSuite(GridCacheNearJobExecutionSelfTest.class)); - suite.addTest(new TestSuite(GridCacheReplicatedJobExecutionTest.class)); - suite.addTest(new TestSuite(GridCacheNearOneNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCacheNearMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCacheAtomicNearMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCacheNearReadersSelfTest.class)); - suite.addTest(new TestSuite(GridCacheNearReaderPreloadSelfTest.class)); - suite.addTest(new TestSuite(GridCacheAtomicNearReadersSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAffinitySelfTest.class)); - //suite.addTest(new TestSuite(RendezvousAffinityFunctionSelfTest.class)); - suite.addTest(new TestSuite(RendezvousAffinityFunctionExcludeNeighborsSelfTest.class)); - suite.addTest(new TestSuite(RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest.class)); - suite.addTest(new TestSuite(RendezvousAffinityFunctionStandardHashSelfTest.class)); - suite.addTest(new TestSuite(GridCacheRendezvousAffinityClientSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedProjectionAffinitySelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedBasicOpSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedBasicStoreSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedGetAndTransformStoreSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedAtomicGetAndTransformStoreSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedBasicStoreMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedNearDisabledBasicStoreMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedEventSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedLockSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedNearDisabledLockSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedMultiNodeLockSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedMultiThreadedPutGetSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedNodeFailureSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedExplicitLockNodeFailureSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedTxSingleThreadedSelfTest.class)); - //suite.addTest(new TestSuite(GridCachePartitionedEntryLockSelfTest.class)); - //suite.addTest(new TestSuite(GridCachePartitionedEvictionSelfTest.class)); - //suite.addTest(new TestSuite(GridCachePartitionedNestedTxTest.class)); - //suite.addTest(new TestSuite(GridCachePartitionedStorePutSelfTest.class)); - //suite.addTest(new TestSuite(GridCachePartitionedTxConcurrentGetTest.class)); - //suite.addTest(new TestSuite(GridCachePartitionedTxMultiNodeSelfTest.class)); - //suite.addTest(new TestSuite(GridCachePartitionedTxReadTest.class)); - suite.addTest(new TestSuite(GridCacheColocatedTxSingleThreadedSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedTxTimeoutSelfTest.class)); - suite.addTest(new TestSuite(GridCacheFinishPartitionsSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtEntrySelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtMappingSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedTxMultiThreadedSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedNearDisabledTxMultiThreadedSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtPreloadSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtPreloadOnheapSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtPreloadBigDataSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtPreloadPutGetSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtPreloadDisabledSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtPreloadMultiThreadedSelfTest.class)); - suite.addTest(new TestSuite(CacheDhtLocalPartitionAfterRemoveSelfTest.class)); - suite.addTest(new TestSuite(GridCacheColocatedPreloadRestartSelfTest.class)); - suite.addTest(new TestSuite(GridCacheNearPreloadRestartSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtPreloadStartStopSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtPreloadUnloadSelfTest.class)); - suite.addTest(new TestSuite(RendezvousAffinityFunctionBackupFilterSelfTest.class)); - suite.addTest(new TestSuite(ClusterNodeAttributeAffinityBackupFilterSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedPreloadLifecycleSelfTest.class)); - suite.addTest(new TestSuite(CacheLoadingConcurrentGridStartSelfTest.class)); - suite.addTest(new TestSuite(CacheLoadingConcurrentGridStartSelfTestAllowOverwrite.class)); - suite.addTest(new TestSuite(CacheTxLoadingConcurrentGridStartSelfTestAllowOverwrite.class)); - suite.addTest(new TestSuite(GridCacheDhtPreloadDelayedSelfTest.class)); - suite.addTest(new TestSuite(GridPartitionedBackupLoadSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedLoadCacheSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionNotLoadedEventSelfTest.class)); - suite.addTest(new TestSuite(GridCacheDhtEvictionsDisabledSelfTest.class)); - suite.addTest(new TestSuite(GridCacheNearEvictionEventSelfTest.class)); - suite.addTest(new TestSuite(GridCacheAtomicNearEvictionEventSelfTest.class)); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedGetSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedBasicApiTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedBasicOpSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearMultiGetSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, NoneRebalanceModeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearOneNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearMultiNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicNearMultiNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearReadersSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearReaderPreloadSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicNearReadersSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedGetAndTransformStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedAtomicGetAndTransformStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedBasicStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridNearCacheStoreUpdateTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedBasicStoreMultiNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedNearDisabledBasicStoreMultiNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheConcurrentReadThroughTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedLockSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedNearDisabledLockSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedMultiNodeLockSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedMultiNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedMultiThreadedPutGetSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedNodeFailureSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedExplicitLockNodeFailureSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheLockReleaseNodeLeaveTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedEntryLockSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedNestedTxTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedTxConcurrentGetTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedTxMultiNodeSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedTxReadTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedTxSingleThreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheColocatedTxSingleThreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedTxTimeoutSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheFinishPartitionsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedTxMultiThreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedNearDisabledTxMultiThreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtEntrySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtMappingSelfTest.class, ignoredTests); + + // Preload + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtPreloadSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtPreloadOnheapSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtPreloadBigDataSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtPreloadPutGetSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtPreloadDisabledSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtPreloadMultiThreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheColocatedPreloadRestartSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearPreloadRestartSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtPreloadStartStopSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtPreloadUnloadSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedPreloadLifecycleSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtPreloadDelayedSelfTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, CacheDhtLocalPartitionAfterRemoveSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheLoadingConcurrentGridStartSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheLoadingConcurrentGridStartSelfTestAllowOverwrite.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheTxLoadingConcurrentGridStartSelfTestAllowOverwrite.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridPartitionedBackupLoadSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheGetReadFromBackupFailoverTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedLoadCacheSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedEventSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionNotLoadedEventSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheDhtEvictionsDisabledSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearEvictionEventSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicNearEvictionEventSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedEvictionSelfTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedTopologyChangeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedUnloadEventsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheColocatedOptimisticTransactionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheAtomicMessageCountSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearPartitionedClearSelfTest.class, ignoredTests); - suite.addTest(new TestSuite(GridCachePartitionedTopologyChangeSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedUnloadEventsSelfTest.class)); - suite.addTest(new TestSuite(GridCacheColocatedOptimisticTransactionSelfTest.class)); - suite.addTestSuite(GridCacheAtomicMessageCountSelfTest.class); - suite.addTest(new TestSuite(GridCacheNearPartitionedClearSelfTest.class)); + GridTestUtils.addTestIfNeeded(suite, GridCacheOffheapUpdateSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearClientHitTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearPrimarySyncSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheColocatedPrimarySyncSelfTest.class, ignoredTests); - suite.addTest(new TestSuite(GridCacheOffheapUpdateSelfTest.class)); - suite.addTest(new TestSuite(GridCacheNearClientHitTest.class)); - suite.addTest(new TestSuite(GridCacheNearPrimarySyncSelfTest.class)); - suite.addTest(new TestSuite(GridCacheColocatedPrimarySyncSelfTest.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteCachePartitionMapUpdateTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheClientNodePartitionsExchangeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheClientNodeChangingTopologyTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheServerNodeConcurrentStart.class, ignoredTests); - suite.addTest(new TestSuite(IgniteCachePartitionMapUpdateTest.class)); - suite.addTest(new TestSuite(IgniteCacheClientNodePartitionsExchangeTest.class)); - suite.addTest(new TestSuite(IgniteCacheClientNodeChangingTopologyTest.class)); - suite.addTest(new TestSuite(IgniteCacheServerNodeConcurrentStart.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheEntryProcessorNodeJoinTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteAtomicCacheEntryProcessorNodeJoinTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheNearTxForceKeyTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CrossCacheTxRandomOperationsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CrossCacheTxNearEnabledRandomOperationsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteDynamicCacheAndNodeStop.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, NearCacheSyncUpdateTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheEnumOperationsSingleNodeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheEnumOperationsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheIncrementTxTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCachePartitionedBackupNodeFailureRecoveryTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheVariableTopologySelfTest.class, ignoredTests); - suite.addTest(new TestSuite(IgniteCacheEntryProcessorNodeJoinTest.class)); - suite.addTest(new TestSuite(IgniteAtomicCacheEntryProcessorNodeJoinTest.class)); - suite.addTest(new TestSuite(GridCacheNearTxForceKeyTest.class)); - suite.addTest(new TestSuite(CrossCacheTxRandomOperationsTest.class)); - suite.addTest(new TestSuite(CrossCacheTxNearEnabledRandomOperationsTest.class)); - suite.addTest(new TestSuite(IgniteDynamicCacheAndNodeStop.class)); - suite.addTest(new TestSuite(CacheLockReleaseNodeLeaveTest.class)); - suite.addTest(new TestSuite(NearCacheSyncUpdateTest.class)); - suite.addTest(new TestSuite(CacheConfigurationLeakTest.class)); - suite.addTest(new TestSuite(MemoryPolicyConfigValidationTest.class)); - suite.addTest(new TestSuite(MemoryPolicyInitializationTest.class)); - suite.addTest(new TestSuite(CacheGroupLocalConfigurationSelfTest.class)); - suite.addTest(new TestSuite(CacheEnumOperationsSingleNodeTest.class)); - suite.addTest(new TestSuite(CacheEnumOperationsTest.class)); - suite.addTest(new TestSuite(IgniteCacheIncrementTxTest.class)); - suite.addTest(new TestSuite(IgniteCachePartitionedBackupNodeFailureRecoveryTest.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteNoCustomEventsOnNodeStart.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheExchangeMessageDuplicatedStateTest.class, ignoredTests); - suite.addTest(new TestSuite(IgniteNoCustomEventsOnNodeStart.class)); + //GridTestUtils.addTestIfNeeded(suite,NearCacheMultithreadedUpdateTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,NearCachePutAllMultinodeTest.class, ignoredTests); - suite.addTest(new TestSuite(CacheExchangeMessageDuplicatedStateTest.class)); - suite.addTest(new TestSuite(CacheConcurrentReadThroughTest.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteOnePhaseCommitInvokeTest.class, ignoredTests); - suite.addTest(new TestSuite(GridNearCacheStoreUpdateTest.class)); - //suite.addTest(new TestSuite(NearCacheMultithreadedUpdateTest.class)); - //suite.addTest(new TestSuite(NearCachePutAllMultinodeTest.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheNoSyncForGetTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCacheContainsKeyNearSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCacheNearTxRollbackTest.class, ignoredTests); - suite.addTest(new TestSuite(IgniteOnePhaseCommitInvokeTest.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteOnePhaseCommitNearReadersTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteNearClientCacheCloseTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteClientCacheStartFailoverTest.class, ignoredTests); - suite.addTest(new TestSuite(IgniteCacheNoSyncForGetTest.class)); - //suite.addTest(new TestSuite(IgniteCacheContainsKeyNearSelfTest.class)); - //suite.addTest(new TestSuite(IgniteCacheNearTxRollbackTest.class)); + GridTestUtils.addTestIfNeeded(suite, CacheOptimisticTransactionsWithFilterSingleServerTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheOptimisticTransactionsWithFilterTest.class, ignoredTests); - suite.addTest(new TestSuite(IgniteOnePhaseCommitNearReadersTest.class)); - suite.addTest(new TestSuite(IgniteNearClientCacheCloseTest.class)); - suite.addTest(new TestSuite(IgniteClientCacheStartFailoverTest.class)); + GridTestUtils.addTestIfNeeded(suite, NonAffinityCoordinatorDynamicStartStopTest.class, ignoredTests); - suite.addTest(new TestSuite(CacheOptimisticTransactionsWithFilterSingleServerTest.class)); - suite.addTest(new TestSuite(CacheOptimisticTransactionsWithFilterTest.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheClearDuringRebalanceTest.class, ignoredTests); - suite.addTest(new TestSuite(NonAffinityCoordinatorDynamicStartStopTest.class)); + //GridTestUtils.addTestIfNeeded(suite,GridCacheColocatedDebugTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite, GridCacheDhtAtomicEvictionNearReadersSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheDhtEntrySetSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheDhtEvictionNearReadersSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheDhtMultiBackupTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheDhtPreloadMessageCountTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedNearDisabledMetricsSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCacheContainsKeyColocatedSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCrossCacheTxNearEnabledSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteTxConsistencyColocatedRestartSelfTest.class, ignoredTests); - suite.addTest(new TestSuite(IgniteCacheClearDuringRebalanceTest.class)); + // Configuration validation + GridTestUtils.addTestIfNeeded(suite, CacheConfigurationLeakTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, MemoryPolicyConfigValidationTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, MemoryPolicyInitializationTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheGroupLocalConfigurationSelfTest.class, ignoredTests); - suite.addTest(new TestSuite(CachePartitionStateTest.class)); + // Affinity and collocation + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedAffinitySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedProjectionAffinitySelfTest.class, ignoredTests); - suite.addTest(new TestSuite(CacheComparatorTest.class)); + // Other tests. + GridTestUtils.addTestIfNeeded(suite, GridCacheNearJobExecutionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheReplicatedJobExecutionTest.class, ignoredTests); - suite.addTest(new TestSuite(CachePartitionPartialCountersMapSelfTest.class)); + //GridTestUtils.addTestIfNeeded(suite,RendezvousAffinityFunctionSelfTest.class), ignoredTests); + GridTestUtils.addTestIfNeeded(suite, RendezvousAffinityFunctionExcludeNeighborsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, RendezvousAffinityFunctionStandardHashSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheRendezvousAffinityClientSelfTest.class, ignoredTests); - suite.addTest(new TestSuite(IgniteReflectionFactorySelfTest.class)); + GridTestUtils.addTestIfNeeded(suite, RendezvousAffinityFunctionBackupFilterSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, ClusterNodeAttributeAffinityBackupFilterSelfTest.class, ignoredTests); - //suite.addTest(new TestSuite(GridCacheColocatedDebugTest.class)); - //suite.addTest(new TestSuite(GridCacheDhtAtomicEvictionNearReadersSelfTest.class)); - //suite.addTest(new TestSuite(GridCacheDhtEntrySetSelfTest.class)); - //suite.addTest(new TestSuite(GridCacheDhtEvictionNearReadersSelfTest.class)); - //suite.addTest(new TestSuite(GridCacheDhtMultiBackupTest.class)); - //suite.addTest(new TestSuite(GridCacheDhtPreloadMessageCountTest.class)); - //suite.addTest(new TestSuite(GridCachePartitionedNearDisabledMetricsSelfTest.class)); - //suite.addTest(new TestSuite(IgniteCacheContainsKeyColocatedSelfTest.class)); - //suite.addTest(new TestSuite(IgniteCrossCacheTxNearEnabledSelfTest.class)); - //suite.addTest(new TestSuite(IgniteTxConsistencyColocatedRestartSelfTest.class)); + GridTestUtils.addTestIfNeeded(suite, CachePartitionStateTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheComparatorTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CachePartitionPartialCountersMapSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteReflectionFactorySelfTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java index 188a035646342..c97e638e4c847 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.CacheStartupInDeploymentModesTest; import org.apache.ignite.internal.processors.cache.GridCacheAtomicEntryProcessorDeploymentSelfTest; @@ -77,126 +78,132 @@ import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxSingleThreadedSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxTimeoutSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheSyncReplicatedPreloadSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.GridReplicatedTxPreloadTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.preloader.GridCacheReplicatedPreloadLifecycleSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.preloader.GridCacheReplicatedPreloadSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.preloader.GridCacheReplicatedPreloadStartStopEventsSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheDaemonNodeLocalSelfTest; import org.apache.ignite.internal.processors.cache.local.GridCacheLocalByteArrayValuesSelfTest; -import org.apache.ignite.testframework.junits.GridAbstractTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheTestSuite3 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTestSuite3 { /** * @return IgniteCache test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); + public static TestSuite suite() { + return suite(null); + } + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("IgniteCache Test Suite part 3"); - suite.addTestSuite(IgniteCacheGroupsTest.class); + GridTestUtils.addTestIfNeeded(suite,IgniteCacheGroupsTest.class, ignoredTests); // Value consistency tests. - suite.addTestSuite(GridCacheValueConsistencyAtomicSelfTest.class); - suite.addTestSuite(GridCacheValueConsistencyAtomicNearEnabledSelfTest.class); - suite.addTestSuite(GridCacheValueConsistencyTransactionalSelfTest.class); - suite.addTestSuite(GridCacheValueConsistencyTransactionalNearEnabledSelfTest.class); - suite.addTestSuite(GridCacheValueBytesPreloadingSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheValueConsistencyAtomicSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheValueConsistencyAtomicNearEnabledSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheValueConsistencyTransactionalSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheValueConsistencyTransactionalNearEnabledSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheValueBytesPreloadingSelfTest.class, ignoredTests); // Replicated cache. - suite.addTestSuite(GridCacheReplicatedBasicApiTest.class); - suite.addTestSuite(GridCacheReplicatedBasicOpSelfTest.class); - suite.addTestSuite(GridCacheReplicatedBasicStoreSelfTest.class); - suite.addTestSuite(GridCacheReplicatedGetAndTransformStoreSelfTest.class); - suite.addTestSuite(GridCacheReplicatedAtomicGetAndTransformStoreSelfTest.class); - suite.addTestSuite(GridCacheReplicatedEventSelfTest.class); - suite.addTestSuite(GridCacheReplicatedEventDisabledSelfTest.class); - suite.addTestSuite(GridCacheReplicatedSynchronousCommitTest.class); - - suite.addTestSuite(GridCacheReplicatedLockSelfTest.class); - suite.addTestSuite(GridCacheReplicatedMultiNodeLockSelfTest.class); - suite.addTestSuite(GridCacheReplicatedMultiNodeSelfTest.class); - suite.addTestSuite(GridCacheReplicatedNodeFailureSelfTest.class); - suite.addTestSuite(GridCacheReplicatedTxSingleThreadedSelfTest.class); - suite.addTestSuite(GridCacheReplicatedTxTimeoutSelfTest.class); - suite.addTestSuite(GridCacheReplicatedPreloadSelfTest.class); - suite.addTestSuite(GridCacheReplicatedPreloadLifecycleSelfTest.class); - suite.addTestSuite(GridCacheSyncReplicatedPreloadSelfTest.class); - - //suite.addTestSuite(GridCacheReplicatedEntrySetSelfTest.class); - //suite.addTestSuite(GridCacheReplicatedMarshallerTxTest.class); - //suite.addTestSuite(GridCacheReplicatedOnheapFullApiSelfTest.class); - //suite.addTestSuite(GridCacheReplicatedOnheapMultiNodeFullApiSelfTest.class); - //suite.addTestSuite(GridCacheReplicatedTxConcurrentGetTest.class); - //suite.addTestSuite(GridCacheReplicatedTxMultiNodeBasicTest.class); - //suite.addTestSuite(GridCacheReplicatedTxReadTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedBasicApiTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedBasicOpSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedBasicStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedGetAndTransformStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedAtomicGetAndTransformStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedEventSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedEventDisabledSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedSynchronousCommitTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedLockSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedMultiNodeLockSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedMultiNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedNodeFailureSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedTxSingleThreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedTxTimeoutSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedPreloadSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedPreloadLifecycleSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheSyncReplicatedPreloadSelfTest.class, ignoredTests); + + //GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedEntrySetSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedMarshallerTxTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedOnheapFullApiSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedOnheapMultiNodeFullApiSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedTxConcurrentGetTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedTxMultiNodeBasicTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedTxReadTest.class, ignoredTests); // TODO GG-11141. -// suite.addTestSuite(GridCacheDeploymentSelfTest.class); -// suite.addTestSuite(GridCacheDeploymentOffHeapSelfTest.class); -// suite.addTestSuite(GridCacheDeploymentOffHeapValuesSelfTest.class); - suite.addTestSuite(CacheStartupInDeploymentModesTest.class); - suite.addTestSuite(GridCacheConditionalDeploymentSelfTest.class); - suite.addTestSuite(GridCacheAtomicEntryProcessorDeploymentSelfTest.class); - suite.addTestSuite(GridCacheTransactionalEntryProcessorDeploymentSelfTest.class); - suite.addTestSuite(IgniteCacheScanPredicateDeploymentSelfTest.class); - - suite.addTestSuite(GridCachePutArrayValueSelfTest.class); - suite.addTestSuite(GridCacheReplicatedEvictionEventSelfTest.class); - suite.addTestSuite(GridCacheReplicatedTxMultiThreadedSelfTest.class); - suite.addTestSuite(GridCacheReplicatedPreloadEventsSelfTest.class); - suite.addTestSuite(GridCacheReplicatedPreloadStartStopEventsSelfTest.class); - suite.addTestSuite(GridReplicatedTxPreloadTest.class); - - suite.addTestSuite(IgniteTxReentryNearSelfTest.class); - suite.addTestSuite(IgniteTxReentryColocatedSelfTest.class); +// GridTestUtils.addTestIfNeeded(suite,GridCacheDeploymentSelfTest.class, ignoredTests); +// GridTestUtils.addTestIfNeeded(suite,GridCacheDeploymentOffHeapSelfTest.class, ignoredTests); +// GridTestUtils.addTestIfNeeded(suite,GridCacheDeploymentOffHeapValuesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,CacheStartupInDeploymentModesTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheConditionalDeploymentSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheAtomicEntryProcessorDeploymentSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheTransactionalEntryProcessorDeploymentSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteCacheScanPredicateDeploymentSelfTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite,GridCachePutArrayValueSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedEvictionEventSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedTxMultiThreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedPreloadEventsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedPreloadStartStopEventsSelfTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite,IgniteTxReentryNearSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteTxReentryColocatedSelfTest.class, ignoredTests); // Test for byte array value special case. - suite.addTestSuite(GridCacheLocalByteArrayValuesSelfTest.class); - suite.addTestSuite(GridCacheNearPartitionedP2PEnabledByteArrayValuesSelfTest.class); - suite.addTestSuite(GridCacheNearPartitionedP2PDisabledByteArrayValuesSelfTest.class); - suite.addTestSuite(GridCachePartitionedOnlyP2PEnabledByteArrayValuesSelfTest.class); - suite.addTestSuite(GridCachePartitionedOnlyP2PDisabledByteArrayValuesSelfTest.class); - suite.addTestSuite(GridCacheReplicatedP2PEnabledByteArrayValuesSelfTest.class); - suite.addTestSuite(GridCacheReplicatedP2PDisabledByteArrayValuesSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheLocalByteArrayValuesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheNearPartitionedP2PEnabledByteArrayValuesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheNearPartitionedP2PDisabledByteArrayValuesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedOnlyP2PEnabledByteArrayValuesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedOnlyP2PDisabledByteArrayValuesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedP2PEnabledByteArrayValuesSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReplicatedP2PDisabledByteArrayValuesSelfTest.class, ignoredTests); // Near-only cache. - suite.addTest(IgniteCacheNearOnlySelfTestSuite.suite()); + suite.addTest(IgniteCacheNearOnlySelfTestSuite.suite(ignoredTests)); // Test cache with daemon nodes. - suite.addTestSuite(GridCacheDaemonNodeLocalSelfTest.class); - suite.addTestSuite(GridCacheDaemonNodePartitionedSelfTest.class); - suite.addTestSuite(GridCacheDaemonNodeReplicatedSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheDaemonNodeLocalSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheDaemonNodePartitionedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheDaemonNodeReplicatedSelfTest.class, ignoredTests); // Write-behind. - suite.addTest(IgniteCacheWriteBehindTestSuite.suite()); + suite.addTest(IgniteCacheWriteBehindTestSuite.suite(ignoredTests)); // Transform. - suite.addTestSuite(GridCachePartitionedTransformWriteThroughBatchUpdateSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCachePartitionedTransformWriteThroughBatchUpdateSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheEntryVersionSelfTest.class); - suite.addTestSuite(GridCacheVersionSelfTest.class); - suite.addTestSuite(GridCacheVersionTopologyChangeTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheEntryVersionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheVersionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheVersionTopologyChangeTest.class, ignoredTests); // Memory leak tests. - suite.addTestSuite(GridCacheReferenceCleanupSelfTest.class); - suite.addTestSuite(GridCacheReloadSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheReferenceCleanupSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,GridCacheReloadSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheMixedModeSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheMixedModeSelfTest.class, ignoredTests); // Cache interceptor tests. - suite.addTest(IgniteCacheInterceptorSelfTestSuite.suite()); + suite.addTest(IgniteCacheInterceptorSelfTestSuite.suite(ignoredTests)); - suite.addTestSuite(IgniteTxGetAfterStopTest.class); + GridTestUtils.addTestIfNeeded(suite,IgniteTxGetAfterStopTest.class, ignoredTests); - suite.addTestSuite(CacheAsyncOperationsTest.class); + GridTestUtils.addTestIfNeeded(suite,CacheAsyncOperationsTest.class, ignoredTests); - suite.addTestSuite(IgniteTxRemoveTimeoutObjectsTest.class); - suite.addTestSuite(IgniteTxRemoveTimeoutObjectsNearTest.class); + GridTestUtils.addTestIfNeeded(suite,IgniteTxRemoveTimeoutObjectsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteTxRemoveTimeoutObjectsNearTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java index cb4be142db58a..d1b7d07fbf958 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import java.util.HashSet; import junit.framework.TestSuite; import org.apache.ignite.cache.store.CacheStoreListenerRWThroughDisabledAtomicCacheTest; import org.apache.ignite.cache.store.CacheStoreListenerRWThroughDisabledTransactionalCacheTest; @@ -26,12 +27,12 @@ import org.apache.ignite.internal.processors.GridCacheTxLoadFromStoreOnLockSelfTest; import org.apache.ignite.internal.processors.cache.CacheClientStoreSelfTest; import org.apache.ignite.internal.processors.cache.CacheConnectionLeakStoreTxTest; -import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticReadCommittedSeltTest; -import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticRepeatableReadSeltTest; -import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticSerializableSeltTest; -import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticReadCommittedSeltTest; -import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticRepeatableReadSeltTest; -import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticSerializableSeltTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticReadCommittedSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticRepeatableReadSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticSerializableSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticReadCommittedSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticRepeatableReadSelfTest; +import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticSerializableSelfTest; import org.apache.ignite.internal.processors.cache.CacheOffheapMapEntrySelfTest; import org.apache.ignite.internal.processors.cache.CacheReadThroughAtomicRestartSelfTest; import org.apache.ignite.internal.processors.cache.CacheReadThroughLocalAtomicRestartSelfTest; @@ -97,12 +98,12 @@ import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionSelfTest; import org.apache.ignite.internal.processors.cache.IgniteSystemCacheOnClientTest; import org.apache.ignite.internal.processors.cache.MarshallerCacheJobRunNodeRestartTest; -import org.apache.ignite.internal.processors.cache.distributed.CacheResultIsNotNullOnPartitionLossTest; import org.apache.ignite.internal.processors.cache.distributed.CacheAffinityEarlyTest; import org.apache.ignite.internal.processors.cache.distributed.CacheDiscoveryDataConcurrentJoinTest; import org.apache.ignite.internal.processors.cache.distributed.CacheGetFutureHangsSelfTest; import org.apache.ignite.internal.processors.cache.distributed.CacheGroupsPreloadTest; import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClassOnServerNodeTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheResultIsNotNullOnPartitionLossTest; import org.apache.ignite.internal.processors.cache.distributed.CacheStartOnJoinTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheCreatePutMultiNodeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheCreatePutTest; @@ -153,195 +154,204 @@ import org.apache.ignite.internal.processors.cache.version.CacheVersionedEntryPartitionedTransactionalSelfTest; import org.apache.ignite.internal.processors.cache.version.CacheVersionedEntryReplicatedAtomicSelfTest; import org.apache.ignite.internal.processors.cache.version.CacheVersionedEntryReplicatedTransactionalSelfTest; -import org.apache.ignite.testframework.junits.GridAbstractTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +import static org.apache.ignite.testframework.GridTestUtils.addTestIfNeeded; /** * Test suite. */ -public class IgniteCacheTestSuite4 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTestSuite4 { /** * @return IgniteCache test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); + public static TestSuite suite() { + return suite(null); + } + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(HashSet ignoredTests) { TestSuite suite = new TestSuite("IgniteCache Test Suite part 4"); // Multi node update. - suite.addTestSuite(GridCacheMultinodeUpdateSelfTest.class); - suite.addTestSuite(GridCacheMultinodeUpdateNearEnabledSelfTest.class); - suite.addTestSuite(GridCacheMultinodeUpdateNearEnabledNoBackupsSelfTest.class); - suite.addTestSuite(GridCacheMultinodeUpdateAtomicSelfTest.class); - suite.addTestSuite(GridCacheMultinodeUpdateAtomicNearEnabledSelfTest.class); - - suite.addTestSuite(IgniteCacheAtomicLoadAllTest.class); - suite.addTestSuite(IgniteCacheAtomicLocalLoadAllTest.class); - suite.addTestSuite(IgniteCacheTxLoadAllTest.class); - suite.addTestSuite(IgniteCacheTxLocalLoadAllTest.class); - - suite.addTestSuite(IgniteCacheAtomicLoaderWriterTest.class); - suite.addTestSuite(IgniteCacheTxLoaderWriterTest.class); - - suite.addTestSuite(IgniteCacheAtomicStoreSessionTest.class); - suite.addTestSuite(IgniteCacheTxStoreSessionTest.class); - suite.addTestSuite(IgniteCacheAtomicStoreSessionWriteBehindTest.class); - suite.addTestSuite(IgniteCacheTxStoreSessionWriteBehindTest.class); - suite.addTestSuite(IgniteCacheTxStoreSessionWriteBehindCoalescingTest.class); - - suite.addTestSuite(IgniteCacheAtomicNoReadThroughTest.class); - suite.addTestSuite(IgniteCacheAtomicNearEnabledNoReadThroughTest.class); - suite.addTestSuite(IgniteCacheAtomicLocalNoReadThroughTest.class); - suite.addTestSuite(IgniteCacheTxNoReadThroughTest.class); - suite.addTestSuite(IgniteCacheTxNearEnabledNoReadThroughTest.class); - suite.addTestSuite(IgniteCacheTxLocalNoReadThroughTest.class); - - suite.addTestSuite(IgniteCacheAtomicNoLoadPreviousValueTest.class); - suite.addTestSuite(IgniteCacheAtomicNearEnabledNoLoadPreviousValueTest.class); - suite.addTestSuite(IgniteCacheAtomicLocalNoLoadPreviousValueTest.class); - suite.addTestSuite(IgniteCacheTxNoLoadPreviousValueTest.class); - suite.addTestSuite(IgniteCacheTxNearEnabledNoLoadPreviousValueTest.class); - suite.addTestSuite(IgniteCacheTxLocalNoLoadPreviousValueTest.class); - - suite.addTestSuite(IgniteCacheAtomicNoWriteThroughTest.class); - suite.addTestSuite(IgniteCacheAtomicNearEnabledNoWriteThroughTest.class); - suite.addTestSuite(IgniteCacheAtomicLocalNoWriteThroughTest.class); - suite.addTestSuite(IgniteCacheTxNoWriteThroughTest.class); - suite.addTestSuite(IgniteCacheTxNearEnabledNoWriteThroughTest.class); - suite.addTestSuite(IgniteCacheTxLocalNoWriteThroughTest.class); - - suite.addTestSuite(IgniteCacheAtomicPeekModesTest.class); - suite.addTestSuite(IgniteCacheAtomicNearPeekModesTest.class); - suite.addTestSuite(IgniteCacheAtomicReplicatedPeekModesTest.class); - suite.addTestSuite(IgniteCacheAtomicLocalPeekModesTest.class); - suite.addTestSuite(IgniteCacheTxPeekModesTest.class); - suite.addTestSuite(IgniteCacheTxNearPeekModesTest.class); - suite.addTestSuite(IgniteCacheTxLocalPeekModesTest.class); - suite.addTestSuite(IgniteCacheTxReplicatedPeekModesTest.class); - - suite.addTestSuite(IgniteCacheInvokeReadThroughSingleNodeTest.class); - suite.addTestSuite(IgniteCacheInvokeReadThroughTest.class); - suite.addTestSuite(IgniteCacheReadThroughStoreCallTest.class); - suite.addTestSuite(GridCacheVersionMultinodeTest.class); - - suite.addTestSuite(IgniteCacheNearReadCommittedTest.class); - suite.addTestSuite(IgniteCacheAtomicCopyOnReadDisabledTest.class); - suite.addTestSuite(IgniteCacheTxCopyOnReadDisabledTest.class); - - suite.addTestSuite(IgniteCacheTxPreloadNoWriteTest.class); - - suite.addTestSuite(IgniteDynamicCacheStartSelfTest.class); - suite.addTestSuite(IgniteDynamicCacheMultinodeTest.class); - suite.addTestSuite(IgniteDynamicCacheStartFailTest.class); - suite.addTestSuite(IgniteDynamicCacheStartCoordinatorFailoverTest.class); - suite.addTestSuite(IgniteDynamicCacheWithConfigStartSelfTest.class); - suite.addTestSuite(IgniteCacheDynamicStopSelfTest.class); - suite.addTestSuite(IgniteDynamicCacheStartStopConcurrentTest.class); - suite.addTestSuite(IgniteCacheConfigurationTemplateTest.class); - suite.addTestSuite(IgniteCacheConfigurationDefaultTemplateTest.class); - suite.addTestSuite(IgniteDynamicClientCacheStartSelfTest.class); - suite.addTestSuite(IgniteDynamicCacheStartNoExchangeTimeoutTest.class); - suite.addTestSuite(CacheAffinityEarlyTest.class); - suite.addTestSuite(IgniteCacheCreatePutMultiNodeSelfTest.class); - suite.addTestSuite(IgniteCacheCreatePutTest.class); - suite.addTestSuite(CacheStartOnJoinTest.class); - suite.addTestSuite(IgniteCacheStartTest.class); - suite.addTestSuite(CacheDiscoveryDataConcurrentJoinTest.class); - suite.addTestSuite(IgniteClientCacheInitializationFailTest.class); - suite.addTestSuite(IgniteCacheFailedUpdateResponseTest.class); - - suite.addTestSuite(GridCacheTxLoadFromStoreOnLockSelfTest.class); - - suite.addTestSuite(GridCacheMarshallingNodeJoinSelfTest.class); - - suite.addTestSuite(IgniteCacheJdbcBlobStoreNodeRestartTest.class); - - suite.addTestSuite(IgniteCacheAtomicLocalStoreValueTest.class); - suite.addTestSuite(IgniteCacheAtomicStoreValueTest.class); - suite.addTestSuite(IgniteCacheAtomicNearEnabledStoreValueTest.class); - suite.addTestSuite(IgniteCacheTxLocalStoreValueTest.class); - suite.addTestSuite(IgniteCacheTxStoreValueTest.class); - suite.addTestSuite(IgniteCacheTxNearEnabledStoreValueTest.class); - - suite.addTestSuite(IgniteCacheLockFailoverSelfTest.class); - suite.addTestSuite(IgniteCacheMultiTxLockSelfTest.class); - - suite.addTestSuite(IgniteInternalCacheTypesTest.class); - - suite.addTestSuite(IgniteExchangeFutureHistoryTest.class); - - suite.addTestSuite(CacheNoValueClassOnServerNodeTest.class); - suite.addTestSuite(IgniteSystemCacheOnClientTest.class); - - suite.addTestSuite(CacheRemoveAllSelfTest.class); - suite.addTestSuite(CacheGetEntryOptimisticReadCommittedSeltTest.class); - suite.addTestSuite(CacheGetEntryOptimisticRepeatableReadSeltTest.class); - suite.addTestSuite(CacheGetEntryOptimisticSerializableSeltTest.class); - suite.addTestSuite(CacheGetEntryPessimisticReadCommittedSeltTest.class); - suite.addTestSuite(CacheGetEntryPessimisticRepeatableReadSeltTest.class); - suite.addTestSuite(CacheGetEntryPessimisticSerializableSeltTest.class); - suite.addTestSuite(CacheTxNotAllowReadFromBackupTest.class); - - suite.addTestSuite(CacheStopAndDestroySelfTest.class); - - suite.addTestSuite(CacheOffheapMapEntrySelfTest.class); - - suite.addTestSuite(CacheJdbcStoreSessionListenerSelfTest.class); - suite.addTestSuite(CacheStoreSessionListenerLifecycleSelfTest.class); - suite.addTestSuite(CacheStoreListenerRWThroughDisabledAtomicCacheTest.class); - suite.addTestSuite(CacheStoreListenerRWThroughDisabledTransactionalCacheTest.class); - suite.addTestSuite(CacheStoreSessionListenerWriteBehindEnabledTest.class); - - suite.addTestSuite(CacheClientStoreSelfTest.class); - suite.addTestSuite(CacheStoreUsageMultinodeStaticStartAtomicTest.class); - suite.addTestSuite(CacheStoreUsageMultinodeStaticStartTxTest.class); - suite.addTestSuite(CacheStoreUsageMultinodeDynamicStartAtomicTest.class); - suite.addTestSuite(CacheStoreUsageMultinodeDynamicStartTxTest.class); - suite.addTestSuite(CacheConnectionLeakStoreTxTest.class); - - suite.addTestSuite(GridCacheStoreManagerDeserializationTest.class); - suite.addTestSuite(GridLocalCacheStoreManagerDeserializationTest.class); - - suite.addTestSuite(IgniteStartCacheInTransactionSelfTest.class); - suite.addTestSuite(IgniteStartCacheInTransactionAtomicSelfTest.class); - - suite.addTestSuite(CacheReadThroughRestartSelfTest.class); - suite.addTestSuite(CacheReadThroughReplicatedRestartSelfTest.class); - suite.addTestSuite(CacheReadThroughReplicatedAtomicRestartSelfTest.class); - suite.addTestSuite(CacheReadThroughLocalRestartSelfTest.class); - suite.addTestSuite(CacheReadThroughLocalAtomicRestartSelfTest.class); - suite.addTestSuite(CacheReadThroughAtomicRestartSelfTest.class); + addTestIfNeeded(suite, GridCacheMultinodeUpdateSelfTest.class, ignoredTests); + addTestIfNeeded(suite, GridCacheMultinodeUpdateNearEnabledSelfTest.class, ignoredTests); + addTestIfNeeded(suite, GridCacheMultinodeUpdateNearEnabledNoBackupsSelfTest.class, ignoredTests); + addTestIfNeeded(suite, GridCacheMultinodeUpdateAtomicSelfTest.class, ignoredTests); + addTestIfNeeded(suite, GridCacheMultinodeUpdateAtomicNearEnabledSelfTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheAtomicLoadAllTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicLocalLoadAllTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxLoadAllTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxLocalLoadAllTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheAtomicLoaderWriterTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxLoaderWriterTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheAtomicStoreSessionTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxStoreSessionTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicStoreSessionWriteBehindTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxStoreSessionWriteBehindTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxStoreSessionWriteBehindCoalescingTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheAtomicNoReadThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicNearEnabledNoReadThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicLocalNoReadThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxNoReadThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxNearEnabledNoReadThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxLocalNoReadThroughTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheAtomicNoLoadPreviousValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicNearEnabledNoLoadPreviousValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicLocalNoLoadPreviousValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxNoLoadPreviousValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxNearEnabledNoLoadPreviousValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxLocalNoLoadPreviousValueTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheAtomicNoWriteThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicNearEnabledNoWriteThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicLocalNoWriteThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxNoWriteThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxNearEnabledNoWriteThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxLocalNoWriteThroughTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheAtomicPeekModesTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicNearPeekModesTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicReplicatedPeekModesTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicLocalPeekModesTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxPeekModesTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxNearPeekModesTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxLocalPeekModesTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxReplicatedPeekModesTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheInvokeReadThroughSingleNodeTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheInvokeReadThroughTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheReadThroughStoreCallTest.class, ignoredTests); + addTestIfNeeded(suite, GridCacheVersionMultinodeTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheNearReadCommittedTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicCopyOnReadDisabledTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxCopyOnReadDisabledTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheTxPreloadNoWriteTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteDynamicCacheStartSelfTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteDynamicCacheMultinodeTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteDynamicCacheStartFailTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteDynamicCacheStartCoordinatorFailoverTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteDynamicCacheWithConfigStartSelfTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheDynamicStopSelfTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteDynamicCacheStartStopConcurrentTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheConfigurationTemplateTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheConfigurationDefaultTemplateTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteDynamicClientCacheStartSelfTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteDynamicCacheStartNoExchangeTimeoutTest.class, ignoredTests); + addTestIfNeeded(suite, CacheAffinityEarlyTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheCreatePutMultiNodeSelfTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheCreatePutTest.class, ignoredTests); + addTestIfNeeded(suite, CacheStartOnJoinTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheStartTest.class, ignoredTests); + addTestIfNeeded(suite, CacheDiscoveryDataConcurrentJoinTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteClientCacheInitializationFailTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheFailedUpdateResponseTest.class, ignoredTests); + + addTestIfNeeded(suite, GridCacheTxLoadFromStoreOnLockSelfTest.class, ignoredTests); + + addTestIfNeeded(suite, GridCacheMarshallingNodeJoinSelfTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheJdbcBlobStoreNodeRestartTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheAtomicLocalStoreValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicStoreValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheAtomicNearEnabledStoreValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxLocalStoreValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxStoreValueTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheTxNearEnabledStoreValueTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteCacheLockFailoverSelfTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheMultiTxLockSelfTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteInternalCacheTypesTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteExchangeFutureHistoryTest.class, ignoredTests); + + addTestIfNeeded(suite, CacheNoValueClassOnServerNodeTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteSystemCacheOnClientTest.class, ignoredTests); + + addTestIfNeeded(suite, CacheRemoveAllSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheGetEntryOptimisticReadCommittedSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheGetEntryOptimisticRepeatableReadSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheGetEntryOptimisticSerializableSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheGetEntryPessimisticReadCommittedSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheGetEntryPessimisticRepeatableReadSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheGetEntryPessimisticSerializableSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheTxNotAllowReadFromBackupTest.class, ignoredTests); + + addTestIfNeeded(suite, CacheStopAndDestroySelfTest.class, ignoredTests); + + addTestIfNeeded(suite, CacheOffheapMapEntrySelfTest.class, ignoredTests); + + addTestIfNeeded(suite, CacheJdbcStoreSessionListenerSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheStoreSessionListenerLifecycleSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheStoreListenerRWThroughDisabledAtomicCacheTest.class, ignoredTests); + addTestIfNeeded(suite, CacheStoreListenerRWThroughDisabledTransactionalCacheTest.class, ignoredTests); + addTestIfNeeded(suite, CacheStoreSessionListenerWriteBehindEnabledTest.class, ignoredTests); + + addTestIfNeeded(suite, CacheClientStoreSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheStoreUsageMultinodeStaticStartAtomicTest.class, ignoredTests); + addTestIfNeeded(suite, CacheStoreUsageMultinodeStaticStartTxTest.class, ignoredTests); + addTestIfNeeded(suite, CacheStoreUsageMultinodeDynamicStartAtomicTest.class, ignoredTests); + addTestIfNeeded(suite, CacheStoreUsageMultinodeDynamicStartTxTest.class, ignoredTests); + addTestIfNeeded(suite, CacheConnectionLeakStoreTxTest.class, ignoredTests); + + addTestIfNeeded(suite, GridCacheStoreManagerDeserializationTest.class, ignoredTests); + addTestIfNeeded(suite, GridLocalCacheStoreManagerDeserializationTest.class, ignoredTests); + + addTestIfNeeded(suite, IgniteStartCacheInTransactionSelfTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteStartCacheInTransactionAtomicSelfTest.class, ignoredTests); + + addTestIfNeeded(suite, CacheReadThroughRestartSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheReadThroughReplicatedRestartSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheReadThroughReplicatedAtomicRestartSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheReadThroughLocalRestartSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheReadThroughLocalAtomicRestartSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheReadThroughAtomicRestartSelfTest.class, ignoredTests); // Versioned entry tests - suite.addTestSuite(CacheVersionedEntryLocalAtomicSwapDisabledSelfTest.class); - suite.addTestSuite(CacheVersionedEntryLocalTransactionalSelfTest.class); - suite.addTestSuite(CacheVersionedEntryPartitionedAtomicSelfTest.class); - suite.addTestSuite(CacheVersionedEntryPartitionedTransactionalSelfTest.class); - suite.addTestSuite(CacheVersionedEntryReplicatedAtomicSelfTest.class); - suite.addTestSuite(CacheVersionedEntryReplicatedTransactionalSelfTest.class); + addTestIfNeeded(suite, CacheVersionedEntryLocalAtomicSwapDisabledSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheVersionedEntryLocalTransactionalSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheVersionedEntryPartitionedAtomicSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheVersionedEntryPartitionedTransactionalSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheVersionedEntryReplicatedAtomicSelfTest.class, ignoredTests); + addTestIfNeeded(suite, CacheVersionedEntryReplicatedTransactionalSelfTest.class, ignoredTests); - suite.addTestSuite(GridCacheDhtTxPreloadSelfTest.class); - suite.addTestSuite(GridCacheNearTxPreloadSelfTest.class); - suite.addTestSuite(GridReplicatedTxPreloadTest.class); - suite.addTestSuite(CacheGroupsPreloadTest.class); + addTestIfNeeded(suite, GridCacheDhtTxPreloadSelfTest.class, ignoredTests); + addTestIfNeeded(suite, GridCacheNearTxPreloadSelfTest.class, ignoredTests); + addTestIfNeeded(suite, GridReplicatedTxPreloadTest.class, ignoredTests); + addTestIfNeeded(suite, CacheGroupsPreloadTest.class, ignoredTests); - suite.addTestSuite(IgniteDynamicCacheFilterTest.class); + addTestIfNeeded(suite, IgniteDynamicCacheFilterTest.class, ignoredTests); - suite.addTestSuite(CrossCacheLockTest.class); - suite.addTestSuite(IgniteCrossCacheTxSelfTest.class); + addTestIfNeeded(suite, CrossCacheLockTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCrossCacheTxSelfTest.class, ignoredTests); - suite.addTestSuite(CacheGetFutureHangsSelfTest.class); + addTestIfNeeded(suite, CacheGetFutureHangsSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteCacheSingleGetMessageTest.class); - suite.addTestSuite(IgniteCacheReadFromBackupTest.class); + addTestIfNeeded(suite, IgniteCacheSingleGetMessageTest.class, ignoredTests); + addTestIfNeeded(suite, IgniteCacheReadFromBackupTest.class, ignoredTests); - suite.addTestSuite(MarshallerCacheJobRunNodeRestartTest.class); + addTestIfNeeded(suite, MarshallerCacheJobRunNodeRestartTest.class, ignoredTests); - suite.addTestSuite(IgniteCacheNearOnlyTxTest.class); + addTestIfNeeded(suite, IgniteCacheNearOnlyTxTest.class, ignoredTests); - suite.addTestSuite(IgniteCacheContainsKeyAtomicTest.class); + addTestIfNeeded(suite, IgniteCacheContainsKeyAtomicTest.class, ignoredTests); - suite.addTestSuite(CacheResultIsNotNullOnPartitionLossTest.class); + addTestIfNeeded(suite, CacheResultIsNotNullOnPartitionLossTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java index dafc44f306081..16b84850a784c 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java @@ -17,6 +17,8 @@ package org.apache.ignite.testsuites; +import java.util.HashSet; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.GridCacheAffinityBackupsSelfTest; import org.apache.ignite.IgniteCacheAffinitySelfTest; @@ -29,6 +31,7 @@ import org.apache.ignite.internal.processors.cache.CacheNearReaderUpdateTest; import org.apache.ignite.internal.processors.cache.CacheRebalancingSelfTest; import org.apache.ignite.internal.processors.cache.CacheSerializableTransactionsTest; +import org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeTest; import org.apache.ignite.internal.processors.cache.ClusterStatePartitionedSelfTest; import org.apache.ignite.internal.processors.cache.ClusterStateReplicatedSelfTest; import org.apache.ignite.internal.processors.cache.ConcurrentCacheStartTest; @@ -43,74 +46,81 @@ import org.apache.ignite.internal.processors.cache.distributed.IgniteCachePartitionLossPolicySelfTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheTxIteratorSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.NotMappedPartitionInTxTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicPreloadSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.IgniteCacheAtomicProtocolTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.IgniteCacheContainsKeyColocatedAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.IgniteCacheContainsKeyNearAtomicSelfTest; import org.apache.ignite.internal.processors.cache.distributed.rebalancing.CacheManualRebalancingTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheSyncRebalanceModeSelfTest; import org.apache.ignite.internal.processors.cache.store.IgniteCacheWriteBehindNoUpdateSelfTest; -import org.apache.ignite.testframework.junits.GridAbstractTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheTestSuite5 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTestSuite5 { /** * @return IgniteCache test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); + public static TestSuite suite() { + return suite(null); + } + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(HashSet ignoredTests) { TestSuite suite = new TestSuite("IgniteCache Test Suite part 5"); - suite.addTestSuite(CacheSerializableTransactionsTest.class); - suite.addTestSuite(CacheNearReaderUpdateTest.class); - suite.addTestSuite(IgniteCacheStoreCollectionTest.class); - suite.addTestSuite(IgniteCacheWriteBehindNoUpdateSelfTest.class); - suite.addTestSuite(IgniteCachePutStackOverflowSelfTest.class); - suite.addTestSuite(CacheKeepBinaryTransactionTest.class); + GridTestUtils.addTestIfNeeded(suite,CacheSerializableTransactionsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,CacheNearReaderUpdateTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteCacheStoreCollectionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteCacheWriteBehindNoUpdateSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteCachePutStackOverflowSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,CacheKeepBinaryTransactionTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite,CacheLateAffinityAssignmentTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,CacheLateAffinityAssignmentNodeJoinValidationTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,EntryVersionConsistencyReadThroughTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteCacheSyncRebalanceModeSelfTest.class, ignoredTests); - suite.addTestSuite(CacheLateAffinityAssignmentTest.class); - suite.addTestSuite(CacheLateAffinityAssignmentNodeJoinValidationTest.class); - suite.addTestSuite(EntryVersionConsistencyReadThroughTest.class); - suite.addTestSuite(IgniteCacheSyncRebalanceModeSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReadThroughEvictionsVariationsSuite.class)); - suite.addTest(IgniteCacheReadThroughEvictionsVariationsSuite.suite()); - suite.addTestSuite(IgniteCacheTxIteratorSelfTest.class); + GridTestUtils.addTestIfNeeded(suite,IgniteCacheTxIteratorSelfTest.class, ignoredTests); - suite.addTestSuite(ClusterStatePartitionedSelfTest.class); - suite.addTestSuite(ClusterStateReplicatedSelfTest.class); - suite.addTestSuite(IgniteCachePartitionLossPolicySelfTest.class); - suite.addTestSuite(IgniteCacheGroupsPartitionLossPolicySelfTest.class); + GridTestUtils.addTestIfNeeded(suite,ClusterStatePartitionedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,ClusterStateReplicatedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,ClusterReadOnlyModeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteCachePartitionLossPolicySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteCacheGroupsPartitionLossPolicySelfTest.class, ignoredTests); - suite.addTestSuite(CacheRebalancingSelfTest.class); - suite.addTestSuite(CacheManualRebalancingTest.class); + GridTestUtils.addTestIfNeeded(suite,CacheRebalancingSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,CacheManualRebalancingTest.class, ignoredTests); // Affinity tests. - suite.addTestSuite(GridCacheAffinityBackupsSelfTest.class); - suite.addTestSuite(IgniteCacheAffinitySelfTest.class); - suite.addTestSuite(AffinityClientNodeSelfTest.class); - suite.addTestSuite(LocalAffinityFunctionTest.class); - suite.addTestSuite(AffinityHistoryCleanupTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCacheAffinityBackupsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,IgniteCacheAffinitySelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,AffinityClientNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,LocalAffinityFunctionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite,AffinityHistoryCleanupTest.class, ignoredTests); - suite.addTestSuite(AffinityDistributionLoggingTest.class); + GridTestUtils.addTestIfNeeded(suite,AffinityDistributionLoggingTest.class, ignoredTests); - suite.addTestSuite(IgniteCacheAtomicProtocolTest.class); + GridTestUtils.addTestIfNeeded(suite,IgniteCacheAtomicProtocolTest.class, ignoredTests); - suite.addTestSuite(PartitionsExchangeOnDiscoveryHistoryOverflowTest.class); + GridTestUtils.addTestIfNeeded(suite,PartitionsExchangeOnDiscoveryHistoryOverflowTest.class, ignoredTests); - suite.addTestSuite(GridCachePartitionExchangeManagerHistSizeTest.class); + GridTestUtils.addTestIfNeeded(suite,GridCachePartitionExchangeManagerHistSizeTest.class, ignoredTests); - suite.addTestSuite(NotMappedPartitionInTxTest.class); + GridTestUtils.addTestIfNeeded(suite,NotMappedPartitionInTxTest.class, ignoredTests); - suite.addTestSuite(ConcurrentCacheStartTest.class); + GridTestUtils.addTestIfNeeded(suite,ConcurrentCacheStartTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,GridCacheAtomicPreloadSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCacheContainsKeyColocatedAtomicSelfTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite,IgniteCacheContainsKeyNearAtomicSelfTest.class, ignoredTests); - //suite.addTestSuite(GridCacheAtomicPreloadSelfTest.class); - //suite.addTestSuite(IgniteCacheContainsKeyColocatedAtomicSelfTest.class); - //suite.addTestSuite(IgniteCacheContainsKeyNearAtomicSelfTest.class); return suite; } } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java index 1269d0d1bbb40..9469b2c1129cc 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite6.java @@ -17,7 +17,9 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; +import org.apache.ignite.internal.processors.cache.CacheNoAffinityExchangeTest; import org.apache.ignite.internal.processors.cache.PartitionedAtomicCacheGetsDistributionTest; import org.apache.ignite.internal.processors.cache.PartitionedTransactionalOptimisticCacheGetsDistributionTest; import org.apache.ignite.internal.processors.cache.PartitionedTransactionalPessimisticCacheGetsDistributionTest; @@ -27,15 +29,13 @@ import org.apache.ignite.internal.processors.cache.ReplicatedTransactionalPessimisticCacheGetsDistributionTest; import org.apache.ignite.internal.processors.cache.datastructures.IgniteExchangeLatchManagerCoordinatorFailTest; import org.apache.ignite.internal.processors.cache.distributed.CacheExchangeMergeTest; -import org.apache.ignite.internal.processors.cache.distributed.CachePartitionStateTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheParallelStartTest; import org.apache.ignite.internal.processors.cache.distributed.CacheTryLockMultithreadedTest; import org.apache.ignite.internal.processors.cache.distributed.GridCachePartitionEvictionDuringReadThroughSelfTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCache150ClientsTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheThreadLocalTxTest; -import org.apache.ignite.internal.processors.cache.distributed.IgniteOptimisticTxSuspendResumeMultiServerTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteOptimisticTxSuspendResumeTest; import org.apache.ignite.internal.processors.cache.distributed.IgnitePessimisticTxSuspendResumeTest; -import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingOrderingTest; import org.apache.ignite.internal.processors.cache.transactions.TxLabelTest; import org.apache.ignite.internal.processors.cache.transactions.TxMultiCacheAsyncOpsTest; import org.apache.ignite.internal.processors.cache.transactions.TxOnCachesStartTest; @@ -46,74 +46,85 @@ import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnIncorrectParamsTest; import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTimeoutNearCacheTest; import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTimeoutNoDeadlockDetectionTest; +import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTimeoutOnePhaseCommitTest; import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTimeoutTest; import org.apache.ignite.internal.processors.cache.transactions.TxRollbackOnTopologyChangeTest; import org.apache.ignite.internal.processors.cache.transactions.TxStateChangeEventTest; -import org.apache.ignite.testframework.junits.GridAbstractTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheTestSuite6 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTestSuite6 { /** * @return IgniteCache test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); + public static TestSuite suite() { + return suite(null); + } + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("IgniteCache Test Suite part 6"); - suite.addTestSuite(CachePartitionStateTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionEvictionDuringReadThroughSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteOptimisticTxSuspendResumeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePessimisticTxSuspendResumeTest.class, ignoredTests); - suite.addTestSuite(GridCachePartitionEvictionDuringReadThroughSelfTest.class); - suite.addTestSuite(IgniteOptimisticTxSuspendResumeTest.class); - suite.addTestSuite(IgniteOptimisticTxSuspendResumeMultiServerTest.class); - suite.addTestSuite(IgnitePessimisticTxSuspendResumeTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheExchangeMergeTest.class, ignoredTests); - suite.addTestSuite(CacheExchangeMergeTest.class); + GridTestUtils.addTestIfNeeded(suite, TxRollbackOnTimeoutTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, TxRollbackOnTimeoutNoDeadlockDetectionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, TxRollbackOnTimeoutNearCacheTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheThreadLocalTxTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, TxRollbackAsyncTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, TxRollbackAsyncNearCacheTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, TxRollbackOnTopologyChangeTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, TxRollbackOnTimeoutOnePhaseCommitTest.class, ignoredTests); - suite.addTestSuite(TxRollbackOnTimeoutTest.class); - suite.addTestSuite(TxRollbackOnTimeoutNoDeadlockDetectionTest.class); - suite.addTestSuite(TxRollbackOnTimeoutNearCacheTest.class); - suite.addTestSuite(IgniteCacheThreadLocalTxTest.class); - suite.addTestSuite(TxRollbackAsyncTest.class); - suite.addTestSuite(TxRollbackAsyncNearCacheTest.class); - suite.addTestSuite(TxRollbackOnTopologyChangeTest.class); + GridTestUtils.addTestIfNeeded(suite, TxOptimisticPrepareOnUnstableTopologyTest.class, ignoredTests); - suite.addTestSuite(TxOptimisticPrepareOnUnstableTopologyTest.class); + GridTestUtils.addTestIfNeeded(suite, TxLabelTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, TxRollbackOnIncorrectParamsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, TxStateChangeEventTest.class, ignoredTests); - suite.addTestSuite(TxLabelTest.class); - suite.addTestSuite(TxRollbackOnIncorrectParamsTest.class); - suite.addTestSuite(TxStateChangeEventTest.class); + GridTestUtils.addTestIfNeeded(suite, TxMultiCacheAsyncOpsTest.class, ignoredTests); - suite.addTestSuite(TxMultiCacheAsyncOpsTest.class); + GridTestUtils.addTestIfNeeded(suite, TxOnCachesStartTest.class, ignoredTests); - suite.addTestSuite(TxOnCachesStartTest.class); - - suite.addTestSuite(IgniteCache150ClientsTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteCache150ClientsTest.class, ignoredTests); // TODO enable this test after IGNITE-6753, now it takes too long -// suite.addTestSuite(IgniteOutOfMemoryPropagationTest.class); +// GridTestUtils.addTestIfNeeded(suite, IgniteOutOfMemoryPropagationTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, ReplicatedAtomicCacheGetsDistributionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, ReplicatedTransactionalOptimisticCacheGetsDistributionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, ReplicatedTransactionalPessimisticCacheGetsDistributionTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, PartitionedAtomicCacheGetsDistributionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, PartitionedTransactionalOptimisticCacheGetsDistributionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, PartitionedTransactionalPessimisticCacheGetsDistributionTest.class, ignoredTests); - suite.addTestSuite(ReplicatedAtomicCacheGetsDistributionTest.class); - suite.addTestSuite(ReplicatedTransactionalOptimisticCacheGetsDistributionTest.class); - suite.addTestSuite(ReplicatedTransactionalPessimisticCacheGetsDistributionTest.class); + GridTestUtils.addTestIfNeeded(suite, TxOptimisticOnPartitionExchangeTest.class, ignoredTests); - suite.addTestSuite(PartitionedAtomicCacheGetsDistributionTest.class); - suite.addTestSuite(PartitionedTransactionalOptimisticCacheGetsDistributionTest.class); - suite.addTestSuite(PartitionedTransactionalPessimisticCacheGetsDistributionTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteExchangeLatchManagerCoordinatorFailTest.class, ignoredTests); - suite.addTestSuite(TxOptimisticOnPartitionExchangeTest.class); + GridTestUtils.addTestIfNeeded(suite, PartitionsExchangeCoordinatorFailoverTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheTryLockMultithreadedTest.class, ignoredTests); - suite.addTestSuite(IgniteExchangeLatchManagerCoordinatorFailTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheParallelStartTest.class, ignoredTests); - suite.addTestSuite(PartitionsExchangeCoordinatorFailoverTest.class); - suite.addTestSuite(CacheTryLockMultithreadedTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheNoAffinityExchangeTest.class, ignoredTests); - //suite.addTestSuite(CacheClientsConcurrentStartTest.class); - //suite.addTestSuite(GridCacheRebalancingOrderingTest.class); - //suite.addTestSuite(IgniteCacheClientMultiNodeUpdateTopologyLockTest.class); + //GridTestUtils.addTestIfNeeded(suite, CacheClientsConcurrentStartTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite, GridCacheRebalancingOrderingTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite, IgniteCacheClientMultiNodeUpdateTopologyLockTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite7.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite7.java index 6c48ecc2da6f7..f540afdcad21b 100755 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite7.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite7.java @@ -33,9 +33,8 @@ import org.apache.ignite.internal.processors.cache.WalModeChangeCoordinatorNotAffinityNodeSelfTest; import org.apache.ignite.internal.processors.cache.WalModeChangeSelfTest; import org.apache.ignite.internal.processors.cache.distributed.Cache64kPartitionsTest; -import org.apache.ignite.internal.processors.cache.distributed.CachePageWriteLockUnlockTest; -import org.apache.ignite.internal.processors.cache.distributed.CacheRentingStateRepairTest; import org.apache.ignite.internal.processors.cache.distributed.CacheDataLossOnPartitionMoveTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheRentingStateRepairTest; import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheStartWithLoadTest; import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingPartitionCountersTest; import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingWithAsyncClearingTest; @@ -45,64 +44,64 @@ import org.apache.ignite.internal.processors.cache.transactions.TransactionIntegrityWithPrimaryIndexCorruptionTest; import org.apache.ignite.internal.processors.cache.transactions.TxRollbackAsyncWithPersistenceTest; import org.apache.ignite.internal.processors.cache.transactions.TxWithSmallTimeoutAndContentionOneKeyTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheTestSuite7 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTestSuite7 { /** * @return IgniteCache test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** * @param ignoredTests Tests to ignore. * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite(Set ignoredTests) throws Exception { + public static TestSuite suite(Set ignoredTests) { TestSuite suite = new TestSuite("IgniteCache With Persistence Test Suite"); - suite.addTestSuite(CheckpointBufferDeadlockTest.class); - suite.addTestSuite(IgniteCacheStartWithLoadTest.class); - - suite.addTestSuite(AuthenticationConfigurationClusterTest.class); - suite.addTestSuite(AuthenticationProcessorSelfTest.class); - suite.addTestSuite(AuthenticationOnNotActiveClusterTest.class); - suite.addTestSuite(AuthenticationProcessorNodeRestartTest.class); - suite.addTestSuite(AuthenticationProcessorNPEOnStartTest.class); - suite.addTestSuite(Authentication1kUsersNodeRestartTest.class); + GridTestUtils.addTestIfNeeded(suite, CheckpointBufferDeadlockTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheStartWithLoadTest.class, ignoredTests); - suite.addTestSuite(CacheDataRegionConfigurationTest.class); + GridTestUtils.addTestIfNeeded(suite, AuthenticationConfigurationClusterTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, AuthenticationProcessorSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, AuthenticationOnNotActiveClusterTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, AuthenticationProcessorNodeRestartTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, AuthenticationProcessorNPEOnStartTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, Authentication1kUsersNodeRestartTest.class, ignoredTests); - suite.addTestSuite(WalModeChangeAdvancedSelfTest.class); - suite.addTestSuite(WalModeChangeSelfTest.class); - suite.addTestSuite(WalModeChangeCoordinatorNotAffinityNodeSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheDataRegionConfigurationTest.class, ignoredTests); - suite.addTestSuite(Cache64kPartitionsTest.class); - suite.addTestSuite(GridCacheRebalancingPartitionCountersTest.class); - suite.addTestSuite(GridCacheRebalancingWithAsyncClearingTest.class); + GridTestUtils.addTestIfNeeded(suite, WalModeChangeAdvancedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, WalModeChangeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, WalModeChangeCoordinatorNotAffinityNodeSelfTest.class, ignoredTests); - suite.addTestSuite(IgnitePdsCacheAssignmentNodeRestartsTest.class); - suite.addTestSuite(TxRollbackAsyncWithPersistenceTest.class); + GridTestUtils.addTestIfNeeded(suite, Cache64kPartitionsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheRebalancingPartitionCountersTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheRebalancingWithAsyncClearingTest.class, ignoredTests); - suite.addTestSuite(CacheGroupMetricsMBeanTest.class); - suite.addTestSuite(CacheMetricsManageTest.class); - suite.addTestSuite(PageEvictionMultinodeMixedRegionsTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsCacheAssignmentNodeRestartsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, TxRollbackAsyncWithPersistenceTest.class, ignoredTests); - suite.addTestSuite(IgniteDynamicCacheStartFailWithPersistenceTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheGroupMetricsMBeanTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheMetricsManageTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, PageEvictionMultinodeMixedRegionsTest.class, ignoredTests); - suite.addTestSuite(TxWithSmallTimeoutAndContentionOneKeyTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteDynamicCacheStartFailWithPersistenceTest.class, ignoredTests); - suite.addTestSuite(CacheRentingStateRepairTest.class); + GridTestUtils.addTestIfNeeded(suite, TxWithSmallTimeoutAndContentionOneKeyTest.class, ignoredTests); - suite.addTestSuite(TransactionIntegrityWithPrimaryIndexCorruptionTest.class); - suite.addTestSuite(CacheDataLossOnPartitionMoveTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheRentingStateRepairTest.class, ignoredTests); - suite.addTestSuite(CachePageWriteLockUnlockTest.class); + GridTestUtils.addTestIfNeeded(suite, TransactionIntegrityWithPrimaryIndexCorruptionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CacheDataLossOnPartitionMoveTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite8.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite8.java index 086c567dac0ea..e32658d23bd44 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite8.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite8.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.GridCacheOrderedPreloadingSelfTest; import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRabalancingDelayedPartitionMapExchangeSelfTest; @@ -25,41 +26,48 @@ import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingSyncCheckDataTest; import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingSyncSelfTest; import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingUnmarshallingFailedSelfTest; -import org.apache.ignite.testframework.junits.GridAbstractTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheTestSuite8 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTestSuite8 { /** * @return IgniteCache test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); + public static TestSuite suite() { + return suite(null); + } + /** + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("IgniteCache Test Suite part 8"); // Cache metrics. - suite.addTest(IgniteCacheMetricsSelfTestSuite.suite()); + suite.addTest(IgniteCacheMetricsSelfTestSuite.suite(ignoredTests)); // Topology validator. - suite.addTest(IgniteTopologyValidatorTestSuite.suite()); + suite.addTest(IgniteTopologyValidatorTestSuite.suite(ignoredTests)); // Eviction. - suite.addTest(IgniteCacheEvictionSelfTestSuite.suite()); + suite.addTest(IgniteCacheEvictionSelfTestSuite.suite(ignoredTests)); // Iterators. - suite.addTest(IgniteCacheIteratorsSelfTestSuite.suite()); + suite.addTest(IgniteCacheIteratorsSelfTestSuite.suite(ignoredTests)); // Rebalancing. - suite.addTestSuite(GridCacheOrderedPreloadingSelfTest.class); - suite.addTestSuite(GridCacheRebalancingSyncSelfTest.class); - suite.addTestSuite(GridCacheRebalancingSyncCheckDataTest.class); - suite.addTestSuite(GridCacheRebalancingUnmarshallingFailedSelfTest.class); - suite.addTestSuite(GridCacheRebalancingAsyncSelfTest.class); - suite.addTestSuite(GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.class); - suite.addTestSuite(GridCacheRebalancingCancelTest.class); + GridTestUtils.addTestIfNeeded(suite, GridCacheOrderedPreloadingSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheRebalancingSyncSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheRebalancingSyncCheckDataTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheRebalancingUnmarshallingFailedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheRebalancingAsyncSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheRebalancingCancelTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite9.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite9.java index 386b17bacae2e..b9a2dc6736004 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite9.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite9.java @@ -17,37 +17,55 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.CachePutIfAbsentTest; import org.apache.ignite.internal.processors.cache.IgniteCacheGetCustomCollectionsSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheLoadRebalanceEvictionSelfTest; import org.apache.ignite.internal.processors.cache.distributed.CacheAtomicPrimarySyncBackPressureTest; +import org.apache.ignite.internal.processors.cache.distributed.CacheOperationsInterruptTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCachePrimarySyncTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteTxCachePrimarySyncTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteTxCacheWriteSynchronizationModesMultithreadedTest; -import org.apache.ignite.testframework.junits.GridAbstractTest; +import org.apache.ignite.internal.processors.cache.distributed.IgniteTxConcurrentRemoveObjectsTest; +import org.apache.ignite.internal.processors.cache.transactions.TxDataConsistencyOnCommitFailureTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite. */ -public class IgniteCacheTestSuite9 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTestSuite9 { /** * @return IgniteCache test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); + public static TestSuite suite() { + return suite(null); + } + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("IgniteCache Test Suite part 9"); - suite.addTestSuite(IgniteCacheGetCustomCollectionsSelfTest.class); - suite.addTestSuite(IgniteCacheLoadRebalanceEvictionSelfTest.class); - suite.addTestSuite(IgniteCachePrimarySyncTest.class); - suite.addTestSuite(IgniteTxCachePrimarySyncTest.class); - suite.addTestSuite(IgniteTxCacheWriteSynchronizationModesMultithreadedTest.class); - suite.addTestSuite(CachePutIfAbsentTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheGetCustomCollectionsSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCacheLoadRebalanceEvictionSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteCachePrimarySyncTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTxCachePrimarySyncTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTxCacheWriteSynchronizationModesMultithreadedTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CachePutIfAbsentTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, CacheAtomicPrimarySyncBackPressureTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, IgniteTxConcurrentRemoveObjectsTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, TxDataConsistencyOnCommitFailureTest.class, ignoredTests); - suite.addTestSuite(CacheAtomicPrimarySyncBackPressureTest.class); + GridTestUtils.addTestIfNeeded(suite, CacheOperationsInterruptTest.class, ignoredTests); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java index 0cdd0c4add84a..2cceda3cb2ba6 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTxRecoverySelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedTxPessimisticOriginatingNodeFailureSelfTest; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledTxOriginatingNodeFailureSelfTest; @@ -30,34 +31,36 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearTxPessimisticOriginatingNodeFailureSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxOriginatingNodeFailureSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedTxPessimisticOriginatingNodeFailureSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Tx recovery self test suite. */ -public class IgniteCacheTxRecoverySelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheTxRecoverySelfTestSuite { /** * @return Cache API test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Cache tx recovery test suite"); - suite.addTestSuite(IgniteCacheCommitDelayTxRecoveryTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheCommitDelayTxRecoveryTest.class)); - suite.addTestSuite(IgniteCachePartitionedPrimaryNodeFailureRecoveryTest.class); - suite.addTestSuite(IgniteCachePartitionedNearDisabledPrimaryNodeFailureRecoveryTest.class); - suite.addTestSuite(IgniteCachePartitionedTwoBackupsPrimaryNodeFailureRecoveryTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedPrimaryNodeFailureRecoveryTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedNearDisabledPrimaryNodeFailureRecoveryTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedTwoBackupsPrimaryNodeFailureRecoveryTest.class)); - suite.addTestSuite(GridCachePartitionedTxOriginatingNodeFailureSelfTest.class); - suite.addTestSuite(GridCachePartitionedNearDisabledTxOriginatingNodeFailureSelfTest.class); - suite.addTestSuite(GridCacheReplicatedTxOriginatingNodeFailureSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedTxOriginatingNodeFailureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNearDisabledTxOriginatingNodeFailureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedTxOriginatingNodeFailureSelfTest.class)); - suite.addTestSuite(GridCacheColocatedTxPessimisticOriginatingNodeFailureSelfTest.class); - suite.addTestSuite(GridCacheNearTxPessimisticOriginatingNodeFailureSelfTest.class); - suite.addTestSuite(GridCacheReplicatedTxPessimisticOriginatingNodeFailureSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheColocatedTxPessimisticOriginatingNodeFailureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheNearTxPessimisticOriginatingNodeFailureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedTxPessimisticOriginatingNodeFailureSelfTest.class)); - suite.addTestSuite(IgniteCacheTxRecoveryRollbackTest.class); - suite.addTestSuite(TxRecoveryStoreEnabledTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheTxRecoveryRollbackTest.class)); + suite.addTest(new JUnit4TestAdapter(TxRecoveryStoreEnabledTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheWriteBehindTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheWriteBehindTestSuite.java index dff93ffa5ecf0..e7e4050176c8a 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheWriteBehindTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheWriteBehindTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.GridCachePartitionedWritesTest; import org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStoreLocalTest; @@ -28,30 +29,41 @@ import org.apache.ignite.internal.processors.cache.store.IgnteCacheClientWriteBehindStoreAtomicTest; import org.apache.ignite.internal.processors.cache.store.IgnteCacheClientWriteBehindStoreNonCoalescingTest; import org.apache.ignite.internal.processors.cache.store.IgnteCacheClientWriteBehindStoreTxTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite that contains all tests for {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore}. */ -public class IgniteCacheWriteBehindTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheWriteBehindTestSuite { /** * @return Ignite Bamboo in-memory data grid test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { + return suite(null); + } + + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("Write-Behind Store Test Suite"); // Write-behind tests. - suite.addTest(new TestSuite(GridCacheWriteBehindStoreSelfTest.class)); - suite.addTest(new TestSuite(GridCacheWriteBehindStoreMultithreadedSelfTest.class)); - suite.addTest(new TestSuite(GridCacheWriteBehindStoreLocalTest.class)); - suite.addTest(new TestSuite(GridCacheWriteBehindStoreReplicatedTest.class)); - suite.addTest(new TestSuite(GridCacheWriteBehindStorePartitionedTest.class)); - suite.addTest(new TestSuite(GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(GridCachePartitionedWritesTest.class)); - suite.addTest(new TestSuite(IgnteCacheClientWriteBehindStoreAtomicTest.class)); - suite.addTest(new TestSuite(IgnteCacheClientWriteBehindStoreTxTest.class)); - suite.addTest(new TestSuite(IgnteCacheClientWriteBehindStoreNonCoalescingTest.class)); + GridTestUtils.addTestIfNeeded(suite, GridCacheWriteBehindStoreSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheWriteBehindStoreMultithreadedSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheWriteBehindStoreLocalTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheWriteBehindStoreReplicatedTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheWriteBehindStorePartitionedTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, GridCachePartitionedWritesTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnteCacheClientWriteBehindStoreAtomicTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnteCacheClientWriteBehindStoreTxTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnteCacheClientWriteBehindStoreNonCoalescingTest.class, ignoredTests); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java index c9405fa00152d..58e485d2daec0 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java @@ -17,28 +17,31 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheClientNodeConcurrentStart; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheClientReconnectTest; import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheManyClientsTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgniteClientNodesTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteClientNodesTestSuite { /** * @return Test suite. - * @throws Exception In case of error. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Client Nodes Reconnect Test Suite"); suite.addTest(IgniteClientReconnectTestSuite.suite()); - suite.addTestSuite(IgniteCacheManyClientsTest.class); - suite.addTestSuite(IgniteCacheClientNodeConcurrentStart.class); - suite.addTestSuite(IgniteCacheClientReconnectTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheManyClientsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheClientNodeConcurrentStart.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheClientReconnectTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java index d5ebd15a3d417..908aa36f615a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientReconnectTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.IgniteClientConnectAfterCommunicationFailureTest; import org.apache.ignite.internal.IgniteClientReconnectApiExceptionTest; @@ -33,33 +34,35 @@ import org.apache.ignite.internal.IgniteClientReconnectStopTest; import org.apache.ignite.internal.IgniteClientReconnectStreamerTest; import org.apache.ignite.internal.IgniteClientRejoinTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgniteClientReconnectTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteClientReconnectTestSuite { /** * @return Test suite. - * @throws Exception In case of error. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Client Reconnect Test Suite"); - suite.addTestSuite(IgniteClientConnectAfterCommunicationFailureTest.class); - suite.addTestSuite(IgniteClientReconnectStopTest.class); - suite.addTestSuite(IgniteClientReconnectApiExceptionTest.class); - suite.addTestSuite(IgniteClientReconnectDiscoveryStateTest.class); - suite.addTestSuite(IgniteClientReconnectCacheTest.class); - suite.addTestSuite(IgniteClientReconnectDelayedSpiTest.class); - suite.addTestSuite(IgniteClientReconnectBinaryContexTest.class); - suite.addTestSuite(IgniteClientReconnectContinuousProcessorTest.class); - suite.addTestSuite(IgniteClientReconnectComputeTest.class); - suite.addTestSuite(IgniteClientReconnectAtomicsTest.class); - suite.addTestSuite(IgniteClientReconnectCollectionsTest.class); - suite.addTestSuite(IgniteClientReconnectServicesTest.class); - suite.addTestSuite(IgniteClientReconnectStreamerTest.class); - suite.addTestSuite(IgniteClientReconnectFailoverTest.class); - suite.addTestSuite(IgniteClientRejoinTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteClientConnectAfterCommunicationFailureTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectStopTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectApiExceptionTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectDiscoveryStateTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectDelayedSpiTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectBinaryContexTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectContinuousProcessorTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectComputeTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectAtomicsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectCollectionsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectServicesTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectStreamerTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientRejoinTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeBasicConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeBasicConfigVariationsFullApiTestSuite.java index 41cc8a10c49f6..83d923c66edf9 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeBasicConfigVariationsFullApiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeBasicConfigVariationsFullApiTestSuite.java @@ -26,11 +26,14 @@ import org.apache.ignite.testframework.configvariations.ConfigVariations; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; import org.apache.ignite.testframework.configvariations.Parameters; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Full API compute test. */ -public class IgniteComputeBasicConfigVariationsFullApiTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteComputeBasicConfigVariationsFullApiTestSuite { /** */ @SuppressWarnings("unchecked") private static final ConfigParameter[][] BASIC_COMPUTE_SET = new ConfigParameter[][] { @@ -45,9 +48,8 @@ public class IgniteComputeBasicConfigVariationsFullApiTestSuite extends TestSuit /** * @return Compute API test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Compute New Full API Test Suite"); suite.addTest(new ConfigVariationsTestSuiteBuilder( diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java index 2e5708d5743ea..b5d0f4ff241ff 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.ClusterNodeMetricsSelfTest; import org.apache.ignite.internal.ClusterNodeMetricsUpdateTest; @@ -77,6 +78,7 @@ import org.apache.ignite.internal.IgniteExplicitImplicitDeploymentSelfTest; import org.apache.ignite.internal.IgniteRoundRobinErrorAfterClientReconnectTest; import org.apache.ignite.internal.TaskNodeRestartTest; +import org.apache.ignite.internal.VisorManagementEventSelfTest; import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManagerSelfTest; import org.apache.ignite.internal.managers.checkpoint.GridCheckpointTaskSelfTest; import org.apache.ignite.internal.managers.communication.GridCommunicationManagerListenersSelfTest; @@ -88,16 +90,18 @@ import org.apache.ignite.p2p.GridMultinodeRedeployIsolatedModeSelfTest; import org.apache.ignite.p2p.GridMultinodeRedeployPrivateModeSelfTest; import org.apache.ignite.p2p.GridMultinodeRedeploySharedModeSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Compute grid test suite. */ +@RunWith(AllTests.class) public class IgniteComputeGridTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Compute Grid Test Suite"); suite.addTest(IgniteTaskSessionSelfTestSuite.suite()); @@ -105,78 +109,80 @@ public static TestSuite suite() throws Exception { suite.addTest(IgniteJobMetricsSelfTestSuite.suite()); suite.addTest(IgniteContinuousTaskSelfTestSuite.suite()); - suite.addTestSuite(GridTaskCancelSingleNodeSelfTest.class); - suite.addTestSuite(GridTaskFailoverSelfTest.class); - suite.addTestSuite(GridJobCollisionCancelSelfTest.class); - suite.addTestSuite(GridTaskTimeoutSelfTest.class); - suite.addTestSuite(GridCancelUnusedJobSelfTest.class); - suite.addTestSuite(GridTaskJobRejectSelfTest.class); - suite.addTestSuite(GridTaskExecutionSelfTest.class); - //suite.addTestSuite(GridTaskExecutionContextSelfTest.class); - suite.addTestSuite(GridTaskExecutionWithoutPeerClassLoadingSelfTest.class); - suite.addTestSuite(GridFailoverSelfTest.class); - suite.addTestSuite(GridTaskListenerSelfTest.class); - suite.addTestSuite(GridFailoverTopologySelfTest.class); - suite.addTestSuite(GridTaskResultCacheSelfTest.class); - suite.addTestSuite(GridTaskMapAsyncSelfTest.class); - suite.addTestSuite(GridJobContextSelfTest.class); - suite.addTestSuite(GridJobMasterLeaveAwareSelfTest.class); - suite.addTestSuite(GridJobStealingSelfTest.class); - suite.addTestSuite(GridJobSubjectIdSelfTest.class); - suite.addTestSuite(GridMultithreadedJobStealingSelfTest.class); - suite.addTestSuite(GridAlwaysFailoverSpiFailSelfTest.class); - suite.addTestSuite(GridTaskInstanceExecutionSelfTest.class); - suite.addTestSuite(ClusterNodeMetricsSelfTest.class); - suite.addTestSuite(ClusterNodeMetricsUpdateTest.class); - suite.addTestSuite(GridNonHistoryMetricsSelfTest.class); - suite.addTestSuite(GridCancelledJobsMetricsSelfTest.class); - suite.addTestSuite(GridCollisionJobsContextSelfTest.class); - suite.addTestSuite(GridJobStealingZeroActiveJobsSelfTest.class); - suite.addTestSuite(GridTaskFutureImplStopGridSelfTest.class); - suite.addTestSuite(GridFailoverCustomTopologySelfTest.class); - suite.addTestSuite(GridMultipleSpisSelfTest.class); - suite.addTestSuite(GridStopWithWaitSelfTest.class); - suite.addTestSuite(GridCancelOnGridStopSelfTest.class); - suite.addTestSuite(GridDeploymentSelfTest.class); - suite.addTestSuite(GridDeploymentMultiThreadedSelfTest.class); - suite.addTestSuite(GridMultipleVersionsDeploymentSelfTest.class); - suite.addTestSuite(IgniteExplicitImplicitDeploymentSelfTest.class); - suite.addTestSuite(GridEventStorageCheckAllEventsSelfTest.class); - suite.addTestSuite(GridCommunicationManagerListenersSelfTest.class); - suite.addTestSuite(IgniteExecutorServiceTest.class); - suite.addTestSuite(GridTaskInstantiationSelfTest.class); - suite.addTestSuite(GridMultipleJobsSelfTest.class); - suite.addTestSuite(GridCheckpointManagerSelfTest.class); - suite.addTestSuite(GridCheckpointTaskSelfTest.class); - suite.addTestSuite(GridTaskNameAnnotationSelfTest.class); - suite.addTestSuite(GridJobCheckpointCleanupSelfTest.class); - suite.addTestSuite(GridEventStorageSelfTest.class); - suite.addTestSuite(GridEventStorageDefaultExceptionTest.class); - suite.addTestSuite(GridFailoverTaskWithPredicateSelfTest.class); - suite.addTestSuite(GridProjectionLocalJobMultipleArgumentsSelfTest.class); - suite.addTestSuite(GridAffinitySelfTest.class); - suite.addTestSuite(GridAffinityNoCacheSelfTest.class); - //suite.addTestSuite(GridAffinityMappedTest.class); - //suite.addTestSuite(GridAffinityP2PSelfTest.class); - suite.addTestSuite(GridEventStorageRuntimeConfigurationSelfTest.class); - suite.addTestSuite(GridMultinodeRedeployContinuousModeSelfTest.class); - suite.addTestSuite(GridMultinodeRedeploySharedModeSelfTest.class); - suite.addTestSuite(GridMultinodeRedeployPrivateModeSelfTest.class); - suite.addTestSuite(GridMultinodeRedeployIsolatedModeSelfTest.class); - suite.addTestSuite(IgniteComputeEmptyClusterGroupTest.class); - suite.addTestSuite(IgniteComputeTopologyExceptionTest.class); - suite.addTestSuite(IgniteComputeResultExceptionTest.class); - suite.addTestSuite(GridTaskFailoverAffinityRunTest.class); - suite.addTestSuite(TaskNodeRestartTest.class); - suite.addTestSuite(IgniteRoundRobinErrorAfterClientReconnectTest.class); - suite.addTestSuite(PublicThreadpoolStarvationTest.class); - suite.addTestSuite(StripedExecutorTest.class); - suite.addTestSuite(GridJobServicesAddNodeTest.class); + suite.addTest(new JUnit4TestAdapter(GridTaskCancelSingleNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobCollisionCancelSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskTimeoutSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCancelUnusedJobSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskJobRejectSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskExecutionSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridTaskExecutionContextSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskExecutionWithoutPeerClassLoadingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskListenerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFailoverTopologySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskResultCacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskMapAsyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobContextSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobMasterLeaveAwareSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobSubjectIdSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultithreadedJobStealingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAlwaysFailoverSpiFailSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskInstanceExecutionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClusterNodeMetricsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClusterNodeMetricsUpdateTest.class)); + suite.addTest(new JUnit4TestAdapter(GridNonHistoryMetricsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCancelledJobsMetricsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCollisionJobsContextSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingZeroActiveJobsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskFutureImplStopGridSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFailoverCustomTopologySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultipleSpisSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridStopWithWaitSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCancelOnGridStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridDeploymentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridDeploymentMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultipleVersionsDeploymentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteExplicitImplicitDeploymentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridEventStorageCheckAllEventsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCommunicationManagerListenersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteExecutorServiceTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskInstantiationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultipleJobsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCheckpointManagerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCheckpointTaskSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskNameAnnotationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobCheckpointCleanupSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridEventStorageSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridEventStorageDefaultExceptionTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFailoverTaskWithPredicateSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridProjectionLocalJobMultipleArgumentsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAffinitySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAffinityNoCacheSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridAffinityMappedTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridAffinityP2PSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridEventStorageRuntimeConfigurationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultinodeRedeployContinuousModeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultinodeRedeploySharedModeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultinodeRedeployPrivateModeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultinodeRedeployIsolatedModeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteComputeEmptyClusterGroupTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteComputeTopologyExceptionTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteComputeResultExceptionTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskFailoverAffinityRunTest.class)); + suite.addTest(new JUnit4TestAdapter(TaskNodeRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteRoundRobinErrorAfterClientReconnectTest.class)); + suite.addTest(new JUnit4TestAdapter(PublicThreadpoolStarvationTest.class)); + suite.addTest(new JUnit4TestAdapter(StripedExecutorTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobServicesAddNodeTest.class)); - suite.addTestSuite(IgniteComputeCustomExecutorConfigurationSelfTest.class); - suite.addTestSuite(IgniteComputeCustomExecutorSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteComputeCustomExecutorConfigurationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteComputeCustomExecutorSelfTest.class)); - suite.addTestSuite(IgniteComputeJobOneThreadTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteComputeJobOneThreadTest.class)); + + suite.addTest(new JUnit4TestAdapter(VisorManagementEventSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteContinuousQueryConfigVariationsSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteContinuousQueryConfigVariationsSuite.java index 221dcaef52879..24b5d520c3714 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteContinuousQueryConfigVariationsSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteContinuousQueryConfigVariationsSuite.java @@ -20,18 +20,20 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryVariationsTest; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCOVERY_HISTORY_SIZE; /** * Test suite for cache queries. */ -public class IgniteContinuousQueryConfigVariationsSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteContinuousQueryConfigVariationsSuite { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { System.setProperty(IGNITE_DISCOVERY_HISTORY_SIZE, "100"); TestSuite suite = new TestSuite("Ignite Continuous Query Config Variations Suite"); diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteContinuousTaskSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteContinuousTaskSelfTestSuite.java index a99826ecae600..32297dfe9bb4b 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteContinuousTaskSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteContinuousTaskSelfTestSuite.java @@ -17,29 +17,32 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.GridContinuousJobAnnotationSelfTest; import org.apache.ignite.internal.GridContinuousJobSiblingsSelfTest; import org.apache.ignite.internal.GridContinuousTaskSelfTest; import org.apache.ignite.internal.GridTaskContinuousMapperSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Continuous task self-test suite. */ -public class IgniteContinuousTaskSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteContinuousTaskSelfTestSuite { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Kernal Test Suite"); - suite.addTest(new TestSuite(GridContinuousJobAnnotationSelfTest.class)); - suite.addTest(new TestSuite(GridContinuousJobSiblingsSelfTest.class)); - suite.addTest(new TestSuite(GridContinuousTaskSelfTest.class)); - suite.addTest(new TestSuite(GridTaskContinuousMapperSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridContinuousJobAnnotationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridContinuousJobSiblingsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridContinuousTaskSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskContinuousMapperSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDatabaseTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDatabaseTestSuite.java index 246b23559d6b4..015eb28347405 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDatabaseTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDatabaseTestSuite.java @@ -17,23 +17,26 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.database.IgniteDbMultiNodePutGetTest; import org.apache.ignite.internal.processors.database.IgniteDbSingleNodePutGetTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgniteDatabaseTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteDatabaseTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Database Tests"); - suite.addTestSuite(IgniteDbSingleNodePutGetTest.class); - suite.addTestSuite(IgniteDbMultiNodePutGetTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteDbSingleNodePutGetTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDbMultiNodePutGetTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakTestSuite.java index f271bd88c4b7d..7a144ae6e63e2 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.cache.LargeEntryUpdateTest; import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakLargeObjectsTest; @@ -24,25 +25,27 @@ import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakNonTransactionalTest; import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakTest; import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakWithExpirationTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Page memory leaks tests. */ -public class IgniteDbMemoryLeakTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteDbMemoryLeakTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Db Memory Leaks Test Suite"); - suite.addTestSuite(IgniteDbMemoryLeakTest.class); - suite.addTestSuite(IgniteDbMemoryLeakWithExpirationTest.class); - suite.addTestSuite(IgniteDbMemoryLeakLargePagesTest.class); - suite.addTestSuite(IgniteDbMemoryLeakLargeObjectsTest.class); - suite.addTestSuite(IgniteDbMemoryLeakNonTransactionalTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteDbMemoryLeakTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDbMemoryLeakWithExpirationTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDbMemoryLeakLargePagesTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDbMemoryLeakLargeObjectsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDbMemoryLeakNonTransactionalTest.class)); - suite.addTestSuite(LargeEntryUpdateTest.class); + suite.addTest(new JUnit4TestAdapter(LargeEntryUpdateTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteExternalizableSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteExternalizableSelfTestSuite.java index 7ac1284a813e5..7f5b7b689116f 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteExternalizableSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteExternalizableSelfTestSuite.java @@ -17,21 +17,25 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.GridTopicExternalizableSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Externalizable self-test suite. */ -public class IgniteExternalizableSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteExternalizableSelfTestSuite { /** * @return Test suite. */ public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Externalizable Test Suite"); - suite.addTest(new TestSuite(GridTopicExternalizableSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTopicExternalizableSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java index 8f026f79a6a23..d6c2833d0098b 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.igfs.IgfsFragmentizerSelfTest; import org.apache.ignite.igfs.IgfsFragmentizerTopologySelfTest; @@ -69,93 +70,95 @@ import org.apache.ignite.internal.processors.igfs.split.IgfsNewLineDelimiterRecordResolverSelfTest; import org.apache.ignite.internal.processors.igfs.split.IgfsStringDelimiterRecordResolverSelfTest; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for Hadoop file system over Ignite cache. * Contains platform independent tests only. */ -public class IgniteIgfsTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteIgfsTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite FS Test Suite For Platform Independent Tests"); - suite.addTest(new TestSuite(IgfsPrimarySelfTest.class)); - suite.addTest(new TestSuite(IgfsPrimaryMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsPrimarySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsPrimaryMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(IgfsPrimaryRelaxedConsistencySelfTest.class)); - suite.addTest(new TestSuite(IgfsPrimaryRelaxedConsistencyMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsPrimaryRelaxedConsistencySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsPrimaryRelaxedConsistencyMultiNodeSelfTest.class)); - suite.addTest(new TestSuite(IgfsDualSyncSelfTest.class)); - suite.addTest(new TestSuite(IgfsDualAsyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsDualSyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsDualAsyncSelfTest.class)); - suite.addTest(new TestSuite(IgfsLocalSecondaryFileSystemDualSyncSelfTest.class)); - suite.addTest(new TestSuite(IgfsLocalSecondaryFileSystemDualAsyncSelfTest.class)); - suite.addTest(new TestSuite(IgfsLocalSecondaryFileSystemDualSyncClientSelfTest.class)); - suite.addTest(new TestSuite(IgfsLocalSecondaryFileSystemDualAsyncClientSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsLocalSecondaryFileSystemDualSyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsLocalSecondaryFileSystemDualAsyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsLocalSecondaryFileSystemDualSyncClientSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsLocalSecondaryFileSystemDualAsyncClientSelfTest.class)); - //suite.addTest(new TestSuite(IgfsSizeSelfTest.class)); - suite.addTest(new TestSuite(IgfsAttributesSelfTest.class)); - suite.addTest(new TestSuite(IgfsFileInfoSelfTest.class)); - suite.addTest(new TestSuite(IgfsMetaManagerSelfTest.class)); - suite.addTest(new TestSuite(IgfsDataManagerSelfTest.class)); - suite.addTest(new TestSuite(IgfsProcessorSelfTest.class)); - suite.addTest(new TestSuite(IgfsProcessorValidationSelfTest.class)); - suite.addTest(new TestSuite(IgfsCacheSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(IgfsSizeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsAttributesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsFileInfoSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsMetaManagerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsDataManagerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsProcessorSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsProcessorValidationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsCacheSelfTest.class)); if (U.isWindows()) - suite.addTest(new TestSuite(IgfsServerManagerIpcEndpointRegistrationOnWindowsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsServerManagerIpcEndpointRegistrationOnWindowsSelfTest.class)); - suite.addTest(new TestSuite(IgfsCachePerBlockLruEvictionPolicySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsCachePerBlockLruEvictionPolicySelfTest.class)); - suite.addTest(new TestSuite(IgfsStreamsSelfTest.class)); - suite.addTest(new TestSuite(IgfsModesSelfTest.class)); - suite.addTest(new TestSuite(IgfsMetricsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsStreamsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsModesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsMetricsSelfTest.class)); - suite.addTest(new TestSuite(IgfsPrimaryClientSelfTest.class)); - suite.addTest(new TestSuite(IgfsPrimaryRelaxedConsistencyClientSelfTest.class)); - suite.addTest(new TestSuite(IgfsDualSyncClientSelfTest.class)); - suite.addTest(new TestSuite(IgfsDualAsyncClientSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsPrimaryClientSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsPrimaryRelaxedConsistencyClientSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsDualSyncClientSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsDualAsyncClientSelfTest.class)); - suite.addTest(new TestSuite(IgfsOneClientNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsOneClientNodeTest.class)); - suite.addTest(new TestSuite(IgfsModeResolverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsModeResolverSelfTest.class)); - //suite.addTestSuite(IgfsPathSelfTest.class); - suite.addTestSuite(IgfsFragmentizerSelfTest.class); - suite.addTestSuite(IgfsFragmentizerTopologySelfTest.class); - suite.addTestSuite(IgfsFileMapSelfTest.class); + //suite.addTest(new JUnit4TestAdapter(IgfsPathSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsFragmentizerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsFragmentizerTopologySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsFileMapSelfTest.class)); - suite.addTestSuite(IgfsByteDelimiterRecordResolverSelfTest.class); - suite.addTestSuite(IgfsStringDelimiterRecordResolverSelfTest.class); - suite.addTestSuite(IgfsFixedLengthRecordResolverSelfTest.class); - suite.addTestSuite(IgfsNewLineDelimiterRecordResolverSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgfsByteDelimiterRecordResolverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsStringDelimiterRecordResolverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsFixedLengthRecordResolverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsNewLineDelimiterRecordResolverSelfTest.class)); - suite.addTestSuite(IgfsTaskSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgfsTaskSelfTest.class)); - suite.addTestSuite(IgfsGroupDataBlockKeyMapperHashSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgfsGroupDataBlockKeyMapperHashSelfTest.class)); - suite.addTestSuite(IgfsStartCacheTest.class); + suite.addTest(new JUnit4TestAdapter(IgfsStartCacheTest.class)); - suite.addTestSuite(IgfsBackupsPrimarySelfTest.class); - suite.addTestSuite(IgfsBackupsDualSyncSelfTest.class); - suite.addTestSuite(IgfsBackupsDualAsyncSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgfsBackupsPrimarySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsBackupsDualSyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsBackupsDualAsyncSelfTest.class)); - suite.addTestSuite(IgfsBlockMessageSystemPoolStarvationSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgfsBlockMessageSystemPoolStarvationSelfTest.class)); // TODO: Enable when IGFS failover is fixed. - //suite.addTestSuite(IgfsBackupFailoverSelfTest.class); + //suite.addTest(new JUnit4TestAdapter(IgfsBackupFailoverSelfTest.class)); - suite.addTestSuite(IgfsProxySelfTest.class); - suite.addTestSuite(IgfsLocalSecondaryFileSystemProxySelfTest.class); - suite.addTestSuite(IgfsLocalSecondaryFileSystemProxyClientSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgfsProxySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsLocalSecondaryFileSystemProxySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsLocalSecondaryFileSystemProxyClientSelfTest.class)); - suite.addTestSuite(IgfsAtomicPrimarySelfTest.class); - suite.addTestSuite(IgfsAtomicPrimaryMultiNodeSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgfsAtomicPrimarySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgfsAtomicPrimaryMultiNodeSelfTest.class)); - suite.addTestSuite(IgfsSecondaryFileSystemInjectionSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgfsSecondaryFileSystemInjectionSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIpcSharedMemorySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIpcSharedMemorySelfTestSuite.java index 0b8d580a1253a..c3ce92106ee34 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIpcSharedMemorySelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIpcSharedMemorySelfTestSuite.java @@ -17,28 +17,31 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryCrashDetectionSelfTest; import org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryNativeLoaderSelfTest; import org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemorySpaceSelfTest; import org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryUtilsSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Shared memory test suite. */ -public class IgniteIpcSharedMemorySelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteIpcSharedMemorySelfTestSuite { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite IPC Shared Memory Test Suite."); - suite.addTest(new TestSuite(IpcSharedMemorySpaceSelfTest.class)); - suite.addTest(new TestSuite(IpcSharedMemoryUtilsSelfTest.class)); - suite.addTest(new TestSuite(IpcSharedMemoryCrashDetectionSelfTest.class)); - suite.addTest(new TestSuite(IpcSharedMemoryNativeLoaderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IpcSharedMemorySpaceSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IpcSharedMemoryUtilsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IpcSharedMemoryCrashDetectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IpcSharedMemoryNativeLoaderSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIpcTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIpcTestSuite.java index b2f2b8d8feddc..df5974ef88db6 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIpcTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIpcTestSuite.java @@ -18,11 +18,14 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Suite for shared memory mode. */ -public class IgniteIpcTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteIpcTestSuite { /** * @return IgniteCache test suite. * @throws Exception Thrown in case of the failure. diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteJobMetricsSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteJobMetricsSelfTestSuite.java index 2255bda1b1984..d2e9c18e28d77 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteJobMetricsSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteJobMetricsSelfTestSuite.java @@ -17,22 +17,25 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessorLoadTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Job metrics self test suite. */ -public class IgniteJobMetricsSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteJobMetricsSelfTestSuite { /** * @return Job metrics test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Job metrics Test Suite"); - suite.addTest(new TestSuite(GridJobMetricsProcessorLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobMetricsProcessorLoadTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java index ab2306edabc16..a6d4dd7b49c23 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.ClusterMetricsSelfTest; import org.apache.ignite.internal.ComputeJobCancelWithServiceSelfTest; @@ -42,6 +43,7 @@ import org.apache.ignite.internal.LongJVMPauseDetectorTest; import org.apache.ignite.internal.managers.GridManagerStopSelfTest; import org.apache.ignite.internal.managers.communication.GridCommunicationSendMessageSelfTest; +import org.apache.ignite.internal.managers.deployment.DeploymentRequestOfUnknownClassProcessingTest; import org.apache.ignite.internal.managers.deployment.GridDeploymentManagerStopSelfTest; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManagerAliveCacheSelfTest; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManagerAttributesSelfTest; @@ -81,93 +83,95 @@ import org.apache.ignite.testframework.GridTestUtils; import java.util.Set; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Kernal self test suite. */ +@RunWith(AllTests.class) public class IgniteKernalSelfTestSuite extends TestSuite { /** * @return Kernal test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** * @param ignoredTests Tests don't include in the execution. * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite(Set ignoredTests) throws Exception { + public static TestSuite suite(Set ignoredTests) { TestSuite suite = new TestSuite("Ignite Kernal Test Suite"); - suite.addTestSuite(GridGetOrStartSelfTest.class); - suite.addTestSuite(GridSameVmStartupSelfTest.class); - suite.addTestSuite(GridSpiExceptionSelfTest.class); - suite.addTestSuite(GridRuntimeExceptionSelfTest.class); - suite.addTestSuite(GridFailedInputParametersSelfTest.class); - suite.addTestSuite(GridNodeFilterSelfTest.class); - suite.addTestSuite(GridNodeVisorAttributesSelfTest.class); - suite.addTestSuite(GridDiscoverySelfTest.class); - suite.addTestSuite(GridCommunicationSelfTest.class); - suite.addTestSuite(GridEventStorageManagerSelfTest.class); - suite.addTestSuite(GridCommunicationSendMessageSelfTest.class); - suite.addTestSuite(GridCacheMessageSelfTest.class); - suite.addTestSuite(GridDeploymentManagerStopSelfTest.class); - suite.addTestSuite(GridManagerStopSelfTest.class); - suite.addTestSuite(GridDiscoveryManagerAttributesSelfTest.RegularDiscovery.class); - suite.addTestSuite(GridDiscoveryManagerAttributesSelfTest.ClientDiscovery.class); - suite.addTestSuite(GridDiscoveryManagerAliveCacheSelfTest.class); - suite.addTestSuite(GridDiscoveryEventSelfTest.class); - suite.addTestSuite(GridPortProcessorSelfTest.class); - suite.addTestSuite(GridHomePathSelfTest.class); - suite.addTestSuite(GridStartupWithUndefinedIgniteHomeSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridGetOrStartSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSameVmStartupSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSpiExceptionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridRuntimeExceptionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFailedInputParametersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridNodeFilterSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridNodeVisorAttributesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridDiscoverySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCommunicationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridEventStorageManagerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCommunicationSendMessageSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheMessageSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridDeploymentManagerStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridManagerStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridDiscoveryManagerAttributesSelfTest.RegularDiscovery.class)); + suite.addTest(new JUnit4TestAdapter(GridDiscoveryManagerAttributesSelfTest.ClientDiscovery.class)); + suite.addTest(new JUnit4TestAdapter(GridDiscoveryManagerAliveCacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridDiscoveryEventSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridPortProcessorSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridHomePathSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridStartupWithUndefinedIgniteHomeSelfTest.class)); GridTestUtils.addTestIfNeeded(suite, GridVersionSelfTest.class, ignoredTests); - suite.addTestSuite(GridListenActorSelfTest.class); - suite.addTestSuite(GridNodeLocalSelfTest.class); - suite.addTestSuite(GridKernalConcurrentAccessStopSelfTest.class); - suite.addTestSuite(IgniteConcurrentEntryProcessorAccessStopTest.class); - suite.addTestSuite(GridUpdateNotifierSelfTest.class); - suite.addTestSuite(GridAddressResolverSelfTest.class); - suite.addTestSuite(IgniteUpdateNotifierPerClusterSettingSelfTest.class); - suite.addTestSuite(GridLocalEventListenerSelfTest.class); - suite.addTestSuite(IgniteTopologyPrintFormatSelfTest.class); - suite.addTestSuite(ComputeJobCancelWithServiceSelfTest.class); - suite.addTestSuite(IgniteConnectionConcurrentReserveAndRemoveTest.class); - suite.addTestSuite(LongJVMPauseDetectorTest.class); - suite.addTestSuite(ClusterMetricsSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridListenActorSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridNodeLocalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridKernalConcurrentAccessStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteConcurrentEntryProcessorAccessStopTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUpdateNotifierSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAddressResolverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteUpdateNotifierPerClusterSettingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLocalEventListenerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteTopologyPrintFormatSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ComputeJobCancelWithServiceSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteConnectionConcurrentReserveAndRemoveTest.class)); + suite.addTest(new JUnit4TestAdapter(LongJVMPauseDetectorTest.class)); + suite.addTest(new JUnit4TestAdapter(ClusterMetricsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DeploymentRequestOfUnknownClassProcessingTest.class)); // Managed Services. - suite.addTestSuite(GridServiceProcessorSingleNodeSelfTest.class); - suite.addTestSuite(GridServiceProcessorMultiNodeSelfTest.class); - suite.addTestSuite(GridServiceProcessorMultiNodeConfigSelfTest.class); - suite.addTestSuite(GridServiceProcessorProxySelfTest.class); - suite.addTestSuite(GridServiceReassignmentSelfTest.class); - suite.addTestSuite(GridServiceClientNodeTest.class); - suite.addTestSuite(GridServiceProcessorStopSelfTest.class); - suite.addTestSuite(ServicePredicateAccessCacheTest.class); - suite.addTestSuite(GridServicePackagePrivateSelfTest.class); - suite.addTestSuite(GridServiceSerializationSelfTest.class); - suite.addTestSuite(GridServiceProxyNodeStopSelfTest.class); - suite.addTestSuite(GridServiceProxyClientReconnectSelfTest.class); - suite.addTestSuite(IgniteServiceReassignmentTest.class); - suite.addTestSuite(IgniteServiceProxyTimeoutInitializedTest.class); - suite.addTestSuite(IgniteServiceDynamicCachesSelfTest.class); - suite.addTestSuite(GridServiceContinuousQueryRedeployTest.class); - suite.addTestSuite(ServiceThreadPoolSelfTest.class); - suite.addTestSuite(GridServiceProcessorBatchDeploySelfTest.class); - suite.addTestSuite(GridServiceDeploymentCompoundFutureSelfTest.class); - suite.addTestSuite(SystemCacheNotConfiguredTest.class); + suite.addTest(new JUnit4TestAdapter(GridServiceProcessorSingleNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceProcessorMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceProcessorMultiNodeConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceProcessorProxySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceReassignmentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceClientNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceProcessorStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ServicePredicateAccessCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServicePackagePrivateSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceSerializationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceProxyNodeStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceProxyClientReconnectSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteServiceReassignmentTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteServiceProxyTimeoutInitializedTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteServiceDynamicCachesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceContinuousQueryRedeployTest.class)); + suite.addTest(new JUnit4TestAdapter(ServiceThreadPoolSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceProcessorBatchDeploySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceDeploymentCompoundFutureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SystemCacheNotConfiguredTest.class)); // IGNITE-3392 - //suite.addTestSuite(GridServiceDeploymentExceptionPropagationTest.class); + //suite.addTestSuite(GridServiceDeploymentExceptionPropagationTest.class)); - suite.addTestSuite(IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.class); - suite.addTestSuite(IgniteServiceDeploymentClassLoadingJdkMarshallerTest.class); - suite.addTestSuite(IgniteServiceDeploymentClassLoadingOptimizedMarshallerTest.class); - suite.addTestSuite(IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest.class); - suite.addTestSuite(IgniteServiceDeployment2ClassLoadersJdkMarshallerTest.class); - suite.addTestSuite(IgniteServiceDeployment2ClassLoadersOptimizedMarshallerTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteServiceDeploymentClassLoadingJdkMarshallerTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteServiceDeploymentClassLoadingOptimizedMarshallerTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteServiceDeployment2ClassLoadersJdkMarshallerTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteServiceDeployment2ClassLoadersOptimizedMarshallerTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLangSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLangSelfTestSuite.java index f40b03e534715..9bfdff017f7ce 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLangSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLangSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.util.future.GridCompoundFutureSelfTest; import org.apache.ignite.internal.util.future.GridEmbeddedFutureSelfTest; @@ -45,51 +46,53 @@ import org.apache.ignite.lang.utils.IgniteOffheapReadWriteLockSelfTest; import org.apache.ignite.util.GridConcurrentLinkedDequeSelfTest; import org.apache.ignite.util.GridConcurrentLinkedHashMapMultiThreadedSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Ignite language test suite. */ -public class IgniteLangSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteLangSelfTestSuite { /** * @return Kernal test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Lang Test Suite"); - suite.addTest(new TestSuite(GridTupleSelfTest.class)); - suite.addTest(new TestSuite(GridBoundedPriorityQueueSelfTest.class)); - suite.addTest(new TestSuite(GridByteArrayListSelfTest.class)); - suite.addTest(new TestSuite(GridLeanMapSelfTest.class)); - suite.addTest(new TestSuite(GridLeanIdentitySetSelfTest.class)); - suite.addTest(new TestSuite(GridListSetSelfTest.class)); - suite.addTest(new TestSuite(GridSetWrapperSelfTest.class)); - suite.addTest(new TestSuite(GridConcurrentWeakHashSetSelfTest.class)); - suite.addTest(new TestSuite(GridMetadataAwareAdapterSelfTest.class)); - suite.addTest(new TestSuite(GridSetWrapperSelfTest.class)); - suite.addTest(new TestSuite(IgniteUuidSelfTest.class)); - suite.addTest(new TestSuite(GridXSelfTest.class)); - suite.addTest(new TestSuite(GridBoundedConcurrentOrderedMapSelfTest.class)); - suite.addTest(new TestSuite(GridBoundedConcurrentLinkedHashMapSelfTest.class)); - suite.addTest(new TestSuite(GridConcurrentLinkedDequeSelfTest.class)); - suite.addTest(new TestSuite(GridCircularBufferSelfTest.class)); - suite.addTest(new TestSuite(GridConcurrentLinkedHashMapSelfTest.class)); - suite.addTest(new TestSuite(GridConcurrentLinkedHashMapMultiThreadedSelfTest.class)); - suite.addTest(new TestSuite(GridStripedLockSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTupleSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridBoundedPriorityQueueSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridByteArrayListSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLeanMapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLeanIdentitySetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridListSetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSetWrapperSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridConcurrentWeakHashSetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMetadataAwareAdapterSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSetWrapperSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteUuidSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridXSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridBoundedConcurrentOrderedMapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridBoundedConcurrentLinkedHashMapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridConcurrentLinkedDequeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCircularBufferSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridConcurrentLinkedHashMapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridConcurrentLinkedHashMapMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridStripedLockSelfTest.class)); - suite.addTest(new TestSuite(GridFutureAdapterSelfTest.class)); - suite.addTest(new TestSuite(GridCompoundFutureSelfTest.class)); - suite.addTest(new TestSuite(GridEmbeddedFutureSelfTest.class)); - suite.addTest(new TestSuite(GridNioFutureSelfTest.class)); - suite.addTest(new TestSuite(GridNioEmbeddedFutureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFutureAdapterSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCompoundFutureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridEmbeddedFutureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridNioFutureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridNioEmbeddedFutureSelfTest.class)); - suite.addTest(new TestSuite(IgniteFutureImplTest.class)); - suite.addTest(new TestSuite(IgniteCacheFutureImplTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteFutureImplTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheFutureImplTest.class)); - suite.addTest(new TestSuite(IgniteOffheapReadWriteLockSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteOffheapReadWriteLockSelfTest.class)); // Consistent hash tests. - suite.addTest(new TestSuite(GridConsistentHashSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridConsistentHashSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLoggingSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLoggingSelfTestSuite.java index 43a56fd664078..19038ea501161 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLoggingSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLoggingSelfTestSuite.java @@ -17,20 +17,24 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.logger.java.JavaLoggerTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Logging self-test suite. */ -public class IgniteLoggingSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteLoggingSelfTestSuite { /** * @return P2P tests suite. */ public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Logging Test Suite"); - suite.addTest(new TestSuite(JavaLoggerTest.class)); + suite.addTest(new JUnit4TestAdapter(JavaLoggerTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLostAndFoundTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLostAndFoundTestSuite.java index 37bb2d6f32257..7abd939619032 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLostAndFoundTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteLostAndFoundTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.GridFactoryVmShutdownTest; import org.apache.ignite.internal.managers.GridManagerMxBeanIllegalArgumentHandleTest; @@ -40,31 +41,34 @@ import org.apache.ignite.lang.GridSystemCurrentTimeMillisTest; import org.apache.ignite.lang.GridThreadPriorityTest; import org.apache.ignite.startup.servlet.GridServletLoaderTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Tests suite for orphaned tests. */ -public class IgniteLostAndFoundTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteLostAndFoundTestSuite { /** * @return Tests suite for orphaned tests (not in any test sute previously). */ public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite List And Found Test Suite"); - suite.addTestSuite(FileIOTest.class); - suite.addTestSuite(FileLocksTest.class); - suite.addTestSuite(GridComputeJobExecutionErrorToLogManualTest.class); - suite.addTestSuite(GridManagerMxBeanIllegalArgumentHandleTest.class); - suite.addTestSuite(GridRoundTripTest.class); - suite.addTestSuite(GridServletLoaderTest.class); + suite.addTest(new JUnit4TestAdapter(FileIOTest.class)); + suite.addTest(new JUnit4TestAdapter(FileLocksTest.class)); + suite.addTest(new JUnit4TestAdapter(GridComputeJobExecutionErrorToLogManualTest.class)); + suite.addTest(new JUnit4TestAdapter(GridManagerMxBeanIllegalArgumentHandleTest.class)); + suite.addTest(new JUnit4TestAdapter(GridRoundTripTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServletLoaderTest.class)); - suite.addTestSuite(LinkedHashMapTest.class); - suite.addTestSuite(NetworkFailureTest.class); - suite.addTestSuite(PagesWriteThrottleSandboxTest.class); - suite.addTestSuite(QueueSizeCounterMultiThreadedTest.class); - suite.addTestSuite(ReadWriteLockMultiThreadedTest.class); - suite.addTestSuite(RegExpTest.class); - suite.addTestSuite(ServerSocketMultiThreadedTest.class); + suite.addTest(new JUnit4TestAdapter(LinkedHashMapTest.class)); + suite.addTest(new JUnit4TestAdapter(NetworkFailureTest.class)); + suite.addTest(new JUnit4TestAdapter(PagesWriteThrottleSandboxTest.class)); + suite.addTest(new JUnit4TestAdapter(QueueSizeCounterMultiThreadedTest.class)); + suite.addTest(new JUnit4TestAdapter(ReadWriteLockMultiThreadedTest.class)); + suite.addTest(new JUnit4TestAdapter(RegExpTest.class)); + suite.addTest(new JUnit4TestAdapter(ServerSocketMultiThreadedTest.class)); // Non-JUnit classes with Test in name, which should be either converted to JUnit or removed in the future diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java index f5e3809760c9a..c8d1756519d09 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java @@ -34,25 +34,26 @@ import org.apache.ignite.testframework.GridTestUtils; import java.util.Set; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for all marshallers. */ -public class IgniteMarshallerSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteMarshallerSelfTestSuite { /** * @return Kernal test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** * @param ignoredTests Ignored tests. * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite(Set ignoredTests) throws Exception { + public static TestSuite suite(Set ignoredTests) { TestSuite suite = new TestSuite("Ignite Marshaller Test Suite"); GridTestUtils.addTestIfNeeded(suite, GridUnsafeDataOutputArraySizingSelfTest.class, ignoredTests); diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMessagingConfigVariationFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMessagingConfigVariationFullApiTestSuite.java index 0490a921a9952..788ca7a4ee168 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMessagingConfigVariationFullApiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMessagingConfigVariationFullApiTestSuite.java @@ -26,11 +26,14 @@ import org.apache.ignite.testframework.configvariations.ConfigVariations; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; import org.apache.ignite.testframework.configvariations.Parameters; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test sute for Messaging process. */ -public class IgniteMessagingConfigVariationFullApiTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteMessagingConfigVariationFullApiTestSuite { /** */ @SuppressWarnings("unchecked") private static final ConfigParameter[][] GRID_PARAMETER_VARIATION = new ConfigParameter[][] { @@ -44,9 +47,8 @@ public class IgniteMessagingConfigVariationFullApiTestSuite extends TestSuite { /** * @return Messaging test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Compute New Full API Test Suite"); suite.addTest(new ConfigVariationsTestSuiteBuilder( diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteP2PSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteP2PSelfTestSuite.java index 76b0aa061eb0a..ec4ce1bf5f46f 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteP2PSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteP2PSelfTestSuite.java @@ -18,6 +18,7 @@ package org.apache.ignite.testsuites; import java.util.Set; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.managers.deployment.GridDeploymentMessageCountSelfTest; import org.apache.ignite.p2p.DeploymentClassLoaderCallableTest; @@ -40,46 +41,47 @@ import org.apache.ignite.p2p.P2PStreamingClassLoaderTest; import org.apache.ignite.p2p.SharedDeploymentTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * P2P test suite. */ -public class IgniteP2PSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteP2PSelfTestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** * @return P2P tests suite. - * @throws Exception If failed. */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) - public static TestSuite suite(Set ignoredTests) throws Exception { + public static TestSuite suite(Set ignoredTests) { TestSuite suite = new TestSuite("Ignite P2P Test Suite"); - suite.addTest(new TestSuite(GridP2PDoubleDeploymentSelfTest.class)); - suite.addTest(new TestSuite(GridP2PHotRedeploymentSelfTest.class)); - suite.addTest(new TestSuite(GridP2PClassLoadingSelfTest.class)); - suite.addTest(new TestSuite(GridP2PUndeploySelfTest.class)); - suite.addTest(new TestSuite(GridP2PRemoteClassLoadersSelfTest.class)); - suite.addTest(new TestSuite(GridP2PNodeLeftSelfTest.class)); - suite.addTest(new TestSuite(GridP2PDifferentClassLoaderSelfTest.class)); - suite.addTest(new TestSuite(GridP2PSameClassLoaderSelfTest.class)); - suite.addTest(new TestSuite(GridP2PJobClassLoaderSelfTest.class)); - suite.addTest(new TestSuite(GridP2PRecursionTaskSelfTest.class)); - suite.addTest(new TestSuite(GridP2PLocalDeploymentSelfTest.class)); - //suite.addTest(new TestSuite(GridP2PTestTaskExecutionTest.class)); - suite.addTest(new TestSuite(GridP2PTimeoutSelfTest.class)); - suite.addTest(new TestSuite(GridP2PMissedResourceCacheSizeSelfTest.class)); - suite.addTest(new TestSuite(GridP2PContinuousDeploymentSelfTest.class)); - suite.addTest(new TestSuite(DeploymentClassLoaderCallableTest.class)); - suite.addTest(new TestSuite(P2PStreamingClassLoaderTest.class)); - suite.addTest(new TestSuite(SharedDeploymentTest.class)); - suite.addTest(new TestSuite(P2PScanQueryUndeployTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PDoubleDeploymentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PHotRedeploymentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PClassLoadingSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PUndeploySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PRemoteClassLoadersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PNodeLeftSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PDifferentClassLoaderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PSameClassLoaderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PJobClassLoaderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PRecursionTaskSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PLocalDeploymentSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridP2PTestTaskExecutionTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PTimeoutSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PMissedResourceCacheSizeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PContinuousDeploymentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DeploymentClassLoaderCallableTest.class)); + suite.addTest(new JUnit4TestAdapter(P2PStreamingClassLoaderTest.class)); + suite.addTest(new JUnit4TestAdapter(SharedDeploymentTest.class)); + suite.addTest(new JUnit4TestAdapter(P2PScanQueryUndeployTest.class)); GridTestUtils.addTestIfNeeded(suite, GridDeploymentMessageCountSelfTest.class, ignoredTests); return suite; diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite.java new file mode 100644 index 0000000000000..396f53bad893c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite.java @@ -0,0 +1,90 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import java.util.Set; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsCacheConfigurationFileConsistencyCheckTest; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsDestroyCacheTest; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsDestroyCacheWithoutCheckpointsTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsDataRegionMetricsTest; +import org.apache.ignite.internal.processors.cache.persistence.db.file.DefaultPageSizeBackwardsCompatibilityTest; +import org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsCheckpointSimulationWithRealCpDisabledTest; +import org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsPageReplacementTest; +import org.apache.ignite.internal.processors.cache.persistence.metastorage.IgniteMetaStorageBasicTest; +import org.apache.ignite.internal.processors.cache.persistence.pagemem.BPlusTreePageMemoryImplTest; +import org.apache.ignite.internal.processors.cache.persistence.pagemem.BPlusTreeReuseListPageMemoryImplTest; +import org.apache.ignite.internal.processors.cache.persistence.pagemem.FillFactorMetricTest; +import org.apache.ignite.internal.processors.cache.persistence.pagemem.IndexStoragePageMemoryImplTest; +import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImplNoLoadTest; +import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImplTest; +import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryNoStoreLeakTest; +import org.apache.ignite.internal.processors.cache.persistence.pagemem.PagesWriteThrottleSmokeTest; +import org.apache.ignite.internal.processors.cache.persistence.wal.SegmentedRingByteBufferTest; +import org.apache.ignite.internal.processors.cache.persistence.wal.aware.SegmentAwareTest; + +/** + * + */ +public class IgnitePdsMvccTestSuite extends TestSuite { + /** + * @return Suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + TestSuite suite = new TestSuite("Ignite Persistent Store Mvcc Test Suite"); + + Set ignoredTests = new HashSet<>(); + + // Skip classes that already contains Mvcc tests. + ignoredTests.add(IgnitePdsCheckpointSimulationWithRealCpDisabledTest.class); + + // Atomic tests. + ignoredTests.add(IgnitePdsDataRegionMetricsTest.class); + + // Non-relevant tests. + ignoredTests.add(IgnitePdsCacheConfigurationFileConsistencyCheckTest.class); + ignoredTests.add(DefaultPageSizeBackwardsCompatibilityTest.class); + ignoredTests.add(IgniteMetaStorageBasicTest.class); + + ignoredTests.add(IgnitePdsPageReplacementTest.class); + + ignoredTests.add(PageMemoryImplNoLoadTest.class); + ignoredTests.add(PageMemoryNoStoreLeakTest.class); + ignoredTests.add(IndexStoragePageMemoryImplTest.class); + ignoredTests.add(PageMemoryImplTest.class); + ignoredTests.add(BPlusTreePageMemoryImplTest.class); + ignoredTests.add(BPlusTreeReuseListPageMemoryImplTest.class); + ignoredTests.add(SegmentedRingByteBufferTest.class); + ignoredTests.add(PagesWriteThrottleSmokeTest.class); + ignoredTests.add(FillFactorMetricTest.class); + ignoredTests.add(IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest.class); + ignoredTests.add(SegmentAwareTest.class); + + ignoredTests.add(IgnitePdsDestroyCacheTest.class); + ignoredTests.add(IgnitePdsDestroyCacheWithoutCheckpointsTest.class); + + suite.addTest(IgnitePdsTestSuite.suite(ignoredTests)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite2.java new file mode 100644 index 0000000000000..35928ce338e84 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite2.java @@ -0,0 +1,97 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import java.util.Collection; +import java.util.HashSet; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.processors.cache.persistence.IgniteDataStorageMetricsSelfTest; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsExchangeDuringCheckpointTest; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsPageSizesTest; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePersistentStoreDataStructuresTest; +import org.apache.ignite.internal.processors.cache.persistence.LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest; +import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteAbsentEvictionNodeOutOfBaselineTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsReserveWalSegmentsTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsReserveWalSegmentsWithCompactionTest; +import org.apache.ignite.internal.processors.cache.persistence.db.filename.IgniteUidAsConsistentIdMigrationTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.FsyncWalRolloverDoesNotBlockTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWALTailIsReachedDuringIterationOverArchiveTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalFormatFileFailoverTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalIteratorExceptionDuringReadTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalIteratorSwitchSegmentTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalSerializerVersionTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalCompactionTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalRolloverTypesTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteDataIntegrityTests; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteFsyncReplayWalIteratorInvalidCrcTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgnitePureJavaCrcCompatibility; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteReplayWalIteratorInvalidCrcTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteStandaloneWalIteratorInvalidCrcTest; +import org.apache.ignite.internal.processors.cache.persistence.wal.reader.StandaloneWalRecordsIteratorTest; + +/** + * + */ +public class IgnitePdsMvccTestSuite2 extends TestSuite { + /** + * @return Suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + TestSuite suite = new TestSuite("Ignite persistent Store Mvcc Test Suite 2"); + + Collection ignoredTests = new HashSet<>(); + + // Classes that are contained mvcc test already. + ignoredTests.add(LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest.class); + + // Atomic caches + ignoredTests.add(IgnitePersistentStoreDataStructuresTest.class); + + // Skip irrelevant test + ignoredTests.add(IgniteDataIntegrityTests.class); + ignoredTests.add(IgniteStandaloneWalIteratorInvalidCrcTest.class); + ignoredTests.add(IgniteReplayWalIteratorInvalidCrcTest.class); + ignoredTests.add(IgniteFsyncReplayWalIteratorInvalidCrcTest.class); + ignoredTests.add(IgnitePureJavaCrcCompatibility.class); + ignoredTests.add(IgniteAbsentEvictionNodeOutOfBaselineTest.class); + + ignoredTests.add(IgnitePdsPageSizesTest.class); + ignoredTests.add(IgniteDataStorageMetricsSelfTest.class); + ignoredTests.add(IgniteWalFormatFileFailoverTest.class); + ignoredTests.add(IgnitePdsExchangeDuringCheckpointTest.class); + ignoredTests.add(IgnitePdsReserveWalSegmentsTest.class); + ignoredTests.add(IgnitePdsReserveWalSegmentsWithCompactionTest.class); + + ignoredTests.add(IgniteUidAsConsistentIdMigrationTest.class); + ignoredTests.add(IgniteWalSerializerVersionTest.class); + ignoredTests.add(WalCompactionTest.class); + ignoredTests.add(IgniteWalIteratorSwitchSegmentTest.class); + ignoredTests.add(IgniteWalIteratorExceptionDuringReadTest.class); + ignoredTests.add(StandaloneWalRecordsIteratorTest.class); + ignoredTests.add(IgniteWALTailIsReachedDuringIterationOverArchiveTest.class); + ignoredTests.add(WalRolloverTypesTest.class); + ignoredTests.add(FsyncWalRolloverDoesNotBlockTest.class); + + suite.addTest(IgnitePdsTestSuite2.suite(ignoredTests)); + + return suite; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite3.java new file mode 100644 index 0000000000000..03ba32312111f --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite3.java @@ -0,0 +1,43 @@ +/* + * 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. + */ +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; + +/** + * Mvcc version of {@link IgnitePdsTestSuite3}. + */ +public class IgnitePdsMvccTestSuite3 extends TestSuite { + /** + * @return Suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + TestSuite suite = new TestSuite("Ignite Persistent Store Mvcc Test Suite 3"); + + HashSet ignoredTests = new HashSet<>(); + + // No ignored tests yet. + + suite.addTest(IgnitePdsTestSuite3.suite(ignoredTests)); + + return suite; + } +} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite4.java new file mode 100644 index 0000000000000..bb93385a34eff --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsMvccTestSuite4.java @@ -0,0 +1,53 @@ +/* + * 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. + */ +package org.apache.ignite.testsuites; + +import java.util.HashSet; +import java.util.Set; +import junit.framework.TestSuite; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsTaskCancelingTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsPartitionPreloadTest; +import org.apache.ignite.internal.processors.cache.persistence.file.FileDownloaderTest; + +/** + * Mvcc variant of {@link IgnitePdsTestSuite4}. + */ +public class IgnitePdsMvccTestSuite4 extends TestSuite { + /** + * @return Suite. + */ + public static TestSuite suite() { + System.setProperty(IgniteSystemProperties.IGNITE_FORCE_MVCC_MODE_IN_TESTS, "true"); + + TestSuite suite = new TestSuite("Ignite persistent Store Mvcc Test Suite 4"); + + Set ignoredTests = new HashSet<>(); + + // Skip classes that already contains Mvcc tests + ignoredTests.add(IgnitePdsPartitionPreloadTest.class); + + // Skip irrelevant test + ignoredTests.add(FileDownloaderTest.class); + ignoredTests.add(IgnitePdsTaskCancelingTest.class); + + suite.addTest(IgnitePdsTestSuite4.suite(ignoredTests)); + + return suite; + } + +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java index 4b5327b5c9c90..1284306941c84 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java @@ -17,8 +17,10 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.IgniteClusterActivateDeactivateTestWithPersistence; +import org.apache.ignite.internal.processors.cache.IgnitePdsDataRegionMetricsTxTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsCacheConfigurationFileConsistencyCheckTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsDestroyCacheTest; @@ -28,6 +30,7 @@ import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsCacheRestoreTest; import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsDataRegionMetricsTest; import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsWithTtlTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsWithTtlTest2; import org.apache.ignite.internal.processors.cache.persistence.db.file.DefaultPageSizeBackwardsCompatibilityTest; import org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsCheckpointSimulationWithRealCpDisabledTest; import org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsPageReplacementTest; @@ -50,51 +53,62 @@ import org.apache.ignite.internal.processors.database.IgniteDbPutGetWithCacheStoreTest; import org.apache.ignite.internal.processors.database.IgniteDbSingleNodePutGetTest; import org.apache.ignite.internal.processors.database.IgniteDbSingleNodeTinyPutGetTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgnitePdsTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgnitePdsTestSuite { /** - * @return Suite. - * @throws Exception If failed. + * @return IgniteCache test suite. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { + return suite(null); + } + + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("Ignite Persistent Store Test Suite"); - addRealPageStoreTests(suite); - addRealPageStoreTestsLongRunning(suite); + addRealPageStoreTests(suite, ignoredTests); + addRealPageStoreTestsLongRunning(suite, ignoredTests); // Basic PageMemory tests. - //suite.addTestSuite(PageMemoryNoLoadSelfTest.class); - suite.addTestSuite(PageMemoryImplNoLoadTest.class); - suite.addTestSuite(PageMemoryNoStoreLeakTest.class); - suite.addTestSuite(IndexStoragePageMemoryImplTest.class); - suite.addTestSuite(PageMemoryImplTest.class); - //suite.addTestSuite(PageIdDistributionTest.class); - //suite.addTestSuite(TrackingPageIOTest.class); + //GridTestUtils.addTestIfNeeded(suite, PageMemoryNoLoadSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, PageMemoryImplNoLoadTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, PageMemoryNoStoreLeakTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IndexStoragePageMemoryImplTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, PageMemoryImplTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite, PageIdDistributionTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite, TrackingPageIOTest.class, ignoredTests); // BTree tests with store page memory. - suite.addTestSuite(BPlusTreePageMemoryImplTest.class); - suite.addTestSuite(BPlusTreeReuseListPageMemoryImplTest.class); + GridTestUtils.addTestIfNeeded(suite, BPlusTreePageMemoryImplTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, BPlusTreeReuseListPageMemoryImplTest.class, ignoredTests); - suite.addTestSuite(SegmentedRingByteBufferTest.class); + GridTestUtils.addTestIfNeeded(suite, SegmentedRingByteBufferTest.class, ignoredTests); // Write throttling - suite.addTestSuite(PagesWriteThrottleSmokeTest.class); + GridTestUtils.addTestIfNeeded(suite, PagesWriteThrottleSmokeTest.class, ignoredTests); // Metrics - suite.addTestSuite(FillFactorMetricTest.class); + GridTestUtils.addTestIfNeeded(suite, FillFactorMetricTest.class, ignoredTests); // WAL delta consistency - suite.addTestSuite(CpTriggeredWalDeltaConsistencyTest.class); - suite.addTestSuite(ExplicitWalDeltaConsistencyTest.class); - suite.addTestSuite(SysPropWalDeltaConsistencyTest.class); + GridTestUtils.addTestIfNeeded(suite, CpTriggeredWalDeltaConsistencyTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, ExplicitWalDeltaConsistencyTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, SysPropWalDeltaConsistencyTest.class, ignoredTests); // Binary meta tests. - suite.addTestSuite(IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest.class, ignoredTests); - suite.addTestSuite(SegmentAwareTest.class); + GridTestUtils.addTestIfNeeded(suite, SegmentAwareTest.class, ignoredTests); return suite; } @@ -104,10 +118,11 @@ public static TestSuite suite() throws Exception { * execute. * * @param suite suite to add tests into. + * @param ignoredTests Ignored tests. */ - private static void addRealPageStoreTestsLongRunning(TestSuite suite) { + private static void addRealPageStoreTestsLongRunning(TestSuite suite, Collection ignoredTests) { // Basic PageMemory tests. - suite.addTestSuite(IgnitePdsPageReplacementTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsPageReplacementTest.class, ignoredTests); } /** @@ -116,41 +131,44 @@ private static void addRealPageStoreTestsLongRunning(TestSuite suite) { * NOTE: These tests are also executed using I/O plugins. * * @param suite suite to add tests into. + * @param ignoredTests Ignored tests. */ - public static void addRealPageStoreTests(TestSuite suite) { + public static void addRealPageStoreTests(TestSuite suite, Collection ignoredTests) { // Checkpointing smoke-test. - suite.addTestSuite(IgnitePdsCheckpointSimulationWithRealCpDisabledTest.class); - //suite.addTestSuite(IgnitePdsCheckpointSimpleTest.class); - //suite.addTestSuite(IgnitePersistenceSequentialCheckpointTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsCheckpointSimulationWithRealCpDisabledTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite, IgnitePdsCheckpointSimpleTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite, IgnitePersistenceSequentialCheckpointTest.class, ignoredTests); // Basic API tests. - suite.addTestSuite(IgniteDbSingleNodePutGetTest.class); - suite.addTestSuite(IgniteDbMultiNodePutGetTest.class); - suite.addTestSuite(IgniteDbSingleNodeTinyPutGetTest.class); - suite.addTestSuite(IgniteDbDynamicCacheSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteDbSingleNodePutGetTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteDbMultiNodePutGetTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteDbSingleNodeTinyPutGetTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteDbDynamicCacheSelfTest.class, ignoredTests); // Persistence-enabled. - suite.addTestSuite(IgnitePdsSingleNodePutGetPersistenceTest.class); - suite.addTestSuite(IgnitePdsDynamicCacheTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsSingleNodePutGetPersistenceTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsDynamicCacheTest.class, ignoredTests); // TODO uncomment when https://issues.apache.org/jira/browse/IGNITE-7510 is fixed - // suite.addTestSuite(IgnitePdsClientNearCachePutGetTest.class); - suite.addTestSuite(IgniteDbPutGetWithCacheStoreTest.class); - suite.addTestSuite(IgnitePdsWithTtlTest.class); + // GridTestUtils.addTestIfNeeded(suite, IgnitePdsClientNearCachePutGetTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteDbPutGetWithCacheStoreTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsWithTtlTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsWithTtlTest2.class, ignoredTests); - suite.addTestSuite(IgniteClusterActivateDeactivateTestWithPersistence.class); + GridTestUtils.addTestIfNeeded(suite, IgniteClusterActivateDeactivateTestWithPersistence.class, ignoredTests); - suite.addTestSuite(IgnitePdsCacheRestoreTest.class); - suite.addTestSuite(IgnitePdsDataRegionMetricsTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsCacheRestoreTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsDataRegionMetricsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsDataRegionMetricsTxTest.class, ignoredTests); - suite.addTestSuite(IgnitePdsDestroyCacheTest.class); - //suite.addTestSuite(IgnitePdsRemoveDuringRebalancingTest.class); - suite.addTestSuite(IgnitePdsDestroyCacheWithoutCheckpointsTest.class); - suite.addTestSuite(IgnitePdsCacheConfigurationFileConsistencyCheckTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsDestroyCacheTest.class, ignoredTests); + //GridTestUtils.addTestIfNeeded(suite, IgnitePdsRemoveDuringRebalancingTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsDestroyCacheWithoutCheckpointsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsCacheConfigurationFileConsistencyCheckTest.class, ignoredTests); - suite.addTestSuite(DefaultPageSizeBackwardsCompatibilityTest.class); + GridTestUtils.addTestIfNeeded(suite, DefaultPageSizeBackwardsCompatibilityTest.class, ignoredTests); //MetaStorage - suite.addTestSuite(IgniteMetaStorageBasicTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteMetaStorageBasicTest.class, ignoredTests); } } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java index 527a044b2afaf..9a5c3d741a0c7 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java @@ -17,16 +17,19 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.persistence.IgniteDataStorageMetricsSelfTest; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsCacheStartStopWithFreqCheckpointTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsCorruptedStoreTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsExchangeDuringCheckpointTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsPageSizesTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsPartitionFilesDestroyTest; +import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsPartitionsStateRecoveryTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePersistentStoreDataStructuresTest; import org.apache.ignite.internal.processors.cache.persistence.IgniteRebalanceScheduleResendPartitionsTest; -import org.apache.ignite.internal.processors.cache.persistence.LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest; import org.apache.ignite.internal.processors.cache.persistence.LocalWalModeChangeDuringRebalancingSelfTest; +import org.apache.ignite.internal.processors.cache.persistence.LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest; import org.apache.ignite.internal.processors.cache.persistence.baseline.ClientAffinityAssignmentWithBaselineTest; import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteAbsentEvictionNodeOutOfBaselineTest; import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteAllBaselineNodesOnlineFullApiSelfTest; @@ -34,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.persistence.baseline.IgniteOnlineNodeOutOfBaselineFullApiSelfTest; import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsRebalancingOnNotStableTopologyTest; import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsReserveWalSegmentsTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsReserveWalSegmentsWithCompactionTest; import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsWholeClusterRestartTest; import org.apache.ignite.internal.processors.cache.persistence.db.SlowHistoricalRebalanceSmallHistoryTest; import org.apache.ignite.internal.processors.cache.persistence.db.checkpoint.IgniteCheckpointDirtyPagesForLowLoadTest; @@ -54,42 +58,58 @@ import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalIteratorExceptionDuringReadTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalIteratorSwitchSegmentTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalSerializerVersionTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalCompactionSwitchOnTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalCompactionTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalDeletionArchiveFsyncTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalDeletionArchiveLogOnlyTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalRolloverTypesTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteDataIntegrityTests; import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteFsyncReplayWalIteratorInvalidCrcTest; +import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgnitePureJavaCrcCompatibility; import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteReplayWalIteratorInvalidCrcTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteStandaloneWalIteratorInvalidCrcTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.reader.IgniteWalReaderTest; import org.apache.ignite.internal.processors.cache.persistence.wal.reader.StandaloneWalRecordsIteratorTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ +@RunWith(AllTests.class) public class IgnitePdsTestSuite2 extends TestSuite { /** * @return Suite. */ public static TestSuite suite() { + return suite(null); + } + + /** + * @param ignoredTests Ignored tests. + * @return Suite. + */ + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("Ignite persistent Store Test Suite 2"); // Integrity test. - suite.addTestSuite(IgniteDataIntegrityTests.class); - suite.addTestSuite(IgniteStandaloneWalIteratorInvalidCrcTest.class); - suite.addTestSuite(IgniteReplayWalIteratorInvalidCrcTest.class); - suite.addTestSuite(IgniteFsyncReplayWalIteratorInvalidCrcTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteDataIntegrityTests.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteStandaloneWalIteratorInvalidCrcTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteReplayWalIteratorInvalidCrcTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteFsyncReplayWalIteratorInvalidCrcTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePureJavaCrcCompatibility.class, ignoredTests); - addRealPageStoreTests(suite); + addRealPageStoreTests(suite, ignoredTests); - addRealPageStoreTestsNotForDirectIo(suite); + addRealPageStoreTestsNotForDirectIo(suite, ignoredTests); // BaselineTopology tests - suite.addTestSuite(IgniteAllBaselineNodesOnlineFullApiSelfTest.class); - suite.addTestSuite(IgniteOfflineBaselineNodeFullApiSelfTest.class); - suite.addTestSuite(IgniteOnlineNodeOutOfBaselineFullApiSelfTest.class); - suite.addTestSuite(ClientAffinityAssignmentWithBaselineTest.class); - suite.addTestSuite(IgniteAbsentEvictionNodeOutOfBaselineTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteAllBaselineNodesOnlineFullApiSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteOfflineBaselineNodeFullApiSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteOnlineNodeOutOfBaselineFullApiSelfTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, ClientAffinityAssignmentWithBaselineTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteAbsentEvictionNodeOutOfBaselineTest.class, ignoredTests); return suite; } @@ -99,19 +119,22 @@ public static TestSuite suite() { * execute. * * @param suite suite to add tests into. + * @param ignoredTests Ignored tests. */ - private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite) { - suite.addTestSuite(IgnitePdsPartitionFilesDestroyTest.class); + private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite, Collection ignoredTests) { + GridTestUtils.addTestIfNeeded(suite, IgnitePdsPartitionFilesDestroyTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, LocalWalModeChangeDuringRebalancingSelfTest.class, ignoredTests); - suite.addTestSuite(LocalWalModeChangeDuringRebalancingSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest.class, ignoredTests); - suite.addTestSuite(LocalWacModeNoChangeDuringRebalanceOnNonNodeAssignTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalFlushFsyncSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteWalFlushFsyncSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalFlushFsyncWithDedicatedWorkerSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteWalFlushFsyncWithDedicatedWorkerSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalFlushFsyncWithMmapBufferSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteWalFlushFsyncWithMmapBufferSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsCacheStartStopWithFreqCheckpointTest.class, ignoredTests); } /** @@ -120,72 +143,79 @@ private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite) { * NOTE: These tests are also executed using I/O plugins. * * @param suite suite to add tests into. + * @param ignoredTests Ignored tests. */ - public static void addRealPageStoreTests(TestSuite suite) { - suite.addTestSuite(IgnitePdsPageSizesTest.class); + public static void addRealPageStoreTests(TestSuite suite, Collection ignoredTests) { + GridTestUtils.addTestIfNeeded(suite, IgnitePdsPageSizesTest.class, ignoredTests); // Metrics test. - suite.addTestSuite(IgniteDataStorageMetricsSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteDataStorageMetricsSelfTest.class, ignoredTests); - suite.addTestSuite(IgnitePdsRebalancingOnNotStableTopologyTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsRebalancingOnNotStableTopologyTest.class, ignoredTests); - suite.addTestSuite(IgnitePdsWholeClusterRestartTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsWholeClusterRestartTest.class, ignoredTests); // Rebalancing test - suite.addTestSuite(IgniteWalHistoryReservationsTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalHistoryReservationsTest.class, ignoredTests); - suite.addTestSuite(SlowHistoricalRebalanceSmallHistoryTest.class); + GridTestUtils.addTestIfNeeded(suite, SlowHistoricalRebalanceSmallHistoryTest.class, ignoredTests); - suite.addTestSuite(IgnitePersistentStoreDataStructuresTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePersistentStoreDataStructuresTest.class, ignoredTests); // Failover test - suite.addTestSuite(IgniteWalFlushFailoverTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalFlushFailoverTest.class, ignoredTests); - suite.addTestSuite(IgniteWalFlushBackgroundSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalFlushBackgroundSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteWalFlushBackgroundWithMmapBufferSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalFlushBackgroundWithMmapBufferSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteWalFlushLogOnlySelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalFlushLogOnlySelfTest.class, ignoredTests); - suite.addTestSuite(IgniteWalFlushLogOnlyWithMmapBufferSelfTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalFlushLogOnlyWithMmapBufferSelfTest.class, ignoredTests); - suite.addTestSuite(IgniteWalFormatFileFailoverTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalFormatFileFailoverTest.class, ignoredTests); // Test suite uses Standalone WAL iterator to verify PDS content. - suite.addTestSuite(IgniteWalReaderTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalReaderTest.class, ignoredTests); - suite.addTestSuite(IgnitePdsExchangeDuringCheckpointTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsExchangeDuringCheckpointTest.class, ignoredTests); - suite.addTestSuite(IgnitePdsReserveWalSegmentsTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsReserveWalSegmentsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsReserveWalSegmentsWithCompactionTest.class, ignoredTests); // new style folders with generated consistent ID test - suite.addTestSuite(IgniteUidAsConsistentIdMigrationTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteUidAsConsistentIdMigrationTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, IgniteWalSerializerVersionTest.class, ignoredTests); + + GridTestUtils.addTestIfNeeded(suite, WalCompactionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, WalCompactionSwitchOnTest.class, ignoredTests); - suite.addTestSuite(IgniteWalSerializerVersionTest.class); + GridTestUtils.addTestIfNeeded(suite, WalDeletionArchiveFsyncTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, WalDeletionArchiveLogOnlyTest.class, ignoredTests); - suite.addTestSuite(WalCompactionTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteCheckpointDirtyPagesForLowLoadTest.class, ignoredTests); - suite.addTestSuite(WalDeletionArchiveFsyncTest.class); - suite.addTestSuite(WalDeletionArchiveLogOnlyTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsCorruptedStoreTest.class, ignoredTests); - suite.addTestSuite(IgniteCheckpointDirtyPagesForLowLoadTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalIteratorSwitchSegmentTest.class, ignoredTests); - suite.addTestSuite(IgnitePdsCorruptedStoreTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWalIteratorExceptionDuringReadTest.class, ignoredTests); - suite.addTestSuite(IgniteWalIteratorSwitchSegmentTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteNodeStoppedDuringDisableWALTest.class, ignoredTests); - suite.addTestSuite(IgniteWalIteratorExceptionDuringReadTest.class); + GridTestUtils.addTestIfNeeded(suite, StandaloneWalRecordsIteratorTest.class, ignoredTests); - suite.addTestSuite(IgniteNodeStoppedDuringDisableWALTest.class); + //GridTestUtils.addTestIfNeeded(suite, IgniteWalRecoverySeveralRestartsTest.class, ignoredTests); - suite.addTestSuite(StandaloneWalRecordsIteratorTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteRebalanceScheduleResendPartitionsTest.class, ignoredTests); - //suite.addTestSuite(IgniteWalRecoverySeveralRestartsTest.class); + GridTestUtils.addTestIfNeeded(suite, IgniteWALTailIsReachedDuringIterationOverArchiveTest.class, ignoredTests); - suite.addTestSuite(IgniteRebalanceScheduleResendPartitionsTest.class); + GridTestUtils.addTestIfNeeded(suite, WalRolloverTypesTest.class, ignoredTests); - suite.addTestSuite(IgniteWALTailIsReachedDuringIterationOverArchiveTest.class); + GridTestUtils.addTestIfNeeded(suite, FsyncWalRolloverDoesNotBlockTest.class, ignoredTests); - suite.addTestSuite(FsyncWalRolloverDoesNotBlockTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsPartitionsStateRecoveryTest.class, ignoredTests); } } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite3.java index 06ba9c0611851..82c482e3840c8 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite3.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite3.java @@ -17,21 +17,34 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsContinuousRestartTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsContinuousRestartTestWithExpiryPolicy; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ +@RunWith(AllTests.class) public class IgnitePdsTestSuite3 extends TestSuite { /** - * @return Suite. + * @return IgniteCache test suite. */ public static TestSuite suite() { - TestSuite suite = new TestSuite("Ignite Persistent Store Test Suite 3"); + return suite(null); + } + + /** + * @param ignoredTests Ignored tests. + * @return IgniteCache test suite. + */ + public static TestSuite suite(Collection ignoredTests) { + TestSuite suite = new TestSuite("Ignite Persistent Store Mvcc Test Suite 3"); - addRealPageStoreTestsNotForDirectIo(suite); + addRealPageStoreTestsNotForDirectIo(suite, ignoredTests); return suite; } @@ -40,10 +53,11 @@ public static TestSuite suite() { * Fills {@code suite} with PDS test subset, which operates with real page store, but requires long time to execute. * * @param suite suite to add tests into. + * @param ignoredTests Ignored tests list.` */ - private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite) { + private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite, Collection ignoredTests) { // Rebalancing test - suite.addTestSuite(IgnitePdsContinuousRestartTest.class); - suite.addTestSuite(IgnitePdsContinuousRestartTestWithExpiryPolicy.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsContinuousRestartTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsContinuousRestartTestWithExpiryPolicy.class, ignoredTests); } } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java index c16463529d55c..d38c34a34ed96 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite4.java @@ -17,32 +17,53 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; +import org.apache.ignite.cache.ResetLostPartitionTest; import org.apache.ignite.internal.processors.cache.IgniteClusterActivateDeactivateTestWithPersistenceAndMemoryReuse; +import org.apache.ignite.internal.processors.cache.distributed.CachePageWriteLockUnlockTest; +import org.apache.ignite.internal.processors.cache.distributed.rebalancing.IgniteRebalanceOnCachesStoppingOrDestroyingTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsRecoveryAfterFileCorruptionTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsTaskCancelingTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsCacheWalDisabledOnRebalancingTest; import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsPageEvictionDuringPartitionClearTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsPartitionPreloadTest; import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsTransactionsHangTest; import org.apache.ignite.internal.processors.cache.persistence.file.FileDownloaderTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgnitePdsTestSuite4 extends TestSuite { +@RunWith(AllTests.class) +public class IgnitePdsTestSuite4 { /** * @return Suite. */ public static TestSuite suite() { - TestSuite suite = new TestSuite("Ignite Persistent Store Test Suite 4"); - - addRealPageStoreTestsNotForDirectIo(suite); + return suite(null); + } - suite.addTestSuite(FileDownloaderTest.class); + /** + * @param ignoredTests Ignored tests. + * @return Suite. + */ + public static TestSuite suite(Collection ignoredTests) { + TestSuite suite = new TestSuite("Ignite Persistent Store Test Suite 4"); - suite.addTestSuite(IgnitePdsTaskCancelingTest.class); + addRealPageStoreTestsNotForDirectIo(suite, ignoredTests); - suite.addTestSuite(IgniteClusterActivateDeactivateTestWithPersistenceAndMemoryReuse.class); + GridTestUtils.addTestIfNeeded(suite, FileDownloaderTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsTaskCancelingTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteClusterActivateDeactivateTestWithPersistenceAndMemoryReuse.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsPartitionPreloadTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, ResetLostPartitionTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteRebalanceOnCachesStoppingOrDestroyingTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, CachePageWriteLockUnlockTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsCacheWalDisabledOnRebalancingTest.class, ignoredTests); return suite; } @@ -51,16 +72,16 @@ public static TestSuite suite() { * Fills {@code suite} with PDS test subset, which operates with real page store, but requires long time to execute. * * @param suite suite to add tests into. + * @param ignoredTests Ignored tests. */ - private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite) { - suite.addTestSuite(IgnitePdsTransactionsHangTest.class); - - suite.addTestSuite(IgnitePdsPageEvictionDuringPartitionClearTest.class); + private static void addRealPageStoreTestsNotForDirectIo(TestSuite suite, Collection ignoredTests) { + GridTestUtils.addTestIfNeeded(suite, IgnitePdsTransactionsHangTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsPageEvictionDuringPartitionClearTest.class, ignoredTests); // Rebalancing test - suite.addTestSuite(IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsContinuousRestartTestWithSharedGroupAndIndexes.class, ignoredTests); // Integrity test. - suite.addTestSuite(IgnitePdsRecoveryAfterFileCorruptionTest.class); + GridTestUtils.addTestIfNeeded(suite, IgnitePdsRecoveryAfterFileCorruptionTest.class, ignoredTests); } } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePerformanceTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePerformanceTestSuite.java index 2e829579df9fc..2b4f18f0c661c 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePerformanceTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePerformanceTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.GridCacheConcurrentTxMultiNodeLoadTest; import org.apache.ignite.internal.processors.cache.GridCacheIteratorPerformanceTest; @@ -57,42 +58,45 @@ import org.apache.ignite.loadtests.nio.GridNioBenchmarkTest; import org.apache.ignite.marshaller.GridMarshallerPerformanceTest; import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiLanLoadTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Tests suite for performance tests tests. * Note: Most of these are resource-consuming or non-terminating. */ -public class IgnitePerformanceTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgnitePerformanceTestSuite { /** * @return Tests suite for orphaned tests (not in any test sute previously). */ public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Load-Test Suite"); - suite.addTestSuite(GridCacheDhtPreloadPerformanceTest.class); - suite.addTestSuite(GridCacheIteratorPerformanceTest.class); - suite.addTestSuite(GridCacheMultiNodeLoadTest.class); - suite.addTestSuite(GridCacheConcurrentTxMultiNodeLoadTest.class); - suite.addTestSuite(GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.class); - suite.addTestSuite(GridCachePartitionedAtomicLongLoadTest.class); - suite.addTestSuite(GridCacheWriteBehindStoreLoadTest.class); - suite.addTestSuite(GridCircularBufferPerformanceTest.class); - suite.addTestSuite(GridFuncPerformanceTest.class); - suite.addTestSuite(GridHashMapLoadTest.class); - suite.addTestSuite(GridLeanMapPerformanceTest.class); - suite.addTestSuite(GridMarshallerPerformanceTest.class); - suite.addTestSuite(GridMetadataAwareAdapterLoadTest.class); - suite.addTestSuite(GridMultiSplitsLoadTest.class); - suite.addTestSuite(GridMultiSplitsRedeployLoadTest.class); - suite.addTestSuite(GridSessionLoadTest.class); - suite.addTestSuite(GridSingleSplitsNewNodesMulticastLoadTest.class); - suite.addTestSuite(GridSingleSplitsRedeployLoadTest.class); - suite.addTestSuite(GridStealingLoadTest.class); - suite.addTestSuite(GridTcpCommunicationSpiLanLoadTest.class); - suite.addTestSuite(GridUnsafeMapPerformanceTest.class); - suite.addTestSuite(GridUnsafePartitionedMapPerformanceTest.class); - suite.addTestSuite(IgniteDataStreamerPerformanceTest.class); - suite.addTestSuite(SortedEvictionPolicyPerformanceTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheDhtPreloadPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheIteratorPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheMultiNodeLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheConcurrentTxMultiNodeLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedAtomicLongLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheWriteBehindStoreLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCircularBufferPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFuncPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(GridHashMapLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLeanMapPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMarshallerPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMetadataAwareAdapterLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultiSplitsLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMultiSplitsRedeployLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSingleSplitsNewNodesMulticastLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSingleSplitsRedeployLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridStealingLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiLanLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUnsafeMapPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUnsafePartitionedMapPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDataStreamerPerformanceTest.class)); + suite.addTest(new JUnit4TestAdapter(SortedEvictionPolicyPerformanceTest.class)); // Non-JUnit classes with Test in name, which should be either converted to JUnit or removed in the future // Main classes: diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePlatformsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePlatformsTestSuite.java index f7021d88ce4c0..75a8587ccc0c8 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePlatformsTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePlatformsTestSuite.java @@ -17,24 +17,27 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.platform.PlatformDefaultJavaObjectFactorySelfTest; import org.apache.ignite.platform.PlatformJavaObjectFactoryProxySelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Suite for platform tests. */ -public class IgnitePlatformsTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgnitePlatformsTestSuite { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Deployment SPI Test Suite"); // LocalDeploymentSpi tests - suite.addTest(new TestSuite(PlatformDefaultJavaObjectFactorySelfTest.class)); - suite.addTest(new TestSuite(PlatformJavaObjectFactoryProxySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(PlatformDefaultJavaObjectFactorySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(PlatformJavaObjectFactoryProxySelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteReproducingSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteReproducingSuite.java index 05464590231fb..1c0cf61dcf494 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteReproducingSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteReproducingSuite.java @@ -18,6 +18,8 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cycled run tests on PR code.
    @@ -29,17 +31,17 @@ * * This suite is not included into main build */ -public class IgniteReproducingSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteReproducingSuite { /** * @return suite with test(s) for reproduction some problem. - * @throws Exception if failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Issue Reproducing Test Suite"); //uncomment to add some test //for (int i = 0; i < 100; i++) - // suite.addTestSuite(IgniteCheckpointDirtyPagesForLowLoadTest.class); + // suite.addTest(new JUnit4TestAdapter(IgniteCheckpointDirtyPagesForLowLoadTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteRestHandlerTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteRestHandlerTestSuite.java index f3e5828de031e..e5ea8d50154e2 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteRestHandlerTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteRestHandlerTestSuite.java @@ -17,29 +17,32 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheAtomicCommandHandlerSelfTest; import org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandlerSelfTest; import org.apache.ignite.internal.processors.rest.handlers.log.GridLogCommandHandlerTest; import org.apache.ignite.internal.processors.rest.handlers.query.GridQueryCommandHandlerTest; import org.apache.ignite.internal.processors.rest.handlers.top.CacheTopologyCommandHandlerTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * REST support tests. */ -public class IgniteRestHandlerTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteRestHandlerTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("REST Support Test Suite"); - suite.addTestSuite(GridCacheCommandHandlerSelfTest.class); - suite.addTestSuite(GridCacheAtomicCommandHandlerSelfTest.class); - suite.addTestSuite(GridLogCommandHandlerTest.class); - suite.addTestSuite(GridQueryCommandHandlerTest.class); - suite.addTestSuite(CacheTopologyCommandHandlerTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheCommandHandlerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicCommandHandlerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLogCommandHandlerTest.class)); + suite.addTest(new JUnit4TestAdapter(GridQueryCommandHandlerTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheTopologyCommandHandlerTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java index 84af386537052..7fa59ae3e004d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteServiceConfigVariationsFullApiTestSuite.java @@ -26,11 +26,14 @@ import org.apache.ignite.testframework.configvariations.ConfigVariations; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; import org.apache.ignite.testframework.configvariations.Parameters; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Full API service test suit. */ -public class IgniteServiceConfigVariationsFullApiTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteServiceConfigVariationsFullApiTestSuite { /** */ @SuppressWarnings("unchecked") private static final ConfigParameter[][] PARAMS = new ConfigParameter[][] { @@ -45,9 +48,8 @@ public class IgniteServiceConfigVariationsFullApiTestSuite extends TestSuite { /** * @return Compute API test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Service Deployment New Full API Test Suite"); suite.addTest(new ConfigVariationsTestSuiteBuilder( @@ -89,4 +91,4 @@ public static TestSuite suite() throws Exception { return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCheckpointSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCheckpointSelfTestSuite.java index a3ba8ff4693cc..cb831ef92b454 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCheckpointSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCheckpointSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpiConfigSelfTest; import org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpiSecondCacheSelfTest; @@ -31,36 +32,38 @@ import org.apache.ignite.spi.checkpoint.sharedfs.GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest; import org.apache.ignite.spi.checkpoint.sharedfs.GridSharedFsCheckpointSpiSelfTest; import org.apache.ignite.spi.checkpoint.sharedfs.GridSharedFsCheckpointSpiStartStopSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Grid SPI checkpoint self test suite. */ -public class IgniteSpiCheckpointSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpiCheckpointSelfTestSuite { /** * @return Checkpoint test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Checkpoint Test Suite"); // Cache. - suite.addTest(new TestSuite(CacheCheckpointSpiConfigSelfTest.class)); - suite.addTest(new TestSuite(CacheCheckpointSpiSelfTest.class)); - suite.addTest(new TestSuite(CacheCheckpointSpiStartStopSelfTest.class)); - suite.addTest(new TestSuite(CacheCheckpointSpiSecondCacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheCheckpointSpiConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheCheckpointSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheCheckpointSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheCheckpointSpiSecondCacheSelfTest.class)); // JDBC. - suite.addTest(new TestSuite(JdbcCheckpointSpiConfigSelfTest.class)); - suite.addTest(new TestSuite(JdbcCheckpointSpiCustomConfigSelfTest.class)); - suite.addTest(new TestSuite(JdbcCheckpointSpiDefaultConfigSelfTest.class)); - suite.addTest(new TestSuite(JdbcCheckpointSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcCheckpointSpiConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcCheckpointSpiCustomConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcCheckpointSpiDefaultConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JdbcCheckpointSpiStartStopSelfTest.class)); // Shared FS. - suite.addTest(new TestSuite(GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.class)); - suite.addTest(new TestSuite(GridSharedFsCheckpointSpiSelfTest.class)); - suite.addTest(new TestSuite(GridSharedFsCheckpointSpiStartStopSelfTest.class)); - suite.addTest(new TestSuite(GridSharedFsCheckpointSpiConfigSelfTest.class)); - //suite.addTest(new TestSuite(GridSharedFsCheckpointSpiMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSharedFsCheckpointSpiMultipleDirectoriesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSharedFsCheckpointSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSharedFsCheckpointSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSharedFsCheckpointSpiConfigSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridSharedFsCheckpointSpiMultiThreadedSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCollisionSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCollisionSelfTestSuite.java index d5d6ab8a7b526..8df78eeeebe07 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCollisionSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCollisionSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.collision.fifoqueue.GridFifoQueueCollisionSpiConfigSelfTest; import org.apache.ignite.spi.collision.fifoqueue.GridFifoQueueCollisionSpiSelfTest; @@ -29,35 +30,37 @@ import org.apache.ignite.spi.collision.priorityqueue.GridPriorityQueueCollisionSpiConfigSelfTest; import org.apache.ignite.spi.collision.priorityqueue.GridPriorityQueueCollisionSpiSelfTest; import org.apache.ignite.spi.collision.priorityqueue.GridPriorityQueueCollisionSpiStartStopSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Collision SPI self-test suite. */ -public class IgniteSpiCollisionSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpiCollisionSelfTestSuite { /** * @return Failover SPI tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Collision SPI Test Suite"); // Priority. - suite.addTestSuite(GridPriorityQueueCollisionSpiSelfTest.class); - suite.addTestSuite(GridPriorityQueueCollisionSpiStartStopSelfTest.class); - suite.addTestSuite(GridPriorityQueueCollisionSpiConfigSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridPriorityQueueCollisionSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridPriorityQueueCollisionSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridPriorityQueueCollisionSpiConfigSelfTest.class)); // FIFO. - suite.addTestSuite(GridFifoQueueCollisionSpiSelfTest.class); - suite.addTestSuite(GridFifoQueueCollisionSpiStartStopSelfTest.class); - suite.addTestSuite(GridFifoQueueCollisionSpiConfigSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridFifoQueueCollisionSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFifoQueueCollisionSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFifoQueueCollisionSpiConfigSelfTest.class)); // Job Stealing. - suite.addTestSuite(GridJobStealingCollisionSpiSelfTest.class); - suite.addTestSuite(GridJobStealingCollisionSpiAttributesSelfTest.class); - suite.addTestSuite(GridJobStealingCollisionSpiCustomTopologySelfTest.class); - suite.addTestSuite(GridJobStealingCollisionSpiStartStopSelfTest.class); - suite.addTestSuite(GridJobStealingCollisionSpiConfigSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridJobStealingCollisionSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingCollisionSpiAttributesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingCollisionSpiCustomTopologySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingCollisionSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingCollisionSpiConfigSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java index ef55d36134a9b..c7e0dcb850d1c 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java @@ -17,8 +17,8 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; -import org.apache.ignite.spi.communication.tcp.GridCacheDhtLockBackupSelfTest; import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConcurrentConnectSelfTest; import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConcurrentConnectSslSelfTest; import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConfigSelfTest; @@ -42,53 +42,55 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiHalfOpenedConnectionTest; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiSkipMessageSendTest; import org.apache.ignite.spi.communication.tcp.TcpCommunicationStatisticsTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for all communication SPIs. */ -public class IgniteSpiCommunicationSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpiCommunicationSelfTestSuite { /** * @return Communication SPI tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Communication SPI Test Suite"); - suite.addTest(new TestSuite(GridTcpCommunicationSpiRecoveryAckSelfTest.class)); - suite.addTest(new TestSuite(IgniteTcpCommunicationRecoveryAckClosureSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiRecoverySelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiRecoveryNoPairedConnectionsTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiRecoverySslSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiRecoveryAckSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteTcpCommunicationRecoveryAckClosureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiRecoverySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiRecoveryNoPairedConnectionsTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiRecoverySslSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiConcurrentConnectSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiConcurrentConnectSslSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiConcurrentConnectSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiConcurrentConnectSslSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiSslSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiSslSmallBuffersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiSslSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiSslSmallBuffersSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiTcpSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiTcpNoDelayOffSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiShmemSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiTcpSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiTcpNoDelayOffSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiShmemSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiStartStopSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiMultithreadedSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiMultithreadedShmemTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiMultithreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiMultithreadedShmemTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiTcpFailureDetectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiTcpFailureDetectionSelfTest.class)); - suite.addTest(new TestSuite(GridTcpCommunicationSpiConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTcpCommunicationSpiConfigSelfTest.class)); - suite.addTest(new TestSuite(TcpCommunicationSpiSkipMessageSendTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpCommunicationSpiSkipMessageSendTest.class)); - suite.addTest(new TestSuite(TcpCommunicationSpiFaultyClientTest.class)); - suite.addTest(new TestSuite(TcpCommunicationSpiDropNodesTest.class)); - suite.addTest(new TestSuite(TcpCommunicationSpiHalfOpenedConnectionTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpCommunicationSpiFaultyClientTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpCommunicationSpiDropNodesTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpCommunicationSpiHalfOpenedConnectionTest.class)); - suite.addTest(new TestSuite(TcpCommunicationStatisticsTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpCommunicationStatisticsTest.class)); - //suite.addTest(new TestSuite(GridCacheDhtLockBackupSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(GridCacheDhtLockBackupSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDeploymentSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDeploymentSelfTestSuite.java index f3b1e5665d298..6fce539a8b27a 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDeploymentSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDeploymentSelfTestSuite.java @@ -17,25 +17,28 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.deployment.local.GridLocalDeploymentSpiSelfTest; import org.apache.ignite.spi.deployment.local.GridLocalDeploymentSpiStartStopSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suit for deployment SPIs. */ -public class IgniteSpiDeploymentSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpiDeploymentSelfTestSuite { /** * @return Deployment SPI tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Deployment SPI Test Suite"); // LocalDeploymentSpi tests - suite.addTest(new TestSuite(GridLocalDeploymentSpiSelfTest.class)); - suite.addTest(new TestSuite(GridLocalDeploymentSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLocalDeploymentSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLocalDeploymentSpiStartStopSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java index 04869f9aa91d8..fb0d5ab45ec3d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java @@ -17,21 +17,25 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.IgniteDiscoveryMassiveNodeFailTest; import org.apache.ignite.spi.GridTcpSpiForwardingSelfTest; import org.apache.ignite.spi.discovery.AuthenticationRestartTest; import org.apache.ignite.spi.discovery.FilterDataForClientNodeDiscoveryTest; import org.apache.ignite.spi.discovery.IgniteDiscoveryCacheReuseSelfTest; +import org.apache.ignite.spi.discovery.LongClientConnectToClusterTest; import org.apache.ignite.spi.discovery.tcp.DiscoveryUnmarshalVulnerabilityTest; import org.apache.ignite.spi.discovery.tcp.IgniteClientConnectTest; import org.apache.ignite.spi.discovery.tcp.IgniteClientReconnectMassiveShutdownTest; import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoveryMarshallerCheckSelfTest; +import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoverySpiCoordinatorChangeTest; import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoverySpiFailureTimeoutSelfTest; import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoverySpiMulticastTest; import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoverySpiSelfTest; import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoveryUnresolvedHostTest; import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryClientSuspensionSelfTest; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryIpFinderCleanerTest; import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryMarshallerCheckSelfTest; import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryMultiThreadedTest; import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryNodeAttributesUpdateOnReconnectTest; @@ -68,78 +72,80 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite { /** * @return Discovery SPI tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, GridTestUtils.getNextMulticastGroup(IgniteSpiDiscoverySelfTestSuite.class)); TestSuite suite = new TestSuite("Ignite Discovery SPI Test Suite"); // Tcp. - suite.addTest(new TestSuite(TcpDiscoveryVmIpFinderSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySharedFsIpFinderSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoveryJdbcIpFinderSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoveryMulticastIpFinderSelfTest.class)); - - suite.addTest(new TestSuite(TcpDiscoverySelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySpiSelfTest.class)); - //suite.addTest(new TestSuite(TcpDiscoverySpiRandomStartStopTest.class)); - //suite.addTest(new TestSuite(TcpDiscoverySpiSslSelfTest.class)); - //suite.addTest(new TestSuite(TcpDiscoverySpiWildcardSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySpiFailureTimeoutSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySpiMBeanTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySpiStartStopSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySpiConfigSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoveryMarshallerCheckSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySnapshotHistoryTest.class)); - - suite.addTest(new TestSuite(GridTcpSpiForwardingSelfTest.class)); - - suite.addTest(new TestSuite(TcpClientDiscoverySpiSelfTest.class)); - suite.addTest(new TestSuite(TcpClientDiscoveryMarshallerCheckSelfTest.class)); - suite.addTest(new TestSuite(TcpClientDiscoverySpiMulticastTest.class)); - suite.addTest(new TestSuite(TcpClientDiscoverySpiFailureTimeoutSelfTest.class)); - suite.addTest(new TestSuite(TcpClientDiscoveryUnresolvedHostTest.class)); - - suite.addTest(new TestSuite(TcpDiscoveryNodeConsistentIdSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoveryNodeConfigConsistentIdSelfTest.class)); - - suite.addTest(new TestSuite(TcpDiscoveryRestartTest.class)); - suite.addTest(new TestSuite(TcpDiscoveryMultiThreadedTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryVmIpFinderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySharedFsIpFinderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryJdbcIpFinderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryMulticastIpFinderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryIpFinderCleanerTest.class)); + + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySpiSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(TcpDiscoverySpiRandomStartStopTest.class)); + //suite.addTest(new JUnit4TestAdapter(TcpDiscoverySpiSslSelfTest.class)); + //suite.addTest(new JUnit4TestAdapter(TcpDiscoverySpiWildcardSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySpiFailureTimeoutSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySpiMBeanTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySpiConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryMarshallerCheckSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySnapshotHistoryTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridTcpSpiForwardingSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(TcpClientDiscoverySpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(LongClientConnectToClusterTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpClientDiscoveryMarshallerCheckSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpClientDiscoverySpiCoordinatorChangeTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpClientDiscoverySpiMulticastTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpClientDiscoverySpiFailureTimeoutSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpClientDiscoveryUnresolvedHostTest.class)); + + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryNodeConsistentIdSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryNodeConfigConsistentIdSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryMultiThreadedTest.class)); //suite.addTest(new TestSuite(TcpDiscoveryConcurrentStartTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySegmentationPolicyTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySegmentationPolicyTest.class)); - suite.addTest(new TestSuite(TcpDiscoveryNodeAttributesUpdateOnReconnectTest.class)); - suite.addTest(new TestSuite(AuthenticationRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryNodeAttributesUpdateOnReconnectTest.class)); + suite.addTest(new JUnit4TestAdapter(AuthenticationRestartTest.class)); - suite.addTest(new TestSuite(TcpDiscoveryWithWrongServerTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryWithWrongServerTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySpiReconnectDelayTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySpiReconnectDelayTest.class)); - suite.addTest(new TestSuite(IgniteDiscoveryMassiveNodeFailTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDiscoveryMassiveNodeFailTest.class)); // Client connect. - suite.addTest(new TestSuite(IgniteClientConnectTest.class)); - suite.addTest(new TestSuite(IgniteClientReconnectMassiveShutdownTest.class)); - suite.addTest(new TestSuite(TcpDiscoveryClientSuspensionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientConnectTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectMassiveShutdownTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryClientSuspensionSelfTest.class)); // SSL. - suite.addTest(new TestSuite(TcpDiscoverySslSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySslTrustedSelfTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySslSecuredUnsecuredTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySslTrustedUntrustedTest.class)); - suite.addTest(new TestSuite(TcpDiscoverySslParametersTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySslSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySslTrustedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySslSecuredUnsecuredTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySslTrustedUntrustedTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoverySslParametersTest.class)); // Disco cache reuse. - suite.addTest(new TestSuite(IgniteDiscoveryCacheReuseSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDiscoveryCacheReuseSelfTest.class)); - suite.addTest(new TestSuite(DiscoveryUnmarshalVulnerabilityTest.class)); + suite.addTest(new JUnit4TestAdapter(DiscoveryUnmarshalVulnerabilityTest.class)); - suite.addTest(new TestSuite(FilterDataForClientNodeDiscoveryTest.class)); + suite.addTest(new JUnit4TestAdapter(FilterDataForClientNodeDiscoveryTest.class)); - suite.addTest(new TestSuite(TcpDiscoveryPendingMessageDeliveryTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryPendingMessageDeliveryTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiEventStorageSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiEventStorageSelfTestSuite.java index 9f295a28e883e..b9917d6246a95 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiEventStorageSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiEventStorageSelfTestSuite.java @@ -17,28 +17,31 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.eventstorage.memory.GridMemoryEventStorageMultiThreadedSelfTest; import org.apache.ignite.spi.eventstorage.memory.GridMemoryEventStorageSpiConfigSelfTest; import org.apache.ignite.spi.eventstorage.memory.GridMemoryEventStorageSpiSelfTest; import org.apache.ignite.spi.eventstorage.memory.GridMemoryEventStorageSpiStartStopSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Event storage test suite. */ -public class IgniteSpiEventStorageSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpiEventStorageSelfTestSuite { /** * @return Event storage test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Event Storage Test Suite"); - suite.addTest(new TestSuite(GridMemoryEventStorageSpiSelfTest.class)); - suite.addTest(new TestSuite(GridMemoryEventStorageSpiStartStopSelfTest.class)); - suite.addTest(new TestSuite(GridMemoryEventStorageMultiThreadedSelfTest.class)); - suite.addTest(new TestSuite(GridMemoryEventStorageSpiConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMemoryEventStorageSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMemoryEventStorageSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMemoryEventStorageMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMemoryEventStorageSpiConfigSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiFailoverSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiFailoverSelfTestSuite.java index 2e8f0e9965326..933a2bcc0b5d1 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiFailoverSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiFailoverSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.failover.always.GridAlwaysFailoverSpiConfigSelfTest; import org.apache.ignite.spi.failover.always.GridAlwaysFailoverSpiSelfTest; @@ -27,33 +28,35 @@ import org.apache.ignite.spi.failover.jobstealing.GridJobStealingFailoverSpiStartStopSelfTest; import org.apache.ignite.spi.failover.never.GridNeverFailoverSpiSelfTest; import org.apache.ignite.spi.failover.never.GridNeverFailoverSpiStartStopSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Failover SPI self-test suite. */ -public class IgniteSpiFailoverSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpiFailoverSelfTestSuite { /** * @return Failover SPI tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Failover SPI Test Suite"); // Always failover. - suite.addTest(new TestSuite(GridAlwaysFailoverSpiSelfTest.class)); - suite.addTest(new TestSuite(GridAlwaysFailoverSpiStartStopSelfTest.class)); - suite.addTest(new TestSuite(GridAlwaysFailoverSpiConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAlwaysFailoverSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAlwaysFailoverSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAlwaysFailoverSpiConfigSelfTest.class)); // Never failover. - suite.addTest(new TestSuite(GridNeverFailoverSpiSelfTest.class)); - suite.addTest(new TestSuite(GridNeverFailoverSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridNeverFailoverSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridNeverFailoverSpiStartStopSelfTest.class)); // Job stealing failover. - suite.addTest(new TestSuite(GridJobStealingFailoverSpiSelfTest.class)); - suite.addTest(new TestSuite(GridJobStealingFailoverSpiOneNodeSelfTest.class)); - suite.addTest(new TestSuite(GridJobStealingFailoverSpiStartStopSelfTest.class)); - suite.addTest(new TestSuite(GridJobStealingFailoverSpiConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingFailoverSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingFailoverSpiOneNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingFailoverSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridJobStealingFailoverSpiConfigSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiLoadBalancingSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiLoadBalancingSelfTestSuite.java index 52d4fddabef24..e5bdfeff08f29 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiLoadBalancingSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiLoadBalancingSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.Test; import junit.framework.TestSuite; import org.apache.ignite.spi.loadbalancing.adaptive.GridAdaptiveLoadBalancingSpiConfigSelfTest; @@ -34,10 +35,13 @@ import org.apache.ignite.spi.loadbalancing.weightedrandom.GridWeightedRandomLoadBalancingSpiSelfTest; import org.apache.ignite.spi.loadbalancing.weightedrandom.GridWeightedRandomLoadBalancingSpiStartStopSelfTest; import org.apache.ignite.spi.loadbalancing.weightedrandom.GridWeightedRandomLoadBalancingSpiWeightedSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Load balancing SPI self-test suite. */ +@RunWith(AllTests.class) public final class IgniteSpiLoadBalancingSelfTestSuite { /** * Enforces singleton. @@ -53,27 +57,27 @@ public static Test suite() { TestSuite suite = new TestSuite("Ignite Load Balancing Test Suite"); // Random. - suite.addTestSuite(GridWeightedRandomLoadBalancingSpiSelfTest.class); - suite.addTestSuite(GridWeightedRandomLoadBalancingSpiWeightedSelfTest.class); - suite.addTestSuite(GridWeightedRandomLoadBalancingSpiStartStopSelfTest.class); - suite.addTestSuite(GridWeightedRandomLoadBalancingSpiConfigSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridWeightedRandomLoadBalancingSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridWeightedRandomLoadBalancingSpiWeightedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridWeightedRandomLoadBalancingSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridWeightedRandomLoadBalancingSpiConfigSelfTest.class)); // Round-robin. - suite.addTestSuite(GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.class); - suite.addTestSuite(GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.class); - suite.addTestSuite(GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.class); - suite.addTestSuite(GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.class); - suite.addTestSuite(GridRoundRobinLoadBalancingSpiStartStopSelfTest.class); - suite.addTestSuite(GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridRoundRobinLoadBalancingSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.class)); // Adaptive. - suite.addTestSuite(GridAdaptiveLoadBalancingSpiSelfTest.class); - suite.addTestSuite(GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.class); - suite.addTestSuite(GridAdaptiveLoadBalancingSpiStartStopSelfTest.class); - suite.addTestSuite(GridAdaptiveLoadBalancingSpiConfigSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridAdaptiveLoadBalancingSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAdaptiveLoadBalancingSpiStartStopSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridAdaptiveLoadBalancingSpiConfigSelfTest.class)); // Load balancing for internal tasks. - suite.addTestSuite(GridInternalTasksLoadBalancingSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridInternalTasksLoadBalancingSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiTestSuite.java index d5ded38bff1bd..c98cbf11c0250 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiTestSuite.java @@ -17,15 +17,19 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.managers.GridManagerLocalMessageListenerSelfTest; import org.apache.ignite.internal.managers.GridNoopManagerSelfTest; import org.apache.ignite.spi.encryption.KeystoreEncryptionSpiSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Grid SPI test suite. */ -public class IgniteSpiTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpiTestSuite { /** * @return All SPI tests suite. * @throws Exception If failed. @@ -58,12 +62,12 @@ public static TestSuite suite() throws Exception { suite.addTest(IgniteSpiCommunicationSelfTestSuite.suite()); // All other tests. - suite.addTestSuite(GridNoopManagerSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridNoopManagerSelfTest.class)); // Local Message Listener tests. - suite.addTestSuite(GridManagerLocalMessageListenerSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridManagerLocalMessageListenerSelfTest.class)); - suite.addTestSuite(KeystoreEncryptionSpiSelfTest.class); + suite.addTest(new JUnit4TestAdapter(KeystoreEncryptionSpiSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStandByClusterSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStandByClusterSuite.java index f5244207c89af..8cdc6df93297c 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStandByClusterSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStandByClusterSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.IgniteClusterActivateDeactivateTest; import org.apache.ignite.internal.processors.cache.distributed.CacheBaselineTopologyTest; @@ -35,45 +36,48 @@ import org.apache.ignite.internal.processors.cache.persistence.standbycluster.join.persistence.JoinInActiveNodeToInActiveClusterWithPersistence; import org.apache.ignite.internal.processors.cache.persistence.standbycluster.reconnect.IgniteStandByClientReconnectTest; import org.apache.ignite.internal.processors.cache.persistence.standbycluster.reconnect.IgniteStandByClientReconnectToNewClusterTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgniteStandByClusterSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteStandByClusterSuite { /** * @return Test suite. */ public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Activate/DeActivate Cluster Test Suite"); - suite.addTestSuite(IgniteClusterActivateDeactivateTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteClusterActivateDeactivateTest.class)); - suite.addTestSuite(IgniteStandByClusterTest.class); - suite.addTestSuite(IgniteStandByClientReconnectTest.class); - suite.addTestSuite(IgniteStandByClientReconnectToNewClusterTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteStandByClusterTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteStandByClientReconnectTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteStandByClientReconnectToNewClusterTest.class)); - suite.addTestSuite(JoinActiveNodeToActiveCluster.class); - suite.addTestSuite(JoinActiveNodeToInActiveCluster.class); - suite.addTestSuite(JoinInActiveNodeToActiveCluster.class); - suite.addTestSuite(JoinInActiveNodeToInActiveCluster.class); + suite.addTest(new JUnit4TestAdapter(JoinActiveNodeToActiveCluster.class)); + suite.addTest(new JUnit4TestAdapter(JoinActiveNodeToInActiveCluster.class)); + suite.addTest(new JUnit4TestAdapter(JoinInActiveNodeToActiveCluster.class)); + suite.addTest(new JUnit4TestAdapter(JoinInActiveNodeToInActiveCluster.class)); - suite.addTestSuite(JoinActiveNodeToActiveClusterWithPersistence.class); - suite.addTestSuite(JoinActiveNodeToInActiveClusterWithPersistence.class); - suite.addTestSuite(JoinInActiveNodeToActiveClusterWithPersistence.class); - suite.addTestSuite(JoinInActiveNodeToInActiveClusterWithPersistence.class); + suite.addTest(new JUnit4TestAdapter(JoinActiveNodeToActiveClusterWithPersistence.class)); + suite.addTest(new JUnit4TestAdapter(JoinActiveNodeToInActiveClusterWithPersistence.class)); + suite.addTest(new JUnit4TestAdapter(JoinInActiveNodeToActiveClusterWithPersistence.class)); + suite.addTest(new JUnit4TestAdapter(JoinInActiveNodeToInActiveClusterWithPersistence.class)); -//TODO https://issues.apache.org/jira/browse/IGNITE-9081 suite.addTestSuite(IgniteChangeGlobalStateTest.class); -//TODO https://issues.apache.org/jira/browse/IGNITE-9081 suite.addTestSuite(IgniteChangeGlobalStateCacheTest.class); -//TODO https://issues.apache.org/jira/browse/IGNITE-9081 suite.addTestSuite(IgniteChangeGlobalStateDataStructureTest.class); -//TODO https://issues.apache.org/jira/browse/IGNITE-9081 suite.addTestSuite(IgniteChangeGlobalStateServiceTest.class); +//TODO https://issues.apache.org/jira/browse/IGNITE-9081 suite.addTest(new JUnit4TestAdapter(IgniteChangeGlobalStateTest.class)); +//TODO https://issues.apache.org/jira/browse/IGNITE-9081 suite.addTest(new JUnit4TestAdapter(IgniteChangeGlobalStateCacheTest.class)); +//TODO https://issues.apache.org/jira/browse/IGNITE-9081 suite.addTest(new JUnit4TestAdapter(IgniteChangeGlobalStateDataStructureTest.class)); +//TODO https://issues.apache.org/jira/browse/IGNITE-9081 suite.addTest(new JUnit4TestAdapter(IgniteChangeGlobalStateServiceTest.class)); - suite.addTestSuite(IgniteChangeGlobalStateDataStreamerTest.class); - suite.addTestSuite(IgniteChangeGlobalStateFailOverTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteChangeGlobalStateDataStreamerTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteChangeGlobalStateFailOverTest.class)); - suite.addTestSuite(IgniteNoParrallelClusterIsAllowedTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteNoParrallelClusterIsAllowedTest.class)); - suite.addTestSuite(CacheBaselineTopologyTest.class); - suite.addTestSuite(IgniteBaselineAffinityTopologyActivationTest.class); + suite.addTest(new JUnit4TestAdapter(CacheBaselineTopologyTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteBaselineAffinityTopologyActivationTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStartUpTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStartUpTestSuite.java index b29f5c730dd2e..815c658e465c7 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStartUpTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStartUpTestSuite.java @@ -17,21 +17,24 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.startup.cmdline.GridCommandLineTransformerSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Loaders self-test suite. */ -public class IgniteStartUpTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteStartUpTestSuite { /** * @return Loaders tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite StartUp Test Suite"); - suite.addTest(new TestSuite(GridCommandLineTransformerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCommandLineTransformerSelfTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStreamSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStreamSelfTestSuite.java index 9eac2773166f7..ab4650db5cffa 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStreamSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStreamSelfTestSuite.java @@ -17,24 +17,27 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.stream.socket.SocketStreamerSelfTest; import org.apache.ignite.stream.socket.SocketStreamerUnmarshalVulnerabilityTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Stream test suite. */ -public class IgniteStreamSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteStreamSelfTestSuite { /** * @return Stream tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Stream Test Suite"); - suite.addTest(new TestSuite(SocketStreamerSelfTest.class)); - suite.addTest(new TestSuite(SocketStreamerUnmarshalVulnerabilityTest.class)); + suite.addTest(new JUnit4TestAdapter(SocketStreamerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SocketStreamerUnmarshalVulnerabilityTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTaskSessionSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTaskSessionSelfTestSuite.java index 9a837db184ac4..8ab1daee13ef9 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTaskSessionSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTaskSessionSelfTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.session.GridSessionCancelSiblingsFromFutureSelfTest; import org.apache.ignite.session.GridSessionCancelSiblingsFromJobSelfTest; @@ -37,38 +38,40 @@ import org.apache.ignite.session.GridSessionSetTaskAttributeSelfTest; import org.apache.ignite.session.GridSessionTaskWaitJobAttributeSelfTest; import org.apache.ignite.session.GridSessionWaitAttributeSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Task session test suite. */ -public class IgniteTaskSessionSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteTaskSessionSelfTestSuite { /** * @return TaskSession test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite TaskSession Test Suite"); - suite.addTest(new TestSuite(GridSessionCancelSiblingsFromFutureSelfTest.class)); - suite.addTest(new TestSuite(GridSessionCancelSiblingsFromJobSelfTest.class)); - suite.addTest(new TestSuite(GridSessionCancelSiblingsFromTaskSelfTest.class)); - suite.addTest(new TestSuite(GridSessionSetFutureAttributeSelfTest.class)); - suite.addTest(new TestSuite(GridSessionSetFutureAttributeWaitListenerSelfTest.class)); - suite.addTest(new TestSuite(GridSessionSetJobAttributeWaitListenerSelfTest.class)); - suite.addTest(new TestSuite(GridSessionSetJobAttributeSelfTest.class)); - suite.addTest(new TestSuite(GridSessionSetJobAttribute2SelfTest.class)); - suite.addTest(new TestSuite(GridSessionJobWaitTaskAttributeSelfTest.class)); - suite.addTest(new TestSuite(GridSessionSetTaskAttributeSelfTest.class)); - suite.addTest(new TestSuite(GridSessionFutureWaitTaskAttributeSelfTest.class)); - suite.addTest(new TestSuite(GridSessionFutureWaitJobAttributeSelfTest.class)); - suite.addTest(new TestSuite(GridSessionTaskWaitJobAttributeSelfTest.class)); - suite.addTest(new TestSuite(GridSessionSetJobAttributeOrderSelfTest.class)); - suite.addTest(new TestSuite(GridSessionWaitAttributeSelfTest.class)); - suite.addTest(new TestSuite(GridSessionJobFailoverSelfTest.class)); - suite.addTest(new TestSuite(GridSessionLoadSelfTest.class)); - suite.addTest(new TestSuite(GridSessionCollisionSpiSelfTest.class)); - suite.addTest(new TestSuite(GridSessionCheckpointSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionCancelSiblingsFromFutureSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionCancelSiblingsFromJobSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionCancelSiblingsFromTaskSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionSetFutureAttributeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionSetFutureAttributeWaitListenerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionSetJobAttributeWaitListenerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionSetJobAttributeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionSetJobAttribute2SelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionJobWaitTaskAttributeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionSetTaskAttributeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionFutureWaitTaskAttributeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionFutureWaitJobAttributeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionTaskWaitJobAttributeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionSetJobAttributeOrderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionWaitAttributeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionJobFailoverSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionLoadSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionCollisionSpiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSessionCheckpointSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTimeoutProcessorSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTimeoutProcessorSelfTestSuite.java index 713dce0a30b8a..50bdbdcf8650f 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTimeoutProcessorSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTimeoutProcessorSelfTestSuite.java @@ -17,23 +17,26 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessorSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Suite for {@link GridTimeoutProcessor} tests. */ -public class IgniteTimeoutProcessorSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteTimeoutProcessorSelfTestSuite { /** * @return Job metrics test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Timeout Processor Test Suite"); - suite.addTest(new TestSuite(GridTimeoutProcessorSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTimeoutProcessorSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTopologyValidatorTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTopologyValidatorTestSuite.java index 1c9b8525c8be0..1466b856910c9 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTopologyValidatorTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteTopologyValidatorTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import java.util.Collection; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorGridSplitCacheTest; import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorNearPartitionedAtomicCacheGroupsTest; @@ -31,34 +32,38 @@ import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorReplicatedAtomicCacheTest; import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorReplicatedTxCacheGroupsTest; import org.apache.ignite.internal.processors.cache.IgniteTopologyValidatorReplicatedTxCacheTest; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Topology validator test suite. */ -public class IgniteTopologyValidatorTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteTopologyValidatorTestSuite { /** + * @param ignoredTests Ignored tests. * @return Topology validator tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite(Collection ignoredTests) { TestSuite suite = new TestSuite("Topology validator Test Suite"); - suite.addTest(new TestSuite(IgniteTopologyValidatorNearPartitionedAtomicCacheTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorNearPartitionedTxCacheTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorPartitionedAtomicCacheTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorPartitionedTxCacheTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorReplicatedAtomicCacheTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorReplicatedTxCacheTest.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorNearPartitionedAtomicCacheTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorNearPartitionedTxCacheTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorPartitionedAtomicCacheTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorPartitionedTxCacheTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorReplicatedAtomicCacheTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorReplicatedTxCacheTest.class, ignoredTests); - suite.addTest(new TestSuite(IgniteTopologyValidatorNearPartitionedAtomicCacheGroupsTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorNearPartitionedTxCacheGroupsTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorPartitionedAtomicCacheGroupsTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorPartitionedTxCacheGroupsTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorReplicatedAtomicCacheGroupsTest.class)); - suite.addTest(new TestSuite(IgniteTopologyValidatorReplicatedTxCacheGroupsTest.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorNearPartitionedAtomicCacheGroupsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorNearPartitionedTxCacheGroupsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorPartitionedAtomicCacheGroupsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorPartitionedTxCacheGroupsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorReplicatedAtomicCacheGroupsTest.class, ignoredTests); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorReplicatedTxCacheGroupsTest.class, ignoredTests); - suite.addTest(new TestSuite(IgniteTopologyValidatorGridSplitCacheTest.class)); + GridTestUtils.addTestIfNeeded(suite, IgniteTopologyValidatorGridSplitCacheTest.class, ignoredTests); return suite; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java index a281662db33ec..2fdf11bfae142 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java @@ -18,7 +18,9 @@ package org.apache.ignite.testsuites; import java.util.Set; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.apache.ignite.internal.IgniteVersionUtilsSelfTest; import org.apache.ignite.internal.commandline.CommandHandlerParsingTest; import org.apache.ignite.internal.pagemem.impl.PageIdUtilsSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheUtilsSelfTest; @@ -62,82 +64,84 @@ import org.apache.ignite.util.mbeans.GridMBeanExoticNamesSelfTest; import org.apache.ignite.util.mbeans.GridMBeanSelfTest; import org.apache.ignite.util.mbeans.WorkersControlMXBeanTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for Ignite utility classes. */ -public class IgniteUtilSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteUtilSelfTestSuite { /** * @return Grid utility methods tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return suite(null); } /** * @param ignoredTests Tests don't include in the execution. * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite(Set ignoredTests) throws Exception { + public static TestSuite suite(Set ignoredTests) { TestSuite suite = new TestSuite("Ignite Util Test Suite"); - suite.addTestSuite(GridThreadPoolExecutorServiceSelfTest.class); - suite.addTestSuite(IgniteThreadPoolSizeTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteVersionUtilsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridThreadPoolExecutorServiceSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteThreadPoolSizeTest.class)); GridTestUtils.addTestIfNeeded(suite, IgniteUtilsSelfTest.class, ignoredTests); - suite.addTestSuite(GridSpinReadWriteLockSelfTest.class); - suite.addTestSuite(GridQueueSelfTest.class); - suite.addTestSuite(GridStringBuilderFactorySelfTest.class); - suite.addTestSuite(GridToStringBuilderSelfTest.class); - suite.addTestSuite(CircularStringBuilderSelfTest.class); - suite.addTestSuite(GridByteArrayListSelfTest.class); - suite.addTestSuite(GridMBeanSelfTest.class); - suite.addTestSuite(GridMBeanDisableSelfTest.class); - suite.addTestSuite(GridMBeanExoticNamesSelfTest.class); - suite.addTestSuite(GridLongListSelfTest.class); - suite.addTestSuite(GridThreadTest.class); - suite.addTestSuite(GridIntListSelfTest.class); - suite.addTestSuite(GridArraysSelfTest.class); - suite.addTestSuite(GridCacheUtilsSelfTest.class); - suite.addTestSuite(IgniteExceptionRegistrySelfTest.class); - suite.addTestSuite(GridMessageCollectionTest.class); - suite.addTestSuite(WorkersControlMXBeanTest.class); - suite.addTestSuite(GridConcurrentLinkedDequeMultiThreadedTest.class); - suite.addTestSuite(GridLogThrottleTest.class); - suite.addTestSuite(GridRandomSelfTest.class); - suite.addTestSuite(GridSnapshotLockSelfTest.class); - suite.addTestSuite(GridTopologyHeapSizeSelfTest.class); - suite.addTestSuite(GridTransientTest.class); - suite.addTestSuite(IgniteDevOnlyLogTest.class); + suite.addTest(new JUnit4TestAdapter(GridSpinReadWriteLockSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridQueueSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridStringBuilderFactorySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridToStringBuilderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CircularStringBuilderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridByteArrayListSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMBeanSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMBeanDisableSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMBeanExoticNamesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLongListSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridThreadTest.class)); + suite.addTest(new JUnit4TestAdapter(GridIntListSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridArraysSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheUtilsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteExceptionRegistrySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridMessageCollectionTest.class)); + suite.addTest(new JUnit4TestAdapter(WorkersControlMXBeanTest.class)); + suite.addTest(new JUnit4TestAdapter(GridConcurrentLinkedDequeMultiThreadedTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLogThrottleTest.class)); + suite.addTest(new JUnit4TestAdapter(GridRandomSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSnapshotLockSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTopologyHeapSizeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTransientTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDevOnlyLogTest.class)); // Sensitive toString. - suite.addTestSuite(IncludeSensitiveAtomicTest.class); - suite.addTestSuite(IncludeSensitiveTransactionalTest.class); + suite.addTest(new JUnit4TestAdapter(IncludeSensitiveAtomicTest.class)); + suite.addTest(new JUnit4TestAdapter(IncludeSensitiveTransactionalTest.class)); // Metrics. - suite.addTestSuite(ClusterMetricsSnapshotSerializeSelfTest.class); + suite.addTest(new JUnit4TestAdapter(ClusterMetricsSnapshotSerializeSelfTest.class)); // Unsafe. - suite.addTestSuite(GridUnsafeMemorySelfTest.class); - suite.addTestSuite(GridUnsafeStripedLruSefTest.class); - suite.addTestSuite(GridUnsafeMapSelfTest.class); - suite.addTestSuite(GridUnsafePartitionedMapSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridUnsafeMemorySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUnsafeStripedLruSefTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUnsafeMapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUnsafePartitionedMapSelfTest.class)); // NIO. - suite.addTestSuite(GridNioSessionMetaKeySelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridNioSessionMetaKeySelfTest.class)); GridTestUtils.addTestIfNeeded(suite, GridNioSelfTest.class, ignoredTests); - suite.addTestSuite(GridNioFilterChainSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridNioFilterChainSelfTest.class)); GridTestUtils.addTestIfNeeded(suite, GridNioSslSelfTest.class, ignoredTests); - suite.addTestSuite(GridNioDelimitedBufferSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridNioDelimitedBufferSelfTest.class)); - suite.addTestSuite(GridPartitionMapSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridPartitionMapSelfTest.class)); //dbx - suite.addTestSuite(PageIdUtilsSelfTest.class); + suite.addTest(new JUnit4TestAdapter(PageIdUtilsSelfTest.class)); // control.sh - suite.addTestSuite(CommandHandlerParsingTest.class); + suite.addTest(new JUnit4TestAdapter(CommandHandlerParsingTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/InterceptorCacheConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/InterceptorCacheConfigVariationsFullApiTestSuite.java index 31fd365fe6392..f25225c191c53 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/InterceptorCacheConfigVariationsFullApiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/InterceptorCacheConfigVariationsFullApiTestSuite.java @@ -20,16 +20,18 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.InterceptorCacheConfigVariationsFullApiTest; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cache API. */ -public class InterceptorCacheConfigVariationsFullApiTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class InterceptorCacheConfigVariationsFullApiTestSuite { /** * @return Cache API test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return new ConfigVariationsTestSuiteBuilder( "Cache New Full API Test Suite with Interceptor", InterceptorCacheConfigVariationsFullApiTest.class) diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/TxDeadlockDetectionTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/TxDeadlockDetectionTestSuite.java index 0bd9584fee0b5..4e94a3193ab43 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/TxDeadlockDetectionTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/TxDeadlockDetectionTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.transactions.DepthFirstSearchTest; import org.apache.ignite.internal.processors.cache.transactions.TxDeadlockCauseTest; @@ -28,28 +29,30 @@ import org.apache.ignite.internal.processors.cache.transactions.TxOptimisticDeadlockDetectionTest; import org.apache.ignite.internal.processors.cache.transactions.TxPessimisticDeadlockDetectionCrossCacheTest; import org.apache.ignite.internal.processors.cache.transactions.TxPessimisticDeadlockDetectionTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Deadlock detection related tests. */ -public class TxDeadlockDetectionTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class TxDeadlockDetectionTestSuite { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Deadlock Detection Test Suite"); - suite.addTestSuite(DepthFirstSearchTest.class); - suite.addTestSuite(TxOptimisticDeadlockDetectionTest.class); - suite.addTestSuite(TxOptimisticDeadlockDetectionCrossCacheTest.class); - suite.addTestSuite(TxPessimisticDeadlockDetectionTest.class); - suite.addTestSuite(TxPessimisticDeadlockDetectionCrossCacheTest.class); - //suite.addTestSuite(TxDeadlockCauseTest.class); - suite.addTestSuite(TxDeadlockDetectionTest.class); - suite.addTestSuite(TxDeadlockDetectionNoHangsTest.class); - suite.addTestSuite(TxDeadlockDetectionUnmasrhalErrorsTest.class); - suite.addTestSuite(TxDeadlockDetectionMessageMarshallingTest.class); + suite.addTest(new JUnit4TestAdapter(DepthFirstSearchTest.class)); + suite.addTest(new JUnit4TestAdapter(TxOptimisticDeadlockDetectionTest.class)); + suite.addTest(new JUnit4TestAdapter(TxOptimisticDeadlockDetectionCrossCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(TxPessimisticDeadlockDetectionTest.class)); + suite.addTest(new JUnit4TestAdapter(TxPessimisticDeadlockDetectionCrossCacheTest.class)); + //suite.addTest(new JUnit4TestAdapter(TxDeadlockCauseTest.class)); + suite.addTest(new JUnit4TestAdapter(TxDeadlockDetectionTest.class)); + suite.addTest(new JUnit4TestAdapter(TxDeadlockDetectionNoHangsTest.class)); + suite.addTest(new JUnit4TestAdapter(TxDeadlockDetectionUnmasrhalErrorsTest.class)); + suite.addTest(new JUnit4TestAdapter(TxDeadlockDetectionMessageMarshallingTest.class)); return suite; } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/WithKeepBinaryCacheConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/WithKeepBinaryCacheConfigVariationsFullApiTestSuite.java index e557d77d93034..069274c25809b 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/WithKeepBinaryCacheConfigVariationsFullApiTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/WithKeepBinaryCacheConfigVariationsFullApiTestSuite.java @@ -23,17 +23,19 @@ import org.apache.ignite.internal.processors.cache.WithKeepBinaryCacheFullApiTest; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cache API. */ -public class WithKeepBinaryCacheConfigVariationsFullApiTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class WithKeepBinaryCacheConfigVariationsFullApiTestSuite { /** * @return Cache API test suite. - * @throws Exception If failed. */ @SuppressWarnings("serial") - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("With Keep Binary Cache Config Variations Full API Test Suite"); suite.addTest(new ConfigVariationsTestSuiteBuilder( diff --git a/modules/core/src/test/java/org/apache/ignite/thread/GridThreadPoolExecutorServiceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/thread/GridThreadPoolExecutorServiceSelfTest.java index dce6328775ef8..f6d00815ed501 100644 --- a/modules/core/src/test/java/org/apache/ignite/thread/GridThreadPoolExecutorServiceSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/thread/GridThreadPoolExecutorServiceSelfTest.java @@ -28,6 +28,9 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; @@ -35,6 +38,7 @@ * Test for {@link IgniteThreadPoolExecutor}. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class GridThreadPoolExecutorServiceSelfTest extends GridCommonAbstractTest { /** Thread count. */ private static final int THREAD_CNT = 40; @@ -42,6 +46,7 @@ public class GridThreadPoolExecutorServiceSelfTest extends GridCommonAbstractTes /** * @throws Exception If failed. */ + @Test public void testSingleThreadExecutor() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(); @@ -63,6 +68,7 @@ public void testSingleThreadExecutor() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingleGridThreadExecutor() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(new IgniteThreadFactory("gridName", "testThread")); @@ -84,6 +90,7 @@ public void testSingleGridThreadExecutor() throws Exception { /** * @throws ExecutionException If failed. */ + @Test public void testGridThreadPoolExecutor() throws Exception { IgniteThreadPoolExecutor exec = new IgniteThreadPoolExecutor("", "", 1, 1, 0, new LinkedBlockingQueue()); @@ -100,6 +107,7 @@ public void testGridThreadPoolExecutor() throws Exception { /** * @throws ExecutionException If failed. */ + @Test public void testGridThreadPoolExecutorRejection() throws Exception { IgniteThreadPoolExecutor exec = new IgniteThreadPoolExecutor("", "", 1, 1, 0, new LinkedBlockingQueue()); @@ -113,6 +121,7 @@ public void testGridThreadPoolExecutorRejection() throws Exception { /** * @throws ExecutionException If failed. */ + @Test public void testGridThreadPoolExecutorPrestartCoreThreads() throws Exception { final AtomicInteger curPoolSize = new AtomicInteger(); @@ -190,4 +199,4 @@ private final class TestRunnable implements Runnable { } } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/thread/GridThreadTest.java b/modules/core/src/test/java/org/apache/ignite/thread/GridThreadTest.java index 56741f6d65b9e..2a3e35214e679 100644 --- a/modules/core/src/test/java/org/apache/ignite/thread/GridThreadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/thread/GridThreadTest.java @@ -21,11 +21,15 @@ import java.util.Collection; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link org.apache.ignite.thread.IgniteThread}. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class GridThreadTest extends GridCommonAbstractTest { /** Thread count. */ private static final int THREAD_CNT = 3; @@ -33,6 +37,7 @@ public class GridThreadTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAssertion() throws Exception { Collection ts = new ArrayList<>(); @@ -50,4 +55,4 @@ public void testAssertion() throws Exception { for (IgniteThread t : ts) t.join(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/thread/IgniteThreadPoolSizeTest.java b/modules/core/src/test/java/org/apache/ignite/thread/IgniteThreadPoolSizeTest.java index f8ea38a2e6a57..6ef4cb65cacf5 100644 --- a/modules/core/src/test/java/org/apache/ignite/thread/IgniteThreadPoolSizeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/thread/IgniteThreadPoolSizeTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.Ignition; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteThreadPoolSizeTest extends GridCommonAbstractTest { /** Wrong thread pool size value for testing */ private static final int WRONG_VALUE = 0; @@ -39,6 +43,7 @@ private IgniteConfiguration configuration() { /** * @throws Exception If failed. */ + @Test public void testAsyncCallbackPoolSize() throws Exception { testWrongPoolSize(configuration().setAsyncCallbackPoolSize(WRONG_VALUE)); } @@ -46,6 +51,7 @@ public void testAsyncCallbackPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgfsThreadPoolSize() throws Exception { testWrongPoolSize(configuration().setIgfsThreadPoolSize(WRONG_VALUE)); } @@ -53,6 +59,7 @@ public void testIgfsThreadPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testManagementThreadPoolSize() throws Exception { testWrongPoolSize(configuration().setManagementThreadPoolSize(WRONG_VALUE)); } @@ -60,6 +67,7 @@ public void testManagementThreadPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPeerClassLoadingThreadPoolSize() throws Exception { testWrongPoolSize(configuration().setPeerClassLoadingThreadPoolSize(WRONG_VALUE)); } @@ -67,6 +75,7 @@ public void testPeerClassLoadingThreadPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPublicThreadPoolSize() throws Exception { testWrongPoolSize(configuration().setPublicThreadPoolSize(WRONG_VALUE)); } @@ -74,6 +83,7 @@ public void testPublicThreadPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalanceThreadPoolSize() throws Exception { testWrongPoolSize(configuration().setRebalanceThreadPoolSize(WRONG_VALUE)); } @@ -81,6 +91,7 @@ public void testRebalanceThreadPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSystemThreadPoolSize() throws Exception { testWrongPoolSize(configuration().setSystemThreadPoolSize(WRONG_VALUE)); } @@ -88,6 +99,7 @@ public void testSystemThreadPoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUtilityCachePoolSize() throws Exception { testWrongPoolSize(configuration().setUtilityCachePoolSize(WRONG_VALUE)); } @@ -95,6 +107,7 @@ public void testUtilityCachePoolSize() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectorThreadPoolSize() throws Exception { final IgniteConfiguration cfg = configuration(); diff --git a/modules/core/src/test/java/org/apache/ignite/util/AttributeNodeFilterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/AttributeNodeFilterSelfTest.java index 2463d9a2d2c79..21c0fdbd3a1d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/AttributeNodeFilterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/AttributeNodeFilterSelfTest.java @@ -28,18 +28,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link AttributeNodeFilter}. */ +@RunWith(JUnit4.class) public class AttributeNodeFilterSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private Map attrs; @@ -47,8 +45,6 @@ public class AttributeNodeFilterSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - if (attrs != null) cfg.setUserAttributes(attrs); @@ -68,6 +64,7 @@ public class AttributeNodeFilterSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSingleAttribute() throws Exception { IgnitePredicate filter = new AttributeNodeFilter("attr", "value"); @@ -82,6 +79,7 @@ public void testSingleAttribute() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingleAttributeNullValue() throws Exception { IgnitePredicate filter = new AttributeNodeFilter("attr", null); @@ -95,6 +93,7 @@ public void testSingleAttributeNullValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleAttributes() throws Exception { IgnitePredicate filter = new AttributeNodeFilter(F.asMap("attr1", "value1", "attr2", "value2")); @@ -111,6 +110,7 @@ public void testMultipleAttributes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleAttributesNullValues() throws Exception { IgnitePredicate filter = new AttributeNodeFilter(F.asMap("attr1", null, "attr2", null)); @@ -126,6 +126,7 @@ public void testMultipleAttributesNullValues() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterGroup() throws Exception { Ignite group1 = startGridsMultiThreaded(3); @@ -146,6 +147,7 @@ public void testClusterGroup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheFilter() throws Exception { Ignite group1 = startGridsMultiThreaded(3); diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerSslTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerSslTest.java new file mode 100644 index 0000000000000..9616d51f4b87e --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerSslTest.java @@ -0,0 +1,173 @@ +/* + * 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. + */ + +package org.apache.ignite.util; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.apache.ignite.Ignite; +import org.apache.ignite.configuration.ConnectorConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.commandline.CommandHandler; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.ssl.SslContextFactory; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_CONNECTION_FAILED; +import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK; + +/** + * Command line handler test with SSL. + */ +@RunWith(JUnit4.class) +public class GridCommandHandlerSslTest extends GridCommonAbstractTest { + /** */ + private volatile String[] cipherSuites; + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + cleanPersistenceDir(); + + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** + * @return SSL factory. + */ + @NotNull private SslContextFactory createSslFactory() { + SslContextFactory factory = (SslContextFactory)GridTestUtils.sslFactory(); + + factory.setCipherSuites(cipherSuites); + + return factory; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setDataStorageConfiguration(new DataStorageConfiguration()); + cfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration().setMaxSize(100 * 1024 * 1024); + cfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration().setPersistenceEnabled(true); + + cfg.setConnectorConfiguration(new ConnectorConfiguration()); + cfg.getConnectorConfiguration().setSslEnabled(true); + cfg.setSslContextFactory(createSslFactory()); + + return cfg; + } + + /** + * @param nodeCipherSuite Ciphers suites to set on node. + * @param utilityCipherSuite Ciphers suites to set on utility. + * @param expRes Expected result. + * @throws Exception If failed. + */ + private void activate(String nodeCipherSuite, String utilityCipherSuite, int expRes) throws Exception { + cipherSuites = F.isEmpty(nodeCipherSuite) ? null : nodeCipherSuite.split(","); + + Ignite ignite = startGrids(1); + + assertFalse(ignite.cluster().active()); + + final CommandHandler cmd = new CommandHandler(); + + List params = new ArrayList<>(); + params.add("--activate"); + params.add("--keystore"); + params.add(GridTestUtils.keyStorePath("node01")); + params.add("--keystore-password"); + params.add(GridTestUtils.keyStorePassword()); + + if (!F.isEmpty(utilityCipherSuite)) { + params.add("--ssl-cipher-suites"); + params.add(utilityCipherSuite); + } + + assertEquals(expRes, cmd.execute(params)); + + if (expRes == EXIT_CODE_OK) + assertTrue(ignite.cluster().active()); + else + assertFalse(ignite.cluster().active()); + + assertEquals(EXIT_CODE_CONNECTION_FAILED, cmd.execute(Arrays.asList("--deactivate", "--yes"))); + } + + /** + * @throws Exception If test failed. + */ + @Test + public void testDefaultCipherSuite() throws Exception { + cipherSuites = null; + + activate(null, null, EXIT_CODE_OK); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testSameCipherSuite() throws Exception { + String ciphers = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," + + "TLS_RSA_WITH_AES_128_GCM_SHA256," + + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"; + + activate(ciphers, ciphers, EXIT_CODE_OK); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testOneCommonCipherSuite() throws Exception { + String nodeCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256," + + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"; + + String utilityCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," + + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"; + + activate(nodeCipherSuites, utilityCipherSuites, EXIT_CODE_OK); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testNoCommonCipherSuite() throws Exception { + String nodeCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256"; + + String utilityCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," + + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"; + + activate(nodeCipherSuites, utilityCipherSuites, EXIT_CODE_CONNECTION_FAILED); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java index cf2bd2873e72a..2021fc2853779 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java @@ -17,11 +17,9 @@ package org.apache.ignite.util; -import javax.cache.processor.EntryProcessor; -import javax.cache.processor.EntryProcessorException; -import javax.cache.processor.MutableEntry; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.IOException; import java.io.PrintStream; import java.nio.file.DirectoryStream; import java.nio.file.Files; @@ -34,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -42,25 +41,33 @@ import java.util.concurrent.atomic.LongAdder; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.cache.processor.EntryProcessor; +import javax.cache.processor.EntryProcessorException; +import javax.cache.processor.MutableEntry; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteAtomicSequence; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.AtomicConfiguration; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.GridJobExecuteResponse; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.commandline.Command; import org.apache.ignite.internal.commandline.CommandHandler; import org.apache.ignite.internal.commandline.cache.CacheCommand; import org.apache.ignite.internal.managers.communication.GridIoMessage; import org.apache.ignite.internal.pagemem.wal.record.DataEntry; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.CacheObjectImpl; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; @@ -76,11 +83,13 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.processors.datastructures.GridCacheInternalKeyImpl; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.tx.VisorTxInfo; import org.apache.ignite.internal.visor.tx.VisorTxTaskResult; @@ -94,6 +103,7 @@ import org.apache.ignite.transactions.TransactionRollbackException; import org.apache.ignite.transactions.TransactionTimeoutException; import org.jetbrains.annotations.NotNull; +import org.junit.Test; import static java.nio.file.Files.delete; import static java.nio.file.Files.newDirectoryStream; @@ -102,7 +112,10 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK; import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_UNEXPECTED_ERROR; -import static org.apache.ignite.internal.processors.cache.verify.VerifyBackupPartitionsDumpTask.IDLE_DUMP_FILE_PREMIX; +import static org.apache.ignite.internal.commandline.OutputFormat.MULTI_LINE; +import static org.apache.ignite.internal.commandline.OutputFormat.SINGLE_LINE; +import static org.apache.ignite.internal.commandline.cache.CacheCommand.HELP; +import static org.apache.ignite.internal.processors.cache.verify.VerifyBackupPartitionsDumpTask.IDLE_DUMP_FILE_PREFIX; import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; @@ -120,6 +133,12 @@ public class GridCommandHandlerTest extends GridCommonAbstractTest { /** Option is used for auto confirmation. */ private static final String CMD_AUTO_CONFIRMATION = "--yes"; + /** Atomic configuration. */ + private AtomicConfiguration atomicConfiguration; + + /** Additional data region configuration. */ + private DataRegionConfiguration dataRegionConfiguration; + /** * @return Folder in work directory. * @throws IgniteCheckedException If failed to resolve folder name. @@ -147,11 +166,12 @@ protected File folder(String folder) throws IgniteCheckedException { cleanPersistenceDir(); - //delete idle-verify dump files. + // Delete idle-verify dump files. try (DirectoryStream files = newDirectoryStream( - Paths.get(U.defaultWorkDirectory()), - entry -> entry.toFile().getName().startsWith(IDLE_DUMP_FILE_PREMIX) - )) { + Paths.get(U.defaultWorkDirectory()), + entry -> entry.toFile().getName().startsWith(IDLE_DUMP_FILE_PREFIX) + ) + ) { for (Path path : files) delete(path); } @@ -180,12 +200,19 @@ protected void injectTestSystemOut() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + if (atomicConfiguration != null) + cfg.setAtomicConfiguration(atomicConfiguration); + cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); cfg.setConnectorConfiguration(new ConnectorConfiguration()); - DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration( - new DataRegionConfiguration().setMaxSize(50L * 1024 * 1024)); + DataStorageConfiguration memCfg = new DataStorageConfiguration() + .setDefaultDataRegionConfiguration(new DataRegionConfiguration() + .setMaxSize(50L * 1024 * 1024)); + + if (dataRegionConfiguration != null) + memCfg.setDataRegionConfigurations(dataRegionConfiguration); cfg.setDataStorageConfiguration(memCfg); @@ -205,6 +232,7 @@ protected void injectTestSystemOut() { * * @throws Exception If failed. */ + @Test public void testActivate() throws Exception { Ignite ignite = startGrids(1); @@ -227,9 +255,11 @@ protected int execute(String... args) { * @param args Arguments. * @return Result of execution */ - protected int execute(ArrayList args) { - // Add force to avoid interactive confirmation - args.add(CMD_AUTO_CONFIRMATION); + protected int execute(List args) { + if(!F.isEmpty(args) && !"--help".equalsIgnoreCase(args.get(0))) { + // Add force to avoid interactive confirmation. + args.add(CMD_AUTO_CONFIRMATION); + } return new CommandHandler().execute(args); } @@ -265,6 +295,7 @@ protected int execute(CommandHandler hnd, String... args) { * * @throws Exception If failed. */ + @Test public void testDeactivate() throws Exception { Ignite ignite = startGrids(1); @@ -284,6 +315,7 @@ public void testDeactivate() throws Exception { * * @throws Exception If failed. */ + @Test public void testState() throws Exception { Ignite ignite = startGrids(1); @@ -301,6 +333,7 @@ public void testState() throws Exception { * * @throws Exception If failed. */ + @Test public void testBaselineCollect() throws Exception { Ignite ignite = startGrids(1); @@ -337,6 +370,7 @@ private String consistentIds(Ignite... ignites) { * * @throws Exception If failed. */ + @Test public void testBaselineAdd() throws Exception { Ignite ignite = startGrids(1); @@ -357,6 +391,7 @@ public void testBaselineAdd() throws Exception { * * @throws Exception If failed. */ + @Test public void testBaselineRemove() throws Exception { Ignite ignite = startGrids(1); Ignite other = startGrid("nodeToStop"); @@ -380,6 +415,7 @@ public void testBaselineRemove() throws Exception { * * @throws Exception If failed. */ + @Test public void testBaselineSet() throws Exception { Ignite ignite = startGrids(1); @@ -401,6 +437,7 @@ public void testBaselineSet() throws Exception { * * @throws Exception If failed. */ + @Test public void testBaselineVersion() throws Exception { Ignite ignite = startGrids(1); @@ -422,6 +459,7 @@ public void testBaselineVersion() throws Exception { * * @throws Exception If failed. */ + @Test public void testActiveTransactions() throws Exception { Ignite ignite = startGridsMultiThreaded(2); @@ -450,9 +488,7 @@ public void testActiveTransactions() throws Exception { // Basic test. validate(h, map -> { - ClusterNode node = grid(0).cluster().localNode(); - - VisorTxTaskResult res = map.get(node); + VisorTxTaskResult res = map.get(grid(0).cluster().localNode()); for (VisorTxInfo info : res.getInfos()) { if (info.getSize() == 100) { @@ -473,7 +509,7 @@ public void testActiveTransactions() throws Exception { for (Map.Entry entry : map.entrySet()) assertEquals(entry.getKey().equals(node) ? 1 : 0, entry.getValue().getInfos().size()); - }, "--tx", "label", "label1"); + }, "--tx", "--label", "label1"); // Test filter by label regex. validate(h, map -> { @@ -495,7 +531,7 @@ else if (entry.getKey().equals(node2)) { assertTrue(entry.getValue().getInfos().isEmpty()); } - }, "--tx", "label", "^label[0-9]"); + }, "--tx", "--label", "^label[0-9]"); // Test filter by empty label. validate(h, map -> { @@ -504,7 +540,7 @@ else if (entry.getKey().equals(node2)) { for (VisorTxInfo info : res.getInfos()) assertNull(info.getLabel()); - }, "--tx", "label", "null"); + }, "--tx", "--label", "null"); // test check minSize int minSize = 10; @@ -516,21 +552,21 @@ else if (entry.getKey().equals(node2)) { for (VisorTxInfo txInfo : res.getInfos()) assertTrue(txInfo.getSize() >= minSize); - }, "--tx", "minSize", Integer.toString(minSize)); + }, "--tx", "--min-size", Integer.toString(minSize)); // test order by size. validate(h, map -> { VisorTxTaskResult res = map.get(grid(0).localNode()); assertTrue(res.getInfos().get(0).getSize() >= res.getInfos().get(1).getSize()); - }, "--tx", "order", "SIZE"); + }, "--tx", "--order", "SIZE"); // test order by duration. validate(h, map -> { VisorTxTaskResult res = map.get(grid(0).localNode()); assertTrue(res.getInfos().get(0).getDuration() >= res.getInfos().get(1).getDuration()); - }, "--tx", "order", "DURATION"); + }, "--tx", "--order", "DURATION"); // test order by start_time. validate(h, map -> { @@ -538,7 +574,7 @@ else if (entry.getKey().equals(node2)) { for (int i = res.getInfos().size() - 1; i > 1; i--) assertTrue(res.getInfos().get(i - 1).getStartTime() >= res.getInfos().get(i).getStartTime()); - }, "--tx", "order", CommandHandler.CMD_TX_ORDER_START_TIME); + }, "--tx", "--order", "START_TIME"); // Trigger topology change and test connection. IgniteInternalFuture startFut = multithreadedAsync(() -> { @@ -563,9 +599,9 @@ else if (entry.getKey().equals(node2)) { VisorTxInfo info = killedEntry.getValue().getInfos().get(0); assertEquals(toKill[0].getXid(), info.getXid()); - }, "--tx", "kill", - "xid", toKill[0].getXid().toString(), // Use saved on first run value. - "nodes", grid(0).localNode().consistentId().toString()); + }, "--tx", "--kill", + "--xid", toKill[0].getXid().toString(), // Use saved on first run value. + "--nodes", grid(0).localNode().consistentId().toString()); unlockLatch.countDown(); @@ -581,6 +617,7 @@ else if (entry.getKey().equals(node2)) { /** * */ + @Test public void testKillHangingLocalTransactions() throws Exception { Ignite ignite = startGridsMultiThreaded(2); @@ -632,7 +669,7 @@ public void testKillHangingLocalTransactions() throws Exception { assertEquals(tx0.xid(), info.getXid()); assertEquals(1, map.size()); - }, "--tx", "kill"); + }, "--tx", "--kill"); tx0.finishFuture().get(); @@ -650,6 +687,7 @@ public void testKillHangingLocalTransactions() throws Exception { /** * Simulate uncommitted backup transactions and test rolling back using utility. */ + @Test public void testKillHangingRemoteTransactions() throws Exception { final int cnt = 3; @@ -797,7 +835,7 @@ public void testKillHangingRemoteTransactions() throws Exception { // Check kill. validate(h, map -> { // No-op. - }, "--tx", "kill"); + }, "--tx", "--kill"); // Wait for all remote txs to finish. for (Ignite ignite : G.allGrids()) { @@ -828,6 +866,7 @@ public void testKillHangingRemoteTransactions() throws Exception { * * @throws Exception If failed. */ + @Test public void testBaselineAddOnNotActiveCluster() throws Exception { Ignite ignite = startGrid(1); @@ -854,36 +893,41 @@ public void testBaselineAddOnNotActiveCluster() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheHelp() throws Exception { - Ignite ignite = startGrids(1); - - ignite.cluster().active(true); - injectTestSystemOut(); assertEquals(EXIT_CODE_OK, execute("--cache", "help")); for (CacheCommand cmd : CacheCommand.values()) { - if (cmd != CacheCommand.HELP) - assertTrue(cmd.text(), testOut.toString().contains(cmd.text())); + if (cmd != HELP) + assertTrue(cmd.text(), testOut.toString().contains(cmd.toString())); } } /** * @throws Exception If failed. */ + @Test + public void testHelp() throws Exception { + injectTestSystemOut(); + + assertEquals(EXIT_CODE_OK, execute("--help")); + + for (Command cmd : Command.values()) + assertTrue(cmd.text(), testOut.toString().contains(cmd.toString())); + } + + /** + * @throws Exception If failed. + */ + @Test public void testCacheIdleVerify() throws Exception { - Ignite ignite = startGrids(2); + IgniteEx ignite = (IgniteEx)startGrids(2); ignite.cluster().active(true); - IgniteCache cache = ignite.createCache(new CacheConfiguration<>() - .setAffinity(new RendezvousAffinityFunction(false, 32)) - .setBackups(1) - .setName(DEFAULT_CACHE_NAME)); - - for (int i = 0; i < 100; i++) - cache.put(i, i); + createCacheAndPreload(ignite, 100); injectTestSystemOut(); @@ -893,7 +937,7 @@ public void testCacheIdleVerify() throws Exception { HashSet clearKeys = new HashSet<>(Arrays.asList(1, 2, 3, 4, 5, 6)); - ((IgniteEx)ignite).context().cache().cache(DEFAULT_CACHE_NAME).clearLocallyAll(clearKeys, true, true, true); + ignite.context().cache().cache(DEFAULT_CACHE_NAME).clearLocallyAll(clearKeys, true, true, true); assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify")); @@ -905,20 +949,13 @@ public void testCacheIdleVerify() throws Exception { * * @throws Exception If failed. */ + @Test public void testCacheIdleVerifyTwoConflictTypes() throws Exception { IgniteEx ignite = (IgniteEx)startGrids(2); ignite.cluster().active(true); - int parts = 32; - - IgniteCache cache = ignite.createCache(new CacheConfiguration<>() - .setAffinity(new RendezvousAffinityFunction(false, parts)) - .setBackups(1) - .setName(DEFAULT_CACHE_NAME)); - - for (int i = 0; i < 100; i++) - cache.put(i, i); + createCacheAndPreload(ignite, 100); injectTestSystemOut(); @@ -930,7 +967,7 @@ public void testCacheIdleVerifyTwoConflictTypes() throws Exception { corruptDataEntry(cacheCtx, 1, true, false); - corruptDataEntry(cacheCtx, 1 + parts / 2, false, true); + corruptDataEntry(cacheCtx, 1 + cacheCtx.config().getAffinity().partitions() / 2, false, true); assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify")); @@ -942,17 +979,17 @@ public void testCacheIdleVerifyTwoConflictTypes() throws Exception { * * @throws Exception If failed. */ + @Test public void testCacheIdleVerifyDump() throws Exception { IgniteEx ignite = (IgniteEx)startGrids(3); ignite.cluster().active(true); - int parts = 32; + int keysCount = 20;//less than parts number for ability to check skipZeros flag. - IgniteCache cache = ignite.createCache(new CacheConfiguration<>() - .setAffinity(new RendezvousAffinityFunction(false, parts)) - .setBackups(1) - .setName(DEFAULT_CACHE_NAME)); + createCacheAndPreload(ignite, keysCount); + + int parts = ignite.affinity(DEFAULT_CACHE_NAME).partitions(); ignite.createCache(new CacheConfiguration<>() .setAffinity(new RendezvousAffinityFunction(false, parts)) @@ -961,14 +998,9 @@ public void testCacheIdleVerifyDump() throws Exception { injectTestSystemOut(); - int keysCount = 20;//less than parts number for ability to check skipZeros flag. - - for (int i = 0; i < keysCount; i++) - cache.put(i, i); - assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump", DEFAULT_CACHE_NAME)); - assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump", "--skipZeros", DEFAULT_CACHE_NAME)); + assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump", "--skip-zeros", DEFAULT_CACHE_NAME)); Matcher fileNameMatcher = dumpFileNameMatcher(); @@ -1028,37 +1060,382 @@ private void assertSort(int expectedPartsCount, String output) { * * @throws Exception If failed. */ + @Test public void testCacheIdleVerifyDumpForCorruptedData() throws Exception { IgniteEx ignite = (IgniteEx)startGrids(3); ignite.cluster().active(true); + createCacheAndPreload(ignite, 100); + + injectTestSystemOut(); + + corruptingAndCheckDefaultCache(ignite, "ALL"); + } + + /** + * @param ignite Ignite. + * @param cacheFilter cacheFilter. + */ + private void corruptingAndCheckDefaultCache(IgniteEx ignite, String cacheFilter) throws IOException { + injectTestSystemOut(); + + GridCacheContext cacheCtx = ignite.cachex(DEFAULT_CACHE_NAME).context(); + + corruptDataEntry(cacheCtx, 0, true, false); + + corruptDataEntry(cacheCtx, cacheCtx.config().getAffinity().partitions() / 2, false, true); + + assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump", "--cache-filter", cacheFilter)); + + Matcher fileNameMatcher = dumpFileNameMatcher(); + + if (fileNameMatcher.find()) { + String dumpWithConflicts = new String(Files.readAllBytes(Paths.get(fileNameMatcher.group(1)))); + + assertTrue(dumpWithConflicts.contains("found 2 conflict partitions: [counterConflicts=1, hashConflicts=1]")); + } + else + fail("Should be found dump with conflicts"); + } + + /** + * Tests that idle verify print partitions info when node failing. + * + * @throws Exception If failed. + */ + @Test + public void testCacheIdleVerifyDumpWhenNodeFailing() throws Exception { + Ignite ignite = startGrids(3); + + Ignite unstable = startGrid("unstable"); + + ignite.cluster().active(true); + + createCacheAndPreload(ignite, 100); + + for (int i = 0; i < 3; i++) { + TestRecordingCommunicationSpi.spi(unstable).blockMessages(GridJobExecuteResponse.class, + getTestIgniteInstanceName(i)); + } + + injectTestSystemOut(); + + IgniteInternalFuture fut = GridTestUtils.runAsync(() -> { + assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump")); + }); + + TestRecordingCommunicationSpi.spi(unstable).waitForBlocked(); + + UUID unstableNodeId = unstable.cluster().localNode().id(); + + unstable.close(); + + fut.get(); + + checkExceptionMessageOnReport(unstableNodeId); + } + + /** + * Tests that idle verify print partitions info when several nodes failing at same time. + * + * @throws Exception If failed. + */ + @Test + public void testCacheIdleVerifyDumpWhenSeveralNodesFailing() throws Exception { + int nodes = 6; + + Ignite ignite = startGrids(nodes); + + List unstableNodes = new ArrayList<>(nodes / 2); + + for (int i = 0; i < nodes; i++) { + if (i % 2 == 1) + unstableNodes.add(ignite(i)); + } + + ignite.cluster().active(true); + + createCacheAndPreload(ignite, 100); + + for (Ignite unstable : unstableNodes) { + for (int i = 0; i < nodes; i++) { + TestRecordingCommunicationSpi.spi(unstable).blockMessages(GridJobExecuteResponse.class, + getTestIgniteInstanceName(i)); + } + } + + injectTestSystemOut(); + + IgniteInternalFuture fut = GridTestUtils.runAsync( + () -> assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump")) + ); + + List unstableNodeIds = new ArrayList<>(nodes / 2); + + for (Ignite unstable : unstableNodes) { + TestRecordingCommunicationSpi.spi(unstable).waitForBlocked(); + + unstableNodeIds.add(unstable.cluster().localNode().id()); + + unstable.close(); + } + + fut.get(); + + for (UUID unstableId : unstableNodeIds) + checkExceptionMessageOnReport(unstableId); + } + + /** + * Creates default cache and preload some data entries. + * + * @param ignite Ignite. + * @param countEntries Count of entries. + */ + private void createCacheAndPreload(Ignite ignite, int countEntries) { + ignite.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME) + .setAffinity(new RendezvousAffinityFunction(false, 32)) + .setBackups(1)); + + try (IgniteDataStreamer streamer = ignite.dataStreamer(DEFAULT_CACHE_NAME)) { + for (int i = 0; i < countEntries; i++) + streamer.addData(i, i); + } + } + + /** + * Try to finds node failed exception message on output report. + * + * @param unstableNodeId Unstable node id. + */ + private void checkExceptionMessageOnReport(UUID unstableNodeId) throws IOException { + Matcher fileNameMatcher = dumpFileNameMatcher(); + + if (fileNameMatcher.find()) { + String dumpWithConflicts = new String(Files.readAllBytes(Paths.get(fileNameMatcher.group(1)))); + + assertTrue(dumpWithConflicts.contains("Idle verify failed on nodes:")); + + assertTrue(dumpWithConflicts.contains("Node ID: " + unstableNodeId + "\n" + + "Exception message:\n" + + "Node has left grid: " + unstableNodeId)); + } + else + fail("Should be found dump with conflicts"); + } + + /** + * Tests that idle verify print partitions info over system caches. + * + * @throws Exception If failed. + */ + @Test + public void testCacheIdleVerifyDumpForCorruptedDataOnSystemCache() throws Exception { int parts = 32; - IgniteCache cache = ignite.createCache(new CacheConfiguration<>() + atomicConfiguration = new AtomicConfiguration() .setAffinity(new RendezvousAffinityFunction(false, parts)) - .setBackups(1) - .setName(DEFAULT_CACHE_NAME)); + .setBackups(2); + + IgniteEx ignite = (IgniteEx)startGrids(3); + + ignite.cluster().active(true); injectTestSystemOut(); + // Adding some assignments without deployments. + for (int i = 0; i < 100; i++) { + ignite.semaphore("s" + i, i, false, true); + + ignite.atomicSequence("sq" + i, 0, true) + .incrementAndGet(); + } + + CacheGroupContext storedSysCacheCtx = ignite.context().cache().cacheGroup(CU.cacheId("default-ds-group")); + + assertNotNull(storedSysCacheCtx); + + corruptDataEntry(storedSysCacheCtx.caches().get(0), new GridCacheInternalKeyImpl("sq0", + "default-ds-group"), true, false); + + corruptDataEntry(storedSysCacheCtx.caches().get(0), new GridCacheInternalKeyImpl("sq" + parts / 2, + "default-ds-group"), false, true); + + CacheGroupContext memorySysCacheCtx = ignite.context().cache().cacheGroup(CU.cacheId("default-volatile-ds-group")); + + assertNotNull(memorySysCacheCtx); + + corruptDataEntry(memorySysCacheCtx.caches().get(0), new GridCacheInternalKeyImpl("s0", + "default-volatile-ds-group"), true, false); + + corruptDataEntry(memorySysCacheCtx.caches().get(0), new GridCacheInternalKeyImpl("s" + parts / 2, + "default-volatile-ds-group"), false, true); + + assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump", "--cache-filter", "SYSTEM")); + + Matcher fileNameMatcher = dumpFileNameMatcher(); + + if (fileNameMatcher.find()) { + String dumpWithConflicts = new String(Files.readAllBytes(Paths.get(fileNameMatcher.group(1)))); + + assertTrue(dumpWithConflicts.contains("found 4 conflict partitions: [counterConflicts=2, " + + "hashConflicts=2]")); + } + else + fail("Should be found dump with conflicts"); + } + + /** + * Tests that idle verify print partitions info over persistence client caches. + * + * @throws Exception If failed. + */ + @Test + public void testCacheIdleVerifyDumpForCorruptedDataOnPersistenceClientCache() throws Exception { + IgniteEx ignite = (IgniteEx)startGrids(3); + + ignite.cluster().active(true); + + createCacheAndPreload(ignite, 100); + + corruptingAndCheckDefaultCache(ignite, "PERSISTENT"); + } + + /** + * Tests that idle verify print partitions info over none-persistence client caches. + * + * @throws Exception If failed. + */ + @Test + public void testCacheIdleVerifyDumpForCorruptedDataOnNonePersistenceClientCache() throws Exception { + int parts = 32; + + dataRegionConfiguration = new DataRegionConfiguration() + .setName("none-persistence-region"); + + IgniteEx ignite = (IgniteEx)startGrids(3); + + ignite.cluster().active(true); + + IgniteCache cache = ignite.createCache(new CacheConfiguration<>() + .setAffinity(new RendezvousAffinityFunction(false, parts)) + .setBackups(2) + .setName(DEFAULT_CACHE_NAME) + .setDataRegionName("none-persistence-region")); + + // Adding some assignments without deployments. for (int i = 0; i < 100; i++) cache.put(i, i); + injectTestSystemOut(); + GridCacheContext cacheCtx = ignite.cachex(DEFAULT_CACHE_NAME).context(); corruptDataEntry(cacheCtx, 0, true, false); - corruptDataEntry(cacheCtx, 0 + parts / 2, false, true); + corruptDataEntry(cacheCtx, parts / 2, false, true); - assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump")); + assertEquals( + EXIT_CODE_OK, + execute("--cache", "idle_verify", "--dump", "--cache-filter", "NOT_PERSISTENT") + ); Matcher fileNameMatcher = dumpFileNameMatcher(); if (fileNameMatcher.find()) { String dumpWithConflicts = new String(Files.readAllBytes(Paths.get(fileNameMatcher.group(1)))); - assertTrue(dumpWithConflicts.contains("found 2 conflict partitions: [counterConflicts=1, hashConflicts=1]")); + assertTrue(dumpWithConflicts.contains("found 1 conflict partitions: [counterConflicts=0, " + + "hashConflicts=1]")); + } + else + fail("Should be found dump with conflicts"); + } + + /** + * Tests that idle verify print partitions info with exclude cache group. + * + * @throws Exception If failed. + */ + @Test + public void testCacheIdleVerifyDumpExcludedCacheGrp() throws Exception { + IgniteEx ignite = (IgniteEx)startGrids(3); + + ignite.cluster().active(true); + + int parts = 32; + + IgniteCache cache = ignite.createCache(new CacheConfiguration<>() + .setAffinity(new RendezvousAffinityFunction(false, parts)) + .setGroupName("shared_grp") + .setBackups(1) + .setName(DEFAULT_CACHE_NAME)); + + IgniteCache secondCache = ignite.createCache(new CacheConfiguration<>() + .setAffinity(new RendezvousAffinityFunction(false, parts)) + .setGroupName("shared_grp") + .setBackups(1) + .setName(DEFAULT_CACHE_NAME + "_second")); + + injectTestSystemOut(); + + assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump", "--excludeCaches", "shared_grp")); + + Matcher fileNameMatcher = dumpFileNameMatcher(); + + if (fileNameMatcher.find()) { + String dumpWithConflicts = new String(Files.readAllBytes(Paths.get(fileNameMatcher.group(1)))); + + assertTrue(dumpWithConflicts.contains("idle_verify check has finished, found 0 partitions")); + } + else + fail("Should be found dump with conflicts"); + } + + /** + * Tests that idle verify print partitions info with exclude caches. + * + * @throws Exception If failed. + */ + @Test + public void testCacheIdleVerifyDumpExcludedCaches() throws Exception { + IgniteEx ignite = (IgniteEx)startGrids(3); + + ignite.cluster().active(true); + + int parts = 32; + + ignite.createCache(new CacheConfiguration<>() + .setAffinity(new RendezvousAffinityFunction(false, parts)) + .setGroupName("shared_grp") + .setBackups(1) + .setName(DEFAULT_CACHE_NAME)); + + ignite.createCache(new CacheConfiguration<>() + .setAffinity(new RendezvousAffinityFunction(false, parts)) + .setGroupName("shared_grp") + .setBackups(1) + .setName(DEFAULT_CACHE_NAME + "_second")); + + ignite.createCache(new CacheConfiguration<>() + .setAffinity(new RendezvousAffinityFunction(false, parts)) + .setBackups(1) + .setName(DEFAULT_CACHE_NAME + "_third")); + + injectTestSystemOut(); + + assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump", "--excludeCaches", DEFAULT_CACHE_NAME + + "," + DEFAULT_CACHE_NAME + "_second")); + + Matcher fileNameMatcher = dumpFileNameMatcher(); + + if (fileNameMatcher.find()) { + String dumpWithConflicts = new String(Files.readAllBytes(Paths.get(fileNameMatcher.group(1)))); + + assertTrue(dumpWithConflicts.contains("idle_verify check has finished, found 32 partitions")); + assertTrue(dumpWithConflicts.contains("default_third")); + assertTrue(!dumpWithConflicts.contains("shared_grp")); } else fail("Should be found dump with conflicts"); @@ -1076,6 +1453,7 @@ public void testCacheIdleVerifyDumpForCorruptedData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheIdleVerifyMovingParts() throws Exception { IgniteEx ignite = (IgniteEx)startGrids(2); @@ -1110,6 +1488,7 @@ public void testCacheIdleVerifyMovingParts() throws Exception { /** * */ + @Test public void testCacheContention() throws Exception { int cnt = 10; @@ -1183,6 +1562,7 @@ public void testCacheContention() throws Exception { /** * */ + @Test public void testCacheSequence() throws Exception { Ignite ignite = startGrid(); @@ -1207,6 +1587,7 @@ public void testCacheSequence() throws Exception { /** * */ + @Test public void testCacheGroups() throws Exception { Ignite ignite = startGrid(); @@ -1231,6 +1612,7 @@ public void testCacheGroups() throws Exception { /** * */ + @Test public void testCacheAffinity() throws Exception { Ignite ignite = startGrid(); @@ -1254,21 +1636,125 @@ public void testCacheAffinity() throws Exception { assertTrue(testOut.toString().contains("affCls=RendezvousAffinityFunction")); } + /** */ + @Test + public void testCacheConfigNoOutputFormat() throws Exception { + testCacheConfig(null, 1, 1); + } + + /** */ + @Test + public void testCacheConfigSingleLineOutputFormatSingleNodeSignleCache() throws Exception { + testCacheConfigSingleLineOutputFormat(1, 1); + } + + /** */ + @Test + public void testCacheConfigSingleLineOutputFormatTwoNodeSignleCache() throws Exception { + testCacheConfigSingleLineOutputFormat(2, 1); + } + + /** */ + @Test + public void testCacheConfigSingleLineOutputFormatTwoNodeManyCaches() throws Exception { + testCacheConfigSingleLineOutputFormat(2, 100); + } + + /** */ + @Test + public void testCacheConfigMultiLineOutputFormatSingleNodeSingleCache() throws Exception { + testCacheConfigMultiLineOutputFormat(1, 1); + } + + /** */ + @Test + public void testCacheConfigMultiLineOutputFormatTwoNodeSingleCache() throws Exception { + testCacheConfigMultiLineOutputFormat(2, 1); + } + + /** */ + @Test + public void testCacheConfigMultiLineOutputFormatTwoNodeManyCaches() throws Exception { + testCacheConfigMultiLineOutputFormat(2, 100); + } + + /** */ + private void testCacheConfigSingleLineOutputFormat(int nodesCnt, int cachesCnt) throws Exception { + testCacheConfig("single-line", nodesCnt, cachesCnt); + } + + /** */ + private void testCacheConfigMultiLineOutputFormat(int nodesCnt, int cachesCnt) throws Exception { + testCacheConfig("multi-line", nodesCnt, cachesCnt); + } + + /** */ + private void testCacheConfig(String outputFormat, int nodesCnt, int cachesCnt) throws Exception { + assertTrue("Invalid number of nodes or caches", nodesCnt > 0 && cachesCnt > 0); + + Ignite ignite = startGrid(nodesCnt); + + ignite.cluster().active(true); + + List ccfgs = new ArrayList<>(cachesCnt); + + for (int i = 0; i < cachesCnt; i++) { + ccfgs.add( + new CacheConfiguration<>() + .setAffinity(new RendezvousAffinityFunction(false, 32)) + .setBackups(1) + .setName(DEFAULT_CACHE_NAME + i) + ); + } + + ignite.createCaches(ccfgs); + + IgniteCache cache1 = ignite.cache(DEFAULT_CACHE_NAME + 0); + + for (int i = 0; i < 100; i++) + cache1.put(i, i); + + injectTestSystemOut(); + + int exitCode; + + if (outputFormat == null) + exitCode = execute("--cache", "list", ".*", "--config"); + else + exitCode = execute("--cache", "list", ".*", "--config", "--output-format", outputFormat); + + assertEquals(EXIT_CODE_OK, exitCode); + + String outStr = testOut.toString(); + + if (outputFormat == null || SINGLE_LINE.text().equals(outputFormat)) { + for (int i = 0; i < cachesCnt; i++) + assertTrue(outStr.contains("name=" + DEFAULT_CACHE_NAME + i)); + + assertTrue(outStr.contains("partitions=32")); + assertTrue(outStr.contains("function=o.a.i.cache.affinity.rendezvous.RendezvousAffinityFunction")); + } + else if (MULTI_LINE.text().equals(outputFormat)) { + for (int i = 0; i < cachesCnt; i++) + assertTrue(outStr.contains("[cache = '" + DEFAULT_CACHE_NAME + i + "']")); + + assertTrue(outStr.contains("Affinity Partitions: 32")); + assertTrue(outStr.contains("Affinity Function: o.a.i.cache.affinity.rendezvous.RendezvousAffinityFunction")); + } + else + fail("Unknown output format: " + outputFormat); + } + /** * */ + @Test public void testCacheDistribution() throws Exception { Ignite ignite = startGrids(2); ignite.cluster().active(true); - IgniteCache cache = ignite.createCache(new CacheConfiguration<>() - .setAffinity(new RendezvousAffinityFunction(false, 32)) - .setBackups(1) - .setName(DEFAULT_CACHE_NAME)); - - for (int i = 0; i < 100; i++) - cache.put(i, i); + createCacheAndPreload(ignite, 100); injectTestSystemOut(); @@ -1294,7 +1780,7 @@ public void testCacheDistribution() throws Exception { assertTrue(lastRowIndex > 0); // Last row is empty, but the previous line contains data - lastRowIndex = log.lastIndexOf('\n', lastRowIndex-1); + lastRowIndex = log.lastIndexOf('\n', lastRowIndex - 1); assertTrue(lastRowIndex > 0); @@ -1312,13 +1798,7 @@ public void testCacheResetLostPartitions() throws Exception { ignite.cluster().active(true); - IgniteCache cache = ignite.createCache(new CacheConfiguration<>() - .setAffinity(new RendezvousAffinityFunction(false, 32)) - .setBackups(1) - .setName(DEFAULT_CACHE_NAME)); - - for (int i = 0; i < 100; i++) - cache.put(i, i); + createCacheAndPreload(ignite, 100); injectTestSystemOut(); @@ -1362,6 +1842,7 @@ private Map generate(int from, int cnt) { * * @throws Exception if failed. */ + @Test public void testUnusedWalPrint() throws Exception { Ignite ignite = startGrids(2); @@ -1395,6 +1876,7 @@ public void testUnusedWalPrint() throws Exception { * * @throws Exception if failed. */ + @Test public void testUnusedWalDelete() throws Exception { Ignite ignite = startGrids(2); @@ -1514,7 +1996,7 @@ private static class IncrementClosure implements EntryProcessor ctx, - int key, + Object key, boolean breakCntr, boolean breakData ) { diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedDequeMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedDequeMultiThreadedTest.java index 99064f0a8f4d3..455b28e11fe2f 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedDequeMultiThreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedDequeMultiThreadedTest.java @@ -25,10 +25,14 @@ import org.jetbrains.annotations.Nullable; import org.jsr166.ConcurrentLinkedDeque8; import org.jsr166.ConcurrentLinkedDeque8.Node; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link org.jsr166.ConcurrentLinkedDeque8}. */ +@RunWith(JUnit4.class) public class GridConcurrentLinkedDequeMultiThreadedTest extends GridCommonAbstractTest { /** */ private static final Random RND = new Random(); @@ -36,7 +40,7 @@ public class GridConcurrentLinkedDequeMultiThreadedTest extends GridCommonAbstra /** * @throws Exception If failed. */ - @SuppressWarnings({"BusyWait"}) + @Test public void testQueueMultiThreaded() throws Exception { final AtomicBoolean done = new AtomicBoolean(); diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedDequeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedDequeSelfTest.java index f695f75f90dce..1e55beb751b68 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedDequeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedDequeSelfTest.java @@ -20,16 +20,21 @@ import java.util.Iterator; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jsr166.ConcurrentLinkedDeque8; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.jsr166.ConcurrentLinkedDeque8.Node; /** * Tests for {@link org.jsr166.ConcurrentLinkedDeque8}. */ +@RunWith(JUnit4.class) public class GridConcurrentLinkedDequeSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPoll() throws Exception { ConcurrentLinkedDeque8 deque = new ConcurrentLinkedDeque8<>(); @@ -66,6 +71,7 @@ public void testPoll() throws Exception { /** * */ + @Test public void testUnlink() { ConcurrentLinkedDeque8 deque = new ConcurrentLinkedDeque8<>(); @@ -116,6 +122,7 @@ public void testUnlink() { /** * */ + @Test public void testEmptyDeque() { ConcurrentLinkedDeque8 deque = new ConcurrentLinkedDeque8<>(); @@ -175,6 +182,7 @@ private void checkSize(ConcurrentLinkedDeque8 q, int expSize) { /** * */ + @Test public void testUnlinkWithIterator() { ConcurrentLinkedDeque8 q = new ConcurrentLinkedDeque8<>(); @@ -211,6 +219,7 @@ public void testUnlinkWithIterator() { /** * */ + @Test public void testUnlinkLastWithIterator() { ConcurrentLinkedDeque8 q = new ConcurrentLinkedDeque8<>(); @@ -230,4 +239,4 @@ public void testUnlinkLastWithIterator() { assertFalse(it.hasNext()); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedHashMapMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedHashMapMultiThreadedSelfTest.java index 9fe2690d1d1f1..0716488eddb4c 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedHashMapMultiThreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridConcurrentLinkedHashMapMultiThreadedSelfTest.java @@ -34,6 +34,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; import org.jsr166.ConcurrentLinkedHashMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.jsr166.ConcurrentLinkedHashMap.QueuePolicy.PER_SEGMENT_Q; import static org.jsr166.ConcurrentLinkedHashMap.QueuePolicy.PER_SEGMENT_Q_OPTIMIZED_RMV; @@ -42,10 +45,12 @@ /** * */ +@RunWith(JUnit4.class) public class GridConcurrentLinkedHashMapMultiThreadedSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { info(">>> Test grid concurrent linked hash map..."); @@ -64,6 +69,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutPerSegment() throws Exception { info(">>> Test grid concurrent linked hash map..."); @@ -81,6 +87,7 @@ public void testPutPerSegment() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvict() throws Exception { info(">>> Test grid concurrent linked hash map..."); @@ -143,6 +150,7 @@ public void testEvict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvictPerSegment() throws Exception { info(">>> Test grid concurrent linked hash map..."); @@ -205,6 +213,7 @@ public void testEvictPerSegment() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvictPerSegmentOptimizedRemoves() throws Exception { info(">>> Test grid concurrent linked hash map..."); @@ -323,6 +332,7 @@ private Map> putMultiThreaded(final ConcurrentMap>> Test grid concurrent linked hash map iterator..."); diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridIntListSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridIntListSelfTest.java index cc48fa8610942..16daa9a7f4665 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridIntListSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridIntListSelfTest.java @@ -17,19 +17,23 @@ package org.apache.ignite.util; -import junit.framework.TestCase; import org.apache.ignite.internal.util.GridIntList; +import org.junit.Test; import static org.apache.ignite.internal.util.GridIntList.asList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * */ -public class GridIntListSelfTest extends TestCase { +public class GridIntListSelfTest { /** * @throws Exception If failed. */ @SuppressWarnings("ZeroLengthArrayAllocation") + @Test public void testCopyWithout() throws Exception { assertCopy( new GridIntList(new int[] {}), @@ -67,6 +71,7 @@ public void testCopyWithout() throws Exception { /** * */ + @Test public void testTruncate() { GridIntList list = asList(1, 2, 3, 4, 5, 6, 7, 8); @@ -108,6 +113,7 @@ private void assertCopy(GridIntList lst, GridIntList rmv) { /** * */ + @Test public void testRemove() { GridIntList list = asList(1, 2, 3, 4, 5, 6); @@ -130,6 +136,7 @@ public void testRemove() { /** * */ + @Test public void testSort() { assertEquals(new GridIntList(), new GridIntList().sort()); assertEquals(asList(1), asList(1).sort()); diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridInternalTaskUnusedWalSegmentsTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridInternalTaskUnusedWalSegmentsTest.java index a39b0c26fa723..f41057241b636 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridInternalTaskUnusedWalSegmentsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridInternalTaskUnusedWalSegmentsTest.java @@ -30,9 +30,6 @@ import org.apache.ignite.internal.visor.misc.VisorWalTaskArg; import org.apache.ignite.internal.visor.misc.VisorWalTaskOperation; import org.apache.ignite.internal.visor.misc.VisorWalTaskResult; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.io.File; @@ -40,24 +37,23 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE; /** * Test correctness of VisorWalTask. */ +@RunWith(JUnit4.class) public class GridInternalTaskUnusedWalSegmentsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { System.setProperty(IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, "2"); IgniteConfiguration cfg = super.getConfiguration(gridName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setAffinity(new RendezvousAffinityFunction(false, 32)); @@ -96,6 +92,7 @@ public class GridInternalTaskUnusedWalSegmentsTest extends GridCommonAbstractTes * * @throws Exception if failed. */ + @Test public void testCorrectnessOfDeletionTaskSegments() throws Exception { try { IgniteEx ig0 = (IgniteEx)startGrids(4); diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridLogThrottleTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridLogThrottleTest.java index 37fa558a65add..5b7a2a443033d 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridLogThrottleTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridLogThrottleTest.java @@ -21,6 +21,9 @@ import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid log throttle test. To verify correctness, you need to run this test @@ -28,6 +31,7 @@ * all messages that should be omitted are indeed omitted. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class GridLogThrottleTest extends GridCommonAbstractTest { /** */ private final GridStringLogger log0 = new GridStringLogger(false, this.log); @@ -42,6 +46,7 @@ public GridLogThrottleTest() { * * @throws Exception If any error occurs. */ + @Test public void testThrottle() throws Exception { LT.throttleTimeout(1000); diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridLongListSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridLongListSelfTest.java index 3b62e32f01f06..bf69de7823d18 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridLongListSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridLongListSelfTest.java @@ -17,19 +17,24 @@ package org.apache.ignite.util; -import junit.framework.TestCase; import org.apache.ignite.internal.util.GridLongList; +import org.junit.Test; import static org.apache.ignite.internal.util.GridLongList.asList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * */ -public class GridLongListSelfTest extends TestCase { +public class GridLongListSelfTest { /** * @throws Exception If failed. */ @SuppressWarnings("ZeroLengthArrayAllocation") + @Test public void testCopyWithout() throws Exception { assertCopy( new GridLongList(new long[] {}), @@ -67,6 +72,7 @@ public void testCopyWithout() throws Exception { /** * */ + @Test public void testTruncate() { GridLongList list = asList(1, 2, 3, 4, 5, 6, 7, 8); @@ -108,6 +114,7 @@ private void assertCopy(GridLongList lst, GridLongList rmv) { /** * */ + @Test public void testRemove() { GridLongList list = asList(1,2,3,4,5,6); @@ -130,6 +137,7 @@ public void testRemove() { /** * */ + @Test public void testSort() { assertEquals(new GridLongList(), new GridLongList().sort()); assertEquals(asList(1), asList(1).sort()); @@ -150,4 +158,28 @@ public void testSort() { assertEquals(asList(1, 3, 4, 5, 0), list); assertEquals(asList(0, 1, 3, 4, 5), list.sort()); } -} \ No newline at end of file + + /** + * + */ + @Test + public void testArray() { + GridLongList list = new GridLongList(); + + long[] array = list.array(); + + assertNotNull(array); + + assertEquals(0, array.length); + + list.add(1L); + + array = list.array(); + + assertNotNull(array); + + assertEquals(1, array.length); + + assertEquals(1L, array[0]); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridMessageCollectionTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridMessageCollectionTest.java index 13538817ee797..ce048393e97d4 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridMessageCollectionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridMessageCollectionTest.java @@ -18,7 +18,6 @@ package org.apache.ignite.util; import java.nio.ByteBuffer; -import junit.framework.TestCase; import org.apache.ignite.internal.direct.DirectMessageReader; import org.apache.ignite.internal.direct.DirectMessageWriter; import org.apache.ignite.internal.managers.communication.GridIoMessageFactory; @@ -27,14 +26,17 @@ import org.apache.ignite.plugin.extensions.communication.MessageFactory; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; +import org.junit.Test; import static java.util.UUID.randomUUID; import static org.apache.ignite.internal.util.GridMessageCollection.of; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; /** * */ -public class GridMessageCollectionTest extends TestCase { +public class GridMessageCollectionTest { /** */ private byte proto; @@ -58,6 +60,7 @@ protected MessageReader reader(MessageFactory msgFactory, byte proto) { /** * */ + @Test public void testMarshal() { UUIDCollectionMessage um0 = UUIDCollectionMessage.of(); UUIDCollectionMessage um1 = UUIDCollectionMessage.of(randomUUID()); diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridPartitionMapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridPartitionMapSelfTest.java index 9068e829072c3..1e98de94908cd 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridPartitionMapSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridPartitionMapSelfTest.java @@ -28,13 +28,18 @@ import org.apache.ignite.internal.util.GridPartitionStateMap; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid utils tests. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class GridPartitionMapSelfTest extends GridCommonAbstractTest { /** */ + @Test public void testPartitionStateMap() { GridPartitionStateMap map = initMap(new GridPartitionStateMap()); @@ -92,6 +97,7 @@ public void testPartitionStateMap() { } /** */ + @Test public void testEqualsAndHashCode() { GridPartitionStateMap map1 = initMap(new GridPartitionStateMap()); @@ -109,6 +115,7 @@ public void testEqualsAndHashCode() { /** * */ + @Test public void testCopy() { GridPartitionStateMap map1 = initMap(new GridPartitionStateMap()); @@ -134,6 +141,7 @@ public void testCopy() { /** * */ + @Test public void testCopyNoActive() { GridPartitionStateMap map2 = new GridPartitionStateMap(); @@ -150,6 +158,7 @@ public void testCopyNoActive() { /** * Tests that entries from {@link Iterator#next()} remain unaltered. */ + @Test public void testIteratorNext() { GridPartitionStateMap map = new GridPartitionStateMap(); @@ -182,6 +191,7 @@ public void testIteratorNext() { /** * Tests {@link GridDhtPartitionState} compatibility with {@link TreeMap} on random operations. */ + @Test public void testOnRandomOperations() { ThreadLocalRandom rnd = ThreadLocalRandom.current(); diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridQueueSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridQueueSelfTest.java index 6a323776393e1..c4ac47eba7333 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridQueueSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridQueueSelfTest.java @@ -21,15 +21,20 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid utils tests. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class GridQueueSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testQueue() { GridQueue q = new GridQueue<>(); for (char c = 'a'; c <= 'z'; c++) @@ -69,4 +74,4 @@ public void testQueue() { assert q.isEmpty(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java index 005da6cf7bdce..3a06a8b00b7b8 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridRandomSelfTest.java @@ -21,13 +21,18 @@ import java.util.concurrent.ThreadLocalRandom; import org.apache.ignite.internal.util.GridRandom; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link GridRandom}. */ +@RunWith(JUnit4.class) public class GridRandomSelfTest extends GridCommonAbstractTest { /** */ + @Test public void testRandom() { for (int i = 0; i < 100; i++) { long seed = ThreadLocalRandom.current().nextLong(); diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridSnapshotLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridSnapshotLockSelfTest.java index 97fa060aca4f3..7b092d2eb7e9f 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridSnapshotLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridSnapshotLockSelfTest.java @@ -26,14 +26,19 @@ import org.apache.ignite.internal.util.GridSnapshotLock; import org.apache.ignite.internal.util.typedef.T3; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridSnapshotLockSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSyncConsistent() throws Exception { final AtomicBoolean stop = new AtomicBoolean(); @@ -110,4 +115,4 @@ public void testSyncConsistent() throws Exception { fut1.get(); fut2.get(); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridSpinReadWriteLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridSpinReadWriteLockSelfTest.java index a1040401f8764..e711f478b73d9 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridSpinReadWriteLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridSpinReadWriteLockSelfTest.java @@ -23,10 +23,14 @@ import org.apache.ignite.internal.util.GridSpinReadWriteLock; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridSpinReadWriteLockSelfTest extends GridCommonAbstractTest { /** Constructor. */ public GridSpinReadWriteLockSelfTest() { @@ -36,6 +40,7 @@ public GridSpinReadWriteLockSelfTest() { /** * @throws Exception If any error occurs. */ + @Test public void testWriteLockReentry() throws Exception { GridSpinReadWriteLock lock = new GridSpinReadWriteLock(); @@ -51,6 +56,7 @@ public void testWriteLockReentry() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testReadLockReentry() throws Exception { final GridSpinReadWriteLock lock = new GridSpinReadWriteLock(); @@ -93,6 +99,7 @@ public void testReadLockReentry() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testLockDowngrade() throws Exception { GridSpinReadWriteLock lock = new GridSpinReadWriteLock(); @@ -124,6 +131,7 @@ public void testLockDowngrade() throws Exception { /** * @throws Exception If any error occurs. */ + @Test public void testMonitorState() throws Exception { GridSpinReadWriteLock lock = new GridSpinReadWriteLock(); @@ -141,4 +149,4 @@ public void testMonitorState() throws Exception { info("Caught expected exception: " + e); } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridStringBuilderFactorySelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridStringBuilderFactorySelfTest.java index e3639cad7907b..3bce1c1f9af3e 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridStringBuilderFactorySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridStringBuilderFactorySelfTest.java @@ -21,11 +21,15 @@ import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * String builder factory test. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class GridStringBuilderFactorySelfTest extends GridCommonAbstractTest { /** */ public GridStringBuilderFactorySelfTest() { @@ -35,6 +39,7 @@ public GridStringBuilderFactorySelfTest() { /** * Tests string builder factory. */ + @Test public void testStringBuilderFactory() { SB b1 = GridStringBuilderFactory.acquire(); @@ -70,4 +75,4 @@ public void testStringBuilderFactory() { assert b3.length() == 0; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridTopologyHeapSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridTopologyHeapSizeSelfTest.java index c8e4619e6dc40..a83bf3359354b 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridTopologyHeapSizeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridTopologyHeapSizeSelfTest.java @@ -19,15 +19,14 @@ import java.util.UUID; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.ClusterMetricsSnapshot; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestNode; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_JVM_PID; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS; @@ -35,26 +34,12 @@ /** * Tests for calculation logic for topology heap size. */ +@RunWith(JUnit4.class) public class GridTopologyHeapSizeSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - /** * @throws Exception If failed. */ + @Test public void testTopologyHeapSizeInOneJvm() throws Exception { try { ClusterNode node1 = startGrid(1).cluster().node(); @@ -72,6 +57,7 @@ public void testTopologyHeapSizeInOneJvm() throws Exception { } /** */ + @Test public void testTopologyHeapSizeForNodesWithDifferentPids() { GridTestNode node1 = getNode("123456789ABC", 1000); GridTestNode node2 = getNode("123456789ABC", 1001); @@ -85,6 +71,7 @@ public void testTopologyHeapSizeForNodesWithDifferentPids() { } /** */ + @Test public void testTopologyHeapSizeForNodesWithDifferentMacs() { GridTestNode node1 = getNode("123456789ABC", 1000); GridTestNode node2 = getNode("CBA987654321", 1000); @@ -117,4 +104,4 @@ private GridTestNode getNode(String mac, int pid) { return node; } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridTransientTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridTransientTest.java index 9614d20a7680e..95f8dacf72dd4 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/GridTransientTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/GridTransientTest.java @@ -24,11 +24,15 @@ import java.io.Serializable; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Transient value serialization test. */ @GridCommonTest(group = "Utils") +@RunWith(JUnit4.class) public class GridTransientTest extends GridCommonAbstractTest implements Serializable { /** */ private static final String VALUE = "value"; @@ -49,6 +53,7 @@ public GridTransientTest() { /** * @throws Exception If failed. */ + @Test public void testTransientSerialization() throws Exception { GridTransientTest objSrc = new GridTransientTest(); @@ -70,4 +75,4 @@ public void testTransientSerialization() throws Exception { assertEquals(objDest.data1, null); assertEquals(objDest.data2, VALUE); } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanBaselineTest.java b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanBaselineTest.java index 31c012c8b2a49..61edffcac12ad 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanBaselineTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanBaselineTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.Set; import java.util.stream.Collectors; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class GridMBeanBaselineTest extends GridCommonAbstractTest { /** Client index. */ private static final int CLIENT_IDX = 33; @@ -71,6 +75,7 @@ public class GridMBeanBaselineTest extends GridCommonAbstractTest { * * @throws Exception Thrown if test fails. */ + @Test public void testIgniteKernalNodeInBaselineTest() throws Exception { try { IgniteEx ignite0 = (IgniteEx)startGrids(NODES); diff --git a/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanDisableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanDisableSelfTest.java index b98cd46c369fe..6758fdaf7a709 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanDisableSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanDisableSelfTest.java @@ -27,20 +27,24 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Disabling MBeans test. */ +@RunWith(JUnit4.class) public class GridMBeanDisableSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ - @Override protected void setUp() throws Exception { + @Override public void setUp() throws Exception { IgniteUtils.IGNITE_MBEANS_DISABLED = true; super.setUp(); } /** {@inheritDoc} */ - @Override protected void tearDown() throws Exception { + @Override public void tearDown() throws Exception { IgniteUtils.IGNITE_MBEANS_DISABLED = false; super.tearDown(); @@ -51,6 +55,7 @@ public class GridMBeanDisableSelfTest extends GridCommonAbstractTest { * * @throws Exception Thrown if test fails. */ + @Test public void testCorrectMBeanInfo() throws Exception { // Node should start and stopped with no errors. try (final Ignite ignite = startGrid(0)) { @@ -84,6 +89,7 @@ public void testCorrectMBeanInfo() throws Exception { } /** Check that a cache can be started when MBeans are disabled. */ + @Test public void testCacheStart() throws Exception { try ( Ignite ignite = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanExoticNamesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanExoticNamesSelfTest.java index 3b79f24b1a2b0..d50bf6bf1456e 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanExoticNamesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanExoticNamesSelfTest.java @@ -22,17 +22,23 @@ import org.apache.ignite.Ignite; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Testing registration of MBeans with special characters in group name or bean name. */ +@RunWith(JUnit4.class) public class GridMBeanExoticNamesSelfTest extends GridCommonAbstractTest { /** Test registration of a bean with special characters in group name. */ + @Test public void testGroupWithSpecialSymbols() throws Exception { checkMBeanRegistration("dummy!@#$^&*()?\\grp", "dummy"); } /** Test registration of a bean with special characters in name. */ + @Test public void testNameWithSpecialSymbols() throws Exception { checkMBeanRegistration("dummygrp", "dum!@#$^&*()?\\my"); } @@ -67,4 +73,4 @@ private static class DummyMBeanImpl implements DummyMBean { // No op. } } -} \ No newline at end of file +} diff --git a/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanSelfTest.java b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanSelfTest.java index 4e329f9fc9437..8ee1e59760390 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanSelfTest.java @@ -29,16 +29,21 @@ import org.apache.ignite.mxbean.MXBeanParametersDescriptions; import org.apache.ignite.mxbean.MXBeanParametersNames; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * MBean test. */ +@RunWith(JUnit4.class) public class GridMBeanSelfTest extends GridCommonAbstractTest { /** * Tests correct MBean interface. * * @throws Exception Thrown if test fails. */ + @Test public void testCorrectMBeanInfo() throws Exception { StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterface.class); @@ -85,6 +90,7 @@ public void testCorrectMBeanInfo() throws Exception { * * @throws Exception Thrown if test fails. */ + @Test public void testMissedNameMBeanInfo() throws Exception { try { StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterfaceBad.class); @@ -103,6 +109,7 @@ public void testMissedNameMBeanInfo() throws Exception { * * @throws Exception Thrown if test fails. */ + @Test public void testMissedDescriptionMBeanInfo() throws Exception { try { StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), @@ -122,6 +129,7 @@ public void testMissedDescriptionMBeanInfo() throws Exception { * * @throws Exception Thrown if test fails. */ + @Test public void testEmptyDescriptionMBeanInfo() throws Exception { try { StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), @@ -141,6 +149,7 @@ public void testEmptyDescriptionMBeanInfo() throws Exception { * * @throws Exception Thrown if test fails. */ + @Test public void testEmptyNameMBeanInfo() throws Exception { try { StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), @@ -160,6 +169,7 @@ public void testEmptyNameMBeanInfo() throws Exception { * * @throws Exception Thrown if test fails. */ + @Test public void testIgniteKernalReturnsValidMBeanInfo() throws Exception { try { IgniteEx igniteCrd = startGrid(0); diff --git a/modules/core/src/test/java/org/apache/ignite/util/mbeans/WorkersControlMXBeanTest.java b/modules/core/src/test/java/org/apache/ignite/util/mbeans/WorkersControlMXBeanTest.java index cb30906371f81..1062267b76e90 100644 --- a/modules/core/src/test/java/org/apache/ignite/util/mbeans/WorkersControlMXBeanTest.java +++ b/modules/core/src/test/java/org/apache/ignite/util/mbeans/WorkersControlMXBeanTest.java @@ -1,98 +1,104 @@ -/* - * 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. - */ - -package org.apache.ignite.util.mbeans; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import org.apache.ignite.internal.worker.WorkersControlMXBeanImpl; -import org.apache.ignite.mxbean.WorkersControlMXBean; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * {@link WorkersControlMXBean} test. - */ -public class WorkersControlMXBeanTest extends GridCommonAbstractTest { - /** Test thread name. */ - private static final String TEST_THREAD_NAME = "test-thread"; - - /** - * @throws Exception Thrown if test fails. - */ - public void testStopThreadByUniqueName() throws Exception { - WorkersControlMXBean workersCtrlMXBean = new WorkersControlMXBeanImpl(null); - - Thread t = startTestThread(); - - assertTrue(workersCtrlMXBean.stopThreadByUniqueName(TEST_THREAD_NAME)); - - t.join(500); - - assertFalse(workersCtrlMXBean.stopThreadByUniqueName(TEST_THREAD_NAME)); - - Thread t1 = startTestThread(); - Thread t2 = startTestThread(); - - assertFalse(workersCtrlMXBean.stopThreadByUniqueName(TEST_THREAD_NAME)); - - t1.stop(); - t2.stop(); - } - - /** - * @throws Exception Thrown if test fails. - */ - public void testStopThreadById() throws Exception { - WorkersControlMXBean workersCtrlMXBean = new WorkersControlMXBeanImpl(null); - - Thread t1 = startTestThread(); - Thread t2 = startTestThread(); - - assertTrue(workersCtrlMXBean.stopThreadById(t1.getId())); - assertTrue(workersCtrlMXBean.stopThreadById(t2.getId())); - - t1.join(500); - t2.join(500); - - assertFalse(workersCtrlMXBean.stopThreadById(t1.getId())); - assertFalse(workersCtrlMXBean.stopThreadById(t2.getId())); - } - - /** - * @return Started thread. - */ - private static Thread startTestThread() throws InterruptedException { - final CountDownLatch latch = new CountDownLatch(1); - - Thread t = new Thread(TEST_THREAD_NAME) { - @Override public void run() { - latch.countDown(); - - for (;;) - ; - } - }; - - t.start(); - - assertTrue(latch.await(500, TimeUnit.MILLISECONDS)); - - assertTrue(t.isAlive()); - - return t; - } -} +/* + * 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. + */ + +package org.apache.ignite.util.mbeans; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.apache.ignite.internal.worker.WorkersControlMXBeanImpl; +import org.apache.ignite.mxbean.WorkersControlMXBean; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * {@link WorkersControlMXBean} test. + */ +@RunWith(JUnit4.class) +public class WorkersControlMXBeanTest extends GridCommonAbstractTest { + /** Test thread name. */ + private static final String TEST_THREAD_NAME = "test-thread"; + + /** + * @throws Exception Thrown if test fails. + */ + @Test + public void testStopThreadByUniqueName() throws Exception { + WorkersControlMXBean workersCtrlMXBean = new WorkersControlMXBeanImpl(null); + + Thread t = startTestThread(); + + assertTrue(workersCtrlMXBean.stopThreadByUniqueName(TEST_THREAD_NAME)); + + t.join(500); + + assertFalse(workersCtrlMXBean.stopThreadByUniqueName(TEST_THREAD_NAME)); + + Thread t1 = startTestThread(); + Thread t2 = startTestThread(); + + assertFalse(workersCtrlMXBean.stopThreadByUniqueName(TEST_THREAD_NAME)); + + t1.stop(); + t2.stop(); + } + + /** + * @throws Exception Thrown if test fails. + */ + @Test + public void testStopThreadById() throws Exception { + WorkersControlMXBean workersCtrlMXBean = new WorkersControlMXBeanImpl(null); + + Thread t1 = startTestThread(); + Thread t2 = startTestThread(); + + assertTrue(workersCtrlMXBean.stopThreadById(t1.getId())); + assertTrue(workersCtrlMXBean.stopThreadById(t2.getId())); + + t1.join(500); + t2.join(500); + + assertFalse(workersCtrlMXBean.stopThreadById(t1.getId())); + assertFalse(workersCtrlMXBean.stopThreadById(t2.getId())); + } + + /** + * @return Started thread. + */ + private static Thread startTestThread() throws InterruptedException { + final CountDownLatch latch = new CountDownLatch(1); + + Thread t = new Thread(TEST_THREAD_NAME) { + @Override public void run() { + latch.countDown(); + + for (;;) + ; + } + }; + + t.start(); + + assertTrue(latch.await(500, TimeUnit.MILLISECONDS)); + + assertTrue(t.isAlive()); + + return t; + } +} diff --git a/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AlignedBuffersDirectFileIOFactory.java b/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AlignedBuffersDirectFileIOFactory.java index 8a28e9eac1c47..ea555a0c583f8 100644 --- a/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AlignedBuffersDirectFileIOFactory.java +++ b/modules/direct-io/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/AlignedBuffersDirectFileIOFactory.java @@ -144,11 +144,6 @@ public AlignedBuffersDirectFileIOFactory( return allocate; } - /** {@inheritDoc} */ - @Override public FileIO create(File file) throws IOException { - return create(file, CREATE, READ, WRITE); - } - /** {@inheritDoc} */ @Override public FileIO create(File file, OpenOption... modes) throws IOException { if (useBackupFactory) diff --git a/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest.java b/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest.java index e2578aee5ca26..f429c50652274 100644 --- a/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest.java +++ b/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest.java @@ -16,10 +16,16 @@ */ package org.apache.ignite.internal.processors.cache.persistence; +import org.apache.ignite.testframework.MvccFeatureChecker; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + /** * Version of test to be executed in Direct IO suite. * Contains reduced number of records, because Direct IO does not support tmpfs. */ +@RunWith(JUnit4.class) public class IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest extends LocalWalModeChangeDuringRebalancingSelfTest { /** {@inheritDoc} */ @Override protected int getKeysCount() { @@ -27,7 +33,11 @@ public class IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest extends L } /** {@inheritDoc} */ + @Test @Override public void testWithExchangesMerge() throws Exception { + if (MvccFeatureChecker.forcedMvcc()) + fail("https://issues.apache.org/jira/browse/IGNITE-10752"); + super.testWithExchangesMerge(); } } diff --git a/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteFileIOTest.java b/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteFileIOTest.java index 9620eb0fca683..6dac3ce560652 100644 --- a/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteFileIOTest.java +++ b/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteFileIOTest.java @@ -21,13 +21,13 @@ import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; import java.util.concurrent.ThreadLocalRandom; -import junit.framework.TestCase; import org.jetbrains.annotations.NotNull; +import org.junit.Test; /** * File IO tests. */ -public class IgniteFileIOTest extends TestCase { +public class IgniteFileIOTest { /** Test data size. */ private static final int TEST_DATA_SIZE = 16 * 1024 * 1024; @@ -171,6 +171,7 @@ private void checkPosition(long position) throws IOException { /** * test for 'full read' functionality. */ + @Test public void testReadFully() throws Exception { byte[] arr = new byte[TEST_DATA_SIZE]; @@ -206,6 +207,7 @@ public void testReadFully() throws Exception { /** * test for 'full read' functionality. */ + @Test public void testReadFullyArray() throws Exception { byte[] arr = new byte[TEST_DATA_SIZE]; @@ -227,6 +229,7 @@ public void testReadFullyArray() throws Exception { /** * test for 'full write' functionality. */ + @Test public void testWriteFully() throws Exception { byte[] arr = new byte[TEST_DATA_SIZE]; @@ -262,6 +265,7 @@ public void testWriteFully() throws Exception { /** * test for 'full write' functionality. */ + @Test public void testWriteFullyArray() throws Exception { byte[] arr = new byte[TEST_DATA_SIZE]; diff --git a/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteNativeIoWithNoPersistenceTest.java b/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteNativeIoWithNoPersistenceTest.java index 981e0d59a633b..adef4daf4442c 100644 --- a/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteNativeIoWithNoPersistenceTest.java +++ b/modules/direct-io/src/test/java/org/apache/ignite/internal/processors/cache/persistence/file/IgniteNativeIoWithNoPersistenceTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks if Direct IO can be set up if no persistent store is configured */ +@RunWith(JUnit4.class) public class IgniteNativeIoWithNoPersistenceTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @@ -52,6 +56,7 @@ public class IgniteNativeIoWithNoPersistenceTest extends GridCommonAbstractTest * Checks simple launch with native IO. * @throws Exception if failed */ + @Test public void testDirectIoHandlesNoPersistentGrid() throws Exception { IgniteEx ignite = startGrid(0); diff --git a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite.java b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite.java index 787a755c36a6f..312c976386e89 100644 --- a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite.java +++ b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite.java @@ -16,26 +16,30 @@ */ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.persistence.file.IgniteNativeIoWithNoPersistenceTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Subset of {@link IgnitePdsTestSuite} suite test, started with direct-oi jar in classpath. */ -public class IgnitePdsNativeIoTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgnitePdsNativeIoTestSuite { /** * @return Suite. */ public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Persistent Store Test Suite (with Direct IO)"); - IgnitePdsTestSuite.addRealPageStoreTests(suite); + IgnitePdsTestSuite.addRealPageStoreTests(suite, null); //long running test by design with light parameters - suite.addTestSuite(IgnitePdsReplacementNativeIoTest.class); + suite.addTest(new JUnit4TestAdapter(IgnitePdsReplacementNativeIoTest.class)); - suite.addTestSuite(IgniteNativeIoWithNoPersistenceTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteNativeIoWithNoPersistenceTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite2.java b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite2.java index 4c1305d6aae5e..1c6e88c1d514f 100644 --- a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite2.java +++ b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite2.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.persistence.IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest; import org.apache.ignite.internal.processors.cache.persistence.IgniteNativeIoPdsRecoveryAfterFileCorruptionTest; @@ -29,21 +30,20 @@ public class IgnitePdsNativeIoTestSuite2 extends TestSuite { /** * @return Suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Persistent Store Test Suite 2 (Native IO)"); - IgnitePdsTestSuite2.addRealPageStoreTests(suite); + IgnitePdsTestSuite2.addRealPageStoreTests(suite, null); //Integrity test with reduced count of pages. - suite.addTestSuite(IgniteNativeIoPdsRecoveryAfterFileCorruptionTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteNativeIoPdsRecoveryAfterFileCorruptionTest.class)); - suite.addTestSuite(IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteNativeIoLocalWalModeChangeDuringRebalancingSelfTest.class)); - suite.addTestSuite(IgniteNativeIoWalFlushFsyncSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteNativeIoWalFlushFsyncSelfTest.class)); - suite.addTestSuite(FsyncWalRolloverDoesNotBlockTest.class); + suite.addTest(new JUnit4TestAdapter(FsyncWalRolloverDoesNotBlockTest.class)); return suite; } diff --git a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsReplacementNativeIoTest.java b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsReplacementNativeIoTest.java index f9bda769b2f42..1d3f91e1c9a75 100644 --- a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsReplacementNativeIoTest.java +++ b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsReplacementNativeIoTest.java @@ -18,10 +18,14 @@ import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsPageReplacementTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Page replacement light variant of test for native direct IO (wastes real IOPs on agents) */ +@RunWith(JUnit4.class) public class IgnitePdsReplacementNativeIoTest extends IgnitePdsPageReplacementTest { /** {@inheritDoc} */ @@ -36,6 +40,7 @@ public class IgnitePdsReplacementNativeIoTest extends IgnitePdsPageReplacementTe } /** {@inheritDoc} */ + @Test @Override public void testPageReplacement() throws Exception { System.setProperty(IgniteSystemProperties.IGNITE_USE_ASYNC_FILE_IO_FACTORY, "false"); diff --git a/modules/flink/src/test/java/org/apache/ignite/sink/flink/FlinkIgniteSinkSelfTest.java b/modules/flink/src/test/java/org/apache/ignite/sink/flink/FlinkIgniteSinkSelfTest.java index eb5937925caca..3c9e40856ab6b 100644 --- a/modules/flink/src/test/java/org/apache/ignite/sink/flink/FlinkIgniteSinkSelfTest.java +++ b/modules/flink/src/test/java/org/apache/ignite/sink/flink/FlinkIgniteSinkSelfTest.java @@ -23,10 +23,14 @@ import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link IgniteSink}. */ +@RunWith(JUnit4.class) public class FlinkIgniteSinkSelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String TEST_CACHE = "testCache"; @@ -34,6 +38,7 @@ public class FlinkIgniteSinkSelfTest extends GridCommonAbstractTest { /** Ignite test configuration file. */ private static final String GRID_CONF_FILE = "modules/flink/src/test/resources/example-ignite.xml"; + @Test public void testIgniteSink() throws Exception { Configuration configuration = new Configuration(); @@ -56,6 +61,7 @@ public void testIgniteSink() throws Exception { assertEquals("testValue", igniteSink.getIgnite().getOrCreateCache(TEST_CACHE).get("testData")); } + @Test public void testIgniteSinkStreamExecution() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); @@ -78,4 +84,4 @@ public void testIgniteSinkStreamExecution() throws Exception { fail("Stream execution process failed."); } } -} \ No newline at end of file +} diff --git a/modules/flink/src/test/java/org/apache/ignite/sink/flink/FlinkIgniteSinkSelfTestSuite.java b/modules/flink/src/test/java/org/apache/ignite/sink/flink/FlinkIgniteSinkSelfTestSuite.java index b6934e256beb5..3fee82ed95133 100644 --- a/modules/flink/src/test/java/org/apache/ignite/sink/flink/FlinkIgniteSinkSelfTestSuite.java +++ b/modules/flink/src/test/java/org/apache/ignite/sink/flink/FlinkIgniteSinkSelfTestSuite.java @@ -17,21 +17,23 @@ package org.apache.ignite.sink.flink; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Apache Flink sink tests. */ -public class FlinkIgniteSinkSelfTestSuite extends TestSuite { - +@RunWith(AllTests.class) +public class FlinkIgniteSinkSelfTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Apache Flink sink Test Suite"); - suite.addTest(new TestSuite(FlinkIgniteSinkSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(FlinkIgniteSinkSelfTest.class)); return suite; } diff --git a/modules/flume/src/test/java/org/apache/ignite/stream/flume/IgniteSinkTest.java b/modules/flume/src/test/java/org/apache/ignite/stream/flume/IgniteSinkTest.java index 031eb5d4d7577..a5fa3940b4176 100644 --- a/modules/flume/src/test/java/org/apache/ignite/stream/flume/IgniteSinkTest.java +++ b/modules/flume/src/test/java/org/apache/ignite/stream/flume/IgniteSinkTest.java @@ -33,12 +33,16 @@ import org.apache.ignite.events.Event; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; /** * {@link IgniteSink} test. */ +@RunWith(JUnit4.class) public class IgniteSinkTest extends GridCommonAbstractTest { /** Number of events to be sent to memory channel. */ private static final int EVENT_CNT = 10000; @@ -49,6 +53,7 @@ public class IgniteSinkTest extends GridCommonAbstractTest { /** * @throws Exception {@link Exception}. */ + @Test public void testSink() throws Exception { IgniteConfiguration cfg = loadConfiguration("modules/flume/src/test/resources/example-ignite.xml"); diff --git a/modules/flume/src/test/java/org/apache/ignite/stream/flume/IgniteSinkTestSuite.java b/modules/flume/src/test/java/org/apache/ignite/stream/flume/IgniteSinkTestSuite.java index ad6d162b83597..0cd52a7dcf769 100644 --- a/modules/flume/src/test/java/org/apache/ignite/stream/flume/IgniteSinkTestSuite.java +++ b/modules/flume/src/test/java/org/apache/ignite/stream/flume/IgniteSinkTestSuite.java @@ -17,20 +17,23 @@ package org.apache.ignite.stream.flume; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Tests for a Flume sink for Ignite. */ -public class IgniteSinkTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSinkTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Apache Flume NG Sink Test Suite"); - suite.addTest(new TestSuite(IgniteSinkTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSinkTest.class)); return suite; } diff --git a/modules/gce/src/test/java/org/apache/ignite/testsuites/IgniteGCETestSuite.java b/modules/gce/src/test/java/org/apache/ignite/testsuites/IgniteGCETestSuite.java index 147abad9e3786..d95748d36f42f 100644 --- a/modules/gce/src/test/java/org/apache/ignite/testsuites/IgniteGCETestSuite.java +++ b/modules/gce/src/test/java/org/apache/ignite/testsuites/IgniteGCETestSuite.java @@ -17,21 +17,24 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinderSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Google Compute Engine integration tests. */ -public class IgniteGCETestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteGCETestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Google Compute Engine Integration Test Suite"); - suite.addTest(new TestSuite(TcpDiscoveryGoogleStorageIpFinderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryGoogleStorageIpFinderSelfTest.class)); return suite; } @@ -68,4 +71,4 @@ public static String getProjectName() { return name; } -} \ No newline at end of file +} diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java index 9c5038ec37851..e0ebc90f3fc55 100644 --- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java +++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java @@ -17,6 +17,19 @@ package org.apache.ignite.internal.processors.query.h2; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import javax.cache.Cache; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; @@ -36,27 +49,17 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.io.ParseException; import org.locationtech.jts.io.WKTReader; -import javax.cache.Cache; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - /** * Geo-indexing test. */ +@RunWith(JUnit4.class) public abstract class H2IndexingAbstractGeoSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int CNT = 100; @@ -227,12 +230,13 @@ private static void destroy(IgniteCache cache, IgniteEx grid, boolean dynamic) { if (!dynamic) cache.destroy(); else - grid.context().cache().dynamicDestroyCache(cache.getName(), true, true, false); + grid.context().cache().dynamicDestroyCache(cache.getName(), true, true, false, null); } /** * @throws Exception If failed. */ + @Test public void testPrimitiveGeometry() throws Exception { IgniteCache cache = createCache("geom", true, Long.class, Geometry.class); @@ -258,6 +262,7 @@ public void testPrimitiveGeometry() throws Exception { * * @throws Exception If failed. */ + @Test public void testGeo() throws Exception { checkGeo(false); } @@ -267,6 +272,7 @@ public void testGeo() throws Exception { * * @throws Exception If failed. */ + @Test public void testGeoDynamic() throws Exception { checkGeo(true); } @@ -349,6 +355,7 @@ private void checkGeo(boolean dynamic) throws Exception { * * @throws Exception If failed. */ + @Test public void testGeoMultithreaded() throws Exception { checkGeoMultithreaded(false); } @@ -358,6 +365,7 @@ public void testGeoMultithreaded() throws Exception { * * @throws Exception If failed. */ + @Test public void testGeoMultithreadedDynamic() throws Exception { checkGeoMultithreaded(true); } @@ -493,6 +501,7 @@ private void checkPoints(Collection> res, String * * @throws Exception if fails. */ + @Test public void testSegmentedGeoIndexJoinPartitioned() throws Exception { checkSegmentedGeoIndexJoin(true, false); } @@ -502,6 +511,7 @@ public void testSegmentedGeoIndexJoinPartitioned() throws Exception { * * @throws Exception if fails. */ + @Test public void testSegmentedGeoIndexJoinPartitionedDynamic() throws Exception { checkSegmentedGeoIndexJoin(true, true); } @@ -511,6 +521,7 @@ public void testSegmentedGeoIndexJoinPartitionedDynamic() throws Exception { * * @throws Exception if fails. */ + @Test public void testSegmentedGeoIndexJoinReplicated() throws Exception { checkSegmentedGeoIndexJoin(false, false); } @@ -520,6 +531,7 @@ public void testSegmentedGeoIndexJoinReplicated() throws Exception { * * @throws Exception if fails. */ + @Test public void testSegmentedGeoIndexJoinReplicatedDynamic() throws Exception { checkSegmentedGeoIndexJoin(false, true); } @@ -674,4 +686,4 @@ protected static class EnemyCamp implements Serializable { this.name = name; } } -} \ No newline at end of file +} diff --git a/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java b/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java index 22109dea2d907..67c06c265e6d9 100644 --- a/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java +++ b/modules/geospatial/src/test/java/org/apache/ignite/testsuites/GeoSpatialIndexingTestSuite.java @@ -17,24 +17,27 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.query.h2.H2IndexingGeoSelfTest; import org.apache.ignite.internal.processors.query.h2.H2IndexingSegmentedGeoSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Geospatial indexing tests. */ -public class GeoSpatialIndexingTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class GeoSpatialIndexingTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("H2 Geospatial Indexing Test Suite"); - suite.addTestSuite(H2IndexingGeoSelfTest.class); - suite.addTestSuite(H2IndexingSegmentedGeoSelfTest.class); + suite.addTest(new JUnit4TestAdapter(H2IndexingGeoSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2IndexingSegmentedGeoSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopCommandLineTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopCommandLineTest.java index 6d4e29e47fa0f..39afab3c209ca 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopCommandLineTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopCommandLineTest.java @@ -50,10 +50,14 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test of integration with Hadoop client via command line interface. */ +@RunWith(JUnit4.class) public class HadoopCommandLineTest extends GridCommonAbstractTest { /** IGFS instance. */ private IgfsEx igfs; @@ -358,6 +362,7 @@ private int executeHiveQuery(String qry) throws Exception { /** * Tests Hadoop command line integration. */ + @Test public void testHadoopCommandLine() throws Exception { assertEquals(0, executeHadoopCmd("fs", "-ls", "/")); @@ -434,6 +439,7 @@ private void checkQuery(String expRes, String qry) throws Exception { /** * Tests Hive integration. */ + @Test public void testHiveCommandLine() throws Exception { assertEquals(0, executeHiveQuery( "create table table_a (" + @@ -495,4 +501,4 @@ public void testHiveCommandLine() throws Exception { checkQuery("1000\n", "select count(b.id_b) from table_a a inner join table_b b on a.id_b = b.id_b"); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopFileSystemsTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopFileSystemsTest.java index 76806902b4a77..4a4ea6f3a5079 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopFileSystemsTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopFileSystemsTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.internal.processors.hadoop.impl.fs.HadoopFileSystemsUtils; import org.apache.ignite.internal.processors.hadoop.impl.fs.HadoopLocalFileSystemV1; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test file systems for the working directory multi-threading support. */ +@RunWith(JUnit4.class) public class HadoopFileSystemsTest extends HadoopAbstractSelfTest { /** the number of threads */ private static final int THREAD_COUNT = 3; @@ -158,7 +162,8 @@ private void testFileSystem(final URI uri) throws Exception { * * @throws Exception If fails. */ + @Test public void testLocal() throws Exception { testFileSystem(URI.create("file:///")); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopGroupingTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopGroupingTest.java index d27a234323f3b..8ca1b86d80824 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopGroupingTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopGroupingTest.java @@ -47,12 +47,16 @@ import java.util.Random; import java.util.Set; import java.util.UUID; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils.createJobInfo; /** * Grouping test. */ +@RunWith(JUnit4.class) public class HadoopGroupingTest extends HadoopAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -60,7 +64,7 @@ public class HadoopGroupingTest extends HadoopAbstractSelfTest { } /** {@inheritDoc} */ - protected boolean igfsEnabled() { + @Override protected boolean igfsEnabled() { return false; } @@ -87,6 +91,7 @@ protected boolean igfsEnabled() { /** * @throws Exception If failed. */ + @Test public void testGroupingReducer() throws Exception { doTestGrouping(false); } @@ -94,6 +99,7 @@ public void testGroupingReducer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGroupingCombiner() throws Exception { doTestGrouping(true); } @@ -299,4 +305,4 @@ public static class OutFormat extends OutputFormat { return null; } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopJobTrackerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopJobTrackerSelfTest.java index 7f94def19eab3..5d69f4155be3d 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopJobTrackerSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopJobTrackerSelfTest.java @@ -43,6 +43,9 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobId; import org.apache.ignite.internal.processors.hadoop.HadoopJobStatus; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils.createJobInfo; import static org.apache.ignite.internal.processors.hadoop.state.HadoopJobTrackerSelfTestState.combineExecCnt; @@ -53,6 +56,7 @@ /** * Job tracker self test. */ +@RunWith(JUnit4.class) public class HadoopJobTrackerSelfTest extends HadoopAbstractSelfTest { /** */ private static final String PATH_OUTPUT = "/test-out"; @@ -99,6 +103,7 @@ public class HadoopJobTrackerSelfTest extends HadoopAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testSimpleTaskSubmit() throws Exception { try { UUID globalId = UUID.randomUUID(); @@ -145,6 +150,7 @@ public void testSimpleTaskSubmit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTaskWithCombinerPerMap() throws Exception { try { UUID globalId = UUID.randomUUID(); @@ -323,4 +329,4 @@ private static class TestCombiner extends Reducer { System.out.println("Completed task: " + ctx.getTaskAttemptID().getTaskID().getId()); } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceEmbeddedSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceEmbeddedSelfTest.java index 21b7ee28c1a3a..9d750c9cf25f2 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceEmbeddedSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceEmbeddedSelfTest.java @@ -37,6 +37,9 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobProperty; import org.apache.ignite.internal.processors.hadoop.impl.examples.HadoopWordCount1; import org.apache.ignite.internal.processors.hadoop.impl.examples.HadoopWordCount2; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils.createJobInfo; import static org.apache.ignite.internal.processors.hadoop.state.HadoopMapReduceEmbeddedSelfTestState.flags; @@ -44,6 +47,7 @@ /** * Tests map-reduce execution with embedded mode. */ +@RunWith(JUnit4.class) public class HadoopMapReduceEmbeddedSelfTest extends HadoopMapReduceTest { /** {@inheritDoc} */ @Override public HadoopConfiguration hadoopConfiguration(String igniteInstanceName) { @@ -58,6 +62,7 @@ public class HadoopMapReduceEmbeddedSelfTest extends HadoopMapReduceTest { /** * @throws Exception If fails. */ + @Test public void testMultiReducerWholeMapReduceExecution() throws Exception { checkMultiReducerWholeMapReduceExecution(false); } @@ -65,6 +70,7 @@ public void testMultiReducerWholeMapReduceExecution() throws Exception { /** * @throws Exception If fails. */ + @Test public void testMultiReducerWholeMapReduceExecutionStriped() throws Exception { checkMultiReducerWholeMapReduceExecution(true); } @@ -268,4 +274,4 @@ private static class CustomV1OutputFormat extends org.apache.hadoop.mapred.TextO flags.put("outputFormatWasConfigured", true); } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceErrorResilienceTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceErrorResilienceTest.java index afd6f26d92e69..afd636d1177d1 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceErrorResilienceTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceErrorResilienceTest.java @@ -19,6 +19,9 @@ import org.apache.ignite.igfs.IgfsPath; import org.apache.ignite.internal.processors.hadoop.impl.examples.HadoopWordCount2; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test of error resiliency after an error in a map-reduce job execution. @@ -27,12 +30,14 @@ * x { unchecked exception, checked exception, error } * x { phase where the error happens }. */ +@RunWith(JUnit4.class) public class HadoopMapReduceErrorResilienceTest extends HadoopAbstractMapReduceTest { /** * Tests recovery. * * @throws Exception If failed. */ + @Test public void testRecoveryAfterAnError0_Runtime() throws Exception { doTestRecoveryAfterAnError(0, HadoopErrorSimulator.Kind.Runtime); } @@ -42,6 +47,7 @@ public void testRecoveryAfterAnError0_Runtime() throws Exception { * * @throws Exception If failed. */ + @Test public void testRecoveryAfterAnError0_IOException() throws Exception { doTestRecoveryAfterAnError(0, HadoopErrorSimulator.Kind.IOException); } @@ -51,6 +57,7 @@ public void testRecoveryAfterAnError0_IOException() throws Exception { * * @throws Exception If failed. */ + @Test public void testRecoveryAfterAnError0_Error() throws Exception { doTestRecoveryAfterAnError(0, HadoopErrorSimulator.Kind.Error); } @@ -60,6 +67,7 @@ public void testRecoveryAfterAnError0_Error() throws Exception { * * @throws Exception If failed. */ + @Test public void testRecoveryAfterAnError7_Runtime() throws Exception { doTestRecoveryAfterAnError(7, HadoopErrorSimulator.Kind.Runtime); } @@ -68,6 +76,7 @@ public void testRecoveryAfterAnError7_Runtime() throws Exception { * * @throws Exception If failed. */ + @Test public void testRecoveryAfterAnError7_IOException() throws Exception { doTestRecoveryAfterAnError(7, HadoopErrorSimulator.Kind.IOException); } @@ -76,6 +85,7 @@ public void testRecoveryAfterAnError7_IOException() throws Exception { * * @throws Exception If failed. */ + @Test public void testRecoveryAfterAnError7_Error() throws Exception { doTestRecoveryAfterAnError(7, HadoopErrorSimulator.Kind.Error); } @@ -151,4 +161,4 @@ private void doTestWithErrorSimulator(HadoopErrorSimulator sim, IgfsPath inFile, // Expect success there: doTest(inFile, useNewMapper, useNewCombiner, useNewReducer); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceTest.java index feccb59193001..04091d03bf7b4 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopMapReduceTest.java @@ -19,15 +19,20 @@ import org.apache.ignite.igfs.IgfsPath; import org.apache.ignite.internal.processors.hadoop.impl.examples.HadoopWordCount2; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test of whole cycle of map-reduce processing via Job tracker. */ +@RunWith(JUnit4.class) public class HadoopMapReduceTest extends HadoopAbstractMapReduceTest { /** * Tests whole job execution with all phases in all combination of new and old versions of API. * @throws Exception If fails. */ + @Test public void testWholeMapReduceExecution() throws Exception { IgfsPath inDir = new IgfsPath(PATH_INPUT); @@ -63,4 +68,4 @@ protected boolean[][] getApiModes() { { true, true, true }, }; } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopNoHadoopMapReduceTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopNoHadoopMapReduceTest.java index 382631db45a4e..e59f9dd403273 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopNoHadoopMapReduceTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopNoHadoopMapReduceTest.java @@ -18,10 +18,14 @@ package org.apache.ignite.internal.processors.hadoop.impl; import org.apache.ignite.configuration.IgniteConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test attempt to execute a map-reduce task while no Hadoop processor available. */ +@RunWith(JUnit4.class) public class HadoopNoHadoopMapReduceTest extends HadoopMapReduceTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -34,6 +38,7 @@ public class HadoopNoHadoopMapReduceTest extends HadoopMapReduceTest { } /** {@inheritDoc} */ + @Test @Override public void testWholeMapReduceExecution() throws Exception { try { super.testWholeMapReduceExecution(); diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSerializationWrapperSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSerializationWrapperSelfTest.java index 5ccc8cea50115..b1f16e0d4bd2d 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSerializationWrapperSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSerializationWrapperSelfTest.java @@ -30,15 +30,20 @@ import org.apache.ignite.internal.processors.hadoop.HadoopSerialization; import org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopSerializationWrapper; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test of wrapper of the native serialization. */ +@RunWith(JUnit4.class) public class HadoopSerializationWrapperSelfTest extends GridCommonAbstractTest { /** * Tests read/write of IntWritable via native WritableSerialization. * @throws Exception If fails. */ + @Test public void testIntWritableSerialization() throws Exception { HadoopSerialization ser = new HadoopSerializationWrapper(new WritableSerialization(), IntWritable.class); @@ -61,6 +66,7 @@ public void testIntWritableSerialization() throws Exception { * Tests read/write of Integer via native JavaleSerialization. * @throws Exception If fails. */ + @Test public void testIntJavaSerialization() throws Exception { HadoopSerialization ser = new HadoopSerializationWrapper(new JavaSerialization(), Integer.class); @@ -77,4 +83,4 @@ public void testIntJavaSerialization() throws Exception { assertEquals(3, ((Integer)ser.read(in, null)).intValue()); assertEquals(-5, ((Integer)ser.read(in, null)).intValue()); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSnappyTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSnappyTest.java index 80ff7547e2988..6958520cd807f 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSnappyTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSnappyTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.internal.processors.hadoop.HadoopHelperImpl; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests isolated Hadoop Snappy codec usage. */ +@RunWith(JUnit4.class) public class HadoopSnappyTest extends GridCommonAbstractTest { /** Length of data. */ private static final int BYTE_SIZE = 1024 * 50; @@ -45,6 +49,7 @@ public class HadoopSnappyTest extends GridCommonAbstractTest { * * @throws Exception On error. */ + @Test public void testSnappy() throws Throwable { // Run Snappy test in default class loader: checkSnappy(); diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSortingTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSortingTest.java index bb11ccb77eeb1..dc84913d6a070 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSortingTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSortingTest.java @@ -50,12 +50,16 @@ import org.apache.ignite.configuration.HadoopConfiguration; import org.apache.ignite.internal.processors.hadoop.HadoopJobId; import org.apache.ignite.internal.util.typedef.X; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils.createJobInfo; /** * Tests correct sorting. */ +@RunWith(JUnit4.class) public class HadoopSortingTest extends HadoopAbstractSelfTest { /** */ private static final String PATH_INPUT = "/test-in"; @@ -98,6 +102,7 @@ public class HadoopSortingTest extends HadoopAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testSortSimple() throws Exception { // Generate test data. Job job = Job.getInstance(); @@ -301,4 +306,4 @@ public FakeSplit() { len = in.readInt(); } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSplitWrapperSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSplitWrapperSelfTest.java index be2bfc2413727..4c661a6755f67 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSplitWrapperSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopSplitWrapperSelfTest.java @@ -29,15 +29,20 @@ import org.apache.hadoop.mapreduce.lib.input.FileSplit; import org.apache.ignite.internal.processors.hadoop.HadoopSplitWrapper; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Self test of {@link HadoopSplitWrapper}. */ +@RunWith(JUnit4.class) public class HadoopSplitWrapperSelfTest extends HadoopAbstractSelfTest { /** * Tests serialization of wrapper and the wrapped native split. * @throws Exception If fails. */ + @Test public void testSerialization() throws Exception { FileSplit nativeSplit = new FileSplit(new Path("/path/to/file"), 100, 500, new String[]{"host1", "host2"}); @@ -69,4 +74,4 @@ public void testSerialization() throws Exception { } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopTaskExecutionSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopTaskExecutionSelfTest.java index bc59c764ed8e2..afd5ac783e3b5 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopTaskExecutionSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopTaskExecutionSelfTest.java @@ -52,6 +52,9 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.hadoop.state.HadoopTaskExecutionSelfTestValues.cancelledTasks; import static org.apache.ignite.internal.processors.hadoop.state.HadoopTaskExecutionSelfTestValues.executedTasks; @@ -64,6 +67,7 @@ /** * Tests map-reduce task execution basics. */ +@RunWith(JUnit4.class) public class HadoopTaskExecutionSelfTest extends HadoopAbstractSelfTest { /** Test param. */ private static final String MAP_WRITE = "test.map.write"; @@ -107,6 +111,7 @@ public class HadoopTaskExecutionSelfTest extends HadoopAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testMapRun() throws Exception { int lineCnt = 10000; String fileName = "/testFile"; @@ -148,6 +153,7 @@ public void testMapRun() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMapCombineRun() throws Exception { int lineCnt = 10001; String fileName = "/testFile"; @@ -196,6 +202,7 @@ public void testMapCombineRun() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMapperException() throws Exception { prepareFile("/testFile", 1000); @@ -301,6 +308,7 @@ private static class InFormat extends TextInputFormat { /** * @throws Exception If failed. */ + @Test public void testTaskCancelling() throws Exception { Configuration cfg = prepareJobForCancelling(); @@ -345,6 +353,7 @@ public void testTaskCancelling() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJobKill() throws Exception { Configuration cfg = prepareJobForCancelling(); @@ -541,4 +550,4 @@ private static class TestReducer extends Reducer hadoopCache = getSystemCache(ignite, CU.SYS_CACHE_HADOOP_MR); @@ -39,4 +44,4 @@ public void testSystemCacheTx() throws Exception { checkImplicitTxSuccess(hadoopCache); checkStartTxSuccess(hadoopCache); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUserLibsSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUserLibsSelfTest.java index 0e4a0ef1d1a82..cf4ef5e88661e 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUserLibsSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUserLibsSelfTest.java @@ -25,10 +25,14 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for user libs parsing. */ +@RunWith(JUnit4.class) public class HadoopUserLibsSelfTest extends GridCommonAbstractTest { /** Directory 1. */ private static final File DIR_1 = HadoopTestUtils.testDir("dir1"); @@ -89,6 +93,7 @@ public class HadoopUserLibsSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testNullOrEmptyUserLibs() throws Exception { assert parse(null).isEmpty(); assert parse("").isEmpty(); @@ -99,6 +104,7 @@ public void testNullOrEmptyUserLibs() throws Exception { * * @throws Exception If failed. */ + @Test public void testSingle() throws Exception { Collection res = parse(single(FILE_1_1)); @@ -115,6 +121,7 @@ public void testSingle() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultiple() throws Exception { Collection res = parse(merge(single(FILE_1_1), single(FILE_1_2), single(FILE_2_1), single(FILE_2_2), single(MISSING_FILE))); @@ -131,6 +138,7 @@ public void testMultiple() throws Exception { * * @throws Exception If failed. */ + @Test public void testSingleWildcard() throws Exception { Collection res = parse(wildcard(DIR_1)); @@ -148,6 +156,7 @@ public void testSingleWildcard() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleWildcards() throws Exception { Collection res = parse(merge(wildcard(DIR_1), wildcard(DIR_2), wildcard(MISSING_DIR))); @@ -163,6 +172,7 @@ public void testMultipleWildcards() throws Exception { * * @throws Exception If failed. */ + @Test public void testMixed() throws Exception { String str = merge( single(FILE_1_1), diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopV2JobSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopV2JobSelfTest.java index 041f0bc7c4634..5eefdf91621a9 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopV2JobSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopV2JobSelfTest.java @@ -40,12 +40,16 @@ import org.apache.ignite.internal.processors.hadoop.HadoopHelperImpl; import org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopSerializationWrapper; import org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopV2Job; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils.createJobInfo; /** * Self test of {@link org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopV2Job}. */ +@RunWith(JUnit4.class) public class HadoopV2JobSelfTest extends HadoopAbstractSelfTest { /** */ private static final String TEST_SERIALIZED_VALUE = "Test serialized value"; @@ -73,6 +77,7 @@ private static class CustomSerialization extends WritableSerialization { * * @throws IgniteCheckedException If fails. */ + @Test public void testCustomSerializationApplying() throws IgniteCheckedException { JobConf cfg = new JobConf(); @@ -105,4 +110,4 @@ public void testCustomSerializationApplying() throws IgniteCheckedException { assertEquals(TEST_SERIALIZED_VALUE, ser.read(in, null).toString()); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopValidationSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopValidationSelfTest.java index ef16762191e6f..58f7f5ebf022d 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopValidationSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopValidationSelfTest.java @@ -18,10 +18,14 @@ package org.apache.ignite.internal.processors.hadoop.impl; import org.apache.ignite.configuration.IgniteConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Configuration validation tests. */ +@RunWith(JUnit4.class) public class HadoopValidationSelfTest extends HadoopAbstractSelfTest { /** Peer class loading enabled flag. */ public boolean peerClassLoading; @@ -47,7 +51,8 @@ public class HadoopValidationSelfTest extends HadoopAbstractSelfTest { * * @throws Exception If failed. */ + @Test public void testValid() throws Exception { startGrids(1); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopWeightedMapReducePlannerTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopWeightedMapReducePlannerTest.java index 6dcd9980c05b7..c55940aa2bcef 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopWeightedMapReducePlannerTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopWeightedMapReducePlannerTest.java @@ -45,10 +45,14 @@ import java.util.Set; import java.util.TreeMap; import java.util.UUID; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for weighted map-reduce planned. */ +@RunWith(JUnit4.class) public class HadoopWeightedMapReducePlannerTest extends GridCommonAbstractTest { /** ID 1. */ private static final UUID ID_1 = new UUID(0, 1); @@ -111,6 +115,7 @@ public class HadoopWeightedMapReducePlannerTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testOneIgfsSplitAffinity() throws Exception { IgfsMock igfs = LocationsBuilder.create().add(0, NODE_1).add(50, NODE_2).add(100, NODE_3).buildIgfs(); @@ -139,6 +144,7 @@ public void testOneIgfsSplitAffinity() throws Exception { * * @throws Exception If failed. */ + @Test public void testHdfsSplitsAffinity() throws Exception { IgfsMock igfs = LocationsBuilder.create().add(0, NODE_1).add(50, NODE_2).add(100, NODE_3).buildIgfs(); @@ -171,6 +177,7 @@ public void testHdfsSplitsAffinity() throws Exception { * * @throws Exception If failed. */ + @Test public void testHdfsSplitsReplication() throws Exception { IgfsMock igfs = LocationsBuilder.create().add(0, NODE_1).add(50, NODE_2).add(100, NODE_3).buildIgfs(); diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java index 0e5ad03559257..dfebd3fbae6f2 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolMultipleServersSelfTest.java @@ -50,11 +50,14 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Hadoop client protocol configured with multiple ignite servers tests. */ -@SuppressWarnings("ResultOfMethodCallIgnored") +@RunWith(JUnit4.class) public class HadoopClientProtocolMultipleServersSelfTest extends HadoopAbstractSelfTest { /** Input path. */ private static final String PATH_INPUT = "/input"; @@ -147,7 +150,7 @@ private void checkJobSubmit(Configuration conf) throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("ConstantConditions") + @Test public void testMultipleAddresses() throws Exception { restPort = REST_PORT; @@ -163,7 +166,7 @@ public void testMultipleAddresses() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"ConstantConditions", "ThrowableResultOfMethodCallIgnored"}) + @Test public void testSingleAddress() throws Exception { try { // Don't use REST_PORT to test connection fails if the only this port is configured @@ -189,7 +192,7 @@ public void testSingleAddress() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("ConstantConditions") + @Test public void testMixedAddrs() throws Exception { restPort = REST_PORT; @@ -312,4 +315,4 @@ public static class OutFormat extends OutputFormat { return null; } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolSelfTest.java index 0027b3e4781a4..ac88082b07826 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/client/HadoopClientProtocolSelfTest.java @@ -56,11 +56,15 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Hadoop client protocol tests in external process mode. */ @SuppressWarnings("ResultOfMethodCallIgnored") +@RunWith(JUnit4.class) public class HadoopClientProtocolSelfTest extends HadoopAbstractSelfTest { /** Input path. */ private static final String PATH_INPUT = "/input"; @@ -160,6 +164,7 @@ private void tstNextJobId() throws Exception { * * @throws Exception If failed. */ + @Test public void testJobCounters() throws Exception { IgniteFileSystem igfs = grid(0).fileSystem(HadoopAbstractSelfTest.igfsName); @@ -663,4 +668,4 @@ public static class TestReducer extends Reducer() { @Override public Object call() throws Exception { @@ -461,6 +468,7 @@ public void testCreateCheckParameters() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreateBase() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -487,6 +495,7 @@ public void testCreateBase() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreateCheckOverwrite() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -517,6 +526,7 @@ public void testCreateCheckOverwrite() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteIfNoSuchPath() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -527,6 +537,7 @@ public void testDeleteIfNoSuchPath() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteSuccessfulIfPathIsOpenedToRead() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "myFile"); @@ -560,6 +571,7 @@ public void testDeleteSuccessfulIfPathIsOpenedToRead() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteIfFilePathExists() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "myFile"); @@ -575,6 +587,7 @@ public void testDeleteIfFilePathExists() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteIfDirectoryPathExists() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -590,6 +603,7 @@ public void testDeleteIfDirectoryPathExists() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteFailsIfNonRecursive() throws Exception { Path fsHome = new Path(primaryFsUri); Path someDir3 = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -614,6 +628,7 @@ public void testDeleteFailsIfNonRecursive() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteRecursively() throws Exception { Path fsHome = new Path(primaryFsUri); Path someDir3 = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -632,6 +647,7 @@ public void testDeleteRecursively() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteRecursivelyFromRoot() throws Exception { Path fsHome = new Path(primaryFsUri); Path someDir3 = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -654,6 +670,7 @@ public void testDeleteRecursivelyFromRoot() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetPermissionCheckDefaultPermission() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); @@ -670,6 +687,7 @@ public void testSetPermissionCheckDefaultPermission() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetPermissionCheckNonRecursiveness() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); @@ -691,6 +709,7 @@ public void testSetPermissionCheckNonRecursiveness() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("OctalInteger") + @Test public void testSetPermission() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); @@ -710,6 +729,7 @@ public void testSetPermission() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetPermissionIfOutputStreamIsNotClosed() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "myFile"); @@ -727,6 +747,7 @@ public void testSetPermissionIfOutputStreamIsNotClosed() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwnerCheckParametersPathIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); @@ -746,6 +767,7 @@ public void testSetOwnerCheckParametersPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwnerCheckParametersUserIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); @@ -765,6 +787,7 @@ public void testSetOwnerCheckParametersUserIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwnerCheckParametersGroupIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); @@ -784,6 +807,7 @@ public void testSetOwnerCheckParametersGroupIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwner() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); @@ -802,6 +826,7 @@ public void testSetOwner() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwnerIfOutputStreamIsNotClosed() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "myFile"); @@ -818,6 +843,7 @@ public void testSetOwnerIfOutputStreamIsNotClosed() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwnerCheckNonRecursiveness() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); @@ -840,6 +866,7 @@ public void testSetOwnerCheckNonRecursiveness() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOpenCheckParametersPathIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -849,6 +876,7 @@ public void testOpenCheckParametersPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOpenNoSuchPath() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "someFile"); @@ -861,6 +889,7 @@ public void testOpenNoSuchPath() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOpenIfPathIsAlreadyOpened() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); @@ -878,6 +907,7 @@ public void testOpenIfPathIsAlreadyOpened() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOpen() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); @@ -901,6 +931,7 @@ public void testOpen() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAppendIfPathPointsToDirectory() throws Exception { final Path fsHome = new Path(primaryFsUri); final Path dir = new Path(fsHome, "/tmp"); @@ -920,6 +951,7 @@ public void testAppendIfPathPointsToDirectory() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAppendIfFileIsAlreadyBeingOpenedToWrite() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "someFile"); @@ -943,6 +975,7 @@ public void testAppendIfFileIsAlreadyBeingOpenedToWrite() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAppend() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); @@ -974,6 +1007,7 @@ public void testAppend() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameCheckParametersSrcPathIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "someFile"); @@ -988,6 +1022,7 @@ public void testRenameCheckParametersSrcPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameCheckParametersDstPathIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "someFile"); @@ -1006,6 +1041,7 @@ public Object call() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameIfSrcPathDoesNotExist() throws Exception { Path fsHome = new Path(primaryFsUri); final Path srcFile = new Path(fsHome, "srcFile"); @@ -1025,6 +1061,7 @@ public void testRenameIfSrcPathDoesNotExist() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameIfSrcPathIsAlreadyBeingOpenedToWrite() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcFile = new Path(fsHome, "srcFile"); @@ -1061,6 +1098,7 @@ public void testRenameIfSrcPathIsAlreadyBeingOpenedToWrite() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameFileIfDstPathExists() throws Exception { Path fsHome = new Path(primaryFsUri); final Path srcFile = new Path(fsHome, "srcFile"); @@ -1089,6 +1127,7 @@ public void testRenameFileIfDstPathExists() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameFile() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcFile = new Path(fsHome, "/tmp/srcFile"); @@ -1106,6 +1145,7 @@ public void testRenameFile() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameIfSrcPathIsAlreadyBeingOpenedToRead() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcFile = new Path(fsHome, "srcFile"); @@ -1141,6 +1181,7 @@ public void testRenameIfSrcPathIsAlreadyBeingOpenedToRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRenameDirectoryIfDstPathExists() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcDir = new Path(fsHome, "/tmp/"); @@ -1174,6 +1215,7 @@ public void testRenameDirectoryIfDstPathExists() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameDirectory() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/tmp/"); @@ -1191,6 +1233,7 @@ public void testRenameDirectory() throws Exception { } /** @throws Exception If failed. */ + @Test public void testListStatusIfPathIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1200,6 +1243,7 @@ public void testListStatusIfPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testListStatusIfPathDoesNotExist() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1213,6 +1257,7 @@ public void testListStatusIfPathDoesNotExist() throws Exception { * * @throws Exception If failed. */ + @Test public void testListStatus() throws Exception { Path igfsHome = new Path(primaryFsUri); @@ -1256,6 +1301,7 @@ public void testListStatus() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMkdirsIfPathIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1267,6 +1313,7 @@ public void testMkdirsIfPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMkdirsIfPermissionIsNull() throws Exception { Path dir = new Path("/tmp"); @@ -1277,6 +1324,7 @@ public void testMkdirsIfPermissionIsNull() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("OctalInteger") + @Test public void testMkdirs() throws Exception { Path fsHome = new Path(primaryFileSystemUriPath()); Path dir = new Path(fsHome, "/tmp/staging"); @@ -1296,6 +1344,7 @@ public void testMkdirs() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetFileStatusIfPathIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1305,6 +1354,7 @@ public void testGetFileStatusIfPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetFileStatusIfPathDoesNotExist() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1314,6 +1364,7 @@ public void testGetFileStatusIfPathDoesNotExist() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetFileBlockLocationsIfFileStatusIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1324,6 +1375,7 @@ public void testGetFileBlockLocationsIfFileStatusIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetFileBlockLocationsIfFileStatusReferenceNotExistingPath() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1333,6 +1385,7 @@ public void testGetFileBlockLocationsIfFileStatusReferenceNotExistingPath() thro } /** @throws Exception If failed. */ + @Test public void testGetFileBlockLocations() throws Exception { Path igfsHome = new Path(primaryFsUri); @@ -1371,6 +1424,7 @@ public void testGetFileBlockLocations() throws Exception { } /** @throws Exception If failed. */ + @Test public void testZeroReplicationFactor() throws Exception { // This test doesn't make sense for any mode except of PRIMARY. if (mode == PRIMARY) { @@ -1404,6 +1458,7 @@ public void testZeroReplicationFactor() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultithreadedCreate() throws Exception { Path dir = new Path(new Path(primaryFsUri), "/dir"); @@ -1479,6 +1534,7 @@ public void testMultithreadedCreate() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultithreadedAppend() throws Exception { Path dir = new Path(new Path(primaryFsUri), "/dir"); @@ -1555,6 +1611,7 @@ public void testMultithreadedAppend() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultithreadedOpen() throws Exception { final byte[] dataChunk = new byte[256]; @@ -1627,6 +1684,7 @@ public void run() { * * @throws Exception If failed. */ + @Test public void testMultithreadedMkdirs() throws Exception { final Path dir = new Path(new Path("igfs:///"), "/dir"); @@ -1707,6 +1765,7 @@ public void testMultithreadedMkdirs() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("TooBroadScope") + @Test public void testMultithreadedDelete() throws Exception { final Path dir = new Path(new Path(primaryFsUri), "/dir"); @@ -1780,6 +1839,7 @@ public void testMultithreadedDelete() throws Exception { } /** @throws Exception If failed. */ + @Test public void testConsistency() throws Exception { // Default buffers values checkConsistency(-1, 1, -1, -1, 1, -1); @@ -1805,6 +1865,7 @@ public void testConsistency() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testClientReconnect() throws Exception { final Path igfsHome = new Path(primaryFsUri); @@ -1850,6 +1911,7 @@ public void testClientReconnect() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testClientReconnectMultithreaded() throws Exception { final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsDualAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsDualAbstractSelfTest.java index 3ffdf23cbb0fd..1c450f3bc9500 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsDualAbstractSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfsDualAbstractSelfTest.java @@ -51,6 +51,9 @@ import java.io.IOException; import java.net.URI; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -66,6 +69,7 @@ /** * Tests for IGFS working in mode when remote file system exists: DUAL_SYNC, DUAL_ASYNC. */ +@RunWith(JUnit4.class) public abstract class HadoopIgfsDualAbstractSelfTest extends IgfsCommonAbstractTest { /** IGFS block size. */ protected static final int IGFS_BLOCK_SIZE = 512 * 1024; @@ -240,6 +244,7 @@ protected IgfsPath[] paths(IgfsPath... paths) { * * @throws Exception IF failed. */ + @Test public void testOpenPrefetchOverride() throws Exception { create(igfsSecondary, paths(DIR, SUBDIR), paths(FILE)); @@ -324,4 +329,4 @@ public void testOpenPrefetchOverride() throws Exception { }, IOException.class, "Failed to read data due to secondary file system exception: /dir/subdir/file"); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java index 04eaf93b5f542..77320f81c31e4 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java @@ -53,6 +53,9 @@ import java.io.IOException; import java.net.URI; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -67,6 +70,7 @@ /** * Tests secondary file system configuration. */ +@RunWith(JUnit4.class) public class HadoopSecondaryFileSystemConfigurationTest extends IgfsCommonAbstractTest { /** IGFS scheme */ static final String IGFS_SCHEME = "igfs"; @@ -420,6 +424,7 @@ private CommunicationSpi communicationSpi() { * * @throws Exception On failure. */ + @Test public void testFsConfigurationOnly() throws Exception { primaryCfgScheme = IGFS_SCHEME; primaryCfgAuthority = PRIMARY_AUTHORITY; @@ -441,6 +446,7 @@ public void testFsConfigurationOnly() throws Exception { * * @throws Exception On failure. */ + @Test public void testFsUriOverridesUriInConfiguration() throws Exception { // wrong primary URI in the configuration: primaryCfgScheme = "foo"; @@ -599,4 +605,4 @@ static String mkUri(String scheme, String authority) { static String mkUri(String scheme, String authority, String path) { return scheme + "://" + authority + "/" + path; } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgfsEventsTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgfsEventsTestSuite.java index e3dac864a6157..b50d9bf35a41c 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgfsEventsTestSuite.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgfsEventsTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.hadoop.impl.igfs; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; @@ -31,6 +32,8 @@ import org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryServerEndpoint; import org.apache.ignite.internal.util.typedef.G; import org.jetbrains.annotations.Nullable; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC; import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC; @@ -40,7 +43,8 @@ * Test suite for IGFS event tests. */ @SuppressWarnings("PublicInnerClass") -public class IgfsEventsTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgfsEventsTestSuite { /** * @return Test suite. * @throws Exception Thrown in case of the failure. @@ -50,13 +54,13 @@ public static TestSuite suite() throws Exception { TestSuite suite = new TestSuite("Ignite FS Events Test Suite"); - suite.addTest(new TestSuite(ldr.loadClass(ShmemPrimary.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(ShmemDualSync.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(ShmemDualAsync.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(ShmemPrimary.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(ShmemDualSync.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(ShmemDualAsync.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(LoopbackPrimary.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(LoopbackDualSync.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(LoopbackDualAsync.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(LoopbackPrimary.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(LoopbackDualSync.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(LoopbackDualAsync.class.getName()))); return suite; } @@ -70,9 +74,9 @@ public static TestSuite suiteNoarchOnly() throws Exception { TestSuite suite = new TestSuite("Ignite IGFS Events Test Suite Noarch Only"); - suite.addTest(new TestSuite(ldr.loadClass(LoopbackPrimary.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(LoopbackDualSync.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(LoopbackDualAsync.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(LoopbackPrimary.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(LoopbackDualSync.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(LoopbackDualAsync.class.getName()))); return suite; } @@ -284,4 +288,4 @@ public static class LoopbackDualAsync extends LoopbackPrimarySecondaryTest { return igfsCfg; } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgfsNearOnlyMultiNodeSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgfsNearOnlyMultiNodeSelfTest.java index 20699f195d613..55914274426cf 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgfsNearOnlyMultiNodeSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgfsNearOnlyMultiNodeSelfTest.java @@ -39,10 +39,10 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -53,6 +53,7 @@ /** * Test hadoop file system implementation. */ +@RunWith(JUnit4.class) public class IgfsNearOnlyMultiNodeSelfTest extends GridCommonAbstractTest { /** Path to the default hadoop configuration. */ public static final String HADOOP_FS_CFG = "examples/config/filesystem/core-site.xml"; @@ -60,9 +61,6 @@ public class IgfsNearOnlyMultiNodeSelfTest extends GridCommonAbstractTest { /** Group size. */ public static final int GRP_SIZE = 128; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Node count. */ private int cnt; @@ -80,8 +78,6 @@ public class IgfsNearOnlyMultiNodeSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER).setForceServerMode(true)); - FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setName("igfs"); @@ -164,6 +160,7 @@ protected URI getFileSystemURI(int grid) { } /** @throws Exception If failed. */ + @Test public void testContentsConsistency() throws Exception { try (FileSystem fs = FileSystem.get(getFileSystemURI(0), getFileSystemConfig())) { Collection> files = F.asList( diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemAbstractSelfTest.java index a73367a4abfc2..bd1cf3c265886 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemAbstractSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemAbstractSelfTest.java @@ -86,6 +86,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -100,6 +103,7 @@ * Test hadoop file system implementation. */ @SuppressWarnings("all") +@RunWith(JUnit4.class) public abstract class IgniteHadoopFileSystemAbstractSelfTest extends IgfsCommonAbstractTest { /** Primary file system authority. */ private static final String PRIMARY_AUTHORITY = "igfs@"; @@ -445,6 +449,7 @@ protected FileSystemConfiguration igfsConfiguration(String igniteInstanceName) t } /** @throws Exception If failed. */ + @Test public void testGetUriIfFSIsNotInitialized() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -456,6 +461,7 @@ public void testGetUriIfFSIsNotInitialized() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("NullableProblems") + @Test public void testInitializeCheckParametersNameIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -468,6 +474,7 @@ public void testInitializeCheckParametersNameIsNull() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("NullableProblems") + @Test public void testInitializeCheckParametersCfgIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -479,6 +486,7 @@ public void testInitializeCheckParametersCfgIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testInitialize() throws Exception { final IgniteHadoopFileSystem fs = new IgniteHadoopFileSystem(); @@ -506,6 +514,7 @@ public void testInitialize() throws Exception { * * @throws Exception If failed. */ + @Test public void testIpcCache() throws Exception { HadoopIgfsEx hadoop = GridTestUtils.getFieldValue(fs, "rmtClient", "delegateRef", "value", "hadoop"); @@ -570,6 +579,7 @@ public void testIpcCache() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCloseIfNotInitialized() throws Exception { final FileSystem fs = new IgniteHadoopFileSystem(); @@ -578,6 +588,7 @@ public void testCloseIfNotInitialized() throws Exception { } /** @throws Exception If failed. */ + @Test public void testClose() throws Exception { final Path path = new Path("dir"); @@ -666,6 +677,7 @@ public void testClose() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreateCheckParameters() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -676,6 +688,7 @@ public void testCreateCheckParameters() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testCreateBase() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -702,6 +715,7 @@ public void testCreateBase() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testCreateCheckOverwrite() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -730,6 +744,7 @@ public void testCreateCheckOverwrite() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteIfNoSuchPath() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -740,6 +755,7 @@ public void testDeleteIfNoSuchPath() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteSuccessfulIfPathIsOpenedToRead() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "myFile"); @@ -766,6 +782,7 @@ public void testDeleteSuccessfulIfPathIsOpenedToRead() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteIfFilePathExists() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "myFile"); @@ -780,6 +797,7 @@ public void testDeleteIfFilePathExists() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteIfDirectoryPathExists() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -794,6 +812,7 @@ public void testDeleteIfDirectoryPathExists() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteFailsIfNonRecursive() throws Exception { Path fsHome = new Path(primaryFsUri); Path someDir3 = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -809,6 +828,7 @@ public void testDeleteFailsIfNonRecursive() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteRecursively() throws Exception { Path fsHome = new Path(primaryFsUri); Path someDir3 = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -826,6 +846,7 @@ public void testDeleteRecursively() throws Exception { } /** @throws Exception If failed. */ + @Test public void testDeleteRecursivelyFromRoot() throws Exception { Path fsHome = new Path(primaryFsUri); Path someDir3 = new Path(fsHome, "/someDir1/someDir2/someDir3"); @@ -847,6 +868,7 @@ public void testDeleteRecursivelyFromRoot() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testSetPermissionCheckDefaultPermission() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); @@ -864,6 +886,7 @@ public void testSetPermissionCheckDefaultPermission() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testSetPermissionCheckNonRecursiveness() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); @@ -885,6 +908,7 @@ public void testSetPermissionCheckNonRecursiveness() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("OctalInteger") + @Test public void testSetPermission() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); @@ -903,6 +927,7 @@ public void testSetPermission() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetPermissionIfOutputStreamIsNotClosed() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "myFile"); @@ -919,6 +944,7 @@ public void testSetPermissionIfOutputStreamIsNotClosed() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwnerCheckParametersPathIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); @@ -937,6 +963,7 @@ public void testSetOwnerCheckParametersPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwnerCheckParametersUserIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); @@ -955,6 +982,7 @@ public void testSetOwnerCheckParametersUserIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwnerCheckParametersGroupIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); @@ -973,6 +1001,7 @@ public void testSetOwnerCheckParametersGroupIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwner() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/tmp/my"); @@ -992,6 +1021,7 @@ public void testSetOwner() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetTimes() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "/heartbeatTs"); @@ -1035,6 +1065,7 @@ public void testSetTimes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetOwnerIfOutputStreamIsNotClosed() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "myFile"); @@ -1050,6 +1081,7 @@ public void testSetOwnerIfOutputStreamIsNotClosed() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetOwnerCheckNonRecursiveness() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); @@ -1071,6 +1103,7 @@ public void testSetOwnerCheckNonRecursiveness() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOpenCheckParametersPathIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1080,6 +1113,7 @@ public void testOpenCheckParametersPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOpenNoSuchPath() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "someFile"); @@ -1092,6 +1126,7 @@ public void testOpenNoSuchPath() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOpenIfPathIsAlreadyOpened() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); @@ -1108,6 +1143,7 @@ public void testOpenIfPathIsAlreadyOpened() throws Exception { } /** @throws Exception If failed. */ + @Test public void testOpen() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); @@ -1130,6 +1166,7 @@ public void testOpen() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAppendCheckParametersPathIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1139,6 +1176,7 @@ public void testAppendCheckParametersPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAppendIfPathPointsToDirectory() throws Exception { final Path fsHome = new Path(primaryFsUri); final Path dir = new Path(fsHome, "/tmp"); @@ -1156,6 +1194,7 @@ public void testAppendIfPathPointsToDirectory() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAppendIfFileIsAlreadyBeingOpenedToWrite() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "someFile"); @@ -1176,6 +1215,7 @@ public void testAppendIfFileIsAlreadyBeingOpenedToWrite() throws Exception { } /** @throws Exception If failed. */ + @Test public void testAppend() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); @@ -1205,6 +1245,7 @@ public void testAppend() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameCheckParametersSrcPathIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "someFile"); @@ -1217,6 +1258,7 @@ public void testRenameCheckParametersSrcPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameCheckParametersDstPathIsNull() throws Exception { Path fsHome = new Path(primaryFsUri); final Path file = new Path(fsHome, "someFile"); @@ -1230,6 +1272,7 @@ public Object call() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameIfSrcPathDoesNotExist() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcFile = new Path(fsHome, "srcFile"); @@ -1243,6 +1286,7 @@ public void testRenameIfSrcPathDoesNotExist() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameIfSrcPathIsAlreadyBeingOpenedToWrite() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcFile = new Path(fsHome, "srcFile"); @@ -1277,6 +1321,7 @@ public void testRenameIfSrcPathIsAlreadyBeingOpenedToWrite() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameFileIfDstPathExists() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcFile = new Path(fsHome, "srcFile"); @@ -1297,6 +1342,7 @@ public void testRenameFileIfDstPathExists() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameFile() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcFile = new Path(fsHome, "/tmp/srcFile"); @@ -1313,6 +1359,7 @@ public void testRenameFile() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameIfSrcPathIsAlreadyBeingOpenedToRead() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcFile = new Path(fsHome, "srcFile"); @@ -1345,6 +1392,7 @@ public void testRenameIfSrcPathIsAlreadyBeingOpenedToRead() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameDirectoryIfDstPathExists() throws Exception { Path fsHome = new Path(primaryFsUri); Path srcDir = new Path(fsHome, "/tmp/"); @@ -1366,6 +1414,7 @@ public void testRenameDirectoryIfDstPathExists() throws Exception { } /** @throws Exception If failed. */ + @Test public void testRenameDirectory() throws Exception { Path fsHome = new Path(primaryFsUri); Path dir = new Path(fsHome, "/tmp/"); @@ -1382,6 +1431,7 @@ public void testRenameDirectory() throws Exception { } /** @throws Exception If failed. */ + @Test public void testListStatusIfPathIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1391,6 +1441,7 @@ public void testListStatusIfPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testListStatusIfPathDoesNotExist() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1404,6 +1455,7 @@ public void testListStatusIfPathDoesNotExist() throws Exception { * * @throws Exception If failed. */ + @Test public void testListStatus() throws Exception { Path igfsHome = new Path(PRIMARY_URI); @@ -1446,6 +1498,7 @@ public void testListStatus() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetWorkingDirectoryIfPathIsNull() throws Exception { fs.setWorkingDirectory(null); @@ -1460,12 +1513,14 @@ public void testSetWorkingDirectoryIfPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testSetWorkingDirectoryIfPathDoesNotExist() throws Exception { // Should not throw any exceptions. fs.setWorkingDirectory(new Path("/someDir")); } /** @throws Exception If failed. */ + @Test public void testSetWorkingDirectory() throws Exception { Path dir = new Path("/tmp/nested/dir"); Path file = new Path("file"); @@ -1483,6 +1538,7 @@ public void testSetWorkingDirectory() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetWorkingDirectoryIfDefault() throws Exception { String path = fs.getWorkingDirectory().toString(); @@ -1490,6 +1546,7 @@ public void testGetWorkingDirectoryIfDefault() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetWorkingDirectory() throws Exception { Path dir = new Path("/tmp/some/dir"); @@ -1503,6 +1560,7 @@ public void testGetWorkingDirectory() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMkdirsIfPathIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1512,6 +1570,7 @@ public void testMkdirsIfPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testMkdirsIfPermissionIsNull() throws Exception { Path dir = new Path("/tmp"); @@ -1522,6 +1581,7 @@ public void testMkdirsIfPermissionIsNull() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("OctalInteger") + @Test public void testMkdirs() throws Exception { Path fsHome = new Path(PRIMARY_URI); final Path dir = new Path(fsHome, "/tmp/staging"); @@ -1541,6 +1601,7 @@ public void testMkdirs() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetFileStatusIfPathIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1550,6 +1611,7 @@ public void testGetFileStatusIfPathIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetFileStatusIfPathDoesNotExist() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1559,6 +1621,7 @@ public void testGetFileStatusIfPathDoesNotExist() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetFileBlockLocationsIfFileStatusIsNull() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -1569,6 +1632,7 @@ public void testGetFileBlockLocationsIfFileStatusIsNull() throws Exception { } /** @throws Exception If failed. */ + @Test public void testGetFileBlockLocationsIfFileStatusReferenceNotExistingPath() throws Exception { Path path = new Path("someFile"); @@ -1584,6 +1648,7 @@ public void testGetFileBlockLocationsIfFileStatusReferenceNotExistingPath() thro } /** @throws Exception If failed. */ + @Test public void testGetFileBlockLocations() throws Exception { Path igfsHome = new Path(PRIMARY_URI); @@ -1622,11 +1687,13 @@ public void testGetFileBlockLocations() throws Exception { /** @throws Exception If failed. */ @SuppressWarnings("deprecation") + @Test public void testGetDefaultBlockSize() throws Exception { assertEquals(1L << 26, fs.getDefaultBlockSize()); } /** @throws Exception If failed. */ + @Test public void testZeroReplicationFactor() throws Exception { // This test doesn't make sense for any mode except of PRIMARY. if (mode == PRIMARY) { @@ -1661,6 +1728,7 @@ public void testZeroReplicationFactor() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultithreadedCreate() throws Exception { Path dir = new Path(new Path(PRIMARY_URI), "/dir"); @@ -1745,6 +1813,7 @@ public void run() { * * @throws Exception If failed. */ + @Test public void testMultithreadedAppend() throws Exception { Path dir = new Path(new Path(PRIMARY_URI), "/dir"); @@ -1829,6 +1898,7 @@ public void testMultithreadedAppend() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultithreadedOpen() throws Exception { final byte[] dataChunk = new byte[256]; @@ -1900,6 +1970,7 @@ public void run() { * * @throws Exception If failed. */ + @Test public void testMultithreadedMkdirs() throws Exception { final Path dir = new Path(new Path(PRIMARY_URI), "/dir"); @@ -1979,6 +2050,7 @@ public void testMultithreadedMkdirs() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("TooBroadScope") + @Test public void testMultithreadedDelete() throws Exception { final Path dir = new Path(new Path(PRIMARY_URI), "/dir"); @@ -2052,6 +2124,7 @@ public void testMultithreadedDelete() throws Exception { } /** @throws Exception If failed. */ + @Test public void testConsistency() throws Exception { // Default buffers values checkConsistency(-1, 1, -1, -1, 1, -1); @@ -2077,6 +2150,7 @@ public void testConsistency() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testClientReconnect() throws Exception { Path filePath = new Path(PRIMARY_URI, "file1"); @@ -2111,6 +2185,7 @@ public void testClientReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testModeResolver() throws Exception { IgfsModeResolver mr = ((IgniteHadoopFileSystem)fs).getModeResolver(); @@ -2122,6 +2197,7 @@ public void testModeResolver() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testClientReconnectMultithreaded() throws Exception { final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); @@ -2500,4 +2576,4 @@ protected Configuration configurationSecondary(String authority) { return cfg; } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedAbstractSelfTest.java index 8198cd3243b7b..eb743476d5ef9 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedAbstractSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedAbstractSelfTest.java @@ -31,10 +31,14 @@ import org.apache.ignite.igfs.IgfsMode; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * IGFS Hadoop file system Ignite client -based self test. */ +@RunWith(JUnit4.class) public abstract class IgniteHadoopFileSystemClientBasedAbstractSelfTest extends IgniteHadoopFileSystemAbstractSelfTest { /** Alive node index. */ private static final int ALIVE_NODE_IDX = GRID_COUNT - 1; @@ -88,6 +92,7 @@ public abstract class IgniteHadoopFileSystemClientBasedAbstractSelfTest extends } /** {@inheritDoc} */ + @Test @Override public void testClientReconnect() throws Exception { Path filePath = new Path(PRIMARY_URI, "file1"); @@ -115,6 +120,7 @@ public abstract class IgniteHadoopFileSystemClientBasedAbstractSelfTest extends * * @throws Exception If error occurs. */ + @Test @Override public void testClientReconnectMultithreaded() throws Exception { final ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); @@ -190,4 +196,4 @@ private void startAllNodesExcept(int nodeIdx) throws Exception { if (i != nodeIdx) startGrid(i); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedOpenTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedOpenTest.java index 932f4d81dfb22..f41884edfba02 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedOpenTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientBasedOpenTest.java @@ -33,10 +33,14 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * IGFS Hadoop file system Ignite client -based self test for PROXY mode. */ +@RunWith(JUnit4.class) public class IgniteHadoopFileSystemClientBasedOpenTest extends GridCommonAbstractTest { /** Config root path. */ private static final String [] CONFIGS = { @@ -165,6 +169,7 @@ private static String authority(int idx) { /** * @throws Exception If failed. */ + @Test public void testFsOpenMultithreaded() throws Exception { skipInProc = false; @@ -176,7 +181,7 @@ public void testFsOpenMultithreaded() throws Exception { */ private void checkFsOpenWithAllNodesTypes() throws Exception { for (int i = 0; i < nodesTypes.length; ++i) { - log.info("Begin test case for nodes: " + S.arrayToString(nodesTypes[i])); + log.info("Begin test case for nodes: " + S.arrayToString(NodeType.class, nodesTypes[i])); startNodes(nodesTypes[i]); @@ -194,6 +199,7 @@ private void checkFsOpenWithAllNodesTypes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFsOpenMultithreadedSkipInProc() throws Exception { skipInProc = true; @@ -203,6 +209,7 @@ public void testFsOpenMultithreadedSkipInProc() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteClientWithIgfsMisconfigure() throws Exception { startNodes(new NodeType[] {NodeType.REMOTE, NodeType.REMOTE, NodeType.REMOTE}); diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientSelfTest.java index 93f1d05ffb6db..5ee95b0726ab8 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemClientSelfTest.java @@ -45,6 +45,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -55,6 +58,7 @@ /** * Test interaction between a IGFS client and a IGFS server. */ +@RunWith(JUnit4.class) public class IgniteHadoopFileSystemClientSelfTest extends IgfsCommonAbstractTest { /** Logger. */ private static final Log LOG = LogFactory.getLog(IgniteHadoopFileSystemClientSelfTest.class); @@ -139,7 +143,7 @@ protected CacheConfiguration metaCacheConfiguration() { * * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testOutputStreamDeferredException() throws Exception { final byte[] data = "test".getBytes(); @@ -182,7 +186,6 @@ public void testOutputStreamDeferredException() throws Exception { * @param flag Flag state. * @throws Exception If failed. */ - @SuppressWarnings("ConstantConditions") private void switchHandlerErrorFlag(boolean flag) throws Exception { IgfsProcessorAdapter igfsProc = ((IgniteKernal)grid(0)).context().igfs(); diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java index 02c708bfaafb5..42a1235ca63df 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java @@ -40,6 +40,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -54,6 +57,7 @@ /** * Tests for IGFS file system handshake. */ +@RunWith(JUnit4.class) public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractTest { /** IP finder. */ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); @@ -83,6 +87,7 @@ public class IgniteHadoopFileSystemHandshakeSelfTest extends IgfsCommonAbstractT * * @throws Exception If failed. */ + @Test public void testHandshake() throws Exception { startUp(false, false); @@ -111,6 +116,7 @@ public void testHandshake() throws Exception { * * @throws Exception If failed. */ + @Test public void testHandshakeDefaultGrid() throws Exception { startUp(true, false); @@ -280,4 +286,4 @@ private static Configuration configuration(String authority, boolean tcp) { return cfg; } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemIpcCacheSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemIpcCacheSelfTest.java index e9de332511638..a40896438b0e4 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemIpcCacheSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemIpcCacheSelfTest.java @@ -35,9 +35,9 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -49,10 +49,8 @@ /** * IPC cache test. */ +@RunWith(JUnit4.class) public class IgniteHadoopFileSystemIpcCacheSelfTest extends IgfsCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Path to test hadoop configuration. */ private static final String HADOOP_FS_CFG = "modules/core/src/test/config/hadoop/core-site.xml"; @@ -66,11 +64,6 @@ public class IgniteHadoopFileSystemIpcCacheSelfTest extends IgfsCommonAbstractTe @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setName("igfs"); @@ -155,6 +148,7 @@ private CacheConfiguration metaCacheConfiguration() { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testIpcCache() throws Exception { Field cacheField = HadoopIgfsIpcIo.class.getDeclaredField("ipcCache"); @@ -221,4 +215,4 @@ public void testIpcCache() throws Exception { assert (Boolean)stopField.get(io); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemLoggerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemLoggerSelfTest.java index 6de033f274419..22c66b14859db 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemLoggerSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemLoggerSelfTest.java @@ -30,6 +30,9 @@ import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.igfs.common.IgfsLogger.DELIM_FIELD; import static org.apache.ignite.internal.igfs.common.IgfsLogger.DELIM_FIELD_VAL; @@ -51,6 +54,7 @@ /** * Grid IGFS client logger test. */ +@RunWith(JUnit4.class) public class IgniteHadoopFileSystemLoggerSelfTest extends IgfsCommonAbstractTest { /** Path string. */ private static final String PATH_STR = "/dir1/dir2/file;test"; @@ -107,6 +111,7 @@ private void removeLogs() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateDelete() throws Exception { IgfsLogger log = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10); @@ -162,6 +167,7 @@ public void testCreateDelete() throws Exception { * * @throws Exception If failed. */ + @Test public void testLogRead() throws Exception { IgfsLogger log = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10); @@ -192,6 +198,7 @@ public void testLogRead() throws Exception { * * @throws Exception If failed. */ + @Test public void testLogWrite() throws Exception { IgfsLogger log = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10); @@ -217,6 +224,7 @@ public void testLogWrite() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("TooBroadScope") + @Test public void testLogMisc() throws Exception { IgfsLogger log = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10); @@ -296,4 +304,4 @@ private String d(int cnt) { return buf.toString(); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemLoggerStateSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemLoggerStateSelfTest.java index 9eeff33f3f2af..1eadea1b75afe 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemLoggerStateSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemLoggerStateSelfTest.java @@ -38,6 +38,9 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -49,6 +52,7 @@ /** * Ensures that sampling is really turned on/off. */ +@RunWith(JUnit4.class) public class IgniteHadoopFileSystemLoggerStateSelfTest extends IgfsCommonAbstractTest { /** IGFS. */ private IgfsEx igfs; @@ -142,6 +146,7 @@ private void startUp() throws Exception { * * @throws Exception If failed. */ + @Test public void testLoggingDisabledSamplingNotSet() throws Exception { startUp(); @@ -153,6 +158,7 @@ public void testLoggingDisabledSamplingNotSet() throws Exception { * * @throws Exception If failed. */ + @Test public void testLoggingEnabledSamplingNotSet() throws Exception { logging = true; @@ -166,6 +172,7 @@ public void testLoggingEnabledSamplingNotSet() throws Exception { * * @throws Exception If failed. */ + @Test public void testLoggingDisabledSamplingDisabled() throws Exception { sampling = false; @@ -179,6 +186,7 @@ public void testLoggingDisabledSamplingDisabled() throws Exception { * * @throws Exception If failed. */ + @Test public void testLoggingEnabledSamplingDisabled() throws Exception { logging = true; sampling = false; @@ -193,6 +201,7 @@ public void testLoggingEnabledSamplingDisabled() throws Exception { * * @throws Exception If failed. */ + @Test public void testLoggingDisabledSamplingEnabled() throws Exception { sampling = true; @@ -206,6 +215,7 @@ public void testLoggingDisabledSamplingEnabled() throws Exception { * * @throws Exception If failed. */ + @Test public void testLoggingEnabledSamplingEnabled() throws Exception { logging = true; sampling = true; @@ -220,6 +230,7 @@ public void testLoggingEnabledSamplingEnabled() throws Exception { * * @throws Exception If failed. */ + @Test public void testSamplingChange() throws Exception { // Start with sampling not set. startUp(); @@ -286,6 +297,7 @@ public void testSamplingChange() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testLogDirectory() throws Exception { startUp(); @@ -329,4 +341,4 @@ private boolean logEnabled() throws Exception { return ((IgfsLogger)field.get(fs)).isLogEnabled(); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemShmemAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemShmemAbstractSelfTest.java index b5cf7beef80a7..6850e720cbf8c 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemShmemAbstractSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemShmemAbstractSelfTest.java @@ -28,12 +28,16 @@ import org.apache.ignite.internal.util.ipc.IpcEndpointFactory; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryServerEndpoint.DFLT_IPC_PORT; /** * IGFS Hadoop file system IPC self test. */ +@RunWith(JUnit4.class) public abstract class IgniteHadoopFileSystemShmemAbstractSelfTest extends IgniteHadoopFileSystemAbstractSelfTest { /** * Constructor. @@ -61,7 +65,7 @@ protected IgniteHadoopFileSystemShmemAbstractSelfTest(IgfsMode mode, boolean ski * * @throws Exception If error occurred. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testOutOfResources() throws Exception { final Collection eps = new LinkedList<>(); @@ -91,4 +95,4 @@ public void testOutOfResources() throws Exception { ep.close(); } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemShmemExternalToClientAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemShmemExternalToClientAbstractSelfTest.java index fa64ed7fe56e7..24bab6b2817ac 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemShmemExternalToClientAbstractSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/IgniteHadoopFileSystemShmemExternalToClientAbstractSelfTest.java @@ -29,12 +29,16 @@ import org.apache.ignite.internal.util.ipc.IpcEndpointFactory; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.util.ipc.shmem.IpcSharedMemoryServerEndpoint.DFLT_IPC_PORT; /** * IGFS Hadoop file system IPC self test. */ +@RunWith(JUnit4.class) public abstract class IgniteHadoopFileSystemShmemExternalToClientAbstractSelfTest extends IgniteHadoopFileSystemAbstractSelfTest { /** @@ -73,7 +77,7 @@ protected IgniteHadoopFileSystemShmemExternalToClientAbstractSelfTest(IgfsMode m * * @throws Exception If error occurred. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testOutOfResources() throws Exception { final Collection eps = new LinkedList<>(); @@ -103,4 +107,4 @@ public void testOutOfResources() throws Exception { ep.close(); } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java index 7862d6eff3595..82cf90e63a4c2 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java @@ -43,12 +43,17 @@ import org.apache.ignite.internal.util.io.GridUnsafeDataInput; import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory; import org.apache.ignite.internal.util.typedef.X; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class HadoopConcurrentHashMultimapSelftest extends HadoopAbstractMapTest { /** */ + @Test public void testMapSimple() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(0); @@ -185,6 +190,7 @@ private void read(long ptr, int size, Writable w) { /** * @throws Exception if failed. */ + @Test public void testMultiThreaded() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(0); @@ -277,4 +283,4 @@ public void testMultiThreaded() throws Exception { assertEquals(0, mem.allocatedSize()); } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopHashMapSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopHashMapSelfTest.java index 195bcbbfcb752..9adb4961a925c 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopHashMapSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopHashMapSelfTest.java @@ -33,16 +33,21 @@ import java.util.Iterator; import java.util.Map; import java.util.Random; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class HadoopHashMapSelfTest extends HadoopAbstractMapTest { /** * Test simple map. * * @throws Exception If failed. */ + @Test public void testMapSimple() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(0); @@ -130,4 +135,4 @@ private GridLongList sorted(Collection col) { return lst.sort(); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopSkipListSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopSkipListSelfTest.java index 21575c545bdb4..720a18782d139 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopSkipListSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/collections/HadoopSkipListSelfTest.java @@ -43,14 +43,19 @@ import org.apache.ignite.internal.util.io.GridUnsafeDataInput; import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory; import org.apache.ignite.internal.util.typedef.X; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Skip list tests. */ +@RunWith(JUnit4.class) public class HadoopSkipListSelfTest extends HadoopAbstractMapTest { /** * @throws Exception On error. */ + @Test public void testMapSimple() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(0); @@ -200,6 +205,7 @@ private void read(long ptr, int size, Writable w) { /** * @throws Exception if failed. */ + @Test public void testMultiThreaded() throws Exception { GridUnsafeMemory mem = new GridUnsafeMemory(0); @@ -292,4 +298,4 @@ public void testMultiThreaded() throws Exception { assertEquals(0, mem.allocatedSize()); } } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/streams/HadoopDataStreamSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/streams/HadoopDataStreamSelfTest.java index c7d4dce0fdec1..eb011ef3ef8d5 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/streams/HadoopDataStreamSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/shuffle/streams/HadoopDataStreamSelfTest.java @@ -34,16 +34,21 @@ import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class HadoopDataStreamSelfTest extends GridCommonAbstractTest { private static final int BUFF_SIZE = 4 * 1024; /** * @throws IOException If failed. */ + @Test public void testStreams() throws IOException { GridUnsafeMemory mem = new GridUnsafeMemory(0); @@ -65,6 +70,7 @@ public void testStreams() throws IOException { /** * @throws IOException If failed. */ + @Test public void testDirectStreams() throws IOException { HadoopDirectDataOutput out = new HadoopDirectDataOutput(BUFF_SIZE); @@ -80,6 +86,7 @@ public void testDirectStreams() throws IOException { /** * @throws IOException If failed. */ + @Test public void testReadline() throws IOException { checkReadLine("String1\rString2\r\nString3\nString4"); checkReadLine("String1\rString2\r\nString3\nString4\r\n"); @@ -295,4 +302,4 @@ private void checkRead(DataInput in) throws IOException { assertEquals("mom washes rum", in.readUTF()); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/HadoopExecutorServiceTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/HadoopExecutorServiceTest.java index cc6cbb36f20b0..c1b7b99783232 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/HadoopExecutorServiceTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/HadoopExecutorServiceTest.java @@ -23,14 +23,19 @@ import java.util.concurrent.Callable; import java.util.concurrent.atomic.LongAdder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class HadoopExecutorServiceTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testExecutesAll() throws Exception { final HadoopExecutorService exec = new HadoopExecutorService(log, "_GRID_NAME_", 10, 5); @@ -69,4 +74,4 @@ public void testExecutesAll() throws Exception { assertTrue(exec.shutdown(0)); } -} \ No newline at end of file +} diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/HadoopExternalTaskExecutionSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/HadoopExternalTaskExecutionSelfTest.java index 12460787702df..84fb7fc16c5ca 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/HadoopExternalTaskExecutionSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/taskexecutor/external/HadoopExternalTaskExecutionSelfTest.java @@ -41,12 +41,16 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobId; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.marshaller.jdk.JdkMarshaller; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils.createJobInfo; /** * Job tracker self test. */ +@RunWith(JUnit4.class) public class HadoopExternalTaskExecutionSelfTest extends HadoopAbstractSelfTest { /** {@inheritDoc} */ @Override protected boolean igfsEnabled() { @@ -89,6 +93,7 @@ public class HadoopExternalTaskExecutionSelfTest extends HadoopAbstractSelfTest /** * @throws Exception If failed. */ + @Test public void testSimpleTaskSubmit() throws Exception { String testInputFile = "/test"; @@ -125,6 +130,7 @@ public void testSimpleTaskSubmit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMapperException() throws Exception { String testInputFile = "/test"; @@ -231,4 +237,4 @@ private static class TestReducer extends Reducer()); } @@ -83,6 +89,7 @@ private void checkNullOrEmptyMappings(@Nullable Map map) throws * * @throws Exception If failed. */ + @Test public void testMappings() throws Exception { Map map = new HashMap<>(); diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/util/ChainedUserNameMapperSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/util/ChainedUserNameMapperSelfTest.java index a9d295f861d6e..a839654a1a493 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/util/ChainedUserNameMapperSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/util/ChainedUserNameMapperSelfTest.java @@ -28,10 +28,14 @@ import java.util.Collections; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for chained user name mapper. */ +@RunWith(JUnit4.class) public class ChainedUserNameMapperSelfTest extends GridCommonAbstractTest { /** Test instance. */ private static final String INSTANCE = "test_instance"; @@ -44,7 +48,7 @@ public class ChainedUserNameMapperSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testNullMappers() throws Exception { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -60,7 +64,7 @@ public void testNullMappers() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testNullMapperElement() throws Exception { GridTestUtils.assertThrows(null, new Callable() { @Override public Void call() throws Exception { @@ -76,6 +80,7 @@ public void testNullMapperElement() throws Exception { * * @throws Exception If failed. */ + @Test public void testChaining() throws Exception { BasicUserNameMapper mapper1 = new BasicUserNameMapper(); diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/util/KerberosUserNameMapperSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/util/KerberosUserNameMapperSelfTest.java index bd76b51a1685b..a32245e5b0ba1 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/util/KerberosUserNameMapperSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/util/KerberosUserNameMapperSelfTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.internal.processors.igfs.IgfsUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for Kerberos name mapper. */ +@RunWith(JUnit4.class) public class KerberosUserNameMapperSelfTest extends GridCommonAbstractTest { /** Test instance. */ private static final String INSTANCE = "test_instance"; @@ -37,6 +41,7 @@ public class KerberosUserNameMapperSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testMapper() throws Exception { KerberosUserNameMapper mapper = create(null, null); @@ -49,6 +54,7 @@ public void testMapper() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapperInstance() throws Exception { KerberosUserNameMapper mapper = create(INSTANCE, null); @@ -61,6 +67,7 @@ public void testMapperInstance() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapperRealm() throws Exception { KerberosUserNameMapper mapper = create(null, REALM); @@ -73,6 +80,7 @@ public void testMapperRealm() throws Exception { * * @throws Exception If failed. */ + @Test public void testMapperInstanceAndRealm() throws Exception { KerberosUserNameMapper mapper = create(INSTANCE, REALM); diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java index 199fa9623bb4e..c4cebbf1dfffd 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; @@ -103,13 +104,16 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; import static org.apache.ignite.testframework.GridTestUtils.modeToPermissionSet; /** * Test suite for Hadoop Map Reduce engine. */ -public class IgniteHadoopTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteHadoopTestSuite { /** * @return Test suite. * @throws Exception Thrown in case of the failure. @@ -122,109 +126,109 @@ public static TestSuite suite() throws Exception { TestSuite suite = new TestSuite("Ignite Hadoop MR Test Suite"); - suite.addTest(new TestSuite(ldr.loadClass(HadoopUserLibsSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopUserLibsSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopWeightedMapReducePlannerTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopWeightedMapReducePlannerTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(BasicUserNameMapperSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(KerberosUserNameMapperSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(ChainedUserNameMapperSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(BasicUserNameMapperSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(KerberosUserNameMapperSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(ChainedUserNameMapperSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(KerberosHadoopFileSystemFactorySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(KerberosHadoopFileSystemFactorySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopTeraSortTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopTeraSortTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopSnappyTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopSnappyFullMapReduceTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopSnappyTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopSnappyFullMapReduceTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfs20FileSystemLoopbackPrimarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopIgfs20FileSystemLoopbackPrimarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfsDualSyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfsDualAsyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopIgfsDualSyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopIgfsDualAsyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(Hadoop1OverIgfsDualSyncTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(Hadoop1OverIgfsDualAsyncTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(Hadoop1OverIgfsProxyTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(Hadoop1OverIgfsDualSyncTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(Hadoop1OverIgfsDualAsyncTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(Hadoop1OverIgfsProxyTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopFIleSystemFactorySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopFIleSystemFactorySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalPrimarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalSecondarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalDualSyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalDualAsyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedPrimarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedSecondarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedDualSyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedDualAsyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemClientBasedPrimarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemClientBasedDualAsyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemClientBasedDualSyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemClientBasedProxySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalToClientPrimarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalToClientDualSyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalToClientDualAsyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalToClientProxySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalPrimarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalSecondarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalDualSyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalDualAsyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedPrimarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedSecondarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedDualSyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackEmbeddedDualAsyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemClientBasedPrimarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemClientBasedDualAsyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemClientBasedDualSyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemClientBasedProxySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalToClientPrimarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalToClientDualSyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalToClientDualAsyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoopbackExternalToClientProxySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemClientSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemClientSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoggerStateSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemLoggerSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoggerStateSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemLoggerSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemHandshakeSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemHandshakeSelfTest.class.getName()))); suite.addTest(IgfsEventsTestSuite.suiteNoarchOnly()); - suite.addTest(new TestSuite(ldr.loadClass(HadoopFileSystemsTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopFileSystemsTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopExecutorServiceTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopExecutorServiceTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopValidationSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopValidationSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopJobTrackerSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopJobTrackerSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopHashMapSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopDataStreamSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopConcurrentHashMultimapSelftest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopHashMapSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopDataStreamSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopConcurrentHashMultimapSelftest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopSkipListSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopSkipListSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopTaskExecutionSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopTaskExecutionSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopV2JobSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopV2JobSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopSerializationWrapperSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopSplitWrapperSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopSerializationWrapperSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopSplitWrapperSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopTasksV1Test.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopTasksV2Test.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopTasksV1Test.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopTasksV2Test.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopMapReduceTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopWeightedPlannerMapReduceTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopNoHadoopMapReduceTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopMapReduceErrorResilienceTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopMapReduceTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopWeightedPlannerMapReduceTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopNoHadoopMapReduceTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopMapReduceErrorResilienceTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopMapReduceEmbeddedSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopMapReduceEmbeddedSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopSortingTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopSortingTest.class.getName()))); // TODO https://issues.apache.org/jira/browse/IGNITE-3167 -// suite.addTest(new TestSuite(ldr.loadClass(HadoopExternalTaskExecutionSelfTest.class.getName()))); -// suite.addTest(new TestSuite(ldr.loadClass(HadoopExternalCommunicationSelfTest.class.getName()))); -// suite.addTest(new TestSuite(ldr.loadClass(HadoopSortingExternalTest.class.getName()))); +// suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopExternalTaskExecutionSelfTest.class.getName()))); +// suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopExternalCommunicationSelfTest.class.getName()))); +// suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopSortingExternalTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopGroupingTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopGroupingTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopClientProtocolSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopClientProtocolEmbeddedSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopClientProtocolMultipleServersSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopClientProtocolSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopClientProtocolEmbeddedSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopClientProtocolMultipleServersSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopCommandLineTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopCommandLineTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopSecondaryFileSystemConfigurationTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopSecondaryFileSystemConfigurationTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopTxConfigCacheTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopTxConfigCacheTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemClientBasedOpenTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemClientBasedOpenTest.class.getName()))); return suite; } diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteIgfsLinuxAndMacOSTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteIgfsLinuxAndMacOSTestSuite.java index 7d1b55dc788d3..ede1f181cb1cd 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteIgfsLinuxAndMacOSTestSuite.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteIgfsLinuxAndMacOSTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.hadoop.HadoopTestClassLoader; import org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfs20FileSystemShmemPrimarySelfTest; @@ -32,6 +33,8 @@ import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgniteHadoopFileSystemShmemExternalToClientPrimarySelfTest; import org.apache.ignite.internal.processors.hadoop.impl.igfs.IgniteHadoopFileSystemShmemExternalToClientProxySelfTest; import org.apache.ignite.internal.processors.igfs.IgfsServerManagerIpcEndpointRegistrationOnLinuxAndMacSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; import static org.apache.ignite.testsuites.IgniteHadoopTestSuite.downloadHadoop; @@ -39,7 +42,8 @@ * Test suite for Hadoop file system over Ignite cache. * Contains tests which works on Linux and Mac OS platform only. */ -public class IgniteIgfsLinuxAndMacOSTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteIgfsLinuxAndMacOSTestSuite { /** * @return Test suite. * @throws Exception Thrown in case of the failure. @@ -51,22 +55,22 @@ public static TestSuite suite() throws Exception { TestSuite suite = new TestSuite("Ignite IGFS Test Suite For Linux And Mac OS"); - suite.addTest(new TestSuite(ldr.loadClass(IgfsServerManagerIpcEndpointRegistrationOnLinuxAndMacSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgfsServerManagerIpcEndpointRegistrationOnLinuxAndMacSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemShmemExternalPrimarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemShmemExternalSecondarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemShmemExternalDualSyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemShmemExternalDualAsyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemShmemExternalToClientPrimarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemShmemExternalToClientDualAsyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemShmemExternalToClientDualSyncSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemShmemExternalToClientProxySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemShmemExternalPrimarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemShmemExternalSecondarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemShmemExternalDualSyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemShmemExternalDualAsyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemShmemExternalToClientPrimarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemShmemExternalToClientDualAsyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemShmemExternalToClientDualSyncSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemShmemExternalToClientProxySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgniteHadoopFileSystemIpcCacheSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgniteHadoopFileSystemIpcCacheSelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(HadoopIgfs20FileSystemShmemPrimarySelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(HadoopIgfs20FileSystemShmemPrimarySelfTest.class.getName()))); - suite.addTest(new TestSuite(ldr.loadClass(IgfsNearOnlyMultiNodeSelfTest.class.getName()))); + suite.addTest(new JUnit4TestAdapter(ldr.loadClass(IgfsNearOnlyMultiNodeSelfTest.class.getName()))); suite.addTest(IgfsEventsTestSuite.suite()); diff --git a/modules/hibernate-4.2/pom.xml b/modules/hibernate-4.2/pom.xml index 5a13c8724ec1f..49543126e6fc4 100644 --- a/modules/hibernate-4.2/pom.xml +++ b/modules/hibernate-4.2/pom.xml @@ -63,7 +63,7 @@ org.ow2.jotm jotm-core - 2.1.9 + ${jotm.version} test @@ -136,14 +136,14 @@ org.jboss.spec.javax.rmi jboss-rmi-api_1.0_spec - 1.0.6.Final + ${jboss.rmi.version} test javax.xml.bind jaxb-api - 2.1 + ${jaxb.api.version} test diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java index a28c5da31a257..eb09c59faa9ca 100644 --- a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java @@ -40,6 +40,9 @@ import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistryBuilder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -57,6 +60,7 @@ /** * Tests Hibernate L2 cache configuration. */ +@RunWith(JUnit4.class) public class HibernateL2CacheConfigurationSelfTest extends GridCommonAbstractTest { /** */ public static final String ENTITY1_NAME = Entity1.class.getName(); @@ -168,6 +172,7 @@ protected Configuration hibernateConfiguration(String igniteInstanceName) { /** * Tests property {@link HibernateAccessStrategyFactory#REGION_CACHE_PROPERTY}. */ + @Test public void testPerRegionCacheProperty() { testCacheUsage(1, 1, 0, 1, 1); } @@ -175,6 +180,7 @@ public void testPerRegionCacheProperty() { /** * Tests property {@link HibernateAccessStrategyFactory#DFLT_CACHE_NAME_PROPERTY}. */ + @Test public void testDefaultCache() { dfltCache = true; @@ -401,4 +407,4 @@ public void setId(int id) { this.id = id; } } -} \ No newline at end of file +} diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java index ed092aa248333..43c54b24abaa7 100644 --- a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java @@ -36,6 +36,9 @@ import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistryBuilder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY; @@ -46,6 +49,7 @@ /** * */ +@RunWith(JUnit4.class) public class HibernateL2CacheMultiJvmTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "hibernateCache"; @@ -89,6 +93,7 @@ public class HibernateL2CacheMultiJvmTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testL2Cache() throws Exception { Ignite srv = ignite(0); diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java index d69c61a10584d..3e60370def2f0 100644 --- a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java @@ -34,9 +34,6 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.hibernate.ObjectNotFoundException; @@ -55,6 +52,9 @@ import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.stat.NaturalIdCacheStatistics; import org.hibernate.stat.SecondLevelCacheStatistics; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -74,10 +74,8 @@ * * Tests Hibernate L2 cache. */ +@RunWith(JUnit4.class) public class HibernateL2CacheSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1"; @@ -411,12 +409,6 @@ public void setVersion(long ver) { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCacheConfiguration(generalRegionConfiguration("org.hibernate.cache.spi.UpdateTimestampsCache"), generalRegionConfiguration("org.hibernate.cache.internal.StandardQueryCache"), transactionalRegionConfiguration(ENTITY_NAME), @@ -535,6 +527,7 @@ protected AccessType[] accessTypes() { /** * @throws Exception If failed. */ + @Test public void testCollectionCache() throws Exception { for (AccessType accessType : accessTypes()) testCollectionCache(accessType); @@ -655,6 +648,7 @@ private void testCollectionCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntityCache() throws Exception { for (AccessType accessType : accessTypes()) testEntityCache(accessType); @@ -815,6 +809,7 @@ private void testEntityCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTwoEntitiesSameCache() throws Exception { for (AccessType accessType : accessTypes()) testTwoEntitiesSameCache(accessType); @@ -1018,6 +1013,7 @@ private void testTwoEntitiesSameCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersionedEntity() throws Exception { for (AccessType accessType : accessTypes()) testVersionedEntity(accessType); @@ -1128,6 +1124,7 @@ private void testVersionedEntity(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testNaturalIdCache() throws Exception { for (AccessType accessType : accessTypes()) testNaturalIdCache(accessType); @@ -1282,6 +1279,7 @@ private void testNaturalIdCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntityCacheTransactionFails() throws Exception { for (AccessType accessType : accessTypes()) testEntityCacheTransactionFails(accessType); @@ -1456,6 +1454,7 @@ private void testEntityCacheTransactionFails(AccessType accessType) throws Excep /** * @throws Exception If failed. */ + @Test public void testQueryCache() throws Exception { for (AccessType accessType : accessTypes()) testQueryCache(accessType); @@ -1620,6 +1619,7 @@ private void testQueryCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testRegionClear() throws Exception { for (AccessType accessType : accessTypes()) testRegionClear(accessType); @@ -1945,4 +1945,4 @@ static Map hibernateProperties(String igniteInstanceName, String return map; } -} \ No newline at end of file +} diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheStrategySelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheStrategySelfTest.java index 5e1fd32fb10b9..44d77011c2821 100644 --- a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheStrategySelfTest.java +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheStrategySelfTest.java @@ -36,6 +36,9 @@ import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistryBuilder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -55,6 +58,7 @@ * Tests Hibernate L2 cache configuration. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class HibernateL2CacheStrategySelfTest extends GridCommonAbstractTest { /** */ private static final String ENTITY1_NAME = Entity1.class.getName(); @@ -168,6 +172,7 @@ private Configuration hibernateConfiguration(AccessType accessType, String ignit /** * @throws Exception If failed. */ + @Test public void testEntityCacheReadWrite() throws Exception { for (AccessType accessType : new AccessType[]{AccessType.READ_WRITE, AccessType.NONSTRICT_READ_WRITE}) testEntityCacheReadWrite(accessType); @@ -589,4 +594,4 @@ private void cleanup() throws Exception { for (IgniteCacheProxy cache : ((IgniteKernal)grid(0)).caches()) cache.clear(); } -} \ No newline at end of file +} diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java index 77025a1ea294c..27e8b53f820a6 100644 --- a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java @@ -24,6 +24,8 @@ import org.hibernate.FlushMode; import org.hibernate.Session; import org.hibernate.Transaction; +import org.junit.Ignore; +import org.junit.Test; /** * Cache store test. @@ -100,6 +102,7 @@ public void testConfigurationByFile() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConfigurationByResource() throws Exception { store.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml"); @@ -107,7 +110,10 @@ public void testConfigurationByResource() throws Exception { store.load("key"); } + /** */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-1757") + @Test @Override public void testSimpleMultithreading() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-1757"); + // No-op. } } diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java index db0e1bebe8026..28fb05d87f53e 100644 --- a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java @@ -43,10 +43,15 @@ import org.hibernate.metadata.ClassMetadata; import org.hibernate.metadata.CollectionMetadata; import org.hibernate.stat.Statistics; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for Cache jdbc blob store factory. */ +@RunWith(JUnit4.class) public class CacheHibernateStoreFactorySelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "test"; @@ -57,6 +62,7 @@ public class CacheHibernateStoreFactorySelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCacheConfiguration() throws Exception { try (Ignite ignite1 = startGrid(0)) { IgniteCache cache1 = ignite1.getOrCreateCache(cacheConfiguration()); @@ -68,6 +74,7 @@ public void testCacheConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testXmlConfiguration() throws Exception { try (Ignite ignite = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache.xml")) { try(Ignite ignite1 = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache1.xml")) { @@ -82,8 +89,10 @@ public void testXmlConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-1094") + @Test public void testIncorrectBeanConfiguration() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-1094"); + fail("https://issues.apache.org/jira/browse/IGNITE-10723"); GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -287,4 +296,4 @@ public static class DummySessionFactory implements SessionFactory { return null; } } -} \ No newline at end of file +} diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java index 3791baed9c93c..84f2f7bf5c8df 100644 --- a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java @@ -20,16 +20,18 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.testframework.config.GridTestProperties; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgniteBinaryHibernateTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteBinaryHibernateTestSuite { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); return IgniteHibernateTestSuite.suite(); diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java index 8d45dea48d8e2..436203a797567 100644 --- a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest; import org.apache.ignite.cache.hibernate.HibernateL2CacheMultiJvmTest; @@ -28,33 +29,35 @@ import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreSelfTest; import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest; import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListenerSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Hibernate integration tests. */ -public class IgniteHibernateTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteHibernateTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Hibernate Integration Test Suite"); // Hibernate L2 cache. - suite.addTestSuite(HibernateL2CacheSelfTest.class); - suite.addTestSuite(HibernateL2CacheTransactionalSelfTest.class); - suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class); - suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class); - suite.addTestSuite(HibernateL2CacheStrategySelfTest.class); - suite.addTestSuite(HibernateL2CacheMultiJvmTest.class); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheTransactionalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheTransactionalUseSyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheConfigurationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheStrategySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheMultiJvmTest.class)); - suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheHibernateBlobStoreSelfTest.class)); - suite.addTestSuite(CacheHibernateBlobStoreNodeRestartTest.class); + suite.addTest(new JUnit4TestAdapter(CacheHibernateBlobStoreNodeRestartTest.class)); - suite.addTestSuite(CacheHibernateStoreSessionListenerSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheHibernateStoreSessionListenerSelfTest.class)); - suite.addTestSuite(CacheHibernateStoreFactorySelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheHibernateStoreFactorySelfTest.class)); return suite; } diff --git a/modules/hibernate-5.1/pom.xml b/modules/hibernate-5.1/pom.xml index 6528f7bfb5f6f..24c1d780c4be6 100644 --- a/modules/hibernate-5.1/pom.xml +++ b/modules/hibernate-5.1/pom.xml @@ -63,7 +63,7 @@ org.ow2.jotm jotm-core - 2.1.9 + ${jotm.version} test @@ -136,28 +136,28 @@ org.jboss.spec.javax.rmi jboss-rmi-api_1.0_spec - 1.0.6.Final + ${jboss.rmi.version} test javax.xml.bind jaxb-api - 2.1 + ${jaxb.api.version} test com.sun.xml.bind jaxb-core - 2.1.14 + ${jaxb.impl.version} test com.sun.xml.bind jaxb-impl - 2.1.14 + ${jaxb.impl.version} test diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java index 2268b06886518..f828d04c83753 100644 --- a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java +++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java @@ -40,6 +40,9 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cfg.Configuration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -55,6 +58,7 @@ /** * Tests Hibernate L2 cache configuration. */ +@RunWith(JUnit4.class) public class HibernateL2CacheConfigurationSelfTest extends GridCommonAbstractTest { /** */ public static final String ENTITY1_NAME = Entity1.class.getName(); @@ -165,6 +169,7 @@ protected Configuration hibernateConfiguration(String igniteInstanceName) { /** * Tests property {@link HibernateAccessStrategyFactory#REGION_CACHE_PROPERTY}. */ + @Test public void testPerRegionCacheProperty() { testCacheUsage(1, 1, 0, 1, 1); } @@ -172,6 +177,7 @@ public void testPerRegionCacheProperty() { /** * Tests property {@link HibernateAccessStrategyFactory#DFLT_CACHE_NAME_PROPERTY}. */ + @Test public void testDefaultCache() { dfltCache = true; @@ -399,4 +405,4 @@ public void setId(int id) { this.id = id; } } -} \ No newline at end of file +} diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java index 268ea8ccf04b2..b3da8bbfaf59d 100644 --- a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java +++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java @@ -36,6 +36,9 @@ import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY; @@ -46,6 +49,7 @@ /** * */ +@RunWith(JUnit4.class) public class HibernateL2CacheMultiJvmTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "hibernateCache"; @@ -89,6 +93,7 @@ public class HibernateL2CacheMultiJvmTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testL2Cache() throws Exception { Ignite srv = ignite(0); diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java index 798f73d43b057..b1b57f05e11c4 100644 --- a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java +++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java @@ -34,9 +34,6 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.hibernate.ObjectNotFoundException; @@ -60,6 +57,9 @@ import org.hibernate.mapping.RootClass; import org.hibernate.stat.NaturalIdCacheStatistics; import org.hibernate.stat.SecondLevelCacheStatistics; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -80,10 +80,8 @@ * * Tests Hibernate L2 cache. */ +@RunWith(JUnit4.class) public class HibernateL2CacheSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1"; @@ -420,12 +418,6 @@ public void setVersion(long ver) { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCacheConfiguration(generalRegionConfiguration("org.hibernate.cache.spi.UpdateTimestampsCache"), generalRegionConfiguration("org.hibernate.cache.internal.StandardQueryCache"), transactionalRegionConfiguration(ENTITY_NAME), @@ -515,6 +507,7 @@ protected AccessType[] accessTypes() { /** * @throws Exception If failed. */ + @Test public void testCollectionCache() throws Exception { for (AccessType accessType : accessTypes()) testCollectionCache(accessType); @@ -635,6 +628,7 @@ private void testCollectionCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntityCache() throws Exception { for (AccessType accessType : accessTypes()) testEntityCache(accessType); @@ -795,6 +789,7 @@ private void testEntityCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testTwoEntitiesSameCache() throws Exception { for (AccessType accessType : accessTypes()) testTwoEntitiesSameCache(accessType); @@ -998,6 +993,7 @@ private void testTwoEntitiesSameCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testVersionedEntity() throws Exception { for (AccessType accessType : accessTypes()) testVersionedEntity(accessType); @@ -1108,6 +1104,7 @@ private void testVersionedEntity(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testNaturalIdCache() throws Exception { for (AccessType accessType : accessTypes()) testNaturalIdCache(accessType); @@ -1262,6 +1259,7 @@ private void testNaturalIdCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testEntityCacheTransactionFails() throws Exception { for (AccessType accessType : accessTypes()) testEntityCacheTransactionFails(accessType); @@ -1436,6 +1434,7 @@ private void testEntityCacheTransactionFails(AccessType accessType) throws Excep /** * @throws Exception If failed. */ + @Test public void testQueryCache() throws Exception { for (AccessType accessType : accessTypes()) testQueryCache(accessType); @@ -1600,6 +1599,7 @@ private void testQueryCache(AccessType accessType) throws Exception { /** * @throws Exception If failed. */ + @Test public void testRegionClear() throws Exception { for (AccessType accessType : accessTypes()) testRegionClear(accessType); @@ -1951,4 +1951,4 @@ static Map hibernateProperties(String igniteInstanceName, String return map; } -} \ No newline at end of file +} diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheStrategySelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheStrategySelfTest.java index 8bd80da5c2ece..0efb815d68648 100644 --- a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheStrategySelfTest.java +++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheStrategySelfTest.java @@ -40,6 +40,9 @@ import org.hibernate.cache.spi.access.AccessType; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.RootClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -51,6 +54,7 @@ * Tests Hibernate L2 cache configuration. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class HibernateL2CacheStrategySelfTest extends GridCommonAbstractTest { /** */ private static final String ENTITY1_NAME = Entity1.class.getName(); @@ -120,6 +124,7 @@ private CacheConfiguration cacheConfiguration(String cacheName) { /** * @throws Exception If failed. */ + @Test public void testEntityCacheReadWrite() throws Exception { for (AccessType accessType : new AccessType[]{AccessType.READ_WRITE, AccessType.NONSTRICT_READ_WRITE}) testEntityCacheReadWrite(accessType); @@ -561,4 +566,4 @@ private void cleanup() throws Exception { for (IgniteCacheProxy cache : ((IgniteKernal)grid(0)).caches()) cache.clear(); } -} \ No newline at end of file +} diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java index c62db4ab619c2..37fd9f8250a89 100644 --- a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java +++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java @@ -25,10 +25,15 @@ import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.resource.transaction.spi.TransactionStatus; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Cache store test. */ +@RunWith(JUnit4.class) public class CacheHibernateBlobStoreSelfTest extends GridAbstractCacheStoreSelfTest> { /** @@ -69,6 +74,7 @@ public CacheHibernateBlobStoreSelfTest() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConfigurationByUrl() throws Exception { URL url = U.resolveIgniteUrl(CacheHibernateStoreFactorySelfTest.MODULE_PATH + "/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml"); @@ -84,6 +90,7 @@ public void testConfigurationByUrl() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConfigurationByFile() throws Exception { URL url = U.resolveIgniteUrl(CacheHibernateStoreFactorySelfTest.MODULE_PATH + "/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml"); @@ -101,6 +108,7 @@ public void testConfigurationByFile() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConfigurationByResource() throws Exception { store.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml"); @@ -108,7 +116,10 @@ public void testConfigurationByResource() throws Exception { store.load("key"); } + /** */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-1757") + @Test @Override public void testSimpleMultithreading() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-1757"); + // No-op. } } diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java index 0ffe52ef1176f..ee3d395e0b6d1 100644 --- a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java +++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java @@ -43,10 +43,15 @@ import org.hibernate.metadata.ClassMetadata; import org.hibernate.metadata.CollectionMetadata; import org.hibernate.stat.Statistics; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for Cache jdbc blob store factory. */ +@RunWith(JUnit4.class) public class CacheHibernateStoreFactorySelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "test"; @@ -57,6 +62,7 @@ public class CacheHibernateStoreFactorySelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCacheConfiguration() throws Exception { try (Ignite ignite1 = startGrid(0)) { IgniteCache cache1 = ignite1.getOrCreateCache(cacheConfiguration()); @@ -68,6 +74,7 @@ public void testCacheConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testXmlConfiguration() throws Exception { try (Ignite ignite = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache.xml")) { try(Ignite ignite1 = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache1.xml")) { @@ -82,8 +89,10 @@ public void testXmlConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-1094") + @Test public void testIncorrectBeanConfiguration() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-1094"); + fail("https://issues.apache.org/jira/browse/IGNITE-10723"); GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -255,4 +264,4 @@ public static class DummySessionFactory implements SessionFactory { return null; } } -} \ No newline at end of file +} diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java index d5395111e84b4..40ee896a848f0 100644 --- a/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java +++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java @@ -20,16 +20,18 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.testframework.config.GridTestProperties; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgniteBinaryHibernate5TestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteBinaryHibernate5TestSuite { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); return IgniteHibernate5TestSuite.suite(); diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java index b5715997eaaed..f87e676bf681c 100644 --- a/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java +++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest; import org.apache.ignite.cache.hibernate.HibernateL2CacheMultiJvmTest; @@ -28,33 +29,35 @@ import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreSelfTest; import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest; import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListenerSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Hibernate integration tests. */ -public class IgniteHibernate5TestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteHibernate5TestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Hibernate5 Integration Test Suite"); // Hibernate L2 cache. - suite.addTestSuite(HibernateL2CacheSelfTest.class); - suite.addTestSuite(HibernateL2CacheTransactionalSelfTest.class); - suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class); - suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class); - suite.addTestSuite(HibernateL2CacheStrategySelfTest.class); - suite.addTestSuite(HibernateL2CacheMultiJvmTest.class); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheTransactionalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheTransactionalUseSyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheConfigurationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheStrategySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheMultiJvmTest.class)); - suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheHibernateBlobStoreSelfTest.class)); - suite.addTestSuite(CacheHibernateBlobStoreNodeRestartTest.class); + suite.addTest(new JUnit4TestAdapter(CacheHibernateBlobStoreNodeRestartTest.class)); - suite.addTestSuite(CacheHibernateStoreSessionListenerSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheHibernateStoreSessionListenerSelfTest.class)); - suite.addTestSuite(CacheHibernateStoreFactorySelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheHibernateStoreFactorySelfTest.class)); return suite; } diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java index fdb87f0c20201..d4efb5fd697c9 100644 --- a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java +++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java @@ -39,7 +39,6 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryPredicate; import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; import org.apache.ignite.lang.IgniteBiPredicate; @@ -124,10 +123,9 @@ public HibernateKeyTransformer keyTransformer(){ /** {@inheritDoc} */ @Nullable @Override public Object localPeek( Object key, - CachePeekMode[] peekModes, - @Nullable IgniteCacheExpiryPolicy plc + CachePeekMode[] peekModes ) throws IgniteCheckedException { - return delegate.localPeek(keyTransformer.transform(key), peekModes, plc); + return delegate.localPeek(keyTransformer.transform(key), peekModes); } /** {@inheritDoc} */ @@ -647,6 +645,21 @@ public HibernateKeyTransformer keyTransformer(){ return delegate.lostPartitions(); } + /** {@inheritDoc} */ + @Override public void preloadPartition(int part) throws IgniteCheckedException { + delegate.preloadPartition(part); + } + + /** {@inheritDoc} */ + @Override public IgniteInternalFuture preloadPartitionAsync(int part) throws IgniteCheckedException { + return delegate.preloadPartitionAsync(part); + } + + /** {@inheritDoc} */ + @Override public boolean localPreloadPartition(int part) throws IgniteCheckedException { + return delegate.localPreloadPartition(part); + } + /** {@inheritDoc} */ @Nullable @Override public EntryProcessorResult invoke( @Nullable AffinityTopologyVersion topVer, diff --git a/modules/ignored-tests/pom.xml b/modules/ignored-tests/pom.xml index b0b4972b34e80..342d50b239078 100644 --- a/modules/ignored-tests/pom.xml +++ b/modules/ignored-tests/pom.xml @@ -227,7 +227,7 @@ org.ow2.jotm jotm-core - 2.1.9 + ${jotm.version} test diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryTable.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryTable.java index 54f5f03f556b1..ca6343c9c7e4d 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryTable.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryTable.java @@ -93,6 +93,7 @@ public String table() { return false; writer.incrementState(); + } return true; @@ -121,6 +122,7 @@ public String table() { return false; reader.incrementState(); + } return reader.afterMessageRead(QueryTable.class); diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java index 31715f1927b57..6ce0c4f5a9aa7 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java @@ -42,6 +42,7 @@ import org.apache.ignite.cache.query.BulkLoadContextCursor; import org.apache.ignite.cache.query.FieldsQueryCursor; import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -87,6 +88,7 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteInClosure; +import org.apache.ignite.lang.IgniteProductVersion; import org.apache.ignite.spi.indexing.IndexingQueryFilter; import org.h2.command.Prepared; import org.h2.command.dml.Delete; @@ -111,6 +113,10 @@ public class DmlStatementsProcessor { /** Default number of attempts to re-run DELETE and UPDATE queries in case of concurrent modifications of values. */ private static final int DFLT_DML_RERUN_ATTEMPTS = 4; + /** The version which changed the anonymous class position of REMOVE closure. */ + private static final IgniteProductVersion RMV_ANON_CLS_POS_CHANGED_SINCE = + IgniteProductVersion.fromString("2.7.0"); + /** Indexing. */ private IgniteH2Indexing idx; @@ -787,7 +793,13 @@ private UpdateResult doDelete(GridCacheContext cctx, Iterable> cursor, i continue; } - sender.add(row.get(0), new ModifyingEntryProcessor(row.get(1), RMV), 0); + Object key = row.get(0); + + ClusterNode node = sender.primaryNodeByKey(key); + + IgniteInClosure> rmvC = getRemoveClosure(node, key); + + sender.add(key, new ModifyingEntryProcessor(row.get(1), rmvC), 0); } sender.flush(); @@ -1097,6 +1109,41 @@ UpdateResult mapDistributedUpdate(String schemaName, PreparedStatement stmt, Sql return updateSqlFields(schemaName, c, GridSqlQueryParser.prepared(stmt), fldsQry, local, filter, cancel); } + /** Remove updater for compatibility with < 2.7.0. Must not be moved around to keep at anonymous position 4. */ + private static final IgniteInClosure> RMV_OLD = + new IgniteInClosure>() { + @Override public void apply(MutableEntry e) { + e.remove(); + } + }; + + /** Remove updater. Must not be moved around to keep at anonymous position 5. */ + private static final IgniteInClosure> RMV = + new IgniteInClosure>() { + @Override public void apply(MutableEntry e) { + e.remove(); + } + }; + + /** + * Returns the remove closure based on the version of the primary node. + * + * @param node Primary node. + * @param key Key. + * @return Remove closure. + */ + protected static IgniteInClosure> getRemoveClosure(ClusterNode node, Object key) { + assert node != null; + assert key != null; + + IgniteInClosure> rmvC = RMV; + + if (node.version().compareTo(RMV_ANON_CLS_POS_CHANGED_SINCE) < 0) + rmvC = RMV_OLD; + + return rmvC; + } + /** * @param schema Schema name. * @param conn Connection. @@ -1301,14 +1348,6 @@ private ModifyingEntryProcessor(Object val, IgniteInClosure> RMV = new IgniteInClosure>() { - /** {@inheritDoc} */ - @Override public void apply(MutableEntry e) { - e.remove(); - } - }; - /** * */ diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java index 5adb6f16f2204..4ad3d3e48347b 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java @@ -61,10 +61,12 @@ import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.GridTopic; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.CacheEntryImpl; import org.apache.ignite.internal.processors.cache.CacheObjectUtils; import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; +import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.QueryCursorImpl; @@ -78,7 +80,6 @@ import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO; import org.apache.ignite.internal.processors.cache.query.CacheQueryPartitionInfo; -import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryMarshallable; import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; @@ -119,7 +120,6 @@ import org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase; import org.apache.ignite.internal.processors.query.h2.opt.GridH2PlainRowFactory; import org.apache.ignite.internal.processors.query.h2.opt.GridH2QueryContext; -import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row; import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor; import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table; import org.apache.ignite.internal.processors.query.h2.sql.GridSqlAlias; @@ -132,6 +132,7 @@ import org.apache.ignite.internal.processors.query.h2.sys.SqlSystemTableEngine; import org.apache.ignite.internal.processors.query.h2.sys.view.SqlSystemView; import org.apache.ignite.internal.processors.query.h2.sys.view.SqlSystemViewBaselineNodes; +import org.apache.ignite.internal.processors.query.h2.sys.view.SqlSystemViewCaches; import org.apache.ignite.internal.processors.query.h2.sys.view.SqlSystemViewNodeAttributes; import org.apache.ignite.internal.processors.query.h2.sys.view.SqlSystemViewNodeMetrics; import org.apache.ignite.internal.processors.query.h2.sys.view.SqlSystemViewNodes; @@ -169,6 +170,8 @@ import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.util.worker.GridWorker; +import org.apache.ignite.internal.util.worker.GridWorkerFuture; import org.apache.ignite.lang.IgniteBiClosure; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteFuture; @@ -177,6 +180,7 @@ import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.plugin.security.SecurityPermission; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.spi.indexing.IndexingQueryFilter; import org.apache.ignite.spi.indexing.IndexingQueryFilterImpl; @@ -888,15 +892,7 @@ private void addInitialUserIndex(String schemaName, H2TableDescriptor desc, Grid // Populate index with existing cache data. final GridH2RowDescriptor rowDesc = h2Tbl.rowDescriptor(); - SchemaIndexCacheVisitorClosure clo = new SchemaIndexCacheVisitorClosure() { - @Override public void apply(CacheDataRow row) throws IgniteCheckedException { - GridH2Row h2Row = rowDesc.createRow(row); - - h2Idx.putx(h2Row); - } - }; - - cacheVisitor.visit(clo); + cacheVisitor.visit(new IndexBuildClosure(rowDesc, h2Idx)); // At this point index is in consistent state, promote it through H2 SQL statement, so that cached // prepared statements are re-built. @@ -1122,6 +1118,14 @@ else if (DdlStatementsProcessor.isDdlStatement(p)) { throw new IgniteSQLException("SELECT FOR UPDATE query requires transactional " + "cache with MVCC enabled.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION); + if (this.ctx.security().enabled()) { + GridSqlQueryParser parser = new GridSqlQueryParser(false); + + parser.parse(p); + + checkSecurity(parser.cacheIds()); + } + GridNearTxSelectForUpdateFuture sfuFut = null; int opTimeout = qryTimeout; @@ -1790,7 +1794,7 @@ private Iterable> runQueryTwoStep( final MvccQueryTracker tracker = mvccTracker == null && qry.mvccEnabled() ? MvccUtils.mvccTracker(ctx.cache().context().cacheContext(qry.cacheIds().get(0)), startTx) : mvccTracker; - GridNearTxLocal tx = tx(ctx); + GridNearTxLocal tx = tracker != null ? tx(ctx) : null; if (qry.forUpdate()) qry.forUpdate(checkActive(tx) != null); @@ -1800,8 +1804,16 @@ private Iterable> runQueryTwoStep( return new Iterable>() { @SuppressWarnings("NullableProblems") @Override public Iterator> iterator() { - return rdcQryExec.query(schemaName, qry, keepCacheObj, enforceJoinOrder, opTimeout, - cancel, params, parts, lazy, tracker); + try { + return rdcQryExec.query(schemaName, qry, keepCacheObj, enforceJoinOrder, opTimeout, + cancel, params, parts, lazy, tracker); + } + catch (Throwable e) { + if (tracker != null) + tracker.onDone(); + + throw e; + } } }; } @@ -1876,7 +1888,17 @@ UpdateResult runDistributedUpdate( } @Override public Cache.Entry next() { - List l = iter0.next(); + List l; + + try { + l = iter0.next(); + } + catch (CacheException e) { + throw e; + } + catch (Exception e) { + throw new CacheException(e); + } return new CacheEntryImpl<>((K)l.get(0), (V)l.get(1)); } @@ -2209,8 +2231,9 @@ private void closeTx(@NotNull GridNearTxLocal tx) throws IgniteCheckedException res.addAll(doRunPrepared(schemaName, prepared, newQry, twoStepQry, meta, keepBinary, startTx, tracker, cancel)); + // We cannot cache two-step query for multiple statements query except the last statement if (parseRes.twoStepQuery() != null && parseRes.twoStepQueryKey() != null && - !parseRes.twoStepQuery().explain()) + !parseRes.twoStepQuery().explain() && remainingSql == null) twoStepCache.putIfAbsent(parseRes.twoStepQueryKey(), new H2TwoStepCachedQuery(meta, twoStepQry.copy())); } @@ -2312,6 +2335,9 @@ private List>> doRunPrepared(String schemaNa checkQueryType(qry, true); + if (ctx.security().enabled()) + checkSecurity(twoStepQry.cacheIds()); + return Collections.singletonList(doRunDistributedQuery(schemaName, qry, twoStepQry, meta, keepBinary, startTx, tracker, cancel)); } @@ -2326,6 +2352,23 @@ private List>> doRunPrepared(String schemaNa } } + /** + * Check security access for caches. + * + * @param cacheIds Cache IDs. + */ + private void checkSecurity(Collection cacheIds) { + if (F.isEmpty(cacheIds)) + return; + + for (Integer cacheId : cacheIds) { + DynamicCacheDescriptor desc = ctx.cache().cacheDescriptor(cacheId); + + if (desc != null) + ctx.security().authorize(desc.cacheName(), SecurityPermission.CACHE_READ, null); + } + } + /** * Parse and split query if needed, cache either two-step query or statement. * @param schemaName Schema name. @@ -2397,7 +2440,7 @@ private ParsingResult parseAndSplit(String schemaName, SqlFieldsQuery qry, int f // Legit assertion - we have H2 query flag above. assert parsedStmt instanceof GridSqlQuery; - loc = parser.isLocalQuery(qry.isReplicatedOnly()); + loc = parser.isLocalQuery(); } if (loc) { @@ -3094,33 +3137,97 @@ public ThreadLocalObjectPool.Reusable detach() { return reusableConnection; } + /** {@inheritDoc} */ + @Override public IgniteInternalFuture rebuildIndexesFromHash(GridCacheContext cctx) { + // No data in fresh in-memory cache. + if (!cctx.group().persistenceEnabled()) + return null; + + IgnitePageStoreManager pageStore = cctx.shared().pageStore(); + + assert pageStore != null; + + SchemaIndexCacheVisitorClosure clo; + + if (!pageStore.hasIndexStore(cctx.groupId())) { + // If there are no index store, rebuild all indexes. + clo = new IndexRebuildFullClosure(cctx.queries(), cctx.mvccEnabled()); + } + else { + // Otherwise iterate over tables looking for missing indexes. + IndexRebuildPartialClosure clo0 = new IndexRebuildPartialClosure(); + + for (H2TableDescriptor tblDesc : tables(cctx.name())) { + assert tblDesc.table() != null; + + tblDesc.table().collectIndexesForPartialRebuild(clo0); + } + + if (clo0.hasIndexes()) + clo = clo0; + else + return null; + } + + // Closure prepared, do rebuild. + final GridWorkerFuture fut = new GridWorkerFuture<>(); + + markIndexRebuild(cctx.name(), true); + + GridWorker worker = new GridWorker(ctx.igniteInstanceName(), "index-rebuild-worker-" + cctx.name(), log) { + @Override protected void body() { + try { + rebuildIndexesFromHash0(cctx, clo); + + markIndexRebuild(cctx.name(), false); + + fut.onDone(); + } + catch (Exception e) { + fut.onDone(e); + } + catch (Throwable e) { + U.error(log, "Failed to rebuild indexes for cache: " + cctx.name(), e); + + fut.onDone(e); + + throw e; + } + } + }; + + fut.setWorker(worker); + + ctx.getExecutorService().execute(worker); + + return fut; + } + /** - * Rebuild indexes from hash index. + * Do index rebuild. * - * @param cacheName Cache name. + * @param cctx Cache context. + * @param clo Closure. * @throws IgniteCheckedException If failed. */ - @Override public void rebuildIndexesFromHash(String cacheName) throws IgniteCheckedException { - int cacheId = CU.cacheId(cacheName); - - GridCacheContext cctx = ctx.cache().context().cacheContext(cacheId); - - final GridCacheQueryManager qryMgr = cctx.queries(); - + protected void rebuildIndexesFromHash0(GridCacheContext cctx, SchemaIndexCacheVisitorClosure clo) + throws IgniteCheckedException { SchemaIndexCacheVisitor visitor = new SchemaIndexCacheVisitorImpl(cctx); - visitor.visit(new RebuildIndexFromHashClosure(qryMgr, cctx.mvccEnabled())); - - for (H2TableDescriptor tblDesc : tables(cacheName)) - tblDesc.table().markRebuildFromHashInProgress(false); + visitor.visit(clo); } - /** {@inheritDoc} */ - @Override public void markForRebuildFromHash(String cacheName) { + /** + * Mark tables for index rebuild, so that their indexes are not used. + * + * @param cacheName Cache name. + * @param val Value. + */ + private void markIndexRebuild(String cacheName, boolean val) { for (H2TableDescriptor tblDesc : tables(cacheName)) { assert tblDesc.table() != null; - tblDesc.table().markRebuildFromHashInProgress(true); + tblDesc.table().markRebuildFromHashInProgress(val); } } @@ -3295,6 +3402,7 @@ public Collection systemViews(GridKernalContext ctx) { views.add(new SqlSystemViewNodeAttributes(ctx)); views.add(new SqlSystemViewBaselineNodes(ctx)); views.add(new SqlSystemViewNodeMetrics(ctx)); + views.add(new SqlSystemViewCaches(ctx)); return views; } diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IndexBuildClosure.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IndexBuildClosure.java new file mode 100644 index 0000000000000..8d1923f2a2a0c --- /dev/null +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IndexBuildClosure.java @@ -0,0 +1,54 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.query.h2; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; +import org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase; +import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row; +import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor; +import org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitorClosure; + +/** + * Index build closure. + */ +public class IndexBuildClosure implements SchemaIndexCacheVisitorClosure { + /** Row descriptor. */ + private final GridH2RowDescriptor rowDesc; + + /** Index. */ + private final GridH2IndexBase idx; + + /** + * Constructor. + * + * @param rowDesc Row descriptor. + * @param idx Target index. + */ + public IndexBuildClosure(GridH2RowDescriptor rowDesc, GridH2IndexBase idx) { + this.rowDesc = rowDesc; + this.idx = idx; + } + + /** {@inheritDoc} */ + @Override public void apply(CacheDataRow row) throws IgniteCheckedException { + GridH2Row row0 = rowDesc.createRow(row); + + idx.putx(row0); + } +} diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/RebuildIndexFromHashClosure.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IndexRebuildFullClosure.java similarity index 89% rename from modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/RebuildIndexFromHashClosure.java rename to modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IndexRebuildFullClosure.java index b635eaca8892b..8018839a6ce7b 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/RebuildIndexFromHashClosure.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IndexRebuildFullClosure.java @@ -22,8 +22,10 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager; import org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitorClosure; -/** */ -class RebuildIndexFromHashClosure implements SchemaIndexCacheVisitorClosure { +/** + * Closure to rebuild all indexes. + */ +public class IndexRebuildFullClosure implements SchemaIndexCacheVisitorClosure { /** */ private final GridCacheQueryManager qryMgr; @@ -34,7 +36,7 @@ class RebuildIndexFromHashClosure implements SchemaIndexCacheVisitorClosure { * @param qryMgr Query manager. * @param mvccEnabled MVCC status flag. */ - RebuildIndexFromHashClosure(GridCacheQueryManager qryMgr, boolean mvccEnabled) { + public IndexRebuildFullClosure(GridCacheQueryManager qryMgr, boolean mvccEnabled) { this.qryMgr = qryMgr; this.mvccEnabled = mvccEnabled; } diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IndexRebuildPartialClosure.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IndexRebuildPartialClosure.java new file mode 100644 index 0000000000000..2672f0627cdb8 --- /dev/null +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IndexRebuildPartialClosure.java @@ -0,0 +1,76 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.query.h2; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; +import org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase; +import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row; +import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table; +import org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitorClosure; + +import java.util.Collection; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Map; + +/** + * Closure to rebuild some cache indexes. + */ +public class IndexRebuildPartialClosure implements SchemaIndexCacheVisitorClosure { + /** Indexes. */ + private final Map> tblIdxs = new IdentityHashMap<>(); + + /** {@inheritDoc} */ + @Override public void apply(CacheDataRow row) throws IgniteCheckedException { + assert hasIndexes(); + + for (Map.Entry> tblIdxEntry : tblIdxs.entrySet()) { + GridH2Table tbl = tblIdxEntry.getKey(); + + GridH2Row row0 = tbl.rowDescriptor().createRow(row); + + for (GridH2IndexBase idx : tblIdxEntry.getValue()) + idx.putx(row0); + } + } + + /** + * @param idx Index to be rebuilt. + */ + public void addIndex(GridH2Table tbl, GridH2IndexBase idx) { + Collection idxs = tblIdxs.get(tbl); + + if (idxs == null) { + idxs = Collections.newSetFromMap(new IdentityHashMap<>()); + + idxs.add(idx); + + tblIdxs.put(tbl, idxs); + } + + idxs.add(idx); + } + + /** + * @return {@code True} if there is at least one index to rebuild. + */ + public boolean hasIndexes() { + return !tblIdxs.isEmpty(); + } +} diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java index 4c6c0c065f58f..34b7fa39cf8b9 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java @@ -108,6 +108,9 @@ public abstract class H2Tree extends BPlusTree { /** */ private final IgniteLogger log; + /** Whether index was created from scratch during owning node lifecycle. */ + private final boolean created; + /** * Constructor. * @@ -191,6 +194,8 @@ protected H2Tree( this.log = log; initTree(initNew, inlineSize); + + this.created = initNew; } /** @@ -507,6 +512,14 @@ private void inlineSizeRecomendation(SearchRow row) { */ public abstract int compareValues(Value v1, Value v2); + /** + * @return {@code True} if index was created during curren node's lifetime, {@code False} if it was restored from + * disk. + */ + public boolean created() { + return created; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(H2Tree.class, this, "super", super.toString()); diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java index e9cca9ee0381e..18a3bbfd922bb 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java @@ -88,6 +88,9 @@ public class H2TreeIndex extends GridH2IndexBase { /** */ private final String idxName; + /** Tree name. */ + private final String treeName; + /** */ private final IgniteLogger log; @@ -135,9 +138,7 @@ public H2TreeIndex( int typeId = cctx.binaryMarshaller() ? typeDesc.typeId() : typeDesc.valueClass().hashCode(); - String treeName = (tbl.rowDescriptor() == null ? "" : typeId + "_") + idxName; - - treeName = BPlusTree.treeName(treeName, "H2Tree"); + treeName = BPlusTree.treeName((tbl.rowDescriptor() == null ? "" : typeId + "_") + idxName, "H2Tree"); if (cctx.affinityNode()) { inlineIdxs = getAvailableInlineColumns(cols); @@ -151,8 +152,8 @@ public H2TreeIndex( for (int i = 0; i < segments.length; i++) { db.checkpointReadLock(); - try { - RootPage page = getMetaPage(treeName, i); + try { + RootPage page = getMetaPage(i); segments[i] = new H2Tree( treeName, @@ -196,6 +197,30 @@ public H2TreeIndex( initDistributedJoinMessaging(tbl); } + /** + * Check if index exists in store. + * + * @return {@code True} if exists. + */ + public boolean rebuildRequired() { + assert segments != null; + + for (int i = 0; i < segments.length; i++) { + try { + H2Tree segment = segments[i]; + + if (segment.created()) + return true; + } + catch (Exception e) { + throw new IgniteException("Failed to check index tree root page existence [cacheName=" + cctx.name() + + ", tblName=" + tblName + ", idxName=" + idxName + ", segment=" + i + ']'); + } + } + + return false; + } + /** * @param cols Columns array. * @return List of {@link InlineIndexHelper} objects. @@ -413,7 +438,7 @@ private List getAvailableInlineColumns(IndexColumn[] cols) { tree.destroy(); - dropMetaPage(tree.getName(), i); + dropMetaPage(i); } } } @@ -508,22 +533,20 @@ private int computeInlineSize(List inlineIdxs, int cfgInlineS } /** - * @param name Name. * @param segIdx Segment index. * @return RootPage for meta page. * @throws IgniteCheckedException If failed. */ - private RootPage getMetaPage(String name, int segIdx) throws IgniteCheckedException { - return cctx.offheap().rootPageForIndex(cctx.cacheId(), name + "%" + segIdx); + private RootPage getMetaPage(int segIdx) throws IgniteCheckedException { + return cctx.offheap().rootPageForIndex(cctx.cacheId(), treeName, segIdx); } /** - * @param name Name. * @param segIdx Segment index. * @throws IgniteCheckedException If failed. */ - private void dropMetaPage(String name, int segIdx) throws IgniteCheckedException { - cctx.offheap().dropRootPageForIndex(cctx.cacheId(), name + "%" + segIdx); + private void dropMetaPage(int segIdx) throws IgniteCheckedException { + cctx.offheap().dropRootPageForIndex(cctx.cacheId(), treeName, segIdx); } /** {@inheritDoc} */ diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java index 5c2865abe1350..94e39ef2870c0 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java @@ -328,7 +328,7 @@ else if (stmt0 instanceof GridSqlDropIndex) { } } else if (stmt0 instanceof GridSqlCreateTable) { - ctx.security().authorize(null, SecurityPermission.CACHE_CREATE, SecurityContextHolder.get()); + ctx.security().authorize(null, SecurityPermission.CACHE_CREATE, null); GridSqlCreateTable cmd = (GridSqlCreateTable)stmt0; @@ -361,7 +361,7 @@ else if (stmt0 instanceof GridSqlCreateTable) { } } else if (stmt0 instanceof GridSqlDropTable) { - ctx.security().authorize(null, SecurityPermission.CACHE_DESTROY, SecurityContextHolder.get()); + ctx.security().authorize(null, SecurityPermission.CACHE_DESTROY, null); GridSqlDropTable cmd = (GridSqlDropTable)stmt0; diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlBatchSender.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlBatchSender.java index 7c2a4228c95d0..88c19c3d907bb 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlBatchSender.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlBatchSender.java @@ -98,14 +98,10 @@ public void add(Object key, EntryProcessor proc, int ro throws IgniteCheckedException { assert key != null; assert proc != null; - - ClusterNode node = cctx.affinity().primaryByKey(key, AffinityTopologyVersion.NONE); - - if (node == null) - throw new IgniteCheckedException("Failed to map key to node."); - assert rowNum < cntPerRow.length; + ClusterNode node = primaryNodeByKey(key); + UUID nodeId = node.id(); Batch batch = batches.get(nodeId); @@ -126,6 +122,20 @@ public void add(Object key, EntryProcessor proc, int ro sendBatch(batch); } + /** + * @param key Key. + * @return Primary node for given key. + * @throws IgniteCheckedException If primary node is not found. + */ + public ClusterNode primaryNodeByKey(Object key) throws IgniteCheckedException { + ClusterNode node = cctx.affinity().primaryByKey(key, AffinityTopologyVersion.NONE); + + if (node == null) + throw new IgniteCheckedException("Failed to map key to node."); + + return node; + } + /** * Flush any remaining entries. */ diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java index a612b637980ad..ca5c3e97de814 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java @@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteInterruptedException; @@ -35,6 +34,7 @@ import org.apache.ignite.internal.processors.cache.query.QueryTable; import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.processors.query.QueryField; +import org.apache.ignite.internal.processors.query.h2.IndexRebuildPartialClosure; import org.apache.ignite.internal.processors.query.h2.database.H2RowFactory; import org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex; import org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor; @@ -88,7 +88,7 @@ public class GridH2Table extends TableBase { private final Map tmpIdxs = new HashMap<>(); /** */ - private final ReadWriteLock lock; + private final ReentrantReadWriteLock lock; /** */ private boolean destroyed; @@ -126,6 +126,7 @@ public class GridH2Table extends TableBase { * @param idxsFactory Indexes factory. * @param cctx Cache context. */ + @SuppressWarnings("ConstantConditions") public GridH2Table(CreateTableData createTblData, GridH2RowDescriptor desc, H2RowFactory rowFactory, GridH2SystemIndexFactory idxsFactory, GridCacheContext cctx) { super(createTblData); @@ -174,11 +175,14 @@ public GridH2Table(CreateTableData createTblData, GridH2RowDescriptor desc, H2Ro assert idxs != null; List clones = new ArrayList<>(idxs.size()); + for (Index index : idxs) { Index clone = createDuplicateIndexIfNeeded(index); + if (clone != null) clones.add(clone); } + idxs.addAll(clones); boolean hasHashIndex = idxs.size() >= 2 && index(0).getIndexType().isHash(); @@ -551,12 +555,39 @@ private void addToIndex(GridH2IndexBase idx, GridH2Row row, GridH2Row prevRow) { } /** + * Collect indexes for rebuild. * + * @param clo Closure. + */ + public void collectIndexesForPartialRebuild(IndexRebuildPartialClosure clo) { + for (int i = sysIdxsCnt; i < idxs.size(); i++) { + Index idx = idxs.get(i); + + if (idx instanceof H2TreeIndex) { + H2TreeIndex idx0 = (H2TreeIndex)idx; + + if (idx0.rebuildRequired()) + clo.addIndex(this, idx0); + } + } + } + + /** + * Mark or unmark index rebuild state. */ public void markRebuildFromHashInProgress(boolean value) { assert !value || (idxs.size() >= 2 && index(1).getIndexType().isHash()) : "Table has no hash index."; rebuildFromHashInProgress = value; + + lock.writeLock().lock(); + + try { + incrementModificationCounter(); + } + finally { + lock.writeLock().unlock(); + } } /** @@ -637,7 +668,7 @@ private Index commitUserIndex(Session ses, String idxName) { if (cloneIdx != null) database.addSchemaObject(ses, cloneIdx); - setModified(); + incrementModificationCounter(); return idx; } @@ -941,7 +972,7 @@ public void addColumns(List cols, boolean ifNotExists) { desc.refreshMetadataFromTypeDescriptor(); - setModified(); + incrementModificationCounter(); } finally { unlock(true); @@ -949,9 +980,10 @@ public void addColumns(List cols, boolean ifNotExists) { } /** + * Drop columns. * - * @param cols - * @param ifExists + * @param cols Columns. + * @param ifExists If EXISTS flag. */ public void dropColumns(List cols, boolean ifExists) { assert !ifExists || cols.size() == 1; @@ -1003,7 +1035,7 @@ public void dropColumns(List cols, boolean ifExists) { ((GridH2IndexBase)idx).refreshColumnIds(); } - setModified(); + incrementModificationCounter(); } finally { unlock(true); @@ -1031,6 +1063,15 @@ public void dropColumns(List cols, boolean ifExists) { return columns; } + /** + * Increment modification counter to force recompilation of existing prepared statements. + */ + private void incrementModificationCounter() { + assert lock.isWriteLockedByCurrentThread(); + + setModified(); + } + /** * Set insert hack flag. * diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java index 856951fe21d01..c042acc1d5bc3 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQueryParser.java @@ -21,6 +21,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.IdentityHashMap; @@ -34,7 +35,6 @@ import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.QueryIndex; import org.apache.ignite.cache.QueryIndexType; -import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.processors.query.IgniteSQLException; @@ -529,6 +529,9 @@ public class GridSqlQueryParser { */ private int parsingSubQryExpression; + /** Whether this is SELECT FOR UPDATE. */ + private boolean selectForUpdate; + /** * @param useOptimizedSubqry If we have to find correct order for table filters in FROM clause. * Relies on uniqueness of table filter aliases. @@ -1710,13 +1713,13 @@ else if (stmt.getClass() == Update.class) /** * Check if query may be run locally on all caches mentioned in the query. - * @param replicatedOnlyQry replicated-only query flag from original {@link SqlFieldsQuery}. + * * @return {@code true} if query may be run locally on all caches mentioned in the query, i.e. there's no need * to run distributed query. - * @see SqlFieldsQuery#isReplicatedOnly() */ - public boolean isLocalQuery(boolean replicatedOnlyQry) { - boolean hasCaches = false; + public boolean isLocalQuery() { + if (selectForUpdate) + return false; for (Object o : h2ObjToGridObj.values()) { if (o instanceof GridSqlAlias) @@ -1726,19 +1729,21 @@ public boolean isLocalQuery(boolean replicatedOnlyQry) { GridH2Table tbl = ((GridSqlTable)o).dataTable(); if (tbl != null) { - hasCaches = true; - GridCacheContext cctx = tbl.cache(); - if (!cctx.isLocal() && !(replicatedOnlyQry && cctx.isReplicatedAffinityNode())) + if (cctx.mvccEnabled()) + return false; + + if (cctx.isPartitioned()) + return false; + + if (cctx.isReplicated() && !cctx.isReplicatedAffinityNode()) return false; } } } - // For consistency with old logic, let's not force locality in absence of caches - - // if there are no caches, original SqlFieldsQuery's isLocal flag will be used. - return hasCaches; + return true; } /** @@ -1763,6 +1768,27 @@ public GridCacheContext getFirstPartitionedCache() { return null; } + /** + * @return All known cache IDs. + */ + public Collection cacheIds() { + ArrayList res = new ArrayList<>(1); + + for (Object o : h2ObjToGridObj.values()) { + if (o instanceof GridSqlAlias) + o = GridSqlAlias.unwrap((GridSqlAst)o); + + if (o instanceof GridSqlTable) { + GridH2Table tbl = ((GridSqlTable)o).dataTable(); + + if (tbl != null) + res.add(tbl.cacheId()); + } + } + + return res; + } + /** * @param stmt Prepared statement. * @return Parsed AST. @@ -1772,6 +1798,8 @@ public final GridSqlStatement parse(Prepared stmt) { if (optimizedTableFilterOrder != null) collectOptimizedTableFiltersOrder((Query)stmt); + selectForUpdate = isForUpdateQuery(stmt); + return parseQuery((Query)stmt); } diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java index ca9c5bb064cb3..7fa426fc6ba6d 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlQuerySplitter.java @@ -58,6 +58,7 @@ import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.processors.query.h2.opt.GridH2CollocationModel.isCollocated; +import static org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap.DEFAULT_COLUMNS_COUNT; import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlConst.TRUE; import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlFunctionType.AVG; import static org.apache.ignite.internal.processors.query.h2.sql.GridSqlFunctionType.CAST; @@ -201,7 +202,7 @@ public static GridCacheTwoStepQuery split( // subqueries because we do not have unique FROM aliases yet. GridSqlQuery qry = parse(prepared, false); - String originalSql = qry.getSQL(); + String originalSql = prepared.getSQL(); // debug("ORIGINAL", originalSql); @@ -2142,16 +2143,23 @@ private void splitAggregate( case SUM: // SUM( SUM(x) ) or SUM(DISTINCT x) case MAX: // MAX( MAX(x) ) or MAX(DISTINCT x) case MIN: // MIN( MIN(x) ) or MIN(DISTINCT x) + GridSqlElement rdcAgg0; + if (hasDistinctAggregate) /* and has no collocated group by */ { mapAgg = agg.child(); - rdcAgg = aggregate(agg.distinct(), agg.type()).addChild(column(mapAggAlias.alias())); + rdcAgg0 = aggregate(agg.distinct(), agg.type()).addChild(column(mapAggAlias.alias())); } else { mapAgg = aggregate(agg.distinct(), agg.type()).resultType(agg.resultType()).addChild(agg.child()); - rdcAgg = aggregate(agg.distinct(), agg.type()).addChild(column(mapAggAlias.alias())); + + rdcAgg0 = function(CAST).resultType(agg.resultType()) + .addChild(aggregate(agg.distinct(), agg.type()).addChild(column(mapAggAlias.alias()))); } + // Avoid second type upcast on reducer (e.g. Int -> (map) -> Long -> (reduce) -> BigDecimal). + rdcAgg = function(CAST).resultType(agg.resultType()).addChild(rdcAgg0); + break; case COUNT_ALL: // CAST(SUM( COUNT(*) ) AS BIGINT) @@ -2375,6 +2383,9 @@ private static CacheQueryPartitionInfo extractPartitionFromEquality(GridSqlOpera GridH2Table tbl = (GridH2Table) column.column().getTable(); + if (!isAffinityKey(column.column().getColumnId(), tbl)) + return null; + GridH2RowDescriptor desc = tbl.rowDescriptor(); IndexColumn affKeyCol = tbl.getAffinityKeyColumn(); @@ -2397,6 +2408,27 @@ private static CacheQueryPartitionInfo extractPartitionFromEquality(GridSqlOpera column.column().getType(), param.index()); } + /** + * + * @param colId Column ID to check + * @param tbl H2 Table + * @return is affinity key or not + */ + private static boolean isAffinityKey(int colId, GridH2Table tbl) { + GridH2RowDescriptor desc = tbl.rowDescriptor(); + + if (desc.isKeyColumn(colId)) + return true; + + IndexColumn affKeyCol = tbl.getAffinityKeyColumn(); + + try { + return affKeyCol != null && colId >= DEFAULT_COLUMNS_COUNT && desc.isColumnKeyProperty(colId - DEFAULT_COLUMNS_COUNT) && colId == affKeyCol.column.getColumnId(); + } catch(IllegalStateException e) { + return false; + } + } + /** * Merges two partition info arrays, removing duplicates * diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlAbstractLocalSystemView.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlAbstractLocalSystemView.java index d692dbac3dafa..d028406a122c9 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlAbstractLocalSystemView.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlAbstractLocalSystemView.java @@ -37,7 +37,7 @@ public abstract class SqlAbstractLocalSystemView extends SqlAbstractSystemView { * @param tblName Table name. * @param desc Description. * @param ctx Context. - * @param indexes Indexed columns. + * @param indexes Indexes. * @param cols Columns. */ public SqlAbstractLocalSystemView(String tblName, String desc, GridKernalContext ctx, String[] indexes, @@ -49,6 +49,17 @@ public SqlAbstractLocalSystemView(String tblName, String desc, GridKernalContext assert indexes != null; } + /** + * @param tblName Table name. + * @param desc Description. + * @param ctx Context. + * @param indexedCols Indexed columns. + * @param cols Columns. + */ + public SqlAbstractLocalSystemView(String tblName, String desc, GridKernalContext ctx, String indexedCols, Column... cols) { + this(tblName, desc, ctx, new String[] {indexedCols}, cols); + } + /** * @param tblName Table name. * @param desc Description. diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewCaches.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewCaches.java new file mode 100644 index 0000000000000..ff9ef32115121 --- /dev/null +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewCaches.java @@ -0,0 +1,197 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.query.h2.sys.view; + +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.concurrent.atomic.AtomicLong; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; +import org.apache.ignite.internal.util.typedef.F; +import org.h2.engine.Session; +import org.h2.result.Row; +import org.h2.result.SearchRow; +import org.h2.value.Value; + +/** + * System view: caches. + */ +public class SqlSystemViewCaches extends SqlAbstractLocalSystemView { + /** + * @param ctx Grid context. + */ + public SqlSystemViewCaches(GridKernalContext ctx) { + super("CACHES", "Ignite caches", ctx, "NAME", + newColumn("NAME"), + newColumn("CACHE_ID", Value.INT), + newColumn("CACHE_TYPE"), + newColumn("GROUP_ID", Value.INT), + newColumn("GROUP_NAME"), + newColumn("CACHE_MODE"), + newColumn("ATOMICITY_MODE"), + newColumn("IS_ONHEAP_CACHE_ENABLED", Value.BOOLEAN), + newColumn("IS_COPY_ON_READ", Value.BOOLEAN), + newColumn("IS_LOAD_PREVIOUS_VALUE", Value.BOOLEAN), + newColumn("IS_READ_FROM_BACKUP", Value.BOOLEAN), + newColumn("PARTITION_LOSS_POLICY"), + newColumn("NODE_FILTER"), + newColumn("TOPOLOGY_VALIDATOR"), + newColumn("IS_EAGER_TTL", Value.BOOLEAN), + newColumn("WRITE_SYNCHRONIZATION_MODE"), + newColumn("IS_INVALIDATE", Value.BOOLEAN), + newColumn("IS_EVENTS_DISABLED", Value.BOOLEAN), + newColumn("IS_STATISTICS_ENABLED", Value.BOOLEAN), + newColumn("IS_MANAGEMENT_ENABLED", Value.BOOLEAN), + newColumn("BACKUPS", Value.INT), + newColumn("AFFINITY"), + newColumn("AFFINITY_MAPPER"), + newColumn("REBALANCE_MODE"), + newColumn("REBALANCE_BATCH_SIZE", Value.INT), + newColumn("REBALANCE_TIMEOUT", Value.LONG), + newColumn("REBALANCE_DELAY", Value.LONG), + newColumn("REBALANCE_THROTTLE", Value.LONG), + newColumn("REBALANCE_BATCHES_PREFETCH_COUNT", Value.LONG), + newColumn("REBALANCE_ORDER", Value.INT), + newColumn("EVICTION_FILTER"), + newColumn("EVICTION_POLICY_FACTORY"), + newColumn("IS_NEAR_CACHE_ENABLED", Value.BOOLEAN), + newColumn("NEAR_CACHE_EVICTION_POLICY_FACTORY"), + newColumn("NEAR_CACHE_START_SIZE", Value.INT), + newColumn("DEFAULT_LOCK_TIMEOUT", Value.LONG), + newColumn("CACHE_INTERCEPTOR"), + newColumn("CACHE_STORE_FACTORY"), + newColumn("IS_STORE_KEEP_BINARY", Value.BOOLEAN), + newColumn("IS_READ_THROUGH", Value.BOOLEAN), + newColumn("IS_WRITE_THROUGH", Value.BOOLEAN), + newColumn("IS_WRITE_BEHIND_ENABLED", Value.BOOLEAN), + newColumn("WRITE_BEHIND_COALESCING", Value.BOOLEAN), + newColumn("WRITE_BEHIND_FLUSH_SIZE", Value.INT), + newColumn("WRITE_BEHIND_FLUSH_FREQUENCY", Value.LONG), + newColumn("WRITE_BEHIND_FLUSH_THREAD_COUNT", Value.INT), + newColumn("WRITE_BEHIND_FLUSH_BATCH_SIZE", Value.INT), + newColumn("MAX_CONCURRENT_ASYNC_OPERATIONS", Value.INT), + newColumn("CACHE_LOADER_FACTORY"), + newColumn("CACHE_WRITER_FACTORY"), + newColumn("EXPIRY_POLICY_FACTORY"), + newColumn("IS_SQL_ESCAPE_ALL", Value.BOOLEAN), + newColumn("SQL_SCHEMA"), + newColumn("SQL_INDEX_MAX_INLINE_SIZE", Value.INT), + newColumn("IS_SQL_ONHEAP_CACHE_ENABLED", Value.BOOLEAN), + newColumn("SQL_ONHEAP_CACHE_MAX_SIZE", Value.INT), + newColumn("QUERY_DETAILS_METRICS_SIZE", Value.INT), + newColumn("QUERY_PARALLELISM", Value.INT), + newColumn("MAX_QUERY_ITERATORS_COUNT", Value.INT), + newColumn("DATA_REGION_NAME") + ); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public Iterator getRows(Session ses, SearchRow first, SearchRow last) { + SqlSystemViewColumnCondition nameCond = conditionForColumn("NAME", first, last); + + Collection caches; + + if (nameCond.isEquality()) { + DynamicCacheDescriptor cache = ctx.cache().cacheDescriptor(nameCond.valueForEquality().getString()); + + caches = cache == null ? Collections.emptySet() : Collections.singleton(cache); + } + else + caches = ctx.cache().cacheDescriptors().values(); + + AtomicLong rowKey = new AtomicLong(); + + return F.iterator(caches, + cache -> createRow(ses, rowKey.incrementAndGet(), + cache.cacheName(), + cache.cacheId(), + cache.cacheType(), + cache.groupId(), + cache.groupDescriptor().groupName(), + cache.cacheConfiguration().getCacheMode(), + cache.cacheConfiguration().getAtomicityMode(), + cache.cacheConfiguration().isOnheapCacheEnabled(), + cache.cacheConfiguration().isCopyOnRead(), + cache.cacheConfiguration().isLoadPreviousValue(), + cache.cacheConfiguration().isReadFromBackup(), + cache.cacheConfiguration().getPartitionLossPolicy(), + cache.cacheConfiguration().getNodeFilter(), + cache.cacheConfiguration().getTopologyValidator(), + cache.cacheConfiguration().isEagerTtl(), + cache.cacheConfiguration().getWriteSynchronizationMode(), + cache.cacheConfiguration().isInvalidate(), + cache.cacheConfiguration().isEventsDisabled(), + cache.cacheConfiguration().isStatisticsEnabled(), + cache.cacheConfiguration().isManagementEnabled(), + cache.cacheConfiguration().getBackups(), + cache.cacheConfiguration().getAffinity(), + cache.cacheConfiguration().getAffinityMapper(), + cache.cacheConfiguration().getRebalanceMode(), + cache.cacheConfiguration().getRebalanceBatchSize(), + cache.cacheConfiguration().getRebalanceTimeout(), + cache.cacheConfiguration().getRebalanceDelay(), + cache.cacheConfiguration().getRebalanceThrottle(), + cache.cacheConfiguration().getRebalanceBatchesPrefetchCount(), + cache.cacheConfiguration().getRebalanceOrder(), + cache.cacheConfiguration().getEvictionFilter(), + cache.cacheConfiguration().getEvictionPolicyFactory(), + cache.cacheConfiguration().getNearConfiguration() != null, + cache.cacheConfiguration().getNearConfiguration() != null ? + cache.cacheConfiguration().getNearConfiguration().getNearEvictionPolicyFactory() : null, + cache.cacheConfiguration().getNearConfiguration() != null ? + cache.cacheConfiguration().getNearConfiguration().getNearStartSize() : null, + cache.cacheConfiguration().getDefaultLockTimeout(), + cache.cacheConfiguration().getInterceptor(), + cache.cacheConfiguration().getCacheStoreFactory(), + cache.cacheConfiguration().isStoreKeepBinary(), + cache.cacheConfiguration().isReadThrough(), + cache.cacheConfiguration().isWriteThrough(), + cache.cacheConfiguration().isWriteBehindEnabled(), + cache.cacheConfiguration().getWriteBehindCoalescing(), + cache.cacheConfiguration().getWriteBehindFlushSize(), + cache.cacheConfiguration().getWriteBehindFlushFrequency(), + cache.cacheConfiguration().getWriteBehindFlushThreadCount(), + cache.cacheConfiguration().getWriteBehindBatchSize(), + cache.cacheConfiguration().getMaxConcurrentAsyncOperations(), + cache.cacheConfiguration().getCacheLoaderFactory(), + cache.cacheConfiguration().getCacheWriterFactory(), + cache.cacheConfiguration().getExpiryPolicyFactory(), + cache.cacheConfiguration().isSqlEscapeAll(), + cache.cacheConfiguration().getSqlSchema(), + cache.cacheConfiguration().getSqlIndexMaxInlineSize(), + cache.cacheConfiguration().isSqlOnheapCacheEnabled(), + cache.cacheConfiguration().getSqlOnheapCacheMaxSize(), + cache.cacheConfiguration().getQueryDetailMetricsSize(), + cache.cacheConfiguration().getQueryParallelism(), + cache.cacheConfiguration().getMaxQueryIteratorsCount(), + cache.cacheConfiguration().getDataRegionName() + ), true); + } + + /** {@inheritDoc} */ + @Override public boolean canGetRowCount() { + return true; + } + + /** {@inheritDoc} */ + @Override public long getRowCount() { + return ctx.cache().cacheDescriptors().size(); + } +} diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewNodeMetrics.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewNodeMetrics.java index 01b4e976f0cae..d3921aaaa0490 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewNodeMetrics.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewNodeMetrics.java @@ -40,7 +40,7 @@ public class SqlSystemViewNodeMetrics extends SqlAbstractLocalSystemView { * @param ctx Grid context. */ public SqlSystemViewNodeMetrics(GridKernalContext ctx) { - super("NODE_METRICS", "Node metrics", ctx, new String[] {"NODE_ID"}, + super("NODE_METRICS", "Node metrics", ctx, "NODE_ID", newColumn("NODE_ID", Value.UUID), newColumn("LAST_UPDATE_TIME", Value.TIMESTAMP), newColumn("MAX_ACTIVE_JOBS", Value.INT), diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewNodes.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewNodes.java index 514f92e9708ee..d8720310aef08 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewNodes.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sys/view/SqlSystemViewNodes.java @@ -39,7 +39,7 @@ public class SqlSystemViewNodes extends SqlAbstractLocalSystemView { * @param ctx Grid context. */ public SqlSystemViewNodes(GridKernalContext ctx) { - super("NODES", "Topology nodes", ctx, new String[] {"ID"}, + super("NODES", "Topology nodes", ctx, "ID", newColumn("ID", Value.UUID), newColumn("CONSISTENT_ID"), newColumn("VERSION"), diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java index b30aa2fedd4c1..74c3005bccc1f 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java @@ -47,6 +47,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.PartitionLossPolicy; import org.apache.ignite.cache.query.QueryCancelledException; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.events.DiscoveryEvent; @@ -112,6 +113,8 @@ import static java.util.Collections.singletonList; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT; +import static org.apache.ignite.cache.PartitionLossPolicy.READ_ONLY_SAFE; +import static org.apache.ignite.cache.PartitionLossPolicy.READ_WRITE_SAFE; import static org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE; import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.checkActive; import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.mvccEnabled; @@ -397,7 +400,13 @@ private boolean hasMovingPartitions(GridCacheContext cctx) { * @return Cache context. */ private GridCacheContext cacheContext(Integer cacheId) { - return ctx.cache().context().cacheContext(cacheId); + GridCacheContext cctx = ctx.cache().context().cacheContext(cacheId); + + if (cctx == null) + throw new CacheException(String.format("Cache not found on local node (was concurrently destroyed?) " + + "[cacheId=%d]", cacheId)); + + return cctx; } /** @@ -1693,6 +1702,24 @@ private NodesForPartitionsResult nodesForPartitions(List cacheIds, Affi Map partsMap = null; Map qryMap = null; + for (int cacheId : cacheIds) { + GridCacheContext cctx = cacheContext(cacheId); + + PartitionLossPolicy plc = cctx.config().getPartitionLossPolicy(); + + if (plc != READ_ONLY_SAFE && plc != READ_WRITE_SAFE) + continue; + + Collection lostParts = cctx.topology().lostPartitions(); + + for (int part : lostParts) { + if (parts == null || Arrays.binarySearch(parts, part) >= 0) { + throw new CacheException("Failed to execute query because cache partition has been " + + "lost [cacheName=" + cctx.name() + ", part=" + part + ']'); + } + } + } + if (isPreloadingActive(cacheIds)) { if (isReplicatedOnly) nodes = replicatedUnstableDataNodes(cacheIds, qryId); diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2IndexRangeRequest.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2IndexRangeRequest.java index 702488487d9c0..186104ad44b54 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2IndexRangeRequest.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2IndexRangeRequest.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.UUID; import org.apache.ignite.internal.GridDirectCollection; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; @@ -30,6 +31,7 @@ /** * Range request. */ +@IgniteCodeGeneratingFail public class GridH2IndexRangeRequest implements Message { /** */ private UUID originNodeId; diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2IndexRangeResponse.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2IndexRangeResponse.java index 4fe660c0677a1..18814bb3f71a7 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2IndexRangeResponse.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2IndexRangeResponse.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.UUID; import org.apache.ignite.internal.GridDirectCollection; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType; @@ -30,6 +31,7 @@ /** * Range response message. */ +@IgniteCodeGeneratingFail public class GridH2IndexRangeResponse implements Message { /** */ public static final byte STATUS_OK = 0; diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java index 0bec66e56be42..cca366af7ce9f 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java @@ -29,6 +29,7 @@ import org.apache.ignite.internal.GridDirectMap; import org.apache.ignite.internal.GridDirectTransient; import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot; @@ -50,6 +51,7 @@ /** * Query request. */ +@IgniteCodeGeneratingFail public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable { /** */ private static final long serialVersionUID = 0L; @@ -518,7 +520,7 @@ public void txDetails(GridH2SelectForUpdateTxDetails txDetails) { writer.incrementState(); case 9: - if (!writer.writeMessage("topVer", topVer)) + if (!writer.writeAffinityTopologyVersion("topVer", topVer)) return false; writer.incrementState(); @@ -633,7 +635,7 @@ public void txDetails(GridH2SelectForUpdateTxDetails txDetails) { reader.incrementState(); case 9: - topVer = reader.readMessage("topVer"); + topVer = reader.readAffinityTopologyVersion("topVer"); if (!reader.isLastRead()) return false; diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java index 18f88803bd218..fd5b5243a7be8 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java @@ -20,6 +20,7 @@ import java.nio.ByteBuffer; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.IgniteCodeGeneratingFail; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; @@ -28,6 +29,7 @@ /** * Abstract message wrapper for H2 values. */ +@IgniteCodeGeneratingFail public abstract class GridH2ValueMessage implements Message { /** * Gets H2 value. diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/visor/verify/ValidateIndexesClosure.java b/modules/indexing/src/main/java/org/apache/ignite/internal/visor/verify/ValidateIndexesClosure.java index 503b57c494c70..b6909e3191e7f 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/visor/verify/ValidateIndexesClosure.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/visor/verify/ValidateIndexesClosure.java @@ -18,6 +18,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -37,22 +39,29 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteInterruptedException; import org.apache.ignite.IgniteLogger; +import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.pagemem.PageIdAllocator; +import org.apache.ignite.internal.pagemem.PageIdUtils; +import org.apache.ignite.internal.pagemem.store.PageStore; import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.CacheObjectUtils; import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; +import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.verify.PartitionKey; import org.apache.ignite.internal.processors.query.GridQueryProcessor; import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor; import org.apache.ignite.internal.processors.query.QueryTypeDescriptorImpl; import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; +import org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex; import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row; import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor; import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table; @@ -104,9 +113,15 @@ public class ValidateIndexesClosure implements IgniteCallable> partArgs = new ArrayList<>(); List> idxArgs = new ArrayList<>(); + totalCacheGrps = grpIds.size(); + + Map integrityCheckResults = integrityCheckIndexesPartitions(grpIds); + for (Integer grpId : grpIds) { CacheGroupContext grpCtx = ignite.context().cache().cacheGroup(grpId); - if (grpCtx == null) + if (grpCtx == null || integrityCheckResults.containsKey(grpId)) continue; List parts = grpCtx.topology().localPartitions(); @@ -210,7 +229,8 @@ private VisorValidateIndexesJobResult call0() throws Exception { ArrayList indexes = gridH2Tbl.getIndexes(); for (Index idx : indexes) - idxArgs.add(new T2<>(ctx, idx)); + if (idx instanceof H2TreeIndex) + idxArgs.add(new T2<>(ctx, idx)); } } } @@ -220,15 +240,15 @@ private VisorValidateIndexesJobResult call0() throws Exception { Collections.shuffle(partArgs); Collections.shuffle(idxArgs); + totalPartitions = partArgs.size(); + totalIndexes = idxArgs.size(); + for (T2 t2 : partArgs) procPartFutures.add(processPartitionAsync(t2.get1(), t2.get2())); for (T2 t2 : idxArgs) procIdxFutures.add(processIndexAsync(t2.get1(), t2.get2())); - totalPartitions = procPartFutures.size(); - totalIndexes = procIdxFutures.size(); - Map partResults = new HashMap<>(); Map idxResults = new HashMap<>(); @@ -240,7 +260,8 @@ private VisorValidateIndexesJobResult call0() throws Exception { Map partRes = fut.get(); - partResults.putAll(partRes); + if (!partRes.isEmpty() && partRes.entrySet().stream().anyMatch(e -> !e.getValue().issues().isEmpty())) + partResults.putAll(partRes); } for (; curIdx < procIdxFutures.size(); curIdx++) { @@ -248,8 +269,12 @@ private VisorValidateIndexesJobResult call0() throws Exception { Map idxRes = fut.get(); - idxResults.putAll(idxRes); + if (!idxRes.isEmpty() && idxRes.entrySet().stream().anyMatch(e -> !e.getValue().issues().isEmpty())) + idxResults.putAll(idxRes); } + + log.warning("ValidateIndexesClosure finished: processed " + totalPartitions + " partitions and " + + totalIndexes + " indexes."); } catch (InterruptedException | ExecutionException e) { for (int j = curPart; j < procPartFutures.size(); j++) @@ -258,15 +283,102 @@ private VisorValidateIndexesJobResult call0() throws Exception { for (int j = curIdx; j < procIdxFutures.size(); j++) procIdxFutures.get(j).cancel(false); - if (e instanceof InterruptedException) - throw new IgniteInterruptedException((InterruptedException)e); - else if (e.getCause() instanceof IgniteException) - throw (IgniteException)e.getCause(); - else - throw new IgniteException(e.getCause()); + throw unwrapFutureException(e); + } + + return new VisorValidateIndexesJobResult(partResults, idxResults, integrityCheckResults.values()); + } + + /** + * @param grpIds Group ids. + */ + private Map integrityCheckIndexesPartitions(Set grpIds) { + List>> integrityCheckFutures = new ArrayList<>(grpIds.size()); + + for (Integer grpId: grpIds) { + final CacheGroupContext grpCtx = ignite.context().cache().cacheGroup(grpId); + + if (grpCtx == null || !grpCtx.persistenceEnabled()) { + integrityCheckedIndexes.incrementAndGet(); + + continue; + } + + Future> checkFut = + calcExecutor.submit(new Callable>() { + @Override public T2 call() throws Exception { + IndexIntegrityCheckIssue issue = integrityCheckIndexPartition(grpCtx); + + return new T2<>(grpCtx.groupId(), issue); + } + }); + + integrityCheckFutures.add(checkFut); + } + + Map integrityCheckResults = new HashMap<>(); + + int curFut = 0; + try { + for (Future> fut : integrityCheckFutures) { + T2 res = fut.get(); + + if (res.getValue() != null) + integrityCheckResults.put(res.getKey(), res.getValue()); + } + } + catch (InterruptedException | ExecutionException e) { + for (int j = curFut; j < integrityCheckFutures.size(); j++) + integrityCheckFutures.get(j).cancel(false); + + throw unwrapFutureException(e); + } + + return integrityCheckResults; + } + + /** + * @param gctx Cache group context. + */ + private IndexIntegrityCheckIssue integrityCheckIndexPartition(CacheGroupContext gctx) { + GridKernalContext ctx = ignite.context(); + GridCacheSharedContext cctx = ctx.cache().context(); + + try { + FilePageStoreManager pageStoreMgr = (FilePageStoreManager)cctx.pageStore(); + + if (pageStoreMgr == null) + return null; + + int pageSz = gctx.dataRegion().pageMemory().pageSize(); + + PageStore pageStore = pageStoreMgr.getStore(gctx.groupId(), PageIdAllocator.INDEX_PARTITION); + + long pageId = PageIdUtils.pageId(PageIdAllocator.INDEX_PARTITION, PageIdAllocator.FLAG_IDX, 0); + + ByteBuffer buf = ByteBuffer.allocateDirect(pageSz); + + buf.order(ByteOrder.nativeOrder()); + + for (int pageNo = 0; pageNo < pageStore.pages(); pageId++, pageNo++) { + buf.clear(); + + pageStore.read(pageId, buf, true); + } + + return null; } + catch (Throwable t) { + log.error("Integrity check of index partition of cache group " + gctx.cacheOrGroupName() + " failed", t); + + return new IndexIntegrityCheckIssue(gctx.cacheOrGroupName(), t); + } + finally { + integrityCheckedIndexes.incrementAndGet(); - return new VisorValidateIndexesJobResult(partResults, idxResults); + printProgressIfNeeded("Current progress of ValidateIndexesClosure: checked integrity of " + + integrityCheckedIndexes.get() + " index partitions of " + totalCacheGrps + " cache groups"); + } } /** @@ -371,6 +483,19 @@ else if (current++ % checkThrough > 0) if (cacheCtx == null) throw new IgniteException("Unknown cacheId of CacheDataRow: " + cacheId); + if (row.link() == 0L) { + String errMsg = "Invalid partition row, possibly deleted"; + + log.error(errMsg); + + IndexValidationIssue is = new IndexValidationIssue(null, cacheCtx.name(), null, + new IgniteCheckedException(errMsg)); + + enoughIssues |= partRes.reportIssue(is); + + continue; + } + try { QueryTypeDescriptorImpl res = (QueryTypeDescriptorImpl)m.invoke( qryProcessor, cacheCtx.name(), cacheCtx.cacheObjectContext(), row.key(), row.value(), true); @@ -392,6 +517,9 @@ else if (current++ % checkThrough > 0) ArrayList indexes = gridH2Tbl.getIndexes(); for (Index idx : indexes) { + if (!(idx instanceof H2TreeIndex)) + continue; + try { Cursor cursor = idx.find((Session) null, h2Row, h2Row); @@ -434,7 +562,7 @@ else if (current++ % checkThrough > 0) finally { part.release(); - printProgressIfNeeded(); + printProgressOfIndexValidationIfNeeded(); } PartitionKey partKey = new PartitionKey(grpCtx.groupId(), part.id(), grpCtx.cacheOrGroupName()); @@ -447,16 +575,21 @@ else if (current++ % checkThrough > 0) /** * */ - private void printProgressIfNeeded() { - long curTs = U.currentTimeMillis(); + private void printProgressOfIndexValidationIfNeeded() { + printProgressIfNeeded("Current progress of ValidateIndexesClosure: processed " + + processedPartitions.get() + " of " + totalPartitions + " partitions, " + + processedIndexes.get() + " of " + totalIndexes + " SQL indexes"); + } + /** + * + */ + private void printProgressIfNeeded(String msg) { + long curTs = U.currentTimeMillis(); long lastTs = lastProgressPrintTs.get(); - if (curTs - lastTs >= 60_000 && lastProgressPrintTs.compareAndSet(lastTs, curTs)) { - log.warning("Current progress of ValidateIndexesClosure: processed " + - processedPartitions.get() + " of " + totalPartitions + " partitions, " + - processedIndexes.get() + " of " + totalIndexes + " SQL indexes"); - } + if (curTs - lastTs >= 60_000 && lastProgressPrintTs.compareAndSet(lastTs, curTs)) + log.warning(msg); } /** @@ -546,12 +679,14 @@ else if (current++ % checkThrough > 0) h2key = h2Row.key(); - CacheDataRow cacheDataStoreRow = ctx.group().offheap().read(ctx, h2key); + if (h2Row.link() != 0L) { + CacheDataRow cacheDataStoreRow = ctx.group().offheap().read(ctx, h2key); - if (cacheDataStoreRow == null) - throw new IgniteCheckedException("Key is present in SQL index, but can't be found in CacheDataTree."); - - previousKey = h2key; + if (cacheDataStoreRow == null) + throw new IgniteCheckedException("Key is present in SQL index, but can't be found in CacheDataTree."); + } + else + throw new IgniteCheckedException("Invalid index row, possibly deleted " + h2Row); } catch (Throwable t) { Object o = CacheObjectUtils.unwrapBinaryIfNeeded( @@ -564,14 +699,34 @@ else if (current++ % checkThrough > 0) enoughIssues |= idxValidationRes.reportIssue(is); } + finally { + previousKey = h2key; + } } String uniqueIdxName = "[cache=" + ctx.name() + ", idx=" + idx.getName() + "]"; processedIndexes.incrementAndGet(); - printProgressIfNeeded(); + printProgressOfIndexValidationIfNeeded(); return Collections.singletonMap(uniqueIdxName, idxValidationRes); } + + /** + * @param e Future result exception. + * @return Unwrapped exception. + */ + private IgniteException unwrapFutureException(Exception e) { + assert e instanceof InterruptedException || e instanceof ExecutionException : "Expecting either InterruptedException " + + "or ExecutionException"; + + if (e instanceof InterruptedException) + return new IgniteInterruptedException((InterruptedException)e); + else if (e.getCause() instanceof IgniteException) + return (IgniteException)e.getCause(); + else + return new IgniteException(e.getCause()); + } + } diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesTask.java b/modules/indexing/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesTask.java index abb7f7ee55ec1..922c53e15ed97 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesTask.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/visor/verify/VisorValidateIndexesTask.java @@ -17,16 +17,22 @@ package org.apache.ignite.internal.visor.verify; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import org.apache.ignite.IgniteException; +import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.compute.ComputeJobResult; import org.apache.ignite.internal.processors.task.GridInternal; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorMultiNodeTask; +import org.apache.ignite.internal.visor.VisorTaskArgument; import org.jetbrains.annotations.Nullable; /** @@ -58,6 +64,29 @@ public class VisorValidateIndexesTask extends VisorMultiNodeTask jobNodes(VisorTaskArgument arg) { + Collection srvNodes = ignite.cluster().forServers().nodes(); + Collection ret = new ArrayList<>(srvNodes.size()); + + VisorValidateIndexesTaskArg taskArg = arg.getArgument(); + + Set nodeIds = taskArg.getNodes() != null ? new HashSet<>(taskArg.getNodes()) : null; + + if (nodeIds == null) { + for (ClusterNode node : srvNodes) + ret.add(node.id()); + } + else { + for (ClusterNode node : srvNodes) { + if (nodeIds.contains(node.id())) + ret.add(node.id()); + } + } + + return ret; + } + /** * */ diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityKeyNameAndValueFieldNameConflictTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityKeyNameAndValueFieldNameConflictTest.java new file mode 100644 index 0000000000000..ff147e7ba7a76 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AffinityKeyNameAndValueFieldNameConflictTest.java @@ -0,0 +1,269 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.io.Serializable; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.function.BiFunction; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheKeyConfiguration; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.affinity.AffinityKeyMapped; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.cache.query.annotations.QuerySqlField; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * IGNITE-7793 SQL does not work if value has sql field which name equals to affinity keyProducer name + */ +@RunWith(JUnit4.class) +public class AffinityKeyNameAndValueFieldNameConflictTest extends GridCommonAbstractTest { + /** */ + private static final String PERSON_CACHE = "person"; + + /** */ + private Class keyCls; + + /** */ + private BiFunction keyProducer; + + /** */ + private boolean qryEntityCfg; + + /** */ + private boolean keyFieldSpecified; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + CacheConfiguration ccfg = new CacheConfiguration(PERSON_CACHE); + + if (qryEntityCfg) { + CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(keyCls.getName(), "name"); + cfg.setCacheKeyConfiguration(keyCfg); + + QueryEntity entity = new QueryEntity(); + entity.setKeyType(keyCls.getName()); + entity.setValueType(Person.class.getName()); + if (keyFieldSpecified) + entity.setKeyFields(Stream.of("name").collect(Collectors.toSet())); + + entity.addQueryField("id", Integer.class.getName(), null); + entity.addQueryField("name", String.class.getName(), null); + + ccfg.setQueryEntities(F.asList(entity)); + } else { + CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(keyCls); + cfg.setCacheKeyConfiguration(keyCfg); + + ccfg.setIndexedTypes(keyCls, Person.class); + } + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** + * @throws Exception If failed. + */ + @Test + public void testQueryEntityConfig() throws Exception { + qryEntityCfg = true; + keyCls = PersonKey1.class; + keyProducer = PersonKey1::new; + checkQuery(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testQueryEntityConfigKeySpecified() throws Exception { + qryEntityCfg = true; + keyFieldSpecified = true; + keyCls = PersonKey1.class; + keyProducer = PersonKey1::new; + checkQuery(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testAnnotationConfig() throws Exception { + keyCls = PersonKey1.class; + keyProducer = PersonKey1::new; + checkQuery(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testAnnotationConfigCollision() throws Exception { + keyCls = PersonKey2.class; + keyProducer = PersonKey2::new; + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + checkQuery(); + + return null; + } + }, CacheException.class, "Property with name 'name' already exists."); + } + + /** + * @throws Exception If failed. + */ + private void checkQuery() throws Exception { + startGrid(2); + + Ignite g = grid(2); + + IgniteCache personCache = g.cache(PERSON_CACHE); + + personCache.put(keyProducer.apply(1, "o1"), new Person("p1")); + + SqlFieldsQuery query = new SqlFieldsQuery("select * from \"" + PERSON_CACHE + "\"." + Person.class.getSimpleName() + " it where it.name=?"); + + List> result = personCache.query(query.setArgs(keyFieldSpecified ? "o1" : "p1")).getAll(); + + assertEquals(1, result.size()); + + stopAllGrids(); + } + + /** + * + */ + public static class PersonKey1 { + /** */ + @QuerySqlField + private int id; + + /** */ + @AffinityKeyMapped + private String name; + + /** + * @param id Key. + * @param name Affinity keyProducer. + */ + public PersonKey1(int id, String name) { + this.id = id; + this.name = name; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (o == null || getClass() != o.getClass()) + return false; + + PersonKey1 other = (PersonKey1)o; + + return id == other.id; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return id; + } + } + + /** + * + */ + public static class PersonKey2 { + /** */ + @QuerySqlField + private int id; + + /** */ + @QuerySqlField + @AffinityKeyMapped + private String name; + + /** + * @param id Key. + * @param name Affinity keyProducer. + */ + public PersonKey2(int id, String name) { + this.id = id; + this.name = name; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (o == null || getClass() != o.getClass()) + return false; + + PersonKey2 other = (PersonKey2)o; + + return id == other.id; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return id; + } + } + + /** + * + */ + private static class Person implements Serializable { + + /** */ + @QuerySqlField + String name; + + /** + * @param name name. + */ + public Person(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(Person.class, this); + } + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BigEntryQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BigEntryQueryTest.java index 3b5562a3035b8..4e443f9b113cb 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BigEntryQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BigEntryQueryTest.java @@ -39,10 +39,14 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.EventType; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * This is a specific test for IGNITE-8900. */ +@RunWith(JUnit4.class) public class BigEntryQueryTest extends GridCommonAbstractTest { /** */ public static final String CACHE = "cache"; @@ -55,6 +59,7 @@ public class BigEntryQueryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testBigEntriesSelect() throws Exception { startGrids(2); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataConcurrentUpdateWithIndexesTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataConcurrentUpdateWithIndexesTest.java new file mode 100644 index 0000000000000..861f16a1e4517 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataConcurrentUpdateWithIndexesTest.java @@ -0,0 +1,440 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.net.Socket; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.binary.BinaryObject; +import org.apache.ignite.binary.BinaryObjectBuilder; +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.BinaryType; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.QueryIndex; +import org.apache.ignite.cache.QueryIndexType; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.events.EventType; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.binary.BinaryMetadata; +import org.apache.ignite.internal.managers.discovery.CustomMessageWrapper; +import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; +import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl; +import org.apache.ignite.internal.processors.cache.binary.MetadataUpdateProposedMessage; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiClosure; +import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static org.apache.ignite.testframework.GridTestUtils.runAsync; +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; + +/** + * Tests scenario for too early metadata update completion in case of multiple concurrent updates for the same schema. + *

    + * Scenario is the following: + * + *

      + *
    • Start 4 nodes, connect client to node 2 in topology order (starting from 1).
    • + *
    • Start two concurrent transactions from client node producing same schema update.
    • + *
    • Delay second update until first update will return to client with stamped propose message and writes new + * schema to local metadata cache
    • + *
    • Unblock second update. It should correctly wait until the metadata is applied on all + * nodes or tx will fail on commit.
    • + *
    + */ +@RunWith(JUnit4.class) +public class BinaryMetadataConcurrentUpdateWithIndexesTest extends GridCommonAbstractTest { + /** */ + private static final int FIELDS = 2; + + /** */ + private static final int MB = 1024 * 1024; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + cfg.setIncludeEventTypes(EventType.EVTS_DISCOVERY); + + BlockTcpDiscoverySpi spi = new BlockTcpDiscoverySpi(); + + Field rndAddrsField = U.findField(BlockTcpDiscoverySpi.class, "skipAddrsRandomization"); + + assertNotNull(rndAddrsField); + + rndAddrsField.set(spi, true); + + cfg.setDiscoverySpi(spi.setIpFinder(sharedStaticIpFinder)); + + cfg.setClientMode(igniteInstanceName.startsWith("client")); + + QueryEntity qryEntity = new QueryEntity("java.lang.Integer", "Value"); + + LinkedHashMap fields = new LinkedHashMap<>(); + + Collection indexes = new ArrayList<>(FIELDS); + + for (int i = 0; i < FIELDS; i++) { + String name = "s" + i; + + fields.put(name, "java.lang.String"); + + indexes.add(new QueryIndex(name, QueryIndexType.SORTED)); + } + + qryEntity.setFields(fields); + + qryEntity.setIndexes(indexes); + + cfg.setDataStorageConfiguration(new DataStorageConfiguration(). + setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(50 * MB))); + + cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME). + setBackups(0). + setQueryEntities(Collections.singleton(qryEntity)). + setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL). + setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC). + setCacheMode(CacheMode.PARTITIONED)); + + return cfg; + } + + /** Flag to start syncing metadata requests. Should skip on exchange. */ + private volatile boolean syncMeta; + + /** Metadata init latch. Both threads must request initial metadata. */ + private CountDownLatch initMetaReq = new CountDownLatch(2); + + /** Thread local flag for need of waiting local metadata update. */ + private ThreadLocal delayMetadataUpdateThreadLoc = new ThreadLocal<>(); + + /** Latch for waiting local metadata update. */ + public static final CountDownLatch localMetaUpdatedLatch = new CountDownLatch(1); + + /** */ + @Test + public void testMissingSchemaUpdate() throws Exception { + // Start order is important. + Ignite node0 = startGrid("node0"); + + Ignite node1 = startGrid("node1"); + + IgniteEx client0 = startGrid("client0"); + + CacheObjectBinaryProcessorImpl.TestBinaryContext clientCtx = + (CacheObjectBinaryProcessorImpl.TestBinaryContext)((CacheObjectBinaryProcessorImpl)client0.context(). + cacheObjects()).binaryContext(); + + clientCtx.addListener(new CacheObjectBinaryProcessorImpl.TestBinaryContext.TestBinaryContextListener() { + @Override public void onAfterMetadataRequest(int typeId, BinaryType type) { + if (syncMeta) { + try { + initMetaReq.countDown(); + + initMetaReq.await(); + } + catch (Exception e) { + throw new BinaryObjectException(e); + } + } + } + + @Override public void onBeforeMetadataUpdate(int typeId, BinaryMetadata metadata) { + // Delay one of updates until schema is locally updated on propose message. + if (delayMetadataUpdateThreadLoc.get() != null) + await(localMetaUpdatedLatch, 5000); + } + }); + + Ignite node2 = startGrid("node2"); + + Ignite node3 = startGrid("node3"); + + startGrid("node4"); + + node0.cluster().active(true); + + awaitPartitionMapExchange(); + + syncMeta = true; + + CountDownLatch clientProposeMsgBlockedLatch = new CountDownLatch(1); + + AtomicBoolean clientWait = new AtomicBoolean(); + final Object clientMux = new Object(); + + AtomicBoolean srvWait = new AtomicBoolean(); + final Object srvMux = new Object(); + + ((BlockTcpDiscoverySpi)node1.configuration().getDiscoverySpi()).setClosure((snd, msg) -> { + if (msg instanceof MetadataUpdateProposedMessage) { + if (Thread.currentThread().getName().contains("client")) { + log.info("Block custom message to client0: [locNode=" + snd + ", msg=" + msg + ']'); + + clientProposeMsgBlockedLatch.countDown(); + + // Message to client + synchronized (clientMux) { + while (!clientWait.get()) + try { + clientMux.wait(); + } + catch (InterruptedException e) { + fail(); + } + } + } + } + + return null; + }); + + ((BlockTcpDiscoverySpi)node2.configuration().getDiscoverySpi()).setClosure((snd, msg) -> { + if (msg instanceof MetadataUpdateProposedMessage) { + MetadataUpdateProposedMessage msg0 = (MetadataUpdateProposedMessage)msg; + + int pendingVer = U.field(msg0, "pendingVer"); + + // Should not block propose messages until they reach coordinator. + if (pendingVer == 0) + return null; + + log.info("Block custom message to next server: [locNode=" + snd + ", msg=" + msg + ']'); + + // Message to client + synchronized (srvMux) { + while (!srvWait.get()) + try { + srvMux.wait(); + } + catch (InterruptedException e) { + fail(); + } + } + } + + return null; + }); + + Integer key = primaryKey(node3.cache(DEFAULT_CACHE_NAME)); + + IgniteInternalFuture fut0 = runAsync(() -> { + try (Transaction tx = client0.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + client0.cache(DEFAULT_CACHE_NAME).put(key, build(client0, "val", 0)); + + tx.commit(); + } + catch (Throwable t) { + log.error("err", t); + } + + }); + + // Implements test logic. + IgniteInternalFuture fut1 = runAsync(() -> { + // Wait for initial metadata received. It should be initial version: pending=0, accepted=0 + await(initMetaReq, 5000); + + // Wait for blocking proposal message to client node. + await(clientProposeMsgBlockedLatch, 5000); + + // Unblock proposal message to client. + clientWait.set(true); + + synchronized (clientMux) { + clientMux.notify(); + } + + // Give some time to apply update. + doSleep(3000); + + // Unblock second metadata update. + localMetaUpdatedLatch.countDown(); + + // Give some time for tx to complete (success or fail). fut2 will throw an error if tx has failed on commit. + doSleep(3000); + + // Unblock metadata message and allow for correct version acceptance. + srvWait.set(true); + + synchronized (srvMux) { + srvMux.notify(); + } + }); + + IgniteInternalFuture fut2 = runAsync(() -> { + delayMetadataUpdateThreadLoc.set(true); + + try (Transaction tx = client0.transactions(). + txStart(PESSIMISTIC, REPEATABLE_READ, 0, 1)) { + client0.cache(DEFAULT_CACHE_NAME).put(key, build(client0, "val", 0)); + + tx.commit(); + } + }); + + fut0.get(); + fut1.get(); + fut2.get(); + } + + /** + * @param latch Latch. + * @param timeout Timeout. + */ + private void await(CountDownLatch latch, long timeout) { + try { + latch.await(5000, MILLISECONDS); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + + long cnt = initMetaReq.getCount(); + + if (cnt != 0) + throw new RuntimeException("Invalid latch count after wait: " + cnt); + } + + /** + * @param ignite Ignite. + * @param prefix Value prefix. + * @param fields Fields. + */ + protected BinaryObject build(Ignite ignite, String prefix, int... fields) { + BinaryObjectBuilder builder = ignite.binary().builder("Value"); + + for (int field : fields) { + assertTrue(field < FIELDS); + + builder.setField("i" + field, field); + builder.setField("s" + field, prefix + field); + } + + return builder.build(); + } + + /** + * Discovery SPI which can simulate network split. + */ + protected class BlockTcpDiscoverySpi extends TcpDiscoverySpi { + /** Closure. */ + private volatile IgniteBiClosure clo; + + /** + * @param clo Closure. + */ + public void setClosure(IgniteBiClosure clo) { + this.clo = clo; + } + + /** + * @param addr Address. + * @param msg Message. + */ + private synchronized void apply(ClusterNode addr, TcpDiscoveryAbstractMessage msg) { + if (!(msg instanceof TcpDiscoveryCustomEventMessage)) + return; + + TcpDiscoveryCustomEventMessage cm = (TcpDiscoveryCustomEventMessage)msg; + + DiscoveryCustomMessage delegate; + + try { + DiscoverySpiCustomMessage custMsg = cm.message(marshaller(), U.resolveClassLoader(ignite().configuration())); + + assertNotNull(custMsg); + + delegate = ((CustomMessageWrapper)custMsg).delegate(); + + } + catch (Throwable throwable) { + throw new RuntimeException(throwable); + } + + if (clo != null) + clo.apply(addr, delegate); + } + + /** {@inheritDoc} */ + @Override protected void writeToSocket( + Socket sock, + TcpDiscoveryAbstractMessage msg, + byte[] data, + long timeout + ) throws IOException { + if (spiCtx != null) + apply(spiCtx.localNode(), msg); + + super.writeToSocket(sock, msg, data, timeout); + } + + /** {@inheritDoc} */ + @Override protected void writeToSocket(Socket sock, + OutputStream out, + TcpDiscoveryAbstractMessage msg, + long timeout) throws IOException, IgniteCheckedException { + if (spiCtx != null) + apply(spiCtx.localNode(), msg); + + super.writeToSocket(sock, out, msg, timeout); + } + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + CacheObjectBinaryProcessorImpl.useTestBinaryCtx = true; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + CacheObjectBinaryProcessorImpl.useTestBinaryCtx = false; + + stopAllGrids(); + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinarySerializationQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinarySerializationQuerySelfTest.java index 4b3c881bf217d..74c834a25e803 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinarySerializationQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinarySerializationQuerySelfTest.java @@ -56,10 +56,14 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for query with BinaryMarshaller and different serialization modes. */ +@RunWith(JUnit4.class) public class BinarySerializationQuerySelfTest extends GridCommonAbstractTest { /** Ignite instance. */ private Ignite ignite; @@ -159,6 +163,7 @@ private static QueryEntity entityForClass(Class cls) { * * @throws Exception If failed. */ + @Test public void testPlain() throws Exception { check(EntityPlain.class); } @@ -168,6 +173,7 @@ public void testPlain() throws Exception { * * @throws Exception If failed. */ + @Test public void testSerializable() throws Exception { check(EntitySerializable.class); } @@ -177,6 +183,7 @@ public void testSerializable() throws Exception { * * @throws Exception If failed. */ + @Test public void testExternalizable() throws Exception { check(EntityExternalizable.class); } @@ -186,6 +193,7 @@ public void testExternalizable() throws Exception { * * @throws Exception If failed. */ + @Test public void testBinarylizable() throws Exception { check(EntityBinarylizable.class); } @@ -195,6 +203,7 @@ public void testBinarylizable() throws Exception { * * @throws Exception If failed. */ + @Test public void testWriteReadObject() throws Exception { check(EntityWriteReadObject.class); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryTypeMismatchLoggingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryTypeMismatchLoggingTest.java index 7a41a6ab726b6..bf9796da3c23e 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryTypeMismatchLoggingTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryTypeMismatchLoggingTest.java @@ -34,11 +34,14 @@ import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests of binary type mismatch logging. */ +@RunWith(JUnit4.class) public class BinaryTypeMismatchLoggingTest extends GridCommonAbstractTest { /** */ public static final String MESSAGE_PAYLOAD_VALUE = "expValType=Payload, actualValType=o.a.i.i.processors.cache.BinaryTypeMismatchLoggingTest$Payload"; @@ -49,6 +52,7 @@ public class BinaryTypeMismatchLoggingTest extends GridCommonAbstractTest { /** * @throws Exception In case of an error. */ + @Test public void testValueReadCreateTable() throws Exception { Ignite ignite = startGrid(0); @@ -74,6 +78,7 @@ public void testValueReadCreateTable() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void testValueReadQueryEntities() throws Exception { Ignite ignite = startGrid(0); @@ -102,6 +107,7 @@ public void testValueReadQueryEntities() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void testEntryReadCreateTable() throws Exception { Ignite ignite = startGrid(0); @@ -127,6 +133,7 @@ public void testEntryReadCreateTable() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void testEntryReadQueryEntities() throws Exception { Ignite ignite = startGrid(0); @@ -156,6 +163,7 @@ public void testEntryReadQueryEntities() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void testValueWriteCreateTable() throws Exception { Ignite ignite = startGridWithLogCapture(); @@ -185,6 +193,7 @@ public void testValueWriteCreateTable() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void testValueWriteQueryEntities() throws Exception { Ignite ignite = startGridWithLogCapture(); @@ -209,6 +218,7 @@ public void testValueWriteQueryEntities() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void testEntryWriteCreateTable() throws Exception { Ignite ignite = startGridWithLogCapture(); @@ -242,6 +252,7 @@ public void testEntryWriteCreateTable() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void testEntryWriteQueryEntities() throws Exception { Ignite ignite = startGridWithLogCapture(); @@ -277,6 +288,7 @@ public void testEntryWriteQueryEntities() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void testEntryWriteCacheIsolation() throws Exception { Ignite ignite = startGridWithLogCapture(); @@ -309,6 +321,7 @@ public void testEntryWriteCacheIsolation() throws Exception { /** * @throws Exception In case of an error. */ + @Test public void testValueWriteMultipleQueryEntities() throws Exception { Ignite ignite = startGridWithLogCapture(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryDetailMetricsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryDetailMetricsSelfTest.java index 837de6544a246..7fd25282dd27a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryDetailMetricsSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryDetailMetricsSelfTest.java @@ -31,17 +31,18 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.util.lang.GridAbsPredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * Tests for cache query details metrics. */ +@RunWith(JUnit4.class) public abstract class CacheAbstractQueryDetailMetricsSelfTest extends GridCommonAbstractTest { /** */ private static final int QRY_DETAIL_METRICS_SIZE = 3; @@ -52,9 +53,6 @@ public abstract class CacheAbstractQueryDetailMetricsSelfTest extends GridCommon /** Cache mode. */ protected CacheMode cacheMode; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startGridsMultiThreaded(gridCnt); @@ -94,12 +92,6 @@ private CacheConfiguration configureCache(String cacheName) { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(configureCache("A"), configureCache("B")); return cfg; @@ -110,6 +102,7 @@ private CacheConfiguration configureCache(String cacheName) { * * @throws Exception In case of error. */ + @Test public void testSqlFieldsQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -123,6 +116,7 @@ public void testSqlFieldsQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlFieldsQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -137,6 +131,7 @@ public void testSqlFieldsQueryNotFullyFetchedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlFieldsQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -150,6 +145,7 @@ public void testSqlFieldsQueryFailedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testQueryMetricsEviction() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -258,6 +254,7 @@ private static class Worker extends Thread { * * @throws Exception In case of error. */ + @Test public void testQueryMetricsMultithreaded() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -286,6 +283,7 @@ public void testQueryMetricsMultithreaded() throws Exception { * * @throws Exception In case of error. */ + @Test public void testScanQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -299,6 +297,7 @@ public void testScanQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testScanQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -313,6 +312,7 @@ public void testScanQueryNotFullyFetchedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testScanQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -326,6 +326,7 @@ public void testScanQueryFailedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -339,6 +340,7 @@ public void testSqlQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -353,6 +355,7 @@ public void testSqlQueryNotFullyFetchedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -366,6 +369,7 @@ public void testSqlQueryFailedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testTextQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -379,6 +383,7 @@ public void testTextQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testTextQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -393,6 +398,7 @@ public void testTextQueryNotFullyFetchedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testTextQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -406,6 +412,7 @@ public void testTextQueryFailedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlFieldsCrossCacheQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -419,6 +426,7 @@ public void testSqlFieldsCrossCacheQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlFieldsCrossCacheQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -433,6 +441,7 @@ public void testSqlFieldsCrossCacheQueryNotFullyFetchedMetrics() throws Exceptio * * @throws Exception In case of error. */ + @Test public void testSqlFieldsCrossCacheQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java index eb3c8d6d3ccbe..702199fd1a221 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java @@ -31,17 +31,18 @@ import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryMetricsAdapter; import org.apache.ignite.internal.util.lang.GridAbsPredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * Tests for cache query metrics. */ +@RunWith(JUnit4.class) public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstractTest { /** Grid count. */ protected int gridCnt; @@ -49,9 +50,6 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra /** Cache mode. */ protected CacheMode cacheMode; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startGridsMultiThreaded(gridCnt); @@ -74,12 +72,6 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg1 = defaultCacheConfiguration(); cacheCfg1.setName("A"); @@ -106,6 +98,7 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra * * @throws Exception In case of error. */ + @Test public void testSqlFieldsQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -119,6 +112,7 @@ public void testSqlFieldsQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlFieldsQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -133,6 +127,7 @@ public void testSqlFieldsQueryNotFullyFetchedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlFieldsQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -146,6 +141,7 @@ public void testSqlFieldsQueryFailedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testScanQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -159,6 +155,7 @@ public void testScanQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testScanQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -173,6 +170,7 @@ public void testScanQueryNotFullyFetchedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testScanQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -186,6 +184,7 @@ public void testScanQueryFailedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -199,6 +198,7 @@ public void testSqlQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -213,6 +213,7 @@ public void testSqlQueryNotFullyFetchedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -226,6 +227,7 @@ public void testSqlQueryFailedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testTextQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -239,6 +241,7 @@ public void testTextQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testTextQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -253,6 +256,7 @@ public void testTextQueryNotFullyFetchedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testTextQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -266,6 +270,7 @@ public void testTextQueryFailedMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlFieldsCrossCacheQueryMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -279,6 +284,7 @@ public void testSqlFieldsCrossCacheQueryMetrics() throws Exception { * * @throws Exception In case of error. */ + @Test public void testSqlFieldsCrossCacheQueryNotFullyFetchedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -293,6 +299,7 @@ public void testSqlFieldsCrossCacheQueryNotFullyFetchedMetrics() throws Exceptio * * @throws Exception In case of error. */ + @Test public void testSqlFieldsCrossCacheQueryFailedMetrics() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); @@ -326,6 +333,7 @@ private static class Worker extends Thread { * * @throws Exception In case of error. */ + @Test public void testQueryMetricsMultithreaded() throws Exception { IgniteCache cache = grid(0).context().cache().jcache("A"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheBinaryKeyConcurrentQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheBinaryKeyConcurrentQueryTest.java index 0582132acedb3..cdf585fa44a9f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheBinaryKeyConcurrentQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheBinaryKeyConcurrentQueryTest.java @@ -38,11 +38,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -53,10 +53,8 @@ * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class CacheBinaryKeyConcurrentQueryTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 3; @@ -67,8 +65,6 @@ public class CacheBinaryKeyConcurrentQueryTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setMarshaller(null); return cfg; @@ -84,6 +80,7 @@ public class CacheBinaryKeyConcurrentQueryTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPutAndQueries() throws Exception { Ignite ignite = ignite(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java index 3777154780487..765e3f73d03ca 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationP2PTest.java @@ -33,12 +33,16 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; /** * */ +@RunWith(JUnit4.class) public class CacheConfigurationP2PTest extends GridCommonAbstractTest { /** */ public static final String NODE_START_MSG = "Test external node started"; @@ -75,6 +79,7 @@ static IgniteConfiguration createConfiguration() { /** * @throws Exception If failed. */ + @Test public void testCacheConfigurationP2P() throws Exception { fail("Enable when IGNITE-537 is fixed."); @@ -181,4 +186,4 @@ public void testCacheConfigurationP2P() throws Exception { } } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheIndexStreamerTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheIndexStreamerTest.java index dda7eedc30c23..65e239ec04a4c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheIndexStreamerTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheIndexStreamerTest.java @@ -25,14 +25,13 @@ import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -41,22 +40,12 @@ /** * */ +@RunWith(JUnit4.class) public class CacheIndexStreamerTest extends GridCommonAbstractTest { - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** * @throws Exception If failed. */ + @Test public void testStreamerAtomic() throws Exception { checkStreamer(ATOMIC); } @@ -64,6 +53,7 @@ public void testStreamerAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStreamerTx() throws Exception { checkStreamer(TRANSACTIONAL); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheIteratorScanQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheIteratorScanQueryTest.java index c6cd87bf067cf..6f7c84d3a4a59 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheIteratorScanQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheIteratorScanQueryTest.java @@ -31,6 +31,9 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -38,6 +41,7 @@ /** * Node filter test. */ +@RunWith(JUnit4.class) public class CacheIteratorScanQueryTest extends GridCommonAbstractTest { /** Client mode. */ private boolean client = false; @@ -75,6 +79,7 @@ public CacheIteratorScanQueryTest() { /** * @throws Exception If failed. */ + @Test public void testScanQuery() throws Exception { Ignite server = startGrid(0); @@ -108,6 +113,7 @@ public void testScanQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryGetAllClientSide() throws Exception { Ignite server = startGrid(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingBaseTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingBaseTest.java index f456c56433b6c..ce1f86a1daacf 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingBaseTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingBaseTest.java @@ -25,9 +25,6 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -37,9 +34,6 @@ * Tests various cache operations with indexing enabled. */ public abstract class CacheOffheapBatchIndexingBaseTest extends GridCommonAbstractTest { - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * Load data into cache * @@ -62,8 +56,6 @@ protected void preload(String name) { cfg.setPeerClassLoadingEnabled(false); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - return cfg; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingMultiTypeTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingMultiTypeTest.java index 87d10a14f66e8..f0a68ad10741a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingMultiTypeTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingMultiTypeTest.java @@ -21,16 +21,20 @@ import java.util.TreeMap; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; -import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests various cache operations with indexing enabled. * Cache contain multiple types. */ +@RunWith(JUnit4.class) public class CacheOffheapBatchIndexingMultiTypeTest extends CacheOffheapBatchIndexingBaseTest { /** * Tests putAll with multiple indexed entities and streamer pre-loading with low off-heap cache size. */ + @Test public void testPutAllMultupleEntitiesAndStreamer() { doStreamerBatchTest(50, 1_000, new Class[] { Integer.class, CacheOffheapBatchIndexingBaseTest.Person.class, @@ -41,6 +45,7 @@ public void testPutAllMultupleEntitiesAndStreamer() { /** * Tests putAll after with streamer batch load with one entity. */ + @Test public void testPuAllSingleEntity() { doStreamerBatchTest(50, 1_000, @@ -90,4 +95,4 @@ private void doStreamerBatchTest(int iterations, cache.destroy(); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingSingleTypeTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingSingleTypeTest.java index acf33dc380db0..f07e041dfddfb 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingSingleTypeTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapBatchIndexingSingleTypeTest.java @@ -27,17 +27,22 @@ import org.apache.ignite.cache.query.QueryCursor; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests various cache operations with indexing enabled. * Cache contains single type. */ +@RunWith(JUnit4.class) public class CacheOffheapBatchIndexingSingleTypeTest extends CacheOffheapBatchIndexingBaseTest { /** * Tests removal using EntryProcessor. * * @throws Exception If failed. */ + @Test public void testBatchRemove() throws Exception { Ignite ignite = grid(0); @@ -84,6 +89,7 @@ public void testBatchRemove() throws Exception { /** * */ + @Test public void testPutAllAndStreamer() { doStreamerBatchTest(50, 1_000, @@ -94,6 +100,7 @@ public void testPutAllAndStreamer() { /** * */ + @Test public void testPuAllSingleEntity() { doStreamerBatchTest(50, 1_000, @@ -144,4 +151,4 @@ private void doStreamerBatchTest(int iterations, cache.destroy(); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOperationsWithExpirationTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOperationsWithExpirationTest.java index 6a04126d37ebf..7167fcfd206b7 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOperationsWithExpirationTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheOperationsWithExpirationTest.java @@ -36,6 +36,9 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -44,6 +47,7 @@ /** * */ +@RunWith(JUnit4.class) public class CacheOperationsWithExpirationTest extends GridCommonAbstractTest { /** */ private static final int KEYS = 10_000; @@ -78,6 +82,7 @@ private CacheConfiguration cacheConfiguration(CacheAtom /** * @throws Exception If failed. */ + @Test public void testAtomicIndexEnabled() throws Exception { concurrentPutGetRemoveExpireAndQuery(cacheConfiguration(ATOMIC, true)); } @@ -85,6 +90,7 @@ public void testAtomicIndexEnabled() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomic() throws Exception { concurrentPutGetRemoveExpireAndQuery(cacheConfiguration(ATOMIC, false)); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryBuildValueTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryBuildValueTest.java index 3bbb007e776d2..e97366cfb77e0 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryBuildValueTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryBuildValueTest.java @@ -34,26 +34,22 @@ import org.apache.ignite.configuration.BinaryConfiguration; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheQueryBuildValueTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setMarshaller(null); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); QueryEntity entity = new QueryEntity(); @@ -99,6 +95,7 @@ public class CacheQueryBuildValueTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testBuilderAndQuery() throws Exception { Ignite node = ignite(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryEvictDataLostTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryEvictDataLostTest.java index 254b59ce8bf0c..99bb20be940c0 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryEvictDataLostTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryEvictDataLostTest.java @@ -31,10 +31,14 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheQueryEvictDataLostTest extends GridCommonAbstractTest { /** */ private static final int KEYS = 100_000; @@ -71,6 +75,7 @@ public CacheQueryEvictDataLostTest() { /** * @throws Exception If failed. */ + @Test public void testQueryDataLost() throws Exception { final long stopTime = U.currentTimeMillis() + 30_000; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryFilterExpiredTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryFilterExpiredTest.java index 47c87fa1cddc2..f9fed9fe39c90 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryFilterExpiredTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryFilterExpiredTest.java @@ -25,13 +25,12 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.lang.GridAbsPredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -39,22 +38,12 @@ /** * */ +@RunWith(JUnit4.class) public class CacheQueryFilterExpiredTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - /** * @throws Exception If failed. */ + @Test public void testFilterExpired() throws Exception { try (Ignite ignite = startGrid(0)) { checkFilterExpired(ignite, ATOMIC, false); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java index d33084026a72e..f5047bc013896 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java @@ -23,28 +23,16 @@ import org.apache.ignite.Ignition; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for the case when client is started after the cache is already created. */ +@RunWith(JUnit4.class) public class CacheQueryNewClientSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -53,6 +41,7 @@ public class CacheQueryNewClientSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testQueryFromNewClient() throws Exception { Ignite srv = startGrid("server"); @@ -88,6 +77,7 @@ public void testQueryFromNewClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryFromNewClientCustomSchemaName() throws Exception { Ignite srv = startGrid("server"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheRandomOperationsMultithreadedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheRandomOperationsMultithreadedTest.java index c2f31f73f060d..c450fd992bfa5 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheRandomOperationsMultithreadedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheRandomOperationsMultithreadedTest.java @@ -40,12 +40,12 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -55,10 +55,8 @@ /** * */ +@RunWith(JUnit4.class) public class CacheRandomOperationsMultithreadedTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int KEYS = 1000; @@ -72,8 +70,6 @@ public class CacheRandomOperationsMultithreadedTest extends GridCommonAbstractTe @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); return cfg; @@ -93,6 +89,7 @@ public class CacheRandomOperationsMultithreadedTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testAtomicOffheapEviction() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, ATOMIC, @@ -105,6 +102,7 @@ public void testAtomicOffheapEviction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAtomicOffheapEvictionIndexing() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, ATOMIC, @@ -117,6 +115,7 @@ public void testAtomicOffheapEvictionIndexing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxOffheapEviction() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, TRANSACTIONAL, @@ -129,6 +128,7 @@ public void testTxOffheapEviction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxOffheapEvictionIndexing() throws Exception { CacheConfiguration ccfg = cacheConfiguration(PARTITIONED, TRANSACTIONAL, diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java index 2e66b71457d21..ab2fa1fad6204 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java @@ -57,13 +57,16 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests partition scan query fallback. */ +@RunWith(JUnit4.class) public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 3; @@ -71,9 +74,6 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT /** Keys count. */ private static final int KEYS_CNT = 50 * RendezvousAffinityFunction.DFLT_PARTITION_COUNT; - /** Ip finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Backups. */ private int backups; @@ -101,10 +101,7 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT cfg.setClientMode(clientMode); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - discoSpi.setForceServerMode(true); - cfg.setDiscoverySpi(discoSpi); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); cfg.setCommunicationSpi(commSpiFactory.create()); @@ -128,6 +125,7 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT * * @throws Exception If failed. */ + @Test public void testScanLocal() throws Exception { cacheMode = CacheMode.PARTITIONED; backups = 0; @@ -155,6 +153,7 @@ public void testScanLocal() throws Exception { * * @throws Exception If failed. */ + @Test public void testScanLocalExplicit() throws Exception { cacheMode = CacheMode.PARTITIONED; backups = 0; @@ -190,6 +189,7 @@ public void testScanLocalExplicit() throws Exception { * * @throws Exception If failed. */ + @Test public void testScanLocalExplicitNoPart() throws Exception { cacheMode = CacheMode.PARTITIONED; backups = 0; @@ -215,6 +215,7 @@ public void testScanLocalExplicitNoPart() throws Exception { * * @throws Exception If failed. */ + @Test public void testScanRemote() throws Exception { cacheMode = CacheMode.PARTITIONED; backups = 0; @@ -244,6 +245,7 @@ public void testScanRemote() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testScanFallbackOnRebalancing() throws Exception { scanFallbackOnRebalancing(false); } @@ -341,6 +343,7 @@ private void scanFallbackOnRebalancing(final boolean cur) throws Exception { * * @throws Exception In case of error. */ + @Test public void testScanFallbackOnRebalancingCursor1() throws Exception { cacheMode = CacheMode.PARTITIONED; clientMode = false; @@ -408,6 +411,7 @@ public void testScanFallbackOnRebalancingCursor1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanFallbackOnRebalancingCursor2() throws Exception { scanFallbackOnRebalancing(true); } @@ -577,4 +581,4 @@ private static class TestFallbackOnRebalancingCommunicationSpiFactory implements return new TcpCommunicationSpi(); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheSqlQueryValueCopySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheSqlQueryValueCopySelfTest.java index 5b92726f85a11..8f188d297179e 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheSqlQueryValueCopySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheSqlQueryValueCopySelfTest.java @@ -34,18 +34,16 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.query.GridQueryProcessor; import org.apache.ignite.internal.processors.query.GridRunningQueryInfo; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests modification of values returned by query iterators with enabled copy on read. */ +@RunWith(JUnit4.class) public class CacheSqlQueryValueCopySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int KEYS = 100; @@ -56,8 +54,6 @@ public class CacheSqlQueryValueCopySelfTest extends GridCommonAbstractTest { if ("client".equals(cfg.getIgniteInstanceName())) cfg.setClientMode(true); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration cc = new CacheConfiguration<>(DEFAULT_CACHE_NAME); cc.setCopyOnRead(true); @@ -98,6 +94,7 @@ public class CacheSqlQueryValueCopySelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testTwoStepSqlClientQuery() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(DEFAULT_CACHE_NAME); @@ -128,6 +125,7 @@ public void testTwoStepSqlClientQuery() throws Exception { /** * Test two step query without local reduce phase. */ + @Test public void testTwoStepSkipReduceSqlQuery() { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -145,6 +143,7 @@ public void testTwoStepSkipReduceSqlQuery() { /** * Test two step query value copy. */ + @Test public void testTwoStepReduceSqlQuery() { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -163,6 +162,7 @@ public void testTwoStepReduceSqlQuery() { /** * Tests local sql query. */ + @Test public void testLocalSqlQuery() { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -182,6 +182,7 @@ public void testLocalSqlQuery() { /** * Tests local sql query. */ + @Test public void testLocalSqlFieldsQuery() { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -224,6 +225,7 @@ private IgniteInternalFuture runQueryAsync(final Query qry) throws Excepti * * @throws Exception If failed. */ + @Test public void testRunningSqlFieldsQuery() throws Exception { IgniteInternalFuture fut = runQueryAsync(new SqlFieldsQuery("select _val, sleep(1000) from Value limit 3")); @@ -264,6 +266,7 @@ public void testRunningSqlFieldsQuery() throws Exception { * * @throws Exception If failed. */ + @Test public void testRunningSqlQuery() throws Exception { IgniteInternalFuture fut = runQueryAsync(new SqlQuery(Value.class, "id > sleep(100)")); @@ -304,6 +307,7 @@ public void testRunningSqlQuery() throws Exception { * * @throws Exception If failed. */ + @Test public void testCancelingSqlFieldsQuery() throws Exception { runQueryAsync(new SqlFieldsQuery("select * from (select _val, sleep(100) from Value limit 50)")); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClientReconnectAfterClusterRestartTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClientReconnectAfterClusterRestartTest.java index 90121615d673d..ff1cc82749d65 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClientReconnectAfterClusterRestartTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClientReconnectAfterClusterRestartTest.java @@ -39,9 +39,13 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class ClientReconnectAfterClusterRestartTest extends GridCommonAbstractTest { /** Server id. */ private static final int SERVER_ID = 0; @@ -113,6 +117,7 @@ public class ClientReconnectAfterClusterRestartTest extends GridCommonAbstractTe } /** */ + @Test public void testReconnectClient() throws Exception { try { startGrid(SERVER_ID); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClusterReadOnlyModeSqlTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClusterReadOnlyModeSqlTest.java new file mode 100644 index 0000000000000..9a91fe215cb2b --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ClusterReadOnlyModeSqlTest.java @@ -0,0 +1,99 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.Random; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.query.FieldsQueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.internal.util.typedef.G; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests SQL queries in read-only cluster mode. + */ +@RunWith(JUnit4.class) +public class ClusterReadOnlyModeSqlTest extends ClusterReadOnlyModeAbstractTest { + /** + * + */ + @Test + public void testSqlReadOnly() { + assertSqlReadOnlyMode(false); + + changeClusterReadOnlyMode(true); + + assertSqlReadOnlyMode(true); + + changeClusterReadOnlyMode(false); + + assertSqlReadOnlyMode(false); + } + + /** + * @param readOnly If {@code true} then data modification SQL queries must fail, else succeed. + */ + private void assertSqlReadOnlyMode(boolean readOnly) { + Random rnd = new Random(); + + for (Ignite ignite : G.allGrids()) { + for (String cacheName : CACHE_NAMES) { + IgniteCache cache = ignite.cache(cacheName); + + try (FieldsQueryCursor cur = cache.query(new SqlFieldsQuery("SELECT * FROM Integer"))) { + cur.getAll(); + } + + boolean failed = false; + + try (FieldsQueryCursor cur = cache.query(new SqlFieldsQuery("DELETE FROM Integer"))) { + cur.getAll(); + } + catch (CacheException ex) { + if (!readOnly) + log.error("Failed to delete data", ex); + + failed = true; + } + + if (failed != readOnly) + fail("SQL delete from " + cacheName + " must " + (readOnly ? "fail" : "succeed")); + + failed = false; + + try (FieldsQueryCursor cur = cache.query(new SqlFieldsQuery( + "INSERT INTO Integer(_KEY, _VAL) VALUES (?, ?)").setArgs(rnd.nextInt(1000), rnd.nextInt()))) { + cur.getAll(); + } + catch (CacheException ex) { + if (!readOnly) + log.error("Failed to insert data", ex); + + failed = true; + } + + if (failed != readOnly) + fail("SQL insert into " + cacheName + " must " + (readOnly ? "fail" : "succeed")); + } + } + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java index 6652559a15060..9fec0b70e6695 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java @@ -26,22 +26,20 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.apache.ignite.transactions.TransactionState; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class DdlTransactionSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -59,11 +57,6 @@ public class DdlTransactionSelfTest extends GridCommonAbstractTest { .setDefaultTxConcurrency(TransactionConcurrency.PESSIMISTIC) .setDefaultTxTimeout(5000)); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); cfg.setCacheConfiguration(getCacheConfiguration()); cfg.setClientMode(client); @@ -84,6 +77,7 @@ private CacheConfiguration getCacheConfiguration() { /** * @throws Exception If failed. */ + @Test public void testTxIsCommittedOnDdlRequestMultinodeClient() throws Exception { startGridsMultiThreaded(4, false); @@ -132,6 +126,7 @@ public void testTxIsCommittedOnDdlRequestMultinodeClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxIsCommittedOnDdlRequestMultinode() throws Exception { Ignite node = startGridsMultiThreaded(4); @@ -174,6 +169,7 @@ public void testTxIsCommittedOnDdlRequestMultinode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxIsCommittedOnDdlRequest() throws Exception { Ignite node = startGrid(); @@ -216,6 +212,7 @@ public void testTxIsCommittedOnDdlRequest() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDdlRequestWithoutTxMultinodeClient() throws Exception { startGridsMultiThreaded(4, false); @@ -260,6 +257,7 @@ public void testDdlRequestWithoutTxMultinodeClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDdlRequestWithoutTxMultinode() throws Exception { Ignite node = startGridsMultiThreaded(4); @@ -298,6 +296,7 @@ public void testDdlRequestWithoutTxMultinode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDdlRequestWithoutTx() throws Exception { Ignite node = startGrid(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java index cf8bb2ebe6b09..8238e36468c08 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java @@ -40,11 +40,11 @@ import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -52,6 +52,7 @@ /** * Tests cross cache queries. */ +@RunWith(JUnit4.class) public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest { /** */ private static final String PART_CACHE_NAME = "partitioned"; @@ -62,9 +63,6 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest { /** */ private static final String REPL_STORE_CACHE_NAME = "replicated-store"; - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private Ignite ignite; @@ -72,12 +70,6 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - c.setCacheConfiguration( createCache(PART_CACHE_NAME, CacheMode.PARTITIONED, Integer.class, FactPurchase.class), createCache(REPL_PROD_CACHE_NAME, CacheMode.REPLICATED, Integer.class, DimProduct.class), @@ -128,6 +120,7 @@ private static CacheConfiguration createCache(String name, CacheMode mode, Class /** * @throws Exception If failed. */ + @Test public void testTwoStepGroupAndAggregates() throws Exception { IgniteInternalCache cache = ((IgniteKernal)ignite).getCache(PART_CACHE_NAME); @@ -228,6 +221,7 @@ public void testTwoStepGroupAndAggregates() throws Exception { /** * @throws Exception If failed. */ + @Test public void testApiQueries() throws Exception { IgniteCache c = ignite.cache(PART_CACHE_NAME); @@ -243,6 +237,7 @@ public void testApiQueries() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultiStatement() throws Exception { final IgniteInternalCache cache = ((IgniteKernal)ignite).getCache(PART_CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQuerySelfTest.java index 14ad39a5c7736..db420085de330 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFullTextQuerySelfTest.java @@ -43,10 +43,10 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -54,6 +54,7 @@ /** * FullTest queries left test. */ +@RunWith(JUnit4.class) public class GridCacheFullTextQuerySelfTest extends GridCommonAbstractTest { /** Cache size. */ private static final int MAX_ITEM_COUNT = 100; @@ -61,19 +62,10 @@ public class GridCacheFullTextQuerySelfTest extends GridCommonAbstractTest { /** Cache name */ private static final String PERSON_CACHE = "Person"; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setIncludeEventTypes(); cfg.setConnectorConfiguration(null); @@ -102,6 +94,7 @@ public class GridCacheFullTextQuerySelfTest extends GridCommonAbstractTest { /** * @throws Exception In case of error. */ + @Test public void testTextQueryWithField() throws Exception { checkTextQuery("name:1*", false, false); } @@ -109,6 +102,7 @@ public void testTextQueryWithField() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testLocalTextQueryWithKeepBinary() throws Exception { checkTextQuery(true, true); } @@ -116,6 +110,7 @@ public void testLocalTextQueryWithKeepBinary() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testLocalTextQuery() throws Exception { checkTextQuery(true, false); } @@ -123,6 +118,7 @@ public void testLocalTextQuery() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testTextQueryWithKeepBinary() throws Exception { checkTextQuery(false, true); } @@ -130,6 +126,7 @@ public void testTextQueryWithKeepBinary() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testTextQuery() throws Exception { checkTextQuery(false, true); } @@ -371,4 +368,4 @@ public Person(String name, int age) { birthday = cal.getTime(); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLazyQueryPartitionsReleaseTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLazyQueryPartitionsReleaseTest.java index a11296966c938..e934989275dc6 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLazyQueryPartitionsReleaseTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLazyQueryPartitionsReleaseTest.java @@ -34,18 +34,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test to lazy query partitions has not been released too early. */ +@RunWith(JUnit4.class) public class GridCacheLazyQueryPartitionsReleaseTest extends GridCommonAbstractTest { - /** IP finder */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Cache name */ private static final String PERSON_CACHE = "person"; @@ -65,12 +63,6 @@ public class GridCacheLazyQueryPartitionsReleaseTest extends GridCommonAbstractT cfg.setCacheConfiguration(ccfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -84,6 +76,7 @@ public class GridCacheLazyQueryPartitionsReleaseTest extends GridCommonAbstractT * * @throws Exception If failed. */ + @Test public void testLazyQueryPartitionsRelease() throws Exception { Ignite node1 = startGrid(0); @@ -131,6 +124,7 @@ public void testLazyQueryPartitionsRelease() throws Exception { * * @throws Exception If failed. */ + @Test public void testLazyQueryPartitionsReleaseOnClose() throws Exception { Ignite node1 = startGrid(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java index e06f6a6a3b660..caabc407b5369 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java @@ -26,10 +26,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -38,23 +38,15 @@ /** * Test for cache swap. */ +@RunWith(JUnit4.class) public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest { /** Saved versions. */ private final Map versions = new HashMap<>(); - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setNetworkTimeout(2000); CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -78,6 +70,7 @@ public class GridCacheOffHeapSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testOffHeapIterator() throws Exception { try { startGrids(1); @@ -142,4 +135,4 @@ public int value() { return S.toString(CacheValue.class, this); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexEntryEvictTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexEntryEvictTest.java index e14da4a22918c..071c68d69da05 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexEntryEvictTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexEntryEvictTest.java @@ -29,10 +29,10 @@ import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -41,20 +41,12 @@ /** * */ +@RunWith(JUnit4.class) public class GridCacheOffheapIndexEntryEvictTest extends GridCommonAbstractTest { - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setNetworkTimeout(2000); CacheConfiguration cacheCfg = defaultCacheConfiguration(); @@ -80,6 +72,7 @@ public class GridCacheOffheapIndexEntryEvictTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testQueryWhenLocked() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -112,6 +105,7 @@ public void testQueryWhenLocked() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdates() throws Exception { final int ENTRIES = 500; @@ -189,4 +183,4 @@ public TestValue(int val) { val = in.readInt(); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java index 321a201297374..029cc628ae4a6 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapIndexGetSelfTest.java @@ -29,13 +29,13 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -45,20 +45,12 @@ /** * Tests off heap storage when both offheaped and swapped entries exists. */ +@RunWith(JUnit4.class) public class GridCacheOffheapIndexGetSelfTest extends GridCommonAbstractTest { - /** */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setNetworkTimeout(2000); cfg.setDeploymentMode(SHARED); @@ -100,6 +92,7 @@ protected CacheConfiguration cacheConfiguration() { * * @throws Exception If failed. */ + @Test public void testGet() throws Exception { IgniteCache cache = jcache(grid(0), cacheConfiguration(), Long.class, Long.class); @@ -124,6 +117,7 @@ public void testGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutGet() throws Exception { IgniteCache cache = jcache(grid(0), cacheConfiguration(), Object.class, Object.class); @@ -151,6 +145,7 @@ public void testPutGet() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithExpiryPolicy() throws Exception { IgniteCache cache = jcache(grid(0), cacheConfiguration(), Long.class, Long.class); @@ -223,4 +218,4 @@ public void setValue(String val) { this.val = val; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexDisabledSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexDisabledSelfTest.java index 525b6882c3651..5c20e195300b5 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexDisabledSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryIndexDisabledSelfTest.java @@ -30,17 +30,15 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteBiPredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class GridCacheQueryIndexDisabledSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ public GridCacheQueryIndexDisabledSelfTest() { super(true); @@ -57,18 +55,13 @@ public GridCacheQueryIndexDisabledSelfTest() { cfg.setCacheConfiguration(ccfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } /** * @throws Exception If failed. */ + @Test public void testSqlQuery() throws Exception { IgniteCache cache = grid().getOrCreateCache(SqlValue.class.getSimpleName()); @@ -88,6 +81,7 @@ public void testSqlQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlFieldsQuery() throws Exception { IgniteCache cache = grid().getOrCreateCache(SqlValue.class.getSimpleName()); @@ -119,6 +113,7 @@ public void testSqlFieldsQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFullTextQuery() throws Exception { IgniteCache cache = grid().getOrCreateCache(String.class.getSimpleName()); @@ -138,6 +133,7 @@ public void testFullTextQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanLocalQuery() throws Exception { IgniteCache cache = grid().getOrCreateCache(String.class.getSimpleName()); @@ -155,6 +151,7 @@ public void testScanLocalQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlLocalQuery() throws Exception { IgniteCache cache = grid().getOrCreateCache(SqlValue.class.getSimpleName()); @@ -174,6 +171,7 @@ public void testSqlLocalQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlLocalFieldsQuery() throws Exception { IgniteCache cache = grid().getOrCreateCache(SqlValue.class.getSimpleName()); @@ -193,6 +191,7 @@ public void testSqlLocalFieldsQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFullTextLocalQuery() throws Exception { IgniteCache cache = grid().getOrCreateCache(String.class.getSimpleName()); @@ -212,6 +211,7 @@ public void testFullTextLocalQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQuery() throws Exception { IgniteCache cache = grid().getOrCreateCache(String.class.getSimpleName()); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySerializationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySerializationSelfTest.java index 85fd6db977b03..73d542d89df5a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySerializationSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySerializationSelfTest.java @@ -28,10 +28,10 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -39,6 +39,7 @@ /** * Tests for cache query results serialization. */ +@RunWith(JUnit4.class) public class GridCacheQuerySerializationSelfTest extends GridCommonAbstractTest { /** */ private static final int GRID_CNT = 2; @@ -49,9 +50,6 @@ public class GridCacheQuerySerializationSelfTest extends GridCommonAbstractTest /** */ private static final CacheMode CACHE_MODE = PARTITIONED; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { startGridsMultiThreaded(GRID_CNT); @@ -66,12 +64,6 @@ public class GridCacheQuerySerializationSelfTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(CACHE_NAME); @@ -102,6 +94,7 @@ private GridCacheQueryTestValue value(String f1, int f2, long f3) { * * @throws Exception In case of error. */ + @Test public void testSerialization() throws Exception { IgniteEx g0 = grid(0); @@ -142,4 +135,4 @@ private static class QueryCallable implements IgniteCallable ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setName("offheap-cache"); @@ -95,6 +87,7 @@ public class GridCacheQuerySimpleBenchmark extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testPerformance() throws Exception { Random rnd = new GridRandom(); @@ -211,4 +204,4 @@ public Person() { name = U.readString(in); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java index 570a1b078ed17..c1d9d5f815388 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java @@ -27,10 +27,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractQuerySelfTest.ObjectValue; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -39,10 +39,8 @@ /** * GG-4368 */ +@RunWith(JUnit4.class) public class GridIndexingWithNoopSwapSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ protected Ignite ignite; @@ -50,12 +48,6 @@ public class GridIndexingWithNoopSwapSelfTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -92,6 +84,7 @@ public class GridIndexingWithNoopSwapSelfTest extends GridCommonAbstractTest { } /** @throws Exception If failed. */ + @Test public void testQuery() throws Exception { IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -111,4 +104,4 @@ public void testQuery() throws Exception { assertEquals(10, cache.query(qry.setArgs(0)).getAll().size()); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryObjectFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryObjectFieldsQuerySelfTest.java index 21e4852c30bae..4f6fa8fd95d49 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryObjectFieldsQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryObjectFieldsQuerySelfTest.java @@ -32,22 +32,20 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests that server nodes do not need class definitions to execute queries. */ +@RunWith(JUnit4.class) public class IgniteBinaryObjectFieldsQuerySelfTest extends GridCommonAbstractTest { /** */ public static final String PERSON_KEY_CLS_NAME = "org.apache.ignite.tests.p2p.cache.PersonKey"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Grid count. */ public static final int GRID_CNT = 4; @@ -68,12 +66,6 @@ protected String getPersonClassName(){ cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setMarshaller(null); if (getTestIgniteInstanceName(3).equals(igniteInstanceName)) { @@ -121,6 +113,7 @@ protected void initExtClassLoader() { /** * @throws Exception If failed. */ + @Test public void testQueryPartitionedAtomic() throws Exception { checkQuery(CacheMode.PARTITIONED, CacheAtomicityMode.ATOMIC); } @@ -128,6 +121,7 @@ public void testQueryPartitionedAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReplicatedAtomic() throws Exception { checkQuery(CacheMode.REPLICATED, CacheAtomicityMode.ATOMIC); } @@ -135,6 +129,7 @@ public void testQueryReplicatedAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryPartitionedTransactional() throws Exception { checkQuery(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL); } @@ -142,6 +137,7 @@ public void testQueryPartitionedTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReplicatedTransactional() throws Exception { checkQuery(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL); } @@ -149,6 +145,7 @@ public void testQueryReplicatedTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFieldsQueryPartitionedAtomic() throws Exception { checkFieldsQuery(CacheMode.PARTITIONED, CacheAtomicityMode.ATOMIC); } @@ -156,6 +153,7 @@ public void testFieldsQueryPartitionedAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFieldsQueryReplicatedAtomic() throws Exception { checkFieldsQuery(CacheMode.REPLICATED, CacheAtomicityMode.ATOMIC); } @@ -163,6 +161,7 @@ public void testFieldsQueryReplicatedAtomic() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFieldsQueryPartitionedTransactional() throws Exception { checkFieldsQuery(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL); } @@ -170,6 +169,7 @@ public void testFieldsQueryPartitionedTransactional() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFieldsQueryReplicatedTransactional() throws Exception { checkFieldsQuery(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryObjectQueryArgumentsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryObjectQueryArgumentsTest.java index e23935324b221..9b3b7707d2076 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryObjectQueryArgumentsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryObjectQueryArgumentsTest.java @@ -37,20 +37,18 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ +@RunWith(JUnit4.class) public class IgniteBinaryObjectQueryArgumentsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 3; @@ -85,8 +83,6 @@ public class IgniteBinaryObjectQueryArgumentsTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setCacheConfiguration(getCacheConfigurations()); cfg.setMarshaller(null); @@ -185,6 +181,7 @@ private CacheConfiguration getCacheConfiguration(final String cacheName, final C /** * @throws Exception If failed. */ + @Test public void testObjectArgument() throws Exception { testKeyQuery(OBJECT_CACHE, new TestKey(1), new TestKey(2)); } @@ -192,6 +189,7 @@ public void testObjectArgument() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimitiveObjectArgument() throws Exception { testKeyValQuery(PRIM_CACHE, 1, 2); } @@ -199,6 +197,7 @@ public void testPrimitiveObjectArgument() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStringObjectArgument() throws Exception { testKeyValQuery(STR_CACHE, "str1", "str2"); } @@ -206,6 +205,7 @@ public void testStringObjectArgument() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEnumObjectArgument() throws Exception { testKeyValQuery(ENUM_CACHE, EnumKey.KEY1, EnumKey.KEY2); } @@ -213,6 +213,7 @@ public void testEnumObjectArgument() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUuidObjectArgument() throws Exception { final UUID uuid1 = UUID.randomUUID(); UUID uuid2 = UUID.randomUUID(); @@ -226,6 +227,7 @@ public void testUuidObjectArgument() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDateObjectArgument() throws Exception { testKeyValQuery(DATE_CACHE, new Date(0), new Date(1)); } @@ -233,6 +235,7 @@ public void testDateObjectArgument() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimestampArgument() throws Exception { testKeyValQuery(TIMESTAMP_CACHE, new Timestamp(0), new Timestamp(1)); } @@ -241,6 +244,7 @@ public void testTimestampArgument() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBigDecimalArgument() throws Exception { final ThreadLocalRandom rnd = ThreadLocalRandom.current(); @@ -353,6 +357,7 @@ private void testValQuery(final String cacheName, final T val1, final T val2 /** * @throws Exception If failed. */ + @Test public void testFieldSearch() throws Exception { final IgniteCache cache = ignite(0).cache(FIELD_CACHE); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryWrappedObjectFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryWrappedObjectFieldsQuerySelfTest.java index bff725c2eadd6..8313e7432b802 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryWrappedObjectFieldsQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteBinaryWrappedObjectFieldsQuerySelfTest.java @@ -23,7 +23,7 @@ public class IgniteBinaryWrappedObjectFieldsQuerySelfTest extends IgniteBinaryObjectFieldsQuerySelfTest { /** {@inheritDoc} */ - protected String getPersonClassName() { + @Override protected String getPersonClassName() { return "org.apache.ignite.tests.p2p.cache.PersonWrapper$Person"; } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java index ce5c95e45c070..3f4d984ec5137 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java @@ -55,12 +55,11 @@ import org.apache.ignite.internal.processors.query.h2.sql.GridSqlQuerySplitter; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -69,10 +68,8 @@ /** * Tests for fields queries. */ +@RunWith(JUnit4.class) public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static IgniteCache orgCache; @@ -100,8 +97,6 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA cfg.setPeerClassLoadingEnabled(false); - cfg.setDiscoverySpi(discovery()); - if (hasCache) cfg.setCacheConfiguration(cacheConfiguration()); else @@ -127,15 +122,6 @@ protected CacheConfiguration cacheConfiguration() { return ccfg; } - /** @return Discovery SPI. */ - private DiscoverySpi discovery() { - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - return spi; - } - /** * @param clsK Class k. * @param clsV Class v. @@ -221,6 +207,7 @@ protected CacheAtomicityMode atomicityMode() { protected abstract int gridCount(); /** @throws Exception If failed. */ + @Test public void testCacheMetaData() throws Exception { // Put internal key to test filtering of internal objects. @@ -364,6 +351,7 @@ else if (!"cacheWithCustomKeyPrecision".equalsIgnoreCase(meta.cacheName())) /** * */ + @Test public void testExplain() { List> res = grid(0).cache(personCache.getName()).query(sqlFieldsQuery( String.format("explain select p.age, p.name, o.name " + @@ -373,7 +361,7 @@ public void testExplain() { for (List row : res) X.println("____ : " + row); - if (cacheMode() == PARTITIONED || (cacheMode() == REPLICATED && !isReplicatedOnly())) { + if (cacheMode() == PARTITIONED) { assertEquals(2, res.size()); assertTrue(((String)res.get(1).get(0)).contains(GridSqlQuerySplitter.mergeTableIdentifier(0))); @@ -384,6 +372,7 @@ public void testExplain() { /** @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testExecuteWithMetaDataAndPrecision() throws Exception { QueryEntity qeWithPrecision = new QueryEntity() .setKeyType("java.lang.Long") @@ -422,6 +411,7 @@ public void testExecuteWithMetaDataAndPrecision() throws Exception { } } + @Test public void testExecuteWithMetaDataAndCustomKeyPrecision() throws Exception { QueryEntity qeWithPrecision = new QueryEntity() .setKeyType("java.lang.String") @@ -479,6 +469,7 @@ public void testExecuteWithMetaDataAndCustomKeyPrecision() throws Exception { } /** @throws Exception If failed. */ + @Test public void testExecuteWithMetaData() throws Exception { QueryCursorImpl> cursor = (QueryCursorImpl>)personCache.query(sqlFieldsQuery( String.format("select p._KEY, p.name, p.age, o.name " + @@ -579,11 +570,13 @@ else if (cnt == 1) { } /** @throws Exception If failed. */ + @Test public void testExecute() throws Exception { doTestExecute(personCache, sqlFieldsQuery("select _KEY, name, age from Person")); } /** @throws Exception If failed. */ + @Test public void testExecuteNoOpCache() throws Exception { doTestExecute(noOpCache, sqlFieldsQuery("select _KEY, name, age from \"AffinityKey-Person\".Person")); } @@ -639,6 +632,7 @@ else if (cnt == 1) { } /** @throws Exception If failed. */ + @Test public void testExecuteWithArguments() throws Exception { QueryCursor> qry = personCache .query(sqlFieldsQuery("select _KEY, name, age from Person where age > ?").setArgs(30)); @@ -691,6 +685,7 @@ private SqlFieldsQuery sqlFieldsQuery(String sql) { } /** @throws Exception If failed. */ + @Test public void testSelectAllJoined() throws Exception { QueryCursor> qry = personCache.query(sqlFieldsQuery( @@ -755,6 +750,7 @@ else if (cnt == 1) { } /** @throws Exception If failed. */ + @Test public void testEmptyResult() throws Exception { QueryCursor> qry = personCache.query(sqlFieldsQuery("select name from Person where age = 0")); @@ -771,6 +767,7 @@ public void testEmptyResult() throws Exception { * * @throws Exception If failed. */ + @Test public void testSingleResultUsesFindOne() throws Exception { QueryCursor> qry = intCache.query(sqlFieldsQuery("select _val from Integer where _key = 25")); @@ -790,6 +787,7 @@ public void testSingleResultUsesFindOne() throws Exception { * * @throws Exception If failed. */ + @Test public void testEmptyResultUsesFindOne() throws Exception { QueryCursor> qry = intCache.query(sqlFieldsQuery("select _val from Integer where _key = -10")); @@ -801,6 +799,7 @@ public void testEmptyResultUsesFindOne() throws Exception { } /** @throws Exception If failed. */ + @Test public void testQueryString() throws Exception { QueryCursor> qry = strCache.query(sqlFieldsQuery("select * from String")); @@ -818,6 +817,7 @@ public void testQueryString() throws Exception { } /** @throws Exception If failed. */ + @Test public void testQueryIntegersWithJoin() throws Exception { QueryCursor> qry = intCache.query(sqlFieldsQuery( "select i._KEY, i._VAL, j._KEY, j._VAL from Integer i join Integer j where i._VAL >= 100")); @@ -840,6 +840,7 @@ public void testQueryIntegersWithJoin() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPagination() throws Exception { // Query with page size 20. QueryCursor> qry = @@ -862,6 +863,7 @@ public void testPagination() throws Exception { } /** @throws Exception If failed. */ + @Test public void testNamedCache() throws Exception { try { IgniteCache cache = jcache("tmp_int", Integer.class, Integer.class); @@ -882,6 +884,7 @@ public void testNamedCache() throws Exception { } /** @throws Exception If failed. */ + @Test public void testNoPrimitives() throws Exception { try { final IgniteCache cache = grid(0).getOrCreateCache("tmp_without_index"); @@ -900,6 +903,7 @@ public void testNoPrimitives() throws Exception { } /** @throws Exception If failed. */ + @Test public void testComplexKeys() throws Exception { IgniteCache cache = jcache(PersonKey.class, Person.class); @@ -941,6 +945,7 @@ else if (cnt == 5) /** * @throws Exception If failed. */ + @Test public void testPaginationIterator() throws Exception { QueryCursor> qry = intCache.query(sqlFieldsQuery("select _key, _val from Integer").setPageSize(10)); @@ -961,6 +966,7 @@ public void testPaginationIterator() throws Exception { } /** @throws Exception If failed. */ + @Test public void testPaginationIteratorKeepAll() throws Exception { QueryCursor> qry = intCache.query(sqlFieldsQuery("select _key, _val from Integer").setPageSize(10)); @@ -1002,6 +1008,7 @@ public void testPaginationIteratorKeepAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPaginationGet() throws Exception { QueryCursor> qry = intCache.query(sqlFieldsQuery("select _key, _val from Integer").setPageSize(10)); @@ -1025,6 +1032,7 @@ public void testPaginationGet() throws Exception { } /** @throws Exception If failed. */ + @Test public void testEmptyGrid() throws Exception { QueryCursor> qry = personCache .query(sqlFieldsQuery("select name, age from Person where age = 25")); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractInsertSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractInsertSqlQuerySelfTest.java index c811cb53d6fd1..ca9c26b673d98 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractInsertSqlQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractInsertSqlQuerySelfTest.java @@ -39,9 +39,6 @@ import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -52,9 +49,6 @@ */ @SuppressWarnings("unchecked") public abstract class IgniteCacheAbstractInsertSqlQuerySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ protected final Marshaller marsh; @@ -96,12 +90,6 @@ boolean isBinaryMarshaller() { cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java index ac9de6f8101aa..59bcc0fb20d82 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java @@ -82,10 +82,9 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -110,9 +109,6 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac /** Cache store. */ private static TestStore store = new TestStore(); - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * @return Grid count. */ @@ -142,7 +138,7 @@ protected NearCacheConfiguration nearCacheConfiguration() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - c.setDiscoverySpi(new TcpDiscoverySpi().setForceServerMode(true).setIpFinder(ipFinder)); + ((TcpDiscoverySpi)c.getDiscoverySpi()).setForceServerMode(true); if (igniteInstanceName.startsWith("client")) { c.setClientMode(true); @@ -266,7 +262,7 @@ protected Ignite ignite() { super.afterTest(); for(String cacheName : ignite().cacheNames()) - ignite().cache(cacheName).removeAll(); + ignite().cache(cacheName).destroy(); } /** {@inheritDoc} */ @@ -286,21 +282,13 @@ protected Ignite ignite() { * * @throws Exception In case of error. */ - public void _testDifferentKeyTypes() throws Exception { - fail("http://atlassian.gridgain.com/jira/browse/GG-11216"); - + @Test + public void testDifferentKeyTypes() throws Exception { final IgniteCache cache = jcache(Object.class, Object.class); cache.put(1, "value"); - try { - cache.put("key", "value"); - - fail(); - } - catch (CacheException ignored) { - // No-op. - } + cache.put("key", "value"); } /** @@ -308,6 +296,7 @@ public void _testDifferentKeyTypes() throws Exception { * * @throws Exception In case of error. */ + @Test public void testDifferentValueTypes() throws Exception { IgniteCache cache = jcache(Integer.class, Object.class); @@ -323,6 +312,7 @@ public void testDifferentValueTypes() throws Exception { * * @throws Exception In case of error. */ + @Test public void testStringType() throws Exception { IgniteCache cache = jcache(Integer.class, String.class); @@ -342,6 +332,7 @@ public void testStringType() throws Exception { * * @throws Exception In case of error. */ + @Test public void testIntegerType() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); @@ -367,6 +358,7 @@ public void testIntegerType() throws Exception { * * @throws Exception In case of error. */ + @Test public void testTableAliasInSqlQuery() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); @@ -404,6 +396,7 @@ public void testTableAliasInSqlQuery() throws Exception { * * @throws IgniteCheckedException If failed. */ + @Test public void testUserDefinedFunction() throws IgniteCheckedException { // Without alias. final IgniteCache cache = jcache(Object.class, Object.class); @@ -451,6 +444,7 @@ public void testUserDefinedFunction() throws IgniteCheckedException { * * @throws Exception If failed. */ + @Test public void testExpiration() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); @@ -483,6 +477,7 @@ public void testExpiration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIllegalBounds() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); @@ -500,6 +495,7 @@ public void testIllegalBounds() throws Exception { * * @throws Exception In case of error. */ + @Test public void testComplexType() throws Exception { IgniteCache cache = jcache(Key.class, GridCacheQueryTestValue.class); @@ -521,7 +517,7 @@ public void testComplexType() throws Exception { QueryCursor> qry = cache .query(new SqlQuery(GridCacheQueryTestValue.class, - "fieldName='field1' and field2=1 and field3=1 and id=100500 and embeddedField2=11 and x=3")); + "fieldName='field1' and field2=1 and field3=1 and id=100500 and embeddedField2=11 and x=3")); Cache.Entry entry = F.first(qry.getAll()); @@ -533,6 +529,7 @@ public void testComplexType() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testComplexTypeKeepBinary() throws Exception { if (ignite().configuration().getMarshaller() == null || ignite().configuration().getMarshaller() instanceof BinaryMarshaller) { IgniteCache cache = jcache(Key.class, GridCacheQueryTestValue.class); @@ -605,6 +602,7 @@ private Key(long id) { * * @throws Exception In case of error. */ + @Test public void testSelectQuery() throws Exception { IgniteCache cache = jcache(Integer.class, String.class); @@ -621,11 +619,17 @@ public void testSelectQuery() throws Exception { /** * JUnit. - * - * @throws Exception In case of error. */ - public void testSimpleCustomTableName() throws Exception { - final IgniteCache cache = ignite().cache(DEFAULT_CACHE_NAME); + @Test + public void testSimpleCustomTableName() { + CacheConfiguration cacheConf = new CacheConfiguration(cacheConfiguration()) + .setName(DEFAULT_CACHE_NAME) + .setQueryEntities(Arrays.asList( + new QueryEntity(Integer.class, Type1.class), + new QueryEntity(Integer.class, Type2.class) + )); + + final IgniteCache cache = ignite().getOrCreateCache(cacheConf); cache.put(10, new Type1(1, "Type1 record #1")); cache.put(20, new Type1(2, "Type1 record #2")); @@ -658,6 +662,7 @@ public void testSimpleCustomTableName() throws Exception { * * @throws Exception In case of error. */ + @Test public void testMixedCustomTableName() throws Exception { final IgniteCache cache = jcache(Integer.class, Object.class); @@ -704,6 +709,7 @@ public void testMixedCustomTableName() throws Exception { * * @throws Exception In case of error. */ + @Test public void testDistributedJoinCustomTableName() throws Exception { IgniteCache cache = jcache(Integer.class, Object.class); @@ -731,6 +737,7 @@ public void testDistributedJoinCustomTableName() throws Exception { * * @throws Exception In case of error. */ + @Test public void testObjectQuery() throws Exception { IgniteCache cache = jcache(Integer.class, ObjectValue.class); @@ -769,6 +776,7 @@ public void testObjectQuery() throws Exception { * * @throws Exception In case of error. */ + @Test public void testObjectWithString() throws Exception { IgniteCache cache = jcache(Integer.class, ObjectValue2.class); @@ -803,6 +811,7 @@ public void testObjectWithString() throws Exception { * * @throws Exception In case of error. */ + @Test public void testEnumObjectQuery() throws Exception { final IgniteCache cache = jcache(Long.class, EnumObject.class); @@ -937,13 +946,14 @@ private void assertEnumType(final List> enumObject /** * JUnit. - * - * @throws Exception In case of error. */ - public void _testObjectQueryWithSwap() throws Exception { - fail("http://atlassian.gridgain.com/jira/browse/GG-11216"); + @Test + public void testObjectQueryWithSwap() { + CacheConfiguration config = new CacheConfiguration(cacheConfiguration()); - IgniteCache cache = jcache(Integer.class, ObjectValue.class); + config.setOnheapCacheEnabled(true); + + IgniteCache cache = jcache(ignite(), config, Integer.class, ObjectValue.class); boolean partitioned = cache.getConfiguration(CacheConfiguration.class).getCacheMode() == PARTITIONED; @@ -956,16 +966,14 @@ public void _testObjectQueryWithSwap() throws Exception { IgniteCache c = g.cache(cache.getName()); for (int i = 0; i < cnt; i++) { - if (i % 2 == 0) { - assertNotNull(c.localPeek(i, CachePeekMode.ONHEAP)); + assertNotNull(c.localPeek(i, CachePeekMode.ONHEAP)); - c.localEvict(Collections.singleton(i)); // Swap. + c.localEvict(Collections.singleton(i)); // Swap. - if (!partitioned || g.affinity(cache.getName()).mapKeyToNode(i).isLocal()) { - ObjectValue peekVal = c.localPeek(i, CachePeekMode.ONHEAP); + if (!partitioned || g.affinity(cache.getName()).mapKeyToNode(i).isLocal()) { + ObjectValue peekVal = c.localPeek(i, CachePeekMode.ONHEAP); - assertNull("Non-null value for peek [key=" + i + ", val=" + peekVal + ']', peekVal); - } + assertNull("Non-null value for peek [key=" + i + ", val=" + peekVal + ']', peekVal); } } } @@ -1035,6 +1043,7 @@ public void _testObjectQueryWithSwap() throws Exception { * * @throws Exception In case of error. */ + @Test public void testFullTextSearch() throws Exception { IgniteCache cache = jcache(Integer.class, ObjectValue.class); @@ -1081,6 +1090,7 @@ public void testFullTextSearch() throws Exception { * * @throws Exception In case of error. */ + @Test public void testScanQuery() throws Exception { IgniteCache c1 = jcache(Integer.class, String.class); @@ -1119,6 +1129,7 @@ public void testScanQuery() throws Exception { /** * @throws Exception In case of error. */ + @Test public void testScanPartitionQuery() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); @@ -1160,13 +1171,17 @@ public void testScanPartitionQuery() throws Exception { /** * JUnit. - * - * @throws Exception In case of error. */ - public void _testTwoObjectsTextSearch() throws Exception { - fail("http://atlassian.gridgain.com/jira/browse/GG-11216"); + @Test + public void testTwoObjectsTextSearch() { + CacheConfiguration conf = new CacheConfiguration<>(cacheConfiguration()); - IgniteCache c = jcache(Object.class, Object.class); + conf.setQueryEntities(Arrays.asList( + new QueryEntity(Integer.class, ObjectValue.class), + new QueryEntity(String.class, ObjectValueOther.class) + )); + + IgniteCache c = jcache(ignite(), conf, Object.class, Object.class); c.put(1, new ObjectValue("ObjectValue str", 1)); c.put("key", new ObjectValueOther("ObjectValueOther str")); @@ -1188,6 +1203,7 @@ public void _testTwoObjectsTextSearch() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPrimitiveType() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); cache.put(1, 1); @@ -1209,6 +1225,7 @@ public void testPrimitiveType() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPaginationIteratorDefaultCache() throws Exception { testPaginationIterator(jcache(ignite(), cacheConfiguration(), DEFAULT_CACHE_NAME, Integer.class, Integer.class)); } @@ -1216,6 +1233,7 @@ public void testPaginationIteratorDefaultCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPaginationIteratorNamedCache() throws Exception { testPaginationIterator(jcache(ignite(), cacheConfiguration(), Integer.class, Integer.class)); } @@ -1249,6 +1267,7 @@ private void testPaginationIterator(IgniteCache cache) throws /** * @throws Exception If failed. */ + @Test public void testPaginationGetDefaultCache() throws Exception { testPaginationGet(jcache(ignite(), cacheConfiguration(), DEFAULT_CACHE_NAME, Integer.class, Integer.class)); } @@ -1256,6 +1275,7 @@ public void testPaginationGetDefaultCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPaginationGetNamedCache() throws Exception { testPaginationGet(jcache(ignite(), cacheConfiguration(), Integer.class, Integer.class)); } @@ -1290,6 +1310,7 @@ private void testPaginationGet(IgniteCache cache) throws Excep /** * @throws Exception If failed. */ + @Test public void testScanFilters() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); @@ -1326,6 +1347,7 @@ public void testScanFilters() throws Exception { /** * @throws IgniteCheckedException if failed. */ + @Test public void testBadHashObjectKey() throws IgniteCheckedException { IgniteCache cache = jcache(BadHashKeyObject.class, Byte.class); @@ -1340,6 +1362,7 @@ public void testBadHashObjectKey() throws IgniteCheckedException { /** * @throws IgniteCheckedException if failed. */ + @Test public void testTextIndexedKey() throws IgniteCheckedException { IgniteCache cache = jcache(ObjectValue.class, Long.class); @@ -1355,6 +1378,7 @@ public void testTextIndexedKey() throws IgniteCheckedException { /** * @throws Exception If failed. */ + @Test public void testOrderByOnly() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); @@ -1385,6 +1409,7 @@ public void testOrderByOnly() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLimitOnly() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); @@ -1413,6 +1438,7 @@ public void testLimitOnly() throws Exception { /** * @throws Exception If failed. */ + @Test public void testArray() throws Exception { IgniteCache cache = jcache(Integer.class, ArrayObject.class); @@ -1436,6 +1462,7 @@ public void testArray() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlQueryEvents() throws Exception { checkSqlQueryEvents(); } @@ -1443,6 +1470,7 @@ public void testSqlQueryEvents() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFieldsQueryMetadata() throws Exception { IgniteCache cache = jcache(UUID.class, Person.class); @@ -1478,6 +1506,8 @@ private void checkSqlQueryEvents() throws Exception { @Override public boolean apply(Event evt) { assert evt instanceof CacheQueryExecutedEvent; + System.out.println(">>> EVENT"); + if (evtsDisabled) fail("Cache events are disabled"); @@ -1520,6 +1550,7 @@ private void checkSqlQueryEvents() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQueryEvents() throws Exception { final Map map = new ConcurrentHashMap<>(); final IgniteCache cache = jcache(Integer.class, Integer.class); @@ -1624,6 +1655,7 @@ public void testScanQueryEvents() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTextQueryEvents() throws Exception { final Map map = new ConcurrentHashMap<>(); final IgniteCache cache = jcache(UUID.class, Person.class); @@ -1727,6 +1759,7 @@ public void testTextQueryEvents() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFieldsQueryEvents() throws Exception { final IgniteCache cache = jcache(UUID.class, Person.class); final boolean evtsDisabled = cache.getConfiguration(CacheConfiguration.class).isEventsDisabled(); @@ -1781,6 +1814,7 @@ public void testFieldsQueryEvents() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalSqlQueryFromClient() throws Exception { try { Ignite g = startGrid("client"); @@ -1804,6 +1838,7 @@ public void testLocalSqlQueryFromClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLocalSqlFieldsQueryFromClient() throws Exception { try { Ignite g = startGrid("client"); @@ -2223,40 +2258,6 @@ public String value() { } } - /** - * Empty test object. - */ - @SuppressWarnings("UnusedDeclaration") - private static class EmptyObject { - /** */ - private int val; - - /** - * @param val Value. - */ - private EmptyObject(int val) { - this.val = val; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return val; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (!(o instanceof EmptyObject)) - return false; - - EmptyObject that = (EmptyObject)o; - - return val == that.val; - } - } - /** * */ @@ -2397,9 +2398,9 @@ public EnumObject(long id, EnumType type) { */ @Override public String toString() { return "EnumObject{" + - "id=" + id + - ", type=" + type + - '}'; + "id=" + id + + ", type=" + type + + '}'; } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractSqlDmlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractSqlDmlQuerySelfTest.java index a57a867526b4a..168b1b7f9c3a6 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractSqlDmlQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractSqlDmlQuerySelfTest.java @@ -33,9 +33,6 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.IgniteTestResources; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -44,9 +41,6 @@ */ @SuppressWarnings("unchecked") public abstract class IgniteCacheAbstractSqlDmlQuerySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ protected final Marshaller marsh; @@ -75,12 +69,6 @@ protected boolean isBinaryMarshaller() { cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCollocatedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCollocatedQuerySelfTest.java index 2b3076c143bc8..643ae72684df3 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCollocatedQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCollocatedQuerySelfTest.java @@ -30,16 +30,17 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.GridRandom; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** */ +@RunWith(JUnit4.class) public class IgniteCacheCollocatedQuerySelfTest extends GridCommonAbstractTest { /** */ private static final String QRY = @@ -61,19 +62,10 @@ public class IgniteCacheCollocatedQuerySelfTest extends GridCommonAbstractTest { /** */ private static final long SEED = ThreadLocalRandom.current().nextLong(); - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); @@ -113,6 +105,7 @@ private static List> query(IgniteCache c, boolean /** * Correct affinity. */ + @Test public void testColocatedQueryRight() { IgniteCache c = ignite(0).cache(DEFAULT_CACHE_NAME); @@ -140,6 +133,7 @@ public void testColocatedQueryRight() { /** * Correct affinity. */ + @Test public void testColocatedQueryWrong() { IgniteCache c = ignite(0).cache(DEFAULT_CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsQueryTest.java index 4e6af25e4cf72..7b6a07f8d3343 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsQueryTest.java @@ -38,6 +38,9 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.IgniteCacheConfigVariationsAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -49,6 +52,7 @@ /** * Config Variations query tests. */ +@RunWith(JUnit4.class) public class IgniteCacheConfigVariationsQueryTest extends IgniteCacheConfigVariationsAbstractTest { /** */ public static final int CNT = 50; @@ -75,6 +79,7 @@ public class IgniteCacheConfigVariationsQueryTest extends IgniteCacheConfigVaria * @throws Exception If failed. */ @SuppressWarnings("serial") + @Test public void testScanQuery() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -106,6 +111,7 @@ public void testScanQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanPartitionQuery() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -164,7 +170,7 @@ public void testScanPartitionQuery() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("SubtractionInCompareTo") + @Test public void testScanFilters() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -208,7 +214,7 @@ public void testScanFilters() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("SubtractionInCompareTo") + @Test public void testLocalScanQuery() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -246,7 +252,7 @@ public void testLocalScanQuery() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("SubtractionInCompareTo") + @Test public void testScanQueryLocalFilter() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { @@ -293,7 +299,7 @@ public void testScanQueryLocalFilter() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("SubtractionInCompareTo") + @Test public void testScanQueryPartitionFilter() throws Exception { runInAllDataModes(new TestRunnable() { @Override public void run() throws Exception { diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationPrimitiveTypesSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationPrimitiveTypesSelfTest.java index 4ea537bb133c8..c1939de06b286 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationPrimitiveTypesSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationPrimitiveTypesSelfTest.java @@ -21,41 +21,25 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ -@SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheConfigurationPrimitiveTypesSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - /** * @throws Exception If failed. */ + @Test public void testPrimitiveTypes() throws Exception { Ignite ignite = startGrid(1); @@ -96,4 +80,4 @@ public void testPrimitiveTypes() throws Exception { assertEquals(cacheDouble.query(new SqlQuery<>(Double.class, "1 = 1")).getAll().size(), 1); assertEquals(cacheBoolean.query(new SqlQuery<>(Boolean.class, "1 = 1")).getAll().size(), 1); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java index 3ebb3b4bb894c..29274903faac6 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheCrossCacheJoinRandomTest.java @@ -38,10 +38,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -51,10 +51,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheCrossCacheJoinRandomTest extends AbstractH2CompareQueryTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -107,10 +105,6 @@ public class IgniteCacheCrossCacheJoinRandomTest extends AbstractH2CompareQueryT @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = ((TcpDiscoverySpi)cfg.getDiscoverySpi()); - - spi.setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -195,6 +189,7 @@ private CacheConfiguration configuration(String name, CacheMode cacheMode, int b /** * @throws Exception If failed. */ + @Test public void testJoin2Caches() throws Exception { testJoin(2, MODES_1); } @@ -202,6 +197,7 @@ public void testJoin2Caches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoin3Caches() throws Exception { testJoin(3, MODES_1); } @@ -209,6 +205,7 @@ public void testJoin3Caches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoin4Caches() throws Exception { testJoin(4, MODES_2); } @@ -216,6 +213,7 @@ public void testJoin4Caches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoin5Caches() throws Exception { testJoin(5, MODES_2); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDeleteSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDeleteSqlQuerySelfTest.java index 92c40b8a8ed29..1baedf81bd951 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDeleteSqlQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDeleteSqlQuerySelfTest.java @@ -22,15 +22,20 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.query.QueryCursor; import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheDeleteSqlQuerySelfTest extends IgniteCacheAbstractSqlDmlQuerySelfTest { /** * */ + @Test public void testDeleteSimple() { IgniteCache p = cache(); @@ -55,6 +60,7 @@ public void testDeleteSimple() { /** * */ + @Test public void testDeleteSingle() { IgniteCache p = cache(); @@ -83,6 +89,7 @@ public void testDeleteSingle() { * In binary mode, this test checks that inner forcing of keepBinary works - without it, EntryProcessors * inside DML engine would compare binary and non-binary objects with the same keys and thus fail. */ + @Test public void testDeleteSimpleWithoutKeepBinary() { IgniteCache p = ignite(0).cache("S2P"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCollocatedAndNotTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCollocatedAndNotTest.java index f53f2633cd832..7a6c3b80755fb 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCollocatedAndNotTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCollocatedAndNotTest.java @@ -35,10 +35,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -46,10 +46,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedJoinCollocatedAndNotTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String PERSON_CACHE = "person"; @@ -70,10 +68,6 @@ public class IgniteCacheDistributedJoinCollocatedAndNotTest extends GridCommonAb cfg.setCacheKeyConfiguration(keyCfg); - TcpDiscoverySpi spi = ((TcpDiscoverySpi)cfg.getDiscoverySpi()); - - spi.setIpFinder(IP_FINDER); - List ccfgs = new ArrayList<>(); { @@ -156,6 +150,7 @@ private CacheConfiguration configuration(String name) { /** * @throws Exception If failed. */ + @Test public void testJoin() throws Exception { Ignite client = grid(2); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java index b8aa4cb985861..34fcfeac94a09 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinCustomAffinityMapper.java @@ -32,11 +32,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -45,10 +45,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedJoinCustomAffinityMapper extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String PERSON_CACHE = "person"; @@ -65,8 +63,6 @@ public class IgniteCacheDistributedJoinCustomAffinityMapper extends GridCommonAb @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - List ccfgs = new ArrayList<>(); { @@ -156,6 +152,7 @@ private CacheConfiguration configuration(String name) { /** * @throws Exception If failed. */ + @Test public void testJoinCustomAffinityMapper() throws Exception { Ignite ignite = ignite(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinNoIndexTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinNoIndexTest.java index f8bc0888792d0..e105fcdb9128e 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinNoIndexTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinNoIndexTest.java @@ -34,11 +34,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -46,10 +46,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedJoinNoIndexTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String PERSON_CACHE = "person"; @@ -63,10 +61,6 @@ public class IgniteCacheDistributedJoinNoIndexTest extends GridCommonAbstractTes @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = ((TcpDiscoverySpi)cfg.getDiscoverySpi()); - - spi.setIpFinder(IP_FINDER); - List ccfgs = new ArrayList<>(); { @@ -132,6 +126,7 @@ private CacheConfiguration configuration(String name) { /** * @throws Exception If failed. */ + @Test public void testJoin() throws Exception { Ignite client = grid(2); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinPartitionedAndReplicatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinPartitionedAndReplicatedTest.java index 462a0082050a1..f1f43a692ed13 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinPartitionedAndReplicatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinPartitionedAndReplicatedTest.java @@ -34,10 +34,11 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -47,10 +48,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedJoinPartitionedAndReplicatedTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String PERSON_CACHE = "person"; @@ -67,10 +66,6 @@ public class IgniteCacheDistributedJoinPartitionedAndReplicatedTest extends Grid @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = ((TcpDiscoverySpi)cfg.getDiscoverySpi()); - - spi.setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -179,6 +174,7 @@ private List caches(boolean idx, /** * @throws Exception If failed. */ + @Test public void testJoin1() throws Exception { join(true, REPLICATED, PARTITIONED, PARTITIONED); } @@ -186,15 +182,16 @@ public void testJoin1() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-5956") + @Test public void testJoin2() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-5956"); - join(true, PARTITIONED, REPLICATED, PARTITIONED); } /** * @throws Exception If failed. */ + @Test public void testJoin3() throws Exception { join(true, PARTITIONED, PARTITIONED, REPLICATED); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinQueryConditionsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinQueryConditionsTest.java index 6f20923b0f69b..820c7ae6a419b 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinQueryConditionsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinQueryConditionsTest.java @@ -32,10 +32,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -43,10 +43,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedJoinQueryConditionsTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String PERSON_CACHE = "person"; @@ -63,10 +61,6 @@ public class IgniteCacheDistributedJoinQueryConditionsTest extends GridCommonAbs @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = ((TcpDiscoverySpi) cfg.getDiscoverySpi()); - - spi.setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -86,6 +80,7 @@ public class IgniteCacheDistributedJoinQueryConditionsTest extends GridCommonAbs /** * @throws Exception If failed. */ + @Test public void testJoinQuery1() throws Exception { joinQuery1(true); } @@ -173,6 +168,7 @@ private void joinQuery1(boolean idx) throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery2() throws Exception { Ignite client = grid(2); @@ -283,6 +279,7 @@ public void _testJoinQuery3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery4() throws Exception { Ignite client = grid(2); @@ -334,6 +331,7 @@ public void testJoinQuery4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery5() throws Exception { Ignite client = grid(2); @@ -375,6 +373,7 @@ public void testJoinQuery5() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery6() throws Exception { Ignite client = grid(2); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java index dee8e64e82c44..40e261db79e05 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java @@ -35,17 +35,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.GridRandom; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedJoinTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static Connection conn; @@ -53,10 +51,6 @@ public class IgniteCacheDistributedJoinTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = ((TcpDiscoverySpi)cfg.getDiscoverySpi()); - - spi.setIpFinder(IP_FINDER); - CacheConfiguration ccfga = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfga.setName("a"); @@ -200,6 +194,7 @@ private static Z insert(Statement s, Z z) throws SQLException { /** * @throws Exception If failed. */ + @Test public void testJoins() throws Exception { Ignite ignite = ignite(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDuplicateEntityConfigurationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDuplicateEntityConfigurationSelfTest.java index d5c0f0a08785d..e82f78960e3ba 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDuplicateEntityConfigurationSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDuplicateEntityConfigurationSelfTest.java @@ -21,32 +21,16 @@ import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheDuplicateEntityConfigurationSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - - return c; - } - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrid(0); @@ -55,6 +39,7 @@ public class IgniteCacheDuplicateEntityConfigurationSelfTest extends GridCommonA /** * @throws Exception If failed. */ + @Test public void testClassDuplicatesQueryEntity() throws Exception { String cacheName = "duplicate"; @@ -86,6 +71,7 @@ public void testClassDuplicatesQueryEntity() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClassDuplicatesQueryReverse() throws Exception { String cacheName = "duplicate"; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheFieldsQueryNoDataSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheFieldsQueryNoDataSelfTest.java index 75c0cd4966a5a..bcc032558a6cb 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheFieldsQueryNoDataSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheFieldsQueryNoDataSelfTest.java @@ -22,10 +22,10 @@ import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -33,10 +33,8 @@ /** * Test for local query on partitioned cache without data. */ +@RunWith(JUnit4.class) public class IgniteCacheFieldsQueryNoDataSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -52,12 +50,6 @@ public class IgniteCacheFieldsQueryNoDataSelfTest extends GridCommonAbstractTest cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -69,6 +61,7 @@ public class IgniteCacheFieldsQueryNoDataSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testQuery() throws Exception { Collection> res = grid().cache(DEFAULT_CACHE_NAME) .query(new SqlQuery("Integer", "from Integer")).getAll(); @@ -76,4 +69,4 @@ public void testQuery() throws Exception { assert res != null; assert res.isEmpty(); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheFullTextQueryNodeJoiningSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheFullTextQueryNodeJoiningSelfTest.java index 162b1e5bacaaa..3ee152da3c553 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheFullTextQueryNodeJoiningSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheFullTextQueryNodeJoiningSelfTest.java @@ -32,10 +32,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -44,10 +45,9 @@ /** * Tests cache in-place modification logic with iterative value increment. */ +@RunWith(JUnit4.class) +@Ignore("https://issues.apache.org/jira/browse/IGNITE-2229") public class IgniteCacheFullTextQueryNodeJoiningSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Number of nodes to test on. */ private static final int GRID_CNT = 3; @@ -80,18 +80,12 @@ public class IgniteCacheFullTextQueryNodeJoiningSelfTest extends GridCommonAbstr cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); commSpi.setSharedMemoryPort(-1); cfg.setCommunicationSpi(commSpi); - cfg.setDiscoverySpi(disco); - return cfg; } @@ -105,9 +99,8 @@ protected CacheAtomicityMode atomicityMode() { /** * @throws Exception If failed. */ + @Test public void testFullTextQueryNodeJoin() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-2229"); - for (int r = 0; r < 5; r++) { startGrids(GRID_CNT); @@ -145,4 +138,4 @@ private IndexedEntity(String val) { this.val = val; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsSqlTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsSqlTest.java index 617909db3027a..7fe1156a7b129 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsSqlTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsSqlTest.java @@ -30,16 +30,15 @@ import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.AffinityKey; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -50,25 +49,14 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheGroupsSqlTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String GROUP1 = "grp1"; /** */ private static final String GROUP2 = "grp2"; - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -86,6 +74,7 @@ public class IgniteCacheGroupsSqlTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testSqlQuery() throws Exception { Ignite node = ignite(0); @@ -112,6 +101,7 @@ public void testSqlQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery1() throws Exception { joinQuery(GROUP1, GROUP2, REPLICATED, PARTITIONED, TRANSACTIONAL, TRANSACTIONAL); } @@ -119,6 +109,7 @@ public void testJoinQuery1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery2() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Void call() throws Exception { @@ -131,6 +122,7 @@ public void testJoinQuery2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery3() throws Exception { joinQuery(GROUP1, GROUP1, PARTITIONED, PARTITIONED, TRANSACTIONAL, ATOMIC); } @@ -138,6 +130,7 @@ public void testJoinQuery3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery4() throws Exception { joinQuery(GROUP1, GROUP1, REPLICATED, REPLICATED, ATOMIC, TRANSACTIONAL); } @@ -145,6 +138,7 @@ public void testJoinQuery4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery5() throws Exception { joinQuery(GROUP1, null, REPLICATED, PARTITIONED, TRANSACTIONAL, TRANSACTIONAL); } @@ -152,6 +146,7 @@ public void testJoinQuery5() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQuery6() throws Exception { joinQuery(GROUP1, null, PARTITIONED, PARTITIONED, TRANSACTIONAL, ATOMIC); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java index 0f72883507129..e14a02577a408 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java @@ -25,10 +25,10 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.IgniteCacheUpdateSqlQuerySelfTest.AllTypes; @@ -36,28 +36,21 @@ * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheInsertSqlQuerySelfTest extends IgniteCacheAbstractInsertSqlQuerySelfTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } /** * */ + @Test public void testInsertWithExplicitKey() { IgniteCache p = ignite(0).cache("S2P").withKeepBinary(); @@ -72,6 +65,7 @@ public void testInsertWithExplicitKey() { /** * */ + @Test public void testInsertFromSubquery() { IgniteCache p = ignite(0).cache("S2P").withKeepBinary(); @@ -92,6 +86,7 @@ public void testInsertFromSubquery() { /** * */ + @Test public void testInsertWithExplicitPrimitiveKey() { IgniteCache p = ignite(0).cache("I2P").withKeepBinary(); @@ -107,6 +102,7 @@ public void testInsertWithExplicitPrimitiveKey() { /** * */ + @Test public void testInsertWithDynamicKeyInstantiation() { IgniteCache p = ignite(0).cache("K2P").withKeepBinary(); @@ -121,6 +117,7 @@ public void testInsertWithDynamicKeyInstantiation() { /** * Test insert with implicit column names. */ + @Test public void testImplicitColumnNames() { IgniteCache p = ignite(0).cache("K2P").withKeepBinary(); @@ -139,6 +136,7 @@ public void testImplicitColumnNames() { /** * */ + @Test public void testFieldsCaseSensitivity() { IgniteCache p = ignite(0).cache("K22P").withKeepBinary(); @@ -153,6 +151,7 @@ public void testFieldsCaseSensitivity() { /** * */ + @Test public void testPrimitives() { IgniteCache p = ignite(0).cache("I2I"); @@ -167,7 +166,7 @@ public void testPrimitives() { /** * */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testDuplicateKeysException() { final IgniteCache p = ignite(0).cache("I2I"); @@ -193,6 +192,7 @@ public void testDuplicateKeysException() { /** * */ + @Test public void testUuidHandling() { IgniteCache p = ignite(0).cache("U2I"); @@ -206,6 +206,7 @@ public void testUuidHandling() { /** * */ + @Test public void testNestedFieldsHandling() { IgniteCache p = ignite(0).cache("I2AT"); @@ -231,6 +232,7 @@ public void testNestedFieldsHandling() { /** * Check that few sequential start-stops of the cache do not affect work of DML. */ + @Test public void testCacheRestartHandling() { for (int i = 0; i < 4; i++) { IgniteCache p = diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedCollocationTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedCollocationTest.java index 3d3f27b07c573..694ddf18d4996 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedCollocationTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedCollocationTest.java @@ -34,9 +34,9 @@ import org.apache.ignite.internal.processors.query.h2.sql.AbstractH2CompareQueryTest; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -45,10 +45,8 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheJoinPartitionedAndReplicatedCollocationTest extends AbstractH2CompareQueryTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String PERSON_CACHE = "person"; @@ -80,10 +78,6 @@ public class IgniteCacheJoinPartitionedAndReplicatedCollocationTest extends Abst @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = ((TcpDiscoverySpi)cfg.getDiscoverySpi()); - - spi.setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -176,6 +170,7 @@ private CacheConfiguration configuration(String name, int backups) { /** * @throws Exception If failed. */ + @Test public void testJoin() throws Exception { Ignite client = grid(SRVS); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java index 4f080e6c7545b..9d655828758ae 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinPartitionedAndReplicatedTest.java @@ -26,9 +26,6 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -37,6 +34,10 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -46,10 +47,9 @@ /** * */ +@RunWith(JUnit4.class) +@Ignore("https://issues.apache.org/jira/browse/IGNITE-5016") public class IgniteCacheJoinPartitionedAndReplicatedTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String PERSON_CACHE = "person"; @@ -66,10 +66,6 @@ public class IgniteCacheJoinPartitionedAndReplicatedTest extends GridCommonAbstr @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = ((TcpDiscoverySpi)cfg.getDiscoverySpi()); - - spi.setIpFinder(IP_FINDER); - List ccfgs = new ArrayList<>(); { @@ -171,9 +167,9 @@ private CacheConfiguration configuration(String name) { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-5016") + @Test public void testJoin() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-5016"); - Ignite client = grid(2); IgniteCache personCache = client.cache(PERSON_CACHE); @@ -224,9 +220,9 @@ public void testJoin() throws Exception { /** */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-5016") + @Test public void testReplicatedToPartitionedLeftJoin() { - fail("https://issues.apache.org/jira/browse/IGNITE-5016"); - Ignite client = grid(2); IgniteCache personCache = client.cache(PERSON_CACHE); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java index be111531320a0..05e71b096e21c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java @@ -37,10 +37,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -50,10 +50,8 @@ * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 5; @@ -67,8 +65,6 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(); keyCfg.setTypeName(TestKeyWithAffinity.class.getName()); @@ -95,6 +91,7 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testJoinQuery() throws Exception { testJoinQuery(PARTITIONED, 0, false, true); @@ -106,6 +103,7 @@ public void testJoinQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQueryEscapeAll() throws Exception { escape = true; @@ -115,6 +113,7 @@ public void testJoinQueryEscapeAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQueryWithAffinityKey() throws Exception { testJoinQuery(PARTITIONED, 0, true, true); @@ -126,6 +125,7 @@ public void testJoinQueryWithAffinityKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQueryWithAffinityKeyEscapeAll() throws Exception { escape = true; @@ -135,6 +135,7 @@ public void testJoinQueryWithAffinityKeyEscapeAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQueryWithAffinityKeyNotQueryField() throws Exception { testJoinQuery(PARTITIONED, 0, true, false); @@ -146,6 +147,7 @@ public void testJoinQueryWithAffinityKeyNotQueryField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJoinQueryWithAffinityKeyNotQueryFieldEscapeAll() throws Exception { escape = true; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLargeResultSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLargeResultSelfTest.java index bac8d1d177273..4d0c19fdb7b5c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLargeResultSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLargeResultSelfTest.java @@ -25,30 +25,22 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** */ +@RunWith(JUnit4.class) public class IgniteCacheLargeResultSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); @@ -71,6 +63,7 @@ public class IgniteCacheLargeResultSelfTest extends GridCommonAbstractTest { /** */ + @Test public void testLargeResult() { // Fill cache. try (IgniteDataStreamer streamer = ignite(0).dataStreamer(DEFAULT_CACHE_NAME)) { @@ -103,4 +96,4 @@ public void testLargeResult() { // Currently we have no ways to do multiple passes through a merge table. } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAtomicCacheOpTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAtomicCacheOpTest.java index a4f398fceff18..c9002f94169ea 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAtomicCacheOpTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunAtomicCacheOpTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test to validate https://issues.apache.org/jira/browse/IGNITE-2310 */ +@RunWith(JUnit4.class) public class IgniteCacheLockPartitionOnAffinityRunAtomicCacheOpTest extends IgniteCacheLockPartitionOnAffinityRunAbstractTest { /** Atomic cache. */ private static final String ATOMIC_CACHE = "atomic"; @@ -137,6 +141,7 @@ protected void destroyCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotReservedAtomicCacheOp() throws Exception { notReservedCacheOp(ATOMIC_CACHE); } @@ -144,6 +149,7 @@ public void testNotReservedAtomicCacheOp() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotReservedTxCacheOp() throws Exception { notReservedCacheOp(TRANSACT_CACHE); } @@ -202,6 +208,7 @@ private void notReservedCacheOp(final String cacheName) throws Exception { /** * @throws Exception If failed. */ + @Test public void testReservedPartitionCacheOp() throws Exception { // Workaround for initial update job metadata. grid(0).cache(Person.class.getSimpleName()).clear(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java index 89ef607b86fa6..dadedf22dadb7 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java @@ -45,10 +45,15 @@ import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test to validate https://issues.apache.org/jira/browse/IGNITE-2310 */ +@RunWith(JUnit4.class) public class IgniteCacheLockPartitionOnAffinityRunTest extends IgniteCacheLockPartitionOnAffinityRunAbstractTest { /** * @param ignite Ignite. @@ -290,6 +295,8 @@ private static int getPersonsCountMultipleCache(final IgniteEx ignite, IgniteLog /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7692") + @Test public void testSingleCache() throws Exception { final PersonsCountGetter personsCntGetter = new PersonsCountGetter() { @Override public int getPersonsCount(IgniteEx ignite, IgniteLogger log, int orgId) throws Exception { @@ -344,6 +351,7 @@ public void testSingleCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleCaches() throws Exception { final PersonsCountGetter personsCntGetter = new PersonsCountGetter() { @Override public int getPersonsCount(IgniteEx ignite, IgniteLogger log, int orgId) throws Exception { @@ -402,6 +410,7 @@ public void testMultipleCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCheckReservePartitionException() throws Exception { int orgId = primaryKey(grid(1).cache(Organization.class.getSimpleName())); @@ -424,6 +433,7 @@ public void testCheckReservePartitionException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReleasePartitionJobCompletesNormally() throws Exception { final int orgId = primaryKey(grid(1).cache(Organization.class.getSimpleName())); @@ -472,6 +482,7 @@ public void testReleasePartitionJobCompletesNormally() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReleasePartitionJobThrowsException() throws Exception { final int orgId = primaryKey(grid(1).cache(Organization.class.getSimpleName())); @@ -532,6 +543,7 @@ public void testReleasePartitionJobThrowsException() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReleasePartitionJobThrowsError() throws Exception { final int orgId = primaryKey(grid(1).cache(Organization.class.getSimpleName())); @@ -591,6 +603,7 @@ public void testReleasePartitionJobThrowsError() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReleasePartitionJobUnmarshalingFails() throws Exception { final int orgId = primaryKey(grid(1).cache(Organization.class.getSimpleName())); @@ -609,6 +622,7 @@ public void testReleasePartitionJobUnmarshalingFails() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReleasePartitionJobMasterLeave() throws Exception { final int orgId = primaryKey(grid(0).cache(Organization.class.getSimpleName())); @@ -698,6 +712,7 @@ public void testReleasePartitionJobMasterLeave() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReleasePartitionJobImplementMasterLeave() throws Exception { final int orgId = primaryKey(grid(0).cache(Organization.class.getSimpleName())); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunWithCollisionSpiTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunWithCollisionSpiTest.java index a05e10ec77cc2..73b467a612927 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunWithCollisionSpiTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunWithCollisionSpiTest.java @@ -35,10 +35,14 @@ import org.apache.ignite.spi.collision.CollisionJobContext; import org.apache.ignite.spi.collision.CollisionSpi; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test to validate https://issues.apache.org/jira/browse/IGNITE-2310 */ +@RunWith(JUnit4.class) public class IgniteCacheLockPartitionOnAffinityRunWithCollisionSpiTest extends IgniteCacheLockPartitionOnAffinityRunAbstractTest { @@ -58,6 +62,7 @@ public class IgniteCacheLockPartitionOnAffinityRunWithCollisionSpiTest /** * @throws Exception If failed. */ + @Test public void testPartitionReservation() throws Exception { int orgId = 0; cancelAllJobs = true; @@ -81,6 +86,7 @@ public void testPartitionReservation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJobFinishing() throws Exception { final AtomicInteger jobNum = new AtomicInteger(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java index c92c7dcf1f004..cab011990434f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java @@ -21,6 +21,9 @@ import java.util.Arrays; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.IgniteCacheUpdateSqlQuerySelfTest.AllTypes; @@ -28,10 +31,12 @@ * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheMergeSqlQuerySelfTest extends IgniteCacheAbstractInsertSqlQuerySelfTest { /** * */ + @Test public void testMergeWithExplicitKey() { IgniteCache p = ignite(0).cache("S2P").withKeepBinary(); @@ -46,6 +51,7 @@ public void testMergeWithExplicitKey() { /** * */ + @Test public void testMergeFromSubquery() { IgniteCache p = ignite(0).cache("S2P").withKeepBinary(); @@ -66,6 +72,7 @@ public void testMergeFromSubquery() { /** * */ + @Test public void testMergeWithExplicitPrimitiveKey() { IgniteCache p = ignite(0).cache("I2P").withKeepBinary(); @@ -81,6 +88,7 @@ public void testMergeWithExplicitPrimitiveKey() { /** * */ + @Test public void testMergeWithDynamicKeyInstantiation() { IgniteCache p = ignite(0).cache("K2P").withKeepBinary(); @@ -95,6 +103,7 @@ public void testMergeWithDynamicKeyInstantiation() { /** * */ + @Test public void testFieldsCaseSensitivity() { IgniteCache p = ignite(0).cache("K22P").withKeepBinary(); @@ -109,6 +118,7 @@ public void testFieldsCaseSensitivity() { /** * */ + @Test public void testPrimitives() { IgniteCache p = ignite(0).cache("I2I").withKeepBinary(); @@ -123,6 +133,7 @@ public void testPrimitives() { /** * */ + @Test public void testNestedFieldsHandling() { IgniteCache p = ignite(0).cache("I2AT"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMultipleIndexedTypesTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMultipleIndexedTypesTest.java index 0614a050a9048..b3d410f750570 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMultipleIndexedTypesTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMultipleIndexedTypesTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheMultipleIndexedTypesTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { @@ -49,6 +53,7 @@ public class IgniteCacheMultipleIndexedTypesTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testMultipleIndexedTypes() throws Exception { CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoClassQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoClassQuerySelfTest.java index 2eb66eecfa6a2..5bf1834e3810d 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoClassQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoClassQuerySelfTest.java @@ -26,9 +26,10 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; @@ -37,16 +38,14 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheNoClassQuerySelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @SuppressWarnings({"unchecked", "deprecation"}) @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - c.setDiscoverySpi(new TcpDiscoverySpi().setForceServerMode(true).setIpFinder(ipFinder)); + ((TcpDiscoverySpi)c.getDiscoverySpi()).setForceServerMode(true); CacheConfiguration cc = defaultCacheConfiguration(); @@ -91,6 +90,7 @@ public class IgniteCacheNoClassQuerySelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNoClass() throws Exception { try { startGrid(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheObjectKeyIndexingSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheObjectKeyIndexingSelfTest.java index 2865767fb04d4..e9766f1aeeb82 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheObjectKeyIndexingSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheObjectKeyIndexingSelfTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test index behavior when key is of plain Object type per indexing settings. */ +@RunWith(JUnit4.class) public class IgniteCacheObjectKeyIndexingSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -52,6 +56,7 @@ protected static CacheConfiguration cacheCfg() { } /** */ + @Test public void testObjectKeyHandling() throws Exception { Ignite ignite = grid(); @@ -92,7 +97,7 @@ public void testObjectKeyHandling() throws Exception { Arrays.asList(uid, "C") ) ); - + cache.remove(uid); // Removal has worked for both keys although the table was the same and keys were of different type @@ -107,7 +112,7 @@ private void assertItemsNumber(long num) { assertEquals(num, grid().cache(DEFAULT_CACHE_NAME).query(new SqlFieldsQuery("select count(*) from TestObject")).getAll() .get(0).get(0)); } - + /** */ private static class TestObject { /** */ diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapEvictQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapEvictQueryTest.java index 6a22f052f2bff..a7ee406efcfd2 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapEvictQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapEvictQueryTest.java @@ -35,30 +35,22 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.LT; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** */ +@RunWith(JUnit4.class) public class IgniteCacheOffheapEvictQueryTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); @@ -87,6 +79,7 @@ public class IgniteCacheOffheapEvictQueryTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testEvictAndRemove() throws Exception { final int KEYS_CNT = 3000; final int THREADS_CNT = 250; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapIndexScanTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapIndexScanTest.java index c0cc46dfc5a02..4cf7d77a39be9 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapIndexScanTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapIndexScanTest.java @@ -26,20 +26,18 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; /** * Based scanCount with offheap index issue. */ +@RunWith(JUnit4.class) public class IgniteCacheOffheapIndexScanTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static IgniteCache cache; @@ -47,12 +45,6 @@ public class IgniteCacheOffheapIndexScanTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - CacheConfiguration cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); cacheCfg.setCacheMode(LOCAL); @@ -75,6 +67,7 @@ public class IgniteCacheOffheapIndexScanTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testQueryPlan() throws Exception { for (int i = 0 ; i < 1000; i++) cache.put(i, new Person(i, "firstName" + i, "lastName" + i, i % 100)); @@ -184,4 +177,4 @@ public Person(int id, int orgId, String firstName, String lastName, double salar ']'; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java index a2f1d1dedf52c..fbf5adb720863 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgniteBiPredicate; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks behavior on exception while unmarshalling key. */ +@RunWith(JUnit4.class) public class IgniteCacheP2pUnmarshallingQueryErrorTest extends IgniteCacheP2pUnmarshallingErrorTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -41,6 +45,7 @@ public class IgniteCacheP2pUnmarshallingQueryErrorTest extends IgniteCacheP2pUnm } /** {@inheritDoc} */ + @Test @Override public void testResponseMessageOnUnmarshallingFailed() { readCnt.set(Integer.MAX_VALUE); @@ -62,6 +67,7 @@ public class IgniteCacheP2pUnmarshallingQueryErrorTest extends IgniteCacheP2pUnm /** * @throws Exception If failed. */ + @Test public void testResponseMessageOnRequestUnmarshallingFailed() throws Exception { readCnt.set(Integer.MAX_VALUE); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionedQueryMultiThreadedSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionedQueryMultiThreadedSelfTest.java index dc8f8d3696828..aa7cb75406f52 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionedQueryMultiThreadedSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionedQueryMultiThreadedSelfTest.java @@ -40,11 +40,11 @@ import org.apache.ignite.internal.util.typedef.CAX; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -52,6 +52,7 @@ /** * Tests for partitioned cache queries. */ +@RunWith(JUnit4.class) public class IgniteCachePartitionedQueryMultiThreadedSelfTest extends GridCommonAbstractTest { /** */ private static final boolean TEST_INFO = true; @@ -59,9 +60,6 @@ public class IgniteCachePartitionedQueryMultiThreadedSelfTest extends GridCommon /** Number of test grids (nodes). Should not be less than 2. */ private static final int GRID_CNT = 3; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** Don't start grid by default. */ public IgniteCachePartitionedQueryMultiThreadedSelfTest() { super(false); @@ -71,12 +69,6 @@ public IgniteCachePartitionedQueryMultiThreadedSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -123,6 +115,7 @@ public IgniteCachePartitionedQueryMultiThreadedSelfTest() { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testLuceneAndSqlMultithreaded() throws Exception { // ---------- Test parameters ---------- // int luceneThreads = 10; @@ -292,4 +285,4 @@ String degree() { return S.toString(PersonObj.class, this); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePrimitiveFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePrimitiveFieldsQuerySelfTest.java index cf098b1ea403a..f8a759bc698e4 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePrimitiveFieldsQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePrimitiveFieldsQuerySelfTest.java @@ -24,21 +24,19 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.LinkedHashMap; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteCachePrimitiveFieldsQuerySelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -46,12 +44,6 @@ public class IgniteCachePrimitiveFieldsQuerySelfTest extends GridCommonAbstractT @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCacheConfiguration(cacheConfiguration(CACHE_NAME)); // Force BinaryMarshaller. @@ -93,6 +85,7 @@ private CacheConfiguration cacheConfiguration(String cache /** * @throws Exception if failed. */ + @Test public void testStaticCache() throws Exception { checkCache(ignite(0).cache(CACHE_NAME)); } @@ -112,7 +105,7 @@ private void checkCache(IgniteCache cache) throws Exceptio } /** - * + * */ @SuppressWarnings("unused") private static class IndexedType { diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueriesLoadTest1.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueriesLoadTest1.java index e5d0e2c84a835..07e18a7f05a35 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueriesLoadTest1.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueriesLoadTest1.java @@ -50,11 +50,11 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -66,6 +66,7 @@ * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheQueriesLoadTest1 extends GridCommonAbstractTest { /** Operation. */ private static final String OPERATION = "Operation"; @@ -130,9 +131,6 @@ public class IgniteCacheQueriesLoadTest1 extends GridCommonAbstractTest { private static final String FIND_DEPOSIT_SQL = "SELECT _key FROM \"" + DEPOSIT_CACHE + "\"." + DEPOSIT + " WHERE " + TRADER_ID + "=?"; - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES = 5; @@ -150,8 +148,6 @@ public class IgniteCacheQueriesLoadTest1 extends GridCommonAbstractTest { cfg.setMarshaller(null); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - RendezvousAffinityFunction aff = new RendezvousAffinityFunction(); aff.setPartitions(3000); @@ -174,6 +170,7 @@ public class IgniteCacheQueriesLoadTest1 extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testQueries() throws Exception { runQueries(1, true, 10_000); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryH2IndexingLeakTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryH2IndexingLeakTest.java index 59be13878aebd..e29b068625d4b 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryH2IndexingLeakTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryH2IndexingLeakTest.java @@ -34,6 +34,9 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_H2_INDEXING_CACHE_CLEANUP_PERIOD; import static org.apache.ignite.IgniteSystemProperties.IGNITE_H2_INDEXING_CACHE_THREAD_USAGE_TIMEOUT; @@ -44,6 +47,7 @@ /** * Tests leaks at the IgniteH2Indexing */ +@RunWith(JUnit4.class) public class IgniteCacheQueryH2IndexingLeakTest extends GridCommonAbstractTest { /** */ private static final long TEST_TIMEOUT = 2 * 60 * 1000; @@ -135,6 +139,7 @@ private static int getStatementCacheSize(GridQueryProcessor qryProcessor) { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testLeaksInIgniteH2IndexingOnTerminatedThread() throws Exception { final IgniteCache c = grid(0).cache(DEFAULT_CACHE_NAME); @@ -187,6 +192,7 @@ public void testLeaksInIgniteH2IndexingOnTerminatedThread() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLeaksInIgniteH2IndexingOnUnusedThread() throws Exception { final IgniteCache c = grid(0).cache(DEFAULT_CACHE_NAME); @@ -219,4 +225,4 @@ public void testLeaksInIgniteH2IndexingOnUnusedThread() throws Exception { fut.get(); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryIndexSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryIndexSelfTest.java index f9916aeb1e3c3..73b8eb0893445 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryIndexSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryIndexSelfTest.java @@ -27,6 +27,9 @@ import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.internal.util.typedef.internal.S; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CachePeekMode.ALL; @@ -34,6 +37,7 @@ /** * Tests for cache query index. */ +@RunWith(JUnit4.class) public class IgniteCacheQueryIndexSelfTest extends GridCacheAbstractSelfTest { /** Grid count. */ private static final int GRID_CNT = 2; @@ -54,6 +58,7 @@ public class IgniteCacheQueryIndexSelfTest extends GridCacheAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testWithoutStoreLoad() throws Exception { IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -72,6 +77,7 @@ public void testWithoutStoreLoad() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithStoreLoad() throws Exception { for (int i = 0; i < ENTRY_CNT; i++) storeStgy.putToStore(i, new CacheValue(i)); @@ -133,4 +139,4 @@ int value() { return S.toString(CacheValue.class, this); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryLoadSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryLoadSelfTest.java index 70f350cd332b7..76b6f3a81e083 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryLoadSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryLoadSelfTest.java @@ -36,11 +36,11 @@ import org.apache.ignite.internal.util.typedef.P2; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -48,10 +48,8 @@ /** * Test that entries are indexed on load/reload methods. */ +@RunWith(JUnit4.class) public class IgniteCacheQueryLoadSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Puts count. */ private static final int PUT_CNT = 10; @@ -82,12 +80,6 @@ public IgniteCacheQueryLoadSelfTest() { cfg.setCacheConfiguration(ccfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -117,6 +109,7 @@ private long size(Class cls) throws IgniteCheckedException { /** * @throws Exception If failed. */ + @Test public void testLoadCache() throws Exception { IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); @@ -135,6 +128,7 @@ public void testLoadCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheAsync() throws Exception { IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); @@ -153,6 +147,7 @@ public void testLoadCacheAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadCacheFiltered() throws Exception { IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); @@ -176,6 +171,7 @@ public boolean apply(Integer key, ValueObject val) { /** * @throws Exception If failed. */ + @Test public void testLoadCacheAsyncFiltered() throws Exception { IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); @@ -199,6 +195,7 @@ public boolean apply(Integer key, ValueObject val) { /** * @throws Exception If failed. */ + @Test public void testReloadAsync() throws Exception { STORE_MAP.put(1, new ValueObject(1)); @@ -219,6 +216,7 @@ public void testReloadAsync() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReloadAll() throws Exception { for (int i = 0; i < PUT_CNT; i++) STORE_MAP.put(i, new ValueObject(i)); @@ -328,4 +326,4 @@ int value() { return S.toString(ValueObject.class, this); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java index eb926a10c15fc..d3d53972e4773 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryMultiThreadedSelfTest.java @@ -42,16 +42,12 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager; -import org.apache.ignite.internal.processors.query.GridQueryProcessor; -import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; import org.apache.ignite.internal.util.typedef.CAX; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -60,7 +56,7 @@ /** * Multi-threaded tests for cache queries. */ -@SuppressWarnings("StatementWithEmptyBody") +@RunWith(JUnit4.class) public class IgniteCacheQueryMultiThreadedSelfTest extends GridCommonAbstractTest { /** */ private static final boolean TEST_INFO = true; @@ -68,9 +64,6 @@ public class IgniteCacheQueryMultiThreadedSelfTest extends GridCommonAbstractTes /** Number of test grids (nodes). Should not be less than 2. */ private static final int GRID_CNT = 3; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static AtomicInteger idxSwapCnt = new AtomicInteger(); @@ -89,12 +82,6 @@ public IgniteCacheQueryMultiThreadedSelfTest() { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration(cacheConfiguration()); return cfg; @@ -224,6 +211,7 @@ private Set affinityNodes(Iterable> entries, * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testMultiThreadedSwapUnswapString() throws Exception { int threadCnt = 50; final int keyCnt = 2000; @@ -294,6 +282,7 @@ public void testMultiThreadedSwapUnswapString() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testMultiThreadedSwapUnswapLong() throws Exception { int threadCnt = 50; final int keyCnt = 2000; @@ -365,9 +354,8 @@ public void testMultiThreadedSwapUnswapLong() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) - public void _testMultiThreadedSwapUnswapLongString() throws Exception { - fail("http://atlassian.gridgain.com/jira/browse/GG-11216"); - + @Test + public void testMultiThreadedSwapUnswapLongString() throws Exception { int threadCnt = 50; final int keyCnt = 2000; final int valCnt = 10000; @@ -438,6 +426,7 @@ public void _testMultiThreadedSwapUnswapLongString() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testMultiThreadedSwapUnswapObject() throws Exception { int threadCnt = 50; final int keyCnt = 4000; @@ -510,6 +499,7 @@ public void testMultiThreadedSwapUnswapObject() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testMultiThreadedSameQuery() throws Exception { int threadCnt = 50; final int keyCnt = 10; @@ -573,6 +563,7 @@ public void testMultiThreadedSameQuery() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testMultiThreadedNewQueries() throws Exception { int threadCnt = 50; final int keyCnt = 10; @@ -632,6 +623,7 @@ public void testMultiThreadedNewQueries() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testMultiThreadedScanQuery() throws Exception { int threadCnt = 50; final int keyCnt = 500; @@ -690,6 +682,7 @@ public void testMultiThreadedScanQuery() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testMultiThreadedSqlFieldsQuery() throws Throwable { int threadCnt = 16; final int keyCnt = 1100; // set resultSet size bigger than page size @@ -763,4 +756,4 @@ public int value() { return val; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryErrorSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryErrorSelfTest.java index 09790854b2d03..a89ed29db1f97 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryErrorSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryErrorSelfTest.java @@ -21,10 +21,14 @@ import javax.cache.CacheException; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Java API query error messages test. */ +@RunWith(JUnit4.class) public class IgniteCacheSqlQueryErrorSelfTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -36,6 +40,7 @@ public class IgniteCacheSqlQueryErrorSelfTest extends GridCacheAbstractSelfTest * * @throws Exception If failed. */ + @Test public void testSelectWrongTable() throws Exception { checkSqlErrorMessage("select from wrong", "Failed to parse query. Table \"WRONG\" not found"); @@ -46,6 +51,7 @@ public void testSelectWrongTable() throws Exception { * * @throws Exception If failed. */ + @Test public void testSelectWrongColumnName() throws Exception { checkSqlErrorMessage("select wrong from test", "Failed to parse query. Column \"WRONG\" not found"); @@ -56,6 +62,7 @@ public void testSelectWrongColumnName() throws Exception { * * @throws Exception If failed. */ + @Test public void testSelectWrongSyntax() throws Exception { checkSqlErrorMessage("select from test where", "Failed to parse query. Syntax error in SQL statement \"SELECT FROM TEST WHERE[*]"); @@ -66,6 +73,7 @@ public void testSelectWrongSyntax() throws Exception { * * @throws Exception If failed. */ + @Test public void testDmlWrongTable() throws Exception { checkSqlErrorMessage("insert into wrong (id, val) values (3, 'val3')", "Failed to parse query. Table \"WRONG\" not found"); @@ -85,6 +93,7 @@ public void testDmlWrongTable() throws Exception { * * @throws Exception If failed. */ + @Test public void testDmlWrongColumnName() throws Exception { checkSqlErrorMessage("insert into test (id, wrong) values (3, 'val3')", "Failed to parse query. Column \"WRONG\" not found"); @@ -104,6 +113,7 @@ public void testDmlWrongColumnName() throws Exception { * * @throws Exception If failed. */ + @Test public void testDmlWrongSyntax() throws Exception { checkSqlErrorMessage("insert test (id, val) values (3, 'val3')", "Failed to parse query. Syntax error in SQL statement \"INSERT TEST[*] (ID, VAL)"); @@ -123,6 +133,7 @@ public void testDmlWrongSyntax() throws Exception { * * @throws Exception If failed. */ + @Test public void testDdlWrongTable() throws Exception { checkSqlErrorMessage("create table test (id int primary key, val varchar)", "Table already exists: TEST"); @@ -145,6 +156,7 @@ public void testDdlWrongTable() throws Exception { * * @throws Exception If failed. */ + @Test public void testDdlWrongColumnName() throws Exception { checkSqlErrorMessage("create index idx1 on test (wrong)", "Column doesn't exist: WRONG"); @@ -158,6 +170,7 @@ public void testDdlWrongColumnName() throws Exception { * * @throws Exception If failed. */ + @Test public void testDdlWrongSyntax() throws Exception { checkSqlErrorMessage("create table wrong (id int wrong key, val varchar)", "Failed to parse query. Syntax error in SQL statement \"CREATE TABLE WRONG (ID INT WRONG[*]"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java index 7241196b502ee..7388150e89ca2 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java @@ -33,11 +33,11 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.GridRandom; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -45,20 +45,12 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteCacheSqlQueryMultiThreadedSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(PARTITIONED); @@ -86,6 +78,7 @@ public class IgniteCacheSqlQueryMultiThreadedSelfTest extends GridCommonAbstract /** * @throws Exception If failed. */ + @Test public void testQuery() throws Exception { final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -117,6 +110,7 @@ public void testQuery() throws Exception { * Test put and parallel query. * @throws Exception If failed. */ + @Test public void testQueryPut() throws Exception { final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -189,4 +183,4 @@ public int age() { return age; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStarvationOnRebalanceTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStarvationOnRebalanceTest.java index 621d10d14f8d4..2f525ca570f6d 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStarvationOnRebalanceTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStarvationOnRebalanceTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -36,6 +39,7 @@ /** * Test to reproduce https://issues.apache.org/jira/browse/IGNITE-3073. */ +@RunWith(JUnit4.class) public class IgniteCacheStarvationOnRebalanceTest extends GridCacheAbstractSelfTest { /** Grid count. */ private static final int GRID_CNT = 4; @@ -86,6 +90,7 @@ public class IgniteCacheStarvationOnRebalanceTest extends GridCacheAbstractSelfT /** * @throws Exception If failed. */ + @Test public void testLoadSystemWithPutAndStartRebalancing() throws Exception { final IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); @@ -163,4 +168,4 @@ int value() { return S.toString(CacheValue.class, this); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheUnionDuplicatesTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheUnionDuplicatesTest.java index 45c9f31aed653..dfb65f5f71f8f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheUnionDuplicatesTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheUnionDuplicatesTest.java @@ -26,12 +26,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.query.h2.sql.AbstractH2CompareQueryTest; import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public class IgniteCacheUnionDuplicatesTest extends AbstractH2CompareQueryTest { /** */ private static IgniteCache pCache; @@ -40,14 +44,14 @@ public class IgniteCacheUnionDuplicatesTest extends AbstractH2CompareQueryTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - cfg.setCacheConfiguration(cacheConfiguration("orgCache", PARTITIONED, Integer.class, Organization.class)); + cfg.setCacheConfiguration(cacheConfiguration("part", PARTITIONED, Integer.class, Organization.class)); return cfg; } /** {@inheritDoc} */ @Override protected void createCaches() { - pCache = ignite.cache("orgCache"); + pCache = ignite.cache("part"); } /** {@inheritDoc} */ @@ -73,6 +77,7 @@ public class IgniteCacheUnionDuplicatesTest extends AbstractH2CompareQueryTest { /** * @throws Exception If failed. */ + @Test public void testUnionDuplicateFilter() throws Exception { compareQueryRes0(pCache, "select name from \"part\".Organization " + "union " + @@ -83,6 +88,8 @@ public void testUnionDuplicateFilter() throws Exception { @Override protected Statement initializeH2Schema() throws SQLException { Statement st = super.initializeH2Schema(); + st.executeUpdate("CREATE SCHEMA \"part\";"); + st.execute("create table \"part\".ORGANIZATION" + " (_key int not null," + " _val other not null," + diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheUpdateSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheUpdateSqlQuerySelfTest.java index 20cbe3a3bce96..7445d8324dfbd 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheUpdateSqlQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheUpdateSqlQuerySelfTest.java @@ -32,11 +32,15 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteCacheUpdateSqlQuerySelfTest extends IgniteCacheAbstractSqlDmlQuerySelfTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -65,6 +69,7 @@ private static CacheConfiguration createAllTypesCacheConfig() { /** * */ + @Test public void testUpdateSimple() { IgniteCache p = cache(); @@ -95,6 +100,7 @@ public void testUpdateSimple() { /** * */ + @Test public void testUpdateSingle() { IgniteCache p = cache(); @@ -125,6 +131,7 @@ public void testUpdateSingle() { /** * */ + @Test public void testUpdateValueAndFields() { IgniteCache p = cache(); @@ -155,6 +162,7 @@ public void testUpdateValueAndFields() { /** * */ + @Test public void testDefault() { IgniteCache p = cache(); @@ -183,6 +191,7 @@ public void testDefault() { } /** */ + @Test public void testTypeConversions() throws ParseException { IgniteCache cache = ignite(0).cache("L2AT"); @@ -227,6 +236,7 @@ public void testTypeConversions() throws ParseException { } /** */ + @Test public void testSingleInnerFieldUpdate() throws ParseException { IgniteCache cache = ignite(0).cache("L2AT"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCheckClusterStateBeforeExecuteQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCheckClusterStateBeforeExecuteQueryTest.java index 7f155ed61a117..a2b258e054769 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCheckClusterStateBeforeExecuteQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCheckClusterStateBeforeExecuteQueryTest.java @@ -24,27 +24,22 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; /** * */ +@RunWith(JUnit4.class) public class IgniteCheckClusterStateBeforeExecuteQueryTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - DataStorageConfiguration pCfg = new DataStorageConfiguration(); pCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration() @@ -73,6 +68,7 @@ public class IgniteCheckClusterStateBeforeExecuteQueryTest extends GridCommonAbs /** * @throws Exception On failed. */ + @Test public void testDynamicSchemaChangesPersistence() throws Exception { final IgniteEx ig = startGrid(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientReconnectCacheQueriesFailoverTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientReconnectCacheQueriesFailoverTest.java index 39634cb5228f7..b415d8d41dd6d 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientReconnectCacheQueriesFailoverTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientReconnectCacheQueriesFailoverTest.java @@ -36,12 +36,16 @@ import org.apache.ignite.internal.IgniteClientReconnectFailoverAbstractTest; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteBiPredicate; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * */ +@RunWith(JUnit4.class) public class IgniteClientReconnectCacheQueriesFailoverTest extends IgniteClientReconnectFailoverAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -73,6 +77,7 @@ public class IgniteClientReconnectCacheQueriesFailoverTest extends IgniteClientR /** * @throws Exception If failed. */ + @Test public void testReconnectCacheQueries() throws Exception { final Ignite client = grid(serverCount()); @@ -120,6 +125,7 @@ public void testReconnectCacheQueries() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectScanQuery() throws Exception { final Ignite client = grid(serverCount()); @@ -229,4 +235,4 @@ public void setName(String name) { return S.toString(Person.class, this); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientReconnectQueriesTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientReconnectQueriesTest.java index 5f45d80eb317a..1f72741e7c756 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientReconnectQueriesTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientReconnectQueriesTest.java @@ -37,6 +37,9 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; @@ -45,6 +48,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteClientReconnectQueriesTest extends IgniteClientReconnectAbstractTest { /** */ public static final String QUERY_CACHE = "query"; @@ -84,6 +88,7 @@ public class IgniteClientReconnectQueriesTest extends IgniteClientReconnectAbstr /** * @throws Exception If failed. */ + @Test public void testQueryReconnect() throws Exception { Ignite cln = grid(serverCount()); @@ -128,6 +133,7 @@ public void testQueryReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectQueryInProgress() throws Exception { Ignite cln = grid(serverCount()); @@ -187,6 +193,7 @@ public void testReconnectQueryInProgress() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQueryReconnect() throws Exception { Ignite cln = grid(serverCount()); @@ -244,6 +251,7 @@ public void testScanQueryReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQueryReconnectInProgress1() throws Exception { scanQueryReconnectInProgress(false); } @@ -251,6 +259,7 @@ public void testScanQueryReconnectInProgress1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScanQueryReconnectInProgress2() throws Exception { scanQueryReconnectInProgress(true); } @@ -437,4 +446,4 @@ public void setSurname(String surname) { return S.toString(Person.class, this); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java index c80ae693fee84..cbe3b579ccc5c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java @@ -48,9 +48,9 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.SB; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -60,10 +60,8 @@ * */ @SuppressWarnings({"unchecked", "PackageVisibleField", "serial"}) +@RunWith(JUnit4.class) public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String PERSON_CACHE_NAME = "person"; @@ -98,8 +96,6 @@ public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setClientMode(client); return cfg; @@ -317,6 +313,7 @@ private boolean useCollocatedData() { /** * @throws Exception If failed. */ + @Test public void testDistributedJoins1() throws Exception { distributedJoins = true; @@ -326,6 +323,7 @@ public void testDistributedJoins1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedJoins2() throws Exception { distributedJoins = true; @@ -335,6 +333,7 @@ public void testDistributedJoins2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedJoins3() throws Exception { distributedJoins = true; @@ -344,6 +343,7 @@ public void testDistributedJoins3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollocatedJoins1() throws Exception { distributedJoins = false; @@ -353,6 +353,7 @@ public void testCollocatedJoins1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollocatedJoins2() throws Exception { distributedJoins = false; @@ -362,6 +363,7 @@ public void testCollocatedJoins2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCollocatedJoins3() throws Exception { distributedJoins = false; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicSqlRestoreTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicSqlRestoreTest.java index f7dc7b41ba6de..1c2aa20507016 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicSqlRestoreTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicSqlRestoreTest.java @@ -18,12 +18,20 @@ package org.apache.ignite.internal.processors.cache; import java.io.Serializable; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.sql.Timestamp; import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.Ignition; import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.query.SqlFieldsQuery; @@ -33,10 +41,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.spi.IgniteSpiException; +import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; @@ -44,6 +57,8 @@ /** * */ +@SuppressWarnings("Duplicates") +@RunWith(JUnit4.class) public class IgniteDynamicSqlRestoreTest extends GridCommonAbstractTest implements Serializable { public static final String TEST_CACHE_NAME = "test"; @@ -84,6 +99,7 @@ public class IgniteDynamicSqlRestoreTest extends GridCommonAbstractTest implemen /** * @throws Exception if failed. */ + @Test public void testMergeChangedConfigOnCoordinator() throws Exception { { //given: two started nodes with test table @@ -117,7 +133,7 @@ public void testMergeChangedConfigOnCoordinator() throws Exception { //and: change data try (IgniteDataStreamer s = ig.dataStreamer(TEST_CACHE_NAME)) { s.allowOverwrite(true); - for (int i = 0; i < 5_000; i++) + for (int i = 0; i < 50; i++) s.addData(i, null); } @@ -134,7 +150,7 @@ public void testMergeChangedConfigOnCoordinator() throws Exception { //then: everything is ok try (IgniteDataStreamer s = ig1.dataStreamer(TEST_CACHE_NAME)) { s.allowOverwrite(true); - for (int i = 0; i < 50_000; i++) { + for (int i = 0; i < 50; i++) { BinaryObject bo = ig1.binary().builder(TEST_INDEX_OBJECT) .setField("a", i, Object.class) .setField("b", String.valueOf(i), Object.class) @@ -147,14 +163,136 @@ public void testMergeChangedConfigOnCoordinator() throws Exception { IgniteCache cache = ig1.cache(TEST_CACHE_NAME); - assertThat(doExplainPlan(cache, "explain select * from TestIndexObject where a > 5"), containsString("myindexa")); + assertIndexUsed(cache, "explain select * from TestIndexObject where a > 5", "myindexa"); assertFalse(cache.query(new SqlFieldsQuery("SELECT a,b,c FROM TestIndexObject limit 1")).getAll().isEmpty()); } } + /** + * @throws Exception If failed. + */ + @SuppressWarnings("AssertWithSideEffects") + @Test + public void testIndexCreationWhenNodeStopped() throws Exception { + // Start topology. + startGrid(0); + Ignite srv2 = startGrid(1); + Ignite cli; + + Ignition.setClientMode(true); + + try { + cli = startGrid(2); + } + finally { + Ignition.setClientMode(false); + } + + cli.cluster().active(true); + + // Create table, add some data. + int entryCnt = 50; + + try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10802")) { + executeJdbc(conn, + " CREATE TABLE PERSON (\n" + + " FIRST_NAME VARCHAR,\n" + + " LAST_NAME VARCHAR,\n" + + " ADDRESS VARCHAR,\n" + + " LANG VARCHAR,\n" + + " BIRTH_DATE TIMESTAMP,\n" + + " CONSTRAINT PK_PESON PRIMARY KEY (FIRST_NAME,LAST_NAME,ADDRESS,LANG)\n" + + " ) WITH \"key_type=PersonKeyType, CACHE_NAME=PersonCache, value_type=PersonValueType, AFFINITY_KEY=FIRST_NAME,template=PARTITIONED,backups=1\""); + + try (PreparedStatement stmt = conn.prepareStatement( + "insert into Person(LANG, FIRST_NAME, ADDRESS, LAST_NAME, BIRTH_DATE) values(?,?,?,?,?)")) { + for (int i = 0; i < entryCnt; i++) { + String s = String.valueOf(i); + + stmt.setString(1, s); + stmt.setString(2, s); + stmt.setString(3, s); + stmt.setString(4, s); + stmt.setTimestamp(5, new Timestamp(System.currentTimeMillis())); + + stmt.executeUpdate(); + } + } + } + + // Stop second node. + srv2.close(); + + // Create an index on remaining node. + try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10802")) { + executeJdbc(conn, "create index PERSON_FIRST_NAME_IDX on PERSON(FIRST_NAME)"); + } + + // Restart second node. + startGrid(1); + + // Await for index rebuild on started node. + assert GridTestUtils.waitForCondition(new PA() { + @Override public boolean apply() { + try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10801")) { + try (PreparedStatement stmt = conn.prepareStatement( + "EXPLAIN SELECT * FROM Person USE INDEX(PERSON_FIRST_NAME_IDX) WHERE FIRST_NAME=?")) { + stmt.setString(1, String.valueOf(1)); + + StringBuilder fullPlan = new StringBuilder(); + + try (ResultSet rs = stmt.executeQuery()) { + while (rs.next()) + fullPlan.append(rs.getString(1)).append("; "); + } + + System.out.println("PLAN: " + fullPlan); + + return fullPlan.toString().contains("PUBLIC.PERSON_FIRST_NAME_IDX"); + } + } + catch (Exception e) { + throw new RuntimeException("Query failed.", e); + } + } + }, 5_000); + + // Make sure that data could be queried. + try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10802")) { + try (PreparedStatement stmt = conn.prepareStatement( + "SELECT COUNT(*) FROM Person USE INDEX(PERSON_FIRST_NAME_IDX) WHERE FIRST_NAME=?")) { + for (int i = 0; i < entryCnt; i ++) { + stmt.setString(1, String.valueOf(i)); + + try (ResultSet rs = stmt.executeQuery()) { + rs.next(); + + long cnt = rs.getLong(1); + + assertEquals(1L, cnt); + } + } + } + } + } + + /** + * Execute a statement through JDBC connection. + * + * @param conn Connection. + * @param sql Statement. + * @throws Exception If failed. + */ + private static void executeJdbc(Connection conn, String sql) throws Exception { + try (Statement stmt = conn.createStatement()) { + stmt.execute(sql); + } + } + /** * @throws Exception if failed. */ + @Test public void testTakeConfigFromJoiningNodeOnInactiveGrid() throws Exception { { //given: two started nodes with test table @@ -186,7 +324,7 @@ public void testTakeConfigFromJoiningNodeOnInactiveGrid() throws Exception { //then: config for cache was applying successful IgniteCache cache = ig.cache(TEST_CACHE_NAME); - assertThat(doExplainPlan(cache, "explain select * from TestIndexObject where a > 5"), containsString("myindexa")); + assertIndexUsed(cache, "explain select * from TestIndexObject where a > 5", "myindexa"); assertFalse(cache.query(new SqlFieldsQuery("SELECT a,b,c FROM TestIndexObject limit 1")).getAll().isEmpty()); } } @@ -194,6 +332,7 @@ public void testTakeConfigFromJoiningNodeOnInactiveGrid() throws Exception { /** * @throws Exception if failed. */ + @Test public void testResaveConfigAfterMerge() throws Exception { { //given: two started nodes with test table @@ -233,7 +372,7 @@ public void testResaveConfigAfterMerge() throws Exception { IgniteCache cache = ig.cache(TEST_CACHE_NAME); - assertThat(doExplainPlan(cache, "explain select * from TestIndexObject where a > 5"), containsString("myindexa")); + assertIndexUsed(cache, "explain select * from TestIndexObject where a > 5", "myindexa"); assertFalse(cache.query(new SqlFieldsQuery("SELECT a,b,c FROM TestIndexObject limit 1")).getAll().isEmpty()); } } @@ -241,6 +380,8 @@ public void testResaveConfigAfterMerge() throws Exception { /** * @throws Exception if failed. */ + @SuppressWarnings("ArraysAsListWithZeroOrOneArgument") + @Test public void testMergeChangedConfigOnInactiveGrid() throws Exception { { //given: two started nodes with test table @@ -288,7 +429,7 @@ public void testMergeChangedConfigOnInactiveGrid() throws Exception { //then: config should be merged try (IgniteDataStreamer s = ig1.dataStreamer(TEST_CACHE_NAME)) { s.allowOverwrite(true); - for (int i = 0; i < 5_000; i++) { + for (int i = 0; i < 50; i++) { BinaryObject bo = ig1.binary().builder("TestIndexObject") .setField("a", i, Object.class) .setField("b", String.valueOf(i), Object.class) @@ -300,15 +441,35 @@ public void testMergeChangedConfigOnInactiveGrid() throws Exception { IgniteCache cache = ig1.cache(TEST_CACHE_NAME); //then: index "myindexa" and column "b" restored from node "1" - assertThat(doExplainPlan(cache, "explain select * from TestIndexObject where a > 5"), containsString("myindexa")); - assertThat(doExplainPlan(cache, "explain select * from TestIndexObject where b > 5"), containsString("myindexb")); + assertIndexUsed(cache, "explain select * from TestIndexObject where a > 5", "myindexa"); + assertIndexUsed(cache, "explain select * from TestIndexObject where b > 5", "myindexb"); assertFalse(cache.query(new SqlFieldsQuery("SELECT a,b FROM TestIndexObject limit 1")).getAll().isEmpty()); } } + /** + * Make sure that index is used for the given statement. + * + * @param cache Cache. + * @param sql Statement. + * @param idx Index. + * @throws IgniteCheckedException If failed. + */ + private void assertIndexUsed(IgniteCache cache, String sql, String idx) + throws IgniteCheckedException { + assert GridTestUtils.waitForCondition(new PA() { + @Override public boolean apply() { + String plan = doExplainPlan(cache, sql); + + return plan.contains(idx); + } + }, 10_000); + } + /** * @throws Exception if failed. */ + @Test public void testTakeChangedConfigOnActiveGrid() throws Exception { { //given: two started nodes with test table @@ -341,7 +502,7 @@ public void testTakeChangedConfigOnActiveGrid() throws Exception { //then: config should be merged try (IgniteDataStreamer s = ig.dataStreamer(TEST_CACHE_NAME)) { s.allowOverwrite(true); - for (int i = 0; i < 5_000; i++) { + for (int i = 0; i < 50; i++) { BinaryObject bo = ig.binary().builder("TestIndexObject") .setField("a", i, Object.class) .setField("b", String.valueOf(i), Object.class) @@ -355,7 +516,7 @@ public void testTakeChangedConfigOnActiveGrid() throws Exception { cache.indexReadyFuture().get(); - assertThat(doExplainPlan(cache, "explain select * from TestIndexObject where a > 5"), containsString("myindexa")); + assertIndexUsed(cache, "explain select * from TestIndexObject where a > 5", "myindexa"); assertFalse(cache.query(new SqlFieldsQuery("SELECT a,b,c FROM TestIndexObject limit 1")).getAll().isEmpty()); } } @@ -363,6 +524,8 @@ public void testTakeChangedConfigOnActiveGrid() throws Exception { /** * @throws Exception if failed. */ + @SuppressWarnings("ConstantConditions") + @Test public void testFailJoiningNodeBecauseDifferentSql() throws Exception { { //given: two started nodes with test table @@ -407,6 +570,8 @@ public void testFailJoiningNodeBecauseDifferentSql() throws Exception { /** * @throws Exception if failed. */ + @SuppressWarnings("ConstantConditions") + @Test public void testFailJoiningNodeBecauseFieldInlineSizeIsDifferent() throws Exception { { //given: two started nodes with test table @@ -417,13 +582,13 @@ public void testFailJoiningNodeBecauseFieldInlineSizeIsDifferent() throws Except IgniteCache cache = ig.getOrCreateCache(getTestTableConfiguration()); - cache.query(new SqlFieldsQuery("create index myindexa on TestIndexObject(a) INLINE_SIZE 1000")).getAll(); + cache.query(new SqlFieldsQuery("create index myindexa on TestIndexObject(a) INLINE_SIZE 100")).getAll(); //stop one node and create index on other node stopGrid(1); cache.query(new SqlFieldsQuery("drop index myindexa")).getAll(); - cache.query(new SqlFieldsQuery("create index myindexa on TestIndexObject(a) INLINE_SIZE 2000")).getAll(); + cache.query(new SqlFieldsQuery("create index myindexa on TestIndexObject(a) INLINE_SIZE 200")).getAll(); //and: stopped all grid stopAllGrids(); @@ -447,6 +612,8 @@ public void testFailJoiningNodeBecauseFieldInlineSizeIsDifferent() throws Except /** * @throws Exception if failed. */ + @SuppressWarnings("ConstantConditions") + @Test public void testFailJoiningNodeBecauseNeedConfigUpdateOnActiveGrid() throws Exception { { startGrid(0); @@ -497,7 +664,7 @@ public void testFailJoiningNodeBecauseNeedConfigUpdateOnActiveGrid() throws Exce */ private void fillTestData(Ignite ig) { try (IgniteDataStreamer s = ig.dataStreamer(TEST_CACHE_NAME)) { - for (int i = 0; i < 50_000; i++) { + for (int i = 0; i < 500; i++) { BinaryObject bo = ig.binary().builder("TestIndexObject") .setField("a", i, Object.class) .setField("b", String.valueOf(i), Object.class) diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteErrorOnRebalanceTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteErrorOnRebalanceTest.java index 98aa4aabb1115..8fd4968976afc 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteErrorOnRebalanceTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteErrorOnRebalanceTest.java @@ -33,14 +33,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.IgniteSpiAdapter; import org.apache.ignite.spi.IgniteSpiException; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.indexing.IndexingQueryFilter; import org.apache.ignite.spi.indexing.IndexingSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -50,16 +50,12 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteErrorOnRebalanceTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - cfg.setConsistentId(gridName); DataStorageConfiguration memCfg = new DataStorageConfiguration() @@ -97,6 +93,7 @@ public class IgniteErrorOnRebalanceTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testErrorOnRebalance() throws Exception { Ignite srv0 = startGrid(0); @@ -125,6 +122,10 @@ public void testErrorOnRebalance() throws Exception { awaitPartitionMapExchange(); + srv1.cluster().setBaselineTopology(srv1.cluster().topologyVersion()); + + awaitPartitionMapExchange(); + IgniteCache cache0 = srv0.cache(DEFAULT_CACHE_NAME); IgniteCache cache1 = srv1.cache(DEFAULT_CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java index 0dd237d8e8d3a..4cfd05cea0cad 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * A test for {@link QueryEntity} initialization with incorrect query field name */ +@RunWith(JUnit4.class) public class IncorrectQueryEntityTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -63,6 +67,7 @@ public class IncorrectQueryEntityTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testIncorrectQueryField() throws Exception { try { startGrid(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IndexingCachePartitionLossPolicySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IndexingCachePartitionLossPolicySelfTest.java index f2085994b0cd0..7007499a84552 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IndexingCachePartitionLossPolicySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IndexingCachePartitionLossPolicySelfTest.java @@ -23,8 +23,6 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.IgniteCachePartitionLossPolicySelfTest; -import java.util.Collection; - /** * Partition loss policy test with enabled indexing. */ @@ -39,80 +37,27 @@ public class IndexingCachePartitionLossPolicySelfTest extends IgniteCachePartiti } /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override protected void validateQuery(boolean safe, int part, Ignite node) { - // Get node lost and remaining partitions. - IgniteCache cache = node.cache(CACHE_NAME); - - Collection lostParts = cache.lostPartitions(); - - Integer remainingPart = null; - - for (int i = 0; i < node.affinity(CACHE_NAME).partitions(); i++) { - if (lostParts.contains(i)) - continue; - - remainingPart = i; - - break; - } - - // Determine whether local query should be executed on that node. - boolean execLocQry = false; - - for (int nodePrimaryPart : node.affinity(CACHE_NAME).primaryPartitions(node.cluster().localNode())) { - if (part == nodePrimaryPart) { - execLocQry = true; - - break; - } - } - - // 1. Check query against all partitions. - validateQuery0(safe, node, false); - - // TODO: https://issues.apache.org/jira/browse/IGNITE-7039 -// if (execLocQry) -// validateQuery0(safe, node, true); - - // 2. Check query against LOST partition. - validateQuery0(safe, node, false, part); + protected void checkQueryPasses(Ignite node, boolean loc, int... parts) { + executeQuery(node, loc, parts); + } - // TODO: https://issues.apache.org/jira/browse/IGNITE-7039 -// if (execLocQry) -// validateQuery0(safe, node, true, part); + /** {@inheritDoc} */ + protected void checkQueryFails(Ignite node, boolean loc, int... parts) { + // TODO: Local queries ignore partition loss, see https://issues.apache.org/jira/browse/IGNITE-7039. + if (loc) + return; - // 3. Check query on remaining partition. - if (remainingPart != null) { - executeQuery(node, false, remainingPart); + try { + executeQuery(node, loc, parts); - // 4. Check query over two partitions - normal and LOST. - validateQuery0(safe, node, false, part, remainingPart); + fail("Exception is not thrown."); } - } - - /** - * Query validation routine. - * - * @param safe Safe flag. - * @param node Node. - * @param loc Local flag. - * @param parts Partitions. - */ - private void validateQuery0(boolean safe, Ignite node, boolean loc, int... parts) { - if (safe) { - try { - executeQuery(node, loc, parts); + catch (Exception e) { + boolean exp = e.getMessage() != null && + e.getMessage().contains("Failed to execute query because cache partition has been lost"); - fail("Exception is not thrown."); - } - catch (Exception e) { - assertTrue(e.getMessage(), e.getMessage() != null && - e.getMessage().contains("Failed to execute query because cache partition has been lost")); - } - } - else { - executeQuery(node, loc, parts); + if (!exp) + throw e; } } @@ -124,7 +69,7 @@ private void validateQuery0(boolean safe, Ignite node, boolean loc, int... parts * @param loc Local flag. */ private static void executeQuery(Ignite node, boolean loc, int... parts) { - IgniteCache cache = node.cache(CACHE_NAME); + IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); SqlFieldsQuery qry = new SqlFieldsQuery("SELECT * FROM Integer"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryEntityCaseMismatchTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryEntityCaseMismatchTest.java index 1b0546af2a437..25357d55b476a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryEntityCaseMismatchTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryEntityCaseMismatchTest.java @@ -32,12 +32,16 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test reveals issue of null values in SQL query resultset columns that correspond to compound key. * That happens when QueryEntity.keyFields has wrong register compared to QueryEntity.fields. * Issue only manifests for BinaryMarshaller case. Otherwise the keyFields aren't taken into account. */ +@RunWith(JUnit4.class) public class QueryEntityCaseMismatchTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { @@ -94,7 +98,7 @@ public class QueryEntityCaseMismatchTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCacheInitializationFailure() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Void call() throws Exception { diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryJoinWithDifferentNodeFiltersTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryJoinWithDifferentNodeFiltersTest.java index 47666b93cc04b..4702995be4684 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryJoinWithDifferentNodeFiltersTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/QueryJoinWithDifferentNodeFiltersTest.java @@ -30,10 +30,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class QueryJoinWithDifferentNodeFiltersTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "cache"; @@ -89,6 +93,7 @@ public class QueryJoinWithDifferentNodeFiltersTest extends GridCommonAbstractTes /** * @throws Exception if failed. */ + @Test public void testSize() throws Exception { startGrids(NODE_COUNT); @@ -160,4 +165,4 @@ private static class TestFilter implements IgnitePredicate { return clusterNode.attribute("DATA") != null; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java index f68484171f7bb..4741cbc53a26f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.query.h2.sql.GridSqlQueryParser; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest { /** INSERT statement. */ private final static String INSERT = "insert into Person(_key, name) values (5, 'x')"; @@ -44,6 +48,7 @@ public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest { /** * @throws Exception If error. */ + @Test public void testSqlFieldsQuery() throws Exception { startGrids(2); @@ -55,6 +60,7 @@ public void testSqlFieldsQuery() throws Exception { /** * @throws Exception If error. */ + @Test public void testSqlFieldsQueryWithTopologyChanges() throws Exception { startGrid(0); @@ -68,6 +74,7 @@ public void testSqlFieldsQueryWithTopologyChanges() throws Exception { /** * @throws Exception If error. */ + @Test public void testQueryCaching() throws Exception { startGrid(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java new file mode 100644 index 0000000000000..30bb018330344 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/StartCachesInParallelTest.java @@ -0,0 +1,155 @@ +/* + * 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. + */ +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.Ignite; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.failure.FailureContext; +import org.apache.ignite.failure.StopNodeFailureHandler; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_ALLOW_START_CACHES_IN_PARALLEL; + +/** + * Tests, that cluster could start and activate with all possible values of IGNITE_ALLOW_START_CACHES_IN_PARALLEL. + */ +@RunWith(JUnit4.class) +public class StartCachesInParallelTest extends GridCommonAbstractTest { + /** IGNITE_ALLOW_START_CACHES_IN_PARALLEL option value before tests. */ + private String allowParallel; + + /** Test failure handler. */ + private TestStopNodeFailureHandler failureHnd; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setDataStorageConfiguration( + new DataStorageConfiguration() + .setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true))); + + cfg.setCacheConfiguration( + new CacheConfiguration<>() + .setName(DEFAULT_CACHE_NAME) + .setIndexedTypes(Integer.class, Integer.class)); + + failureHnd = new TestStopNodeFailureHandler(); + + cfg.setFailureHandler(failureHnd); + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + allowParallel = System.getProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + super.afterTestsStopped(); + + if (allowParallel != null) + System.setProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL, allowParallel); + else + System.clearProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** */ + @Test + public void testWithEnabledOption() throws Exception { + doTest("true"); + } + + /** */ + @Test + public void testWithDisabledOption() throws Exception { + doTest("false"); + } + + /** */ + @Test + public void testWithoutOption() throws Exception { + doTest(null); + } + + /** + * Test routine. + * + * @param optionVal IGNITE_ALLOW_START_CACHES_IN_PARALLEL value. + * @throws Exception If failed. + */ + private void doTest(String optionVal) throws Exception { + if (optionVal == null) + System.clearProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL); + else { + Boolean.parseBoolean(optionVal); + + System.setProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL, optionVal); + } + + assertEquals("Property wasn't set", optionVal, System.getProperty(IGNITE_ALLOW_START_CACHES_IN_PARALLEL)); + + IgniteEx node = startGrid(0); + + node.cluster().active(true); + + assertNull("Node failed with " + failureHnd.lastFailureCtx, failureHnd.lastFailureCtx); + + assertTrue(node.cluster().active()); + } + + /** */ + private static class TestStopNodeFailureHandler extends StopNodeFailureHandler { + /** Last failure context. */ + private volatile FailureContext lastFailureCtx; + + /** {@inheritDoc} */ + @Override public boolean handle(Ignite ignite, FailureContext failureCtx) { + lastFailureCtx = failureCtx; + + return super.handle(ignite, failureCtx); + } + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/authentication/SqlUserCommandSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/authentication/SqlUserCommandSelfTest.java index 64819f3173449..15e635bcf48bf 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/authentication/SqlUserCommandSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/authentication/SqlUserCommandSelfTest.java @@ -28,19 +28,17 @@ import org.apache.ignite.internal.processors.authentication.User; import org.apache.ignite.internal.processors.authentication.UserManagementException; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for leaks JdbcConnection on SqlFieldsQuery execute. */ +@RunWith(JUnit4.class) public class SqlUserCommandSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Nodes count. */ private static final int NODES_COUNT = 3; @@ -57,12 +55,6 @@ public class SqlUserCommandSelfTest extends GridCommonAbstractTest { if (getTestIgniteInstanceIndex(igniteInstanceName) == CLI_NODE) cfg.setClientMode(true); - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - cfg.setAuthenticationEnabled(true); cfg.setDataStorageConfiguration(new DataStorageConfiguration() @@ -101,6 +93,7 @@ public class SqlUserCommandSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCreateUpdateDropUser() throws Exception { AuthorizationContext.context(actxDflt); @@ -128,6 +121,7 @@ public void testCreateUpdateDropUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateWithAlreadyExistUser() throws Exception { AuthorizationContext.context(actxDflt); userSql(0, "CREATE USER test WITH PASSWORD 'test'"); @@ -148,6 +142,7 @@ public void testCreateWithAlreadyExistUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAlterDropNotExistUser() throws Exception { AuthorizationContext.context(actxDflt); @@ -175,6 +170,7 @@ public void testAlterDropNotExistUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotAuthenticateOperation() throws Exception { for (int i = 0; i < NODES_COUNT; ++i) { final int idx = i; @@ -208,6 +204,7 @@ public void testNotAuthenticateOperation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNotAuthorizedOperation() throws Exception { AuthorizationContext.context(actxDflt); @@ -250,6 +247,7 @@ public void testNotAuthorizedOperation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDropDefaultUser() throws Exception { AuthorizationContext.context(actxDflt); @@ -269,6 +267,7 @@ public void testDropDefaultUser() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQuotedUsername() throws Exception { AuthorizationContext.context(actxDflt); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheClientQueryReplicatedNodeRestartSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheClientQueryReplicatedNodeRestartSelfTest.java index 996d6a7c583de..aef93bc113a78 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheClientQueryReplicatedNodeRestartSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheClientQueryReplicatedNodeRestartSelfTest.java @@ -44,10 +44,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.internal.util.typedef.X; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -57,6 +57,7 @@ /** * Test for distributed queries with replicated client cache and node restarts. */ +@RunWith(JUnit4.class) public class IgniteCacheClientQueryReplicatedNodeRestartSelfTest extends GridCommonAbstractTest { /** */ private static final String QRY = "select co.id, count(*) cnt\n" + @@ -91,21 +92,12 @@ public class IgniteCacheClientQueryReplicatedNodeRestartSelfTest extends GridCom /** */ private static final int PRODUCT_CNT = 100; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { X.println("Ignite instance name: " + igniteInstanceName); IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - int i = 0; CacheConfiguration[] ccs = new CacheConfiguration[4]; @@ -208,6 +200,7 @@ private void assertClient(IgniteCache c, boolean client) { /** * @throws Exception If failed. */ + @Test public void testRestarts() throws Exception { int duration = 90 * 1000; int qryThreadNum = 5; @@ -437,4 +430,4 @@ private static class Product implements Serializable { this.companyId = companyId; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java index 7a83014e1cd47..591ac9dc6af8f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java @@ -52,8 +52,6 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.util.AttributeNodeFilter; @@ -75,9 +73,6 @@ public abstract class IgniteCacheDistributedPartitionQueryAbstractSelfTest exten /** Grids count. */ protected static final int GRIDS_COUNT = 10; - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Partitions per region distribution. */ protected static final int[] PARTS_PER_REGION = new int[] {10, 20, 30, 40, 24}; @@ -142,11 +137,6 @@ public abstract class IgniteCacheDistributedPartitionQueryAbstractSelfTest exten cfg.setDataStorageConfiguration(memCfg); - TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - spi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(spi); - /** Clients cache */ CacheConfiguration clientCfg = new CacheConfiguration<>(); clientCfg.setName("cl"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java index 0253fe873ed12..af0ddd62cc9a6 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java @@ -20,12 +20,17 @@ import java.util.Arrays; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests cache query configuration. */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedPartitionQueryConfigurationSelfTest extends GridCommonAbstractTest { /** Tests partition validation. */ + @Test public void testPartitions() { final SqlFieldsQuery qry = new SqlFieldsQuery("select 1"); @@ -89,4 +94,4 @@ private void failIfNotThrown(Runnable r) { // No-op. } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java index e6a4e7377a388..379bd50110d65 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests distributed queries over set of partitions on unstable topology. */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest extends IgniteCacheDistributedPartitionQueryAbstractSelfTest { /** {@inheritDoc} */ @@ -53,6 +57,7 @@ public class IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest extends /** * Tests join query within region on unstable topology. */ + @Test public void testJoinQueryUnstableTopology() throws Exception { final AtomicBoolean stop = new AtomicBoolean(); @@ -128,4 +133,4 @@ public void testJoinQueryUnstableTopology() throws Exception { restartStats.get(i)); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java index 00c384870e580..b4e656d9046ea 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java @@ -24,42 +24,53 @@ import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cache.query.SqlQuery; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests distributed queries over set of partitions on stable topology. */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedPartitionQuerySelfTest extends IgniteCacheDistributedPartitionQueryAbstractSelfTest { /** Tests query within region. */ + @Test public void testRegionQuery() { doTestRegionQuery(grid(0)); } /** Tests query within region (client). */ + @Test public void testRegionQueryClient() throws Exception { doTestRegionQuery(grid("client")); } /** Test query within partitions. */ + @Test public void testPartitionsQuery() { doTestPartitionsQuery(grid(0)); } /** Test query within partitions (client). */ + @Test public void testPartitionsQueryClient() throws Exception { doTestPartitionsQuery(grid("client")); } /** Tests join query within region. */ + @Test public void testJoinQuery() { doTestJoinQuery(grid(0)); } /** Tests join query within region. */ + @Test public void testJoinQueryClient() throws Exception { doTestJoinQuery(grid("client")); } /** Tests local query over partitions. */ + @Test public void testLocalQuery() { Affinity affinity = grid(0).affinity("cl"); @@ -87,4 +98,4 @@ public void testLocalQuery() { for (List row : rows) assertEquals("Incorrect partition", parts[0], affinity.partition(row.get(0))); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryCancelSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryCancelSelfTest.java index d5ee0e978f874..88e44aa480381 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryCancelSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryCancelSelfTest.java @@ -30,20 +30,19 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests distributed SQL query cancel related scenarios. */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedQueryCancelSelfTest extends GridCommonAbstractTest { /** Grids count. */ private static final int GRIDS_COUNT = 3; - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache size. */ public static final int CACHE_SIZE = 10_000; @@ -63,8 +62,6 @@ public class IgniteCacheDistributedQueryCancelSelfTest extends GridCommonAbstrac /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - spi.setIpFinder(IP_FINDER); CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setIndexedTypes(Integer.class, String.class); @@ -85,6 +82,7 @@ public class IgniteCacheDistributedQueryCancelSelfTest extends GridCommonAbstrac } /** */ + @Test public void testQueryCancelsOnGridShutdown() throws Exception { try (Ignite client = startGrid("client")) { @@ -138,6 +136,7 @@ public void testQueryCancelsOnGridShutdown() throws Exception { } /** */ + @Test public void testQueryResponseFailCode() throws Exception { try (Ignite client = startGrid("client")) { diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java index 56fd7b8d13b75..5de6351ebd54a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java @@ -37,20 +37,19 @@ import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests distributed SQL queries cancel by user or timeout. */ +@RunWith(JUnit4.class) public class IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest extends GridCommonAbstractTest { /** Grids count. */ private static final int GRIDS_CNT = 3; - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache size. */ public static final int CACHE_SIZE = 10_000; @@ -76,8 +75,6 @@ public class IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest extends Gr /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - spi.setIpFinder(IP_FINDER); CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setIndexedTypes(Integer.class, String.class); @@ -99,76 +96,91 @@ public class IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest extends Gr } /** */ + @Test public void testRemoteQueryExecutionTimeout() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 500, TimeUnit.MILLISECONDS, true); } /** */ + @Test public void testRemoteQueryWithMergeTableTimeout() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 500, TimeUnit.MILLISECONDS, true); } /** */ + @Test public void testRemoteQueryExecutionCancel0() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 1, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testRemoteQueryExecutionCancel1() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 500, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testRemoteQueryExecutionCancel2() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 1, TimeUnit.SECONDS, false); } /** */ + @Test public void testRemoteQueryExecutionCancel3() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_1, 3, TimeUnit.SECONDS, false); } /** */ + @Test public void testRemoteQueryWithMergeTableCancel0() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 1, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testRemoteQueryWithMergeTableCancel1() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 500, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testRemoteQueryWithMergeTableCancel2() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 1_500, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testRemoteQueryWithMergeTableCancel3() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_2, 3, TimeUnit.SECONDS, false); } /** */ + @Test public void testRemoteQueryWithoutMergeTableCancel0() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_3, 1, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testRemoteQueryWithoutMergeTableCancel1() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_3, 500, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testRemoteQueryWithoutMergeTableCancel2() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_3, 1_000, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testRemoteQueryWithoutMergeTableCancel3() throws Exception { testQueryCancel(CACHE_SIZE, VAL_SIZE, QRY_3, 3, TimeUnit.SECONDS, false); } /** */ + @Test public void testRemoteQueryAlreadyFinishedStop() throws Exception { testQueryCancel(100, VAL_SIZE, QRY_3, 3, TimeUnit.SECONDS, false); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java index 7f9989ddeaefc..3a478ed2e3888 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java @@ -27,12 +27,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractFieldsQuerySelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Tests for fields queries. */ +@RunWith(JUnit4.class) public class IgniteCachePartitionedFieldsQuerySelfTest extends IgniteCacheAbstractFieldsQuerySelfTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -62,11 +66,13 @@ protected NearCacheConfiguration nearConfiguration() { } /** @throws Exception If failed. */ + @Test public void testLocalQuery() throws Exception { doTestLocalQuery(intCache, new SqlFieldsQuery("select _key, _val from Integer")); } /** @throws Exception If failed. */ + @Test public void testLocalQueryNoOpCache() throws Exception { doTestLocalQuery(noOpCache, new SqlFieldsQuery("select _key, _val from \"Integer-Integer\".Integer")); } @@ -90,4 +96,4 @@ private void doTestLocalQuery(IgniteCache cache, SqlFieldsQuery fldsQry) t assertEquals(exp, qry.getAll().size()); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java index 72709acde4682..d5ca183899752 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java @@ -41,6 +41,7 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.communication.CommunicationSpi; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; +import org.junit.Test; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CachePeekMode.ALL; @@ -67,6 +68,7 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer /** * @throws Exception If failed. */ + @Test public void testFieldsQuery() throws Exception { Person p1 = new Person("Jon", 1500); Person p2 = new Person("Jane", 2000); @@ -106,6 +108,7 @@ public void testFieldsQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleNodesQuery() throws Exception { Person p1 = new Person("Jon", 1500); Person p2 = new Person("Jane", 2000); @@ -154,6 +157,7 @@ private void checkResult(Iterable> entries, Person... /** * @throws Exception If failed. */ + @Test public void testScanQueryPagination() throws Exception { final int pageSize = 5; @@ -218,4 +222,4 @@ private static class TestTcpCommunicationSpi extends TcpCommunicationSpi { super.sendMessage(node, msg, ackC); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryAbstractDistributedJoinSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryAbstractDistributedJoinSelfTest.java index 7e23c8881cd6a..bcb3841e451f1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryAbstractDistributedJoinSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryAbstractDistributedJoinSelfTest.java @@ -29,9 +29,6 @@ import org.apache.ignite.internal.util.GridRandom; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -82,9 +79,6 @@ public class IgniteCacheQueryAbstractDistributedJoinSelfTest extends GridCommonA /** */ private static final int PRODUCT_CNT = 100; - /** */ - private static TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -92,12 +86,6 @@ public class IgniteCacheQueryAbstractDistributedJoinSelfTest extends GridCommonA if ("client".equals(igniteInstanceName)) c.setClientMode(true); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - int i = 0; CacheConfiguration[] ccs = new CacheConfiguration[4]; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNoRebalanceSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNoRebalanceSelfTest.java index 7b4d400778aa8..07e558df71fe1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNoRebalanceSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNoRebalanceSelfTest.java @@ -24,18 +24,16 @@ import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test added to check for https://issues.apache.org/jira/browse/IGNITE-3326. */ +@RunWith(JUnit4.class) public class IgniteCacheQueryNoRebalanceSelfTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** * */ @@ -47,8 +45,6 @@ public IgniteCacheQueryNoRebalanceSelfTest() { @Override protected IgniteConfiguration getConfiguration() throws Exception { IgniteConfiguration cfg = super.getConfiguration(); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setBackups(0); ccfg.setIndexedTypes(Integer.class, Integer.class); @@ -62,6 +58,7 @@ public IgniteCacheQueryNoRebalanceSelfTest() { /** * Tests correct query execution with disabled re-balancing. */ + @Test public void testQueryNoRebalance() { IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeFailTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeFailTest.java index 6e47399b46854..6b244d5149953 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeFailTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeFailTest.java @@ -27,19 +27,17 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test added to check for https://issues.apache.org/jira/browse/IGNITE-2542. */ +@RunWith(JUnit4.class) public class IgniteCacheQueryNodeFailTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean client; @@ -47,8 +45,6 @@ public class IgniteCacheQueryNodeFailTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - cfg.setClientMode(client); CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); @@ -76,6 +72,7 @@ public class IgniteCacheQueryNodeFailTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testNodeFailedSimpleQuery()throws Exception { checkNodeFailed("select _key from Integer"); } @@ -83,6 +80,7 @@ public void testNodeFailedSimpleQuery()throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeFailedReduceQuery()throws Exception { checkNodeFailed("select avg(_key) from Integer"); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java index bad53030d26dd..634af06a8f775 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartDistributedJoinSelfTest.java @@ -33,10 +33,14 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicIntegerArray; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for distributed queries with node restarts. */ +@RunWith(JUnit4.class) public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends IgniteCacheQueryAbstractDistributedJoinSelfTest { /** Total nodes. */ private int totalNodes = 6; @@ -64,6 +68,7 @@ public class IgniteCacheQueryNodeRestartDistributedJoinSelfTest extends IgniteCa /** * @throws Exception If failed. */ + @Test public void testRestarts() throws Exception { restarts(false); } @@ -71,6 +76,7 @@ public void testRestarts() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestartsBroadcast() throws Exception { restarts(true); } @@ -278,4 +284,4 @@ private void restarts(final boolean broadcastQry) throws Exception { info("Stopped."); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest.java index dd495cfb216a9..57d8d7c136aec 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest.java @@ -38,9 +38,9 @@ import org.apache.ignite.internal.util.typedef.CAX; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -49,6 +49,7 @@ /** * Test for distributed queries with node restarts. */ +@RunWith(JUnit4.class) public class IgniteCacheQueryNodeRestartSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int GRID_CNT = 3; @@ -56,9 +57,6 @@ public class IgniteCacheQueryNodeRestartSelfTest extends GridCacheAbstractSelfTe /** */ private static final int KEY_CNT = 1000; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected int gridCount() { return GRID_CNT; @@ -75,12 +73,6 @@ public class IgniteCacheQueryNodeRestartSelfTest extends GridCacheAbstractSelfTe c.setConsistentId(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); @@ -104,6 +96,7 @@ public class IgniteCacheQueryNodeRestartSelfTest extends GridCacheAbstractSelfTe * @throws Exception If failed. */ @SuppressWarnings({"TooBroadScope"}) + @Test public void testRestarts() throws Exception { int duration = 60 * 1000; int qryThreadNum = 10; @@ -259,4 +252,4 @@ public synchronized boolean awaitEvents(int cnt, long timeout) throws Interrupte return false; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java index 834a7324ef066..c72554f5c4277 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java @@ -45,12 +45,12 @@ import org.apache.ignite.internal.util.typedef.CAX; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.TransactionException; import org.apache.ignite.transactions.TransactionTimeoutException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -61,6 +61,7 @@ /** * Test for distributed queries with node restarts. */ +@RunWith(JUnit4.class) public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest { /** */ private static final String PARTITIONED_QRY = "select co.id, count(*) cnt\n" + @@ -89,9 +90,6 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest /** */ private static final int PRODUCT_CNT = 100; - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); @@ -101,12 +99,6 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest c.setDataStorageConfiguration(memCfg); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - int i = 0; CacheConfiguration[] ccs = new CacheConfiguration[4]; @@ -199,6 +191,7 @@ private void fillCaches() { /** * @throws Exception If failed. */ + @Test public void testRestarts() throws Exception { int duration = 90 * 1000; int qryThreadNum = 4; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java index 03a8d499adbc5..c6dd5cf6493a7 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java @@ -33,47 +33,59 @@ import org.apache.ignite.internal.processors.GridProcessor; import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for cancel of query containing distributed joins. */ +@RunWith(JUnit4.class) public class IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest extends IgniteCacheQueryAbstractDistributedJoinSelfTest { /** */ + @Test public void testCancel1() throws Exception { testQueryCancel(grid(0), "pe", QRY_0, 1, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testCancel2() throws Exception { testQueryCancel(grid(0), "pe", QRY_0, 50, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testCancel3() throws Exception { testQueryCancel(grid(0), "pe", QRY_0, 100, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testCancel4() throws Exception { testQueryCancel(grid(0), "pe", QRY_0, 500, TimeUnit.MILLISECONDS, false); } /** */ + @Test public void testTimeout1() throws Exception { testQueryCancel(grid(0), "pe", QRY_0, 1, TimeUnit.MILLISECONDS, true); } /** */ + @Test public void testTimeout2() throws Exception { testQueryCancel(grid(0), "pe", QRY_0, 50, TimeUnit.MILLISECONDS, true); } /** */ + @Test public void testTimeout3() throws Exception { testQueryCancel(grid(0), "pe", QRY_0, 100, TimeUnit.MILLISECONDS, true); } /** */ + @Test public void testTimeout4() throws Exception { testQueryCancel(grid(0), "pe", QRY_0, 500, TimeUnit.MILLISECONDS, true); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteSqlQueryWithBaselineTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteSqlQueryWithBaselineTest.java index 203a319a3c6b7..81429c535f3a5 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteSqlQueryWithBaselineTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteSqlQueryWithBaselineTest.java @@ -27,20 +27,18 @@ import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import javax.cache.Cache; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteSqlQueryWithBaselineTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -54,12 +52,6 @@ public class IgniteSqlQueryWithBaselineTest extends GridCommonAbstractTest { ) ); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -110,6 +102,7 @@ public static class C2 implements Serializable { /** * @throws Exception If failed. */ + @Test public void testQueryWithNodeNotInBLT() throws Exception { startGrids(2); @@ -123,6 +116,7 @@ public void testQueryWithNodeNotInBLT() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryWithoutBLTNode() throws Exception { startGrids(2); @@ -137,6 +131,7 @@ public void testQueryWithoutBLTNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryFromNotBLTNode() throws Exception { startGrid(1); @@ -181,4 +176,4 @@ private void doQuery() { log.info("result size: " + res.size()); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest.java index a5b3706105112..d97e50b487a2f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -36,6 +39,7 @@ * Tests non-collocated join with REPLICATED cache and no primary partitions for that cache on some nodes. */ @SuppressWarnings("unused") +@RunWith(JUnit4.class) public class IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest extends GridCommonAbstractTest { /** Client node name. */ public static final String NODE_CLI = "client"; @@ -103,6 +107,7 @@ public class IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest ext * * @throws Exception If failed. */ + @Test public void testJoinNonCollocated() throws Exception { SqlFieldsQuery qry = new SqlFieldsQuery("SELECT COUNT(*) FROM PartValue p, RepValue r WHERE p.repId=r.id"); @@ -148,4 +153,4 @@ public RepValue(int id) { this.id = id; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java index 953e5fafa05a9..c4b5c054f208c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java @@ -27,12 +27,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractFieldsQuerySelfTest; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; /** * Tests for fields queries. */ +@RunWith(JUnit4.class) public class IgniteCacheReplicatedFieldsQuerySelfTest extends IgniteCacheAbstractFieldsQuerySelfTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -47,6 +51,7 @@ public class IgniteCacheReplicatedFieldsQuerySelfTest extends IgniteCacheAbstrac /** * @throws Exception If failed. */ + @Test public void testLostIterator() throws Exception { IgniteCache cache = intCache; @@ -77,4 +82,4 @@ public void testLostIterator() throws Exception { } }, IgniteException.class, null); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java index 13942c2ede3d4..52fd0347144b7 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java @@ -46,16 +46,20 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testsuites.IgniteIgnore; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CachePeekMode.ALL; +import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; import static org.apache.ignite.events.EventType.EVT_NODE_LEFT; /** * Tests replicated query. */ +@RunWith(JUnit4.class) public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuerySelfTest { /** */ private static final boolean TEST_DEBUG = false; @@ -101,8 +105,8 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery } /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - super.beforeTestsStarted(); + @Override protected void beforeTest() throws Exception { + super.beforeTest(); ignite1 = grid(0); ignite2 = grid(1); @@ -113,22 +117,10 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery cache3 = jcache(ignite3, CacheKey.class, CacheValue.class); } - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - super.afterTestsStopped(); - - ignite1 = null; - ignite2 = null; - ignite3 = null; - - cache1 = null; - cache2 = null; - cache3 = null; - } - /** * @throws Exception If failed. */ + @Test public void testClientOnlyNode() throws Exception { try { Ignite g = startGrid("client"); @@ -165,6 +157,7 @@ public void testClientOnlyNode() throws Exception { * * @throws Exception If failed. */ + @Test public void testIterator() throws Exception { int keyCnt = 100; @@ -196,6 +189,7 @@ public void testIterator() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testLocalQueryWithExplicitFlag() throws Exception { doTestLocalQuery(true); } @@ -203,6 +197,7 @@ public void testLocalQueryWithExplicitFlag() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testLocalQueryWithoutExplicitFlag() throws Exception { doTestLocalQuery(false); } @@ -240,6 +235,7 @@ private void doTestLocalQuery(boolean loc) throws Exception { /** * @throws Exception If test failed. */ + @Test public void testDistributedQuery() throws Exception { final int keyCnt = 4; @@ -292,6 +288,7 @@ public void testDistributedQuery() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testToString() throws Exception { int keyCnt = 4; @@ -309,6 +306,7 @@ public void testToString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLostIterator() throws Exception { IgniteCache cache = jcache(Integer.class, Integer.class); @@ -346,14 +344,14 @@ public void testLostIterator() throws Exception { /** * @throws Exception If failed. */ - @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-613", forceFailure = true) + @Test public void testNodeLeft() throws Exception { Ignite g = startGrid("client"); try { assertTrue(g.configuration().isClientMode()); - IgniteCache cache = jcache(Integer.class, Integer.class); + IgniteCache cache = jcache(g, Integer.class, Integer.class); for (int i = 0; i < 1000; i++) cache.put(i, i); @@ -384,7 +382,7 @@ public void testNodeLeft() throws Exception { return true; } - }, EVT_NODE_LEFT); + }, EVT_NODE_LEFT, EVT_NODE_FAILED); stopGrid("client"); @@ -434,6 +432,15 @@ private void checkLocalQueryResults(IgniteCache cache, boo assert !iter.hasNext(); } + /** + * @throws Exception If failed. + */ + @Override public void testSqlQueryEvents() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-8765"); + + super.testSqlQueryEvents(); + } + /** * Cache key. */ diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java index 7f1e2e74e8ec1..e7ab35d9d6472 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java @@ -59,9 +59,6 @@ import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; @@ -70,9 +67,6 @@ */ @SuppressWarnings("unchecked") public abstract class AbstractSchemaSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cache. */ protected static final String CACHE_NAME = "cache"; @@ -125,8 +119,6 @@ public abstract class AbstractSchemaSelfTest extends GridCommonAbstractTest { protected IgniteConfiguration commonConfiguration(int idx) throws Exception { IgniteConfiguration cfg = super.getConfiguration(getTestIgniteInstanceName(idx)); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setMarshaller(new BinaryMarshaller()); DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration( @@ -566,7 +558,7 @@ protected void dynamicIndexDrop(Ignite node, String cacheName, String idxName, b * @param node Node to create cache on. */ protected void destroySqlCache(Ignite node) throws IgniteCheckedException { - ((IgniteEx)node).context().cache().dynamicDestroyCache(CACHE_NAME, true, true, false).get(); + ((IgniteEx)node).context().cache().dynamicDestroyCache(CACHE_NAME, true, true, false, null).get(); } /** diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/BasicIndexMultinodeTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/BasicIndexMultinodeTest.java new file mode 100644 index 0000000000000..37c82c2156c84 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/BasicIndexMultinodeTest.java @@ -0,0 +1,28 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.cache.index; + +/** + * A set of basic tests for caches with indexes in multi-node environment. + */ +public class BasicIndexMultinodeTest extends BasicIndexTest { + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 3; + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/BasicIndexTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/BasicIndexTest.java index feb330bcaef87..afd071d364d10 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/BasicIndexTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/BasicIndexTest.java @@ -25,8 +25,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheKeyConfiguration; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.QueryIndex; import org.apache.ignite.cache.query.SqlFieldsQuery; @@ -34,51 +34,43 @@ import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; +import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; /** * A set of basic tests for caches with indexes. */ public class BasicIndexTest extends GridCommonAbstractTest { /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private Collection indexes; + private Collection indexes = Collections.emptyList(); /** */ private Integer inlineSize; /** */ - private Boolean isPersistenceEnabled; + private boolean isPersistenceEnabled; /** */ - private String affKeyFieldName; + private int gridCount = 1; - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - assertNotNull(indexes); - assertNotNull(inlineSize); - assertNotNull(isPersistenceEnabled); - - for (QueryIndex index : indexes) { + for (QueryIndex index : indexes) index.setInlineSize(inlineSize); - } IgniteConfiguration igniteCfg = super.getConfiguration(igniteInstanceName); - igniteCfg.setDiscoverySpi( - new TcpDiscoverySpi().setIpFinder(IP_FINDER) - ); + igniteCfg.setConsistentId(igniteInstanceName); LinkedHashMap fields = new LinkedHashMap<>(); fields.put("keyStr", String.class.getName()); @@ -98,13 +90,6 @@ public class BasicIndexTest extends GridCommonAbstractTest { )) .setSqlIndexMaxInlineSize(inlineSize); - if (affKeyFieldName != null) { - ccfg.setKeyConfiguration(new CacheKeyConfiguration() - .setTypeName(Key.class.getTypeName()) - .setAffinityKeyFieldName(affKeyFieldName) - ); - } - igniteCfg.setCacheConfiguration(ccfg); if (isPersistenceEnabled) { @@ -118,7 +103,9 @@ public class BasicIndexTest extends GridCommonAbstractTest { return igniteCfg; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override protected void beforeTest() throws Exception { super.beforeTest(); @@ -127,47 +114,46 @@ public class BasicIndexTest extends GridCommonAbstractTest { cleanPersistenceDir(); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override protected void afterTest() throws Exception { stopAllGrids(); cleanPersistenceDir(); - indexes = null; - - inlineSize = null; - - isPersistenceEnabled = null; - - affKeyFieldName = null; - super.afterTest(); } + /** + * @return Grid count used in test. + */ + protected int gridCount() { + return gridCount; + } + /** */ + @Test public void testNoIndexesNoPersistence() throws Exception { - indexes = Collections.emptyList(); - - isPersistenceEnabled = false; - - int[] inlineSizes = { 0, 10, 20, 50, 100 }; + int[] inlineSizes = {0, 10, 20, 50, 100}; for (int i : inlineSizes) { log().info("Checking inlineSize=" + i); inlineSize = i; - startGrid(); + startGridsMultiThreaded(gridCount()); populateCache(); checkAll(); - stopGrid(); + stopAllGrids(); } } /** */ + @Test public void testAllIndexesNoPersistence() throws Exception { indexes = Arrays.asList( new QueryIndex("keyStr"), @@ -178,39 +164,34 @@ public void testAllIndexesNoPersistence() throws Exception { new QueryIndex("valPojo") ); - isPersistenceEnabled = false; - - int[] inlineSizes = { 0, 10, 20, 50, 100 }; + int[] inlineSizes = {0, 10, 20, 50, 100}; for (int i : inlineSizes) { log().info("Checking inlineSize=" + i); inlineSize = i; - startGrid(); + startGridsMultiThreaded(gridCount()); populateCache(); checkAll(); - stopGrid(); + stopAllGrids(); } } /** */ + @Test public void testDynamicIndexesNoPersistence() throws Exception { - indexes = Collections.emptyList(); - - isPersistenceEnabled = false; - - int[] inlineSizes = { 0, 10, 20, 50, 100 }; + int[] inlineSizes = {0, 10, 20, 50, 100}; for (int i : inlineSizes) { log().info("Checking inlineSize=" + i); inlineSize = i; - startGrid(); + startGridsMultiThreaded(gridCount()); populateCache(); @@ -225,46 +206,42 @@ public void testDynamicIndexesNoPersistence() throws Exception { checkAll(); - stopGrid(); + stopAllGrids(); } } /** */ + @Test public void testNoIndexesWithPersistence() throws Exception { - indexes = Collections.emptyList(); - isPersistenceEnabled = true; - int[] inlineSizes = { 0, 10, 20, 50, 100 }; + int[] inlineSizes = {0, 10, 20, 50, 100}; for (int i : inlineSizes) { log().info("Checking inlineSize=" + i); inlineSize = i; - startGrid(); - - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); populateCache(); checkAll(); - stopGrid(); - - startGrid(); + stopAllGrids(); - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); checkAll(); - stopGrid(); + stopAllGrids(); cleanPersistenceDir(); } } /** */ + @Test public void testAllIndexesWithPersistence() throws Exception { indexes = Arrays.asList( new QueryIndex("keyStr"), @@ -277,51 +254,44 @@ public void testAllIndexesWithPersistence() throws Exception { isPersistenceEnabled = true; - int[] inlineSizes = { 0, 10, 20, 50, 100 }; + int[] inlineSizes = {0, 10, 20, 50, 100}; for (int i : inlineSizes) { log().info("Checking inlineSize=" + i); inlineSize = i; - startGrid(); - - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); populateCache(); checkAll(); - stopGrid(); - - startGrid(); + stopAllGrids(); - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); checkAll(); - stopGrid(); + stopAllGrids(); cleanPersistenceDir(); } } /** */ + @Test public void testDynamicIndexesWithPersistence() throws Exception { - indexes = Collections.emptyList(); - isPersistenceEnabled = true; - int[] inlineSizes = { 0, 10, 20, 50, 100 }; + int[] inlineSizes = {0, 10, 20, 50, 100}; for (int i : inlineSizes) { log().info("Checking inlineSize=" + i); inlineSize = i; - startGrid(); - - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); populateCache(); @@ -336,66 +306,105 @@ public void testDynamicIndexesWithPersistence() throws Exception { checkAll(); - stopGrid(); + stopAllGrids(); + + startGridsMultiThreaded(gridCount()); + + checkAll(); + + stopAllGrids(); + + cleanPersistenceDir(); + } + } + + /** */ + @Test + public void testDynamicIndexesDropWithPersistence() throws Exception { + isPersistenceEnabled = true; - startGrid(); + int[] inlineSizes = {0, 10, 20, 50, 100}; - grid().cluster().active(true); + for (int i : inlineSizes) { + log().info("Checking inlineSize=" + i); + + inlineSize = i; + + startGridsMultiThreaded(gridCount()); + + populateCache(); + + String[] cols = { + "keyStr", + "keyLong", + "keyPojo", + "valStr", + "valLong", + "valPojo" + }; + + createDynamicIndexes(cols); + + checkAll(); + + dropDynamicIndexes(cols); + + checkAll(); + + stopAllGrids(); + + startGridsMultiThreaded(gridCount()); checkAll(); - stopGrid(); + stopAllGrids(); cleanPersistenceDir(); } } /** */ + @Test public void testNoIndexesWithPersistenceIndexRebuild() throws Exception { - indexes = Collections.emptyList(); - isPersistenceEnabled = true; - int[] inlineSizes = { 0, 10, 20, 50, 100 }; + int[] inlineSizes = {0, 10, 20, 50, 100}; for (int i : inlineSizes) { log().info("Checking inlineSize=" + i); inlineSize = i; - startGrid(); - - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); populateCache(); checkAll(); - Path idxPath = getIndexBinPath(); + List idxPaths = getIndexBinPaths(); // Shutdown gracefully to ensure there is a checkpoint with index.bin. // Otherwise index.bin rebuilding may not work. - grid().cluster().active(false); - - stopGrid(); + grid(0).cluster().active(false); - assertTrue(U.delete(idxPath)); + stopAllGrids(); - startGrid(); + idxPaths.forEach(idxPath -> assertTrue(U.delete(idxPath))); - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); - grid().cache(DEFAULT_CACHE_NAME).indexReadyFuture().get(); + grid(0).cache(DEFAULT_CACHE_NAME).indexReadyFuture().get(); checkAll(); - stopGrid(); + stopAllGrids(); cleanPersistenceDir(); } } /** */ + @Test public void testAllIndexesWithPersistenceIndexRebuild() throws Exception { indexes = Arrays.asList( new QueryIndex("keyStr"), @@ -408,61 +417,54 @@ public void testAllIndexesWithPersistenceIndexRebuild() throws Exception { isPersistenceEnabled = true; - int[] inlineSizes = { 0, 10, 20, 50, 100 }; + int[] inlineSizes = {0, 10, 20, 50, 100}; for (int i : inlineSizes) { log().info("Checking inlineSize=" + i); inlineSize = i; - startGrid(); - - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); populateCache(); checkAll(); - Path idxPath = getIndexBinPath(); + List idxPaths = getIndexBinPaths(); // Shutdown gracefully to ensure there is a checkpoint with index.bin. // Otherwise index.bin rebuilding may not work. - grid().cluster().active(false); - - stopGrid(); + grid(0).cluster().active(false); - assertTrue(U.delete(idxPath)); + stopAllGrids(); - startGrid(); + idxPaths.forEach(idxPath -> assertTrue(U.delete(idxPath))); - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); - grid().cache(DEFAULT_CACHE_NAME).indexReadyFuture().get(); + grid(0).cache(DEFAULT_CACHE_NAME).indexReadyFuture().get(); checkAll(); - stopGrid(); + stopAllGrids(); cleanPersistenceDir(); } } /** */ + @Test public void testDynamicIndexesWithPersistenceIndexRebuild() throws Exception { - indexes = Collections.emptyList(); - isPersistenceEnabled = true; - int[] inlineSizes = { 0, 10, 20, 50, 100 }; + int[] inlineSizes = {0, 10, 20, 50, 100}; for (int i : inlineSizes) { log().info("Checking inlineSize=" + i); inlineSize = i; - startGrid(); - - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); populateCache(); @@ -477,25 +479,23 @@ public void testDynamicIndexesWithPersistenceIndexRebuild() throws Exception { checkAll(); - Path idxPath = getIndexBinPath(); + List idxPaths = getIndexBinPaths(); // Shutdown gracefully to ensure there is a checkpoint with index.bin. // Otherwise index.bin rebuilding may not work. - grid().cluster().active(false); - - stopGrid(); + grid(0).cluster().active(false); - assertTrue(U.delete(idxPath)); + stopAllGrids(); - startGrid(); + idxPaths.forEach(idxPath -> assertTrue(U.delete(idxPath))); - grid().cluster().active(true); + startGridsMultiThreaded(gridCount()); - grid().cache(DEFAULT_CACHE_NAME).indexReadyFuture().get(); + grid(0).cache(DEFAULT_CACHE_NAME).indexReadyFuture().get(); checkAll(); - stopGrid(); + stopAllGrids(); cleanPersistenceDir(); } @@ -503,7 +503,7 @@ public void testDynamicIndexesWithPersistenceIndexRebuild() throws Exception { /** */ private void checkAll() { - IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); + IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); checkRemovePut(cache); @@ -520,7 +520,7 @@ private void checkAll() { /** */ private void populateCache() { - IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); + IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); // Be paranoid and populate first even indexes in ascending order, then odd indexes in descending // to check that inserting in the middle works. @@ -557,9 +557,9 @@ private void checkSelectAll(IgniteCache cache) { assertEquals(100, data.size()); for (List row : data) { - Key key = (Key)row.get(0); + Key key = (Key) row.get(0); - Val val = (Val)row.get(1); + Val val = (Val) row.get(1); long i = key.keyLong; @@ -616,9 +616,9 @@ private void checkSelectStringRange(IgniteCache cache) { assertEquals(10, data.size()); for (List row : data) { - Key key = (Key)row.get(0); + Key key = (Key) row.get(0); - Val val = (Val)row.get(1); + Val val = (Val) row.get(1); long i = key.keyLong; @@ -644,9 +644,9 @@ private void checkSelectLongRange(IgniteCache cache) { assertEquals(10, data.size()); for (List row : data) { - Key key = (Key)row.get(0); + Key key = (Key) row.get(0); - Val val = (Val)row.get(1); + Val val = (Val) row.get(1); long i = key.keyLong; @@ -658,29 +658,54 @@ private void checkSelectLongRange(IgniteCache cache) { } } - /** Must be called when the grid is up. */ - private Path getIndexBinPath() { - IgniteInternalCache cachex = grid().cachex(DEFAULT_CACHE_NAME); + /** + * Must be called when the grid is up. + */ + private List getIndexBinPaths() { + return G.allGrids().stream() + .map(grid -> (IgniteEx) grid) + .map(grid -> { + IgniteInternalCache cachex = grid.cachex(DEFAULT_CACHE_NAME); - assertNotNull(cachex); + assertNotNull(cachex); - FilePageStoreManager pageStoreMgr = (FilePageStoreManager)cachex.context().shared().pageStore(); + FilePageStoreManager pageStoreMgr = (FilePageStoreManager) cachex.context().shared().pageStore(); - assertNotNull(pageStoreMgr); + assertNotNull(pageStoreMgr); - File cacheWorkDir = pageStoreMgr.cacheWorkDir(cachex.configuration()); + File cacheWorkDir = pageStoreMgr.cacheWorkDir(cachex.configuration()); - return cacheWorkDir.toPath().resolve("index.bin"); + return cacheWorkDir.toPath().resolve("index.bin"); + }) + .collect(Collectors.toList()); } /** */ private void createDynamicIndexes(String... cols) { - IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); + IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); for (String col : cols) { + String indexName = col + "_idx"; + String schemaName = DEFAULT_CACHE_NAME; + + cache.query(new SqlFieldsQuery( + String.format("create index %s on \"%s\".Val(%s) INLINE_SIZE %s;", indexName, schemaName, col, inlineSize) + )).getAll(); + } + + cache.indexReadyFuture().get(); + } + + /** */ + private void dropDynamicIndexes(String... cols) { + IgniteCache cache = grid(0).cache(DEFAULT_CACHE_NAME); + + for (String col : cols) { + String indexName = col + "_idx"; + cache.query(new SqlFieldsQuery( - "create index on Val(" + col + ") INLINE_SIZE " + inlineSize - )); + String.format("drop index %s;", indexName) + )).getAll(); } cache.indexReadyFuture().get(); @@ -714,7 +739,9 @@ private Key(String str, long aLong, Pojo pojo) { keyPojo = pojo; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public boolean equals(Object o) { if (this == o) return true; @@ -722,19 +749,23 @@ private Key(String str, long aLong, Pojo pojo) { if (o == null || getClass() != o.getClass()) return false; - Key key = (Key)o; + Key key = (Key) o; return keyLong == key.keyLong && Objects.equals(keyStr, key.keyStr) && Objects.equals(keyPojo, key.keyPojo); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public int hashCode() { return Objects.hash(keyStr, keyLong, keyPojo); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return S.toString(Key.class, this); } @@ -758,7 +789,9 @@ private Val(String str, long aLong, Pojo pojo) { valPojo = pojo; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public boolean equals(Object o) { if (this == o) return true; @@ -766,19 +799,23 @@ private Val(String str, long aLong, Pojo pojo) { if (o == null || getClass() != o.getClass()) return false; - Val val = (Val)o; + Val val = (Val) o; return valLong == val.valLong && Objects.equals(valStr, val.valStr) && Objects.equals(valPojo, val.valPojo); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public int hashCode() { return Objects.hash(valStr, valLong, valPojo); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return S.toString(Val.class, this); } @@ -794,7 +831,9 @@ private Pojo(long pojoLong) { this.pojoLong = pojoLong; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public boolean equals(Object o) { if (this == o) return true; @@ -802,17 +841,21 @@ private Pojo(long pojoLong) { if (o == null || getClass() != o.getClass()) return false; - Pojo pojo = (Pojo)o; + Pojo pojo = (Pojo) o; return pojoLong == pojo.pojoLong; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public int hashCode() { return Objects.hash(pojoLong); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String toString() { return S.toString(Pojo.class, this); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DuplicateKeyValueClassesSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DuplicateKeyValueClassesSelfTest.java index 6eb1bb982df7f..2b67214b90bed 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DuplicateKeyValueClassesSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DuplicateKeyValueClassesSelfTest.java @@ -22,11 +22,15 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.UUID; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Make sure that cache can start with multiple key-value classes of the same type. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class DuplicateKeyValueClassesSelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -48,6 +52,7 @@ public class DuplicateKeyValueClassesSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testDuplicateKeyClass() throws Exception { CacheConfiguration ccfg = new CacheConfiguration() .setName(CACHE_NAME) @@ -61,6 +66,7 @@ public void testDuplicateKeyClass() throws Exception { * * @throws Exception If failed. */ + @Test public void testDuplicateValueClass() throws Exception { CacheConfiguration ccfg = new CacheConfiguration() .setName(CACHE_NAME) diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java index 072f1ab2d136a..9d03d2434cb69 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractConcurrentSelfTest.java @@ -59,6 +59,9 @@ import org.apache.ignite.internal.util.typedef.T3; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgnitePredicate; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteClientReconnectAbstractTest.TestTcpDiscoverySpi; @@ -66,6 +69,7 @@ * Concurrency tests for dynamic index create/drop. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public abstract class DynamicColumnsAbstractConcurrentSelfTest extends DynamicColumnsAbstractTest { /** Test duration. */ private static final long TEST_DUR = 10_000L; @@ -155,6 +159,7 @@ public abstract class DynamicColumnsAbstractConcurrentSelfTest extends DynamicCo * * @throws Exception If failed. */ + @Test public void testAddColumnCoordinatorChange() throws Exception { checkCoordinatorChange(true); } @@ -164,6 +169,7 @@ public void testAddColumnCoordinatorChange() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropColumnCoordinatorChange() throws Exception { checkCoordinatorChange(false); } @@ -241,6 +247,7 @@ public void checkCoordinatorChange(boolean addOrRemove) throws Exception { * * @throws Exception If failed. */ + @Test public void testOperationChaining() throws Exception { // 7 nodes * 2 columns = 14 latch countdowns. CountDownLatch finishLatch = new CountDownLatch(14); @@ -295,6 +302,7 @@ public void testOperationChaining() throws Exception { * * @throws Exception If failed. */ + @Test public void testNodeJoinOnPendingAddOperation() throws Exception { checkNodeJoinOnPendingOperation(true); } @@ -304,6 +312,7 @@ public void testNodeJoinOnPendingAddOperation() throws Exception { * * @throws Exception If failed. */ + @Test public void testNodeJoinOnPendingDropOperation() throws Exception { checkNodeJoinOnPendingOperation(false); } @@ -351,6 +360,7 @@ private void checkNodeJoinOnPendingOperation(boolean addOrRemove) throws Excepti * * @throws Exception If failed, */ + @Test public void testConcurrentPutRemove() throws Exception { CountDownLatch finishLatch = new CountDownLatch(4); @@ -481,6 +491,7 @@ private Object key(int id) { * * @throws Exception If failed. */ + @Test public void testAddConcurrentRebalance() throws Exception { checkConcurrentRebalance(true); } @@ -490,6 +501,7 @@ public void testAddConcurrentRebalance() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropConcurrentRebalance() throws Exception { checkConcurrentRebalance(false); } @@ -557,6 +569,7 @@ private void put(Ignite node, int startIdx, int endIdx) { * * @throws Exception If failed. */ + @Test public void testAddConcurrentCacheDestroy() throws Exception { checkConcurrentCacheDestroy(true); } @@ -566,6 +579,7 @@ public void testAddConcurrentCacheDestroy() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropConcurrentCacheDestroy() throws Exception { checkConcurrentCacheDestroy(false); } @@ -626,6 +640,7 @@ private void checkConcurrentCacheDestroy(boolean addOrRemove) throws Exception { * * @throws Exception If failed. */ + @Test public void testQueryConsistencyMultithreaded() throws Exception { // Start complex topology. ignitionStart(serverConfiguration(1)); @@ -717,6 +732,7 @@ public void testQueryConsistencyMultithreaded() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientReconnect() throws Exception { checkClientReconnect(false, true); } @@ -726,6 +742,7 @@ public void testClientReconnect() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientReconnectWithCacheRestart() throws Exception { checkClientReconnect(true, true); } @@ -735,6 +752,7 @@ public void testClientReconnectWithCacheRestart() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientReconnectWithNonDynamicCache() throws Exception { checkClientReconnect(false, false); } @@ -744,6 +762,7 @@ public void testClientReconnectWithNonDynamicCache() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientReconnectWithNonDynamicCacheRestart() throws Exception { checkClientReconnect(true, false); } @@ -842,6 +861,7 @@ private void reconnectClientNode(final Ignite srvNode, final Ignite cliNode, fin * @throws Exception If failed. */ @SuppressWarnings("StringConcatenationInLoop") + @Test public void testConcurrentOperationsAndNodeStartStopMultithreaded() throws Exception { // Start several stable nodes. ignitionStart(serverConfiguration(1)); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java index 5ddafa355888d..e515e27416096 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicColumnsAbstractTest.java @@ -38,9 +38,6 @@ import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.processors.query.QueryField; import org.apache.ignite.internal.processors.query.QueryUtils; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.h2.value.DataType; @@ -61,9 +58,6 @@ public abstract class DynamicColumnsAbstractTest extends GridCommonAbstractTest /** SQL to drop test table. */ final static String DROP_SQL = "DROP TABLE Person"; - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** * Check that given columns are seen by client. * @param node Node to check. @@ -181,8 +175,6 @@ protected IgniteConfiguration clientConfiguration(int idx) throws Exception { protected IgniteConfiguration commonConfiguration(int idx) throws Exception { IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(idx)); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration( new DataRegionConfiguration().setMaxSize(128L * 1024 * 1024)); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java index bd3b0939e92bd..7bc95c79e6c85 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java @@ -23,7 +23,6 @@ import java.util.concurrent.Callable; import javax.cache.CacheException; import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.Ignition; import org.apache.ignite.cache.CacheAtomicityMode; @@ -39,6 +38,9 @@ import org.apache.ignite.internal.processors.query.schema.SchemaOperationException; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; @@ -48,7 +50,8 @@ /** * Tests for dynamic index creation. */ -@SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"}) +@SuppressWarnings({"unchecked"}) +@RunWith(JUnit4.class) public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbstractSelfTest { /** Node index for regular server (coordinator). */ protected static final int IDX_SRV_CRD = 0; @@ -78,7 +81,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { - node().context().cache().dynamicDestroyCache(CACHE_NAME, true, true, false).get(); + node().context().cache().dynamicDestroyCache(CACHE_NAME, true, true, false, null).get(); super.afterTest(); } @@ -137,6 +140,7 @@ private void loadInitialData() { * * @throws Exception If failed. */ + @Test public void testCreatePartitionedAtomic() throws Exception { checkCreate(PARTITIONED, ATOMIC, false); } @@ -146,6 +150,7 @@ public void testCreatePartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreatePartitionedAtomicNear() throws Exception { checkCreate(PARTITIONED, ATOMIC, true); } @@ -155,6 +160,7 @@ public void testCreatePartitionedAtomicNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreatePartitionedTransactional() throws Exception { checkCreate(PARTITIONED, TRANSACTIONAL, false); } @@ -164,6 +170,7 @@ public void testCreatePartitionedTransactional() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreatePartitionedTransactionalNear() throws Exception { checkCreate(PARTITIONED, TRANSACTIONAL, true); } @@ -173,6 +180,7 @@ public void testCreatePartitionedTransactionalNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateReplicatedAtomic() throws Exception { checkCreate(REPLICATED, ATOMIC, false); } @@ -182,6 +190,7 @@ public void testCreateReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateReplicatedTransactional() throws Exception { checkCreate(REPLICATED, TRANSACTIONAL, false); } @@ -221,6 +230,7 @@ private void checkCreate(CacheMode mode, CacheAtomicityMode atomicityMode, boole * * @throws Exception If failed. */ + @Test public void testCreateCompositePartitionedAtomic() throws Exception { checkCreateComposite(PARTITIONED, ATOMIC, false); } @@ -230,6 +240,7 @@ public void testCreateCompositePartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateCompositePartitionedAtomicNear() throws Exception { checkCreateComposite(PARTITIONED, ATOMIC, true); } @@ -239,6 +250,7 @@ public void testCreateCompositePartitionedAtomicNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateCompositePartitionedTransactional() throws Exception { checkCreateComposite(PARTITIONED, TRANSACTIONAL, false); } @@ -248,6 +260,7 @@ public void testCreateCompositePartitionedTransactional() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateCompositePartitionedTransactionalNear() throws Exception { checkCreateComposite(PARTITIONED, TRANSACTIONAL, true); } @@ -257,6 +270,7 @@ public void testCreateCompositePartitionedTransactionalNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateCompositeReplicatedAtomic() throws Exception { checkCreateComposite(REPLICATED, ATOMIC, false); } @@ -266,6 +280,7 @@ public void testCreateCompositeReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateCompositeReplicatedTransactional() throws Exception { checkCreateComposite(REPLICATED, TRANSACTIONAL, false); } @@ -297,6 +312,7 @@ private void checkCreateComposite(CacheMode mode, CacheAtomicityMode atomicityMo * * @throws Exception If failed. */ + @Test public void testCreateIndexNoCachePartitionedAtomic() throws Exception { checkCreateNotCache(PARTITIONED, ATOMIC, false); } @@ -306,6 +322,7 @@ public void testCreateIndexNoCachePartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexNoCachePartitionedAtomicNear() throws Exception { checkCreateNotCache(PARTITIONED, ATOMIC, true); } @@ -315,6 +332,7 @@ public void testCreateIndexNoCachePartitionedAtomicNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexNoCachePartitionedTransactional() throws Exception { checkCreateNotCache(PARTITIONED, TRANSACTIONAL, false); } @@ -324,6 +342,7 @@ public void testCreateIndexNoCachePartitionedTransactional() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexNoCachePartitionedTransactionalNear() throws Exception { checkCreateNotCache(PARTITIONED, TRANSACTIONAL, true); } @@ -333,6 +352,7 @@ public void testCreateIndexNoCachePartitionedTransactionalNear() throws Exceptio * * @throws Exception If failed. */ + @Test public void testCreateIndexNoCacheReplicatedAtomic() throws Exception { checkCreateNotCache(REPLICATED, ATOMIC, false); } @@ -342,6 +362,7 @@ public void testCreateIndexNoCacheReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexNoCacheReplicatedTransactional() throws Exception { checkCreateNotCache(REPLICATED, TRANSACTIONAL, false); } @@ -383,6 +404,7 @@ private void checkCreateNotCache(CacheMode mode, CacheAtomicityMode atomicityMod * * @throws Exception If failed. */ + @Test public void testCreateNoTablePartitionedAtomic() throws Exception { checkCreateNoTable(PARTITIONED, ATOMIC, false); } @@ -392,6 +414,7 @@ public void testCreateNoTablePartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateNoTablePartitionedAtomicNear() throws Exception { checkCreateNoTable(PARTITIONED, ATOMIC, true); } @@ -401,6 +424,7 @@ public void testCreateNoTablePartitionedAtomicNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateNoTablePartitionedTransactional() throws Exception { checkCreateNoTable(PARTITIONED, TRANSACTIONAL, false); } @@ -410,6 +434,7 @@ public void testCreateNoTablePartitionedTransactional() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateNoTablePartitionedTransactionalNear() throws Exception { checkCreateNoTable(PARTITIONED, TRANSACTIONAL, true); } @@ -419,6 +444,7 @@ public void testCreateNoTablePartitionedTransactionalNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateNoTableReplicatedAtomic() throws Exception { checkCreateNoTable(REPLICATED, ATOMIC, false); } @@ -428,6 +454,7 @@ public void testCreateNoTableReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateNoTableReplicatedTransactional() throws Exception { checkCreateNoTable(REPLICATED, TRANSACTIONAL, false); } @@ -459,6 +486,7 @@ private void checkCreateNoTable(CacheMode mode, CacheAtomicityMode atomicityMode * * @throws Exception If failed. */ + @Test public void testCreateIndexNoColumnPartitionedAtomic() throws Exception { checkCreateIndexNoColumn(PARTITIONED, ATOMIC, false); } @@ -468,6 +496,7 @@ public void testCreateIndexNoColumnPartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexNoColumnPartitionedAtomicNear() throws Exception { checkCreateIndexNoColumn(PARTITIONED, ATOMIC, true); } @@ -477,6 +506,7 @@ public void testCreateIndexNoColumnPartitionedAtomicNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexNoColumnPartitionedTransactional() throws Exception { checkCreateIndexNoColumn(PARTITIONED, TRANSACTIONAL, false); } @@ -486,6 +516,7 @@ public void testCreateIndexNoColumnPartitionedTransactional() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexNoColumnPartitionedTransactionalNear() throws Exception { checkCreateIndexNoColumn(PARTITIONED, TRANSACTIONAL, true); } @@ -495,6 +526,7 @@ public void testCreateIndexNoColumnPartitionedTransactionalNear() throws Excepti * * @throws Exception If failed. */ + @Test public void testCreateIndexNoColumnReplicatedAtomic() throws Exception { checkCreateIndexNoColumn(REPLICATED, ATOMIC, false); } @@ -504,6 +536,7 @@ public void testCreateIndexNoColumnReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexNoColumnReplicatedTransactional() throws Exception { checkCreateIndexNoColumn(REPLICATED, TRANSACTIONAL, false); } @@ -535,6 +568,7 @@ private void checkCreateIndexNoColumn(CacheMode mode, CacheAtomicityMode atomici * * @throws Exception If failed. */ + @Test public void testCreateIndexOnColumnWithAliasPartitionedAtomic() throws Exception { checkCreateIndexOnColumnWithAlias(PARTITIONED, ATOMIC, false); } @@ -544,6 +578,7 @@ public void testCreateIndexOnColumnWithAliasPartitionedAtomic() throws Exception * * @throws Exception If failed. */ + @Test public void testCreateIndexOnColumnWithAliasPartitionedAtomicNear() throws Exception { checkCreateIndexOnColumnWithAlias(PARTITIONED, ATOMIC, true); } @@ -553,6 +588,7 @@ public void testCreateIndexOnColumnWithAliasPartitionedAtomicNear() throws Excep * * @throws Exception If failed. */ + @Test public void testCreateIndexOnColumnWithAliasPartitionedTransactional() throws Exception { checkCreateIndexOnColumnWithAlias(PARTITIONED, TRANSACTIONAL, false); } @@ -562,6 +598,7 @@ public void testCreateIndexOnColumnWithAliasPartitionedTransactional() throws Ex * * @throws Exception If failed. */ + @Test public void testCreateColumnWithAliasPartitionedTransactionalNear() throws Exception { checkCreateIndexOnColumnWithAlias(PARTITIONED, TRANSACTIONAL, true); } @@ -571,6 +608,7 @@ public void testCreateColumnWithAliasPartitionedTransactionalNear() throws Excep * * @throws Exception If failed. */ + @Test public void testCreateColumnWithAliasReplicatedAtomic() throws Exception { checkCreateIndexOnColumnWithAlias(REPLICATED, ATOMIC, false); } @@ -580,6 +618,7 @@ public void testCreateColumnWithAliasReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateColumnWithAliasReplicatedTransactional() throws Exception { checkCreateIndexOnColumnWithAlias(REPLICATED, TRANSACTIONAL, false); } @@ -621,6 +660,7 @@ private void checkCreateIndexOnColumnWithAlias(CacheMode mode, CacheAtomicityMod * * @throws Exception If failed. */ + @Test public void testCreateIndexWithInlineSizePartitionedAtomic() throws Exception { checkCreateIndexWithInlineSize(PARTITIONED, ATOMIC, false); } @@ -630,6 +670,7 @@ public void testCreateIndexWithInlineSizePartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexWithInlineSizePartitionedAtomicNear() throws Exception { checkCreateIndexWithInlineSize(PARTITIONED, ATOMIC, true); } @@ -639,6 +680,7 @@ public void testCreateIndexWithInlineSizePartitionedAtomicNear() throws Exceptio * * @throws Exception If failed. */ + @Test public void testCreateIndexWithInlineSizePartitionedTransactional() throws Exception { checkCreateIndexWithInlineSize(PARTITIONED, TRANSACTIONAL, false); } @@ -648,6 +690,7 @@ public void testCreateIndexWithInlineSizePartitionedTransactional() throws Excep * * @throws Exception If failed. */ + @Test public void testCreateIndexWithInlineSizePartitionedTransactionalNear() throws Exception { checkCreateIndexWithInlineSize(PARTITIONED, TRANSACTIONAL, true); } @@ -657,6 +700,7 @@ public void testCreateIndexWithInlineSizePartitionedTransactionalNear() throws E * * @throws Exception If failed. */ + @Test public void testCreateIndexWithInlineSizeReplicatedAtomic() throws Exception { checkCreateIndexWithInlineSize(REPLICATED, ATOMIC, false); } @@ -666,6 +710,7 @@ public void testCreateIndexWithInlineSizeReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexWithInlineSizeReplicatedTransactional() throws Exception { checkCreateIndexWithInlineSize(REPLICATED, TRANSACTIONAL, false); } @@ -751,6 +796,7 @@ private void checkNoIndexIsCreatedForInlineSize(final int inlineSize, int ignite * * @throws Exception If failed. */ + @Test public void testCreateIndexWithParallelismPartitionedAtomic() throws Exception { checkCreateIndexWithParallelism(PARTITIONED, ATOMIC, false); } @@ -760,6 +806,7 @@ public void testCreateIndexWithParallelismPartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexWithParallelismPartitionedAtomicNear() throws Exception { checkCreateIndexWithParallelism(PARTITIONED, ATOMIC, true); } @@ -769,6 +816,7 @@ public void testCreateIndexWithParallelismPartitionedAtomicNear() throws Excepti * * @throws Exception If failed. */ + @Test public void testCreateIndexWithParallelismPartitionedTransactional() throws Exception { checkCreateIndexWithParallelism(PARTITIONED, TRANSACTIONAL, false); } @@ -778,6 +826,7 @@ public void testCreateIndexWithParallelismPartitionedTransactional() throws Exce * * @throws Exception If failed. */ + @Test public void testCreateIndexWithParallelismPartitionedTransactionalNear() throws Exception { checkCreateIndexWithParallelism(PARTITIONED, TRANSACTIONAL, true); } @@ -787,6 +836,7 @@ public void testCreateIndexWithParallelismPartitionedTransactionalNear() throws * * @throws Exception If failed. */ + @Test public void testCreateIndexWithParallelismReplicatedAtomic() throws Exception { checkCreateIndexWithParallelism(REPLICATED, ATOMIC, false); } @@ -796,6 +846,7 @@ public void testCreateIndexWithParallelismReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testCreateIndexWithParallelismReplicatedTransactional() throws Exception { checkCreateIndexWithParallelism(REPLICATED, TRANSACTIONAL, false); } @@ -880,6 +931,7 @@ private void checkNoIndexIsCreatedForParallelism(final int parallel, int igniteQ * * @throws Exception If failed. */ + @Test public void testDropPartitionedAtomic() throws Exception { checkDrop(PARTITIONED, ATOMIC, false); } @@ -889,6 +941,7 @@ public void testDropPartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropPartitionedAtomicNear() throws Exception { checkDrop(PARTITIONED, ATOMIC, true); } @@ -898,6 +951,7 @@ public void testDropPartitionedAtomicNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropPartitionedTransactional() throws Exception { checkDrop(PARTITIONED, TRANSACTIONAL, false); } @@ -907,6 +961,7 @@ public void testDropPartitionedTransactional() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropPartitionedTransactionalNear() throws Exception { checkDrop(PARTITIONED, TRANSACTIONAL, true); } @@ -916,6 +971,7 @@ public void testDropPartitionedTransactionalNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropReplicatedAtomic() throws Exception { checkDrop(REPLICATED, ATOMIC, false); } @@ -925,6 +981,7 @@ public void testDropReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropReplicatedTransactional() throws Exception { checkDrop(REPLICATED, TRANSACTIONAL, false); } @@ -976,6 +1033,7 @@ public void checkDrop(CacheMode mode, CacheAtomicityMode atomicityMode, boolean * * @throws Exception If failed. */ + @Test public void testDropNoIndexPartitionedAtomic() throws Exception { checkDropNoIndex(PARTITIONED, ATOMIC, false); } @@ -985,6 +1043,7 @@ public void testDropNoIndexPartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoIndexPartitionedAtomicNear() throws Exception { checkDropNoIndex(PARTITIONED, ATOMIC, true); } @@ -994,6 +1053,7 @@ public void testDropNoIndexPartitionedAtomicNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoIndexPartitionedTransactional() throws Exception { checkDropNoIndex(PARTITIONED, TRANSACTIONAL, false); } @@ -1003,6 +1063,7 @@ public void testDropNoIndexPartitionedTransactional() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoIndexPartitionedTransactionalNear() throws Exception { checkDropNoIndex(PARTITIONED, TRANSACTIONAL, true); } @@ -1012,6 +1073,7 @@ public void testDropNoIndexPartitionedTransactionalNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoIndexReplicatedAtomic() throws Exception { checkDropNoIndex(REPLICATED, ATOMIC, false); } @@ -1021,6 +1083,7 @@ public void testDropNoIndexReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoIndexReplicatedTransactional() throws Exception { checkDropNoIndex(REPLICATED, TRANSACTIONAL, false); } @@ -1051,6 +1114,7 @@ private void checkDropNoIndex(CacheMode mode, CacheAtomicityMode atomicityMode, * * @throws Exception If failed. */ + @Test public void testDropNoCachePartitionedAtomic() throws Exception { checkDropNoCache(PARTITIONED, ATOMIC, false); } @@ -1060,6 +1124,7 @@ public void testDropNoCachePartitionedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoCachePartitionedAtomicNear() throws Exception { checkDropNoCache(PARTITIONED, ATOMIC, true); } @@ -1069,6 +1134,7 @@ public void testDropNoCachePartitionedAtomicNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoCachePartitionedTransactional() throws Exception { checkDropNoCache(PARTITIONED, TRANSACTIONAL, false); } @@ -1078,6 +1144,7 @@ public void testDropNoCachePartitionedTransactional() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoCachePartitionedTransactionalNear() throws Exception { checkDropNoCache(PARTITIONED, TRANSACTIONAL, true); } @@ -1087,6 +1154,7 @@ public void testDropNoCachePartitionedTransactionalNear() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoCacheReplicatedAtomic() throws Exception { checkDropNoCache(REPLICATED, ATOMIC, false); } @@ -1096,6 +1164,7 @@ public void testDropNoCacheReplicatedAtomic() throws Exception { * * @throws Exception If failed. */ + @Test public void testDropNoCacheReplicatedTransactional() throws Exception { checkDropNoCache(REPLICATED, TRANSACTIONAL, false); } @@ -1137,6 +1206,7 @@ private void checkDropNoCache(CacheMode mode, CacheAtomicityMode atomicityMode, * * @throws Exception If failed. */ + @Test public void testFailOnLocalCache() throws Exception { for (Ignite node : Ignition.allGrids()) { if (!node.configuration().isClientMode()) @@ -1165,6 +1235,7 @@ public void testFailOnLocalCache() throws Exception { * * @throws Exception If failed. */ + @Test public void testNonSqlCache() throws Exception { final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1)); @@ -1178,6 +1249,7 @@ public void testNonSqlCache() throws Exception { /** * Test behavior depending on index name case sensitivity. */ + @Test public void testIndexNameCaseSensitivity() throws Exception { doTestIndexNameCaseSensitivity("myIdx", false); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java index bf98491c25381..33054670b23a7 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java @@ -51,6 +51,9 @@ import org.apache.ignite.internal.util.typedef.T3; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteClientReconnectAbstractTest.TestTcpDiscoverySpi; @@ -58,6 +61,7 @@ * Concurrency tests for dynamic index create/drop. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicIndexAbstractSelfTest { /** Test duration. */ private static final long TEST_DUR = 10_000L; @@ -136,6 +140,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde * * @throws Exception If failed. */ + @Test public void testCoordinatorChange() throws Exception { // Start servers. Ignite srv1 = ignitionStart(serverConfiguration(1)); @@ -201,6 +206,7 @@ public void testCoordinatorChange() throws Exception { * * @throws Exception If failed. */ + @Test public void testOperationChaining() throws Exception { Ignite srv1 = ignitionStart(serverConfiguration(1)); @@ -253,6 +259,7 @@ public void testOperationChaining() throws Exception { * * @throws Exception If failed. */ + @Test public void testNodeJoinOnPendingOperation() throws Exception { Ignite srv1 = ignitionStart(serverConfiguration(1)); @@ -290,6 +297,7 @@ public void testNodeJoinOnPendingOperation() throws Exception { * * @throws Exception If failed, */ + @Test public void testConcurrentPutRemove() throws Exception { // Start several nodes. Ignite srv1 = ignitionStart(serverConfiguration(1)); @@ -387,6 +395,7 @@ public void testConcurrentPutRemove() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentRebalance() throws Exception { // Start cache and populate it with data. Ignite srv1 = ignitionStart(serverConfiguration(1)); @@ -434,6 +443,7 @@ public void testConcurrentRebalance() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentCacheDestroy() throws Exception { // Start complex topology. Ignite srv1 = ignitionStart(serverConfiguration(1)); @@ -479,6 +489,7 @@ public void testConcurrentCacheDestroy() throws Exception { * * @throws Exception If failed. */ + @Test public void testConcurrentOperationsMultithreaded() throws Exception { // Start complex topology. ignitionStart(serverConfiguration(1)); @@ -553,6 +564,7 @@ public void testConcurrentOperationsMultithreaded() throws Exception { * * @throws Exception If failed. */ + @Test public void testQueryConsistencyMultithreaded() throws Exception { // Start complex topology. ignitionStart(serverConfiguration(1)); @@ -631,6 +643,7 @@ public void testQueryConsistencyMultithreaded() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientReconnect() throws Exception { checkClientReconnect(false); } @@ -640,6 +653,7 @@ public void testClientReconnect() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientReconnectWithCacheRestart() throws Exception { checkClientReconnect(true); } @@ -753,6 +767,7 @@ private void reconnectClientNode(final Ignite srvNode, final Ignite cliNode, fin * * @throws Exception If failed. */ + @Test public void testConcurrentOperationsAndNodeStartStopMultithreaded() throws Exception { // Start several stable nodes. ignitionStart(serverConfiguration(1)); @@ -878,6 +893,7 @@ public void testConcurrentOperationsAndNodeStartStopMultithreaded() throws Excep * * @throws Exception If failed. */ + @Test public void testConcurrentOperationsAndCacheStartStopMultithreaded() throws Exception { // Start complex topology. ignitionStart(serverConfiguration(1)); @@ -1097,7 +1113,7 @@ private static class BlockingIndexing extends IgniteH2Indexing { /** * Start a node. - * + * * @param cfg Configuration. * @return Ignite instance. */ diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractSelfTest.java index 0bab750a063e2..158eac43557a4 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractSelfTest.java @@ -46,18 +46,12 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; /** * Tests for dynamic index creation. */ @SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"}) public abstract class DynamicIndexAbstractSelfTest extends AbstractSchemaSelfTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Attribute to filter node out of cache data nodes. */ protected static final String ATTR_FILTERED = "FILTERED"; @@ -142,8 +136,6 @@ protected IgniteConfiguration commonConfiguration(int idx) throws Exception { cfg.setFailureHandler(new StopNodeFailureHandler()); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - cfg.setMarshaller(new BinaryMarshaller()); DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration( diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2ConnectionLeaksSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2ConnectionLeaksSelfTest.java index 7713004446c9f..14e5ac9d42c35 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2ConnectionLeaksSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2ConnectionLeaksSelfTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for leaks JdbcConnection on SqlFieldsQuery execute. */ +@RunWith(JUnit4.class) public class H2ConnectionLeaksSelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -73,6 +77,7 @@ public class H2ConnectionLeaksSelfTest extends GridCommonAbstractTest { /** * @throws Exception On failed. */ + @Test public void testConnectionLeaks() throws Exception { final IgniteCache cache = grid(1).cache(CACHE_NAME); @@ -98,6 +103,7 @@ public void testConnectionLeaks() throws Exception { /** * @throws Exception On failed. */ + @Test public void testConnectionLeaksOnSqlException() throws Exception { final CountDownLatch latch = new CountDownLatch(THREAD_CNT); final CountDownLatch latch2 = new CountDownLatch(1); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java index e74e9cdf11514..846e9f1e1694a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicColumnsAbstractBasicSelfTest.java @@ -33,27 +33,31 @@ import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.testframework.config.GridTestProperties; import org.h2.jdbc.JdbcSQLException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.config.GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER; /** * Test to check dynamic columns related features. */ +@RunWith(JUnit4.class) public abstract class H2DynamicColumnsAbstractBasicSelfTest extends DynamicColumnsAbstractTest { /** * Index of coordinator node. */ - final static int SRV_CRD_IDX = 0; + static final int SRV_CRD_IDX = 0; /** * Index of non coordinator server node. */ - final static int SRV_IDX = 1; + static final int SRV_IDX = 1; /** * Index of client. */ - final static int CLI_IDX = 2; + static final int CLI_IDX = 2; /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -105,6 +109,7 @@ private int checkTableState(String schemaName, String tblName, QueryField... col /** * Test column addition to the end of the columns list. */ + @Test public void testAddColumnSimple() throws SQLException { run("ALTER TABLE Person ADD COLUMN age int"); @@ -118,6 +123,7 @@ public void testAddColumnSimple() throws SQLException { /** * Test column addition to the end of the columns list. */ + @Test public void testAddFewColumnsSimple() throws SQLException { run("ALTER TABLE Person ADD COLUMN (age int, \"city\" varchar)"); @@ -130,6 +136,7 @@ public void testAddFewColumnsSimple() throws SQLException { /** * Test {@code IF EXISTS} handling. */ + @Test public void testIfTableExists() { run("ALTER TABLE if exists City ADD COLUMN population int"); } @@ -137,6 +144,7 @@ public void testIfTableExists() { /** * Test {@code IF NOT EXISTS} handling. */ + @Test public void testIfColumnNotExists() { run("ALTER TABLE Person ADD COLUMN if not exists name varchar"); } @@ -144,6 +152,7 @@ public void testIfColumnNotExists() { /** * Test {@code IF NOT EXISTS} handling. */ + @Test public void testDuplicateColumnName() { assertThrows("ALTER TABLE Person ADD COLUMN name varchar", "Column already exists: NAME"); } @@ -151,12 +160,14 @@ public void testDuplicateColumnName() { /** * Test behavior in case of missing table. */ + @Test public void testMissingTable() { assertThrows("ALTER TABLE City ADD COLUMN name varchar", "Table doesn't exist: CITY"); } /** */ @SuppressWarnings("unchecked") + @Test public void testComplexOperations() { IgniteCache cache = ignite(nodeIndex()) .cache(QueryUtils.createTableCacheName(QueryUtils.DFLT_SCHEMA, "PERSON")); @@ -229,6 +240,7 @@ public void testComplexOperations() { /** * Test that we can add columns dynamically to tables associated with non dynamic caches as well. */ + @Test public void testAddColumnToNonDynamicCache() throws SQLException { run("ALTER TABLE \"idx\".PERSON ADD COLUMN CITY varchar"); @@ -243,6 +255,7 @@ public void testAddColumnToNonDynamicCache() throws SQLException { * Test that we can add columns dynamically to tables associated with non dynamic caches storing user types as well. */ @SuppressWarnings("unchecked") + @Test public void testAddColumnToNonDynamicCacheWithRealValueType() throws SQLException { CacheConfiguration ccfg = defaultCacheConfiguration().setName("City") .setIndexedTypes(Integer.class, City.class); @@ -289,6 +302,7 @@ public void testAddColumnToNonDynamicCacheWithRealValueType() throws SQLExceptio * @throws SQLException If failed. */ @SuppressWarnings("unchecked") + @Test public void testAddColumnUUID() throws SQLException { CacheConfiguration ccfg = defaultCacheConfiguration().setName("GuidTest") .setIndexedTypes(Integer.class, GuidTest.class); @@ -356,6 +370,7 @@ public void testAddColumnUUID() throws SQLException { /** * Test addition of column with not null constraint. */ + @Test public void testAddNotNullColumn() throws SQLException { run("ALTER TABLE Person ADD COLUMN age int NOT NULL"); @@ -369,6 +384,7 @@ public void testAddNotNullColumn() throws SQLException { /** * Test addition of column explicitly defined as nullable. */ + @Test public void testAddNullColumn() throws SQLException { run("ALTER TABLE Person ADD COLUMN age int NULL"); @@ -382,7 +398,8 @@ public void testAddNullColumn() throws SQLException { /** * Test that {@code ADD COLUMN} fails for non dynamic table that has flat value. */ - @SuppressWarnings({"unchecked", "ThrowFromFinallyBlock"}) + @SuppressWarnings({"unchecked"}) + @Test public void testTestAlterTableOnFlatValueNonDynamicTable() { CacheConfiguration c = new CacheConfiguration("ints").setIndexedTypes(Integer.class, Integer.class) @@ -401,7 +418,7 @@ public void testTestAlterTableOnFlatValueNonDynamicTable() { /** * Test that {@code ADD COLUMN} fails for dynamic table that has flat value. */ - @SuppressWarnings({"unchecked", "ThrowFromFinallyBlock"}) + @Test public void testTestAlterTableOnFlatValueDynamicTable() { try { run("CREATE TABLE TEST (id int primary key, x varchar) with \"wrap_value=false\""); @@ -417,6 +434,7 @@ public void testTestAlterTableOnFlatValueDynamicTable() { * * @throws Exception if failed. */ + @Test public void testDropColumn() throws Exception { try { run("CREATE TABLE test (id INT PRIMARY KEY, a INT, b CHAR)"); @@ -445,6 +463,7 @@ public void testDropColumn() throws Exception { * * @throws Exception if failed. */ + @Test public void testDroppedColumnMeta() throws Exception { try { run("CREATE TABLE test (id INT PRIMARY KEY, a INT, b CHAR)"); @@ -467,6 +486,7 @@ public void testDroppedColumnMeta() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropMultipleColumns() throws Exception { try { run("CREATE TABLE test (id INT PRIMARY KEY, a INT, b CHAR, c INT)"); @@ -492,6 +512,7 @@ public void testDropMultipleColumns() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropNonExistingColumn() throws Exception { try { run("CREATE TABLE test (id INT PRIMARY KEY, a INT)"); @@ -507,6 +528,7 @@ public void testDropNonExistingColumn() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropColumnNonExistingTable() throws Exception { assertThrowsAnyCause("ALTER TABLE nosuchtable DROP COLUMN a", JdbcSQLException.class, "Table \"NOSUCHTABLE\" not found"); @@ -516,6 +538,7 @@ public void testDropColumnNonExistingTable() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropColumnIfTableExists() throws Exception { try { run("CREATE TABLE test (id INT PRIMARY KEY, a INT, b CHAR)"); @@ -535,6 +558,7 @@ public void testDropColumnIfTableExists() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropColumnIfExists() throws Exception { try { run("CREATE TABLE test (id INT PRIMARY KEY, a INT)"); @@ -555,6 +579,7 @@ public void testDropColumnIfExists() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropColumnIndexPresent() throws Exception { try { run("CREATE TABLE test (id INT PRIMARY KEY, a INT, b INT)"); @@ -581,6 +606,7 @@ public void testDropColumnIndexPresent() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropColumnOnRealClassValuedTable() throws Exception { try { run("CREATE TABLE test (id INT PRIMARY KEY, x VARCHAR) with \"wrap_value=false\""); @@ -597,6 +623,7 @@ public void testDropColumnOnRealClassValuedTable() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropColumnThatIsPartOfKey() throws Exception { try { run("CREATE TABLE test(id INT, a INT, b CHAR, PRIMARY KEY(id, a))"); @@ -613,6 +640,7 @@ public void testDropColumnThatIsPartOfKey() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropColumnThatIsKey() throws Exception { try { run("CREATE TABLE test(id INT PRIMARY KEY, a INT, b CHAR)"); @@ -629,6 +657,7 @@ public void testDropColumnThatIsKey() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropColumnThatIsValue() throws Exception { try { run("CREATE TABLE test(id INT PRIMARY KEY, a INT, b CHAR)"); @@ -648,6 +677,7 @@ public void testDropColumnThatIsValue() throws Exception { * @throws SQLException if failed. */ @SuppressWarnings("unchecked") + @Test public void testDropColumnFromNonDynamicCacheWithRealValueType() throws SQLException { CacheConfiguration ccfg = defaultCacheConfiguration().setName("City") .setIndexedTypes(Integer.class, City.class); @@ -713,6 +743,7 @@ public void testDropColumnFromNonDynamicCacheWithRealValueType() throws SQLExcep * * @throws Exception if failed. */ + @Test public void testDropColumnPriorToIndexedColumn() throws Exception { try { run("CREATE TABLE test(id INT PRIMARY KEY, a CHAR, b INT)"); @@ -760,7 +791,6 @@ private void doTestAlterTableOnFlatValue(String tblName) { * @param sql Statement. * @param msg Expected message. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") protected void assertThrows(final String sql, String msg) { assertThrows(grid(nodeIndex()), sql, msg); } @@ -772,7 +802,6 @@ protected void assertThrows(final String sql, String msg) { * @param cls Expected exception class. * @param msg Expected message. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") protected void assertThrowsAnyCause(final String sql, Class cls, String msg) { assertThrowsAnyCause(grid(nodeIndex()), sql, cls, msg); } @@ -787,7 +816,7 @@ protected List> run(String sql) { } /** City class. */ - private final static class City { + private static final class City { /** City id. */ @QuerySqlField private int id; @@ -844,7 +873,7 @@ public void state(String state) { } /** */ - private final static class GuidTest { + private static final class GuidTest { /** */ @QuerySqlField private int id; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexAbstractSelfTest.java index 10ef56fcd3b5e..90645f1396b90 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexAbstractSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexAbstractSelfTest.java @@ -34,10 +34,14 @@ import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.util.typedef.F; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test that checks indexes handling on H2 side. */ +@RunWith(JUnit4.class) public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfTest { /** Client node index. */ private final static int CLIENT = 2; @@ -75,6 +79,7 @@ public abstract class H2DynamicIndexAbstractSelfTest extends AbstractSchemaSelfT /** * Test that after index creation index is used by queries. */ + @Test public void testCreateIndex() throws Exception { IgniteCache cache = cache(); @@ -114,6 +119,7 @@ public void testCreateIndex() throws Exception { /** * Test that creating an index with duplicate name yields an error. */ + @Test public void testCreateIndexWithDuplicateName() { final IgniteCache cache = cache(); @@ -131,6 +137,7 @@ public void testCreateIndexWithDuplicateName() { /** * Test that creating an index with duplicate name does not yield an error with {@code IF NOT EXISTS}. */ + @Test public void testCreateIndexIfNotExists() { final IgniteCache cache = cache(); @@ -144,6 +151,7 @@ public void testCreateIndexIfNotExists() { /** * Test that after index drop there are no attempts to use it, and data state remains intact. */ + @Test public void testDropIndex() { IgniteCache cache = cache(); @@ -179,6 +187,7 @@ public void testDropIndex() { /** * Test that dropping a non-existent index yields an error. */ + @Test public void testDropMissingIndex() { final IgniteCache cache = cache(); @@ -192,6 +201,7 @@ public void testDropMissingIndex() { /** * Test that dropping a non-existent index does not yield an error with {@code IF EXISTS}. */ + @Test public void testDropMissingIndexIfExists() { final IgniteCache cache = cache(); @@ -201,6 +211,7 @@ public void testDropMissingIndexIfExists() { /** * Test that changes in cache affect index, and vice versa. */ + @Test public void testIndexState() { IgniteCache cache = cache(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexAbstractTest.java index 2c21e2319404e..fd6728faa2876 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicIndexingComplexAbstractTest.java @@ -31,10 +31,14 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Base class for testing work of combinations of DML and DDL operations. */ +@RunWith(JUnit4.class) public abstract class H2DynamicIndexingComplexAbstractTest extends DynamicIndexAbstractSelfTest { /** Cache mode to test with. */ private final CacheMode cacheMode; @@ -49,16 +53,16 @@ public abstract class H2DynamicIndexingComplexAbstractTest extends DynamicIndexA private final int backups; /** Names of companies to use. */ - private final static List COMPANIES = Arrays.asList("ASF", "GNU", "BSD"); + private static final List COMPANIES = Arrays.asList("ASF", "GNU", "BSD"); /** Cities to use. */ - private final static List CITIES = Arrays.asList("St. Petersburg", "Boston", "Berkeley", "London"); + private static final List CITIES = Arrays.asList("St. Petersburg", "Boston", "Berkeley", "London"); /** Index of server node. */ - protected final static int SRV_IDX = 0; + protected static final int SRV_IDX = 0; /** Index of client node. */ - protected final static int CLIENT_IDX = 1; + protected static final int CLIENT_IDX = 1; /** * Constructor. @@ -88,7 +92,7 @@ public abstract class H2DynamicIndexingComplexAbstractTest extends DynamicIndexA } /** Do test. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testOperations() { executeSql("CREATE TABLE person (id int, name varchar, age int, company varchar, city varchar, " + "primary key (id, name, city)) WITH \"template=" + cacheMode.name() + ",atomicity=" + atomicityMode.name() + diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java index c97d93437b34f..1d7c0e8aee209 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java @@ -33,7 +33,6 @@ import java.util.Random; import java.util.UUID; import java.util.concurrent.Callable; -import javax.cache.CacheException; import org.apache.ignite.IgniteException; import org.apache.ignite.Ignition; import org.apache.ignite.binary.BinaryObject; @@ -67,11 +66,15 @@ import org.apache.ignite.testframework.GridTestUtils; import org.h2.jdbc.JdbcSQLException; import org.h2.value.DataType; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for CREATE/DROP TABLE. */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest { /** Client node index. */ private static final int CLIENT = 2; @@ -132,6 +135,7 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest { * Test that {@code CREATE TABLE} actually creates new cache, H2 table and type descriptor on all nodes. * @throws Exception if failed. */ + @Test public void testCreateTable() throws Exception { doTestCreateTable(CACHE_NAME, null, null, null); } @@ -140,6 +144,7 @@ public void testCreateTable() throws Exception { * Test that {@code CREATE TABLE} actually creates new cache, H2 table and type descriptor on all nodes. * @throws Exception if failed. */ + @Test public void testCreateTableWithCacheGroup() throws Exception { doTestCreateTable(CACHE_NAME, "MyGroup", null, null); } @@ -148,6 +153,7 @@ public void testCreateTableWithCacheGroup() throws Exception { * Test that {@code CREATE TABLE} actually creates new cache, H2 table and type descriptor on all nodes. * @throws Exception if failed. */ + @Test public void testCreateTableWithCacheGroupAndLegacyParamName() throws Exception { doTestCreateTable(CACHE_NAME, "MyGroup", null, null, true); } @@ -157,6 +163,7 @@ public void testCreateTableWithCacheGroupAndLegacyParamName() throws Exception { * H2 table and type descriptor on all nodes. * @throws Exception if failed. */ + @Test public void testCreateTableWithWriteSyncMode() throws Exception { doTestCreateTable(CACHE_NAME + "_async", null, null, CacheWriteSynchronizationMode.FULL_ASYNC); } @@ -166,6 +173,7 @@ public void testCreateTableWithWriteSyncMode() throws Exception { * H2 table and type descriptor on all nodes. * @throws Exception if failed. */ + @Test public void testCreateTableReplicated() throws Exception { doTestCreateTable("REPLICATED", null, CacheMode.REPLICATED, CacheWriteSynchronizationMode.FULL_SYNC); } @@ -175,6 +183,7 @@ public void testCreateTableReplicated() throws Exception { * H2 table and type descriptor on all nodes. * @throws Exception if failed. */ + @Test public void testCreateTablePartitioned() throws Exception { doTestCreateTable("PARTITIONED", null, CacheMode.PARTITIONED, CacheWriteSynchronizationMode.FULL_SYNC); } @@ -184,6 +193,7 @@ public void testCreateTablePartitioned() throws Exception { * H2 table and type descriptor on all nodes. * @throws Exception if failed. */ + @Test public void testCreateTableReplicatedCaseInsensitive() throws Exception { doTestCreateTable("replicated", null, CacheMode.REPLICATED, CacheWriteSynchronizationMode.FULL_SYNC); } @@ -193,6 +203,7 @@ public void testCreateTableReplicatedCaseInsensitive() throws Exception { * H2 table and type descriptor on all nodes. * @throws Exception if failed. */ + @Test public void testCreateTablePartitionedCaseInsensitive() throws Exception { doTestCreateTable("partitioned", null, CacheMode.PARTITIONED, CacheWriteSynchronizationMode.FULL_SYNC); } @@ -202,6 +213,7 @@ public void testCreateTablePartitionedCaseInsensitive() throws Exception { * H2 table and type descriptor on all nodes, when no cache template name is given. * @throws Exception if failed. */ + @Test public void testCreateTableNoTemplate() throws Exception { doTestCreateTable(null, null, CacheMode.PARTITIONED, CacheWriteSynchronizationMode.FULL_SYNC); } @@ -209,6 +221,7 @@ public void testCreateTableNoTemplate() throws Exception { /** * Test behavior depending on table name case sensitivity. */ + @Test public void testTableNameCaseSensitivity() { doTestTableNameCaseSensitivity("Person", false); @@ -219,6 +232,7 @@ public void testTableNameCaseSensitivity() { * Test that {@code CREATE TABLE} with given write sync mode actually creates new cache as needed. * @throws Exception if failed. */ + @Test public void testFullSyncWriteMode() throws Exception { doTestCreateTable(null, null, null, CacheWriteSynchronizationMode.FULL_SYNC, "write_synchronization_mode=full_sync"); @@ -228,6 +242,7 @@ public void testFullSyncWriteMode() throws Exception { * Test that {@code CREATE TABLE} with given write sync mode actually creates new cache as needed. * @throws Exception if failed. */ + @Test public void testPrimarySyncWriteMode() throws Exception { doTestCreateTable(null, null, null, CacheWriteSynchronizationMode.PRIMARY_SYNC, "write_synchronization_mode=primary_sync"); @@ -237,6 +252,7 @@ public void testPrimarySyncWriteMode() throws Exception { * Test that {@code CREATE TABLE} with given write sync mode actually creates new cache as needed. * @throws Exception if failed. */ + @Test public void testFullAsyncWriteMode() throws Exception { doTestCreateTable(null, null, null, CacheWriteSynchronizationMode.FULL_ASYNC, "write_synchronization_mode=full_async"); @@ -245,6 +261,7 @@ public void testFullAsyncWriteMode() throws Exception { /** * Test behavior only in case of cache name override. */ + @Test public void testCustomCacheName() { doTestCustomNames("cname", null, null); } @@ -252,6 +269,7 @@ public void testCustomCacheName() { /** * Test behavior only in case of key type name override. */ + @Test public void testCustomKeyTypeName() { doTestCustomNames(null, "keytype", null); } @@ -259,6 +277,7 @@ public void testCustomKeyTypeName() { /** * Test behavior only in case of value type name override. */ + @Test public void testCustomValueTypeName() { doTestCustomNames(null, null, "valtype"); } @@ -266,6 +285,7 @@ public void testCustomValueTypeName() { /** * Test behavior only in case of cache and key type name override. */ + @Test public void testCustomCacheAndKeyTypeName() { doTestCustomNames("cname", "keytype", null); } @@ -273,6 +293,7 @@ public void testCustomCacheAndKeyTypeName() { /** * Test behavior only in case of cache and value type name override. */ + @Test public void testCustomCacheAndValueTypeName() { doTestCustomNames("cname", null, "valtype"); } @@ -280,6 +301,7 @@ public void testCustomCacheAndValueTypeName() { /** * Test behavior only in case of key and value type name override. */ + @Test public void testCustomKeyAndValueTypeName() { doTestCustomNames(null, "keytype", "valtype"); } @@ -287,6 +309,7 @@ public void testCustomKeyAndValueTypeName() { /** * Test behavior only in case of cache, key, and value type name override. */ + @Test public void testCustomCacheAndKeyAndValueTypeName() { doTestCustomNames("cname", "keytype", "valtype"); } @@ -296,6 +319,7 @@ public void testCustomCacheAndKeyAndValueTypeName() { * @throws Exception if failed. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testDuplicateCustomCacheName() throws Exception { client().getOrCreateCache("new"); @@ -315,6 +339,7 @@ public void testDuplicateCustomCacheName() throws Exception { * Test that {@code CREATE TABLE} with given write sync mode actually creates new cache as needed. * @throws Exception if failed. */ + @Test public void testPlainKey() throws Exception { doTestCreateTable(null, null, null, CacheWriteSynchronizationMode.FULL_SYNC); } @@ -505,6 +530,7 @@ private void doTestCreateTable(String tplCacheName, String cacheGrp, CacheMode c * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testBackups() throws Exception { String cacheName = "BackupTestCache"; @@ -626,6 +652,7 @@ private void doTestCreateTable(String tplCacheName, String cacheGrp, CacheMode c /** * Test that attempting to specify negative number of backups yields exception. */ + @Test public void testNegativeBackups() { assertCreateTableWithParamsThrows("bAckUPs = -5 ", "\"BACKUPS\" cannot be negative: -5"); } @@ -633,6 +660,7 @@ public void testNegativeBackups() { /** * Test that attempting to omit mandatory value of BACKUPS parameter yields an error. */ + @Test public void testEmptyBackups() { assertCreateTableWithParamsThrows(" bAckUPs = ", "Parameter value cannot be empty: BACKUPS"); } @@ -640,6 +668,7 @@ public void testEmptyBackups() { /** * Test that attempting to omit mandatory value of ATOMICITY parameter yields an error. */ + @Test public void testEmptyAtomicity() { assertCreateTableWithParamsThrows("AtomicitY= ", "Parameter value cannot be empty: ATOMICITY"); } @@ -647,6 +676,7 @@ public void testEmptyAtomicity() { /** * Test that providing an invalid value of ATOMICITY parameter yields an error. */ + @Test public void testInvalidAtomicity() { assertCreateTableWithParamsThrows("atomicity=InvalidValue", "Invalid value of \"ATOMICITY\" parameter (should be either TRANSACTIONAL or ATOMIC): InvalidValue"); @@ -655,6 +685,7 @@ public void testInvalidAtomicity() { /** * Test that attempting to omit mandatory value of CACHEGROUP parameter yields an error. */ + @Test public void testEmptyCacheGroup() { assertCreateTableWithParamsThrows("cache_group=", "Parameter value cannot be empty: CACHE_GROUP"); } @@ -662,6 +693,7 @@ public void testEmptyCacheGroup() { /** * Test that attempting to omit mandatory value of WRITE_SYNCHRONIZATION_MODE parameter yields an error. */ + @Test public void testEmptyWriteSyncMode() { assertCreateTableWithParamsThrows("write_synchronization_mode=", "Parameter value cannot be empty: WRITE_SYNCHRONIZATION_MODE"); @@ -670,6 +702,7 @@ public void testEmptyWriteSyncMode() { /** * Test that attempting to provide invalid value of WRITE_SYNCHRONIZATION_MODE parameter yields an error. */ + @Test public void testInvalidWriteSyncMode() { assertCreateTableWithParamsThrows("write_synchronization_mode=invalid", "Invalid value of \"WRITE_SYNCHRONIZATION_MODE\" parameter " + @@ -681,6 +714,7 @@ public void testInvalidWriteSyncMode() { * contains {@code IF NOT EXISTS} clause. * @throws Exception if failed. */ + @Test public void testCreateTableIfNotExists() throws Exception { execute("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," + " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " + @@ -696,6 +730,7 @@ public void testCreateTableIfNotExists() throws Exception { * @throws Exception if failed. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCreateExistingTable() throws Exception { execute("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," + " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " + @@ -717,6 +752,7 @@ public void testCreateExistingTable() throws Exception { * yields an error. * @throws Exception if failed. */ + @Test public void testCreateTableWithWrongColumnNameAsKey() throws Exception { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { @@ -733,6 +769,7 @@ public void testCreateTableWithWrongColumnNameAsKey() throws Exception { * Test that {@code DROP TABLE} actually removes specified cache and type descriptor on all nodes. * @throws Exception if failed. */ + @Test public void testDropTable() throws Exception { execute("CREATE TABLE IF NOT EXISTS \"Person\" (\"id\" int, \"city\" varchar," + " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " + @@ -756,6 +793,7 @@ public void testDropTable() throws Exception { * @throws Exception if failed. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCacheSelfDrop() throws Exception { execute("CREATE TABLE IF NOT EXISTS \"Person\" (\"id\" int, \"city\" varchar," + " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " + @@ -780,6 +818,7 @@ public void testCacheSelfDrop() throws Exception { * * @throws Exception if failed. */ + @Test public void testDropMissingTableIfExists() throws Exception { execute("DROP TABLE IF EXISTS \"City\""); } @@ -789,6 +828,7 @@ public void testDropMissingTableIfExists() throws Exception { * @throws Exception if failed. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testDropMissingTable() throws Exception { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { @@ -804,6 +844,7 @@ public void testDropMissingTable() throws Exception { * @throws Exception if failed. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testDropNonDynamicTable() throws Exception { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { @@ -816,23 +857,17 @@ public void testDropNonDynamicTable() throws Exception { } /** - * Test that attempting to destroy via cache API a cache created via SQL yields an error. + * Test that attempting to destroy via cache API a cache created via SQL finishes successfully. * @throws Exception if failed. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testDestroyDynamicSqlCache() throws Exception { execute("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," + " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " + "\"template=cache\""); - GridTestUtils.assertThrows(null, new Callable() { - @Override public Object call() throws Exception { - client().destroyCache(cacheName("Person")); - - return null; - } - }, CacheException.class, - "Only cache created with cache API may be removed with direct call to destroyCache"); + client().destroyCache(cacheName("Person")); } /** @@ -841,6 +876,7 @@ public void testDestroyDynamicSqlCache() throws Exception { * @throws Exception if failed. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testSqlFlagCompatibilityCheck() throws Exception { execute("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar, \"name\" varchar, \"surname\" varchar, " + "\"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH \"template=cache\""); @@ -862,6 +898,7 @@ public void testSqlFlagCompatibilityCheck() throws Exception { * @throws Exception if failed. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testIndexNameConflictCheckDiscovery() throws Exception { execute(grid(0), "CREATE TABLE \"Person\" (id int primary key, name varchar)"); @@ -891,6 +928,7 @@ public void testIndexNameConflictCheckDiscovery() throws Exception { * @throws Exception if failed. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testTableNameConflictCheckSql() throws Exception { execute(grid(0), "CREATE TABLE \"Person\" (id int primary key, name varchar)"); @@ -906,6 +944,7 @@ public void testTableNameConflictCheckSql() throws Exception { /** * @throws Exception if failed. */ + @Test public void testAffinityKey() throws Exception { execute("CREATE TABLE \"City\" (\"name\" varchar primary key, \"code\" int) WITH wrap_key,wrap_value," + "\"affinity_key='name'\""); @@ -967,6 +1006,7 @@ public void testAffinityKey() throws Exception { * @throws Exception If failed. */ @SuppressWarnings({"ThrowableNotThrown", "unchecked"}) + @Test public void testDataRegion() throws Exception { // Empty region name. GridTestUtils.assertThrows(log, new Callable() { @@ -992,6 +1032,7 @@ public void testDataRegion() throws Exception { * Test various cases of affinity key column specification. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testAffinityKeyCaseSensitivity() { execute("CREATE TABLE \"A\" (\"name\" varchar primary key, \"code\" int) WITH wrap_key,wrap_value," + "\"affinity_key='name'\""); @@ -1054,6 +1095,7 @@ public void testAffinityKeyCaseSensitivity() { * Tests that attempting to specify an affinity key that actually is a value column yields an error. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testAffinityKeyNotKeyColumn() { // Error arises because user has specified case sensitive affinity column name GridTestUtils.assertThrows(null, new Callable() { @@ -1069,6 +1111,7 @@ public void testAffinityKeyNotKeyColumn() { * Tests that attempting to specify an affinity key that actually is a value column yields an error. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testAffinityKeyNotFound() { // Error arises because user has specified case sensitive affinity column name GridTestUtils.assertThrows(null, new Callable() { @@ -1083,6 +1126,7 @@ public void testAffinityKeyNotFound() { /** * Tests behavior on sequential create and drop of a table and its index. */ + @Test public void testTableAndIndexRecreate() { execute("drop table if exists \"PUBLIC\".t"); @@ -1126,6 +1170,7 @@ public void testTableAndIndexRecreate() { /** * @throws Exception If test failed. */ + @Test public void testQueryLocalWithRecreate() throws Exception { execute("CREATE TABLE A(id int primary key, name varchar, surname varchar) WITH \"cache_name=cache," + "template=replicated\""); @@ -1159,6 +1204,7 @@ public void testQueryLocalWithRecreate() throws Exception { /** * Test that it's impossible to create tables with same name regardless of key/value wrapping settings. */ + @Test public void testWrappedAndUnwrappedKeyTablesInteroperability() { { execute("create table a (id int primary key, x varchar)"); @@ -1224,6 +1270,7 @@ public void testWrappedAndUnwrappedKeyTablesInteroperability() { /** * Test that it's possible to create tables with matching key and/or value primitive types. */ + @Test public void testDynamicTablesInteroperability() { execute("create table a (id int primary key, x varchar) with \"wrap_value=false\""); @@ -1245,6 +1292,7 @@ public void testDynamicTablesInteroperability() { /** * Test that when key or value has more than one column, wrap=false is forbidden. */ + @Test public void testWrappingAlwaysOnWithComplexObjects() { assertDdlCommandThrows("create table a (id int, x varchar, c long, primary key(id, c)) with \"wrap_key=false\"", "WRAP_KEY cannot be false when composite primary key exists."); @@ -1257,6 +1305,7 @@ public void testWrappingAlwaysOnWithComplexObjects() { * Test behavior when neither key nor value should be wrapped. * @throws SQLException if failed. */ + @Test public void testNoWrap() throws SQLException { doTestKeyValueWrap(false, false, false); } @@ -1265,6 +1314,7 @@ public void testNoWrap() throws SQLException { * Test behavior when only key is wrapped. * @throws SQLException if failed. */ + @Test public void testKeyWrap() throws SQLException { doTestKeyValueWrap(true, false, false); } @@ -1273,6 +1323,7 @@ public void testKeyWrap() throws SQLException { * Test behavior when only value is wrapped. * @throws SQLException if failed. */ + @Test public void testValueWrap() throws SQLException { doTestKeyValueWrap(false, true, false); } @@ -1281,6 +1332,7 @@ public void testValueWrap() throws SQLException { * Test behavior when both key and value is wrapped. * @throws SQLException if failed. */ + @Test public void testKeyAndValueWrap() throws SQLException { doTestKeyValueWrap(true, true, false); } @@ -1290,6 +1342,7 @@ public void testKeyAndValueWrap() throws SQLException { * Key and value are UUID. * @throws SQLException if failed. */ + @Test public void testUuidNoWrap() throws SQLException { doTestKeyValueWrap(false, false, true); } @@ -1299,6 +1352,7 @@ public void testUuidNoWrap() throws SQLException { * Key and value are UUID. * @throws SQLException if failed. */ + @Test public void testUuidKeyWrap() throws SQLException { doTestKeyValueWrap(true, false, true); } @@ -1308,6 +1362,7 @@ public void testUuidKeyWrap() throws SQLException { * Key and value are UUID. * @throws SQLException if failed. */ + @Test public void testUuidValueWrap() throws SQLException { doTestKeyValueWrap(false, true, true); } @@ -1317,6 +1372,7 @@ public void testUuidValueWrap() throws SQLException { * Key and value are UUID. * @throws SQLException if failed. */ + @Test public void testUuidKeyAndValueWrap() throws SQLException { doTestKeyValueWrap(true, true, true); } @@ -1510,6 +1566,7 @@ private void assertDdlCommandThrows(final String cmd, String expErrMsg) { * * @throws Exception if failed. */ + @Test public void testGetTablesForCache() throws Exception { try { execute("create table t1(id int primary key, name varchar)"); @@ -1606,7 +1663,7 @@ private IgniteConfiguration clientConfiguration(int idx) throws Exception { * @return Configuration. * @throws Exception If failed. */ - protected IgniteConfiguration commonConfiguration(int idx) throws Exception { + @Override protected IgniteConfiguration commonConfiguration(int idx) throws Exception { IgniteConfiguration cfg = super.commonConfiguration(idx); DataRegionConfiguration dataRegionCfg = new DataRegionConfiguration().setName(DATA_REGION_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2RowCachePageEvictionTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2RowCachePageEvictionTest.java index ba5edc9f1125b..85769ef52abbb 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2RowCachePageEvictionTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2RowCachePageEvictionTest.java @@ -36,10 +36,14 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for H2RowCacheRegistry with page eviction. */ +@RunWith(JUnit4.class) public class H2RowCachePageEvictionTest extends GridCommonAbstractTest { /** Entries count. */ private static final int ENTRIES = 10_000; @@ -147,6 +151,7 @@ private void checkRowCacheOnPageEviction() { /** * @throws Exception On error. */ + @Test public void testEvictPagesWithDiskStorageSingleCacheInGroup() throws Exception { persistenceEnabled = true; @@ -160,6 +165,7 @@ public void testEvictPagesWithDiskStorageSingleCacheInGroup() throws Exception { /** * @throws Exception On error. */ + @Test public void testEvictPagesWithDiskStorageWithOtherCacheInGroup() throws Exception { persistenceEnabled = true; @@ -175,6 +181,7 @@ public void testEvictPagesWithDiskStorageWithOtherCacheInGroup() throws Exceptio /** * @throws Exception On error. */ + @Test public void testEvictPagesWithoutDiskStorageSingleCacheInGroup() throws Exception { persistenceEnabled = false; @@ -186,6 +193,7 @@ public void testEvictPagesWithoutDiskStorageSingleCacheInGroup() throws Exceptio /** * @throws Exception On error. */ + @Test public void testEvictPagesWithoutDiskStorageWithOtherCacheInGroup() throws Exception { persistenceEnabled = false; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2RowCacheSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2RowCacheSelfTest.java index 5db8231394bc5..6a177f022f0ca 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2RowCacheSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2RowCacheSelfTest.java @@ -39,11 +39,15 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jsr166.ConcurrentLinkedHashMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests H2RowCacheRegistry. */ @SuppressWarnings({"unchecked", "ConstantConditions"}) +@RunWith(JUnit4.class) public class H2RowCacheSelfTest extends GridCommonAbstractTest { /** Keys count. */ private static final int ENTRIES = 1_000; @@ -79,6 +83,7 @@ private CacheConfiguration cacheConfiguration(String name, boolean enableOnheapC /** */ + @Test public void testDestroyCacheCreation() { final String cacheName0 = "cache0"; final String cacheName1 = "cache1"; @@ -99,6 +104,7 @@ public void testDestroyCacheCreation() { /** * @throws IgniteCheckedException If failed. */ + @Test public void testDestroyCacheSingleCacheInGroup() throws IgniteCheckedException { checkDestroyCache(); } @@ -106,6 +112,7 @@ public void testDestroyCacheSingleCacheInGroup() throws IgniteCheckedException { /** * @throws IgniteCheckedException If failed. */ + @Test public void testDestroyCacheWithOtherCacheInGroup() throws IgniteCheckedException { grid().getOrCreateCache(cacheConfiguration("cacheWithoutOnheapCache", false)); @@ -115,6 +122,7 @@ public void testDestroyCacheWithOtherCacheInGroup() throws IgniteCheckedExceptio /** * @throws Exception If failed. */ + @Test public void testDeleteEntryCacheSingleCacheInGroup() throws Exception { checkDeleteEntry(); } @@ -122,6 +130,7 @@ public void testDeleteEntryCacheSingleCacheInGroup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeleteEntryWithOtherCacheInGroup() throws Exception { grid().getOrCreateCache(cacheConfiguration("cacheWithoutOnheapCache", false)); @@ -131,6 +140,7 @@ public void testDeleteEntryWithOtherCacheInGroup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateEntryCacheSingleCacheInGroup() throws Exception { checkDeleteEntry(); } @@ -138,6 +148,7 @@ public void testUpdateEntryCacheSingleCacheInGroup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateEntryWithOtherCacheInGroup() throws Exception { grid().getOrCreateCache(cacheConfiguration("cacheWithoutOnheapCache", false)); @@ -147,6 +158,7 @@ public void testUpdateEntryWithOtherCacheInGroup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFixedSize() throws Exception { int maxSize = 100; String cacheName = "cacheWithLimitedSize"; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/IgniteDecimalSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/IgniteDecimalSelfTest.java index 96926ea5efbaf..aaeb030ecb7b1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/IgniteDecimalSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/IgniteDecimalSelfTest.java @@ -33,13 +33,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -import static java.math.RoundingMode.HALF_UP; import static java.util.Arrays.asList; /** * Test to check decimal columns. */ +@RunWith(JUnit4.class) public class IgniteDecimalSelfTest extends AbstractSchemaSelfTest { /** */ private static final int PRECISION = 9; @@ -60,13 +63,13 @@ public class IgniteDecimalSelfTest extends AbstractSchemaSelfTest { private static final MathContext MATH_CTX = new MathContext(PRECISION); /** */ - private static final BigDecimal VAL_1 = new BigDecimal("123456789", MATH_CTX).setScale(SCALE, HALF_UP); + private static final BigDecimal VAL_1 = BigDecimal.valueOf(123456789); /** */ - private static final BigDecimal VAL_2 = new BigDecimal("12345678.12345678", MATH_CTX).setScale(SCALE, HALF_UP); + private static final BigDecimal VAL_2 = BigDecimal.valueOf(1.23456789); /** */ - private static final BigDecimal VAL_3 = new BigDecimal(".123456789", MATH_CTX).setScale(SCALE, HALF_UP); + private static final BigDecimal VAL_3 = BigDecimal.valueOf(.12345678); /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -123,6 +126,7 @@ public class IgniteDecimalSelfTest extends AbstractSchemaSelfTest { /** * @throws Exception If failed. */ + @Test public void testConfiguredFromDdl() throws Exception { checkPrecisionAndScale(DEC_TAB_NAME, VALUE, PRECISION, SCALE); } @@ -130,6 +134,7 @@ public void testConfiguredFromDdl() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConfiguredFromQueryEntity() throws Exception { checkPrecisionAndScale(SALARY_TAB_NAME, "amount", PRECISION, SCALE); } @@ -137,6 +142,7 @@ public void testConfiguredFromQueryEntity() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConfiguredFromQueryEntityInDynamicallyCreatedCache() throws Exception { IgniteEx grid = grid(0); @@ -152,6 +158,7 @@ public void testConfiguredFromQueryEntityInDynamicallyCreatedCache() throws Exce /** * @throws Exception If failed. */ + @Test public void testConfiguredFromAnnotations() throws Exception { IgniteEx grid = grid(0); @@ -165,6 +172,7 @@ public void testConfiguredFromAnnotations() throws Exception { } /** */ + @Test public void testSelectDecimal() throws Exception { IgniteEx grid = grid(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/LongIndexNameTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/LongIndexNameTest.java index 3c2b7133bb217..f7063b8da8394 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/LongIndexNameTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/LongIndexNameTest.java @@ -33,10 +33,14 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class LongIndexNameTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -64,6 +68,7 @@ public class LongIndexNameTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testLongIndexNames() throws Exception { try { Ignite ignite = startGrid(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/MvccEmptyTransactionSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/MvccEmptyTransactionSelfTest.java index 5a660625283e8..0db97fcb20313 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/MvccEmptyTransactionSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/MvccEmptyTransactionSelfTest.java @@ -22,8 +22,6 @@ import org.apache.ignite.Ignition; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; @@ -31,14 +29,15 @@ import java.sql.DriverManager; import java.sql.Statement; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for empty transaction while is then enlisted with real value. */ +@RunWith(JUnit4.class) public class MvccEmptyTransactionSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -48,6 +47,7 @@ public class MvccEmptyTransactionSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testEmptyTransaction() throws Exception { Ignition.start(config("srv", false)); @@ -103,8 +103,6 @@ private static IgniteConfiguration config(String name, boolean client) { cfg.setIgniteInstanceName(name); cfg.setClientMode(client); - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER)); - return cfg; } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/OptimizedMarshallerIndexNameTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/OptimizedMarshallerIndexNameTest.java index 57a55f391b30b..fb5e2d0a019cf 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/OptimizedMarshallerIndexNameTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/OptimizedMarshallerIndexNameTest.java @@ -40,6 +40,9 @@ import java.io.ObjectOutput; import java.util.List; import java.util.UUID; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -50,6 +53,7 @@ * See IGNITE-6915 for details. */ +@RunWith(JUnit4.class) public class OptimizedMarshallerIndexNameTest extends GridCommonAbstractTest { /** Test name 1 */ private static final String TEST_NAME1 = "Name1"; @@ -111,6 +115,7 @@ protected static CacheConfiguration cacheConfiguration(String na * Verifies that BPlusTree are not erroneously shared between tables in the same cache * due to IGNITE-6915 bug. */ + @Test public void testOptimizedMarshallerIndex() { // Put objects of different types into the same cache diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java index c8f670615d756..ace76354f1189 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java @@ -29,11 +29,14 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for query entity validation. */ -@SuppressWarnings("ThrowableResultOfMethodCallIgnored") +@RunWith(JUnit4.class) public class QueryEntityValidationSelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "cache"; @@ -48,6 +51,7 @@ public class QueryEntityValidationSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testValueTypeNull() throws Exception { final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME); @@ -71,6 +75,7 @@ public void testValueTypeNull() throws Exception { * * @throws Exception If failed. */ + @Test public void testIndexTypeNull() throws Exception { final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME); @@ -113,6 +118,7 @@ public void testIndexTypeNull() throws Exception { * * @throws Exception If failed. */ + @Test public void testIndexNameDuplicate() throws Exception { final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java index c7709f2893955..9280d6b4af584 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java @@ -32,8 +32,10 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import java.util.Collections; import java.util.Map; @@ -44,13 +46,11 @@ /** * Tests for schema exchange between nodes. */ +@RunWith(JUnit4.class) public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest { /** Node on which filter should be applied (if any). */ private static String filterNodeName; - /** */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); @@ -65,6 +65,7 @@ public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest { * * @throws Exception If failed. */ + @Test public void testEmptyStatic() throws Exception { checkEmpty(false); } @@ -74,6 +75,7 @@ public void testEmptyStatic() throws Exception { * * @throws Exception If failed. */ + @Test public void testEmptyDynamic() throws Exception { checkEmpty(true); } @@ -114,6 +116,7 @@ private void checkEmpty(boolean dynamic) throws Exception { * * @throws Exception If failed. */ + @Test public void testNonEmptyStatic() throws Exception { checkNonEmpty(false); } @@ -123,6 +126,7 @@ public void testNonEmptyStatic() throws Exception { * * @throws Exception If failed. */ + @Test public void testNonEmptyDynamic() throws Exception { checkNonEmpty(true); } @@ -163,6 +167,7 @@ private void checkNonEmpty(boolean dynamic) throws Exception { * * @throws Exception If failed. */ + @Test public void testDynamicRestarts() throws Exception { IgniteEx node1 = start(1, KeyClass.class, ValueClass.class); IgniteEx node2 = startNoCache(2); @@ -245,6 +250,7 @@ public void testDynamicRestarts() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientJoinStatic() throws Exception { checkClientJoin(false); } @@ -254,6 +260,7 @@ public void testClientJoinStatic() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientJoinDynamic() throws Exception { checkClientJoin(true); } @@ -303,6 +310,7 @@ private void checkClientJoin(boolean dynamic) throws Exception { * * @throws Exception If failed. */ + @Test public void testClientCacheStartStatic() throws Exception { checkClientCacheStart(false); } @@ -312,6 +320,7 @@ public void testClientCacheStartStatic() throws Exception { * * @throws Exception If failed. */ + @Test public void testClientCacheStartDynamic() throws Exception { checkClientCacheStart(true); } @@ -386,6 +395,7 @@ private void checkClientCacheStart(boolean dynamic) throws Exception { * * @throws Exception If failed. */ + @Test public void testNodeFilter() throws Exception { filterNodeName = getTestIgniteInstanceName(1); @@ -411,6 +421,7 @@ public void testNodeFilter() throws Exception { * * @throws Exception If failed. */ + @Test public void testServerRestartWithNewTypes() throws Exception { IgniteEx node1 = start(1, KeyClass.class, ValueClass.class); assertTypes(node1, ValueClass.class); @@ -457,6 +468,7 @@ public void testServerRestartWithNewTypes() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("unchecked") + @Test public void testClientReconnect() throws Exception { final IgniteEx node1 = start(1, KeyClass.class, ValueClass.class); assertTypes(node1, ValueClass.class); @@ -545,7 +557,6 @@ private IgniteEx start(int idx, boolean client, Class... clss) throws Exception cfg.setClientMode(client); cfg.setLocalHost("127.0.0.1"); - cfg.setDiscoverySpi(new TestTcpDiscoverySpi().setIpFinder(IP_FINDER)); if (filterNodeName != null && F.eq(name, filterNodeName)) cfg.setUserAttributes(Collections.singletonMap("AFF_NODE", true)); @@ -595,8 +606,6 @@ private IgniteEx startNoCache(int idx, boolean client) throws Exception { cfg.setClientMode(client); cfg.setLocalHost("127.0.0.1"); - cfg.setDiscoverySpi(new TestTcpDiscoverySpi().setIpFinder(IP_FINDER)); - return (IgniteEx)Ignition.start(cfg); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionCommandsWithMvccDisabledSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionCommandsWithMvccDisabledSelfTest.java index b8b9360f03454..95fd2d14fa137 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionCommandsWithMvccDisabledSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionCommandsWithMvccDisabledSelfTest.java @@ -20,10 +20,14 @@ import java.util.concurrent.Callable; import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class SqlTransactionCommandsWithMvccDisabledSelfTest extends AbstractSchemaSelfTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -46,6 +50,7 @@ public class SqlTransactionCommandsWithMvccDisabledSelfTest extends AbstractSche /** * @throws Exception if failed. */ + @Test public void testBeginWithMvccDisabled() throws Exception { GridTestUtils.assertThrows(null, new Callable() { @Override public Object call() throws Exception { @@ -59,6 +64,7 @@ public void testBeginWithMvccDisabled() throws Exception { /** * @throws Exception if failed. */ + @Test public void testCommitWithMvccDisabled() throws Exception { execute(grid(0), "COMMIT"); // assert no exception @@ -67,6 +73,7 @@ public void testCommitWithMvccDisabled() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRollbackWithMvccDisabled() throws Exception { execute(grid(0), "ROLLBACK"); // assert no exception diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionsCommandsWithMvccEnabledSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionsCommandsWithMvccEnabledSelfTest.java index dcd46ff86af06..29eaad6710b96 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionsCommandsWithMvccEnabledSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionsCommandsWithMvccEnabledSelfTest.java @@ -43,10 +43,15 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionState; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests to check behavior regarding transactions started via SQL. */ +@RunWith(JUnit4.class) public class SqlTransactionsCommandsWithMvccEnabledSelfTest extends AbstractSchemaSelfTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -68,6 +73,7 @@ public class SqlTransactionsCommandsWithMvccEnabledSelfTest extends AbstractSche /** * Test that BEGIN opens a transaction. */ + @Test public void testBegin() { execute(node(), "BEGIN"); @@ -79,6 +85,7 @@ public void testBegin() { /** * Test that COMMIT commits a transaction. */ + @Test public void testCommit() { execute(node(), "BEGIN WORK"); @@ -98,6 +105,7 @@ public void testCommit() { /** * Test that COMMIT without a transaction yields nothing. */ + @Test public void testCommitNoTransaction() { execute(node(), "COMMIT"); } @@ -105,6 +113,7 @@ public void testCommitNoTransaction() { /** * Test that ROLLBACK without a transaction yields nothing. */ + @Test public void testRollbackNoTransaction() { execute(node(), "ROLLBACK"); } @@ -112,6 +121,7 @@ public void testRollbackNoTransaction() { /** * Test that ROLLBACK rolls back a transaction. */ + @Test public void testRollback() { execute(node(), "BEGIN TRANSACTION"); @@ -131,9 +141,9 @@ public void testRollback() { /** * Test that attempting to perform various SQL operations within non SQL transaction yields an exception. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testSqlOperationsWithinNonSqlTransaction() { - fail("https://issues.apache.org/jira/browse/IGNITE-9470"); - assertSqlOperationWithinNonSqlTransactionThrows("COMMIT"); assertSqlOperationWithinNonSqlTransactionThrows("ROLLBACK"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionsSelfTest.java index d93bdab7cbe6e..c3853881eff84 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionsSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SqlTransactionsSelfTest.java @@ -43,10 +43,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionState; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests to check behavior regarding transactions started via SQL. */ +@RunWith(JUnit4.class) public class SqlTransactionsSelfTest extends AbstractSchemaSelfTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -68,6 +72,7 @@ public class SqlTransactionsSelfTest extends AbstractSchemaSelfTest { /** * Test that BEGIN opens a transaction. */ + @Test public void testBegin() { execute(node(), "BEGIN"); @@ -79,6 +84,7 @@ public void testBegin() { /** * Test that COMMIT commits a transaction. */ + @Test public void testCommit() { execute(node(), "BEGIN WORK"); @@ -98,6 +104,7 @@ public void testCommit() { /** * Test that COMMIT without a transaction yields nothing. */ + @Test public void testCommitNoTransaction() { execute(node(), "COMMIT"); } @@ -105,6 +112,7 @@ public void testCommitNoTransaction() { /** * Test that ROLLBACK without a transaction yields nothing. */ + @Test public void testRollbackNoTransaction() { execute(node(), "ROLLBACK"); } @@ -112,6 +120,7 @@ public void testRollbackNoTransaction() { /** * Test that ROLLBACK rolls back a transaction. */ + @Test public void testRollback() { execute(node(), "BEGIN TRANSACTION"); @@ -131,6 +140,7 @@ public void testRollback() { /** * Test that attempting to perform various SQL operations within non SQL transaction yields an exception. */ + @Test public void testSqlOperationsWithinNonSqlTransaction() { assertSqlOperationWithinNonSqlTransactionThrows("COMMIT"); @@ -181,7 +191,6 @@ private void assertSqlOperationWithinNonSqlTransactionThrows(final String sql) { /** * Test that attempting to perform a cache API operation from within an SQL transaction fails. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") private void checkCacheOperationThrows(final String opName, final Object... args) { execute(node(), "BEGIN"); @@ -264,7 +273,7 @@ else if (arg instanceof EntryProcessor) /** * Test that attempting to perform a cache PUT operation from within an SQL transaction fails. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCacheOperationsFromSqlTransaction() { checkCacheOperationThrows("get", 1); @@ -361,7 +370,7 @@ public void testCacheOperationsFromSqlTransaction() { } /** */ - private final static EntryProcessor ENTRY_PROC = + private static final EntryProcessor ENTRY_PROC = new EntryProcessor() { @Override public Object process(MutableEntry entry, Object... arguments) throws EntryProcessorException { @@ -370,7 +379,7 @@ public void testCacheOperationsFromSqlTransaction() { }; /** */ - private final static CacheEntryProcessor CACHE_ENTRY_PROC = + private static final CacheEntryProcessor CACHE_ENTRY_PROC = new CacheEntryProcessor() { @Override public Object process(MutableEntry entry, Object... arguments) throws EntryProcessorException { diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQuerySelfTest.java index 72d72903a1210..c494ca319c2e3 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalFieldsQuerySelfTest.java @@ -21,12 +21,16 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractFieldsQuerySelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; /** * Tests for fields queries. */ +@RunWith(JUnit4.class) public class IgniteCacheLocalFieldsQuerySelfTest extends IgniteCacheAbstractFieldsQuerySelfTest { // static { // System.setProperty(IgniteSystemProperties.IGNITE_H2_DEBUG_CONSOLE, "1"); @@ -45,8 +49,9 @@ public class IgniteCacheLocalFieldsQuerySelfTest extends IgniteCacheAbstractFiel /** * @throws Exception If failed. */ + @Test public void testInformationSchema() throws Exception { jcache(String.class, String.class).query( new SqlFieldsQuery("SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS").setLocal(true)).getAll(); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryCancelOrTimeoutSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryCancelOrTimeoutSelfTest.java index fc681a4f33009..d4f76425ff4fe 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryCancelOrTimeoutSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQueryCancelOrTimeoutSelfTest.java @@ -29,12 +29,16 @@ import org.apache.ignite.cache.query.QueryCancelledException; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; /** * Tests local query cancellations and timeouts. */ +@RunWith(JUnit4.class) public class IgniteCacheLocalQueryCancelOrTimeoutSelfTest extends GridCommonAbstractTest { /** Cache size. */ private static final int CACHE_SIZE = 10_000; @@ -92,6 +96,7 @@ private void loadCache(IgniteCache cache) { /** * Tests cancellation. */ + @Test public void testQueryCancel() { testQuery(false, 1, TimeUnit.SECONDS); } @@ -99,6 +104,7 @@ public void testQueryCancel() { /** * Tests cancellation with zero timeout. */ + @Test public void testQueryCancelZeroTimeout() { testQuery(false, 1, TimeUnit.MILLISECONDS); } @@ -106,6 +112,7 @@ public void testQueryCancelZeroTimeout() { /** * Tests timeout. */ + @Test public void testQueryTimeout() { testQuery(true, 1, TimeUnit.SECONDS); } @@ -148,4 +155,4 @@ private void testQuery(boolean timeout, int timeoutUnits, TimeUnit timeUnit) { // Test must exit gracefully. } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java index 2272f27d158dd..f5f171f4f3ad5 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java @@ -29,12 +29,16 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractQuerySelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.LOCAL; /** * Tests local query. */ +@RunWith(JUnit4.class) public class IgniteCacheLocalQuerySelfTest extends IgniteCacheAbstractQuerySelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -49,6 +53,7 @@ public class IgniteCacheLocalQuerySelfTest extends IgniteCacheAbstractQuerySelfT /** * @throws Exception If test failed. */ + @Test public void testQueryLocal() throws Exception { // Let's do it twice to see how prepared statement caching behaves - without recompilation // check for cached prepared statements this would fail. @@ -98,6 +103,7 @@ public void testQueryLocal() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testLocalSqlQueryFromClient() throws Exception { try { Ignite g = startGrid("client"); @@ -127,6 +133,7 @@ public void testQueryLocal() throws Exception { } /** {@inheritDoc} */ + @Test @Override public void testLocalSqlFieldsQueryFromClient() throws Exception { try { Ignite g = startGrid("client"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractContinuousQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractContinuousQuerySelfTest.java index 1418d47451fd6..468349432642f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractContinuousQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractContinuousQuerySelfTest.java @@ -19,12 +19,17 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAbstractSelfTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; /** * */ +@RunWith(JUnit4.class) public abstract class CacheMvccAbstractContinuousQuerySelfTest extends GridCacheContinuousQueryAbstractSelfTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { @@ -42,22 +47,29 @@ public abstract class CacheMvccAbstractContinuousQuerySelfTest extends GridCache } /** {@inheritDoc} */ + @Test @Override public void testInternalKey() throws Exception { // No-op. } /** {@inheritDoc} */ - public void testExpired() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-7311"); + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7311") + @Test + @Override public void testExpired() throws Exception { + // No-op. } /** {@inheritDoc} */ - public void testLoadCache() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-7954"); + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7954") + @Test + @Override public void testLoadCache() throws Exception { + // No-op. } /** {@inheritDoc} */ - public void testEvents() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-9321"); + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9321") + @Test + @Override public void testEvents() throws Exception { + // No-op. } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractSqlCoordinatorFailoverTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractSqlCoordinatorFailoverTest.java index c449ee20e390b..e59018ec0b26f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractSqlCoordinatorFailoverTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccAbstractSqlCoordinatorFailoverTest.java @@ -17,6 +17,27 @@ package org.apache.ignite.internal.processors.cache.mvcc; +import java.util.concurrent.Callable; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheServerNotFoundException; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgniteNodeAttributes; +import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgnitePredicate; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SCAN; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.WriteMode.DML; @@ -26,11 +47,13 @@ /** * Mvcc SQL API coordinator failover test. */ -@SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public abstract class CacheMvccAbstractSqlCoordinatorFailoverTest extends CacheMvccAbstractBasicCoordinatorFailoverTest { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10750") + @Test public void testAccountsTxSql_Server_Backups0_CoordinatorFails() throws Exception { accountsTxReadAll(2, 1, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL, DML, DFLT_TEST_TIME, RestartMode.RESTART_CRD); @@ -39,6 +62,8 @@ public void testAccountsTxSql_Server_Backups0_CoordinatorFails() throws Exceptio /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10753") + @Test public void testAccountsTxSql_SingleNode_CoordinatorFails_Persistence() throws Exception { persistence = true; @@ -49,6 +74,7 @@ public void testAccountsTxSql_SingleNode_CoordinatorFails_Persistence() throws E /** * @throws Exception If failed. */ + @Test public void testPutAllGetAll_ClientServer_Backups0_RestartCoordinator_ScanDml() throws Exception { putAllGetAll(RestartMode.RESTART_CRD , 2, 1, 0, 64, new InitIndexing(Integer.class, Integer.class), SCAN, DML); @@ -57,6 +83,8 @@ public void testPutAllGetAll_ClientServer_Backups0_RestartCoordinator_ScanDml() /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10767") + @Test public void testPutAllGetAll_SingleNode_RestartCoordinator_ScanDml_Persistence() throws Exception { persistence = true; @@ -67,6 +95,8 @@ public void testPutAllGetAll_SingleNode_RestartCoordinator_ScanDml_Persistence() /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10753") + @Test public void testPutAllGetAll_ClientServer_Backups0_RestartCoordinator_SqlDml() throws Exception { putAllGetAll(RestartMode.RESTART_CRD, 2, 1, 0, DFLT_PARTITION_COUNT, new InitIndexing(Integer.class, Integer.class), SQL, DML); @@ -75,6 +105,7 @@ public void testPutAllGetAll_ClientServer_Backups0_RestartCoordinator_SqlDml() t /** * @throws Exception If failed. */ + @Test public void testPutAllGetAll_SingleNode_RestartCoordinator_SqlDml_Persistence() throws Exception { persistence = true; @@ -85,6 +116,8 @@ public void testPutAllGetAll_SingleNode_RestartCoordinator_SqlDml_Persistence() /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testUpdate_N_Objects_ClientServer_Backups0_Sql_Persistence() throws Exception { persistence = true; @@ -95,6 +128,8 @@ public void testUpdate_N_Objects_ClientServer_Backups0_Sql_Persistence() throws /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testUpdate_N_Objects_SingleNode_Sql_Persistence() throws Exception { updateNObjectsTest(3, 1, 0, 0, 1, DFLT_TEST_TIME, new InitIndexing(Integer.class, Integer.class), SQL, DML, RestartMode.RESTART_CRD); @@ -103,6 +138,7 @@ public void testUpdate_N_Objects_SingleNode_Sql_Persistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCoordinatorFailureSimplePessimisticTxSql() throws Exception { coordinatorFailureSimple(PESSIMISTIC, REPEATABLE_READ, SQL, DML); } @@ -110,6 +146,7 @@ public void testCoordinatorFailureSimplePessimisticTxSql() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxInProgressCoordinatorChangeSimple_Readonly() throws Exception { txInProgressCoordinatorChangeSimple(PESSIMISTIC, REPEATABLE_READ, new InitIndexing(Integer.class, Integer.class), SQL, DML); @@ -118,6 +155,7 @@ public void testTxInProgressCoordinatorChangeSimple_Readonly() throws Exception /** * @throws Exception If failed. */ + @Test public void testReadInProgressCoordinatorFailsSimple_FromClient() throws Exception { readInProgressCoordinatorFailsSimple(true, new InitIndexing(Integer.class, Integer.class), SQL, DML); } @@ -125,6 +163,7 @@ public void testReadInProgressCoordinatorFailsSimple_FromClient() throws Excepti /** * @throws Exception If failed. */ + @Test public void testCoordinatorChangeActiveQueryClientFails_Simple() throws Exception { checkCoordinatorChangeActiveQueryClientFails_Simple(new InitIndexing(Integer.class, Integer.class), SQL, DML); } @@ -132,7 +171,153 @@ public void testCoordinatorChangeActiveQueryClientFails_Simple() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testCoordinatorChangeActiveQueryClientFails_SimpleScan() throws Exception { checkCoordinatorChangeActiveQueryClientFails_Simple(new InitIndexing(Integer.class, Integer.class), SCAN, DML); } + + /** + * @throws Exception If failed. + */ + @Test + public void testStartLastServerFails() throws Exception { + testSpi = true; + + startGrids(3); + + CacheConfiguration cfg = cacheConfiguration(cacheMode(), FULL_SYNC, 0, DFLT_PARTITION_COUNT) + .setIndexedTypes(Integer.class, Integer.class); + + cfg.setNodeFilter(new TestNodeFilter(getTestIgniteInstanceName(1))); + + Ignite srv1 = ignite(1); + + srv1.createCache(cfg); + + client = true; + + final Ignite c = startGrid(3); + + client = false; + + TestRecordingCommunicationSpi.spi(srv1).blockMessages(GridDhtAffinityAssignmentResponse.class, c.name()); + + IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable() { + @Override public Void call() throws Exception { + c.cache(DEFAULT_CACHE_NAME); + + return null; + } + }, "start-cache"); + + U.sleep(1000); + + assertFalse(fut.isDone()); + + stopGrid(1); + + fut.get(); + + final IgniteCache clientCache = c.cache(DEFAULT_CACHE_NAME); + + for (int i = 0; i < 10; i++) { + final int k = i; + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + clientCache.get(k); + + return null; + } + }, CacheServerNotFoundException.class, null); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + clientCache.put(k, k); + + return null; + } + }, CacheServerNotFoundException.class, null); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + clientCache.remove(k); + + return null; + } + }, CacheServerNotFoundException.class, null); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + clientCache.query(new SqlFieldsQuery("SELECT * FROM INTEGER")).getAll(); + + return null; + } + }, CacheException.class, "Failed to find data nodes for cache"); // TODO IGNITE-10377 should be CacheServerNotFoundException. + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + clientCache.query(new SqlFieldsQuery("SELECT * FROM INTEGER ORDER BY _val")).getAll(); + + return null; + } + }, CacheException.class, "Failed to find data nodes for cache"); // TODO IGNITE-10377 should be CacheServerNotFoundException. + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + clientCache.query(new SqlFieldsQuery("DELETE FROM Integer WHERE 1 = 1")).getAll(); + + return null; + } + }, CacheException.class, "Failed to find data nodes for cache"); // TODO IGNITE-10377 should be CacheServerNotFoundException. + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + clientCache.query(new SqlFieldsQuery("INSERT INTO Integer (_key, _val) VALUES (1, 2)")).getAll(); + + return null; + } + }, CacheException.class, "Failed to get primary node"); // TODO IGNITE-10377 should be CacheServerNotFoundException. + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + clientCache.query(new SqlFieldsQuery("UPDATE Integer SET _val=42 WHERE _key IN (SELECT DISTINCT _val FROM INTEGER)")).getAll(); + + return null; + } + }, CacheException.class, "Failed to find data nodes for cache"); // TODO IGNITE-10377 should be CacheServerNotFoundException. + } + + startGrid(1); + + awaitPartitionMapExchange(); + + for (int i = 0; i < 100; i++) { + assertNull(clientCache.get(i)); + + clientCache.put(i, i); + + assertEquals(i, clientCache.get(i)); + } + } + + /** + * + */ + private static class TestNodeFilter implements IgnitePredicate { + /** */ + private final String includeName; + + /** + * @param includeName Node to include. + */ + public TestNodeFilter(String includeName) { + this.includeName = includeName; + } + + /** {@inheritDoc} */ + @Override public boolean apply(ClusterNode node) { + return includeName.equals(node.attribute(IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME)); + } + } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBackupsAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBackupsAbstractTest.java index 998cb766668c7..147562eab1e88 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBackupsAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBackupsAbstractTest.java @@ -46,6 +46,10 @@ import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.transactions.Transaction; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL; @@ -58,8 +62,8 @@ * Backups tests. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public abstract class CacheMvccBackupsAbstractTest extends CacheMvccAbstractTest { - /** Test timeout. */ private final long txLongTimeout = getTestTimeout() / 4; @@ -68,6 +72,7 @@ public abstract class CacheMvccBackupsAbstractTest extends CacheMvccAbstractTest * * @throws Exception If fails. */ + @Test public void testBackupsCoherenceSimple() throws Exception { disableScheduledVacuum = true; @@ -181,6 +186,8 @@ public void testBackupsCoherenceSimple() throws Exception { * * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10104") + @Test public void testBackupsCoherenceWithLargeOperations() throws Exception { disableScheduledVacuum = true; @@ -277,6 +284,7 @@ public void testBackupsCoherenceWithLargeOperations() throws Exception { * * @throws Exception If failed. */ + @Test public void testBackupsCoherenceWithInFlightBatchesOverflow() throws Exception { testSpi = true; @@ -387,6 +395,7 @@ public void testBackupsCoherenceWithInFlightBatchesOverflow() throws Exception { * * @throws Exception If failed. */ + @Test public void testBackupsCoherenceWithConcurrentUpdates2ServersNoClients() throws Exception { checkBackupsCoherenceWithConcurrentUpdates(2, 0); } @@ -396,6 +405,7 @@ public void testBackupsCoherenceWithConcurrentUpdates2ServersNoClients() throws * * @throws Exception If failed. */ + @Test public void testBackupsCoherenceWithConcurrentUpdates4ServersNoClients() throws Exception { checkBackupsCoherenceWithConcurrentUpdates(4, 0); } @@ -405,6 +415,7 @@ public void testBackupsCoherenceWithConcurrentUpdates4ServersNoClients() throws * * @throws Exception If failed. */ + @Test public void testBackupsCoherenceWithConcurrentUpdates3Servers1Client() throws Exception { checkBackupsCoherenceWithConcurrentUpdates(3, 1); } @@ -414,6 +425,7 @@ public void testBackupsCoherenceWithConcurrentUpdates3Servers1Client() throws Ex * * @throws Exception If failed. */ + @Test public void testBackupsCoherenceWithConcurrentUpdates5Servers2Clients() throws Exception { checkBackupsCoherenceWithConcurrentUpdates(5, 2); } @@ -461,6 +473,7 @@ private void checkBackupsCoherenceWithConcurrentUpdates(int srvs, int clients) t /** * @throws Exception If failed. */ + @Test public void testNoForceKeyRequestDelayedRebalanceNoVacuum() throws Exception { disableScheduledVacuum = true; @@ -470,6 +483,7 @@ public void testNoForceKeyRequestDelayedRebalanceNoVacuum() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoForceKeyRequestDelayedRebalance() throws Exception { doTestRebalanceNodeAdd(true); } @@ -477,6 +491,7 @@ public void testNoForceKeyRequestDelayedRebalance() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoForceKeyRequestNoVacuum() throws Exception { disableScheduledVacuum = true; @@ -486,6 +501,7 @@ public void testNoForceKeyRequestNoVacuum() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoForceKeyRequest() throws Exception { doTestRebalanceNodeAdd(false); } @@ -569,6 +585,7 @@ private void doTestRebalanceNodeAdd(boolean delayRebalance) throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalanceNodeLeaveClient() throws Exception { doTestRebalanceNodeLeave(true); } @@ -576,6 +593,7 @@ public void testRebalanceNodeLeaveClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRebalanceNodeLeaveServer() throws Exception { doTestRebalanceNodeLeave(false); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBasicContinuousQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBasicContinuousQueryTest.java index ed97b1bec710d..c0ffa12725347 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBasicContinuousQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBasicContinuousQueryTest.java @@ -17,11 +17,14 @@ package org.apache.ignite.internal.processors.cache.mvcc; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicInteger; import javax.cache.Cache; import javax.cache.CacheException; import javax.cache.event.CacheEntryEvent; @@ -29,27 +32,44 @@ import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.cache.query.ContinuousQuery; import org.apache.ignite.cache.query.QueryCursor; import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.TestRecordingCommunicationSpi; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest; +import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager; +import org.apache.ignite.internal.processors.continuous.GridContinuousMessage; import org.apache.ignite.internal.processors.continuous.GridContinuousProcessor; +import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiPredicate; +import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.mvcc.MvccCachingManager.TX_SIZE_THRESHOLD; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; +import static org.apache.ignite.transactions.TransactionState.PREPARING; +import static org.apache.ignite.transactions.TransactionState.ROLLED_BACK; /** * Basic continuous queries test with enabled mvcc. */ +@RunWith(JUnit4.class) public class CacheMvccBasicContinuousQueryTest extends CacheMvccAbstractTest { /** */ private static final long LATCH_TIMEOUT = 5000; @@ -100,6 +120,7 @@ public class CacheMvccBasicContinuousQueryTest extends CacheMvccAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAllEntries() throws Exception { Ignite node = startGrids(3); @@ -196,6 +217,7 @@ public void testAllEntries() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCachingMaxSize() throws Exception { Ignite node = startGrids(1); @@ -227,4 +249,357 @@ public void testCachingMaxSize() throws Exception { } }, CacheException.class, "Failed to run update. Transaction is too large. Consider reducing transaction size"); } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10768") + @Test + public void testUpdateCountersGapClosedSimplePartitioned() throws Exception { + checkUpdateCountersGapIsProcessedSimple(CacheMode.PARTITIONED); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testUpdateCountersGapClosedSimpleReplicated() throws Exception { + checkUpdateCountersGapIsProcessedSimple(CacheMode.REPLICATED); + } + + /** + * @throws Exception if failed. + */ + private void checkUpdateCountersGapIsProcessedSimple(CacheMode cacheMode) throws Exception { + testSpi = true; + + int srvCnt = 4; + + startGridsMultiThreaded(srvCnt); + + client = true; + + IgniteEx nearNode = startGrid(srvCnt); + + IgniteCache cache = nearNode.createCache( + cacheConfiguration(cacheMode, FULL_SYNC, srvCnt - 1, srvCnt) + .setIndexedTypes(Integer.class, Integer.class)); + + IgniteEx primary = grid(0); + + List keys = primaryKeys(primary.cache(DEFAULT_CACHE_NAME), 3); + + ContinuousQuery qry = new ContinuousQuery<>(); + + List arrivedEvts = new ArrayList<>(); + + CountDownLatch latch = new CountDownLatch(2); + + qry.setLocalListener(new CacheEntryUpdatedListener() { + @Override public void onUpdated(Iterable> evts) { + for (CacheEntryEvent e : evts) { + arrivedEvts.add(e); + + latch.countDown(); + } + } + }); + + QueryCursor> cur = nearNode.cache(DEFAULT_CACHE_NAME).query(qry); + + // Initial value. + cache.query(new SqlFieldsQuery("insert into Integer(_key, _val) values(?, 42)").setArgs(keys.get(0))).getAll(); + + Transaction txA = nearNode.transactions().txStart(PESSIMISTIC, REPEATABLE_READ); + + // prevent first transaction prepare on backups + TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(primary); + + spi.blockMessages(new IgniteBiPredicate() { + private final AtomicInteger limiter = new AtomicInteger(); + + @Override public boolean apply(ClusterNode node, Message msg) { + if (msg instanceof GridDhtTxPrepareRequest) + return limiter.getAndIncrement() < srvCnt - 1; + + if (msg instanceof GridContinuousMessage) + return true; + + return false; + } + }); + + cache.query(new SqlFieldsQuery("insert into Integer(_key, _val) values(?, 42)").setArgs(keys.get(1))).getAll(); + + txA.commitAsync(); + + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + return nearNode.context().cache().context().tm().activeTransactions().stream().allMatch(tx -> tx.state() == PREPARING); + } + }, 3_000); + + GridTestUtils.runAsync(() -> { + try (Transaction txB = nearNode.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + cache.query(new SqlFieldsQuery("insert into Integer(_key, _val) values(?, 42)").setArgs(keys.get(2))); + + txB.commit(); + } + }).get(); + + long primaryUpdCntr = getUpdateCounter(primary, keys.get(0)); + + assertEquals(3, primaryUpdCntr); // There were three updates. + + // drop primary + stopGrid(primary.name()); + + // Wait all txs are rolled back. + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + boolean allRolledBack = true; + + for (int i = 1; i < srvCnt; i++) { + boolean rolledBack = grid(i).context().cache().context().tm().activeTransactions().stream().allMatch(tx -> tx.state() == ROLLED_BACK); + + allRolledBack &= rolledBack; + } + + return allRolledBack; + } + }, 3_000); + + for (int i = 1; i < srvCnt; i++) { + IgniteCache backupCache = grid(i).cache(DEFAULT_CACHE_NAME); + + int size = backupCache.query(new SqlFieldsQuery("select * from Integer")).getAll().size(); + + long backupCntr = getUpdateCounter(grid(i), keys.get(0)); + + assertEquals(2, size); + assertEquals(primaryUpdCntr, backupCntr); + } + + assertTrue(latch.await(3, SECONDS)); + + assertEquals(2, arrivedEvts.size()); + assertEquals(keys.get(0), arrivedEvts.get(0).getKey()); + assertEquals(keys.get(2), arrivedEvts.get(1).getKey()); + + cur.close(); + nearNode.close(); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10756") + @Test + public void testUpdateCountersGapClosedPartitioned() throws Exception { + checkUpdateCountersGapsClosed(CacheMode.PARTITIONED); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testUpdateCountersGapClosedReplicated() throws Exception { + checkUpdateCountersGapsClosed(CacheMode.REPLICATED); + } + + /** + * @throws Exception If failed. + */ + private void checkUpdateCountersGapsClosed(CacheMode cacheMode) throws Exception { + testSpi = true; + + int srvCnt = 4; + + startGridsMultiThreaded(srvCnt); + + IgniteEx nearNode = grid(srvCnt - 1); + + IgniteCache cache = nearNode.createCache( + cacheConfiguration(cacheMode, FULL_SYNC, srvCnt - 1, srvCnt) + .setIndexedTypes(Integer.class, Integer.class)); + + IgniteEx primary = grid(0); + + Affinity aff = nearNode.affinity(cache.getName()); + + int[] nearBackupParts = aff.backupPartitions(nearNode.localNode()); + + int[] primaryParts = aff.primaryPartitions(primary.localNode()); + + Collection nearSet = new HashSet<>(); + + for (int part : nearBackupParts) + nearSet.add(part); + + Collection primarySet = new HashSet<>(); + + for (int part : primaryParts) + primarySet.add(part); + + // We need backup partitions on the near node. + nearSet.retainAll(primarySet); + + List keys = singlePartKeys(primary.cache(DEFAULT_CACHE_NAME), 20, nearSet.iterator().next()); + + int range = 3; + + ContinuousQuery qry = new ContinuousQuery<>(); + + List arrivedEvts = new ArrayList<>(); + + CountDownLatch latch = new CountDownLatch(range * 2); + + qry.setLocalListener(new CacheEntryUpdatedListener() { + @Override public void onUpdated(Iterable> evts) { + for (CacheEntryEvent e : evts) { + arrivedEvts.add(e); + + latch.countDown(); + } + } + }); + + QueryCursor> cur = nearNode.cache(DEFAULT_CACHE_NAME).query(qry); + + // prevent first transaction prepare on backups + TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(primary); + + spi.blockMessages(new IgniteBiPredicate() { + private final AtomicInteger limiter = new AtomicInteger(); + + @Override public boolean apply(ClusterNode node, Message msg) { + if (msg instanceof GridDhtTxPrepareRequest) + return limiter.getAndIncrement() < srvCnt - 1; + + return false; + } + }); + + Transaction txA = primary.transactions().txStart(PESSIMISTIC, REPEATABLE_READ); + + for (int i = 0; i < range; i++) + primary.cache(DEFAULT_CACHE_NAME).put(keys.get(i), 2); + + txA.commitAsync(); + + GridTestUtils.runAsync(() -> { + try (Transaction tx = primary.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + for (int i = range; i < range * 2; i++) + primary.cache(DEFAULT_CACHE_NAME).put(keys.get(i), 1); + + tx.commit(); + } + }).get(); + + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + return primary.context().cache().context().tm().activeTransactions().stream().allMatch(tx -> tx.state() == PREPARING); + } + }, 3_000); + + GridTestUtils.runAsync(() -> { + try (Transaction txB = primary.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + for (int i = range * 2; i < range * 3; i++) + primary.cache(DEFAULT_CACHE_NAME).put(keys.get(i), 3); + + txB.commit(); + } + }).get(); + + long primaryUpdCntr = getUpdateCounter(primary, keys.get(0)); + + assertEquals(range * 3, primaryUpdCntr); + + // drop primary + stopGrid(primary.name()); + + // Wait all txs are rolled back. + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + boolean allRolledBack = true; + + for (int i = 1; i < srvCnt; i++) { + boolean rolledBack = grid(i).context().cache().context().tm().activeTransactions().stream().allMatch(tx -> tx.state() == ROLLED_BACK); + + allRolledBack &= rolledBack; + } + + return allRolledBack; + } + }, 3_000); + + for (int i = 1; i < srvCnt; i++) { + IgniteCache backupCache = grid(i).cache(DEFAULT_CACHE_NAME); + + int size = backupCache.query(new SqlFieldsQuery("select * from Integer")).getAll().size(); + + long backupCntr = getUpdateCounter(grid(i), keys.get(0)); + + assertEquals(range * 2, size); + assertEquals(primaryUpdCntr, backupCntr); + } + + assertTrue(latch.await(5, SECONDS)); + + assertEquals(range * 2, arrivedEvts.size()); + + cur.close(); + } + + /** + * @param primaryCache Cache. + * @param size Number of keys. + * @return Keys belong to a given part. + * @throws Exception If failed. + */ + private List singlePartKeys(IgniteCache primaryCache, int size, int part) throws Exception { + Ignite ignite = primaryCache.unwrap(Ignite.class); + + List res = new ArrayList<>(); + + final Affinity aff = ignite.affinity(primaryCache.getName()); + + final ClusterNode node = ignite.cluster().localNode(); + + assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + return aff.primaryPartitions(node).length > 0; + } + }, 5000)); + + int cnt = 0; + + for (int key = 0; key < aff.partitions() * size * 10; key++) { + if (aff.partition(key) == part) { + res.add(key); + + if (++cnt == size) + break; + } + } + + assertEquals(size, res.size()); + + return res; + } + + /** + * @param node Node. + * @param key Key. + * @return Extracts update counter of partition which key belongs to. + */ + private long getUpdateCounter(IgniteEx node, Integer key) { + int partId = node.cachex(DEFAULT_CACHE_NAME).context().affinity().partition(key); + + GridDhtLocalPartition part = node.cachex(DEFAULT_CACHE_NAME).context().dht().topology().localPartition(partId); + + assert part != null; + + return part.updateCounter(); + } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBulkLoadTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBulkLoadTest.java index 98bbdfc400346..bff6e9781a844 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBulkLoadTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccBulkLoadTest.java @@ -28,6 +28,9 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; @@ -35,6 +38,7 @@ /** * */ +@RunWith(JUnit4.class) public class CacheMvccBulkLoadTest extends CacheMvccAbstractTest { /** */ private IgniteCache sqlNexus; @@ -65,6 +69,7 @@ public class CacheMvccBulkLoadTest extends CacheMvccAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCopyStoresData() throws Exception { String csvFilePath = new File(getClass().getResource("mvcc_person.csv").toURI()).getAbsolutePath(); stmt.executeUpdate("copy from '" + csvFilePath + "' into person (id, name) format csv"); @@ -81,6 +86,7 @@ public void testCopyStoresData() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCopyDoesNotOverwrite() throws Exception { sqlNexus.query(q("insert into person values(1, 'Old')")); String csvFilePath = new File(getClass().getResource("mvcc_person.csv").toURI()).getAbsolutePath(); @@ -98,6 +104,7 @@ public void testCopyDoesNotOverwrite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCopyLeavesPartialResultsInCaseOfFailure() throws Exception { String csvFilePath = new File(getClass().getResource("mvcc_person_broken.csv").toURI()).getAbsolutePath(); try { diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousQueryClientReconnectTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousQueryClientReconnectTest.java index 4c4c95ba1ff2b..ec622217f987f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousQueryClientReconnectTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousQueryClientReconnectTest.java @@ -18,6 +18,8 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientReconnectTest; +import org.junit.Ignore; +import org.junit.Test; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; @@ -29,4 +31,18 @@ public class CacheMvccContinuousQueryClientReconnectTest extends IgniteCacheCon @Override protected CacheAtomicityMode atomicMode() { return TRANSACTIONAL_SNAPSHOT; } + + /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10537") + @Test + @Override public void testReconnectClient() throws Exception { + super.testReconnectClient(); + } + + /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10537") + @Test + @Override public void testReconnectClientAndLeftRouter() throws Exception { + super.testReconnectClientAndLeftRouter(); + } } \ No newline at end of file diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousQueryClientTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousQueryClientTest.java index 5c6c7a8b0f815..21488779092b1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousQueryClientTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousQueryClientTest.java @@ -18,6 +18,8 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest; +import org.junit.Ignore; +import org.junit.Test; /** * Mvcc CQ client test. @@ -27,4 +29,11 @@ public class CacheMvccContinuousQueryClientTest extends IgniteCacheContinuousQue @Override protected CacheAtomicityMode atomicityMode() { return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; } + + /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10769") + @Test + @Override public void testNodeJoinsRestartQuery() throws Exception { + super.testNodeJoinsRestartQuery(); + } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerClientSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerClientSelfTest.java index a3ea0e812d5c8..696b7e267d472 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerClientSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerClientSelfTest.java @@ -18,10 +18,15 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerClientSelfTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheMvccContinuousWithTransformerClientSelfTest extends CacheContinuousWithTransformerClientSelfTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { @@ -29,7 +34,9 @@ public class CacheMvccContinuousWithTransformerClientSelfTest extends CacheConti } /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7311") + @Test @Override public void testExpired() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-7311"); + // No-op. } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerPartitionedSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerPartitionedSelfTest.java index d029143220cbf..a85b8dfcd3fa6 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerPartitionedSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerPartitionedSelfTest.java @@ -19,10 +19,15 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerReplicatedSelfTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheMvccContinuousWithTransformerPartitionedSelfTest extends CacheContinuousWithTransformerReplicatedSelfTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { @@ -35,8 +40,10 @@ public class CacheMvccContinuousWithTransformerPartitionedSelfTest extends Cache } /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7311") + @Test @Override public void testExpired() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-7311"); + // No-op. } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerReplicatedSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerReplicatedSelfTest.java index a294e17a42053..b05c878e61c34 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerReplicatedSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccContinuousWithTransformerReplicatedSelfTest.java @@ -18,10 +18,15 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerReplicatedSelfTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheMvccContinuousWithTransformerReplicatedSelfTest extends CacheContinuousWithTransformerReplicatedSelfTest { /** {@inheritDoc} */ @@ -30,7 +35,9 @@ public class CacheMvccContinuousWithTransformerReplicatedSelfTest } /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7311") + @Test @Override public void testExpired() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-7311"); + // No-op. } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccDmlSimpleTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccDmlSimpleTest.java index 7f141ca36c4b1..dcd19a64aca4d 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccDmlSimpleTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccDmlSimpleTest.java @@ -28,12 +28,16 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.processors.query.IgniteSQLException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.Arrays.asList; /** * */ +@RunWith(JUnit4.class) public class CacheMvccDmlSimpleTest extends CacheMvccAbstractTest { /** */ private IgniteCache cache; @@ -58,6 +62,7 @@ public class CacheMvccDmlSimpleTest extends CacheMvccAbstractTest { /** * @throws Exception if failed. */ + @Test public void testInsert() throws Exception { int cnt = update("insert into Integer(_key, _val) values(1, 1),(2, 2)"); @@ -78,6 +83,7 @@ public void testInsert() throws Exception { /** * @throws Exception if failed. */ + @Test public void testMerge() throws Exception { { int cnt = update("merge into Integer(_key, _val) values(1, 1),(2, 2)"); @@ -97,6 +103,7 @@ public void testMerge() throws Exception { /** * @throws Exception if failed. */ + @Test public void testUpdate() throws Exception { { int cnt = update("update Integer set _val = 42 where _key = 42"); @@ -139,6 +146,7 @@ public void testUpdate() throws Exception { /** * @throws Exception if failed. */ + @Test public void testDelete() throws Exception { { int cnt = update("delete from Integer where _key = 42"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSelectForUpdateQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSelectForUpdateQueryTest.java index 12209abd4f389..3e849edfefb23 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSelectForUpdateQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSelectForUpdateQueryTest.java @@ -18,19 +18,24 @@ package org.apache.ignite.internal.processors.cache.mvcc; import org.apache.ignite.cache.CacheMode; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** */ +@RunWith(JUnit4.class) public class CacheMvccPartitionedSelectForUpdateQueryTest extends CacheMvccSelectForUpdateQueryAbstractTest { /** {@inheritDoc} */ - public CacheMode cacheMode() { + @Override public CacheMode cacheMode() { return PARTITIONED; } /** * */ + @Test public void testSelectForUpdateDistributedSegmented() throws Exception { doTestSelectForUpdateDistributed("PersonSeg", false); } @@ -38,6 +43,7 @@ public void testSelectForUpdateDistributedSegmented() throws Exception { /** * */ + @Test public void testSelectForUpdateLocalSegmented() throws Exception { doTestSelectForUpdateLocal("PersonSeg", false); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlCoordinatorFailoverTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlCoordinatorFailoverTest.java index b347497b5b2b2..0cabf65d7b190 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlCoordinatorFailoverTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlCoordinatorFailoverTest.java @@ -18,17 +18,21 @@ package org.apache.ignite.internal.processors.cache.mvcc; import org.apache.ignite.cache.CacheMode; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SCAN; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.WriteMode.DML; -import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.WriteMode.PUT; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** * SQL Mvcc coordinator failover test for partitioned caches. */ +@RunWith(JUnit4.class) public class CacheMvccPartitionedSqlCoordinatorFailoverTest extends CacheMvccAbstractSqlCoordinatorFailoverTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -38,6 +42,8 @@ public class CacheMvccPartitionedSqlCoordinatorFailoverTest extends CacheMvccAbs /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10750") + @Test public void testAccountsTxSql_ClientServer_Backups2_CoordinatorFails() throws Exception { accountsTxReadAll(4, 2, 2, DFLT_PARTITION_COUNT, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL, DML, DFLT_TEST_TIME, RestartMode.RESTART_CRD); @@ -46,6 +52,8 @@ public void testAccountsTxSql_ClientServer_Backups2_CoordinatorFails() throws Ex /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testAccountsTxSql_Server_Backups1_CoordinatorFails_Persistence() throws Exception { persistence = true; @@ -56,6 +64,8 @@ public void testAccountsTxSql_Server_Backups1_CoordinatorFails_Persistence() thr /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testPutAllGetAll_ClientServer_Backups3_RestartCoordinator_ScanDml() throws Exception { putAllGetAll(RestartMode.RESTART_CRD , 5, 2, 3, DFLT_PARTITION_COUNT, new InitIndexing(Integer.class, Integer.class), SCAN, DML); @@ -64,14 +74,7 @@ public void testPutAllGetAll_ClientServer_Backups3_RestartCoordinator_ScanDml() /** * @throws Exception If failed. */ - public void testPutAllGetAll_ClientServer_Backups1_Restart_Scan() throws Exception { - // TODO add tests with RESTART_RND_SRV https://issues.apache.org/jira/browse/IGNITE-9928 - putAllGetAll(RestartMode.RESTART_RND_SRV, 4, 2, 2, 64, /*new InitIndexing(Integer.class, Integer.class)*/ null, SCAN, PUT); - } - - /** - * @throws Exception If failed. - */ + @Test public void testPutAllGetAll_ClientServer_Backups1_RestartCoordinator_ScanDml_Persistence() throws Exception { persistence = true; @@ -82,6 +85,7 @@ public void testPutAllGetAll_ClientServer_Backups1_RestartCoordinator_ScanDml_Pe /** * @throws Exception If failed. */ + @Test public void testPutAllGetAll_ClientServer_Backups2_RestartCoordinator_SqlDml_Persistence() throws Exception { persistence = true; @@ -92,6 +96,7 @@ public void testPutAllGetAll_ClientServer_Backups2_RestartCoordinator_SqlDml_Per /** * @throws Exception If failed. */ + @Test public void testPutAllGetAll_ClientServer_Backups1_RestartCoordinator_SqlDml() throws Exception { putAllGetAll(RestartMode.RESTART_CRD, 2, 1, 1, 64, new InitIndexing(Integer.class, Integer.class), SQL, DML); @@ -100,6 +105,55 @@ public void testPutAllGetAll_ClientServer_Backups1_RestartCoordinator_SqlDml() t /** * @throws Exception If failed. */ + @Test + public void testPutAllGetAll_ClientServer_Backups1_RestartRandomSrv_SqlDml() throws Exception { + putAllGetAll(RestartMode.RESTART_RND_SRV, 3, 1, 1, DFLT_PARTITION_COUNT, + new InitIndexing(Integer.class, Integer.class), SQL, DML); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutAllGetAll_ClientServer_Backups2_RestartRandomSrv_SqlDml() throws Exception { + putAllGetAll(RestartMode.RESTART_RND_SRV, 4, 1, 2, DFLT_PARTITION_COUNT, + new InitIndexing(Integer.class, Integer.class), SQL, DML); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutAllGetAll_Server_Backups2_RestartRandomSrv_SqlDml() throws Exception { + putAllGetAll(RestartMode.RESTART_RND_SRV, 4, 0, 2, DFLT_PARTITION_COUNT, + new InitIndexing(Integer.class, Integer.class), SQL, DML); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test + public void testPutAllGetAll_Server_Backups1_SinglePartition_RestartRandomSrv_SqlDml() throws Exception { + putAllGetAll(RestartMode.RESTART_RND_SRV, 4, 0, 1, 1, + new InitIndexing(Integer.class, Integer.class), SQL, DML); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test + public void testPutAllGetAll_ClientServer_Backups1_SinglePartition_RestartRandomSrv_SqlDml() throws Exception { + putAllGetAll(RestartMode.RESTART_RND_SRV, 3, 1, 1, 1, + new InitIndexing(Integer.class, Integer.class), SQL, DML); + } + + /** + * @throws Exception If failed. + */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testUpdate_N_Objects_ClientServer_Backups2_Sql() throws Exception { updateNObjectsTest(7, 3, 2, 2, DFLT_PARTITION_COUNT, DFLT_TEST_TIME, new InitIndexing(Integer.class, Integer.class), SQL, DML, RestartMode.RESTART_CRD); @@ -108,6 +162,8 @@ public void testUpdate_N_Objects_ClientServer_Backups2_Sql() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10752") + @Test public void testUpdate_N_Objects_ClientServer_Backups1_Sql_Persistence() throws Exception { persistence = true; @@ -118,6 +174,7 @@ public void testUpdate_N_Objects_ClientServer_Backups1_Sql_Persistence() throws /** * @throws Exception If failed. */ + @Test public void testSqlReadInProgressCoordinatorFails() throws Exception { readInProgressCoordinatorFails(false, false, PESSIMISTIC, REPEATABLE_READ, SQL, DML, new InitIndexing(Integer.class, Integer.class)); } @@ -125,6 +182,7 @@ public void testSqlReadInProgressCoordinatorFails() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlReadInsideTxInProgressCoordinatorFails() throws Exception { readInProgressCoordinatorFails(false, true, PESSIMISTIC, REPEATABLE_READ, SQL, DML, new InitIndexing(Integer.class, Integer.class)); } @@ -132,6 +190,7 @@ public void testSqlReadInsideTxInProgressCoordinatorFails() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlReadInProgressCoordinatorFails_ReadDelay() throws Exception { readInProgressCoordinatorFails(true, false, PESSIMISTIC, REPEATABLE_READ, SQL, DML, new InitIndexing(Integer.class, Integer.class)); } @@ -139,6 +198,7 @@ public void testSqlReadInProgressCoordinatorFails_ReadDelay() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlReadInsideTxInProgressCoordinatorFails_ReadDelay() throws Exception { readInProgressCoordinatorFails(true, true, PESSIMISTIC, REPEATABLE_READ, SQL, DML, new InitIndexing(Integer.class, Integer.class)); } @@ -146,6 +206,7 @@ public void testSqlReadInsideTxInProgressCoordinatorFails_ReadDelay() throws Exc /** * @throws Exception If failed. */ + @Test public void testReadInProgressCoordinatorFailsSimple_FromServer() throws Exception { readInProgressCoordinatorFailsSimple(false, new InitIndexing(Integer.class, Integer.class), SQL, DML); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlTxQueriesTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlTxQueriesTest.java index 199cfad017b56..02f091d74dff4 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlTxQueriesTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlTxQueriesTest.java @@ -24,7 +24,7 @@ /** */ public class CacheMvccPartitionedSqlTxQueriesTest extends CacheMvccSqlTxQueriesAbstractTest { /** {@inheritDoc} */ - protected CacheMode cacheMode() { + @Override protected CacheMode cacheMode() { return PARTITIONED; } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlTxQueriesWithReducerTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlTxQueriesWithReducerTest.java index b98715895f06b..86966c199f2f7 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlTxQueriesWithReducerTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccPartitionedSqlTxQueriesWithReducerTest.java @@ -25,20 +25,25 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.internal.TestRecordingCommunicationSpi; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** */ +@RunWith(JUnit4.class) public class CacheMvccPartitionedSqlTxQueriesWithReducerTest extends CacheMvccSqlTxQueriesWithReducerAbstractTest { /** {@inheritDoc} */ - protected CacheMode cacheMode() { + @Override protected CacheMode cacheMode() { return PARTITIONED; } /** * @throws Exception If failed. */ + @Test public void testQueryUpdateOnUnstableTopologyDoesNotCauseDeadlock() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, CacheMvccSqlTxQueriesAbstractTest.MvccTestSqlIndexValue.class); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccReplicatedSelectForUpdateQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccReplicatedSelectForUpdateQueryTest.java index a45831942b889..b123e57fcacfc 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccReplicatedSelectForUpdateQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccReplicatedSelectForUpdateQueryTest.java @@ -24,7 +24,7 @@ /** */ public class CacheMvccReplicatedSelectForUpdateQueryTest extends CacheMvccSelectForUpdateQueryAbstractTest { /** {@inheritDoc} */ - public CacheMode cacheMode() { + @Override public CacheMode cacheMode() { return REPLICATED; } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccReplicatedSqlTxQueriesTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccReplicatedSqlTxQueriesTest.java index bde2c5dd6d9e3..4554a7f67c552 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccReplicatedSqlTxQueriesTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccReplicatedSqlTxQueriesTest.java @@ -28,6 +28,10 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.query.GridQueryProcessor; import org.apache.ignite.transactions.Transaction; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -36,9 +40,10 @@ import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** */ +@RunWith(JUnit4.class) public class CacheMvccReplicatedSqlTxQueriesTest extends CacheMvccSqlTxQueriesAbstractTest { /** {@inheritDoc} */ - protected CacheMode cacheMode() { + @Override protected CacheMode cacheMode() { return REPLICATED; } @@ -53,6 +58,7 @@ protected CacheMode cacheMode() { /** * @throws Exception If failed. */ + @Test public void testReplicatedJoinPartitionedClient() throws Exception { checkReplicatedJoinPartitioned(true); } @@ -60,6 +66,7 @@ public void testReplicatedJoinPartitionedClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicatedJoinPartitionedServer() throws Exception { checkReplicatedJoinPartitioned(false); } @@ -144,6 +151,8 @@ public void checkReplicatedJoinPartitioned(boolean client) throws Exception { * * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10763") + @Test public void testReplicatedAndPartitionedUpdateSingleTransaction() throws Exception { ccfgs = new CacheConfiguration[] { cacheConfiguration(REPLICATED, FULL_SYNC, 0, DFLT_PARTITION_COUNT) diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSelectForUpdateQueryAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSelectForUpdateQueryAbstractTest.java index 16b45ab517d74..b5631e228b0a1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSelectForUpdateQueryAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSelectForUpdateQueryAbstractTest.java @@ -39,6 +39,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.internal.processors.cache.index.AbstractSchemaSelfTest.connect; @@ -47,6 +50,7 @@ /** * Test for {@code SELECT FOR UPDATE} queries. */ +@RunWith(JUnit4.class) public abstract class CacheMvccSelectForUpdateQueryAbstractTest extends CacheMvccAbstractTest { /** */ private static final int CACHE_SIZE = 50; @@ -96,6 +100,7 @@ public abstract class CacheMvccSelectForUpdateQueryAbstractTest extends CacheMvc /** * */ + @Test public void testSelectForUpdateDistributed() throws Exception { doTestSelectForUpdateDistributed("Person", false); } @@ -104,6 +109,7 @@ public void testSelectForUpdateDistributed() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSelectForUpdateLocal() throws Exception { doTestSelectForUpdateLocal("Person", false); } @@ -111,6 +117,7 @@ public void testSelectForUpdateLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSelectForUpdateOutsideTxDistributed() throws Exception { doTestSelectForUpdateDistributed("Person", true); } @@ -118,6 +125,7 @@ public void testSelectForUpdateOutsideTxDistributed() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSelectForUpdateOutsideTxLocal() throws Exception { doTestSelectForUpdateLocal("Person", true); } @@ -193,6 +201,7 @@ void doTestSelectForUpdateDistributed(String cacheName, boolean outsideTx) throw /** * */ + @Test public void testSelectForUpdateWithUnion() { assertQueryThrows("select id from person union select 1 for update", "SELECT UNION FOR UPDATE is not supported."); @@ -201,6 +210,7 @@ public void testSelectForUpdateWithUnion() { /** * */ + @Test public void testSelectForUpdateWithJoin() { assertQueryThrows("select p1.id from person p1 join person p2 on p1.id = p2.id for update", "SELECT FOR UPDATE with joins is not supported."); @@ -209,6 +219,7 @@ public void testSelectForUpdateWithJoin() { /** * */ + @Test public void testSelectForUpdateWithLimit() { assertQueryThrows("select id from person limit 0,5 for update", "LIMIT/OFFSET clauses are not supported for SELECT FOR UPDATE."); @@ -217,6 +228,7 @@ public void testSelectForUpdateWithLimit() { /** * */ + @Test public void testSelectForUpdateWithGroupings() { assertQueryThrows("select count(*) from person for update", "SELECT FOR UPDATE with aggregates and/or GROUP BY is not supported."); @@ -228,6 +240,7 @@ public void testSelectForUpdateWithGroupings() { /** * @throws Exception If failed. */ + @Test public void testSelectForUpdateAfterAbortedTx() throws Exception { assert disableScheduledVacuum; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSizeTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSizeTest.java index 36a23224e2044..acb3d34f21f6b 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSizeTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSizeTest.java @@ -34,12 +34,16 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.processors.query.IgniteSQLException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CachePeekMode.BACKUP; /** * */ +@RunWith(JUnit4.class) public class CacheMvccSizeTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -100,6 +104,7 @@ private void checkSizeModificationByOperation(Consumer> before /** * @throws Exception if failed. */ + @Test public void testSql() throws Exception { startGridsMultiThreaded(2); @@ -215,6 +220,7 @@ public void testSql() throws Exception { /** * @throws Exception if failed. */ + @Test public void testInsertDeleteConcurrent() throws Exception { startGridsMultiThreaded(2); @@ -263,6 +269,7 @@ private int update(SqlFieldsQuery qry, IgniteCache cache) { /** * @throws Exception if failed. */ + @Test public void testWriteConflictDoesNotChangeSize() throws Exception { startGridsMultiThreaded(2); @@ -316,6 +323,7 @@ public void testWriteConflictDoesNotChangeSize() throws Exception { /** * @throws Exception if failed. */ + @Test public void testDeleteChangesSizeAfterUnlock() throws Exception { startGridsMultiThreaded(2); @@ -362,6 +370,7 @@ public void testDeleteChangesSizeAfterUnlock() throws Exception { /** * @throws Exception if failed. */ + @Test public void testDataStreamerModifiesReplicatedCacheSize() throws Exception { startGridsMultiThreaded(2); @@ -391,6 +400,7 @@ public void testDataStreamerModifiesReplicatedCacheSize() throws Exception { /** * @throws Exception if failed. */ + @Test public void testSizeIsConsistentAfterRebalance() throws Exception { IgniteEx ignite = startGrid(0); @@ -415,6 +425,7 @@ public void testSizeIsConsistentAfterRebalance() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSizeIsConsistentAfterRebalanceDuringInsert() throws Exception { IgniteEx ignite = startGrid(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlConfigurationValidationTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlConfigurationValidationTest.java index 7e6c9e884fff5..b10a847e50503 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlConfigurationValidationTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlConfigurationValidationTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Configuration validation for SQL configured caches. */ +@RunWith(JUnit4.class) public class CacheMvccSqlConfigurationValidationTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -39,6 +43,7 @@ public class CacheMvccSqlConfigurationValidationTest extends CacheMvccAbstractTe /** * @throws Exception If failed. */ + @Test public void testCacheGroupAtomicityModeMismatch1() throws Exception { Ignite node = startGrid(); @@ -62,6 +67,7 @@ public void testCacheGroupAtomicityModeMismatch1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheGroupAtomicityModeMismatch2() throws Exception { Ignite node = startGrid(); @@ -84,6 +90,7 @@ public void testCacheGroupAtomicityModeMismatch2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTxDifferentMvccSettingsTransactional() throws Exception { ccfg = defaultCacheConfiguration().setSqlSchema("PUBLIC"); Ignite node = startGrid(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlLockTimeoutTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlLockTimeoutTest.java index bdd9a762e3a57..5cc6efebdb677 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlLockTimeoutTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlLockTimeoutTest.java @@ -34,6 +34,9 @@ import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheMode.REPLICATED; @@ -41,6 +44,7 @@ import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; /** */ +@RunWith(JUnit4.class) public class CacheMvccSqlLockTimeoutTest extends CacheMvccAbstractTest { /** */ private static final int TIMEOUT_MILLIS = 200; @@ -61,6 +65,7 @@ public class CacheMvccSqlLockTimeoutTest extends CacheMvccAbstractTest { /** * @throws Exception if failed. */ + @Test public void testLockTimeoutsForPartitionedCache() throws Exception { checkLockTimeouts(partitionedCacheConfig()); } @@ -68,6 +73,7 @@ public void testLockTimeoutsForPartitionedCache() throws Exception { /** * @throws Exception if failed. */ + @Test public void testLockTimeoutsForReplicatedCache() throws Exception { checkLockTimeouts(replicatedCacheConfig()); } @@ -75,6 +81,7 @@ public void testLockTimeoutsForReplicatedCache() throws Exception { /** * @throws Exception if failed. */ + @Test public void testLockTimeoutsAfterDefaultTxTimeoutForPartitionedCache() throws Exception { checkLockTimeoutsAfterDefaultTxTimeout(partitionedCacheConfig()); } @@ -82,6 +89,7 @@ public void testLockTimeoutsAfterDefaultTxTimeoutForPartitionedCache() throws Ex /** * @throws Exception if failed. */ + @Test public void testLockTimeoutsAfterDefaultTxTimeoutForReplicatedCache() throws Exception { checkLockTimeoutsAfterDefaultTxTimeout(replicatedCacheConfig()); } @@ -89,6 +97,7 @@ public void testLockTimeoutsAfterDefaultTxTimeoutForReplicatedCache() throws Exc /** * @throws Exception if failed. */ + @Test public void testConcurrentForPartitionedCache() throws Exception { checkTimeoutsConcurrent(partitionedCacheConfig()); } @@ -96,6 +105,7 @@ public void testConcurrentForPartitionedCache() throws Exception { /** * @throws Exception if failed. */ + @Test public void testConcurrentForReplicatedCache() throws Exception { checkTimeoutsConcurrent(replicatedCacheConfig()); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlQueriesAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlQueriesAbstractTest.java index 313b58f594ea8..b52f2ec7e83b7 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlQueriesAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlQueriesAbstractTest.java @@ -42,6 +42,10 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.transactions.Transaction; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL; @@ -57,10 +61,12 @@ * TODO IGNITE-6739: dynamic index create. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public abstract class CacheMvccSqlQueriesAbstractTest extends CacheMvccAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAccountsTxSql_SingleNode_SinglePartition() throws Exception { accountsTxReadAll(1, 0, 0, 1, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL, PUT); @@ -69,6 +75,7 @@ public void testAccountsTxSql_SingleNode_SinglePartition() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxSql_WithRemoves_SingleNode_SinglePartition() throws Exception { accountsTxReadAll(1, 0, 0, 1, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL, PUT); @@ -77,6 +84,7 @@ public void testAccountsTxSql_WithRemoves_SingleNode_SinglePartition() throws Ex /** * @throws Exception If failed. */ + @Test public void testAccountsTxSql_SingleNode() throws Exception { accountsTxReadAll(1, 0, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL, PUT); @@ -85,6 +93,7 @@ public void testAccountsTxSql_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxSql_SingleNode_Persistence() throws Exception { persistence = true; @@ -94,6 +103,7 @@ public void testAccountsTxSql_SingleNode_Persistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxSumSql_SingleNode() throws Exception { accountsTxReadAll(1, 0, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL_SUM, PUT); @@ -102,6 +112,7 @@ public void testAccountsTxSumSql_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxSql_WithRemoves_SingleNode() throws Exception { accountsTxReadAll(1, 0, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL, PUT); @@ -110,6 +121,7 @@ public void testAccountsTxSql_WithRemoves_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxSql_WithRemoves_SingleNode_Persistence() throws Exception { persistence = true; @@ -119,6 +131,7 @@ public void testAccountsTxSql_WithRemoves_SingleNode_Persistence() throws Except /** * @throws Exception If failed. */ + @Test public void testAccountsTxSql_ClientServer_Backups2() throws Exception { accountsTxReadAll(4, 2, 2, 64, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL, PUT); @@ -127,6 +140,8 @@ public void testAccountsTxSql_ClientServer_Backups2() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testUpdateSingleValue_SingleNode() throws Exception { updateSingleValue(true, false); } @@ -134,6 +149,8 @@ public void testUpdateSingleValue_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testUpdateSingleValue_LocalQuery_SingleNode() throws Exception { updateSingleValue(true, true); } @@ -141,6 +158,8 @@ public void testUpdateSingleValue_LocalQuery_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testUpdateSingleValue_ClientServer() throws Exception { updateSingleValue(false, false); } @@ -355,6 +374,8 @@ private void updateSingleValue(boolean singleNode, final boolean locQry) throws /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testJoinTransactional_SingleNode() throws Exception { joinTransactional(true, false); } @@ -362,6 +383,8 @@ public void testJoinTransactional_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testJoinTransactional_ClientServer() throws Exception { joinTransactional(false, false); } @@ -369,6 +392,8 @@ public void testJoinTransactional_ClientServer() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testJoinTransactional_DistributedJoins_ClientServer() throws Exception { joinTransactional(false, true); } @@ -524,6 +549,7 @@ private void joinTransactional(boolean singleNode, final boolean distributedJoin /** * @throws Exception If failed. */ + @Test public void testJoinTransactional_DistributedJoins_ClientServer2() throws Exception { final int KEYS = 100; @@ -632,6 +658,7 @@ public void testJoinTransactional_DistributedJoins_ClientServer2() throws Except /** * @throws Exception If failed. */ + @Test public void testDistributedJoinSimple() throws Exception { startGridsMultiThreaded(4); @@ -693,6 +720,7 @@ public void testDistributedJoinSimple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheRecreate() throws Exception { cacheRecreate(new InitIndexing(Integer.class, MvccTestAccount.class)); } @@ -700,6 +728,7 @@ public void testCacheRecreate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheRecreateChangeIndexedType() throws Exception { Ignite srv0 = startGrid(0); @@ -775,6 +804,7 @@ public void testCacheRecreateChangeIndexedType() throws Exception { /** * @throws Exception If failed. */ + @Test public void testChangeValueType1() throws Exception { Ignite srv0 = startGrid(0); @@ -802,6 +832,7 @@ public void testChangeValueType1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testChangeValueType2() throws Exception { Ignite srv0 = startGrid(0); @@ -833,6 +864,7 @@ public void testChangeValueType2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCountTransactional_SingleNode() throws Exception { countTransactional(true); } @@ -840,6 +872,7 @@ public void testCountTransactional_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCountTransactional_ClientServer() throws Exception { countTransactional(false); } @@ -979,6 +1012,7 @@ private void countTransactional(boolean singleNode) throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxMinTransactional_SingleNode() throws Exception { maxMinTransactional(true); } @@ -986,6 +1020,7 @@ public void testMaxMinTransactional_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMaxMinTransactional_ClientServer() throws Exception { maxMinTransactional(false); } @@ -1140,6 +1175,7 @@ private void maxMinTransactional(boolean singleNode) throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlQueriesWithMvcc() throws Exception { Ignite srv0 = startGrid(0); @@ -1243,6 +1279,7 @@ private void checkSingleResult(IgniteCache cache, SqlFieldsQuery qry, Object exp /** * @throws Exception If failed. */ + @Test public void testSqlSimple() throws Exception { startGrid(0); @@ -1310,6 +1347,7 @@ private void sqlSimple(int inlineSize) throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlSimplePutRemoveRandom() throws Exception { startGrid(0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxModesTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxModesTest.java new file mode 100644 index 0000000000000..05f30b6af498d --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxModesTest.java @@ -0,0 +1,213 @@ +/* + * 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. + */ +package org.apache.ignite.internal.processors.cache.mvcc; + +import java.util.concurrent.Callable; +import javax.cache.CacheException; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.transactions.Transaction; +import org.junit.Test; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC; +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; +import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; +import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE; + +/** + * + */ +public class CacheMvccSqlTxModesTest extends CacheMvccAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return PARTITIONED; + } + + /** + * @throws Exception If failed + */ + @Test + public void testSqlTransactionModesNoMvcc() throws Exception { + IgniteEx node = startGrid(0); + + IgniteCache nonMvccCache = node.createCache(new CacheConfiguration<>("no-mvcc-cache") + .setAtomicityMode(TRANSACTIONAL).setIndexedTypes(Integer.class, Integer.class)); + + nonMvccCache.put(1,1); + + try (Transaction tx = node.transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { + nonMvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + nonMvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) { + nonMvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { + nonMvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + nonMvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, SERIALIZABLE)) { + nonMvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + nonMvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer").setLocal(true)).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, SERIALIZABLE)) { + nonMvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer").setLocal(true)).getAll(); + + tx.commit(); + } + } + + /** + * @throws Exception If failed + */ + @Test + public void testSqlTransactionModesMvcc() throws Exception { + IgniteEx node = startGrid(0); + + IgniteCache mvccCache = node.createCache(new CacheConfiguration<>("mvcc-cache") + .setAtomicityMode(TRANSACTIONAL_SNAPSHOT).setIndexedTypes(Integer.class, Integer.class)); + + mvccCache.put(1,1); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + try (Transaction tx = node.transactions().txStart(OPTIMISTIC, READ_COMMITTED)) { + mvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + return null; + } + }, CacheException.class, "Only pessimistic transactions are supported when MVCC is enabled"); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + try (Transaction tx = node.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + mvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + return null; + } + }, CacheException.class, "Only pessimistic transactions are supported when MVCC is enabled"); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + try (Transaction tx = node.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) { + mvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + return null; + } + }, CacheException.class, "Only pessimistic transactions are supported when MVCC is enabled"); + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { + mvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + mvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, SERIALIZABLE)) { + mvccCache.query(new SqlFieldsQuery("SELECT * FROM Integer")).getAll(); + + tx.commit(); + } + } + + /** + * @throws Exception If failed + */ + @Test + public void testConsequentMvccNonMvccOperations() throws Exception { + IgniteEx node = startGrid(0); + + IgniteCache mvccCache = node.createCache(new CacheConfiguration<>("mvcc-cache") + .setAtomicityMode(TRANSACTIONAL_SNAPSHOT).setIndexedTypes(Integer.class, Integer.class)); + + IgniteCache nonMvccCache = node.createCache(new CacheConfiguration<>("no-mvcc-cache") + .setAtomicityMode(TRANSACTIONAL).setIndexedTypes(Integer.class, Integer.class)); + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + nonMvccCache.put(1, 1); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + mvccCache.query(new SqlFieldsQuery("INSERT INTO Integer (_key, _val) VALUES (3,3)")).getAll(); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + nonMvccCache.put(2, 2); + + tx.commit(); + } + + try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { + mvccCache.query(new SqlFieldsQuery("INSERT INTO Integer (_key, _val) VALUES (5,5)")).getAll(); + + tx.commit(); + } + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxQueriesAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxQueriesAbstractTest.java index b71dd261d4061..863df2eb529fa 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxQueriesAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxQueriesAbstractTest.java @@ -62,6 +62,10 @@ import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL; @@ -75,10 +79,12 @@ /** * Tests for transactional SQL. */ +@RunWith(JUnit4.class) public abstract class CacheMvccSqlTxQueriesAbstractTest extends CacheMvccAbstractTest { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_SingleNode_SinglePartition() throws Exception { accountsTxReadAll(1, 0, 0, 1, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL, DML); @@ -87,6 +93,7 @@ public void testAccountsTxDmlSql_SingleNode_SinglePartition() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_WithRemoves_SingleNode_SinglePartition() throws Exception { accountsTxReadAll(1, 0, 0, 1, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL, DML); @@ -95,6 +102,7 @@ public void testAccountsTxDmlSql_WithRemoves_SingleNode_SinglePartition() throws /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_SingleNode() throws Exception { accountsTxReadAll(1, 0, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL, DML); @@ -103,6 +111,7 @@ public void testAccountsTxDmlSql_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_SingleNode_Persistence() throws Exception { persistence = true; @@ -112,6 +121,7 @@ public void testAccountsTxDmlSql_SingleNode_Persistence() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSumSql_SingleNode() throws Exception { accountsTxReadAll(1, 0, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL_SUM, DML); @@ -120,6 +130,7 @@ public void testAccountsTxDmlSumSql_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSumSql_WithRemoves_SingleNode() throws Exception { accountsTxReadAll(1, 0, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL_SUM, DML); @@ -128,6 +139,7 @@ public void testAccountsTxDmlSumSql_WithRemoves_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSumSql_WithRemoves__ClientServer_Backups0() throws Exception { accountsTxReadAll(4, 2, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL_SUM, DML); @@ -136,6 +148,7 @@ public void testAccountsTxDmlSumSql_WithRemoves__ClientServer_Backups0() throws /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSumSql_ClientServer_Backups2() throws Exception { accountsTxReadAll(4, 2, 2, 64, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL_SUM, DML); @@ -144,6 +157,7 @@ public void testAccountsTxDmlSumSql_ClientServer_Backups2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_WithRemoves_SingleNode() throws Exception { accountsTxReadAll(1, 0, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL, DML); @@ -152,6 +166,7 @@ public void testAccountsTxDmlSql_WithRemoves_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_WithRemoves_SingleNode_Persistence() throws Exception { persistence = true; @@ -161,6 +176,7 @@ public void testAccountsTxDmlSql_WithRemoves_SingleNode_Persistence() throws Exc /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_ClientServer_Backups0() throws Exception { accountsTxReadAll(4, 2, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL, DML); @@ -169,6 +185,7 @@ public void testAccountsTxDmlSql_ClientServer_Backups0() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups0() throws Exception { accountsTxReadAll(4, 2, 0, 64, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL, DML); @@ -177,6 +194,7 @@ public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups0() throws Exce /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups0_Persistence() throws Exception { persistence = true; @@ -186,6 +204,7 @@ public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups0_Persistence() /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_ClientServer_Backups1() throws Exception { accountsTxReadAll(3, 0, 1, 64, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL, DML); @@ -194,6 +213,7 @@ public void testAccountsTxDmlSql_ClientServer_Backups1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups1() throws Exception { accountsTxReadAll(4, 2, 1, 64, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL, DML); @@ -202,6 +222,7 @@ public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups1() throws Exce /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups1_Persistence() throws Exception { persistence = true; @@ -211,6 +232,7 @@ public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups1_Persistence() /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_ClientServer_Backups2() throws Exception { accountsTxReadAll(4, 2, 2, 64, new InitIndexing(Integer.class, MvccTestAccount.class), false, SQL, DML); @@ -219,6 +241,7 @@ public void testAccountsTxDmlSql_ClientServer_Backups2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups2() throws Exception { accountsTxReadAll(4, 2, 2, 64, new InitIndexing(Integer.class, MvccTestAccount.class), true, SQL, DML); @@ -227,9 +250,8 @@ public void testAccountsTxDmlSql_WithRemoves_ClientServer_Backups2() throws Exce /** * @throws Exception If failed. */ + @Test public void testAccountsTxDmlSql_ClientServer_Backups2_Persistence() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-9292"); - persistence = true; testAccountsTxDmlSql_ClientServer_Backups2(); @@ -238,6 +260,7 @@ public void testAccountsTxDmlSql_ClientServer_Backups2_Persistence() throws Exce /** * @throws Exception If failed. */ + @Test public void testParsingErrorHasNoSideEffect() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 0, 4) .setIndexedTypes(Integer.class, Integer.class); @@ -285,6 +308,7 @@ public void testParsingErrorHasNoSideEffect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryInsertStaticCache() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -330,6 +354,7 @@ public void testQueryInsertStaticCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryInsertStaticCacheImplicit() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -360,6 +385,7 @@ public void testQueryInsertStaticCacheImplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryDeleteStaticCache() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -406,6 +432,7 @@ public void testQueryDeleteStaticCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryFastDeleteStaticCache() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -451,6 +478,7 @@ public void testQueryFastDeleteStaticCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryFastUpdateStaticCache() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -496,6 +524,7 @@ public void testQueryFastUpdateStaticCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryFastDeleteObjectStaticCache() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, MvccTestSqlIndexValue.class); @@ -540,6 +569,7 @@ public void testQueryFastDeleteObjectStaticCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryFastUpdateObjectStaticCache() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, MvccTestSqlIndexValue.class); @@ -584,6 +614,7 @@ public void testQueryFastUpdateObjectStaticCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryDeleteStaticCacheImplicit() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -620,6 +651,7 @@ public void testQueryDeleteStaticCacheImplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryUpdateStaticCache() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -661,6 +693,7 @@ public void testQueryUpdateStaticCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryUpdateStaticCacheImplicit() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -697,6 +730,7 @@ public void testQueryUpdateStaticCacheImplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryDeadlockWithTxTimeout() throws Exception { checkQueryDeadlock(TimeoutMode.TX); } @@ -704,6 +738,7 @@ public void testQueryDeadlockWithTxTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryDeadlockWithStmtTimeout() throws Exception { checkQueryDeadlock(TimeoutMode.STMT); } @@ -787,6 +822,7 @@ private void checkQueryDeadlock(TimeoutMode timeoutMode) throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryDeadlockImplicit() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 0, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -855,6 +891,7 @@ public void testQueryDeadlockImplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryInsertClient() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -904,6 +941,7 @@ public void testQueryInsertClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryInsertClientImplicit() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -938,6 +976,7 @@ public void testQueryInsertClientImplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryInsertSubquery() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class, Integer.class, MvccTestSqlIndexValue.class); @@ -981,6 +1020,7 @@ public void testQueryInsertSubquery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryInsertSubqueryImplicit() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class, Integer.class, MvccTestSqlIndexValue.class); @@ -1019,6 +1059,7 @@ public void testQueryInsertSubqueryImplicit() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryUpdateSubquery() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class, Integer.class, MvccTestSqlIndexValue.class); @@ -1062,6 +1103,7 @@ public void testQueryUpdateSubquery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryUpdateSubqueryImplicit() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class, Integer.class, MvccTestSqlIndexValue.class); @@ -1100,6 +1142,8 @@ public void testQueryUpdateSubqueryImplicit() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10764") + @Test public void testQueryInsertMultithread() throws Exception { final int THREAD_CNT = 8; final int BATCH_SIZE = 1000; @@ -1167,9 +1211,9 @@ public void testQueryInsertMultithread() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9470") + @Test public void testQueryInsertUpdateMultithread() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-9470"); - ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1276,6 +1320,7 @@ public Void process(MutableEntry entry, /** * @throws Exception If failed. */ + @Test public void testQueryInsertVersionConflict() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1341,6 +1386,7 @@ public void testQueryInsertVersionConflict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInsertAndFastDeleteWithoutVersionConflict() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1371,6 +1417,7 @@ public void testInsertAndFastDeleteWithoutVersionConflict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInsertAndFastUpdateWithoutVersionConflict() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1401,9 +1448,9 @@ public void testInsertAndFastUpdateWithoutVersionConflict() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-9292") + @Test public void testInsertFastUpdateConcurrent() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-9292"); - ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1434,6 +1481,7 @@ public void testInsertFastUpdateConcurrent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryInsertRollback() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1474,6 +1522,7 @@ public void testQueryInsertRollback() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryInsertUpdateSameKeys() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1515,6 +1564,7 @@ public void testQueryInsertUpdateSameKeys() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryInsertUpdateSameKeysInSameOperation() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1547,6 +1597,7 @@ public void testQueryInsertUpdateSameKeysInSameOperation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryPendingUpdates() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1615,6 +1666,7 @@ public void testQueryPendingUpdates() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSelectProducesTransaction() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, MvccTestSqlIndexValue.class); @@ -1649,6 +1701,7 @@ public void testSelectProducesTransaction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableRead() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, MvccTestSqlIndexValue.class); @@ -1700,6 +1753,7 @@ public void testRepeatableRead() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFastInsertUpdateConcurrent() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1724,6 +1778,7 @@ public void testFastInsertUpdateConcurrent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIterator() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -1794,6 +1849,7 @@ public void testIterator() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHints() throws Exception { persistence = true; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxQueriesWithReducerAbstractTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxQueriesWithReducerAbstractTest.java index 7826e5fa13b87..684631a2b3ea4 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxQueriesWithReducerAbstractTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlTxQueriesWithReducerAbstractTest.java @@ -39,6 +39,10 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; @@ -49,6 +53,7 @@ /** * Tests for transactional SQL. */ +@RunWith(JUnit4.class) public abstract class CacheMvccSqlTxQueriesWithReducerAbstractTest extends CacheMvccAbstractTest { /** */ private static final int TIMEOUT = 3000; @@ -64,6 +69,7 @@ public abstract class CacheMvccSqlTxQueriesWithReducerAbstractTest extends Cache /** * @throws Exception If failed. */ + @Test public void testQueryReducerInsert() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, CacheMvccSqlTxQueriesAbstractTest.MvccTestSqlIndexValue.class); @@ -117,6 +123,7 @@ public void testQueryReducerInsert() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerInsertDuplicateKey() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, CacheMvccSqlTxQueriesAbstractTest.MvccTestSqlIndexValue.class); @@ -165,6 +172,7 @@ public void testQueryReducerInsertDuplicateKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerMerge() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, CacheMvccSqlTxQueriesAbstractTest.MvccTestSqlIndexValue.class); @@ -217,6 +225,7 @@ public void testQueryReducerMerge() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerMultiBatchPerNodeServer() throws Exception { checkMultiBatchPerNode(false); } @@ -224,6 +233,7 @@ public void testQueryReducerMultiBatchPerNodeServer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerMultiBatchPerNodeClient() throws Exception { checkMultiBatchPerNode(true); } @@ -292,6 +302,7 @@ private void checkMultiBatchPerNode(boolean client) throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerDelete() throws Exception { ccfgs = new CacheConfiguration[] { cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) @@ -343,6 +354,7 @@ public void testQueryReducerDelete() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerUpdate() throws Exception { ccfgs = new CacheConfiguration[] { cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) @@ -395,6 +407,7 @@ public void testQueryReducerUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerImplicitTxInsert() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, CacheMvccSqlTxQueriesAbstractTest.MvccTestSqlIndexValue.class); @@ -444,6 +457,7 @@ public void testQueryReducerImplicitTxInsert() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerRollbackInsert() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, CacheMvccSqlTxQueriesAbstractTest.MvccTestSqlIndexValue.class); @@ -506,6 +520,8 @@ private List sqlGet(int key, IgniteCache cache) { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10763") + @Test public void testQueryReducerDeadlockInsertWithTxTimeout() throws Exception { checkQueryReducerDeadlockInsert(TimeoutMode.TX); } @@ -513,6 +529,7 @@ public void testQueryReducerDeadlockInsertWithTxTimeout() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerDeadlockInsertWithStmtTimeout() throws Exception { checkQueryReducerDeadlockInsert(TimeoutMode.STMT); } @@ -612,6 +629,7 @@ public void checkQueryReducerDeadlockInsert(TimeoutMode timeoutMode) throws Exce /** * @throws Exception If failed. */ + @Test public void testQueryReducerInsertVersionConflict() throws Exception { ccfgs = new CacheConfiguration[] { cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) @@ -686,6 +704,7 @@ public void testQueryReducerInsertVersionConflict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerInsertValues() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, CacheMvccSqlTxQueriesAbstractTest.MvccTestSqlIndexValue.class); @@ -723,6 +742,7 @@ public void testQueryReducerInsertValues() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerMergeValues() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, CacheMvccSqlTxQueriesAbstractTest.MvccTestSqlIndexValue.class); @@ -763,6 +783,7 @@ public void testQueryReducerMergeValues() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerFastUpdate() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -804,6 +825,7 @@ public void testQueryReducerFastUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryReducerFastDelete() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, CacheMvccSqlTxQueriesAbstractTest.MvccTestSqlIndexValue.class); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlUpdateCountersTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlUpdateCountersTest.java index 943f5a42afe52..3b5f8e447e1e1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlUpdateCountersTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccSqlUpdateCountersTest.java @@ -36,6 +36,9 @@ import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL; @@ -46,6 +49,7 @@ * Test for MVCC caches update counters behaviour. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class CacheMvccSqlUpdateCountersTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -55,6 +59,7 @@ public class CacheMvccSqlUpdateCountersTest extends CacheMvccAbstractTest { /** * @throws Exception If failed. */ + @Test public void testUpdateCountersInsertSimple() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -93,6 +98,7 @@ public void testUpdateCountersInsertSimple() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateCountersDoubleUpdate() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -139,6 +145,7 @@ public void testUpdateCountersDoubleUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateCountersRollback() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT) .setIndexedTypes(Integer.class, Integer.class); @@ -185,6 +192,7 @@ public void testUpdateCountersRollback() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeleteOwnKey() throws Exception { ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, 1) .setCacheMode(CacheMode.REPLICATED) @@ -320,6 +328,7 @@ public void testDeleteOwnKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateCountersMultithreaded() throws Exception { final int writers = 4; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccStreamingInsertTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccStreamingInsertTest.java index b07a187a579af..e0415b8c55a64 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccStreamingInsertTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccStreamingInsertTest.java @@ -29,12 +29,16 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.Arrays.asList; /** * */ +@RunWith(JUnit4.class) public class CacheMvccStreamingInsertTest extends CacheMvccAbstractTest { /** */ private IgniteCache sqlNexus; @@ -68,6 +72,7 @@ public class CacheMvccStreamingInsertTest extends CacheMvccAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStreamingInsertWithoutOverwrite() throws Exception { conn.createStatement().execute("SET STREAMING 1 BATCH_SIZE 2 ALLOW_OVERWRITE 0 " + " PER_NODE_BUFFER_SIZE 1000 FLUSH_FREQUENCY 100"); @@ -93,6 +98,7 @@ public void testStreamingInsertWithoutOverwrite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUpdateWithOverwrite() throws Exception { conn.createStatement().execute("SET STREAMING 1 BATCH_SIZE 2 ALLOW_OVERWRITE 1 " + " PER_NODE_BUFFER_SIZE 1000 FLUSH_FREQUENCY 100"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxNodeMappingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxNodeMappingTest.java index a329609447efd..6df21437a54d8 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxNodeMappingTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxNodeMappingTest.java @@ -39,6 +39,9 @@ import org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -48,6 +51,7 @@ /** * Test checks that transactions started on nodes collect all nodes participating in distributed transaction. */ +@RunWith(JUnit4.class) public class CacheMvccTxNodeMappingTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -57,6 +61,7 @@ public class CacheMvccTxNodeMappingTest extends CacheMvccAbstractTest { /** * @throws Exception if failed. */ + @Test public void testAllTxNodesAreTrackedCli() throws Exception { checkAllTxNodesAreTracked(false); } @@ -64,6 +69,7 @@ public void testAllTxNodesAreTrackedCli() throws Exception { /** * @throws Exception if failed. */ + @Test public void testAllTxNodesAreTrackedSrv() throws Exception { checkAllTxNodesAreTracked(true); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxRecoveryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxRecoveryTest.java index 01f50cc4801b5..10d5d363f46bd 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxRecoveryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTxRecoveryTest.java @@ -54,6 +54,10 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.transactions.Transaction; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -69,6 +73,7 @@ import static org.apache.ignite.transactions.TransactionState.ROLLED_BACK; /** */ +@RunWith(JUnit4.class) public class CacheMvccTxRecoveryTest extends CacheMvccAbstractTest { /** */ public enum TxEndResult { @@ -99,6 +104,7 @@ public enum NodeMode { /** * @throws Exception if failed. */ + @Test public void testRecoveryCommitNearFailure1() throws Exception { checkRecoveryNearFailure(COMMIT, CLIENT); } @@ -106,6 +112,7 @@ public void testRecoveryCommitNearFailure1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRecoveryCommitNearFailure2() throws Exception { checkRecoveryNearFailure(COMMIT, SERVER); } @@ -113,6 +120,7 @@ public void testRecoveryCommitNearFailure2() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRecoveryRollbackNearFailure1() throws Exception { checkRecoveryNearFailure(ROLLBAK, CLIENT); } @@ -120,6 +128,7 @@ public void testRecoveryRollbackNearFailure1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRecoveryRollbackNearFailure2() throws Exception { checkRecoveryNearFailure(ROLLBAK, SERVER); } @@ -127,6 +136,7 @@ public void testRecoveryRollbackNearFailure2() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRecoveryCommitPrimaryFailure1() throws Exception { checkRecoveryPrimaryFailure(COMMIT, false); } @@ -134,6 +144,7 @@ public void testRecoveryCommitPrimaryFailure1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRecoveryRollbackPrimaryFailure1() throws Exception { checkRecoveryPrimaryFailure(ROLLBAK, false); } @@ -141,6 +152,7 @@ public void testRecoveryRollbackPrimaryFailure1() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRecoveryCommitPrimaryFailure2() throws Exception { checkRecoveryPrimaryFailure(COMMIT, true); } @@ -148,6 +160,7 @@ public void testRecoveryCommitPrimaryFailure2() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRecoveryRollbackPrimaryFailure2() throws Exception { checkRecoveryPrimaryFailure(ROLLBAK, true); } @@ -344,6 +357,7 @@ private void checkRecoveryPrimaryFailure(TxEndResult endRes, boolean mvccCrd) th /** * @throws Exception if failed. */ + @Test public void testRecoveryCommit() throws Exception { startGridsMultiThreaded(2); @@ -387,6 +401,8 @@ public void testRecoveryCommit() throws Exception { /** * @throws Exception if failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10766") + @Test public void testCountersNeighborcastServerFailed() throws Exception { int srvCnt = 4; @@ -493,6 +509,7 @@ public void testCountersNeighborcastServerFailed() throws Exception { /** * @throws Exception if failed. */ + @Test public void testUpdateCountersGapIsClosed() throws Exception { int srvCnt = 3; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccRepeatableReadBulkOpsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccRepeatableReadBulkOpsTest.java index 5ec96e47941f8..bf73db1551ca7 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccRepeatableReadBulkOpsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccRepeatableReadBulkOpsTest.java @@ -50,6 +50,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.GET; @@ -61,6 +64,7 @@ /** * Test basic mvcc bulk cache operations. */ +@RunWith(JUnit4.class) public class MvccRepeatableReadBulkOpsTest extends CacheMvccAbstractTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { @@ -108,6 +112,7 @@ private int nodesCount() { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationGetPut() throws Exception { checkOperations(GET, GET, PUT, true); checkOperations(GET, GET, PUT, false); @@ -116,6 +121,7 @@ public void testRepeatableReadIsolationGetPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationInvoke() throws Exception { checkOperations(GET, GET, WriteMode.INVOKE, true); checkOperations(GET, GET, WriteMode.INVOKE, false); @@ -124,6 +130,7 @@ public void testRepeatableReadIsolationInvoke() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationSqlPut() throws Exception { checkOperations(SQL, SQL, PUT, true); checkOperations(SQL, SQL, PUT, false); @@ -132,6 +139,7 @@ public void testRepeatableReadIsolationSqlPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationSqlInvoke() throws Exception { checkOperations(SQL, SQL, WriteMode.INVOKE, true); checkOperations(SQL, SQL, WriteMode.INVOKE, false); @@ -140,6 +148,7 @@ public void testRepeatableReadIsolationSqlInvoke() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationSqlDml() throws Exception { checkOperations(SQL, SQL, DML, true); checkOperations(SQL, SQL, DML, false); @@ -148,6 +157,7 @@ public void testRepeatableReadIsolationSqlDml() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationGetDml() throws Exception { checkOperations(GET, GET, DML, true); checkOperations(GET, GET, DML, false); @@ -156,6 +166,7 @@ public void testRepeatableReadIsolationGetDml() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationMixedPut() throws Exception { checkOperations(SQL, GET, PUT, false); checkOperations(SQL, GET, PUT, true); @@ -166,6 +177,7 @@ public void testRepeatableReadIsolationMixedPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationMixedPut2() throws Exception { checkOperations(GET, SQL, PUT, false); checkOperations(GET, SQL, PUT, true); @@ -176,6 +188,7 @@ public void testRepeatableReadIsolationMixedPut2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationMixedDml() throws Exception { checkOperations(SQL, GET, DML, false); checkOperations(SQL, GET, DML, true); @@ -184,6 +197,7 @@ public void testRepeatableReadIsolationMixedDml() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatableReadIsolationMixedDml2() throws Exception { checkOperations(GET, SQL, DML, false); checkOperations(GET, SQL, DML, true); @@ -192,6 +206,7 @@ public void testRepeatableReadIsolationMixedDml2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOperationConsistency() throws Exception { checkOperationsConsistency(PUT, false); checkOperationsConsistency(DML, false); @@ -204,6 +219,7 @@ public void testOperationConsistency() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvokeConsistency() throws Exception { Ignite node = grid(/*requestFromClient ? nodesCount() - 1 :*/ 0); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccRepeatableReadOperationsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccRepeatableReadOperationsTest.java index 618d910db05bd..e6ed0a369b9ef 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccRepeatableReadOperationsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/MvccRepeatableReadOperationsTest.java @@ -31,6 +31,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.GET; import static org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL; @@ -38,6 +41,7 @@ /** * Test basic mvcc cache operation operations. */ +@RunWith(JUnit4.class) public class MvccRepeatableReadOperationsTest extends MvccRepeatableReadBulkOpsTest { /** {@inheritDoc} */ @Override protected Map getEntries( @@ -166,6 +170,7 @@ public class MvccRepeatableReadOperationsTest extends MvccRepeatableReadBulkOpsT * * @throws IgniteCheckedException If failed. */ + @Test public void testGetAndUpdateOperations() throws IgniteCheckedException { Ignite node1 = grid(0); @@ -227,6 +232,7 @@ public void testGetAndUpdateOperations() throws IgniteCheckedException { * * @throws IgniteCheckedException If failed. */ + @Test public void testPutIfAbsentConsistency() throws IgniteCheckedException { Ignite node1 = grid(0); @@ -267,6 +273,7 @@ public void testPutIfAbsentConsistency() throws IgniteCheckedException { * * @throws IgniteCheckedException If failed. */ + @Test public void testReplaceConsistency() throws IgniteCheckedException { Ignite node1 = grid(0); @@ -311,4 +318,4 @@ public void testReplaceConsistency() throws IgniteCheckedException { assertEquals(updateMap, getEntries(cache1, allKeys, SQL)); assertEquals(updateMap, getEntries(cache1, allKeys, GET)); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java index c2b5dc2d382ef..2fe864af4557a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRecoveryTest.java @@ -18,8 +18,12 @@ package org.apache.ignite.internal.processors.cache.persistence.db.wal; import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -38,6 +42,7 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteCompute; import org.apache.ignite.IgniteException; +import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; @@ -53,9 +58,11 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.DiscoverySpiTestListener; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi; import org.apache.ignite.internal.pagemem.FullPageId; import org.apache.ignite.internal.pagemem.PageUtils; import org.apache.ignite.internal.pagemem.wal.WALIterator; @@ -67,15 +74,22 @@ import org.apache.ignite.internal.pagemem.wal.record.TxRecord; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.pagemem.wal.record.delta.PageDeltaRecord; +import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; +import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; +import org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntry; +import org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointEntryType; +import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.persistence.filename.PdsConsistentIdProcessor; import org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage; import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx; import org.apache.ignite.internal.processors.cache.persistence.tree.io.TrackingPageIO; +import org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.typedef.CA; +import org.apache.ignite.internal.util.lang.IgniteInClosureX; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.PA; import org.apache.ignite.internal.util.typedef.PAX; @@ -94,12 +108,18 @@ import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME; +import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DATA_FILENAME; import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.DFLT_STORE_DIR; /** * */ +@RunWith(JUnit4.class) public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** */ private static final String HAS_CACHE = "HAS_CACHE"; @@ -116,6 +136,9 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** */ private static final String RENAMED_CACHE_NAME = "partitioned0"; + /** */ + private static final String CACHE_TO_DESTROY_NAME = "destroyCache"; + /** */ private static final String LOC_CACHE_NAME = "local"; @@ -221,6 +244,7 @@ public class IgniteWalRecoveryTest extends GridCommonAbstractTest { /** * @throws Exception if failed. */ + @Test public void testWalBig() throws Exception { IgniteEx ignite = startGrid(1); @@ -263,6 +287,7 @@ public void testWalBig() throws Exception { /** * @throws Exception if failed. */ + @Test public void testWalBigObjectNodeCancel() throws Exception { final int MAX_SIZE_POWER = 21; @@ -301,6 +326,7 @@ public void testWalBigObjectNodeCancel() throws Exception { /** * @throws Exception If fail. */ + @Test public void testSwitchClassLoader() throws Exception { try { final IgniteEx igniteEx = startGrid(1); @@ -342,6 +368,7 @@ public void testSwitchClassLoader() throws Exception { /** * @throws Exception if failed. */ + @Test public void testWalSimple() throws Exception { try { IgniteEx ignite = startGrid(1); @@ -419,6 +446,7 @@ else if (i % 2 == 0) /** * @throws Exception If fail. */ + @Test public void testWalLargeValue() throws Exception { try { IgniteEx ignite = startGrid(1); @@ -466,9 +494,115 @@ public void testWalLargeValue() throws Exception { } } + /** + * Check binary recover completes successfully when node stopped at the middle of checkpoint. + * Destroy cache_data.bin file for particular cache to emulate missing {@link DynamicCacheDescriptor} + * file (binary recovery should complete successfully in this case). + * + * @throws Exception if failed. + */ + @Test + public void testBinaryRecoverBeforePMEWhenMiddleCheckpoint() throws Exception { + startGrids(3); + + IgniteEx ig2 = grid(2); + + ig2.cluster().active(true); + + IgniteCache cache = ig2.cache(CACHE_NAME); + + for (int i = 1; i <= 4_000; i++) + cache.put(i, new BigObject(i)); + + BigObject objToCheck; + + ig2.getOrCreateCache(CACHE_TO_DESTROY_NAME).put(1, objToCheck = new BigObject(1)); + + GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)ig2 + .context().cache().context().database(); + + IgniteInternalFuture cpFinishFut = dbMgr.forceCheckpoint("force checkpoint").finishFuture(); + + // Delete checkpoint END file to emulate node stopped at the middle of checkpoint. + cpFinishFut.listen(new IgniteInClosureX() { + @Override public void applyx(IgniteInternalFuture fut0) throws IgniteCheckedException { + try { + CheckpointEntry cpEntry = dbMgr.checkpointHistory().lastCheckpoint(); + + String cpEndFileName = GridCacheDatabaseSharedManager.checkpointFileName(cpEntry, + CheckpointEntryType.END); + + Files.delete(Paths.get(dbMgr.checkpointDirectory().getAbsolutePath(), cpEndFileName)); + + log.info("Checkpoint marker removed [cpEndFileName=" + cpEndFileName + ']'); + } + catch (IOException e) { + throw new IgniteCheckedException(e); + } + } + }); + + // Resolve cache directory. Emulating cache destroy in the middle of checkpoint. + IgniteInternalCache destoryCache = ig2.cachex(CACHE_TO_DESTROY_NAME); + + FilePageStoreManager pageStoreMgr = (FilePageStoreManager)destoryCache.context().shared().pageStore(); + + File destroyCacheWorkDir = pageStoreMgr.cacheWorkDir(destoryCache.configuration()); + + // Stop the whole cluster + stopAllGrids(); + + // Delete cache_data.bin file for this cache. Binary recovery should complete successfully after it. + final File[] files = destroyCacheWorkDir.listFiles(new FilenameFilter() { + @Override public boolean accept(final File dir, final String name) { + return name.endsWith(CACHE_DATA_FILENAME); + } + }); + + assertTrue(files.length > 0); + + for (final File file : files) + assertTrue("Can't remove " + file.getAbsolutePath(), file.delete()); + + startGrids(2); + + // Preprare Ignite instance configuration with additional Discovery checks. + final String ig2Name = getTestIgniteInstanceName(2); + + final IgniteConfiguration onJoinCfg = optimize(getConfiguration(ig2Name)); + + // Check restore beeing called before PME and joining node to cluster. + ((IgniteDiscoverySpi)onJoinCfg.getDiscoverySpi()) + .setInternalListener(new DiscoverySpiTestListener() { + @Override public void beforeJoin(ClusterNode locNode, IgniteLogger log) { + String nodeName = locNode.attribute(ATTR_IGNITE_INSTANCE_NAME); + + GridCacheSharedContext sharedCtx = ((IgniteEx)ignite(getTestIgniteInstanceIndex(nodeName))) + .context() + .cache() + .context(); + + if (nodeName.equals(ig2Name)) { + // Checkpoint history initialized on node start. + assertFalse(((GridCacheDatabaseSharedManager)sharedCtx.database()) + .checkpointHistory().checkpoints().isEmpty()); + } + + super.beforeJoin(locNode, log); + } + }); + + Ignite restoredIg2 = startGrid(ig2Name, onJoinCfg); + + awaitPartitionMapExchange(); + + assertEquals(restoredIg2.cache(CACHE_TO_DESTROY_NAME).get(1), objToCheck); + } + /** * @throws Exception if failed. */ + @Test public void testWalRolloverMultithreadedDefault() throws Exception { logOnly = false; @@ -478,6 +612,7 @@ public void testWalRolloverMultithreadedDefault() throws Exception { /** * @throws Exception if failed. */ + @Test public void testWalRolloverMultithreadedLogOnly() throws Exception { logOnly = true; @@ -487,6 +622,7 @@ public void testWalRolloverMultithreadedLogOnly() throws Exception { /** * @throws Exception if failed. */ + @Test public void testHugeCheckpointRecord() throws Exception { long prevFDTimeout = customFailureDetectionTimeout; @@ -573,6 +709,7 @@ private void checkWalRolloverMultithreaded() throws Exception { /** * @throws Exception If fail. */ + @Test public void testWalRenameDirSimple() throws Exception { try { IgniteEx ignite = startGrid(1); @@ -636,6 +773,7 @@ private File cacheDir(final String cacheName, final String consId) throws Ignite /** * @throws Exception if failed. */ + @Test public void testRecoveryNoCheckpoint() throws Exception { try { IgniteEx ctrlGrid = startGrid(0); @@ -689,6 +827,7 @@ public void testRecoveryNoCheckpoint() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRecoveryLargeNoCheckpoint() throws Exception { try { IgniteEx ctrlGrid = startGrid(0); @@ -744,6 +883,7 @@ public void testRecoveryLargeNoCheckpoint() throws Exception { /** * @throws Exception if failed. */ + @Test public void testRandomCrash() throws Exception { try { IgniteEx ctrlGrid = startGrid(0); @@ -782,6 +922,7 @@ public void testRandomCrash() throws Exception { /** * @throws Exception if failed. */ + @Test public void testLargeRandomCrash() throws Exception { try { IgniteEx ctrlGrid = startGrid(0); @@ -830,6 +971,7 @@ private static class RemoteNodeFilter implements IgnitePredicate { /** * @throws Exception If failed. */ + @Test public void testDestroyCache() throws Exception { try { IgniteEx ignite = startGrid(1); @@ -855,6 +997,7 @@ public void testDestroyCache() throws Exception { /** * @throws Exception If fail. */ + @Test public void testEvictPartition() throws Exception { try { Ignite ignite1 = startGrid("node1"); @@ -899,6 +1042,7 @@ public void testEvictPartition() throws Exception { /** * @throws Exception If fail. */ + @Test public void testMetastorage() throws Exception { try { int cnt = 5000; @@ -964,6 +1108,7 @@ public void testMetastorage() throws Exception { /** * @throws Exception If fail. */ + @Test public void testMetastorageLargeArray() throws Exception { try { int cnt = 5000; @@ -1011,6 +1156,7 @@ public void testMetastorageLargeArray() throws Exception { /** * @throws Exception If fail. */ + @Test public void testMetastorageRemove() throws Exception { try { int cnt = 400; @@ -1064,6 +1210,7 @@ public void testMetastorageRemove() throws Exception { /** * @throws Exception If fail. */ + @Test public void testMetastorageUpdate() throws Exception { try { int cnt = 2000; @@ -1116,6 +1263,7 @@ public void testMetastorageUpdate() throws Exception { /** * @throws Exception If fail. */ + @Test public void testMetastorageWalRestore() throws Exception { try { int cnt = 2000; @@ -1172,6 +1320,7 @@ public void testMetastorageWalRestore() throws Exception { /** * @throws Exception if failed. */ + @Test public void testAbsentDeadlock_Iterator_RollOver_Archivation() throws Exception { try { walSegments = 2; @@ -1240,6 +1389,7 @@ public void testAbsentDeadlock_Iterator_RollOver_Archivation() throws Exception /** * @throws Exception if failed. */ + @Test public void testApplyDeltaRecords() throws Exception { try { IgniteEx ignite0 = (IgniteEx)startGrid("node0"); @@ -1377,6 +1527,7 @@ else if (rec instanceof PageDeltaRecord) { * * @throws Exception If fail. */ + @Test public void testRecoveryOnTransactionalAndPartitionedCache() throws Exception { IgniteEx ignite = (IgniteEx) startGrids(3); ignite.cluster().active(true); @@ -1453,6 +1604,7 @@ public void testRecoveryOnTransactionalAndPartitionedCache() throws Exception { * * @throws Exception If any fail. */ + @Test public void testTxRecordsConsistency() throws Exception { System.setProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS, "true"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ttl/CacheTtlAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ttl/CacheTtlAbstractSelfTest.java index c9a5bf6ff9652..34663801f95c2 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ttl/CacheTtlAbstractSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/ttl/CacheTtlAbstractSelfTest.java @@ -38,10 +38,10 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -56,10 +56,8 @@ /** * TTL test. */ +@RunWith(JUnit4.class) public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int MAX_CACHE_SIZE = 5; @@ -112,8 +110,6 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfg); - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - return cfg; } @@ -145,6 +141,7 @@ public abstract class CacheTtlAbstractSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLiveLoadCache() throws Exception { IgniteCache cache = jcache(0); @@ -160,6 +157,7 @@ public void testDefaultTimeToLiveLoadCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLiveLoadAll() throws Exception { defaultTimeToLiveLoadAll(false); @@ -194,6 +192,7 @@ private void defaultTimeToLiveLoadAll(boolean replaceExisting) throws Exception /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLiveStreamerAdd() throws Exception { try (IgniteDataStreamer streamer = ignite(0).dataStreamer(DEFAULT_CACHE_NAME)) { for (int i = 0; i < SIZE; i++) @@ -223,6 +222,7 @@ public void testDefaultTimeToLiveStreamerAdd() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLivePut() throws Exception { IgniteCache cache = jcache(0); @@ -240,6 +240,7 @@ public void testDefaultTimeToLivePut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLivePutAll() throws Exception { IgniteCache cache = jcache(0); @@ -260,6 +261,7 @@ public void testDefaultTimeToLivePutAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultTimeToLivePreload() throws Exception { if (cacheMode() == LOCAL) return; @@ -285,6 +287,7 @@ public void testDefaultTimeToLivePreload() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTimeToLiveTtl() throws Exception { long time = DEFAULT_TIME_TO_LIVE + 2000; @@ -360,4 +363,4 @@ private void checkSizeAfterLive(int gridCnt) throws Exception { assertNull(cache.localPeek(key)); } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java index 8ce334ee0a44e..593952f8e5349 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/ClientConnectorConfigurationValidationSelfTest.java @@ -40,11 +40,15 @@ import java.sql.Statement; import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Client connector configuration validation tests. */ @SuppressWarnings("deprecation") +@RunWith(JUnit4.class) public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAbstractTest { /** Node index generator. */ private static final AtomicInteger NODE_IDX_GEN = new AtomicInteger(); @@ -62,6 +66,7 @@ public class ClientConnectorConfigurationValidationSelfTest extends GridCommonAb * * @throws Exception If failed. */ + @Test public void testDefault() throws Exception { check(new ClientConnectorConfiguration(), true); checkJdbc(null, ClientConnectorConfiguration.DFLT_PORT); @@ -72,6 +77,7 @@ public void testDefault() throws Exception { * * @throws Exception If failed. */ + @Test public void testHost() throws Exception { check(new ClientConnectorConfiguration().setHost("126.0.0.1"), false); @@ -88,6 +94,7 @@ public void testHost() throws Exception { * * @throws Exception If failed. */ + @Test public void testPort() throws Exception { check(new ClientConnectorConfiguration().setPort(-1), false); check(new ClientConnectorConfiguration().setPort(0), false); @@ -107,6 +114,7 @@ public void testPort() throws Exception { * * @throws Exception If failed. */ + @Test public void testPortRange() throws Exception { check(new ClientConnectorConfiguration().setPortRange(-1), false); @@ -122,6 +130,7 @@ public void testPortRange() throws Exception { * * @throws Exception If failed. */ + @Test public void testSocketBuffers() throws Exception { check(new ClientConnectorConfiguration().setSocketSendBufferSize(-4 * 1024), false); check(new ClientConnectorConfiguration().setSocketReceiveBufferSize(-4 * 1024), false); @@ -138,6 +147,7 @@ public void testSocketBuffers() throws Exception { * * @throws Exception If failed. */ + @Test public void testMaxOpenCusrorsPerConnection() throws Exception { check(new ClientConnectorConfiguration().setMaxOpenCursorsPerConnection(-1), false); @@ -153,6 +163,7 @@ public void testMaxOpenCusrorsPerConnection() throws Exception { * * @throws Exception If failed. */ + @Test public void testThreadPoolSize() throws Exception { check(new ClientConnectorConfiguration().setThreadPoolSize(0), false); check(new ClientConnectorConfiguration().setThreadPoolSize(-1), false); @@ -166,6 +177,7 @@ public void testThreadPoolSize() throws Exception { * * @throws Exception If failed. */ + @Test public void testOdbcConnectorConversion() throws Exception { int port = ClientConnectorConfiguration.DFLT_PORT - 1; @@ -183,6 +195,7 @@ public void testOdbcConnectorConversion() throws Exception { * * @throws Exception If failed. */ + @Test public void testSqlConnectorConversion() throws Exception { int port = ClientConnectorConfiguration.DFLT_PORT - 1; @@ -200,6 +213,7 @@ public void testSqlConnectorConversion() throws Exception { * * @throws Exception If failed. */ + @Test public void testIgnoreOdbcWhenSqlSet() throws Exception { int port = ClientConnectorConfiguration.DFLT_PORT - 1; @@ -218,6 +232,7 @@ public void testIgnoreOdbcWhenSqlSet() throws Exception { * * @throws Exception If failed. */ + @Test public void testIgnoreOdbcAndSqlWhenClientSet() throws Exception { int cliPort = ClientConnectorConfiguration.DFLT_PORT - 1; int sqlPort = ClientConnectorConfiguration.DFLT_PORT - 2; @@ -239,6 +254,7 @@ public void testIgnoreOdbcAndSqlWhenClientSet() throws Exception { * * @throws Exception If failed. */ + @Test public void testIgnoreOdbcWhenClientSet() throws Exception { int cliPort = ClientConnectorConfiguration.DFLT_PORT - 1; int odbcPort = ClientConnectorConfiguration.DFLT_PORT - 2; @@ -258,6 +274,7 @@ public void testIgnoreOdbcWhenClientSet() throws Exception { * * @throws Exception If failed. */ + @Test public void testIgnoreSqlWhenClientSet() throws Exception { int cliPort = ClientConnectorConfiguration.DFLT_PORT - 1; int sqlPort = ClientConnectorConfiguration.DFLT_PORT - 2; @@ -277,7 +294,7 @@ public void testIgnoreSqlWhenClientSet() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testDisabled() throws Exception { IgniteConfiguration cfg = baseConfiguration(); @@ -299,6 +316,7 @@ public void testDisabled() throws Exception { * * @throws Exception If failed. */ + @Test public void testJdbcConnectionEnabled() throws Exception { IgniteConfiguration cfg = baseConfiguration(); @@ -317,7 +335,7 @@ public void testJdbcConnectionEnabled() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testJdbcConnectionDisabled() throws Exception { IgniteConfiguration cfg = baseConfiguration(); @@ -342,7 +360,7 @@ public void testJdbcConnectionDisabled() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testJdbcConnectionDisabledForDaemon() throws Exception { final IgniteConfiguration cfg = baseConfiguration().setDaemon(true); @@ -395,7 +413,6 @@ private IgniteConfiguration baseConfiguration() throws Exception { * @param cliConnCfg Client connector configuration. * @param success Success flag. * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") private void check(ClientConnectorConfiguration cliConnCfg, boolean success) throws Exception { final IgniteConfiguration cfg = baseConfiguration(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java index 1bfb02e192952..415c05b000d82 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java @@ -28,11 +28,15 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CachePeekMode.ALL; /** */ +@RunWith(JUnit4.class) public class IgniteDataStreamerTest extends GridCommonAbstractTest { public static final String CACHE_NAME = "UUID_CACHE"; @@ -83,6 +87,7 @@ private CacheConfiguration cacheConfiguration(Class key, Class CacheConfiguration cacheConfig(String name, boolean partitioned, Class... idxTypes) { @@ -31,6 +35,7 @@ public class IgniteCacheGroupsSqlSegmentedIndexSelfTest extends IgniteSqlSegment /** * @throws Exception If failed. */ + @Test @Override public void testSegmentedPartitionedWithReplicated() throws Exception { log.info("Test is ignored"); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCachelessQueriesSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCachelessQueriesSelfTest.java index a7dae9e849421..15c33322dc054 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCachelessQueriesSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteCachelessQueriesSelfTest.java @@ -31,18 +31,16 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery; import org.apache.ignite.internal.processors.query.h2.H2TwoStepCachedQuery; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for behavior in various cases of local and distributed queries. */ +@RunWith(JUnit4.class) public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private final static String SELECT = "select count(*) from \"pers\".Person p, \"org\".Organization o where p.orgId = o._key"; @@ -63,12 +61,6 @@ public class IgniteCachelessQueriesSelfTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -109,6 +101,7 @@ protected CacheConfiguration cacheConfig(String name, TestCacheMode /** * */ + @Test public void testDistributedQueryOnPartitionedCaches() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.PARTITIONED, false, false); @@ -118,6 +111,7 @@ public void testDistributedQueryOnPartitionedCaches() { /** * */ + @Test public void testDistributedQueryOnPartitionedAndReplicatedCache() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.REPLICATED, false, false); @@ -127,15 +121,17 @@ public void testDistributedQueryOnPartitionedAndReplicatedCache() { /** * */ + @Test public void testDistributedQueryOnReplicatedCaches() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.REPLICATED, false, false); - assertDistributedQuery(); + assertLocalQuery(); } /** * */ + @Test public void testDistributedQueryOnSegmentedCaches() { createCachesAndExecuteQuery(TestCacheMode.SEGMENTED, TestCacheMode.SEGMENTED, false, false); @@ -145,6 +141,7 @@ public void testDistributedQueryOnSegmentedCaches() { /** * */ + @Test public void testDistributedQueryOnReplicatedAndSegmentedCache() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.SEGMENTED, false, false); @@ -154,6 +151,7 @@ public void testDistributedQueryOnReplicatedAndSegmentedCache() { /** * */ + @Test public void testDistributedQueryOnPartitionedCachesWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.PARTITIONED, true, false); @@ -163,6 +161,7 @@ public void testDistributedQueryOnPartitionedCachesWithReplicatedFlag() { /** * */ + @Test public void testDistributedQueryOnPartitionedAndReplicatedCacheWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.REPLICATED, true, false); @@ -172,6 +171,7 @@ public void testDistributedQueryOnPartitionedAndReplicatedCacheWithReplicatedFla /** * */ + @Test public void testLocalQueryOnReplicatedCachesWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.REPLICATED, true, false); @@ -181,6 +181,7 @@ public void testLocalQueryOnReplicatedCachesWithReplicatedFlag() { /** * */ + @Test public void testDistributedQueryOnSegmentedCachesWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.SEGMENTED, TestCacheMode.SEGMENTED, true, false); @@ -190,6 +191,7 @@ public void testDistributedQueryOnSegmentedCachesWithReplicatedFlag() { /** * */ + @Test public void testDistributedQueryOnReplicatedAndSegmentedCacheWithReplicatedFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.SEGMENTED, true, false); @@ -199,6 +201,7 @@ public void testDistributedQueryOnReplicatedAndSegmentedCacheWithReplicatedFlag( /** * */ + @Test public void testLocalQueryOnPartitionedCachesWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.PARTITIONED, false, true); @@ -208,6 +211,7 @@ public void testLocalQueryOnPartitionedCachesWithLocalFlag() { /** * */ + @Test public void testLocalQueryOnPartitionedAndReplicatedCacheWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.REPLICATED, false, true); @@ -217,6 +221,7 @@ public void testLocalQueryOnPartitionedAndReplicatedCacheWithLocalFlag() { /** * */ + @Test public void testLocalQueryOnReplicatedCachesWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.REPLICATED, false, true); @@ -226,6 +231,7 @@ public void testLocalQueryOnReplicatedCachesWithLocalFlag() { /** * */ + @Test public void testLocalTwoStepQueryOnSegmentedCachesWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.SEGMENTED, TestCacheMode.SEGMENTED, false, true); @@ -235,6 +241,7 @@ public void testLocalTwoStepQueryOnSegmentedCachesWithLocalFlag() { /** * */ + @Test public void testLocalTwoStepQueryOnReplicatedAndSegmentedCacheWithLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.SEGMENTED, false, true); @@ -244,6 +251,7 @@ public void testLocalTwoStepQueryOnReplicatedAndSegmentedCacheWithLocalFlag() { /** * */ + @Test public void testLocalQueryOnPartitionedCachesWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.PARTITIONED, false, true); @@ -253,6 +261,7 @@ public void testLocalQueryOnPartitionedCachesWithReplicatedAndLocalFlag() { /** * */ + @Test public void testLocalQueryOnPartitionedAndReplicatedCacheWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.PARTITIONED, TestCacheMode.REPLICATED, true, true); @@ -262,6 +271,7 @@ public void testLocalQueryOnPartitionedAndReplicatedCacheWithReplicatedAndLocalF /** * */ + @Test public void testLocalQueryOnReplicatedCachesWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.REPLICATED, true, true); @@ -271,6 +281,7 @@ public void testLocalQueryOnReplicatedCachesWithReplicatedAndLocalFlag() { /** * */ + @Test public void testLocalTwoStepQueryOnSegmentedCachesWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.SEGMENTED, TestCacheMode.SEGMENTED, true, true); @@ -280,6 +291,7 @@ public void testLocalTwoStepQueryOnSegmentedCachesWithReplicatedAndLocalFlag() { /** * */ + @Test public void testLocalTwoStepQueryOnReplicatedAndSegmentedCacheWithReplicatedAndLocalFlag() { createCachesAndExecuteQuery(TestCacheMode.REPLICATED, TestCacheMode.SEGMENTED, true, true); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java index b2f4e47ec2048..884ab77ac3a87 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteQueryDedicatedPoolTest.java @@ -40,20 +40,19 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.spi.IgniteSpiAdapter; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.indexing.IndexingQueryFilter; import org.apache.ignite.spi.indexing.IndexingSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Ensures that SQL queries are executed in a dedicated thread pool. */ +@RunWith(JUnit4.class) public class IgniteQueryDedicatedPoolTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Name of the cache for test */ private static final String CACHE_NAME = "query_pool_test"; @@ -68,10 +67,6 @@ public class IgniteQueryDedicatedPoolTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setIndexedTypes(Integer.class, Integer.class); @@ -101,6 +96,7 @@ public class IgniteQueryDedicatedPoolTest extends GridCommonAbstractTest { * @throws Exception If failed. * @see GridCacheTwoStepQuery#isLocal() */ + @Test public void testSqlQueryUsesDedicatedThreadPool() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME); @@ -129,6 +125,7 @@ public void testSqlQueryUsesDedicatedThreadPool() throws Exception { * Tests that Scan queries are executed in dedicated pool * @throws Exception If failed. */ + @Test public void testScanQueryUsesDedicatedThreadPool() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME); @@ -152,6 +149,7 @@ public void testScanQueryUsesDedicatedThreadPool() throws Exception { * Tests that SPI queries are executed in dedicated pool * @throws Exception If failed. */ + @Test public void testSpiQueryUsesDedicatedThreadPool() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlCreateTableTemplateTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlCreateTableTemplateTest.java new file mode 100644 index 0000000000000..ba0ef38560089 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlCreateTableTemplateTest.java @@ -0,0 +1,159 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.query; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.binary.BinaryObjectBuilder; +import org.apache.ignite.cache.affinity.AffinityKeyMapper; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Ensures that SQL queries work for tables created dynamically based on a template. + */ +public class IgniteSqlCreateTableTemplateTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override public IgniteConfiguration getConfiguration(String name) throws Exception { + IgniteConfiguration configuration = new IgniteConfiguration(); + configuration.setIgniteInstanceName(name); + + CacheConfiguration defaultCacheConfiguration = new CacheConfiguration(); + + defaultCacheConfiguration.setName("DEFAULT_TEMPLATE*"); + + CacheConfiguration customCacheConfiguration = new CacheConfiguration(); + + customCacheConfiguration.setName("CUSTOM_TEMPLATE*"); + + MockAffinityKeyMapper customAffinityMapper = new MockAffinityKeyMapper(); + + customCacheConfiguration.setAffinityMapper(customAffinityMapper); + + configuration.setCacheConfiguration(defaultCacheConfiguration, customCacheConfiguration); + + return configuration; + } + + /** {@inheritDoc} */ + @SuppressWarnings("deprecation") + @Override protected void beforeTestsStarted() throws Exception { + startGrid(); + } + + /** + * Tests select statement works on a table with BinaryObject as a primary key. + */ + @Test + public void testSelectForTableWithDataInsertedWithKeyValueAPI() { + Ignite ignite = grid(); + IgniteCache cache = ignite.getOrCreateCache("test"); + + createTable(cache, "PERSON", "DEFAULT_TEMPLATE"); + + createTable(cache, "ORGANIZATION", "DEFAULT_TEMPLATE"); + + BinaryObjectBuilder keyBuilder = ignite.binary().builder("PERSON_KEY"); + + keyBuilder.setField("ID", 1); + keyBuilder.setField("AFF_PERSON", 2); + + BinaryObjectBuilder valueBuilder = ignite.binary().builder("PERSON_VALUE"); + valueBuilder.setField("NAME", "test"); + + ignite.cache("PERSON_CACHE").withKeepBinary().put(keyBuilder.build(), valueBuilder.build()); + + keyBuilder = ignite.binary().builder("ORGANIZATION_KEY"); + + keyBuilder.setField("ID", 1); + keyBuilder.setField("AFF_ORGANIZATION", 2); + + valueBuilder = ignite.binary().builder("ORGANIZATION_VALUE"); + + valueBuilder.setField("NAME", "test"); + + ignite.cache("ORGANIZATION_CACHE").withKeepBinary().put(keyBuilder.build(), valueBuilder.build()); + + assertEquals(1, ignite.cache("PERSON_CACHE").query( + new SqlFieldsQuery("Select NAME from PERSON where ID = 1")).getAll().size() + ); + + assertEquals(1, ignite.cache("PERSON_CACHE").query( + new SqlFieldsQuery("Select NAME from PERSON where AFF_PERSON = 2")).getAll().size() + ); + + assertEquals(1, ignite.cache("ORGANIZATION_CACHE").query( + new SqlFieldsQuery("Select NAME from ORGANIZATION where AFF_ORGANIZATION = 2")).getAll().size() + ); + + } + + /** + * Creates table based on a template. + * + * @param cache Cache. + */ + private void createTable(IgniteCache cache, String tableName, String template) { + String sql = String.format( + "CREATE TABLE IF NOT EXISTS %1$s(\n" + + " ID INT NOT NULL,\n" + + " AFF_%1$s INT NOT NULL,\n" + + " NAME VARCHAR2(100),\n" + + " PRIMARY KEY (ID, AFF_%1$s)\n" + + ") with \"TEMPLATE=%2$s,KEY_TYPE=%1$s_KEY, AFFINITY_KEY=AFF_%1$s, CACHE_NAME=%1$s_CACHE, " + + "VALUE_TYPE=%1$s_VALUE, ATOMICITY=TRANSACTIONAL\";", tableName, template); + + cache.query(new SqlFieldsQuery(sql).setSchema("PUBLIC")); + } + + /** + * When template has custom affinity mapper. + * then cache created via CREATE TABLE command should have the same affinity mapper. + */ + @SuppressWarnings("unchecked") + @Test + public void testCustomAffinityKeyMapperIsNotOverwritten() { + Ignite ignite = grid(); + + IgniteCache cache = ignite.getOrCreateCache("test"); + + createTable(cache, "CUSTOM", "CUSTOM_TEMPLATE"); + + assertTrue(ignite.getOrCreateCache("CUSTOM_CACHE").getConfiguration( + CacheConfiguration.class).getAffinityMapper() instanceof MockAffinityKeyMapper); + } + + /** + * Mock affinity mapper implementation. + */ + @SuppressWarnings("deprecation") + private static class MockAffinityKeyMapper implements AffinityKeyMapper { + /** {@inheritDoc} */ + @Override public Object affinityKey(Object key) { + return null; + } + + /** {@inheritDoc} */ + @Override public void reset() { + // no-op + } + } +} \ No newline at end of file diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDefaultValueTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDefaultValueTest.java index f4c05397960e4..4da1940661725 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDefaultValueTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDefaultValueTest.java @@ -29,16 +29,16 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ @SuppressWarnings("ThrowableNotThrown") +@RunWith(JUnit4.class) public class IgniteSqlDefaultValueTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Name of client node. */ private static final String NODE_CLIENT = "client"; @@ -49,12 +49,7 @@ public class IgniteSqlDefaultValueTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration c = super.getConfiguration(gridName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - disco.setForceServerMode(true); - - c.setDiscoverySpi(disco); + ((TcpDiscoverySpi)c.getDiscoverySpi()).setForceServerMode(true); if (gridName.equals(NODE_CLIENT)) c.setClientMode(true); @@ -88,6 +83,7 @@ public class IgniteSqlDefaultValueTest extends GridCommonAbstractTest { /** */ + @Test public void testDefaultValueColumn() { sql("CREATE TABLE TEST (id int, val0 varchar DEFAULT 'default-val', primary key (id))"); sql("INSERT INTO TEST (id) VALUES (?)", 1); @@ -107,6 +103,7 @@ public void testDefaultValueColumn() { /** */ + @Test public void testDefaultValueColumnAfterUpdate() { sql("CREATE TABLE TEST (id int, val0 varchar DEFAULT 'default-val', val1 varchar, primary key (id))"); sql("INSERT INTO TEST (id, val1) VALUES (?, ?)", 1, "val-10"); @@ -138,6 +135,7 @@ public void testDefaultValueColumnAfterUpdate() { /** */ + @Test public void testEmptyValueNullDefaults() { sql("CREATE TABLE TEST (id int, val0 varchar, primary key (id))"); sql("INSERT INTO TEST (id) VALUES (?)", 1); @@ -155,6 +153,7 @@ public void testEmptyValueNullDefaults() { /** */ + @Test public void testAddColumnWithDefaults() { sql("CREATE TABLE TEST (id int, val0 varchar, primary key (id))"); @@ -169,6 +168,7 @@ public void testAddColumnWithDefaults() { /** */ + @Test public void testDefaultTypes() { assertEquals("Check tinyint", (byte)28, getDefaultObject("TINYINT", "28")); assertEquals("Check smallint", (short)28, getDefaultObject("SMALLINT", "28")); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDistributedJoinSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDistributedJoinSelfTest.java index 4b993eca16ec1..f3968ad49ff7a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDistributedJoinSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlDistributedJoinSelfTest.java @@ -25,18 +25,16 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for correct distributed sql joins. */ +@RunWith(JUnit4.class) public class IgniteSqlDistributedJoinSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final int NODES_COUNT = 2; @@ -52,12 +50,6 @@ public class IgniteSqlDistributedJoinSelfTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -84,6 +76,7 @@ protected CacheConfiguration cacheConfig(String name, boolean partitioned, Class /** * @throws Exception If failed. */ + @Test public void testNonCollocatedDistributedJoin() throws Exception { CacheConfiguration ccfg1 = cacheConfig("pers", true, String.class, Person.class); CacheConfiguration ccfg2 = cacheConfig("org", true, String.class, Organization.class); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlEntryCacheModeAgnosticTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlEntryCacheModeAgnosticTest.java index db7ca399d7d65..e87e72345dbe7 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlEntryCacheModeAgnosticTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlEntryCacheModeAgnosticTest.java @@ -23,12 +23,12 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.LOCAL; @@ -38,10 +38,8 @@ /** * Test different cache modes for query entry */ +@RunWith(JUnit4.class) public class IgniteSqlEntryCacheModeAgnosticTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Host. */ public static final String HOST = "127.0.0.1"; @@ -60,12 +58,6 @@ public class IgniteSqlEntryCacheModeAgnosticTest extends GridCommonAbstractTest c.setLocalHost(HOST); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - c.setCacheConfiguration(cacheConfiguration(LOCAL_CACHE_NAME), cacheConfiguration(REPLICATED_CACHE_NAME), cacheConfiguration(PARTITIONED_CACHE_NAME)); @@ -116,6 +108,7 @@ private CacheConfiguration cacheConfiguration(String cacheName) throws Exception /** * It should not matter what cache mode does entry cache use, if there is no join */ + @Test public void testCrossCacheModeQuery() throws Exception { Ignite ignite = startGrid(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatCollocatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatCollocatedTest.java index 05d29bfe65b66..36250e9044ecc 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatCollocatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatCollocatedTest.java @@ -30,15 +30,16 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for GROUP_CONCAT aggregate function in collocated mode. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteSqlGroupConcatCollocatedTest extends GridCommonAbstractTest { /** */ private static final int CLIENT = 7; @@ -49,19 +50,10 @@ public class IgniteSqlGroupConcatCollocatedTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "cache"; - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration( new CacheConfiguration(CACHE_NAME) .setAffinity(new RendezvousAffinityFunction().setPartitions(8)) @@ -115,6 +107,7 @@ public class IgniteSqlGroupConcatCollocatedTest extends GridCommonAbstractTest { /** * */ + @Test public void testGroupConcatSimple() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); @@ -139,6 +132,7 @@ public void testGroupConcatSimple() { /** * */ + @Test public void testGroupConcatOrderBy() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); @@ -164,6 +158,7 @@ public void testGroupConcatOrderBy() { /** * */ + @Test public void testGroupConcatWithDistinct() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatNotCollocatedTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatNotCollocatedTest.java index fbd38f7aeabfc..af40c763929a0 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatNotCollocatedTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlGroupConcatNotCollocatedTest.java @@ -28,16 +28,17 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for GROUP_CONCAT aggregate function in not collocated mode. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteSqlGroupConcatNotCollocatedTest extends GridCommonAbstractTest { /** */ private static final int CLIENT = 7; @@ -45,19 +46,10 @@ public class IgniteSqlGroupConcatNotCollocatedTest extends GridCommonAbstractTes /** */ private static final String CACHE_NAME = "cache"; - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - cfg.setCacheConfiguration( new CacheConfiguration(CACHE_NAME) .setAffinity(new RendezvousAffinityFunction().setPartitions(8)) @@ -99,6 +91,7 @@ public class IgniteSqlGroupConcatNotCollocatedTest extends GridCommonAbstractTes /** * */ + @Test public void testGroupConcatSimple() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); @@ -122,6 +115,7 @@ public void testGroupConcatSimple() { /** * */ + @Test public void testGroupConcatCountDistinct() { IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); @@ -145,6 +139,7 @@ public void testGroupConcatCountDistinct() { /** * */ + @Test public void testGroupConcatDistributedException() { final IgniteCache c = ignite(CLIENT).cache(CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlKeyValueFieldsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlKeyValueFieldsTest.java index d63be7cf3624c..36a1cc0137341 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlKeyValueFieldsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlKeyValueFieldsTest.java @@ -1,392 +1,392 @@ -/* - * 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. - */ - -package org.apache.ignite.internal.processors.query; - -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.cache.QueryEntity; -import org.apache.ignite.cache.QueryIndex; -import org.apache.ignite.cache.query.QueryCursor; -import org.apache.ignite.cache.query.SqlFieldsQuery; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.concurrent.Callable; - -/** - * Test hidden _key, _val, _ver columns - */ -public class IgniteSqlKeyValueFieldsTest extends GridCommonAbstractTest { - - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static String NODE_BAD_CONF_MISS_KEY_FIELD = "badConf1"; - /** */ - private static String NODE_BAD_CONF_MISS_VAL_FIELD = "badConf2"; - /** */ - private static String NODE_CLIENT = "client"; - - /** */ - private static String CACHE_PERSON_NO_KV = "PersonNoKV"; - /** */ - private static String CACHE_INT_NO_KV_TYPE = "IntNoKVType"; - /** */ - private static String CACHE_PERSON = "Person"; - /** */ - private static String CACHE_JOB = "Job"; - - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration c = super.getConfiguration(gridName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - - c.setMarshaller(new BinaryMarshaller()); - - List ccfgs = new ArrayList<>(); - CacheConfiguration ccfg = buildCacheConfiguration(gridName); - if (ccfg != null) - ccfgs.add(ccfg); - - ccfgs.add(buildCacheConfiguration(CACHE_PERSON_NO_KV)); - ccfgs.add(buildCacheConfiguration(CACHE_INT_NO_KV_TYPE)); - ccfgs.add(buildCacheConfiguration(CACHE_PERSON)); - ccfgs.add(buildCacheConfiguration(CACHE_JOB)); - - c.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()])); - if (gridName.equals(NODE_CLIENT)) - c.setClientMode(true); - - return c; - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - super.beforeTest(); - - startGrid(0); - startGrid(NODE_CLIENT); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); - - stopAllGrids(); - } - - private CacheConfiguration buildCacheConfiguration(String name) { - if (name.equals(NODE_BAD_CONF_MISS_KEY_FIELD)) { - CacheConfiguration ccfg = new CacheConfiguration(NODE_BAD_CONF_MISS_KEY_FIELD); - QueryEntity qe = new QueryEntity(Object.class.getName(), Object.class.getName()); - qe.setKeyFieldName("k"); - qe.addQueryField("a", Integer.class.getName(), null); - ccfg.setQueryEntities(F.asList(qe)); - return ccfg; - } - else if (name.equals(NODE_BAD_CONF_MISS_VAL_FIELD)) { - CacheConfiguration ccfg = new CacheConfiguration(NODE_BAD_CONF_MISS_VAL_FIELD); - QueryEntity qe = new QueryEntity(Object.class.getName(), Object.class.getName()); - qe.setValueFieldName("v"); - qe.addQueryField("a", Integer.class.getName(), null); - ccfg.setQueryEntities(F.asList(qe)); - return ccfg; - } - else if (name.equals(CACHE_PERSON_NO_KV)) { - CacheConfiguration ccfg = new CacheConfiguration(CACHE_PERSON_NO_KV); - - QueryEntity entity = new QueryEntity(); - - entity.setKeyType(Integer.class.getName()); - entity.setValueType(Person.class.getName()); - - LinkedHashMap fields = new LinkedHashMap<>(); - fields.put("name", String.class.getName()); - fields.put("age", Integer.class.getName()); - - entity.setFields(fields); - - ccfg.setQueryEntities(Arrays.asList(entity)); - return ccfg; - } - else if (name.equals(CACHE_INT_NO_KV_TYPE)) { - CacheConfiguration ccfg = new CacheConfiguration(CACHE_INT_NO_KV_TYPE); - QueryEntity entity = new QueryEntity(); - - entity.setKeyType(null); - entity.setValueType(null); - - entity.setKeyFieldName("id"); - entity.setValueFieldName("v"); - - LinkedHashMap fields = new LinkedHashMap<>(); - fields.put("id", Integer.class.getName()); - fields.put("v", Integer.class.getName()); - - entity.setFields(fields); - - ccfg.setQueryEntities(Arrays.asList(entity)); - return ccfg; - } - else if (name.equals(CACHE_PERSON)) { - CacheConfiguration ccfg = new CacheConfiguration(CACHE_PERSON); - - QueryEntity entity = new QueryEntity(); - - entity.setKeyType(Integer.class.getName()); - entity.setValueType(Person.class.getName()); - - entity.setKeyFieldName("id"); - entity.setValueFieldName("v"); - - LinkedHashMap fields = new LinkedHashMap<>(); - fields.put("name", String.class.getName()); - fields.put("age", Integer.class.getName()); - - fields.put(entity.getKeyFieldName(), entity.getKeyType()); - fields.put(entity.getValueFieldName(), entity.getValueType()); - - entity.setFields(fields); - - ccfg.setQueryEntities(Arrays.asList(entity)); - return ccfg; - } - else if (name.equals(CACHE_JOB)) { - CacheConfiguration ccfg = new CacheConfiguration(CACHE_JOB); - ccfg.setIndexedTypes(Integer.class, Integer.class); - return ccfg; - } - return null; - } - - /** Test for setIndexedTypes() primitive types */ - public void testSetIndexTypesPrimitive() throws Exception { - IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_JOB); - - checkInsert(cache, "insert into Integer (_key, _val) values (?,?)", 1, 100); - - checkSelect(cache, "select * from Integer", 1, 100); - checkSelect(cache, "select _key, _val from Integer", 1, 100); - } - - /** Test configuration error : keyFieldName is missing from fields */ - public void testErrorKeyFieldMissingFromFields() throws Exception { - checkCacheStartupError(NODE_BAD_CONF_MISS_KEY_FIELD); - } - - /** Test configuration error : valueFieldName is missing from fields */ - public void testErrorValueFieldMissingFromFields() throws Exception { - checkCacheStartupError(NODE_BAD_CONF_MISS_VAL_FIELD); - } - - /** */ - private void checkCacheStartupError(final String name) { - GridTestUtils.assertThrows(log, new Callable() { - @Override public Void call() throws Exception { - startGrid(name); - - return null; - } - }, IgniteCheckedException.class, null); - } - - /** - * Check that it is allowed to leave QE.keyType and QE.valueType unset - * in case keyFieldName and valueFieldName are set and present in fields - */ - public void testQueryEntityAutoKeyValTypes() throws Exception { - IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_INT_NO_KV_TYPE); - - checkInsert(cache, "insert into Integer (_key, _val) values (?,?)", 1, 100); - - checkSelect(cache, "select * from Integer where id = 1", 1, 100); - - checkSelect(cache, "select * from Integer", 1, 100); - checkSelect(cache, "select _key, _val from Integer", 1, 100); - checkSelect(cache, "select id, v from Integer", 1, 100); - } - - /** Check that it is possible to not have keyFieldName and valueFieldName */ - public void testNoKeyValueAliases() throws Exception { - IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_PERSON_NO_KV); - - Person alice = new Person("Alice", 1); - checkInsert(cache, "insert into Person (_key, _val) values (?,?)", 1, alice); - - checkSelect(cache, "select * from Person", alice.name, alice.age); - checkSelect(cache, "select _key, _val from Person", 1, alice); - } - - /** Check keyFieldName and valueFieldName columns access */ - public void testKeyValueAlias() throws Exception { - //_key, _val, _ver | name, age, id, v - Person alice = new Person("Alice", 1); - Person bob = new Person("Bob", 2); - - IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_PERSON); - - checkInsert(cache, "insert into Person (_key, _val) values (?,?)", 1, alice); - checkInsert(cache, "insert into Person (id, v) values (?,?)", 2, bob); - - checkSelect(cache, "select * from Person where _key=1", alice.name, alice.age, 1, alice); - checkSelect(cache, "select _key, _val from Person where id=1", 1, alice); - - checkSelect(cache, "select * from Person where _key=2", bob.name, bob.age, 2, bob); - checkSelect(cache, "select _key, _val from Person where id=2", 2, bob); - - checkInsert(cache, "update Person set age = ? where id = ?", 3, 1); - checkSelect(cache, "select _key, age from Person where id=1", 1, 3); - - checkInsert(cache, "update Person set v = ? where id = ?", alice, 1); - checkSelect(cache, "select _key, _val from Person where id=1", 1, alice); - } - - /** Check _ver version field is accessible */ - public void testVersionField() throws Exception { - Person alice = new Person("Alice", 1); - Person bob = new Person("Bob", 2); - - IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_PERSON); - - checkInsert(cache, "insert into Person (id, v) values (?,?)", 1, alice); - assertNotNull(getVersion(cache, 1)); - - checkInsert(cache, "insert into Person (id, v) values (?,?)", 2, bob); - assertNotNull(getVersion(cache, 2)); - - GridCacheVersion v1 = getVersion(cache, 1); - - checkInsert(cache, "update Person set age = ? where id = ?", 3, 1); - - GridCacheVersion v2 = getVersion(cache, 1); - - assertFalse( v1.equals(v2) ); - } - - /** Check that joins are working on keyFieldName, valueFieldName columns */ - public void testJoinKeyValFields() throws Exception { - IgniteEx client = grid(NODE_CLIENT); - IgniteCache cache = client.cache(CACHE_PERSON); - IgniteCache cache2 = client.cache(CACHE_JOB); - - checkInsert(cache, "insert into Person (id, v) values (?, ?)", 1, new Person("Bob", 30)); - checkInsert(cache, "insert into Person (id, v) values (?, ?)", 2, new Person("David", 35)); - checkInsert(cache2, "insert into Integer (_key, _val) values (?, ?)", 100, 1); - checkInsert(cache2, "insert into Integer (_key, _val) values (?, ?)", 200, 2); - - QueryCursor> cursor = cache.query(new SqlFieldsQuery("select p.id, j._key from Person p, \""+ CACHE_JOB +"\".Integer j where p.id = j._val")); - List> results = cursor.getAll(); - assertEquals(2, results.size()); - assertEquals(1, results.get(0).get(0)); - assertEquals(100, results.get(0).get(1)); - assertEquals(2, results.get(1).get(0)); - assertEquals(200, results.get(1).get(1)); - } - - /** Check automatic addition of index for keyFieldName column */ - public void testAutoKeyFieldIndex() throws Exception { - IgniteEx client = grid(NODE_CLIENT); - IgniteCache cache = client.cache(CACHE_PERSON); - - QueryCursor> cursor = cache.query(new SqlFieldsQuery("explain select * from Person where id = 1")); - List> results = cursor.getAll(); - assertEquals(2, results.size()); - assertTrue(((String)results.get(0).get(0)).contains("\"_key_PK_proxy\"")); - - cursor = cache.query(new SqlFieldsQuery("explain select * from Person where _key = 1")); - results = cursor.getAll(); - assertEquals(2, results.size()); - assertTrue(((String)results.get(0).get(0)).contains("\"_key_PK\"")); - } - - /** */ - private GridCacheVersion getVersion(IgniteCache cache, int key) { - QueryCursor> cursor = cache.query(new SqlFieldsQuery("select _ver from Person where id = ?").setArgs(key)); - List> results = cursor.getAll(); - assertEquals(1, results.size()); - return ((GridCacheVersion) results.get(0).get(0)); - } - - /** */ - private void checkInsert(IgniteCache cache, String qry, Object ... args) throws Exception { - QueryCursor> cursor = cache.query(new SqlFieldsQuery(qry).setArgs(args)); - assertEquals(1, ((Number) cursor.getAll().get(0).get(0)).intValue()); - } - - /** */ - private void checkSelect(IgniteCache cache, String selectQry, Object ... expected) { - QueryCursor> cursor = cache.query(new SqlFieldsQuery(selectQry)); - - List> results = cursor.getAll(); - - assertEquals(1, results.size()); - - List row0 = results.get(0); - for(int col = 0; col < expected.length; ++col) - assertEquals(expected[col], row0.get(col)); - } - - /** */ - private static class Person { - /** */ - private String name; - - /** */ - private int age; - - /** */ - public Person(String name, int age) { - this.name = name; - this.age = age; - } - - /** */ - @Override public int hashCode() { - return name.hashCode() ^ age; - } - - /** */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - if (!(o instanceof Person)) - return false; - Person other = (Person)o; - return name.equals(other.name) && age == other.age; - } - } -} +/* + * 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. + */ + +package org.apache.ignite.internal.processors.query; + +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.concurrent.Callable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Test hidden _key, _val, _ver columns + */ +@RunWith(JUnit4.class) +public class IgniteSqlKeyValueFieldsTest extends GridCommonAbstractTest { + /** */ + private static String NODE_BAD_CONF_MISS_KEY_FIELD = "badConf1"; + /** */ + private static String NODE_BAD_CONF_MISS_VAL_FIELD = "badConf2"; + /** */ + private static String NODE_CLIENT = "client"; + + /** */ + private static String CACHE_PERSON_NO_KV = "PersonNoKV"; + /** */ + private static String CACHE_INT_NO_KV_TYPE = "IntNoKVType"; + /** */ + private static String CACHE_PERSON = "Person"; + /** */ + private static String CACHE_JOB = "Job"; + + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration c = super.getConfiguration(gridName); + + c.setMarshaller(new BinaryMarshaller()); + + List ccfgs = new ArrayList<>(); + CacheConfiguration ccfg = buildCacheConfiguration(gridName); + if (ccfg != null) + ccfgs.add(ccfg); + + ccfgs.add(buildCacheConfiguration(CACHE_PERSON_NO_KV)); + ccfgs.add(buildCacheConfiguration(CACHE_INT_NO_KV_TYPE)); + ccfgs.add(buildCacheConfiguration(CACHE_PERSON)); + ccfgs.add(buildCacheConfiguration(CACHE_JOB)); + + c.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()])); + if (gridName.equals(NODE_CLIENT)) + c.setClientMode(true); + + return c; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + startGrid(0); + startGrid(NODE_CLIENT); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + private CacheConfiguration buildCacheConfiguration(String name) { + if (name.equals(NODE_BAD_CONF_MISS_KEY_FIELD)) { + CacheConfiguration ccfg = new CacheConfiguration(NODE_BAD_CONF_MISS_KEY_FIELD); + QueryEntity qe = new QueryEntity(Object.class.getName(), Object.class.getName()); + qe.setKeyFieldName("k"); + qe.addQueryField("a", Integer.class.getName(), null); + ccfg.setQueryEntities(F.asList(qe)); + return ccfg; + } + else if (name.equals(NODE_BAD_CONF_MISS_VAL_FIELD)) { + CacheConfiguration ccfg = new CacheConfiguration(NODE_BAD_CONF_MISS_VAL_FIELD); + QueryEntity qe = new QueryEntity(Object.class.getName(), Object.class.getName()); + qe.setValueFieldName("v"); + qe.addQueryField("a", Integer.class.getName(), null); + ccfg.setQueryEntities(F.asList(qe)); + return ccfg; + } + else if (name.equals(CACHE_PERSON_NO_KV)) { + CacheConfiguration ccfg = new CacheConfiguration(CACHE_PERSON_NO_KV); + + QueryEntity entity = new QueryEntity(); + + entity.setKeyType(Integer.class.getName()); + entity.setValueType(Person.class.getName()); + + LinkedHashMap fields = new LinkedHashMap<>(); + fields.put("name", String.class.getName()); + fields.put("age", Integer.class.getName()); + + entity.setFields(fields); + + ccfg.setQueryEntities(Arrays.asList(entity)); + return ccfg; + } + else if (name.equals(CACHE_INT_NO_KV_TYPE)) { + CacheConfiguration ccfg = new CacheConfiguration(CACHE_INT_NO_KV_TYPE); + QueryEntity entity = new QueryEntity(); + + entity.setKeyType(null); + entity.setValueType(null); + + entity.setKeyFieldName("id"); + entity.setValueFieldName("v"); + + LinkedHashMap fields = new LinkedHashMap<>(); + fields.put("id", Integer.class.getName()); + fields.put("v", Integer.class.getName()); + + entity.setFields(fields); + + ccfg.setQueryEntities(Arrays.asList(entity)); + return ccfg; + } + else if (name.equals(CACHE_PERSON)) { + CacheConfiguration ccfg = new CacheConfiguration(CACHE_PERSON); + + QueryEntity entity = new QueryEntity(); + + entity.setKeyType(Integer.class.getName()); + entity.setValueType(Person.class.getName()); + + entity.setKeyFieldName("id"); + entity.setValueFieldName("v"); + + LinkedHashMap fields = new LinkedHashMap<>(); + fields.put("name", String.class.getName()); + fields.put("age", Integer.class.getName()); + + fields.put(entity.getKeyFieldName(), entity.getKeyType()); + fields.put(entity.getValueFieldName(), entity.getValueType()); + + entity.setFields(fields); + + ccfg.setQueryEntities(Arrays.asList(entity)); + return ccfg; + } + else if (name.equals(CACHE_JOB)) { + CacheConfiguration ccfg = new CacheConfiguration(CACHE_JOB); + ccfg.setIndexedTypes(Integer.class, Integer.class); + return ccfg; + } + return null; + } + + /** Test for setIndexedTypes() primitive types */ + @Test + public void testSetIndexTypesPrimitive() throws Exception { + IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_JOB); + + checkInsert(cache, "insert into Integer (_key, _val) values (?,?)", 1, 100); + + checkSelect(cache, "select * from Integer", 1, 100); + checkSelect(cache, "select _key, _val from Integer", 1, 100); + } + + /** Test configuration error : keyFieldName is missing from fields */ + @Test + public void testErrorKeyFieldMissingFromFields() throws Exception { + checkCacheStartupError(NODE_BAD_CONF_MISS_KEY_FIELD); + } + + /** Test configuration error : valueFieldName is missing from fields */ + @Test + public void testErrorValueFieldMissingFromFields() throws Exception { + checkCacheStartupError(NODE_BAD_CONF_MISS_VAL_FIELD); + } + + /** */ + private void checkCacheStartupError(final String name) { + GridTestUtils.assertThrows(log, new Callable() { + @Override public Void call() throws Exception { + startGrid(name); + + return null; + } + }, IgniteCheckedException.class, null); + } + + /** + * Check that it is allowed to leave QE.keyType and QE.valueType unset + * in case keyFieldName and valueFieldName are set and present in fields + */ + @Test + public void testQueryEntityAutoKeyValTypes() throws Exception { + IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_INT_NO_KV_TYPE); + + checkInsert(cache, "insert into Integer (_key, _val) values (?,?)", 1, 100); + + checkSelect(cache, "select * from Integer where id = 1", 1, 100); + + checkSelect(cache, "select * from Integer", 1, 100); + checkSelect(cache, "select _key, _val from Integer", 1, 100); + checkSelect(cache, "select id, v from Integer", 1, 100); + } + + /** Check that it is possible to not have keyFieldName and valueFieldName */ + @Test + public void testNoKeyValueAliases() throws Exception { + IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_PERSON_NO_KV); + + Person alice = new Person("Alice", 1); + checkInsert(cache, "insert into Person (_key, _val) values (?,?)", 1, alice); + + checkSelect(cache, "select * from Person", alice.name, alice.age); + checkSelect(cache, "select _key, _val from Person", 1, alice); + } + + /** Check keyFieldName and valueFieldName columns access */ + @Test + public void testKeyValueAlias() throws Exception { + //_key, _val, _ver | name, age, id, v + Person alice = new Person("Alice", 1); + Person bob = new Person("Bob", 2); + + IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_PERSON); + + checkInsert(cache, "insert into Person (_key, _val) values (?,?)", 1, alice); + checkInsert(cache, "insert into Person (id, v) values (?,?)", 2, bob); + + checkSelect(cache, "select * from Person where _key=1", alice.name, alice.age, 1, alice); + checkSelect(cache, "select _key, _val from Person where id=1", 1, alice); + + checkSelect(cache, "select * from Person where _key=2", bob.name, bob.age, 2, bob); + checkSelect(cache, "select _key, _val from Person where id=2", 2, bob); + + checkInsert(cache, "update Person set age = ? where id = ?", 3, 1); + checkSelect(cache, "select _key, age from Person where id=1", 1, 3); + + checkInsert(cache, "update Person set v = ? where id = ?", alice, 1); + checkSelect(cache, "select _key, _val from Person where id=1", 1, alice); + } + + /** Check _ver version field is accessible */ + @Test + public void testVersionField() throws Exception { + Person alice = new Person("Alice", 1); + Person bob = new Person("Bob", 2); + + IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_PERSON); + + checkInsert(cache, "insert into Person (id, v) values (?,?)", 1, alice); + assertNotNull(getVersion(cache, 1)); + + checkInsert(cache, "insert into Person (id, v) values (?,?)", 2, bob); + assertNotNull(getVersion(cache, 2)); + + GridCacheVersion v1 = getVersion(cache, 1); + + checkInsert(cache, "update Person set age = ? where id = ?", 3, 1); + + GridCacheVersion v2 = getVersion(cache, 1); + + assertFalse( v1.equals(v2) ); + } + + /** Check that joins are working on keyFieldName, valueFieldName columns */ + @Test + public void testJoinKeyValFields() throws Exception { + IgniteEx client = grid(NODE_CLIENT); + IgniteCache cache = client.cache(CACHE_PERSON); + IgniteCache cache2 = client.cache(CACHE_JOB); + + checkInsert(cache, "insert into Person (id, v) values (?, ?)", 1, new Person("Bob", 30)); + checkInsert(cache, "insert into Person (id, v) values (?, ?)", 2, new Person("David", 35)); + checkInsert(cache2, "insert into Integer (_key, _val) values (?, ?)", 100, 1); + checkInsert(cache2, "insert into Integer (_key, _val) values (?, ?)", 200, 2); + + QueryCursor> cursor = cache.query(new SqlFieldsQuery("select p.id, j._key from Person p, \""+ CACHE_JOB +"\".Integer j where p.id = j._val")); + List> results = cursor.getAll(); + assertEquals(2, results.size()); + assertEquals(1, results.get(0).get(0)); + assertEquals(100, results.get(0).get(1)); + assertEquals(2, results.get(1).get(0)); + assertEquals(200, results.get(1).get(1)); + } + + /** Check automatic addition of index for keyFieldName column */ + @Test + public void testAutoKeyFieldIndex() throws Exception { + IgniteEx client = grid(NODE_CLIENT); + IgniteCache cache = client.cache(CACHE_PERSON); + + QueryCursor> cursor = cache.query(new SqlFieldsQuery("explain select * from Person where id = 1")); + List> results = cursor.getAll(); + assertEquals(2, results.size()); + assertTrue(((String)results.get(0).get(0)).contains("\"_key_PK_proxy\"")); + + cursor = cache.query(new SqlFieldsQuery("explain select * from Person where _key = 1")); + results = cursor.getAll(); + assertEquals(2, results.size()); + assertTrue(((String)results.get(0).get(0)).contains("\"_key_PK\"")); + } + + /** */ + private GridCacheVersion getVersion(IgniteCache cache, int key) { + QueryCursor> cursor = cache.query(new SqlFieldsQuery("select _ver from Person where id = ?").setArgs(key)); + List> results = cursor.getAll(); + assertEquals(1, results.size()); + return ((GridCacheVersion) results.get(0).get(0)); + } + + /** */ + private void checkInsert(IgniteCache cache, String qry, Object ... args) throws Exception { + QueryCursor> cursor = cache.query(new SqlFieldsQuery(qry).setArgs(args)); + assertEquals(1, ((Number) cursor.getAll().get(0).get(0)).intValue()); + } + + /** */ + private void checkSelect(IgniteCache cache, String selectQry, Object ... expected) { + QueryCursor> cursor = cache.query(new SqlFieldsQuery(selectQry)); + + List> results = cursor.getAll(); + + assertEquals(1, results.size()); + + List row0 = results.get(0); + for(int col = 0; col < expected.length; ++col) + assertEquals(expected[col], row0.get(col)); + } + + /** */ + private static class Person { + /** */ + private String name; + + /** */ + private int age; + + /** */ + public Person(String name, int age) { + this.name = name; + this.age = age; + } + + /** */ + @Override public int hashCode() { + return name.hashCode() ^ age; + } + + /** */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Person)) + return false; + Person other = (Person)o; + return name.equals(other.name) && age == other.age; + } + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java index 3a90c990927f0..33660b24c1df6 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlNotNullConstraintTest.java @@ -50,20 +50,19 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class IgniteSqlNotNullConstraintTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Name of client node. */ private static String NODE_CLIENT = "client"; @@ -112,13 +111,6 @@ public class IgniteSqlNotNullConstraintTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration c = super.getConfiguration(gridName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - disco.setForceServerMode(true); - - c.setDiscoverySpi(disco); - List ccfgs = new ArrayList<>(); ccfgs.addAll(cacheConfigurations()); @@ -250,6 +242,7 @@ private CacheConfiguration buildCacheConfigurationRestricted(String cacheName, b } /** */ + @Test public void testQueryEntityGetSetNotNullFields() throws Exception { QueryEntity qe = new QueryEntity(); @@ -267,6 +260,7 @@ public void testQueryEntityGetSetNotNullFields() throws Exception { } /** */ + @Test public void testQueryEntityEquals() throws Exception { QueryEntity a = new QueryEntity(); @@ -284,6 +278,7 @@ public void testQueryEntityEquals() throws Exception { } /** */ + @Test public void testAtomicOrImplicitTxPut() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -301,6 +296,7 @@ public void testAtomicOrImplicitTxPut() throws Exception { } /** */ + @Test public void testAtomicOrImplicitTxPutIfAbsent() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -318,6 +314,7 @@ public void testAtomicOrImplicitTxPutIfAbsent() throws Exception { } /** */ + @Test public void testAtomicOrImplicitTxGetAndPut() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -335,6 +332,7 @@ public void testAtomicOrImplicitTxGetAndPut() throws Exception { } /** */ + @Test public void testAtomicOrImplicitTxGetAndPutIfAbsent() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -352,6 +350,7 @@ public void testAtomicOrImplicitTxGetAndPutIfAbsent() throws Exception { } /** */ + @Test public void testAtomicOrImplicitTxReplace() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -370,6 +369,7 @@ public void testAtomicOrImplicitTxReplace() throws Exception { } /** */ + @Test public void testAtomicOrImplicitTxGetAndReplace() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -388,16 +388,19 @@ public void testAtomicOrImplicitTxGetAndReplace() throws Exception { } /** */ + @Test public void testAtomicOrImplicitTxPutAll() throws Exception { doAtomicOrImplicitTxPutAll(F.asMap(1, okValue, 5, badValue), 1); } /** */ + @Test public void testAtomicOrImplicitTxPutAllForSingleValue() throws Exception { doAtomicOrImplicitTxPutAll(F.asMap(5, badValue), 0); } /** */ + @Test public void testAtomicOrImplicitTxInvoke() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -413,6 +416,7 @@ public void testAtomicOrImplicitTxInvoke() throws Exception { } /** */ + @Test public void testAtomicOrImplicitTxInvokeAll() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -434,6 +438,7 @@ key1, new TestEntryProcessor(okValue), } /** */ + @Test public void testTxPutCreate() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -456,6 +461,7 @@ public void testTxPutCreate() throws Exception { } /** */ + @Test public void testTxPutUpdate() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -479,6 +485,7 @@ public void testTxPutUpdate() throws Exception { } /** */ + @Test public void testTxPutIfAbsent() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -500,6 +507,7 @@ public void testTxPutIfAbsent() throws Exception { } /** */ + @Test public void testTxGetAndPut() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -521,6 +529,7 @@ public void testTxGetAndPut() throws Exception { } /** */ + @Test public void testTxGetAndPutIfAbsent() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -542,6 +551,7 @@ public void testTxGetAndPutIfAbsent() throws Exception { } /** */ + @Test public void testTxReplace() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -566,6 +576,7 @@ public void testTxReplace() throws Exception { } /** */ + @Test public void testTxGetAndReplace() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -590,16 +601,19 @@ public void testTxGetAndReplace() throws Exception { } /** */ + @Test public void testTxPutAll() throws Exception { doTxPutAll(F.asMap(1, okValue, 5, badValue)); } /** */ + @Test public void testTxPutAllForSingleValue() throws Exception { doTxPutAll(F.asMap(5, badValue)); } /** */ + @Test public void testTxInvoke() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -624,6 +638,7 @@ public void testTxInvoke() throws Exception { } /** */ + @Test public void testTxInvokeAll() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -650,6 +665,7 @@ key1, new TestEntryProcessor(okValue), } /** */ + @Test public void testAtomicOrImplicitTxInvokeDelete() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -663,6 +679,7 @@ public void testAtomicOrImplicitTxInvokeDelete() throws Exception { } /** */ + @Test public void testAtomicOrImplicitTxInvokeAllDelete() throws Exception { executeWithAllCaches(new TestClosure() { @Override public void run() throws Exception { @@ -679,6 +696,7 @@ key1, new TestEntryProcessor(null), } /** */ + @Test public void testTxInvokeDelete() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -696,6 +714,7 @@ public void testTxInvokeDelete() throws Exception { } /** */ + @Test public void testTxInvokeAllDelete() throws Exception { executeWithAllTxCaches(new TestClosure() { @Override public void run() throws Exception { @@ -716,6 +735,7 @@ key1, new TestEntryProcessor(null), } /** */ + @Test public void testDynamicTableCreateNotNullFieldsAllowed() throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, field INT NOT NULL)"); @@ -733,6 +753,7 @@ public void testDynamicTableCreateNotNullFieldsAllowed() throws Exception { } /** */ + @Test public void testAlterTableAddColumnNotNullFieldAllowed() throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, age INT)"); @@ -742,11 +763,13 @@ public void testAlterTableAddColumnNotNullFieldAllowed() throws Exception { } /** */ + @Test public void testAtomicNotNullCheckDmlInsertValues() throws Exception { checkNotNullCheckDmlInsertValues(CacheAtomicityMode.ATOMIC); } /** */ + @Test public void testTransactionalNotNullCheckDmlInsertValues() throws Exception { checkNotNullCheckDmlInsertValues(CacheAtomicityMode.TRANSACTIONAL); } @@ -777,11 +800,13 @@ private void checkNotNullCheckDmlInsertValues(CacheAtomicityMode atomicityMode) } /** */ + @Test public void testAtomicAddColumnNotNullCheckDmlInsertValues() throws Exception { checkAddColumnNotNullCheckDmlInsertValues(CacheAtomicityMode.ATOMIC); } /** */ + @Test public void testTransactionalAddColumnNotNullCheckDmlInsertValues() throws Exception { checkAddColumnNotNullCheckDmlInsertValues(CacheAtomicityMode.TRANSACTIONAL); } @@ -814,6 +839,7 @@ private void checkAddColumnNotNullCheckDmlInsertValues(CacheAtomicityMode atomic } /** */ + @Test public void testNotNullCheckDmlInsertFromSelect() throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, name VARCHAR, age INT)"); @@ -839,6 +865,7 @@ public void testNotNullCheckDmlInsertFromSelect() throws Exception { } /** */ + @Test public void testNotNullCheckDmlUpdateValues() throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, name VARCHAR NOT NULL)"); @@ -865,6 +892,7 @@ public void testNotNullCheckDmlUpdateValues() throws Exception { } /** */ + @Test public void testNotNullCheckDmlUpdateFromSelect() throws Exception { executeSql("CREATE TABLE src(id INT PRIMARY KEY, name VARCHAR)"); executeSql("CREATE TABLE dest(id INT PRIMARY KEY, name VARCHAR NOT NULL)"); @@ -912,6 +940,7 @@ public void testNotNullCheckDmlUpdateFromSelect() throws Exception { } /** Check QueryEntity configuration fails with NOT NULL field and read-through. */ + @Test public void testReadThroughRestrictionQueryEntity() throws Exception { // Node start-up failure (read-through cache store). GridTestUtils.assertThrowsAnyCause(log, new Callable() { @@ -930,6 +959,7 @@ public void testReadThroughRestrictionQueryEntity() throws Exception { } /** Check QueryEntity configuration fails with NOT NULL field and cache interceptor. */ + @Test public void testInterceptorRestrictionQueryEntity() throws Exception { // Node start-up failure (interceptor). GridTestUtils.assertThrowsAnyCause(log, new Callable() { @@ -948,6 +978,7 @@ public void testInterceptorRestrictionQueryEntity() throws Exception { } /** Check create table fails with NOT NULL field and read-through. */ + @Test public void testReadThroughRestrictionCreateTable() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable() { @Override public Object call() throws Exception { @@ -958,6 +989,7 @@ public void testReadThroughRestrictionCreateTable() throws Exception { } /** Check create table fails with NOT NULL field and cache interceptor. */ + @Test public void testInterceptorRestrictionCreateTable() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable() { @Override public Object call() throws Exception { @@ -968,6 +1000,7 @@ public void testInterceptorRestrictionCreateTable() throws Exception { } /** Check alter table fails with NOT NULL field and read-through. */ + @Test public void testReadThroughRestrictionAlterTable() throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, age INT) " + "WITH \"template=" + CACHE_READ_THROUGH + "\""); @@ -980,6 +1013,7 @@ public void testReadThroughRestrictionAlterTable() throws Exception { } /** Check alter table fails with NOT NULL field and cache interceptor. */ + @Test public void testInterceptorRestrictionAlterTable() throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, age INT) " + "WITH \"template=" + CACHE_INTERCEPTOR + "\""); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlParameterizedQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlParameterizedQueryTest.java index b5039cd4cb9ea..2c1416ba64326 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlParameterizedQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlParameterizedQueryTest.java @@ -30,9 +30,10 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test sql queries with parameters for all types. @@ -41,10 +42,8 @@ * @author Sergey Chernolyas &sergey_chernolyas@gmail.com& * @see IGNITE-6286 */ +@RunWith(JUnit4.class) public class IgniteSqlParameterizedQueryTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String CACHE_BOOKMARK = "Bookmark"; @@ -55,12 +54,6 @@ public class IgniteSqlParameterizedQueryTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration c = super.getConfiguration(gridName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - c.setCacheConfiguration(buildCacheConfiguration(CACHE_BOOKMARK)); if (gridName.equals(NODE_CLIENT)) c.setClientMode(true); @@ -119,6 +112,7 @@ private Object columnValue(String field, Object val) { * testing parametrized query by field with supported type * @throws Exception if any error occurs */ + @Test public void testSupportedTypes() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_BOOKMARK); Bookmark bookmark = new Bookmark(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlQueryParallelismTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlQueryParallelismTest.java index e4321086cbe2d..31f663366e113 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlQueryParallelismTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlQueryParallelismTest.java @@ -28,20 +28,18 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * A test against setting different values of query parallelism in cache configurations of the same cache. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteSqlQueryParallelismTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private boolean isClient = false; @@ -61,12 +59,6 @@ public class IgniteSqlQueryParallelismTest extends GridCommonAbstractTest { cfg.setCacheConfiguration(ccfg1, ccfg2); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -97,6 +89,7 @@ private static CacheConfiguration cacheConfig(String name, Class... idxTypes) /** * @throws Exception If failed. */ + @Test public void testIndexSegmentationOnClient() throws Exception { IgniteCache c1 = ignite(0).cache("org"); IgniteCache c2 = ignite(0).cache("pers"); @@ -124,6 +117,7 @@ public void testIndexSegmentationOnClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIndexSegmentation() throws Exception { IgniteCache c1 = ignite(0).cache("org"); IgniteCache c2 = ignite(0).cache("pers"); @@ -199,4 +193,4 @@ public Organization(String name) { this.name = name; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlRoutingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlRoutingTest.java index 4976ee8a04c96..7a70d7fc8055c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlRoutingTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlRoutingTest.java @@ -29,8 +29,6 @@ import org.apache.ignite.events.Event; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.nio.ByteBuffer; @@ -48,15 +46,16 @@ import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED; /** Tests for query partitions derivation. */ +@RunWith(JUnit4.class) public class IgniteSqlRoutingTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static String NODE_CLIENT = "client"; @@ -79,12 +78,6 @@ public class IgniteSqlRoutingTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration c = super.getConfiguration(gridName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - c.setMarshaller(new BinaryMarshaller()); List ccfgs = new ArrayList<>(); @@ -176,6 +169,7 @@ private CacheConfiguration buildCacheConfiguration(String name) { } /** */ + @Test public void testUnicastQuerySelectAffinityKeyEqualsConstant() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_CALL); @@ -189,6 +183,7 @@ public void testUnicastQuerySelectAffinityKeyEqualsConstant() throws Exception { } /** */ + @Test public void testUnicastQuerySelectAffinityKeyEqualsParameter() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_CALL); @@ -203,6 +198,7 @@ public void testUnicastQuerySelectAffinityKeyEqualsParameter() throws Exception } /** */ + @Test public void testUnicastQuerySelectKeyEqualsParameterReused() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_PERSON); @@ -219,6 +215,7 @@ public void testUnicastQuerySelectKeyEqualsParameterReused() throws Exception { } /** */ + @Test public void testUnicastQuerySelectKeyEqualsParameter() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_CALL); @@ -236,6 +233,7 @@ public void testUnicastQuerySelectKeyEqualsParameter() throws Exception { } /** Check group, having, ordering allowed to be unicast requests. */ + @Test public void testUnicastQueryGroups() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_CALL); @@ -257,6 +255,7 @@ public void testUnicastQueryGroups() throws Exception { } /** */ + @Test public void testUnicastQuerySelectKeyEqualAndFieldParameter() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_CALL); @@ -274,6 +273,7 @@ public void testUnicastQuerySelectKeyEqualAndFieldParameter() throws Exception { } /** */ + @Test public void testUnicastQuerySelect2KeyEqualsAndFieldParameter() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_CALL); @@ -296,6 +296,7 @@ public void testUnicastQuerySelect2KeyEqualsAndFieldParameter() throws Exception } /** */ + @Test public void testUnicastQueryKeyTypeConversionParameter() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_PERSON); @@ -313,6 +314,7 @@ public void testUnicastQueryKeyTypeConversionParameter() throws Exception { } /** */ + @Test public void testUnicastQueryKeyTypeConversionConstant() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_PERSON); @@ -329,6 +331,7 @@ public void testUnicastQueryKeyTypeConversionConstant() throws Exception { } /** */ + @Test public void testUnicastQueryAffinityKeyTypeConversionParameter() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_CALL); @@ -344,6 +347,7 @@ public void testUnicastQueryAffinityKeyTypeConversionParameter() throws Exceptio } /** */ + @Test public void testUnicastQueryAffinityKeyTypeConversionConstant() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_CALL); @@ -358,6 +362,7 @@ public void testUnicastQueryAffinityKeyTypeConversionConstant() throws Exception } /** */ + @Test public void testBroadcastQuerySelectKeyEqualsOrFieldParameter() throws Exception { IgniteCache cache = grid(NODE_CLIENT).cache(CACHE_CALL); @@ -371,6 +376,7 @@ public void testBroadcastQuerySelectKeyEqualsOrFieldParameter() throws Exception } /** */ + @Test public void testUuidKeyAsByteArrayParameter() throws Exception { String cacheName = "uuidCache"; @@ -411,6 +417,7 @@ public void testUuidKeyAsByteArrayParameter() throws Exception { } /** */ + @Test public void testDateKeyAsTimestampParameter() throws Exception { String cacheName = "dateCache"; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSchemaIndexingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSchemaIndexingTest.java index 2dee617502424..534cf5becf9c1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSchemaIndexingTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSchemaIndexingTest.java @@ -31,32 +31,24 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests {@link IgniteH2Indexing} support {@link CacheConfiguration#setSqlSchema(String)} configuration. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteSqlSchemaIndexingTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration() throws Exception { IgniteConfiguration cfg = super.getConfiguration(); cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -85,10 +77,11 @@ private static CacheConfiguration cacheConfig(String name, boolean partitioned, * * @throws Exception If failed. */ + @Test public void testCaseSensitive() throws Exception { //TODO rewrite with dynamic cache creation, and GRID start in #beforeTest after resolve of - //TODO https://issues.apache.org/jira/browse/IGNITE-1094 - fail("https://issues.apache.org/jira/browse/IGNITE-1094"); + //TODO IGNITE-1094 + fail("https://issues.apache.org/jira/browse/IGNITE-10723"); GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -114,11 +107,11 @@ public void testCaseSensitive() throws Exception { * * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testCustomSchemaMultipleCachesTablesCollision() throws Exception { //TODO: Rewrite with dynamic cache creation, and GRID start in #beforeTest after resolve of - //TODO: https://issues.apache.org/jira/browse/IGNITE-1094 - fail("https://issues.apache.org/jira/browse/IGNITE-1094"); + //TODO: IGNITE-1094 + fail("https://issues.apache.org/jira/browse/IGNITE-10723"); GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { @@ -144,6 +137,7 @@ public void testCustomSchemaMultipleCachesTablesCollision() throws Exception { * * @throws Exception If failed. */ + @Test public void testCacheUnregistration() throws Exception { startGridsMultiThreaded(3, true); @@ -182,6 +176,7 @@ public void testCacheUnregistration() throws Exception { * * @throws Exception If failed. */ + @Test public void testSchemaEscapeAll() throws Exception { startGridsMultiThreaded(3, true); @@ -239,7 +234,7 @@ private static void escapeCheckSchemaName(final IgniteCache cache } } - // TODO add tests with dynamic cache unregistration, after resolve of https://issues.apache.org/jira/browse/IGNITE-1094 + // TODO add tests with dynamic cache unregistration - IGNITE-1094 resolved /** Test class as query entity */ private static class Fact { diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java index 389a1ab6529a0..4d786e4ce390f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java @@ -34,18 +34,16 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for correct distributed queries with index consisted of many segments. */ +@RunWith(JUnit4.class) public class IgniteSqlSegmentedIndexSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static final String ORG_CACHE_NAME = "org"; @@ -74,12 +72,6 @@ public class IgniteSqlSegmentedIndexSelfTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -118,6 +110,7 @@ protected CacheConfiguration cacheConfig(String name, boolean parti /** * @throws Exception If failed. */ + @Test public void testSegmentedIndex() throws Exception { ignite(0).createCache(cacheConfig(PERSON_CAHE_NAME, true, Integer.class, Person.class)); ignite(0).createCache(cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class)); @@ -135,6 +128,7 @@ public void testSegmentedIndex() throws Exception { * Check correct index snapshots with segmented indices. * @throws Exception If failed. */ + @Test public void testSegmentedIndexReproducableResults() throws Exception { ignite(0).createCache(cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class)); @@ -160,6 +154,7 @@ public void testSegmentedIndexReproducableResults() throws Exception { * Checks correct select count(*) result with segmented indices. * @throws Exception If failed. */ + @Test public void testSegmentedIndexSizeReproducableResults() throws Exception { ignite(0).createCache(cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class)); @@ -186,6 +181,7 @@ public void testSegmentedIndexSizeReproducableResults() throws Exception { * * @throws Exception If failed. */ + @Test public void testSegmentedIndexWithEvictionPolicy() throws Exception { final IgniteCache cache = ignite(0).createCache( cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class) @@ -209,6 +205,7 @@ public void testSegmentedIndexWithEvictionPolicy() throws Exception { * * @throws Exception If failed. */ + @Test public void testSizeOnSegmentedIndexWithEvictionPolicy() throws Exception { final IgniteCache cache = ignite(0).createCache( cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class) @@ -232,6 +229,7 @@ public void testSizeOnSegmentedIndexWithEvictionPolicy() throws Exception { * * @throws Exception If failed. */ + @Test public void testSegmentedPartitionedWithReplicated() throws Exception { ignite(0).createCache(cacheConfig(PERSON_CAHE_NAME, true, Integer.class, Person.class)); ignite(0).createCache(cacheConfig(ORG_CACHE_NAME, false, Integer.class, Organization.class)); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest.java index 6d1b32b3b65bd..3b4c761d96f46 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest.java @@ -32,17 +32,16 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link SqlFieldsQueryEx#skipReducerOnUpdate} flag. */ +@RunWith(JUnit4.class) public class IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static int NODE_COUNT = 4; @@ -71,12 +70,6 @@ public class IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest extends GridCommonAbstr @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration c = super.getConfiguration(gridName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - List ccfgs = new ArrayList<>(); ccfgs.add(buildCacheConfiguration(CACHE_ACCOUNT)); @@ -189,6 +182,7 @@ private CacheConfiguration buildCacheConfiguration(String name) { * * @throws Exception If failed. */ + @Test public void testUpdate() throws Exception { Map accounts = getAccounts(100, 1, 100); @@ -201,6 +195,7 @@ public void testUpdate() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdateFastKey() throws Exception { Map accounts = getAccounts(100, 1, 100); @@ -214,6 +209,7 @@ public void testUpdateFastKey() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdateLimit() throws Exception { Map accounts = getAccounts(100, 1, 100); @@ -227,6 +223,7 @@ public void testUpdateLimit() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdateWhereSubquery() throws Exception { Map accounts = getAccounts(100, 1, -100); @@ -245,6 +242,7 @@ public void testUpdateWhereSubquery() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdateSetSubquery() throws Exception { Map accounts = getAccounts(100, 1, 1000); Map trades = getTrades(100, 2); @@ -262,6 +260,7 @@ public void testUpdateSetSubquery() throws Exception { * * @throws Exception If failed. */ + @Test public void testUpdateSetTableSubquery() throws Exception { Map accounts = getAccounts(100, 1, 1000); Map trades = getTrades(100, 2); @@ -279,6 +278,7 @@ public void testUpdateSetTableSubquery() throws Exception { * * @throws Exception If failed. */ + @Test public void testInsertValues() throws Exception { String text = "INSERT INTO \"acc\".Account (_key, name, sn, depo)" + " VALUES (?, ?, ?, ?), (?, ?, ?, ?)"; @@ -291,6 +291,7 @@ public void testInsertValues() throws Exception { * * @throws Exception If failed. */ + @Test public void testInsertFromSelect() throws Exception { Map accounts = getAccounts(100, 1, 1000); @@ -307,6 +308,7 @@ public void testInsertFromSelect() throws Exception { * * @throws Exception If failed. */ + @Test public void testInsertFromSelectOrderBy() throws Exception { Map accounts = getAccounts(100, 1, 1000); @@ -324,6 +326,7 @@ public void testInsertFromSelectOrderBy() throws Exception { * * @throws Exception If failed. */ + @Test public void testInsertFromSelectUnion() throws Exception { Map accounts = getAccounts(20, 1, 1000); @@ -342,6 +345,7 @@ public void testInsertFromSelectUnion() throws Exception { * * @throws Exception If failed. */ + @Test public void testInsertFromSelectGroupBy() throws Exception { Map accounts = getAccounts(100, 1, 1000); Map trades = getTrades(100, 2); @@ -362,6 +366,7 @@ public void testInsertFromSelectGroupBy() throws Exception { * * @throws Exception If failed. */ + @Test public void testInsertFromSelectDistinct() throws Exception { Map accounts = getAccounts(100, 2, 100); @@ -378,6 +383,7 @@ public void testInsertFromSelectDistinct() throws Exception { * * @throws Exception If failed. */ + @Test public void testInsertFromSelectJoin() throws Exception { Map accounts = getAccounts(100, 1, 100); Map stocks = getStocks(5); @@ -397,6 +403,7 @@ public void testInsertFromSelectJoin() throws Exception { * * @throws Exception If failed. */ + @Test public void testDelete() throws Exception { Map accounts = getAccounts(100, 1, 100); @@ -412,6 +419,7 @@ public void testDelete() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeleteTop() throws Exception { Map accounts = getAccounts(100, 1, 100); @@ -427,6 +435,7 @@ public void testDeleteTop() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeleteWhereSubquery() throws Exception { Map accounts = getAccounts(20, 1, 100); Map trades = getTrades(10, 2); @@ -445,6 +454,7 @@ public void testDeleteWhereSubquery() throws Exception { * * @throws Exception If failed. */ + @Test public void testMergeValues() throws Exception { Map accounts = getAccounts(1, 1, 100); @@ -459,6 +469,7 @@ public void testMergeValues() throws Exception { * * @throws Exception If failed. */ + @Test public void testMergeFromSelectJoin() throws Exception { Map accounts = getAccounts(100, 1, 100); Map stocks = getStocks(5); @@ -482,6 +493,7 @@ public void testMergeFromSelectJoin() throws Exception { * * @throws Exception If failed. */ + @Test public void testMergeFromSelectOrderBy() throws Exception { Map accounts = getAccounts(100, 1, 1000); @@ -503,6 +515,7 @@ public void testMergeFromSelectOrderBy() throws Exception { * * @throws Exception If failed. */ + @Test public void testMergeFromSelectGroupBy() throws Exception { Map accounts = getAccounts(100, 1, 1000); Map trades = getTrades(100, 2); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSkipReducerOnUpdateDmlSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSkipReducerOnUpdateDmlSelfTest.java index 12def671c6bea..f41d52f11c0ac 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSkipReducerOnUpdateDmlSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSkipReducerOnUpdateDmlSelfTest.java @@ -50,10 +50,11 @@ import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_EXECUTED; @@ -61,11 +62,9 @@ /** * Tests for distributed DML. */ -@SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"}) +@SuppressWarnings({"unchecked"}) +@RunWith(JUnit4.class) public class IgniteSqlSkipReducerOnUpdateDmlSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static int NODE_COUNT = 4; @@ -91,12 +90,6 @@ public class IgniteSqlSkipReducerOnUpdateDmlSelfTest extends GridCommonAbstractT @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration c = super.getConfiguration(gridName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - List ccfgs = new ArrayList<>(); ccfgs.add(buildCacheConfiguration(CACHE_ORG)); @@ -201,6 +194,7 @@ private CacheConfiguration buildCacheConfiguration(String name) { * * @throws Exception if failed. */ + @Test public void testSimpleUpdateDistributedReplicated() throws Exception { fillCaches(); @@ -220,6 +214,7 @@ public void testSimpleUpdateDistributedReplicated() throws Exception { * * @throws Exception if failed. */ + @Test public void testSimpleUpdateDistributedPartitioned() throws Exception { fillCaches(); @@ -236,6 +231,7 @@ public void testSimpleUpdateDistributedPartitioned() throws Exception { * * @throws Exception if failed. */ + @Test public void testDistributedUpdateFailedKeys() throws Exception { // UPDATE can produce failed keys due to concurrent modification fillCaches(); @@ -254,6 +250,7 @@ public void testDistributedUpdateFailedKeys() throws Exception { * * @throws Exception if failed. */ + @Test public void testDistributedUpdateFail() throws Exception { fillCaches(); @@ -272,6 +269,7 @@ public void testDistributedUpdateFail() throws Exception { * @throws Exception if failed. */ @SuppressWarnings("ConstantConditions") + @Test public void testQueryParallelism() throws Exception { String cacheName = CACHE_ORG + "x4"; @@ -294,6 +292,7 @@ public void testQueryParallelism() throws Exception { * * @throws Exception if failed. */ + @Test public void testEvents() throws Exception { final CountDownLatch latch = new CountDownLatch(NODE_COUNT); @@ -332,6 +331,7 @@ public void testEvents() throws Exception { * * @throws Exception if failed. */ + @Test public void testSpecificPartitionsUpdate() throws Exception { fillCaches(); @@ -365,6 +365,7 @@ public void testSpecificPartitionsUpdate() throws Exception { * * @throws Exception if failed. */ + @Test public void testCancel() throws Exception { latch = new CountDownLatch(NODE_COUNT + 1); @@ -407,6 +408,7 @@ public void testCancel() throws Exception { * * @throws Exception if failed. */ + @Test public void testNodeStopDuringUpdate() throws Exception { startGrid(NODE_COUNT + 1); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java index df226b2fcdd6b..49ae546625b63 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java @@ -51,25 +51,24 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.SB; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testsuites.IgniteIgnore; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.util.StringUtils; /** * Tests for correct distributed partitioned queries. */ @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest { /** */ private static final int CLIENT = 7; - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -80,12 +79,6 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest { cfg.setPeerClassLoadingEnabled(false); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -120,6 +113,7 @@ private static CacheConfiguration cacheConfig(String name, boolean partitioned, * Tests offset and limit clauses for query. * @throws Exception If failed. */ + @Test public void testOffsetLimit() throws Exception { IgniteCache c = ignite(0).getOrCreateCache(cacheConfig("ints", true, Integer.class, Integer.class)); @@ -160,7 +154,9 @@ public void testOffsetLimit() throws Exception { /** */ - public void _testMergeJoin() { + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10199") + @Test + public void testMergeJoin() { IgniteCache c = ignite(CLIENT).getOrCreateCache(cacheConfig("org", true, Integer.class, Org.class)); @@ -187,6 +183,8 @@ public void _testMergeJoin() { } } + /** */ + @Test public void testPushDownSubquery() { IgniteCache c = ignite(CLIENT).getOrCreateCache(cacheConfig("ps", true, Integer.class, Person.class)); @@ -232,6 +230,7 @@ public void testPushDownSubquery() { /** */ + @Test public void testPushDown() { IgniteCache c = ignite(CLIENT).getOrCreateCache(cacheConfig("ps", true, Integer.class, Person.class)); @@ -278,6 +277,7 @@ public void testPushDown() { /** */ + @Test public void testPushDownLeftJoin() { IgniteCache c = ignite(0).getOrCreateCache(cacheConfig("ps", true, Integer.class, Person.class)); @@ -328,48 +328,56 @@ public void testPushDownLeftJoin() { /** */ + @Test public void testReplicatedTablesUsingPartitionedCache() { doTestReplicatedTablesUsingPartitionedCache(1, false, false); } /** */ + @Test public void testReplicatedTablesUsingPartitionedCacheSegmented() { doTestReplicatedTablesUsingPartitionedCache(5, false, false); } /** */ + @Test public void testReplicatedTablesUsingPartitionedCacheClient() { doTestReplicatedTablesUsingPartitionedCache(1, true, false); } /** */ + @Test public void testReplicatedTablesUsingPartitionedCacheSegmentedClient() { doTestReplicatedTablesUsingPartitionedCache(5, true, false); } /** */ + @Test public void testReplicatedTablesUsingPartitionedCacheRO() { doTestReplicatedTablesUsingPartitionedCache(1, false, true); } /** */ + @Test public void testReplicatedTablesUsingPartitionedCacheSegmentedRO() { doTestReplicatedTablesUsingPartitionedCache(5, false, true); } /** */ + @Test public void testReplicatedTablesUsingPartitionedCacheClientRO() { doTestReplicatedTablesUsingPartitionedCache(1, true, true); } /** */ + @Test public void testReplicatedTablesUsingPartitionedCacheSegmentedClientRO() { doTestReplicatedTablesUsingPartitionedCache(5, true, true); } @@ -413,18 +421,22 @@ private void doTestReplicatedTablesUsingPartitionedCache(int segments, boolean c } } + @Test public void testPartitionedTablesUsingReplicatedCache() { doTestPartitionedTablesUsingReplicatedCache(1, false); } + @Test public void testPartitionedTablesUsingReplicatedCacheSegmented() { doTestPartitionedTablesUsingReplicatedCache(7, false); } + @Test public void testPartitionedTablesUsingReplicatedCacheClient() { doTestPartitionedTablesUsingReplicatedCache(1, true); } + @Test public void testPartitionedTablesUsingReplicatedCacheSegmentedClient() { doTestPartitionedTablesUsingReplicatedCache(7, true); } @@ -458,6 +470,7 @@ private void doTestPartitionedTablesUsingReplicatedCache(int segments, boolean c /** */ + @Test public void testSubQueryWithAggregate() { CacheConfiguration ccfg1 = cacheConfig("pers", true, AffinityKey.class, Person2.class); @@ -488,6 +501,7 @@ public void testSubQueryWithAggregate() { /** * @throws InterruptedException If failed. */ + @Test public void testDistributedJoinFromReplicatedCache() throws InterruptedException { CacheConfiguration ccfg1 = cacheConfig("pers", true, Integer.class, Person2.class); @@ -515,6 +529,7 @@ public void testDistributedJoinFromReplicatedCache() throws InterruptedException } @SuppressWarnings("SuspiciousMethodCalls") + @Test public void testExists() { IgniteCache x = ignite(0).getOrCreateCache(cacheConfig("x", true, Integer.class, Person2.class)); @@ -558,6 +573,7 @@ public void testExists() { /** * @throws Exception If failed. */ + @Test public void testSortedMergeIndex() throws Exception { IgniteCache c = ignite(0).getOrCreateCache(cacheConfig("v", true, Integer.class, Value.class)); @@ -622,6 +638,7 @@ public void testSortedMergeIndex() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGroupIndexOperations() throws Exception { IgniteCache c = ignite(0).getOrCreateCache(cacheConfig("grp", false, Integer.class, GroupIndexTestValue.class)); @@ -701,6 +718,7 @@ public void testGroupIndexOperations() throws Exception { /** */ + @Test public void testUseIndexHints() { CacheConfiguration ccfg = cacheConfig("pers", true, Integer.class, Person2.class); @@ -734,6 +752,7 @@ public void testUseIndexHints() { /** * @throws Exception If failed. */ + @Test public void testDistributedJoins() throws Exception { CacheConfiguration ccfg1 = cacheConfig("pers", true, Integer.class, Person2.class); @@ -765,6 +784,7 @@ public void testDistributedJoins() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedJoinsUnion() throws Exception { CacheConfiguration ccfg1 = cacheConfig("pers", true, Integer.class, Person2.class); CacheConfiguration ccfg2 = cacheConfig("org", true, Integer.class, Organization.class); @@ -819,6 +839,7 @@ public void testDistributedJoinsUnion() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedJoinsUnionPartitionedReplicated() throws Exception { CacheConfiguration ccfg1 = cacheConfig("pers", true, Integer.class, Person2.class); @@ -888,6 +909,7 @@ public void testDistributedJoinsUnionPartitionedReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedJoinsPlan() throws Exception { List> caches = new ArrayList<>(); @@ -1242,6 +1264,7 @@ public void testDistributedJoinsPlan() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDistributedJoinsEnforceReplicatedNotLast() throws Exception { List> caches = new ArrayList<>(); @@ -1289,24 +1312,28 @@ public void testDistributedJoinsEnforceReplicatedNotLast() throws Exception { /** */ + @Test public void testSchemaQuoted() { doTestSchemaName("\"ppAf\""); } /** */ + @Test public void testSchemaQuotedUpper() { doTestSchemaName("\"PPAF\""); } /** */ + @Test public void testSchemaUnquoted() { doTestSchemaName("ppAf"); } /** */ + @Test public void testSchemaUnquotedUpper() { doTestSchemaName("PPAF"); } @@ -1339,6 +1366,7 @@ public void doTestSchemaName(String schema) { /** * @throws Exception If failed. */ + @Test public void testIndexSegmentation() throws Exception { CacheConfiguration ccfg1 = cacheConfig("pers", true, Integer.class, Person2.class).setQueryParallelism(4); @@ -1370,6 +1398,7 @@ public void testIndexSegmentation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReplicationCacheIndexSegmentationFailure() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Void call() throws Exception { @@ -1386,6 +1415,7 @@ public void testReplicationCacheIndexSegmentationFailure() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIndexSegmentationPartitionedReplicated() throws Exception { CacheConfiguration ccfg1 = cacheConfig("pers", true, Integer.class, Person2.class).setQueryParallelism(4); @@ -1452,6 +1482,7 @@ public void testIndexSegmentationPartitionedReplicated() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIndexWithDifferentSegmentationLevelsFailure() throws Exception { CacheConfiguration ccfg1 = cacheConfig("pers", true, Integer.class, Person2.class).setQueryParallelism(4); @@ -1628,6 +1659,7 @@ private void checkQueryPlan(IgniteCache cache, /** * Test HAVING clause. */ + @Test public void testHaving() { IgniteCache c = ignite(0).getOrCreateCache(cacheConfig("having", true, Integer.class, Integer.class)); @@ -1766,6 +1798,7 @@ private static List column(int idx, List> rows) { * */ @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-1886", forceFailure = true) + @Test public void testFunctionNpe() { IgniteCache userCache = ignite(0).createCache( cacheConfig("UserCache", true, Integer.class, User.class)); @@ -1798,6 +1831,7 @@ public void testFunctionNpe() { /** * */ + @Test public void testImplicitJoinConditionGeneration() { IgniteCache p = ignite(0).createCache(cacheConfig("P", true, Integer.class, Person.class)); IgniteCache d = ignite(0).createCache(cacheConfig("D", true, Integer.class, Department.class)); @@ -1826,6 +1860,7 @@ public void testImplicitJoinConditionGeneration() { /** * @throws Exception If failed. */ + @Test public void testJoinWithSubquery() throws Exception { IgniteCache c1 = ignite(0).createCache( cacheConfig("Contract", true, @@ -1855,6 +1890,7 @@ public void testJoinWithSubquery() throws Exception { } /** @throws Exception if failed. */ + @Test public void testDistributedAggregates() throws Exception { final String cacheName = "ints"; @@ -1902,6 +1938,7 @@ public void testDistributedAggregates() throws Exception { } /** @throws Exception if failed. */ + @Test public void testCollocatedAggregates() throws Exception { final String cacheName = "ints"; @@ -1948,6 +1985,7 @@ public void testCollocatedAggregates() throws Exception { * * @throws Exception If failed, */ + @Test public void testEmptyCacheAggregates() throws Exception { final String cacheName = "ints"; @@ -1978,6 +2016,7 @@ public void testEmptyCacheAggregates() throws Exception { * * @throws Exception If failed. */ + @Test public void testAvgVariousDataTypes() throws Exception { final String cacheName = "avgtypes"; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/LazyQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/LazyQuerySelfTest.java index d5cc0ebc0ee91..7f2f1d201912b 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/LazyQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/LazyQuerySelfTest.java @@ -35,10 +35,14 @@ import java.util.Iterator; import java.util.List; import java.util.concurrent.ThreadLocalRandom; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for lazy query execution. */ +@RunWith(JUnit4.class) public class LazyQuerySelfTest extends GridCommonAbstractTest { /** Keys ocunt. */ private static final int KEY_CNT = 200; @@ -62,6 +66,7 @@ public class LazyQuerySelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testSingleNode() throws Exception { checkSingleNode(1); } @@ -71,6 +76,7 @@ public void testSingleNode() throws Exception { * * @throws Exception If failed. */ + @Test public void testSingleNodeWithParallelism() throws Exception { checkSingleNode(4); } @@ -80,6 +86,7 @@ public void testSingleNodeWithParallelism() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleNodes() throws Exception { checkMultipleNodes(1); } @@ -89,6 +96,7 @@ public void testMultipleNodes() throws Exception { * * @throws Exception If failed. */ + @Test public void testMultipleNodesWithParallelism() throws Exception { checkMultipleNodes(4); } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/MultipleStatementsSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/MultipleStatementsSqlQuerySelfTest.java index becd5865c642c..2c07349d8aefa 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/MultipleStatementsSqlQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/MultipleStatementsSqlQuerySelfTest.java @@ -25,10 +25,14 @@ import org.apache.ignite.internal.processors.cache.QueryCursorImpl; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for schemas. */ +@RunWith(JUnit4.class) public class MultipleStatementsSqlQuerySelfTest extends GridCommonAbstractTest { /** Node. */ private IgniteEx node; @@ -47,10 +51,9 @@ public class MultipleStatementsSqlQuerySelfTest extends GridCommonAbstractTest { /** * Test query without caches. - * - * @throws Exception If failed. */ - public void testQuery() throws Exception { + @Test + public void testQuery() { GridQueryProcessor qryProc = node.context().query(); SqlFieldsQuery qry = new SqlFieldsQuery( @@ -92,10 +95,9 @@ public void testQuery() throws Exception { /** * Test query without caches. - * - * @throws Exception If failed. */ - public void testQueryWithParameters() throws Exception { + @Test + public void testQueryWithParameters() { GridQueryProcessor qryProc = node.context().query(); SqlFieldsQuery qry = new SqlFieldsQuery( @@ -137,9 +139,9 @@ public void testQueryWithParameters() throws Exception { } /** - * @throws Exception If failed. */ - public void testQueryMultipleStatementsFailed() throws Exception { + @Test + public void testQueryMultipleStatementsFailed() { final SqlFieldsQuery qry = new SqlFieldsQuery("select 1; select 1;").setSchema("PUBLIC"); GridTestUtils.assertThrows(log, @@ -151,4 +153,34 @@ public void testQueryMultipleStatementsFailed() throws Exception { } }, IgniteSQLException.class, "Multiple statements queries are not supported"); } + + /** + * Check cached two-steps query. + */ + @Test + public void testCachedTwoSteps() { + List>> curs = sql("SELECT 1; SELECT 2"); + + assertEquals(2, curs.size()); + assertEquals(1, curs.get(0).getAll().get(0).get(0)); + assertEquals(2, curs.get(1).getAll().get(0).get(0)); + + curs = sql("SELECT 1; SELECT 2"); + + assertEquals(2, curs.size()); + assertEquals(1, curs.get(0).getAll().get(0).get(0)); + assertEquals(2, curs.get(1).getAll().get(0).get(0)); + } + + /** + * @param sql SQL query. + * @return Results. + */ + private List>> sql(String sql) { + GridQueryProcessor qryProc = node.context().query(); + + SqlFieldsQuery qry = new SqlFieldsQuery(sql).setSchema("PUBLIC"); + + return qryProc.querySqlFields(qry, true, false); + } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/RunningQueriesTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/RunningQueriesTest.java new file mode 100644 index 0000000000000..81b6006a15879 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/RunningQueriesTest.java @@ -0,0 +1,95 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.query; + +import java.util.Collection; +import java.util.Collections; +import java.util.concurrent.CyclicBarrier; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.cache.query.SqlQuery; +import org.apache.ignite.cache.query.annotations.QuerySqlFunction; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +/** + * Tests for running queries. + */ +public class RunningQueriesTest extends GridCommonAbstractTest { + /** + * + */ + @Test + public void testQueriesOriginalText() throws Exception { + IgniteEx ignite = startGrid(0); + + IgniteCache cache = ignite.getOrCreateCache(new CacheConfiguration() + .setName("cache") + .setQueryEntities(Collections.singletonList(new QueryEntity(Integer.class, Integer.class))) + .setSqlFunctionClasses(TestSQLFunctions.class) + ); + + cache.put(0, 0); + + GridTestUtils.runAsync(() -> cache.query(new SqlFieldsQuery( + "SELECT * FROM /* comment */ Integer WHERE awaitBarrier() = 0")).getAll()); + + GridTestUtils.runAsync(() -> cache.query(new SqlQuery(Integer.class, + "FROM /* comment */ Integer WHERE awaitBarrier() = 0")).getAll()); + + TestSQLFunctions.barrier.await(); + + Collection runningQueries = ignite.context().query().runningQueries(-1); + + TestSQLFunctions.barrier.await(); + + assertEquals(2, runningQueries.size()); + + for (GridRunningQueryInfo info : runningQueries) + assertTrue("Failed to find comment in query: " + info.query(), info.query().contains("/* comment */")); + } + + /** + * Utility class with custom SQL functions. + */ + public static class TestSQLFunctions { + /** Barrier. */ + static CyclicBarrier barrier = new CyclicBarrier(3); + + /** + * Await cyclic barrier twice, first time to wait for enter method, second time to wait for collecting running + * queries. + */ + @QuerySqlFunction + public static long awaitBarrier() { + try { + barrier.await(); + barrier.await(); + } + catch (Exception ignored) { + // No-op. + } + + return 0; + } + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlIllegalSchemaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlIllegalSchemaSelfTest.java index e56f8a2069b56..51dc4dc46a456 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlIllegalSchemaSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlIllegalSchemaSelfTest.java @@ -17,21 +17,28 @@ package org.apache.ignite.internal.processors.query; +import java.util.concurrent.Callable; +import java.util.function.Consumer; +import javax.cache.CacheException; import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.Ignition; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -import javax.cache.CacheException; -import java.util.concurrent.Callable; +import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for illegal SQL schemas in node and cache configurations. */ @SuppressWarnings({"ThrowableNotThrown", "unchecked"}) +@RunWith(JUnit4.class) public class SqlIllegalSchemaSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { @@ -41,6 +48,7 @@ public class SqlIllegalSchemaSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testBadCacheName() throws Exception { IgniteConfiguration cfg = getConfiguration(); @@ -60,23 +68,35 @@ public void testBadCacheName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBadCacheNameDynamic() throws Exception { - Ignite node = startGrid(); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Void call() throws Exception { - node.getOrCreateCache(new CacheConfiguration().setName(QueryUtils.SCHEMA_SYS)); - - return null; + doubleConsumerAccept( + (node)->{ + try { + node.getOrCreateCache(new CacheConfiguration().setName(QueryUtils.SCHEMA_SYS)); + } + catch (CacheException e) { + assertTrue(hasCause(e, IgniteCheckedException.class, + "SQL schema name derived from cache name is reserved (please set explicit SQL " + + "schema name through CacheConfiguration.setSqlSchema() or choose another cache name) [" + + "cacheName=IGNITE, schemaName=null]")); + + return; + } + catch (Throwable e) { + fail("Exception class is not as expected [expected=" + + CacheException.class + ", actual=" + e.getClass() + ']'); + } + + fail("Exception has not been thrown."); } - }, CacheException.class, "SQL schema name derived from cache name is reserved (please set explicit SQL " + - "schema name through CacheConfiguration.setSqlSchema() or choose another cache name) [" + - "cacheName=IGNITE, schemaName=null]"); + ); } /** * @throws Exception If failed. */ + @Test public void testBadSchemaLower() throws Exception { IgniteConfiguration cfg = getConfiguration(); @@ -96,23 +116,35 @@ public void testBadSchemaLower() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBadSchemaLowerDynamic() throws Exception { - Ignite node = startGrid(); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Void call() throws Exception { - node.getOrCreateCache( - new CacheConfiguration().setName("CACHE").setSqlSchema(QueryUtils.SCHEMA_SYS.toLowerCase()) - ); - - return null; + doubleConsumerAccept( + (node) -> { + try { + node.getOrCreateCache( + new CacheConfiguration().setName("CACHE").setSqlSchema(QueryUtils.SCHEMA_SYS.toLowerCase()) + ); + } + catch (CacheException e) { + assertTrue(hasCause(e, IgniteCheckedException.class, + "SQL schema name is reserved (please choose another one) [cacheName=CACHE, schemaName=ignite]")); + + return; + } + catch (Throwable e) { + fail("Exception class is not as expected [expected=" + + CacheException.class + ", actual=" + e.getClass() + ']'); + } + + fail("Exception has not been thrown."); } - }, CacheException.class, "SQL schema name is reserved (please choose another one) [cacheName=CACHE, schemaName=ignite]"); + ); } /** * @throws Exception If failed. */ + @Test public void testBadSchemaUpper() throws Exception { IgniteConfiguration cfg = getConfiguration(); @@ -132,24 +164,35 @@ public void testBadSchemaUpper() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBadSchemaUpperDynamic() throws Exception { - Ignite node = startGrid(); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Void call() throws Exception { - node.getOrCreateCache( - new CacheConfiguration().setName("CACHE").setSqlSchema(QueryUtils.SCHEMA_SYS.toUpperCase()) - ); - - return null; + doubleConsumerAccept( + (node) -> { + try { + node.getOrCreateCache( + new CacheConfiguration().setName("CACHE").setSqlSchema(QueryUtils.SCHEMA_SYS.toUpperCase()) + ); + } + catch (CacheException e) { + assertTrue(hasCause(e, IgniteCheckedException.class, + "SQL schema name is reserved (please choose another one) [cacheName=CACHE, schemaName=IGNITE]")); + + return; + } + catch (Throwable e) { + fail("Exception class is not as expected [expected=" + + CacheException.class + ", actual=" + e.getClass() + ']'); + } + + fail("Exception has not been thrown."); } - }, CacheException.class, "SQL schema name is reserved (please choose another one) [cacheName=CACHE, " + - "schemaName=IGNITE]"); + ); } /** * @throws Exception If failed. */ + @Test public void testBadSchemaQuoted() throws Exception { IgniteConfiguration cfg = getConfiguration(); @@ -169,19 +212,78 @@ public void testBadSchemaQuoted() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBadSchemaQuotedDynamic() throws Exception { + doubleConsumerAccept( + (node) -> { + try { + node.getOrCreateCache( + new CacheConfiguration().setName("CACHE") + .setSqlSchema("\"" + QueryUtils.SCHEMA_SYS.toUpperCase() + "\"") + ); + } + catch (CacheException e) { + assertTrue(hasCause(e, IgniteCheckedException.class, + "SQL schema name is reserved (please choose another one) [cacheName=CACHE, schemaName=\"IGNITE\"]")); + + return; + } + catch (Throwable e) { + fail("Exception class is not as expected [expected=" + + CacheException.class + ", actual=" + e.getClass() + ']'); + } + + fail("Exception has not been thrown."); + } + ); + } + + /** + * Executes double call of consumer's accept method with passed Ignite instance. + * + * @param cons Consumer. + * @throws Exception If failed. + */ + private void doubleConsumerAccept(Consumer cons) throws Exception { Ignite node = startGrid(); - GridTestUtils.assertThrows(log, new Callable() { - @Override public Void call() throws Exception { - node.getOrCreateCache( - new CacheConfiguration().setName("CACHE") - .setSqlSchema("\"" + QueryUtils.SCHEMA_SYS.toUpperCase() + "\"") - ); + cons.accept(node); - return null; + cons.accept(node); + } + + /** + * Checks if passed in {@code 'Throwable'} has given class in {@code 'cause'} hierarchy + * including that throwable itself and it contains passed message. + *

    + * Note that this method follows includes {@link Throwable#getSuppressed()} + * into check. + * + * @param t Throwable to check (if {@code null}, {@code false} is returned). + * @param cls Cause class to check (if {@code null}, {@code false} is returned). + * @param msg Message to check. + * @return {@code True} if one of the causing exception is an instance of passed in classes + * and it contains the passed message, {@code false} otherwise. + */ + private boolean hasCause(@Nullable Throwable t, Class cls, String msg) { + if (t == null) + return false; + + assert cls != null; + + for (Throwable th = t; th != null; th = th.getCause()) { + if (cls.isAssignableFrom(th.getClass()) && F.eq(th.getMessage(), msg)) + return true; + + for (Throwable n : th.getSuppressed()) { + if (hasCause(n, cls, msg)) + return true; } - }, CacheException.class, "SQL schema name is reserved (please choose another one) [cacheName=CACHE, " + - "schemaName=\"IGNITE\"]"); + + if (th.getCause() == th) + break; + } + + return false; } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlPushDownFunctionTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlPushDownFunctionTest.java index 9e7877003d27e..a36b4796f7e2b 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlPushDownFunctionTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlPushDownFunctionTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for schemas. */ +@RunWith(JUnit4.class) public class SqlPushDownFunctionTest extends GridCommonAbstractTest { /** Node. */ private IgniteEx node; @@ -43,6 +47,7 @@ public class SqlPushDownFunctionTest extends GridCommonAbstractTest { /** */ + @Test public void testPushDownFunction() { sql("CREATE TABLE Person(id INTEGER PRIMARY KEY, company_id INTEGER)"); sql("CREATE TABLE Company(id INTEGER PRIMARY KEY, name VARCHAR)"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSchemaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSchemaSelfTest.java index b271d806d70c0..b02ef49ac377f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSchemaSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSchemaSelfTest.java @@ -20,20 +20,28 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; +import javax.cache.CacheException; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.query.schema.SchemaOperationException; import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for schemas. */ +@RunWith(JUnit4.class) public class SqlSchemaSelfTest extends GridCommonAbstractTest { /** Person cache name. */ private static final String CACHE_PERSON = "PersonCache"; @@ -61,6 +69,7 @@ public class SqlSchemaSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testQueryWithoutCacheOnPublicSchema() throws Exception { GridQueryProcessor qryProc = node.context().query(); @@ -89,6 +98,7 @@ public void testQueryWithoutCacheOnPublicSchema() throws Exception { * * @throws Exception If failed. */ + @Test public void testQueryWithoutCacheOnCacheSchema() throws Exception { node.createCache(new CacheConfiguration() .setName(CACHE_PERSON) @@ -121,6 +131,7 @@ public void testQueryWithoutCacheOnCacheSchema() throws Exception { * * @throws Exception If failed. */ + @Test public void testSchemaChange() throws Exception { IgniteCache cache = node.createCache(new CacheConfiguration() .setName(CACHE_PERSON) @@ -161,6 +172,7 @@ public void testSchemaChange() throws Exception { * * @throws Exception If failed. */ + @Test public void testSchemaChangeOnCacheWithPublicSchema() throws Exception { IgniteCache cache = node.createCache(new CacheConfiguration() .setName(CACHE_PERSON) @@ -197,6 +209,7 @@ public void testSchemaChangeOnCacheWithPublicSchema() throws Exception { * * @throws Exception If failed. */ + @Test public void testCustomSchemaName() throws Exception { IgniteCache cache = registerQueryEntity("Person", CACHE_PERSON); @@ -208,6 +221,7 @@ public void testCustomSchemaName() throws Exception { * * @throws Exception If failed. */ + @Test public void testCustomSchemaMultipleCaches() throws Exception { for (int i = 1; i <= 3; i++) { String tbl = "Person" + i; @@ -229,6 +243,7 @@ public void testCustomSchemaMultipleCaches() throws Exception { * * @throws Exception If failed. */ + @Test public void testCustomSchemaConcurrentUse() throws Exception { final AtomicInteger maxIdx = new AtomicInteger(); @@ -292,19 +307,25 @@ private void testQueryEntity(IgniteCache cache, String tbl) { * * @throws Exception If failed. */ - public void _testTypeConflictInPublicSchema() throws Exception { - // TODO: IGNITE-5380: uncomment work after fix. - fail("Hang for now, need to fix"); - + @Test + public void testTypeConflictInPublicSchema() throws Exception { node.createCache(new CacheConfiguration() .setName(CACHE_PERSON) .setIndexedTypes(PersonKey.class, Person.class) .setSqlSchema(QueryUtils.DFLT_SCHEMA)); - node.createCache(new CacheConfiguration() - .setName(CACHE_PERSON_2) - .setIndexedTypes(PersonKey.class, Person.class) - .setSqlSchema(QueryUtils.DFLT_SCHEMA)); + Throwable th = GridTestUtils.assertThrows(log, (Callable) () -> { + node.createCache(new CacheConfiguration() + .setName(CACHE_PERSON_2) + .setIndexedTypes(PersonKey.class, Person.class) + .setSqlSchema(QueryUtils.DFLT_SCHEMA)); + + return null; + }, CacheException.class, null); + + SchemaOperationException e = X.cause(th, SchemaOperationException.class); + + assertEquals(SchemaOperationException.CODE_TABLE_EXISTS, e.code()); } /** diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSystemViewsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSystemViewsSelfTest.java index ccd07964fba29..5be574c354805 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSystemViewsSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/SqlSystemViewsSelfTest.java @@ -19,24 +19,36 @@ import java.sql.Time; import java.sql.Timestamp; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Random; import java.util.TimeZone; import java.util.UUID; import java.util.concurrent.Callable; +import javax.cache.Cache; +import javax.cache.configuration.Factory; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.eviction.EvictableEntry; +import org.apache.ignite.cache.eviction.EvictionFilter; +import org.apache.ignite.cache.eviction.EvictionPolicy; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cluster.ClusterMetrics; +import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.DataRegionConfiguration; import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.TopologyValidator; import org.apache.ignite.internal.ClusterMetricsSnapshot; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteNodeAttributes; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; +import org.apache.ignite.internal.util.lang.GridNodePredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.internal.util.typedef.X; @@ -44,10 +56,14 @@ import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for ignite SQL system views. */ +@RunWith(JUnit4.class) public class SqlSystemViewsSelfTest extends GridCommonAbstractTest { /** Metrics check attempts. */ private static final int METRICS_CHECK_ATTEMPTS = 10; @@ -109,10 +125,11 @@ private void assertSqlError(final String sql) { assertEquals(IgniteQueryErrorCode.UNSUPPORTED_OPERATION, sqlE.statusCode()); } - + /** * Test system views modifications. */ + @Test public void testModifications() throws Exception { startGrid(getConfiguration()); @@ -140,6 +157,7 @@ public void testModifications() throws Exception { /** * Test different query modes. */ + @Test public void testQueryModes() throws Exception { Ignite ignite = startGrid(0); startGrid(1); @@ -168,6 +186,7 @@ public void testQueryModes() throws Exception { /** * Test that we can't use cache tables and system views in the same query. */ + @Test public void testCacheToViewJoin() throws Exception { Ignite ignite = startGrid(); @@ -193,6 +212,7 @@ private void assertColumnTypes(List rowData, Class ... colTypes) { * * @throws Exception If failed. */ + @Test public void testNodesViews() throws Exception { Ignite igniteSrv = startGrid(getTestIgniteInstanceName(), getConfiguration().setMetricsUpdateFrequency(500L)); @@ -459,6 +479,7 @@ public void testNodesViews() throws Exception { /** * Test baseline topology system view. */ + @Test public void testBaselineViews() throws Exception { cleanPersistenceDir(); @@ -504,6 +525,225 @@ public void testBaselineViews() throws Exception { return super.getConfiguration().setCacheConfiguration(new CacheConfiguration().setName(DEFAULT_CACHE_NAME)); } + /** + * Test caches system views. + */ + @SuppressWarnings("ConstantConditions") + @Test + public void testCachesViews() throws Exception { + DataStorageConfiguration dsCfg = new DataStorageConfiguration() + .setDefaultDataRegionConfiguration(new DataRegionConfiguration().setName("def").setPersistenceEnabled(true)) + .setDataRegionConfigurations(new DataRegionConfiguration().setName("dr1"), + new DataRegionConfiguration().setName("dr2")); + + IgniteEx ignite0 = startGrid(getConfiguration().setDataStorageConfiguration(dsCfg)); + + Ignite ignite1 = startGrid(getConfiguration().setDataStorageConfiguration(dsCfg).setIgniteInstanceName("node1")); + + ignite0.cluster().active(true); + + Ignite ignite2 = startGrid(getConfiguration().setDataStorageConfiguration(dsCfg).setIgniteInstanceName("node2")); + + Ignite ignite3 = startGrid(getConfiguration().setDataStorageConfiguration(dsCfg).setIgniteInstanceName("node3") + .setClientMode(true)); + + ignite0.getOrCreateCache(new CacheConfiguration<>() + .setName("cache_atomic_part") + .setAtomicityMode(CacheAtomicityMode.ATOMIC) + .setCacheMode(CacheMode.PARTITIONED) + .setGroupName("cache_grp") + .setNodeFilter(new TestNodeFilter(ignite0.cluster().localNode())) + ); + + ignite0.getOrCreateCache(new CacheConfiguration<>() + .setName("cache_atomic_repl") + .setAtomicityMode(CacheAtomicityMode.ATOMIC) + .setCacheMode(CacheMode.REPLICATED) + .setDataRegionName("dr1") + .setTopologyValidator(new TestTopologyValidator()) + ); + + ignite0.getOrCreateCache(new CacheConfiguration<>() + .setName("cache_tx_part") + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setCacheMode(CacheMode.PARTITIONED) + .setGroupName("cache_grp") + .setNodeFilter(new TestNodeFilter(ignite0.cluster().localNode())) + ); + + ignite0.getOrCreateCache(new CacheConfiguration<>() + .setName("cache_tx_repl") + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setCacheMode(CacheMode.REPLICATED) + .setDataRegionName("dr2") + .setEvictionFilter(new TestEvictionFilter()) + .setEvictionPolicyFactory(new TestEvictionPolicyFactory()) + .setOnheapCacheEnabled(true) + ); + + execSql("CREATE TABLE cache_sql (ID INT PRIMARY KEY, VAL VARCHAR) WITH " + + "\"cache_name=cache_sql,template=partitioned,atomicity=atomic\""); + + awaitPartitionMapExchange(); + + List> resAll = execSql("SELECT NAME, CACHE_ID, CACHE_TYPE, GROUP_ID, GROUP_NAME, " + + "CACHE_MODE, ATOMICITY_MODE, IS_ONHEAP_CACHE_ENABLED, IS_COPY_ON_READ, IS_LOAD_PREVIOUS_VALUE, " + + "IS_READ_FROM_BACKUP, PARTITION_LOSS_POLICY, NODE_FILTER, TOPOLOGY_VALIDATOR, IS_EAGER_TTL, " + + "WRITE_SYNCHRONIZATION_MODE, IS_INVALIDATE, IS_EVENTS_DISABLED, IS_STATISTICS_ENABLED, " + + "IS_MANAGEMENT_ENABLED, BACKUPS, AFFINITY, AFFINITY_MAPPER, " + + "REBALANCE_MODE, REBALANCE_BATCH_SIZE, REBALANCE_TIMEOUT, REBALANCE_DELAY, REBALANCE_THROTTLE, " + + "REBALANCE_BATCHES_PREFETCH_COUNT, REBALANCE_ORDER, " + + "EVICTION_FILTER, EVICTION_POLICY_FACTORY, " + + "IS_NEAR_CACHE_ENABLED, NEAR_CACHE_EVICTION_POLICY_FACTORY, NEAR_CACHE_START_SIZE, " + + "DEFAULT_LOCK_TIMEOUT, CACHE_INTERCEPTOR, CACHE_STORE_FACTORY, " + + "IS_STORE_KEEP_BINARY, IS_READ_THROUGH, IS_WRITE_THROUGH, " + + "IS_WRITE_BEHIND_ENABLED, WRITE_BEHIND_COALESCING, WRITE_BEHIND_FLUSH_SIZE, " + + "WRITE_BEHIND_FLUSH_FREQUENCY, WRITE_BEHIND_FLUSH_THREAD_COUNT, WRITE_BEHIND_FLUSH_BATCH_SIZE, " + + "MAX_CONCURRENT_ASYNC_OPERATIONS, CACHE_LOADER_FACTORY, CACHE_WRITER_FACTORY, EXPIRY_POLICY_FACTORY, " + + "IS_SQL_ESCAPE_ALL, SQL_SCHEMA, SQL_INDEX_MAX_INLINE_SIZE, IS_SQL_ONHEAP_CACHE_ENABLED, " + + "SQL_ONHEAP_CACHE_MAX_SIZE, QUERY_DETAILS_METRICS_SIZE, QUERY_PARALLELISM, MAX_QUERY_ITERATORS_COUNT, " + + "DATA_REGION_NAME FROM IGNITE.CACHES"); + + assertColumnTypes(resAll.get(0), + String.class, Integer.class, String.class, Integer.class, String.class, + String.class, String.class, Boolean.class, Boolean.class, Boolean.class, + Boolean.class, String.class, String.class, String.class, Boolean.class, + String.class, Boolean.class, Boolean.class, Boolean.class, + Boolean.class, Integer.class, String.class, String.class, + String.class, Integer.class, Long.class, Long.class, Long.class, // Rebalance. + Long.class, Integer.class, + String.class, String.class, // Eviction. + Boolean.class, String.class, Integer.class, // Near cache. + Long.class, String.class, String.class, + Boolean.class, Boolean.class, Boolean.class, + Boolean.class, Boolean.class, Integer.class, // Write-behind. + Long.class, Integer.class, Integer.class, + Integer.class, String.class, String.class, String.class, + Boolean.class, String.class, Integer.class, Boolean.class, // SQL. + Integer.class, Integer.class, Integer.class, Integer.class, + String.class); + + assertEquals("cache_tx_part", execSql("SELECT NAME FROM IGNITE.CACHES WHERE " + + "CACHE_MODE = 'PARTITIONED' AND ATOMICITY_MODE = 'TRANSACTIONAL' AND NAME like 'cache%'").get(0).get(0)); + + assertEquals("cache_atomic_repl", execSql("SELECT NAME FROM IGNITE.CACHES WHERE " + + "CACHE_MODE = 'REPLICATED' AND ATOMICITY_MODE = 'ATOMIC' AND NAME like 'cache%'").get(0).get(0)); + + assertEquals(2L, execSql("SELECT COUNT(*) FROM IGNITE.CACHES WHERE GROUP_NAME = 'cache_grp'") + .get(0).get(0)); + + assertEquals("cache_atomic_repl", execSql("SELECT NAME FROM IGNITE.CACHES " + + "WHERE DATA_REGION_NAME = 'dr1'").get(0).get(0)); + + assertEquals("cache_tx_repl", execSql("SELECT NAME FROM IGNITE.CACHES " + + "WHERE DATA_REGION_NAME = 'dr2'").get(0).get(0)); + + assertEquals("PARTITIONED", execSql("SELECT CACHE_MODE FROM IGNITE.CACHES " + + "WHERE NAME = 'cache_atomic_part'").get(0).get(0)); + + assertEquals("USER", execSql("SELECT CACHE_TYPE FROM IGNITE.CACHES WHERE NAME = 'cache_sql'") + .get(0).get(0)); + + assertEquals(0L, execSql("SELECT COUNT(*) FROM IGNITE.CACHES WHERE NAME = 'no_such_cache'").get(0) + .get(0)); + + assertEquals(0L, execSql("SELECT COUNT(*) FROM IGNITE.CACHES WHERE NAME = 1").get(0).get(0)); + + assertEquals("TestNodeFilter", execSql("SELECT NODE_FILTER FROM IGNITE.CACHES WHERE NAME = " + + "'cache_atomic_part'").get(0).get(0)); + + assertEquals("TestEvictionFilter", execSql("SELECT EVICTION_FILTER FROM IGNITE.CACHES " + + "WHERE NAME = 'cache_tx_repl'").get(0).get(0)); + + assertEquals("TestEvictionPolicyFactory", execSql("SELECT EVICTION_POLICY_FACTORY " + + "FROM IGNITE.CACHES WHERE NAME = 'cache_tx_repl'").get(0).get(0)); + + assertEquals("TestTopologyValidator", execSql("SELECT TOPOLOGY_VALIDATOR FROM IGNITE.CACHES " + + "WHERE NAME = 'cache_atomic_repl'").get(0).get(0)); + + // Check quick count. + assertEquals(execSql("SELECT COUNT(*) FROM IGNITE.CACHES").get(0).get(0), + execSql("SELECT COUNT(*) FROM IGNITE.CACHES WHERE CACHE_ID <> CACHE_ID + 1").get(0).get(0)); + + // Check that caches are the same on BLT, BLT filtered by node filter, non BLT and client nodes. + assertEquals(5L, execSql("SELECT COUNT(*) FROM IGNITE.CACHES WHERE NAME like 'cache%'").get(0) + .get(0)); + + assertEquals(5L, execSql(ignite1, "SELECT COUNT(*) FROM IGNITE.CACHES WHERE NAME like 'cache%'") + .get(0).get(0)); + + assertEquals(5L, execSql(ignite2, "SELECT COUNT(*) FROM IGNITE.CACHES WHERE NAME like 'cache%'") + .get(0).get(0)); + + assertEquals(5L, execSql(ignite3, "SELECT COUNT(*) FROM IGNITE.CACHES WHERE NAME like 'cache%'") + .get(0).get(0)); + + // Check cache groups. + resAll = execSql("SELECT ID, GROUP_NAME, IS_SHARED, CACHE_COUNT, " + + "CACHE_MODE, ATOMICITY_MODE, AFFINITY, PARTITIONS_COUNT, " + + "NODE_FILTER, DATA_REGION_NAME, TOPOLOGY_VALIDATOR, PARTITION_LOSS_POLICY, " + + "REBALANCE_MODE, REBALANCE_DELAY, REBALANCE_ORDER, BACKUPS " + + "FROM IGNITE.CACHE_GROUPS"); + + assertColumnTypes(resAll.get(0), + Integer.class, String.class, Boolean.class, Integer.class, + String.class, String.class, String.class, Integer.class, + String.class, String.class, String.class, String.class, + String.class, Long.class, Integer.class, Integer.class); + + assertEquals(2, execSql("SELECT CACHE_COUNT FROM IGNITE.CACHE_GROUPS " + + "WHERE GROUP_NAME = 'cache_grp'").get(0).get(0)); + + assertEquals("cache_grp", execSql("SELECT GROUP_NAME FROM IGNITE.CACHE_GROUPS " + + "WHERE IS_SHARED = true AND GROUP_NAME like 'cache%'").get(0).get(0)); + + // Check index on ID column. + assertEquals("cache_tx_repl", execSql("SELECT GROUP_NAME FROM IGNITE.CACHE_GROUPS " + + "WHERE ID = ?", ignite0.cachex("cache_tx_repl").context().groupId()).get(0).get(0)); + + assertEquals(0, execSql("SELECT ID FROM IGNITE.CACHE_GROUPS WHERE ID = 0").size()); + + // Check join by indexed column. + assertEquals("cache_tx_repl", execSql("SELECT CG.GROUP_NAME FROM IGNITE.CACHES C JOIN " + + "IGNITE.CACHE_GROUPS CG ON C.GROUP_ID = CG.ID WHERE C.NAME = 'cache_tx_repl'").get(0).get(0)); + + // Check join by non-indexed column. + assertEquals("cache_grp", execSql("SELECT CG.GROUP_NAME FROM IGNITE.CACHES C JOIN " + + "IGNITE.CACHE_GROUPS CG ON C.GROUP_NAME = CG.GROUP_NAME WHERE C.NAME = 'cache_tx_part'").get(0).get(0)); + + // Check configuration equality for cache and cache group views. + assertEquals(3L, execSql("SELECT COUNT(*) FROM IGNITE.CACHES C JOIN IGNITE.CACHE_GROUPS CG " + + "ON C.NAME = CG.GROUP_NAME WHERE C.NAME like 'cache%' " + + "AND C.CACHE_MODE = CG.CACHE_MODE " + + "AND C.ATOMICITY_MODE = CG.ATOMICITY_MODE " + + "AND COALESCE(C.AFFINITY, '-') = COALESCE(CG.AFFINITY, '-') " + + "AND COALESCE(C.NODE_FILTER, '-') = COALESCE(CG.NODE_FILTER, '-') " + + "AND COALESCE(C.DATA_REGION_NAME, '-') = COALESCE(CG.DATA_REGION_NAME, '-') " + + "AND COALESCE(C.TOPOLOGY_VALIDATOR, '-') = COALESCE(CG.TOPOLOGY_VALIDATOR, '-') " + + "AND C.PARTITION_LOSS_POLICY = CG.PARTITION_LOSS_POLICY " + + "AND C.REBALANCE_MODE = CG.REBALANCE_MODE " + + "AND C.REBALANCE_DELAY = CG.REBALANCE_DELAY " + + "AND C.REBALANCE_ORDER = CG.REBALANCE_ORDER " + + "AND C.BACKUPS = CG.BACKUPS").get(0).get(0)); + + // Check quick count. + assertEquals(execSql("SELECT COUNT(*) FROM IGNITE.CACHE_GROUPS").get(0).get(0), + execSql("SELECT COUNT(*) FROM IGNITE.CACHE_GROUPS WHERE ID <> ID + 1").get(0).get(0)); + + // Check that cache groups are the same on different nodes. + assertEquals(4L, execSql("SELECT COUNT(*) FROM IGNITE.CACHE_GROUPS " + + "WHERE GROUP_NAME like 'cache%'").get(0).get(0)); + + assertEquals(4L, execSql(ignite1, "SELECT COUNT(*) FROM IGNITE.CACHE_GROUPS " + + "WHERE GROUP_NAME like 'cache%'").get(0).get(0)); + + assertEquals(4L, execSql(ignite2, "SELECT COUNT(*) FROM IGNITE.CACHE_GROUPS " + + "WHERE GROUP_NAME like 'cache%'").get(0).get(0)); + + assertEquals(4L, execSql(ignite3, "SELECT COUNT(*) FROM IGNITE.CACHE_GROUPS " + + "WHERE GROUP_NAME like 'cache%'").get(0).get(0)); + } + /** * Gets ignite configuration with persistence enabled. */ @@ -533,4 +773,70 @@ private long convertToMilliseconds(Object sqlTime) { return time0.getTime() + TimeZone.getDefault().getOffset(time0.getTime()); } + + /** + * + */ + private static class TestNodeFilter extends GridNodePredicate { + /** + * @param node Node. + */ + public TestNodeFilter(ClusterNode node) { + super(node); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "TestNodeFilter"; + } + } + + /** + * + */ + private static class TestEvictionFilter implements EvictionFilter { + /** {@inheritDoc} */ + @Override public boolean evictAllowed(Cache.Entry entry) { + return false; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "TestEvictionFilter"; + } + } + + /** + * + */ + private static class TestEvictionPolicyFactory implements Factory> { + /** {@inheritDoc} */ + @Override public EvictionPolicy create() { + return new EvictionPolicy() { + @Override public void onEntryAccessed(boolean rmv, EvictableEntry entry) { + // No-op. + } + }; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "TestEvictionPolicyFactory"; + } + } + + /** + * + */ + private static class TestTopologyValidator implements TopologyValidator { + /** {@inheritDoc} */ + @Override public boolean validate(Collection nodes) { + return true; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "TestTopologyValidator"; + } + } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessorTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessorTest.java new file mode 100644 index 0000000000000..63ae9000c23f7 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessorTest.java @@ -0,0 +1,153 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.query.h2; + +import javax.cache.processor.MutableEntry; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.lang.IgniteInClosure; +import org.apache.ignite.lang.IgniteProductVersion; +import org.apache.ignite.testframework.GridTestNode; +import org.junit.Assert; +import org.junit.Test; + +/** + * Ensures that anonymous classes of entry modifiers are compatible with old versions. + */ +public class DmlStatementsProcessorTest { + /** + * Checks that remove-closure is available by anonymous class position (4). + * This is required for compatibility with versions < 2.7.0. + * + * @throws Exception If failed. + */ + @Test + public void testRemoveEntryModifierCompatibilityOld() throws Exception { + checkRemoveClosureByAnonymousPosition(4); + } + + /** + * Checks that remove-closure is available by anonymous class position (5). + * This is required for compatibility with versions >= 2.7.0. + * + * @throws Exception If failed. + */ + @Test + public void testRemoveEntryModifierCompatibilityNew() throws Exception { + checkRemoveClosureByAnonymousPosition(5); + } + + /** + * Checks that the old remove-closure is used if the remote node version is less than 2.7.0. + */ + @Test + public void testRemoveEntryModifierClassName() { + String oldClsName = DmlStatementsProcessor.class.getName() + "$" + 4; + String newClsName = DmlStatementsProcessor.class.getName() + "$" + 5; + + checkRemoveEntryClassName("2.4.0", oldClsName); + checkRemoveEntryClassName("2.5.0", oldClsName); + checkRemoveEntryClassName("2.6.0", oldClsName); + + checkRemoveEntryClassName("2.7.0", newClsName); + checkRemoveEntryClassName("2.8.0", newClsName); + } + + /** + * Checks remove-closure class name. + * + * @param ver The version of the remote node. + * @param expClsName Expected class name. + */ + private void checkRemoveEntryClassName(final String ver, String expClsName) { + ClusterNode node = new GridTestNode() { + @Override public IgniteProductVersion version() { + return IgniteProductVersion.fromString(ver); + } + }; + + IgniteInClosure> rmvC = + DmlStatementsProcessor.getRemoveClosure(node, 0); + + Assert.assertNotNull("Check remove-closure", rmvC); + + Assert.assertEquals("Check remove-closure class name for version " + ver, + expClsName, rmvC.getClass().getName()); + } + + /** + * Checks that remove-closure is available by anonymous class position. + */ + @SuppressWarnings("unchecked") + private void checkRemoveClosureByAnonymousPosition(int position) throws Exception { + Class cls = Class.forName(DmlStatementsProcessor.class.getName() + "$" + position); + + IgniteInClosure> rmvC = + (IgniteInClosure>)cls.newInstance(); + + CustomMutableEntry entry = new CustomMutableEntry<>(); + + rmvC.apply(entry); + + Assert.assertTrue("Entry should be removed", entry.isRemoved()); + } + + /** + * + */ + private static class CustomMutableEntry implements MutableEntry { + /** */ + private boolean rmvd; + + /** + * @return {@code true} if remove method was called. + */ + private boolean isRemoved() { + return rmvd; + } + + /** {@inheritDoc} */ + @Override public boolean exists() { + return false; + } + + /** {@inheritDoc} */ + @Override public void remove() { + rmvd = true; + } + + /** {@inheritDoc} */ + @Override public void setValue(V v) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public K getKey() { + return null; + } + + /** {@inheritDoc} */ + @Override public V getValue() { + return null; + } + + /** {@inheritDoc} */ + @Override public T unwrap(Class aCls) { + return null; + } + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java index c5f1441af5d69..5bbb4e28adef1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java @@ -24,21 +24,27 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.cache.index.DynamicIndexAbstractSelfTest; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.query.GridQueryProcessor; +import org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitorClosure; import org.apache.ignite.internal.util.lang.GridCursor; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Index rebuild after node restart test. */ +@RunWith(JUnit4.class) public class GridIndexRebuildSelfTest extends DynamicIndexAbstractSelfTest { /** Data size. */ - protected static final int AMOUNT = 300; + protected static final int AMOUNT = 50; /** Data size. */ protected static final String CACHE_NAME = "T"; @@ -109,11 +115,12 @@ public class GridIndexRebuildSelfTest extends DynamicIndexAbstractSelfTest { *

    * @throws Exception if failed. */ + @Test public void testIndexRebuild() throws Exception { IgniteEx srv = startServer(); execute(srv, "CREATE TABLE T(k int primary key, v int) WITH \"cache_name=T,wrap_value=false," + - "atomicity=transactional_snapshot\""); + "atomicity=transactional\""); execute(srv, "CREATE INDEX IDX ON T(v)"); @@ -228,13 +235,14 @@ private static class BlockingIndexing extends IgniteH2Indexing { private boolean firstRbld = true; /** {@inheritDoc} */ - @Override public void rebuildIndexesFromHash(String cacheName) throws IgniteCheckedException { + @Override protected void rebuildIndexesFromHash0(GridCacheContext cctx, SchemaIndexCacheVisitorClosure clo) + throws IgniteCheckedException { if (!firstRbld) U.await(INSTANCE.rebuildLatch); else firstRbld = false; - super.rebuildIndexesFromHash(cacheName); + super.rebuildIndexesFromHash0(cctx, clo); } } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildWithMvccEnabledSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildWithMvccEnabledSelfTest.java index a0d492cd26f60..15f8ca8e73b65 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildWithMvccEnabledSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildWithMvccEnabledSelfTest.java @@ -33,10 +33,14 @@ import org.apache.ignite.internal.util.lang.GridCursor; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Index rebuild after node restart test. */ +@RunWith(JUnit4.class) public class GridIndexRebuildWithMvccEnabledSelfTest extends GridIndexRebuildSelfTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration serverConfiguration(int idx, boolean filter) throws Exception { @@ -45,6 +49,7 @@ public class GridIndexRebuildWithMvccEnabledSelfTest extends GridIndexRebuildSel } /** {@inheritDoc} */ + @Test public void testIndexRebuild() throws Exception { IgniteEx srv = startServer(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java index 6b76230590e85..716cd029da70d 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java @@ -17,20 +17,7 @@ package org.apache.ignite.internal.processors.query.h2; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; -import org.apache.ignite.binary.BinaryObject; -import org.apache.ignite.binary.BinaryObjectBuilder; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.QueryIndex; import org.apache.ignite.cache.QueryIndexType; @@ -38,48 +25,37 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.internal.binary.BinaryObjectImpl; -import org.apache.ignite.internal.processors.cache.CacheObject; -import org.apache.ignite.internal.processors.cache.CacheObjectContext; -import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; -import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.query.GridQueryFieldsResult; -import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor; -import org.apache.ignite.internal.processors.query.GridQueryProperty; -import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor; -import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; -import org.apache.ignite.spi.IgniteSpiCloseableIterator; -import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.h2.util.JdbcUtils; -import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for all SQL based indexing SPI implementations. */ +@RunWith(JUnit4.class) public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstractTest { - /** */ - private static final TextIndex textIdx = new TextIndex(F.asList("txt")); - /** */ private static final LinkedHashMap fieldsAA = new LinkedHashMap<>(); /** */ private static final LinkedHashMap fieldsAB = new LinkedHashMap<>(); - /** */ - private static final LinkedHashMap fieldsBA = new LinkedHashMap<>(); - /** */ private IgniteEx ignite0; /** {@inheritDoc} */ + @SuppressWarnings("deprecation") @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); @@ -98,20 +74,8 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract fieldsAB.putAll(fieldsAA); fieldsAB.put("txt", String.class.getName()); - - fieldsBA.putAll(fieldsAA); - fieldsBA.put("sex", Boolean.class.getName()); } - /** */ - private static TypeDesc typeAA = new TypeDesc("A", "A", "A", Collections.>emptyMap(), null); - - /** */ - private static TypeDesc typeAB = new TypeDesc("A", "A", "B", Collections.>emptyMap(), textIdx); - - /** */ - private static TypeDesc typeBA = new TypeDesc("B", "B", "A", Collections.>emptyMap(), null); - /** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { ignite0 = startGrid(0); @@ -144,81 +108,11 @@ private CacheConfiguration cacheACfg() { return cfg; } - /** - * - */ - private CacheConfiguration cacheBCfg() { - CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); - - cfg.setName("B"); - - QueryEntity eA = new QueryEntity(Integer.class.getName(), "A"); - eA.setFields(fieldsBA); - - cfg.setQueryEntities(Collections.singleton(eA)); - - return cfg; - } - /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); } - /** - * @param id Id. - * @param name Name. - * @param age Age. - * @return AA. - */ - private BinaryObjectBuilder aa(String typeName, long id, String name, int age) { - BinaryObjectBuilder aBuilder = ignite0.binary().builder(typeName) - .setField("id", id) - .setField("name", name) - .setField("age", age); - - return aBuilder; - } - - /** - * @param id Id. - * @param name Name. - * @param age Age. - * @param txt Text. - * @return AB. - */ - private BinaryObjectBuilder ab(long id, String name, int age, String txt) { - BinaryObjectBuilder aBuilder = aa("B", id, name, age); - - aBuilder.setField("txt", txt); - - return aBuilder; - } - - /** - * @param id Id. - * @param name Name. - * @param age Age. - * @param sex Sex. - * @return BA. - */ - private BinaryObjectBuilder ba(long id, String name, int age, boolean sex) { - BinaryObjectBuilder builder = aa("A", id, name, age); - - builder.setField("sex", sex); - - return builder; - } - - /** - * @param row Row - * @return Value. - * @throws IgniteSpiException If failed. - */ - private BinaryObjectImpl value(IgniteBiTuple row) throws IgniteSpiException { - return row.get2(); - } - /** * @return Indexing. */ @@ -233,148 +127,13 @@ protected boolean offheap() { return false; } - /** - * @param key Key. - * @return Cache object. - */ - private KeyCacheObject key(int key) { - return new TestCacheObject(key); - } - - /** - * @throws Exception If failed. - */ - public void testSpi() throws Exception { - IgniteH2Indexing spi = getIndexing(); - - IgniteCache cacheA = ignite0.createCache(cacheACfg()); - - IgniteCache cacheB = ignite0.createCache(cacheBCfg()); - - assertFalse(spi.queryLocalSql(spi.schema(typeAA.cacheName()), typeAA.cacheName(), "select * from A.A", null, - Collections.emptySet(), typeAA.name(), null, null).hasNext()); - - assertFalse(spi.queryLocalSql(spi.schema(typeAB.cacheName()), typeAB.cacheName(), "select * from A.B", null, - Collections.emptySet(), typeAB.name(), null, null).hasNext()); - - assertFalse(spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(), "select * from B.A", null, - Collections.emptySet(), typeBA.name(), null, null).hasNext()); - - assertFalse(spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(), - "select * from B.A, A.B, A.A", null, Collections.emptySet(), typeBA.name(), null, null).hasNext()); - - try { - spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(), - "select aa.*, ab.*, ba.* from A.A aa, A.B ab, B.A ba", - null, Collections.emptySet(), typeBA.name(), null, null).hasNext(); - - fail("Enumerations of aliases in select block must be prohibited"); - } - catch (IgniteCheckedException ignored) { - // all fine - } - - assertFalse(spi.queryLocalSql(spi.schema(typeAB.cacheName()), typeAB.cacheName(), "select ab.* from A.B ab", - null, Collections.emptySet(), typeAB.name(), null, null).hasNext()); - - assertFalse(spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(), - "select ba.* from B.A as ba", null, Collections.emptySet(), typeBA.name(), null, null).hasNext()); - - cacheA.put(1, aa("A", 1, "Vasya", 10).build()); - cacheA.put(1, ab(1, "Vasya", 20, "Some text about Vasya goes here.").build()); - cacheB.put(1, ba(2, "Petya", 25, true).build()); - cacheB.put(1, ba(2, "Kolya", 25, true).build()); - cacheA.put(2, aa("A", 2, "Valera", 19).build()); - cacheA.put(3, aa("A", 3, "Borya", 18).build()); - cacheA.put(4, ab(4, "Vitalya", 20, "Very Good guy").build()); - - // Query data. - Iterator> res = spi.queryLocalSql(spi.schema(typeAA.cacheName()), - typeAA.cacheName(), "from a order by age", null, Collections.emptySet(), typeAA.name(), null, null); - - assertTrue(res.hasNext()); - assertEquals(aa("A", 3, "Borya", 18).build(), value(res.next())); - assertTrue(res.hasNext()); - assertEquals(aa("A", 2, "Valera", 19).build(), value(res.next())); - assertFalse(res.hasNext()); - - res = spi.queryLocalSql(spi.schema(typeAA.cacheName()), typeAA.cacheName(), - "select aa.* from a aa order by aa.age", null, Collections.emptySet(), typeAA.name(), null, null); - - assertTrue(res.hasNext()); - assertEquals(aa("A", 3, "Borya", 18).build(), value(res.next())); - assertTrue(res.hasNext()); - assertEquals(aa("A", 2, "Valera", 19).build(), value(res.next())); - assertFalse(res.hasNext()); - - res = spi.queryLocalSql(spi.schema(typeAB.cacheName()), typeAB.cacheName(), "from b order by name", null, - Collections.emptySet(), typeAB.name(), null, null); - - assertTrue(res.hasNext()); - assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here.").build(), value(res.next())); - assertTrue(res.hasNext()); - assertEquals(ab(4, "Vitalya", 20, "Very Good guy").build(), value(res.next())); - assertFalse(res.hasNext()); - - res = spi.queryLocalSql(spi.schema(typeAB.cacheName()), typeAB.cacheName(), - "select bb.* from b as bb order by bb.name", null, Collections.emptySet(), typeAB.name(), null, null); - - assertTrue(res.hasNext()); - assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here.").build(), value(res.next())); - assertTrue(res.hasNext()); - assertEquals(ab(4, "Vitalya", 20, "Very Good guy").build(), value(res.next())); - assertFalse(res.hasNext()); - - res = spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(), "from a", null, - Collections.emptySet(), typeBA.name(), null, null); - - assertTrue(res.hasNext()); - assertEquals(ba(2, "Kolya", 25, true).build(), value(res.next())); - assertFalse(res.hasNext()); - - // Text queries - Iterator> txtRes = spi.queryLocalText(spi.schema(typeAB.cacheName()), - typeAB.cacheName(), "good", typeAB.name(), null); - - assertTrue(txtRes.hasNext()); - assertEquals(ab(4, "Vitalya", 20, "Very Good guy").build(), value(txtRes.next())); - assertFalse(txtRes.hasNext()); - - // Fields query - GridQueryFieldsResult fieldsRes = - spi.queryLocalSqlFields(spi.schema("A"), "select a.a.name n1, a.a.age a1, b.a.name n2, " + - "b.a.age a2 from a.a, b.a where a.a.id = b.a.id ", Collections.emptySet(), null, false, false, 0, null); - - String[] aliases = {"N1", "A1", "N2", "A2"}; - Object[] vals = { "Valera", 19, "Kolya", 25}; - - IgniteSpiCloseableIterator> it = fieldsRes.iterator(); - - assertTrue(it.hasNext()); - - List fields = it.next(); - - assertEquals(4, fields.size()); - - int i = 0; - - for (Object f : fields) { - assertEquals(aliases[i], fieldsRes.metaData().get(i).fieldName()); - assertEquals(vals[i++], f); - } - - assertFalse(it.hasNext()); - - // Remove - cacheA.remove(2); - cacheB.remove(1); - } - /** * Test long queries write explain warnings into log. * * @throws Exception If failed. */ + @SuppressWarnings({"unchecked", "deprecation"}) + @Test public void testLongQueries() throws Exception { IgniteH2Indexing spi = getIndexing(); @@ -416,381 +175,4 @@ public void testLongQueries() throws Exception { GridTestUtils.setFieldValue(spi, "log", oldLog); } } - - /** - * Index descriptor. - */ - private static class TextIndex implements GridQueryIndexDescriptor { - /** */ - private final Collection fields; - - /** - * @param fields Fields. - */ - private TextIndex(Collection fields) { - this.fields = Collections.unmodifiableCollection(fields); - } - - /** {@inheritDoc} */ - @Override public String name() { - return null; - } - - /** {@inheritDoc} */ - @Override public Collection fields() { - return fields; - } - - /** {@inheritDoc} */ - @Override public boolean descending(String field) { - return false; - } - - /** {@inheritDoc} */ - @Override public QueryIndexType type() { - return QueryIndexType.FULLTEXT; - } - - /** {@inheritDoc} */ - @Override public int inlineSize() { - return 0; - } - } - - /** - * Type descriptor. - */ - private static class TypeDesc implements GridQueryTypeDescriptor { - /** */ - private final String name; - - /** */ - private final String cacheName; - - /** */ - private final String schemaName; - - /** */ - private final Map> valFields; - - /** */ - private final GridQueryIndexDescriptor textIdx; - - /** - * @param cacheName Cache name. - * @param schemaName Schema name. - * @param name Type name. - * @param valFields Fields. - * @param textIdx Fulltext index. - */ - private TypeDesc(String cacheName, String schemaName, String name, Map> valFields, GridQueryIndexDescriptor textIdx) { - this.name = name; - this.cacheName = cacheName; - this.schemaName = schemaName; - this.valFields = Collections.unmodifiableMap(valFields); - this.textIdx = textIdx; - } - - /** {@inheritDoc} */ - @Override public String affinityKey() { - return null; - } - - /** {@inheritDoc} */ - @Override public String name() { - return name; - } - - /** {@inheritDoc} */ - @Override public String schemaName() { - return schemaName; - } - - /** {@inheritDoc} */ - @Override public String tableName() { - return null; - } - - /** - * @return Cache name. - */ - String cacheName() { - return cacheName; - } - - /** {@inheritDoc} */ - @Override public Map> fields() { - return valFields; - } - - /** {@inheritDoc} */ - @Override public GridQueryProperty property(final String name) { - return new GridQueryProperty() { - /** */ - @Override public Object value(Object key, Object val) throws IgniteCheckedException { - return TypeDesc.this.value(name, key, val); - } - - /** */ - @Override public void setValue(Object key, Object val, Object propVal) throws IgniteCheckedException { - throw new UnsupportedOperationException(); - } - - /** */ - @Override public String name() { - return name; - } - - /** */ - @Override public Class type() { - return Object.class; - } - - /** */ - @Override public boolean key() { - return false; - } - - /** */ - @Override public GridQueryProperty parent() { - return null; - } - - /** */ - @Override public boolean notNull() { - return false; - } - - /** */ - @Override public Object defaultValue() { - return null; - } - - /** */ - @Override public int precision() { - return -1; - } - - /** */ - @Override public int scale() { - return -1; - } - }; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override public T value(String field, Object key, Object val) throws IgniteSpiException { - assert !F.isEmpty(field); - - assert key instanceof Integer; - - Map m = (Map)val; - - if (m.containsKey(field)) - return m.get(field); - - return null; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override public void setValue(String field, Object key, Object val, Object propVal) throws IgniteCheckedException { - assert !F.isEmpty(field); - - assert key instanceof Integer; - - Map m = (Map)val; - - m.put(field, propVal); - } - - /** */ - @Override public Map indexes() { - return Collections.emptyMap(); - } - - /** */ - @Override public GridQueryIndexDescriptor textIndex() { - return textIdx; - } - - /** */ - @Override public Class valueClass() { - return Object.class; - } - - /** */ - @Override public Class keyClass() { - return Integer.class; - } - - /** */ - @Override public String keyTypeName() { - return null; - } - - /** */ - @Override public String valueTypeName() { - return null; - } - - /** */ - @Override public boolean valueTextIndex() { - return textIdx == null; - } - - /** */ - @Override public int typeId() { - return 0; - } - - /** {@inheritDoc} */ - @Override public String keyFieldName() { - return null; - } - - /** {@inheritDoc} */ - @Override public String valueFieldName() { - return null; - } - - /** {@inheritDoc} */ - @Nullable @Override public String keyFieldAlias() { - return null; - } - - /** {@inheritDoc} */ - @Nullable @Override public String valueFieldAlias() { - return null; - } - - /** {@inheritDoc} */ - @Override public void validateKeyAndValue(Object key, Object value) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void setDefaults(Object key, Object val) throws IgniteCheckedException { - // No-op. - } - } - - /** - */ - private static class TestCacheObject implements KeyCacheObject { - /** */ - private Object val; - - /** */ - private int part; - - /** - * @param val Value. - */ - private TestCacheObject(Object val) { - this.val = val; - } - - /** {@inheritDoc} */ - @Override public void onAckReceived() { - // No-op. - } - - /** {@inheritDoc} */ - @Nullable @Override public T value(CacheObjectValueContext ctx, boolean cpy) { - return (T)val; - } - - /** {@inheritDoc} */ - @Override public int partition() { - return part; - } - - /** {@inheritDoc} */ - @Override public void partition(int part) { - this.part = part; - } - - /** {@inheritDoc} */ - @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException { - return JdbcUtils.serialize(val, null); - } - - /** {@inheritDoc} */ - @Override public boolean putValue(ByteBuffer buf) throws IgniteCheckedException { - return false; - } - - /** {@inheritDoc} */ - @Override public int putValue(long addr) throws IgniteCheckedException { - return 0; - } - - /** {@inheritDoc} */ - @Override public boolean putValue(final ByteBuffer buf, final int off, final int len) - throws IgniteCheckedException { - return false; - } - - /** {@inheritDoc} */ - @Override public int valueBytesLength(CacheObjectContext ctx) throws IgniteCheckedException { - return 0; - } - - /** {@inheritDoc} */ - @Override public byte cacheObjectType() { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public boolean isPlatformType() { - return true; - } - - /** {@inheritDoc} */ - @Override public KeyCacheObject copy(int part) { - return this; - } - - /** {@inheritDoc} */ - @Override public CacheObject prepareForCache(CacheObjectContext ctx) { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public short directType() { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public byte fieldsCount() { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public boolean internal() { - return false; - } - } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIteratorNullifyOnEndSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIteratorNullifyOnEndSelfTest.java index 31b0b97c5b0ed..8f324a39a34e8 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIteratorNullifyOnEndSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIteratorNullifyOnEndSelfTest.java @@ -35,10 +35,14 @@ import org.apache.ignite.internal.util.lang.GridCloseableIterator; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for iterator data link erasure after closing or completing */ +@RunWith(JUnit4.class) public class H2ResultSetIteratorNullifyOnEndSelfTest extends GridCommonAbstractTest { /** */ private static final int NODES_COUNT = 2; @@ -55,6 +59,7 @@ public class H2ResultSetIteratorNullifyOnEndSelfTest extends GridCommonAbstractT /** * Non local SQL check nullification after close */ + @Test public void testSqlQueryClose() { SqlQuery qry = new SqlQuery<>(Person.class, SELECT_ALL_SQL); @@ -72,6 +77,7 @@ public void testSqlQueryClose() { /** * Non local SQL check nullification after complete */ + @Test public void testSqlQueryComplete() { SqlQuery qry = new SqlQuery<>(Person.class, SELECT_ALL_SQL); @@ -87,6 +93,7 @@ public void testSqlQueryComplete() { /** * Local SQL check nullification after close */ + @Test public void testSqlQueryLocalClose() { SqlQuery qry = new SqlQuery<>(Person.class, SELECT_ALL_SQL); @@ -106,6 +113,7 @@ public void testSqlQueryLocalClose() { /** * Local SQL check nullification after complete */ + @Test public void testSqlQueryLocalComplete() { SqlQuery qry = new SqlQuery<>(Person.class, SELECT_ALL_SQL); @@ -123,6 +131,7 @@ public void testSqlQueryLocalComplete() { /** * Non local SQL Fields check nullification after close */ + @Test public void testSqlFieldsQueryClose() { SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF); @@ -140,6 +149,7 @@ public void testSqlFieldsQueryClose() { /** * Non local SQL Fields check nullification after complete */ + @Test public void testSqlFieldsQueryComplete() { SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF); @@ -155,6 +165,7 @@ public void testSqlFieldsQueryComplete() { /** * Local SQL Fields check nullification after close */ + @Test public void testSqlFieldsQueryLocalClose() { SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF); @@ -174,6 +185,7 @@ public void testSqlFieldsQueryLocalClose() { /** * Local SQL Fields check nullification after complete */ + @Test public void testSqlFieldsQueryLocalComplete() { SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF); @@ -259,6 +271,7 @@ private H2ResultSetIterator extractGridIteratorInnerH2ResultSetIterator(QueryCur /** * "onClose" should remove links to data. */ + @Test public void testOnClose() { try { GridCloseableIterator it = indexing().queryLocalSql( @@ -289,6 +302,7 @@ public void testOnClose() { /** * Complete iterate should remove links to data. */ + @Test public void testOnComplete() { try { GridCloseableIterator it = indexing().queryLocalSql( diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2StatementCacheSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2StatementCacheSelfTest.java index 655d039632386..f3bd8d7f7a1c0 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2StatementCacheSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2StatementCacheSelfTest.java @@ -19,15 +19,20 @@ import java.sql.PreparedStatement; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class H2StatementCacheSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testEviction() throws Exception { H2StatementCache stmtCache = new H2StatementCache(1); H2CachedStatementKey key1 = new H2CachedStatementKey("", "1"); @@ -44,6 +49,7 @@ public void testEviction() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLruEvictionInStoreOrder() throws Exception { H2StatementCache stmtCache = new H2StatementCache(2); @@ -60,6 +66,7 @@ public void testLruEvictionInStoreOrder() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLruEvictionInAccessOrder() throws Exception { H2StatementCache stmtCache = new H2StatementCache(2); @@ -80,4 +87,4 @@ public void testLruEvictionInAccessOrder() throws Exception { private static PreparedStatement stmt() { return new PreparedStatementExImpl(null); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/IgniteSqlBigIntegerKeyTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/IgniteSqlBigIntegerKeyTest.java index 366c61ac15f12..262beabeb1a88 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/IgniteSqlBigIntegerKeyTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/IgniteSqlBigIntegerKeyTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Ensures that BigInteger can be used as key */ +@RunWith(JUnit4.class) public class IgniteSqlBigIntegerKeyTest extends GridCommonAbstractTest { /** */ private static final String CACHE_NAME = "Mycache"; @@ -65,6 +69,7 @@ private IgniteCache getCache() { } /** */ + @Test public void testBigIntegerKeyGet() { IgniteCache cache = getCache(); @@ -82,6 +87,7 @@ public void testBigIntegerKeyGet() { } /** */ + @Test public void testBigIntegerKeyQuery() { IgniteCache cache = getCache(); @@ -90,6 +96,7 @@ public void testBigIntegerKeyQuery() { } /** */ + @Test public void testBigIntegerFieldQuery() { IgniteCache cache = getCache(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/IgniteSqlQueryMinMaxTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/IgniteSqlQueryMinMaxTest.java index e8403ec23a0c8..2d1409a304cdf 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/IgniteSqlQueryMinMaxTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/IgniteSqlQueryMinMaxTest.java @@ -24,17 +24,16 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** Test for SQL min() and max() optimization */ +@RunWith(JUnit4.class) public class IgniteSqlQueryMinMaxTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Name of the cache for test */ private static final String CACHE_NAME = "intCache"; @@ -59,10 +58,6 @@ public class IgniteSqlQueryMinMaxTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - - spi.setIpFinder(IP_FINDER); - CacheConfiguration ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setIndexedTypes(Integer.class, Integer.class); ccfg.setName(CACHE_NAME); @@ -80,6 +75,7 @@ public class IgniteSqlQueryMinMaxTest extends GridCommonAbstractTest { } /** Check min() and max() functions in queries */ + @Test public void testQueryMinMax() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME_2); @@ -118,6 +114,7 @@ public void testQueryMinMax() throws Exception { } /** Check min() and max() on empty cache */ + @Test public void testQueryMinMaxEmptyCache() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME_2); @@ -135,6 +132,7 @@ public void testQueryMinMaxEmptyCache() throws Exception { * Check min() and max() over _key use correct index * Test uses value object cache */ + @Test public void testMinMaxQueryPlanOnKey() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME_2); @@ -151,6 +149,7 @@ public void testMinMaxQueryPlanOnKey() throws Exception { * Check min() and max() over value fields use correct index. * Test uses value object cache */ + @Test public void testMinMaxQueryPlanOnFields() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME_2); @@ -167,6 +166,7 @@ public void testMinMaxQueryPlanOnFields() throws Exception { * Check min() and max() over _key uses correct index * Test uses primitive cache */ + @Test public void testSimpleMinMaxQueryPlanOnKey() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME); @@ -183,6 +183,7 @@ public void testSimpleMinMaxQueryPlanOnKey() throws Exception { * Check min() and max() over _val uses correct index. * Test uses primitive cache */ + @Test public void testSimpleMinMaxQueryPlanOnValue() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME); @@ -196,6 +197,7 @@ public void testSimpleMinMaxQueryPlanOnValue() throws Exception { } /** Check min() and max() over group */ + @Test public void testGroupMinMax() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME_2); @@ -225,6 +227,7 @@ public void testGroupMinMax() throws Exception { } /** Check min() and max() over group with having clause */ + @Test public void testGroupHavingMinMax() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME_2); @@ -261,6 +264,7 @@ public void testGroupHavingMinMax() throws Exception { } /** Check min() and max() over group with joins */ + @Test public void testJoinGroupMinMax() throws Exception { try (Ignite client = startGrid("client")) { IgniteCache cache = client.cache(CACHE_NAME); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/PreparedStatementExSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/PreparedStatementExSelfTest.java index 22bff3b2a9b9b..808413bce685f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/PreparedStatementExSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/PreparedStatementExSelfTest.java @@ -19,14 +19,19 @@ import java.sql.PreparedStatement; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class PreparedStatementExSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testStoringMeta() throws Exception { PreparedStatement stmt = stmt(); @@ -40,6 +45,7 @@ public void testStoringMeta() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStoringMoreMetaKeepsExisting() throws Exception { PreparedStatement stmt = stmt(); @@ -58,4 +64,4 @@ public void testStoringMoreMetaKeepsExisting() throws Exception { private static PreparedStatement stmt() { return new PreparedStatementExImpl(null); } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/ThreadLocalObjectPoolSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/ThreadLocalObjectPoolSelfTest.java index b7b7a3701c975..7a11261a2f0ca 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/ThreadLocalObjectPoolSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/ThreadLocalObjectPoolSelfTest.java @@ -20,10 +20,14 @@ import java.util.concurrent.CompletableFuture; import org.apache.ignite.internal.processors.query.h2.ThreadLocalObjectPool.Reusable; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class ThreadLocalObjectPoolSelfTest extends GridCommonAbstractTest { /** */ private ThreadLocalObjectPool pool = new ThreadLocalObjectPool<>(Obj::new, 1); @@ -31,6 +35,7 @@ public class ThreadLocalObjectPoolSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testObjectIsReusedAfterRecycling() throws Exception { Reusable o1 = pool.borrow(); o1.recycle(); @@ -43,6 +48,7 @@ public void testObjectIsReusedAfterRecycling() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBorrowedObjectIsNotReturnedTwice() throws Exception { Reusable o1 = pool.borrow(); Reusable o2 = pool.borrow(); @@ -53,6 +59,7 @@ public void testBorrowedObjectIsNotReturnedTwice() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectShouldBeClosedOnRecycleIfPoolIsFull() throws Exception { Reusable o1 = pool.borrow(); Reusable o2 = pool.borrow(); @@ -65,6 +72,7 @@ public void testObjectShouldBeClosedOnRecycleIfPoolIsFull() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectShouldNotBeReturnedIfPoolIsFull() throws Exception { Reusable o1 = pool.borrow(); Reusable o2 = pool.borrow(); @@ -81,6 +89,7 @@ public void testObjectShouldNotBeReturnedIfPoolIsFull() throws Exception { /** * @throws Exception If failed. */ + @Test public void testObjectShouldReturnedToRecyclingThreadBag() throws Exception { Reusable o1 = pool.borrow(); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java index 06001379d36e4..3604248215eb6 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java @@ -51,6 +51,9 @@ import org.h2.value.ValueTime; import org.h2.value.ValueTimestamp; import org.h2.value.ValueUuid; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.util.SerializationUtils; import static org.apache.ignite.internal.processors.query.h2.database.InlineIndexHelper.CANT_BE_COMPARE; @@ -58,6 +61,7 @@ /** * Simple tests for {@link InlineIndexHelper}. */ +@RunWith(JUnit4.class) public class InlineIndexHelperTest extends GridCommonAbstractTest { /** */ private static final int CACHE_ID = 42; @@ -72,6 +76,7 @@ public class InlineIndexHelperTest extends GridCommonAbstractTest { private static final Comparator ALWAYS_FAILS_COMPARATOR = new AlwaysFailsComparator(); /** Test utf-8 string cutting. */ + @Test public void testConvert() { // 8 bytes total: 1b, 1b, 3b, 3b. @@ -86,6 +91,7 @@ public void testConvert() { } /** */ + @Test public void testCompare1bytes() throws Exception { int maxSize = 3 + 2; // 2 ascii chars + 3 bytes header. @@ -101,6 +107,7 @@ public void testCompare1bytes() throws Exception { } /** */ + @Test public void testCompare2bytes() throws Exception { int maxSize = 3 + 4; // 2 2-bytes chars + 3 bytes header. @@ -116,6 +123,7 @@ public void testCompare2bytes() throws Exception { } /** */ + @Test public void testCompare3bytes() throws Exception { int maxSize = 3 + 6; // 2 3-bytes chars + 3 bytes header. @@ -131,6 +139,7 @@ public void testCompare3bytes() throws Exception { } /** */ + @Test public void testCompare4bytes() throws Exception { int maxSize = 3 + 8; // 2 4-bytes chars + 3 bytes header. @@ -146,6 +155,7 @@ public void testCompare4bytes() throws Exception { } /** */ + @Test public void testCompareMixed() throws Exception { int maxSize = 3 + 8; // 2 up to 4-bytes chars + 3 bytes header. @@ -156,6 +166,7 @@ public void testCompareMixed() throws Exception { } /** */ + @Test public void testCompareMixed2() throws Exception { int strCnt = 1000; int symbCnt = 20; @@ -225,6 +236,7 @@ private int putAndCompare(String v1, String v2, int maxSize) throws Exception { } /** Limit is too small to cut */ + @Test public void testStringCut() { // 6 bytes total: 3b, 3b. byte[] bytes = InlineIndexHelper.trimUTF8("\u20ac\u20ac".getBytes(Charsets.UTF_8), 2); @@ -233,6 +245,7 @@ public void testStringCut() { } /** Test on String values compare */ + @Test public void testRelyOnCompare() { InlineIndexHelper ha = new InlineIndexHelper("", Value.STRING, 0, SortOrder.ASCENDING, CompareMode.getInstance(null, 0)); @@ -255,6 +268,7 @@ public void testRelyOnCompare() { } /** Test on Bytes values compare */ + @Test public void testRelyOnCompareBytes() { InlineIndexHelper ha = new InlineIndexHelper("", Value.BYTES, 0, SortOrder.ASCENDING, CompareMode.getInstance(null, 0)); @@ -277,6 +291,7 @@ public void testRelyOnCompareBytes() { } /** Test on Bytes values compare */ + @Test public void testRelyOnCompareJavaObject() { InlineIndexHelper ha = new InlineIndexHelper("",Value.JAVA_OBJECT, 0, SortOrder.ASCENDING, CompareMode.getInstance(null, 0)); @@ -301,6 +316,7 @@ public void testRelyOnCompareJavaObject() { } /** */ + @Test public void testStringTruncate() throws Exception { DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB) .setMaxSize(1024 * MB); @@ -352,6 +368,7 @@ public void testStringTruncate() throws Exception { } /** */ + @Test public void testBytes() throws Exception { DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB) .setMaxSize(1024 * MB); @@ -410,6 +427,7 @@ public void testBytes() throws Exception { } /** */ + @Test public void testJavaObject() throws Exception { DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB) .setMaxSize(1024 * MB); @@ -468,6 +486,7 @@ public void testJavaObject() throws Exception { } /** */ + @Test public void testNull() throws Exception { testPutGet(ValueInt.get(-1), ValueNull.INSTANCE, ValueInt.get(3)); testPutGet(ValueInt.get(-1), ValueNull.INSTANCE, ValueInt.get(3)); @@ -477,41 +496,49 @@ public void testNull() throws Exception { } /** */ + @Test public void testBoolean() throws Exception { testPutGet(ValueBoolean.get(true), ValueBoolean.get(false), ValueBoolean.get(true)); } /** */ + @Test public void testByte() throws Exception { testPutGet(ValueByte.get((byte)-1), ValueByte.get((byte)2), ValueByte.get((byte)3)); } /** */ + @Test public void testShort() throws Exception { testPutGet(ValueShort.get((short)-32000), ValueShort.get((short)2), ValueShort.get((short)3)); } /** */ + @Test public void testInt() throws Exception { testPutGet(ValueInt.get(-1), ValueInt.get(2), ValueInt.get(3)); } /** */ + @Test public void testLong() throws Exception { testPutGet(ValueLong.get(-1), ValueLong.get(2), ValueLong.get(3)); } /** */ + @Test public void testFloat() throws Exception { testPutGet(ValueFloat.get(1.1f), ValueFloat.get(2.2f), ValueFloat.get(1.1f)); } /** */ + @Test public void testDouble() throws Exception { testPutGet(ValueDouble.get(1.1f), ValueDouble.get(2.2f), ValueDouble.get(1.1f)); } /** */ + @Test public void testDate() throws Exception { testPutGet(ValueDate.get(Date.valueOf("2017-02-20")), ValueDate.get(Date.valueOf("2017-02-21")), @@ -519,6 +546,7 @@ public void testDate() throws Exception { } /** */ + @Test public void testTime() throws Exception { testPutGet(ValueTime.get(Time.valueOf("10:01:01")), ValueTime.get(Time.valueOf("11:02:02")), @@ -526,6 +554,7 @@ public void testTime() throws Exception { } /** */ + @Test public void testTimestamp() throws Exception { testPutGet(ValueTimestamp.get(Timestamp.valueOf("2017-02-20 10:01:01")), ValueTimestamp.get(Timestamp.valueOf("2017-02-20 10:01:01")), @@ -533,6 +562,7 @@ public void testTimestamp() throws Exception { } /** */ + @Test public void testUUID() throws Exception { testPutGet(ValueUuid.get(UUID.randomUUID().toString()), ValueUuid.get(UUID.randomUUID().toString()), diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/AbstractH2CompareQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/AbstractH2CompareQueryTest.java index b1d58421b255c..8e16ed022cf3b 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/AbstractH2CompareQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/AbstractH2CompareQueryTest.java @@ -41,9 +41,6 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; @@ -52,9 +49,6 @@ * partitioned) which have the same data models and data content. */ public abstract class AbstractH2CompareQueryTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ protected static Ignite ignite; @@ -69,12 +63,6 @@ public abstract class AbstractH2CompareQueryTest extends GridCommonAbstractTest @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - c.setDiscoverySpi(disco); - c.setMarshaller(new BinaryMarshaller()); return c; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java index f9d25d67d8f0e..157dc3b61dae8 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java @@ -39,11 +39,15 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testsuites.IgniteIgnore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Base set of queries to compare query results from h2 database instance and mixed ignite caches (replicated and partitioned) * which have the same data models and data content. */ +@RunWith(JUnit4.class) public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest { /** Org count. */ public static final int ORG_CNT = 30; @@ -223,6 +227,7 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest { /** * */ + @Test public void testSelectStar() { assertEquals(1, cachePers.query(new SqlQuery,Person>( Person.class, "\t\r\n select \n*\t from Person limit 1")).getAll().size()); @@ -239,6 +244,7 @@ public void testSelectStar() { /** * @throws Exception If failed. */ + @Test public void testInvalidQuery() throws Exception { final SqlFieldsQuery sql = new SqlFieldsQuery("SELECT firstName from Person where id <> ? and orgId <> ?"); @@ -255,6 +261,7 @@ public void testInvalidQuery() throws Exception { * @throws Exception */ @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-705", forceFailure = true) + @Test public void testAllExamples() throws Exception { // compareQueryRes0("select ? limit ? offset ?"); @@ -424,6 +431,7 @@ public void testAllExamples() throws Exception { /** * @throws Exception If failed. */ + @Test public void testParamSubstitution() throws Exception { compareQueryRes0(cachePers, "select ? from \"pers\".Person", "Some arg"); } @@ -431,6 +439,7 @@ public void testParamSubstitution() throws Exception { /** * @throws SQLException If failed. */ + @Test public void testAggregateOrderBy() throws SQLException { compareOrderedQueryRes0(cachePers, "select firstName name, count(*) cnt from \"pers\".Person " + "group by name order by cnt, name desc"); @@ -439,6 +448,7 @@ public void testAggregateOrderBy() throws SQLException { /** * @throws Exception If failed. */ + @Test public void testNullParamSubstitution() throws Exception { List> rs1 = compareQueryRes0(cachePers, "select ? from \"pers\".Person", null); @@ -449,6 +459,7 @@ public void testNullParamSubstitution() throws Exception { /** * */ + @Test public void testUnion() throws SQLException { String base = "select _val v from \"pers\".Person"; @@ -464,6 +475,7 @@ public void testUnion() throws SQLException { /** * @throws Exception If failed. */ + @Test public void testEmptyResult() throws Exception { compareQueryRes0(cachePers, "select id from \"pers\".Person where 0 = 1"); } @@ -471,6 +483,7 @@ public void testEmptyResult() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlQueryWithAggregation() throws Exception { compareQueryRes0(cachePers, "select avg(salary) from \"pers\".Person, \"org\".Organization " + "where Person.orgId = Organization.id and " + @@ -480,6 +493,7 @@ public void testSqlQueryWithAggregation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlFieldsQuery() throws Exception { compareQueryRes0(cachePers, "select concat(firstName, ' ', lastName) from \"pers\".Person"); } @@ -487,6 +501,7 @@ public void testSqlFieldsQuery() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSqlFieldsQueryWithJoin() throws Exception { compareQueryRes0(cachePers, "select concat(firstName, ' ', lastName), " + "Organization.name from \"pers\".Person, \"org\".Organization where " @@ -496,6 +511,7 @@ public void testSqlFieldsQueryWithJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testOrdered() throws Exception { compareOrderedQueryRes0(cachePers, "select firstName, lastName" + " from \"pers\".Person" + @@ -505,6 +521,7 @@ public void testOrdered() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleJoin() throws Exception { // Have expected results. compareQueryRes0(cachePers, String.format("select id, firstName, lastName" + @@ -520,6 +537,7 @@ public void testSimpleJoin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleReplicatedSelect() throws Exception { compareQueryRes0(cacheProd, "select id, name from \"prod\".Product"); } @@ -527,6 +545,7 @@ public void testSimpleReplicatedSelect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCrossCache() throws Exception { compareQueryRes0(cachePers, "select firstName, lastName" + " from \"pers\".Person, \"purch\".Purchase" + @@ -962,4 +981,4 @@ private static class Address implements Serializable { return "Address [id=" + id + ", street=" + street + ']'; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java index de77150c51d34..a3a3a093f6c61 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java @@ -48,9 +48,6 @@ import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.h2.command.Prepared; @@ -60,6 +57,9 @@ import org.h2.table.Column; import org.h2.value.Value; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheRebalanceMode.SYNC; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -67,10 +67,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridQueryParsingTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ private static Ignite ignite; @@ -79,12 +77,6 @@ public class GridQueryParsingTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(ipFinder); - - c.setDiscoverySpi(disco); - c.setCacheConfiguration( cacheConfiguration(DEFAULT_CACHE_NAME, "SCH1", String.class, Person.class), cacheConfiguration("addr", "SCH2", String.class, Address.class), @@ -135,6 +127,7 @@ private CacheConfiguration cacheConfiguration(@NotNull String name, String sqlSc /** * @throws Exception If failed. */ + @Test public void testParseSelectAndUnion() throws Exception { checkQuery("select 1 from Person p where addrIds in ((1,2,3), (3,4,5))"); checkQuery("select 1 from Person p where addrId in ((1,))"); @@ -328,6 +321,7 @@ public void testParseSelectAndUnion() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUseIndexHints() throws Exception { checkQuery("select * from Person use index (\"PERSON_NAME_IDX\")"); checkQuery("select * from Person use index (\"PERSON_PARENTNAME_IDX\")"); @@ -345,6 +339,7 @@ public void testUseIndexHints() throws Exception { * * @throws Exception If failed. */ + @Test public void testParseTableFilter() throws Exception { Prepared prepared = parse("select Person.old, p1.old, p1.addrId from Person, Person p1 " + "where exists(select 1 from sch2.Address a where a.id = p1.addrId)"); @@ -388,6 +383,7 @@ public void testParseTableFilter() throws Exception { } /** */ + @Test public void testParseMerge() throws Exception { /* Plain rows w/functions, operators, defaults, and placeholders. */ checkQuery("merge into Person(old, name) values(5, 'John')"); @@ -434,6 +430,7 @@ public void testParseMerge() throws Exception { } /** */ + @Test public void testParseInsert() throws Exception { /* Plain rows w/functions, operators, defaults, and placeholders. */ checkQuery("insert into Person(old, name) values(5, 'John')"); @@ -476,6 +473,7 @@ public void testParseInsert() throws Exception { } /** */ + @Test public void testParseDelete() throws Exception { checkQuery("delete from Person"); checkQuery("delete from Person p where p.old > ?"); @@ -487,6 +485,7 @@ public void testParseDelete() throws Exception { } /** */ + @Test public void testParseUpdate() throws Exception { checkQuery("update Person set name='Peter'"); checkQuery("update Person per set name='Peter', old = 5"); @@ -503,6 +502,7 @@ public void testParseUpdate() throws Exception { /** * */ + @Test public void testParseCreateIndex() throws Exception { assertCreateIndexEquals( buildCreateIndex(null, "Person", "sch1", false, QueryIndexType.SORTED, @@ -561,6 +561,7 @@ public void testParseCreateIndex() throws Exception { /** * */ + @Test public void testParseDropIndex() throws Exception { // Schema that is not set defaults to default schema of connection which is sch1 assertDropIndexEquals(buildDropIndex("idx", "sch1", false), "drop index idx"); @@ -578,6 +579,7 @@ public void testParseDropIndex() throws Exception { /** * */ + @Test public void testParseDropTable() throws Exception { // Schema that is not set defaults to default schema of connection which is sch1 assertDropTableEquals(buildDropTable("sch1", "tbl", false), "drop table tbl"); @@ -593,6 +595,7 @@ public void testParseDropTable() throws Exception { } /** */ + @Test public void testParseCreateTable() throws Exception { assertCreateTableEquals( buildCreateTable("sch1", "Person", "cache", F.asList("id", "city"), @@ -636,6 +639,7 @@ false, c("id", Value.INT), c("city", Value.STRING), c("name", Value.STRING), } /** */ + @Test public void testParseCreateTableWithDefaults() { assertParseThrows("create table Person (id int primary key, age int, " + "ts TIMESTAMP default CURRENT_TIMESTAMP()) WITH \"template=cache\"", @@ -653,6 +657,7 @@ public void testParseCreateTableWithDefaults() { } /** */ + @Test public void testParseAlterTableAddColumn() throws Exception { assertAlterTableAddColumnEquals(buildAlterTableAddColumn("SCH2", "Person", false, false, c("COMPANY", Value.STRING)), "ALTER TABLE SCH2.Person ADD company varchar"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java index 50b71b598216e..3c3a785e07198 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java @@ -36,6 +36,9 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.X; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Executes one big query (and subqueries of the big query) to compare query results from h2 database instance and @@ -72,6 +75,7 @@ * * */ +@RunWith(JUnit4.class) public class H2CompareBigQueryTest extends AbstractH2CompareQueryTest { /** Root order count. */ private static final int ROOT_ORDER_CNT = 1000; @@ -282,6 +286,7 @@ protected boolean distributedJoins() { /** * @throws Exception If failed. */ + @Test public void testBigQuery() throws Exception { X.println(); X.println(bigQry); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/CacheQueryMemoryLeakTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/CacheQueryMemoryLeakTest.java index 754504e14a990..8d801e768cba3 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/CacheQueryMemoryLeakTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/CacheQueryMemoryLeakTest.java @@ -32,22 +32,19 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** */ +@RunWith(JUnit4.class) public class CacheQueryMemoryLeakTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration igniteCfg = super.getConfiguration(igniteInstanceName); - ((TcpDiscoverySpi)igniteCfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - if (igniteInstanceName.equals("client")) igniteCfg.setClientMode(true); @@ -64,6 +61,7 @@ public class CacheQueryMemoryLeakTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testResultIsMultipleOfPage() throws Exception { IgniteEx srv = (IgniteEx)startGrid("server"); Ignite client = startGrid("client"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheCauseRetryMessageSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheCauseRetryMessageSelfTest.java index 8c4358a7fd722..b9c846ad7a57c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheCauseRetryMessageSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheCauseRetryMessageSelfTest.java @@ -32,6 +32,9 @@ import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT; import static org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization; @@ -40,6 +43,7 @@ /** * Failed to reserve partitions for query (cache is not found on local node) Root cause test */ +@RunWith(JUnit4.class) public class DisappearedCacheCauseRetryMessageSelfTest extends GridCommonAbstractTest { /** */ private static final int NODES_COUNT = 2; @@ -51,6 +55,7 @@ public class DisappearedCacheCauseRetryMessageSelfTest extends GridCommonAbstrac private IgniteCache orgCache; /** */ + @Test public void testDisappearedCacheCauseRetryMessage() { SqlQuery qry = new SqlQuery(JoinSqlTestHelper.Person.class, JoinSqlTestHelper.JOIN_SQL).setArgs("Organization #0"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheWasNotFoundMessageSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheWasNotFoundMessageSelfTest.java index 9928ed6ff2745..c54f2695f18c0 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheWasNotFoundMessageSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/DisappearedCacheWasNotFoundMessageSelfTest.java @@ -31,7 +31,11 @@ import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT; import static org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization; @@ -40,6 +44,7 @@ /** * Grid cache context is not registered for cache id root cause message test */ +@RunWith(JUnit4.class) public class DisappearedCacheWasNotFoundMessageSelfTest extends GridCommonAbstractTest { /** */ private static final int NODES_COUNT = 2; @@ -51,6 +56,7 @@ public class DisappearedCacheWasNotFoundMessageSelfTest extends GridCommonAbstra private IgniteCache orgCache; /** */ + @Test public void testDisappearedCacheWasNotFoundMessage() { SqlQuery qry = new SqlQuery(Person.class, JoinSqlTestHelper.JOIN_SQL).setArgs("Organization #0"); @@ -62,7 +68,10 @@ public void testDisappearedCacheWasNotFoundMessage() { fail("No CacheException emitted."); } catch (CacheException e) { - assertTrue(e.getMessage(), e.getMessage().contains("Cache not found on local node")); + boolean exp = e.getMessage().contains("Cache not found on local node (was concurrently destroyed?)"); + + if (!exp) + throw e; } } @@ -70,6 +79,8 @@ public void testDisappearedCacheWasNotFoundMessage() { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); + cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(LOCAL_IP_FINDER)); + cfg.setCommunicationSpi(new TcpCommunicationSpi(){ /** {@inheritDoc} */ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure ackC) { diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/NonCollocatedRetryMessageSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/NonCollocatedRetryMessageSelfTest.java index c602225e8e30e..2b657b126d728 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/NonCollocatedRetryMessageSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/NonCollocatedRetryMessageSelfTest.java @@ -36,12 +36,16 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT; /** * Failed to execute non-collocated query root cause message test */ +@RunWith(JUnit4.class) public class NonCollocatedRetryMessageSelfTest extends GridCommonAbstractTest { /** */ private static final int NODES_COUNT = 3; @@ -53,6 +57,7 @@ public class NonCollocatedRetryMessageSelfTest extends GridCommonAbstractTest { private IgniteCache personCache; /** */ + @Test public void testNonCollocatedRetryMessage() { SqlQuery qry = new SqlQuery(JoinSqlTestHelper.Person.class, JoinSqlTestHelper.JOIN_SQL).setArgs("Organization #0"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/RetryCauseMessageSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/RetryCauseMessageSelfTest.java index dbb2c59bc2fd7..3ebda5a355cac 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/RetryCauseMessageSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/RetryCauseMessageSelfTest.java @@ -43,6 +43,10 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT; import static org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE; @@ -53,6 +57,7 @@ /** * Test for 6 retry cases */ +@RunWith(JUnit4.class) public class RetryCauseMessageSelfTest extends GridCommonAbstractTest { /** */ private static final int NODES_COUNT = 2; @@ -80,6 +85,7 @@ public class RetryCauseMessageSelfTest extends GridCommonAbstractTest { /** * Failed to reserve partitions for query (cache is not found on local node) */ + @Test public void testSynthCacheWasNotFoundMessage() { GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec"); @@ -121,6 +127,7 @@ public void testSynthCacheWasNotFoundMessage() { /** * Failed to reserve partitions for query (group reservation failed) */ + @Test public void testGrpReservationFailureMessage() { final GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec"); @@ -166,7 +173,11 @@ public void testGrpReservationFailureMessage() { /** * Failed to reserve partitions for query (partition of REPLICATED cache is not in OWNING state) */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-7039") + @Test public void testReplicatedCacheReserveFailureMessage() { + fail("https://issues.apache.org/jira/browse/IGNITE-7039"); + GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec"); final GridKernalContext ctx = GridTestUtils.getFieldValue(mapQryExec, GridMapQueryExecutor.class, "ctx"); @@ -189,7 +200,7 @@ public void testReplicatedCacheReserveFailureMessage() { aState.getAndSet(stateVal); } - else + else startedExecutor.onMessage(nodeId, msg); } }.insertRealExecutor(mapQryExec)); @@ -197,6 +208,7 @@ public void testReplicatedCacheReserveFailureMessage() { SqlQuery qry = new SqlQuery<>(Organization.class, ORG_SQL); qry.setDistributedJoins(true); + try { orgCache.query(qry).getAll(); } @@ -214,6 +226,7 @@ public void testReplicatedCacheReserveFailureMessage() { /** * Failed to reserve partitions for query (partition of PARTITIONED cache cannot be reserved) */ + @Test public void testPartitionedCacheReserveFailureMessage() { GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec"); @@ -264,6 +277,7 @@ public void testPartitionedCacheReserveFailureMessage() { /** * Failed to execute non-collocated query (will retry) */ + @Test public void testNonCollocatedFailureMessage() { final GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/TableViewSubquerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/TableViewSubquerySelfTest.java index eaf4243018ff3..677344d719cf8 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/TableViewSubquerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/twostep/TableViewSubquerySelfTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class TableViewSubquerySelfTest extends GridCommonAbstractTest { /** */ private static final int NODES_COUNT = 1; @@ -52,6 +56,7 @@ public class TableViewSubquerySelfTest extends GridCommonAbstractTest { } /** */ + @Test public void testSubqueryTableView() { final String cacheName = "a1"; diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedAtomicColumnConstraintsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedAtomicColumnConstraintsTest.java index 601090fa3faa1..2e7effef667f2 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedAtomicColumnConstraintsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedAtomicColumnConstraintsTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.sql; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -37,8 +38,12 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.processors.query.QueryUtils.KEY_FIELD_NAME; @@ -46,6 +51,7 @@ import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; /** */ +@RunWith(JUnit4.class) public class IgniteCachePartitionedAtomicColumnConstraintsTest extends GridCommonAbstractTest { /** */ private static final long FUT_TIMEOUT = 10_000L; @@ -55,12 +61,31 @@ public class IgniteCachePartitionedAtomicColumnConstraintsTest extends GridCommo /** */ private static final String STR_ORG_CACHE_NAME = "STR_ORG"; - + + /** */ private static final String STR_ORG_WITH_FIELDS_CACHE_NAME = "STR_ORG_WITH_FIELDS"; /** */ private static final String OBJ_CACHE_NAME = "ORG_ADDRESS"; + /** */ + private static final String DEC_CACHE_NAME_FOR_SCALE = "DEC_DEC_FOR_SCALE"; + + /** */ + private static final String OBJ_CACHE_NAME_FOR_SCALE = "ORG_EMPLOYEE_FOR_SCALE"; + + /** */ + private static final String DEC_EMPL_CACHE_NAME_FOR_SCALE = "DEC_EMPLOYEE_FOR_SCALE"; + + /** */ + private static final String DEC_CACHE_NAME_FOR_PREC = "DEC_DEC_FOR_PREC"; + + /** */ + private static final String OBJ_CACHE_NAME_FOR_PREC = "ORG_EMPLOYEE_FOR_PREC"; + + /** */ + private static final String DEC_EMPL_CACHE_NAME_FOR_PREC = "DEC_EMPLOYEE_FOR_PREC"; + /** */ private Consumer shouldFail = (op) -> assertThrowsWithCause(op, IgniteException.class); @@ -71,6 +96,15 @@ public class IgniteCachePartitionedAtomicColumnConstraintsTest extends GridCommo @Override protected void beforeTestsStarted() throws Exception { startGrid(0); + createCachesForStringTests(); + + createCachesForDecimalPrecisionTests(); + + createCachesForDecimalScaleTests(); + } + + /** @throws Exception If failed.*/ + private void createCachesForStringTests() throws Exception { Map strStrPrecision = new HashMap<>(); strStrPrecision.put(KEY_FIELD_NAME, 5); @@ -102,10 +136,89 @@ public class IgniteCachePartitionedAtomicColumnConstraintsTest extends GridCommo .setFieldsPrecision(strOrgPrecision)), STR_ORG_WITH_FIELDS_CACHE_NAME); } + /** @throws Exception If failed.*/ + private void createCachesForDecimalPrecisionTests() throws Exception { + Map decDecPrecision = new HashMap<>(); + + decDecPrecision.put(KEY_FIELD_NAME, 4); + decDecPrecision.put(VAL_FIELD_NAME, 4); + + jcache(grid(0), cacheConfiguration(new QueryEntity(BigDecimal.class.getName(), BigDecimal.class.getName()) + .setFieldsPrecision(decDecPrecision)), DEC_CACHE_NAME_FOR_PREC); + + Map orgEmployeePrecision = new HashMap<>(); + + orgEmployeePrecision.put("id", 4); + orgEmployeePrecision.put("salary", 4); + + jcache(grid(0), cacheConfiguration(new QueryEntity(DecOrganization.class.getName(), Employee.class.getName()) + .addQueryField("id", "java.math.BigDecimal", "id") + .addQueryField("salary", "java.math.BigDecimal", "salary") + .setFieldsPrecision(orgEmployeePrecision)), OBJ_CACHE_NAME_FOR_PREC); + + Map decEmployeePrecision = new HashMap<>(); + + decEmployeePrecision.put(KEY_FIELD_NAME, 4); + decEmployeePrecision.put("salary", 4); + + jcache(grid(0), cacheConfiguration(new QueryEntity(BigDecimal.class.getName(), Employee.class.getName()) + .addQueryField("salary", "java.math.BigDecimal", "salary") + .setFieldsPrecision(decEmployeePrecision)), DEC_EMPL_CACHE_NAME_FOR_PREC); + } + + /** @throws Exception If failed.*/ + private void createCachesForDecimalScaleTests() throws Exception { + Map decDecPrecision = new HashMap<>(); + + decDecPrecision.put(KEY_FIELD_NAME, 4); + decDecPrecision.put(VAL_FIELD_NAME, 4); + + Map decDecScale = new HashMap<>(); + + decDecScale.put(KEY_FIELD_NAME, 2); + decDecScale.put(VAL_FIELD_NAME, 2); + + jcache(grid(0), cacheConfiguration(new QueryEntity(BigDecimal.class.getName(), BigDecimal.class.getName()) + .setFieldsScale(decDecScale) + .setFieldsPrecision(decDecPrecision)), DEC_CACHE_NAME_FOR_SCALE); + + Map orgEmployeePrecision = new HashMap<>(); + + orgEmployeePrecision.put("id", 4); + orgEmployeePrecision.put("salary", 4); + + Map orgEmployeeScale = new HashMap<>(); + + orgEmployeeScale.put("id", 2); + orgEmployeeScale.put("salary", 2); + + jcache(grid(0), cacheConfiguration(new QueryEntity(DecOrganization.class.getName(), Employee.class.getName()) + .addQueryField("id", "java.math.BigDecimal", "id") + .addQueryField("salary", "java.math.BigDecimal", "salary") + .setFieldsScale(orgEmployeeScale) + .setFieldsPrecision(orgEmployeePrecision)), OBJ_CACHE_NAME_FOR_SCALE); + + Map decEmployeePrecision = new HashMap<>(); + + decEmployeePrecision.put(KEY_FIELD_NAME, 4); + decEmployeePrecision.put("salary", 4); + + Map decEmployeeScale = new HashMap<>(); + + decEmployeeScale.put(KEY_FIELD_NAME, 2); + decEmployeeScale.put("salary", 2); + + jcache(grid(0), cacheConfiguration(new QueryEntity(BigDecimal.class.getName(), Employee.class.getName()) + .addQueryField("salary", "java.math.BigDecimal", "salary") + .setFieldsPrecision(decEmployeePrecision) + .setFieldsScale(decEmployeeScale)), DEC_EMPL_CACHE_NAME_FOR_SCALE); + } + /** * @throws Exception If failed. */ - public void testPutTooLongValueFail() throws Exception { + @Test + public void testPutTooLongStringValueFail() throws Exception { IgniteCache cache = jcache(0, STR_CACHE_NAME); T2 val = new T2<>("3", "123456"); @@ -113,14 +226,15 @@ public void testPutTooLongValueFail() throws Exception { checkPutAll(shouldFail, cache, new T2<>("1", "1"), val); checkPutOps(shouldFail, cache, val); - + checkReplaceOps(shouldFail, cache, val, "1"); } /** * @throws Exception If failed. */ - public void testPutTooLongKeyFail() throws Exception { + @Test + public void testPutTooLongStringKeyFail() throws Exception { IgniteCache cache = jcache(0, STR_CACHE_NAME); T2 val = new T2<>("123456", "2"); @@ -133,7 +247,8 @@ public void testPutTooLongKeyFail() throws Exception { /** * @throws Exception If failed. */ - public void testPutTooLongValueFieldFail() throws Exception { + @Test + public void testPutTooLongStringValueFieldFail() throws Exception { IgniteCache cache = jcache(0, OBJ_CACHE_NAME); T2 val = new T2<>(new Organization("3"), new Address("123456")); @@ -148,7 +263,8 @@ public void testPutTooLongValueFieldFail() throws Exception { /** * @throws Exception If failed. */ - public void testPutTooLongKeyFieldFail() throws Exception { + @Test + public void testPutTooLongStringKeyFieldFail() throws Exception { IgniteCache cache = jcache(0, OBJ_CACHE_NAME); T2 val = new T2<>(new Organization("123456"), new Address("2")); @@ -161,19 +277,23 @@ public void testPutTooLongKeyFieldFail() throws Exception { /** * @throws Exception If failed. */ - public void testPutTooLongKeyFail2() throws Exception { - doCheckPutTooLongKeyFail2(STR_ORG_CACHE_NAME); + @Test + public void testPutTooLongStringKeyFail2() throws Exception { + doCheckPutTooLongStringKeyFail2(STR_ORG_CACHE_NAME); } /** * @throws Exception If failed. */ - public void testPutTooLongKeyFail3() throws Exception { - doCheckPutTooLongKeyFail2(STR_ORG_WITH_FIELDS_CACHE_NAME); + @Test + public void testPutTooLongStringKeyFail3() throws Exception { + doCheckPutTooLongStringKeyFail2(STR_ORG_WITH_FIELDS_CACHE_NAME); } - - private void doCheckPutTooLongKeyFail2(String cacheName) { + /** + * @throws Exception If failed. + */ + private void doCheckPutTooLongStringKeyFail2(String cacheName) { IgniteCache cache = jcache(0, cacheName); T2 val = new T2<>("123456", new Organization("1")); @@ -186,7 +306,8 @@ private void doCheckPutTooLongKeyFail2(String cacheName) { /** * @throws Exception If failed. */ - public void testPutLongValue() throws Exception { + @Test + public void testPutLongStringValue() throws Exception { IgniteCache cache = jcache(0, STR_CACHE_NAME); T2 val = new T2<>("3", "12345"); @@ -201,7 +322,8 @@ public void testPutLongValue() throws Exception { /** * @throws Exception If failed. */ - public void testPutLongKey() throws Exception { + @Test + public void testPutLongStringKey() throws Exception { IgniteCache cache = jcache(0, STR_CACHE_NAME); T2 val = new T2<>("12345", "2"); @@ -214,7 +336,8 @@ public void testPutLongKey() throws Exception { /** * @throws Exception If failed. */ - public void testPutLongValueField() throws Exception { + @Test + public void testPutLongStringValueField() throws Exception { IgniteCache cache = jcache(0, OBJ_CACHE_NAME); T2 val = new T2<>(new Organization("3"), new Address("12345")); @@ -229,7 +352,8 @@ public void testPutLongValueField() throws Exception { /** * @throws Exception If failed. */ - public void testPutLongKeyField() throws Exception { + @Test + public void testPutLongStringKeyField() throws Exception { IgniteCache cache = jcache(0, OBJ_CACHE_NAME); T2 val = new T2<>(new Organization("12345"), new Address("2")); @@ -242,18 +366,23 @@ public void testPutLongKeyField() throws Exception { /** * @throws Exception If failed. */ - public void testPutLongKey2() throws Exception { - doCheckPutLongKey2(STR_ORG_CACHE_NAME); + @Test + public void testPutLongStringKey2() throws Exception { + doCheckPutLongStringKey2(STR_ORG_CACHE_NAME); } /** * @throws Exception If failed. */ - public void testPutLongKey3() throws Exception { - doCheckPutLongKey2(STR_ORG_WITH_FIELDS_CACHE_NAME); + @Test + public void testPutLongStringKey3() throws Exception { + doCheckPutLongStringKey2(STR_ORG_WITH_FIELDS_CACHE_NAME); } - private void doCheckPutLongKey2(String cacheName) { + /** + * @throws Exception If failed. + */ + private void doCheckPutLongStringKey2(String cacheName) { IgniteCache cache = jcache(0, cacheName); T2 key2 = new T2<>("12345", new Organization("1")); @@ -263,6 +392,239 @@ private void doCheckPutLongKey2(String cacheName) { checkPutOps(shouldSucceed, cache, key2); } + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalValueFail() throws Exception { + IgniteCache cache = jcache(0, DEC_CACHE_NAME_FOR_PREC); + + T2 val = new T2<>(d(12.36), d(123.45)); + + checkPutAll(shouldFail, cache, new T2<>(d(12.34), d(12.34)), val); + + checkPutOps(shouldFail, cache, val); + + checkReplaceOps(shouldFail, cache, val, d(12.34)); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalKeyFail() throws Exception { + IgniteCache cache = jcache(0, DEC_CACHE_NAME_FOR_PREC); + + T2 val = new T2<>(d(123.45), d(12.34)); + + checkPutAll(shouldFail, cache, new T2<>(d(12.35), d(12.34)), val); + + checkPutOps(shouldFail, cache, val); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalKeyFail2() throws Exception { + IgniteCache cache = jcache(0, DEC_EMPL_CACHE_NAME_FOR_PREC); + + T2 val = new T2<>(d(123.45), new Employee(d(12.34))); + + checkPutAll(shouldFail, cache, new T2<>(d(12.35), new Employee(d(12.34))), val); + + checkPutOps(shouldFail, cache, val); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalValueFieldFail() throws Exception { + IgniteCache cache = jcache(0, OBJ_CACHE_NAME_FOR_PREC); + + T2 val = new T2<>(new DecOrganization(d(12.36)), new Employee(d(123.45))); + + checkPutAll(shouldFail, cache, new T2<>(new DecOrganization(d(12.34)), new Employee(d(12.34))), val); + + checkPutOps(shouldFail, cache, val); + + checkReplaceOps(shouldFail, cache, val, new Employee(d(12.34))); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalValueFieldFail2() throws Exception { + IgniteCache cache = jcache(0, DEC_EMPL_CACHE_NAME_FOR_PREC); + + T2 val = new T2<>(d(12.36), new Employee(d(123.45))); + + checkPutAll(shouldFail, cache, new T2<>(d(12.34), new Employee(d(12.34))), val); + + checkPutOps(shouldFail, cache, val); + + checkReplaceOps(shouldFail, cache, val, new Employee(d(12.34))); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalKeyFieldFail() throws Exception { + IgniteCache cache = jcache(0, OBJ_CACHE_NAME_FOR_PREC); + + T2 val = new T2<>(new DecOrganization(d(123.45)), new Employee(d(12.34))); + + checkPutAll(shouldFail, cache, new T2<>(new DecOrganization(d(12.35)), new Employee(d(12.34))), val); + + checkPutOps(shouldFail, cache, val); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalValueScaleFail() throws Exception { + IgniteCache cache = jcache(0, DEC_CACHE_NAME_FOR_SCALE); + + T2 val = new T2<>(d(12.36), d(3.456)); + + checkPutAll(shouldFail, cache, new T2<>(d(12.34), d(12.34)), val); + + checkPutOps(shouldFail, cache, val); + + checkReplaceOps(shouldFail, cache, val, d(12.34)); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalKeyScaleFail() throws Exception { + IgniteCache cache = jcache(0, DEC_CACHE_NAME_FOR_SCALE); + + T2 val = new T2<>(d(3.456), d(12.34)); + + checkPutAll(shouldFail, cache, new T2<>(d(12.35), d(12.34)), val); + + checkPutOps(shouldFail, cache, val); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalKeyScaleFail2() throws Exception { + IgniteCache cache = jcache(0, DEC_EMPL_CACHE_NAME_FOR_SCALE); + + T2 val = new T2<>(d(3.456), new Employee(d(12.34))); + + checkPutAll(shouldFail, cache, new T2<>(d(12.35), new Employee(d(12.34))), val); + + checkPutOps(shouldFail, cache, val); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalValueFieldScaleFail() throws Exception { + IgniteCache cache = jcache(0, OBJ_CACHE_NAME_FOR_SCALE); + + T2 val = new T2<>(new DecOrganization(d(12.36)), new Employee(d(3.456))); + + checkPutAll(shouldFail, cache, new T2<>(new DecOrganization(d(12.34)), new Employee(d(12.34))), val); + + checkPutOps(shouldFail, cache, val); + + checkReplaceOps(shouldFail, cache, val, new Employee(d(12.34))); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalValueFieldScaleFail2() throws Exception { + IgniteCache cache = jcache(0, DEC_EMPL_CACHE_NAME_FOR_SCALE); + + T2 val = new T2<>(d(12.36), new Employee(d(3.456))); + + checkPutAll(shouldFail, cache, new T2<>(d(12.34), new Employee(d(12.34))), val); + + checkPutOps(shouldFail, cache, val); + + checkReplaceOps(shouldFail, cache, val, new Employee(d(12.34))); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutTooLongDecimalKeyFieldScaleFail() throws Exception { + IgniteCache cache = jcache(0, OBJ_CACHE_NAME_FOR_SCALE); + + T2 val = new T2<>(new DecOrganization(d(3.456)), new Employee(d(12.34))); + + checkPutAll(shouldFail, cache, new T2<>(new DecOrganization(d(12.35)), new Employee(d(12.34))), val); + + checkPutOps(shouldFail, cache, val); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutValidDecimalKeyAndValue() throws Exception { + IgniteCache cache = jcache(0, DEC_CACHE_NAME_FOR_SCALE); + + T2 val = new T2<>(d(12.37), d(12.34)); + + checkPutAll(shouldSucceed, cache, new T2<>(d(12.36), d(12.34)), val); + + checkPutOps(shouldSucceed, cache, val); + + checkReplaceOps(shouldSucceed, cache, val, d(12.34)); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutValidDecimalKeyAndValueField() throws Exception { + IgniteCache cache = jcache(0, OBJ_CACHE_NAME_FOR_SCALE); + + T2 val = new T2<>(new DecOrganization(d(12.37)), new Employee(d(12.34))); + + checkPutAll(shouldSucceed, cache, new T2<>(new DecOrganization(d(12.36)), new Employee(d(12.34))), val); + + checkPutOps(shouldSucceed, cache, val); + + checkReplaceOps(shouldSucceed, cache, val, new Employee(d(12.34))); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testPutValidDecimalKeyAndValueField2() throws Exception { + IgniteCache cache = jcache(0, DEC_EMPL_CACHE_NAME_FOR_SCALE); + + T2 val = new T2<>(d(12.37), new Employee(d(12.34))); + + checkPutAll(shouldSucceed, cache, new T2<>(d(12.36), new Employee(d(12.34))), val); + + checkPutOps(shouldSucceed, cache, val); + + checkReplaceOps(shouldSucceed, cache, val, new Employee(d(12.34))); + } + + /** */ + private BigDecimal d(double val) { + return BigDecimal.valueOf(val); + } + /** */ private void checkReplaceOps(Consumer checker, IgniteCache cache, T2 val, V okVal) { K k = val.get1(); @@ -352,9 +714,11 @@ protected CacheConfiguration cacheConfiguration(QueryEntity qryEntity) { cache.setAtomicityMode(atomicityMode()); cache.setBackups(1); cache.setWriteSynchronizationMode(FULL_SYNC); - cache.setQueryEntities(Collections.singletonList(qryEntity)); + if (TRANSACTIONAL_SNAPSHOT.equals(atomicityMode())) + cache.setNearConfiguration(null); + return cache; } @@ -369,7 +733,6 @@ protected CacheConfiguration cacheConfiguration(QueryEntity qryEntity) { } /** */ - @SuppressWarnings("UnusedDeclaration") private static class Organization implements Serializable { /** Name. */ private final String name; @@ -383,7 +746,6 @@ private Organization(String name) { } /** */ - @SuppressWarnings("UnusedDeclaration") private static class Address implements Serializable { /** Name. */ private final String address; @@ -395,4 +757,32 @@ private Address(String address) { this.address = address; } } + + /** */ + @SuppressWarnings("UnusedDeclaration") + private static class DecOrganization implements Serializable { + /** Id. */ + private final BigDecimal id; + + /** + * @param id Id. + */ + private DecOrganization(BigDecimal id) { + this.id = id; + } + } + + /** */ + @SuppressWarnings("UnusedDeclaration") + private static class Employee implements Serializable { + /** Salary. */ + private final BigDecimal salary; + + /** + * @param salary Salary. + */ + private Employee(BigDecimal salary) { + this.salary = salary; + } + } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedTransactionalColumnConstraintsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedTransactionalColumnConstraintsTest.java index cd5c979e9636f..c73c04ec24fee 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedTransactionalColumnConstraintsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedTransactionalColumnConstraintsTest.java @@ -21,10 +21,10 @@ import org.jetbrains.annotations.NotNull; /** */ -public class IgniteCachePartitionedTransactionalColumnConstraintsTest +public class IgniteCachePartitionedTransactionalColumnConstraintsTest extends IgniteCachePartitionedAtomicColumnConstraintsTest { /** {@inheritDoc} */ - @NotNull protected CacheAtomicityMode atomicityMode() { + @Override @NotNull protected CacheAtomicityMode atomicityMode() { return CacheAtomicityMode.TRANSACTIONAL; } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedTransactionalSnapshotColumnConstraintTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedTransactionalSnapshotColumnConstraintTest.java new file mode 100644 index 0000000000000..a636a3c11cb1d --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCachePartitionedTransactionalSnapshotColumnConstraintTest.java @@ -0,0 +1,120 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.sql; + +import org.apache.ignite.cache.CacheAtomicityMode; +import org.jetbrains.annotations.NotNull; + +/** */ +public class IgniteCachePartitionedTransactionalSnapshotColumnConstraintTest + extends IgniteCachePartitionedAtomicColumnConstraintsTest { + /** {@inheritDoc} */ + @NotNull @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + } + + /** */ + @Override public void testPutTooLongStringValueFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringKeyFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringValueFieldFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringKeyFieldFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringKeyFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringKeyFail3() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFieldFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFieldFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyFieldFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueScaleFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyScaleFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyScaleFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFieldScaleFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFieldScaleFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyFieldScaleFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCacheReplicatedTransactionalSnapshotColumnConstraintTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCacheReplicatedTransactionalSnapshotColumnConstraintTest.java new file mode 100644 index 0000000000000..2a7f6b5375aeb --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteCacheReplicatedTransactionalSnapshotColumnConstraintTest.java @@ -0,0 +1,120 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.sql; + +import org.apache.ignite.cache.CacheAtomicityMode; +import org.jetbrains.annotations.NotNull; + +/** */ +public class IgniteCacheReplicatedTransactionalSnapshotColumnConstraintTest + extends IgniteCacheReplicatedAtomicColumnConstraintsTest { + /** {@inheritDoc} */ + @NotNull @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; + } + + /** */ + @Override public void testPutTooLongStringValueFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringKeyFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringValueFieldFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringKeyFieldFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringKeyFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongStringKeyFail3() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFieldFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFieldFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyFieldFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueScaleFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyScaleFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyScaleFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFieldScaleFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalValueFieldScaleFail2() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } + + /** */ + @Override public void testPutTooLongDecimalKeyFieldScaleFail() { + fail("https://issues.apache.org/jira/browse/IGNITE-10066"); + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteSQLColumnConstraintsTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteSQLColumnConstraintsTest.java index 762743b636f59..0080bf0171a8c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteSQLColumnConstraintsTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteSQLColumnConstraintsTest.java @@ -17,127 +17,365 @@ package org.apache.ignite.internal.processors.sql; +import java.math.BigDecimal; import java.util.List; +import java.util.Objects; import org.apache.ignite.cache.query.SqlFieldsQuery; -import org.apache.ignite.internal.processors.odbc.SqlStateCode; import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.processors.odbc.SqlStateCode.CONSTRAINT_VIOLATION; +import static org.apache.ignite.internal.processors.odbc.SqlStateCode.INTERNAL_ERROR; /** */ +@RunWith(JUnit4.class) public class IgniteSQLColumnConstraintsTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrid(0); - execSQL("CREATE TABLE varchar_table(id INT PRIMARY KEY, str VARCHAR(5))"); + String mvccQry = mvccEnabled() ? " WITH \"atomicity=transactional_snapshot\"" : ""; + + runSQL("CREATE TABLE varchar_table(id INT PRIMARY KEY, str VARCHAR(5))" + mvccQry); execSQL("INSERT INTO varchar_table VALUES(?, ?)", 1, "12345"); - execSQL("CREATE TABLE char_table(id INT PRIMARY KEY, str CHAR(5))"); + checkSQLResults("SELECT * FROM varchar_table WHERE id = 1", 1, "12345"); + + runSQL("CREATE TABLE decimal_table(id INT PRIMARY KEY, val DECIMAL(4, 2))" + mvccQry); + + execSQL("INSERT INTO decimal_table VALUES(?, ?)", 1, 12.34); + + checkSQLResults("SELECT * FROM decimal_table WHERE id = 1", 1, BigDecimal.valueOf(12.34)); + + runSQL("CREATE TABLE char_table(id INT PRIMARY KEY, str CHAR(5))" + mvccQry); execSQL("INSERT INTO char_table VALUES(?, ?)", 1, "12345"); + + checkSQLResults("SELECT * FROM char_table WHERE id = 1", 1, "12345"); + + runSQL("CREATE TABLE decimal_table_4(id INT PRIMARY KEY, field DECIMAL(4, 2))" + mvccQry); + + runSQL("CREATE TABLE char_table_2(id INT PRIMARY KEY, field INTEGER)" + mvccQry); + + runSQL("CREATE TABLE decimal_table_2(id INT PRIMARY KEY, field INTEGER)" + mvccQry); + + runSQL("CREATE TABLE char_table_3(id INT PRIMARY KEY, field CHAR(5), field2 INTEGER)" + mvccQry); + + runSQL("CREATE TABLE decimal_table_3(id INT PRIMARY KEY, field DECIMAL(4, 2), field2 INTEGER)" + mvccQry); + + runSQL("CREATE TABLE char_table_4(id INT PRIMARY KEY, field CHAR(5))" + mvccQry); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testCreateTableWithTooLongCharDefault() throws Exception { + checkSQLThrows("CREATE TABLE too_long_default(id INT PRIMARY KEY, str CHAR(5) DEFAULT '123456')", + INTERNAL_ERROR); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testCreateTableWithTooLongScaleDecimalDefault() throws Exception { + checkSQLThrows("CREATE TABLE too_long_decimal_default_scale(id INT PRIMARY KEY, val DECIMAL(4, 2)" + + " DEFAULT 1.345)", INTERNAL_ERROR); + } + + @Test + public void testCreateTableWithTooLongDecimalDefault() throws Exception { + checkSQLThrows("CREATE TABLE too_long_decimal_default(id INT PRIMARY KEY, val DECIMAL(4, 2)" + + " DEFAULT 123.45)", INTERNAL_ERROR); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testInsertTooLongDecimal() throws Exception { + checkSQLThrows("INSERT INTO decimal_table VALUES(?, ?)", CONSTRAINT_VIOLATION, 2, 123.45); + + assertTrue(execSQL("SELECT * FROM decimal_table WHERE id = ?", 2).isEmpty()); + + checkSQLThrows("UPDATE decimal_table SET val = ? WHERE id = ?", CONSTRAINT_VIOLATION, 123.45, 1); + + checkSQLResults("SELECT * FROM decimal_table WHERE id = 1", 1, BigDecimal.valueOf(12.34)); + + checkSQLThrows("MERGE INTO decimal_table(id, val) VALUES(?, ?)", CONSTRAINT_VIOLATION, 1, 123.45); + + checkSQLResults("SELECT * FROM decimal_table WHERE id = 1", 1, BigDecimal.valueOf(12.34)); } /** * @throws Exception If failed. */ - public void testCreateTableWithTooLongDefault() throws Exception { - checkSQLThrows("CREATE TABLE too_long_default(id INT PRIMARY KEY, str CHAR(5) DEFAULT '123456')"); + @Test + public void testInsertTooLongScaleDecimal() throws Exception { + checkSQLThrows("INSERT INTO decimal_table VALUES(?, ?)", CONSTRAINT_VIOLATION, 3, 1.234); + + assertTrue(execSQL("SELECT * FROM decimal_table WHERE id = ?", 3).isEmpty()); + + checkSQLThrows("UPDATE decimal_table SET val = ? WHERE id = ?", CONSTRAINT_VIOLATION, 1.234, 1); + + checkSQLResults("SELECT * FROM decimal_table WHERE id = 1", 1, BigDecimal.valueOf(12.34)); + + checkSQLThrows("MERGE INTO decimal_table(id, val) VALUES(?, ?)", CONSTRAINT_VIOLATION, 1, 1.234); + + checkSQLResults("SELECT * FROM decimal_table WHERE id = 1", 1, BigDecimal.valueOf(12.34)); } /** * @throws Exception If failed. */ + @Test public void testInsertTooLongVarchar() throws Exception { - checkSQLThrows("INSERT INTO varchar_table VALUES(?, ?)", 2, "123456"); + checkSQLThrows("INSERT INTO varchar_table VALUES(?, ?)", CONSTRAINT_VIOLATION, 2, "123456"); + + assertTrue(execSQL("SELECT * FROM varchar_table WHERE id = ?", 2).isEmpty()); + + checkSQLThrows("UPDATE varchar_table SET str = ? WHERE id = ?", CONSTRAINT_VIOLATION, "123456", 1); + + checkSQLResults("SELECT * FROM varchar_table WHERE id = 1", 1, "12345"); - checkSQLThrows("UPDATE varchar_table SET str = ? WHERE id = ?", "123456", 1); + checkSQLThrows("MERGE INTO varchar_table(id, str) VALUES(?, ?)", CONSTRAINT_VIOLATION, 1, "123456"); - checkSQLThrows("MERGE INTO varchar_table(id, str) VALUES(?, ?)", 1, "123456"); + checkSQLResults("SELECT * FROM varchar_table WHERE id = 1", 1, "12345"); } /** * @throws Exception If failed. */ + @Test public void testInsertTooLongChar() throws Exception { - checkSQLThrows("INSERT INTO char_table VALUES(?, ?)", 2, "123456"); + checkSQLThrows("INSERT INTO char_table VALUES(?, ?)", CONSTRAINT_VIOLATION, 2, "123456"); + + assertTrue(execSQL("SELECT * FROM char_table WHERE id = ?", 2).isEmpty()); + + checkSQLThrows("UPDATE char_table SET str = ? WHERE id = ?", CONSTRAINT_VIOLATION, "123456", 1); + + checkSQLResults("SELECT * FROM char_table WHERE id = 1", 1, "12345"); - checkSQLThrows("UPDATE char_table SET str = ? WHERE id = ?", "123456", 1); + checkSQLThrows("MERGE INTO char_table(id, str) VALUES(?, ?)", CONSTRAINT_VIOLATION, 1, "123456"); - checkSQLThrows("MERGE INTO char_table(id, str) VALUES(?, ?)", 1, "123456"); + checkSQLResults("SELECT * FROM char_table WHERE id = 1", 1, "12345"); } /** * @throws Exception If failed. */ - public void testConstraintsAfterAlterTable() throws Exception { - execSQL("CREATE TABLE char_table_2(id INT PRIMARY KEY, field INTEGER)"); - + @Test + public void testCharConstraintsAfterAlterTable() throws Exception { execSQL("ALTER TABLE char_table_2 ADD COLUMN str CHAR(5) NOT NULL"); - + execSQL("INSERT INTO char_table_2(id, str) VALUES(?, ?)", 1, "1"); - checkSQLThrows("INSERT INTO char_table_2(id, str) VALUES(?, ?)", 2, "123456"); + checkSQLResults("SELECT * FROM char_table_2 WHERE id = 1", 1, null, "1"); + + checkSQLThrows("INSERT INTO char_table_2(id, str) VALUES(?, ?)", CONSTRAINT_VIOLATION, 2, "123456"); + + assertTrue(execSQL("SELECT * FROM decimal_table_2 WHERE id = ?", 2).isEmpty()); - checkSQLThrows("UPDATE char_table_2 SET str = ? WHERE id = ?", "123456", 1); + checkSQLThrows("UPDATE char_table_2 SET str = ? WHERE id = ?", CONSTRAINT_VIOLATION, "123456", 1); - checkSQLThrows("MERGE INTO char_table_2(id, str) VALUES(?, ?)", 1, "123456"); + checkSQLResults("SELECT * FROM char_table_2 WHERE id = 1", 1, null, "1"); + + checkSQLThrows("MERGE INTO char_table_2(id, str) VALUES(?, ?)", CONSTRAINT_VIOLATION, 1, "123456"); + + checkSQLResults("SELECT * FROM char_table_2 WHERE id = 1", 1, null, "1"); } /** * @throws Exception If failed. */ - public void testDropColumnWithConstraint() throws Exception { - execSQL("CREATE TABLE char_table_3(id INT PRIMARY KEY, field CHAR(5), field2 INTEGER)"); + @Test + public void testDecimalConstraintsAfterAlterTable() throws Exception { + execSQL("ALTER TABLE decimal_table_2 ADD COLUMN val DECIMAL(4, 2) NOT NULL"); + + execSQL("INSERT INTO decimal_table_2(id, val) VALUES(?, ?)", 1, 12.34); + + checkSQLResults("SELECT * FROM decimal_table_2 WHERE id = 1", 1, null, BigDecimal.valueOf(12.34)); + + checkSQLThrows("INSERT INTO decimal_table_2(id, val) VALUES(?, ?)", CONSTRAINT_VIOLATION, 2, 1234.56); + + assertTrue(execSQL("SELECT * FROM decimal_table_2 WHERE id = ?", 2).isEmpty()); + + checkSQLThrows("UPDATE decimal_table_2 SET val = ? WHERE id = ?", CONSTRAINT_VIOLATION, 1234.56, 1); + + checkSQLResults("SELECT * FROM decimal_table_2 WHERE id = 1", 1, null, BigDecimal.valueOf(12.34)); + + checkSQLThrows("MERGE INTO decimal_table_2(id, val) VALUES(?, ?)", CONSTRAINT_VIOLATION, 1, 12345.6); + + checkSQLResults("SELECT * FROM decimal_table_2 WHERE id = 1", 1, null, BigDecimal.valueOf(12.34)); + + checkSQLThrows("INSERT INTO decimal_table_2(id, val) VALUES(?, ?)", CONSTRAINT_VIOLATION, 3, 1.234); + checkSQLResults("SELECT * FROM decimal_table_2 WHERE id = 1", 1, null, BigDecimal.valueOf(12.34)); + + checkSQLThrows("UPDATE decimal_table_2 SET val = ? WHERE id = ?", CONSTRAINT_VIOLATION, 1.234, 1); + + checkSQLResults("SELECT * FROM decimal_table_2 WHERE id = 1", 1, null, BigDecimal.valueOf(12.34)); + + checkSQLThrows("MERGE INTO decimal_table_2(id, val) VALUES(?, ?)", CONSTRAINT_VIOLATION, 1, 1.234); + + checkSQLResults("SELECT * FROM decimal_table_2 WHERE id = 1", 1, null, BigDecimal.valueOf(12.34)); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testCharDropColumnWithConstraint() throws Exception { execSQL("INSERT INTO char_table_3(id, field, field2) VALUES(?, ?, ?)", 1, "12345", 1); - checkSQLThrows("INSERT INTO char_table_3(id, field, field2) VALUES(?, ?, ?)", 2, "123456", 1); + checkSQLResults("SELECT * FROM char_table_3 WHERE id = 1", 1, "12345", 1); + + checkSQLThrows("INSERT INTO char_table_3(id, field, field2) VALUES(?, ?, ?)", CONSTRAINT_VIOLATION, + 2, "123456", 1); + + assertTrue(execSQL("SELECT * FROM decimal_table_3 WHERE id = ?", 2).isEmpty()); execSQL("ALTER TABLE char_table_3 DROP COLUMN field"); execSQL("INSERT INTO char_table_3(id, field2) VALUES(?, ?)", 3, 3); + + checkSQLResults("SELECT * FROM char_table_3 WHERE id = 3", 3, 3); } - public void testSqlState() throws Exception { - execSQL("CREATE TABLE char_table_4(id INT PRIMARY KEY, field CHAR(5))"); + /** + * @throws Exception If failed. + */ + @Test + public void testDecimalDropColumnWithConstraint() throws Exception { + execSQL("INSERT INTO decimal_table_3(id, field, field2) VALUES(?, ?, ?)", 1, 12.34, 1); + + checkSQLResults("SELECT * FROM decimal_table_3 WHERE id = 1", 1, BigDecimal.valueOf(12.34), 1); + + checkSQLThrows("INSERT INTO decimal_table_3(id, field, field2) VALUES(?, ?, ?)", CONSTRAINT_VIOLATION, + 2, 12.3456, 1); + + assertTrue(execSQL("SELECT * FROM decimal_table_3 WHERE id = ?", 2).isEmpty()); + + execSQL("ALTER TABLE decimal_table_3 DROP COLUMN field"); - IgniteSQLException err = (IgniteSQLException) - checkSQLThrows("INSERT INTO char_table_4(id, field) VALUES(?, ?)", 1, "123456"); + execSQL("INSERT INTO decimal_table_3(id, field2) VALUES(?, ?)", 3, 3); - assertEquals(err.sqlState(), CONSTRAINT_VIOLATION); + checkSQLResults("SELECT * FROM decimal_table_3 WHERE id = 3", 3, 3); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testCharSqlState() throws Exception { + checkSQLThrows("INSERT INTO char_table_4(id, field) VALUES(?, ?)", CONSTRAINT_VIOLATION, 1, "123456"); + + assertTrue(execSQL("SELECT * FROM decimal_table_4 WHERE id = ?", 1).isEmpty()); execSQL("INSERT INTO char_table_4(id, field) VALUES(?, ?)", 2, "12345"); - err = (IgniteSQLException) - checkSQLThrows("UPDATE char_table_4 SET field = ? WHERE id = ?", "123456", 2); + checkSQLResults("SELECT * FROM char_table_4 WHERE id = 2", 2, "12345"); + + checkSQLThrows("UPDATE char_table_4 SET field = ? WHERE id = ?", CONSTRAINT_VIOLATION, "123456", 2); + + checkSQLResults("SELECT * FROM char_table_4 WHERE id = 2", 2, "12345"); + + checkSQLThrows("MERGE INTO char_table_4(id, field) VALUES(?, ?)", CONSTRAINT_VIOLATION, 2, "123456"); + + checkSQLResults("SELECT * FROM char_table_4 WHERE id = 2", 2, "12345"); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testDecimalSqlState() throws Exception { + checkSQLThrows("INSERT INTO decimal_table_4 VALUES(?, ?)", CONSTRAINT_VIOLATION, + 1, BigDecimal.valueOf(1234.56)); + + assertTrue(execSQL("SELECT * FROM decimal_table_4 WHERE id = ?", 1).isEmpty()); + + checkSQLThrows("INSERT INTO decimal_table_4 VALUES(?, ?)", CONSTRAINT_VIOLATION, + 1, BigDecimal.valueOf(1.345)); + + assertTrue(execSQL("SELECT * FROM decimal_table_4 WHERE id = ?", 1).isEmpty()); + + execSQL("INSERT INTO decimal_table_4 (id, field) VALUES(?, ?)", 2, 12.34); - assertEquals(err.sqlState(), CONSTRAINT_VIOLATION); + checkSQLResults("SELECT * FROM decimal_table_4 WHERE id = 2", 2, BigDecimal.valueOf(12.34)); - err = (IgniteSQLException) - checkSQLThrows("MERGE INTO char_table_4(id, field) VALUES(?, ?)", 2, "123456"); + checkSQLThrows("UPDATE decimal_table_4 SET field = ? WHERE id = ?", CONSTRAINT_VIOLATION, + BigDecimal.valueOf(1234.56), 2); - assertEquals(err.sqlState(), CONSTRAINT_VIOLATION); + checkSQLResults("SELECT * FROM decimal_table_4 WHERE id = 2", 2, BigDecimal.valueOf(12.34)); + + checkSQLThrows("MERGE INTO decimal_table_4(id, field) VALUES(?, ?)", CONSTRAINT_VIOLATION, + 2, BigDecimal.valueOf(1234.56)); + + checkSQLResults("SELECT * FROM decimal_table_4 WHERE id = 2", 2, BigDecimal.valueOf(12.34)); + + checkSQLThrows("UPDATE decimal_table_4 SET field = ? WHERE id = ?", CONSTRAINT_VIOLATION, + BigDecimal.valueOf(1.345), 2); + + checkSQLResults("SELECT * FROM decimal_table_4 WHERE id = 2", 2, BigDecimal.valueOf(12.34)); + + checkSQLThrows("MERGE INTO decimal_table_4(id, field) VALUES(?, ?)", CONSTRAINT_VIOLATION, + 2, BigDecimal.valueOf(1.345)); + + checkSQLResults("SELECT * FROM decimal_table_4 WHERE id = 2", 2, BigDecimal.valueOf(12.34)); } /** */ - private Throwable checkSQLThrows(String sql, Object... args) { - return GridTestUtils.assertThrowsWithCause(() -> { + protected void checkSQLThrows(String sql, String sqlStateCode, Object... args) { + IgniteSQLException err = (IgniteSQLException)GridTestUtils.assertThrowsWithCause(() -> { execSQL(sql, args); return 0; }, IgniteSQLException.class); + + assertEquals(err.sqlState(), sqlStateCode); } /** */ - private List execSQL(String sql, Object... args) { + protected List execSQL(String sql, Object... args) { + return runSQL(sql, args); + } + + /** */ + protected List runSQL(String sql, Object... args) { SqlFieldsQuery qry = new SqlFieldsQuery(sql) .setArgs(args); return grid(0).context().query().querySqlFields(qry, true).getAll(); } + + /** */ + protected void checkSQLResults(String sql, Object... args) { + List rows = execSQL(sql); + + assertNotNull(rows); + + assertTrue(!rows.isEmpty()); + + assertEquals(rows.size(), 1); + + List row = (List)rows.get(0); + + assertEquals(row.size(), args.length); + + for (int i = 0; i < args.length; i++) + assertTrue(args[i] + " != " + row.get(i), Objects.equals(args[i], row.get(i))); + } + + /** */ + protected boolean mvccEnabled() { + return false; + } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteTransactionSQLColumnConstraintTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteTransactionSQLColumnConstraintTest.java new file mode 100644 index 0000000000000..5239e1fb36165 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/IgniteTransactionSQLColumnConstraintTest.java @@ -0,0 +1,71 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.sql; + +import java.util.List; +import org.apache.ignite.internal.processors.query.IgniteSQLException; +import org.apache.ignite.testframework.GridTestUtils; + +/** + */ +public class IgniteTransactionSQLColumnConstraintTest extends IgniteSQLColumnConstraintsTest { + /** {@inheritDoc} */ + @Override protected void checkSQLThrows(String sql, String sqlStateCode, Object... args) { + runSQL("BEGIN TRANSACTION"); + + IgniteSQLException err = (IgniteSQLException)GridTestUtils.assertThrowsWithCause(() -> { + runSQL(sql, args); + + return 0; + }, IgniteSQLException.class); + + runSQL("ROLLBACK TRANSACTION"); + + assertEquals(err.sqlState(), sqlStateCode); + } + + /** {@inheritDoc} */ + @Override protected List execSQL(String sql, Object... args) { + runSQL("BEGIN TRANSACTION"); + + List res = runSQL(sql, args); + + runSQL("COMMIT TRANSACTION"); + + return res; + } + + /** + * That test is ignored due to drop column(s) operation is unsupported for the MVCC tables. + */ + @Override public void testCharDropColumnWithConstraint() { + // No-op. + } + + /** + * That test is ignored due to drop column(s) operation is unsupported for the MVCC tables. + */ + @Override public void testDecimalDropColumnWithConstraint() { + // No-op. + } + + /** {@inheritDoc} */ + @Override protected boolean mvccEnabled() { + return true; + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/SqlConnectorConfigurationValidationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/SqlConnectorConfigurationValidationSelfTest.java index 4d1b333739d84..19bc925a4a198 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/SqlConnectorConfigurationValidationSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/sql/SqlConnectorConfigurationValidationSelfTest.java @@ -36,11 +36,15 @@ import java.sql.Statement; import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * SQL connector configuration validation tests. */ @SuppressWarnings("deprecation") +@RunWith(JUnit4.class) public class SqlConnectorConfigurationValidationSelfTest extends GridCommonAbstractTest { /** Node index generator. */ private static final AtomicInteger NODE_IDX_GEN = new AtomicInteger(); @@ -58,6 +62,7 @@ public class SqlConnectorConfigurationValidationSelfTest extends GridCommonAbstr * * @throws Exception If failed. */ + @Test public void testDefault() throws Exception { check(new SqlConnectorConfiguration(), true); assertJdbc(null, SqlConnectorConfiguration.DFLT_PORT); @@ -68,6 +73,7 @@ public void testDefault() throws Exception { * * @throws Exception If failed. */ + @Test public void testHost() throws Exception { check(new SqlConnectorConfiguration().setHost("126.0.0.1"), false); @@ -84,6 +90,7 @@ public void testHost() throws Exception { * * @throws Exception If failed. */ + @Test public void testPort() throws Exception { check(new SqlConnectorConfiguration().setPort(-1), false); check(new SqlConnectorConfiguration().setPort(0), false); @@ -103,6 +110,7 @@ public void testPort() throws Exception { * * @throws Exception If failed. */ + @Test public void testPortRange() throws Exception { check(new SqlConnectorConfiguration().setPortRange(-1), false); @@ -118,6 +126,7 @@ public void testPortRange() throws Exception { * * @throws Exception If failed. */ + @Test public void testSocketBuffers() throws Exception { check(new SqlConnectorConfiguration().setSocketSendBufferSize(-4 * 1024), false); check(new SqlConnectorConfiguration().setSocketReceiveBufferSize(-4 * 1024), false); @@ -134,6 +143,7 @@ public void testSocketBuffers() throws Exception { * * @throws Exception If failed. */ + @Test public void testMaxOpenCusrorsPerConnection() throws Exception { check(new SqlConnectorConfiguration().setMaxOpenCursorsPerConnection(-1), false); @@ -149,6 +159,7 @@ public void testMaxOpenCusrorsPerConnection() throws Exception { * * @throws Exception If failed. */ + @Test public void testThreadPoolSize() throws Exception { check(new SqlConnectorConfiguration().setThreadPoolSize(0), false); check(new SqlConnectorConfiguration().setThreadPoolSize(-1), false); diff --git a/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java index cfb56b0d4ea77..11e2e596d1d5d 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java @@ -41,11 +41,11 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteRunnable; import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheMode.PARTITIONED; @@ -54,10 +54,8 @@ /** * */ +@RunWith(JUnit4.class) public class GridOrderedMessageCancelSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Cancel latch. */ private static CountDownLatch cancelLatch; @@ -80,12 +78,6 @@ public class GridOrderedMessageCancelSelfTest extends GridCommonAbstractTest { cfg.setCommunicationSpi(new CommunicationSpi()); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } @@ -106,6 +98,7 @@ public class GridOrderedMessageCancelSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testTask() throws Exception { Map map = U.field(((IgniteKernal)grid(0)).context().io(), "msgSetMap"); @@ -119,6 +112,7 @@ public void testTask() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTaskException() throws Exception { Map map = U.field(((IgniteKernal)grid(0)).context().io(), "msgSetMap"); @@ -236,4 +230,4 @@ private static class FailTask extends ComputeTaskSplitAdapter { return null; } } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/sqltests/BaseSqlTest.java b/modules/indexing/src/test/java/org/apache/ignite/sqltests/BaseSqlTest.java index 5827db1eccafc..034d363364f18 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/sqltests/BaseSqlTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/sqltests/BaseSqlTest.java @@ -58,10 +58,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test base for test for sql features. */ +@RunWith(JUnit4.class) public class BaseSqlTest extends GridCommonAbstractTest { /** Number of all employees. */ public final static long EMP_CNT = 1000L; @@ -622,6 +626,7 @@ protected void testAllNodes(Consumer consumer) { /** * Check basic SELECT * query. */ + @Test public void testBasicSelect() { testAllNodes(node -> { Result emps = executeFrom("SELECT * FROM Employee", node); @@ -637,6 +642,7 @@ public void testBasicSelect() { /** * Check SELECT query with projection (fields). */ + @Test public void testSelectFields() { testAllNodes(node -> { Result res = executeFrom("SELECT firstName, id, age FROM Employee;", node); @@ -654,6 +660,7 @@ public void testSelectFields() { /** * Check basic BETWEEN operator usage. */ + @Test public void testSelectBetween() { testAllNodes(node -> { Result emps = executeFrom("SELECT * FROM Employee e WHERE e.id BETWEEN 101 and 200", node); @@ -678,6 +685,7 @@ public void testSelectBetween() { /** * Check BETWEEN operator filters out all the result (empty result set is expected). */ + @Test public void testEmptyBetween() { testAllNodes(node -> { Result emps = executeFrom("SELECT * FROM Employee e WHERE e.id BETWEEN 200 AND 101", node); @@ -689,6 +697,7 @@ public void testEmptyBetween() { /** * Check SELECT IN with fixed values. */ + @Test public void testSelectInStatic() { testAllNodes(node -> { Result actual = executeFrom("SELECT age FROM Employee WHERE id IN (1, 256, 42)", node); @@ -708,6 +717,7 @@ public void testSelectInStatic() { /** * Check SELECT IN with simple subquery values. */ + @Test public void testSelectInSubquery() { testAllNodes(node -> { Result actual = executeFrom("SELECT lastName FROM Employee WHERE id in (SELECT id FROM Employee WHERE age < 30)", node); @@ -721,6 +731,7 @@ public void testSelectInSubquery() { /** * Check ORDER BY operator with varchar field. */ + @Test public void testBasicOrderByLastName() { testAllNodes(node -> { Result result = executeFrom("SELECT * FROM Employee e ORDER BY e.lastName", node); @@ -739,6 +750,7 @@ public void testBasicOrderByLastName() { /** * Check DISTINCT operator selecting not unique field. */ + @Test public void testBasicDistinct() { testAllNodes(node -> { Result ages = executeFrom("SELECT DISTINCT age FROM Employee", node); @@ -752,6 +764,7 @@ public void testBasicDistinct() { /** * Check simple WHERE operator. */ + @Test public void testDistinctWithWhere() { testAllNodes(node -> { Result ages = executeFrom("SELECT DISTINCT age FROM Employee WHERE id < 100", node); @@ -765,6 +778,7 @@ public void testDistinctWithWhere() { /** * Check greater operator in where clause with both indexed and non-indexed field. */ + @Test public void testWhereGreater() { testAllNodes(node -> { Result idxActual = executeFrom("SELECT firstName FROM Employee WHERE age > 30", node); @@ -783,6 +797,7 @@ public void testWhereGreater() { /** * Check less operator in where clause with both indexed and non-indexed field. */ + @Test public void testWhereLess() { testAllNodes(node -> { Result idxActual = executeFrom("SELECT firstName FROM Employee WHERE age < 30", node); @@ -801,6 +816,7 @@ public void testWhereLess() { /** * Check equals operator in where clause with both indexed and non-indexed field. */ + @Test public void testWhereEq() { testAllNodes(node -> { Result idxActual = executeFrom("SELECT firstName FROM Employee WHERE age = 30", node); @@ -819,6 +835,7 @@ public void testWhereEq() { /** * Check GROUP BY operator with indexed field. */ + @Test public void testGroupByIndexedField() { testAllNodes(node -> { // Need to filter out only part of records (each one is a count of employees @@ -851,6 +868,7 @@ public void testGroupByIndexedField() { /** * Check GROUP BY operator with indexed field. */ + @Test public void testGroupByNonIndexedField() { testAllNodes(node -> { // Need to filter out only part of records (each one is a count of employees @@ -1040,6 +1058,7 @@ public void checkInnerJoinEmployeeDepartment(String depTab) { /** * Check INNER JOIN with collocated data. */ + @Test public void testInnerJoinEmployeeDepartment() { checkInnerJoinEmployeeDepartment(DEP_TAB); } @@ -1138,6 +1157,7 @@ public void checkLeftJoinDepartmentEmployee(String depTab) { /** * Check LEFT JOIN with collocated data. */ + @Test public void testLeftJoin() { checkLeftJoinEmployeeDepartment(DEP_TAB); } @@ -1207,6 +1227,7 @@ public void checkRightJoinDepartmentEmployee(String depTab) { /** * Check RIGHT JOIN with collocated data. */ + @Test public void testRightJoin() { checkRightJoinEmployeeDepartment(DEP_TAB); } @@ -1215,6 +1236,7 @@ public void testRightJoin() { * Check that FULL OUTER JOIN (which is currently unsupported) causes valid error message. */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testFullOuterJoinIsNotSupported() { testAllNodes(node -> { String fullOuterJoinQry = "SELECT e.id as EmpId, e.firstName as EmpName, d.id as DepId, d.name as DepName " + @@ -1235,6 +1257,7 @@ public void testFullOuterJoinIsNotSupported() { * Check that distributed FULL OUTER JOIN (which is currently unsupported) causes valid error message. */ @SuppressWarnings("ThrowableNotThrown") + @Test public void testFullOuterDistributedJoinIsNotSupported() { testAllNodes(node -> { String qry = "SELECT d.id, d.name, a.address " + diff --git a/modules/indexing/src/test/java/org/apache/ignite/sqltests/PartitionedSqlTest.java b/modules/indexing/src/test/java/org/apache/ignite/sqltests/PartitionedSqlTest.java index 83e70157d359d..8899b38290b36 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/sqltests/PartitionedSqlTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/sqltests/PartitionedSqlTest.java @@ -19,10 +19,14 @@ import java.util.Arrays; import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Includes all base sql test plus tests that make sense in partitioned mode. */ +@RunWith(JUnit4.class) public class PartitionedSqlTest extends BaseSqlTest { /** {@inheritDoc} */ @Override protected void setupData() { @@ -34,6 +38,7 @@ public class PartitionedSqlTest extends BaseSqlTest { /** * Check distributed INNER JOIN. */ + @Test public void testInnerDistributedJoin() { Arrays.asList(true, false).forEach(forceOrder -> testAllNodes(node -> { final String qryTpl = "SELECT d.id, d.name, a.address " + @@ -57,6 +62,7 @@ public void testInnerDistributedJoin() { /** * Check that if required index is missed, correct exception will be thrown. */ + @Test public void testInnerDistJoinMissedIndex() { Arrays.asList(true, false).forEach(forceOrder -> testAllNodes(node -> { String qryTpl = "SELECT d.id, d.name, a.address " + @@ -74,6 +80,7 @@ public void testInnerDistJoinMissedIndex() { /** * Check distributed LEFT JOIN. */ + @Test public void testLeftDistributedJoin() { Arrays.asList(true, false).forEach(forceOrder -> testAllNodes(node -> { final String qryTpl = "SELECT d.id, d.name, a.depId, a.address " + @@ -97,6 +104,7 @@ public void testLeftDistributedJoin() { /** * Check that if required index is missed, correct exception will be thrown. */ + @Test public void testLeftDistributedJoinMissedIndex() { Arrays.asList(true, false).forEach(forceOrder -> testAllNodes(node -> { String qryTpl = "SELECT d.id, d.name, a.address " + @@ -114,6 +122,7 @@ public void testLeftDistributedJoinMissedIndex() { /** * Check distributed RIGHT JOIN. */ + @Test public void testRightDistributedJoin() { setExplain(true); @@ -140,6 +149,7 @@ public void testRightDistributedJoin() { /** * Check that if required index is missed, correct exception will be thrown. */ + @Test public void testRightDistributedJoinMissedIndex() { Arrays.asList(true, false).forEach(forceOrder -> testAllNodes(node -> { String qryTpl = "SELECT d.id, d.name, a.address " + diff --git a/modules/indexing/src/test/java/org/apache/ignite/sqltests/ReplicatedSqlTest.java b/modules/indexing/src/test/java/org/apache/ignite/sqltests/ReplicatedSqlTest.java index a71f217ba1afc..e7fafdffb08ad 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/sqltests/ReplicatedSqlTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/sqltests/ReplicatedSqlTest.java @@ -19,10 +19,15 @@ import java.util.Arrays; import java.util.List; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Includes all base sql test plus tests that make sense in replicated mode. */ +@RunWith(JUnit4.class) public class ReplicatedSqlTest extends BaseSqlTest { /** Name of the department table created in partitioned mode. */ private String DEP_PART_TAB = "DepartmentPart"; @@ -45,6 +50,7 @@ public class ReplicatedSqlTest extends BaseSqlTest { /** * Checks distributed INNER JOIN of replicated and replicated tables. */ + @Test public void testInnerDistributedJoinReplicatedReplicated() { checkInnerDistJoinWithReplicated(DEP_TAB); } @@ -52,6 +58,7 @@ public void testInnerDistributedJoinReplicatedReplicated() { /** * Checks distributed INNER JOIN of partitioned and replicated tables. */ + @Test public void testInnerDistJoinPartitionedReplicated() { checkInnerDistJoinWithReplicated(DEP_PART_TAB); } @@ -90,6 +97,7 @@ private void checkInnerDistJoinWithReplicated(String depTab) { /** * Checks distributed INNER JOIN of replicated and partitioned tables. */ + @Test public void testMixedInnerDistJoinReplicatedPartitioned() { checkInnerDistJoinReplicatedWith(DEP_PART_TAB); } @@ -129,6 +137,7 @@ private void checkInnerDistJoinReplicatedWith(String depTab) { /** * Checks distributed LEFT JOIN of replicated and replicated tables. */ + @Test public void testLeftDistributedJoinReplicatedReplicated() { checkLeftDistributedJoinWithReplicated(DEP_TAB); } @@ -136,6 +145,7 @@ public void testLeftDistributedJoinReplicatedReplicated() { /** * Checks distributed LEFT JOIN of partitioned and replicated tables. */ + @Test public void testLeftDistributedJoinPartitionedReplicated() { setExplain(true); checkLeftDistributedJoinWithReplicated(DEP_PART_TAB); @@ -144,9 +154,9 @@ public void testLeftDistributedJoinPartitionedReplicated() { /** * Checks distributed LEFT JOIN of replicated and partitioned tables. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8732") + @Test public void testLeftDistributedJoinReplicatedPartitioned() { - fail("https://issues.apache.org/jira/browse/IGNITE-8732"); - checkLeftDistributedJoinReplicatedWith(DEP_PART_TAB); } @@ -215,6 +225,7 @@ private void checkLeftDistributedJoinReplicatedWith(String depTab) { /** * Checks distributed RIGHT JOIN of replicated and replicated tables. */ + @Test public void testRightDistributedJoinReplicatedReplicated() { checkRightDistributedJoinWithReplicated(DEP_TAB); } @@ -222,15 +233,16 @@ public void testRightDistributedJoinReplicatedReplicated() { /** * Checks distributed RIGHT JOIN of partitioned and replicated tables. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8732") + @Test public void testRightDistributedJoinPartitionedReplicated() { - fail("https://issues.apache.org/jira/browse/IGNITE-8732"); - checkRightDistributedJoinWithReplicated(DEP_PART_TAB); } /** * Checks distributed RIGHT JOIN of replicated and partitioned tables. */ + @Test public void testRightDistributedJoinReplicatedPartitioned() { setExplain(true); checkRightDistributedJoinReplicatedWith(DEP_PART_TAB); @@ -304,6 +316,7 @@ public void checkRightDistributedJoinReplicatedWith(String depTab) { /** * Check INNER JOIN with collocated data of replicated and partitioned tables. */ + @Test public void testInnerJoinReplicatedPartitioned() { checkInnerJoinEmployeeDepartment(DEP_PART_TAB); } @@ -311,6 +324,7 @@ public void testInnerJoinReplicatedPartitioned() { /** * Check INNER JOIN with collocated data of partitioned and replicated tables. */ + @Test public void testInnerJoinPartitionedReplicated() { checkInnerJoinDepartmentEmployee(DEP_PART_TAB); } @@ -318,15 +332,16 @@ public void testInnerJoinPartitionedReplicated() { /** * Check LEFT JOIN with collocated data of replicated and partitioned tables. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8732") + @Test public void testLeftJoinReplicatedPartitioned() { - fail("https://issues.apache.org/jira/browse/IGNITE-8732"); - checkLeftJoinEmployeeDepartment(DEP_PART_TAB); } /** * Check LEFT JOIN with collocated data of partitioned and replicated tables. */ + @Test public void testLeftJoinPartitionedReplicated() { checkLeftJoinDepartmentEmployee(DEP_PART_TAB); } @@ -334,6 +349,7 @@ public void testLeftJoinPartitionedReplicated() { /** * Check RIGHT JOIN with collocated data of replicated and partitioned tables. */ + @Test public void testRightJoinReplicatedPartitioned() { checkRightJoinEmployeeDepartment(DEP_PART_TAB); } @@ -341,9 +357,9 @@ public void testRightJoinReplicatedPartitioned() { /** * Check RIGHT JOIN with collocated data of partitioned and replicated tables. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-8732") + @Test public void testRightJoinPartitionedReplicated() { - fail("https://issues.apache.org/jira/browse/IGNITE-8732"); - checkRightJoinDepartmentEmployee(DEP_PART_TAB); } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java index b44ff2dbc3517..c62df2fb630c1 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java @@ -17,36 +17,505 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.apache.ignite.internal.processors.cache.AffinityKeyNameAndValueFieldNameConflictTest; +import org.apache.ignite.internal.processors.cache.BigEntryQueryTest; +import org.apache.ignite.internal.processors.cache.BinaryMetadataConcurrentUpdateWithIndexesTest; import org.apache.ignite.internal.processors.cache.BinarySerializationQuerySelfTest; import org.apache.ignite.internal.processors.cache.BinarySerializationQueryWithReflectiveSerializerSelfTest; +import org.apache.ignite.internal.processors.cache.CacheIteratorScanQueryTest; +import org.apache.ignite.internal.processors.cache.CacheLocalQueryDetailMetricsSelfTest; +import org.apache.ignite.internal.processors.cache.CacheLocalQueryMetricsSelfTest; +import org.apache.ignite.internal.processors.cache.CacheOffheapBatchIndexingBaseTest; +import org.apache.ignite.internal.processors.cache.CacheOffheapBatchIndexingMultiTypeTest; +import org.apache.ignite.internal.processors.cache.CacheOffheapBatchIndexingSingleTypeTest; +import org.apache.ignite.internal.processors.cache.CachePartitionedQueryDetailMetricsDistributedSelfTest; +import org.apache.ignite.internal.processors.cache.CachePartitionedQueryDetailMetricsLocalSelfTest; +import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsDistributedSelfTest; +import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsLocalSelfTest; +import org.apache.ignite.internal.processors.cache.CacheQueryBuildValueTest; +import org.apache.ignite.internal.processors.cache.CacheQueryEvictDataLostTest; +import org.apache.ignite.internal.processors.cache.CacheQueryNewClientSelfTest; +import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryDetailMetricsDistributedSelfTest; +import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryDetailMetricsLocalSelfTest; +import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsDistributedSelfTest; +import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsLocalSelfTest; +import org.apache.ignite.internal.processors.cache.CacheSqlQueryValueCopySelfTest; +import org.apache.ignite.internal.processors.cache.DdlTransactionSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheCrossCacheQuerySelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheFullTextQuerySelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheLazyQueryPartitionsReleaseTest; +import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexingDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheQueryInternalKeysSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheQuerySerializationSelfTest; +import org.apache.ignite.internal.processors.cache.GridCacheQuerySqlFieldInlineSizeSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectFieldsQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectLocalQueryArgumentsTest; +import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectQueryArgumentsTest; +import org.apache.ignite.internal.processors.cache.IgniteBinaryWrappedObjectFieldsQuerySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanWithEventsSelfTest; -import org.apache.ignite.internal.processors.cache.BigEntryQueryTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheCollocatedQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheDeleteSqlQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinCollocatedAndNotTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinCustomAffinityMapper; +import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinNoIndexTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinPartitionedAndReplicatedTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinQueryConditionsTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheDuplicateEntityConfigurationSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheFieldsQueryNoDataSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheFullTextQueryNodeJoiningSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheInsertSqlQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheJoinPartitionedAndReplicatedCollocationTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheJoinPartitionedAndReplicatedTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheJoinQueryWithAffinityKeyTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheLargeResultSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheMergeSqlQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheMultipleIndexedTypesTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheNoClassQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapEvictQueryTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapIndexScanTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingQueryErrorTest; +import org.apache.ignite.internal.processors.cache.IgniteCachePrimitiveFieldsQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheQueryH2IndexingLeakTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheQueryIndexSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheQueryLoadSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryErrorSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheUnionDuplicatesTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheUpdateSqlQuerySelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCheckClusterStateBeforeExecuteQueryTest; +import org.apache.ignite.internal.processors.cache.IgniteClientReconnectCacheQueriesFailoverTest; +import org.apache.ignite.internal.processors.cache.IgniteCrossCachesJoinsQueryTest; +import org.apache.ignite.internal.processors.cache.IgniteDynamicSqlRestoreTest; +import org.apache.ignite.internal.processors.cache.IgniteErrorOnRebalanceTest; +import org.apache.ignite.internal.processors.cache.IncorrectQueryEntityTest; +import org.apache.ignite.internal.processors.cache.IndexingCachePartitionLossPolicySelfTest; +import org.apache.ignite.internal.processors.cache.QueryEntityCaseMismatchTest; +import org.apache.ignite.internal.processors.cache.SqlFieldsQuerySelfTest; +import org.apache.ignite.internal.processors.cache.authentication.SqlUserCommandSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicFieldsQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledFieldsQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQueryConfigurationSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedQueryCancelSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQueryEvtsDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQueryP2PDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedSnapshotEnabledQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNoRebalanceSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryROSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQueryEvtsDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQueryP2PDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQuerySelfTest; +import org.apache.ignite.internal.processors.cache.encryption.EncryptedSqlTableTest; +import org.apache.ignite.internal.processors.cache.index.BasicIndexMultinodeTest; +import org.apache.ignite.internal.processors.cache.index.BasicIndexTest; +import org.apache.ignite.internal.processors.cache.index.DuplicateKeyValueClassesSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicIndexClientBasicSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerBasicSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerCoordinatorBasicSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFIlterBasicSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFilterCoordinatorBasicSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2ConnectionLeaksSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicColumnsClientBasicSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicColumnsServerBasicSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicColumnsServerCoordinatorBasicSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexAtomicPartitionedNearSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexAtomicPartitionedSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexAtomicReplicatedSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexTransactionalPartitionedNearSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexTransactionalPartitionedSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexTransactionalReplicatedSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientAtomicPartitionedTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientAtomicReplicatedTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientTransactionalPartitionedTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientTransactionalReplicatedTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerAtomicPartitionedTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerAtomicReplicatedTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerTransactionalPartitionedTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerTransactionalReplicatedTest; +import org.apache.ignite.internal.processors.cache.index.H2DynamicTableSelfTest; +import org.apache.ignite.internal.processors.cache.index.H2RowCachePageEvictionTest; +import org.apache.ignite.internal.processors.cache.index.H2RowCacheSelfTest; +import org.apache.ignite.internal.processors.cache.index.IgniteDecimalSelfTest; +import org.apache.ignite.internal.processors.cache.index.LongIndexNameTest; +import org.apache.ignite.internal.processors.cache.index.OptimizedMarshallerIndexNameTest; +import org.apache.ignite.internal.processors.cache.index.QueryEntityValidationSelfTest; +import org.apache.ignite.internal.processors.cache.index.SchemaExchangeSelfTest; +import org.apache.ignite.internal.processors.cache.index.SqlTransactionCommandsWithMvccDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalAtomicQuerySelfTest; +import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalFieldsQuerySelfTest; +import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQueryCancelOrTimeoutSelfTest; +import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQuerySelfTest; +import org.apache.ignite.internal.processors.cache.query.CacheScanQueryFailoverTest; +import org.apache.ignite.internal.processors.cache.query.GridCacheQueryTransformerSelfTest; +import org.apache.ignite.internal.processors.cache.query.GridCircularQueueTest; +import org.apache.ignite.internal.processors.cache.query.IgniteCacheQueryCacheDestroySelfTest; +import org.apache.ignite.internal.processors.cache.query.IndexingSpiQuerySelfTest; +import org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryTxSelfTest; +import org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryWithH2IndexingSelfTest; +import org.apache.ignite.internal.processors.client.ClientConnectorConfigurationValidationSelfTest; +import org.apache.ignite.internal.processors.database.baseline.IgniteStableBaselineBinObjFieldsQuerySelfTest; +import org.apache.ignite.internal.processors.query.IgniteCachelessQueriesSelfTest; +import org.apache.ignite.internal.processors.query.IgniteQueryDedicatedPoolTest; +import org.apache.ignite.internal.processors.query.IgniteSqlDefaultValueTest; +import org.apache.ignite.internal.processors.query.IgniteSqlDistributedJoinSelfTest; +import org.apache.ignite.internal.processors.query.IgniteSqlEntryCacheModeAgnosticTest; +import org.apache.ignite.internal.processors.query.IgniteSqlGroupConcatCollocatedTest; +import org.apache.ignite.internal.processors.query.IgniteSqlGroupConcatNotCollocatedTest; +import org.apache.ignite.internal.processors.query.IgniteSqlKeyValueFieldsTest; +import org.apache.ignite.internal.processors.query.IgniteSqlNotNullConstraintTest; +import org.apache.ignite.internal.processors.query.IgniteSqlParameterizedQueryTest; +import org.apache.ignite.internal.processors.query.IgniteSqlQueryParallelismTest; +import org.apache.ignite.internal.processors.query.IgniteSqlRoutingTest; +import org.apache.ignite.internal.processors.query.IgniteSqlSchemaIndexingTest; +import org.apache.ignite.internal.processors.query.IgniteSqlSegmentedIndexMultiNodeSelfTest; +import org.apache.ignite.internal.processors.query.IgniteSqlSegmentedIndexSelfTest; +import org.apache.ignite.internal.processors.query.IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest; +import org.apache.ignite.internal.processors.query.IgniteSqlSkipReducerOnUpdateDmlSelfTest; +import org.apache.ignite.internal.processors.query.IgniteSqlSplitterSelfTest; +import org.apache.ignite.internal.processors.query.LazyQuerySelfTest; +import org.apache.ignite.internal.processors.query.MultipleStatementsSqlQuerySelfTest; +import org.apache.ignite.internal.processors.query.SqlIllegalSchemaSelfTest; +import org.apache.ignite.internal.processors.query.SqlPushDownFunctionTest; +import org.apache.ignite.internal.processors.query.SqlSchemaSelfTest; +import org.apache.ignite.internal.processors.query.SqlSystemViewsSelfTest; +import org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessorTest; +import org.apache.ignite.internal.processors.query.h2.GridH2IndexingInMemSelfTest; +import org.apache.ignite.internal.processors.query.h2.GridH2IndexingOffheapSelfTest; +import org.apache.ignite.internal.processors.query.h2.GridIndexRebuildSelfTest; +import org.apache.ignite.internal.processors.query.h2.H2ResultSetIteratorNullifyOnEndSelfTest; +import org.apache.ignite.internal.processors.query.h2.H2StatementCacheSelfTest; +import org.apache.ignite.internal.processors.query.h2.IgniteSqlBigIntegerKeyTest; +import org.apache.ignite.internal.processors.query.h2.IgniteSqlQueryMinMaxTest; +import org.apache.ignite.internal.processors.query.h2.PreparedStatementExSelfTest; +import org.apache.ignite.internal.processors.query.h2.ThreadLocalObjectPoolSelfTest; +import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest; +import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest; +import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryDistributedJoinsTest; +import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryTest; +import org.apache.ignite.internal.processors.sql.IgniteCachePartitionedAtomicColumnConstraintsTest; +import org.apache.ignite.internal.processors.sql.IgniteCachePartitionedTransactionalColumnConstraintsTest; +import org.apache.ignite.internal.processors.sql.IgniteCachePartitionedTransactionalSnapshotColumnConstraintTest; +import org.apache.ignite.internal.processors.sql.IgniteCacheReplicatedAtomicColumnConstraintsTest; +import org.apache.ignite.internal.processors.sql.IgniteCacheReplicatedTransactionalColumnConstraintsTest; +import org.apache.ignite.internal.processors.sql.IgniteCacheReplicatedTransactionalSnapshotColumnConstraintTest; +import org.apache.ignite.internal.processors.sql.IgniteSQLColumnConstraintsTest; +import org.apache.ignite.internal.processors.sql.IgniteTransactionSQLColumnConstraintTest; +import org.apache.ignite.internal.processors.sql.SqlConnectorConfigurationValidationSelfTest; +import org.apache.ignite.internal.sql.SqlParserBulkLoadSelfTest; +import org.apache.ignite.internal.sql.SqlParserCreateIndexSelfTest; +import org.apache.ignite.internal.sql.SqlParserDropIndexSelfTest; +import org.apache.ignite.internal.sql.SqlParserSetStreamingSelfTest; +import org.apache.ignite.internal.sql.SqlParserTransactionalKeywordsSelfTest; +import org.apache.ignite.internal.sql.SqlParserUserSelfTest; +import org.apache.ignite.spi.communication.tcp.GridOrderedMessageCancelSelfTest; +import org.apache.ignite.sqltests.PartitionedSqlTest; +import org.apache.ignite.sqltests.ReplicatedSqlTest; +import org.apache.ignite.testframework.IgniteTestSuite; /** - * Cache query suite with binary marshaller. + * Test suite for cache queries. */ public class IgniteBinaryCacheQueryTestSuite extends TestSuite { /** - * @return Suite. - * @throws Exception In case of error. + * @return Test suite. + * @throws Exception If failed. */ public static TestSuite suite() throws Exception { - TestSuite suite = IgniteCacheQuerySelfTestSuite.suite(); + IgniteTestSuite suite = new IgniteTestSuite("Ignite Cache Queries Test Suite"); + + suite.addTest(new JUnit4TestAdapter(AffinityKeyNameAndValueFieldNameConflictTest.class)); + + suite.addTest(new JUnit4TestAdapter(PartitionedSqlTest.class)); + suite.addTest(new JUnit4TestAdapter(ReplicatedSqlTest.class)); + + suite.addTest(new JUnit4TestAdapter(SqlParserCreateIndexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SqlParserDropIndexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SqlParserTransactionalKeywordsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SqlParserBulkLoadSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SqlParserSetStreamingSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(SqlConnectorConfigurationValidationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientConnectorConfigurationValidationSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(SqlSchemaSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SqlIllegalSchemaSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(MultipleStatementsSqlQuerySelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(BasicIndexTest.class)); + suite.addTest(new JUnit4TestAdapter(BasicIndexMultinodeTest.class)); + + // Misc tests. + suite.addTest(new JUnit4TestAdapter(QueryEntityValidationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DuplicateKeyValueClassesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheLazyQueryPartitionsReleaseTest.class)); + + // Dynamic index create/drop tests. + suite.addTest(new JUnit4TestAdapter(SchemaExchangeSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(DynamicIndexServerCoordinatorBasicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicIndexServerBasicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicIndexServerNodeFilterCoordinatorBasicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicIndexServerNodeFIlterBasicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicIndexClientBasicSelfTest.class)); + + // H2 tests. + suite.addTest(new JUnit4TestAdapter(DmlStatementsProcessorTest.class)); + suite.addTest(new JUnit4TestAdapter(GridH2IndexingInMemSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridH2IndexingOffheapSelfTest.class)); + + // Parsing + suite.addTest(new JUnit4TestAdapter(GridQueryParsingTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheSqlQueryErrorSelfTest.class)); + + // Config. + suite.addTest(new JUnit4TestAdapter(IgniteCacheDuplicateEntityConfigurationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IncorrectQueryEntityTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDynamicSqlRestoreTest.class)); + + // Queries tests. + suite.addTest(new JUnit4TestAdapter(LazyQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlSplitterSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SqlPushDownFunctionTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlSegmentedIndexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachelessQueriesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlSegmentedIndexMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlSchemaIndexingTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheQueryIndexDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryLoadSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLocalQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLocalAtomicQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedQueryP2PDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedQueryEvtsDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedSnapshotEnabledQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicNearEnabledQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedQueryP2PDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedQueryEvtsDisabledSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCacheUnionDuplicatesTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheJoinPartitionedAndReplicatedCollocationTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectCacheQueriesFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteErrorOnRebalanceTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheQueryBuildValueTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheOffheapBatchIndexingMultiTypeTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryIndexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheCollocatedQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLargeResultSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheQueryInternalKeysSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2ResultSetIteratorNullifyOnEndSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlBigIntegerKeyTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheOffheapEvictQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheOffheapIndexScanTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCacheCrossCacheQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheQuerySerializationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteBinaryObjectFieldsQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteStableBaselineBinObjFieldsQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteBinaryWrappedObjectFieldsQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryH2IndexingLeakTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryNoRebalanceSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheQueryTransformerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheScanQueryFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePrimitiveFieldsQuerySelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCacheJoinQueryWithAffinityKeyTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheJoinPartitionedAndReplicatedTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCrossCachesJoinsQueryTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCacheMultipleIndexedTypesTest.class)); + + // DML. + suite.addTest(new JUnit4TestAdapter(IgniteCacheMergeSqlQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheInsertSqlQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheUpdateSqlQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDeleteSqlQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlSkipReducerOnUpdateDmlSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteBinaryObjectQueryArgumentsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteBinaryObjectLocalQueryArgumentsTest.class)); + + suite.addTest(new JUnit4TestAdapter(IndexingSpiQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IndexingSpiQueryTxSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCacheMultipleIndexedTypesTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlQueryMinMaxTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridCircularQueueTest.class)); + suite.addTest(new JUnit4TestAdapter(IndexingSpiQueryWithH2IndexingSelfTest.class)); + + // DDL. + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexTransactionalReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexTransactionalPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexTransactionalPartitionedNearSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexAtomicReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexAtomicPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexAtomicPartitionedNearSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicTableSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicColumnsClientBasicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicColumnsServerBasicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicColumnsServerCoordinatorBasicSelfTest.class)); + + // DML+DDL. + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexClientAtomicPartitionedTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexClientAtomicReplicatedTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexClientTransactionalPartitionedTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexClientTransactionalReplicatedTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexServerAtomicPartitionedTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexServerAtomicReplicatedTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexServerTransactionalPartitionedTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest.class)); + suite.addTest(new JUnit4TestAdapter(H2DynamicIndexingComplexServerTransactionalReplicatedTest.class)); + + suite.addTest(new JUnit4TestAdapter(DdlTransactionSelfTest.class)); + + // Fields queries. + suite.addTest(new JUnit4TestAdapter(SqlFieldsQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLocalFieldsQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedFieldsQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedFieldsQueryROSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedFieldsQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicFieldsQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheAtomicNearEnabledFieldsQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheFieldsQueryNoDataSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheQueryIndexingDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridOrderedMessageCancelSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheQueryEvictDataLostTest.class)); + + // Full text queries. + suite.addTest(new JUnit4TestAdapter(GridCacheFullTextQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheFullTextQueryNodeJoiningSelfTest.class)); + + // Ignite cache and H2 comparison. + suite.addTest(new JUnit4TestAdapter(BaseH2CompareQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(H2CompareBigQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(H2CompareBigQueryDistributedJoinsTest.class)); + + // Cache query metrics. + suite.addTest(new JUnit4TestAdapter(CacheLocalQueryMetricsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePartitionedQueryMetricsDistributedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePartitionedQueryMetricsLocalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheReplicatedQueryMetricsDistributedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheReplicatedQueryMetricsLocalSelfTest.class)); + + // Cache query metrics. + suite.addTest(new JUnit4TestAdapter(CacheLocalQueryDetailMetricsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePartitionedQueryDetailMetricsDistributedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePartitionedQueryDetailMetricsLocalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheReplicatedQueryDetailMetricsDistributedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheReplicatedQueryDetailMetricsLocalSelfTest.class)); + + // Unmarshalling query test. + suite.addTest(new JUnit4TestAdapter(IgniteCacheP2pUnmarshallingQueryErrorTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheNoClassQuerySelfTest.class)); + + // Cancellation. + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedQueryCancelSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLocalQueryCancelOrTimeoutSelfTest.class)); + + // Distributed joins. + suite.addTest(new JUnit4TestAdapter(H2CompareBigQueryDistributedJoinsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedJoinCollocatedAndNotTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedJoinCustomAffinityMapper.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedJoinNoIndexTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedJoinPartitionedAndReplicatedTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedJoinQueryConditionsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedJoinTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlDistributedJoinSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlQueryParallelismTest.class)); + + // Other. + suite.addTest(new JUnit4TestAdapter(CacheIteratorScanQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheQueryNewClientSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheOffheapBatchIndexingSingleTypeTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheSqlQueryValueCopySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryCacheDestroySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteQueryDedicatedPoolTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlEntryCacheModeAgnosticTest.class)); + suite.addTest(new JUnit4TestAdapter(QueryEntityCaseMismatchTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedPartitionQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedPartitionQueryConfigurationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlKeyValueFieldsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlRoutingTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlNotNullConstraintTest.class)); + suite.addTest(new JUnit4TestAdapter(LongIndexNameTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheQuerySqlFieldInlineSizeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlParameterizedQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(H2ConnectionLeaksSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCheckClusterStateBeforeExecuteQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(OptimizedMarshallerIndexNameTest.class)); + suite.addTest(new JUnit4TestAdapter(SqlSystemViewsSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(GridIndexRebuildSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(SqlTransactionCommandsWithMvccDisabledSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteSqlDefaultValueTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDecimalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSQLColumnConstraintsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteTransactionSQLColumnConstraintTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedAtomicColumnConstraintsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedTransactionalColumnConstraintsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedAtomicColumnConstraintsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedTransactionalColumnConstraintsTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedTransactionalSnapshotColumnConstraintTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedTransactionalSnapshotColumnConstraintTest.class)); + + // H2 Rows on-heap cache + suite.addTest(new JUnit4TestAdapter(H2RowCacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2RowCachePageEvictionTest.class)); + + // User operation SQL + suite.addTest(new JUnit4TestAdapter(SqlParserUserSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(SqlUserCommandSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(EncryptedSqlTableTest.class)); + + suite.addTest(new JUnit4TestAdapter(ThreadLocalObjectPoolSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(H2StatementCacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(PreparedStatementExSelfTest.class)); - // Serialization. - suite.addTestSuite(BinarySerializationQuerySelfTest.class); - suite.addTestSuite(BinarySerializationQueryWithReflectiveSerializerSelfTest.class); - suite.addTestSuite(IgniteCacheBinaryObjectsScanSelfTest.class); - suite.addTestSuite(IgniteCacheBinaryObjectsScanWithEventsSelfTest.class); - suite.addTestSuite(BigEntryQueryTest.class); + // Partition loss. + suite.addTest(new JUnit4TestAdapter(IndexingCachePartitionLossPolicySelfTest.class)); - //Should be adjusted. Not ready to be used with BinaryMarshaller. - //suite.addTestSuite(GridCacheBinarySwapScanQuerySelfTest.class); + // GROUP_CONCAT + suite.addTest(new JUnit4TestAdapter(IgniteSqlGroupConcatCollocatedTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlGroupConcatNotCollocatedTest.class)); - //TODO: the following tests= was never tested with binary. Exclude or pass? -// suite.addTestSuite(IgniteSqlSchemaIndexingTest.class); + // Binary + suite.addTest(new JUnit4TestAdapter(BinarySerializationQuerySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BinarySerializationQueryWithReflectiveSerializerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheBinaryObjectsScanSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheBinaryObjectsScanWithEventsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(BigEntryQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(BinaryMetadataConcurrentUpdateWithIndexesTest.class)); return suite; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite2.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite2.java index ce2a6669f621a..33b6273cfd701 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite2.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite2.java @@ -17,21 +17,112 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.apache.ignite.internal.processors.cache.CacheScanPartitionQueryFallbackSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheCrossCacheJoinRandomTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheObjectKeyIndexingSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCachePartitionedQueryMultiThreadedSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheQueriesLoadTest1; +import org.apache.ignite.internal.processors.cache.IgniteCacheQueryEvictsMultiThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryMultiThreadedSelfTest; +import org.apache.ignite.internal.processors.cache.QueryJoinWithDifferentNodeFiltersTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheClientQueryReplicatedNodeRestartSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeFailTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartDistributedJoinSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest2; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartTxSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteSqlQueryWithBaselineTest; +import org.apache.ignite.internal.processors.cache.index.DynamicColumnsConcurrentAtomicPartitionedSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicColumnsConcurrentAtomicReplicatedSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicColumnsConcurrentTransactionalPartitionedSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicColumnsConcurrentTransactionalReplicatedSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicIndexPartitionedAtomicConcurrentSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicIndexPartitionedTransactionalConcurrentSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicIndexReplicatedAtomicConcurrentSelfTest; +import org.apache.ignite.internal.processors.cache.index.DynamicIndexReplicatedTransactionalConcurrentSelfTest; +import org.apache.ignite.internal.processors.cache.query.ScanQueryOffheapExpiryPolicySelfTest; +import org.apache.ignite.internal.processors.database.baseline.IgniteChangingBaselineCacheQueryNodeRestartSelfTest; +import org.apache.ignite.internal.processors.database.baseline.IgniteStableBaselineCacheQueryNodeRestartsSelfTest; +import org.apache.ignite.internal.processors.query.*; +import org.apache.ignite.internal.processors.query.h2.twostep.CacheQueryMemoryLeakTest; +import org.apache.ignite.internal.processors.query.h2.twostep.DisappearedCacheCauseRetryMessageSelfTest; +import org.apache.ignite.internal.processors.query.h2.twostep.DisappearedCacheWasNotFoundMessageSelfTest; +import org.apache.ignite.internal.processors.query.h2.twostep.NonCollocatedRetryMessageSelfTest; +import org.apache.ignite.internal.processors.query.h2.twostep.RetryCauseMessageSelfTest; +import org.apache.ignite.internal.processors.query.h2.twostep.TableViewSubquerySelfTest; +import org.apache.ignite.testframework.IgniteTestSuite; /** - * Cache query suite with binary marshaller. + * Test suite for cache queries. */ public class IgniteBinaryCacheQueryTestSuite2 extends TestSuite { /** - * @return Suite. - * @throws Exception In case of error. + * @return Test suite. + * @throws Exception If failed. */ public static TestSuite suite() throws Exception { - TestSuite suite = IgniteCacheQuerySelfTestSuite2.suite(); + TestSuite suite = new IgniteTestSuite("Ignite Cache Queries Test Suite 2"); - suite.addTestSuite(IgniteCacheQueriesLoadTest1.class); + // Dynamic index create/drop tests. + suite.addTest(new JUnit4TestAdapter(DynamicIndexPartitionedAtomicConcurrentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicIndexPartitionedTransactionalConcurrentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicIndexReplicatedAtomicConcurrentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicIndexReplicatedTransactionalConcurrentSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(DynamicColumnsConcurrentAtomicPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicColumnsConcurrentTransactionalPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicColumnsConcurrentAtomicReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DynamicColumnsConcurrentTransactionalReplicatedSelfTest.class)); + + // Distributed joins. + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryNodeRestartDistributedJoinSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.class)); + + // Other tests. + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryMultiThreadedSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryEvictsMultiThreadedSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(ScanQueryOffheapExpiryPolicySelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCacheCrossCacheJoinRandomTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheClientQueryReplicatedNodeRestartSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryNodeFailTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryNodeRestartSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlQueryWithBaselineTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteChangingBaselineCacheQueryNodeRestartSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteStableBaselineCacheQueryNodeRestartsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryNodeRestartSelfTest2.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueryNodeRestartTxSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheSqlQueryMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePartitionedQueryMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheScanPartitionQueryFallbackSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheObjectKeyIndexingSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCacheGroupsCompareQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheGroupsSqlSegmentedIndexSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheGroupsSqlSegmentedIndexMultiNodeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheGroupsSqlDistributedJoinSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(QueryJoinWithDifferentNodeFiltersTest.class)); + + suite.addTest(new JUnit4TestAdapter(CacheQueryMemoryLeakTest.class)); + + suite.addTest(new JUnit4TestAdapter(NonCollocatedRetryMessageSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(RetryCauseMessageSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DisappearedCacheCauseRetryMessageSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(DisappearedCacheWasNotFoundMessageSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(TableViewSubquerySelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteCacheQueriesLoadTest1.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSqlCreateTableTemplateTest.class)); return suite; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java index 109e244e0b5b7..0bf334a9e8519 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java @@ -19,14 +19,16 @@ import junit.framework.TestSuite; import org.apache.ignite.testframework.config.GridTestProperties; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Cache query suite with binary marshaller. */ -public class IgniteBinarySimpleNameMapperCacheQueryTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteBinarySimpleNameMapperCacheQueryTestSuite { /** * @return Suite. - * @throws Exception In case of error. */ public static TestSuite suite() throws Exception { GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true"); diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheAffinityRunTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheAffinityRunTestSuite.java index e9c7b79c6f73d..9b470f779da3a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheAffinityRunTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheAffinityRunTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.IgniteCacheLockPartitionOnAffinityRunAtomicCacheOpTest; import org.apache.ignite.internal.processors.cache.IgniteCacheLockPartitionOnAffinityRunTest; @@ -24,26 +25,28 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheLockPartitionOnAffinityRunWithCollisionSpiTest; import org.apache.ignite.internal.processors.database.baseline.IgniteBaselineLockPartitionOnAffinityRunAtomicCacheTest; import org.apache.ignite.internal.processors.database.baseline.IgniteBaselineLockPartitionOnAffinityRunTxCacheTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Compute and Cache tests for affinityRun/Call. These tests is extracted into separate suite * because ones take a lot of time. */ -public class IgniteCacheAffinityRunTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheAffinityRunTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Compute and Cache Affinity Run Test Suite"); - suite.addTestSuite(IgniteCacheLockPartitionOnAffinityRunTest.class); - suite.addTestSuite(IgniteCacheLockPartitionOnAffinityRunWithCollisionSpiTest.class); - suite.addTestSuite(IgniteCacheLockPartitionOnAffinityRunAtomicCacheOpTest.class); - suite.addTestSuite(IgniteBaselineLockPartitionOnAffinityRunAtomicCacheTest.class); - suite.addTestSuite(IgniteBaselineLockPartitionOnAffinityRunTxCacheTest.class); - suite.addTestSuite(IgniteCacheLockPartitionOnAffinityRunTxCacheOpTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLockPartitionOnAffinityRunTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLockPartitionOnAffinityRunWithCollisionSpiTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLockPartitionOnAffinityRunAtomicCacheOpTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteBaselineLockPartitionOnAffinityRunAtomicCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteBaselineLockPartitionOnAffinityRunTxCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheLockPartitionOnAffinityRunTxCacheOpTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheConfigVariationQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheConfigVariationQueryTestSuite.java index 83ae27f584a9c..a8e9c1c4832e0 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheConfigVariationQueryTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheConfigVariationQueryTestSuite.java @@ -20,16 +20,18 @@ import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.IgniteCacheConfigVariationsQueryTest; import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cache queries. */ -public class IgniteCacheConfigVariationQueryTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheConfigVariationQueryTestSuite { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { return new ConfigVariationsTestSuiteBuilder( "Cache Config Variations Query Test Suite", IgniteCacheConfigVariationsQueryTest.class) diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccSqlTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccSqlTestSuite.java index 15045c9f6e9c5..04189145dba35 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccSqlTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheMvccSqlTestSuite.java @@ -17,7 +17,6 @@ package org.apache.ignite.testsuites; -import junit.framework.TestSuite; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedTxPessimisticOriginatingNodeFailureSelfTest; @@ -63,6 +62,7 @@ import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccSqlContinuousQueryPartitionedSelfTest; import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccSqlContinuousQueryReplicatedSelfTest; import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccSqlLockTimeoutTest; +import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccSqlTxModesTest; import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccSqlUpdateCountersTest; import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccStreamingInsertTest; import org.apache.ignite.internal.processors.cache.mvcc.CacheMvccTxNodeMappingTest; @@ -70,96 +70,91 @@ import org.apache.ignite.internal.processors.cache.mvcc.MvccRepeatableReadBulkOpsTest; import org.apache.ignite.internal.processors.cache.mvcc.MvccRepeatableReadOperationsTest; import org.apache.ignite.internal.processors.query.h2.GridIndexRebuildWithMvccEnabledSelfTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT; -/** - * - */ -public class IgniteCacheMvccSqlTestSuite extends TestSuite { - /** - * @return Test suite. - */ - public static TestSuite suite() { - TestSuite suite = new TestSuite("IgniteCache SQL MVCC Test Suite"); - - // Simple tests. - suite.addTestSuite(MvccEmptyTransactionSelfTest.class); - suite.addTestSuite(CacheMvccSqlConfigurationValidationTest.class); - suite.addTestSuite(CacheMvccDmlSimpleTest.class); - suite.addTestSuite(SqlTransactionsCommandsWithMvccEnabledSelfTest.class); - suite.addTestSuite(CacheMvccSizeTest.class); - suite.addTestSuite(CacheMvccSqlUpdateCountersTest.class); - suite.addTestSuite(CacheMvccSqlLockTimeoutTest.class); - - suite.addTestSuite(GridIndexRebuildWithMvccEnabledSelfTest.class); - - suite.addTestSuite(CacheMvccTxNodeMappingTest.class); - - // SQL vs CacheAPI consistency. - suite.addTestSuite(MvccRepeatableReadOperationsTest.class); - suite.addTestSuite(MvccRepeatableReadBulkOpsTest.class); - - // JDBC tests. - suite.addTestSuite(CacheMvccSizeWithConcurrentJdbcTransactionTest.class); - suite.addTestSuite(CacheMvccScanQueryWithConcurrentJdbcTransactionTest.class); - suite.addTestSuite(CacheMvccLocalEntriesWithConcurrentJdbcTransactionTest.class); - suite.addTestSuite(CacheMvccIteratorWithConcurrentJdbcTransactionTest.class); - - // Load tests. - suite.addTestSuite(CacheMvccBulkLoadTest.class); - suite.addTestSuite(CacheMvccStreamingInsertTest.class); - - suite.addTestSuite(CacheMvccPartitionedSqlQueriesTest.class); - suite.addTestSuite(CacheMvccReplicatedSqlQueriesTest.class); - suite.addTestSuite(CacheMvccPartitionedSqlTxQueriesTest.class); - suite.addTestSuite(CacheMvccReplicatedSqlTxQueriesTest.class); - - suite.addTestSuite(CacheMvccPartitionedSqlTxQueriesWithReducerTest.class); - suite.addTestSuite(CacheMvccReplicatedSqlTxQueriesWithReducerTest.class); - suite.addTestSuite(CacheMvccPartitionedSelectForUpdateQueryTest.class); - suite.addTestSuite(CacheMvccReplicatedSelectForUpdateQueryTest.class); - - // Failover tests. - suite.addTestSuite(CacheMvccPartitionedBackupsTest.class); - suite.addTestSuite(CacheMvccReplicatedBackupsTest.class); - - suite.addTestSuite(CacheMvccPartitionedSqlCoordinatorFailoverTest.class); - suite.addTestSuite(CacheMvccReplicatedSqlCoordinatorFailoverTest.class); - - // Continuous queries. - suite.addTestSuite(CacheMvccBasicContinuousQueryTest.class); - suite.addTestSuite(CacheMvccContinuousQueryPartitionedSelfTest.class); - suite.addTestSuite(CacheMvccContinuousQueryReplicatedSelfTest.class); - suite.addTestSuite(CacheMvccSqlContinuousQueryPartitionedSelfTest.class); - suite.addTestSuite(CacheMvccSqlContinuousQueryReplicatedSelfTest.class); - - suite.addTestSuite(CacheMvccContinuousQueryPartitionedTxOneNodeTest.class); - suite.addTestSuite(CacheMvccContinuousQueryReplicatedTxOneNodeTest.class); - - suite.addTestSuite(CacheMvccContinuousQueryClientReconnectTest.class); - suite.addTestSuite(CacheMvccContinuousQueryClientTest.class); - - suite.addTestSuite(CacheMvccContinuousQueryMultiNodesFilteringTest.class); - suite.addTestSuite(CacheMvccContinuousQueryBackupQueueTest.class); - suite.addTestSuite(CacheMvccContinuousQueryImmutableEntryTest.class); - suite.addTestSuite(CacheMvccClientReconnectContinuousQueryTest.class); - - suite.addTestSuite(CacheMvccContinuousWithTransformerClientSelfTest.class); - suite.addTestSuite(CacheMvccContinuousWithTransformerPartitionedSelfTest.class); - suite.addTestSuite(CacheMvccContinuousWithTransformerReplicatedSelfTest.class); - - // Transaction recovery. - suite.addTestSuite(CacheMvccTxRecoveryTest.class); - - suite.addTestSuite(MvccPartitionedPrimaryNodeFailureRecoveryTest.class); - suite.addTestSuite(MvccPartitionedTwoBackupsPrimaryNodeFailureRecoveryTest.class); - suite.addTestSuite(MvccColocatedTxPessimisticOriginatingNodeFailureRecoveryTest.class); - suite.addTestSuite(MvccReplicatedTxPessimisticOriginatingNodeFailureRecoveryTest.class); - - return suite; - } - +/** */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + // Simple tests. + MvccEmptyTransactionSelfTest.class, + CacheMvccSqlConfigurationValidationTest.class, + CacheMvccDmlSimpleTest.class, + SqlTransactionsCommandsWithMvccEnabledSelfTest.class, + CacheMvccSizeTest.class, + CacheMvccSqlUpdateCountersTest.class, + CacheMvccSqlLockTimeoutTest.class, + CacheMvccSqlTxModesTest.class, + GridIndexRebuildWithMvccEnabledSelfTest.class, + + CacheMvccTxNodeMappingTest.class, + + // SQL vs CacheAPI consistency. + MvccRepeatableReadOperationsTest.class, + MvccRepeatableReadBulkOpsTest.class, + + // JDBC tests. + CacheMvccSizeWithConcurrentJdbcTransactionTest.class, + CacheMvccScanQueryWithConcurrentJdbcTransactionTest.class, + CacheMvccLocalEntriesWithConcurrentJdbcTransactionTest.class, + CacheMvccIteratorWithConcurrentJdbcTransactionTest.class, + + // Load tests. + CacheMvccBulkLoadTest.class, + CacheMvccStreamingInsertTest.class, + + CacheMvccPartitionedSqlQueriesTest.class, + CacheMvccReplicatedSqlQueriesTest.class, + CacheMvccPartitionedSqlTxQueriesTest.class, + CacheMvccReplicatedSqlTxQueriesTest.class, + + CacheMvccPartitionedSqlTxQueriesWithReducerTest.class, + CacheMvccReplicatedSqlTxQueriesWithReducerTest.class, + CacheMvccPartitionedSelectForUpdateQueryTest.class, + CacheMvccReplicatedSelectForUpdateQueryTest.class, + + // Failover tests. + CacheMvccPartitionedBackupsTest.class, + CacheMvccReplicatedBackupsTest.class, + + CacheMvccPartitionedSqlCoordinatorFailoverTest.class, + CacheMvccReplicatedSqlCoordinatorFailoverTest.class, + + // Continuous queries. + CacheMvccBasicContinuousQueryTest.class, + CacheMvccContinuousQueryPartitionedSelfTest.class, + CacheMvccContinuousQueryReplicatedSelfTest.class, + CacheMvccSqlContinuousQueryPartitionedSelfTest.class, + CacheMvccSqlContinuousQueryReplicatedSelfTest.class, + + CacheMvccContinuousQueryPartitionedTxOneNodeTest.class, + CacheMvccContinuousQueryReplicatedTxOneNodeTest.class, + + CacheMvccContinuousQueryClientReconnectTest.class, + CacheMvccContinuousQueryClientTest.class, + + CacheMvccContinuousQueryMultiNodesFilteringTest.class, + CacheMvccContinuousQueryBackupQueueTest.class, + CacheMvccContinuousQueryImmutableEntryTest.class, + CacheMvccClientReconnectContinuousQueryTest.class, + + CacheMvccContinuousWithTransformerClientSelfTest.class, + CacheMvccContinuousWithTransformerPartitionedSelfTest.class, + CacheMvccContinuousWithTransformerReplicatedSelfTest.class, + + // Transaction recovery. + CacheMvccTxRecoveryTest.class, + + IgniteCacheMvccSqlTestSuite.MvccPartitionedPrimaryNodeFailureRecoveryTest.class, + IgniteCacheMvccSqlTestSuite.MvccPartitionedTwoBackupsPrimaryNodeFailureRecoveryTest.class, + IgniteCacheMvccSqlTestSuite.MvccColocatedTxPessimisticOriginatingNodeFailureRecoveryTest.class, + IgniteCacheMvccSqlTestSuite.MvccReplicatedTxPessimisticOriginatingNodeFailureRecoveryTest.class +}) +public class IgniteCacheMvccSqlTestSuite { /** */ public static class MvccPartitionedPrimaryNodeFailureRecoveryTest extends IgniteCachePartitionedNearDisabledPrimaryNodeFailureRecoveryTest { @@ -199,5 +194,12 @@ public static class MvccReplicatedTxPessimisticOriginatingNodeFailureRecoveryTes @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL_SNAPSHOT; } + + /** {@inheritDoc} */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10765") + @Test + @Override public void testManyKeysRollback() throws Exception { + super.testManyKeysRollback(); + } } } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java deleted file mode 100644 index 801d51e2754dc..0000000000000 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java +++ /dev/null @@ -1,491 +0,0 @@ -/* - * 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. - */ - -package org.apache.ignite.testsuites; - -import junit.framework.TestSuite; -import org.apache.ignite.internal.processors.cache.CacheIteratorScanQueryTest; -import org.apache.ignite.internal.processors.cache.CacheLocalQueryDetailMetricsSelfTest; -import org.apache.ignite.internal.processors.cache.CacheLocalQueryMetricsSelfTest; -import org.apache.ignite.internal.processors.cache.CacheOffheapBatchIndexingSingleTypeTest; -import org.apache.ignite.internal.processors.cache.CachePartitionedQueryDetailMetricsDistributedSelfTest; -import org.apache.ignite.internal.processors.cache.CachePartitionedQueryDetailMetricsLocalSelfTest; -import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsDistributedSelfTest; -import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsLocalSelfTest; -import org.apache.ignite.internal.processors.cache.CacheQueryEvictDataLostTest; -import org.apache.ignite.internal.processors.cache.CacheQueryNewClientSelfTest; -import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryDetailMetricsDistributedSelfTest; -import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryDetailMetricsLocalSelfTest; -import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsDistributedSelfTest; -import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsLocalSelfTest; -import org.apache.ignite.internal.processors.cache.CacheSqlQueryValueCopySelfTest; -import org.apache.ignite.internal.processors.cache.DdlTransactionSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheCrossCacheQuerySelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheFullTextQuerySelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheLazyQueryPartitionsReleaseTest; -import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexingDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheQueryInternalKeysSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheQuerySerializationSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheQuerySqlFieldInlineSizeSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectLocalQueryArgumentsTest; -import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectQueryArgumentsTest; -import org.apache.ignite.internal.processors.cache.IgniteBinaryWrappedObjectFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheCollocatedQuerySelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheDeleteSqlQuerySelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinCollocatedAndNotTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinCustomAffinityMapper; -import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinNoIndexTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinPartitionedAndReplicatedTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinQueryConditionsTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheDistributedJoinTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheDuplicateEntityConfigurationSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheFieldsQueryNoDataSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheFullTextQueryNodeJoiningSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheInsertSqlQuerySelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheJoinPartitionedAndReplicatedTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheJoinQueryWithAffinityKeyTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheLargeResultSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheMergeSqlQuerySelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheMultipleIndexedTypesTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheNoClassQuerySelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapEvictQueryTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapIndexScanTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingQueryErrorTest; -import org.apache.ignite.internal.processors.cache.IgniteCachePrimitiveFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheQueryH2IndexingLeakTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheQueryIndexSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheQueryLoadSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryErrorSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheUpdateSqlQuerySelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCheckClusterStateBeforeExecuteQueryTest; -import org.apache.ignite.internal.processors.cache.IgniteCrossCachesJoinsQueryTest; -import org.apache.ignite.internal.processors.cache.IgniteDynamicSqlRestoreTest; -import org.apache.ignite.internal.processors.cache.IncorrectQueryEntityTest; -import org.apache.ignite.internal.processors.cache.IndexingCachePartitionLossPolicySelfTest; -import org.apache.ignite.internal.processors.cache.QueryEntityCaseMismatchTest; -import org.apache.ignite.internal.processors.cache.SqlFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.cache.authentication.SqlUserCommandSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledQuerySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicQuerySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQueryConfigurationSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQuerySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedQueryCancelSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQueryEvtsDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQueryP2PDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQuerySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedSnapshotEnabledQuerySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryAbstractDistributedJoinSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNoRebalanceSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryROSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQueryEvtsDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQueryP2PDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQuerySelfTest; -import org.apache.ignite.internal.processors.cache.encryption.EncryptedSqlTableTest; -import org.apache.ignite.internal.processors.cache.index.BasicIndexTest; -import org.apache.ignite.internal.processors.cache.index.DuplicateKeyValueClassesSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicIndexClientBasicSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerBasicSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerCoordinatorBasicSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFIlterBasicSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFilterCoordinatorBasicSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2ConnectionLeaksSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicColumnsClientBasicSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicColumnsServerBasicSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicColumnsServerCoordinatorBasicSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexAtomicPartitionedNearSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexAtomicPartitionedSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexAtomicReplicatedSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexTransactionalPartitionedNearSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexTransactionalPartitionedSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexTransactionalReplicatedSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientAtomicPartitionedTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientAtomicReplicatedTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientTransactionalPartitionedTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexClientTransactionalReplicatedTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerAtomicPartitionedTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerAtomicReplicatedTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerTransactionalPartitionedTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicIndexingComplexServerTransactionalReplicatedTest; -import org.apache.ignite.internal.processors.cache.index.H2DynamicTableSelfTest; -import org.apache.ignite.internal.processors.cache.index.H2RowCachePageEvictionTest; -import org.apache.ignite.internal.processors.cache.index.H2RowCacheSelfTest; -import org.apache.ignite.internal.processors.cache.index.IgniteDecimalSelfTest; -import org.apache.ignite.internal.processors.cache.index.LongIndexNameTest; -import org.apache.ignite.internal.processors.cache.index.OptimizedMarshallerIndexNameTest; -import org.apache.ignite.internal.processors.cache.index.SchemaExchangeSelfTest; -import org.apache.ignite.internal.processors.cache.index.SqlTransactionCommandsWithMvccDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalAtomicQuerySelfTest; -import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQueryCancelOrTimeoutSelfTest; -import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQuerySelfTest; -import org.apache.ignite.internal.processors.cache.query.CacheScanQueryFailoverTest; -import org.apache.ignite.internal.processors.cache.query.GridCacheQueryTransformerSelfTest; -import org.apache.ignite.internal.processors.cache.query.IgniteCacheQueryCacheDestroySelfTest; -import org.apache.ignite.internal.processors.cache.query.IndexingSpiQuerySelfTest; -import org.apache.ignite.internal.processors.cache.query.IndexingSpiQueryTxSelfTest; -import org.apache.ignite.internal.processors.client.ClientConnectorConfigurationValidationSelfTest; -import org.apache.ignite.internal.processors.database.baseline.IgniteStableBaselineBinObjFieldsQuerySelfTest; -import org.apache.ignite.internal.processors.query.IgniteCachelessQueriesSelfTest; -import org.apache.ignite.internal.processors.query.IgniteQueryDedicatedPoolTest; -import org.apache.ignite.internal.processors.query.IgniteSqlDefaultValueTest; -import org.apache.ignite.internal.processors.query.IgniteSqlDistributedJoinSelfTest; -import org.apache.ignite.internal.processors.query.IgniteSqlEntryCacheModeAgnosticTest; -import org.apache.ignite.internal.processors.query.IgniteSqlGroupConcatCollocatedTest; -import org.apache.ignite.internal.processors.query.IgniteSqlGroupConcatNotCollocatedTest; -import org.apache.ignite.internal.processors.query.IgniteSqlKeyValueFieldsTest; -import org.apache.ignite.internal.processors.query.IgniteSqlNotNullConstraintTest; -import org.apache.ignite.internal.processors.query.IgniteSqlParameterizedQueryTest; -import org.apache.ignite.internal.processors.query.IgniteSqlQueryParallelismTest; -import org.apache.ignite.internal.processors.query.IgniteSqlRoutingTest; -import org.apache.ignite.internal.processors.query.IgniteSqlSchemaIndexingTest; -import org.apache.ignite.internal.processors.query.IgniteSqlSegmentedIndexMultiNodeSelfTest; -import org.apache.ignite.internal.processors.query.IgniteSqlSegmentedIndexSelfTest; -import org.apache.ignite.internal.processors.query.IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest; -import org.apache.ignite.internal.processors.query.IgniteSqlSkipReducerOnUpdateDmlSelfTest; -import org.apache.ignite.internal.processors.query.IgniteSqlSplitterSelfTest; -import org.apache.ignite.internal.processors.query.LazyQuerySelfTest; -import org.apache.ignite.internal.processors.query.MultipleStatementsSqlQuerySelfTest; -import org.apache.ignite.internal.processors.query.SqlIllegalSchemaSelfTest; -import org.apache.ignite.internal.processors.query.SqlPushDownFunctionTest; -import org.apache.ignite.internal.processors.query.SqlSchemaSelfTest; -import org.apache.ignite.internal.processors.query.SqlSystemViewsSelfTest; -import org.apache.ignite.internal.processors.query.h2.GridH2IndexingInMemSelfTest; -import org.apache.ignite.internal.processors.query.h2.GridH2IndexingOffheapSelfTest; -import org.apache.ignite.internal.processors.query.h2.GridIndexRebuildSelfTest; -import org.apache.ignite.internal.processors.query.h2.H2ResultSetIteratorNullifyOnEndSelfTest; -import org.apache.ignite.internal.processors.query.h2.H2StatementCacheSelfTest; -import org.apache.ignite.internal.processors.query.h2.IgniteSqlBigIntegerKeyTest; -import org.apache.ignite.internal.processors.query.h2.IgniteSqlQueryMinMaxTest; -import org.apache.ignite.internal.processors.query.h2.PreparedStatementExSelfTest; -import org.apache.ignite.internal.processors.query.h2.ThreadLocalObjectPoolSelfTest; -import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest; -import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest; -import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryDistributedJoinsTest; -import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryTest; -import org.apache.ignite.internal.processors.sql.IgniteCachePartitionedAtomicColumnConstraintsTest; -import org.apache.ignite.internal.processors.sql.IgniteCachePartitionedTransactionalColumnConstraintsTest; -import org.apache.ignite.internal.processors.sql.IgniteCacheReplicatedAtomicColumnConstraintsTest; -import org.apache.ignite.internal.processors.sql.IgniteCacheReplicatedTransactionalColumnConstraintsTest; -import org.apache.ignite.internal.processors.sql.IgniteSQLColumnConstraintsTest; -import org.apache.ignite.internal.processors.sql.SqlConnectorConfigurationValidationSelfTest; -import org.apache.ignite.internal.sql.SqlParserBulkLoadSelfTest; -import org.apache.ignite.internal.sql.SqlParserCreateIndexSelfTest; -import org.apache.ignite.internal.sql.SqlParserDropIndexSelfTest; -import org.apache.ignite.internal.sql.SqlParserSetStreamingSelfTest; -import org.apache.ignite.internal.sql.SqlParserTransactionalKeywordsSelfTest; -import org.apache.ignite.internal.sql.SqlParserUserSelfTest; -import org.apache.ignite.spi.communication.tcp.GridOrderedMessageCancelSelfTest; -import org.apache.ignite.sqltests.PartitionedSqlTest; -import org.apache.ignite.sqltests.ReplicatedSqlTest; -import org.apache.ignite.testframework.IgniteTestSuite; - -/** - * Test suite for cache queries. - */ -public class IgniteCacheQuerySelfTestSuite extends TestSuite { - /** - * @return Test suite. - * @throws Exception If failed. - */ - public static TestSuite suite() throws Exception { - IgniteTestSuite suite = new IgniteTestSuite("Ignite Cache Queries Test Suite"); - - suite.addTestSuite(PartitionedSqlTest.class); - suite.addTestSuite(ReplicatedSqlTest.class); - - suite.addTestSuite(SqlParserCreateIndexSelfTest.class); - suite.addTestSuite(SqlParserDropIndexSelfTest.class); - suite.addTestSuite(SqlParserTransactionalKeywordsSelfTest.class); - suite.addTestSuite(SqlParserBulkLoadSelfTest.class); - suite.addTestSuite(SqlParserSetStreamingSelfTest.class); - - suite.addTestSuite(SqlConnectorConfigurationValidationSelfTest.class); - suite.addTestSuite(ClientConnectorConfigurationValidationSelfTest.class); - - suite.addTestSuite(SqlSchemaSelfTest.class); - suite.addTestSuite(SqlIllegalSchemaSelfTest.class); - suite.addTestSuite(MultipleStatementsSqlQuerySelfTest.class); - - suite.addTestSuite(BasicIndexTest.class); - - // Misc tests. - // TODO: Enable when IGNITE-1094 is fixed. - // suite.addTest(new TestSuite(QueryEntityValidationSelfTest.class)); - suite.addTest(new TestSuite(DuplicateKeyValueClassesSelfTest.class)); - suite.addTest(new TestSuite(GridCacheLazyQueryPartitionsReleaseTest.class)); - - // Dynamic index create/drop tests. - suite.addTest(new TestSuite(SchemaExchangeSelfTest.class)); - - suite.addTest(new TestSuite(DynamicIndexServerCoordinatorBasicSelfTest.class)); - suite.addTest(new TestSuite(DynamicIndexServerBasicSelfTest.class)); - suite.addTest(new TestSuite(DynamicIndexServerNodeFilterCoordinatorBasicSelfTest.class)); - suite.addTest(new TestSuite(DynamicIndexServerNodeFIlterBasicSelfTest.class)); - suite.addTest(new TestSuite(DynamicIndexClientBasicSelfTest.class)); - - // H2 tests. - - // TODO: IGNITE-4994: Restore mock. - // suite.addTest(new TestSuite(GridH2TableSelfTest.class)); - - suite.addTest(new TestSuite(GridH2IndexingInMemSelfTest.class)); - suite.addTest(new TestSuite(GridH2IndexingOffheapSelfTest.class)); - - // Parsing - suite.addTestSuite(GridQueryParsingTest.class); - suite.addTestSuite(IgniteCacheSqlQueryErrorSelfTest.class); - - // Config. - suite.addTestSuite(IgniteCacheDuplicateEntityConfigurationSelfTest.class); - suite.addTestSuite(IncorrectQueryEntityTest.class); - suite.addTestSuite(IgniteDynamicSqlRestoreTest.class); - - // Queries tests. - suite.addTestSuite(LazyQuerySelfTest.class); - suite.addTestSuite(IgniteSqlSplitterSelfTest.class); - suite.addTestSuite(SqlPushDownFunctionTest.class); - suite.addTestSuite(IgniteSqlSegmentedIndexSelfTest.class); - suite.addTestSuite(IgniteCachelessQueriesSelfTest.class); - suite.addTestSuite(IgniteSqlSegmentedIndexMultiNodeSelfTest.class); - suite.addTestSuite(IgniteSqlSchemaIndexingTest.class); - suite.addTestSuite(GridCacheQueryIndexDisabledSelfTest.class); - suite.addTestSuite(IgniteCacheQueryLoadSelfTest.class); - suite.addTestSuite(IgniteCacheLocalQuerySelfTest.class); - suite.addTestSuite(IgniteCacheLocalAtomicQuerySelfTest.class); - suite.addTestSuite(IgniteCacheReplicatedQuerySelfTest.class); - suite.addTestSuite(IgniteCacheReplicatedQueryP2PDisabledSelfTest.class); - suite.addTestSuite(IgniteCacheReplicatedQueryEvtsDisabledSelfTest.class); - suite.addTestSuite(IgniteCachePartitionedQuerySelfTest.class); - suite.addTestSuite(IgniteCachePartitionedSnapshotEnabledQuerySelfTest.class); - suite.addTestSuite(IgniteCacheAtomicQuerySelfTest.class); - suite.addTestSuite(IgniteCacheAtomicNearEnabledQuerySelfTest.class); - suite.addTestSuite(IgniteCachePartitionedQueryP2PDisabledSelfTest.class); - suite.addTestSuite(IgniteCachePartitionedQueryEvtsDisabledSelfTest.class); - - //suite.addTestSuite(IgniteCacheUnionDuplicatesTest.class); - //suite.addTestSuite(IgniteCacheConfigVariationsQueryTest.class); - //suite.addTestSuite(IgniteCacheJoinPartitionedAndReplicatedCollocationTest.class); - //suite.addTestSuite(IgniteClientReconnectCacheQueriesFailoverTest.class); - //suite.addTestSuite(IgniteErrorOnRebalanceTest.class); - //suite.addTestSuite(CacheQueryBuildValueTest.class); - //suite.addTestSuite(CacheOffheapBatchIndexingMultiTypeTest.class); - //suite.addTestSuite(CacheOffheapBatchIndexingBaseTest.class); - - suite.addTestSuite(IgniteCacheQueryIndexSelfTest.class); - suite.addTestSuite(IgniteCacheCollocatedQuerySelfTest.class); - suite.addTestSuite(IgniteCacheLargeResultSelfTest.class); - suite.addTestSuite(GridCacheQueryInternalKeysSelfTest.class); - suite.addTestSuite(H2ResultSetIteratorNullifyOnEndSelfTest.class); - suite.addTestSuite(IgniteSqlBigIntegerKeyTest.class); - suite.addTestSuite(IgniteCacheOffheapEvictQueryTest.class); - suite.addTestSuite(IgniteCacheOffheapIndexScanTest.class); - - suite.addTestSuite(IgniteCacheQueryAbstractDistributedJoinSelfTest.class); - - suite.addTestSuite(GridCacheCrossCacheQuerySelfTest.class); - suite.addTestSuite(GridCacheQuerySerializationSelfTest.class); - suite.addTestSuite(IgniteBinaryObjectFieldsQuerySelfTest.class); - suite.addTestSuite(IgniteStableBaselineBinObjFieldsQuerySelfTest.class); - suite.addTestSuite(IgniteBinaryWrappedObjectFieldsQuerySelfTest.class); - suite.addTestSuite(IgniteCacheQueryH2IndexingLeakTest.class); - suite.addTestSuite(IgniteCacheQueryNoRebalanceSelfTest.class); - suite.addTestSuite(GridCacheQueryTransformerSelfTest.class); - suite.addTestSuite(CacheScanQueryFailoverTest.class); - suite.addTestSuite(IgniteCachePrimitiveFieldsQuerySelfTest.class); - - suite.addTestSuite(IgniteCacheJoinQueryWithAffinityKeyTest.class); - suite.addTestSuite(IgniteCacheJoinPartitionedAndReplicatedTest.class); - suite.addTestSuite(IgniteCrossCachesJoinsQueryTest.class); - - suite.addTestSuite(IgniteCacheMultipleIndexedTypesTest.class); - - // DML. - suite.addTestSuite(IgniteCacheMergeSqlQuerySelfTest.class); - suite.addTestSuite(IgniteCacheInsertSqlQuerySelfTest.class); - suite.addTestSuite(IgniteCacheUpdateSqlQuerySelfTest.class); - suite.addTestSuite(IgniteCacheDeleteSqlQuerySelfTest.class); - suite.addTestSuite(IgniteSqlSkipReducerOnUpdateDmlSelfTest.class); - suite.addTestSuite(IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest.class); - - suite.addTestSuite(IgniteBinaryObjectQueryArgumentsTest.class); - suite.addTestSuite(IgniteBinaryObjectLocalQueryArgumentsTest.class); - - suite.addTestSuite(IndexingSpiQuerySelfTest.class); - suite.addTestSuite(IndexingSpiQueryTxSelfTest.class); - - suite.addTestSuite(IgniteCacheMultipleIndexedTypesTest.class); - suite.addTestSuite(IgniteSqlQueryMinMaxTest.class); - - //suite.addTestSuite(GridCircularQueueTest.class); - //suite.addTestSuite(IndexingSpiQueryWithH2IndexingSelfTest.class); - - // DDL. - suite.addTestSuite(H2DynamicIndexTransactionalReplicatedSelfTest.class); - suite.addTestSuite(H2DynamicIndexTransactionalPartitionedSelfTest.class); - suite.addTestSuite(H2DynamicIndexTransactionalPartitionedNearSelfTest.class); - suite.addTestSuite(H2DynamicIndexAtomicReplicatedSelfTest.class); - suite.addTestSuite(H2DynamicIndexAtomicPartitionedSelfTest.class); - suite.addTestSuite(H2DynamicIndexAtomicPartitionedNearSelfTest.class); - suite.addTestSuite(H2DynamicTableSelfTest.class); - suite.addTestSuite(H2DynamicColumnsClientBasicSelfTest.class); - suite.addTestSuite(H2DynamicColumnsServerBasicSelfTest.class); - suite.addTestSuite(H2DynamicColumnsServerCoordinatorBasicSelfTest.class); - - // DML+DDL. - //suite.addTestSuite(H2DynamicIndexingComplexAbstractTest.class); - suite.addTestSuite(H2DynamicIndexingComplexClientAtomicPartitionedTest.class); - //suite.addTestSuite(H2DynamicIndexingComplexClientAtomicPartitionedNoBackupsTest.class); - suite.addTestSuite(H2DynamicIndexingComplexClientAtomicReplicatedTest.class); - suite.addTestSuite(H2DynamicIndexingComplexClientTransactionalPartitionedTest.class); - //suite.addTestSuite(H2DynamicIndexingComplexClientTransactionalPartitionedNoBackupsTest.class); - suite.addTestSuite(H2DynamicIndexingComplexClientTransactionalReplicatedTest.class); - suite.addTestSuite(H2DynamicIndexingComplexServerAtomicPartitionedTest.class); - //suite.addTestSuite(H2DynamicIndexingComplexServerAtomicPartitionedNoBackupsTest.class); - suite.addTestSuite(H2DynamicIndexingComplexServerAtomicReplicatedTest.class); - suite.addTestSuite(H2DynamicIndexingComplexServerTransactionalPartitionedTest.class); - //suite.addTestSuite(H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest.class); - suite.addTestSuite(H2DynamicIndexingComplexServerTransactionalReplicatedTest.class); - - suite.addTestSuite(DdlTransactionSelfTest.class); - - // Fields queries. - suite.addTestSuite(SqlFieldsQuerySelfTest.class); - suite.addTestSuite(IgniteCacheLocalFieldsQuerySelfTest.class); - suite.addTestSuite(IgniteCacheReplicatedFieldsQuerySelfTest.class); - suite.addTestSuite(IgniteCacheReplicatedFieldsQueryROSelfTest.class); - suite.addTestSuite(IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest.class); - suite.addTestSuite(IgniteCacheReplicatedFieldsQueryJoinNoPrimaryPartitionsSelfTest.class); - suite.addTestSuite(IgniteCachePartitionedFieldsQuerySelfTest.class); - suite.addTestSuite(IgniteCacheAtomicFieldsQuerySelfTest.class); - suite.addTestSuite(IgniteCacheAtomicNearEnabledFieldsQuerySelfTest.class); - suite.addTestSuite(IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest.class); - suite.addTestSuite(IgniteCacheFieldsQueryNoDataSelfTest.class); - suite.addTestSuite(GridCacheQueryIndexingDisabledSelfTest.class); - suite.addTestSuite(GridOrderedMessageCancelSelfTest.class); - suite.addTestSuite(CacheQueryEvictDataLostTest.class); - - // Full text queries. - suite.addTestSuite(GridCacheFullTextQuerySelfTest.class); - suite.addTestSuite(IgniteCacheFullTextQueryNodeJoiningSelfTest.class); - - // Ignite cache and H2 comparison. - suite.addTestSuite(BaseH2CompareQueryTest.class); - suite.addTestSuite(H2CompareBigQueryTest.class); - suite.addTestSuite(H2CompareBigQueryDistributedJoinsTest.class); - - // Cache query metrics. - suite.addTestSuite(CacheLocalQueryMetricsSelfTest.class); - suite.addTestSuite(CachePartitionedQueryMetricsDistributedSelfTest.class); - suite.addTestSuite(CachePartitionedQueryMetricsLocalSelfTest.class); - suite.addTestSuite(CacheReplicatedQueryMetricsDistributedSelfTest.class); - suite.addTestSuite(CacheReplicatedQueryMetricsLocalSelfTest.class); - - // Cache query metrics. - suite.addTestSuite(CacheLocalQueryDetailMetricsSelfTest.class); - suite.addTestSuite(CachePartitionedQueryDetailMetricsDistributedSelfTest.class); - suite.addTestSuite(CachePartitionedQueryDetailMetricsLocalSelfTest.class); - suite.addTestSuite(CacheReplicatedQueryDetailMetricsDistributedSelfTest.class); - suite.addTestSuite(CacheReplicatedQueryDetailMetricsLocalSelfTest.class); - - // Unmarshalling query test. - suite.addTestSuite(IgniteCacheP2pUnmarshallingQueryErrorTest.class); - suite.addTestSuite(IgniteCacheNoClassQuerySelfTest.class); - - // Cancellation. - suite.addTestSuite(IgniteCacheDistributedQueryCancelSelfTest.class); - suite.addTestSuite(IgniteCacheLocalQueryCancelOrTimeoutSelfTest.class); - - // Distributed joins. - suite.addTestSuite(H2CompareBigQueryDistributedJoinsTest.class); - suite.addTestSuite(IgniteCacheDistributedJoinCollocatedAndNotTest.class); - suite.addTestSuite(IgniteCacheDistributedJoinCustomAffinityMapper.class); - suite.addTestSuite(IgniteCacheDistributedJoinNoIndexTest.class); - suite.addTestSuite(IgniteCacheDistributedJoinPartitionedAndReplicatedTest.class); - suite.addTestSuite(IgniteCacheDistributedJoinQueryConditionsTest.class); - suite.addTestSuite(IgniteCacheDistributedJoinTest.class); - suite.addTestSuite(IgniteSqlDistributedJoinSelfTest.class); - suite.addTestSuite(IgniteSqlQueryParallelismTest.class); - - // Other. - suite.addTestSuite(CacheIteratorScanQueryTest.class); - suite.addTestSuite(CacheQueryNewClientSelfTest.class); - suite.addTestSuite(CacheOffheapBatchIndexingSingleTypeTest.class); - suite.addTestSuite(CacheSqlQueryValueCopySelfTest.class); - suite.addTestSuite(IgniteCacheQueryCacheDestroySelfTest.class); - suite.addTestSuite(IgniteQueryDedicatedPoolTest.class); - suite.addTestSuite(IgniteSqlEntryCacheModeAgnosticTest.class); - suite.addTestSuite(QueryEntityCaseMismatchTest.class); - suite.addTestSuite(IgniteCacheDistributedPartitionQuerySelfTest.class); - suite.addTestSuite(IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.class); - suite.addTestSuite(IgniteCacheDistributedPartitionQueryConfigurationSelfTest.class); - suite.addTestSuite(IgniteSqlKeyValueFieldsTest.class); - suite.addTestSuite(IgniteSqlRoutingTest.class); - suite.addTestSuite(IgniteSqlNotNullConstraintTest.class); - suite.addTestSuite(LongIndexNameTest.class); - suite.addTestSuite(GridCacheQuerySqlFieldInlineSizeSelfTest.class); - suite.addTestSuite(IgniteSqlParameterizedQueryTest.class); - suite.addTestSuite(H2ConnectionLeaksSelfTest.class); - suite.addTestSuite(IgniteCheckClusterStateBeforeExecuteQueryTest.class); - suite.addTestSuite(OptimizedMarshallerIndexNameTest.class); - suite.addTestSuite(SqlSystemViewsSelfTest.class); - - suite.addTestSuite(GridIndexRebuildSelfTest.class); - - suite.addTestSuite(SqlTransactionCommandsWithMvccDisabledSelfTest.class); - - suite.addTestSuite(IgniteSqlDefaultValueTest.class); - suite.addTestSuite(IgniteDecimalSelfTest.class); - suite.addTestSuite(IgniteSQLColumnConstraintsTest.class); - - suite.addTestSuite(IgniteCachePartitionedAtomicColumnConstraintsTest.class); - suite.addTestSuite(IgniteCachePartitionedTransactionalColumnConstraintsTest.class); - suite.addTestSuite(IgniteCacheReplicatedAtomicColumnConstraintsTest.class); - suite.addTestSuite(IgniteCacheReplicatedTransactionalColumnConstraintsTest.class); - - // H2 Rows on-heap cache - suite.addTestSuite(H2RowCacheSelfTest.class); - suite.addTestSuite(H2RowCachePageEvictionTest.class); - - // User operation SQL - suite.addTestSuite(SqlParserUserSelfTest.class); - suite.addTestSuite(SqlUserCommandSelfTest.class); - suite.addTestSuite(EncryptedSqlTableTest.class); - - suite.addTestSuite(ThreadLocalObjectPoolSelfTest.class); - suite.addTestSuite(H2StatementCacheSelfTest.class); - suite.addTestSuite(PreparedStatementExSelfTest.class); - - // Partition loss. - suite.addTestSuite(IndexingCachePartitionLossPolicySelfTest.class); - - // GROUP_CONCAT - suite.addTestSuite(IgniteSqlGroupConcatCollocatedTest.class); - suite.addTestSuite(IgniteSqlGroupConcatNotCollocatedTest.class); - - return suite; - } -} diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java deleted file mode 100644 index 4b91b4307869e..0000000000000 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite2.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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. - */ - -package org.apache.ignite.testsuites; - -import junit.framework.TestSuite; -import org.apache.ignite.internal.processors.cache.CacheScanPartitionQueryFallbackSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheCrossCacheJoinRandomTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheObjectKeyIndexingSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCachePartitionedQueryMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheQueryEvictsMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.QueryJoinWithDifferentNodeFiltersTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheClientQueryReplicatedNodeRestartSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeFailTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartDistributedJoinSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest2; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartTxSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.IgniteSqlQueryWithBaselineTest; -import org.apache.ignite.internal.processors.cache.index.DynamicColumnsConcurrentAtomicPartitionedSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicColumnsConcurrentAtomicReplicatedSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicColumnsConcurrentTransactionalPartitionedSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicColumnsConcurrentTransactionalReplicatedSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicIndexPartitionedAtomicConcurrentSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicIndexPartitionedTransactionalConcurrentSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicIndexReplicatedAtomicConcurrentSelfTest; -import org.apache.ignite.internal.processors.cache.index.DynamicIndexReplicatedTransactionalConcurrentSelfTest; -import org.apache.ignite.internal.processors.cache.query.ScanQueryOffheapExpiryPolicySelfTest; -import org.apache.ignite.internal.processors.database.baseline.IgniteChangingBaselineCacheQueryNodeRestartSelfTest; -import org.apache.ignite.internal.processors.database.baseline.IgniteStableBaselineCacheQueryNodeRestartsSelfTest; -import org.apache.ignite.internal.processors.query.IgniteCacheGroupsCompareQueryTest; -import org.apache.ignite.internal.processors.query.IgniteCacheGroupsSqlDistributedJoinSelfTest; -import org.apache.ignite.internal.processors.query.IgniteCacheGroupsSqlSegmentedIndexMultiNodeSelfTest; -import org.apache.ignite.internal.processors.query.IgniteCacheGroupsSqlSegmentedIndexSelfTest; -import org.apache.ignite.internal.processors.query.h2.twostep.CacheQueryMemoryLeakTest; -import org.apache.ignite.internal.processors.query.h2.twostep.DisappearedCacheCauseRetryMessageSelfTest; -import org.apache.ignite.internal.processors.query.h2.twostep.DisappearedCacheWasNotFoundMessageSelfTest; -import org.apache.ignite.internal.processors.query.h2.twostep.NonCollocatedRetryMessageSelfTest; -import org.apache.ignite.internal.processors.query.h2.twostep.RetryCauseMessageSelfTest; -import org.apache.ignite.internal.processors.query.h2.twostep.TableViewSubquerySelfTest; -import org.apache.ignite.testframework.IgniteTestSuite; - -/** - * Test suite for cache queries. - */ -public class IgniteCacheQuerySelfTestSuite2 extends TestSuite { - /** - * @return Test suite. - * @throws Exception If failed. - */ - public static TestSuite suite() throws Exception { - TestSuite suite = new IgniteTestSuite("Ignite Cache Queries Test Suite 2"); - - // Dynamic index create/drop tests. - suite.addTestSuite(DynamicIndexPartitionedAtomicConcurrentSelfTest.class); - suite.addTestSuite(DynamicIndexPartitionedTransactionalConcurrentSelfTest.class); - suite.addTestSuite(DynamicIndexReplicatedAtomicConcurrentSelfTest.class); - suite.addTestSuite(DynamicIndexReplicatedTransactionalConcurrentSelfTest.class); - - suite.addTestSuite(DynamicColumnsConcurrentAtomicPartitionedSelfTest.class); - suite.addTestSuite(DynamicColumnsConcurrentTransactionalPartitionedSelfTest.class); - suite.addTestSuite(DynamicColumnsConcurrentAtomicReplicatedSelfTest.class); - suite.addTestSuite(DynamicColumnsConcurrentTransactionalReplicatedSelfTest.class); - - // Distributed joins. - suite.addTestSuite(IgniteCacheQueryNodeRestartDistributedJoinSelfTest.class); - suite.addTestSuite(IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.class); - - // Other tests. - suite.addTestSuite(IgniteCacheQueryMultiThreadedSelfTest.class); - - suite.addTestSuite(IgniteCacheQueryEvictsMultiThreadedSelfTest.class); - - suite.addTestSuite(ScanQueryOffheapExpiryPolicySelfTest.class); - - suite.addTestSuite(IgniteCacheCrossCacheJoinRandomTest.class); - suite.addTestSuite(IgniteCacheClientQueryReplicatedNodeRestartSelfTest.class); - suite.addTestSuite(IgniteCacheQueryNodeFailTest.class); - suite.addTestSuite(IgniteCacheQueryNodeRestartSelfTest.class); - suite.addTestSuite(IgniteSqlQueryWithBaselineTest.class); - suite.addTestSuite(IgniteChangingBaselineCacheQueryNodeRestartSelfTest.class); - suite.addTestSuite(IgniteStableBaselineCacheQueryNodeRestartsSelfTest.class); - suite.addTestSuite(IgniteCacheQueryNodeRestartSelfTest2.class); - suite.addTestSuite(IgniteCacheQueryNodeRestartTxSelfTest.class); - suite.addTestSuite(IgniteCacheSqlQueryMultiThreadedSelfTest.class); - suite.addTestSuite(IgniteCachePartitionedQueryMultiThreadedSelfTest.class); - suite.addTestSuite(CacheScanPartitionQueryFallbackSelfTest.class); - suite.addTestSuite(IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.class); - suite.addTestSuite(IgniteCacheObjectKeyIndexingSelfTest.class); - - suite.addTestSuite(IgniteCacheGroupsCompareQueryTest.class); - suite.addTestSuite(IgniteCacheGroupsSqlSegmentedIndexSelfTest.class); - suite.addTestSuite(IgniteCacheGroupsSqlSegmentedIndexMultiNodeSelfTest.class); - suite.addTestSuite(IgniteCacheGroupsSqlDistributedJoinSelfTest.class); - - suite.addTestSuite(QueryJoinWithDifferentNodeFiltersTest.class); - - suite.addTestSuite(CacheQueryMemoryLeakTest.class); - - suite.addTestSuite(NonCollocatedRetryMessageSelfTest.class); - suite.addTestSuite(RetryCauseMessageSelfTest.class); - suite.addTestSuite(DisappearedCacheCauseRetryMessageSelfTest.class); - suite.addTestSuite(DisappearedCacheWasNotFoundMessageSelfTest.class); - - suite.addTestSuite(TableViewSubquerySelfTest.class); - - return suite; - } -} diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java index dbcea2b1ce586..b23e8529931e3 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java @@ -17,15 +17,24 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; -import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousBatchAckTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousBatchForceServerModeAckTest; -import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryAsyncFilterListenerTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryConcurrentPartitionUpdateTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterPartitionedAtomicTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterPartitionedTxTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterReplicatedAtomicTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterReplicatedTxTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryEventBufferTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterPartitionedAtomicTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterPartitionedTxTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterReplicatedAtomicTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterReplicatedTxTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryExecuteInPrimaryTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryAsyncFilterRandomOperationTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicNearEnabledSelfSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryFilterRandomOperationTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicNearEnabledSelfSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryLostPartitionTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOperationFromCallbackTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOperationP2PTest; @@ -38,117 +47,80 @@ import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerPartitionedSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerRandomOperationsTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerReplicatedSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationNearEnabledTest; -import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationStoreEnabledTest; -import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationTest; import org.apache.ignite.internal.processors.cache.query.continuous.ClientReconnectContinuousQueryTest; -import org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryMarshallerTest; -import org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryPeerClassLoadingTest; -import org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryRemoteFilterMissingInClassPathSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryReassignmentTest; import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicNearEnabledSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicP2PDisabledSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryConcurrentTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryMultiNodesFilteringTest; import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryNodesFilteringTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionAtomicOneNodeTest; import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionTxOneNodeTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedOnlySelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedP2PDisabledSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicOneNodeTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedP2PDisabledSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedTxOneNodeTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryTxSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryBackupQueueTest; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientReconnectTest; -import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTxReconnectTest; -import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryImmutableEntryTest; import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryNoUnsubscribeTest; +import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryReconnectTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; +import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryReconnectTest; /** * Test suite for cache queries. */ -public class IgniteCacheQuerySelfTestSuite3 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheQuerySelfTestSuite3 { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { - TestSuite suite = new TestSuite("Ignite Cache Queries Test Suite 3"); + public static TestSuite suite() { + TestSuite suite = new TestSuite("Ignite Cache Continuous Queries Test Suite"); - // Continuous queries. - suite.addTestSuite(GridCacheContinuousQueryLocalSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryLocalAtomicSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryReplicatedSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryReplicatedAtomicSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryReplicatedP2PDisabledSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryPartitionedSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryPartitionedOnlySelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryPartitionedP2PDisabledSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryTxSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryAtomicSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class); + // Continuous queries 1. + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryNodesFilteringTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryPartitionTxOneNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryExecuteInPrimaryTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerClientSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientReconnectContinuousQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryNoUnsubscribeTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryClientTxReconnectTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryClientReconnectTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryAtomicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryPartitionTxOneNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryClientReconnectTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryClientTxReconnectTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFactoryAsyncFilterRandomOperationTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousBatchForceServerModeAckTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryExecuteInPrimaryTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryNodesFilteringTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryNoUnsubscribeTest.class)); + suite.addTest(new JUnit4TestAdapter(ClientReconnectContinuousQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(ContinuousQueryReassignmentTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryConcurrentPartitionUpdateTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFactoryAsyncFilterRandomOperationTest.class)); - suite.addTestSuite(GridCacheContinuousQueryReplicatedTxOneNodeTest.class); - suite.addTestSuite(GridCacheContinuousQueryReplicatedAtomicOneNodeTest.class); - suite.addTestSuite(GridCacheContinuousQueryPartitionTxOneNodeTest.class); - suite.addTestSuite(GridCacheContinuousQueryPartitionAtomicOneNodeTest.class); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryCounterPartitionedAtomicTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryCounterPartitionedTxTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryCounterReplicatedAtomicTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryCounterReplicatedTxTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFailoverAtomicNearEnabledSelfSelfTest.class)); - suite.addTestSuite(IgniteCacheContinuousQueryClientTest.class); - suite.addTestSuite(IgniteCacheContinuousQueryClientReconnectTest.class); - suite.addTestSuite(IgniteCacheContinuousQueryClientTxReconnectTest.class); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerLocalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerClientSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerRandomOperationsTest.class)); - suite.addTestSuite(CacheContinuousQueryRandomOperationsTest.class); - suite.addTestSuite(CacheContinuousQueryRandomOperationsTwoNodesTest.class); - suite.addTestSuite(GridCacheContinuousQueryConcurrentTest.class); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryCounterPartitionedAtomicTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryCounterPartitionedTxTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryCounterReplicatedAtomicTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryCounterReplicatedTxTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFailoverAtomicNearEnabledSelfSelfTest.class)); - suite.addTestSuite(CacheContinuousQueryAsyncFilterListenerTest.class); - suite.addTestSuite(CacheContinuousQueryFactoryFilterRandomOperationTest.class); - suite.addTestSuite(CacheContinuousQueryFactoryAsyncFilterRandomOperationTest.class); - suite.addTestSuite(CacheContinuousQueryOrderingEventTest.class); - suite.addTestSuite(CacheContinuousQueryOperationFromCallbackTest.class); - suite.addTestSuite(CacheContinuousQueryOperationP2PTest.class); - suite.addTestSuite(CacheContinuousBatchAckTest.class); - suite.addTestSuite(CacheContinuousBatchForceServerModeAckTest.class); - suite.addTestSuite(CacheContinuousQueryExecuteInPrimaryTest.class); - suite.addTestSuite(CacheContinuousQueryLostPartitionTest.class); - suite.addTestSuite(ContinuousQueryRemoteFilterMissingInClassPathSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryNodesFilteringTest.class); - suite.addTestSuite(GridCacheContinuousQueryMultiNodesFilteringTest.class); - suite.addTestSuite(IgniteCacheContinuousQueryImmutableEntryTest.class); - suite.addTestSuite(CacheKeepBinaryIterationTest.class); - suite.addTestSuite(CacheKeepBinaryIterationStoreEnabledTest.class); - suite.addTestSuite(CacheKeepBinaryIterationNearEnabledTest.class); - suite.addTestSuite(IgniteCacheContinuousQueryBackupQueueTest.class); - suite.addTestSuite(IgniteCacheContinuousQueryNoUnsubscribeTest.class); - suite.addTestSuite(ClientReconnectContinuousQueryTest.class); - suite.addTestSuite(ContinuousQueryPeerClassLoadingTest.class); - suite.addTestSuite(ContinuousQueryMarshallerTest.class); - - suite.addTestSuite(CacheContinuousQueryConcurrentPartitionUpdateTest.class); - suite.addTestSuite(CacheContinuousQueryEventBufferTest.class); - - suite.addTestSuite(CacheContinuousWithTransformerReplicatedSelfTest.class); - suite.addTestSuite(CacheContinuousWithTransformerLocalSelfTest.class); - suite.addTestSuite(CacheContinuousWithTransformerPartitionedSelfTest.class); - suite.addTestSuite(CacheContinuousWithTransformerClientSelfTest.class); - suite.addTestSuite(CacheContinuousWithTransformerFailoverTest.class); - suite.addTestSuite(CacheContinuousWithTransformerRandomOperationsTest.class); - - //suite.addTestSuite(CacheContinuousQueryCounterPartitionedAtomicTest.class); - //suite.addTestSuite(CacheContinuousQueryCounterPartitionedTxTest.class); - //suite.addTestSuite(CacheContinuousQueryCounterReplicatedAtomicTest.class); - //suite.addTestSuite(CacheContinuousQueryCounterReplicatedTxTest.class); - //suite.addTestSuite(CacheContinuousQueryFailoverAtomicNearEnabledSelfSelfTest.class); - - //suite.addTestSuite(IgniteCacheContinuousQueryReconnectTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryReconnectTest.class)); return suite; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite4.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite4.java index 2aa3419764427..b07d16872617c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite4.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite4.java @@ -17,35 +17,44 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryAsyncFailoverAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryAsyncFailoverMvccTxSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryAsyncFailoverTxReplicatedSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryAsyncFailoverTxSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicReplicatedSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverMvccTxReplicatedSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverMvccTxSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxReplicatedSelfTest; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for cache queries. */ -public class IgniteCacheQuerySelfTestSuite4 extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheQuerySelfTestSuite4 { /** * @return Test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Cache Queries Test Suite 4"); // Continuous queries failover tests. - suite.addTestSuite(CacheContinuousQueryFailoverAtomicSelfTest.class); - suite.addTestSuite(CacheContinuousQueryFailoverAtomicReplicatedSelfTest.class); - suite.addTestSuite(CacheContinuousQueryFailoverTxSelfTest.class); - suite.addTestSuite(CacheContinuousQueryFailoverTxReplicatedSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFailoverAtomicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFailoverAtomicReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFailoverTxSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFailoverTxReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFailoverMvccTxSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFailoverMvccTxReplicatedSelfTest.class)); - suite.addTestSuite(CacheContinuousQueryAsyncFailoverAtomicSelfTest.class); - suite.addTestSuite(CacheContinuousQueryAsyncFailoverTxReplicatedSelfTest.class); - suite.addTestSuite(CacheContinuousQueryAsyncFailoverTxSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryAsyncFailoverAtomicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryAsyncFailoverTxReplicatedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryAsyncFailoverTxSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryAsyncFailoverMvccTxSelfTest.class)); return suite; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite5.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite5.java new file mode 100644 index 0000000000000..c6e1550fbef10 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite5.java @@ -0,0 +1,76 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryEventBufferTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryFilterRandomOperationTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryLostPartitionTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOperationFromCallbackTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTwoNodesTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerFailoverTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerLocalSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryPeerClassLoadingTest; +import org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryRemoteFilterMissingInClassPathSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicP2PDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryConcurrentTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedP2PDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedP2PDisabledSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedTxOneNodeTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryTxSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryBackupQueueTest; +import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryImmutableEntryTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * Test suite for cache queries. + */ +@RunWith(AllTests.class) +public class IgniteCacheQuerySelfTestSuite5 { + /** + * @return Test suite. + */ + public static TestSuite suite() { + TestSuite suite = new TestSuite("Ignite Cache Continuous Queries Test Suite 2"); + + // Continuous queries 2. + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryImmutableEntryTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerLocalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryEventBufferTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryReplicatedTxOneNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryLocalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerFailoverTest.class)); + suite.addTest(new JUnit4TestAdapter(ContinuousQueryRemoteFilterMissingInClassPathSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ContinuousQueryPeerClassLoadingTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryTxSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryReplicatedP2PDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryPartitionedP2PDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryLostPartitionTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryConcurrentTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryRandomOperationsTwoNodesTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryBackupQueueTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryOperationFromCallbackTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryFactoryFilterRandomOperationTest.class)); + + return suite; + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite6.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite6.java new file mode 100644 index 0000000000000..6c8ad7e07bdd0 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite6.java @@ -0,0 +1,76 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousBatchAckTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryAsyncFilterListenerTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOperationP2PTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOrderingEventTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerPartitionedSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousWithTransformerRandomOperationsTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationNearEnabledTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationStoreEnabledTest; +import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationTest; +import org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryMarshallerTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryMultiNodesFilteringTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionAtomicOneNodeTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedOnlySelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicOneNodeTest; +import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; + +/** + * Test suite for cache queries. + */ +@RunWith(AllTests.class) +public class IgniteCacheQuerySelfTestSuite6 { + /** + * @return Test suite. + */ + public static TestSuite suite() { + TestSuite suite = new TestSuite("Ignite Cache Continuous Queries Test Suite 3"); + + // Continuous queries 3. + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryPartitionAtomicOneNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryLocalAtomicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryReplicatedAtomicOneNodeTest.class)); + suite.addTest(new JUnit4TestAdapter(ContinuousQueryMarshallerTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryReplicatedAtomicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheKeepBinaryIterationTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryMultiNodesFilteringTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheKeepBinaryIterationStoreEnabledTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheKeepBinaryIterationNearEnabledTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheContinuousQueryPartitionedOnlySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryOperationP2PTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousBatchAckTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryOrderingEventTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheContinuousQueryClientTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryAsyncFilterListenerTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousWithTransformerRandomOperationsTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheContinuousQueryRandomOperationsTest.class)); + + return suite; + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingAndPersistenceTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingAndPersistenceTestSuite.java index 1bc60f65658c8..540d100184e0c 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingAndPersistenceTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingAndPersistenceTestSuite.java @@ -17,21 +17,26 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.apache.ignite.internal.processors.cache.StartCachesInParallelTest; import org.apache.ignite.util.GridCommandHandlerIndexingTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Cache tests using indexing. */ -public class IgniteCacheWithIndexingAndPersistenceTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheWithIndexingAndPersistenceTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Cache With Indexing And Persistence Test Suite"); - suite.addTestSuite(GridCommandHandlerIndexingTest.class); + suite.addTest(new JUnit4TestAdapter(GridCommandHandlerIndexingTest.class)); + suite.addTest(new JUnit4TestAdapter(StartCachesInParallelTest.class)); return suite; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java index e351cb6f4a106..55d129bddd224 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.BinaryTypeMismatchLoggingTest; import org.apache.ignite.internal.processors.cache.CacheBinaryKeyConcurrentQueryTest; @@ -27,6 +28,7 @@ import org.apache.ignite.internal.processors.cache.CacheQueryFilterExpiredTest; import org.apache.ignite.internal.processors.cache.CacheRandomOperationsMultithreadedTest; import org.apache.ignite.internal.processors.cache.ClientReconnectAfterClusterRestartTest; +import org.apache.ignite.internal.processors.cache.ClusterReadOnlyModeSqlTest; import org.apache.ignite.internal.processors.cache.GridCacheOffHeapSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheOffheapIndexEntryEvictTest; import org.apache.ignite.internal.processors.cache.GridCacheOffheapIndexGetSelfTest; @@ -41,54 +43,55 @@ import org.apache.ignite.internal.processors.cache.ttl.CacheTtlTransactionalPartitionedSelfTest; import org.apache.ignite.internal.processors.client.IgniteDataStreamerTest; import org.apache.ignite.internal.processors.query.h2.database.InlineIndexHelperTest; -import org.apache.ignite.testframework.junits.GridAbstractTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Cache tests using indexing. */ -public class IgniteCacheWithIndexingTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteCacheWithIndexingTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { - System.setProperty(GridAbstractTest.PERSISTENCE_IN_TESTS_IS_ALLOWED_PROPERTY, "false"); - + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Cache With Indexing Test Suite"); - suite.addTestSuite(InlineIndexHelperTest.class); + suite.addTest(new JUnit4TestAdapter(InlineIndexHelperTest.class)); - suite.addTestSuite(GridIndexingWithNoopSwapSelfTest.class); - suite.addTestSuite(GridCacheOffHeapSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridIndexingWithNoopSwapSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheOffHeapSelfTest.class)); - suite.addTestSuite(CacheTtlTransactionalLocalSelfTest.class); - suite.addTestSuite(CacheTtlTransactionalPartitionedSelfTest.class); - suite.addTestSuite(CacheTtlAtomicLocalSelfTest.class); - suite.addTestSuite(CacheTtlAtomicPartitionedSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheTtlTransactionalLocalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheTtlTransactionalPartitionedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheTtlAtomicLocalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheTtlAtomicPartitionedSelfTest.class)); - suite.addTestSuite(GridCacheOffheapIndexGetSelfTest.class); - suite.addTestSuite(GridCacheOffheapIndexEntryEvictTest.class); - suite.addTestSuite(CacheIndexStreamerTest.class); + suite.addTest(new JUnit4TestAdapter(GridCacheOffheapIndexGetSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheOffheapIndexEntryEvictTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheIndexStreamerTest.class)); - suite.addTestSuite(CacheConfigurationP2PTest.class); + suite.addTest(new JUnit4TestAdapter(CacheConfigurationP2PTest.class)); - suite.addTestSuite(IgniteCacheConfigurationPrimitiveTypesSelfTest.class); - suite.addTestSuite(IgniteClientReconnectQueriesTest.class); - suite.addTestSuite(CacheRandomOperationsMultithreadedTest.class); - suite.addTestSuite(IgniteCacheStarvationOnRebalanceTest.class); - suite.addTestSuite(CacheOperationsWithExpirationTest.class); - suite.addTestSuite(CacheBinaryKeyConcurrentQueryTest.class); - suite.addTestSuite(CacheQueryFilterExpiredTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheConfigurationPrimitiveTypesSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectQueriesTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheRandomOperationsMultithreadedTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheStarvationOnRebalanceTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheOperationsWithExpirationTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheBinaryKeyConcurrentQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheQueryFilterExpiredTest.class)); - suite.addTestSuite(ClientReconnectAfterClusterRestartTest.class); + suite.addTest(new JUnit4TestAdapter(ClientReconnectAfterClusterRestartTest.class)); - suite.addTestSuite(CacheQueryAfterDynamicCacheStartFailureTest.class); + suite.addTest(new JUnit4TestAdapter(CacheQueryAfterDynamicCacheStartFailureTest.class)); - suite.addTestSuite(IgniteCacheGroupsSqlTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteCacheGroupsSqlTest.class)); - suite.addTestSuite(IgniteDataStreamerTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteDataStreamerTest.class)); - suite.addTestSuite(BinaryTypeMismatchLoggingTest.class); + suite.addTest(new JUnit4TestAdapter(BinaryTypeMismatchLoggingTest.class)); + + suite.addTest(new JUnit4TestAdapter(ClusterReadOnlyModeSqlTest.class)); return suite; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakWithIndexingTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakWithIndexingTestSuite.java index 36cd10130da1d..9946f94db32e4 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakWithIndexingTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteDbMemoryLeakWithIndexingTestSuite.java @@ -17,23 +17,26 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakIndexedTest; import org.apache.ignite.internal.processors.database.IgniteDbMemoryLeakSqlQueryTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Page memory leaks tests using indexing. */ -public class IgniteDbMemoryLeakWithIndexingTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteDbMemoryLeakWithIndexingTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Db Memory Leaks With Indexing Test Suite"); - suite.addTestSuite(IgniteDbMemoryLeakSqlQueryTest.class); - suite.addTestSuite(IgniteDbMemoryLeakIndexedTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteDbMemoryLeakSqlQueryTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDbMemoryLeakIndexedTest.class)); return suite; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingCoreTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingCoreTestSuite.java index e9159bf7cd553..fdd3a47fb6a31 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingCoreTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingCoreTestSuite.java @@ -16,6 +16,7 @@ */ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsAtomicCacheHistoricalRebalancingTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsAtomicCacheRebalancingTest; @@ -27,8 +28,10 @@ import org.apache.ignite.internal.processors.cache.persistence.IgnitePdsTxHistoricalRebalancingTest; import org.apache.ignite.internal.processors.cache.persistence.IgnitePersistentStoreCacheGroupsTest; import org.apache.ignite.internal.processors.cache.persistence.PersistenceDirectoryWarningLoggingTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgniteLogicalRecoveryTest; import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsMultiNodePutGetRestartTest; import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsPageEvictionTest; +import org.apache.ignite.internal.processors.cache.persistence.db.IgniteSequentialNodeCrashRecoveryTest; import org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsCacheDestroyDuringCheckpointTest; import org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsCacheIntegrationTest; import org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsDiskErrorsRecoveringTest; @@ -42,51 +45,57 @@ import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalRecoveryTxLogicalRecordsTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalRolloverRecordLoggingFsyncTest; import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalRolloverRecordLoggingLogOnlyTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for tests that cover core PDS features and depend on indexing module. */ -public class IgnitePdsWithIndexingCoreTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgnitePdsWithIndexingCoreTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Persistent Store With Indexing Test Suite"); - suite.addTestSuite(IgnitePdsCacheIntegrationTest.class); - suite.addTestSuite(IgnitePdsPageEvictionTest.class); - suite.addTestSuite(IgnitePdsMultiNodePutGetRestartTest.class); - suite.addTestSuite(IgnitePersistentStoreCacheGroupsTest.class); - suite.addTestSuite(PersistenceDirectoryWarningLoggingTest.class); - suite.addTestSuite(WalPathsTest.class); - suite.addTestSuite(WalRecoveryTxLogicalRecordsTest.class); - suite.addTestSuite(WalRolloverRecordLoggingFsyncTest.class); - suite.addTestSuite(WalRolloverRecordLoggingLogOnlyTest.class); + suite.addTest(new JUnit4TestAdapter(IgnitePdsCacheIntegrationTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsPageEvictionTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsMultiNodePutGetRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePersistentStoreCacheGroupsTest.class)); + suite.addTest(new JUnit4TestAdapter(PersistenceDirectoryWarningLoggingTest.class)); + suite.addTest(new JUnit4TestAdapter(WalPathsTest.class)); + suite.addTest(new JUnit4TestAdapter(WalRecoveryTxLogicalRecordsTest.class)); + suite.addTest(new JUnit4TestAdapter(WalRolloverRecordLoggingFsyncTest.class)); + suite.addTest(new JUnit4TestAdapter(WalRolloverRecordLoggingLogOnlyTest.class)); - suite.addTestSuite(IgniteWalRecoveryTest.class); - suite.addTestSuite(IgniteWalRecoveryWithCompactionTest.class); - suite.addTestSuite(IgnitePdsNoActualWalHistoryTest.class); - suite.addTestSuite(IgniteWalRebalanceTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteWalRecoveryTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteWalRecoveryWithCompactionTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsNoActualWalHistoryTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteWalRebalanceTest.class)); - suite.addTestSuite(IgnitePdsAtomicCacheRebalancingTest.class); - suite.addTestSuite(IgnitePdsAtomicCacheHistoricalRebalancingTest.class); + suite.addTest(new JUnit4TestAdapter(IgnitePdsAtomicCacheRebalancingTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsAtomicCacheHistoricalRebalancingTest.class)); - suite.addTestSuite(IgnitePdsTxCacheRebalancingTest.class); - suite.addTestSuite(IgnitePdsTxHistoricalRebalancingTest.class); + suite.addTest(new JUnit4TestAdapter(IgnitePdsTxCacheRebalancingTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsTxHistoricalRebalancingTest.class)); - suite.addTestSuite(IgniteWalRecoveryPPCTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteWalRecoveryPPCTest.class)); - suite.addTestSuite(IgnitePdsDiskErrorsRecoveringTest.class); + suite.addTest(new JUnit4TestAdapter(IgnitePdsDiskErrorsRecoveringTest.class)); - suite.addTestSuite(IgnitePdsCacheDestroyDuringCheckpointTest.class); + suite.addTest(new JUnit4TestAdapter(IgnitePdsCacheDestroyDuringCheckpointTest.class)); - suite.addTestSuite(IgnitePdsBinaryMetadataOnClusterRestartTest.class); - suite.addTestSuite(IgnitePdsMarshallerMappingRestoreOnNodeStartTest.class); - suite.addTestSuite(IgnitePdsThreadInterruptionTest.class); - suite.addTestSuite(IgnitePdsBinarySortObjectFieldsTest.class); + suite.addTest(new JUnit4TestAdapter(IgnitePdsBinaryMetadataOnClusterRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsMarshallerMappingRestoreOnNodeStartTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsThreadInterruptionTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsBinarySortObjectFieldsTest.class)); - suite.addTestSuite(IgnitePdsCorruptedIndexTest.class); + suite.addTest(new JUnit4TestAdapter(IgnitePdsCorruptedIndexTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteLogicalRecoveryTest.class)); + + suite.addTest(new JUnit4TestAdapter(IgniteSequentialNodeCrashRecoveryTest.class)); return suite; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java index 67b9fad63cde2..1db34b009d549 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePdsWithIndexingTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest; import org.apache.ignite.internal.processors.cache.IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest; @@ -26,26 +27,28 @@ import org.apache.ignite.internal.processors.database.IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest; import org.apache.ignite.internal.processors.database.IgnitePersistentStoreSchemaLoadTest; import org.apache.ignite.internal.processors.database.IgniteTwoRegionsRebuildIndexTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class IgnitePdsWithIndexingTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgnitePdsWithIndexingTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Db Memory Leaks With Indexing Test Suite"); - suite.addTestSuite(IgniteDbSingleNodeWithIndexingWalRestoreTest.class); - suite.addTestSuite(IgniteDbSingleNodeWithIndexingPutGetTest.class); - suite.addTestSuite(IgniteDbMultiNodeWithIndexingPutGetTest.class); - suite.addTestSuite(IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest.class); - suite.addTestSuite(IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.class); - suite.addTestSuite(IgnitePersistentStoreSchemaLoadTest.class); - suite.addTestSuite(IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.class); - suite.addTestSuite(IgniteTwoRegionsRebuildIndexTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteDbSingleNodeWithIndexingWalRestoreTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDbSingleNodeWithIndexingPutGetTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteDbMultiNodeWithIndexingPutGetTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsSingleNodeWithIndexingPutGetPersistenceTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePersistentStoreSchemaLoadTest.class)); + suite.addTest(new JUnit4TestAdapter(IgnitePersistentStoreQueryWithMultipleClassesPerCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteTwoRegionsRebuildIndexTest.class)); return suite; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/util/GridCommandHandlerIndexingTest.java b/modules/indexing/src/test/java/org/apache/ignite/util/GridCommandHandlerIndexingTest.java index 48e94c1e62cce..1be768b4ec5fc 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/util/GridCommandHandlerIndexingTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/util/GridCommandHandlerIndexingTest.java @@ -17,6 +17,9 @@ package org.apache.ignite.util; +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; @@ -24,8 +27,8 @@ import java.util.concurrent.ThreadLocalRandom; import javax.cache.Cache; import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cache.QueryEntity; @@ -39,65 +42,50 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; +import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; import org.apache.ignite.internal.processors.cache.tree.SearchRow; import org.apache.ignite.internal.processors.query.GridQueryProcessor; import org.apache.ignite.internal.util.lang.GridIterator; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK; +import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.INDEX_FILE_NAME; /** * */ +@RunWith(JUnit4.class) public class GridCommandHandlerIndexingTest extends GridCommandHandlerTest { + /** Test cache name. */ + private static final String CACHE_NAME = "persons-cache-vi"; + /** * Tests that validation doesn't fail if nothing is broken. */ + @Test public void testValidateIndexesNoErrors() throws Exception { - Ignite ignite = startGrids(2); - - ignite.cluster().active(true); - - Ignite client = startGrid("client"); - - String cacheName = "persons-cache-vi"; - - IgniteCache personCache = createPersonCache(client, cacheName); - - ThreadLocalRandom rand = ThreadLocalRandom.current(); - - for (int i = 0; i < 10_000; i++) - personCache.put(i, new Person(rand.nextInt(), String.valueOf(rand.nextLong()))); + prepareGridForTest(); injectTestSystemOut(); - assertEquals(EXIT_CODE_OK, execute("--cache", "validate_indexes", cacheName)); + assertEquals(EXIT_CODE_OK, execute("--cache", "validate_indexes", CACHE_NAME)); - assertTrue(testOut.toString().contains("validate_indexes has finished, no issues found")); + assertTrue(testOut.toString().contains("no issues found")); } /** * Tests that missing rows in CacheDataTree are detected. */ + @Test public void testBrokenCacheDataTreeShouldFailValidation() throws Exception { - Ignite ignite = startGrids(2); + Ignite ignite = prepareGridForTest(); - ignite.cluster().active(true); - - Ignite client = startGrid("client"); - - String cacheName = "persons-cache-vi"; - - IgniteCache personCache = createPersonCache(client, cacheName); - - ThreadLocalRandom rand = ThreadLocalRandom.current(); - - for (int i = 0; i < 10_000; i++) - personCache.put(i, new Person(rand.nextInt(), String.valueOf(rand.nextLong()))); - - breakCacheDataTree(ignite, cacheName, 1); + breakCacheDataTree(ignite, CACHE_NAME, 1); injectTestSystemOut(); @@ -105,11 +93,11 @@ public void testBrokenCacheDataTreeShouldFailValidation() throws Exception { execute( "--cache", "validate_indexes", - cacheName, - "checkFirst", "10000", - "checkThrough", "10")); + CACHE_NAME, + "--check-first", "10000", + "--check-through", "10")); - assertTrue(testOut.toString().contains("validate_indexes has finished with errors")); + assertTrue(testOut.toString().contains("issues found (listed above)")); assertTrue(testOut.toString().contains( "Key is present in SQL index, but is missing in corresponding data page.")); @@ -118,7 +106,49 @@ public void testBrokenCacheDataTreeShouldFailValidation() throws Exception { /** * Tests that missing rows in H2 indexes are detected. */ + @Test public void testBrokenSqlIndexShouldFailValidation() throws Exception { + Ignite ignite = prepareGridForTest(); + + breakSqlIndex(ignite, CACHE_NAME); + + injectTestSystemOut(); + + assertEquals(EXIT_CODE_OK, execute("--cache", "validate_indexes", CACHE_NAME)); + + assertTrue(testOut.toString().contains("issues found (listed above)")); + } + + /** + * Tests that corrupted pages in the index partition are detected. + */ + @Test + public void testCorruptedIndexPartitionShouldFailValidation() throws Exception { + Ignite ignite = prepareGridForTest(); + + forceCheckpoint(); + + File idxPath = indexPartition(ignite, CACHE_NAME); + + stopAllGrids(); + + corruptIndexPartition(idxPath); + + startGrids(2); + + awaitPartitionMapExchange(); + + injectTestSystemOut(); + + assertEquals(EXIT_CODE_OK, execute("--cache", "validate_indexes", CACHE_NAME)); + + assertTrue(testOut.toString().contains("issues found (listed above)")); + } + + /** + * + */ + private Ignite prepareGridForTest() throws Exception{ Ignite ignite = startGrids(2); ignite.cluster().active(true); @@ -127,20 +157,52 @@ public void testBrokenSqlIndexShouldFailValidation() throws Exception { String cacheName = "persons-cache-vi"; - IgniteCache personCache = createPersonCache(client, cacheName); + client.getOrCreateCache(new CacheConfiguration() + .setName(cacheName) + .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) + .setAtomicityMode(CacheAtomicityMode.ATOMIC) + .setBackups(1) + .setQueryEntities(F.asList(personEntity(true, true))) + .setAffinity(new RendezvousAffinityFunction(false, 32))); ThreadLocalRandom rand = ThreadLocalRandom.current(); - for (int i = 0; i < 10_000; i++) - personCache.put(i, new Person(rand.nextInt(), String.valueOf(rand.nextLong()))); + try (IgniteDataStreamer streamer = client.dataStreamer(CACHE_NAME)) { + for (int i = 0; i < 10_000; i++) + streamer.addData(i, new Person(rand.nextInt(), String.valueOf(rand.nextLong()))); + } - breakSqlIndex(ignite, cacheName); + return ignite; + } - injectTestSystemOut(); + /** + * Get index partition file for specific node and cache. + */ + private File indexPartition(Ignite ig, String cacheName) { + IgniteEx ig0 = (IgniteEx)ig; - assertEquals(EXIT_CODE_OK, execute("--cache", "validate_indexes", cacheName)); + FilePageStoreManager pageStoreManager = ((FilePageStoreManager) ig0.context().cache().context().pageStore()); - assertTrue(testOut.toString().contains("validate_indexes has finished with errors")); + return new File(pageStoreManager.cacheWorkDir(false, cacheName), INDEX_FILE_NAME); + } + + /** + * Write some random trash in index partition. + */ + private void corruptIndexPartition(File path) throws IOException { + assertTrue(path.exists()); + + ThreadLocalRandom rand = ThreadLocalRandom.current(); + + try (RandomAccessFile idx = new RandomAccessFile(path, "rw")) { + byte[] trash = new byte[1024]; + + rand.nextBytes(trash); + + idx.seek(4096); + + idx.write(trash); + } } /** @@ -241,22 +303,6 @@ private void breakSqlIndex(Ignite ig, String cacheName) throws Exception { } } - /** - * Dynamically creates cache with SQL indexes. - * - * @param ig Client. - * @param cacheName Cache name. - */ - private IgniteCache createPersonCache(Ignite ig, String cacheName) { - return ig.getOrCreateCache(new CacheConfiguration() - .setName(cacheName) - .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC) - .setAtomicityMode(CacheAtomicityMode.ATOMIC) - .setBackups(1) - .setQueryEntities(F.asList(personEntity(true, true))) - .setAffinity(new RendezvousAffinityFunction(false, 32))); - } - /** * @param idxName Index name. * @param idxOrgId Index org id. diff --git a/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.java b/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.java index 9cb0f21562cfc..6a144fcfc6089 100644 --- a/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.java +++ b/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.java @@ -31,10 +31,14 @@ import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cache.query.annotations.QuerySqlField; import org.apache.ignite.configuration.CacheConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests queries against entities with JSR-310 Java 8 Date and Time API fields. */ +@RunWith(JUnit4.class) public class CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest extends CacheQueryJsr310Java8DateTimeApiAbstractTest { /** * Entity containing JSR-310 fields. @@ -222,6 +226,7 @@ private static CacheConfiguration createCacheConfi * * @throws Exception If failed. */ + @Test public void testInsertEntityFields() throws Exception { cache.remove(entity.getId()); @@ -247,6 +252,7 @@ public void testInsertEntityFields() throws Exception { * * @throws Exception If failed. */ + @Test public void testDateDiffForLocalDateTimeFieldAtMidnight() throws Exception { SqlFieldsQuery qry = new SqlFieldsQuery("select DATEDIFF('DAY', locDateTime, CURRENT_DATE ()) from EntityWithJsr310Fields"); @@ -262,6 +268,7 @@ public void testDateDiffForLocalDateTimeFieldAtMidnight() throws Exception { * * @throws Exception If failed. */ + @Test public void testSelectLocalTimeFieldReturnsTime() throws Exception { SqlFieldsQuery qry = new SqlFieldsQuery("select locTime from EntityWithJsr310Fields"); @@ -276,6 +283,7 @@ public void testSelectLocalTimeFieldReturnsTime() throws Exception { * * @throws Exception If failed. */ + @Test public void testSelectLocalDateFieldReturnsDate() throws Exception { SqlFieldsQuery qry = new SqlFieldsQuery("select locDate from EntityWithJsr310Fields"); @@ -290,6 +298,7 @@ public void testSelectLocalDateFieldReturnsDate() throws Exception { * * @throws Exception If failed. */ + @Test public void testSelectLocalDateTimeFieldReturnsTimestamp() throws Exception { SqlFieldsQuery qry = new SqlFieldsQuery("select locDateTime from EntityWithJsr310Fields"); @@ -302,6 +311,7 @@ public void testSelectLocalDateTimeFieldReturnsTimestamp() throws Exception { /** * Tests selection of an entity by a {@link LocalTime} field. */ + @Test public void testSelectByAllJsr310Fields() { SqlFieldsQuery qry = new SqlFieldsQuery( "select locDate from EntityWithJsr310Fields where locTime = ? and locDate = ? and locDateTime = ?" @@ -316,6 +326,7 @@ public void testSelectByAllJsr310Fields() { /** * Tests updating of all JSR-310 fields. */ + @Test public void testUpdateAllJsr310Fields() { EntityWithJsr310Fields expEntity = new EntityWithJsr310Fields(entity); @@ -337,6 +348,7 @@ public void testUpdateAllJsr310Fields() { /** * Tests deleting by all JSR-310 fields. */ + @Test public void testDeleteByAllJsr310Fields() { SqlFieldsQuery qry = new SqlFieldsQuery( "delete from EntityWithJsr310Fields where locTime = ? and locDate = ? and locDateTime = ?" diff --git a/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiAbstractTest.java b/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiAbstractTest.java index d0ca8f1b6d1a3..61c5d1d3eea35 100644 --- a/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiAbstractTest.java +++ b/modules/indexing/src/test/java8/org/apache/ignite/internal/processors/query/h2/CacheQueryJsr310Java8DateTimeApiAbstractTest.java @@ -25,18 +25,12 @@ import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** * Base class for JSR-310 Java 8 Date and Time API queries tests. */ public abstract class CacheQueryJsr310Java8DateTimeApiAbstractTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@link LocalTime} instance. */ protected static final LocalTime LOCAL_TIME = LocalTime.now().minusHours(10); @@ -53,16 +47,6 @@ public abstract class CacheQueryJsr310Java8DateTimeApiAbstractTest extends GridC /** {@link LocalDateTime} instance. */ protected static final LocalDateTime LOCAL_DATE_TIME = LocalDateTime.of(LOCAL_DATE, LocalTime.MIDNIGHT); - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); - - discoverySpi.setIpFinder(IP_FINDER); - - return cfg; - } - /** * Creates a cache configuration with the specified cache name * and indexed type key/value pairs. diff --git a/modules/indexing/src/test/java8/org/apache/ignite/testsuites/CacheQueryJsr310Java8DateTimeApiSupportTestSuite.java b/modules/indexing/src/test/java8/org/apache/ignite/testsuites/CacheQueryJsr310Java8DateTimeApiSupportTestSuite.java index aa7aed8a59c01..7999218dc1ed6 100644 --- a/modules/indexing/src/test/java8/org/apache/ignite/testsuites/CacheQueryJsr310Java8DateTimeApiSupportTestSuite.java +++ b/modules/indexing/src/test/java8/org/apache/ignite/testsuites/CacheQueryJsr310Java8DateTimeApiSupportTestSuite.java @@ -17,13 +17,17 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.query.h2.CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suite for JSR-310 Java 8 Date and Time API queries. */ -public class CacheQueryJsr310Java8DateTimeApiSupportTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class CacheQueryJsr310Java8DateTimeApiSupportTestSuite { /** * @return Test suite. * @throws Exception If failed. @@ -31,7 +35,7 @@ public class CacheQueryJsr310Java8DateTimeApiSupportTestSuite extends TestSuite public static TestSuite suite() throws Exception { TestSuite suite = new TestSuite("JSR-310 Java 8 Date and Time API Cache Queries Test Suite"); - suite.addTestSuite(CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.class); + suite.addTest(new JUnit4TestAdapter(CacheQueryEntityWithJsr310Java8DateTimeApiFieldsTest.class)); return suite; } diff --git a/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/JclLoggerTest.java b/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/JclLoggerTest.java index f7b60ecdcc70c..0568e0ce8525a 100644 --- a/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/JclLoggerTest.java +++ b/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/JclLoggerTest.java @@ -17,21 +17,22 @@ package org.apache.ignite.logger.jcl; -import junit.framework.TestCase; import org.apache.commons.logging.LogFactory; import org.apache.ignite.IgniteLogger; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; /** * Jcl logger test. */ @GridCommonTest(group = "Logger") -public class JclLoggerTest extends TestCase { +public class JclLoggerTest { /** */ @SuppressWarnings({"FieldCanBeLocal"}) private IgniteLogger log; /** */ + @Test public void testLogInitialize() { log = new JclLogger(LogFactory.getLog(JclLoggerTest.class.getName())); @@ -45,4 +46,4 @@ public void testLogInitialize() { assert log.getLogger(JclLoggerTest.class.getName()) instanceof JclLogger; } -} \ No newline at end of file +} diff --git a/modules/jcl/src/test/java/org/apache/ignite/testsuites/IgniteJclTestSuite.java b/modules/jcl/src/test/java/org/apache/ignite/testsuites/IgniteJclTestSuite.java index 8c65cd92335f1..5736006bba8e6 100644 --- a/modules/jcl/src/test/java/org/apache/ignite/testsuites/IgniteJclTestSuite.java +++ b/modules/jcl/src/test/java/org/apache/ignite/testsuites/IgniteJclTestSuite.java @@ -17,22 +17,25 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.logger.jcl.JclLoggerTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Commons logging test. */ -public class IgniteJclTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteJclTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Commons Logging Test Suite"); - suite.addTest(new TestSuite(JclLoggerTest.class)); + suite.addTest(new JUnit4TestAdapter(JclLoggerTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/jms11/src/test/java/org/apache/ignite/stream/jms11/IgniteJmsStreamerTest.java b/modules/jms11/src/test/java/org/apache/ignite/stream/jms11/IgniteJmsStreamerTest.java index caf8f9eb644bc..4b2e819c23258 100644 --- a/modules/jms11/src/test/java/org/apache/ignite/stream/jms11/IgniteJmsStreamerTest.java +++ b/modules/jms11/src/test/java/org/apache/ignite/stream/jms11/IgniteJmsStreamerTest.java @@ -57,8 +57,9 @@ import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.junit.After; -import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; @@ -67,6 +68,7 @@ * * @author Raul Kripalani */ +@RunWith(JUnit4.class) public class IgniteJmsStreamerTest extends GridCommonAbstractTest { /** */ private static final int CACHE_ENTRY_COUNT = 100; @@ -99,9 +101,8 @@ public IgniteJmsStreamerTest() { /** * @throws Exception If failed. */ - @Before @SuppressWarnings("unchecked") - public void beforeTest() throws Exception { + @Override public void beforeTest() throws Exception { grid().getOrCreateCache(defaultCacheConfiguration()); broker = new BrokerService(); @@ -127,8 +128,7 @@ public void beforeTest() throws Exception { /** * @throws Exception Iff ailed. */ - @After - public void afterTest() throws Exception { + @Override public void afterTest() throws Exception { grid().cache(DEFAULT_CACHE_NAME).clear(); broker.stop(); @@ -138,6 +138,7 @@ public void afterTest() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueueFromName() throws Exception { Destination dest = new ActiveMQQueue(QUEUE_NAME); @@ -167,6 +168,7 @@ public void testQueueFromName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopicFromName() throws JMSException, InterruptedException { Destination dest = new ActiveMQTopic(TOPIC_NAME); @@ -199,6 +201,7 @@ public void testTopicFromName() throws JMSException, InterruptedException { /** * @throws Exception If failed. */ + @Test public void testQueueFromExplicitDestination() throws Exception { Destination dest = new ActiveMQQueue(QUEUE_NAME); @@ -228,6 +231,7 @@ public void testQueueFromExplicitDestination() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopicFromExplicitDestination() throws JMSException, InterruptedException { Destination dest = new ActiveMQTopic(TOPIC_NAME); @@ -259,6 +263,7 @@ public void testTopicFromExplicitDestination() throws JMSException, InterruptedE /** * @throws Exception If failed. */ + @Test public void testInsertMultipleCacheEntriesFromOneMessage() throws Exception { Destination dest = new ActiveMQQueue(QUEUE_NAME); @@ -287,6 +292,7 @@ public void testInsertMultipleCacheEntriesFromOneMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDurableSubscriberStartStopStart() throws Exception { Destination dest = new ActiveMQTopic(TOPIC_NAME); @@ -327,6 +333,7 @@ public void testDurableSubscriberStartStopStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueueMessagesConsumedInBatchesCompletionSizeBased() throws Exception { Destination dest = new ActiveMQQueue(QUEUE_NAME); @@ -366,6 +373,7 @@ public void testQueueMessagesConsumedInBatchesCompletionSizeBased() throws Excep /** * @throws Exception If failed. */ + @Test public void testQueueMessagesConsumedInBatchesCompletionTimeBased() throws Exception { Destination dest = new ActiveMQQueue(QUEUE_NAME); @@ -416,6 +424,7 @@ public void testQueueMessagesConsumedInBatchesCompletionTimeBased() throws Excep /** * @throws Exception If failed. */ + @Test public void testGenerateNoEntries() throws Exception { Destination dest = new ActiveMQQueue(QUEUE_NAME); @@ -444,6 +453,7 @@ public void testGenerateNoEntries() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTransactedSessionNoBatching() throws Exception { Destination dest = new ActiveMQQueue(QUEUE_NAME); @@ -473,6 +483,7 @@ public void testTransactedSessionNoBatching() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueueMultipleThreads() throws Exception { Destination dest = new ActiveMQQueue(QUEUE_NAME); @@ -512,6 +523,7 @@ public void testQueueMultipleThreads() throws Exception { * * @throws Exception If fails. */ + @Test public void testExceptionListener() throws Exception { // restart broker with auth plugin if (broker.isStarted()) @@ -696,4 +708,4 @@ private void produceStringMessages(Destination dest, boolean singleMsg) throws J } } -} \ No newline at end of file +} diff --git a/modules/jta/pom.xml b/modules/jta/pom.xml index 9c3bd6cc5dbac..b6b0b8ab1cb00 100644 --- a/modules/jta/pom.xml +++ b/modules/jta/pom.xml @@ -50,7 +50,7 @@ org.ow2.jotm jotm-core - 2.2.3 + ${jotm.version} test @@ -95,7 +95,7 @@ org.jboss.spec.javax.rmi jboss-rmi-api_1.0_spec - 1.0.6.Final + ${jboss.rmi.version} test diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/CacheJndiTmFactorySelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/CacheJndiTmFactorySelfTest.java index 494c5b726e196..0dae5f87f37e6 100644 --- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/CacheJndiTmFactorySelfTest.java +++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/CacheJndiTmFactorySelfTest.java @@ -32,10 +32,14 @@ import org.apache.ignite.cache.jta.jndi.CacheJndiTmFactory; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class CacheJndiTmFactorySelfTest extends GridCommonAbstractTest { /** */ private static final String TM_JNDI_NAME = "java:/comp/env/tm/testtm1"; @@ -87,6 +91,7 @@ public class CacheJndiTmFactorySelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testFactory() throws Exception { CacheJndiTmFactory f = new CacheJndiTmFactory("wrongJndiName", NOT_TM_JNDI_NAME, TM_JNDI_NAME2, TM_JNDI_NAME); @@ -100,6 +105,7 @@ public void testFactory() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFactoryException() throws Exception { final CacheJndiTmFactory f = new CacheJndiTmFactory("wrongJndiName", NOT_TM_JNDI_NAME, "wrongJndiName2"); diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaConfigurationValidationSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaConfigurationValidationSelfTest.java index c7b7feddbb384..dc65ae5daf3b6 100644 --- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaConfigurationValidationSelfTest.java +++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaConfigurationValidationSelfTest.java @@ -26,12 +26,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; /** * Configuration validation test. */ +@RunWith(JUnit4.class) public class GridCacheJtaConfigurationValidationSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -53,6 +57,7 @@ public class GridCacheJtaConfigurationValidationSelfTest extends GridCommonAbstr * * @throws Exception If failed. */ + @Test public void testAtomicWithTmLookup() throws Exception { GridTestUtils.assertThrows(log, new Callable() { @Override public Void call() throws Exception { diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaFactoryConfigValidationSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaFactoryConfigValidationSelfTest.java index bb12d5e2b3de8..c63df3cdb90a3 100644 --- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaFactoryConfigValidationSelfTest.java +++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaFactoryConfigValidationSelfTest.java @@ -25,12 +25,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; /** * Configuration validation test. */ +@RunWith(JUnit4.class) public class GridCacheJtaFactoryConfigValidationSelfTest extends GridCommonAbstractTest { /** */ private Factory factory; @@ -53,6 +57,7 @@ public class GridCacheJtaFactoryConfigValidationSelfTest extends GridCommonAbstr /** * @throws Exception If failed. */ + @Test public void testNullFactory() throws Exception { factory = new NullTxFactory(); @@ -70,6 +75,7 @@ public void testNullFactory() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWrongTypeFactory() throws Exception { factory = new IntegerTxFactory(); @@ -87,6 +93,7 @@ public void testWrongTypeFactory() throws Exception { /** * @throws Exception If failed. */ + @Test public void testExceptionFactory() throws Exception { factory = new ExceptionTxFactory(); diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaLifecycleAwareSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaLifecycleAwareSelfTest.java index c10d11541ccd1..bd36a2593a452 100644 --- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaLifecycleAwareSelfTest.java +++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaLifecycleAwareSelfTest.java @@ -31,12 +31,16 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridAbstractLifecycleAwareSelfTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.cache.CacheMode.PARTITIONED; /** * Test for {@link LifecycleAware} support for {@link CacheTmLookup}. */ +@RunWith(JUnit4.class) public class GridJtaLifecycleAwareSelfTest extends GridAbstractLifecycleAwareSelfTest { /** */ private static final String CACHE_NAME = "cache"; @@ -140,11 +144,13 @@ public static class TestTxFactory extends GridAbstractLifecycleAwareSelfTest.Tes } /** {@inheritDoc} */ + @Test @Override public void testLifecycleAware() throws Exception { // No-op, see anothre tests. } /** {@inheritDoc} */ + @Test public void testCacheLookupLifecycleAware() throws Exception { tmConfigurationType = TmConfigurationType.CACHE_LOOKUP; @@ -152,6 +158,7 @@ public void testCacheLookupLifecycleAware() throws Exception { } /** {@inheritDoc} */ + @Test public void testGlobalLookupLifecycleAware() throws Exception { tmConfigurationType = TmConfigurationType.GLOBAL_LOOKUP; @@ -159,6 +166,7 @@ public void testGlobalLookupLifecycleAware() throws Exception { } /** {@inheritDoc} */ + @Test public void testFactoryLifecycleAware() throws Exception { tmConfigurationType = TmConfigurationType.FACTORY; diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaTransactionManagerSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaTransactionManagerSelfTest.java index a7bb78523646e..dff2aacb62856 100644 --- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaTransactionManagerSelfTest.java +++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaTransactionManagerSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.objectweb.jotm.Current; import org.objectweb.jotm.Jotm; @@ -35,6 +38,7 @@ /** * JTA Tx Manager test. */ +@RunWith(JUnit4.class) public class GridJtaTransactionManagerSelfTest extends GridCommonAbstractTest { /** Java Open Transaction Manager facade. */ private static Jotm jotm; @@ -70,6 +74,7 @@ public class GridJtaTransactionManagerSelfTest extends GridCommonAbstractTest { * * @throws Exception If failed. */ + @Test public void testJtaTxContextSwitch() throws Exception { for (TransactionIsolation isolation : TransactionIsolation.values()) { TransactionConfiguration cfg = grid().context().config().getTransactionConfiguration(); @@ -144,6 +149,7 @@ public void testJtaTxContextSwitch() throws Exception { /** * @throws Exception If failed. */ + @Test public void testJtaTxContextSwitchWithExistingTx() throws Exception { for (TransactionIsolation isolation : TransactionIsolation.values()) { TransactionConfiguration cfg = grid().context().config().getTransactionConfiguration(); diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/jta/AbstractCacheJtaSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/jta/AbstractCacheJtaSelfTest.java index 89fb72f2a98cf..1ea553db203c9 100644 --- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/jta/AbstractCacheJtaSelfTest.java +++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/jta/AbstractCacheJtaSelfTest.java @@ -27,6 +27,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; import org.apache.ignite.testframework.GridTestSafeThreadFactory; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.objectweb.jotm.Jotm; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; @@ -39,6 +42,7 @@ /** * Abstract class for cache tests. */ +@RunWith(JUnit4.class) public abstract class AbstractCacheJtaSelfTest extends GridCacheAbstractSelfTest { /** */ private static final int GRID_CNT = 1; @@ -97,6 +101,7 @@ public abstract class AbstractCacheJtaSelfTest extends GridCacheAbstractSelfTest * * @throws Exception If failed. */ + @Test public void testJta() throws Exception { UserTransaction jtaTx = jotm.getUserTransaction(); @@ -140,7 +145,7 @@ public void testJta() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings("ConstantConditions") + @Test public void testJtaTwoCaches() throws Exception { UserTransaction jtaTx = jotm.getUserTransaction(); @@ -190,6 +195,7 @@ public void testJtaTwoCaches() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAsyncOpAwait() throws Exception { final IgniteCache cache = jcache(); diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/jta/GridPartitionedCacheJtaLookupClassNameSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/jta/GridPartitionedCacheJtaLookupClassNameSelfTest.java index 7357f8ea9af80..0429de8b2c466 100644 --- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/jta/GridPartitionedCacheJtaLookupClassNameSelfTest.java +++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/jta/GridPartitionedCacheJtaLookupClassNameSelfTest.java @@ -27,10 +27,14 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testsuites.IgniteIgnore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Lookup class name based JTA integration test using PARTITIONED cache. */ +@RunWith(JUnit4.class) public class GridPartitionedCacheJtaLookupClassNameSelfTest extends AbstractCacheJtaSelfTest { /** {@inheritDoc} */ @Override protected void configureJta(IgniteConfiguration cfg) { @@ -40,7 +44,8 @@ public class GridPartitionedCacheJtaLookupClassNameSelfTest extends AbstractCach /** * */ - @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-1094", forceFailure = true) + @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-10723", forceFailure = true) + @Test public void testIncompatibleTmLookup() { final IgniteEx ignite = grid(0); diff --git a/modules/jta/src/test/java/org/apache/ignite/testsuites/IgniteJtaTestSuite.java b/modules/jta/src/test/java/org/apache/ignite/testsuites/IgniteJtaTestSuite.java index 3cc7935eb19a6..82350b282960f 100644 --- a/modules/jta/src/test/java/org/apache/ignite/testsuites/IgniteJtaTestSuite.java +++ b/modules/jta/src/test/java/org/apache/ignite/testsuites/IgniteJtaTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.cache.CacheJndiTmFactorySelfTest; import org.apache.ignite.internal.processors.cache.GridCacheJtaConfigurationValidationSelfTest; @@ -30,35 +31,37 @@ import org.apache.ignite.internal.processors.cache.jta.GridReplicatedCacheJtaLookupClassNameSelfTest; import org.apache.ignite.internal.processors.cache.GridJtaLifecycleAwareSelfTest; import org.apache.ignite.testframework.IgniteTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * JTA integration tests. */ -public class IgniteJtaTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteJtaTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new IgniteTestSuite("JTA Integration Test Suite"); - suite.addTestSuite(GridPartitionedCacheJtaFactorySelfTest.class); - suite.addTestSuite(GridReplicatedCacheJtaFactorySelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridPartitionedCacheJtaFactorySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridReplicatedCacheJtaFactorySelfTest.class)); - suite.addTestSuite(GridPartitionedCacheJtaLookupClassNameSelfTest.class); - suite.addTestSuite(GridReplicatedCacheJtaLookupClassNameSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridPartitionedCacheJtaLookupClassNameSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridReplicatedCacheJtaLookupClassNameSelfTest.class)); - suite.addTestSuite(GridPartitionedCacheJtaFactoryUseSyncSelfTest.class); - suite.addTestSuite(GridReplicatedCacheJtaFactoryUseSyncSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridPartitionedCacheJtaFactoryUseSyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridReplicatedCacheJtaFactoryUseSyncSelfTest.class)); - suite.addTestSuite(GridJtaLifecycleAwareSelfTest.class); - suite.addTestSuite(GridCacheJtaConfigurationValidationSelfTest.class); - suite.addTestSuite(GridCacheJtaFactoryConfigValidationSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridJtaLifecycleAwareSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheJtaConfigurationValidationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheJtaFactoryConfigValidationSelfTest.class)); - suite.addTestSuite(GridJtaTransactionManagerSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridJtaTransactionManagerSelfTest.class)); // Factory - suite.addTestSuite(CacheJndiTmFactorySelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheJndiTmFactorySelfTest.class)); return suite; } diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/IgniteKafkaStreamerSelfTestSuite.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/IgniteKafkaStreamerSelfTestSuite.java index c8d413ab79021..f86f7a782278d 100644 --- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/IgniteKafkaStreamerSelfTestSuite.java +++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/IgniteKafkaStreamerSelfTestSuite.java @@ -17,27 +17,30 @@ package org.apache.ignite.stream.kafka; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.stream.kafka.connect.IgniteSinkConnectorTest; import org.apache.ignite.stream.kafka.connect.IgniteSourceConnectorTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Apache Kafka streamers tests. */ -public class IgniteKafkaStreamerSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteKafkaStreamerSelfTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Apache Kafka streamer Test Suite"); // Kafka streamer. - suite.addTest(new TestSuite(KafkaIgniteStreamerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(KafkaIgniteStreamerSelfTest.class)); // Kafka streamers via Connect API. - suite.addTest(new TestSuite(IgniteSinkConnectorTest.class)); - suite.addTest(new TestSuite(IgniteSourceConnectorTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSinkConnectorTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSourceConnectorTest.class)); return suite; } diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/KafkaIgniteStreamerSelfTest.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/KafkaIgniteStreamerSelfTest.java index 081add820d8c3..24fd8a33a5c76 100644 --- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/KafkaIgniteStreamerSelfTest.java +++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/KafkaIgniteStreamerSelfTest.java @@ -42,12 +42,16 @@ import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.StringDeserializer; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; /** * Tests {@link KafkaStreamer}. */ +@RunWith(JUnit4.class) public class KafkaIgniteStreamerSelfTest extends GridCommonAbstractTest { /** Embedded Kafka. */ private TestKafkaBroker embeddedBroker; @@ -96,6 +100,7 @@ public KafkaIgniteStreamerSelfTest() { * @throws TimeoutException If timed out. * @throws InterruptedException If interrupted. */ + @Test public void testKafkaStreamer() throws TimeoutException, InterruptedException { embeddedBroker.createTopic(TOPIC_NAME, PARTITIONS, REPLICATION_FACTOR); diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSinkConnectorTest.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSinkConnectorTest.java index d710a7502d600..24a605e77b27d 100644 --- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSinkConnectorTest.java +++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSinkConnectorTest.java @@ -51,6 +51,9 @@ import org.apache.kafka.connect.util.Callback; import org.apache.kafka.connect.util.ConnectUtils; import org.apache.kafka.connect.util.FutureCallback; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; import static org.easymock.EasyMock.mock; @@ -58,6 +61,7 @@ /** * Tests for {@link IgniteSinkConnector}. */ +@RunWith(JUnit4.class) public class IgniteSinkConnectorTest extends GridCommonAbstractTest { /** Number of input messages. */ private static final int EVENT_CNT = 10000; @@ -90,7 +94,6 @@ public class IgniteSinkConnectorTest extends GridCommonAbstractTest { private static Ignite grid; /** {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override protected void beforeTest() throws Exception { kafkaBroker = new TestKafkaBroker(); @@ -128,7 +131,6 @@ public class IgniteSinkConnectorTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override protected void beforeTestsStarted() throws Exception { IgniteConfiguration cfg = loadConfiguration("modules/kafka/src/test/resources/example-ignite.xml"); @@ -137,6 +139,10 @@ public class IgniteSinkConnectorTest extends GridCommonAbstractTest { grid = startGrid("igniteServerNode", cfg); } + /** + * @throws Exception if failed. + */ + @Test public void testSinkPutsWithoutTransformation() throws Exception { Map sinkProps = makeSinkProps(Utils.join(TOPICS, ",")); @@ -145,6 +151,10 @@ public void testSinkPutsWithoutTransformation() throws Exception { testSinkPuts(sinkProps, false); } + /** + * @throws Exception if failed. + */ + @Test public void testSinkPutsWithTransformation() throws Exception { testSinkPuts(makeSinkProps(Utils.join(TOPICS, ",")), true); } @@ -291,7 +301,6 @@ private Map makeWorkerProps() { * Test transformer. */ static class TestExtractor implements StreamSingleTupleExtractor { - /** {@inheritDoc} */ @Override public Map.Entry extract(SinkRecord msg) { String[] parts = ((String)msg.value()).split("_"); diff --git a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorTest.java b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorTest.java index 8717044ec8f96..0d0612911e7fd 100644 --- a/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorTest.java +++ b/modules/kafka/src/test/java/org/apache/ignite/stream/kafka/connect/IgniteSourceConnectorTest.java @@ -55,12 +55,16 @@ import org.apache.kafka.connect.util.Callback; import org.apache.kafka.connect.util.ConnectUtils; import org.apache.kafka.connect.util.FutureCallback; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; /** * Tests for {@link IgniteSourceConnector}. */ +@RunWith(JUnit4.class) public class IgniteSourceConnectorTest extends GridCommonAbstractTest { /** Number of input messages. */ private static final int EVENT_CNT = 100; @@ -136,6 +140,7 @@ public class IgniteSourceConnectorTest extends GridCommonAbstractTest { * * @throws Exception Thrown in case of the failure. */ + @Test public void testEventsInjectedIntoKafkaWithoutFilter() throws Exception { Map srcProps = makeSourceProps(Utils.join(TOPICS, ",")); @@ -149,6 +154,7 @@ public void testEventsInjectedIntoKafkaWithoutFilter() throws Exception { * * @throws Exception Thrown in case of the failure. */ + @Test public void testEventsInjectedIntoKafka() throws Exception { doTest(makeSourceProps(Utils.join(TOPICS, ",")), true); } diff --git a/modules/kubernetes/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/kubernetes/TcpDiscoveryKubernetesIpFinderSelfTest.java b/modules/kubernetes/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/kubernetes/TcpDiscoveryKubernetesIpFinderSelfTest.java index fd3e2a35e432c..c12e18ad4225b 100644 --- a/modules/kubernetes/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/kubernetes/TcpDiscoveryKubernetesIpFinderSelfTest.java +++ b/modules/kubernetes/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/kubernetes/TcpDiscoveryKubernetesIpFinderSelfTest.java @@ -19,10 +19,14 @@ import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAbstractSelfTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * TcpDiscoveryKubernetesIpFinder test. */ +@RunWith(JUnit4.class) public class TcpDiscoveryKubernetesIpFinderSelfTest extends TcpDiscoveryIpFinderAbstractSelfTest { /** @@ -45,6 +49,7 @@ public TcpDiscoveryKubernetesIpFinderSelfTest() throws Exception { } /* {@inheritDoc} */ + @Test @Override public void testIpFinder() throws Exception { TcpDiscoveryKubernetesIpFinder ipFinder = new TcpDiscoveryKubernetesIpFinder(); @@ -90,4 +95,4 @@ public TcpDiscoveryKubernetesIpFinderSelfTest() throws Exception { assertTrue(e.getMessage().startsWith("One or more configuration parameters are invalid")); } } -} \ No newline at end of file +} diff --git a/modules/kubernetes/src/test/java/org/apache/ignite/testsuites/IgniteKubernetesTestSuite.java b/modules/kubernetes/src/test/java/org/apache/ignite/testsuites/IgniteKubernetesTestSuite.java index 540657e8b2601..43b9b917164de 100644 --- a/modules/kubernetes/src/test/java/org/apache/ignite/testsuites/IgniteKubernetesTestSuite.java +++ b/modules/kubernetes/src/test/java/org/apache/ignite/testsuites/IgniteKubernetesTestSuite.java @@ -18,24 +18,27 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinderSelfTest; import org.apache.ignite.testframework.IgniteTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Ignite Kubernetes integration test. */ -public class IgniteKubernetesTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteKubernetesTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new IgniteTestSuite("Kubernetes Integration Test Suite"); // Cloud Nodes IP finder. - suite.addTestSuite(TcpDiscoveryKubernetesIpFinderSelfTest.class); + suite.addTest(new JUnit4TestAdapter(TcpDiscoveryKubernetesIpFinderSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jConfigUpdateTest.java b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jConfigUpdateTest.java index c0d9591c4df59..e2dc02ba600ed 100644 --- a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jConfigUpdateTest.java +++ b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jConfigUpdateTest.java @@ -21,14 +21,17 @@ import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.Date; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.log4j.helpers.FileWatchdog; +import org.junit.Test; + +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; /** * Checking that Log4j configuration is updated when its source file is changed. */ -public class GridLog4jConfigUpdateTest extends TestCase { +public class GridLog4jConfigUpdateTest { /** Path to log4j configuration with INFO enabled. */ private static final String LOG_CONFIG_INFO = "modules/log4j/src/test/config/log4j-info.xml"; @@ -51,7 +54,7 @@ public class GridLog4jConfigUpdateTest extends TestCase { * Check that changing log4j config file causes the logger configuration to be updated. * String-accepting constructor is used. */ - @SuppressWarnings("ResultOfMethodCallIgnored") + @Test public void testConfigChangeStringConstructor() throws Exception { checkConfigUpdate(new Log4JLoggerSupplier() { @Override public Log4JLogger get(File cfgFile) throws Exception { @@ -64,7 +67,7 @@ public void testConfigChangeStringConstructor() throws Exception { * Check that changing log4j config file causes the logger configuration to be updated. * String-accepting constructor is used. */ - @SuppressWarnings("ResultOfMethodCallIgnored") + @Test public void testConfigChangeStringConstructorDefaultDelay() throws Exception { checkConfigUpdate(new Log4JLoggerSupplier() { @Override public Log4JLogger get(File cfgFile) throws Exception { @@ -77,7 +80,7 @@ public void testConfigChangeStringConstructorDefaultDelay() throws Exception { * Check that changing log4j config file causes the logger configuration to be updated. * File-accepting constructor is used. */ - @SuppressWarnings("ResultOfMethodCallIgnored") + @Test public void testConfigChangeFileConstructor() throws Exception { checkConfigUpdate(new Log4JLoggerSupplier() { @Override public Log4JLogger get(File cfgFile) throws Exception { @@ -90,7 +93,7 @@ public void testConfigChangeFileConstructor() throws Exception { * Check that changing log4j config file causes the logger configuration to be updated. * File-accepting constructor is used. */ - @SuppressWarnings("ResultOfMethodCallIgnored") + @Test public void testConfigChangeUrlConstructor() throws Exception { checkConfigUpdate(new Log4JLoggerSupplier() { @Override public Log4JLogger get(File cfgFile) throws Exception { diff --git a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jCorrectFileNameTest.java b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jCorrectFileNameTest.java index ac5b4983af799..f166c000e6313 100644 --- a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jCorrectFileNameTest.java +++ b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jCorrectFileNameTest.java @@ -20,7 +20,6 @@ import java.io.File; import java.util.Collections; import java.util.Enumeration; -import junit.framework.TestCase; import org.apache.ignite.Ignite; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.G; @@ -32,17 +31,24 @@ import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.apache.log4j.varia.LevelRangeFilter; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * Tests that several grids log to files with correct names. */ @GridCommonTest(group = "Logger") -public class GridLog4jCorrectFileNameTest extends TestCase { +public class GridLog4jCorrectFileNameTest { /** Appender */ private Log4jRollingFileAppender appender; - /** {@inheritDoc} */ - @Override protected void setUp() throws Exception { + /** */ + @Before + public void setUp() { Logger root = Logger.getRootLogger(); for (Enumeration appenders = root.getAllAppenders(); appenders.hasMoreElements(); ) { @@ -55,8 +61,9 @@ public class GridLog4jCorrectFileNameTest extends TestCase { root.addAppender(appender); } - /** {@inheritDoc} */ - @Override public void tearDown() { + /** */ + @After + public void tearDown() { if (appender != null) { Logger.getRootLogger().removeAppender(Log4jRollingFileAppender.class.getSimpleName()); @@ -69,6 +76,7 @@ public class GridLog4jCorrectFileNameTest extends TestCase { * * @throws Exception If error occurs. */ + @Test public void testLogFilesTwoNodes() throws Exception { checkOneNode(0); checkOneNode(1); @@ -102,9 +110,8 @@ private void checkOneNode(int id) throws Exception { * * @param igniteInstanceName Ignite instance name. * @return Grid configuration. - * @throws Exception If error occurred. */ - private static IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + private static IgniteConfiguration getConfiguration(String igniteInstanceName) { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteInstanceName(igniteInstanceName); @@ -128,9 +135,8 @@ private static IgniteConfiguration getConfiguration(String igniteInstanceName) t * Creates new GridLog4jRollingFileAppender. * * @return GridLog4jRollingFileAppender. - * @throws Exception If error occurred. */ - private static Log4jRollingFileAppender createAppender() throws Exception { + private static Log4jRollingFileAppender createAppender() { Log4jRollingFileAppender appender = new Log4jRollingFileAppender(); appender.setLayout(new PatternLayout("[%d{ISO8601}][%-5p][%t][%c{1}] %m%n")); diff --git a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jInitializedTest.java b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jInitializedTest.java index 1fb9c34c0c21f..a8bb4fea91342 100644 --- a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jInitializedTest.java +++ b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jInitializedTest.java @@ -17,25 +17,27 @@ package org.apache.ignite.logger.log4j; -import junit.framework.TestCase; import org.apache.ignite.IgniteLogger; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.apache.log4j.BasicConfigurator; +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.assertTrue; /** * Log4j initialized test. */ @GridCommonTest(group = "Logger") -public class GridLog4jInitializedTest extends TestCase { - - /** - * @throws Exception If failed. - */ - @Override protected void setUp() throws Exception { +public class GridLog4jInitializedTest { + /** */ + @Before + public void setUp() { BasicConfigurator.configure(); } /** */ + @Test public void testLogInitialize() { IgniteLogger log = new Log4JLogger(); @@ -57,4 +59,4 @@ public void testLogInitialize() { assert log.getLogger(GridLog4jInitializedTest.class.getName()) instanceof Log4JLogger; } -} \ No newline at end of file +} diff --git a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingFileTest.java b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingFileTest.java index d1b09d7542e0a..a6d683e68ea92 100644 --- a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingFileTest.java +++ b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingFileTest.java @@ -18,24 +18,28 @@ package org.apache.ignite.logger.log4j; import java.io.File; -import junit.framework.TestCase; import org.apache.ignite.IgniteLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; /** * Grid Log4j SPI test. */ @GridCommonTest(group = "Logger") -public class GridLog4jLoggingFileTest extends TestCase { +public class GridLog4jLoggingFileTest { /** */ private IgniteLogger log; /** Logger config */ private File xml; - /** {@inheritDoc} */ - @Override protected void setUp() throws Exception { + /** */ + @Before + public void setUp() throws Exception { xml = GridTestUtils.resolveIgnitePath("modules/core/src/test/config/log4j-test.xml"); assert xml != null; @@ -47,6 +51,7 @@ public class GridLog4jLoggingFileTest extends TestCase { /** * Tests log4j logging SPI. */ + @Test public void testLog() { System.out.println(log.toString()); @@ -62,4 +67,4 @@ public void testLog() { log.error("This is 'error' message."); log.error("This is 'error' message.", new Exception("It's a test error exception")); } -} \ No newline at end of file +} diff --git a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingPathTest.java b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingPathTest.java index 867efbac45c68..b4840a41925d1 100644 --- a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingPathTest.java +++ b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingPathTest.java @@ -17,29 +17,34 @@ package org.apache.ignite.logger.log4j; -import junit.framework.TestCase; import org.apache.ignite.IgniteLogger; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; /** * Grid Log4j SPI test. */ @GridCommonTest(group = "Logger") -public class GridLog4jLoggingPathTest extends TestCase { +public class GridLog4jLoggingPathTest { /** */ private IgniteLogger log; /** Logger config */ private String path = "modules/core/src/test/config/log4j-test.xml"; - /** {@inheritDoc} */ - @Override protected void setUp() throws Exception { + /** */ + @Before + public void setUp() throws Exception { log = new Log4JLogger(path).getLogger(getClass()); } /** * Tests log4j logging SPI. */ + @Test public void testLog() { System.out.println(log.toString()); @@ -57,4 +62,4 @@ public void testLog() { log.error("This is 'error' message."); log.error("This is 'error' message.", new Exception("It's a test error exception")); } -} \ No newline at end of file +} diff --git a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingUrlTest.java b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingUrlTest.java index 1e2e8df82bf31..e76625adc5f57 100644 --- a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingUrlTest.java +++ b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jLoggingUrlTest.java @@ -19,24 +19,28 @@ import java.io.File; import java.net.URL; -import junit.framework.TestCase; import org.apache.ignite.IgniteLogger; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; /** * Grid Log4j SPI test. */ @GridCommonTest(group = "Logger") -public class GridLog4jLoggingUrlTest extends TestCase { +public class GridLog4jLoggingUrlTest { /** */ private IgniteLogger log; /** Logger config */ private URL url; - /** {@inheritDoc} */ - @Override protected void setUp() throws Exception { + /** */ + @Before + public void setUp() throws Exception { File xml = GridTestUtils.resolveIgnitePath("modules/core/src/test/config/log4j-test.xml"); assert xml != null; @@ -49,6 +53,7 @@ public class GridLog4jLoggingUrlTest extends TestCase { /** * Tests log4j logging SPI. */ + @Test public void testLog() { System.out.println(log.toString()); @@ -64,4 +69,4 @@ public void testLog() { log.error("This is 'error' message."); log.error("This is 'error' message.", new Exception("It's a test error exception")); } -} \ No newline at end of file +} diff --git a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jNotInitializedTest.java b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jNotInitializedTest.java index d32e890686420..c230e7ef6ffcb 100644 --- a/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jNotInitializedTest.java +++ b/modules/log4j/src/test/java/org/apache/ignite/logger/log4j/GridLog4jNotInitializedTest.java @@ -17,16 +17,19 @@ package org.apache.ignite.logger.log4j; -import junit.framework.TestCase; import org.apache.ignite.IgniteLogger; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; + +import static junit.framework.Assert.assertTrue; /** * Log4j not initialized test. */ @GridCommonTest(group = "Logger") -public class GridLog4jNotInitializedTest extends TestCase { +public class GridLog4jNotInitializedTest { /** */ + @Test public void testLogInitialize() { IgniteLogger log = new Log4JLogger().getLogger(GridLog4jNotInitializedTest.class); @@ -48,4 +51,4 @@ public void testLogInitialize() { log.warning("This is 'warning' message."); log.error("This is 'error' message."); } -} \ No newline at end of file +} diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2ConfigUpdateTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2ConfigUpdateTest.java index d9f75176ee299..ae09b73d3b0ff 100644 --- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2ConfigUpdateTest.java +++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2ConfigUpdateTest.java @@ -21,13 +21,16 @@ import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.Date; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.Test; + +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; /** * Checking that Log4j2 configuration is updated when its source file is changed. */ -public class Log4j2ConfigUpdateTest extends TestCase { +public class Log4j2ConfigUpdateTest { /** Path to log4j2 configuration with INFO enabled. */ private static final String LOG_CONFIG_INFO = "modules/log4j2/src/test/config/log4j2-info.xml"; @@ -56,7 +59,7 @@ public class Log4j2ConfigUpdateTest extends TestCase { * Check that changing log4j2 config file causes the logger configuration to be updated. * String-accepting constructor is used. */ - @SuppressWarnings("ResultOfMethodCallIgnored") + @Test public void testConfigChangeStringConstructor() throws Exception { checkConfigUpdate(new Log4J2LoggerSupplier() { @Override public Log4J2Logger get(File cfgFile) throws Exception { @@ -69,7 +72,7 @@ public void testConfigChangeStringConstructor() throws Exception { * Check that changing log4j config file causes the logger configuration to be updated. * File-accepting constructor is used. */ - @SuppressWarnings("ResultOfMethodCallIgnored") + @Test public void testConfigChangeFileConstructor() throws Exception { checkConfigUpdate(new Log4J2LoggerSupplier() { @Override public Log4J2Logger get(File cfgFile) throws Exception { @@ -82,7 +85,7 @@ public void testConfigChangeFileConstructor() throws Exception { * Check that changing log4j config file causes the logger configuration to be updated. * File-accepting constructor is used. */ - @SuppressWarnings("ResultOfMethodCallIgnored") + @Test public void testConfigChangeUrlConstructor() throws Exception { checkConfigUpdate(new Log4J2LoggerSupplier() { @Override public Log4J2Logger get(File cfgFile) throws Exception { diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerMarkerTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerMarkerTest.java index 672f5d960974b..22f8c5e3f6e23 100644 --- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerMarkerTest.java +++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerMarkerTest.java @@ -18,13 +18,22 @@ package org.apache.ignite.logger.log4j2; import java.io.File; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * Testing that markers are supported by log4j2 implementation. */ -public class Log4j2LoggerMarkerTest extends TestCase { +@RunWith(JUnit4.class) +public class Log4j2LoggerMarkerTest { /** Path to log4j configuration. */ private static final String LOG_CONFIG = "modules/log4j2/src/test/config/log4j2-markers.xml"; @@ -35,22 +44,21 @@ public class Log4j2LoggerMarkerTest extends TestCase { private static final String LOG_FILTERED = "work/log/filtered.log"; /** */ - @Override protected void setUp() throws Exception { - super.setUp(); - + @Before + public void setUp() { Log4J2Logger.cleanup(); deleteLogs(); } /** */ - @Override protected void tearDown() throws Exception { - super.tearDown(); - + @After + public void tearDown() { deleteLogs(); } /** */ + @Test public void testMarkerFiltering() throws Exception { // create log Log4J2Logger log = new Log4J2Logger(LOG_CONFIG); diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerSelfTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerSelfTest.java index 5f3207ec52e80..4ad4c65bf3237 100644 --- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerSelfTest.java +++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerSelfTest.java @@ -21,7 +21,6 @@ import java.net.URL; import java.util.Collections; import java.util.UUID; -import junit.framework.TestCase; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteLogger; import org.apache.ignite.configuration.IgniteConfiguration; @@ -31,27 +30,36 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * Grid Log4j2 SPI test. */ -public class Log4j2LoggerSelfTest extends TestCase { +@RunWith(JUnit4.class) +public class Log4j2LoggerSelfTest { /** */ private static final String LOG_PATH_TEST = "modules/core/src/test/config/log4j2-test.xml"; /** */ private static final String LOG_PATH_MAIN = "config/ignite-log4j2.xml"; - /** - * @throws Exception If failed. - */ - @Override protected void setUp() throws Exception { + /** */ + @Before + public void setUp() { Log4J2Logger.cleanup(); } /** * @throws Exception If failed. */ + @Test public void testFileConstructor() throws Exception { File xml = GridTestUtils.resolveIgnitePath(LOG_PATH_TEST); @@ -73,6 +81,7 @@ public void testFileConstructor() throws Exception { /** * @throws Exception If failed. */ + @Test public void testUrlConstructor() throws Exception { File xml = GridTestUtils.resolveIgnitePath(LOG_PATH_TEST); @@ -95,6 +104,7 @@ public void testUrlConstructor() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPathConstructor() throws Exception { IgniteLogger log = new Log4J2Logger(LOG_PATH_TEST).getLogger(getClass()); @@ -126,6 +136,7 @@ private void checkLog(IgniteLogger log) { /** * @throws Exception If failed. */ + @Test public void testSystemNodeId() throws Exception { UUID id = UUID.randomUUID(); @@ -139,6 +150,7 @@ public void testSystemNodeId() throws Exception { * * @throws Exception If error occurs. */ + @Test public void testLogFilesTwoNodes() throws Exception { checkOneNode(0); checkOneNode(1); @@ -196,4 +208,4 @@ private static IgniteConfiguration getConfiguration(String igniteInstanceName, S .setConnectorConfiguration(null) .setDiscoverySpi(disco); } -} \ No newline at end of file +} diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerVerboseModeSelfTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerVerboseModeSelfTest.java index c28108ce54914..5c4390838e389 100644 --- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerVerboseModeSelfTest.java +++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2LoggerVerboseModeSelfTest.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.PrintStream; import java.util.Collections; -import junit.framework.TestCase; import org.apache.ignite.Ignite; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.G; @@ -29,20 +28,22 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestUtils; import org.apache.logging.log4j.Level; +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.assertTrue; /** * Grid Log4j2 SPI test. */ -public class Log4j2LoggerVerboseModeSelfTest extends TestCase { +public class Log4j2LoggerVerboseModeSelfTest { /** */ private static final String LOG_PATH_VERBOSE_TEST = "modules/core/src/test/config/log4j2-verbose-test.xml"; - /** - * @throws Exception If failed. - */ - @Override protected void setUp() throws Exception { + /** */ + @Before + public void setUp() { Log4J2Logger.cleanup(); - } /** @@ -50,6 +51,7 @@ public class Log4j2LoggerVerboseModeSelfTest extends TestCase { * * @throws Exception If failed. */ + @Test public void testVerboseMode() throws Exception { final PrintStream backupSysOut = System.out; final PrintStream backupSysErr = System.err; @@ -137,4 +139,4 @@ private static IgniteConfiguration getConfiguration(String igniteInstanceName, S .setConnectorConfiguration(null) .setDiscoverySpi(disco); } -} \ No newline at end of file +} diff --git a/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java b/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java index 0b8cefa50147e..665ae31baac87 100644 --- a/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java +++ b/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java @@ -17,28 +17,31 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.logger.log4j2.Log4j2ConfigUpdateTest; import org.apache.ignite.logger.log4j2.Log4j2LoggerMarkerTest; import org.apache.ignite.logger.log4j2.Log4j2LoggerSelfTest; import org.apache.ignite.logger.log4j2.Log4j2LoggerVerboseModeSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Log4j2 logging tests. */ -public class IgniteLog4j2TestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteLog4j2TestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Log4j2 Logging Test Suite"); - suite.addTestSuite(Log4j2LoggerSelfTest.class); - suite.addTestSuite(Log4j2LoggerVerboseModeSelfTest.class); - suite.addTestSuite(Log4j2LoggerMarkerTest.class); - suite.addTestSuite(Log4j2ConfigUpdateTest.class); + suite.addTest(new JUnit4TestAdapter(Log4j2LoggerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(Log4j2LoggerVerboseModeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(Log4j2LoggerMarkerTest.class)); + suite.addTest(new JUnit4TestAdapter(Log4j2ConfigUpdateTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/mesos/src/test/java/org/apache/ignite/IgniteMesosTestSuite.java b/modules/mesos/src/test/java/org/apache/ignite/IgniteMesosTestSuite.java index af9a37db6a606..886bc9ebdc374 100644 --- a/modules/mesos/src/test/java/org/apache/ignite/IgniteMesosTestSuite.java +++ b/modules/mesos/src/test/java/org/apache/ignite/IgniteMesosTestSuite.java @@ -17,22 +17,25 @@ package org.apache.ignite; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.mesos.IgniteSchedulerSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Apache Mesos integration tests. */ -public class IgniteMesosTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteMesosTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Apache Mesos Integration Test Suite"); - suite.addTest(new TestSuite(IgniteSchedulerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSchedulerSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/mesos/src/test/java/org/apache/ignite/mesos/IgniteSchedulerSelfTest.java b/modules/mesos/src/test/java/org/apache/ignite/mesos/IgniteSchedulerSelfTest.java index 4e485698aa4f7..64117f02989cf 100644 --- a/modules/mesos/src/test/java/org/apache/ignite/mesos/IgniteSchedulerSelfTest.java +++ b/modules/mesos/src/test/java/org/apache/ignite/mesos/IgniteSchedulerSelfTest.java @@ -22,22 +22,27 @@ import java.util.Collections; import java.util.List; import java.util.regex.Pattern; -import junit.framework.TestCase; import org.apache.ignite.mesos.resource.ResourceProvider; import org.apache.mesos.Protos; import org.apache.mesos.SchedulerDriver; +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; /** * Scheduler tests. */ -public class IgniteSchedulerSelfTest extends TestCase { +public class IgniteSchedulerSelfTest { /** */ private IgniteScheduler scheduler; - /** {@inheritDoc} */ - @Override public void setUp() throws Exception { - super.setUp(); - + /** */ + @Before + public void setUp() throws Exception { ClusterProperties clustProp = new ClusterProperties(); scheduler = new IgniteScheduler(clustProp, new ResourceProvider() { @@ -62,6 +67,7 @@ public class IgniteSchedulerSelfTest extends TestCase { /** * @throws Exception If failed. */ + @Test public void testHostRegister() throws Exception { Protos.Offer offer = createOffer("hostname", 4, 1024); @@ -81,6 +87,7 @@ public void testHostRegister() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeclineByCpu() throws Exception { Protos.Offer offer = createOffer("hostname", 4, 1024); @@ -115,6 +122,7 @@ public void testDeclineByCpu() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeclineByMem() throws Exception { Protos.Offer offer = createOffer("hostname", 4, 1024); @@ -149,6 +157,7 @@ public void testDeclineByMem() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeclineByMemCpu() throws Exception { Protos.Offer offer = createOffer("hostname", 1, 1024); @@ -191,6 +200,7 @@ public void testDeclineByMemCpu() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeclineByCpuMinRequirements() throws Exception { Protos.Offer offer = createOffer("hostname", 8, 10240); @@ -211,6 +221,7 @@ public void testDeclineByCpuMinRequirements() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeclineByMemMinRequirements() throws Exception { Protos.Offer offer = createOffer("hostname", 8, 10240); @@ -231,6 +242,7 @@ public void testDeclineByMemMinRequirements() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHosthameConstraint() throws Exception { Protos.Offer offer = createOffer("hostname", 8, 10240); @@ -258,6 +270,7 @@ public void testHosthameConstraint() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPerNode() throws Exception { Protos.Offer offer = createOffer("hostname", 8, 1024); @@ -304,6 +317,7 @@ public void testPerNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIgniteFramework() throws Exception { final String mesosUserValue = "userAAAAA"; final String mesosRoleValue = "role1"; @@ -330,6 +344,7 @@ public void testIgniteFramework() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMesosRoleValidation() throws Exception { List failedRoleValues = Arrays.asList("", ".", "..", "-testRole", "test/Role", "test\\Role", "test Role", null); @@ -511,4 +526,4 @@ public void clear() { return null; } } -} \ No newline at end of file +} diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/preprocessing/package-info.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/preprocessing/package-info.java new file mode 100644 index 0000000000000..77dd980c56a0d --- /dev/null +++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/preprocessing/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/** + * + * Contains exceptions for preprocessing. + */ +package org.apache.ignite.ml.math.exceptions.preprocessing; \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/ignite-status/index.js b/modules/ml/src/main/java/org/apache/ignite/ml/selection/scoring/evaluator/package-info.java similarity index 85% rename from modules/web-console/frontend/app/components/ignite-status/index.js rename to modules/ml/src/main/java/org/apache/ignite/ml/selection/scoring/evaluator/package-info.java index a8520bc876952..c2c7c4307ba5e 100644 --- a/modules/web-console/frontend/app/components/ignite-status/index.js +++ b/modules/ml/src/main/java/org/apache/ignite/ml/selection/scoring/evaluator/package-info.java @@ -15,8 +15,8 @@ * limitations under the License. */ -import angular from 'angular'; -import './style.scss'; - -export default angular - .module('ignite-console.ignite-status', []); +/** + * + * Package for model evaluator classes. + */ +package org.apache.ignite.ml.selection.scoring.evaluator; \ No newline at end of file diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/IgniteMLTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/ml/IgniteMLTestSuite.java index 481e1faa6f993..3c98c1c9290e1 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/IgniteMLTestSuite.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/IgniteMLTestSuite.java @@ -17,6 +17,8 @@ package org.apache.ignite.ml; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; import org.apache.ignite.ml.clustering.ClusteringTestSuite; import org.apache.ignite.ml.common.CommonTestSuite; import org.apache.ignite.ml.composition.CompositionTestSuite; @@ -34,31 +36,38 @@ import org.apache.ignite.ml.svm.SVMTestSuite; import org.apache.ignite.ml.tree.DecisionTreeTestSuite; import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.runners.AllTests; /** * Test suite for all module tests. IMPL NOTE tests in {@code org.apache.ignite.ml.tree.performance} are not * included here because these are intended only for manual execution. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - MathImplMainTestSuite.class, - RegressionsTestSuite.class, - SVMTestSuite.class, - ClusteringTestSuite.class, - DecisionTreeTestSuite.class, - KNNTestSuite.class, - MLPTestSuite.class, - DatasetTestSuite.class, - PipelineTestSuite.class, - PreprocessingTestSuite.class, - GAGridTestSuite.class, - SelectionTestSuite.class, - CompositionTestSuite.class, - EnvironmentTestSuite.class, - StructuresTestSuite.class, - CommonTestSuite.class -}) +@RunWith(AllTests.class) public class IgniteMLTestSuite { - // No-op. + /** */ + public static TestSuite suite() { + TestSuite suite = new TestSuite(IgniteMLTestSuite.class.getSimpleName()); + + /** JUnit 4 tests. */ + suite.addTest(new JUnit4TestAdapter(MathImplMainTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(RegressionsTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(SVMTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(ClusteringTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(KNNTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(PipelineTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(PreprocessingTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(GAGridTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(CompositionTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(EnvironmentTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(StructuresTestSuite.class)); + suite.addTest(new JUnit4TestAdapter(CommonTestSuite.class)); + + /** JUnit 3 tests. */ + suite.addTest(DecisionTreeTestSuite.suite()); + suite.addTest(MLPTestSuite.suite()); + suite.addTest(DatasetTestSuite.suite()); + suite.addTest(SelectionTestSuite.suite()); + + return suite; + } } diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/dataset/DatasetTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/ml/dataset/DatasetTestSuite.java index babddfb168c00..8ab41c5ac2882 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/dataset/DatasetTestSuite.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/dataset/DatasetTestSuite.java @@ -17,6 +17,8 @@ package org.apache.ignite.ml.dataset; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; import org.apache.ignite.ml.dataset.feature.ObjectHistogramTest; import org.apache.ignite.ml.dataset.impl.cache.CacheBasedDatasetBuilderTest; import org.apache.ignite.ml.dataset.impl.cache.CacheBasedDatasetTest; @@ -28,24 +30,29 @@ import org.apache.ignite.ml.dataset.primitive.SimpleDatasetTest; import org.apache.ignite.ml.dataset.primitive.SimpleLabeledDatasetTest; import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.runners.AllTests; /** * Test suite for all tests located in org.apache.ignite.ml.dataset.* package. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - DatasetWrapperTest.class, - ComputeUtilsTest.class, - DatasetAffinityFunctionWrapperTest.class, - PartitionDataStorageTest.class, - CacheBasedDatasetBuilderTest.class, - CacheBasedDatasetTest.class, - LocalDatasetBuilderTest.class, - SimpleDatasetTest.class, - SimpleLabeledDatasetTest.class, - ObjectHistogramTest.class -}) +@RunWith(AllTests.class) public class DatasetTestSuite { - // No-op. + /** */ + public static TestSuite suite() { + TestSuite suite = new TestSuite(DatasetTestSuite.class.getSimpleName()); + + suite.addTest(new JUnit4TestAdapter(DatasetWrapperTest.class)); + suite.addTest(new JUnit4TestAdapter(DatasetAffinityFunctionWrapperTest.class)); + suite.addTest(new JUnit4TestAdapter(PartitionDataStorageTest.class)); + suite.addTest(new JUnit4TestAdapter(LocalDatasetBuilderTest.class)); + suite.addTest(new JUnit4TestAdapter(SimpleDatasetTest.class)); + suite.addTest(new JUnit4TestAdapter(SimpleLabeledDatasetTest.class)); + suite.addTest(new JUnit4TestAdapter(DatasetWrapperTest.class)); + suite.addTest(new JUnit4TestAdapter(ObjectHistogramTest.class)); + suite.addTest(new JUnit4TestAdapter(ComputeUtilsTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheBasedDatasetBuilderTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheBasedDatasetTest.class)); + + return suite; + } } diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/CacheBasedDatasetBuilderTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/CacheBasedDatasetBuilderTest.java index 1cf6dbfb0f1b5..82d9259c133c3 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/CacheBasedDatasetBuilderTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/CacheBasedDatasetBuilderTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.ml.dataset.UpstreamEntry; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link CacheBasedDatasetBuilder}. */ +@RunWith(JUnit4.class) public class CacheBasedDatasetBuilderTest extends GridCommonAbstractTest { /** Number of nodes in grid. */ private static final int NODE_COUNT = 10; @@ -61,6 +65,7 @@ public class CacheBasedDatasetBuilderTest extends GridCommonAbstractTest { /** * Tests that partitions of the dataset cache are placed on the same nodes as upstream cache. */ + @Test public void testBuild() { IgniteCache upstreamCache = createTestCache(100, 10); CacheBasedDatasetBuilder builder = new CacheBasedDatasetBuilder<>(ignite, upstreamCache); @@ -89,6 +94,7 @@ public void testBuild() { /** * Tests that predicate works correctly. */ + @Test public void testBuildWithPredicate() { CacheConfiguration upstreamCacheConfiguration = new CacheConfiguration<>(); upstreamCacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 1)); diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/CacheBasedDatasetTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/CacheBasedDatasetTest.java index a89253036ed89..374449885bde7 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/CacheBasedDatasetTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/CacheBasedDatasetTest.java @@ -40,10 +40,14 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.ml.dataset.primitive.data.SimpleDatasetData; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link CacheBasedDataset}. */ +@RunWith(JUnit4.class) public class CacheBasedDatasetTest extends GridCommonAbstractTest { /** Number of nodes in grid. */ private static final int NODE_COUNT = 4; @@ -75,6 +79,7 @@ public class CacheBasedDatasetTest extends GridCommonAbstractTest { * computations on dataset. Reservation means that partitions won't be unloaded from the node before computation is * completed. */ + @Test public void testPartitionExchangeDuringComputeCall() { int partitions = 4; @@ -130,6 +135,7 @@ public void testPartitionExchangeDuringComputeCall() { * computations on dataset. Reservation means that partitions won't be unloaded from the node before computation is * completed. */ + @Test public void testPartitionExchangeDuringComputeWithCtxCall() { int partitions = 4; diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/util/ComputeUtilsTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/util/ComputeUtilsTest.java index 952fc435cefde..e879f93f0a827 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/util/ComputeUtilsTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/dataset/impl/cache/util/ComputeUtilsTest.java @@ -34,6 +34,7 @@ import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.ml.dataset.UpstreamEntry; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; /** * Tests for {@link ComputeUtils}. @@ -57,7 +58,7 @@ public class ComputeUtilsTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + @Override protected void beforeTest() { /* Grid instance. */ ignite = grid(NODE_COUNT); ignite.configuration().setPeerClassLoadingEnabled(true); @@ -67,6 +68,7 @@ public class ComputeUtilsTest extends GridCommonAbstractTest { /** * Tests that in case two caches maintain their partitions on different nodes, affinity call won't be completed. */ + @Test public void testAffinityCallWithRetriesNegative() { ClusterNode node1 = grid(1).cluster().localNode(); ClusterNode node2 = grid(2).cluster().localNode(); @@ -108,6 +110,7 @@ public void testAffinityCallWithRetriesNegative() { /** * Test that in case two caches maintain their partitions on the same node, affinity call will be completed. */ + @Test public void testAffinityCallWithRetriesPositive() { ClusterNode node = grid(1).cluster().localNode(); @@ -147,6 +150,7 @@ public void testAffinityCallWithRetriesPositive() { /** * Tests {@code getData()} method. */ + @Test public void testGetData() { ClusterNode node = grid(1).cluster().localNode(); @@ -205,6 +209,7 @@ public void testGetData() { /** * Tests {@code initContext()} method. */ + @Test public void testInitContext() { ClusterNode node = grid(1).cluster().localNode(); @@ -259,7 +264,7 @@ private static class TestPartitionData implements AutoCloseable { } /** {@inheritDoc} */ - @Override public void close() throws Exception { + @Override public void close() { // Do nothing, GC will clean up. } } diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledVectorSetTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledVectorSetTest.java index 2303e96f0de37..27c1192a5d2b1 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledVectorSetTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/knn/LabeledVectorSetTest.java @@ -277,6 +277,7 @@ public void testSetLabelInvalid() { } /** */ + @Test @Override public void testExternalization() { double[][] mtx = new double[][] { diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/nn/MLPTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/ml/nn/MLPTestSuite.java index 3f98ba51a95da..58eea8da605a5 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/nn/MLPTestSuite.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/nn/MLPTestSuite.java @@ -17,19 +17,25 @@ package org.apache.ignite.ml.nn; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.runners.AllTests; /** * Test suite for multilayer perceptrons. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - MLPTest.class, - MLPTrainerTest.class, - MLPTrainerIntegrationTest.class, - LossFunctionsTest.class -}) +@RunWith(AllTests.class) public class MLPTestSuite { - // No-op. + /** */ + public static TestSuite suite() { + TestSuite suite = new TestSuite(MLPTestSuite.class.getSimpleName()); + + suite.addTest(new JUnit4TestAdapter(MLPTest.class)); + suite.addTest(new JUnit4TestAdapter(MLPTrainerTest.class)); + suite.addTest(new JUnit4TestAdapter(LossFunctionsTest.class)); + suite.addTest(new JUnit4TestAdapter(MLPTrainerIntegrationTest.class)); + + return suite; + } } diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/nn/MLPTrainerIntegrationTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/nn/MLPTrainerIntegrationTest.java index 3521cb6b1b444..ff6754abe2eca 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/nn/MLPTrainerIntegrationTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/nn/MLPTrainerIntegrationTest.java @@ -39,10 +39,14 @@ import org.apache.ignite.ml.optimization.updatecalculators.SimpleGDParameterUpdate; import org.apache.ignite.ml.optimization.updatecalculators.SimpleGDUpdateCalculator; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link MLPTrainer} that require to start the whole Ignite infrastructure. */ +@RunWith(JUnit4.class) public class MLPTrainerIntegrationTest extends GridCommonAbstractTest { /** Number of nodes in grid */ private static final int NODE_COUNT = 3; @@ -64,7 +68,7 @@ public class MLPTrainerIntegrationTest extends GridCommonAbstractTest { /** * {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + @Override protected void beforeTest() { /* Grid instance. */ ignite = grid(NODE_COUNT); ignite.configuration().setPeerClassLoadingEnabled(true); @@ -74,6 +78,7 @@ public class MLPTrainerIntegrationTest extends GridCommonAbstractTest { /** * Test 'XOR' operation training with {@link SimpleGDUpdateCalculator}. */ + @Test public void testXORSimpleGD() { xorTest(new UpdatesStrategy<>( new SimpleGDUpdateCalculator(0.3), @@ -85,6 +90,7 @@ public void testXORSimpleGD() { /** * Test 'XOR' operation training with {@link RPropUpdateCalculator}. */ + @Test public void testXORRProp() { xorTest(new UpdatesStrategy<>( new RPropUpdateCalculator(), @@ -96,6 +102,7 @@ public void testXORRProp() { /** * Test 'XOR' operation training with {@link NesterovUpdateCalculator}. */ + @Test public void testXORNesterov() { xorTest(new UpdatesStrategy<>( new NesterovUpdateCalculator(0.1, 0.7), diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/nn/performance/MLPTrainerMnistIntegrationTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/nn/performance/MLPTrainerMnistIntegrationTest.java index bd31b196b120f..f8792a5cd42f6 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/nn/performance/MLPTrainerMnistIntegrationTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/nn/performance/MLPTrainerMnistIntegrationTest.java @@ -36,10 +36,14 @@ import org.apache.ignite.ml.optimization.updatecalculators.RPropUpdateCalculator; import org.apache.ignite.ml.util.MnistUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests {@link MLPTrainer} on the MNIST dataset that require to start the whole Ignite infrastructure. */ +@RunWith(JUnit4.class) public class MLPTrainerMnistIntegrationTest extends GridCommonAbstractTest { /** Number of nodes in grid */ private static final int NODE_COUNT = 3; @@ -61,7 +65,7 @@ public class MLPTrainerMnistIntegrationTest extends GridCommonAbstractTest { /** * {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + @Override protected void beforeTest() { /* Grid instance. */ ignite = grid(NODE_COUNT); ignite.configuration().setPeerClassLoadingEnabled(true); @@ -69,6 +73,7 @@ public class MLPTrainerMnistIntegrationTest extends GridCommonAbstractTest { } /** Tests on the MNIST dataset. */ + @Test public void testMNIST() throws IOException { int featCnt = 28 * 28; int hiddenNeuronsCnt = 100; diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/selection/SelectionTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/ml/selection/SelectionTestSuite.java index 21c605b737fd5..e2f8feb9fee92 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/selection/SelectionTestSuite.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/selection/SelectionTestSuite.java @@ -17,6 +17,8 @@ package org.apache.ignite.ml.selection; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; import org.apache.ignite.ml.selection.cv.CrossValidationTest; import org.apache.ignite.ml.selection.paramgrid.ParameterSetGeneratorTest; import org.apache.ignite.ml.selection.scoring.cursor.CacheBasedLabelPairCursorTest; @@ -29,25 +31,29 @@ import org.apache.ignite.ml.selection.split.TrainTestDatasetSplitterTest; import org.apache.ignite.ml.selection.split.mapper.SHA256UniformMapperTest; import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.runners.AllTests; /** * Test suite for all tests located in org.apache.ignite.ml.selection.* package. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - CrossValidationTest.class, - EvaluatorTest.class, - ParameterSetGeneratorTest.class, - CacheBasedLabelPairCursorTest.class, - LocalLabelPairCursorTest.class, - AccuracyTest.class, - PrecisionTest.class, - RecallTest.class, - FmeasureTest.class, - SHA256UniformMapperTest.class, - TrainTestDatasetSplitterTest.class -}) +@RunWith(AllTests.class) public class SelectionTestSuite { - // No-op. + /** */ + public static TestSuite suite() { + TestSuite suite = new TestSuite(SelectionTestSuite.class.getSimpleName()); + + suite.addTest(new JUnit4TestAdapter(CrossValidationTest.class)); + suite.addTest(new JUnit4TestAdapter(ParameterSetGeneratorTest.class)); + suite.addTest(new JUnit4TestAdapter(LocalLabelPairCursorTest.class)); + suite.addTest(new JUnit4TestAdapter(AccuracyTest.class)); + suite.addTest(new JUnit4TestAdapter(PrecisionTest.class)); + suite.addTest(new JUnit4TestAdapter(RecallTest.class)); + suite.addTest(new JUnit4TestAdapter(FmeasureTest.class)); + suite.addTest(new JUnit4TestAdapter(SHA256UniformMapperTest.class)); + suite.addTest(new JUnit4TestAdapter(TrainTestDatasetSplitterTest.class)); + suite.addTest(new JUnit4TestAdapter(EvaluatorTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheBasedLabelPairCursorTest.class)); + + return suite; + } } diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/selection/scoring/cursor/CacheBasedLabelPairCursorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/selection/scoring/cursor/CacheBasedLabelPairCursorTest.java index 8d020770a70cc..33b0eed351451 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/selection/scoring/cursor/CacheBasedLabelPairCursorTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/selection/scoring/cursor/CacheBasedLabelPairCursorTest.java @@ -24,10 +24,14 @@ import org.apache.ignite.ml.math.primitives.vector.VectorUtils; import org.apache.ignite.ml.selection.scoring.LabelPair; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link CacheBasedLabelPairCursor}. */ +@RunWith(JUnit4.class) public class CacheBasedLabelPairCursorTest extends GridCommonAbstractTest { /** Number of nodes in grid. */ private static final int NODE_COUNT = 4; @@ -55,6 +59,7 @@ public class CacheBasedLabelPairCursorTest extends GridCommonAbstractTest { } /** */ + @Test public void testIterate() { IgniteCache data = ignite.createCache(UUID.randomUUID().toString()); diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/selection/scoring/evaluator/EvaluatorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/selection/scoring/evaluator/EvaluatorTest.java index 6f7aa366a50e0..58e30b2d51284 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/selection/scoring/evaluator/EvaluatorTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/selection/scoring/evaluator/EvaluatorTest.java @@ -47,6 +47,9 @@ import org.apache.ignite.ml.tree.DecisionTreeNode; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.thread.IgniteThread; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.junit.Assert.assertArrayEquals; @@ -54,6 +57,7 @@ * Tests for {@link Evaluator} that require to start the whole Ignite infrastructure. IMPL NOTE based on * Step_8_CV_with_Param_Grid example. */ +@RunWith(JUnit4.class) public class EvaluatorTest extends GridCommonAbstractTest { /** Number of nodes in grid */ private static final int NODE_COUNT = 3; @@ -83,6 +87,7 @@ public class EvaluatorTest extends GridCommonAbstractTest { } /** */ + @Test public void testBasic() throws InterruptedException { AtomicReference actualAccuracy = new AtomicReference<>(null); AtomicReference actualAccuracy2 = new AtomicReference<>(null); @@ -129,6 +134,7 @@ public void testBasic() throws InterruptedException { } /** */ + @Test public void testBasic2() throws InterruptedException { AtomicReference actualAccuracy = new AtomicReference<>(null); AtomicReference actualAccuracy2 = new AtomicReference<>(null); @@ -162,6 +168,7 @@ public void testBasic2() throws InterruptedException { } /** */ + @Test public void testBasic3() throws InterruptedException { AtomicReference actualAccuracy = new AtomicReference<>(null); AtomicReference actualAccuracy2 = new AtomicReference<>(null); diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeClassificationTrainerIntegrationTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeClassificationTrainerIntegrationTest.java index aadc8a76a0d33..f7f13f25b1f20 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeClassificationTrainerIntegrationTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeClassificationTrainerIntegrationTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.ml.math.primitives.vector.VectorUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link DecisionTreeClassificationTrainer} that require to start the whole Ignite infrastructure. */ +@RunWith(JUnit4.class) public class DecisionTreeClassificationTrainerIntegrationTest extends GridCommonAbstractTest { /** Number of nodes in grid */ private static final int NODE_COUNT = 3; @@ -51,7 +55,7 @@ public class DecisionTreeClassificationTrainerIntegrationTest extends GridCommon /** * {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + @Override protected void beforeTest() { /* Grid instance. */ ignite = grid(NODE_COUNT); ignite.configuration().setPeerClassLoadingEnabled(true); @@ -59,6 +63,7 @@ public class DecisionTreeClassificationTrainerIntegrationTest extends GridCommon } /** */ + @Test public void testFit() { int size = 100; diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeRegressionTrainerIntegrationTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeRegressionTrainerIntegrationTest.java index a190685a8475b..9b25ce075c0f7 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeRegressionTrainerIntegrationTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeRegressionTrainerIntegrationTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.ml.math.primitives.vector.VectorUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link DecisionTreeRegressionTrainer} that require to start the whole Ignite infrastructure. */ +@RunWith(JUnit4.class) public class DecisionTreeRegressionTrainerIntegrationTest extends GridCommonAbstractTest { /** Number of nodes in grid */ private static final int NODE_COUNT = 3; @@ -51,7 +55,7 @@ public class DecisionTreeRegressionTrainerIntegrationTest extends GridCommonAbst /** * {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + @Override protected void beforeTest() { /* Grid instance. */ ignite = grid(NODE_COUNT); ignite.configuration().setPeerClassLoadingEnabled(true); @@ -59,6 +63,7 @@ public class DecisionTreeRegressionTrainerIntegrationTest extends GridCommonAbst } /** */ + @Test public void testFit() { int size = 100; diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeTestSuite.java b/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeTestSuite.java index 2cbb486c3df5f..7c984c1002fc3 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeTestSuite.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/tree/DecisionTreeTestSuite.java @@ -17,6 +17,8 @@ package org.apache.ignite.ml.tree; +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; import org.apache.ignite.ml.tree.data.DecisionTreeDataTest; import org.apache.ignite.ml.tree.impurity.gini.GiniImpurityMeasureCalculatorTest; import org.apache.ignite.ml.tree.impurity.gini.GiniImpurityMeasureTest; @@ -25,24 +27,29 @@ import org.apache.ignite.ml.tree.impurity.util.SimpleStepFunctionCompressorTest; import org.apache.ignite.ml.tree.impurity.util.StepFunctionTest; import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.runners.AllTests; /** * Test suite for all tests located in {@link org.apache.ignite.ml.tree} package. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - DecisionTreeClassificationTrainerTest.class, - DecisionTreeRegressionTrainerTest.class, - DecisionTreeClassificationTrainerIntegrationTest.class, - DecisionTreeRegressionTrainerIntegrationTest.class, - DecisionTreeDataTest.class, - GiniImpurityMeasureCalculatorTest.class, - GiniImpurityMeasureTest.class, - MSEImpurityMeasureCalculatorTest.class, - MSEImpurityMeasureTest.class, - StepFunctionTest.class, - SimpleStepFunctionCompressorTest.class -}) +@RunWith(AllTests.class) public class DecisionTreeTestSuite { + /** */ + public static TestSuite suite() { + TestSuite suite = new TestSuite(DecisionTreeTestSuite.class.getSimpleName()); + + suite.addTest(new JUnit4TestAdapter(DecisionTreeClassificationTrainerTest.class)); + suite.addTest(new JUnit4TestAdapter(DecisionTreeRegressionTrainerTest.class)); + suite.addTest(new JUnit4TestAdapter(DecisionTreeDataTest.class)); + suite.addTest(new JUnit4TestAdapter(GiniImpurityMeasureCalculatorTest.class)); + suite.addTest(new JUnit4TestAdapter(GiniImpurityMeasureTest.class)); + suite.addTest(new JUnit4TestAdapter(MSEImpurityMeasureCalculatorTest.class)); + suite.addTest(new JUnit4TestAdapter(MSEImpurityMeasureTest.class)); + suite.addTest(new JUnit4TestAdapter(StepFunctionTest.class)); + suite.addTest(new JUnit4TestAdapter(SimpleStepFunctionCompressorTest.class)); + suite.addTest(new JUnit4TestAdapter(DecisionTreeRegressionTrainerIntegrationTest.class)); + suite.addTest(new JUnit4TestAdapter(DecisionTreeClassificationTrainerIntegrationTest.class)); + + return suite; + } } diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/tree/performance/DecisionTreeMNISTIntegrationTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/tree/performance/DecisionTreeMNISTIntegrationTest.java index ca513ed432adb..e0cdc96348f25 100644 --- a/modules/ml/src/test/java/org/apache/ignite/ml/tree/performance/DecisionTreeMNISTIntegrationTest.java +++ b/modules/ml/src/test/java/org/apache/ignite/ml/tree/performance/DecisionTreeMNISTIntegrationTest.java @@ -31,11 +31,15 @@ import org.apache.ignite.ml.tree.impurity.util.SimpleStepFunctionCompressor; import org.apache.ignite.ml.util.MnistUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests {@link DecisionTreeClassificationTrainer} on the MNIST dataset that require to start the whole Ignite * infrastructure. For manual run. */ +@RunWith(JUnit4.class) public class DecisionTreeMNISTIntegrationTest extends GridCommonAbstractTest { /** Number of nodes in grid */ private static final int NODE_COUNT = 3; @@ -57,7 +61,7 @@ public class DecisionTreeMNISTIntegrationTest extends GridCommonAbstractTest { /** * {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { + @Override protected void beforeTest() { /* Grid instance. */ ignite = grid(NODE_COUNT); ignite.configuration().setPeerClassLoadingEnabled(true); @@ -65,6 +69,7 @@ public class DecisionTreeMNISTIntegrationTest extends GridCommonAbstractTest { } /** Tests on the MNIST dataset. For manual run. */ + @Test public void testMNIST() throws IOException { CacheConfiguration trainingSetCacheCfg = new CacheConfiguration<>(); trainingSetCacheCfg.setAffinity(new RendezvousAffinityFunction(false, 10)); diff --git a/modules/mqtt/src/test/java/org/apache/ignite/stream/mqtt/IgniteMqttStreamerTest.java b/modules/mqtt/src/test/java/org/apache/ignite/stream/mqtt/IgniteMqttStreamerTest.java index d8c15eae0256f..029ff6e5c7e04 100644 --- a/modules/mqtt/src/test/java/org/apache/ignite/stream/mqtt/IgniteMqttStreamerTest.java +++ b/modules/mqtt/src/test/java/org/apache/ignite/stream/mqtt/IgniteMqttStreamerTest.java @@ -53,14 +53,16 @@ import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; -import org.junit.After; -import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; /** * Test for {@link MqttStreamer}. */ +@RunWith(JUnit4.class) public class IgniteMqttStreamerTest extends GridCommonAbstractTest { /** The test data. */ private static final Map TEST_DATA = new HashMap<>(); @@ -105,9 +107,8 @@ public IgniteMqttStreamerTest() { /** * @throws Exception If failed. */ - @Before @SuppressWarnings("unchecked") - public void beforeTest() throws Exception { + @Override public void beforeTest() throws Exception { grid().getOrCreateCache(defaultCacheConfiguration()); // find an available local port @@ -153,8 +154,7 @@ public void beforeTest() throws Exception { /** * @throws Exception If failed. */ - @After - public void afterTest() throws Exception { + @Override public void afterTest() throws Exception { try { streamer.stop(); } @@ -173,6 +173,7 @@ public void afterTest() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectDisconnect() throws Exception { // configure streamer streamer.setSingleTupleExtractor(singleTupleExtractor()); @@ -194,6 +195,7 @@ public void testConnectDisconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionStatusWithBrokerDisconnection() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-2255"); @@ -225,6 +227,7 @@ public void testConnectionStatusWithBrokerDisconnection() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingleTopic_NoQoS_OneEntryPerMessage() throws Exception { // configure streamer streamer.setSingleTupleExtractor(singleTupleExtractor()); @@ -247,6 +250,7 @@ public void testSingleTopic_NoQoS_OneEntryPerMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleTopics_NoQoS_OneEntryPerMessage() throws Exception { // configure streamer streamer.setSingleTupleExtractor(singleTupleExtractor()); @@ -273,6 +277,7 @@ public void testMultipleTopics_NoQoS_OneEntryPerMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingleTopic_NoQoS_MultipleEntriesOneMessage() throws Exception { // configure streamer streamer.setMultipleTupleExtractor(multipleTupleExtractor()); @@ -295,6 +300,7 @@ public void testSingleTopic_NoQoS_MultipleEntriesOneMessage() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleTopics_NoQoS_MultipleEntriesOneMessage() throws Exception { // configure streamer streamer.setMultipleTupleExtractor(multipleTupleExtractor()); @@ -321,6 +327,7 @@ public void testMultipleTopics_NoQoS_MultipleEntriesOneMessage() throws Exceptio /** * @throws Exception If failed. */ + @Test public void testSingleTopic_NoQoS_ConnectOptions_Durable() throws Exception { // configure streamer streamer.setSingleTupleExtractor(singleTupleExtractor()); @@ -362,6 +369,7 @@ public void testSingleTopic_NoQoS_ConnectOptions_Durable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingleTopic_NoQoS_Reconnect() throws Exception { // configure streamer streamer.setSingleTupleExtractor(singleTupleExtractor()); @@ -408,6 +416,7 @@ public void testSingleTopic_NoQoS_Reconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingleTopic_NoQoS_RetryOnce() throws Exception { // configure streamer streamer.setSingleTupleExtractor(singleTupleExtractor()); @@ -447,6 +456,7 @@ public void testSingleTopic_NoQoS_RetryOnce() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleTopics_MultipleQoS_OneEntryPerMessage() throws Exception { // configure streamer streamer.setSingleTupleExtractor(singleTupleExtractor()); @@ -474,6 +484,7 @@ public void testMultipleTopics_MultipleQoS_OneEntryPerMessage() throws Exception /** * @throws Exception If failed. */ + @Test public void testMultipleTopics_MultipleQoS_Mismatch() throws Exception { // configure streamer streamer.setSingleTupleExtractor(singleTupleExtractor()); diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h index 29e36f525d90b..cbcc10ce6ab58 100644 --- a/modules/platforms/cpp/common/include/ignite/common/utils.h +++ b/modules/platforms/cpp/common/include/ignite/common/utils.h @@ -548,6 +548,62 @@ namespace ignite return BoundInstance(instance, mfunc); } + /** + * Method guard class template. + * + * Upon destruction calls provided method on provided class instance. + * + * @tparam T Value type. + */ + template + class MethodGuard + { + public: + /** Value type. */ + typedef T ValueType; + + /** Mehtod type. */ + typedef void (ValueType::*MethodType)(); + + /** + * Constructor. + * + * @param val Instance, to call method on. + * @param method Method to call. + */ + MethodGuard(ValueType* val, MethodType method) : + val(val), + method(method) + { + // No-op. + } + + /** + * Destructor. + */ + ~MethodGuard() + { + if (val && method) + (val->*method)(); + } + + /** + * Release control over object. + */ + void Release() + { + val = 0; + method = 0; + } + + private: + /** Instance, to call method on. */ + ValueType* val; + + /** Method to call. */ + MethodType method; + }; + /** * Get dynamic library full name. * @param name Name without extension. diff --git a/modules/platforms/cpp/core/src/ignition.cpp b/modules/platforms/cpp/core/src/ignition.cpp index 7d90a52c77682..087d42d04e2c7 100644 --- a/modules/platforms/cpp/core/src/ignition.cpp +++ b/modules/platforms/cpp/core/src/ignition.cpp @@ -75,8 +75,7 @@ namespace ignite * Constructor. */ JvmOptions() : - size(0), - opts(0) + opts() { // No-op. } @@ -100,39 +99,43 @@ namespace ignite { Deinit(); - size = 3 + static_cast(cfg.jvmOpts.size()); + const size_t REQ_OPTS_CNT = 4; + const size_t JAVA9_OPTS_CNT = 6; - if (!home.empty()) - ++size; - - // Brackets '()' here guarantee for the array to be zeroed. - // Important to avoid crash in case of exception. - opts = new char*[size](); - - int idx = 0; + opts.reserve(cfg.jvmOpts.size() + REQ_OPTS_CNT + JAVA9_OPTS_CNT); // 1. Set classpath. std::string cpFull = "-Djava.class.path=" + cp; - opts[idx++] = CopyChars(cpFull.c_str()); + opts.push_back(CopyChars(cpFull.c_str())); // 2. Set home. if (!home.empty()) { std::string homeFull = "-DIGNITE_HOME=" + home; - opts[idx++] = CopyChars(homeFull.c_str()); + opts.push_back(CopyChars(homeFull.c_str())); } // 3. Set Xms, Xmx. std::string xmsStr = JvmMemoryString("-Xms", cfg.jvmInitMem); std::string xmxStr = JvmMemoryString("-Xmx", cfg.jvmMaxMem); - opts[idx++] = CopyChars(xmsStr.c_str()); - opts[idx++] = CopyChars(xmxStr.c_str()); + opts.push_back(CopyChars(xmsStr.c_str())); + opts.push_back(CopyChars(xmxStr.c_str())); // 4. Set the rest options. for (std::list::const_iterator i = cfg.jvmOpts.begin(); i != cfg.jvmOpts.end(); ++i) - opts[idx++] = CopyChars(i->c_str()); + opts.push_back(CopyChars(i->c_str())); + + // Adding options for Java 9 or later + if (IsJava9OrLater()) { + opts.push_back(CopyChars("--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED")); + opts.push_back(CopyChars("--add-exports=java.base/sun.nio.ch=ALL-UNNAMED")); + opts.push_back(CopyChars("--add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED")); + opts.push_back(CopyChars("--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED")); + opts.push_back(CopyChars("--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED")); + opts.push_back(CopyChars("--illegal-access=permit")); + } } /** @@ -140,13 +143,10 @@ namespace ignite */ void Deinit() { - if (opts) - { - for (int i = 0; i < size; ++i) - ReleaseChars(opts[i]); + for (size_t i = 0; i < opts.size(); ++i) + ReleaseChars(opts[i]); - delete[] opts; - } + opts.clear(); } /** @@ -154,9 +154,9 @@ namespace ignite * * @return Built options */ - char** GetOpts() const + char** GetOpts() { - return opts; + return &opts[0]; } /** @@ -166,15 +166,12 @@ namespace ignite */ int GetSize() const { - return size; + return static_cast(opts.size()); } private: - /** Size */ - int size; - /** Options array. */ - char** opts; + std::vector opts; }; Ignite Ignition::Start(const IgniteConfiguration& cfg) diff --git a/modules/platforms/cpp/jni/Makefile.am b/modules/platforms/cpp/jni/Makefile.am index 56eaa6c844f11..da107a2bdadf8 100644 --- a/modules/platforms/cpp/jni/Makefile.am +++ b/modules/platforms/cpp/jni/Makefile.am @@ -39,6 +39,7 @@ AM_CXXFLAGS = \ libignite_jni_la_LIBADD = \ -L$(JAVA_HOME)/jre/lib/amd64/server \ + -L$(JAVA_HOME)/lib/server \ @top_srcdir@/common/libignite-common.la libignite_jni_la_LDFLAGS = \ diff --git a/modules/platforms/cpp/jni/include/ignite/jni/java.h b/modules/platforms/cpp/jni/include/ignite/jni/java.h index c713e811ad733..196d941e49d03 100644 --- a/modules/platforms/cpp/jni/include/ignite/jni/java.h +++ b/modules/platforms/cpp/jni/include/ignite/jni/java.h @@ -114,6 +114,13 @@ namespace ignite typedef long long(JNICALL *InLongOutLongHandler)(void* target, int type, long long val); typedef long long(JNICALL *InLongLongLongObjectOutLongHandler)(void* target, int type, long long val1, long long val2, long long val3, void* arg); + /** + * Is Java 9 or later is used. + * + * @return true if the Java 9 or later is in use. + */ + bool IGNITE_IMPORT_EXPORT IsJava9OrLater(); + /** * JNI handlers holder. */ diff --git a/modules/platforms/cpp/jni/os/linux/src/utils.cpp b/modules/platforms/cpp/jni/os/linux/src/utils.cpp index 52e4097b67f51..0fda52dbed061 100644 --- a/modules/platforms/cpp/jni/os/linux/src/utils.cpp +++ b/modules/platforms/cpp/jni/os/linux/src/utils.cpp @@ -37,7 +37,8 @@ namespace ignite namespace jni { const char* JAVA_HOME = "JAVA_HOME"; - const char* JAVA_DLL = "/jre/lib/amd64/server/libjvm.so"; + const char* JAVA_DLL1 = "/jre/lib/amd64/server/libjvm.so"; + const char* JAVA_DLL2 = "/lib/server/libjvm.so"; const char* IGNITE_HOME = "IGNITE_HOME"; @@ -311,7 +312,12 @@ namespace ignite if (!javaEnv.empty()) { - std::string javaDll = javaEnv + JAVA_DLL; + std::string javaDll = javaEnv + JAVA_DLL1; + + if (FileExists(javaDll)) + return javaDll; + + javaDll = javaEnv + JAVA_DLL2; if (FileExists(javaDll)) return javaDll; diff --git a/modules/platforms/cpp/jni/src/java.cpp b/modules/platforms/cpp/jni/src/java.cpp index ac4ba6345d5c2..9a07a5f3af6c8 100644 --- a/modules/platforms/cpp/jni/src/java.cpp +++ b/modules/platforms/cpp/jni/src/java.cpp @@ -23,10 +23,15 @@ #include #include -#include "ignite/jni/utils.h" -#include "ignite/common/concurrent.h" -#include "ignite/jni/java.h" +#include +#include +#include #include +#include + +#ifndef JNI_VERSION_9 +#define JNI_VERSION_9 0x00090000 +#endif // JNI_VERSION_9 #define IGNITE_SAFE_PROC_NO_ARG(jniEnv, envPtr, type, field) { \ JniHandlers* hnds = reinterpret_cast(envPtr); \ @@ -94,7 +99,18 @@ namespace ignite { namespace java { - namespace gcc = ignite::common::concurrent; + namespace icc = ignite::common::concurrent; + + bool IGNITE_IMPORT_EXPORT IsJava9OrLater() + { + JavaVMInitArgs args; + + memset(&args, 0, sizeof(args)); + + args.version = JNI_VERSION_9; + + return JNI_GetDefaultJavaVMInitArgs(&args) == JNI_OK; + } /* --- Startup exception. --- */ class JvmException : public std::exception { @@ -114,26 +130,6 @@ namespace ignite } }; - /** - * Heloper function to copy characters. - * - * @param src Source. - * @return Result. - */ - char* CopyChars(const char* src) - { - if (src) - { - size_t len = strlen(src); - char* dest = new char[len + 1]; - strcpy(dest, src); - *(dest + len) = 0; - return dest; - } - else - return NULL; - } - JniErrorInfo::JniErrorInfo() : code(IGNITE_JNI_ERR_SUCCESS), errCls(NULL), errMsg(NULL) { // No-op. @@ -141,14 +137,14 @@ namespace ignite JniErrorInfo::JniErrorInfo(int code, const char* errCls, const char* errMsg) : code(code) { - this->errCls = CopyChars(errCls); - this->errMsg = CopyChars(errMsg); + this->errCls = common::CopyChars(errCls); + this->errMsg = common::CopyChars(errMsg); } JniErrorInfo::JniErrorInfo(const JniErrorInfo& other) : code(other.code) { - this->errCls = CopyChars(other.errCls); - this->errMsg = CopyChars(other.errMsg); + this->errCls = common::CopyChars(other.errCls); + this->errMsg = common::CopyChars(other.errMsg); } JniErrorInfo& JniErrorInfo::operator=(const JniErrorInfo& other) @@ -159,17 +155,9 @@ namespace ignite JniErrorInfo tmp(other); // 2. Swap with temp. - int code0 = code; - char* errCls0 = errCls; - char* errMsg0 = errMsg; - - code = tmp.code; - errCls = tmp.errCls; - errMsg = tmp.errMsg; - - tmp.code = code0; - tmp.errCls = errCls0; - tmp.errMsg = errMsg0; + std::swap(code, tmp.code); + std::swap(errCls, tmp.errCls); + std::swap(errMsg, tmp.errMsg); } return *this; @@ -177,11 +165,8 @@ namespace ignite JniErrorInfo::~JniErrorInfo() { - if (errCls) - delete[] errCls; - - if (errMsg) - delete[] errMsg; + delete[] errCls; + delete[] errMsg; } /** @@ -255,8 +240,8 @@ namespace ignite JniMethod M_PLATFORM_IGNITION_STOP_ALL = JniMethod("stopAll", "(Z)V", true); /* STATIC STATE. */ - gcc::CriticalSection JVM_LOCK; - gcc::CriticalSection CONSOLE_LOCK; + icc::CriticalSection JVM_LOCK; + icc::CriticalSection CONSOLE_LOCK; JniJvm JVM; bool PRINT_EXCEPTION = false; std::vector consoleWriteHandlers; @@ -725,7 +710,7 @@ namespace ignite } void JniContext::Detach() { - gcc::Memory::Fence(); + icc::Memory::Fence(); if (JVM.GetJvm()) { JNIEnv* env; diff --git a/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp b/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp index d3b4a260625ba..1edda7c124ba0 100644 --- a/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp @@ -418,4 +418,47 @@ BOOST_AUTO_TEST_CASE(TestDdlColumnsMeta) BOOST_REQUIRE_EQUAL(ret, SQL_NO_DATA); } +BOOST_AUTO_TEST_CASE(TestDdlColumnsMetaEscaped) +{ + Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=PUBLIC"); + + SQLCHAR createTable[] = "create table ESG_FOCUS(id int primary key, TEST_COLUMN varchar)"; + SQLRETURN ret = SQLExecDirect(stmt, createTable, SQL_NTS); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + SQLCHAR empty[] = ""; + SQLCHAR table[] = "ESG\\_FOCUS"; + + ret = SQLColumns(stmt, empty, SQL_NTS, empty, SQL_NTS, table, SQL_NTS, empty, SQL_NTS); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + ret = SQLFetch(stmt); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + CheckStringColumn(stmt, 1, ""); + CheckStringColumn(stmt, 2, "\"PUBLIC\""); + CheckStringColumn(stmt, 3, "ESG_FOCUS"); + CheckStringColumn(stmt, 4, "ID"); + + ret = SQLFetch(stmt); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + CheckStringColumn(stmt, 1, ""); + CheckStringColumn(stmt, 2, "\"PUBLIC\""); + CheckStringColumn(stmt, 3, "ESG_FOCUS"); + CheckStringColumn(stmt, 4, "TEST_COLUMN"); + + ret = SQLFetch(stmt); + + BOOST_REQUIRE_EQUAL(ret, SQL_NO_DATA); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp index d8ed0879aec4d..96e6164e5f21b 100644 --- a/modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(TestValues) CheckIntInfo(SQL_POS_OPERATIONS, 0); CheckIntInfo(SQL_SQL92_DATETIME_FUNCTIONS, SQL_SDF_CURRENT_DATE | SQL_SDF_CURRENT_TIMESTAMP); CheckIntInfo(SQL_SQL92_VALUE_EXPRESSIONS, SQL_SVE_CASE | SQL_SVE_CAST | SQL_SVE_COALESCE | SQL_SVE_NULLIF); - CheckIntInfo(SQL_STATIC_CURSOR_ATTRIBUTES1, SQL_CA1_NEXT); + CheckIntInfo(SQL_STATIC_CURSOR_ATTRIBUTES1, SQL_CA1_NEXT | SQL_CA1_ABSOLUTE); CheckIntInfo(SQL_STATIC_CURSOR_ATTRIBUTES2, 0); CheckIntInfo(SQL_PARAM_ARRAY_ROW_COUNTS, SQL_PARC_BATCH); CheckIntInfo(SQL_PARAM_ARRAY_SELECTS, SQL_PAS_NO_SELECT); diff --git a/modules/platforms/cpp/odbc/Makefile.am b/modules/platforms/cpp/odbc/Makefile.am index 5a8ed6decf943..5230a2c5d5993 100644 --- a/modules/platforms/cpp/odbc/Makefile.am +++ b/modules/platforms/cpp/odbc/Makefile.am @@ -57,7 +57,7 @@ libignite_odbc_la_SOURCES = \ src/config/config_tools.cpp \ src/config/configuration.cpp \ src/config/connection_info.cpp \ - src/config/connection_string_parser.cpp \ + src/config/connection_string_parser.cpp \ src/connection.cpp \ src/cursor.cpp \ src/diagnostic/diagnosable_adapter.cpp \ @@ -81,6 +81,7 @@ libignite_odbc_la_SOURCES = \ src/ssl/ssl_gateway.cpp \ src/ssl/secure_socket_client.cpp \ src/ssl/ssl_mode.cpp \ + src/ssl/ssl_api.cpp \ src/sql/sql_lexer.cpp \ src/sql/sql_parser.cpp \ src/sql/sql_set_streaming_command.cpp \ diff --git a/modules/platforms/cpp/odbc/include/Makefile.am b/modules/platforms/cpp/odbc/include/Makefile.am index be6e059edfcfc..a3f6995512b12 100644 --- a/modules/platforms/cpp/odbc/include/Makefile.am +++ b/modules/platforms/cpp/odbc/include/Makefile.am @@ -53,7 +53,7 @@ noinst_HEADERS = \ ignite/odbc/diagnostic/diagnosable.h \ ignite/odbc/diagnostic/diagnosable_adapter.h \ ignite/odbc/ssl/ssl_mode.h \ - ignite/odbc/ssl/ssl_bindings.h \ + ignite/odbc/ssl/ssl_api.h \ ignite/odbc/ssl/secure_socket_client.h \ ignite/odbc/ssl/ssl_gateway.h \ ignite/odbc/sql/sql_command.h \ diff --git a/modules/web-console/frontend/app/modules/navbar/Navbar.provider.js b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_api.h similarity index 78% rename from modules/web-console/frontend/app/modules/navbar/Navbar.provider.js rename to modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_api.h index 9b905d7285aa8..69c7ab540d04d 100644 --- a/modules/web-console/frontend/app/modules/navbar/Navbar.provider.js +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_api.h @@ -15,16 +15,18 @@ * limitations under the License. */ -export default function() { - const items = []; +#ifndef _IGNITE_ODBC_SSL_SSL_API +#define _IGNITE_ODBC_SSL_SSL_API - this.push = function(data) { - items.push(data); - }; - - this.$get = function() { - return items; - }; - - return this; +namespace ignite +{ + namespace odbc + { + namespace ssl + { + bool EnsureSslLoaded(); + } + } } + +#endif //_IGNITE_ODBC_SSL_SSL_API \ No newline at end of file diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_bindings.h b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_bindings.h deleted file mode 100644 index 9a1740dc41f7c..0000000000000 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_bindings.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - * 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. - */ - -#ifndef _IGNITE_ODBC_SSL_SSL_BINDINGS -#define _IGNITE_ODBC_SSL_SSL_BINDINGS - -#include -#include -#include - -#include "ignite/odbc/ssl/ssl_gateway.h" - -namespace ignite -{ - namespace odbc - { - namespace ssl - { - // Declaring constant used by OpenSSL for readability. - enum { OPERATION_SUCCESS = 1 }; - - inline SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) - { - typedef SSL_CTX*(FuncType)(const SSL_METHOD*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_CTX_new); - - return fp(meth); - } - - inline void SSL_CTX_free(SSL_CTX *ctx) - { - typedef void(FuncType)(SSL_CTX*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_CTX_free); - - fp(ctx); - } - - inline void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, int(*callback) (int, X509_STORE_CTX *)) - { - typedef void(FuncType)(SSL_CTX*, int, int(*)(int, X509_STORE_CTX*)); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_set_verify); - - fp(ctx, mode, callback); - } - - inline void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth) - { - typedef void(FuncType)(SSL_CTX*, int); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_set_verify_depth); - - fp(ctx, depth); - } - - inline int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *cAfile, const char *cApath) - { - typedef int(FuncType)(SSL_CTX*, const char*, const char*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_load_verify_locations); - - return fp(ctx, cAfile, cApath); - } - - inline int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) - { - typedef int(FuncType)(SSL_CTX*, const char*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_use_certificate_chain_file); - - return fp(ctx, file); - } - - inline int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type) - { - typedef int(FuncType)(SSL_CTX*, const char*, int); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_use_RSAPrivateKey_file); - - return fp(ctx, file, type); - } - - inline int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) - { - typedef int(FuncType)(SSL_CTX*, const char*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_set_cipher_list); - - return fp(ctx, str); - } - - inline long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) - { - typedef long(FuncType)(SSL_CTX*, int, long, void*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_CTX_ctrl); - - return fp(ctx, cmd, larg, parg); - } - - inline long SSL_get_verify_result(const SSL *s) - { - typedef long(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_get_verify_result); - - return fp(s); - } - - inline int SSL_library_init() - { - typedef int(FuncType)(); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_library_init); - - return fp(); - } - - inline void SSL_load_error_strings() - { - typedef void(FuncType)(); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_load_error_strings); - - fp(); - } - - inline X509 *SSL_get_peer_certificate(const SSL *s) - { - typedef X509*(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_get_peer_certificate); - - return fp(s); - } - - inline long SSL_ctrl(SSL *s, int cmd, long larg, void *parg) - { - typedef long(FuncType)(SSL*, int, long, void*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_ctrl); - - return fp(s, cmd, larg ,parg); - } - - inline long SSL_set_tlsext_host_name_(SSL *s, const char *name) - { - return ssl::SSL_ctrl(s, SSL_CTRL_SET_TLSEXT_HOSTNAME, - TLSEXT_NAMETYPE_host_name, const_cast(name)); - } - - inline void SSL_set_connect_state_(SSL* s) - { - typedef void(FuncType)(SSL*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_set_connect_state); - - return fp(s); - } - - inline int SSL_connect_(SSL* s) - { - typedef int(FuncType)(SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_connect); - - return fp(s); - } - - inline int SSL_get_error_(const SSL *s, int ret) - { - typedef int(FuncType)(const SSL*, int); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_get_error); - - return fp(s, ret); - } - - inline int SSL_want_(const SSL *s) - { - typedef int(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_want); - - return fp(s); - } - - inline int SSL_write_(SSL *s, const void *buf, int num) - { - typedef int(FuncType)(SSL*, const void*, int); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_write); - - return fp(s, buf, num); - } - - inline int SSL_read_(SSL *s, void *buf, int num) - { - typedef int(FuncType)(SSL*, void*, int); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_read); - - return fp(s, buf, num); - } - - inline int SSL_pending_(const SSL *ssl) - { - typedef int(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_pending); - - return fp(ssl); - } - - inline int SSL_get_fd_(const SSL *ssl) - { - typedef int(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_get_fd); - - return fp(ssl); - } - - inline void SSL_free_(SSL *ssl) - { - typedef void(FuncType)(SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_free); - - fp(ssl); - } - - inline const SSL_METHOD *SSLv23_client_method_() - { - typedef const SSL_METHOD*(FuncType)(); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSLv23_client_method); - - return fp(); - } - - inline void OPENSSL_config(const char *configName) - { - typedef void(FuncType)(const char*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpOPENSSL_config); - - fp(configName); - } - - inline void X509_free(X509 *a) - { - typedef void(FuncType)(X509*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpX509_free); - - fp(a); - } - - inline BIO *BIO_new_ssl_connect(SSL_CTX *ctx) - { - typedef BIO*(FuncType)(SSL_CTX*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpBIO_new_ssl_connect); - - return fp(ctx); - } - - inline void BIO_free_all(BIO *a) - { - typedef void(FuncType)(BIO*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpBIO_free_all); - - fp(a); - } - - inline long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg) - { - typedef long(FuncType)(BIO*, int, long, void*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpBIO_ctrl); - - return fp(bp, cmd, larg, parg); - } - - inline long BIO_get_fd_(BIO *bp, int *fd) - { - return ssl::BIO_ctrl(bp, BIO_C_GET_FD, 0, reinterpret_cast(fd)); - } - - inline long BIO_get_ssl_(BIO *bp, SSL** ssl) - { - return ssl::BIO_ctrl(bp, BIO_C_GET_SSL, 0, reinterpret_cast(ssl)); - } - - inline long BIO_set_nbio_(BIO *bp, long n) - { - return ssl::BIO_ctrl(bp, BIO_C_SET_NBIO, n, NULL); - } - - inline long BIO_set_conn_hostname_(BIO *bp, const char *name) - { - return ssl::BIO_ctrl(bp, BIO_C_SET_CONNECT, 0, const_cast(name)); - } - - inline unsigned long ERR_get_error_() - { - typedef unsigned long(FuncType)(); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpERR_get_error); - - return fp(); - } - - inline void ERR_error_string_n_(unsigned long e, char *buf, size_t len) - { - typedef void(FuncType)(unsigned long, char*, size_t); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpERR_error_string_n); - - fp(e, buf, len); - } - } - } -} - -#endif //_IGNITE_ODBC_SSL_SSL_BINDINGS \ No newline at end of file diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_gateway.h b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_gateway.h index 4b102ad28b972..02761b2dc5f32 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_gateway.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_gateway.h @@ -18,6 +18,10 @@ #ifndef _IGNITE_ODBC_SSL_SSL_LIBRARY #define _IGNITE_ODBC_SSL_SSL_LIBRARY +#include +#include +#include + #include "ignite/common/concurrent.h" #include "ignite/common/dynamic_load_os.h" @@ -32,6 +36,7 @@ namespace ignite */ struct SslFunctions { + void *fpSSLeay_version; void *fpSSL_CTX_new; void *fpSSL_CTX_free; void *fpSSL_CTX_set_verify; @@ -63,6 +68,12 @@ namespace ignite void *fpBIO_ctrl; void *fpERR_get_error; void *fpERR_error_string_n; + void *fpERR_print_errors_fp; + + void *fpOpenSSL_version; + void *fpSSL_CTX_set_options; + void *fpOPENSSL_init_ssl; + void *fpTLS_client_method; }; /** @@ -103,6 +114,88 @@ namespace ignite return inited; } + char* SSLeay_version_(int type); + + int OPENSSL_init_ssl_(uint64_t opts, const void* settings); + + long SSL_CTX_set_options_(SSL_CTX* ctx, long options); + + long SSL_CTX_ctrl_(SSL_CTX* ctx, int cmd, long larg, void* parg); + + SSL_CTX* SSL_CTX_new_(const SSL_METHOD* meth); + + void SSL_CTX_free_(SSL_CTX* ctx); + + void SSL_CTX_set_verify_(SSL_CTX* ctx, int mode, int (*callback)(int, X509_STORE_CTX*)); + + void SSL_CTX_set_verify_depth_(SSL_CTX* ctx, int depth); + + int SSL_CTX_load_verify_locations_(SSL_CTX* ctx, const char* cAfile, const char* cApath); + + int SSL_CTX_use_certificate_chain_file_(SSL_CTX* ctx, const char* file); + + int SSL_CTX_use_RSAPrivateKey_file_(SSL_CTX* ctx, const char* file, int type); + + int SSL_CTX_set_cipher_list_(SSL_CTX* ctx, const char* str); + + long SSL_get_verify_result_(const SSL* s); + + int SSL_library_init_(); + + void SSL_load_error_strings_(); + + X509* SSL_get_peer_certificate_(const SSL* s); + + long SSL_ctrl_(SSL* s, int cmd, long larg, void* parg); + + long SSL_set_tlsext_host_name_(SSL* s, const char* name); + + void SSL_set_connect_state_(SSL* s); + + int SSL_connect_(SSL* s); + + int SSL_get_error_(const SSL* s, int ret); + + int SSL_want_(const SSL* s); + + int SSL_write_(SSL* s, const void* buf, int num); + + int SSL_read_(SSL* s, void* buf, int num); + + int SSL_pending_(const SSL* ssl); + + int SSL_get_fd_(const SSL* ssl); + + void SSL_free_(SSL* ssl); + + const SSL_METHOD* SSLv23_client_method_(); + + const SSL_METHOD* TLS_client_method_(); + + void OPENSSL_config_(const char* configName); + + void X509_free_(X509* a); + + BIO* BIO_new_ssl_connect_(SSL_CTX* ctx); + + void BIO_free_all_(BIO* a); + + long BIO_ctrl_(BIO* bp, int cmd, long larg, void* parg); + + long BIO_get_fd_(BIO* bp, int* fd); + + long BIO_get_ssl_(BIO* bp, SSL** ssl); + + long BIO_set_nbio_(BIO* bp, long n); + + long BIO_set_conn_hostname_(BIO* bp, const char* name); + + unsigned long ERR_get_error_(); + + void ERR_error_string_n_(unsigned long e, char* buf, size_t len); + + void ERR_print_errors_fp_(FILE *fd); + private: /** * Constructor. @@ -114,6 +207,11 @@ namespace ignite */ ~SslGateway(); + /** + * Unload all SSL symbols. + */ + void UnloadAll(); + /** * Load SSL library. * @param name Name. @@ -126,9 +224,23 @@ namespace ignite */ bool LoadSslLibraries(); + /** + * Load mandatory SSL methods. + * + * @throw IgniteError if can not load one of the functions. + */ + void LoadMandatoryMethods(); + + /** + * Try load SSL method. + * + * @param name Name. + * @return Method pointer. + */ + void* TryLoadSslMethod(const char* name); + /** * Load SSL method. - * @param mod Module. * @param name Name. * @return Method pointer. */ @@ -146,6 +258,9 @@ namespace ignite /** ssleay32 module. */ common::dynamic::Module ssleay32; + /** libcrypto module. */ + common::dynamic::Module libcrypto; + /** libssl module. */ common::dynamic::Module libssl; diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj index 69318ef1e496a..b583c111031df 100644 --- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj +++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj @@ -201,6 +201,7 @@ + @@ -263,7 +264,7 @@ - + diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters index f0e49b576e4c1..5fe3bd367e54f 100644 --- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters +++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters @@ -196,6 +196,9 @@ Code\streaming + + Code\ssl + @@ -344,9 +347,6 @@ Code\ssl - - Code\ssl - Code\config @@ -392,5 +392,8 @@ Code\streaming + + Code\ssl + \ No newline at end of file diff --git a/modules/platforms/cpp/odbc/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/src/config/connection_info.cpp index 5885381b0532b..fde8ca53c710f 100644 --- a/modules/platforms/cpp/odbc/src/config/connection_info.cpp +++ b/modules/platforms/cpp/odbc/src/config/connection_info.cpp @@ -1103,7 +1103,7 @@ namespace ignite // Bitmask that describes the attributes of a static cursor that are supported by the driver. This // bitmask contains the first subset of attributes; for the second subset, see // SQL_STATIC_CURSOR_ATTRIBUTES2. - intParams[SQL_STATIC_CURSOR_ATTRIBUTES1] = SQL_CA1_NEXT; + intParams[SQL_STATIC_CURSOR_ATTRIBUTES1] = SQL_CA1_NEXT | SQL_CA1_ABSOLUTE; #endif // SQL_STATIC_CURSOR_ATTRIBUTES1 #ifdef SQL_STATIC_CURSOR_ATTRIBUTES2 diff --git a/modules/platforms/cpp/odbc/src/connection.cpp b/modules/platforms/cpp/odbc/src/connection.cpp index b580f12804fea..1953a162620da 100644 --- a/modules/platforms/cpp/odbc/src/connection.cpp +++ b/modules/platforms/cpp/odbc/src/connection.cpp @@ -30,7 +30,7 @@ #include "ignite/odbc/connection.h" #include "ignite/odbc/message.h" #include "ignite/odbc/ssl/ssl_mode.h" -#include "ignite/odbc/ssl/ssl_gateway.h" +#include "ignite/odbc/ssl/ssl_api.h" #include "ignite/odbc/ssl/secure_socket_client.h" #include "ignite/odbc/system/tcp_socket_client.h" #include "ignite/odbc/dsn_config.h" @@ -155,7 +155,7 @@ namespace ignite if (sslMode != SslMode::DISABLE) { - bool loaded = ssl::SslGateway::GetInstance().LoadAll(); + bool loaded = ssl::EnsureSslLoaded(); if (!loaded) { diff --git a/modules/platforms/cpp/odbc/src/message.cpp b/modules/platforms/cpp/odbc/src/message.cpp index 587d2535ce203..6398964948a0c 100644 --- a/modules/platforms/cpp/odbc/src/message.cpp +++ b/modules/platforms/cpp/odbc/src/message.cpp @@ -84,9 +84,10 @@ namespace ignite { utility::WriteString(writer, config.GetUser()); utility::WriteString(writer, config.GetPassword()); + } + if (version >= ProtocolVersion::VERSION_2_7_0) writer.WriteInt8(config.GetNestedTxMode()); - } } QueryExecuteRequest::QueryExecuteRequest(const std::string& schema, const std::string& sql, diff --git a/modules/platforms/cpp/odbc/src/ssl/secure_socket_client.cpp b/modules/platforms/cpp/odbc/src/ssl/secure_socket_client.cpp index 84eb1e8867f82..f7811fb7925b6 100644 --- a/modules/platforms/cpp/odbc/src/ssl/secure_socket_client.cpp +++ b/modules/platforms/cpp/odbc/src/ssl/secure_socket_client.cpp @@ -22,13 +22,15 @@ #include "ignite/common/concurrent.h" #include "ignite/odbc/system/tcp_socket_client.h" #include "ignite/odbc/ssl/secure_socket_client.h" -#include "ignite/odbc/ssl/ssl_bindings.h" +#include "ignite/odbc/ssl/ssl_gateway.h" #include "ignite/common/utils.h" #ifndef SOCKET_ERROR # define SOCKET_ERROR (-1) #endif // SOCKET_ERROR +enum { OPERATION_SUCCESS = 1 }; + namespace ignite { namespace odbc @@ -52,13 +54,15 @@ namespace ignite CloseInteral(); if (context) - ssl::SSL_CTX_free(reinterpret_cast(context)); + SslGateway::GetInstance().SSL_CTX_free_(reinterpret_cast(context)); } bool SecureSocketClient::Connect(const char* hostname, uint16_t port, int32_t, diagnostic::Diagnosable& diag) { - assert(SslGateway::GetInstance().Loaded()); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); if (!context) { @@ -77,52 +81,52 @@ namespace ignite if (!ssl0) return false; - int res = ssl::SSL_set_tlsext_host_name_(ssl0, hostname); + int res = sslGateway.SSL_set_tlsext_host_name_(ssl0, hostname); if (res != OPERATION_SUCCESS) { + sslGateway.SSL_free_(ssl0); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not set host name for secure connection: " + GetSslError(ssl0, res)); - ssl::SSL_free_(ssl0); - return false; } - ssl::SSL_set_connect_state_(ssl0); + sslGateway.SSL_set_connect_state_(ssl0); bool connected = CompleteConnectInternal(ssl0, DEFALT_CONNECT_TIMEOUT, diag); if (!connected) { - ssl::SSL_free_(ssl0); + sslGateway.SSL_free_(ssl0); return false; } // Verify a server certificate was presented during the negotiation - X509* cert = ssl::SSL_get_peer_certificate(ssl0); + X509* cert = sslGateway.SSL_get_peer_certificate_(ssl0); if (cert) - ssl::X509_free(cert); + sslGateway.X509_free_(cert); else { + sslGateway.SSL_free_(ssl0); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Remote host did not provide certificate: " + GetSslError(ssl0, res)); - ssl::SSL_free_(ssl0); - return false; } // Verify the result of chain verification // Verification performed according to RFC 4158 - res = ssl::SSL_get_verify_result(ssl0); + res = sslGateway.SSL_get_verify_result_(ssl0); if (X509_V_OK != res) { + sslGateway.SSL_free_(ssl0); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Certificate chain verification failed: " + GetSslError(ssl0, res)); - ssl::SSL_free_(ssl0); - return false; } @@ -138,7 +142,9 @@ namespace ignite int SecureSocketClient::Send(const int8_t* data, size_t size, int32_t timeout) { - assert(SslGateway::GetInstance().Loaded()); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); if (!ssl) { @@ -149,14 +155,16 @@ namespace ignite SSL* ssl0 = reinterpret_cast(ssl); - int res = ssl::SSL_write_(ssl0, data, static_cast(size)); + int res = sslGateway.SSL_write_(ssl0, data, static_cast(size)); return res; } int SecureSocketClient::Receive(int8_t* buffer, size_t size, int32_t timeout) { - assert(SslGateway::GetInstance().Loaded()); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); if (!ssl) { @@ -169,7 +177,7 @@ namespace ignite int res = 0; - if (!blocking && ssl::SSL_pending_(ssl0) == 0) + if (!blocking && sslGateway.SSL_pending_(ssl0) == 0) { res = WaitOnSocket(ssl, timeout, true); @@ -177,7 +185,7 @@ namespace ignite return res; } - res = ssl::SSL_read_(ssl0, buffer, static_cast(size)); + res = sslGateway.SSL_read_(ssl0, buffer, static_cast(size)); return res; } @@ -190,30 +198,11 @@ namespace ignite void* SecureSocketClient::MakeContext(const std::string& certPath, const std::string& keyPath, const std::string& caPath, diagnostic::Diagnosable& diag) { - assert(SslGateway::GetInstance().Loaded()); + SslGateway &sslGateway = SslGateway::GetInstance(); - static bool sslLibInited = false; - static common::concurrent::CriticalSection sslCs; + assert(sslGateway.Loaded()); - if (!sslLibInited) - { - common::concurrent::CsLockGuard lock(sslCs); - - if (!sslLibInited) - { - LOG_MSG("Initializing SSL library"); - - (void)SSL_library_init(); - - SSL_load_error_strings(); - - OPENSSL_config(0); - - sslLibInited = true; - } - } - - const SSL_METHOD* method = ssl::SSLv23_client_method_(); + const SSL_METHOD* method = sslGateway.SSLv23_client_method_(); if (!method) { diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not get SSL method."); @@ -221,7 +210,7 @@ namespace ignite return 0; } - SSL_CTX* ctx = ssl::SSL_CTX_new(method); + SSL_CTX* ctx = sslGateway.SSL_CTX_new_(method); if (!ctx) { diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not create new SSL context."); @@ -229,57 +218,56 @@ namespace ignite return 0; } - ssl::SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0); + sslGateway.SSL_CTX_set_verify_(ctx, SSL_VERIFY_PEER, 0); - ssl::SSL_CTX_set_verify_depth(ctx, 8); + sslGateway.SSL_CTX_set_verify_depth_(ctx, 8); - const long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION; - ssl::SSL_CTX_ctrl(ctx, SSL_CTRL_OPTIONS, flags, NULL); + sslGateway.SSL_CTX_set_options_(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION); const char* cCaPath = caPath.empty() ? 0 : caPath.c_str(); - long res = ssl::SSL_CTX_load_verify_locations(ctx, cCaPath, 0); + long res = sslGateway.SSL_CTX_load_verify_locations_(ctx, cCaPath, 0); if (res != OPERATION_SUCCESS) { + sslGateway.SSL_CTX_free_(ctx); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not set Certificate Authority path for secure connection."); - ssl::SSL_CTX_free(ctx); - return 0; } - res = ssl::SSL_CTX_use_certificate_chain_file(ctx, certPath.c_str()); + res = sslGateway.SSL_CTX_use_certificate_chain_file_(ctx, certPath.c_str()); if (res != OPERATION_SUCCESS) { + sslGateway.SSL_CTX_free_(ctx); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not set client certificate file for secure connection."); - ssl::SSL_CTX_free(ctx); - return 0; } - res = ssl::SSL_CTX_use_RSAPrivateKey_file(ctx, keyPath.c_str(), SSL_FILETYPE_PEM); + res = sslGateway.SSL_CTX_use_RSAPrivateKey_file_(ctx, keyPath.c_str(), SSL_FILETYPE_PEM); if (res != OPERATION_SUCCESS) { + sslGateway.SSL_CTX_free_(ctx); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not set private key file for secure connection."); - ssl::SSL_CTX_free(ctx); - return 0; } const char* const PREFERRED_CIPHERS = "HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4"; - res = ssl::SSL_CTX_set_cipher_list(ctx, PREFERRED_CIPHERS); + res = sslGateway.SSL_CTX_set_cipher_list_(ctx, PREFERRED_CIPHERS); if (res != OPERATION_SUCCESS) { + sslGateway.SSL_CTX_free_(ctx); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not set ciphers list for secure connection."); - ssl::SSL_CTX_free(ctx); - return 0; } @@ -289,7 +277,11 @@ namespace ignite void* SecureSocketClient::MakeSsl(void* context, const char* hostname, uint16_t port, bool& blocking, diagnostic::Diagnosable& diag) { - BIO* bio = ssl::BIO_new_ssl_connect(reinterpret_cast(context)); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); + + BIO* bio = sslGateway.BIO_new_ssl_connect_(reinterpret_cast(context)); if (!bio) { diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not create SSL connection."); @@ -298,7 +290,7 @@ namespace ignite } blocking = false; - long res = ssl::BIO_set_nbio_(bio, 1); + long res = sslGateway.BIO_set_nbio_(bio, 1); if (res != OPERATION_SUCCESS) { blocking = true; @@ -312,23 +304,23 @@ namespace ignite std::string address = stream.str(); - res = ssl::BIO_set_conn_hostname_(bio, address.c_str()); + res = sslGateway.BIO_set_conn_hostname_(bio, address.c_str()); if (res != OPERATION_SUCCESS) { - diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not set SSL connection hostname."); + sslGateway.BIO_free_all_(bio); - ssl::BIO_free_all(bio); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not set SSL connection hostname."); return 0; } SSL* ssl = 0; - ssl::BIO_get_ssl_(bio, &ssl); + sslGateway.BIO_get_ssl_(bio, &ssl); if (!ssl) { - diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not get SSL instance from BIO."); + sslGateway.BIO_free_all_(bio); - ssl::BIO_free_all(bio); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not get SSL instance from BIO."); return 0; } @@ -338,16 +330,20 @@ namespace ignite bool SecureSocketClient::CompleteConnectInternal(void* ssl, int timeout, diagnostic::Diagnosable& diag) { + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); + SSL* ssl0 = reinterpret_cast(ssl); while (true) { - int res = ssl::SSL_connect_(ssl0); + int res = sslGateway.SSL_connect_(ssl0); if (res == OPERATION_SUCCESS) return true; - int sslError = ssl::SSL_get_error_(ssl0, res); + int sslError = sslGateway.SSL_get_error_(ssl0, res); LOG_MSG("wait res=" << res << ", sslError=" << sslError); @@ -359,7 +355,7 @@ namespace ignite return false; } - int want = ssl::SSL_want_(ssl0); + int want = sslGateway.SSL_want_(ssl0); res = WaitOnSocket(ssl, timeout, want == SSL_READING); @@ -386,9 +382,13 @@ namespace ignite std::string SecureSocketClient::GetSslError(void* ssl, int ret) { + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); + SSL* ssl0 = reinterpret_cast(ssl); - int sslError = ssl::SSL_get_error_(ssl0, ret); + int sslError = sslGateway.SSL_get_error_(ssl0, ret); LOG_MSG("ssl_error: " << sslError); @@ -407,11 +407,11 @@ namespace ignite return std::string("SSL error: ") + common::LexicalCast(sslError); } - long error = ssl::ERR_get_error_(); + long error = sslGateway.ERR_get_error_(); char errBuf[1024] = { 0 }; - ssl::ERR_error_string_n_(error, errBuf, sizeof(errBuf)); + sslGateway.ERR_error_string_n_(error, errBuf, sizeof(errBuf)); return std::string(errBuf); } @@ -435,11 +435,13 @@ namespace ignite void SecureSocketClient::CloseInteral() { - assert(SslGateway::GetInstance().Loaded()); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); if (ssl) { - ssl::SSL_free_(reinterpret_cast(ssl)); + sslGateway.SSL_free_(reinterpret_cast(ssl)); ssl = 0; } @@ -447,13 +449,17 @@ namespace ignite int SecureSocketClient::WaitOnSocket(void* ssl, int32_t timeout, bool rd) { + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); + int ready = 0; int lastError = 0; SSL* ssl0 = reinterpret_cast(ssl); fd_set fds; - int fd = ssl::SSL_get_fd_(ssl0); + int fd = sslGateway.SSL_get_fd_(ssl0); if (fd < 0) { diff --git a/modules/platforms/cpp/odbc/src/ssl/ssl_api.cpp b/modules/platforms/cpp/odbc/src/ssl/ssl_api.cpp new file mode 100644 index 0000000000000..4a1d6926c2765 --- /dev/null +++ b/modules/platforms/cpp/odbc/src/ssl/ssl_api.cpp @@ -0,0 +1,33 @@ +/* + * 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. + */ + +#include "ignite/odbc/ssl/ssl_gateway.h" +#include "ignite/odbc/ssl/ssl_api.h" + +namespace ignite +{ + namespace odbc + { + namespace ssl + { + bool EnsureSslLoaded() + { + return SslGateway::GetInstance().LoadAll(); + } + } + } +} diff --git a/modules/platforms/cpp/odbc/src/ssl/ssl_gateway.cpp b/modules/platforms/cpp/odbc/src/ssl/ssl_gateway.cpp index 308302a069f8a..6116a767a7e69 100644 --- a/modules/platforms/cpp/odbc/src/ssl/ssl_gateway.cpp +++ b/modules/platforms/cpp/odbc/src/ssl/ssl_gateway.cpp @@ -17,9 +17,6 @@ #include -#include -#include - #include "ignite/common/utils.h" #include "ignite/odbc/ssl/ssl_gateway.h" @@ -29,6 +26,18 @@ # define ADDITIONAL_OPENSSL_HOME_ENV "OPEN_SSL_HOME" #endif // ADDITIONAL_OPENSSL_HOME_ENV +#ifndef SSL_CTRL_OPTIONS +# define SSL_CTRL_OPTIONS 32 +#endif // SSL_CTRL_OPTIONS + +#ifndef OPENSSL_INIT_LOAD_SSL_STRINGS +# define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L +#endif // OPENSSL_INIT_LOAD_SSL_STRINGS + +#ifndef OPENSSL_INIT_LOAD_CRYPTO_STRINGS +# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L +#endif // OPENSSL_INIT_LOAD_CRYPTO_STRINGS + namespace ignite { namespace odbc @@ -39,7 +48,7 @@ namespace ignite inited(false), functions() { - // No-op. + memset(&functions, 0, sizeof(functions)); } SslGateway::~SslGateway() @@ -47,41 +56,61 @@ namespace ignite // No-op. } + void SslGateway::UnloadAll() + { + libeay32.Unload(); + ssleay32.Unload(); + libssl.Unload(); + libcrypto.Unload(); + + memset(&functions, 0, sizeof(functions)); + } + common::dynamic::Module SslGateway::LoadSslLibrary(const char* name) { using namespace common; using namespace dynamic; - std::string fullName = GetDynamicLibraryName(name); - - Module libModule = LoadModule(fullName); - - if (libModule.IsLoaded()) - return libModule; - std::string home = GetEnv(ADDITIONAL_OPENSSL_HOME_ENV); if (home.empty()) home = GetEnv("OPENSSL_HOME"); - if (home.empty()) - return libModule; + std::string fullName = GetDynamicLibraryName(name); + + if (!home.empty()) + { + std::stringstream constructor; + + constructor << home << Fs << "bin" << Fs << fullName; - std::stringstream constructor; + std::string fullPath = constructor.str(); - constructor << home << Fs << "bin" << Fs << fullName; + Module mod = LoadModule(fullPath); - std::string fullPath = constructor.str(); + if (mod.IsLoaded()) + return mod; + } - return LoadModule(fullPath); + return LoadModule(fullName); } bool SslGateway::LoadSslLibraries() { - libeay32 = LoadSslLibrary("libeay32"); - ssleay32 = LoadSslLibrary("ssleay32"); libssl = LoadSslLibrary("libssl"); + if (!libssl.IsLoaded()) + { + libcrypto = LoadSslLibrary("libcrypto-1_1-x64"); + libssl = LoadSslLibrary("libssl-1_1-x64"); + } + + if (!libssl.IsLoaded()) + { + libeay32 = LoadSslLibrary("libeay32"); + ssleay32 = LoadSslLibrary("ssleay32"); + } + if (!libssl.IsLoaded() && (!libeay32.IsLoaded() || !ssleay32.IsLoaded())) { if (!libeay32.IsLoaded()) @@ -93,41 +122,29 @@ namespace ignite if (!libssl.IsLoaded()) LOG_MSG("Can not load libssl."); - libeay32.Unload(); - ssleay32.Unload(); - libssl.Unload(); - return false; } return true; } - SslGateway& SslGateway::GetInstance() - { - static SslGateway self; - - return self; - } - - bool SslGateway::LoadAll() + void SslGateway::LoadMandatoryMethods() { - using namespace common::dynamic; + functions.fpSSLeay_version = TryLoadSslMethod("SSLeay_version"); - if (inited) - return true; + if (!functions.fpSSLeay_version) + functions.fpOpenSSL_version = LoadSslMethod("OpenSSL_version"); - common::concurrent::CsLockGuard lock(initCs); + functions.fpSSL_library_init = TryLoadSslMethod("SSL_library_init"); + functions.fpSSL_load_error_strings = TryLoadSslMethod("SSL_load_error_strings"); - if (inited) - return true; + if (!functions.fpSSL_library_init || !functions.fpSSL_load_error_strings) + functions.fpOPENSSL_init_ssl = LoadSslMethod("OPENSSL_init_ssl"); - if (!LoadSslLibraries()) - { - LOG_MSG("Can not load neccessary OpenSSL libraries."); + functions.fpSSLv23_client_method = TryLoadSslMethod("SSLv23_client_method"); - return false; - } + if (!functions.fpSSLv23_client_method) + functions.fpTLS_client_method = LoadSslMethod("TLS_client_method"); functions.fpSSL_CTX_new = LoadSslMethod("SSL_CTX_new"); functions.fpSSL_CTX_free = LoadSslMethod("SSL_CTX_free"); @@ -139,13 +156,11 @@ namespace ignite functions.fpSSL_CTX_set_cipher_list = LoadSslMethod("SSL_CTX_set_cipher_list"); functions.fpSSL_get_verify_result = LoadSslMethod("SSL_get_verify_result"); - functions.fpSSL_library_init = LoadSslMethod("SSL_library_init"); - functions.fpSSL_load_error_strings = LoadSslMethod("SSL_load_error_strings"); + functions.fpSSL_get_peer_certificate = LoadSslMethod("SSL_get_peer_certificate"); functions.fpSSL_ctrl = LoadSslMethod("SSL_ctrl"); functions.fpSSL_CTX_ctrl = LoadSslMethod("SSL_CTX_ctrl"); - functions.fpSSLv23_client_method = LoadSslMethod("SSLv23_client_method"); functions.fpSSL_set_connect_state = LoadSslMethod("SSL_set_connect_state"); functions.fpSSL_connect = LoadSslMethod("SSL_connect"); functions.fpSSL_get_error = LoadSslMethod("SSL_get_error"); @@ -165,67 +180,521 @@ namespace ignite functions.fpERR_get_error = LoadSslMethod("ERR_get_error"); functions.fpERR_error_string_n = LoadSslMethod("ERR_error_string_n"); + } + + SslGateway& SslGateway::GetInstance() + { + static SslGateway self; + + return self; + } + + bool SslGateway::LoadAll() + { + using namespace common::dynamic; + + if (inited) + return true; + + common::concurrent::CsLockGuard lock(initCs); - bool allLoaded = - functions.fpSSL_CTX_new != 0 && - functions.fpSSL_CTX_free != 0 && - functions.fpSSL_CTX_set_verify != 0 && - functions.fpSSL_CTX_set_verify_depth != 0 && - functions.fpSSL_CTX_load_verify_locations != 0 && - functions.fpSSL_CTX_use_certificate_chain_file != 0 && - functions.fpSSL_CTX_use_RSAPrivateKey_file != 0 && - functions.fpSSL_CTX_set_cipher_list != 0 && - functions.fpSSL_get_verify_result != 0 && - functions.fpSSL_library_init != 0 && - functions.fpSSL_load_error_strings != 0 && - functions.fpSSL_get_peer_certificate != 0 && - functions.fpSSL_ctrl != 0 && - functions.fpSSL_CTX_ctrl != 0 && - functions.fpSSLv23_client_method != 0 && - functions.fpSSL_set_connect_state != 0 && - functions.fpSSL_connect != 0 && - functions.fpSSL_get_error != 0 && - functions.fpSSL_want != 0 && - functions.fpSSL_write != 0 && - functions.fpSSL_read != 0 && - functions.fpSSL_pending != 0 && - functions.fpSSL_get_fd != 0 && - functions.fpSSL_free != 0 && - functions.fpBIO_new_ssl_connect != 0 && - functions.fpOPENSSL_config != 0 && - functions.fpX509_free != 0 && - functions.fpBIO_free_all != 0 && - functions.fpBIO_ctrl != 0 && - functions.fpERR_get_error != 0 && - functions.fpERR_error_string_n != 0; - - if (!allLoaded) + if (inited) + return true; + + common::MethodGuard guard(this, &SslGateway::UnloadAll); + + if (!LoadSslLibraries()) { - libeay32.Unload(); - ssleay32.Unload(); - libssl.Unload(); + LOG_MSG("Can not load neccessary OpenSSL libraries."); + + return false; } - inited = allLoaded; + LoadMandatoryMethods(); + + functions.fpSSL_CTX_set_options = TryLoadSslMethod("SSL_CTX_set_options"); + functions.fpERR_print_errors_fp = TryLoadSslMethod("ERR_print_errors_fp"); + + (void)SSL_library_init_(); - return inited; + SSL_load_error_strings_(); + + OPENSSL_config_(0); + + guard.Release(); + + inited = true; + + return true; } - void* SslGateway::LoadSslMethod(const char* name) + void* SslGateway::TryLoadSslMethod(const char* name) { void* fp = libeay32.FindSymbol(name); if (!fp) fp = ssleay32.FindSymbol(name); + if (!fp) + fp = libcrypto.FindSymbol(name); + if (!fp) fp = libssl.FindSymbol(name); + return fp; + } + + void* SslGateway::LoadSslMethod(const char* name) + { + void* fp = TryLoadSslMethod(name); + if (!fp) LOG_MSG("Can not load function " << name); return fp; } + + char* SslGateway::SSLeay_version_(int type) + { + typedef char* (FuncType)(int); + + FuncType* fp = 0; + + if (functions.fpSSLeay_version) + fp = reinterpret_cast(functions.fpSSLeay_version); + else + fp = reinterpret_cast(functions.fpOpenSSL_version); + + assert(fp != 0); + + return fp(type); + } + + int SslGateway::OPENSSL_init_ssl_(uint64_t opts, const void* settings) + { + assert(functions.fpOPENSSL_init_ssl != 0); + + typedef int (FuncType)(uint64_t, const void*); + + FuncType* fp = reinterpret_cast(functions.fpOPENSSL_init_ssl); + + return fp(opts, settings); + } + + long SslGateway::SSL_CTX_set_options_(SSL_CTX* ctx, long options) + { + if (functions.fpSSL_CTX_set_options) + { + typedef long (FuncType)(SSL_CTX*, long); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_set_options); + + return fp(ctx, options); + } + + return SSL_CTX_ctrl_(ctx, SSL_CTRL_OPTIONS, options, NULL); + } + + long SslGateway::SSL_CTX_ctrl_(SSL_CTX* ctx, int cmd, long larg, void* parg) + { + assert(functions.fpSSL_CTX_ctrl != 0); + + typedef long (FuncType)(SSL_CTX*, int, long, void*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_ctrl); + + return fp(ctx, cmd, larg, parg); + } + + SSL_CTX* SslGateway::SSL_CTX_new_(const SSL_METHOD* meth) + { + assert(functions.fpSSL_CTX_new != 0); + + typedef SSL_CTX*(FuncType)(const SSL_METHOD*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_new); + + return fp(meth); + } + + void SslGateway::SSL_CTX_free_(SSL_CTX* ctx) + { + assert(functions.fpSSL_CTX_free != 0); + + typedef void (FuncType)(SSL_CTX*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_free); + + fp(ctx); + } + + void SslGateway::SSL_CTX_set_verify_(SSL_CTX* ctx, int mode, int (* callback)(int, X509_STORE_CTX*)) + { + assert(functions.fpSSL_CTX_set_verify != 0); + + typedef void (FuncType)(SSL_CTX*, int, int (*)(int, X509_STORE_CTX*)); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_set_verify); + + fp(ctx, mode, callback); + } + + void SslGateway::SSL_CTX_set_verify_depth_(SSL_CTX* ctx, int depth) + { + assert(functions.fpSSL_CTX_set_verify_depth != 0); + + typedef void (FuncType)(SSL_CTX*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_set_verify_depth); + + fp(ctx, depth); + } + + int SslGateway::SSL_CTX_load_verify_locations_(SSL_CTX* ctx, const char* cAfile, const char* cApath) + { + assert(functions.fpSSL_CTX_load_verify_locations != 0); + + typedef int (FuncType)(SSL_CTX*, const char*, const char*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_load_verify_locations); + + return fp(ctx, cAfile, cApath); + } + + int SslGateway::SSL_CTX_use_certificate_chain_file_(SSL_CTX* ctx, const char* file) + { + assert(functions.fpSSL_CTX_use_certificate_chain_file != 0); + + typedef int (FuncType)(SSL_CTX*, const char*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_use_certificate_chain_file); + + return fp(ctx, file); + } + + int SslGateway::SSL_CTX_use_RSAPrivateKey_file_(SSL_CTX* ctx, const char* file, int type) + { + assert(functions.fpSSL_CTX_use_RSAPrivateKey_file != 0); + + typedef int (FuncType)(SSL_CTX*, const char*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_use_RSAPrivateKey_file); + + return fp(ctx, file, type); + } + + int SslGateway::SSL_CTX_set_cipher_list_(SSL_CTX* ctx, const char* str) + { + assert(functions.fpSSL_CTX_set_cipher_list != 0); + + typedef int (FuncType)(SSL_CTX*, const char*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_set_cipher_list); + + return fp(ctx, str); + } + + long SslGateway::SSL_get_verify_result_(const SSL* s) + { + assert(functions.fpSSL_get_verify_result != 0); + + typedef long (FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_get_verify_result); + + return fp(s); + } + + int SslGateway::SSL_library_init_() + { + typedef int (FuncType)(); + + if (functions.fpSSL_library_init) + { + FuncType* fp = reinterpret_cast(functions.fpSSL_library_init); + + return fp(); + } + + return OPENSSL_init_ssl_(0, NULL); + } + + void SslGateway::SSL_load_error_strings_() + { + typedef void (FuncType)(); + + if (functions.fpSSL_load_error_strings) + { + FuncType* fp = reinterpret_cast(functions.fpSSL_load_error_strings); + + fp(); + + return; + } + + OPENSSL_init_ssl_(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); + } + + X509* SslGateway::SSL_get_peer_certificate_(const SSL* s) + { + assert(functions.fpSSL_get_peer_certificate != 0); + + typedef X509*(FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_get_peer_certificate); + + return fp(s); + } + + long SslGateway::SSL_ctrl_(SSL* s, int cmd, long larg, void* parg) + { + assert(functions.fpSSL_ctrl != 0); + + typedef long (FuncType)(SSL*, int, long, void*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_ctrl); + + return fp(s, cmd, larg, parg); + } + + long SslGateway::SSL_set_tlsext_host_name_(SSL* s, const char* name) + { + return SSL_ctrl_(s, SSL_CTRL_SET_TLSEXT_HOSTNAME, + TLSEXT_NAMETYPE_host_name, const_cast(name)); + } + + void SslGateway::SSL_set_connect_state_(SSL* s) + { + assert(functions.fpSSL_set_connect_state != 0); + + typedef void (FuncType)(SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_set_connect_state); + + return fp(s); + } + + int SslGateway::SSL_connect_(SSL* s) + { + assert(functions.fpSSL_connect != 0); + + typedef int (FuncType)(SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_connect); + + return fp(s); + } + + int SslGateway::SSL_get_error_(const SSL* s, int ret) + { + assert(functions.fpSSL_get_error != 0); + + typedef int (FuncType)(const SSL*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_get_error); + + return fp(s, ret); + } + + int SslGateway::SSL_want_(const SSL* s) + { + assert(functions.fpSSL_want != 0); + + typedef int (FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_want); + + return fp(s); + } + + int SslGateway::SSL_write_(SSL* s, const void* buf, int num) + { + assert(functions.fpSSL_write != 0); + + typedef int (FuncType)(SSL*, const void*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_write); + + return fp(s, buf, num); + } + + int SslGateway::SSL_read_(SSL* s, void* buf, int num) + { + assert(functions.fpSSL_read != 0); + + typedef int (FuncType)(SSL*, void*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_read); + + return fp(s, buf, num); + } + + int SslGateway::SSL_pending_(const SSL* ssl) + { + assert(functions.fpSSL_pending != 0); + + typedef int (FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_pending); + + return fp(ssl); + } + + int SslGateway::SSL_get_fd_(const SSL* ssl) + { + assert(functions.fpSSL_get_fd != 0); + + typedef int (FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_get_fd); + + return fp(ssl); + } + + void SslGateway::SSL_free_(SSL* ssl) + { + assert(functions.fpSSL_free != 0); + + typedef void (FuncType)(SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_free); + + fp(ssl); + } + + const SSL_METHOD* SslGateway::SSLv23_client_method_() + { + if (functions.fpSSLv23_client_method) + { + typedef const SSL_METHOD*(FuncType)(); + + FuncType* fp = reinterpret_cast(functions.fpSSLv23_client_method); + + return fp(); + } + + return TLS_client_method_(); + } + + const SSL_METHOD* SslGateway::TLS_client_method_() + { + assert(functions.fpTLS_client_method != 0); + + typedef const SSL_METHOD*(FuncType)(); + + FuncType* fp = reinterpret_cast(functions.fpTLS_client_method); + + return fp(); + } + + void SslGateway::OPENSSL_config_(const char* configName) + { + assert(functions.fpOPENSSL_config != 0); + + typedef void (FuncType)(const char*); + + FuncType* fp = reinterpret_cast(functions.fpOPENSSL_config); + + fp(configName); + } + + void SslGateway::X509_free_(X509* a) + { + assert(functions.fpX509_free != 0); + + typedef void (FuncType)(X509*); + + FuncType* fp = reinterpret_cast(functions.fpX509_free); + + fp(a); + } + + BIO* SslGateway::BIO_new_ssl_connect_(SSL_CTX* ctx) + { + assert(functions.fpBIO_new_ssl_connect != 0); + + typedef BIO*(FuncType)(SSL_CTX*); + + FuncType* fp = reinterpret_cast(functions.fpBIO_new_ssl_connect); + + return fp(ctx); + } + + void SslGateway::BIO_free_all_(BIO* a) + { + assert(functions.fpBIO_free_all != 0); + + typedef void (FuncType)(BIO*); + + FuncType* fp = reinterpret_cast(functions.fpBIO_free_all); + + fp(a); + } + + long SslGateway::BIO_ctrl_(BIO* bp, int cmd, long larg, void* parg) + { + assert(functions.fpBIO_ctrl != 0); + + typedef long (FuncType)(BIO*, int, long, void*); + + FuncType* fp = reinterpret_cast(functions.fpBIO_ctrl); + + return fp(bp, cmd, larg, parg); + } + + long SslGateway::BIO_get_fd_(BIO* bp, int* fd) + { + return BIO_ctrl_(bp, BIO_C_GET_FD, 0, reinterpret_cast(fd)); + } + + long SslGateway::BIO_get_ssl_(BIO* bp, SSL** ssl) + { + return BIO_ctrl_(bp, BIO_C_GET_SSL, 0, reinterpret_cast(ssl)); + } + + long SslGateway::BIO_set_nbio_(BIO* bp, long n) + { + return BIO_ctrl_(bp, BIO_C_SET_NBIO, n, NULL); + } + + long SslGateway::BIO_set_conn_hostname_(BIO* bp, const char* name) + { + return BIO_ctrl_(bp, BIO_C_SET_CONNECT, 0, const_cast(name)); + } + + unsigned long SslGateway::ERR_get_error_() + { + assert(functions.fpERR_get_error != 0); + + typedef unsigned long (FuncType)(); + + FuncType* fp = reinterpret_cast(functions.fpERR_get_error); + + return fp(); + } + + void SslGateway::ERR_error_string_n_(unsigned long e, char* buf, size_t len) + { + assert(functions.fpERR_error_string_n != 0); + + typedef void (FuncType)(unsigned long, char*, size_t); + + FuncType* fp = reinterpret_cast(functions.fpERR_error_string_n); + + fp(e, buf, len); + } + + void SslGateway::ERR_print_errors_fp_(FILE* fd) + { + if (!functions.fpERR_print_errors_fp) + return; + + typedef void (FuncType)(FILE*); + + FuncType* fp = reinterpret_cast(functions.fpERR_print_errors_fp); + + fp(fd); + } } } } diff --git a/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp b/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp index 24ff48f215f7c..4031d4611ef91 100644 --- a/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp +++ b/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp @@ -814,6 +814,33 @@ BOOST_AUTO_TEST_CASE(CacheClientDefaultDynamicCache) } } +BOOST_AUTO_TEST_CASE(CacheClientDefaultDynamicCacheThreeNodes) +{ + StartNode("node1"); + StartNode("node2"); + + IgniteClientConfiguration cfg; + cfg.SetEndPoints("127.0.0.1:11110..11120"); + + IgniteClient client = IgniteClient::Start(cfg); + + cache::CacheClient cache = + client.CreateCache("defaultdynamic3"); + + cache.RefreshAffinityMapping(); + + for (int64_t i = 1; i < 1000; ++i) + cache.Put(ignite::common::LexicalCast(i * 39916801), i * 5039); + + for (int64_t i = 1; i < 1000; ++i) + { + int64_t val; + LocalPeek(cache, ignite::common::LexicalCast(i * 39916801), val); + + BOOST_CHECK_EQUAL(val, i * 5039); + } +} + BOOST_AUTO_TEST_CASE(CacheClientGetAllContainers) { IgniteClientConfiguration cfg; diff --git a/modules/platforms/cpp/thin-client-test/src/ssl_test.cpp b/modules/platforms/cpp/thin-client-test/src/ssl_test.cpp index 6bfda493a3005..eaadd9b26c59f 100644 --- a/modules/platforms/cpp/thin-client-test/src/ssl_test.cpp +++ b/modules/platforms/cpp/thin-client-test/src/ssl_test.cpp @@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(SslConnectionReject2) cfg.SetEndPoints("127.0.0.1:11110"); cfg.SetSslMode(SslMode::DISABLE); - + BOOST_CHECK_THROW(IgniteClient::Start(cfg), ignite::IgniteError); } diff --git a/modules/platforms/cpp/thin-client/Makefile.am b/modules/platforms/cpp/thin-client/Makefile.am index f8d919012fade..1efff8ea44341 100644 --- a/modules/platforms/cpp/thin-client/Makefile.am +++ b/modules/platforms/cpp/thin-client/Makefile.am @@ -63,6 +63,7 @@ libignite_thin_client_la_SOURCES = \ src/impl/data_router.cpp \ src/impl/ssl/ssl_gateway.cpp \ src/impl/ssl/secure_socket_client.cpp \ + src/impl/ssl/ssl_api.cpp \ src/ignite_client.cpp clean-local: diff --git a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj b/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj index 3221268d37f1f..9c0091380cafa 100644 --- a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj +++ b/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj @@ -166,6 +166,7 @@ + @@ -195,7 +196,7 @@ - + @@ -210,4 +211,4 @@ - + \ No newline at end of file diff --git a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj.filters b/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj.filters index 2d20106f35572..a5cad74bcb705 100644 --- a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj.filters +++ b/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj.filters @@ -67,6 +67,9 @@ Code\impl\cache + + Code\impl\ssl + @@ -123,9 +126,6 @@ Code\impl\ssl - - Code\impl\ssl - Code\impl\ssl @@ -153,5 +153,8 @@ Code\impl\cache + + Code\impl\ssl + - + \ No newline at end of file diff --git a/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp b/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp index 6b40d811b64f0..592dba331fc9e 100644 --- a/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp +++ b/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp @@ -23,7 +23,7 @@ #include #include "impl/message.h" -#include "impl/ssl/ssl_gateway.h" +#include "impl/ssl/ssl_api.h" #include "impl/ssl/secure_socket_client.h" #include "impl/net/tcp_socket_client.h" #include "impl/net/remote_type_updater.h" @@ -81,7 +81,7 @@ namespace ignite if (sslMode != SslMode::DISABLE) { - ssl::SslGateway::GetInstance().LoadAll(); + ssl::EnsureSslLoaded(); socket.reset(new ssl::SecureSocketClient(config.GetSslCertFile(), config.GetSslKeyFile(), config.GetSslCaFile())); diff --git a/modules/platforms/cpp/thin-client/src/impl/ssl/secure_socket_client.cpp b/modules/platforms/cpp/thin-client/src/impl/ssl/secure_socket_client.cpp index e7e60b6e55e61..5a9b7f4afd24c 100644 --- a/modules/platforms/cpp/thin-client/src/impl/ssl/secure_socket_client.cpp +++ b/modules/platforms/cpp/thin-client/src/impl/ssl/secure_socket_client.cpp @@ -24,12 +24,15 @@ #include "impl/net/tcp_socket_client.h" #include "impl/ssl/secure_socket_client.h" -#include "impl/ssl/ssl_bindings.h" + +#include "impl/ssl/ssl_gateway.h" #ifndef SOCKET_ERROR # define SOCKET_ERROR (-1) #endif // SOCKET_ERROR +enum { OPERATION_SUCCESS = 1 }; + namespace ignite { namespace impl @@ -55,12 +58,14 @@ namespace ignite CloseInteral(); if (context) - ssl::SSL_CTX_free(reinterpret_cast(context)); + SslGateway::GetInstance().SSL_CTX_free_(reinterpret_cast(context)); } bool SecureSocketClient::Connect(const char* hostname, uint16_t port, int32_t timeout) { - assert(SslGateway::GetInstance().Loaded()); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); if (!context) { @@ -77,34 +82,34 @@ namespace ignite if (!ssl0) return false; - int res = ssl::SSL_set_tlsext_host_name_(ssl0, hostname); + int res = sslGateway.SSL_set_tlsext_host_name_(ssl0, hostname); if (res != OPERATION_SUCCESS) { - ssl::SSL_free_(ssl0); + sslGateway.SSL_free_(ssl0); std::string err = "Can not set host name for secure connection: " + GetSslError(ssl0, res); throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, err.c_str()); } - ssl::SSL_set_connect_state_(ssl0); + sslGateway.SSL_set_connect_state_(ssl0); bool connected = CompleteConnectInternal(ssl0, timeout); if (!connected) { - ssl::SSL_free_(ssl0); + sslGateway.SSL_free_(ssl0); return false; } // Verify a server certificate was presented during the negotiation - X509* cert = ssl::SSL_get_peer_certificate(ssl0); + X509* cert = sslGateway.SSL_get_peer_certificate_(ssl0); if (cert) - ssl::X509_free(cert); + sslGateway.X509_free_(cert); else { - ssl::SSL_free_(ssl0); + sslGateway.SSL_free_(ssl0); // std::string err = "Remote host did not provide certificate: " + GetSslError(ssl0, res); @@ -113,10 +118,10 @@ namespace ignite // Verify the result of chain verification // Verification performed according to RFC 4158 - res = ssl::SSL_get_verify_result(ssl0); + res = sslGateway.SSL_get_verify_result_(ssl0); if (X509_V_OK != res) { - ssl::SSL_free_(ssl0); + sslGateway.SSL_free_(ssl0); // std::string err = "Certificate chain verification failed: " + GetSslError(ssl0, res); @@ -135,7 +140,9 @@ namespace ignite int SecureSocketClient::Send(const int8_t* data, size_t size, int32_t timeout) { - assert(SslGateway::GetInstance().Loaded()); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); if (!ssl) { @@ -145,14 +152,16 @@ namespace ignite SSL* ssl0 = reinterpret_cast(ssl); - int res = ssl::SSL_write_(ssl0, data, static_cast(size)); + int res = sslGateway.SSL_write_(ssl0, data, static_cast(size)); return res; } int SecureSocketClient::Receive(int8_t* buffer, size_t size, int32_t timeout) { - assert(SslGateway::GetInstance().Loaded()); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); if (!ssl) { @@ -164,7 +173,7 @@ namespace ignite int res = 0; - if (!blocking && ssl::SSL_pending_(ssl0) == 0) + if (!blocking && sslGateway.SSL_pending_(ssl0) == 0) { res = WaitOnSocket(ssl, timeout, true); @@ -172,7 +181,7 @@ namespace ignite return res; } - res = ssl::SSL_read_(ssl0, buffer, static_cast(size)); + res = sslGateway.SSL_read_(ssl0, buffer, static_cast(size)); return res; } @@ -185,76 +194,58 @@ namespace ignite void* SecureSocketClient::MakeContext(const std::string& certPath, const std::string& keyPath, const std::string& caPath) { - assert(SslGateway::GetInstance().Loaded()); - - static bool sslLibInited = false; - static common::concurrent::CriticalSection sslCs; + SslGateway &sslGateway = SslGateway::GetInstance(); - if (!sslLibInited) - { - common::concurrent::CsLockGuard lock(sslCs); - - if (!sslLibInited) - { - (void)SSL_library_init(); + assert(sslGateway.Loaded()); - SSL_load_error_strings(); - - OPENSSL_config(0); - - sslLibInited = true; - } - } - - const SSL_METHOD* method = ssl::SSLv23_client_method_(); + const SSL_METHOD* method = sslGateway.SSLv23_client_method_(); if (!method) throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not get SSL method"); - SSL_CTX* ctx = ssl::SSL_CTX_new(method); + SSL_CTX* ctx = sslGateway.SSL_CTX_new_(method); if (!ctx) throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not create new SSL context"); - ssl::SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0); + sslGateway.SSL_CTX_set_verify_(ctx, SSL_VERIFY_PEER, 0); - ssl::SSL_CTX_set_verify_depth(ctx, 8); + sslGateway.SSL_CTX_set_verify_depth_(ctx, 8); - const long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION; - ssl::SSL_CTX_ctrl(ctx, SSL_CTRL_OPTIONS, flags, NULL); + sslGateway.SSL_CTX_set_options_(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION); const char* cCaPath = caPath.empty() ? 0 : caPath.c_str(); - long res = ssl::SSL_CTX_load_verify_locations(ctx, cCaPath, 0); + long res = sslGateway.SSL_CTX_load_verify_locations_(ctx, cCaPath, 0); if (res != OPERATION_SUCCESS) { - ssl::SSL_CTX_free(ctx); + sslGateway.SSL_CTX_free_(ctx); throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not set Certificate Authority path for secure connection"); } - res = ssl::SSL_CTX_use_certificate_chain_file(ctx, certPath.c_str()); + res = sslGateway.SSL_CTX_use_certificate_chain_file_(ctx, certPath.c_str()); if (res != OPERATION_SUCCESS) { - ssl::SSL_CTX_free(ctx); + sslGateway.SSL_CTX_free_(ctx); throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not set client certificate file for secure connection"); } - res = ssl::SSL_CTX_use_RSAPrivateKey_file(ctx, keyPath.c_str(), SSL_FILETYPE_PEM); + res = sslGateway.SSL_CTX_use_RSAPrivateKey_file_(ctx, keyPath.c_str(), SSL_FILETYPE_PEM); if (res != OPERATION_SUCCESS) { - ssl::SSL_CTX_free(ctx); + sslGateway.SSL_CTX_free_(ctx); throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not set private key file for secure connection"); } const char* const PREFERRED_CIPHERS = "HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4"; - res = ssl::SSL_CTX_set_cipher_list(ctx, PREFERRED_CIPHERS); + res = sslGateway.SSL_CTX_set_cipher_list_(ctx, PREFERRED_CIPHERS); if (res != OPERATION_SUCCESS) { - ssl::SSL_CTX_free(ctx); + sslGateway.SSL_CTX_free_(ctx); throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not set ciphers list for secure connection"); @@ -265,30 +256,34 @@ namespace ignite void* SecureSocketClient::MakeSsl(void* context, const char* hostname, uint16_t port, bool& blocking) { - BIO* bio = ssl::BIO_new_ssl_connect(reinterpret_cast(context)); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); + + BIO* bio = sslGateway.BIO_new_ssl_connect_(reinterpret_cast(context)); if (!bio) throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not create SSL connection."); - blocking = ssl::BIO_set_nbio_(bio, 1) != OPERATION_SUCCESS; + blocking = sslGateway.BIO_set_nbio_(bio, 1) != OPERATION_SUCCESS; std::stringstream stream; stream << hostname << ":" << port; std::string address = stream.str(); - long res = ssl::BIO_set_conn_hostname_(bio, address.c_str()); + long res = sslGateway.BIO_set_conn_hostname_(bio, address.c_str()); if (res != OPERATION_SUCCESS) { - ssl::BIO_free_all(bio); + sslGateway.BIO_free_all_(bio); throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not set SSL connection hostname."); } SSL* ssl = 0; - ssl::BIO_get_ssl_(bio, &ssl); + sslGateway.BIO_get_ssl_(bio, &ssl); if (!ssl) { - ssl::BIO_free_all(bio); + sslGateway.BIO_free_all_(bio); throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Can not get SSL instance from BIO."); } @@ -298,21 +293,25 @@ namespace ignite bool SecureSocketClient::CompleteConnectInternal(void* ssl, int timeout) { + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); + SSL* ssl0 = reinterpret_cast(ssl); while (true) { - int res = ssl::SSL_connect_(ssl0); + int res = sslGateway.SSL_connect_(ssl0); if (res == OPERATION_SUCCESS) return true; - int sslError = ssl::SSL_get_error_(ssl0, res); + int sslError = sslGateway.SSL_get_error_(ssl0, res); if (IsActualError(sslError)) return false; - int want = ssl::SSL_want_(ssl0); + int want = sslGateway.SSL_want_(ssl0); res = WaitOnSocket(ssl, timeout, want == SSL_READING); @@ -326,9 +325,13 @@ namespace ignite std::string SecureSocketClient::GetSslError(void* ssl, int ret) { + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); + SSL* ssl0 = reinterpret_cast(ssl); - int sslError = ssl::SSL_get_error_(ssl0, ret); + int sslError = sslGateway.SSL_get_error_(ssl0, ret); switch (sslError) { @@ -345,11 +348,11 @@ namespace ignite return std::string("SSL error: ") + common::LexicalCast(sslError); } - long error = ssl::ERR_get_error_(); + long error = sslGateway.ERR_get_error_(); char errBuf[1024] = { 0 }; - ssl::ERR_error_string_n_(error, errBuf, sizeof(errBuf)); + sslGateway.ERR_error_string_n_(error, errBuf, sizeof(errBuf)); return std::string(errBuf); } @@ -373,11 +376,13 @@ namespace ignite void SecureSocketClient::CloseInteral() { - assert(SslGateway::GetInstance().Loaded()); + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); if (ssl) { - ssl::SSL_free_(reinterpret_cast(ssl)); + sslGateway.SSL_free_(reinterpret_cast(ssl)); ssl = 0; } @@ -385,13 +390,17 @@ namespace ignite int SecureSocketClient::WaitOnSocket(void* ssl, int32_t timeout, bool rd) { + SslGateway &sslGateway = SslGateway::GetInstance(); + + assert(sslGateway.Loaded()); + int ready = 0; int lastError = 0; SSL* ssl0 = reinterpret_cast(ssl); fd_set fds; - int fd = ssl::SSL_get_fd_(ssl0); + int fd = sslGateway.SSL_get_fd_(ssl0); if (fd < 0) { diff --git a/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_api.cpp b/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_api.cpp new file mode 100644 index 0000000000000..a1da21524d6f1 --- /dev/null +++ b/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_api.cpp @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#include "impl/ssl/ssl_gateway.h" +#include "impl/ssl/ssl_api.h" + +namespace ignite +{ + namespace impl + { + namespace thin + { + namespace ssl + { + void EnsureSslLoaded() + { + SslGateway::GetInstance().LoadAll(); + } + } + } + } +} diff --git a/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_api.h b/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_api.h new file mode 100644 index 0000000000000..8d6b72dbd00f6 --- /dev/null +++ b/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_api.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#ifndef _IGNITE_IMPL_THIN_SSL_SSL_API +#define _IGNITE_IMPL_THIN_SSL_SSL_API + + +namespace ignite +{ + namespace impl + { + namespace thin + { + namespace ssl + { + void EnsureSslLoaded(); + } + } + } +} + +#endif //_IGNITE_IMPL_THIN_SSL_SSL_API \ No newline at end of file diff --git a/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_bindings.h b/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_bindings.h deleted file mode 100644 index 05ad00d9354ce..0000000000000 --- a/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_bindings.h +++ /dev/null @@ -1,360 +0,0 @@ -/* - * 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. - */ - -#ifndef _IGNITE_IMPL_THIN_SSL_SSL_BINDINGS -#define _IGNITE_IMPL_THIN_SSL_SSL_BINDINGS - -#include -#include -#include - -#include "impl/ssl/ssl_gateway.h" - -namespace ignite -{ - namespace impl - { - namespace thin - { - namespace ssl - { - // Declaring constant used by OpenSSL for readability. - enum { OPERATION_SUCCESS = 1 }; - - inline SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) - { - typedef SSL_CTX*(FuncType)(const SSL_METHOD*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_CTX_new); - - return fp(meth); - } - - inline void SSL_CTX_free(SSL_CTX *ctx) - { - typedef void(FuncType)(SSL_CTX*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_CTX_free); - - fp(ctx); - } - - inline void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, int(*callback) (int, X509_STORE_CTX *)) - { - typedef void(FuncType)(SSL_CTX*, int, int(*)(int, X509_STORE_CTX*)); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_set_verify); - - fp(ctx, mode, callback); - } - - inline void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth) - { - typedef void(FuncType)(SSL_CTX*, int); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_set_verify_depth); - - fp(ctx, depth); - } - - inline int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *cAfile, const char *cApath) - { - typedef int(FuncType)(SSL_CTX*, const char*, const char*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_load_verify_locations); - - return fp(ctx, cAfile, cApath); - } - - inline int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) - { - typedef int(FuncType)(SSL_CTX*, const char*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_use_certificate_chain_file); - - return fp(ctx, file); - } - - inline int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type) - { - typedef int(FuncType)(SSL_CTX*, const char*, int); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_use_RSAPrivateKey_file); - - return fp(ctx, file, type); - } - - inline int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) - { - typedef int(FuncType)(SSL_CTX*, const char*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_CTX_set_cipher_list); - - return fp(ctx, str); - } - - inline long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) - { - typedef long(FuncType)(SSL_CTX*, int, long, void*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_CTX_ctrl); - - return fp(ctx, cmd, larg, parg); - } - - inline long SSL_get_verify_result(const SSL *s) - { - typedef long(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_get_verify_result); - - return fp(s); - } - - inline int SSL_library_init() - { - typedef int(FuncType)(); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_library_init); - - return fp(); - } - - inline void SSL_load_error_strings() - { - typedef void(FuncType)(); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_load_error_strings); - - fp(); - } - - inline X509 *SSL_get_peer_certificate(const SSL *s) - { - typedef X509*(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_get_peer_certificate); - - return fp(s); - } - - inline long SSL_ctrl(SSL *s, int cmd, long larg, void *parg) - { - typedef long(FuncType)(SSL*, int, long, void*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_ctrl); - - return fp(s, cmd, larg ,parg); - } - - inline long SSL_set_tlsext_host_name_(SSL *s, const char *name) - { - return ssl::SSL_ctrl(s, SSL_CTRL_SET_TLSEXT_HOSTNAME, - TLSEXT_NAMETYPE_host_name, const_cast(name)); - } - - inline void SSL_set_connect_state_(SSL* s) - { - typedef void(FuncType)(SSL*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSL_set_connect_state); - - return fp(s); - } - - inline int SSL_connect_(SSL* s) - { - typedef int(FuncType)(SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_connect); - - return fp(s); - } - - inline int SSL_get_error_(const SSL *s, int ret) - { - typedef int(FuncType)(const SSL*, int); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_get_error); - - return fp(s, ret); - } - - inline int SSL_want_(const SSL *s) - { - typedef int(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_want); - - return fp(s); - } - - inline int SSL_write_(SSL *s, const void *buf, int num) - { - typedef int(FuncType)(SSL*, const void*, int); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_write); - - return fp(s, buf, num); - } - - inline int SSL_read_(SSL *s, void *buf, int num) - { - typedef int(FuncType)(SSL*, void*, int); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_read); - - return fp(s, buf, num); - } - - inline int SSL_pending_(const SSL *ssl) - { - typedef int(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_pending); - - return fp(ssl); - } - - inline int SSL_get_fd_(const SSL *ssl) - { - typedef int(FuncType)(const SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_get_fd); - - return fp(ssl); - } - - inline void SSL_free_(SSL *ssl) - { - typedef void(FuncType)(SSL*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpSSL_free); - - fp(ssl); - } - - inline const SSL_METHOD *SSLv23_client_method_() - { - typedef const SSL_METHOD*(FuncType)(); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpSSLv23_client_method); - - return fp(); - } - - inline void OPENSSL_config(const char *configName) - { - typedef void(FuncType)(const char*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpOPENSSL_config); - - fp(configName); - } - - inline void X509_free(X509 *a) - { - typedef void(FuncType)(X509*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpX509_free); - - fp(a); - } - - inline BIO *BIO_new_ssl_connect(SSL_CTX *ctx) - { - typedef BIO*(FuncType)(SSL_CTX*); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpBIO_new_ssl_connect); - - return fp(ctx); - } - - inline void BIO_free_all(BIO *a) - { - typedef void(FuncType)(BIO*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpBIO_free_all); - - fp(a); - } - - inline long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg) - { - typedef long(FuncType)(BIO*, int, long, void*); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpBIO_ctrl); - - return fp(bp, cmd, larg, parg); - } - - inline long BIO_get_fd_(BIO *bp, int *fd) - { - return ssl::BIO_ctrl(bp, BIO_C_GET_FD, 0, reinterpret_cast(fd)); - } - - inline long BIO_get_ssl_(BIO *bp, SSL** ssl) - { - return ssl::BIO_ctrl(bp, BIO_C_GET_SSL, 0, reinterpret_cast(ssl)); - } - - inline long BIO_set_nbio_(BIO *bp, long n) - { - return ssl::BIO_ctrl(bp, BIO_C_SET_NBIO, n, NULL); - } - - inline long BIO_set_conn_hostname_(BIO *bp, const char *name) - { - return ssl::BIO_ctrl(bp, BIO_C_SET_CONNECT, 0, const_cast(name)); - } - - inline unsigned long ERR_get_error_() - { - typedef unsigned long(FuncType)(); - - FuncType* fp = reinterpret_cast(SslGateway::GetInstance().GetFunctions().fpERR_get_error); - - return fp(); - } - - inline void ERR_error_string_n_(unsigned long e, char *buf, size_t len) - { - typedef void(FuncType)(unsigned long, char*, size_t); - - FuncType* fp = reinterpret_cast( - SslGateway::GetInstance().GetFunctions().fpERR_error_string_n); - - fp(e, buf, len); - } - } - } - } -} - -#endif //_IGNITE_IMPL_THIN_SSL_SSL_BINDINGS \ No newline at end of file diff --git a/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_gateway.cpp b/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_gateway.cpp index 380fe0f1843fd..42ed88dc7d47c 100644 --- a/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_gateway.cpp +++ b/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_gateway.cpp @@ -26,6 +26,18 @@ # define ADDITIONAL_OPENSSL_HOME_ENV "OPEN_SSL_HOME" #endif // ADDITIONAL_OPENSSL_HOME_ENV +#ifndef SSL_CTRL_OPTIONS +# define SSL_CTRL_OPTIONS 32 +#endif // SSL_CTRL_OPTIONS + +#ifndef OPENSSL_INIT_LOAD_SSL_STRINGS +# define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L +#endif // OPENSSL_INIT_LOAD_SSL_STRINGS + +#ifndef OPENSSL_INIT_LOAD_CRYPTO_STRINGS +# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L +#endif // OPENSSL_INIT_LOAD_CRYPTO_STRINGS + namespace ignite { namespace impl @@ -38,7 +50,7 @@ namespace ignite inited(false), functions() { - // No-op. + memset(&functions, 0, sizeof(functions)); } SslGateway::~SslGateway() @@ -46,41 +58,61 @@ namespace ignite // No-op. } + void SslGateway::UnloadAll() + { + libeay32.Unload(); + ssleay32.Unload(); + libssl.Unload(); + libcrypto.Unload(); + + memset(&functions, 0, sizeof(functions)); + } + common::dynamic::Module SslGateway::LoadSslLibrary(const char* name) { using namespace common; using namespace dynamic; - std::string fullName = GetDynamicLibraryName(name); - - Module libModule = LoadModule(fullName); - - if (libModule.IsLoaded()) - return libModule; - std::string home = GetEnv(ADDITIONAL_OPENSSL_HOME_ENV); if (home.empty()) home = GetEnv("OPENSSL_HOME"); - if (home.empty()) - return libModule; + std::string fullName = GetDynamicLibraryName(name); + + if (!home.empty()) + { + std::stringstream constructor; - std::stringstream constructor; + constructor << home << Fs << "bin" << Fs << fullName; - constructor << home << Fs << "bin" << Fs << fullName; + std::string fullPath = constructor.str(); - std::string fullPath = constructor.str(); + Module mod = LoadModule(fullPath); - return LoadModule(fullPath); + if (mod.IsLoaded()) + return mod; + } + + return LoadModule(fullName); } void SslGateway::LoadSslLibraries() { - libeay32 = LoadSslLibrary("libeay32"); - ssleay32 = LoadSslLibrary("ssleay32"); libssl = LoadSslLibrary("libssl"); + if (!libssl.IsLoaded()) + { + libcrypto = LoadSslLibrary("libcrypto-1_1-x64"); + libssl = LoadSslLibrary("libssl-1_1-x64"); + } + + if (!libssl.IsLoaded()) + { + libeay32 = LoadSslLibrary("libeay32"); + ssleay32 = LoadSslLibrary("ssleay32"); + } + if (!libssl.IsLoaded() && (!libeay32.IsLoaded() || !ssleay32.IsLoaded())) { if (!libssl.IsLoaded()) @@ -89,44 +121,37 @@ namespace ignite std::stringstream ss; - ss << "Can not load neccessary OpenSSL libraries: "; + ss << "Can not load neccessary OpenSSL libraries:"; if (!libeay32.IsLoaded()) - ss << "libeay32"; + ss << " libeay32"; if (!ssleay32.IsLoaded()) ss << " ssleay32"; - libeay32.Unload(); - ssleay32.Unload(); - libssl.Unload(); - std::string res = ss.str(); throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, res.c_str()); } } - SslGateway& SslGateway::GetInstance() + void SslGateway::LoadMandatoryMethods() { - static SslGateway self; + functions.fpSSLeay_version = TryLoadSslMethod("SSLeay_version"); - return self; - } - - void SslGateway::LoadAll() - { - using namespace common::dynamic; + if (!functions.fpSSLeay_version) + functions.fpOpenSSL_version = LoadSslMethod("OpenSSL_version"); - if (inited) - return; + functions.fpSSL_library_init = TryLoadSslMethod("SSL_library_init"); + functions.fpSSL_load_error_strings = TryLoadSslMethod("SSL_load_error_strings"); - common::concurrent::CsLockGuard lock(initCs); + if (!functions.fpSSL_library_init || !functions.fpSSL_load_error_strings) + functions.fpOPENSSL_init_ssl = LoadSslMethod("OPENSSL_init_ssl"); - if (inited) - return; + functions.fpSSLv23_client_method = TryLoadSslMethod("SSLv23_client_method"); - LoadSslLibraries(); + if (!functions.fpSSLv23_client_method) + functions.fpTLS_client_method = LoadSslMethod("TLS_client_method"); functions.fpSSL_CTX_new = LoadSslMethod("SSL_CTX_new"); functions.fpSSL_CTX_free = LoadSslMethod("SSL_CTX_free"); @@ -138,13 +163,11 @@ namespace ignite functions.fpSSL_CTX_set_cipher_list = LoadSslMethod("SSL_CTX_set_cipher_list"); functions.fpSSL_get_verify_result = LoadSslMethod("SSL_get_verify_result"); - functions.fpSSL_library_init = LoadSslMethod("SSL_library_init"); - functions.fpSSL_load_error_strings = LoadSslMethod("SSL_load_error_strings"); + functions.fpSSL_get_peer_certificate = LoadSslMethod("SSL_get_peer_certificate"); functions.fpSSL_ctrl = LoadSslMethod("SSL_ctrl"); functions.fpSSL_CTX_ctrl = LoadSslMethod("SSL_CTX_ctrl"); - functions.fpSSLv23_client_method = LoadSslMethod("SSLv23_client_method"); functions.fpSSL_set_connect_state = LoadSslMethod("SSL_set_connect_state"); functions.fpSSL_connect = LoadSslMethod("SSL_connect"); functions.fpSSL_get_error = LoadSslMethod("SSL_get_error"); @@ -164,60 +187,67 @@ namespace ignite functions.fpERR_get_error = LoadSslMethod("ERR_get_error"); functions.fpERR_error_string_n = LoadSslMethod("ERR_error_string_n"); + } - bool allLoaded = - functions.fpSSL_CTX_new != 0 && - functions.fpSSL_CTX_free != 0 && - functions.fpSSL_CTX_set_verify != 0 && - functions.fpSSL_CTX_set_verify_depth != 0 && - functions.fpSSL_CTX_load_verify_locations != 0 && - functions.fpSSL_CTX_use_certificate_chain_file != 0 && - functions.fpSSL_CTX_use_RSAPrivateKey_file != 0 && - functions.fpSSL_CTX_set_cipher_list != 0 && - functions.fpSSL_get_verify_result != 0 && - functions.fpSSL_library_init != 0 && - functions.fpSSL_load_error_strings != 0 && - functions.fpSSL_get_peer_certificate != 0 && - functions.fpSSL_ctrl != 0 && - functions.fpSSL_CTX_ctrl != 0 && - functions.fpSSLv23_client_method != 0 && - functions.fpSSL_set_connect_state != 0 && - functions.fpSSL_connect != 0 && - functions.fpSSL_get_error != 0 && - functions.fpSSL_want != 0 && - functions.fpSSL_write != 0 && - functions.fpSSL_read != 0 && - functions.fpSSL_pending != 0 && - functions.fpSSL_get_fd != 0 && - functions.fpSSL_free != 0 && - functions.fpBIO_new_ssl_connect != 0 && - functions.fpOPENSSL_config != 0 && - functions.fpX509_free != 0 && - functions.fpBIO_free_all != 0 && - functions.fpBIO_ctrl != 0 && - functions.fpERR_get_error != 0 && - functions.fpERR_error_string_n != 0; - - if (!allLoaded) - { - libeay32.Unload(); - ssleay32.Unload(); - libssl.Unload(); - } + SslGateway& SslGateway::GetInstance() + { + static SslGateway self; - inited = allLoaded; + return self; } - void* SslGateway::LoadSslMethod(const char* name) + void SslGateway::LoadAll() + { + using namespace common::dynamic; + + if (inited) + return; + + common::concurrent::CsLockGuard lock(initCs); + + if (inited) + return; + + common::MethodGuard guard(this, &SslGateway::UnloadAll); + + LoadSslLibraries(); + + LoadMandatoryMethods(); + + functions.fpSSL_CTX_set_options = TryLoadSslMethod("SSL_CTX_set_options"); + functions.fpERR_print_errors_fp = TryLoadSslMethod("ERR_print_errors_fp"); + + (void)SSL_library_init_(); + + SSL_load_error_strings_(); + + OPENSSL_config_(0); + + guard.Release(); + + inited = true; + } + + void* SslGateway::TryLoadSslMethod(const char* name) { void* fp = libeay32.FindSymbol(name); if (!fp) fp = ssleay32.FindSymbol(name); + if (!fp) + fp = libcrypto.FindSymbol(name); + if (!fp) fp = libssl.FindSymbol(name); + return fp; + } + + void* SslGateway::LoadSslMethod(const char* name) + { + void* fp = TryLoadSslMethod(name); + if (!fp) { std::stringstream ss; @@ -231,6 +261,448 @@ namespace ignite return fp; } + + char* SslGateway::SSLeay_version_(int type) + { + typedef char* (FuncType)(int); + + FuncType* fp = 0; + + if (functions.fpSSLeay_version) + fp = reinterpret_cast(functions.fpSSLeay_version); + else + fp = reinterpret_cast(functions.fpOpenSSL_version); + + assert(fp != 0); + + return fp(type); + } + + int SslGateway::OPENSSL_init_ssl_(uint64_t opts, const void* settings) + { + assert(functions.fpOPENSSL_init_ssl != 0); + + typedef int (FuncType)(uint64_t, const void*); + + FuncType* fp = reinterpret_cast(functions.fpOPENSSL_init_ssl); + + return fp(opts, settings); + } + + long SslGateway::SSL_CTX_set_options_(SSL_CTX* ctx, long options) + { + if (functions.fpSSL_CTX_set_options) + { + typedef long (FuncType)(SSL_CTX*, long); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_set_options); + + return fp(ctx, options); + } + + return SSL_CTX_ctrl_(ctx, SSL_CTRL_OPTIONS, options, NULL); + } + + long SslGateway::SSL_CTX_ctrl_(SSL_CTX* ctx, int cmd, long larg, void* parg) + { + assert(functions.fpSSL_CTX_ctrl != 0); + + typedef long (FuncType)(SSL_CTX*, int, long, void*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_ctrl); + + return fp(ctx, cmd, larg, parg); + } + + SSL_CTX* SslGateway::SSL_CTX_new_(const SSL_METHOD* meth) + { + assert(functions.fpSSL_CTX_new != 0); + + typedef SSL_CTX*(FuncType)(const SSL_METHOD*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_new); + + return fp(meth); + } + + void SslGateway::SSL_CTX_free_(SSL_CTX* ctx) + { + assert(functions.fpSSL_CTX_free != 0); + + typedef void (FuncType)(SSL_CTX*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_free); + + fp(ctx); + } + + void SslGateway::SSL_CTX_set_verify_(SSL_CTX* ctx, int mode, int (* callback)(int, X509_STORE_CTX*)) + { + assert(functions.fpSSL_CTX_set_verify != 0); + + typedef void (FuncType)(SSL_CTX*, int, int (*)(int, X509_STORE_CTX*)); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_set_verify); + + fp(ctx, mode, callback); + } + + void SslGateway::SSL_CTX_set_verify_depth_(SSL_CTX* ctx, int depth) + { + assert(functions.fpSSL_CTX_set_verify_depth != 0); + + typedef void (FuncType)(SSL_CTX*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_set_verify_depth); + + fp(ctx, depth); + } + + int SslGateway::SSL_CTX_load_verify_locations_(SSL_CTX* ctx, const char* cAfile, const char* cApath) + { + assert(functions.fpSSL_CTX_load_verify_locations != 0); + + typedef int (FuncType)(SSL_CTX*, const char*, const char*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_load_verify_locations); + + return fp(ctx, cAfile, cApath); + } + + int SslGateway::SSL_CTX_use_certificate_chain_file_(SSL_CTX* ctx, const char* file) + { + assert(functions.fpSSL_CTX_use_certificate_chain_file != 0); + + typedef int (FuncType)(SSL_CTX*, const char*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_use_certificate_chain_file); + + return fp(ctx, file); + } + + int SslGateway::SSL_CTX_use_RSAPrivateKey_file_(SSL_CTX* ctx, const char* file, int type) + { + assert(functions.fpSSL_CTX_use_RSAPrivateKey_file != 0); + + typedef int (FuncType)(SSL_CTX*, const char*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_use_RSAPrivateKey_file); + + return fp(ctx, file, type); + } + + int SslGateway::SSL_CTX_set_cipher_list_(SSL_CTX* ctx, const char* str) + { + assert(functions.fpSSL_CTX_set_cipher_list != 0); + + typedef int (FuncType)(SSL_CTX*, const char*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_CTX_set_cipher_list); + + return fp(ctx, str); + } + + long SslGateway::SSL_get_verify_result_(const SSL* s) + { + assert(functions.fpSSL_get_verify_result != 0); + + typedef long (FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_get_verify_result); + + return fp(s); + } + + int SslGateway::SSL_library_init_() + { + typedef int (FuncType)(); + + if (functions.fpSSL_library_init) + { + FuncType* fp = reinterpret_cast(functions.fpSSL_library_init); + + return fp(); + } + + return OPENSSL_init_ssl_(0, NULL); + } + + void SslGateway::SSL_load_error_strings_() + { + typedef void (FuncType)(); + + if (functions.fpSSL_load_error_strings) + { + FuncType* fp = reinterpret_cast(functions.fpSSL_load_error_strings); + + fp(); + + return; + } + + OPENSSL_init_ssl_(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); + } + + X509* SslGateway::SSL_get_peer_certificate_(const SSL* s) + { + assert(functions.fpSSL_get_peer_certificate != 0); + + typedef X509*(FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_get_peer_certificate); + + return fp(s); + } + + long SslGateway::SSL_ctrl_(SSL* s, int cmd, long larg, void* parg) + { + assert(functions.fpSSL_ctrl != 0); + + typedef long (FuncType)(SSL*, int, long, void*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_ctrl); + + return fp(s, cmd, larg, parg); + } + + long SslGateway::SSL_set_tlsext_host_name_(SSL* s, const char* name) + { + return SSL_ctrl_(s, SSL_CTRL_SET_TLSEXT_HOSTNAME, + TLSEXT_NAMETYPE_host_name, const_cast(name)); + } + + void SslGateway::SSL_set_connect_state_(SSL* s) + { + assert(functions.fpSSL_set_connect_state != 0); + + typedef void (FuncType)(SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_set_connect_state); + + return fp(s); + } + + int SslGateway::SSL_connect_(SSL* s) + { + assert(functions.fpSSL_connect != 0); + + typedef int (FuncType)(SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_connect); + + return fp(s); + } + + int SslGateway::SSL_get_error_(const SSL* s, int ret) + { + assert(functions.fpSSL_get_error != 0); + + typedef int (FuncType)(const SSL*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_get_error); + + return fp(s, ret); + } + + int SslGateway::SSL_want_(const SSL* s) + { + assert(functions.fpSSL_want != 0); + + typedef int (FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_want); + + return fp(s); + } + + int SslGateway::SSL_write_(SSL* s, const void* buf, int num) + { + assert(functions.fpSSL_write != 0); + + typedef int (FuncType)(SSL*, const void*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_write); + + return fp(s, buf, num); + } + + int SslGateway::SSL_read_(SSL* s, void* buf, int num) + { + assert(functions.fpSSL_read != 0); + + typedef int (FuncType)(SSL*, void*, int); + + FuncType* fp = reinterpret_cast(functions.fpSSL_read); + + return fp(s, buf, num); + } + + int SslGateway::SSL_pending_(const SSL* ssl) + { + assert(functions.fpSSL_pending != 0); + + typedef int (FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_pending); + + return fp(ssl); + } + + int SslGateway::SSL_get_fd_(const SSL* ssl) + { + assert(functions.fpSSL_get_fd != 0); + + typedef int (FuncType)(const SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_get_fd); + + return fp(ssl); + } + + void SslGateway::SSL_free_(SSL* ssl) + { + assert(functions.fpSSL_free != 0); + + typedef void (FuncType)(SSL*); + + FuncType* fp = reinterpret_cast(functions.fpSSL_free); + + fp(ssl); + } + + const SSL_METHOD* SslGateway::SSLv23_client_method_() + { + if (functions.fpSSLv23_client_method) + { + typedef const SSL_METHOD*(FuncType)(); + + FuncType* fp = reinterpret_cast(functions.fpSSLv23_client_method); + + return fp(); + } + + return TLS_client_method_(); + } + + const SSL_METHOD* SslGateway::TLS_client_method_() + { + assert(functions.fpTLS_client_method != 0); + + typedef const SSL_METHOD*(FuncType)(); + + FuncType* fp = reinterpret_cast(functions.fpTLS_client_method); + + return fp(); + } + + void SslGateway::OPENSSL_config_(const char* configName) + { + assert(functions.fpOPENSSL_config != 0); + + typedef void (FuncType)(const char*); + + FuncType* fp = reinterpret_cast(functions.fpOPENSSL_config); + + fp(configName); + } + + void SslGateway::X509_free_(X509* a) + { + assert(functions.fpX509_free != 0); + + typedef void (FuncType)(X509*); + + FuncType* fp = reinterpret_cast(functions.fpX509_free); + + fp(a); + } + + BIO* SslGateway::BIO_new_ssl_connect_(SSL_CTX* ctx) + { + assert(functions.fpBIO_new_ssl_connect != 0); + + typedef BIO*(FuncType)(SSL_CTX*); + + FuncType* fp = reinterpret_cast(functions.fpBIO_new_ssl_connect); + + return fp(ctx); + } + + void SslGateway::BIO_free_all_(BIO* a) + { + assert(functions.fpBIO_free_all != 0); + + typedef void (FuncType)(BIO*); + + FuncType* fp = reinterpret_cast(functions.fpBIO_free_all); + + fp(a); + } + + long SslGateway::BIO_ctrl_(BIO* bp, int cmd, long larg, void* parg) + { + assert(functions.fpBIO_ctrl != 0); + + typedef long (FuncType)(BIO*, int, long, void*); + + FuncType* fp = reinterpret_cast(functions.fpBIO_ctrl); + + return fp(bp, cmd, larg, parg); + } + + long SslGateway::BIO_get_fd_(BIO* bp, int* fd) + { + return BIO_ctrl_(bp, BIO_C_GET_FD, 0, reinterpret_cast(fd)); + } + + long SslGateway::BIO_get_ssl_(BIO* bp, SSL** ssl) + { + return BIO_ctrl_(bp, BIO_C_GET_SSL, 0, reinterpret_cast(ssl)); + } + + long SslGateway::BIO_set_nbio_(BIO* bp, long n) + { + return BIO_ctrl_(bp, BIO_C_SET_NBIO, n, NULL); + } + + long SslGateway::BIO_set_conn_hostname_(BIO* bp, const char* name) + { + return BIO_ctrl_(bp, BIO_C_SET_CONNECT, 0, const_cast(name)); + } + + unsigned long SslGateway::ERR_get_error_() + { + assert(functions.fpERR_get_error != 0); + + typedef unsigned long (FuncType)(); + + FuncType* fp = reinterpret_cast(functions.fpERR_get_error); + + return fp(); + } + + void SslGateway::ERR_error_string_n_(unsigned long e, char* buf, size_t len) + { + assert(functions.fpERR_error_string_n != 0); + + typedef void (FuncType)(unsigned long, char*, size_t); + + FuncType* fp = reinterpret_cast(functions.fpERR_error_string_n); + + fp(e, buf, len); + } + + void SslGateway::ERR_print_errors_fp_(FILE* fd) + { + if (!functions.fpERR_print_errors_fp) + return; + + typedef void (FuncType)(FILE*); + + FuncType* fp = reinterpret_cast(functions.fpERR_print_errors_fp); + + fp(fd); + } } } } diff --git a/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_gateway.h b/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_gateway.h index 440aaa867c6f9..0908c103581c1 100644 --- a/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_gateway.h +++ b/modules/platforms/cpp/thin-client/src/impl/ssl/ssl_gateway.h @@ -18,9 +18,14 @@ #ifndef _IGNITE_IMPL_THIN_SSL_SSL_LIBRARY #define _IGNITE_IMPL_THIN_SSL_SSL_LIBRARY +#include +#include +#include + #include #include + namespace ignite { namespace impl @@ -34,6 +39,7 @@ namespace ignite */ struct SslFunctions { + void *fpSSLeay_version; void *fpSSL_CTX_new; void *fpSSL_CTX_free; void *fpSSL_CTX_set_verify; @@ -65,6 +71,12 @@ namespace ignite void *fpBIO_ctrl; void *fpERR_get_error; void *fpERR_error_string_n; + void *fpERR_print_errors_fp; + + void *fpOpenSSL_version; + void *fpSSL_CTX_set_options; + void *fpOPENSSL_init_ssl; + void *fpTLS_client_method; }; /** @@ -104,6 +116,88 @@ namespace ignite return inited; } + char* SSLeay_version_(int type); + + int OPENSSL_init_ssl_(uint64_t opts, const void* settings); + + long SSL_CTX_set_options_(SSL_CTX* ctx, long options); + + long SSL_CTX_ctrl_(SSL_CTX* ctx, int cmd, long larg, void* parg); + + SSL_CTX* SSL_CTX_new_(const SSL_METHOD* meth); + + void SSL_CTX_free_(SSL_CTX* ctx); + + void SSL_CTX_set_verify_(SSL_CTX* ctx, int mode, int (*callback)(int, X509_STORE_CTX*)); + + void SSL_CTX_set_verify_depth_(SSL_CTX* ctx, int depth); + + int SSL_CTX_load_verify_locations_(SSL_CTX* ctx, const char* cAfile, const char* cApath); + + int SSL_CTX_use_certificate_chain_file_(SSL_CTX* ctx, const char* file); + + int SSL_CTX_use_RSAPrivateKey_file_(SSL_CTX* ctx, const char* file, int type); + + int SSL_CTX_set_cipher_list_(SSL_CTX* ctx, const char* str); + + long SSL_get_verify_result_(const SSL* s); + + int SSL_library_init_(); + + void SSL_load_error_strings_(); + + X509* SSL_get_peer_certificate_(const SSL* s); + + long SSL_ctrl_(SSL* s, int cmd, long larg, void* parg); + + long SSL_set_tlsext_host_name_(SSL* s, const char* name); + + void SSL_set_connect_state_(SSL* s); + + int SSL_connect_(SSL* s); + + int SSL_get_error_(const SSL* s, int ret); + + int SSL_want_(const SSL* s); + + int SSL_write_(SSL* s, const void* buf, int num); + + int SSL_read_(SSL* s, void* buf, int num); + + int SSL_pending_(const SSL* ssl); + + int SSL_get_fd_(const SSL* ssl); + + void SSL_free_(SSL* ssl); + + const SSL_METHOD* SSLv23_client_method_(); + + const SSL_METHOD* TLS_client_method_(); + + void OPENSSL_config_(const char* configName); + + void X509_free_(X509* a); + + BIO* BIO_new_ssl_connect_(SSL_CTX* ctx); + + void BIO_free_all_(BIO* a); + + long BIO_ctrl_(BIO* bp, int cmd, long larg, void* parg); + + long BIO_get_fd_(BIO* bp, int* fd); + + long BIO_get_ssl_(BIO* bp, SSL** ssl); + + long BIO_set_nbio_(BIO* bp, long n); + + long BIO_set_conn_hostname_(BIO* bp, const char* name); + + unsigned long ERR_get_error_(); + + void ERR_error_string_n_(unsigned long e, char* buf, size_t len); + + void ERR_print_errors_fp_(FILE *fd); + private: /** * Constructor. @@ -115,6 +209,11 @@ namespace ignite */ ~SslGateway(); + /** + * Unload all SSL symbols. + */ + void UnloadAll(); + /** * Load SSL library. * @param name Name. @@ -127,10 +226,28 @@ namespace ignite */ void LoadSslLibraries(); + /** + * Load mandatory SSL methods. + * + * @throw IgniteError if can not load one of the functions. + */ + void LoadMandatoryMethods(); + + /** + * Try load SSL method. + * + * @param name Name. + * @return Method pointer. + */ + void* TryLoadSslMethod(const char* name); + /** * Load SSL method. + * * @param name Name. * @return Method pointer. + * + * @throw IgniteError if the method is not present. */ void* LoadSslMethod(const char* name); @@ -146,6 +263,9 @@ namespace ignite /** ssleay32 module. */ common::dynamic::Module ssleay32; + /** libcrypto module. */ + common::dynamic::Module libcrypto; + /** libssl module. */ common::dynamic::Module libssl; diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs index 17a9bbb80cf41..37168d62c2c3d 100644 --- a/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.AspNet.Tests/Properties/AssemblyInfo.cs @@ -27,7 +27,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec b/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec index 1bc204ab28f5a..c4b163e28c915 100644 --- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec +++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec @@ -45,7 +45,7 @@ Session State Store Provider: stores session state data in a distributed in-memo More info: https://apacheignite-net.readme.io/ - Copyright 2018 + Copyright 2019 OutputCacheProvider Apache Ignite In-Memory Distributed Computing SQL NoSQL Grid Map Reduce Cache diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs index 25646bd53a14f..775fe680bbe36 100644 --- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Properties/AssemblyInfo.cs @@ -25,7 +25,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Properties/AssemblyInfo.cs index 369f4df64959d..26ccb996adbf7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Properties/AssemblyInfo.cs @@ -23,7 +23,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj index 6550a7fe6956b..2ec0bdb905951 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj @@ -42,6 +42,7 @@ + diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs index 3b49386bf27ab..9eb79eb351254 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.NuGet/Properties/AssemblyInfo.cs @@ -23,7 +23,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs index 5a18026911dae..6237c09ee235a 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Properties/AssemblyInfo.cs @@ -23,7 +23,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj index aa58afc110e68..77b68baec172d 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj @@ -94,6 +94,7 @@ + @@ -115,6 +116,7 @@ + diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheParityTest.cs index 7548740c04711..d0a103fabd6a8 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheParityTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheParityTest.cs @@ -57,7 +57,10 @@ public class CacheParityTest "sizeLongAsync", // IGNITE-6563 "localSizeLong", // IGNITE-6563 "enableStatistics", // IGNITE-7276 - "clearStatistics" // IGNITE-9017 + "clearStatistics", // IGNITE-9017 + "preloadPartition", // IGNITE-9998 + "preloadPartitionAsync", // IGNITE-9998 + "localPreloadPartition", // IGNITE-9998 }; /// diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteConfigurationParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteConfigurationParityTest.cs index 71d2ba07a9511..a50d48a64a32c 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteConfigurationParityTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteConfigurationParityTest.cs @@ -81,7 +81,8 @@ public class IgniteConfigurationParityTest "TimeServerPortBase", "TimeServerPortRange", "IncludeProperties", - "isAutoActivationEnabled" // IGNITE-7301 + "isAutoActivationEnabled", // IGNITE-7301 + "NetworkCompressionLevel" }; /// diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/TcpCommunicationSpiParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/TcpCommunicationSpiParityTest.cs new file mode 100644 index 0000000000000..be8bd11af6487 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/TcpCommunicationSpiParityTest.cs @@ -0,0 +1,84 @@ +/* + * 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. + */ + +namespace Apache.Ignite.Core.Tests.ApiParity +{ + using System.Collections.Generic; + using Apache.Ignite.Core.Cache.Configuration; + using Apache.Ignite.Core.Communication.Tcp; + using NUnit.Framework; + + /// + /// Tests that .NET has all properties from Java configuration APIs. + /// + public class TcpCommunicationSpiParityTest + { + /** Known property name mappings. */ + private static readonly Dictionary KnownMappings = new Dictionary() + { + {"SocketReceiveBuffer", "SocketReceiveBufferSize"}, + {"SocketSendBuffer", "SocketSendBufferSize"} + }; + + /** Properties that are not needed on .NET side. */ + private static readonly string[] UnneededProperties = + { + // Java-specific. + "AddressResolver", + "Listener", + "run", + "ReceivedMessagesByType", + "ReceivedMessagesByNode", + "SentMessagesByType", + "SentMessagesByNode", + "SentMessagesCount", + "SentBytesCount", + "ReceivedMessagesCount", + "ReceivedBytesCount", + "OutboundMessagesQueueSize", + "resetMetrics", + "dumpStats", + "boundPort", + "SpiContext", + "simulateNodeFailure", + "cancel", + "order", + "onTimeout", + "endTime", + "id", + "connectionIndex", + "NodeFilter" + }; + + /** Properties that are missing on .NET side. */ + private static readonly string[] MissingProperties = {}; + + /// + /// Tests the cache configuration parity. + /// + [Test] + public void TestTcpCommunicationSpi() + { + ParityTest.CheckConfigurationParity( + @"modules\core\src\main\java\org\apache\ignite\spi\communication\tcp\TcpCommunicationSpi.java", + typeof(TcpCommunicationSpi), + UnneededProperties, + MissingProperties, + KnownMappings); + } + } +} diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs index ceeeb374707f8..ef5623ea8bc27 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs @@ -350,7 +350,9 @@ public void TestSqlQuery([Values(true, false)] bool loc, [Values(true, false)] b var qry = new SqlQuery(typeof(QueryPerson), "age < 50", loc) { EnableDistributedJoins = distrJoin, +#pragma warning disable 618 ReplicatedOnly = false, +#pragma warning restore 618 Timeout = TimeSpan.FromSeconds(3) }; @@ -381,7 +383,9 @@ public void TestSqlFieldsQuery([Values(true, false)] bool loc, [Values(true, fal EnableDistributedJoins = distrJoin, EnforceJoinOrder = enforceJoinOrder, Colocated = !distrJoin, +#pragma warning disable 618 ReplicatedOnly = false, +#pragma warning restore 618 Local = loc, Timeout = TimeSpan.FromSeconds(2), Lazy = lazy diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesWithRestartServerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesWithRestartServerTest.cs new file mode 100644 index 0000000000000..d54204a0baf18 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesWithRestartServerTest.cs @@ -0,0 +1,160 @@ +/* + * 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. + */ + +namespace Apache.Ignite.Core.Tests.Cache.Query +{ + using System.Linq; + using System.Threading; + using Apache.Ignite.Core.Binary; + using Apache.Ignite.Core.Cache; + using Apache.Ignite.Core.Cache.Query; + using NUnit.Framework; + + /// + /// Tests queries behavior with client reconnect and server restart. + /// + public sealed class CacheQueriesRestartServerTest + { + /** */ + private IIgnite _client; + + /** */ + private IIgnite _server; + + /// + /// Sets up the fixture. + /// + [TestFixtureSetUp] + public void FixtureSetUp() + { + _server = StartGrid(0); + _client = StartGrid(0, true); + + TestUtils.WaitForCondition(() => _server.GetCluster().GetNodes().Count == 2, 1000); + } + + /// + /// Tears down the fixture. + /// + [TestFixtureTearDown] + public void FixtureTearDown() + { + Ignition.StopAll(true); + } + + /// + /// Tests that Scan query works after client reconnect with full cluster restart. + /// + [Test] + public void Test_ScanQueryAfterClientReconnect_ReturnsResults([Values(true, false)] bool emptyFilterObject) + { + var cache = _client.GetOrCreateCache("Test"); + cache.Put(1, new Item { Id = 20, Title = "test" }); + + Ignition.Stop(_server.Name, false); + _server = StartGrid(0); + WaitForReconnect(_client, 5000); + + cache = _client.GetOrCreateCache("Test"); + cache.Put(1, new Item { Id = 30, Title = "test" }); + + var filter = emptyFilterObject + ? (ICacheEntryFilter) new TestFilter() + : new TestFilterWithField {TestValue = 9}; + + var cursor = cache.Query(new ScanQuery(filter)); + var items = cursor.GetAll(); + + Assert.AreEqual(30, items.Single().Value.Id); + } + + /// + /// Starts the grid. + /// + private static IIgnite StartGrid(int i, bool client = false) + { + return Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) + { + ClientMode = client, + IgniteInstanceName = client ? "client-" + i : "grid-" + i + }); + } + + /// + /// Waits for reconnect. + /// + private static void WaitForReconnect(IIgnite ignite, int timeout) + { + var evt = new ManualResetEventSlim(false); + + ignite.ClientReconnected += (sender, args) => evt.Set(); + + var restarted = evt.Wait(timeout); + Assert.IsTrue(restarted); + } + + /// + /// Test filter. + /// + private class TestFilter : ICacheEntryFilter + { + /** */ + public bool Invoke(ICacheEntry entry) + { + return entry.Value.Id > 10; + } + } + + /// + /// Test filter with field. + /// + private class TestFilterWithField : ICacheEntryFilter + { + /** */ + public int TestValue { get; set; } + + /** */ + public bool Invoke(ICacheEntry entry) + { + return entry.Value.Id > TestValue; + } + } + + private class Item : IBinarizable + { + /** */ + public int Id { get; set; } + + /** */ + public string Title { get; set; } + + /** */ + public void WriteBinary(IBinaryWriter writer) + { + writer.WriteInt("Id", Id); + writer.WriteString("Title", Title); + } + + /** */ + public void ReadBinary(IBinaryReader reader) + { + Id = reader.ReadInt("Id"); + Title = reader.ReadString("Title"); + } + } + } +} diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Introspection.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Introspection.cs index f5b5baa4f3569..77f79f47d9c60 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Introspection.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Introspection.cs @@ -52,7 +52,9 @@ public void TestIntrospection() PageSize = 999, EnforceJoinOrder = true, Timeout = TimeSpan.FromSeconds(2.5), +#pragma warning disable 618 ReplicatedOnly = true, +#pragma warning restore 618 Colocated = true, Lazy = true }).Where(x => x.Key > 10).ToCacheQueryable(); @@ -76,7 +78,9 @@ public void TestIntrospection() Assert.AreEqual(999, fq.PageSize); Assert.IsFalse(fq.EnableDistributedJoins); Assert.IsTrue(fq.EnforceJoinOrder); +#pragma warning disable 618 Assert.IsTrue(fq.ReplicatedOnly); +#pragma warning restore 618 Assert.IsTrue(fq.Colocated); Assert.AreEqual(TimeSpan.FromSeconds(2.5), fq.Timeout); Assert.IsTrue(fq.Lazy); diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Misc.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Misc.cs index 8aaa7b8a80002..0cc6e5d158bce 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Misc.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Linq/CacheLinqTest.Misc.cs @@ -30,6 +30,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Linq using System.Linq; using Apache.Ignite.Core.Cache; using Apache.Ignite.Core.Cache.Configuration; + using Apache.Ignite.Core.Common; using Apache.Ignite.Linq; using NUnit.Framework; @@ -342,7 +343,7 @@ public void TestTimeout() }); // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - var ex = Assert.Throws(() => + var ex = Assert.Throws(() => persons.SelectMany(p => GetRoleCache().AsCacheQueryable()).ToArray()); Assert.IsTrue(ex.ToString().Contains("QueryCancelledException: The query was cancelled while executing.")); diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FailureHandlerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FailureHandlerTest.cs index 7c447b180942b..a8aff71c63804 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FailureHandlerTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FailureHandlerTest.cs @@ -71,6 +71,7 @@ public void TearDown() /// Tests /// [Test] + [Ignore("IGNITE-10364")] public void TestStopNodeFailureHandler() { TestFailureHandler(typeof(StopNodeFailureHandler)); @@ -80,6 +81,7 @@ public void TestStopNodeFailureHandler() /// Tests /// [Test] + [Ignore("IGNITE-10364")] public void TestStopNodeOrHaltFailureHandler() { TestFailureHandler(typeof(StopNodeOrHaltFailureHandler)); diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs index c26e5a346694e..f0f3b7cf956c5 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs @@ -186,9 +186,11 @@ public void TestAllConfigurationProperties() var com = (TcpCommunicationSpi) cfg.CommunicationSpi; var resCom = (TcpCommunicationSpi) resCfg.CommunicationSpi; Assert.AreEqual(com.AckSendThreshold, resCom.AckSendThreshold); + Assert.AreEqual(com.ConnectionsPerNode, resCom.ConnectionsPerNode); Assert.AreEqual(com.ConnectTimeout, resCom.ConnectTimeout); Assert.AreEqual(com.DirectBuffer, resCom.DirectBuffer); Assert.AreEqual(com.DirectSendBuffer, resCom.DirectSendBuffer); + Assert.AreEqual(com.FilterReachableAddresses, resCom.FilterReachableAddresses); Assert.AreEqual(com.IdleConnectionTimeout, resCom.IdleConnectionTimeout); Assert.AreEqual(com.LocalAddress, resCom.LocalAddress); Assert.AreEqual(com.LocalPort, resCom.LocalPort); @@ -197,12 +199,16 @@ public void TestAllConfigurationProperties() Assert.AreEqual(com.MessageQueueLimit, resCom.MessageQueueLimit); Assert.AreEqual(com.ReconnectCount, resCom.ReconnectCount); Assert.AreEqual(com.SelectorsCount, resCom.SelectorsCount); + Assert.AreEqual(com.SelectorSpins, resCom.SelectorSpins); + Assert.AreEqual(com.SharedMemoryPort, resCom.SharedMemoryPort); Assert.AreEqual(com.SlowClientQueueLimit, resCom.SlowClientQueueLimit); Assert.AreEqual(com.SocketReceiveBufferSize, resCom.SocketReceiveBufferSize); Assert.AreEqual(com.SocketSendBufferSize, resCom.SocketSendBufferSize); + Assert.AreEqual(com.SocketWriteTimeout, resCom.SocketWriteTimeout); Assert.AreEqual(com.TcpNoDelay, resCom.TcpNoDelay); Assert.AreEqual(com.UnacknowledgedMessagesBufferSize, resCom.UnacknowledgedMessagesBufferSize); - + Assert.AreEqual(com.UsePairedConnections, resCom.UsePairedConnections); + Assert.AreEqual(cfg.FailureDetectionTimeout, resCfg.FailureDetectionTimeout); Assert.AreEqual(cfg.SystemWorkerBlockedTimeout, resCfg.SystemWorkerBlockedTimeout); Assert.AreEqual(cfg.ClientFailureDetectionTimeout, resCfg.ClientFailureDetectionTimeout); @@ -750,7 +756,13 @@ private static IgniteConfiguration GetCustomConfig() TcpNoDelay = false, SlowClientQueueLimit = 98, SocketSendBufferSize = 2045, - UnacknowledgedMessagesBufferSize = 3450 + UnacknowledgedMessagesBufferSize = 3450, + ConnectionsPerNode = 12, + UsePairedConnections = true, + SharedMemoryPort = 1234, + SocketWriteTimeout = 2222, + SelectorSpins = 12, + FilterReachableAddresses = true }, FailureDetectionTimeout = TimeSpan.FromSeconds(3.5), SystemWorkerBlockedTimeout = TimeSpan.FromSeconds(8.5), diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs index 32b7702ab55d0..3b0a5bb40f46e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Properties/AssemblyInfo.cs @@ -23,7 +23,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs index 5d40408c2bee7..e8aa60a5dfd4e 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ReconnectTest.cs @@ -17,11 +17,14 @@ namespace Apache.Ignite.Core.Tests { + using System; using System.Threading; + using System.Threading.Tasks; using Apache.Ignite.Core.Cache; using Apache.Ignite.Core.Cache.Configuration; using Apache.Ignite.Core.Common; using Apache.Ignite.Core.Lifecycle; + using Apache.Ignite.Core.Tests.Client.Cache; using Apache.Ignite.Core.Tests.Process; using NUnit.Framework; @@ -63,9 +66,9 @@ public void TestClusterRestart() client.ClientReconnected += (sender, args) => { eventArgs = args; }; - var cache = client.GetCache(CacheName); + var cache = client.GetCache(CacheName); - cache[1] = 1; + cache[1] = new Person(1); Ignition.Stop(server.Name, true); @@ -91,14 +94,14 @@ public void TestClusterRestart() Assert.IsTrue(eventArgs.HasClusterRestarted); // Refresh the cache instance and check that it works. - var cache1 = client.GetCache(CacheName); + var cache1 = client.GetCache(CacheName); Assert.AreEqual(0, cache1.GetSize()); - cache1[1] = 2; - Assert.AreEqual(2, cache1[1]); + cache1[1] = new Person(2); + Assert.AreEqual(2, cache1[1].Id); // Check that old cache instance still works. - Assert.AreEqual(2, cache.Get(1)); + Assert.AreEqual(2, cache.Get(1).Id); } /// @@ -163,6 +166,60 @@ public void TestFailedConnection() } } + /// + /// Tests writer structure cleanup after client reconnect with full cluster restart. + /// + [Test] + public void TestClusterRestart_ResetsCachedMetadataAndWriterStructures() + { + var serverCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) + { + CacheConfiguration = new[] {new CacheConfiguration(CacheName)} + }; + + var clientCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) + { + IgniteInstanceName = "client", + ClientMode = true + }; + + var server = Ignition.Start(serverCfg); + var client = Ignition.Start(clientCfg); + + Assert.AreEqual(2, client.GetCluster().GetNodes().Count); + + var evt = new ManualResetEventSlim(false); + client.ClientReconnected += (sender, args) => evt.Set(); + + var cache = client.GetCache(CacheName); + cache[1] = new Person(1); + + Task.Factory.StartNew(() => + { + while (!evt.IsSet) + { + try + { + cache[1] = new Person(1); + } + catch (Exception) + { + // Ignore exceptions while disconnected, keep on trying to populate writer structure cache. + } + } + }); + + Ignition.Stop(server.Name, true); + var server2 = Ignition.Start(serverCfg); + evt.Wait(); + + // Verify that we can deserialize on server (meta is resent properly). + cache[2] = new Person(2); + + var serverCache = server2.GetCache(CacheName); + Assert.AreEqual(2, serverCache[2].Id); + } + /// /// Starts the server process. /// @@ -173,7 +230,6 @@ private static IgniteProcess StartServerProcess(IgniteConfiguration cfg) "-J-DIGNITE_QUIET=false"); } - /// /// Test set up. /// diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec index de4e47230a6c9..337fac177fcf1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec @@ -42,7 +42,7 @@ XSD file describes the structure of IgniteConfigurationSection and enables Intel More info on Apache Ignite.NET: https://apacheignite-net.readme.io/ - Copyright 2018 + Copyright 2019 Apache Ignite XSD Intellisense diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec index d5a0c682ff7a3..d2d94b3e89e75 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec @@ -46,7 +46,7 @@ Supports .NET 4+ and .NET Core 2.0+. More info: https://apacheignite-net.readme.io/ - Copyright 2018 + Copyright 2019 Apache Ignite In-Memory Distributed Computing SQL NoSQL Grid Map Reduce Cache linqpad-samples diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs index a93e00dd84d65..060321bdc7d63 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs @@ -115,6 +115,7 @@ public SqlFieldsQuery(string sql, bool loc, params object[] args) /// Gets or sets a value indicating whether this query contains only replicated tables. /// This is a hint for potentially more effective execution. /// + [Obsolete("No longer used as of Apache Ignite 2.8.")] public bool ReplicatedOnly { get; set; } /// @@ -161,7 +162,9 @@ public override string ToString() return string.Format("SqlFieldsQuery [Sql={0}, Arguments=[{1}], Local={2}, PageSize={3}, " + "EnableDistributedJoins={4}, EnforceJoinOrder={5}, Timeout={6}, ReplicatedOnly={7}" + ", Colocated={8}, Schema={9}, Lazy={10}]", Sql, args, Local, +#pragma warning disable 618 PageSize, EnableDistributedJoins, EnforceJoinOrder, Timeout, ReplicatedOnly, +#pragma warning restore 618 Colocated, Schema, Lazy); } } diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs index 7d8e8fba7c67d..4c979ed0b8804 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlQuery.cs @@ -119,6 +119,7 @@ public SqlQuery(string queryType, string sql, bool local, params object[] args) /// Gets or sets a value indicating whether this query contains only replicated tables. /// This is a hint for potentially more effective execution. /// + [Obsolete("No longer used as of Apache Ignite 2.8.")] public bool ReplicatedOnly { get; set; } /** */ @@ -140,7 +141,9 @@ internal override void Write(BinaryWriter writer, bool keepBinary) writer.WriteBoolean(EnableDistributedJoins); writer.WriteInt((int) Timeout.TotalMilliseconds); +#pragma warning disable 618 writer.WriteBoolean(ReplicatedOnly); +#pragma warning restore 618 } /** */ @@ -161,7 +164,9 @@ public override string ToString() return string.Format("SqlQuery [Sql={0}, Arguments=[{1}], Local={2}, PageSize={3}, " + "EnableDistributedJoins={4}, Timeout={5}, ReplicatedOnly={6}]", Sql, args, Local, +#pragma warning disable 618 PageSize, EnableDistributedJoins, Timeout, ReplicatedOnly); +#pragma warning restore 618 } } diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Communication/Tcp/TcpCommunicationSpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Communication/Tcp/TcpCommunicationSpi.cs index d272906a39bf8..b070f9aadf804 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Communication/Tcp/TcpCommunicationSpi.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Communication/Tcp/TcpCommunicationSpi.cs @@ -40,6 +40,9 @@ public class TcpCommunicationSpi : ICommunicationSpi /// Default value of property. public const int DefaultAckSendThreshold = 16; + /// Default value of property. + public const int DefaultConnectionsPerNode = 1; + /// Default value of property. public static readonly TimeSpan DefaultConnectTimeout = TimeSpan.FromSeconds(5); @@ -49,6 +52,9 @@ public class TcpCommunicationSpi : ICommunicationSpi /// Default value of property. public const bool DefaultDirectSendBuffer = false; + /// Default value of property. + public const bool DefaultFilterReachableAddresses = false; + /// Default value of property. public static readonly TimeSpan DefaultIdleConnectionTimeout = TimeSpan.FromSeconds(30); @@ -70,31 +76,49 @@ public class TcpCommunicationSpi : ICommunicationSpi /// Default value of property. public static readonly int DefaultSelectorsCount = Math.Min(4, Environment.ProcessorCount); + /// Default value of property. + public const long DefaultSelectorSpins = 0; + + /// Default value of property. + public const int DefaultSharedMemoryPort = -1; + /// Default socket buffer size. public const int DefaultSocketBufferSize = 32 * 1024; + /// Default value of property. + public const long DefaultSocketWriteTimeout = 2000; + /// Default value of property. public const bool DefaultTcpNoDelay = true; + /// Default value of property. + public const bool DefaultUsePairedConnections = false; + /// /// Initializes a new instance of the class. /// public TcpCommunicationSpi() { AckSendThreshold = DefaultAckSendThreshold; + ConnectionsPerNode = DefaultConnectionsPerNode; ConnectTimeout = DefaultConnectTimeout; DirectBuffer = DefaultDirectBuffer; DirectSendBuffer = DefaultDirectSendBuffer; + FilterReachableAddresses = DefaultFilterReachableAddresses; IdleConnectionTimeout = DefaultIdleConnectionTimeout; LocalPort = DefaultLocalPort; LocalPortRange = DefaultLocalPortRange; MaxConnectTimeout = DefaultMaxConnectTimeout; MessageQueueLimit = DefaultMessageQueueLimit; ReconnectCount = DefaultReconnectCount; + SharedMemoryPort = DefaultSharedMemoryPort; SelectorsCount = DefaultSelectorsCount; + SelectorSpins = DefaultSelectorSpins; SocketReceiveBufferSize = DefaultSocketBufferSize; SocketSendBufferSize = DefaultSocketBufferSize; + SocketWriteTimeout = DefaultSocketWriteTimeout; TcpNoDelay = DefaultTcpNoDelay; + UsePairedConnections = DefaultUsePairedConnections; } /// @@ -104,9 +128,11 @@ public TcpCommunicationSpi() internal TcpCommunicationSpi(IBinaryRawReader reader) { AckSendThreshold = reader.ReadInt(); + ConnectionsPerNode = reader.ReadInt(); ConnectTimeout = reader.ReadLongAsTimespan(); DirectBuffer = reader.ReadBoolean(); DirectSendBuffer = reader.ReadBoolean(); + FilterReachableAddresses = reader.ReadBoolean(); IdleConnectionTimeout = reader.ReadLongAsTimespan(); LocalAddress = reader.ReadString(); LocalPort = reader.ReadInt(); @@ -115,15 +141,19 @@ internal TcpCommunicationSpi(IBinaryRawReader reader) MessageQueueLimit = reader.ReadInt(); ReconnectCount = reader.ReadInt(); SelectorsCount = reader.ReadInt(); + SelectorSpins = reader.ReadLong(); + SharedMemoryPort = reader.ReadInt(); SlowClientQueueLimit = reader.ReadInt(); SocketReceiveBufferSize = reader.ReadInt(); SocketSendBufferSize = reader.ReadInt(); + SocketWriteTimeout = reader.ReadLong(); TcpNoDelay = reader.ReadBoolean(); UnacknowledgedMessagesBufferSize = reader.ReadInt(); + UsePairedConnections = reader.ReadBoolean(); } /// - /// Gets or sets the number of received messages per connection to node + /// Gets or sets the number of received messages per connection to node /// after which acknowledgment message is sent. /// [DefaultValue(DefaultAckSendThreshold)] @@ -136,14 +166,14 @@ internal TcpCommunicationSpi(IBinaryRawReader reader) public TimeSpan ConnectTimeout { get; set; } /// - /// Gets or sets a value indicating whether to allocate direct (ByteBuffer.allocateDirect) + /// Gets or sets a value indicating whether to allocate direct (ByteBuffer.allocateDirect) /// or heap (ByteBuffer.allocate) buffer. /// [DefaultValue(DefaultDirectBuffer)] public bool DirectBuffer { get; set; } /// - /// Gets or sets a value indicating whether to allocate direct (ByteBuffer.allocateDirect) + /// Gets or sets a value indicating whether to allocate direct (ByteBuffer.allocateDirect) /// or heap (ByteBuffer.allocate) send buffer. /// [DefaultValue(DefaultDirectSendBuffer)] @@ -156,7 +186,7 @@ internal TcpCommunicationSpi(IBinaryRawReader reader) public TimeSpan IdleConnectionTimeout { get; set; } /// - /// Gets or sets the local host address for socket binding. Note that one node could have + /// Gets or sets the local host address for socket binding. Note that one node could have /// additional addresses beside the loopback one. This configuration parameter is optional. /// public string LocalAddress { get; set; } @@ -193,7 +223,7 @@ internal TcpCommunicationSpi(IBinaryRawReader reader) /// /// Gets or sets the message queue limit for incoming and outgoing messages. /// - /// When set to positive number send queue is limited to the configured value. + /// When set to positive number send queue is limited to the configured value. /// 0 disables the limitation. /// [DefaultValue(DefaultMessageQueueLimit)] @@ -216,11 +246,11 @@ internal TcpCommunicationSpi(IBinaryRawReader reader) /// /// Gets or sets slow client queue limit. /// - /// When set to a positive number, communication SPI will monitor clients outbound message queue sizes + /// When set to a positive number, communication SPI will monitor clients outbound message queue sizes /// and will drop those clients whose queue exceeded this limit. /// /// Usually this value should be set to the same value as which controls - /// message back-pressure for server nodes. The default value for this parameter is 0 + /// message back-pressure for server nodes. The default value for this parameter is 0 /// which means unlimited. /// public int SlowClientQueueLimit { get; set; } @@ -230,7 +260,7 @@ internal TcpCommunicationSpi(IBinaryRawReader reader) /// [DefaultValue(DefaultSocketBufferSize)] public int SocketReceiveBufferSize { get; set; } - + /// /// Gets or sets the size of the socket send buffer. /// @@ -250,21 +280,66 @@ internal TcpCommunicationSpi(IBinaryRawReader reader) public bool TcpNoDelay { get; set; } /// - /// Gets or sets the maximum number of stored unacknowledged messages per connection to node. - /// If number of unacknowledged messages exceeds this number + /// Gets or sets the maximum number of stored unacknowledged messages per connection to node. + /// If number of unacknowledged messages exceeds this number /// then connection to node is closed and reconnect is attempted. /// public int UnacknowledgedMessagesBufferSize { get; set; } + /// + /// Gets or sets the number of connections per node. + /// + [DefaultValue(DefaultConnectionsPerNode)] + public int ConnectionsPerNode { get; set; } + + /// + /// Gets or sets a value indicating whether separate connections should be used for incoming and outgoing data. + /// Set this to true if should maintain connection for outgoing + /// and incoming messages separately. In this case total number of connections between local and each remote + /// node is equals to * 2. + /// + public bool UsePairedConnections { get; set; } + + /// + /// Gets or sets a local port to accept shared memory connections. + /// + [DefaultValue(DefaultSharedMemoryPort)] + public int SharedMemoryPort { get; set; } + + /// + /// Gets or sets socket write timeout for TCP connection. If message can not be written to + /// socket within this time then connection is closed and reconnect is attempted. + /// + /// Default value is . + /// + [DefaultValue(DefaultSocketWriteTimeout)] + public long SocketWriteTimeout { get; set; } + + /// + /// Gets or sets a values that defines how many non-blocking selectors should be made. + /// Can be set to so selector threads will never block. + /// + /// Default value is . + /// + public long SelectorSpins { get; set; } + + /// + /// Gets or sets a value indicating whether filter for reachable addresses + /// should be enabled on creating tcp client. + /// + public bool FilterReachableAddresses { get; set; } + /// /// Writes this instance to the specified writer. /// internal void Write(IBinaryRawWriter writer) { writer.WriteInt(AckSendThreshold); + writer.WriteInt(ConnectionsPerNode); writer.WriteLong((long) ConnectTimeout.TotalMilliseconds); writer.WriteBoolean(DirectBuffer); writer.WriteBoolean(DirectSendBuffer); + writer.WriteBoolean(FilterReachableAddresses); writer.WriteLong((long) IdleConnectionTimeout.TotalMilliseconds); writer.WriteString(LocalAddress); writer.WriteInt(LocalPort); @@ -273,11 +348,15 @@ internal void Write(IBinaryRawWriter writer) writer.WriteInt(MessageQueueLimit); writer.WriteInt(ReconnectCount); writer.WriteInt(SelectorsCount); + writer.WriteLong(SelectorSpins); + writer.WriteInt(SharedMemoryPort); writer.WriteInt(SlowClientQueueLimit); writer.WriteInt(SocketReceiveBufferSize); writer.WriteInt(SocketSendBufferSize); + writer.WriteLong(SocketWriteTimeout); writer.WriteBoolean(TcpNoDelay); writer.WriteInt(UnacknowledgedMessagesBufferSize); + writer.WriteBoolean(UsePairedConnections); } } } diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs index 50c8c275b4fc2..c4003448e90fa 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs @@ -245,6 +245,17 @@ public void UpdateWriteStructure(int pathIdx, IList updat } } + /// + /// Resets writer structure. + /// + public void ResetWriteStructure() + { + lock (this) + { + _writerTypeStruct = null; + } + } + /** */ public void UpdateReadStructure(int pathIdx, IList updates) { diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs index 0a7b54ce9aeff..e1cc98fb8556f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs @@ -268,7 +268,7 @@ public BinaryReader StartUnmarshal(IBinaryStream stream, BinaryMode mode = Binar { return new BinaryReader(this, stream, mode, null); } - + /// /// Gets metadata for the given type ID. /// @@ -297,7 +297,7 @@ public void PutBinaryType(IBinaryTypeDescriptor desc) { Debug.Assert(desc != null); - GetBinaryTypeHandler(desc); // ensure that handler exists + GetBinaryTypeHandler(desc); // ensure that handler exists if (Ignite != null) { @@ -505,7 +505,7 @@ private BinaryFullTypeDescriptor AddUserType(Type type, int typeId, string typeN desc = desc == null ? new BinaryFullTypeDescriptor(type, typeId, typeName, true, _cfg.NameMapper, - _cfg.IdMapper, ser, false, AffinityKeyMappedAttribute.GetFieldNameFromAttribute(type), + _cfg.IdMapper, ser, false, AffinityKeyMappedAttribute.GetFieldNameFromAttribute(type), BinaryUtils.IsIgniteEnum(type), registered) : new BinaryFullTypeDescriptor(desc, type, ser, registered); @@ -576,8 +576,8 @@ private BinaryFullTypeDescriptor AddUserType(BinaryTypeConfiguration typeCfg, Ty // Type is found. var typeName = GetTypeName(type, nameMapper); int typeId = GetTypeId(typeName, idMapper); - var affKeyFld = typeCfg.AffinityKeyFieldName - ?? AffinityKeyMappedAttribute.GetFieldNameFromAttribute(type); + var affKeyFld = typeCfg.AffinityKeyFieldName + ?? AffinityKeyMappedAttribute.GetFieldNameFromAttribute(type); var serializer = GetSerializer(_cfg, typeCfg, type, typeId, nameMapper, idMapper, _log); return AddType(type, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, serializer, @@ -655,7 +655,7 @@ private BinaryFullTypeDescriptor AddType(Type type, int typeId, string typeName, ThrowConflictingTypeError(typeName, conflictingType.TypeName, typeId); } - var descriptor = new BinaryFullTypeDescriptor(type, typeId, typeName, userType, nameMapper, idMapper, + var descriptor = new BinaryFullTypeDescriptor(type, typeId, typeName, userType, nameMapper, idMapper, serializer, keepDeserialized, affKeyFieldName, isEnum); if (RegistrationDisabled) @@ -783,6 +783,30 @@ public string GetTypeName(Type type, IBinaryNameMapper mapper = null) return GetTypeName(type.AssemblyQualifiedName, mapper); } + /// + /// Called when local client node has been reconnected to the cluster. + /// + /// Cluster restarted flag. + public void OnClientReconnected(bool clusterRestarted) + { + if (!clusterRestarted) + return; + + // Reset all binary structures. Metadata must be sent again. + // _idToDesc enumerator is thread-safe (returns a snapshot). + // If there are new descriptors added concurrently, they are fine (we are already connected). + + // Race is possible when serialization is started before reconnect (or even before disconnect) + // and finished after reconnect, meta won't be sent to cluster because it is assumed to be known, + // but operation will succeed. + // We don't support this use case. Users should handle reconnect events properly when cluster is restarted. + // Supporting this very rare use case will complicate the code a lot with little benefit. + foreach (var desc in _idToDesc) + { + desc.Value.ResetWriteStructure(); + } + } + /// /// Gets the name of the type. /// diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureTracker.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureTracker.cs index ee2e7e17047df..bf3ea6a6ddab8 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureTracker.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Structure/BinaryStructureTracker.cs @@ -97,6 +97,7 @@ public void UpdateWriterStructure(BinaryWriter writer) { if (_curStructUpdates != null) { + // The following line assumes that cluster meta update will succeed (BinaryProcessor.PutBinaryTypes). _desc.UpdateWriteStructure(_curStructPath, _curStructUpdates); var marsh = writer.Marshaller; @@ -146,4 +147,4 @@ private int GetNewFieldId(string fieldName, byte fieldTypeId, int action) return fieldId; } } -} \ No newline at end of file +} diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs index 9e99967872b09..ab16f67e182f6 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs @@ -1129,7 +1129,9 @@ private IPlatformTargetInternal QueryFieldsInternal(SqlFieldsQuery qry) writer.WriteBoolean(qry.EnforceJoinOrder); writer.WriteBoolean(qry.Lazy); // Lazy flag. writer.WriteInt((int) qry.Timeout.TotalMilliseconds); +#pragma warning disable 618 writer.WriteBoolean(qry.ReplicatedOnly); +#pragma warning restore 618 writer.WriteBoolean(qry.Colocated); writer.WriteString(qry.Schema); // Schema }); diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs index 8cc2741cfe740..d930b51834c6c 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs @@ -680,7 +680,9 @@ private static void WriteSqlQuery(IBinaryRawWriter writer, SqlQuery qry) QueryBase.WriteQueryArgs(writer, qry.Arguments); writer.WriteBoolean(qry.EnableDistributedJoins); writer.WriteBoolean(qry.Local); +#pragma warning disable 618 writer.WriteBoolean(qry.ReplicatedOnly); +#pragma warning restore 618 writer.WriteInt(qry.PageSize); writer.WriteTimeSpanAsLong(qry.Timeout); } @@ -705,7 +707,9 @@ private static void WriteSqlFieldsQuery(IBinaryRawWriter writer, SqlFieldsQuery writer.WriteBoolean(qry.EnableDistributedJoins); writer.WriteBoolean(qry.Local); +#pragma warning disable 618 writer.WriteBoolean(qry.ReplicatedOnly); +#pragma warning restore 618 writer.WriteBoolean(qry.EnforceJoinOrder); writer.WriteBoolean(qry.Colocated); writer.WriteBoolean(qry.Lazy); diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs index cd26af7b74522..4d3d1f82150e9 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs @@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Common { using System; + using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -27,7 +28,8 @@ namespace Apache.Ignite.Core.Impl.Common /// Good for frequent reads / infrequent writes scenarios. /// [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] - public class CopyOnWriteConcurrentDictionary + [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] + public class CopyOnWriteConcurrentDictionary : IEnumerable> { /** */ private volatile Dictionary _dict = new Dictionary(); @@ -88,13 +90,17 @@ public void Set(TKey key, TValue value) _dict = dict0; } } + + /** */ + public IEnumerator> GetEnumerator() + { + return _dict.GetEnumerator(); + } - /// - /// Determines whether the specified key exists in the dictionary. - /// - public bool ContainsKey(TKey key) + /** */ + IEnumerator IEnumerable.GetEnumerator() { - return _dict.ContainsKey(key); + return GetEnumerator(); } } } \ No newline at end of file diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs index 42d9ed65e8889..ecec7684d3cf7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs @@ -1002,6 +1002,8 @@ internal void OnClientDisconnected() /// Cluster restarted flag. internal void OnClientReconnected(bool clusterRestarted) { + _marsh.OnClientReconnected(clusterRestarted); + _clientReconnectTaskCompletionSource.TrySetResult(clusterRestarted); var handler = ClientReconnected; diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs index c403c1f543711..983778a938c2f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs @@ -25,7 +25,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Apache.Ignite.EntityFramework.nuspec b/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Apache.Ignite.EntityFramework.nuspec index e9b778c02eb24..7da005e5a1dc5 100644 --- a/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Apache.Ignite.EntityFramework.nuspec +++ b/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Apache.Ignite.EntityFramework.nuspec @@ -47,7 +47,7 @@ More info: https://apacheignite-net.readme.io/ Apache Ignite EntityFramework Integration - Copyright 2018 + Copyright 2019 EntityFramework Second-Level Apache Ignite In-Memory Distributed Computing SQL NoSQL Grid Map Reduce Cache diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Properties/AssemblyInfo.cs index 1e5c565381b0c..4c07a322ab312 100644 --- a/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.EntityFramework/Properties/AssemblyInfo.cs @@ -25,7 +25,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec b/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec index 0a4f99971a84d..a2150bc31e418 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec +++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec @@ -49,7 +49,7 @@ Supports .NET 4+ and .NET Core 2.0+. More info: https://apacheignite-net.readme.io/ - Copyright 2018 + Copyright 2019 Apache Ignite In-Memory Distributed Computing SQL NoSQL LINQ Grid Map Reduce Cache linqpad-samples diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs index 9d0edd7f516ca..866edff8fd0e8 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs @@ -204,7 +204,9 @@ internal SqlFieldsQuery GetFieldsQuery(string text, object[] args) PageSize = _options.PageSize, EnforceJoinOrder = _options.EnforceJoinOrder, Timeout = _options.Timeout, +#pragma warning disable 618 ReplicatedOnly = _options.ReplicatedOnly, +#pragma warning restore 618 Colocated = _options.Colocated, Local = _options.Local, Arguments = args, diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Properties/AssemblyInfo.cs index 0e90d60985eb9..a528903946ff6 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Linq/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Properties/AssemblyInfo.cs @@ -24,7 +24,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/QueryOptions.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/QueryOptions.cs index c727e1cdbc635..994baf2648340 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Linq/QueryOptions.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Linq/QueryOptions.cs @@ -99,6 +99,7 @@ public QueryOptions() /// Gets or sets a value indicating whether this query contains only replicated tables. /// This is a hint for potentially more effective execution. /// + [Obsolete("No longer used as of Apache Ignite 2.8.")] public bool ReplicatedOnly { get; set; } /// diff --git a/modules/platforms/dotnet/Apache.Ignite.Log4Net/Apache.Ignite.Log4Net.nuspec b/modules/platforms/dotnet/Apache.Ignite.Log4Net/Apache.Ignite.Log4Net.nuspec index 1ae2b93ee85e9..370a88c935361 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Log4Net/Apache.Ignite.Log4Net.nuspec +++ b/modules/platforms/dotnet/Apache.Ignite.Log4Net/Apache.Ignite.Log4Net.nuspec @@ -40,7 +40,7 @@ Creating NuGet package: false log4net Logger for Apache Ignite - Copyright 2018 + Copyright 2019 Apache Ignite In-Memory Distributed Computing SQL NoSQL LINQ Grid Map Reduce Cache log4net logger diff --git a/modules/platforms/dotnet/Apache.Ignite.Log4Net/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Log4Net/Properties/AssemblyInfo.cs index f29a30366b394..08c359ce2eaf7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Log4Net/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Log4Net/Properties/AssemblyInfo.cs @@ -24,7 +24,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.nuspec b/modules/platforms/dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.nuspec index f5e9a6959bf85..109ccb553b0c8 100644 --- a/modules/platforms/dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.nuspec +++ b/modules/platforms/dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.nuspec @@ -40,7 +40,7 @@ Creating NuGet package: false NLog Logger for Apache Ignite - Copyright 2018 + Copyright 2019 Apache Ignite In-Memory Distributed Computing SQL NoSQL LINQ Grid Map Reduce Cache NLog logger diff --git a/modules/platforms/dotnet/Apache.Ignite.NLog/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.NLog/Properties/AssemblyInfo.cs index 7a7a555750180..da00396e7c3ee 100644 --- a/modules/platforms/dotnet/Apache.Ignite.NLog/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite.NLog/Properties/AssemblyInfo.cs @@ -24,7 +24,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs index 195285fcd594f..1052683578ca2 100644 --- a/modules/platforms/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/Apache.Ignite/Properties/AssemblyInfo.cs @@ -23,7 +23,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/docfx/Apache.Ignite.docfx.json b/modules/platforms/dotnet/docfx/Apache.Ignite.docfx.json index 1b2214ef5dccd..5db2b9c82b321 100644 --- a/modules/platforms/dotnet/docfx/Apache.Ignite.docfx.json +++ b/modules/platforms/dotnet/docfx/Apache.Ignite.docfx.json @@ -81,7 +81,7 @@ "_appTitle": "Apache Ignite.NET", "_appFaviconPath": "images/favicon.ico", "_appLogoPath": "images/logo_ignite_32_32.png", - "_appFooter": "© 2015 - 2018 The Apache Software Foundation", + "_appFooter": "© 2015 - 2019 The Apache Software Foundation", "_disableContribution": true } } diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs index a3d63e1c5615b..075c0b614b706 100644 --- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Properties/AssemblyInfo.cs @@ -23,7 +23,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs index d58e3fd34ec5d..d559fa4393e66 100644 --- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs +++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Properties/AssemblyInfo.cs @@ -23,7 +23,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache Ignite.NET")] -[assembly: AssemblyCopyright("Copyright 2018")] +[assembly: AssemblyCopyright("Copyright 2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/modules/platforms/nodejs/lib/EnumItem.js b/modules/platforms/nodejs/lib/EnumItem.js index 1d1725e3d5908..5e80da9dee2b5 100644 --- a/modules/platforms/nodejs/lib/EnumItem.js +++ b/modules/platforms/nodejs/lib/EnumItem.js @@ -17,6 +17,7 @@ 'use strict'; +const Util = require('util'); const ArgumentChecker = require('./internal/ArgumentChecker'); const Errors = require('./Errors'); @@ -157,14 +158,18 @@ class EnumItem { * @ignore */ async _write(communicator, buffer) { + const type = await this._getType(communicator, this._typeId); + if (!type || !type._isEnum) { + throw Errors.IgniteClientError.enumSerializationError( + true, Util.format('enum type id "%d" is not registered', this._typeId)); + } buffer.writeInteger(this._typeId); if (this._ordinal !== null) { buffer.writeInteger(this._ordinal); return; } else if (this._name !== null || this._value !== null) { - const type = await this._getType(communicator, this._typeId); - if (type._isEnum && type._enumValues) { + if (type._enumValues) { for (let i = 0; i < type._enumValues.length; i++) { if (this._name === type._enumValues[i][0] || this._value === type._enumValues[i][1]) { @@ -185,8 +190,12 @@ class EnumItem { this._typeId = buffer.readInteger(); this._ordinal = buffer.readInteger(); const type = await this._getType(communicator, this._typeId); - if (!type._isEnum || !type._enumValues || type._enumValues.length <= this._ordinal) { - throw new Errors.IgniteClientError('EnumItem can not be deserialized: type mismatch'); + if (!type || !type._isEnum) { + throw Errors.IgniteClientError.enumSerializationError( + false, Util.format('enum type id "%d" is not registered', this._typeId)); + } + else if (!type._enumValues || type._enumValues.length <= this._ordinal) { + throw Errors.IgniteClientError.enumSerializationError(false, 'type mismatch'); } this._name = type._enumValues[this._ordinal][0]; this._value = type._enumValues[this._ordinal][1]; diff --git a/modules/platforms/nodejs/lib/Errors.js b/modules/platforms/nodejs/lib/Errors.js index 57a7a8c291306..89baf386ca0e8 100644 --- a/modules/platforms/nodejs/lib/Errors.js +++ b/modules/platforms/nodejs/lib/Errors.js @@ -83,6 +83,18 @@ class IgniteClientError extends Error { } return new IgniteClientError(msg); } + + /** + * EnumItem serialization/deserialization errors. + * @ignore + */ + static enumSerializationError(serialize, message = null) { + let msg = serialize ? 'Enum item can not be serialized' : 'Enum item can not be deserialized'; + if (message) { + msg = msg + ': ' + message; + } + return new IgniteClientError(msg); + } } /** diff --git a/modules/platforms/nodejs/lib/internal/BinaryUtils.js b/modules/platforms/nodejs/lib/internal/BinaryUtils.js index 2619df7961fd7..fe1e4034a9958 100644 --- a/modules/platforms/nodejs/lib/internal/BinaryUtils.js +++ b/modules/platforms/nodejs/lib/internal/BinaryUtils.js @@ -497,6 +497,10 @@ class BinaryUtils { expectedTypeCode === BinaryUtils.TYPE_CODE.COMPLEX_OBJECT) { return; } + else if (expectedTypeCode === BinaryUtils.TYPE_CODE.ENUM && + actualTypeCode === BinaryUtils.TYPE_CODE.BINARY_ENUM) { + return; + } else if (actualTypeCode !== expectedTypeCode) { throw Errors.IgniteClientError.typeCastError(actualTypeCode, expectedTypeCode); } diff --git a/modules/platforms/nodejs/spec/TestingHelper.js b/modules/platforms/nodejs/spec/TestingHelper.js index 79a53361dce8e..78df0cb37915f 100644 --- a/modules/platforms/nodejs/spec/TestingHelper.js +++ b/modules/platforms/nodejs/spec/TestingHelper.js @@ -232,6 +232,13 @@ class TestingHelper { TestingHelper.checkError(error, Errors.IgniteClientError, done) } + static checkEnumItemSerializationError(error, done) { + if (!(error instanceof Errors.IgniteClientError) || + error.message.indexOf('Enum item can not be serialized') < 0) { + done.fail('unexpected error: ' + error); + } + } + static checkError(error, errorType, done) { if (!(error instanceof errorType)) { done.fail('unexpected error: ' + error); diff --git a/modules/platforms/nodejs/spec/cache/CachePutGetDiffTypes.spec.js b/modules/platforms/nodejs/spec/cache/CachePutGetDiffTypes.spec.js index 28a9ae3825f43..a6e1bba8c64a6 100644 --- a/modules/platforms/nodejs/spec/cache/CachePutGetDiffTypes.spec.js +++ b/modules/platforms/nodejs/spec/cache/CachePutGetDiffTypes.spec.js @@ -543,6 +543,45 @@ describe('cache put get test suite >', () => { catch(error => done.fail(error)); }); + it('put enum items', (done) => { + Promise.resolve(). + then(async () => { + const fakeTypeId = 12345; + const enumItem1 = new EnumItem(fakeTypeId); + enumItem1.setOrdinal(1); + await putEnumItem(enumItem1, null, done); + await putEnumItem(enumItem1, ObjectType.PRIMITIVE_TYPE.ENUM, done); + const enumItem2 = new EnumItem(fakeTypeId); + enumItem2.setName('name'); + await putEnumItem(enumItem2, null, done); + await putEnumItem(enumItem2, ObjectType.PRIMITIVE_TYPE.ENUM, done); + const enumItem3 = new EnumItem(fakeTypeId); + enumItem3.setValue(2); + await putEnumItem(enumItem3, null, done); + await putEnumItem(enumItem3, ObjectType.PRIMITIVE_TYPE.ENUM, done); + }). + then(done). + catch(error => done.fail(error)); + }); + + async function putEnumItem(value, valueType, done) { + const cache = igniteClient.getCache(CACHE_NAME). + setKeyType(null). + setValueType(valueType); + const key = new Date(); + // Enums registration is not supported by the client, therefore put EnumItem must throw IgniteClientError + try { + await cache.put(key, value); + done.fail('put EnumItem must throw IgniteClientError'); + } + catch (err) { + TestingHelper.checkEnumItemSerializationError(err, done); + } + finally { + await cache.removeAll(); + } + } + async function putGetPrimitiveValues(keyType, valueType, key, value, modificator) { const cache = await igniteClient.getCache(CACHE_NAME). setKeyType(keyType). diff --git a/modules/platforms/php/src/Apache/Ignite/Internal/Binary/BinaryCommunicator.php b/modules/platforms/php/src/Apache/Ignite/Internal/Binary/BinaryCommunicator.php index 520063c65f524..781a73073d0d1 100644 --- a/modules/platforms/php/src/Apache/Ignite/Internal/Binary/BinaryCommunicator.php +++ b/modules/platforms/php/src/Apache/Ignite/Internal/Binary/BinaryCommunicator.php @@ -265,8 +265,10 @@ private function readEnum(MessageBuffer $buffer): EnumItem $ordinal = $buffer->readInteger(); $enumItem->setOrdinal($ordinal); $type = $this->typeStorage->getType($enumItem->getTypeId()); - if (!$type->isEnum() || !$type->getEnumValues() || count($type->getEnumValues()) <= $ordinal) { - BinaryUtils::serializationError(false, 'EnumItem can not be deserialized: type mismatch'); + if (!$type || !$type->isEnum()) { + BinaryUtils::enumSerializationError(false, sprintf('enum type id "%d" is not registered', $enumItem->getTypeId())); + } elseif (!$type->getEnumValues() || count($type->getEnumValues()) <= $ordinal) { + BinaryUtils::enumSerializationError(false, 'type mismatch'); } $enumValues = $type->getEnumValues(); $enumItem->setName($enumValues[$ordinal][0]); @@ -396,21 +398,22 @@ private function writeUUID(MessageBuffer $buffer, array $value): void private function writeEnum(MessageBuffer $buffer, EnumItem $enumValue): void { + $type = $this->typeStorage->getType($enumValue->getTypeId()); + if (!$type || !$type->isEnum()) { + BinaryUtils::enumSerializationError(true, sprintf('enum type id "%d" is not registered', $enumValue->getTypeId())); + } $buffer->writeInteger($enumValue->getTypeId()); if ($enumValue->getOrdinal() !== null) { $buffer->writeInteger($enumValue->getOrdinal()); return; } elseif ($enumValue->getName() !== null || $enumValue->getValue() !== null) { - $type = $this->typeStorage->getType($enumValue->getTypeId()); - if ($type && $type->isEnum()) { - $enumValues = $type->getEnumValues(); - if ($enumValues) { - for ($i = 0; $i < count($enumValues); $i++) { - if ($enumValue->getName() === $enumValues[$i][0] || - $enumValue->getValue() === $enumValues[$i][1]) { - $buffer->writeInteger($i); - return; - } + $enumValues = $type->getEnumValues(); + if ($enumValues) { + for ($i = 0; $i < count($enumValues); $i++) { + if ($enumValue->getName() === $enumValues[$i][0] || + $enumValue->getValue() === $enumValues[$i][1]) { + $buffer->writeInteger($i); + return; } } } diff --git a/modules/platforms/php/src/Apache/Ignite/Internal/Binary/BinaryUtils.php b/modules/platforms/php/src/Apache/Ignite/Internal/Binary/BinaryUtils.php index ad0bf56c77f19..e9ff2f1b98b04 100644 --- a/modules/platforms/php/src/Apache/Ignite/Internal/Binary/BinaryUtils.php +++ b/modules/platforms/php/src/Apache/Ignite/Internal/Binary/BinaryUtils.php @@ -203,6 +203,9 @@ public static function checkTypesCompatibility($expectedType, int $actualTypeCod $actualTypeCode === ObjectType::BINARY_OBJECT && $expectedTypeCode === ObjectType::COMPLEX_OBJECT) { return; + } elseif ($expectedTypeCode === ObjectType::ENUM && + $actualTypeCode === ObjectType::BINARY_ENUM) { + return; } elseif ($actualTypeCode !== $expectedTypeCode) { BinaryUtils::typeCastError($actualTypeCode, $expectedTypeCode); } @@ -419,6 +422,15 @@ public static function serializationError(bool $serialize, string $message = nul throw new ClientException($msg); } + public static function enumSerializationError(bool $serialize, string $message = null): void + { + $msg = $serialize ? 'Enum item can not be serialized' : 'Enum item can not be deserialized'; + if ($message) { + $msg = $msg . ': ' . $message; + } + throw new ClientException($msg); + } + public static function typeCastError($fromType, $toType): void { throw new ClientException(sprintf('Type "%s" can not be cast to %s', diff --git a/modules/platforms/php/tests/CachePutGetTest.php b/modules/platforms/php/tests/CachePutGetTest.php index 9d15ab2810564..c3ff1e9f7de0b 100644 --- a/modules/platforms/php/tests/CachePutGetTest.php +++ b/modules/platforms/php/tests/CachePutGetTest.php @@ -18,14 +18,20 @@ namespace Apache\Ignite\Tests; +use \DateTime; use Ds\Map; use Ds\Set; use PHPUnit\Framework\TestCase; +use Apache\Ignite\Type\ObjectType; use Apache\Ignite\Type\MapObjectType; use Apache\Ignite\Type\CollectionObjectType; use Apache\Ignite\Type\ObjectArrayType; use Apache\Ignite\Type\ComplexObjectType; use Apache\Ignite\Data\BinaryObject; +use Apache\Ignite\Data\Date; +use Apache\Ignite\Data\Timestamp; +use Apache\Ignite\Data\EnumItem; +use Apache\Ignite\Exception\ClientException; class TstComplObjectWithPrimitiveFields { @@ -490,6 +496,119 @@ public function testPutGetObjectArrayOfObjectArraysOfComplexObjectsWithDefaultFi $this->putGetObjectArrays(new ObjectArrayType(new ObjectArrayType(new ComplexObjectType())), $array); } + public function testPutGetDateTime(): void + { + $this->putGetDate("Y-m-d H:i:s", "2018-10-19 18:31:13", 0); + $this->putGetDate("Y-m-d H:i:s", "2018-10-19 18:31:13", 29726); + $this->putGetDate("Y-m-d H:i:s", "2018-10-19 18:31:13", 999999); + + $this->putGetTimestamp("Y-m-d H:i:s", "2018-10-19 18:31:13", 0); + $this->putGetTimestamp("Y-m-d H:i:s", "2018-10-19 18:31:13", 29726000); + $this->putGetTimestamp("Y-m-d H:i:s", "2018-10-19 18:31:13", 999999999); + + $this->putGetTimestampFromDateTime("Y-m-d H:i:s", "2018-10-19 18:31:13", 0); + $this->putGetTimestampFromDateTime("Y-m-d H:i:s", "2018-10-19 18:31:13", 29726); + $this->putGetTimestampFromDateTime("Y-m-d H:i:s", "2018-10-19 18:31:13", 999999); + } + + public function testPutEnumItems(): void + { + $fakeTypeId = 12345; + $enumItem1 = new EnumItem($fakeTypeId); + $enumItem1->setOrdinal(1); + $this->putEnumItem($enumItem1, null); + $this->putEnumItem($enumItem1, ObjectType::ENUM); + $enumItem2 = new EnumItem($fakeTypeId); + $enumItem2->setName('name'); + $this->putEnumItem($enumItem2, null); + $this->putEnumItem($enumItem2, ObjectType::ENUM); + $enumItem3 = new EnumItem($fakeTypeId); + $enumItem3->setOrdinal(2); + $this->putEnumItem($enumItem3, null); + $this->putEnumItem($enumItem3, ObjectType::ENUM); + } + + private function putEnumItem($value, $valueType): void + { + $key = microtime(); + self::$cache-> + setKeyType(null)-> + setValueType($valueType); + // Enums registration is not supported by the client, therefore put EnumItem must throw ClientException + try { + self::$cache->put($key, $value); + $this->fail('put EnumItem must throw ClientException'); + } catch (ClientException $e) { + $this->assertContains('Enum item can not be serialized', $e->getMessage()); + } finally { + self::$cache->removeAll(); + } + } + + private function putGetDate(string $format, string $dateString, int $micros): void + { + $key = microtime(); + self::$cache-> + setKeyType(null)-> + setValueType(ObjectType::DATE); + try { + $dt = DateTime::createFromFormat("$format.u", sprintf("%s.%06d", $dateString, $micros)); + $iDate = Date::fromDateTime($dt); + self::$cache->put($key, $iDate); + $result = self::$cache->get($key); + + $this->assertEquals(sprintf("%06d", intval($micros / 1000) * 1000), $result->toDateTime()->format('u')); + $this->assertEquals($dateString, $result->toDateTime()->format($format)); + } finally { + self::$cache->removeAll(); + } + } + + private function putGetTimestamp(string $format, string $dateString, int $nanos): void + { + $key = microtime(); + self::$cache-> + setKeyType(null)-> + setValueType(ObjectType::TIMESTAMP); + + try { + $millis = intval($nanos / 1000000); + $nanosInMillis = $nanos % 1000000; + self::$cache->put($key, + new Timestamp( + DateTime::createFromFormat($format, $dateString)->getTimestamp() * 1000 + $millis, + $nanosInMillis + ) + ); + $result = self::$cache->get($key); + + $this->assertEquals($nanos % 1000000, $result->getNanos()); + $this->assertEquals($dateString, $result->toDateTime()->format($format)); + } finally { + self::$cache->removeAll(); + } + } + + private function putGetTimestampFromDateTime(string $format, string $dateString, $micros): void + { + $key = microtime(); + self::$cache-> + setKeyType(null)-> + setValueType(ObjectType::TIMESTAMP); + + try { + self::$cache->put($key, Timestamp::fromDateTime( + DateTime::createFromFormat("$format.u", sprintf("%s.%06d", $dateString, $micros)) + )); + $result = self::$cache->get($key); + + $this->assertEquals(intval($micros / 1000) * 1000, $result->toDateTime()->format('u')); + $this->assertEquals($dateString, $result->toDateTime()->format($format)); + } finally { + self::$cache->removeAll(); + } + } + private function putGetObjectArrays(?ObjectArrayType $arrayType, array $value): void { $key = microtime(); diff --git a/modules/platforms/python/docs/source/pyignite.datatypes.base.rst b/modules/platforms/python/docs/source/pyignite.datatypes.base.rst new file mode 100644 index 0000000000000..849a02817a04a --- /dev/null +++ b/modules/platforms/python/docs/source/pyignite.datatypes.base.rst @@ -0,0 +1,7 @@ +pyignite.datatypes.base module +============================== + +.. automodule:: pyignite.datatypes.base + :members: + :undoc-members: + :show-inheritance: diff --git a/modules/platforms/python/docs/source/pyignite.datatypes.rst b/modules/platforms/python/docs/source/pyignite.datatypes.rst index 77e7183bd0a91..d72f84432d835 100644 --- a/modules/platforms/python/docs/source/pyignite.datatypes.rst +++ b/modules/platforms/python/docs/source/pyignite.datatypes.rst @@ -11,6 +11,7 @@ Submodules .. toctree:: + pyignite.datatypes.base pyignite.datatypes.binary pyignite.datatypes.cache_config pyignite.datatypes.cache_properties diff --git a/modules/platforms/python/pyignite/datatypes/base.py b/modules/platforms/python/pyignite/datatypes/base.py new file mode 100644 index 0000000000000..a0522c0ac3e45 --- /dev/null +++ b/modules/platforms/python/pyignite/datatypes/base.py @@ -0,0 +1,24 @@ +# 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. + +from abc import ABC + + +class IgniteDataType(ABC): + """ + This is a base class for all Ignite data types, a.k.a. parser/constructor + classes, both object and payload varieties. + """ + pass diff --git a/modules/platforms/python/pyignite/datatypes/complex.py b/modules/platforms/python/pyignite/datatypes/complex.py index 9a5664c97c74e..87e5130bf3bdc 100644 --- a/modules/platforms/python/pyignite/datatypes/complex.py +++ b/modules/platforms/python/pyignite/datatypes/complex.py @@ -20,7 +20,8 @@ from pyignite.constants import * from pyignite.exceptions import ParseError from pyignite.utils import entity_id, hashcode, is_hinted -from .internal import AnyDataObject +from .base import IgniteDataType +from .internal import AnyDataObject, infer_from_python from .type_codes import * @@ -30,7 +31,7 @@ ] -class ObjectArrayObject: +class ObjectArrayObject(IgniteDataType): """ Array of objects of any type. Its Python representation is tuple(type_id, iterable of any type). @@ -106,11 +107,11 @@ def from_python(cls, value): buffer = bytes(header) for x in value: - buffer += AnyDataObject.from_python(x) + buffer += infer_from_python(x) return buffer -class WrappedDataObject: +class WrappedDataObject(IgniteDataType): """ One or more binary objects can be wrapped in an array. This allows reading, storing, passing and writing objects efficiently without understanding @@ -195,7 +196,7 @@ def build_header(cls): ) -class Map: +class Map(IgniteDataType): """ Dictionary type, payload-only. @@ -273,14 +274,8 @@ def from_python(cls, value, type_id=None): buffer = bytes(header) for k, v in value.items(): - if is_hinted(k): - buffer += k[1].from_python(k[0]) - else: - buffer += AnyDataObject.from_python(k) - if is_hinted(v): - buffer += v[1].from_python(v[0]) - else: - buffer += AnyDataObject.from_python(v) + buffer += infer_from_python(k) + buffer += infer_from_python(v) return buffer @@ -323,7 +318,7 @@ def from_python(cls, value): return super().from_python(value, type_id) -class BinaryObject: +class BinaryObject(IgniteDataType): type_code = TC_COMPLEX_OBJECT USER_TYPE = 0x0001 diff --git a/modules/platforms/python/pyignite/datatypes/internal.py b/modules/platforms/python/pyignite/datatypes/internal.py index a363a5fd766f9..844e0ef9e7fb4 100644 --- a/modules/platforms/python/pyignite/datatypes/internal.py +++ b/modules/platforms/python/pyignite/datatypes/internal.py @@ -389,6 +389,20 @@ def from_python(cls, value): return cls.map_python_type(value).from_python(value) +def infer_from_python(value: Any): + """ + Convert pythonic value to ctypes buffer, type hint-aware. + + :param value: pythonic value or (value, type_hint) tuple, + :return: bytes. + """ + if is_hinted(value): + value, data_type = value + else: + data_type = AnyDataObject + return data_type.from_python(value) + + @attr.s class AnyDataArray(AnyDataObject): """ @@ -454,8 +468,5 @@ def from_python(self, value): buffer = bytes(header) for x in value: - if is_hinted(x): - buffer += x[1].from_python(x[0]) - else: - buffer += super().from_python(x) + buffer += infer_from_python(x) return buffer diff --git a/modules/platforms/python/pyignite/datatypes/null_object.py b/modules/platforms/python/pyignite/datatypes/null_object.py index 9fa1e8feefbdb..a648e30f1bb96 100644 --- a/modules/platforms/python/pyignite/datatypes/null_object.py +++ b/modules/platforms/python/pyignite/datatypes/null_object.py @@ -21,13 +21,14 @@ import ctypes +from .base import IgniteDataType from .type_codes import TC_NULL __all__ = ['Null'] -class Null: +class Null(IgniteDataType): default = None pythonic = type(None) _object_c_type = None diff --git a/modules/platforms/python/pyignite/datatypes/primitive.py b/modules/platforms/python/pyignite/datatypes/primitive.py index 94c8fe3163b12..d1e9f4e4ae566 100644 --- a/modules/platforms/python/pyignite/datatypes/primitive.py +++ b/modules/platforms/python/pyignite/datatypes/primitive.py @@ -16,6 +16,7 @@ import ctypes from pyignite.constants import * +from .base import IgniteDataType __all__ = [ @@ -24,7 +25,7 @@ ] -class Primitive: +class Primitive(IgniteDataType): """ Ignite primitive type. Base type for the following types: diff --git a/modules/platforms/python/pyignite/datatypes/primitive_arrays.py b/modules/platforms/python/pyignite/datatypes/primitive_arrays.py index 83a2b4ceb5b4d..6a931910d4636 100644 --- a/modules/platforms/python/pyignite/datatypes/primitive_arrays.py +++ b/modules/platforms/python/pyignite/datatypes/primitive_arrays.py @@ -16,6 +16,7 @@ import ctypes from pyignite.constants import * +from .base import IgniteDataType from .primitive import * from .type_codes import * @@ -28,7 +29,7 @@ ] -class PrimitiveArray: +class PrimitiveArray(IgniteDataType): """ Base class for array of primitives. Payload-only. """ diff --git a/modules/platforms/python/pyignite/datatypes/primitive_objects.py b/modules/platforms/python/pyignite/datatypes/primitive_objects.py index 4e37ce10c1d70..105acee000b56 100644 --- a/modules/platforms/python/pyignite/datatypes/primitive_objects.py +++ b/modules/platforms/python/pyignite/datatypes/primitive_objects.py @@ -16,6 +16,7 @@ import ctypes from pyignite.constants import * +from .base import IgniteDataType from .type_codes import * @@ -25,7 +26,7 @@ ] -class DataObject: +class DataObject(IgniteDataType): """ Base class for primitive data objects. diff --git a/modules/platforms/python/pyignite/datatypes/standard.py b/modules/platforms/python/pyignite/datatypes/standard.py index 5f3af744c6bd0..cc5b9553bcd08 100644 --- a/modules/platforms/python/pyignite/datatypes/standard.py +++ b/modules/platforms/python/pyignite/datatypes/standard.py @@ -20,6 +20,7 @@ import uuid from pyignite.constants import * +from .base import IgniteDataType from .type_codes import * from .null_object import Null @@ -39,7 +40,7 @@ ] -class StandardObject: +class StandardObject(IgniteDataType): type_code = None @classmethod @@ -58,7 +59,7 @@ def parse(cls, client: 'Client'): return c_type, buffer -class String: +class String(IgniteDataType): """ Pascal-style string: `c_int` counter, followed by count*bytes. UTF-8-encoded, so that one character may take 1 to 4 bytes. @@ -125,7 +126,7 @@ def from_python(cls, value): return bytes(data_object) -class DecimalObject: +class DecimalObject(IgniteDataType): type_code = TC_DECIMAL pythonic = decimal.Decimal default = decimal.Decimal('0.00') @@ -511,7 +512,7 @@ class BinaryEnumObject(EnumObject): type_code = TC_BINARY_ENUM -class StandardArray: +class StandardArray(IgniteDataType): """ Base class for array of primitives. Payload-only. """ diff --git a/modules/platforms/python/pyignite/utils.py b/modules/platforms/python/pyignite/utils.py index a08bc9bae9a6f..1d4298ec8e4f8 100644 --- a/modules/platforms/python/pyignite/utils.py +++ b/modules/platforms/python/pyignite/utils.py @@ -16,6 +16,7 @@ from functools import wraps from typing import Any, Type, Union +from pyignite.datatypes.base import IgniteDataType from .constants import * @@ -47,11 +48,14 @@ def is_hinted(value): return ( isinstance(value, tuple) and len(value) == 2 - and isinstance(value[1], object) + and issubclass(value[1], IgniteDataType) ) def is_wrapped(value: Any) -> bool: + """ + Check if a value is of WrappedDataObject type. + """ return ( type(value) is tuple and len(value) == 2 diff --git a/modules/platforms/python/setup.py b/modules/platforms/python/setup.py index 7419c975e9c1a..583eaa38b31c4 100644 --- a/modules/platforms/python/setup.py +++ b/modules/platforms/python/setup.py @@ -70,7 +70,7 @@ def is_a_requirement(line): setuptools.setup( name='pyignite', - version='0.3.1', + version='0.3.4', python_requires='>={}.{}'.format(*PYTHON_REQUIRED), author='Dmitry Melnichuk', author_email='dmitry.melnichuk@nobitlost.com', diff --git a/modules/platforms/python/tests/test_key_value.py b/modules/platforms/python/tests/test_key_value.py index c569c7724cc72..6b4fb0ea575d2 100644 --- a/modules/platforms/python/tests/test_key_value.py +++ b/modules/platforms/python/tests/test_key_value.py @@ -13,8 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +from datetime import datetime + from pyignite.api import * -from pyignite.datatypes import IntObject +from pyignite.datatypes import ( + CollectionObject, IntObject, MapObject, TimestampObject, +) def test_put_get(client, cache): @@ -325,3 +329,72 @@ def test_cache_get_size(client, cache): result = cache_get_size(client, cache) assert result.status == 0 assert result.value == 1 + + +def test_put_get_collection(client): + + test_datetime = datetime(year=1996, month=3, day=1) + + cache = client.get_or_create_cache('test_coll_cache') + cache.put( + 'simple', + ( + 1, + [ + (123, IntObject), + 678, + None, + 55.2, + ((test_datetime, 0), TimestampObject), + ] + ), + value_hint=CollectionObject + ) + value = cache.get('simple') + assert value == (1, [123, 678, None, 55.2, (test_datetime, 0)]) + + cache.put( + 'nested', + ( + 1, + [ + 123, + ((1, [456, 'inner_test_string', 789]), CollectionObject), + 'outer_test_string', + ] + ), + value_hint=CollectionObject + ) + value = cache.get('nested') + assert value == ( + 1, + [ + 123, + (1, [456, 'inner_test_string', 789]), + 'outer_test_string' + ] + ) + + +def test_put_get_map(client): + + cache = client.get_or_create_cache('test_map_cache') + + cache.put( + 'test_map', + ( + MapObject.HASH_MAP, + { + (123, IntObject): 'test_data', + 456: ((1, [456, 'inner_test_string', 789]), CollectionObject), + 'test_key': 32.4, + } + ), + value_hint=MapObject + ) + value = cache.get('test_map') + assert value == (MapObject.HASH_MAP, { + 123: 'test_data', + 456: (1, [456, 'inner_test_string', 789]), + 'test_key': 32.4, + }) diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java index 03bed694017e3..f502fac8a3a0f 100644 --- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java +++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java @@ -51,6 +51,7 @@ import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler; import org.apache.ignite.internal.processors.rest.GridRestResponse; import org.apache.ignite.internal.processors.rest.request.DataStructuresRequest; +import org.apache.ignite.internal.processors.rest.request.GridRestBaselineRequest; import org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest; import org.apache.ignite.internal.processors.rest.request.GridRestChangeStateRequest; import org.apache.ignite.internal.processors.rest.request.GridRestLogRequest; @@ -633,6 +634,7 @@ private Object convert(String type, Object obj) throws IgniteCheckedException { case CACHE_CAS: case CACHE_METRICS: case CACHE_SIZE: + case CACHE_UPDATE_TLL: case CACHE_METADATA: case CACHE_REPLACE: case CACHE_APPEND: @@ -689,6 +691,9 @@ private Object convert(String type, Object obj) throws IgniteCheckedException { restReq0.includeMetrics(Boolean.parseBoolean((String)params.get("mtr"))); restReq0.includeAttributes(Boolean.parseBoolean((String)params.get("attr"))); + String caches = (String)params.get("caches"); + restReq0.includeCaches(caches == null || Boolean.parseBoolean(caches)); + restReq0.nodeIp((String)params.get("ip")); restReq0.nodeId(uuidValue("id", params)); @@ -756,6 +761,20 @@ else if (cmd == CLUSTER_ACTIVE || cmd == CLUSTER_ACTIVATE) break; } + case BASELINE_CURRENT_STATE: + case BASELINE_SET: + case BASELINE_ADD: + case BASELINE_REMOVE: { + GridRestBaselineRequest restReq0 = new GridRestBaselineRequest(); + + restReq0.topologyVersion(longValue("topVer", params, null)); + restReq0.consistentIds(values(null, "consistentId", params)); + + restReq = restReq0; + + break; + } + case AUTHENTICATE: { restReq = new GridRestRequest(); diff --git a/modules/rest-http/src/test/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridRestSuite.java b/modules/rest-http/src/test/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridRestSuite.java index c69ce7f03ae54..8a53e51a5565c 100644 --- a/modules/rest-http/src/test/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridRestSuite.java +++ b/modules/rest-http/src/test/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridRestSuite.java @@ -16,19 +16,23 @@ */ package org.apache.ignite.internal.processors.rest.protocols.http.jetty; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Integration tests for Grid REST functionality; Jetty is under the hood. */ -public class GridRestSuite extends TestSuite { +@RunWith(AllTests.class) +public class GridRestSuite { /** * @return Suite that contains all tests for REST. */ public static TestSuite suite() { TestSuite suite = new TestSuite("Apache Ignite REST Api suite"); - suite.addTest(new TestSuite(RestSetupSimpleTest.class)); + suite.addTest(new JUnit4TestAdapter(RestSetupSimpleTest.class)); return suite; } diff --git a/modules/rest-http/src/test/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/RestSetupSimpleTest.java b/modules/rest-http/src/test/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/RestSetupSimpleTest.java index 7c076f7759a0b..93fdbcfe1313f 100644 --- a/modules/rest-http/src/test/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/RestSetupSimpleTest.java +++ b/modules/rest-http/src/test/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/RestSetupSimpleTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Integration test for Grid REST functionality; Jetty is under the hood. */ +@RunWith(JUnit4.class) public class RestSetupSimpleTest extends GridCommonAbstractTest { /** Jetty port. */ private static final int JETTY_PORT = 8080; @@ -56,6 +60,7 @@ public class RestSetupSimpleTest extends GridCommonAbstractTest { /** * Runs version command using GridJettyRestProtocol. */ + @Test public void testVersionCommand() throws Exception { URLConnection conn = new URL("http://localhost:" + JETTY_PORT + "/ignite?cmd=version").openConnection(); diff --git a/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTest.java b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTest.java index 44b00303fe80e..5ed24e15331bd 100644 --- a/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTest.java +++ b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTest.java @@ -38,6 +38,9 @@ import org.apache.rocketmq.common.message.Message; import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.tools.admin.DefaultMQAdminExt; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; import static org.apache.ignite.stream.rocketmq.TestRocketMQServer.NAME_SERVER_PORT; @@ -46,6 +49,7 @@ /** * Test for {@link RocketMQStreamer}. */ +@RunWith(JUnit4.class) public class RocketMQStreamerTest extends GridCommonAbstractTest { /** Test topic. */ private static final String TOPIC_NAME = "testTopic"; @@ -92,6 +96,7 @@ public RocketMQStreamerTest() { * * @throws Exception If fails. */ + @Test public void testStreamer() throws Exception { RocketMQStreamer streamer = null; diff --git a/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTestSuite.java b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTestSuite.java index 127b442a8a5a6..8649a13edd766 100644 --- a/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTestSuite.java +++ b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTestSuite.java @@ -17,20 +17,23 @@ package org.apache.ignite.stream.rocketmq; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Apache RocketMQ streamers tests. */ -public class RocketMQStreamerTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class RocketMQStreamerTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Apache RocketMQ streamer Test Suite"); - suite.addTest(new TestSuite(RocketMQStreamerTest.class)); + suite.addTest(new JUnit4TestAdapter(RocketMQStreamerTest.class)); return suite; } diff --git a/modules/scalar-2.10/pom.xml b/modules/scalar-2.10/pom.xml index de7f480d6f898..285ae579b7ebf 100644 --- a/modules/scalar-2.10/pom.xml +++ b/modules/scalar-2.10/pom.xml @@ -163,7 +163,7 @@ - + diff --git a/modules/scalar/pom.xml b/modules/scalar/pom.xml index 8e63fc69decad..7372f569686f7 100644 --- a/modules/scalar/pom.xml +++ b/modules/scalar/pom.xml @@ -72,7 +72,7 @@ org.scalatest scalatest_2.11 - 2.2.4 + ${scala.test.version} test @@ -143,7 +143,7 @@ Ignite™ - Scalar DSL, ver. ${project.version}
    - 2018 Copyright © Apache Software Foundation + 2019 Copyright © Apache Software Foundation diff --git a/modules/schedule/src/test/java/org/apache/ignite/internal/processors/schedule/GridScheduleSelfTest.java b/modules/schedule/src/test/java/org/apache/ignite/internal/processors/schedule/GridScheduleSelfTest.java index 992deb5179ad0..bb4e9fc79d7ca 100644 --- a/modules/schedule/src/test/java/org/apache/ignite/internal/processors/schedule/GridScheduleSelfTest.java +++ b/modules/schedule/src/test/java/org/apache/ignite/internal/processors/schedule/GridScheduleSelfTest.java @@ -39,6 +39,9 @@ import org.apache.ignite.scheduler.SchedulerFuture; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.testframework.GridTestUtils.assertThrows; @@ -47,6 +50,7 @@ * Test for task scheduler. */ @SuppressWarnings({"ProhibitedExceptionDeclared", "TooBroadScope"}) +@RunWith(JUnit4.class) public class GridScheduleSelfTest extends GridCommonAbstractTest { /** */ private static final int NODES_CNT = 2; @@ -89,6 +93,7 @@ public class GridScheduleSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testRunLocal() throws Exception { for (int i = 0; i < NODES_CNT; i++) { IgniteFuture fut = grid(i).scheduler().runLocal(new TestRunnable()); @@ -102,6 +107,7 @@ public void testRunLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCallLocal() throws Exception { for (int i = 0; i < NODES_CNT; i++) { IgniteFuture fut = grid(i).scheduler().callLocal(new TestCallable()); @@ -115,6 +121,7 @@ public void testCallLocal() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScheduleRunnable() throws Exception { final CountDownLatch latch = new CountDownLatch(1); @@ -232,6 +239,7 @@ public void testScheduleRunnable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testScheduleCallable() throws Exception { SchedulerFuture fut = null; @@ -289,6 +297,7 @@ public void testScheduleCallable() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRunnableCancel() throws Exception { SchedulerFuture fut = null; @@ -339,6 +348,7 @@ public void testRunnableCancel() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInvalidPatterns() throws Exception { Runnable run = new Runnable() { @Override public void run() { @@ -410,6 +420,7 @@ public void testInvalidPatterns() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoNextExecutionTime() throws Exception { Callable run = new Callable() { @Override public Integer call() { @@ -508,4 +519,4 @@ private static class TestCallable implements IgniteCallable { return execCntr.incrementAndGet(); } } -} \ No newline at end of file +} diff --git a/modules/schedule/src/test/java/org/apache/ignite/testsuites/IgniteSchedulerTestSuite.java b/modules/schedule/src/test/java/org/apache/ignite/testsuites/IgniteSchedulerTestSuite.java index 688c3ebbbcae3..e1b95a78b2594 100644 --- a/modules/schedule/src/test/java/org/apache/ignite/testsuites/IgniteSchedulerTestSuite.java +++ b/modules/schedule/src/test/java/org/apache/ignite/testsuites/IgniteSchedulerTestSuite.java @@ -17,22 +17,25 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.schedule.GridScheduleSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Scheduler tests. */ -public class IgniteSchedulerTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSchedulerTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Grid Scheduler Test Suite"); - suite.addTestSuite(GridScheduleSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridScheduleSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/slf4j/src/test/java/org/apache/ignite/logger/slf4j/Slf4jLoggerMarkerTest.java b/modules/slf4j/src/test/java/org/apache/ignite/logger/slf4j/Slf4jLoggerMarkerTest.java index 578e6ba3def3d..70b52067bd18b 100644 --- a/modules/slf4j/src/test/java/org/apache/ignite/logger/slf4j/Slf4jLoggerMarkerTest.java +++ b/modules/slf4j/src/test/java/org/apache/ignite/logger/slf4j/Slf4jLoggerMarkerTest.java @@ -18,14 +18,20 @@ package org.apache.ignite.logger.slf4j; import java.io.File; -import junit.framework.TestCase; import org.apache.ignite.internal.util.typedef.internal.U; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.slf4j.LoggerFactory; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; + /** * Testing that markers are supported by log4j2 implementation. */ -public class Slf4jLoggerMarkerTest extends TestCase { +public class Slf4jLoggerMarkerTest { /** Path to full log. */ private static final String LOG_ALL = "work/log/all.log"; @@ -33,20 +39,19 @@ public class Slf4jLoggerMarkerTest extends TestCase { private static final String LOG_FILTERED = "work/log/filtered.log"; /** */ - @Override protected void setUp() throws Exception { - super.setUp(); - + @Before + public void setUp() { deleteLogs(); } /** */ - @Override protected void tearDown() throws Exception { - super.tearDown(); - + @After + public void tearDown() { deleteLogs(); } /** */ + @Test public void testMarkerFiltering() throws Exception { // create log Slf4jLogger log = new Slf4jLogger(LoggerFactory.getLogger(Slf4jLoggerMarkerTest.class)); diff --git a/modules/slf4j/src/test/java/org/apache/ignite/testsuites/IgniteSlf4jTestSuite.java b/modules/slf4j/src/test/java/org/apache/ignite/testsuites/IgniteSlf4jTestSuite.java index 8668f927ca370..25deaeaf9e2b0 100644 --- a/modules/slf4j/src/test/java/org/apache/ignite/testsuites/IgniteSlf4jTestSuite.java +++ b/modules/slf4j/src/test/java/org/apache/ignite/testsuites/IgniteSlf4jTestSuite.java @@ -17,20 +17,24 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.logger.slf4j.Slf4jLoggerMarkerTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Slf4j logging tests. */ -public class IgniteSlf4jTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSlf4jTestSuite { /** * @return Test suite. */ public static TestSuite suite() { TestSuite suite = new TestSuite("Slf4j Logging Test Suite"); - suite.addTestSuite(Slf4jLoggerMarkerTest.class); + suite.addTest(new JUnit4TestAdapter(Slf4jLoggerMarkerTest.class)); return suite; } diff --git a/modules/spark/pom.xml b/modules/spark/pom.xml index e8d4c2f5acafd..b054c42a4e821 100644 --- a/modules/spark/pom.xml +++ b/modules/spark/pom.xml @@ -151,7 +151,7 @@ org.scalatest scalatest_2.11 - 2.2.6 + ${scala.test.version} test diff --git a/modules/spark/src/test/java/org/apache/ignite/spark/JavaEmbeddedIgniteRDDSelfTest.java b/modules/spark/src/test/java/org/apache/ignite/spark/JavaEmbeddedIgniteRDDSelfTest.java index 49bb1ac63ed61..f4a9a1abe45d9 100644 --- a/modules/spark/src/test/java/org/apache/ignite/spark/JavaEmbeddedIgniteRDDSelfTest.java +++ b/modules/spark/src/test/java/org/apache/ignite/spark/JavaEmbeddedIgniteRDDSelfTest.java @@ -37,11 +37,15 @@ import org.apache.spark.sql.Column; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import scala.Tuple2; /** * Tests for {@link JavaIgniteRDD} (embedded mode). */ +@RunWith(JUnit4.class) public class JavaEmbeddedIgniteRDDSelfTest extends GridCommonAbstractTest { /** For Ignite instance names generation */ private static AtomicInteger cntr = new AtomicInteger(1); @@ -64,7 +68,7 @@ public class JavaEmbeddedIgniteRDDSelfTest extends GridCommonAbstractTest { /** Sum function. */ private static final Function2 SUM_F = new Function2() { - public Integer call(Integer x, Integer y) { + @Override public Integer call(Integer x, Integer y) { return x + y; } }; @@ -120,6 +124,7 @@ private JavaSparkContext createContext() { /** * @throws Exception If failed. */ + @Test public void testStoreDataToIgnite() throws Exception { JavaSparkContext sc = createContext(); @@ -153,6 +158,7 @@ public void testStoreDataToIgnite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadDataFromIgnite() throws Exception { JavaSparkContext sc = createContext(); @@ -187,6 +193,7 @@ public void testReadDataFromIgnite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryObjectsFromIgnite() throws Exception { JavaSparkContext sc = createContext(); @@ -225,6 +232,7 @@ public void testQueryObjectsFromIgnite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryFieldsFromIgnite() throws Exception { JavaSparkContext sc = createContext(); @@ -272,9 +280,6 @@ public void testQueryFieldsFromIgnite() throws Exception { } } - /** Finder. */ - private static TcpDiscoveryVmIpFinder FINDER = new TcpDiscoveryVmIpFinder(true); - /** * @param igniteInstanceName Ignite instance name. * @param client Client. @@ -284,12 +289,6 @@ public void testQueryFieldsFromIgnite() throws Exception { private static IgniteConfiguration getConfiguration(String igniteInstanceName, boolean client) throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(FINDER); - - cfg.setDiscoverySpi(discoSpi); - cfg.setCacheConfiguration(cacheConfiguration()); cfg.setClientMode(client); diff --git a/modules/spark/src/test/java/org/apache/ignite/spark/JavaStandaloneIgniteRDDSelfTest.java b/modules/spark/src/test/java/org/apache/ignite/spark/JavaStandaloneIgniteRDDSelfTest.java index 29ada3f459d7d..1ec637c81cd90 100644 --- a/modules/spark/src/test/java/org/apache/ignite/spark/JavaStandaloneIgniteRDDSelfTest.java +++ b/modules/spark/src/test/java/org/apache/ignite/spark/JavaStandaloneIgniteRDDSelfTest.java @@ -37,6 +37,9 @@ import org.apache.spark.sql.Column; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import scala.Tuple2; import java.lang.reflect.Field; @@ -46,6 +49,7 @@ /** * Tests for {@link JavaIgniteRDD} (standalone mode). */ +@RunWith(JUnit4.class) public class JavaStandaloneIgniteRDDSelfTest extends GridCommonAbstractTest { /** Grid count. */ private static final int GRID_CNT = 3; @@ -64,7 +68,7 @@ public class JavaStandaloneIgniteRDDSelfTest extends GridCommonAbstractTest { /** Sum function. */ private static final Function2 SUM_F = new Function2() { - public Integer call(Integer x, Integer y) { + @Override public Integer call(Integer x, Integer y) { return x + y; } }; @@ -120,6 +124,7 @@ public Integer call(Integer x, Integer y) { /** * @throws Exception If failed. */ + @Test public void testStoreDataToIgnite() throws Exception { JavaSparkContext sc = new JavaSparkContext("local[*]", "test"); @@ -148,6 +153,7 @@ public void testStoreDataToIgnite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReadDataFromIgnite() throws Exception { JavaSparkContext sc = new JavaSparkContext("local[*]", "test"); @@ -177,6 +183,7 @@ public void testReadDataFromIgnite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryObjectsFromIgnite() throws Exception { JavaSparkContext sc = new JavaSparkContext("local[*]", "test"); @@ -204,6 +211,7 @@ public void testQueryObjectsFromIgnite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQueryFieldsFromIgnite() throws Exception { JavaSparkContext sc = new JavaSparkContext("local[*]", "test"); @@ -249,6 +257,7 @@ public void testQueryFieldsFromIgnite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAllFieldsTypes() throws Exception { JavaSparkContext sc = new JavaSparkContext("local[*]", "test"); diff --git a/modules/spark/src/test/java/org/apache/ignite/testsuites/IgniteRDDTestSuite.java b/modules/spark/src/test/java/org/apache/ignite/testsuites/IgniteRDDTestSuite.java index 9d6227b49939a..e963dd1ab19e9 100644 --- a/modules/spark/src/test/java/org/apache/ignite/testsuites/IgniteRDDTestSuite.java +++ b/modules/spark/src/test/java/org/apache/ignite/testsuites/IgniteRDDTestSuite.java @@ -17,23 +17,26 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.spark.JavaEmbeddedIgniteRDDSelfTest; import org.apache.ignite.spark.JavaStandaloneIgniteRDDSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Test suit for Ignite RDD */ -public class IgniteRDDTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteRDDTestSuite { /** * @return Java Ignite RDD test suit. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Java Ignite RDD tests (standalone and embedded modes"); - suite.addTest(new TestSuite(JavaEmbeddedIgniteRDDSelfTest.class)); - suite.addTest(new TestSuite(JavaStandaloneIgniteRDDSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JavaEmbeddedIgniteRDDSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(JavaStandaloneIgniteRDDSelfTest.class)); return suite; } diff --git a/modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java b/modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java index 766b2a8e60d40..5e717bf9dbaa1 100644 --- a/modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java +++ b/modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java @@ -26,11 +26,15 @@ import org.apache.ignite.springdata.misc.Person; import org.apache.ignite.springdata.misc.PersonRepository; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.context.annotation.AnnotationConfigApplicationContext; /** * */ +@RunWith(JUnit4.class) public class IgniteSpringDataCrudSelfTest extends GridCommonAbstractTest { /** Repository. */ private static PersonRepository repo; @@ -80,6 +84,7 @@ public class IgniteSpringDataCrudSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testPutGet() { Person person = new Person("some_name", "some_surname"); @@ -104,6 +109,7 @@ public void testPutGet() { /** * */ + @Test public void testPutAllGetAll() { LinkedHashMap map = new LinkedHashMap<>(); @@ -143,6 +149,7 @@ public void testPutAllGetAll() { /** * */ + @Test public void testGetAll() { assertEquals(CACHE_SIZE, repo.count()); @@ -161,6 +168,7 @@ public void testGetAll() { /** * */ + @Test public void testDelete() { assertEquals(CACHE_SIZE, repo.count()); @@ -182,6 +190,7 @@ public void testDelete() { /** * */ + @Test public void testDeleteSet() { assertEquals(CACHE_SIZE, repo.count()); @@ -212,6 +221,7 @@ public void testDeleteSet() { /** * */ + @Test public void testDeleteAll() { assertEquals(CACHE_SIZE, repo.count()); diff --git a/modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java b/modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java index c03c9c8fadcbc..68ff6e747bb16 100644 --- a/modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java +++ b/modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.springdata.misc.Person; import org.apache.ignite.springdata.misc.PersonSecondRepository; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Slice; @@ -34,6 +37,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteSpringDataQueriesSelfTest extends GridCommonAbstractTest { /** Repository. */ private static PersonRepository repo; @@ -76,6 +80,7 @@ public class IgniteSpringDataQueriesSelfTest extends GridCommonAbstractTest { } /** */ + @Test public void testExplicitQuery() { List persons = repo.simpleQuery("person4a"); @@ -86,6 +91,7 @@ public void testExplicitQuery() { } /** */ + @Test public void testEqualsPart() { List persons = repo.findByFirstName("person4e"); @@ -96,6 +102,7 @@ public void testEqualsPart() { } /** */ + @Test public void testContainingPart() { List persons = repo.findByFirstNameContaining("person4"); @@ -106,6 +113,7 @@ public void testContainingPart() { } /** */ + @Test public void testTopPart() { Iterable top = repo.findTopByFirstNameContaining("person4"); @@ -119,6 +127,7 @@ public void testTopPart() { } /** */ + @Test public void testLikeAndLimit() { Iterable like = repo.findFirst10ByFirstNameLike("person"); @@ -134,6 +143,7 @@ public void testLikeAndLimit() { } /** */ + @Test public void testCount() { int cnt = repo.countByFirstNameLike("person"); @@ -141,6 +151,7 @@ public void testCount() { } /** */ + @Test public void testCount2() { int cnt = repo.countByFirstNameLike("person4"); @@ -148,6 +159,7 @@ public void testCount2() { } /** */ + @Test public void testPageable() { PageRequest pageable = new PageRequest(1, 5, Sort.Direction.DESC, "firstName"); @@ -177,6 +189,7 @@ public void testPageable() { } /** */ + @Test public void testAndAndOr() { int cntAnd = repo.countByFirstNameLikeAndSecondNameLike("person1", "lastName1"); @@ -186,6 +199,7 @@ public void testAndAndOr() { } /** */ + @Test public void testQueryWithSort() { List persons = repo.queryWithSort("^[a-z]+$", new Sort(Sort.Direction.DESC, "secondName")); @@ -201,6 +215,7 @@ public void testQueryWithSort() { } /** */ + @Test public void testQueryWithPaging() { List persons = repo.queryWithPageable("^[a-z]+$", new PageRequest(1, 7, Sort.Direction.DESC, "secondName")); @@ -218,6 +233,7 @@ public void testQueryWithPaging() { } /** */ + @Test public void testQueryFields() { List persons = repo.selectField("^[a-z]+$", new PageRequest(1, 7, Sort.Direction.DESC, "secondName")); @@ -225,6 +241,7 @@ public void testQueryFields() { } /** */ + @Test public void testFindCacheEntries() { List> cacheEntries = repo.findBySecondNameLike("stName1"); @@ -235,6 +252,7 @@ public void testFindCacheEntries() { } /** */ + @Test public void testFindOneCacheEntry() { Cache.Entry cacheEntry = repo.findTopBySecondNameLike("tName18"); @@ -244,6 +262,7 @@ public void testFindOneCacheEntry() { } /** */ + @Test public void testFindOneValue() { Person person = repo.findTopBySecondNameStartingWith("lastName18"); @@ -253,6 +272,7 @@ public void testFindOneValue() { } /** */ + @Test public void testSelectSeveralFields() { List lists = repo.selectSeveralField("^[a-z]+$", new PageRequest(2, 6)); @@ -266,6 +286,7 @@ public void testSelectSeveralFields() { } /** */ + @Test public void testCountQuery() { int cnt = repo.countQuery(".*"); @@ -273,6 +294,7 @@ public void testCountQuery() { } /** */ + @Test public void testSliceOfCacheEntries() { Slice> slice = repo2.findBySecondNameIsNot("lastName18", new PageRequest(3, 4)); @@ -283,6 +305,7 @@ public void testSliceOfCacheEntries() { } /** */ + @Test public void testSliceOfLists() { Slice lists = repo2.querySliceOfList("^[a-z]+$", new PageRequest(0, 3)); diff --git a/modules/spring-data-2.0/src/test/java/org/apache/ignite/testsuites/IgniteSpringData2TestSuite.java b/modules/spring-data-2.0/src/test/java/org/apache/ignite/testsuites/IgniteSpringData2TestSuite.java index c4134e565864b..4fb9605625857 100644 --- a/modules/spring-data-2.0/src/test/java/org/apache/ignite/testsuites/IgniteSpringData2TestSuite.java +++ b/modules/spring-data-2.0/src/test/java/org/apache/ignite/testsuites/IgniteSpringData2TestSuite.java @@ -17,23 +17,26 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.springdata.IgniteSpringDataCrudSelfTest; import org.apache.ignite.springdata.IgniteSpringDataQueriesSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Ignite Spring Data 2.0 test suite. */ -public class IgniteSpringData2TestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpringData2TestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Spring Data 2.0 Test Suite"); - suite.addTestSuite(IgniteSpringDataCrudSelfTest.class); - suite.addTestSuite(IgniteSpringDataQueriesSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteSpringDataCrudSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSpringDataQueriesSelfTest.class)); return suite; } diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java index f9011fad753dc..155e784069c04 100644 --- a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java +++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfTest.java @@ -25,11 +25,15 @@ import org.apache.ignite.springdata.misc.Person; import org.apache.ignite.springdata.misc.PersonRepository; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.context.annotation.AnnotationConfigApplicationContext; /** * */ +@RunWith(JUnit4.class) public class IgniteSpringDataCrudSelfTest extends GridCommonAbstractTest { /** Repository. */ private static PersonRepository repo; @@ -79,6 +83,7 @@ public class IgniteSpringDataCrudSelfTest extends GridCommonAbstractTest { /** * */ + @Test public void testPutGet() { Person person = new Person("some_name", "some_surname"); @@ -103,6 +108,7 @@ public void testPutGet() { /** * */ + @Test public void testPutAllGetAll() { LinkedHashMap map = new LinkedHashMap<>(); @@ -142,6 +148,7 @@ public void testPutAllGetAll() { /** * */ + @Test public void testGetAll() { assertEquals(CACHE_SIZE, repo.count()); @@ -160,6 +167,7 @@ public void testGetAll() { /** * */ + @Test public void testDelete() { assertEquals(CACHE_SIZE, repo.count()); @@ -181,6 +189,7 @@ public void testDelete() { /** * */ + @Test public void testDeleteSet() { assertEquals(CACHE_SIZE, repo.count()); @@ -211,6 +220,7 @@ public void testDeleteSet() { /** * */ + @Test public void testDeleteAll() { assertEquals(CACHE_SIZE, repo.count()); diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java index 2d7dcc0d8eb3e..d7678c64a1418 100644 --- a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java +++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.springdata.misc.Person; import org.apache.ignite.springdata.misc.PersonSecondRepository; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Slice; @@ -34,6 +37,7 @@ /** * */ +@RunWith(JUnit4.class) public class IgniteSpringDataQueriesSelfTest extends GridCommonAbstractTest { /** Repository. */ private static PersonRepository repo; @@ -70,6 +74,7 @@ public class IgniteSpringDataQueriesSelfTest extends GridCommonAbstractTest { } /** */ + @Test public void testExplicitQuery() { List persons = repo.simpleQuery("person4a"); @@ -80,6 +85,7 @@ public void testExplicitQuery() { } /** */ + @Test public void testEqualsPart() { List persons = repo.findByFirstName("person4e"); @@ -90,6 +96,7 @@ public void testEqualsPart() { } /** */ + @Test public void testContainingPart() { List persons = repo.findByFirstNameContaining("person4"); @@ -100,6 +107,7 @@ public void testContainingPart() { } /** */ + @Test public void testTopPart() { Iterable top = repo.findTopByFirstNameContaining("person4"); @@ -113,6 +121,7 @@ public void testTopPart() { } /** */ + @Test public void testLikeAndLimit() { Iterable like = repo.findFirst10ByFirstNameLike("person"); @@ -128,6 +137,7 @@ public void testLikeAndLimit() { } /** */ + @Test public void testCount() { int cnt = repo.countByFirstNameLike("person"); @@ -135,6 +145,7 @@ public void testCount() { } /** */ + @Test public void testCount2() { int cnt = repo.countByFirstNameLike("person4"); @@ -142,6 +153,7 @@ public void testCount2() { } /** */ + @Test public void testPageable() { PageRequest pageable = new PageRequest(1, 5, Sort.Direction.DESC, "firstName"); @@ -169,6 +181,7 @@ public void testPageable() { } /** */ + @Test public void testAndAndOr() { int cntAnd = repo.countByFirstNameLikeAndSecondNameLike("person1", "lastName1"); @@ -178,6 +191,7 @@ public void testAndAndOr() { } /** */ + @Test public void testQueryWithSort() { List persons = repo.queryWithSort("^[a-z]+$", new Sort(Sort.Direction.DESC, "secondName")); @@ -193,6 +207,7 @@ public void testQueryWithSort() { } /** */ + @Test public void testQueryWithPaging() { List persons = repo.queryWithPageable("^[a-z]+$", new PageRequest(1, 7, Sort.Direction.DESC, "secondName")); @@ -210,6 +225,7 @@ public void testQueryWithPaging() { } /** */ + @Test public void testQueryFields() { List persons = repo.selectField("^[a-z]+$", new PageRequest(1, 7, Sort.Direction.DESC, "secondName")); @@ -217,6 +233,7 @@ public void testQueryFields() { } /** */ + @Test public void testFindCacheEntries() { List> cacheEntries = repo.findBySecondNameLike("stName1"); @@ -227,6 +244,7 @@ public void testFindCacheEntries() { } /** */ + @Test public void testFindOneCacheEntry() { Cache.Entry cacheEntry = repo.findTopBySecondNameLike("tName18"); @@ -236,6 +254,7 @@ public void testFindOneCacheEntry() { } /** */ + @Test public void testFindOneValue() { Person person = repo.findTopBySecondNameStartingWith("lastName18"); @@ -245,6 +264,7 @@ public void testFindOneValue() { } /** */ + @Test public void testSelectSeveralFields() { List lists = repo.selectSeveralField("^[a-z]+$", new PageRequest(2, 6)); @@ -258,6 +278,7 @@ public void testSelectSeveralFields() { } /** */ + @Test public void testCountQuery() { int cnt = repo.countQuery(".*"); @@ -265,6 +286,7 @@ public void testCountQuery() { } /** */ + @Test public void testSliceOfCacheEntries() { Slice> slice = repo2.findBySecondNameIsNot("lastName18", new PageRequest(3, 4)); @@ -275,6 +297,7 @@ public void testSliceOfCacheEntries() { } /** */ + @Test public void testSliceOfLists() { Slice lists = repo2.querySliceOfList("^[a-z]+$", new PageRequest(0, 3)); @@ -290,6 +313,7 @@ public void testSliceOfLists() { /** * Tests the repository method with a custom query which takes no parameters. */ + @Test public void testCountAllPersons() { int cnt = repo.countAllPersons(); diff --git a/modules/spring-data/src/test/java/org/apache/ignite/testsuites/IgniteSpringDataTestSuite.java b/modules/spring-data/src/test/java/org/apache/ignite/testsuites/IgniteSpringDataTestSuite.java index 0d6c51965108b..503c820f1f9ef 100644 --- a/modules/spring-data/src/test/java/org/apache/ignite/testsuites/IgniteSpringDataTestSuite.java +++ b/modules/spring-data/src/test/java/org/apache/ignite/testsuites/IgniteSpringDataTestSuite.java @@ -17,23 +17,26 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.springdata.IgniteSpringDataCrudSelfTest; import org.apache.ignite.springdata.IgniteSpringDataQueriesSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Ignite Spring Data test suite. */ -public class IgniteSpringDataTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpringDataTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Spring Data Test Suite"); - suite.addTestSuite(IgniteSpringDataCrudSelfTest.class); - suite.addTestSuite(IgniteSpringDataQueriesSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteSpringDataCrudSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSpringDataQueriesSelfTest.class)); return suite; } diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerAbstractTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerAbstractTest.java index 370c6346ad07e..bed8574541b80 100644 --- a/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerAbstractTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerAbstractTest.java @@ -22,10 +22,14 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Spring cache test. */ +@RunWith(JUnit4.class) public abstract class GridSpringCacheManagerAbstractTest extends GridCommonAbstractTest { /** */ protected static final String CACHE_NAME = "testCache"; @@ -61,6 +65,7 @@ public abstract class GridSpringCacheManagerAbstractTest extends GridCommonAbstr /** * @throws Exception If failed. */ + @Test public void testSimpleKey() throws Exception { for (int i = 0; i < 3; i++) { assertEquals("value" + i, svc.simpleKey(i)); @@ -80,6 +85,7 @@ public void testSimpleKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleKeyNullValue() throws Exception { for (int i = 0; i < 3; i++) { assertNull(svc.simpleKeyNullValue(i)); @@ -99,6 +105,7 @@ public void testSimpleKeyNullValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testComplexKey() throws Exception { for (int i = 0; i < 3; i++) { assertEquals("value" + i + "suffix" + i, svc.complexKey(i, "suffix" + i)); @@ -118,6 +125,7 @@ public void testComplexKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testComplexKeyNullValue() throws Exception { for (int i = 0; i < 3; i++) { assertNull(svc.complexKeyNullValue(i, "suffix" + i)); @@ -137,6 +145,7 @@ public void testComplexKeyNullValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleKeyPut() throws Exception { IgniteCache c = grid().cache(CACHE_NAME); @@ -158,6 +167,7 @@ public void testSimpleKeyPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleKeyPutNullValue() throws Exception { IgniteCache c = grid().cache(CACHE_NAME); @@ -179,6 +189,7 @@ public void testSimpleKeyPutNullValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testComplexKeyPut() throws Exception { IgniteCache c = grid().cache(CACHE_NAME); @@ -200,6 +211,7 @@ public void testComplexKeyPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testComplexKeyPutNullValue() throws Exception { IgniteCache c = grid().cache(CACHE_NAME); @@ -221,6 +233,7 @@ public void testComplexKeyPutNullValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleKeyEvict() throws Exception { IgniteCache c = grid().cache(CACHE_NAME); @@ -245,6 +258,7 @@ public void testSimpleKeyEvict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testComplexKeyEvict() throws Exception { IgniteCache c = grid().cache(CACHE_NAME); @@ -269,6 +283,7 @@ public void testComplexKeyEvict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvictAll() throws Exception { IgniteCache c = grid().cache(CACHE_NAME); @@ -289,6 +304,7 @@ public void testEvictAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicCache() throws Exception { for (int i = 0; i < 3; i++) { assertEquals("value" + i, dynamicSvc.cacheable(i)); @@ -311,6 +327,7 @@ public void testDynamicCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicCachePut() throws Exception { for (int i = 0; i < 3; i++) { assertEquals("value" + i, dynamicSvc.cachePut(i)); @@ -333,6 +350,7 @@ public void testDynamicCachePut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicCacheEvict() throws Exception { CacheConfiguration cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); @@ -360,6 +378,7 @@ public void testDynamicCacheEvict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicCacheEvictAll() throws Exception { CacheConfiguration cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerMultiJvmSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerMultiJvmSelfTest.java index acf09a77628c3..0b3f7073ba6e2 100644 --- a/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerMultiJvmSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerMultiJvmSelfTest.java @@ -29,12 +29,16 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Spring cache test in multi jvm environment. */ +@RunWith(JUnit4.class) public class GridSpringCacheManagerMultiJvmSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected boolean isMultiJvm() { @@ -54,6 +58,7 @@ public class GridSpringCacheManagerMultiJvmSelfTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testSyncCache() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-9488"); diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerSelfTest.java index 33adcb07a43a0..75c722a0f3622 100644 --- a/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerSelfTest.java @@ -19,9 +19,6 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -29,9 +26,6 @@ * Spring cache test. */ public class GridSpringCacheManagerSelfTest extends GridSpringCacheManagerAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -42,12 +36,6 @@ public class GridSpringCacheManagerSelfTest extends GridSpringCacheManagerAbstra cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/spring/SpringCacheManagerContextInjectionTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/spring/SpringCacheManagerContextInjectionTest.java index 482c837651b2f..68373608187af 100644 --- a/modules/spring/src/test/java/org/apache/ignite/cache/spring/SpringCacheManagerContextInjectionTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/cache/spring/SpringCacheManagerContextInjectionTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.internal.IgnitionEx; import org.apache.ignite.lifecycle.LifecycleBean; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -31,10 +34,12 @@ /** * */ +@RunWith(JUnit4.class) public class SpringCacheManagerContextInjectionTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testBeanInjectionUsingConfigPath() throws Exception { new AnnotationConfigApplicationContext(TestPathConfiguration.class); @@ -56,6 +61,7 @@ public void testBeanInjectionUsingConfigPath() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBeanInjectionUsingConfiguration() throws Exception { BeanFactory factory = new AnnotationConfigApplicationContext(TestCfgConfiguration.class); diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/spring/SpringCacheTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/spring/SpringCacheTest.java index 53c52f84413a3..3b80a63f975fd 100644 --- a/modules/spring/src/test/java/org/apache/ignite/cache/spring/SpringCacheTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/cache/spring/SpringCacheTest.java @@ -21,10 +21,14 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.internal.util.typedef.G; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for {@link SpringCache} */ +@RunWith(JUnit4.class) public class SpringCacheTest extends GridCommonAbstractTest { /** */ private static Ignite ignite; @@ -70,6 +74,7 @@ public class SpringCacheTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testGetName() throws Exception { assertEquals(cacheName, springCache.getName()); } @@ -77,6 +82,7 @@ public void testGetName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetNativeCache() throws Exception { assertEquals(nativeCache, springCache.getNativeCache()); } @@ -84,6 +90,7 @@ public void testGetNativeCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetByKey() throws Exception { String key = "key"; String value = "value"; @@ -97,6 +104,7 @@ public void testGetByKey() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetByKeyType() throws Exception { String key = "key"; String value = "value"; @@ -116,6 +124,7 @@ public void testGetByKeyType() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPut() throws Exception { String key = "key"; assertNull(springCache.get(key)); @@ -129,6 +138,7 @@ public void testPut() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPutIfAbsent() throws Exception { String key = "key"; String expected = "value"; @@ -143,6 +153,7 @@ public void testPutIfAbsent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testEvict() throws Exception { String key = "key"; assertNull(springCache.get(key)); @@ -157,6 +168,7 @@ public void testEvict() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClear() throws Exception { String key; springCache.put((key = "key1"), "value1"); diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactorySelfTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactorySelfTest.java index be2238bd8bf93..4a944f0edf398 100644 --- a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactorySelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStoreFactorySelfTest.java @@ -32,10 +32,15 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.h2.jdbcx.JdbcDataSource; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for Cache JDBC blob store factory. */ +@RunWith(JUnit4.class) public class CacheJdbcBlobStoreFactorySelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "test"; @@ -46,6 +51,7 @@ public class CacheJdbcBlobStoreFactorySelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testXmlConfiguration() throws Exception { try (Ignite ignite = Ignition.start("modules/spring/src/test/config/store-cache.xml")) { try(Ignite ignite1 = Ignition.start("modules/spring/src/test/config/store-cache1.xml")) { @@ -59,6 +65,7 @@ public void testXmlConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCacheConfiguration() throws Exception { try (Ignite ignite = Ignition.start("modules/spring/src/test/config/node.xml")) { try (Ignite ignite1 = Ignition.start("modules/spring/src/test/config/node1.xml")) { @@ -76,8 +83,10 @@ public void testCacheConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10723") + @Test public void testIncorrectBeanConfiguration() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-1094"); + fail("https://issues.apache.org/jira/browse/IGNITE-10723"); GridTestUtils.assertThrows(log, new Callable() { @Override public Object call() throws Exception { diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactorySelfTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactorySelfTest.java index ba4984d22cab9..084143e40f0ec 100644 --- a/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactorySelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreFactorySelfTest.java @@ -29,10 +29,15 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.h2.jdbcx.JdbcDataSource; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for Cache JDBC POJO store factory. */ +@RunWith(JUnit4.class) public class CacheJdbcPojoStoreFactorySelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String CACHE_NAME = "test"; @@ -40,6 +45,7 @@ public class CacheJdbcPojoStoreFactorySelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testCacheConfiguration() throws Exception { try (Ignite ignite = Ignition.start("modules/spring/src/test/config/node.xml")) { try (Ignite ignite1 = Ignition.start("modules/spring/src/test/config/node1.xml")) { @@ -57,6 +63,7 @@ public void testCacheConfiguration() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSerializable() throws Exception { try (Ignite ignite = Ignition.start("modules/spring/src/test/config/node.xml")) { try (IgniteCache cache = ignite.getOrCreateCache(cacheConfigurationH2Dialect())) { @@ -68,8 +75,10 @@ public void testSerializable() throws Exception { /** * @throws Exception If failed. */ + @Ignore("https://issues.apache.org/jira/browse/IGNITE-10723") + @Test public void testIncorrectBeanConfiguration() throws Exception { - fail("https://issues.apache.org/jira/browse/IGNITE-1094"); + fail("https://issues.apache.org/jira/browse/IGNITE-10723"); GridTestUtils.assertThrowsAnyCause(log, new Callable() { @Override public Object call() throws Exception { diff --git a/modules/spring/src/test/java/org/apache/ignite/encryption/SpringEncryptedCacheRestartTest.java b/modules/spring/src/test/java/org/apache/ignite/encryption/SpringEncryptedCacheRestartTest.java index 64885274cbea8..962209a0b2ff4 100644 --- a/modules/spring/src/test/java/org/apache/ignite/encryption/SpringEncryptedCacheRestartTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/encryption/SpringEncryptedCacheRestartTest.java @@ -29,10 +29,14 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; /** */ +@RunWith(JUnit4.class) public class SpringEncryptedCacheRestartTest extends EncryptedCacheRestartTest { /** {@inheritDoc} */ @Override protected void createEncryptedCache(IgniteEx grid0, IgniteEx grid1, String cacheName, String cacheGroup) { @@ -63,6 +67,7 @@ public class SpringEncryptedCacheRestartTest extends EncryptedCacheRestartTest { } /** @throws Exception If failed. */ + @Test public void testEncryptionKeysEqualsOnThirdNodeJoin() throws Exception { T2 g = startTestGrids(true); @@ -97,6 +102,7 @@ public void testEncryptionKeysEqualsOnThirdNodeJoin() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreateEncryptedCacheGroup() throws Exception { IgniteEx g0 = (IgniteEx)IgnitionEx.start( IgniteUtils.resolveIgnitePath( @@ -134,6 +140,7 @@ public void testCreateEncryptedCacheGroup() throws Exception { } /** @throws Exception If failed. */ + @Test public void testCreateNotEncryptedCacheInEncryptedGroupFails() throws Exception { IgniteEx g0 = (IgniteEx)IgnitionEx.start( IgniteUtils.resolveIgnitePath( @@ -151,6 +158,7 @@ public void testCreateNotEncryptedCacheInEncryptedGroupFails() throws Exception } /** @throws Exception If failed. */ + @Test public void testStartWithEncryptedOnDiskPlainInCfg() throws Exception { doTestDiffCfgAndPersistentFlagVal( "modules/spring/src/test/config/enc/enc-cache.xml", @@ -158,6 +166,7 @@ public void testStartWithEncryptedOnDiskPlainInCfg() throws Exception { } /** @throws Exception If failed. */ + @Test public void testStartWithPlainOnDiskEncryptedInCfg() throws Exception { doTestDiffCfgAndPersistentFlagVal( "modules/spring/src/test/config/enc/not-encrypted-cache.xml", diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java index fd832a02a0be4..7cc008e0c9f82 100644 --- a/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java @@ -57,8 +57,6 @@ import org.apache.ignite.spi.collision.CollisionExternalListener; import org.apache.ignite.spi.collision.CollisionSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.config.GridTestProperties; @@ -66,6 +64,9 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.ConstructorArgumentValues; import org.springframework.beans.factory.support.AbstractBeanDefinition; @@ -83,12 +84,9 @@ * Tests for {@link org.apache.ignite.Ignition}. * @see GridFactoryVmShutdownTest */ -@SuppressWarnings("UnusedDeclaration") @GridCommonTest(group = "NonDistributed Kernal Self") +@RunWith(JUnit4.class) public class GridFactorySelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private static final AtomicInteger cnt = new AtomicInteger(); @@ -114,18 +112,10 @@ public GridFactorySelfTest() { cnt.set(0); } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); - - return cfg; - } - /** * @throws Exception If failed. */ + @Test public void testIgnitionStartDefault() throws Exception { try (Ignite ignite = Ignition.start()) { log.info("Started1: " + ignite.name()); @@ -148,6 +138,7 @@ public void testIgnitionStartDefault() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartDefault() throws Exception { try (Ignite ignite = Ignition.start("config/default-config.xml")) { log.info("Started: " + ignite.name()); @@ -157,6 +148,7 @@ public void testStartDefault() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartGridWithConfigUrlString() throws Exception { GridEmbeddedHttpServer srv = null; String igniteInstanceName = "grid_with_url_config"; @@ -180,6 +172,7 @@ public void testStartGridWithConfigUrlString() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartGridWithConfigUrl() throws Exception { GridEmbeddedHttpServer srv = null; String igniteInstanceName = "grid_with_url_config"; @@ -203,6 +196,7 @@ public void testStartGridWithConfigUrl() throws Exception { /** * Tests default grid */ + @Test public void testDefaultGridGetOrStart() throws Exception { IgniteConfiguration cfg = getConfiguration(null); @@ -226,6 +220,7 @@ public void testDefaultGridGetOrStart() throws Exception { /** * Tests named grid */ + @Test public void testNamedGridGetOrStart() throws Exception { IgniteConfiguration cfg = getConfiguration("test"); try (Ignite ignite = Ignition.getOrStart(cfg)) { @@ -249,6 +244,7 @@ public void testNamedGridGetOrStart() throws Exception { /** * Tests concurrent grid initialization */ + @Test public void testConcurrentGridGetOrStartCon() throws Exception { final IgniteConfiguration cfg = getConfiguration(null); @@ -285,6 +281,7 @@ public void testConcurrentGridGetOrStartCon() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBeansNullIgniteInstanceName() throws Exception { checkLifecycleBeans(null); } @@ -292,6 +289,7 @@ public void testLifecycleBeansNullIgniteInstanceName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLifecycleBeansNotNullIgniteInstanceName() throws Exception { checkLifecycleBeans("testGrid"); } @@ -364,7 +362,7 @@ private void checkIgniteInstanceNameEquals(String n1, String n2) { /** * @throws Exception If failed. */ - @SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter"}) + @Test public void testStartMultipleGridsFromSpring() throws Exception { File cfgFile = GridTestUtils.resolveIgnitePath(GridTestProperties.getProperty("loader.self.multipletest.config")); @@ -419,6 +417,7 @@ else if ("grid-factory-test-2".equals(name)) /** * @throws Exception If failed. */ + @Test public void testStartMultipleDefaultGrids() throws Exception { try { multithreaded( @@ -456,6 +455,7 @@ public void testStartMultipleDefaultGrids() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartMultipleNonDefaultGrids() throws Exception { try { multithreaded( @@ -494,6 +494,7 @@ public void testStartMultipleNonDefaultGrids() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartStop() throws Exception { checkConcurrentStartStop("TEST_NAME"); } @@ -501,6 +502,7 @@ public void testConcurrentStartStop() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartStopDefaultGrid() throws Exception { checkConcurrentStartStop(null); } @@ -583,6 +585,7 @@ private void checkConcurrentStartStop(@Nullable final String igniteInstanceName) /** * @throws Exception If failed. */ + @Test public void testGridStartRollback() throws Exception { GridTestUtils.assertThrows( log, @@ -659,6 +662,7 @@ public void disabledTestStartSingleInstanceSpi() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartMultipleInstanceSpi() throws Exception { IgniteConfiguration cfg1 = getConfiguration(); IgniteConfiguration cfg2 = getConfiguration(); @@ -694,6 +698,7 @@ public void testStartMultipleInstanceSpi() throws Exception { /** * @throws Exception If failed. */ + @Test public void testLoadBean() throws Exception { final String path = "modules/spring/src/test/java/org/apache/ignite/internal/cache.xml"; @@ -929,6 +934,7 @@ private ApplicationContext getTestApplicationContext() { /** * @throws Exception If failed. */ + @Test public void testStopCancel() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); @@ -944,6 +950,7 @@ public void testStopCancel() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConfigInClassPath() throws Exception { try (Ignite ignite = Ignition.start("config/ignite-test-config.xml")) { assert "config-in-classpath".equals(ignite.name()); @@ -953,6 +960,7 @@ public void testConfigInClassPath() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCurrentIgnite() throws Exception { final String LEFT = "LEFT"; final String RIGHT = "RIGHT"; @@ -983,6 +991,7 @@ public void testCurrentIgnite() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRepeatingStart() throws Exception { try { IgniteConfiguration c = getConfiguration("1"); diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/GridSpringBeanSerializationSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/GridSpringBeanSerializationSelfTest.java index 6a72213235c09..04326606282b5 100644 --- a/modules/spring/src/test/java/org/apache/ignite/internal/GridSpringBeanSerializationSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/internal/GridSpringBeanSerializationSelfTest.java @@ -22,18 +22,16 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link org.apache.ignite.IgniteSpringBean} serialization. */ +@RunWith(JUnit4.class) public class GridSpringBeanSerializationSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** Marshaller. */ private Marshaller marsh; @@ -62,12 +60,6 @@ public class GridSpringBeanSerializationSelfTest extends GridCommonAbstractTest private IgniteConfiguration config() { IgniteConfiguration cfg = new IgniteConfiguration(); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - cfg.setUserAttributes(F.asMap(ATTR_KEY, true)); cfg.setConnectorConfiguration(null); @@ -87,6 +79,7 @@ private IgniteConfiguration config() { /** * @throws Exception If failed. */ + @Test public void testSerialization() throws Exception { assert bean != null; diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/IgniteDynamicCacheConfigTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/IgniteDynamicCacheConfigTest.java index 45655e1154fa6..13ed4ac9e66a3 100644 --- a/modules/spring/src/test/java/org/apache/ignite/internal/IgniteDynamicCacheConfigTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/internal/IgniteDynamicCacheConfigTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.http.GridEmbeddedHttpServer; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for dynamic cache start from config file. */ +@RunWith(JUnit4.class) public class IgniteDynamicCacheConfigTest extends GridCommonAbstractTest { /** */ public static final String CACHE_NAME = "TestDynamicCache"; @@ -86,6 +90,7 @@ public int nodeCount() { /** * @throws Exception If failed. */ + @Test public void testDynamicCacheStartFromConfig() throws Exception { IgniteCache cache = ignite(0).createCache(load( "modules/spring/src/test/java/org/apache/ignite/internal/cache.xml")); @@ -101,6 +106,7 @@ public void testDynamicCacheStartFromConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicNearCacheStartFromConfig() throws Exception { testAttribute = false; @@ -130,6 +136,7 @@ public void testDynamicNearCacheStartFromConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateNearCache() throws Exception { testAttribute = false; @@ -162,6 +169,7 @@ public void testCreateNearCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testGetOrCreateNearCache() throws Exception { testAttribute = false; @@ -197,6 +205,7 @@ public void testGetOrCreateNearCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDynamicCacheStartFromNotExistConfig() throws Exception { try { ignite(0).getOrCreateCache(load("config/cache.xml")); @@ -211,6 +220,7 @@ public void testDynamicCacheStartFromNotExistConfig() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartCachedWithConfigUrlString() throws Exception { GridEmbeddedHttpServer srv = null; diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/IgniteSpringBeanTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/IgniteSpringBeanTest.java index c7f0d59780f35..03ab32e8d10fe 100644 --- a/modules/spring/src/test/java/org/apache/ignite/internal/IgniteSpringBeanTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/internal/IgniteSpringBeanTest.java @@ -19,14 +19,19 @@ import org.apache.ignite.IgniteSpringBean; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class IgniteSpringBeanTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testInitialization() throws Exception { try (IgniteSpringBean bean = new IgniteSpringBean()) { bean.setConfiguration(getConfiguration("test")); @@ -40,6 +45,7 @@ public void testInitialization() throws Exception { /** * @throws Exception If failed. */ + @Test public void testIllegalState() throws Exception { IgniteSpringBean bean = new IgniteSpringBean(); diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridLoggerInjectionSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridLoggerInjectionSelfTest.java index 3fc64b5fab98b..60a84814ee2e8 100644 --- a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridLoggerInjectionSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridLoggerInjectionSelfTest.java @@ -28,10 +28,14 @@ import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.resources.LoggerResource; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for injected logger category. */ +@RunWith(JUnit4.class) public class GridLoggerInjectionSelfTest extends GridCommonAbstractTest implements Externalizable { /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { @@ -45,6 +49,7 @@ public class GridLoggerInjectionSelfTest extends GridCommonAbstractTest implemen * * @throws Exception If failed. */ + @Test public void testClosureField() throws Exception { Ignite ignite = grid(0); @@ -72,6 +77,7 @@ public void testClosureField() throws Exception { * * @throws Exception If failed. */ + @Test public void testClosureMethod() throws Exception { Ignite ignite = grid(0); @@ -99,6 +105,7 @@ private void log(IgniteLogger log) { * * @throws Exception If failed. */ + @Test public void testStringCategory() throws Exception { Ignite ignite = grid(0); @@ -130,4 +137,4 @@ private void log(IgniteLogger log) { @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // No-op. } -} \ No newline at end of file +} diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridResourceProcessorSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridResourceProcessorSelfTest.java index f3aecf86dfa8b..062a434857726 100644 --- a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridResourceProcessorSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridResourceProcessorSelfTest.java @@ -42,12 +42,16 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.util.Assert; /** * Unit tests for grid resource processor. */ @GridCommonTest(group = "Resource Self") +@RunWith(JUnit4.class) public class GridResourceProcessorSelfTest extends GridCommonAbstractTest { /** */ private GridTestKernalContext ctx; @@ -116,6 +120,7 @@ public void setStr(String str) { /** * @throws Exception If failed. */ + @Test public void testInjectResourceToAnnotatedField() throws Exception { TestClassWithAnnotatedField target = new TestClassWithAnnotatedField(); @@ -148,6 +153,7 @@ void setStr(String str) { /** * @throws Exception If failed. */ + @Test public void testInjectResourceToAnnotatedMethod() throws Exception { TestClassWithAnnotatedMethod target = new TestClassWithAnnotatedMethod(); @@ -269,6 +275,7 @@ private class TestClassWithAnnotationsDeep { /** * @throws Exception If failed. */ + @Test public void testInjectResourceInnerClasses() throws Exception { // Test fields. TestClassWithAnnotationsOuter outer = new TestClassWithAnnotationsOuter(); @@ -383,6 +390,7 @@ public IgniteLogger getTaskLog() { /** * @throws Exception If failed. */ + @Test public void testInjectResourceGridTaskAndJob() throws Exception { Ignite g = startGrid(); @@ -398,6 +406,7 @@ public void testInjectResourceGridTaskAndJob() throws Exception { /** * @throws Exception If failed. */ + @Test public void testInjectResourcePerformance() throws Exception { int injNum = 50000; @@ -417,6 +426,7 @@ public void testInjectResourcePerformance() throws Exception { * @throws Exception If failed. */ @SuppressWarnings("TooBroadScope") + @Test public void testInjectResourceMultiThreaded() throws Exception { final int threadsCnt = 100; final int iters = 2000000; @@ -475,4 +485,4 @@ private static final class Test1 { @TestAnnotation1 private String val1; } -} \ No newline at end of file +} diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridServiceInjectionSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridServiceInjectionSelfTest.java index a8cd89c064839..fe9623c1964d9 100644 --- a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridServiceInjectionSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridServiceInjectionSelfTest.java @@ -26,10 +26,14 @@ import org.apache.ignite.services.ServiceContext; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for injected service. */ +@RunWith(JUnit4.class) public class GridServiceInjectionSelfTest extends GridCommonAbstractTest implements Serializable { /** */ private static final long serialVersionUID = 0L; @@ -57,6 +61,7 @@ public class GridServiceInjectionSelfTest extends GridCommonAbstractTest impleme /** * @throws Exception If failed. */ + @Test public void testClosureField() throws Exception { grid(0).compute().call(new IgniteCallable() { @ServiceResource(serviceName = SERVICE_NAME1) @@ -76,6 +81,7 @@ public void testClosureField() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClosureFieldProxy() throws Exception { grid(0).compute(grid(0).cluster().forRemotes()).call(new IgniteCallable() { @ServiceResource(serviceName = SERVICE_NAME2, proxyInterface = DummyService.class) @@ -97,6 +103,7 @@ public void testClosureFieldProxy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClosureFieldLocalProxy() throws Exception { grid(0).compute(grid(0).cluster().forRemotes()).call(new IgniteCallable() { @ServiceResource(serviceName = SERVICE_NAME1, proxyInterface = DummyService.class) @@ -118,6 +125,7 @@ public void testClosureFieldLocalProxy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClosureFieldWithIncorrectType() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable() { @Override public Void call() { @@ -140,6 +148,7 @@ public void testClosureFieldWithIncorrectType() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClosureMethod() throws Exception { grid(0).compute().call(new IgniteCallable() { private DummyService svc; @@ -164,6 +173,7 @@ private void service(DummyService svc) { /** * @throws Exception If failed. */ + @Test public void testClosureMethodProxy() throws Exception { grid(0).compute(grid(0).cluster().forRemotes()).call(new IgniteCallable() { private DummyService svc; @@ -189,6 +199,7 @@ private void service(DummyService svc) { /** * @throws Exception If failed. */ + @Test public void testClosureMethodLocalProxy() throws Exception { grid(0).compute(grid(0).cluster().forRemotes()).call(new IgniteCallable() { private DummyService svc; @@ -214,6 +225,7 @@ private void service(DummyService svc) { /** * @throws Exception If failed. */ + @Test public void testClosureMethodWithIncorrectType() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable() { @Override public Void call() { @@ -236,6 +248,7 @@ private void service(String svcs) { /** * @throws Exception If failed. */ + @Test public void testClosureFieldWithNonExistentService() throws Exception { grid(0).compute().call(new IgniteCallable() { @ServiceResource(serviceName = "nonExistentService") @@ -252,6 +265,7 @@ public void testClosureFieldWithNonExistentService() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClosureMethodWithNonExistentService() throws Exception { grid(0).compute().call(new IgniteCallable() { @ServiceResource(serviceName = "nonExistentService") @@ -299,4 +313,4 @@ public static class DummyServiceImpl implements DummyService, Service { System.out.println("Executing service: " + ctx.name()); } } -} \ No newline at end of file +} diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridSpringResourceInjectionSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridSpringResourceInjectionSelfTest.java index 7f89b3244b34b..d891f91abef27 100644 --- a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridSpringResourceInjectionSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridSpringResourceInjectionSelfTest.java @@ -27,6 +27,9 @@ import org.apache.ignite.resources.SpringResource; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoUniqueBeanDefinitionException; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -35,6 +38,7 @@ * Tests for injected resource. */ @SuppressWarnings("unused") +@RunWith(JUnit4.class) public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest { /** Bean name. */ private static final String DUMMY_BEAN = "dummyResourceBean"; @@ -51,6 +55,7 @@ public class GridSpringResourceInjectionSelfTest extends GridCommonAbstractTest /** * @throws Exception If failed. */ + @Test public void testClosureFieldByResourceName() throws Exception { grid.compute().call(new IgniteCallable() { @SpringResource(resourceName = DUMMY_BEAN) @@ -67,6 +72,7 @@ public void testClosureFieldByResourceName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClosureFieldByResourceClass() throws Exception { grid.compute().call(new IgniteCallable() { @SpringResource(resourceClass = DummyResourceBean.class) @@ -83,6 +89,7 @@ public void testClosureFieldByResourceClass() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClosureFieldByResourceClassWithMultipleBeans() throws Exception { IgniteConfiguration anotherCfg = new IgniteConfiguration(); anotherCfg.setIgniteInstanceName("anotherGrid"); @@ -109,6 +116,7 @@ public void testClosureFieldByResourceClassWithMultipleBeans() throws Exception /** * Resource injection with non-existing resource name. */ + @Test public void testClosureFieldWithWrongResourceName() { assertError(new IgniteCallable() { @SpringResource(resourceName = "nonExistentResource") @@ -125,6 +133,7 @@ public void testClosureFieldWithWrongResourceName() { /** * Resource injection with non-existing resource class. */ + @Test public void testClosureFieldWithWrongResourceClass() { assertError(new IgniteCallable() { @SpringResource(resourceClass = AnotherDummyResourceBean.class) @@ -142,6 +151,7 @@ public void testClosureFieldWithWrongResourceClass() { /** * Resource injection with both resource and class set (ambiguity). */ + @Test public void testClosureFieldByResourceClassAndName() { assertError(new IgniteCallable() { @SpringResource(resourceClass = DummyResourceBean.class, resourceName = DUMMY_BEAN) @@ -158,6 +168,7 @@ public void testClosureFieldByResourceClassAndName() { /** * Resource injection with no name and class set. */ + @Test public void testClosureFieldWithNoParams() { assertError(new IgniteCallable() { @SpringResource @@ -174,6 +185,7 @@ public void testClosureFieldWithNoParams() { /** * @throws Exception If failed. */ + @Test public void testClosureMethodWithResourceName() throws Exception { grid.compute().call(new IgniteCallable() { private DummyResourceBean dummyRsrcBean; @@ -196,6 +208,7 @@ private void setDummyResourceBean(DummyResourceBean dummyRsrcBean) { /** * @throws Exception If failed. */ + @Test public void testClosureMethodWithResourceClass() throws Exception { grid.compute().call(new IgniteCallable() { private DummyResourceBean dummyRsrcBean; @@ -218,7 +231,7 @@ private void setDummyResourceBean(DummyResourceBean dummyRsrcBean) { /** * @throws Exception If failed. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") + @Test public void testClosureMethodWithResourceClassWithMultipleBeans() throws Exception { IgniteConfiguration anotherCfg = new IgniteConfiguration(); anotherCfg.setIgniteInstanceName("anotherGrid"); @@ -254,6 +267,7 @@ private void setDummyResourceBean(DummyResourceBean dummyRsrcBean) { /** * Resource injection with non-existing resource name. */ + @Test public void testClosureMethodWithWrongResourceName() { assertError(new IgniteCallable() { private DummyResourceBean dummyRsrcBean; @@ -274,6 +288,7 @@ private void setDummyResourceBean(DummyResourceBean dummyRsrcBean) { /** * Resource injection with non-existing resource class. */ + @Test public void testClosureMethodWithWrongResourceClass() { assertError(new IgniteCallable() { private AnotherDummyResourceBean dummyRsrcBean; @@ -295,6 +310,7 @@ private void setDummyResourceBean(AnotherDummyResourceBean dummyRsrcBean) { /** * Resource injection with both resource and class set (ambiguity). */ + @Test public void testClosureMethodByResourceClassAndName() { assertError(new IgniteCallable() { @SpringResource(resourceClass = DummyResourceBean.class, resourceName = DUMMY_BEAN) @@ -311,6 +327,7 @@ public void testClosureMethodByResourceClassAndName() { /** * Resource injection with no params. */ + @Test public void testClosureMethodWithNoParams() { assertError(new IgniteCallable() { @SpringResource @@ -330,7 +347,6 @@ public void testClosureMethodWithNoParams() { * @param expE Expected exception type. * @param expEMsg Expected exception message. */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") private void assertError(final IgniteCallable job, final Ignite grid, Class expE, String expEMsg) { GridTestUtils.assertThrowsAnyCause(log, new Callable() { diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridTransformSpringInjectionSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridTransformSpringInjectionSelfTest.java index dcf42c034d2dd..8c0c0631e31f7 100644 --- a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridTransformSpringInjectionSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridTransformSpringInjectionSelfTest.java @@ -36,6 +36,9 @@ import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -45,6 +48,7 @@ /** * */ +@RunWith(JUnit4.class) public class GridTransformSpringInjectionSelfTest extends GridCacheAbstractSelfTest { /** {@inheritDoc} */ @Override protected int gridCount() { @@ -60,6 +64,7 @@ public class GridTransformSpringInjectionSelfTest extends GridCacheAbstractSelfT /** * @throws Exception If failed. */ + @Test public void testTransformResourceInjection() throws Exception { Ignite grid = grid(0); diff --git a/modules/spring/src/test/java/org/apache/ignite/p2p/GridP2PUserVersionChangeSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/p2p/GridP2PUserVersionChangeSelfTest.java index 46da3cc18dec0..c0c6aed979797 100644 --- a/modules/spring/src/test/java/org/apache/ignite/p2p/GridP2PUserVersionChangeSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/p2p/GridP2PUserVersionChangeSelfTest.java @@ -34,14 +34,14 @@ import org.apache.ignite.events.Event; import org.apache.ignite.internal.util.typedef.PAX; import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.GridTestExternalClassLoader; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testsuites.IgniteIgnore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; @@ -58,7 +58,8 @@ * 3. The test should execute a task in SHARED_UNDEPLOY mode, restart a node with same version and * make sure that a new class loader is created on remote node. */ -@SuppressWarnings({"ProhibitedExceptionDeclared", "ObjectEquality", "unchecked"}) +@SuppressWarnings({"ProhibitedExceptionDeclared", "unchecked"}) +@RunWith(JUnit4.class) public class GridP2PUserVersionChangeSelfTest extends GridCommonAbstractTest { /** Current deployment mode. */ private DeploymentMode depMode; @@ -69,9 +70,6 @@ public class GridP2PUserVersionChangeSelfTest extends GridCommonAbstractTest { /** Test resource class name. */ private static final String TEST_RCRS_NAME = "org.apache.ignite.tests.p2p.TestUserResource"; - /** IP finder. */ - private final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** */ public GridP2PUserVersionChangeSelfTest() { super(/*start grid*/false); @@ -96,12 +94,6 @@ private long getConditionTimeout() { cfg.setDeploymentMode(depMode); cfg.setNetworkTimeout(10000); - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - - discoSpi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(discoSpi); - if (igniteInstanceName.contains("testCacheRedeployVersionChangeContinuousMode")) { CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); @@ -118,6 +110,7 @@ private long getConditionTimeout() { /** * @throws Exception If test failed. */ + @Test public void testRedeployVersionChangeContinuousMode() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -127,6 +120,7 @@ public void testRedeployVersionChangeContinuousMode() throws Exception { /** * @throws Exception If test failed. */ + @Test public void testRedeployVersionChangeSharedMode() throws Exception { depMode = DeploymentMode.SHARED; @@ -183,6 +177,7 @@ private void checkRedeployVersionChange() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRedeployOnNodeRestartContinuousMode() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -228,6 +223,7 @@ public void testRedeployOnNodeRestartContinuousMode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRedeployOnNodeRestartSharedMode() throws Exception { depMode = DeploymentMode.SHARED; @@ -287,6 +283,7 @@ public void testRedeployOnNodeRestartSharedMode() throws Exception { * @throws Exception If failed. */ @IgniteIgnore(value = "https://issues.apache.org/jira/browse/IGNITE-604", forceFailure = true) + @Test public void testCacheRedeployVersionChangeContinuousMode() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -377,4 +374,4 @@ private String makeUserVersion(String userVer) { " " + ""; } -} \ No newline at end of file +} diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/IgniteExcludeInConfigurationTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/IgniteExcludeInConfigurationTest.java index 3104b8ec90d31..6e5cb0b2c1ba0 100644 --- a/modules/spring/src/test/java/org/apache/ignite/spring/IgniteExcludeInConfigurationTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/spring/IgniteExcludeInConfigurationTest.java @@ -26,17 +26,22 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.IgniteComponentType.SPRING; /** * Checks excluding properties, beans with not existing classes in spring. */ +@RunWith(JUnit4.class) public class IgniteExcludeInConfigurationTest extends GridCommonAbstractTest { private URL cfgLocation = U.resolveIgniteUrl( "modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml"); /** Spring should exclude properties by list and ignore beans with class not existing in classpath. */ + @Test public void testExclude() throws Exception { IgniteSpringHelper spring = SPRING.create(false); @@ -70,6 +75,7 @@ public void testExclude() throws Exception { } /** Spring should fail if bean class not exist in classpath. */ + @Test public void testFail() throws Exception { IgniteSpringHelper spring = SPRING.create(false); @@ -79,4 +85,4 @@ public void testFail() throws Exception { assertTrue(X.hasCause(e, ClassNotFoundException.class)); } } -} \ No newline at end of file +} diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamConfigurationTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamConfigurationTest.java index 2307a357fb5d6..2cbeb000ce327 100644 --- a/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamConfigurationTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/spring/IgniteStartFromStreamConfigurationTest.java @@ -25,16 +25,21 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Checks starts from Stream. */ +@RunWith(JUnit4.class) public class IgniteStartFromStreamConfigurationTest extends GridCommonAbstractTest { /** * Tests starts from stream. * * @throws Exception If failed. */ + @Test public void testStartFromStream() throws Exception { String cfg = "examples/config/example-cache.xml"; @@ -51,4 +56,4 @@ public void testStartFromStream() throws Exception { } } -} \ No newline at end of file +} diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java index 891c42e277258..ee1f4f609908b 100644 --- a/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java @@ -26,6 +26,9 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.EventListener; import org.springframework.context.support.AbstractApplicationContext; @@ -43,6 +46,7 @@ /** * Tests for injected service. */ +@RunWith(JUnit4.class) public class GridServiceInjectionSpringResourceTest extends GridCommonAbstractTest { /** Service name. */ private static final String SERVICE_NAME = "testService"; @@ -78,6 +82,7 @@ public class GridServiceInjectionSpringResourceTest extends GridCommonAbstractTe /** * @throws Exception If failed. */ + @Test public void testDeployServiceWithSpring() throws Exception { generateConfigXmls(NODES); diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/injection/IgniteSpringBeanSpringResourceInjectionTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/injection/IgniteSpringBeanSpringResourceInjectionTest.java index 2a06deb6e872e..7881ebbccd2a3 100644 --- a/modules/spring/src/test/java/org/apache/ignite/spring/injection/IgniteSpringBeanSpringResourceInjectionTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/spring/injection/IgniteSpringBeanSpringResourceInjectionTest.java @@ -32,12 +32,16 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Test checking injections of {@link SpringResource} annotated fields. */ +@RunWith(JUnit4.class) public class IgniteSpringBeanSpringResourceInjectionTest extends GridCommonAbstractTest { /** */ private static final String SPRING_CFG_LOCATION = "/org/apache/ignite/spring/injection/spring-bean.xml"; @@ -184,6 +188,7 @@ private void doTestSpringResourceInjected(Runnable testRunnable) throws Exceptio } /** */ + @Test public void testSpringResourceInjectedInCacheStore() throws Exception { doTestSpringResourceInjected( new TestSpringResourceInjectedRunnable(SPRING_CFG_LOCATION, BEAN_TO_INJECT_NAME) { @@ -199,6 +204,7 @@ public void testSpringResourceInjectedInCacheStore() throws Exception { } /** */ + @Test public void testSpringResourceInjectedInService() throws Exception { doTestSpringResourceInjected( new TestSpringResourceInjectedRunnable(SPRING_CFG_LOCATION, BEAN_TO_INJECT_NAME) { diff --git a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteResourceSelfTestSuite.java b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteResourceSelfTestSuite.java index e120aaa41cd8f..4b0ac6b381b1c 100644 --- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteResourceSelfTestSuite.java +++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteResourceSelfTestSuite.java @@ -17,30 +17,33 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.processors.resource.GridLoggerInjectionSelfTest; import org.apache.ignite.internal.processors.resource.GridResourceProcessorSelfTest; import org.apache.ignite.internal.processors.resource.GridServiceInjectionSelfTest; import org.apache.ignite.internal.processors.resource.GridSpringResourceInjectionSelfTest; import org.apache.ignite.testframework.IgniteTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Ignite resource injection test Suite. */ @SuppressWarnings({"ProhibitedExceptionDeclared"}) -public class IgniteResourceSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteResourceSelfTestSuite { /** * @return Resource injection test suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new IgniteTestSuite("Ignite Resource Injection Test Suite"); - suite.addTestSuite(GridResourceProcessorSelfTest.class); - suite.addTestSuite(GridLoggerInjectionSelfTest.class); - suite.addTestSuite(GridServiceInjectionSelfTest.class); - suite.addTestSuite(GridSpringResourceInjectionSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridResourceProcessorSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridLoggerInjectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridServiceInjectionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSpringResourceInjectionSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java index 0943d5148b0ff..5c14b98529ff0 100644 --- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java +++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.cache.spring.GridSpringCacheManagerMultiJvmSelfTest; import org.apache.ignite.cache.spring.GridSpringCacheManagerSelfTest; @@ -45,63 +46,65 @@ import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSelfTest; import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSpringBeanSelfTest; import org.apache.ignite.transactions.spring.SpringTransactionManagerContextInjectionTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Spring tests. */ -public class IgniteSpringTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteSpringTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new IgniteTestSuite("Spring Test Suite"); - suite.addTestSuite(GridSpringBeanSerializationSelfTest.class); - suite.addTestSuite(IgniteSpringBeanTest.class); - suite.addTestSuite(GridFactorySelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridSpringBeanSerializationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSpringBeanTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFactorySelfTest.class)); suite.addTest(IgniteResourceSelfTestSuite.suite()); - suite.addTestSuite(IgniteExcludeInConfigurationTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteExcludeInConfigurationTest.class)); // Tests moved to this suite since they require Spring functionality. - suite.addTestSuite(GridP2PUserVersionChangeSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridP2PUserVersionChangeSelfTest.class)); - suite.addTestSuite(GridSpringCacheManagerSelfTest.class); - suite.addTestSuite(GridSpringCacheManagerSpringBeanSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridSpringCacheManagerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSpringCacheManagerSpringBeanSelfTest.class)); - suite.addTestSuite(IgniteDynamicCacheConfigTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteDynamicCacheConfigTest.class)); - suite.addTestSuite(IgniteStartFromStreamConfigurationTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteStartFromStreamConfigurationTest.class)); - suite.addTestSuite(CacheSpringStoreSessionListenerSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheSpringStoreSessionListenerSelfTest.class)); - suite.addTestSuite(CacheJdbcBlobStoreFactorySelfTest.class); - suite.addTestSuite(CacheJdbcPojoStoreFactorySelfTest.class); - suite.addTestSuite(CachePojoStoreXmlSelfTest.class); - suite.addTestSuite(CachePojoStoreXmlWithSqlEscapeSelfTest.class); + suite.addTest(new JUnit4TestAdapter(CacheJdbcBlobStoreFactorySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CacheJdbcPojoStoreFactorySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePojoStoreXmlSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(CachePojoStoreXmlWithSqlEscapeSelfTest.class)); - suite.addTestSuite(GridSpringTransactionManagerSelfTest.class); - suite.addTestSuite(GridSpringTransactionManagerSpringBeanSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridSpringTransactionManagerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSpringTransactionManagerSpringBeanSelfTest.class)); - suite.addTestSuite(GridServiceInjectionSpringResourceTest.class); - suite.addTestSuite(IgniteSpringBeanSpringResourceInjectionTest.class); + suite.addTest(new JUnit4TestAdapter(GridServiceInjectionSpringResourceTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteSpringBeanSpringResourceInjectionTest.class)); - suite.addTestSuite(GridTransformSpringInjectionSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridTransformSpringInjectionSelfTest.class)); - suite.addTestSuite(SpringCacheManagerContextInjectionTest.class); - suite.addTestSuite(SpringTransactionManagerContextInjectionTest.class); + suite.addTest(new JUnit4TestAdapter(SpringCacheManagerContextInjectionTest.class)); + suite.addTest(new JUnit4TestAdapter(SpringTransactionManagerContextInjectionTest.class)); - suite.addTestSuite(SpringCacheTest.class); + suite.addTest(new JUnit4TestAdapter(SpringCacheTest.class)); - suite.addTestSuite(SpringEncryptedCacheRestartTest.class); - suite.addTestSuite(SpringEncryptedCacheRestartClientTest.class); + suite.addTest(new JUnit4TestAdapter(SpringEncryptedCacheRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(SpringEncryptedCacheRestartClientTest.class)); - //suite.addTestSuite(GridSpringCacheManagerMultiJvmSelfTest.class); - suite.addTestSuite(GridSpringCacheManagerMultiJvmSelfTest.class); + //suite.addTest(new JUnit4TestAdapter(GridSpringCacheManagerMultiJvmSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridSpringCacheManagerMultiJvmSelfTest.class)); - suite.addTestSuite(GridCommandLineLoaderTest.class); + suite.addTest(new JUnit4TestAdapter(GridCommandLineLoaderTest.class)); return suite; } diff --git a/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerAbstractTest.java b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerAbstractTest.java index 8a4e44814a603..055c7de39b5cd 100644 --- a/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerAbstractTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerAbstractTest.java @@ -20,12 +20,16 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.transaction.IllegalTransactionStateException; import org.springframework.transaction.InvalidIsolationLevelException; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallback; import org.springframework.transaction.support.TransactionTemplate; +@RunWith(JUnit4.class) public abstract class GridSpringTransactionManagerAbstractTest extends GridCommonAbstractTest { /** */ @@ -48,6 +52,7 @@ public abstract class GridSpringTransactionManagerAbstractTest extends GridCommo } /** */ + @Test public void testSuccessPut() { int entryCnt = 1_000; @@ -57,6 +62,7 @@ public void testSuccessPut() { } /** */ + @Test public void testFailPut() { int entryCnt = 1_000; @@ -72,6 +78,7 @@ public void testFailPut() { } /** */ + @Test public void testMandatoryPropagation() { try { service().putWithMandatoryPropagation(cache()); @@ -84,6 +91,7 @@ public void testMandatoryPropagation() { } /** */ + @Test public void testUnsupportedIsolationLevel() { try { service().putWithUnsupportedIsolationLevel(cache()); @@ -98,6 +106,7 @@ public void testUnsupportedIsolationLevel() { /** * @throws Exception If test failed. */ + @Test public void testDoSetRollbackOnlyInExistingTransaction() throws Exception { SpringTransactionManager mngr = new SpringTransactionManager(); mngr.setIgniteInstanceName(grid().name()); diff --git a/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerSelfTest.java index 03c2ab060140f..1f85f5a253428 100644 --- a/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerSelfTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerSelfTest.java @@ -21,9 +21,6 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.springframework.context.ApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; @@ -31,9 +28,6 @@ * Spring transaction test. */ public class GridSpringTransactionManagerSelfTest extends GridSpringTransactionManagerAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - /** */ private GridSpringTransactionService service; @@ -48,12 +42,6 @@ public class GridSpringTransactionManagerSelfTest extends GridSpringTransactionM cfg.setCacheConfiguration(cache); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - return cfg; } diff --git a/modules/spring/src/test/java/org/apache/ignite/transactions/spring/SpringTransactionManagerContextInjectionTest.java b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/SpringTransactionManagerContextInjectionTest.java index 8c014a9a7ad6e..247c7a6c8a68f 100644 --- a/modules/spring/src/test/java/org/apache/ignite/transactions/spring/SpringTransactionManagerContextInjectionTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/SpringTransactionManagerContextInjectionTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.internal.IgnitionEx; import org.apache.ignite.lifecycle.LifecycleBean; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -31,10 +34,12 @@ /** * */ +@RunWith(JUnit4.class) public class SpringTransactionManagerContextInjectionTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testBeanInjectionUsingConfigPath() throws Exception { BeanFactory factory = new AnnotationConfigApplicationContext(TestPathConfiguration.class); @@ -56,6 +61,7 @@ public void testBeanInjectionUsingConfigPath() throws Exception { /** * @throws Exception If failed. */ + @Test public void testBeanInjectionUsingConfig() throws Exception { BeanFactory factory = new AnnotationConfigApplicationContext(TestCfgConfiguration.class); @@ -122,4 +128,4 @@ LifecycleBean bean2() { return new TestInjectionLifecycleBean(); } } -} \ No newline at end of file +} diff --git a/modules/sqlline/bin/sqlline.bat b/modules/sqlline/bin/sqlline.bat index c21ae82042f2b..d31fe502ab39e 100644 --- a/modules/sqlline/bin/sqlline.bat +++ b/modules/sqlline/bin/sqlline.bat @@ -42,13 +42,12 @@ if exist "%JAVA_HOME%\bin\java.exe" goto checkJdkVersion goto error_finish :checkJdkVersion -"%JAVA_HOME%\bin\java.exe" -version 2>&1 | findstr /R /c:"version .9\..*" /c:"version .1\.8\..*" > nul -if %ERRORLEVEL% equ 0 goto checkIgniteHome1 - echo %0, ERROR: - echo The version of JAVA installed in %JAVA_HOME% is incorrect. - echo Please point JAVA_HOME variable to installation of JDK 1.8 or later. - echo You can also download latest JDK at http://java.com/download. -goto error_finish +set cmd="%JAVA_HOME%\bin\java.exe" +for /f "tokens=* USEBACKQ" %%f in (`%cmd% -version 2^>^&1`) do ( + set var=%%f + goto :LoopEscape +) +:LoopEscape :: Check IGNITE_HOME. :checkIgniteHome1 @@ -103,9 +102,46 @@ if "%OS%" == "Windows_NT" set PROG_NAME=%~nx0% :: call "%SCRIPTS_HOME%\include\setenv.bat" +for /f "tokens=1-3 delims= " %%a in ("%var%") do set JAVA_VER_STR=%%c +set JAVA_VER_STR=%JAVA_VER_STR:"=% + +for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set MAJOR_JAVA_VER=%%a& set MINOR_JAVA_VER=%%b + +if %MAJOR_JAVA_VER% == 8 ( + set JVM_OPTS= ^ + -XX:+AggressiveOpts ^ + %JVM_OPTS% +) + +if %MAJOR_JAVA_VER% GEQ 9 if %MAJOR_JAVA_VER% LSS 11 ( + set JVM_OPTS= ^ + -XX:+AggressiveOpts ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + --add-modules=java.transaction ^ + --add-modules=java.xml.bind ^ + %JVM_OPTS% +) + +if %MAJOR_JAVA_VER% == 11 ( + set JVM_OPTS= ^ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^ + --illegal-access=permit ^ + -Djdk.tls.client.protocols=TLSv1.2 ^ + %JVM_OPTS% +) + set CP=%IGNITE_LIBS% set CP=%CP%;%IGNITE_HOME%\bin\include\sqlline\* -"%JAVA_HOME%\bin\java.exe" -cp "%CP%" sqlline.SqlLine -d org.apache.ignite.IgniteJdbcThinDriver %* +"%JAVA_HOME%\bin\java.exe" %JVM_OPTS% -cp "%CP%" sqlline.SqlLine -d org.apache.ignite.IgniteJdbcThinDriver %* :error_finish \ No newline at end of file diff --git a/modules/sqlline/bin/sqlline.sh b/modules/sqlline/bin/sqlline.sh index 552440de5d185..1110154cbbb84 100644 --- a/modules/sqlline/bin/sqlline.sh +++ b/modules/sqlline/bin/sqlline.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o nounset +set -o errexit +set -o pipefail +set -o errtrace +set -o functrace + # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -23,7 +29,7 @@ # # Import common functions. # -if [ "${IGNITE_HOME}" = "" ]; +if [ "${IGNITE_HOME:-}" = "" ]; then IGNITE_HOME_TMP="$(dirname "$(cd "$(dirname "$0")"; "pwd")")"; else IGNITE_HOME_TMP=${IGNITE_HOME}; fi @@ -50,10 +56,48 @@ setIgniteHome # . "${SCRIPTS_HOME}"/include/setenv.sh -JDBCLINK="jdbc:ignite:thin://${HOST_AND_PORT}${SCHEMA_DELIMITER}${SCHEMA}${PARAMS}" +JVM_OPTS=${JVM_OPTS:-} + +# +# Final JVM_OPTS for Java 9+ compatibility +# +javaMajorVersion "${JAVA_HOME}/bin/java" + +if [ $version -eq 8 ] ; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + ${JVM_OPTS}" + +elif [ $version -gt 8 ] && [ $version -lt 11 ]; then + JVM_OPTS="\ + -XX:+AggressiveOpts \ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + --add-modules=java.transaction \ + --add-modules=java.xml.bind \ + ${JVM_OPTS}" + +elif [ $version -eq 11 ] ; then + JVM_OPTS="\ + --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ + --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ + --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \ + --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \ + --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ + --illegal-access=permit \ + -Djdk.tls.client.protocols=TLSv1.2 \ + ${JVM_OPTS}" +fi + + +JDBCLINK="jdbc:ignite:thin://${HOST_AND_PORT:-}${SCHEMA_DELIMITER:-}${SCHEMA:-}${PARAMS:-}" CP="${IGNITE_LIBS}" CP="${CP}${SEP}${IGNITE_HOME_TMP}/bin/include/sqlline/*" -"$JAVA" -cp ${CP} sqlline.SqlLine -d org.apache.ignite.IgniteJdbcThinDriver $@ \ No newline at end of file +"$JAVA" ${JVM_OPTS} -cp ${CP} sqlline.SqlLine -d org.apache.ignite.IgniteJdbcThinDriver $@ diff --git a/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java b/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java index 6014510002159..2e9905413cedb 100644 --- a/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java +++ b/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java @@ -31,6 +31,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.UUID; +import java.util.regex.Pattern; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterStartNodeResult; @@ -90,6 +91,9 @@ public class StartNodeCallableImpl implements StartNodeCallable { /** Connection timeout. */ private final int timeout; + /** Timeout processor. */ + private GridTimeoutProcessor proc; + /** Logger. */ @LoggerResource private transient IgniteLogger log; @@ -130,6 +134,8 @@ public StartNodeCallableImpl(IgniteRemoteStartSpecification spec, int timeout) { Session ses = null; try { + proc = ((IgniteEx)ignite).context().timeout(); + if (spec.key() != null) ssh.addIdentity(spec.key().getAbsolutePath()); @@ -274,7 +280,8 @@ public StartNodeCallableImpl(IgniteRemoteStartSpecification spec, int timeout) { info("Starting remote node with SSH command: " + startNodeCmd, spec.logger(), log); - shell(ses, startNodeCmd); + // Execute command via ssh and wait until id of new process will be found in the output. + shell(ses, startNodeCmd, "\\[(\\d)\\] (\\d)+"); findSuccess = "grep \"" + SUCCESSFUL_START_MSG + "\" " + scriptOutputPath; } @@ -315,8 +322,25 @@ public StartNodeCallableImpl(IgniteRemoteStartSpecification spec, int timeout) { * @throws IgniteInterruptedCheckedException If thread was interrupted while waiting. */ private void shell(Session ses, String cmd) throws JSchException, IOException, IgniteInterruptedCheckedException { + shell(ses, cmd, null); + } + + /** + * Executes command using {@code shell} channel. + * + * @param ses SSH session. + * @param cmd Command. + * @param regexp Regular expression to wait until it will be found in stream from node. + * @throws JSchException In case of SSH error. + * @throws IOException If IO error occurs. + * @throws IgniteInterruptedCheckedException If thread was interrupted while waiting. + */ + private void shell(Session ses, String cmd, String regexp) + throws JSchException, IOException, IgniteInterruptedCheckedException { ChannelShell ch = null; + GridTimeoutObject to = null; + try { ch = (ChannelShell)ses.openChannel("shell"); @@ -324,9 +348,44 @@ private void shell(Session ses, String cmd) throws JSchException, IOException, I try (PrintStream out = new PrintStream(ch.getOutputStream(), true)) { out.println(cmd); + } + + if (regexp != null) { + Pattern ptrn = Pattern.compile(regexp); + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(ch.getInputStream()))) { + String line; + + boolean first = true; + + while ((line = reader.readLine()) != null) { + if (ptrn.matcher(line).find()) { + // Wait for a while until process from regexp really will be started. + U.sleep(50); + + break; + } + else if (first) { + to = initTimer(cmd); + + first = false; + } + } + } + catch (InterruptedIOException ignore) { + // No-op. + } + finally { + if (to != null) { + boolean r = proc.removeTimeoutObject(to); + + assert r || to.endTime() <= U.currentTimeMillis() : "Timeout object was not removed: " + to; + } + } - U.sleep(EXECUTE_WAIT_TIME); } + else + U.sleep(EXECUTE_WAIT_TIME); } finally { if (ch != null && ch.isConnected()) @@ -425,10 +484,6 @@ private String exec(Session ses, final String cmd, String encoding) throws JSchE if (encoding == null) encoding = Charset.defaultCharset().name(); - IgniteEx grid = (IgniteEx)ignite; - - GridTimeoutProcessor proc = grid.context().timeout(); - GridTimeoutObject to = null; SB out = null; @@ -447,20 +502,7 @@ private String exec(Session ses, final String cmd, String encoding) throws JSchE out.a(line); if (first) { - to = new GridTimeoutObjectAdapter(EXECUTE_WAIT_TIME) { - /** */ - private final Thread thread = Thread.currentThread(); - - @Override public void onTimeout() { - thread.interrupt(); - } - - @Override public String toString() { - return S.toString("GridTimeoutObject", "cmd", cmd, "thread", thread); - } - }; - - assert proc.addTimeoutObject(to) : "Timeout object was not added: " + to; + to = initTimer(cmd); first = false; } @@ -485,6 +527,31 @@ private String exec(Session ses, final String cmd, String encoding) throws JSchE } } + /** + * Initialize timer to wait for command execution. + * + * @param cmd Command to log. + */ + private GridTimeoutObject initTimer(String cmd){ + GridTimeoutObject to = new GridTimeoutObjectAdapter(EXECUTE_WAIT_TIME) { + private final Thread thread = Thread.currentThread(); + + @Override public void onTimeout() { + thread.interrupt(); + } + + @Override public String toString() { + return S.toString("GridTimeoutObject", "cmd", cmd, "thread", thread); + } + }; + + boolean wasAdded = proc.addTimeoutObject(to); + + assert wasAdded : "Timeout object was not added: " + to; + + return to; + } + /** * Builds ignite.sh attributes to set up SSH username and password and log directory for started node. * diff --git a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteNodeStartUtilsSelfTest.java b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteNodeStartUtilsSelfTest.java index 79625768cb000..b8883f682fccd 100644 --- a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteNodeStartUtilsSelfTest.java +++ b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteNodeStartUtilsSelfTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.CFG; import static org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.HOST; @@ -38,10 +41,12 @@ /** * Tests for {@link org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils}. */ +@RunWith(JUnit4.class) public class IgniteNodeStartUtilsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testParseFile() throws Exception { File file = U.resolveIgnitePath("modules/core/src/test/config/start-nodes.ini"); @@ -94,4 +99,4 @@ else if ("192.168.1.2".equals(host.get(HOST))) { assert "cfg3".equals(dflts.get(CFG)); assert "script3".equals(dflts.get(SCRIPT)); } -} \ No newline at end of file +} diff --git a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java index a91488caa985d..2d8728f6aec98 100644 --- a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java +++ b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java @@ -45,6 +45,9 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVT_NODE_FAILED; @@ -72,6 +75,7 @@ * credentials.

    */ @SuppressWarnings("ConstantConditions") +@RunWith(JUnit4.class) public class IgniteProjectionStartStopRestartSelfTest extends GridCommonAbstractTest { /** */ private static final String SSH_UNAME = getProperty("test.ssh.username", "ssh.username"); @@ -101,7 +105,7 @@ public class IgniteProjectionStartStopRestartSelfTest extends GridCommonAbstract private static final String CUSTOM_CFG_ATTR_VAL = "true"; /** */ - private static final long WAIT_TIMEOUT = 40 * 1000; + private static final long WAIT_TIMEOUT = 90 * 1000; /** */ private String pwd; @@ -206,6 +210,7 @@ else if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) { /** * @throws Exception If failed. */ + @Test public void testStartOneNode() throws Exception { joinedLatch = new CountDownLatch(1); @@ -234,6 +239,7 @@ public void testStartOneNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartThreeNodes() throws Exception { joinedLatch = new CountDownLatch(3); @@ -262,31 +268,18 @@ public void testStartThreeNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartThreeNodesAndDoEmptyCall() throws Exception { joinedLatch = new CountDownLatch(3); - Collection res = - startNodes(ignite.cluster(), - maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), - false, 0, 16); - - assert res.size() == 3; - - res.forEach(t -> { - assert t.getHostName().equals(HOST); - - if (!t.isSuccess()) - throw new IgniteException(t.getError()); - }); - - assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); + startCheckNodes(); assert joinedCnt.get() == 3; assert leftCnt.get() == 0; assert ignite.cluster().nodes().size() == 3; - res = startNodes(ignite.cluster(), + Collection res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), false, 0, 16); @@ -301,31 +294,16 @@ public void testStartThreeNodesAndDoEmptyCall() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartThreeNodesAndTryToStartOneNode() throws Exception { joinedLatch = new CountDownLatch(3); - Collection res = - startNodes(ignite.cluster(), - maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), - false, 0, 16); - - assert res.size() == 3; - - res.forEach(t -> { - assert t.getHostName().equals(HOST); - - if (!t.isSuccess()) - throw new IgniteException(t.getError()); - }); - - assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); + startCheckNodes(); assert joinedCnt.get() == 3; assert leftCnt.get() == 0; - assert ignite.cluster().nodes().size() == 3; - - res = startNodes(ignite.cluster(), + Collection res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), pwd, key, 1, U.getIgniteHome(), CFG_NO_ATTR, null), false, 0, 16); @@ -340,33 +318,18 @@ public void testStartThreeNodesAndTryToStartOneNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartFiveNodesInTwoCalls() throws Exception { joinedLatch = new CountDownLatch(3); - Collection res = - startNodes(ignite.cluster(), - maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), - false, 0, 16); - - assert res.size() == 3; - - res.forEach(t -> { - assert t.getHostName().equals(HOST); - - if (!t.isSuccess()) - throw new IgniteException(t.getError()); - }); - - assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); + startCheckNodes(); assert joinedCnt.get() == 3; assert leftCnt.get() == 0; - assert ignite.cluster().nodes().size() == 3; - joinedLatch = new CountDownLatch(2); - res = startNodes(ignite.cluster(), + Collection res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), pwd, key, 5, U.getIgniteHome(), CFG_NO_ATTR, null), false, 0, 16); @@ -390,6 +353,7 @@ public void testStartFiveNodesInTwoCalls() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartFiveWithTwoSpecs() throws Exception { joinedLatch = new CountDownLatch(5); @@ -419,34 +383,19 @@ public void testStartFiveWithTwoSpecs() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartThreeNodesAndRestart() throws Exception { joinedLatch = new CountDownLatch(3); - Collection res = - startNodes(ignite.cluster(), - maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), - false, 0, 16); - - assert res.size() == 3; - - res.forEach(t -> { - assert t.getHostName().equals(HOST); - - if (!t.isSuccess()) - throw new IgniteException(t.getError()); - }); - - assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); + startCheckNodes(); assert joinedCnt.get() == 3; assert leftCnt.get() == 0; - assert ignite.cluster().nodes().size() == 3; - joinedLatch = new CountDownLatch(3); leftLatch = new CountDownLatch(3); - res = startNodes(ignite.cluster(), + Collection res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), true, 0, 16); @@ -471,6 +420,7 @@ public void testStartThreeNodesAndRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomScript() throws Exception { joinedLatch = new CountDownLatch(1); @@ -505,13 +455,14 @@ public void testCustomScript() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopNodes() throws Exception { joinedLatch = new CountDownLatch(3); Collection res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), pwd, null, 3, U.getIgniteHome(), CFG_NO_ATTR, - null), false, 0, 16); + null), false, 0, 16); assert res.size() == 3; @@ -538,6 +489,7 @@ public void testStopNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopNodesFiltered() throws Exception { joinedLatch = new CountDownLatch(2); @@ -593,26 +545,11 @@ public void testStopNodesFiltered() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopNodeById() throws Exception { joinedLatch = new CountDownLatch(3); - Collection res = - startNodes(ignite.cluster(), - maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), - false, 0, 16); - - assert res.size() == 3; - - res.forEach(t -> { - assert t.getHostName().equals(HOST); - - if (!t.isSuccess()) - throw new IgniteException(t.getError()); - }); - - assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); - - assert ignite.cluster().nodes().size() == 3; + startCheckNodes(); leftLatch = new CountDownLatch(1); @@ -626,26 +563,11 @@ public void testStopNodeById() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopNodesByIds() throws Exception { joinedLatch = new CountDownLatch(3); - Collection res = - startNodes(ignite.cluster(), - maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), - false, 0, 16); - - assert res.size() == 3; - - res.forEach(t -> { - assert t.getHostName().equals(HOST); - - if (!t.isSuccess()) - throw new IgniteException(t.getError()); - }); - - assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); - - assert ignite.cluster().nodes().size() == 3; + startCheckNodes(); leftLatch = new CountDownLatch(2); @@ -666,26 +588,11 @@ public void testStopNodesByIds() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestartNodes() throws Exception { joinedLatch = new CountDownLatch(3); - Collection res = - startNodes(ignite.cluster(), - maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), - false, 0, 16); - - assert res.size() == 3; - - res.forEach(t -> { - assert t.getHostName().equals(HOST); - - if (!t.isSuccess()) - throw new IgniteException(t.getError()); - }); - - assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); - - assert ignite.cluster().nodes().size() == 3; + startCheckNodes(); joinedLatch = new CountDownLatch(3); leftLatch = new CountDownLatch(3); @@ -701,6 +608,7 @@ public void testRestartNodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestartNodesFiltered() throws Exception { joinedLatch = new CountDownLatch(2); @@ -759,26 +667,11 @@ public void testRestartNodesFiltered() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestartNodeById() throws Exception { joinedLatch = new CountDownLatch(3); - Collection res = - startNodes(ignite.cluster(), - maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), - false, 0, 16); - - assert res.size() == 3; - - res.forEach(t -> { - assert t.getHostName().equals(HOST); - - if (!t.isSuccess()) - throw new IgniteException(t.getError()); - }); - - assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); - - assert ignite.cluster().nodes().size() == 3; + startCheckNodes(); joinedLatch = new CountDownLatch(1); leftLatch = new CountDownLatch(1); @@ -794,26 +687,11 @@ public void testRestartNodeById() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestartNodesByIds() throws Exception { joinedLatch = new CountDownLatch(3); - Collection res = - startNodes(ignite.cluster(), - maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), - false, 0, 16); - - assert res.size() == 3; - - res.forEach(t -> { - assert t.getHostName().equals(HOST); - - if (!t.isSuccess()) - throw new IgniteException(t.getError()); - }); - - assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); - - assert ignite.cluster().nodes().size() == 3; + startCheckNodes(); joinedLatch = new CountDownLatch(2); leftLatch = new CountDownLatch(2); @@ -895,6 +773,30 @@ private Collection> maps( return maps; } + /** + * @throws InterruptedException If failed. + */ + private void startCheckNodes() throws InterruptedException { + joinedLatch = new CountDownLatch(3); + + Collection res = + startNodes(ignite.cluster(), + maps(Collections.singleton(HOST), pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), + false, 0, 16); + + assert res.size() == 3; + + res.forEach(t -> { + assert t.getHostName().equals(HOST); + + if (!t.isSuccess()) + throw new IgniteException(t.getError()); + }); + + assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS); + + assert ignite.cluster().nodes().size() == 3; + } /** * @param cluster Cluster. diff --git a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteStartStopRestartTestSuite.java b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteStartStopRestartTestSuite.java index 29671317787a2..0f9fe9c4bafe7 100644 --- a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteStartStopRestartTestSuite.java +++ b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteStartStopRestartTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; /** @@ -25,14 +26,13 @@ public class IgniteStartStopRestartTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Start Nodes Test Suite"); - suite.addTestSuite(IgniteNodeStartUtilsSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteNodeStartUtilsSelfTest.class)); - suite.addTestSuite(IgniteProjectionStartStopRestartSelfTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteProjectionStartStopRestartSelfTest.class)); return suite; } diff --git a/modules/storm/src/test/java/org/apache/ignite/stream/storm/IgniteStormStreamerSelfTestSuite.java b/modules/storm/src/test/java/org/apache/ignite/stream/storm/IgniteStormStreamerSelfTestSuite.java index 25546e5638b7b..085b755aa42d4 100644 --- a/modules/storm/src/test/java/org/apache/ignite/stream/storm/IgniteStormStreamerSelfTestSuite.java +++ b/modules/storm/src/test/java/org/apache/ignite/stream/storm/IgniteStormStreamerSelfTestSuite.java @@ -17,21 +17,23 @@ package org.apache.ignite.stream.storm; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Apache Storm streamer tests. */ -public class IgniteStormStreamerSelfTestSuite extends TestSuite { - +@RunWith(AllTests.class) +public class IgniteStormStreamerSelfTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Apache Storm streamer Test Suite"); - suite.addTest(new TestSuite(StormIgniteStreamerSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(StormIgniteStreamerSelfTest.class)); return suite; } diff --git a/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java b/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java index e2547b1a58ae1..07b35421378a8 100644 --- a/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java +++ b/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java @@ -42,12 +42,16 @@ import org.apache.storm.topology.TopologyBuilder; import org.apache.storm.tuple.Values; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; /** * Tests for {@link StormStreamer}. */ +@RunWith(JUnit4.class) public class StormIgniteStreamerSelfTest extends GridCommonAbstractTest { /** Cache name. */ private static final String TEST_CACHE = "testCache"; @@ -82,6 +86,7 @@ public class StormIgniteStreamerSelfTest extends GridCommonAbstractTest { * @throws TimeoutException * @throws InterruptedException */ + @Test public void testStormStreamerIgniteBolt() throws TimeoutException, InterruptedException { final StormStreamer stormStreamer = new StormStreamer<>(); diff --git a/modules/twitter/pom.xml b/modules/twitter/pom.xml index bdb044a437c58..6f1d191d090f2 100644 --- a/modules/twitter/pom.xml +++ b/modules/twitter/pom.xml @@ -71,7 +71,7 @@ com.github.tomakehurst wiremock - 1.57 + 1.58 standalone diff --git a/modules/twitter/src/test/java/org/apache/ignite/stream/twitter/IgniteTwitterStreamerTest.java b/modules/twitter/src/test/java/org/apache/ignite/stream/twitter/IgniteTwitterStreamerTest.java index 2210a277643fe..9b5647873ab88 100644 --- a/modules/twitter/src/test/java/org/apache/ignite/stream/twitter/IgniteTwitterStreamerTest.java +++ b/modules/twitter/src/test/java/org/apache/ignite/stream/twitter/IgniteTwitterStreamerTest.java @@ -18,7 +18,8 @@ package org.apache.ignite.stream.twitter; import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.junit.WireMockRule; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.junit.WireMockClassRule; import com.twitter.hbc.core.HttpHosts; import java.util.HashMap; import java.util.Map; @@ -30,7 +31,9 @@ import org.apache.ignite.events.CacheEvent; import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.ClassRule; import org.junit.Rule; +import org.junit.Test; import twitter4j.Status; import twitter4j.TwitterException; import twitter4j.TwitterObjectFactory; @@ -45,7 +48,6 @@ * Test for {@link TwitterStreamer}. Tests Public Status streaming API https://dev.twitter.com/streaming/public. */ public class IgniteTwitterStreamerTest extends GridCommonAbstractTest { - /** Cache entries count. */ private static final int CACHE_ENTRY_COUNT = 100; @@ -60,39 +62,47 @@ public IgniteTwitterStreamerTest() { super(true); } + /** + * See The JUnit 4.x Rule. + */ + @ClassRule + public static WireMockClassRule wireMockClsRule = new WireMockClassRule(WireMockConfiguration.DYNAMIC_PORT); + /** Embedded mock HTTP server's for Twitter API rule. */ @Rule - public final WireMockRule wireMockRule = new WireMockRule(); + public WireMockClassRule wireMockRule = wireMockClsRule; /** Embedded mock HTTP server for Twitter API. */ - public final WireMockServer mockServer = new WireMockServer(); //Starts server on 8080 port. + public final WireMockServer mockSrv = new WireMockServer(); //Starts server on 8080 port. /** {@inheritDoc} */ @Override protected long getTestTimeout() { return 10_000; } - /** {@inheritDoc} */ - @Override public void beforeTest() throws Exception { + /** */ + private void init() { grid().getOrCreateCache(defaultCacheConfiguration()); - mockServer.start(); + mockSrv.start(); stubFor(get(urlMatching("/1.1" + MOCK_TWEET_PATH + ".*")).willReturn(aResponse(). withHeader("Content-Type", "text/plain").withBody(tweet.length() + "\n" + tweet))); } - /** {@inheritDoc} */ - public void afterTest() throws Exception { + /** */ + private void cleanup() { stopAllGrids(); - mockServer.stop(); + mockSrv.stop(); } /** * @throws Exception Test exception. */ + @Test public void testStatusesFilterEndpointOAuth1() throws Exception { + init(); try (IgniteDataStreamer dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) { TwitterStreamerImpl streamer = newStreamerInstance(dataStreamer); @@ -107,6 +117,8 @@ public void testStatusesFilterEndpointOAuth1() throws Exception { streamer.setThreadsCount(8); executeStreamer(streamer); + } finally { + cleanup(); } } @@ -118,7 +130,7 @@ public void testStatusesFilterEndpointOAuth1() throws Exception { private void executeStreamer(TwitterStreamer streamer) throws InterruptedException, TwitterException { // Checking streaming. - CacheListener listener = subscribeToPutEvents(); + CacheListener lsnr = subscribeToPutEvents(); streamer.start(); @@ -131,12 +143,12 @@ private void executeStreamer(TwitterStreamer streamer) throws InterruptedExcepti // No-op. } - CountDownLatch latch = listener.getLatch(); + CountDownLatch latch = lsnr.getLatch(); // Enough tweets was handled in 10 seconds. Limited by test's timeout. latch.await(); - unsubscribeToPutEvents(listener); + unsubscribeToPutEvents(lsnr); streamer.stop(); @@ -155,13 +167,13 @@ private void executeStreamer(TwitterStreamer streamer) throws InterruptedExcepti IgniteCache cache = grid().cache(DEFAULT_CACHE_NAME); - String cachedValue = cache.get(status.getId()); + String cachedVal = cache.get(status.getId()); // Tweet successfully put to cache. - assertTrue(cachedValue != null && cachedValue.equals(status.getText())); + assertTrue(cachedVal != null && cachedVal.equals(status.getText())); // Same tweets does not produce duplicate entries. - assertTrue(cache.size() == 1); + assertEquals(1, cache.size()); } /** @@ -171,20 +183,20 @@ private CacheListener subscribeToPutEvents() { Ignite ignite = grid(); // Listen to cache PUT events and expect as many as messages as test data items. - CacheListener listener = new CacheListener(); + CacheListener lsnr = new CacheListener(); - ignite.events(ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME)).localListen(listener, EVT_CACHE_OBJECT_PUT); + ignite.events(ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME)).localListen(lsnr, EVT_CACHE_OBJECT_PUT); - return listener; + return lsnr; } /** - * @param listener Cache listener. + * @param lsnr Cache listener. */ - private void unsubscribeToPutEvents(CacheListener listener) { + private void unsubscribeToPutEvents(CacheListener lsnr) { Ignite ignite = grid(); - ignite.events(ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME)).stopLocalListen(listener, EVT_CACHE_OBJECT_PUT); + ignite.events(ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME)).stopLocalListen(lsnr, EVT_CACHE_OBJECT_PUT); } /** @@ -208,7 +220,7 @@ private TwitterStreamerImpl newStreamerInstance(IgniteDataStreamer /** * Listener. */ - private class CacheListener implements IgnitePredicate { + private static class CacheListener implements IgnitePredicate { /** */ private final CountDownLatch latch = new CountDownLatch(CACHE_ENTRY_COUNT); @@ -224,8 +236,7 @@ public CountDownLatch getLatch() { * @param evt Cache Event. * @return {@code true}. */ - @Override - public boolean apply(CacheEvent evt) { + @Override public boolean apply(CacheEvent evt) { latch.countDown(); return true; diff --git a/modules/twitter/src/test/java/org/apache/ignite/stream/twitter/IgniteTwitterStreamerTestSuite.java b/modules/twitter/src/test/java/org/apache/ignite/stream/twitter/IgniteTwitterStreamerTestSuite.java index e07aaec647dc0..5a0730aab8b5d 100644 --- a/modules/twitter/src/test/java/org/apache/ignite/stream/twitter/IgniteTwitterStreamerTestSuite.java +++ b/modules/twitter/src/test/java/org/apache/ignite/stream/twitter/IgniteTwitterStreamerTestSuite.java @@ -17,20 +17,23 @@ package org.apache.ignite.stream.twitter; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Twitter streamer tests. */ -public class IgniteTwitterStreamerTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteTwitterStreamerTestSuite { /** * @return Twitter streamer tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Twitter streamed Test Suite"); - suite.addTestSuite(IgniteTwitterStreamerTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteTwitterStreamerTest.class)); return suite; } diff --git a/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java index 22cfc5631d042..2f22f86384cc3 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java @@ -29,6 +29,9 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.spi.deployment.uri.UriDeploymentSpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.SECONDS; import static org.apache.ignite.events.EventType.EVT_NODE_JOINED; @@ -36,6 +39,7 @@ /** * Test to reproduce gg-2852. */ +@RunWith(JUnit4.class) public class GridTaskUriDeploymentDeadlockSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { @@ -63,6 +67,7 @@ public class GridTaskUriDeploymentDeadlockSelfTest extends GridCommonAbstractTes /** * @throws Exception If failed. */ + @Test public void testDeadlock() throws Exception { try { Ignite g = startGrid(1); @@ -100,4 +105,4 @@ public void testDeadlock() throws Exception { stopAllGrids(); } } -} \ No newline at end of file +} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java index 2cfaa4661347f..413b543316025 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java @@ -30,6 +30,9 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.testframework.junits.common.GridCommonTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test what happens if peer class loading is disabled. @@ -39,6 +42,7 @@ */ @SuppressWarnings({"ProhibitedExceptionDeclared", "ProhibitedExceptionThrown"}) @GridCommonTest(group = "P2P") +@RunWith(JUnit4.class) public class GridP2PDisabledSelfTest extends GridCommonAbstractTest { /** Task name. */ private static final String TASK_NAME = "org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1"; @@ -174,6 +178,7 @@ private void checkGar() throws Exception { * * @throws Exception if error occur. */ + @Test public void testGarPrivateMode() throws Exception { depMode = DeploymentMode.PRIVATE; @@ -185,6 +190,7 @@ public void testGarPrivateMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testGarIsolatedMode() throws Exception { depMode = DeploymentMode.ISOLATED; @@ -196,6 +202,7 @@ public void testGarIsolatedMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testGarContinuousMode() throws Exception { depMode = DeploymentMode.CONTINUOUS; @@ -207,6 +214,7 @@ public void testGarContinuousMode() throws Exception { * * @throws Exception if error occur. */ + @Test public void testGarSharedMode() throws Exception { depMode = DeploymentMode.SHARED; diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderMultiThreadedSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderMultiThreadedSelfTest.java index f4265b98e3c69..80b7016b8154a 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderMultiThreadedSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderMultiThreadedSelfTest.java @@ -23,14 +23,19 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid URI deployment class loader self test. */ +@RunWith(JUnit4.class) public class GridUriDeploymentClassLoaderMultiThreadedSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + @Test public void testMultiThreadedClassLoading() throws Exception { for (int i = 0; i < 50; i++) doTest(); @@ -70,4 +75,4 @@ private void doTest() throws Exception { 500 ); } -} \ No newline at end of file +} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderSelfTest.java index caa4851c2d50c..33ba125da3770 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassLoaderSelfTest.java @@ -25,15 +25,20 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Grid URI deployment class loader test. */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridUriDeploymentClassLoaderSelfTest extends GridUriDeploymentAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testNestedJarClassloading() throws Exception { ClassLoader ldr = getGarClassLoader(); @@ -44,6 +49,7 @@ public void testNestedJarClassloading() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClasspathResourceLoading() throws Exception { ClassLoader ldr = getGarClassLoader(); @@ -73,4 +79,4 @@ public List getUriList() { return Collections.singletonList(GridTestProperties.getProperty("ant.urideployment.gar.uri"). replace("EXTDATA", U.resolveIgnitePath("modules/extdata").getAbsolutePath())); } -} \ No newline at end of file +} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassloaderRegisterSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassloaderRegisterSelfTest.java index b4b6bb28f2165..c6105e9792808 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassloaderRegisterSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentClassloaderRegisterSelfTest.java @@ -36,11 +36,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for classloader registering. */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridUriDeploymentClassloaderRegisterSelfTest extends GridSpiAbstractTest { /** */ private static Map>>> tasks = @@ -87,6 +91,7 @@ private void checkUndeployed(Class> taskCls) { /** * @throws Exception If failed. */ + @Test public void testDeploy() throws Exception { Class> task = GridFileDeploymentTestTask.class; @@ -111,6 +116,7 @@ public void testDeploy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRedeploy() throws Exception { // Test non-versioned redeploy. Class> t1 = GridFileDeploymentTestTask.class; @@ -151,4 +157,4 @@ private static class GridFileDeploymentTestTask extends ComputeTaskSplitAdapter< return null; } } -} \ No newline at end of file +} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentConfigSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentConfigSelfTest.java index 2dc6e9ecad793..2864b4d3d8760 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentConfigSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentConfigSelfTest.java @@ -20,18 +20,23 @@ import java.util.Collections; import org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridUriDeploymentConfigSelfTest extends GridSpiAbstractConfigTest { /** * @throws Exception If failed. */ + @Test public void testNegativeConfig() throws Exception { checkNegativeSpiProperty(new UriDeploymentSpi(), "uriList", null); checkNegativeSpiProperty(new UriDeploymentSpi(), "uriList", Collections.singletonList("qwertyuiop"), false); checkNegativeSpiProperty(new UriDeploymentSpi(), "uriList", Collections.singletonList(null), false); } -} \ No newline at end of file +} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorSelfTest.java index 9508fa9a9dccc..de4fc798feb7b 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileProcessorSelfTest.java @@ -29,15 +29,20 @@ import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; import org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask; import org.apache.tools.ant.Project; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridUriDeploymentFileProcessorSelfTest extends GridUriDeploymentAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testTaskCorrect() throws Exception { proceedTest("correct.gar", "ignite.xml", "org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask0", true); @@ -46,6 +51,7 @@ public void testTaskCorrect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTaskWithBrokenXML() throws Exception { proceedTest("broken.gar", "ignite.brokenxml", "brokenxml-task", false); } @@ -53,6 +59,7 @@ public void testTaskWithBrokenXML() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTaskWithEmptyXML() throws Exception { proceedTest("empty.gar", "ignite.empty", "emptyxml-task", false); } @@ -60,6 +67,7 @@ public void testTaskWithEmptyXML() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTaskWithIncorrectRefsXML() throws Exception { proceedTest("incorrefs.gar", "ignite.incorrefs", "incorrectref-task", false); } diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMd5CheckSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMd5CheckSelfTest.java index 126e202cb475a..b3e2642d41d05 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMd5CheckSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMd5CheckSelfTest.java @@ -28,11 +28,15 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Redundancy for URI deployment test */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridUriDeploymentMd5CheckSelfTest extends GridUriDeploymentAbstractSelfTest { /** * Used to count number of unit undeployments. @@ -44,6 +48,7 @@ public class GridUriDeploymentMd5CheckSelfTest extends GridUriDeploymentAbstract * * @throws Exception if failed. */ + @Test public void testMd5FileCheck() throws Exception { undeployCntr.set(0); @@ -71,6 +76,7 @@ public void testMd5FileCheck() throws Exception { * * @throws Exception if failed. */ + @Test public void testMd5DirectoryCheck() throws Exception { undeployCntr.set(0); @@ -94,7 +100,7 @@ public void testMd5DirectoryCheck() throws Exception { } /** {@inheritDoc} */ - protected void afterTest() throws Exception { + @Override protected void afterTest() throws Exception { U.delete(getGarDir()); U.delete(new File(getDeployDir(), "uri1.gar")); U.delete(new File(getDeployDir(), "uri2.gar")); diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersErrorThrottlingTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersErrorThrottlingTest.java index 246ad80a5c2df..0d96ca05da3ae 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersErrorThrottlingTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersErrorThrottlingTest.java @@ -22,15 +22,20 @@ import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests error and warn messages throttling. */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridUriDeploymentMultiScannersErrorThrottlingTest extends GridUriDeploymentAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testThrottling() throws Exception { LT.throttleTimeout(11000); diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersSelfTest.java index 1561ab4a21bf9..5263b5708446e 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentMultiScannersSelfTest.java @@ -23,15 +23,20 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test URI deployment with multiple scanners. */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridUriDeploymentMultiScannersSelfTest extends GridUriDeploymentAbstractSelfTest { /** * @throws Exception If failed. */ + @Test public void testDeployment() throws Exception { checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask0"); } @@ -52,4 +57,4 @@ public List getUriList() { return uriList; } -} \ No newline at end of file +} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSimpleSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSimpleSelfTest.java index acd40f55d8aa0..1d4c5b3b781fe 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSimpleSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentSimpleSelfTest.java @@ -33,11 +33,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridUriDeploymentSimpleSelfTest extends GridSpiAbstractTest { /** * @return List of URI to use as deployment source. @@ -52,6 +56,7 @@ public List getUriList() { /** * @throws Exception If failed. */ + @Test public void testSimpleDeploy() throws Exception { UriDeploymentSpi spi = getSpi(); @@ -71,6 +76,7 @@ public void testSimpleDeploy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleRedeploy() throws Exception { for (int i = 0; i < 100; i++) testSimpleDeploy(); @@ -79,6 +85,7 @@ public void testSimpleRedeploy() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleDeployWithName() throws Exception { UriDeploymentSpi spi = getSpi(); @@ -98,6 +105,7 @@ public void testSimpleDeployWithName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleRedeployWithName() throws Exception { for (int i = 0; i < 100; i++) testSimpleDeployWithName(); @@ -106,6 +114,7 @@ public void testSimpleRedeployWithName() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleDeployTwoTasks() throws Exception { UriDeploymentSpi spi = getSpi(); @@ -135,6 +144,7 @@ public void testSimpleDeployTwoTasks() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSimpleRedeployTwoTasks() throws Exception { for (int i = 0; i < 100; i++) testSimpleDeployTwoTasks(); @@ -182,4 +192,4 @@ private static class TestTaskWithName extends ComputeTaskAdapter return results.get(0).getData(); } } -} \ No newline at end of file +} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentSelfTest.java index d307a322d2963..dca550754a4c3 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentSelfTest.java @@ -24,11 +24,15 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test file protocol scanner. */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridFileDeploymentSelfTest extends GridUriDeploymentAbstractSelfTest { /** * @return List of URI to use as deployment source. @@ -43,6 +47,7 @@ public List getUriList() { * * @throws Exception If failed. */ + @Test public void testDeploymentFromFolder() throws Exception { checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask0"); checkTask("GridUriDeploymentTestWithNameTask0"); @@ -53,6 +58,7 @@ public void testDeploymentFromFolder() throws Exception { * * @throws Exception If failed. */ + @Test public void testDeploymentFromFile() throws Exception { checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3"); checkTask("GridUriDeploymentTestWithNameTask3"); @@ -70,6 +76,7 @@ public void testDeploymentFromFile() throws Exception { * * @throws Exception If failed. */ + @Test public void testNoDescriptorDeployment() throws Exception { checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask4"); checkTask("GridUriDeploymentTestWithNameTask4"); @@ -85,6 +92,7 @@ public void testNoDescriptorDeployment() throws Exception { * * @throws Exception If failed. */ + @Test public void testBadDeployment() throws Exception { checkNoTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentAbstractTestTask"); @@ -109,6 +117,7 @@ public void testBadDeployment() throws Exception { * * @throws Exception If failed. */ + @Test public void testDependenceDeployment() throws Exception { checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask1"); getSpi().findResource("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask1") @@ -128,6 +137,7 @@ public void testDependenceDeployment() throws Exception { * * @throws Exception If failed. */ + @Test public void testNoDescriptorDependenceDeployment() throws Exception { checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask2"); getSpi().findResource("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask2") @@ -148,6 +158,7 @@ public void testNoDescriptorDependenceDeployment() throws Exception { * * @throws Exception If failed. */ + @Test public void testSignedDeployment() throws Exception { checkTask("org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask5"); checkTask("GridUriDeploymentTestWithNameTask5"); diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentUndeploySelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentUndeploySelfTest.java index 843d80992ebec..9dea59f050fb8 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentUndeploySelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/file/GridFileDeploymentUndeploySelfTest.java @@ -27,11 +27,15 @@ import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest; import org.apache.ignite.testframework.junits.spi.GridSpiTest; import org.apache.ignite.testframework.junits.spi.GridSpiTestConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests correct task undeployment after source file removing. */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridFileDeploymentUndeploySelfTest extends GridSpiAbstractTest { /** */ private static String tmpDirPath = System.getProperty("java.io.tmpdir") + '/' + UUID.randomUUID(); @@ -57,6 +61,7 @@ public class GridFileDeploymentUndeploySelfTest extends GridSpiAbstractTest getUriList() { return Collections.singletonList("file:///" + tmpDirPath); } -} \ No newline at end of file +} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java index 333f7070607a7..457ea70c66dcb 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/spi/deployment/uri/scanners/http/GridHttpDeploymentSelfTest.java @@ -30,11 +30,15 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ResourceHandler; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test http scanner. */ @GridSpiTest(spi = UriDeploymentSpi.class, group = "Deployment SPI") +@RunWith(JUnit4.class) public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTest { /** Frequency */ private static final int FREQ = 5000; @@ -107,6 +111,7 @@ public class GridHttpDeploymentSelfTest extends GridUriDeploymentAbstractSelfTes /** * @throws Exception If failed. */ + @Test public void testDeployUndeploy2Files() throws Exception { String taskName = "org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3"; @@ -133,6 +138,7 @@ public void testDeployUndeploy2Files() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSameContantFiles() throws Exception { String taskName = "org.apache.ignite.spi.deployment.uri.tasks.GridUriDeploymentTestTask3"; diff --git a/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteToolsSelfTestSuite.java b/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteToolsSelfTestSuite.java index 4c5439ed24ee5..0cc6b170081ec 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteToolsSelfTestSuite.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteToolsSelfTestSuite.java @@ -17,22 +17,25 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.tools.GridToolsSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Tools self-test suite. */ -public class IgniteToolsSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteToolsSelfTestSuite { /** * @return Grid ant tasks tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Ignite Ant Tasks Test Suite"); - suite.addTest(new TestSuite(GridToolsSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridToolsSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteUriDeploymentTestSuite.java b/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteUriDeploymentTestSuite.java index 345ce804b6783..41cb70fac2a12 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteUriDeploymentTestSuite.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/testsuites/IgniteUriDeploymentTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.internal.GridTaskUriDeploymentDeadlockSelfTest; import org.apache.ignite.p2p.GridP2PDisabledSelfTest; @@ -39,32 +40,31 @@ public class IgniteUriDeploymentTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("URI Deployment Spi Test Suite"); - suite.addTest(new TestSuite(GridUriDeploymentConfigSelfTest.class)); - suite.addTest(new TestSuite(GridUriDeploymentSimpleSelfTest.class)); - suite.addTest(new TestSuite(GridUriDeploymentClassloaderRegisterSelfTest.class)); - suite.addTest(new TestSuite(GridUriDeploymentFileProcessorSelfTest.class)); - suite.addTest(new TestSuite(GridUriDeploymentClassLoaderSelfTest.class)); - suite.addTest(new TestSuite(GridUriDeploymentClassLoaderMultiThreadedSelfTest.class)); - suite.addTest(new TestSuite(GridUriDeploymentMultiScannersSelfTest.class)); - suite.addTest(new TestSuite(GridUriDeploymentConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentConfigSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentSimpleSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentClassloaderRegisterSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentFileProcessorSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentClassLoaderSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentClassLoaderMultiThreadedSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentMultiScannersSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentConfigSelfTest.class)); - suite.addTest(new TestSuite(GridFileDeploymentUndeploySelfTest.class)); - suite.addTest(new TestSuite(GridHttpDeploymentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFileDeploymentUndeploySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridHttpDeploymentSelfTest.class)); - suite.addTest(new TestSuite(GridFileDeploymentSelfTest.class)); - suite.addTest(new TestSuite(GridUriDeploymentMultiScannersErrorThrottlingTest.class)); - suite.addTest(new TestSuite(GridUriDeploymentMd5CheckSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridFileDeploymentSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentMultiScannersErrorThrottlingTest.class)); + suite.addTest(new JUnit4TestAdapter(GridUriDeploymentMd5CheckSelfTest.class)); // GAR Ant task tests. suite.addTest(IgniteToolsSelfTestSuite.suite()); - suite.addTestSuite(GridTaskUriDeploymentDeadlockSelfTest.class); - suite.addTest(new TestSuite(GridP2PDisabledSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridTaskUriDeploymentDeadlockSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PDisabledSelfTest.class)); return suite; } diff --git a/modules/urideploy/src/test/java/org/apache/ignite/tools/GridToolsSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/tools/GridToolsSelfTest.java index de2d40522b91b..15fd7253bf389 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/tools/GridToolsSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/tools/GridToolsSelfTest.java @@ -30,16 +30,20 @@ import org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests for Ant task generating GAR file. */ @GridCommonTest(group = "Tools") +@RunWith(JUnit4.class) public class GridToolsSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ - @SuppressWarnings({"TypeMayBeWeakened"}) + @Test public void testCorrectAntGarTask() throws Exception { String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); @@ -126,6 +130,7 @@ else if (entry != null && hasDescr) { /** * @throws Exception If failed. */ + @Test public void testAntGarTaskWithExternalP2PDescriptor() throws Exception { String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); @@ -172,6 +177,7 @@ public void testAntGarTaskWithExternalP2PDescriptor() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAntGarTaskWithDoubleP2PDescriptor() throws Exception { String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); @@ -222,6 +228,7 @@ public void testAntGarTaskWithDoubleP2PDescriptor() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAntGarTaskWithDirDescriptor() throws Exception { String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); @@ -266,7 +273,7 @@ public void testAntGarTaskWithDirDescriptor() throws Exception { /** * @throws Exception If failed. */ - @SuppressWarnings({"TypeMayBeWeakened"}) + @Test public void testAntGarTaskWithNullDescriptor() throws Exception { String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); @@ -310,6 +317,7 @@ public void testAntGarTaskWithNullDescriptor() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAntGarTaskWithFileBaseDir() throws Exception { String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); @@ -354,6 +362,7 @@ public void testAntGarTaskWithFileBaseDir() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAntGarTaskToString() throws Exception { String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir"); String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir"); @@ -386,4 +395,4 @@ public void testAntGarTaskToString() throws Exception { garTask.toString(); } -} \ No newline at end of file +} diff --git a/modules/visor-console/pom.xml b/modules/visor-console/pom.xml index aad731964ad85..6975e739adc30 100644 --- a/modules/visor-console/pom.xml +++ b/modules/visor-console/pom.xml @@ -101,7 +101,7 @@ org.scalatest scalatest_2.11 - 2.2.4 + ${scala.test.version} test diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala index 25f1212720d99..5853610448c17 100755 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala @@ -41,31 +41,33 @@ import scala.language.{implicitConversions, reflectiveCalls} * * ==Help== * {{{ - * +-------------------------------------------------------------------------------------------+ - * | cache | Prints statistics about caches from specified node on the entire grid. | - * | | Output sorting can be specified in arguments. | - * | | | - * | | Output abbreviations: | - * | | # Number of nodes. | - * | | H/h Number of cache hits. | - * | | M/m Number of cache misses. | - * | | R/r Number of cache reads. | - * | | W/w Number of cache writes. | - * +-------------------------------------------------------------------------------------------+ - * | cache -clear | Clears all entries from cache on all nodes. | - * +-------------------------------------------------------------------------------------------+ - * | cache -scan | List all entries in cache with specified name. | - * +-------------------------------------------------------------------------------------------+ - * | cache -stop | Stop cache with specified name. | - * +-------------------------------------------------------------------------------------------+ - * | cache -reset | Reset metrics for cache with specified name. | - * +-------------------------------------------------------------------------------------------+ - * | cache -rebalance | Re-balance partitions for cache with specified name. | - * +-------------------------------------------------------------------------------------------+ - * | cache -slp | Show list of lost partitions for specified cache. | - * +-------------------------------------------------------------------------------------------+ - * | cache -rlp | Reset lost partitions for specified cache. | - * +-------------------------------------------------------------------------------------------+ + * +--------------------------------------------------------------------------------------------+ + * | cache | Prints statistics about caches from specified node on the entire grid. | + * | | Output sorting can be specified in arguments. | + * | | | + * | | Output abbreviations: | + * | | # Number of nodes. | + * | | H/h Number of cache hits. | + * | | M/m Number of cache misses. | + * | | R/r Number of cache reads. | + * | | W/w Number of cache writes. | + * +--------------------------------------------------------------------------------------------+ + * | cache -clear | Clears all entries from cache on all nodes. | + * +--------------------------------------------------------------------------------------------+ + * | cache -scan | List all entries in cache with specified name. | + * +--------------------------------------------------------------------------------------------+ + * | cache -stop | Stop cache with specified name. | + * +--------------------------------------------------------------------------------------------+ + * | cache -reset | Reset metrics for cache with specified name. | + * +--------------------------------------------------------------------------------------------+ + * | cache -rebalance | Re-balance partitions for cache with specified name. | + * +--------------------------------------------------------------------------------------------+ + * | cache -slp | Show list of lost partitions for specified cache. | + * +--------------------------------------------------------------------------------------------+ + * | cache -rlp | Reset lost partitions for specified cache. | + * +--------------------------------------------------------------------------------------------+ + * | cache -statistics | Switch collection of statistics for specified cache. | + * +--------------------------------------------------------------------------------------------+ * * }}} * @@ -81,6 +83,7 @@ import scala.language.{implicitConversions, reflectiveCalls} * cache -rebalance -c= * cache -slp -c= * cache -rlp -c= + * cache -statistics= -c= * }}} * * ====Arguments==== @@ -133,6 +136,8 @@ import scala.language.{implicitConversions, reflectiveCalls} * Show list of lost partitions for specified cache. * -rlp * Reset lost partitions for specified cache. + * -statistics=<-on|-off> + * Switch collection of statistics for specified cache. * -p= * Number of object to fetch from cache at once. * Valid range from 1 to 100. @@ -177,6 +182,10 @@ import scala.language.{implicitConversions, reflectiveCalls} * Show list of lost partitions for cache with name 'cache'. * cache -rlp -c=cache * Reset lost partitions for cache with name 'cache'. + * cache -statistics=on -c=cache + * Enable statistics for cache with name 'cache'. + * cache -statistics=off -c=cache + * Disable statistics for cache with name 'cache'. * * }}} */ @@ -279,7 +288,8 @@ class VisorCacheCommand extends VisorConsoleCommand { // Get cache stats data from all nodes. val aggrData = cacheData(node, cacheName, showSystem) - if (hasArgFlagIn("clear", "scan", "stop", "reset", "rebalance", "slp", "rlp")) { + if (hasArgFlagIn("clear", "scan", "stop", "reset", "rebalance", "slp", "rlp") + || hasArgName("statistics", argLst)) { if (cacheName.isEmpty) askForCache("Select cache from:", node, showSystem && !hasArgFlagIn("clear", "stop", "reset", "rebalance"), aggrData) match { @@ -309,6 +319,8 @@ class VisorCacheCommand extends VisorConsoleCommand { VisorCacheLostPartitionsCommand().showLostPartitions(argLst, node) else if (hasArgFlag("rlp", argLst)) VisorCacheResetLostPartitionsCommand().resetLostPartitions(argLst, node) + else if (hasArgName("statistics", argLst)) + VisorCacheToggleStatisticsCommand().toggle(argLst, node) } else { if (hasArgFlag("scan", argLst)) @@ -321,6 +333,8 @@ class VisorCacheCommand extends VisorConsoleCommand { warn("Reset metrics of system cache is not allowed: " + name) else if (hasArgFlag("rebalance", argLst)) warn("Re-balance partitions of system cache is not allowed: " + name) + else if (hasArgName("statistics", argLst)) + warn("Toggle of statistics collection for system cache is not allowed: " + name) } case None => warn("Cache with specified name not found: " + name) @@ -755,7 +769,8 @@ object VisorCacheCommand { "cache -reset -c=", "cache -rebalance -c=", "cache -slp -c=", - "cache -rlp -c=" + "cache -rlp -c=", + "cache -statistics= -c=" ), args = Seq( "-id8=" -> Seq( @@ -784,6 +799,7 @@ object VisorCacheCommand { "-slp" -> "Show list of lost partitions for specified cache.", "-rlp" -> "Reset lost partitions for specified cache.", "-rebalance" -> "Re-balance partitions for cache with specified name.", + "-statistics=" -> "Change statistics collection state for cache with specified name.", "-s=hi|mi|rd|wr|cn" -> Seq( "Defines sorting type. Sorted by:", " hi Hits.", @@ -845,7 +861,11 @@ object VisorCacheCommand { "cache -reset -c=@c0" -> "Reset metrics for cache with name taken from 'c0' memory variable.", "cache -rebalance -c=cache" -> "Re-balance partitions for cache with name 'cache'.", "cache -slp -c=@c0" -> "Show list of lost partitions for cache with name taken from 'c0' memory variable.", - "cache -rlp -c=@c0" -> "Reset lost partitions for cache with name taken from 'c0' memory variable." + "cache -rlp -c=@c0" -> "Reset lost partitions for cache with name taken from 'c0' memory variable.", + "cache -statistics=on -c=@c0" -> + "Enable statistics collection for cache with name taken from 'c0' memory variable.", + "cache -statistics=off -c=@c0" -> + "Disable statistics collection for cache with name taken from 'c0' memory variable." ), emptyArgs = cmd.cache, withArgs = cmd.cache diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheToggleStatisticsCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheToggleStatisticsCommand.scala new file mode 100644 index 0000000000000..2156de03390bd --- /dev/null +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheToggleStatisticsCommand.scala @@ -0,0 +1,152 @@ +/* + * 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. + */ + +package org.apache.ignite.visor.commands.cache + +import java.util.{HashSet => JavaSet} + +import org.apache.ignite.cluster.{ClusterGroupEmptyException, ClusterNode} +import org.apache.ignite.internal.visor.cache.{VisorCacheToggleStatisticsTask, VisorCacheToggleStatisticsTaskArg} +import org.apache.ignite.internal.visor.util.VisorTaskUtils._ +import org.apache.ignite.visor.visor._ + +import scala.language.reflectiveCalls + +/** + * ==Overview== + * Visor 'statistics' command implementation. + * + * ====Specification==== + * {{{ + * cache -statistics= -c= + * }}} + * + * ====Arguments==== + * {{{ + * + * Statistics collection state to set for cache. + * + * Name of the cache. + * }}} + * + * ====Examples==== + * {{{ + * cache -statistics=on -c=@c0 + * Enable collection of statistics for cache with name taken from 'c0' memory variable. + * cache -statistics=off -c=@c0 + * Disable collection of statistics for cache with name taken from 'c0' memory variable. + * }}} + */ +class VisorCacheToggleStatisticsCommand { + /** + * Prints error message and advise. + * + * @param errMsgs Error messages. + */ + private def scold(errMsgs: Any*) { + assert(errMsgs != null) + + warn(errMsgs: _*) + warn("Type 'help cache' to see how to use this command.") + } + + private def error(e: Exception) { + var cause: Throwable = e + + while (cause.getCause != null) + cause = cause.getCause + + scold(cause.getMessage) + } + + /** + * ===Command=== + * Toggle statistics collection for cache with specified name. + * + * ===Examples=== + * cache -statistics=on -c=cache + * Enable collection of statistics for cache with name 'cache'. + * cache -statistics=off -c=cache + * Disable collection of statistics for cache with name 'cache'. + * + * @param argLst Command arguments. + */ + def toggle(argLst: ArgList, node: Option[ClusterNode]) { + val cacheArg = argValue("c", argLst) + + val cacheName = cacheArg match { + case None => null // default cache. + + case Some(s) if s.startsWith("@") => + warn("Can't find cache variable with specified name: " + s, + "Type 'cache' to see available cache variables." + ) + + return + + case Some(name) => name + } + + val grp = try { + groupForDataNode(node, cacheName) + } + catch { + case _: ClusterGroupEmptyException => + scold(messageNodeNotFound(node, cacheName)) + + return + } + + try { + val cacheNames = new JavaSet[String]() + cacheNames.add(cacheName) + + val enable = argValue("statistics", argLst) match { + case Some(state) if "on".equalsIgnoreCase(state) => true + case Some(state) if "off".equalsIgnoreCase(state) => false + case _ => + warn("Goal state for collection of cache statistics is not specified.", + "Use \"on\" and \"off\" value of \"statistics\" argument to toggle collection of cache statistics.") + + return + } + + executeRandom(grp, classOf[VisorCacheToggleStatisticsTask], + new VisorCacheToggleStatisticsTaskArg(enable, cacheNames)) + + println("Visor successfully " + (if (enable) "enable" else "disable") + + " collection of statistics for cache: " + escapeName(cacheName)) + } + catch { + case _: ClusterGroupEmptyException => scold(messageNodeNotFound(node, cacheName)) + case e: Exception => error(e) + } + } +} + +/** + * Companion object that does initialization of the command. + */ +object VisorCacheToggleStatisticsCommand { + /** Singleton command. */ + private val cmd = new VisorCacheToggleStatisticsCommand + + /** + * Singleton. + */ + def apply() = cmd +} diff --git a/modules/web-console/DEVNOTES.txt b/modules/web-console/DEVNOTES.txt index ba61150b41bd9..e7c5eb3e92898 100644 --- a/modules/web-console/DEVNOTES.txt +++ b/modules/web-console/DEVNOTES.txt @@ -51,19 +51,6 @@ To build docker images from sources run following command in Ignite project root Prepared image can be listed with `docker images` command. -Ignite Web Console Standalone Docker Image Build Manual Instructions -==================================================================== -Install Docker (version >=17.05) using instructions from https://www.docker.com/community-edition. - -1. Build Apache Ignite Web Agent archive as described in `modules/web-console/web-agent/README.txt`. -2. Goto Web Console's module directory: `cd modules/web-console` -3. Build docker image: - -"docker build . -t apacheignite/web-console-standalone[:] -f docker/standalone/Dockerfile" - -Prepared image can be listed in `docker images` command output. - - Ignite Web Console Backend Docker Image Build Manual Instructions ==================================================================== Install Docker (version >=17.05) using instructions from https://www.docker.com/community-edition. @@ -139,3 +126,20 @@ Unit tests are performed with Mocha framework - https://mochajs.org To launch tests on your local machine you will need: 1. In new terminal change directory to 'modules/web-console/backend' folder and execute: "npm install". 2. To start test environment and tests execute: "npm run test". + + +Web Console settings +==================== +Web Console backend could be configured with custom parameters. + +See "backend/config/settings.json.sample" for list of parameters with example value. + +If you need custom parameters, you will need create "backend/config/settings.json" and adjust values. + +Web Console settings for Docker +=============================== +Web Console backend could be configured with custom parameters. + +You may pass custom parameters with help of "-e" option. + +For example: docker run -e "server_disable_signup=true" -p 9090:80 $IMAGE_ID diff --git a/modules/web-console/assembly/README.txt b/modules/web-console/assembly/README.txt index dd323993e5231..e88e34570cb13 100644 --- a/modules/web-console/assembly/README.txt +++ b/modules/web-console/assembly/README.txt @@ -41,22 +41,50 @@ Technical details On Windows: `ignite-web-console-win.exe --server:port 3000` All available parameters with defaults: - Web Console host: --server:host 0.0.0.0 - Web Console port: --server:port 80 - Enable HTTPS: --server:ssl false - HTTPS key: --server:key "serve/keys/test.key" - HTTPS certificate: --server:cert "serve/keys/test.crt" - HTTPS passphrase: --server:keyPassphrase "password" - MongoDB URL: --mongodb:url mongodb://localhost/console - Mail service: --mail:service "gmail" - Signature text: --mail:sign "Kind regards, Apache Ignite Team" - Greeting text: --mail:greeting "Apache Ignite Web Console" - Mail FROM: --mail:from "Apache Ignite Web Console " - User to send e-mail: --mail:auth:user "someusername@somecompany.somedomain" - E-mail service password: --mail:auth:pass "" - -Sample usage: - `ignite-web-console-win.exe --mail:auth:user "my_user@gmail.com" --mail:auth:pass "my_password"` + Web Console host: --server:host 0.0.0.0 + Web Console port: --server:port 80 + + Enable HTTPS: --server:ssl false + Disable self registration: --server:disable:signup false + + MongoDB URL: --mongodb:url mongodb://localhost/console + + Enable account activation: --activation:enabled false + Activation timeout(milliseconds): --activation:timeout 1800000 + Activation send email throttle (milliseconds): --activation:sendTimeout 180000 + + Mail service: --mail:service "gmail" + Signature text: --mail:sign "Kind regards, Apache Ignite Team" + Greeting text: --mail:greeting "Apache Ignite Web Console" + Mail FROM: --mail:from "Apache Ignite Web Console " + User to send e-mail: --mail:auth:user "someusername@somecompany.somedomain" + E-mail service password: --mail:auth:pass "" + +SSL options has no default values: + --server:key "path to file with server.key" + --server:cert "path to file with server.crt" + --server:ca "path to file with ca.crt" + --server:passphrase "Password for key" + --server:ciphers "Comma separated ciphers list" + --server:secureProtocol "The TLS protocol version to use" + --server:clientCertEngine "Name of an OpenSSL engine which can provide the client certificate" + --server:pfx "Path to PFX or PKCS12 encoded private key and certificate chain" + --server:crl "Path to file with CRLs (Certificate Revocation Lists)" + --server:dhparam "Diffie Hellman parameters" + --server:ecdhCurve "A string describing a named curve" + --server:maxVersion "Optional the maximmu TLS version to allow" + --server:minVersion "Optional the minimum TLS version to allow" + --server:secureOptions "Optional OpenSSL options" + --server:sessionIdContext "Opaque identifier used by servers to ensure session state is not shared between applications" + --server:honorCipherOrder "true or false" + --server:requestCert "Set to true to specify whether a server should request a certificate from a connecting client" + --server:rejectUnauthorized "Set to true to automatically reject clients with invalid certificates" + +Documentation for SSL options: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options + +Sample usages: + `ignite-web-console-win.exe --mail:auth:user "my_user@gmail.com" --mail:auth:pass "my_password"` + `ignite-web-console-win.exe --server:port 11443 --server:ssl true --server:requestCert true --server:key "server.key" --server:cert "server.crt" --server:ca "ca.crt" --server:passphrase "my_password"` Advanced configuration of SMTP for Web Console. ------------------------------------- @@ -89,9 +117,11 @@ In case of non GMail SMTP server it may require to change options in "settings.j Troubleshooting ------------------------------------- 1. On Windows check that MongoDB is not blocked by Antivirus/Firewall/Smartscreen. -2. Root permission is required to bind to 80 port under Mac OS X and Linux, but you may always start Web Console on another port if you don't have such permission. +2. Root permission is required to bind to 80 port under macOS and Linux, but you may always start Web Console + on another port if you don't have such permission. 3. For extended debug output start Web Console as following: - On Linux execute command in terminal: `DEBUG=mongodb-* ./ignite-web-console-linux` - On Windows execute two commands in terminal: - `SET DEBUG=mongodb-*` - `ignite-web-console-win.exe` + On Linux execute command in terminal: `DEBUG=mongodb-* ./ignite-web-console-linux` + On macOS execute command in terminal: `DEBUG=mongodb-* ./ignite-web-console-macos` + On Windows execute two commands in terminal: + `SET DEBUG=mongodb-*` + `ignite-web-console-win.exe` diff --git a/modules/web-console/backend/app/agentSocket.js b/modules/web-console/backend/app/agentSocket.js index aff62c4b3f304..dfebda0b1b232 100644 --- a/modules/web-console/backend/app/agentSocket.js +++ b/modules/web-console/backend/app/agentSocket.js @@ -38,21 +38,33 @@ module.exports.factory = function() { class AgentSocket { /** * @param {Socket} socket Socket for interaction. + * @param {Object} accounts Active accounts. * @param {Array.} tokens Agent tokens. * @param {String} demoEnabled Demo enabled. */ - constructor(socket, tokens, demoEnabled) { + constructor(socket, accounts, tokens, demoEnabled) { Object.assign(this, { - socket, - tokens, + accounts, cluster: null, demo: { enabled: demoEnabled, browserSockets: [] - } + }, + socket, + tokens }); } + resetToken(oldToken) { + _.pull(this.tokens, oldToken); + + this.emitEvent('agent:reset:token', oldToken) + .then(() => { + if (_.isEmpty(this.tokens) && this.socket.connected) + this.socket.close(); + }); + } + /** * Send event to agent. * @@ -115,7 +127,8 @@ module.exports.factory = function() { const top = this.restResultParse(res); _.forEach(this.demo.browserSockets, (sock) => sock.emit('topology', top)); - } catch (err) { + } + catch (err) { _.forEach(this.demo.browserSockets, (sock) => sock.emit('topology:err', err)); } }); diff --git a/modules/web-console/backend/app/agentsHandler.js b/modules/web-console/backend/app/agentsHandler.js index 6d8c621474fb4..fd55ac3491247 100644 --- a/modules/web-console/backend/app/agentsHandler.js +++ b/modules/web-console/backend/app/agentsHandler.js @@ -50,22 +50,22 @@ module.exports.factory = function(settings, mongo, AgentSocket) { this.sockets = new Map(); } - get(token) { - let sockets = this.sockets.get(token); + get(account) { + let sockets = this.sockets.get(account._id.toString()); if (_.isEmpty(sockets)) - this.sockets.set(token, sockets = []); + this.sockets.set(account._id.toString(), sockets = []); return sockets; } /** * @param {AgentSocket} sock - * @param {String} token + * @param {String} account * @return {Array.} */ - add(token, sock) { - const sockets = this.get(token); + add(account, sock) { + const sockets = this.get(account); sockets.push(sock); } @@ -75,9 +75,9 @@ module.exports.factory = function(settings, mongo, AgentSocket) { * @return {AgentSocket} */ find(browserSocket) { - const token = browserSocket.request.user.token; + const {_id} = browserSocket.request.user; - const sockets = this.sockets.get(token); + const sockets = this.sockets.get(_id); return _.find(sockets, (sock) => _.includes(sock.demo.browserSockets, browserSocket)); } @@ -87,7 +87,8 @@ module.exports.factory = function(settings, mongo, AgentSocket) { constructor(top) { const clusterName = top.clusterName; - this.id = _.isEmpty(clusterName) ? `Cluster ${uuid().substring(0, 8).toUpperCase()}` : clusterName; + this.id = _.isEmpty(top.clusterId) ? uuid() : top.clusterId; + this.name = _.isEmpty(clusterName) ? `Cluster ${this.id.substring(0, 8).toUpperCase()}` : clusterName; this.nids = top.nids; this.addresses = top.addresses; this.clients = top.clients; @@ -227,19 +228,26 @@ module.exports.factory = function(settings, mongo, AgentSocket) { * Link agent with browsers by account. * * @param {Socket} sock + * @param {Array.} accounts * @param {Array.} tokens * @param {boolean} demoEnabled * * @private */ - onConnect(sock, tokens, demoEnabled) { - const agentSocket = new AgentSocket(sock, tokens, demoEnabled); + onConnect(sock, accounts, tokens, demoEnabled) { + const agentSocket = new AgentSocket(sock, accounts, tokens, demoEnabled); + + _.forEach(accounts, (account) => { + this._agentSockets.add(account, agentSocket); + + this._browsersHnd.agentStats(account); + }); sock.on('disconnect', () => { - _.forEach(tokens, (token) => { - _.pull(this._agentSockets.get(token), agentSocket); + _.forEach(accounts, (account) => { + _.pull(this._agentSockets.get(account), agentSocket); - this._browsersHnd.agentStats(token); + this._browsersHnd.agentStats(account); }); }); @@ -257,8 +265,8 @@ module.exports.factory = function(settings, mongo, AgentSocket) { if (agentSocket.cluster !== cluster) { agentSocket.cluster = cluster; - _.forEach(tokens, (token) => { - this._browsersHnd.agentStats(token); + _.forEach(accounts, (account) => { + this._browsersHnd.agentStats(account); }); } else { @@ -267,8 +275,8 @@ module.exports.factory = function(settings, mongo, AgentSocket) { if (changed) { cluster.update(top); - _.forEach(tokens, (token) => { - this._browsersHnd.clusterChanged(token, cluster); + _.forEach(accounts, (account) => { + this._browsersHnd.clusterChanged(account, cluster); }); } } @@ -281,16 +289,17 @@ module.exports.factory = function(settings, mongo, AgentSocket) { agentSocket.cluster = null; - _.forEach(tokens, (token) => { - this._browsersHnd.agentStats(token); + _.forEach(accounts, (account) => { + this._browsersHnd.agentStats(account); }); }); - _.forEach(tokens, (token) => { - this._agentSockets.add(token, agentSocket); + return agentSocket; + } - this._browsersHnd.agentStats(token); - }); + getAccounts(tokens) { + return mongo.Account.find({token: {$in: tokens}}, '_id token').lean().exec() + .then((accounts) => ({accounts, activeTokens: _.uniq(_.map(accounts, 'token'))})); } /** @@ -300,17 +309,27 @@ module.exports.factory = function(settings, mongo, AgentSocket) { attach(srv, browsersHnd) { this._browsersHnd = browsersHnd; - if (this.io) - throw 'Agent server already started!'; - this._collectSupportedAgents() .then((supportedAgents) => { this.currentAgent = _.get(supportedAgents, 'current'); + if (this.io) + throw 'Agent server already started!'; + this.io = socketio(srv, {path: '/agents'}); this.io.on('connection', (sock) => { + const sockId = sock.id; + + console.log('Connected agent with socketId: ', sockId); + + sock.on('disconnect', (reason) => { + console.log(`Agent disconnected with [socketId=${sockId}, reason=${reason}]`); + }); + sock.on('agent:auth', ({ver, bt, tokens, disableDemo} = {}, cb) => { + console.log(`Received authentication request [socketId=${sockId}, tokens=${tokens}, ver=${ver}].`); + if (_.isEmpty(tokens)) return cb('Tokens not set. Please reload agent archive or check settings'); @@ -321,32 +340,33 @@ module.exports.factory = function(settings, mongo, AgentSocket) { return cb('You are using an older version of the agent. Please reload agent'); } - return mongo.Account.find({token: {$in: tokens}}, '_id token').lean().exec() - .then((accounts) => { - const activeTokens = _.uniq(_.map(accounts, 'token')); - + return this.getAccounts(tokens) + .then(({accounts, activeTokens}) => { if (_.isEmpty(activeTokens)) return cb(`Failed to authenticate with token(s): ${tokens.join(',')}. Please reload agent archive or check settings`); cb(null, activeTokens); - return this.onConnect(sock, activeTokens, disableDemo); + return this.onConnect(sock, accounts, activeTokens, disableDemo); }) // TODO IGNITE-1379 send error to web master. .catch(() => cb(`Invalid token(s): ${tokens.join(',')}. Please reload agent archive or check settings`)); }); }); + }) + .catch(() => { + console.log('Failed to collect supported agents'); }); } - agent(token, demo, clusterId) { + agent(account, demo, clusterId) { if (!this.io) return Promise.reject(new Error('Agent server not started yet!')); - const socks = this._agentSockets.get(token); + const socks = this._agentSockets.get(account); if (_.isEmpty(socks)) - return Promise.reject(new Error('Failed to find connected agent for this token')); + return Promise.reject(new Error('Failed to find connected agent for this account')); if (demo || _.isNil(clusterId)) return Promise.resolve(_.head(socks)); @@ -359,11 +379,11 @@ module.exports.factory = function(settings, mongo, AgentSocket) { return Promise.resolve(sock); } - agents(token) { + agents(account) { if (!this.io) return Promise.reject(new Error('Agent server not started yet!')); - const socks = this._agentSockets.get(token); + const socks = this._agentSockets.get(account); if (_.isEmpty(socks)) return Promise.reject(new Error('Failed to find connected agent for this token')); @@ -371,61 +391,18 @@ module.exports.factory = function(settings, mongo, AgentSocket) { return Promise.resolve(socks); } - tryStopDemo(browserSocket) { - const agentSock = this._agentSockets.find(browserSocket); - } - - /** - * @param {ObjectId} token - * @param {Socket} browserSock - * @returns {int} Connected agent count. - */ - onBrowserConnect(token, browserSock) { - this.emitAgentsCount(token); - - // If connect from browser with enabled demo. - const demo = browserSock.request._query.IgniteDemoMode === 'true'; - - // Agents where possible to run demo. - const agentSockets = _.filter(this._agentSockets[token], 'demo.enabled'); - - if (demo && _.size(agentSockets)) { - const agentSocket = _.find(agentSockets, (agent) => _.includes(agent.demo.tokens, token)); - - if (agentSocket) - agentSocket.attachToDemoCluster(browserSock); - else - _.head(agentSockets).runDemoCluster(token, [browserSock]); - } - } - - /** - * @param {Socket} browserSock. - */ - onBrowserDisconnect(browserSock) { - const token = browserSock.client.request.user.token; - - this._browserSockets.pull(token, browserSock); - - // If connect from browser with enabled demo. - if (browserSock.request._query.IgniteDemoMode === 'true') - this._agentSockets.find(token, (agent) => _.includes(agent.demo.browserSockets, browserSock)); - - // TODO If latest browser with demo need stop demo cluster on agent. - } - /** * Try stop agent for token if not used by others. * - * @param {String} token + * @param {mongo.Account} account */ - onTokenReset(token) { + onTokenReset(account) { if (_.isNil(this.io)) return; - const sockets = this._agentSockets[token]; + const agentSockets = this._agentSockets.get(account); - _.forEach(sockets, (socket) => socket._sendToAgent('agent:reset:token', token)); + _.forEach(agentSockets, (sock) => sock.resetToken(account.token)); } } diff --git a/modules/web-console/backend/app/browsersHandler.js b/modules/web-console/backend/app/browsersHandler.js index d0cd1128406d4..820c3d47272da 100644 --- a/modules/web-console/backend/app/browsersHandler.js +++ b/modules/web-console/backend/app/browsersHandler.js @@ -38,38 +38,38 @@ module.exports = { * @param {Socket} sock */ add(sock) { - const token = sock.request.user.token; + const key = sock.request.user._id.toString(); - if (this.sockets.has(token)) - this.sockets.get(token).push(sock); + if (this.sockets.has(key)) + this.sockets.get(key).push(sock); else - this.sockets.set(token, [sock]); + this.sockets.set(key, [sock]); - return this.sockets.get(token); + return this.sockets.get(sock.request.user); } /** * @param {Socket} sock */ remove(sock) { - const token = sock.request.user.token; + const key = sock.request.user._id.toString(); - const sockets = this.sockets.get(token); + const sockets = this.sockets.get(key); _.pull(sockets, sock); return sockets; } - get(token) { - if (this.sockets.has(token)) - return this.sockets.get(token); + get(account) { + const key = account._id.toString(); - return []; - } + let sockets = this.sockets.get(key); + + if (_.isEmpty(sockets)) + this.sockets.set(key, sockets = []); - demo(token) { - return _.filter(this.sockets.get(token), (sock) => sock.request._query.IgniteDemoMode === 'true'); + return sockets; } } @@ -103,11 +103,11 @@ module.exports = { } /** - * @param {String} token + * @param {String} account * @param {Array.} [socks] */ - agentStats(token, socks = this._browserSockets.get(token)) { - return this._agentHnd.agents(token) + agentStats(account, socks = this._browserSockets.get(account)) { + return this._agentHnd.agents(account) .then((agentSocks) => { const stat = _.reduce(agentSocks, (acc, agentSock) => { acc.count += 1; @@ -127,8 +127,8 @@ module.exports = { .then((stat) => _.forEach(socks, (sock) => sock.emit('agents:stat', stat))); } - clusterChanged(token, cluster) { - const socks = this._browserSockets.get(token); + clusterChanged(account, cluster) { + const socks = this._browserSockets.get(account); _.forEach(socks, (sock) => sock.emit('cluster:changed', cluster)); } @@ -153,10 +153,10 @@ module.exports = { } } - executeOnAgent(token, demo, event, ...args) { + executeOnAgent(account, demo, event, ...args) { const cb = _.last(args); - return this._agentHnd.agent(token, demo) + return this._agentHnd.agent(account, demo) .then((agentSock) => agentSock.emitEvent(event, ..._.dropRight(args))) .then((res) => cb(null, res)) .catch((err) => cb(this.errorTransformer(err))); @@ -164,21 +164,21 @@ module.exports = { agentListeners(sock) { const demo = sock.request._query.IgniteDemoMode === 'true'; - const token = () => sock.request.user.token; + const account = () => sock.request.user; // Return available drivers to browser. sock.on('schemaImport:drivers', (...args) => { - this.executeOnAgent(token(), demo, 'schemaImport:drivers', ...args); + this.executeOnAgent(account(), demo, 'schemaImport:drivers', ...args); }); // Return schemas from database to browser. sock.on('schemaImport:schemas', (...args) => { - this.executeOnAgent(token(), demo, 'schemaImport:schemas', ...args); + this.executeOnAgent(account(), demo, 'schemaImport:schemas', ...args); }); // Return tables from database to browser. sock.on('schemaImport:metadata', (...args) => { - this.executeOnAgent(token(), demo, 'schemaImport:metadata', ...args); + this.executeOnAgent(account(), demo, 'schemaImport:metadata', ...args); }); } @@ -189,10 +189,10 @@ module.exports = { * @param {Object.} params * @return {Promise.} */ - executeOnNode(agent, demo, credentials, params) { + executeOnNode(agent, token, demo, credentials, params) { return agent .then((agentSock) => agentSock.emitEvent('node:rest', - {uri: 'ignite', demo, params: _.merge({}, credentials, params)})); + {uri: 'ignite', token, demo, params: _.merge({}, credentials, params)})); } registerVisorTask(taskId, taskCls, ...argCls) { @@ -218,11 +218,11 @@ module.exports = { return cb('Invalid format of message: "node:rest"'); } - const token = sock.request.user.token; + const agent = this._agentHnd.agent(sock.request.user, demo, clusterId); - const agent = this._agentHnd.agent(token, demo, clusterId); + const token = sock.request.user.token; - this.executeOnNode(agent, demo, credentials, params) + this.executeOnNode(agent, token, demo, credentials, params) .then((data) => cb(null, data)) .catch((err) => cb(this.errorTransformer(err))); }); @@ -244,6 +244,11 @@ module.exports = { this.registerVisorTask('toggleClusterState', internalVisor('misc.VisorChangeGridActiveStateTask'), internalVisor('misc.VisorChangeGridActiveStateTaskArg')); + this.registerVisorTask('cacheNamesCollectorTask', internalVisor('cache.VisorCacheNamesCollectorTask'), 'java.lang.Void'); + + this.registerVisorTask('cacheNodesTask', internalVisor('cache.VisorCacheNodesTask'), 'java.lang.String'); + this.registerVisorTask('cacheNodesTaskX2', internalVisor('cache.VisorCacheNodesTask'), internalVisor('cache.VisorCacheNodesTaskArg')); + // Return command result from grid to browser. sock.on('node:visor', (arg, cb) => { const {clusterId, params, credentials} = arg || {}; @@ -259,8 +264,6 @@ module.exports = { return cb('Invalid format of message: "node:visor"'); } - const token = sock.request.user.token; - const {taskId, nids, args = []} = params; const desc = this._visorTasks.get(taskId); @@ -277,9 +280,11 @@ module.exports = { _.forEach(_.concat(desc.argCls, args), (param, idx) => { exeParams[`p${idx + 3}`] = param; }); - const agent = this._agentHnd.agent(token, demo, clusterId); + const agent = this._agentHnd.agent(sock.request.user, demo, clusterId); + + const token = sock.request.user.token; - this.executeOnNode(agent, demo, credentials, exeParams) + this.executeOnNode(agent, token, demo, credentials, exeParams) .then((data) => { if (data.finished && !data.zipped) return cb(null, data.result); @@ -317,18 +322,13 @@ module.exports = { // Handle browser disconnect event. sock.on('disconnect', () => { this._browserSockets.remove(sock); - - const demo = sock.request._query.IgniteDemoMode === 'true'; - - // Stop demo if latest demo tab for this token. - demo && agentHnd.tryStopDemo(sock); }); this.agentListeners(sock); this.nodeListeners(sock); this.pushInitialData(sock); - this.agentStats(sock.request.user.token, [sock]); + this.agentStats(sock.request.user, [sock]); this.emitNotification(sock); }); }); diff --git a/modules/web-console/backend/app/configure.js b/modules/web-console/backend/app/configure.js index b7bdb49097d33..ac71b74864833 100644 --- a/modules/web-console/backend/app/configure.js +++ b/modules/web-console/backend/app/configure.js @@ -25,6 +25,7 @@ const session = require('express-session'); const connectMongo = require('connect-mongo'); const passport = require('passport'); const passportSocketIo = require('passport.socketio'); +const mongoSanitize = require('express-mongo-sanitize'); // Fire me up! @@ -47,11 +48,12 @@ module.exports.factory = function(settings, mongo, apis) { _.forEach(apis, (api) => app.use(api)); - app.use(cookieParser(settings.sessionSecret)); - app.use(bodyParser.json({limit: '50mb'})); app.use(bodyParser.urlencoded({limit: '50mb', extended: true})); + + app.use(mongoSanitize({replaceWith: '_'})); + app.use(session({ secret: settings.sessionSecret, resave: false, @@ -67,18 +69,26 @@ module.exports.factory = function(settings, mongo, apis) { app.use(passport.initialize()); app.use(passport.session()); - passport.serializeUser(mongo.Account.serializeUser()); - passport.deserializeUser(mongo.Account.deserializeUser()); + passport.serializeUser((user, done) => done(null, user._id)); + + passport.deserializeUser((id, done) => { + if (mongo.ObjectId.isValid(id)) + return mongo.Account.findById(id, done); + + // Invalidates the existing login session. + done(null, false); + }); passport.use(mongo.Account.createStrategy()); }, socketio: (io) => { - const _onAuthorizeSuccess = (data, accept) => { - accept(null, true); - }; + const _onAuthorizeSuccess = (data, accept) => accept(); const _onAuthorizeFail = (data, message, error, accept) => { - accept(null, false); + if (error) + accept(new Error(message)); + + return accept(new Error(message)); }; io.use(passportSocketIo.authorize({ diff --git a/modules/web-console/backend/app/mongo.js b/modules/web-console/backend/app/mongo.js index 6a843dbdd15e7..209c11c9b6ea6 100644 --- a/modules/web-console/backend/app/mongo.js +++ b/modules/web-console/backend/app/mongo.js @@ -54,6 +54,22 @@ const defineSchema = (mongoose, schemas) => { return result; }; +const upgradeAccounts = (mongo, activation) => { + if (activation) { + return mongo.Account.find({ + $or: [{activated: false}, {activated: {$exists: false}}], + activationToken: {$exists: false} + }, '_id').lean().exec() + .then((accounts) => { + const conditions = _.map(accounts, (account) => ({session: {$regex: `"${account._id}"`}})); + + return mongoose.connection.db.collection('sessions').deleteMany({$or: conditions}); + }); + } + + return mongo.Account.update({activated: false}, {$unset: {activationSentAt: "", activationToken: ""}}, {multi: true}).exec(); +}; + module.exports.factory = function(settings, mongoose, schemas) { // Use native promises mongoose.Promise = global.Promise; @@ -128,7 +144,8 @@ module.exports.factory = function(settings, mongoose, schemas) { admin: true, token: 'ruQvlWff09zqoVYyh6WJ', attempts: 0, - resetPasswordToken: 'O2GWgOkKkhqpDcxjYnSP' + resetPasswordToken: 'O2GWgOkKkhqpDcxjYnSP', + activated: true }), mongo.Space.create({ _id: '59fc0c26e145c32be0f83b34', @@ -146,5 +163,10 @@ module.exports.factory = function(settings, mongoose, schemas) { return mongo; }); + }) + .then((mongo) => { + return upgradeAccounts(mongo, settings.activation.enabled) + .then(() => mongo) + .catch(() => mongo); }); }; diff --git a/modules/web-console/backend/app/schemas.js b/modules/web-console/backend/app/schemas.js index 5898ed88cb247..95c3f5b1b2503 100644 --- a/modules/web-console/backend/app/schemas.js +++ b/modules/web-console/backend/app/schemas.js @@ -46,7 +46,10 @@ module.exports.factory = function(mongoose) { lastActivity: Date, admin: Boolean, token: String, - resetPasswordToken: String + resetPasswordToken: String, + activated: {type: Boolean, default: false}, + activationSentAt: Date, + activationToken: String }); // Install passport plugin. @@ -136,7 +139,7 @@ module.exports.factory = function(mongoose) { clusters: [{type: ObjectId, ref: 'Cluster'}], domains: [{type: ObjectId, ref: 'DomainModel'}], cacheMode: {type: String, enum: ['PARTITIONED', 'REPLICATED', 'LOCAL']}, - atomicityMode: {type: String, enum: ['ATOMIC', 'TRANSACTIONAL']}, + atomicityMode: {type: String, enum: ['ATOMIC', 'TRANSACTIONAL', 'TRANSACTIONAL_SNAPSHOT']}, partitionLossPolicy: { type: String, enum: ['READ_ONLY_SAFE', 'READ_ONLY_ALL', 'READ_WRITE_SAFE', 'READ_WRITE_ALL', 'IGNORE'] @@ -985,6 +988,7 @@ module.exports.factory = function(mongoose) { consistentId: String, failureDetectionTimeout: Number, clientFailureDetectionTimeout: Number, + systemWorkerBlockedTimeout: Number, workDirectory: String, lateAffinityAssignment: Boolean, utilityCacheKeepAliveTime: Number, @@ -1054,7 +1058,8 @@ module.exports.factory = function(mongoose) { fileIOFactory: {type: String, enum: ['RANDOM', 'ASYNC']}, walAutoArchiveAfterInactivity: Number, writeThrottlingEnabled: Boolean, - walCompactionEnabled: Boolean + walCompactionEnabled: Boolean, + checkpointReadLockTimeout: Number }, memoryConfiguration: { systemCacheInitialSize: Number, @@ -1109,7 +1114,9 @@ module.exports.factory = function(mongoose) { rateTimeInterval: Number, tlbSize: Number, subIntervals: Number - } + }, + mvccVacuumThreadCount: Number, + mvccVacuumFrequency: Number }); Cluster.index({name: 1, space: 1}, {unique: true}); diff --git a/modules/web-console/backend/app/settings.js b/modules/web-console/backend/app/settings.js index d206107843908..0079788615473 100644 --- a/modules/web-console/backend/app/settings.js +++ b/modules/web-console/backend/app/settings.js @@ -18,6 +18,7 @@ 'use strict'; const fs = require('fs'); +const _ = require('lodash'); // Fire me up! @@ -53,7 +54,23 @@ module.exports = { const dfltHost = packaged ? '0.0.0.0' : '127.0.0.1'; const dfltPort = packaged ? 80 : 3000; - return { + // We need this function because nconf() can return String or Boolean. + // And in JS we cannot compare String with Boolean. + const _isTrue = (confParam) => { + const v = nconf.get(confParam); + + return v === 'true' || v === true; + }; + + let activationEnabled = _isTrue('activation:enabled'); + + if (activationEnabled && _.isEmpty(mail)) { + activationEnabled = false; + + console.warn('Mail server settings are required for account confirmation!'); + } + + const settings = { agent: { dists: nconf.get('agent:dists') || dfltAgentDists }, @@ -61,19 +78,73 @@ module.exports = { server: { host: nconf.get('server:host') || dfltHost, port: _normalizePort(nconf.get('server:port') || dfltPort), - SSLOptions: nconf.get('server:ssl') && { - enable301Redirects: true, - trustXFPHeader: true, - key: fs.readFileSync(nconf.get('server:key')), - cert: fs.readFileSync(nconf.get('server:cert')), - passphrase: nconf.get('server:keyPassphrase') - } + disableSignup: _isTrue('server:disable:signup') }, mail, + activation: { + enabled: activationEnabled, + timeout: nconf.get('activation:timeout') || 1800000, + sendTimeout: nconf.get('activation:sendTimeout') || 180000 + }, mongoUrl: nconf.get('mongodb:url') || 'mongodb://127.0.0.1/console', cookieTTL: 3600000 * 24 * 30, sessionSecret: nconf.get('server:sessionSecret') || 'keyboard cat', tokenLength: 20 }; + + // Configure SSL options. + if (_isTrue('server:ssl')) { + const sslOptions = { + enable301Redirects: true, + trustXFPHeader: true, + isServer: true + }; + + const setSslOption = (name, fromFile = false) => { + const v = nconf.get(`server:${name}`); + + const hasOption = !!v; + + if (hasOption) + sslOptions[name] = fromFile ? fs.readFileSync(v) : v; + + return hasOption; + }; + + const setSslOptionBoolean = (name) => { + const v = nconf.get(`server:${name}`); + + if (v) + sslOptions[name] = v === 'true' || v === true; + }; + + setSslOption('key', true); + setSslOption('cert', true); + setSslOption('ca', true); + setSslOption('passphrase'); + setSslOption('ciphers'); + setSslOption('secureProtocol'); + setSslOption('clientCertEngine'); + setSslOption('pfx', true); + setSslOption('crl'); + setSslOption('dhparam'); + setSslOption('ecdhCurve'); + setSslOption('maxVersion'); + setSslOption('minVersion'); + setSslOption('secureOptions'); + setSslOption('sessionIdContext'); + + setSslOptionBoolean('honorCipherOrder'); + setSslOptionBoolean('requestCert'); + setSslOptionBoolean('rejectUnauthorized'); + + // Special care for case, when user set password for something like "123456". + if (sslOptions.passphrase) + sslOptions.passphrase = sslOptions.passphrase.toString(); + + settings.server.SSLOptions = sslOptions; + } + + return settings; } }; diff --git a/modules/web-console/backend/config/settings.json.sample b/modules/web-console/backend/config/settings.json.sample index aa93e07c57eba..02bc3270b8402 100644 --- a/modules/web-console/backend/config/settings.json.sample +++ b/modules/web-console/backend/config/settings.json.sample @@ -1,23 +1,36 @@ { - "server": { - "port": 3000, - "sessionSecret": "CHANGE ME", - "ssl": false, - "key": "serve/keys/test.key", - "cert": "serve/keys/test.crt", - "keyPassphrase": "password" - }, - "mongodb": { - "url": "mongodb://localhost/console" - }, - "mail": { - "service": "", - "from": "Some Company Web Console ", - "greeting": "Some Company Web Console", - "sign": "Kind regards,
    Some Company Team", - "auth": { - "user": "some_username@some_company.com", - "pass": "" - } + "server": { + "port": 3000, + "sessionSecret": "CHANGE ME", + "ssl": false, + "key": "path to file with server.key", + "cert": "path to file with server.crt", + "ca": "path to file with ca.crt", + "passphrase": "password", + "ciphers": "ECDHE-RSA-AES128-GCM-SHA256", + "secureProtocol": "TLSv1_2_method", + "requestCert": false, + "rejectUnauthorized": false, + "disable": { + "signup": false } + }, + "mongodb": { + "url": "mongodb://localhost/console" + }, + "activation": { + "enabled": false, + "timeout": 1800000, + "sendTimeout": 180000 + }, + "mail": { + "service": "gmail", + "from": "Some Company Web Console ", + "greeting": "Some Company Web Console", + "sign": "Kind regards,
    Some Company Team", + "auth": { + "user": "some_username@some_company.com", + "pass": "CHANGE ME" + } + } } diff --git a/modules/web-console/backend/errors/MissingConfirmRegistrationException.js b/modules/web-console/backend/errors/MissingConfirmRegistrationException.js new file mode 100644 index 0000000000000..a094a679bf33f --- /dev/null +++ b/modules/web-console/backend/errors/MissingConfirmRegistrationException.js @@ -0,0 +1,34 @@ +/* + * 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. + */ + +'use strict'; + +const IllegalAccessError = require('./IllegalAccessError'); + +class MissingConfirmRegistrationException extends IllegalAccessError { + constructor(email) { + super('User account email not activated'); + + this.data = { + errorCode: 10104, + message: this.message, + email + }; + } +} + +module.exports = MissingConfirmRegistrationException; diff --git a/modules/web-console/backend/errors/index.js b/modules/web-console/backend/errors/index.js index 2fadc120ab08d..cb8f043503071 100644 --- a/modules/web-console/backend/errors/index.js +++ b/modules/web-console/backend/errors/index.js @@ -24,6 +24,7 @@ const IllegalArgumentException = require('./IllegalArgumentException'); const IllegalAccessError = require('./IllegalAccessError'); const DuplicateKeyException = require('./DuplicateKeyException'); const ServerErrorException = require('./ServerErrorException'); +const MissingConfirmRegistrationException = require('./MissingConfirmRegistrationException'); const MissingResourceException = require('./MissingResourceException'); const AuthFailedException = require('./AuthFailedException'); @@ -35,6 +36,7 @@ module.exports = { IllegalArgumentException, DuplicateKeyException, ServerErrorException, + MissingConfirmRegistrationException, MissingResourceException, AuthFailedException }) diff --git a/modules/web-console/backend/index.js b/modules/web-console/backend/index.js index 4697de91eaffd..c601c0bf8a121 100644 --- a/modules/web-console/backend/index.js +++ b/modules/web-console/backend/index.js @@ -23,17 +23,17 @@ const appPath = require('app-module-path'); appPath.addPath(__dirname); appPath.addPath(path.join(__dirname, 'node_modules')); -const { migrate, init } = require('./launch-tools'); +const { checkMongo, migrate, init } = require('./launch-tools'); const injector = require('./injector'); injector.log.info = () => {}; injector.log.debug = () => {}; -Promise.all([injector('settings'), injector('mongo')]) - .then(([{mongoUrl}]) => { - return migrate(mongoUrl, 'Ignite', path.join(__dirname, 'migrations')); - }) +injector('mongo') + .then(() => checkMongo()) + .then(() => injector('settings')) + .then(({mongoUrl}) => migrate(mongoUrl, 'Ignite', path.join(__dirname, 'migrations'))) .then(() => Promise.all([injector('settings'), injector('api-server'), injector('agents-handler'), injector('browsers-handler')])) .then(init) .catch((err) => { diff --git a/modules/web-console/backend/launch-tools.js b/modules/web-console/backend/launch-tools.js index f1f3b2f4e835c..0d6114fb363a6 100644 --- a/modules/web-console/backend/launch-tools.js +++ b/modules/web-console/backend/launch-tools.js @@ -21,6 +21,7 @@ const _ = require('lodash'); const http = require('http'); const https = require('https'); const MigrateMongoose = require('migrate-mongoose'); +const mongoose = require('mongoose'); /** * Event listener for HTTP server "error" event. @@ -54,7 +55,11 @@ const _onError = (addr, error) => { */ const init = ([settings, apiSrv, agentsHnd, browsersHnd]) => { // Start rest server. - const srv = settings.server.SSLOptions ? https.createServer(settings.server.SSLOptions) : http.createServer(); + const sslOptions = settings.server.SSLOptions; + + console.log(`Starting ${sslOptions ? 'HTTPS' : 'HTTP'} server`); + + const srv = sslOptions ? https.createServer(sslOptions) : http.createServer(); srv.listen(settings.server.port, settings.server.host); @@ -106,4 +111,21 @@ const migrate = (dbConnectionUri, group, migrationsPath, collectionName) => { }); }; -module.exports = { migrate, init }; +/** + * Check version of used MongoDB. + */ +const checkMongo = () => { + const versionValid = (mijor, minor) => mijor === 3 && minor >= 2 && minor <= 4; + + const admin = new mongoose.mongo.Admin(mongoose.connection.db, null, global.Promise); + + return admin.buildInfo() + .then((info) => { + const versions = info.version.split('.'); + + if (!versionValid(parseInt(versions[0]), parseInt(versions[1]))) + throw Error(`Unsupported version of MongoDB ${info.version}. Supported versions: 3.2.x-3.4.x`); + }); +}; + +module.exports = { checkMongo, migrate, init }; diff --git a/modules/web-console/backend/middlewares/api.js b/modules/web-console/backend/middlewares/api.js index 27e130d4e8e38..d4d832b5a650f 100644 --- a/modules/web-console/backend/middlewares/api.js +++ b/modules/web-console/backend/middlewares/api.js @@ -37,6 +37,9 @@ module.exports.factory = () => { if (_.includes(['MongoError', 'MongooseError'], err.name)) return res.status(500).send(err.message); + if (_.isObject(err.data)) + return res.status(err.httpCode || err.code || 500).json(err.data); + res.status(err.httpCode || err.code || 500).send(err.message); }, diff --git a/modules/web-console/backend/package.json b/modules/web-console/backend/package.json index fb127489f2667..9d1918e83eb9c 100644 --- a/modules/web-console/backend/package.json +++ b/modules/web-console/backend/package.json @@ -52,6 +52,7 @@ "connect-mongo": "1.3.2", "cookie-parser": "1.4.3", "express": "4.15.3", + "express-mongo-sanitize": "1.3.2", "express-session": "1.15.4", "fire-up": "1.0.0", "glob": "7.1.2", @@ -68,7 +69,7 @@ "passport-local-mongoose": "4.0.0", "passport.socketio": "3.7.0", "pkg": "4.3.1", - "socket.io": "1.7.3", + "socket.io": "2.1.1", "uuid": "3.1.0" }, "devDependencies": { diff --git a/modules/web-console/backend/routes/activities.js b/modules/web-console/backend/routes/activities.js index 4db6ac2372ad0..11fd81bec75b6 100644 --- a/modules/web-console/backend/routes/activities.js +++ b/modules/web-console/backend/routes/activities.js @@ -24,8 +24,8 @@ const express = require('express'); module.exports = { implements: 'routes/activities', inject: ['services/activities'], + /** - * @param express * @param {ActivitiesService} activitiesService * @returns {Promise} */ @@ -35,7 +35,7 @@ module.exports = { // Post user activities to page. router.post('/page', (req, res) => { - activitiesService.merge(req.user._id, req.body) + activitiesService.merge(req.user, req.body) .then(res.api.ok) .catch(res.api.error); }); diff --git a/modules/web-console/backend/routes/profile.js b/modules/web-console/backend/routes/profile.js index 0ce2656b1f7f0..79fb3de42d225 100644 --- a/modules/web-console/backend/routes/profile.js +++ b/modules/web-console/backend/routes/profile.js @@ -43,7 +43,7 @@ module.exports.factory = function(mongo, usersService) { if (req.body.password && _.isEmpty(req.body.password)) return res.status(500).send('Wrong value for new password!'); - usersService.save(req.body) + usersService.save(req.user._id, req.body) .then((user) => { const becomeUsed = req.session.viewedUser && req.user.admin; diff --git a/modules/web-console/backend/routes/public.js b/modules/web-console/backend/routes/public.js index 155b2e9f268e4..d290b53520553 100644 --- a/modules/web-console/backend/routes/public.js +++ b/modules/web-console/backend/routes/public.js @@ -17,6 +17,7 @@ 'use strict'; +const _ = require('lodash'); const express = require('express'); const passport = require('passport'); @@ -24,17 +25,18 @@ const passport = require('passport'); module.exports = { implements: 'routes/public', - inject: ['mongo', 'services/mails', 'services/users', 'services/auth'] + inject: ['mongo', 'settings', 'services/users', 'services/auth', 'errors'] }; -/** +/** * @param mongo - * @param mailsService + * @param settings * @param {UsersService} usersService * @param {AuthService} authService + * @param errors * @returns {Promise} */ -module.exports.factory = function(mongo, mailsService, usersService, authService) { +module.exports.factory = function(mongo, settings, usersService, authService, errors) { return new Promise((factoryResolve) => { const router = new express.Router(); @@ -49,15 +51,22 @@ module.exports.factory = function(mongo, mailsService, usersService, authService * Register new account. */ router.post('/signup', (req, res) => { - usersService.create(req.origin(), req.body) - .then((user) => new Promise((resolve, reject) => { - req.logIn(user, {}, (err) => { - if (err) - reject(err); + const createdByAdmin = _.get(req, 'user.admin', false); - resolve(user); + usersService.create(req.origin(), req.body, createdByAdmin) + .then((user) => { + if (createdByAdmin) + return user; + + return new Promise((resolve, reject) => { + req.logIn(user, {}, (err) => { + if (err) + reject(err); + + resolve(user); + }); }); - })) + }) .then(res.api.ok) .catch(res.api.error); }); @@ -68,14 +77,34 @@ module.exports.factory = function(mongo, mailsService, usersService, authService router.post('/signin', (req, res, next) => { passport.authenticate('local', (errAuth, user) => { if (errAuth) - return res.status(401).send(errAuth.message); + return res.api.error(new errors.AuthFailedException(errAuth.message)); if (!user) - return res.status(401).send('Invalid email or password'); + return res.api.error(new errors.AuthFailedException('Invalid email or password')); + + if (settings.activation.enabled) { + const activationToken = req.body.activationToken; + + const errToken = authService.validateActivationToken(user, activationToken); + + if (errToken) + return res.api.error(errToken); + + if (authService.isActivationTokenExpired(user, activationToken)) { + authService.resetActivationToken(req.origin(), user.email) + .catch((ignored) => { + // No-op. + }); - req.logIn(user, {}, (errLogIn) => { + return res.api.error(new errors.AuthFailedException('This activation link was expired. We resend a new one. Please open the most recent email and click on the activation link.')); + } + + user.activated = true; + } + + return req.logIn(user, {}, (errLogIn) => { if (errLogIn) - return res.status(401).send(errLogIn.message); + return res.api.error(new errors.AuthFailedException(errLogIn.message)); return res.sendStatus(200); }); @@ -95,10 +124,8 @@ module.exports.factory = function(mongo, mailsService, usersService, authService * Send e-mail to user with reset token. */ router.post('/password/forgot', (req, res) => { - authService.resetPasswordToken(req.body.email) - .then((user) => mailsService.emailUserResetLink(req.origin(), user)) - .then(() => 'An email has been sent with further instructions.') - .then(res.api.ok) + authService.resetPasswordToken(req.origin(), req.body.email) + .then(() => res.api.ok('An email has been sent with further instructions.')) .catch(res.api.error); }); @@ -108,8 +135,7 @@ module.exports.factory = function(mongo, mailsService, usersService, authService router.post('/password/reset', (req, res) => { const {token, password} = req.body; - authService.resetPasswordByToken(token, password) - .then((user) => mailsService.emailPasswordChanged(req.origin(), user)) + authService.resetPasswordByToken(req.origin(), token, password) .then(res.api.ok) .catch(res.api.error); }); @@ -123,6 +149,13 @@ module.exports.factory = function(mongo, mailsService, usersService, authService .catch(res.api.error); }); + /* Send e-mail to user with account confirmation token. */ + router.post('/activation/resend', (req, res) => { + authService.resetActivationToken(req.origin(), req.body.email) + .then(() => res.api.ok('An email has been sent with further instructions.')) + .catch(res.api.error); + }); + factoryResolve(router); }); }; diff --git a/modules/web-console/backend/services/activities.js b/modules/web-console/backend/services/activities.js index 9399eb056d8a6..bc0245de8f5e8 100644 --- a/modules/web-console/backend/services/activities.js +++ b/modules/web-console/backend/services/activities.js @@ -35,13 +35,15 @@ module.exports.factory = (mongo) => { /** * Update page activities. * - * @param {String} owner - User ID + * @param {Object} user - User. * @param {String} action - Action string presentation. * @param {String} group - Action group string presentation. * @param {Date} [now] - Optional date to save in activity. - * @returns {Promise.} that resolve activity + * @returns {Promise.} that resolve activity. */ - static merge(owner, {action, group}, now = new Date()) { + static merge(user, {action, group}, now = new Date()) { + const owner = user._id; + mongo.Account.findById(owner) .then((user) => { user.lastActivity = new Date(); diff --git a/modules/web-console/backend/services/auth.js b/modules/web-console/backend/services/auth.js index 986ed9555d0df..c6da86e08d1d0 100644 --- a/modules/web-console/backend/services/auth.js +++ b/modules/web-console/backend/services/auth.js @@ -19,9 +19,11 @@ // Fire me up! +const _ = require('lodash'); + module.exports = { implements: 'services/auth', - inject: ['mongo', 'settings', 'errors', 'services/utils'] + inject: ['mongo', 'settings', 'errors', 'services/utils', 'services/mails'] }; /** @@ -29,42 +31,52 @@ module.exports = { * @param settings * @param errors * @param {UtilsService} utilsService + * @param {MailsService} mailsService * @returns {AuthService} */ -module.exports.factory = (mongo, settings, errors, utilsService) => { +module.exports.factory = (mongo, settings, errors, utilsService, mailsService) => { class AuthService { /** * Reset password reset token for user. * + * @param host Web Console host. * @param email - user email * @returns {Promise.} - that resolves account found by email with new reset password token. */ - static resetPasswordToken(email) { + static resetPasswordToken(host, email) { return mongo.Account.findOne({email}).exec() .then((user) => { if (!user) throw new errors.MissingResourceException('Account with that email address does not exists!'); + if (settings.activation.enabled && !user.activated) + throw new errors.MissingConfirmRegistrationException(user.email); + user.resetPasswordToken = utilsService.randomString(settings.tokenLength); return user.save(); - }); + }) + .then((user) => mailsService.emailUserResetLink(host, user)); } /** * Reset password by reset token. * + * @param host Web Console host. * @param {string} token - reset token * @param {string} newPassword - new password * @returns {Promise.} - that resolves account with new password */ - static resetPasswordByToken(token, newPassword) { + static resetPasswordByToken(host, token, newPassword) { return mongo.Account.findOne({resetPasswordToken: token}).exec() .then((user) => { if (!user) throw new errors.MissingResourceException('Failed to find account with this token! Please check link from email.'); + if (settings.activation.enabled && !user.activated) + throw new errors.MissingConfirmRegistrationException(user.email); + return new Promise((resolve, reject) => { user.setPassword(newPassword, (err, _user) => { if (err) @@ -75,7 +87,8 @@ module.exports.factory = (mongo, settings, errors, utilsService) => { resolve(_user.save()); }); }); - }); + }) + .then((user) => mailsService.emailPasswordChanged(host, user)); } /** @@ -90,9 +103,73 @@ module.exports.factory = (mongo, settings, errors, utilsService) => { if (!user) throw new errors.IllegalAccessError('Invalid token for password reset!'); + if (settings.activation.enabled && !user.activated) + throw new errors.MissingConfirmRegistrationException(user.email); + return {token, email: user.email}; }); } + + /** + * Validate activationToken token. + * + * @param {mongo.Account} user - User object. + * @param {string} activationToken - activate account token + * @return {Error} If token is invalid. + */ + static validateActivationToken(user, activationToken) { + if (user.activated) { + if (!_.isEmpty(activationToken) && user.activationToken !== activationToken) + return new errors.AuthFailedException('Invalid email or password!'); + } + else { + if (_.isEmpty(activationToken)) + return new errors.MissingConfirmRegistrationException(user.email); + + if (user.activationToken !== activationToken) + return new errors.AuthFailedException('This activation token isn\'t valid.'); + } + } + + /** + * Check if activation token expired. + * + * @param {mongo.Account} user - User object. + * @param {string} activationToken - activate account token + * @return {boolean} If token was already expired. + */ + static isActivationTokenExpired(user, activationToken) { + return !user.activated && + new Date().getTime() - user.activationSentAt.getTime() >= settings.activation.timeout; + } + + /** + * Reset password reset token for user. + * + * @param host Web Console host. + * @param email - user email. + * @returns {Promise}. + */ + static resetActivationToken(host, email) { + return mongo.Account.findOne({email}).exec() + .then((user) => { + if (!user) + throw new errors.MissingResourceException('Account with that email address does not exists!'); + + if (!settings.activation.enabled) + throw new errors.IllegalAccessError('Activation was not enabled!'); + + if (user.activationSentAt && + new Date().getTime() - user.activationSentAt.getTime() < settings.activation.sendTimeout) + throw new errors.IllegalAccessError('Too Many Activation Attempts!'); + + user.activationToken = utilsService.randomString(settings.tokenLength); + user.activationSentAt = new Date(); + + return user.save(); + }) + .then((user) => mailsService.emailUserActivation(host, user)); + } } return AuthService; diff --git a/modules/web-console/backend/services/downloads.js b/modules/web-console/backend/services/downloads.js index d7f616a5ae0e4..75548c883ecc8 100644 --- a/modules/web-console/backend/services/downloads.js +++ b/modules/web-console/backend/services/downloads.js @@ -67,6 +67,16 @@ module.exports.factory = (settings, agentsHnd, errors) => { prop.push('#node-login=ignite'); prop.push('#node-password=ignite'); prop.push('#driver-folder=./jdbc-drivers'); + prop.push('#Uncomment and configure following SSL options if needed:'); + prop.push('#node-key-store=client.jks'); + prop.push('#node-key-store-password=MY_PASSWORD'); + prop.push('#node-trust-store=ca.jks'); + prop.push('#node-trust-store-password=MY_PASSWORD'); + prop.push('#server-key-store=client.jks'); + prop.push('#server-key-store-password=MY_PASSWORD'); + prop.push('#server-trust-store=ca.jks'); + prop.push('#server-trust-store-password=MY_PASSWORD'); + prop.push('#cipher-suites=CIPHER1,CIPHER2,CIPHER3'); zip.file(`${folder}/default.properties`, prop.join('\n')); diff --git a/modules/web-console/backend/services/mails.js b/modules/web-console/backend/services/mails.js index e0737cd2a7500..183fbe1086e30 100644 --- a/modules/web-console/backend/services/mails.js +++ b/modules/web-console/backend/services/mails.js @@ -80,24 +80,52 @@ module.exports.factory = (settings) => { }); } + /** + * Send email when user signed up. + * + * @param host Web Console host. + * @param user User that signed up. + * @param createdByAdmin Whether user was created by admin. + */ + emailUserSignUp(host, user, createdByAdmin) { + const resetLink = `${host}/password/reset?token=${user.resetPasswordToken}`; + + const sbj = createdByAdmin + ? 'Account was created for' + : 'Thanks for signing up for'; + + const reason = createdByAdmin + ? 'administrator created account for you' + : 'you have signed up'; + + return this.send(user, `${sbj} ${settings.mail.greeting}.`, + `Hello ${user.firstName} ${user.lastName}!

    ` + + `You are receiving this email because ${reason} to use ${settings.mail.greeting}.

    ` + + 'If you do not know what this email is about, please ignore it.
    ' + + 'You may reset the password by clicking on the following link, or paste this into your browser:

    ' + + `${resetLink}`); + } + /** * Send email to user for password reset. + * * @param host * @param user */ - emailUserSignUp(host, user) { - const resetLink = `${host}/password/reset?token=${user.resetPasswordToken}`; + emailUserActivation(host, user) { + const activationLink = `${host}/signin?activationToken=${user.activationToken}`; - return this.send(user, `Thanks for signing up for ${settings.mail.greeting}.`, + return this.send(user, `Confirm your account on ${settings.mail.greeting}`, `Hello ${user.firstName} ${user.lastName}!

    ` + `You are receiving this email because you have signed up to use ${settings.mail.greeting}.

    ` + - 'If you have not done the sign up and do not know what this email is about, please ignore it.
    ' + - 'You may reset the password by clicking on the following link, or paste this into your browser:

    ' + - `${resetLink}`); + 'Please click on the following link, or paste this into your browser to activate your account:

    ' + + `${activationLink}`, + 'Failed to send email with confirm account link!'); } /** * Send email to user for password reset. + * * @param host * @param user */ diff --git a/modules/web-console/backend/services/users.js b/modules/web-console/backend/services/users.js index 43bceda3cd6d5..ecfdc0be8954b 100644 --- a/modules/web-console/backend/services/users.js +++ b/modules/web-console/backend/services/users.js @@ -42,16 +42,22 @@ module.exports.factory = (errors, settings, mongo, spacesService, mailsService, /** * Save profile information. * - * @param {String} host - The host - * @param {Object} user - The user + * @param {String} host - The host. + * @param {Object} user - The user. + * @param {Object} createdByAdmin - Whether user created by admin. * @returns {Promise.} that resolves account id of merge operation. */ - static create(host, user) { + static create(host, user, createdByAdmin) { return mongo.Account.count().exec() .then((cnt) => { user.admin = cnt === 0; user.registered = new Date(); user.token = utilsService.randomString(settings.tokenLength); + user.resetPasswordToken = utilsService.randomString(settings.tokenLength); + user.activated = false; + + if (settings.server.disableSignup && !user.admin && !createdByAdmin) + throw new errors.ServerErrorException('Sign-up is not allowed. Ask your Web Console administrator to create account for you.'); return new mongo.Account(user); }) @@ -69,28 +75,44 @@ module.exports.factory = (errors, settings, mongo, spacesService, mailsService, }); }) .then((registered) => { - registered.resetPasswordToken = utilsService.randomString(settings.tokenLength); + return mongo.Space.create({name: 'Personal space', owner: registered._id}) + .then(() => registered); + }) + .then((registered) => { + if (settings.activation.enabled) { + registered.activationToken = utilsService.randomString(settings.tokenLength); + registered.activationSentAt = new Date(); - return registered.save() - .then(() => mongo.Space.create({name: 'Personal space', owner: registered._id})) - .then(() => { - mailsService.emailUserSignUp(host, registered); + if (!createdByAdmin) { + return registered.save() + .then(() => { + mailsService.emailUserActivation(host, registered); - return registered; - }); + throw new errors.MissingConfirmRegistrationException(registered.email); + }); + } + } + + mailsService.emailUserSignUp(host, registered, createdByAdmin); + + return registered; }); } /** * Save user. * - * @param {Object} changed - The user + * @param userId User ID. + * @param {Object} changed Changed user. * @returns {Promise.} that resolves account id of merge operation. */ - static save(changed) { + static save(userId, changed) { delete changed.admin; + delete changed.activated; + delete changed.activationSentAt; + delete changed.activationToken; - return mongo.Account.findById(changed._id).exec() + return mongo.Account.findById(userId).exec() .then((user) => { if (!changed.password) return Promise.resolve(user); @@ -153,6 +175,7 @@ module.exports.factory = (errors, settings, mongo, spacesService, mailsService, country: 1, lastLogin: 1, lastActivity: 1, + activated: 1, spaces: { $filter: { input: '$spaces', diff --git a/modules/web-console/docker/compose/docker-compose.yml b/modules/web-console/docker/compose/docker-compose.yml index 109bfca85ab2d..15f2ae4de6436 100644 --- a/modules/web-console/docker/compose/docker-compose.yml +++ b/modules/web-console/docker/compose/docker-compose.yml @@ -15,7 +15,7 @@ # limitations under the License. # -version: 1 +version: '3' services: mongodb: @@ -50,7 +50,6 @@ services: image: apacheignite/web-console-frontend depends_on: - mongodb - - testenv ports: # Proxy HTTP nginx port (HOST_PORT:DOCKER_PORT) - 80:80 diff --git a/modules/web-console/e2e/testcafe/components/FormField.js b/modules/web-console/e2e/testcafe/components/FormField.js index 4ddfc6199124f..0c6c4ebab54f5 100644 --- a/modules/web-console/e2e/testcafe/components/FormField.js +++ b/modules/web-console/e2e/testcafe/components/FormField.js @@ -32,13 +32,12 @@ export class FormField { if (id) this._selector = Selector(`#${id}`).parent(this.constructor.ROOT_SELECTOR); else if (label) { - this._selector = Selector(() => { - return Array - .from(window.document.querySelectorAll(this.constructor.LABEL_SELECTOR)) - .filter((el) => el.textContent.contains(label)) - .map((el) => el.parent(this.constructor.ROOT_SELECTOR)) + this._selector = Selector((LABEL_SELECTOR, ROOT_SELECTOR, label) => { + return [].slice.call((window.document.querySelectorAll(LABEL_SELECTOR))) + .filter((el) => el.textContent.includes(label)) + .map((el) => el.closest(ROOT_SELECTOR)) .pop(); - }); + })(this.constructor.LABEL_SELECTOR, this.constructor.ROOT_SELECTOR, label); } else if (model) this._selector = AngularJSSelector.byModel(model).parent(this.constructor.ROOT_SELECTOR); @@ -63,6 +62,12 @@ export class FormField { // return this._selector.find(`.form-field__error`) return this._selector.find(`[ng-message="${errorType}"]`); } + get selectedOption() { + return this.control.textContent; + } + get postfix() { + return this._selector.find('[data-postfix]').getAttribute('data-postfix'); + } } /** @@ -72,4 +77,12 @@ export class CustomFormField extends FormField { static ROOT_SELECTOR = '.form-field'; static LABEL_SELECTOR = '.form-field__label'; static ERRORS_SELECTOR = '.form-field__errors'; + constructor(...args) { + super(...args); + this.errors = this.errors.addCustomMethods({ + hasError(errors, errorMessage) { + return !!errors.querySelectorAll(`.form-field__error [data-title*="${errorMessage}"]`).length; + } + }); + } } diff --git a/modules/web-console/e2e/testcafe/components/confirmation.js b/modules/web-console/e2e/testcafe/components/confirmation.js index b4fa2b5aa2719..cdfdd548415ff 100644 --- a/modules/web-console/e2e/testcafe/components/confirmation.js +++ b/modules/web-console/e2e/testcafe/components/confirmation.js @@ -17,10 +17,10 @@ import {Selector, t} from 'testcafe'; -const body = Selector('.modal-body'); +const body = Selector('.modal').withText('Confirmation').find('.modal-body'); const confirmButton = Selector('#confirm-btn-ok'); const cancelButton = Selector('#confirm-btn-cancel'); -const closeButton = Selector('.modal .close'); +const closeButton = Selector('.modal').withText('Confirmation').find('.modal .close'); export const confirmation = { body, diff --git a/modules/web-console/e2e/testcafe/components/topNavigation.js b/modules/web-console/e2e/testcafe/components/topNavigation.js index b4262d0f80661..6db745e741191 100644 --- a/modules/web-console/e2e/testcafe/components/topNavigation.js +++ b/modules/web-console/e2e/testcafe/components/topNavigation.js @@ -17,5 +17,7 @@ import {Selector} from 'testcafe'; -export const configureNavButton = Selector('.wch-nav-item').withText('Configure'); -export const queriesNavButton = Selector('.wch-nav-item').withText('Queries'); +export const toggleMenuButton = Selector('.web-console-header__togle-menu-button'); + +export const configureNavButton = Selector('.web-console-sidebar-navigation__link[title="Configuration"]'); +export const queriesNavButton = Selector('.web-console-sidebar-navigation__link[title="Queries"]'); diff --git a/modules/web-console/e2e/testcafe/components/userMenu.js b/modules/web-console/e2e/testcafe/components/userMenu.js index 75246c8d6cae4..973f21f184d86 100644 --- a/modules/web-console/e2e/testcafe/components/userMenu.js +++ b/modules/web-console/e2e/testcafe/components/userMenu.js @@ -17,7 +17,7 @@ import {Selector, t} from 'testcafe'; -const _selector = Selector('[ignite-userbar]'); +const _selector = Selector('user-menu'); export const userMenu = { _selector, diff --git a/modules/web-console/e2e/testcafe/environment/envtools.js b/modules/web-console/e2e/testcafe/environment/envtools.js index c86a34a254e71..095295134e9a6 100644 --- a/modules/web-console/e2e/testcafe/environment/envtools.js +++ b/modules/web-console/e2e/testcafe/environment/envtools.js @@ -146,6 +146,7 @@ const exec = (command, onResolveString, cwd, env) => { const startEnv = (webConsoleRootDirectoryPath = '../../') => { return new Promise(async(resolve) => { + const BACKEND_PORT = 3001; const command = `${process.platform === 'win32' ? 'npm.cmd' : 'npm'} start`; let port = 9001; @@ -153,8 +154,8 @@ const startEnv = (webConsoleRootDirectoryPath = '../../') => { if (process.env.APP_URL) port = parseInt(url.parse(process.env.APP_URL).port, 10) || 80; - const backendInstanceLaunch = exec(command, 'Start listening', `${webConsoleRootDirectoryPath}backend`, {server_port: 3001, mongodb_url: mongoUrl}); // Todo: refactor cwd for backend when it's linked - const frontendInstanceLaunch = exec(command, 'Compiled successfully', `${webConsoleRootDirectoryPath}frontend`, {BACKEND_PORT: 3001, PORT: port}); + const backendInstanceLaunch = exec(command, 'Start listening', `${webConsoleRootDirectoryPath}backend`, {server_port: BACKEND_PORT, mongodb_url: mongoUrl}); + const frontendInstanceLaunch = exec(command, 'Compiled successfully', `${webConsoleRootDirectoryPath}frontend`, {BACKEND_URL: `http://localhost:${BACKEND_PORT}`, PORT: port}); console.log('Building backend in progress...'); await backendInstanceLaunch; diff --git a/modules/web-console/e2e/testcafe/package.json b/modules/web-console/e2e/testcafe/package.json index 23d1b2707e1a5..6cba09e14020d 100644 --- a/modules/web-console/e2e/testcafe/package.json +++ b/modules/web-console/e2e/testcafe/package.json @@ -33,7 +33,7 @@ "objectid": "3.2.1", "path": "0.12.7", "sinon": "2.3.8", - "testcafe": "0.20.5", + "testcafe": "0.22.0", "testcafe-angular-selectors": "0.3.0", "testcafe-reporter-teamcity": "1.0.9", "type-detect": "4.0.3", diff --git a/modules/web-console/e2e/testcafe/page-models/pageSignup.js b/modules/web-console/e2e/testcafe/page-models/pageSignup.js index c380abed41907..83f2932b2c362 100644 --- a/modules/web-console/e2e/testcafe/page-models/pageSignup.js +++ b/modules/web-console/e2e/testcafe/page-models/pageSignup.js @@ -19,13 +19,13 @@ import {Selector, t} from 'testcafe'; import {CustomFormField} from '../components/FormField'; export const pageSignup = { - email: new CustomFormField({model: '$ctrl.data.email'}), - password: new CustomFormField({model: '$ctrl.data.password'}), - passwordConfirm: new CustomFormField({model: 'confirm'}), - firstName: new CustomFormField({model: '$ctrl.data.firstName'}), - lastName: new CustomFormField({model: '$ctrl.data.lastName'}), - company: new CustomFormField({model: '$ctrl.data.company'}), - country: new CustomFormField({model: '$ctrl.data.country'}), + email: new CustomFormField({id: 'emailInput'}), + password: new CustomFormField({id: 'passwordInput'}), + passwordConfirm: new CustomFormField({id: 'confirmInput'}), + firstName: new CustomFormField({id: 'firstNameInput'}), + lastName: new CustomFormField({id: 'lastNameInput'}), + company: new CustomFormField({id: 'companyInput'}), + country: new CustomFormField({id: 'countryInput'}), signupButton: Selector('button').withText('Sign Up'), async fillSignupForm({ email, diff --git a/modules/web-console/e2e/testcafe/testcafe-runner.js b/modules/web-console/e2e/testcafe/testcafe-runner.js index 681ee2ed0e758..eab767c03d0d1 100644 --- a/modules/web-console/e2e/testcafe/testcafe-runner.js +++ b/modules/web-console/e2e/testcafe/testcafe-runner.js @@ -42,7 +42,8 @@ const startTestcafe = (config) => { .browsers(config.browsers) .reporter(config.reporter) .run({ skipJsErrors: true }); - } catch (err) { + } + catch (err) { console.log(err); process.exit(1); diff --git a/modules/web-console/frontend/.eslintrc b/modules/web-console/frontend/.eslintrc index ac1a37f55df81..8f6bf20970b31 100644 --- a/modules/web-console/frontend/.eslintrc +++ b/modules/web-console/frontend/.eslintrc @@ -163,7 +163,6 @@ rules: no-unused-expressions: [2, { allowShortCircuit: true }] no-unused-vars: [0, {"vars": "all", "args": "after-used"}] typescript/no-unused-vars: [0] - no-use-before-define: 2 no-useless-call: 2 no-void: 0 no-var: 2 diff --git a/modules/web-console/frontend/app/app.config.js b/modules/web-console/frontend/app/app.config.js index e2bc057fc4ece..04c02ea02db20 100644 --- a/modules/web-console/frontend/app/app.config.js +++ b/modules/web-console/frontend/app/app.config.js @@ -15,13 +15,14 @@ * limitations under the License. */ -import _ from 'lodash'; import angular from 'angular'; + import negate from 'lodash/negate'; import isNil from 'lodash/isNil'; import isEmpty from 'lodash/isEmpty'; import mixin from 'lodash/mixin'; +import {user as userAction, register as registerStore} from './store'; const nonNil = negate(isNil); const nonEmpty = negate(isEmpty); @@ -36,6 +37,8 @@ import validationTemplateUrl from 'views/templates/validation-error.tpl.pug'; const igniteConsoleCfg = angular.module('ignite-console.config', ['ngAnimate', 'mgcrea.ngStrap']); +igniteConsoleCfg.run(registerStore); + // Configure AngularJS animation: do not animate fa-spin. igniteConsoleCfg.config(['$animateProvider', ($animateProvider) => { $animateProvider.classNameFilter(/^((?!(fa-spin|ng-animate-disabled)).)*$/); @@ -134,3 +137,6 @@ igniteConsoleCfg.directive('uiGridSelection', function() { }; }); +igniteConsoleCfg.run(['$rootScope', 'Store', ($root, store) => { + $root.$on('user', (event, user) => store.dispatch(userAction({...user}))); +}]); diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js index 98792c4c50bb8..94f97042f84f5 100644 --- a/modules/web-console/frontend/app/app.js +++ b/modules/web-console/frontend/app/app.js @@ -44,7 +44,6 @@ import './modules/configuration/configuration.module'; import './modules/getting-started/GettingStarted.provider'; import './modules/dialog/dialog.module'; import './modules/ace.module'; -import './modules/socket.module'; import './modules/loading/loading.module'; import servicesModule from './services'; // endignite @@ -96,6 +95,7 @@ import {CSV} from './services/CSV'; import {$exceptionHandler} from './services/exceptionHandler'; import IGFSs from './services/IGFSs'; import Models from './services/Models'; +import {Store} from './services/store'; import AngularStrapTooltip from './services/AngularStrapTooltip.decorator'; import AngularStrapSelect from './services/AngularStrapSelect.decorator'; @@ -112,6 +112,7 @@ import id8 from './filters/id8.filter'; // Components import igniteListOfRegisteredUsers from './components/list-of-registered-users'; +import dialogAdminCreateUser from './components/dialog-admin-create-user'; import IgniteActivitiesUserDialog from './components/activities-user-dialog'; import './components/input-dialog'; import webConsoleHeader from './components/web-console-header'; @@ -148,7 +149,8 @@ import progressLine from './components/progress-line'; import formField from './components/form-field'; import igniteChart from './components/ignite-chart'; import igniteChartSelector from './components/ignite-chart-series-selector'; -import igniteStatus from './components/ignite-status'; +import statusOutput from './components/status-output'; +import timedRedirection from './components/timed-redirection'; import pageProfile from './components/page-profile'; import pagePasswordChanged from './components/page-password-changed'; @@ -156,6 +158,10 @@ import pagePasswordReset from './components/page-password-reset'; import pageSignup from './components/page-signup'; import pageSignin from './components/page-signin'; import pageForgotPassword from './components/page-forgot-password'; +import formSignup from './components/form-signup'; +import sidebar from './components/web-console-sidebar'; +import permanentNotifications from './components/permanent-notifications'; +import signupConfirmation from './components/page-signup-confirmation'; import igniteServices from './services'; @@ -171,7 +177,6 @@ export default angular.module('ignite-console', [ 'ngSanitize', 'ngMessages', // Third party libs. - 'btford.socket-io', 'dndLists', 'gridster', 'mgcrea.ngStrap', @@ -195,7 +200,6 @@ export default angular.module('ignite-console', [ 'ignite-console.input-dialog', 'ignite-console.user', 'ignite-console.branding', - 'ignite-console.socket', 'ignite-console.agent', 'ignite-console.nodes', 'ignite-console.demo', @@ -245,6 +249,7 @@ export default angular.module('ignite-console', [ connectedClusters.name, connectedClustersDialog.name, igniteListOfRegisteredUsers.name, + dialogAdminCreateUser.name, pageProfile.name, pageLanding.name, pagePasswordChanged.name, @@ -258,9 +263,15 @@ export default angular.module('ignite-console', [ passwordVisibility.name, igniteChart.name, igniteChartSelector.name, - igniteStatus.name, + statusOutput.name, progressLine.name, - formField.name + formField.name, + formSignup.name, + timedRedirection.name, + sidebar.name, + permanentNotifications.name, + timedRedirection.name, + signupConfirmation.name ]) .service('$exceptionHandler', $exceptionHandler) // Directives. @@ -308,6 +319,7 @@ export default angular.module('ignite-console', [ .service('CSV', CSV) .service('IGFSs', IGFSs) .service('Models', Models) +.service('Store', Store) // Filters. .filter('byName', byName) .filter('bytes', bytes) diff --git a/modules/web-console/frontend/app/components/activities-user-dialog/activities-user-dialog.controller.js b/modules/web-console/frontend/app/components/activities-user-dialog/activities-user-dialog.controller.js index fb9d15a46b666..bd3bb0796669d 100644 --- a/modules/web-console/frontend/app/components/activities-user-dialog/activities-user-dialog.controller.js +++ b/modules/web-console/frontend/app/components/activities-user-dialog/activities-user-dialog.controller.js @@ -25,9 +25,9 @@ export default class ActivitiesCtrl { $ctrl.data = _.map(user.activitiesDetail, (amount, action) => ({action, amount})); $ctrl.columnDefs = [ - { displayName: 'Description', field: 'action', enableFiltering: false, cellFilter: 'translate'}, - { displayName: 'Action', field: 'action', enableFiltering: false}, - { displayName: 'Visited', field: 'amount', enableFiltering: false} + { displayName: 'Description', field: 'action', enableFiltering: false, cellFilter: 'translate', minWidth: 120, width: '43%'}, + { displayName: 'Action', field: 'action', enableFiltering: false, minWidth: 120, width: '43%'}, + { displayName: 'Visited', field: 'amount', enableFiltering: false, minWidth: 80} ]; } } diff --git a/modules/web-console/frontend/app/components/activities-user-dialog/activities-user-dialog.tpl.pug b/modules/web-console/frontend/app/components/activities-user-dialog/activities-user-dialog.tpl.pug index 7e9d3f5142364..511a37bfd9090 100644 --- a/modules/web-console/frontend/app/components/activities-user-dialog/activities-user-dialog.tpl.pug +++ b/modules/web-console/frontend/app/components/activities-user-dialog/activities-user-dialog.tpl.pug @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. -.modal.modal--ignite.theme--ignite(tabindex='-1' role='dialog') +.modal.modal--ignite.modal--wide.theme--ignite(tabindex='-1' role='dialog') .modal-dialog .modal-content .modal-header diff --git a/modules/web-console/frontend/app/components/bs-select-menu/style.scss b/modules/web-console/frontend/app/components/bs-select-menu/style.scss index ac3991b4957dc..ac3f7aa39f988 100644 --- a/modules/web-console/frontend/app/components/bs-select-menu/style.scss +++ b/modules/web-console/frontend/app/components/bs-select-menu/style.scss @@ -99,4 +99,4 @@ bottom: 0; left: 0; z-index: 1999; -} \ No newline at end of file +} diff --git a/modules/web-console/frontend/app/components/cluster-selector/controller.js b/modules/web-console/frontend/app/components/cluster-selector/controller.js index fb64b9f229eed..484a5eb4bc893 100644 --- a/modules/web-console/frontend/app/components/cluster-selector/controller.js +++ b/modules/web-console/frontend/app/components/cluster-selector/controller.js @@ -17,8 +17,8 @@ import _ from 'lodash'; -import { BehaviorSubject } from 'rxjs/BehaviorSubject'; -import 'rxjs/add/operator/combineLatest'; +import { BehaviorSubject } from 'rxjs'; +import {tap, filter, combineLatest} from 'rxjs/operators'; export default class { static $inject = ['AgentManager', 'IgniteConfirm', 'IgniteVersion', 'IgniteMessages']; @@ -46,15 +46,16 @@ export default class { this.inProgress$ = this._inProgressSubject.asObservable(); - this.clusters$ = this.agentMgr.connectionSbj - .combineLatest(this.inProgress$) - .do(([sbj, inProgress]) => this.inProgress = inProgress) - .filter(([sbj, inProgress]) => !inProgress) - .do(([{cluster, clusters}]) => { + this.clusters$ = this.agentMgr.connectionSbj.pipe( + combineLatest(this.inProgress$), + tap(([sbj, inProgress]) => this.inProgress = inProgress), + filter(([sbj, inProgress]) => !inProgress), + tap(([{cluster, clusters}]) => { this.cluster = cluster ? {...cluster} : null; this.clusters = _.orderBy(clusters, ['name'], ['asc']); }) - .subscribe(() => {}); + ) + .subscribe(() => {}); } $onDestroy() { diff --git a/modules/web-console/frontend/app/components/cluster-selector/template.pug b/modules/web-console/frontend/app/components/cluster-selector/template.pug index f1e80db67f2c4..39c1af29abada 100644 --- a/modules/web-console/frontend/app/components/cluster-selector/template.pug +++ b/modules/web-console/frontend/app/components/cluster-selector/template.pug @@ -45,7 +45,7 @@ span(data-ng-if='!$ctrl.isDemo && $ctrl.clusters.length > 1') aria-expanded='false' ) span(ng-if='!$ctrl.cluster') No clusters available - + span(ng-if='$ctrl.cluster') cluster-security-icon(secured='$ctrl.cluster.secured') | {{ $ctrl.cluster.name }} diff --git a/modules/web-console/frontend/app/components/connected-clusters-badge/controller.js b/modules/web-console/frontend/app/components/connected-clusters-badge/controller.js index 807c3ba8b7d65..896c02bd90b02 100644 --- a/modules/web-console/frontend/app/components/connected-clusters-badge/controller.js +++ b/modules/web-console/frontend/app/components/connected-clusters-badge/controller.js @@ -15,16 +15,20 @@ * limitations under the License. */ +import {tap} from 'rxjs/operators'; + export default class { - static $inject = ['AgentManager', 'ConnectedClustersDialog']; + static $inject = ['$scope', 'AgentManager', 'ConnectedClustersDialog']; connectedClusters = 0; /** + * @param $scope Angular scope. * @param {import('app/modules/agent/AgentManager.service').default} agentMgr * @param {import('../connected-clusters-dialog/service').default} connectedClustersDialog */ - constructor(agentMgr, connectedClustersDialog) { + constructor($scope, agentMgr, connectedClustersDialog) { + this.$scope = $scope; this.agentMgr = agentMgr; this.connectedClustersDialog = connectedClustersDialog; } @@ -36,10 +40,14 @@ export default class { } $onInit() { - this.connectedClusters$ = this.agentMgr.connectionSbj - .do(({ clusters }) => this.connectedClusters = clusters.length) - .do(({ clusters }) => this.clusters = clusters) - .subscribe(); + this.connectedClusters$ = this.agentMgr.connectionSbj.pipe( + tap(({ clusters }) => this.connectedClusters = clusters.length), + tap(({ clusters }) => { + this.clusters = clusters; + this.$scope.$applyAsync(); + }) + ) + .subscribe(); } $onDestroy() { diff --git a/modules/web-console/frontend/app/components/connected-clusters-badge/style.scss b/modules/web-console/frontend/app/components/connected-clusters-badge/style.scss index 3b2d202527ed7..e46e382a44c9c 100644 --- a/modules/web-console/frontend/app/components/connected-clusters-badge/style.scss +++ b/modules/web-console/frontend/app/components/connected-clusters-badge/style.scss @@ -18,26 +18,26 @@ connected-clusters { @import "./../../../public/stylesheets/variables.scss"; - div { - position: absolute; - top: 0; - right: 30px; + height: 100%; + display: flex; - display: flex; - align-items: center; - padding: 3px 10px; - - cursor: pointer; - color: white; - font-size: 12px; - line-height: 12px; + .connected-cluster-badge__count { + color: $ignite-brand-success; + margin-left: 5px; + } - background-color: $text-color; + button { + height: 100%; + width: 100%; + background: none !important; + border: none !important; + margin: 0 !important; + padding: 0 !important; + outline: none !important; - border-radius: 0 0 4px 4px; + display: flex; + align-items: center; - [ignite-icon] { - margin-right: 6px; - } + font-size: 14px; } } diff --git a/modules/web-console/frontend/app/components/connected-clusters-badge/template.pug b/modules/web-console/frontend/app/components/connected-clusters-badge/template.pug index 49224e5c778c5..dfb4bd9ccf51b 100644 --- a/modules/web-console/frontend/app/components/connected-clusters-badge/template.pug +++ b/modules/web-console/frontend/app/components/connected-clusters-badge/template.pug @@ -14,6 +14,5 @@ See the License for the specific language governing permissions and limitations under the License. -div(ng-click='$ctrl.show()') - svg(ignite-icon='connectedClusters') - | Connected clusters: {{ $ctrl.connectedClusters }} +button(type='button' ng-click='$ctrl.show()') + | My Connected Clusters: {{ $ctrl.connectedClusters }} diff --git a/modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/index.ts b/modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/index.ts new file mode 100644 index 0000000000000..c3f201f15b37a --- /dev/null +++ b/modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/index.ts @@ -0,0 +1,31 @@ +/* + * 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. + */ + +import {componentFactory, StatusLevel} from 'app/components/status-output'; + +export default componentFactory([ + { + level: StatusLevel.GREEN, + value: true, + label: 'Active' + }, + { + level: StatusLevel.RED, + value: false, + label: 'Not Active' + } +]); diff --git a/modules/web-console/frontend/app/components/connected-clusters-dialog/components/list/column-defs.js b/modules/web-console/frontend/app/components/connected-clusters-dialog/components/list/column-defs.js index ca5dc6b23f04e..6b25878d3e874 100644 --- a/modules/web-console/frontend/app/components/connected-clusters-dialog/components/list/column-defs.js +++ b/modules/web-console/frontend/app/components/connected-clusters-dialog/components/list/column-defs.js @@ -46,7 +46,7 @@ export default [ cellTemplate: `
    , + private IgniteFormUtils: ReturnType, + private loading: ReturnType + ) {} + + canSubmitForm(form: DialogAdminCreateUser['form']) { + return form.$error.server ? true : !form.$invalid; + } + + setServerError(error: DialogAdminCreateUser['serverError']) { + this.serverError = error; + } + + createUser() { + this.IgniteFormUtils.triggerValidation(this.form); + + this.setServerError(null); + + if (!this.canSubmitForm(this.form)) + return; + + this.loading.start('createUser'); + + this.Auth.signup(this.data, false) + .then(() => { + this.IgniteMessages.showInfo(`User ${this.data.email} created`); + this.close({}); + }) + .catch((res) => { + this.loading.finish('createUser'); + this.IgniteMessages.showError(null, res.data); + this.setServerError(res.data); + }); + } +} diff --git a/modules/web-console/frontend/app/components/dialog-admin-create-user/index.ts b/modules/web-console/frontend/app/components/dialog-admin-create-user/index.ts new file mode 100644 index 0000000000000..5a23368229030 --- /dev/null +++ b/modules/web-console/frontend/app/components/dialog-admin-create-user/index.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +import component from './component'; +import {registerState} from './state'; + +export default angular.module('ignite-console.dialog-admin-create-user', []) + .run(registerState) + .component('dialogAdminCreateUser', component); diff --git a/modules/web-console/frontend/app/components/dialog-admin-create-user/state.ts b/modules/web-console/frontend/app/components/dialog-admin-create-user/state.ts new file mode 100644 index 0000000000000..c64238e6c882d --- /dev/null +++ b/modules/web-console/frontend/app/components/dialog-admin-create-user/state.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +import {UIRouter} from '@uirouter/angularjs'; +import {dialogState} from '../../utils/dialogState'; + +registerState.$inject = ['$uiRouter']; + +export function registerState(router: UIRouter) { + router.stateRegistry.register({ + ...dialogState('dialog-admin-create-user'), + name: 'base.settings.admin.createUser', + url: '/create-user' + }); +} diff --git a/modules/web-console/frontend/app/components/dialog-admin-create-user/template.pug b/modules/web-console/frontend/app/components/dialog-admin-create-user/template.pug new file mode 100644 index 0000000000000..0a9f2b4c4b67c --- /dev/null +++ b/modules/web-console/frontend/app/components/dialog-admin-create-user/template.pug @@ -0,0 +1,37 @@ +//- + 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. + +.modal-dialog(ng-click='$event.stopPropagation()' ) + form.modal-content( + name='$ctrl.form' novalidate + ignite-loading='createUser' + ignite-loading-text='Creating user…' + ) + .modal-header + h4.modal-title Create User + + button.close(type='button' aria-label='Close' ng-click='$ctrl.close()') + svg(ignite-icon="cross") + .modal-body + form-signup( + outer-form='$ctrl.form' + ng-model='$ctrl.data' + server-error='$ctrl.serverError' + ) + .modal-footer + div + button.btn-ignite.btn-ignite--link-success(ng-click='$ctrl.close()') Cancel + button.btn-ignite.btn-ignite--success(ng-click='$ctrl.createUser()') Create user diff --git a/modules/web-console/frontend/app/components/form-field/components/form-field-size/controller.js b/modules/web-console/frontend/app/components/form-field/components/form-field-size/controller.js index 7663e9d0037fc..e158c0af9ae9e 100644 --- a/modules/web-console/frontend/app/components/form-field/components/form-field-size/controller.js +++ b/modules/web-console/frontend/app/components/form-field/components/form-field-size/controller.js @@ -28,6 +28,8 @@ export default class PCFormFieldSizeController { onScaleChange; /** @type {ng.IFormController} */ innerForm; + /** @type {boolean?} */ + autofocus; static $inject = ['$element', '$attrs']; @@ -38,6 +40,10 @@ export default class PCFormFieldSizeController { {label: 'Mb', value: 1024 * 1024}, {label: 'Gb', value: 1024 * 1024 * 1024} ], + gigabytes: [ + {label: 'Gb', value: 1}, + {label: 'Tb', value: 1024} + ], seconds: [ {label: 'ns', value: 1 / 1000}, {label: 'ms', value: 1}, @@ -61,7 +67,8 @@ export default class PCFormFieldSizeController { } $onDestroy() { - this.$element = null; + delete this.$element[0].focus; + this.$element = this.inputElement = null; } $onInit() { @@ -78,6 +85,8 @@ export default class PCFormFieldSizeController { this.ngModel.$validators.max = (value) => this.ngModel.$isEmpty(value) || value === void 0 || value <= this.max; this.ngModel.$validators.step = (value) => this.ngModel.$isEmpty(value) || value === void 0 || Math.floor(value) === value; + this.inputElement = this.$element[0].querySelector('input'); + this.$element[0].focus = () => this.inputElement.focus(); } $onChanges(changes) { @@ -137,4 +146,18 @@ export default class PCFormFieldSizeController { this.sizesMenu = PCFormFieldSizeController.sizeTypes.bytes; this.sizeScale = this.chooseSizeScale(); } + + notifyAboutError() { + if (this.$element) + this.$element.find('.form-field__error [bs-tooltip]').trigger('mouseenter'); + } + + hideError() { + if (this.$element) + this.$element.find('.form-field__error [bs-tooltip]').trigger('mouseleave'); + } + + triggerBlur() { + this.$element[0].dispatchEvent(new FocusEvent('blur', {relatedTarget: this.inputElement})); + } } diff --git a/modules/web-console/frontend/app/components/form-field/components/form-field-size/index.js b/modules/web-console/frontend/app/components/form-field/components/form-field-size/index.js index 5e08df2921194..e7da7d5df0acd 100644 --- a/modules/web-console/frontend/app/components/form-field/components/form-field-size/index.js +++ b/modules/web-console/frontend/app/components/form-field/components/form-field-size/index.js @@ -36,6 +36,7 @@ export default { sizeType: '@?', sizeScaleLabel: '@?', onScaleChange: '&?', - ngDisabled: ' { + el[0].removeEventListener('blur', onBlur); + onBlur = null; + }); + const off = scope.$on('$showValidationError', (e, target) => { if (target !== ngModel) return; @@ -32,6 +41,12 @@ export function directive($timeout) { bsCollapseTarget && bsCollapseTarget.open(); panelCollapsible && panelCollapsible.open(); + if (!onBlur && formFieldController) { + onBlur = () => formFieldController.hideError(); + + el[0].addEventListener('blur', onBlur, {passive: true}); + } + $timeout(() => { if (el[0].scrollIntoViewIfNeeded) el[0].scrollIntoViewIfNeeded(); @@ -39,9 +54,9 @@ export function directive($timeout) { el[0].scrollIntoView(); if (!attr.bsSelect) - $timeout(() => el[0].focus()); + $timeout(() => el[0].focus(), 100); - igniteFormField && igniteFormField.notifyAboutError(); + formFieldController && formFieldController.notifyAboutError(); }); }); } diff --git a/modules/web-console/frontend/app/components/form-signup/component.ts b/modules/web-console/frontend/app/components/form-signup/component.ts new file mode 100644 index 0000000000000..79863db09c84b --- /dev/null +++ b/modules/web-console/frontend/app/components/form-signup/component.ts @@ -0,0 +1,32 @@ +/* + * 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. + */ + +import template from './template.pug'; +import './style.scss'; +import {FormSignup} from './controller'; + +export const component: ng.IComponentOptions = { + template, + controller: FormSignup, + bindings: { + outerForm: '<', + serverError: '<' + }, + require: { + ngModel: 'ngModel' + } +}; diff --git a/modules/web-console/frontend/app/components/form-signup/controller.ts b/modules/web-console/frontend/app/components/form-signup/controller.ts new file mode 100644 index 0000000000000..eedf6d0ca0b07 --- /dev/null +++ b/modules/web-console/frontend/app/components/form-signup/controller.ts @@ -0,0 +1,46 @@ +/* + * 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. + */ + +import CountriesService from '../../services/Countries.service'; +import {ISignupFormController} from '.'; + +export class FormSignup implements ng.IPostLink, ng.IOnDestroy, ng.IOnChanges { + static $inject = ['IgniteCountries']; + + constructor(private Countries: ReturnType) {} + + countries = this.Countries.getAll(); + + innerForm: ISignupFormController; + outerForm: ng.IFormController; + ngModel: ng.INgModelController; + serverError: string | null = null; + + $postLink() { + this.outerForm.$addControl(this.innerForm); + this.innerForm.email.$validators.server = () => !this.serverError; + } + + $onDestroy() { + this.outerForm.$removeControl(this.innerForm); + } + + $onChanges(changes: {serverError: ng.IChangesObject}) { + if (changes.serverError && this.innerForm) + this.innerForm.email.$validate(); + } +} diff --git a/modules/web-console/frontend/app/components/page-signup/types.ts b/modules/web-console/frontend/app/components/form-signup/index.ts similarity index 89% rename from modules/web-console/frontend/app/components/page-signup/types.ts rename to modules/web-console/frontend/app/components/form-signup/index.ts index 49e8d5d15072b..1798aa0ae0ea6 100644 --- a/modules/web-console/frontend/app/components/page-signup/types.ts +++ b/modules/web-console/frontend/app/components/form-signup/index.ts @@ -15,6 +15,11 @@ * limitations under the License. */ +import {component} from './component'; + +export default angular.module('ignite-console.form-signup', []) + .component('formSignup', component); + export interface ISignupData { email: string, password: string, diff --git a/modules/web-console/frontend/app/components/web-console-footer/components/web-console-footer-links/style.scss b/modules/web-console/frontend/app/components/form-signup/style.scss similarity index 77% rename from modules/web-console/frontend/app/components/web-console-footer/components/web-console-footer-links/style.scss rename to modules/web-console/frontend/app/components/form-signup/style.scss index 47b88af82c7c3..e80b5108131ef 100644 --- a/modules/web-console/frontend/app/components/web-console-footer/components/web-console-footer-links/style.scss +++ b/modules/web-console/frontend/app/components/form-signup/style.scss @@ -1,4 +1,4 @@ -/*! +/* * 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. @@ -15,17 +15,17 @@ * limitations under the License. */ -web-console-footer-links { - margin-left: auto; +form-signup { + .form-signup__grid { + display: grid; + grid-gap: 10px; + grid-template-columns: 1fr 1fr; - a + a { - margin-left: 5px; - - &:before { - content: '|'; - display: inline-block; - margin-right: 5px; - color: #fafafa; + .span-1 { + grid-column: span 1; + } + .span-2 { + grid-column: span 2; } } } diff --git a/modules/web-console/frontend/app/components/form-signup/template.pug b/modules/web-console/frontend/app/components/form-signup/template.pug new file mode 100644 index 0000000000000..b9ed94821a2f4 --- /dev/null +++ b/modules/web-console/frontend/app/components/form-signup/template.pug @@ -0,0 +1,105 @@ +//- + 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. + +include /app/helpers/jade/mixins + +.form-signup__grid(ng-form='signup' ng-ref='$ctrl.innerForm' ng-ref-read='form') + .span-2 + +form-field__email({ + label: 'Email:', + model: '$ctrl.ngModel.$viewValue.email', + name: '"email"', + placeholder: 'Input email', + required: true + })( + ng-model-options='{allowInvalid: true}' + autocomplete='email' + ignite-auto-focus + ) + +form-field__error({error: 'server', message: `{{$ctrl.serverError}}`}) + .span-1 + +form-field__password({ + label: 'Password:', + model: '$ctrl.ngModel.$viewValue.password', + name: '"password"', + placeholder: 'Input password', + required: true + })( + autocomplete='new-password' + ) + .span-1 + +form-field__password({ + label: 'Confirm:', + model: 'confirm', + name: '"confirm"', + placeholder: 'Confirm password', + required: true + })( + ignite-match='$ctrl.ngModel.$viewValue.password' + autocomplete='off' + ) + .span-1 + +form-field__text({ + label: 'First name:', + model: '$ctrl.ngModel.$viewValue.firstName', + name: '"firstName"', + placeholder: 'Input first name', + required: true + })( + autocomplete='given-name' + ) + .span-1 + +form-field__text({ + label: 'Last name:', + model: '$ctrl.ngModel.$viewValue.lastName', + name: '"lastName"', + placeholder: 'Input last name', + required: true + })( + autocomplete='family-name' + ) + .span-1 + +form-field__phone({ + label: 'Phone:', + model: '$ctrl.ngModel.$viewValue.phone', + name: '"phone"', + placeholder: 'Input phone (ex.: +15417543010)', + optional: true + })( + autocomplete='tel' + ) + .span-1 + +form-field__dropdown({ + label: 'Country/Region:', + model: '$ctrl.ngModel.$viewValue.country', + name: '"country"', + required: true, + placeholder: 'Choose your country', + options: '$ctrl.countries' + })( + autocomplete='country' + ) + .span-2 + +form-field__text({ + label: 'Company:', + model: '$ctrl.ngModel.$viewValue.company', + name: '"company"', + placeholder: 'Input company name', + required: true + })( + ignite-on-enter-focus-move='countryInput' + autocomplete='organization' + ) diff --git a/modules/web-console/frontend/app/components/ignite-chart/controller.js b/modules/web-console/frontend/app/components/ignite-chart/controller.js index 79156fc8110c1..b6112502559c1 100644 --- a/modules/web-console/frontend/app/components/ignite-chart/controller.js +++ b/modules/web-console/frontend/app/components/ignite-chart/controller.js @@ -21,22 +21,13 @@ import _ from 'lodash'; * @typedef {{x: number, y: {[key: string]: number}}} IgniteChartDataPoint */ -const RANGE_RATE_PRESET = [{ - label: '1 min', - value: 1 -}, { - label: '5 min', - value: 5 -}, { - label: '10 min', - value: 10 -}, { - label: '15 min', - value: 15 -}, { - label: '30 min', - value: 30 -}]; +const RANGE_RATE_PRESET = [ + {label: '1 min', value: 1}, + {label: '5 min', value: 5}, + {label: '10 min', value: 10}, + {label: '15 min', value: 15}, + {label: '30 min', value: 30} +]; export class IgniteChartController { /** @type {import('chart.js').ChartConfiguration} */ @@ -96,6 +87,7 @@ export class IgniteChartController { if ((changes.chartDataPoint && _.isNil(changes.chartDataPoint.currentValue)) || (changes.chartHistory && _.isEmpty(changes.chartHistory.currentValue))) { this.clearDatasets(); + this.localHistory = []; return; } @@ -227,7 +219,8 @@ export class IgniteChartController { duration: this.currentRange.value * 1000 * 60, frameRate: 1000 / this.refreshRate || 1 / 3, refresh: this.refreshRate || 3000, - ttl: this.maxRangeInMilliseconds, + // Temporary workaround before https://github.com/nagix/chartjs-plugin-streaming/issues/53 resolved. + // ttl: this.maxRangeInMilliseconds, onRefresh: () => { this.onRefresh(); } @@ -308,6 +301,24 @@ export class IgniteChartController { this.config.data.datasets[datasetIndex].fill = false; } }); + + // Temporary workaround before https://github.com/nagix/chartjs-plugin-streaming/issues/53 resolved. + this.pruneHistory(); + } + + // Temporary workaround before https://github.com/nagix/chartjs-plugin-streaming/issues/53 resolved. + pruneHistory() { + if (!this.xRangeUpdateInProgress) { + const currenTime = Date.now(); + + while (currenTime - this.localHistory[0].x > this.maxRangeInMilliseconds) + this.localHistory.shift(); + + this.config.data.datasets.forEach((dataset) => { + while (currenTime - dataset.data[0].x > this.maxRangeInMilliseconds) + dataset.data.shift(); + }); + } } /** @@ -346,6 +357,8 @@ export class IgniteChartController { changeXRange(range) { if (this.chart) { + this.xRangeUpdateInProgress = true; + this.chart.config.options.plugins.streaming.duration = range.value * 60 * 1000; this.clearDatasets(); @@ -353,6 +366,8 @@ export class IgniteChartController { this.onRefresh(); this.rerenderChart(); + + this.xRangeUpdateInProgress = false; } } diff --git a/modules/web-console/frontend/app/components/input-dialog/input-dialog.service.js b/modules/web-console/frontend/app/components/input-dialog/input-dialog.service.js deleted file mode 100644 index 6ddf051290e13..0000000000000 --- a/modules/web-console/frontend/app/components/input-dialog/input-dialog.service.js +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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. - */ - -import _ from 'lodash'; -import controller from './input-dialog.controller'; -import templateUrl from './input-dialog.tpl.pug'; -import {CancellationError} from 'app/errors/CancellationError'; - -export default class InputDialog { - static $inject = ['$modal', '$q']; - - /** - * @param {mgcrea.ngStrap.modal.IModalService} $modal - * @param {ng.IQService} $q - */ - constructor($modal, $q) { - this.$modal = $modal; - this.$q = $q; - } - - /** - * Fabric for creating modal instance with different input types. - * - * @param {Object} args Options for rendering inputs: - * @param {'text'|'number'} args.mode Input type. - * @param {String} args.title Dialog title. - * @param {String} args.label Input field label. - * @param {String} args.tip Message for tooltip in label. - * @param {String|Number} args.value Default value. - * @param {String} args.placeholder Placeholder for input. - * @param {Function} [args.toValidValue] Validator function. - * @param {Number} args.min Min value for number input. - * @param {Number} args.max Max value for number input. - * @param {String} args.postfix Postfix for units in numer input. - * @return {Promise.} User input. - */ - dialogFabric(args) { - const deferred = this.$q.defer(); - - const modal = this.$modal({ - templateUrl, - resolve: { - deferred: () => deferred, - ui: () => args - }, - controller, - controllerAs: 'ctrl' - }); - - const modalHide = modal.hide; - - modal.hide = () => deferred.reject(new CancellationError()); - - return deferred.promise - .finally(modalHide); - } - - /** - * Open input dialog to configure custom value. - * - * @param {String} title Dialog title. - * @param {String} label Input field label. - * @param {String} value Default value. - * @param {Function} [toValidValue] Validator function. - * @param {'text'|'number'} mode Input type. - * @returns {ng.IPromise} User input. - */ - input(title, label, value, toValidValue, mode = 'text') { - return this.dialogFabric({title, label, value, toValidValue, mode}); - } - - /** - * Open input dialog to configure cloned object name. - * - * @param {String} srcName Name of source object. - * @param {Array.} names List of already exist names. - * @returns {ng.IPromise} New name. - */ - clone(srcName, names) { - const uniqueName = (value) => { - let num = 1; - let tmpName = value; - - while (_.includes(names, tmpName)) { - tmpName = `${value}_${num}`; - - num++; - } - - return tmpName; - }; - - return this.input('Clone', 'New name', uniqueName(srcName), uniqueName); - } - - /** - * Open input dialog to configure custom number value. - * - * @param {Object} options Object with settings for rendering number input. - * @returns {Promise.} User input. - */ - number(options) { - return this.dialogFabric({mode: 'number', ...options}); - } -} diff --git a/modules/web-console/frontend/app/components/input-dialog/input-dialog.service.ts b/modules/web-console/frontend/app/components/input-dialog/input-dialog.service.ts new file mode 100644 index 0000000000000..b2a241fb9206a --- /dev/null +++ b/modules/web-console/frontend/app/components/input-dialog/input-dialog.service.ts @@ -0,0 +1,172 @@ +/* + * 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. + */ + +import _ from 'lodash'; +import controller from './input-dialog.controller'; +import templateUrl from './input-dialog.tpl.pug'; +import {CancellationError} from 'app/errors/CancellationError'; + +type InputModes = 'text' | 'number' | 'email' | 'date' | 'time' | 'date-and-time'; + +interface ValidationFunction { + (value: T): boolean +} + +/** + * Options for rendering inputs. + */ +interface InputOptions { + /** Input type. */ + mode?: InputModes, + /** Dialog title. */ + title?: string, + /** Input field label. */ + label?: string, + /** Message for tooltip in label. */ + tip?: string, + /** Default value. */ + value: T, + /** Placeholder for input. */ + placeholder?: string, + /** Validator function. */ + toValidValue?: ValidationFunction, + /** Min value for number input. */ + min?: number, + /** Max value for number input. */ + max?: number, + /** Postfix for units in number input. */ + postfix?: string +} + +export default class InputDialog { + static $inject = ['$modal', '$q']; + + constructor(private $modal: mgcrea.ngStrap.modal.IModalService, private $q: ng.IQService) {} + + /** + * Fabric for creating modal instance with different input types. + * + * @returns User input. + */ + private dialogFabric(args: InputOptions) { + const deferred = this.$q.defer(); + + const modal = this.$modal({ + templateUrl, + resolve: { + deferred: () => deferred, + ui: () => args + }, + controller, + controllerAs: 'ctrl' + }); + + const modalHide = modal.hide; + + modal.hide = () => deferred.reject(new CancellationError()); + + return deferred.promise + .finally(modalHide); + } + + /** + * Open input dialog to configure custom value. + * + * @param title Dialog title. + * @param label Input field label. + * @param value Default value. + * @param toValidValue Validator function. + * @param mode Input type. + */ + input(title: string, label: string, value: T, toValidValue?: ValidationFunction, mode: InputModes = 'text') { + return this.dialogFabric({title, label, value, toValidValue, mode}); + } + + /** + * Open input dialog to configure cloned object name. + * + * @param srcName Name of source object. + * @param names List of already exist names. + * @returns New name. + */ + clone(srcName: string, names: Array) { + const uniqueName = (value) => { + let num = 1; + let tmpName = value; + + while (_.includes(names, tmpName)) { + tmpName = `${value}_${num}`; + + num++; + } + + return tmpName; + }; + + return this.input('Clone', 'New name', uniqueName(srcName), uniqueName); + } + + /** + * Open input dialog to configure custom number value. + * + * @param options Object with settings for rendering number input. + * @returns User input. + */ + number(options: InputOptions) { + return this.dialogFabric({mode: 'number', ...options}); + } + + /** + * Open input dialog to configure custom e-mail. + * + * @param options Object with settings for rendering e-mail input. + * @return User input. + */ + email(options: InputOptions) { + return this.dialogFabric({mode: 'email', ...options}); + } + + /** + * Open input dialog to configure custom date value. + * + * @param options Settings for rendering date input. + * @returns User input. + */ + date(options: InputOptions) { + return this.dialogFabric({mode: 'date', ...options}); + } + + /** + * Open input dialog to configure custom time value. + * + * @param options Settings for rendering time input. + * @returns User input. + */ + time(options: InputOptions) { + return this.dialogFabric({mode: 'time', ...options}); + } + + /** + * Open input dialog to configure custom date and time value. + * + * @param options Settings for rendering date and time inputs. + * @returns User input. + */ + dateTime(options: InputOptions) { + return this.dialogFabric({mode: 'date-and-time', ...options}); + } +} diff --git a/modules/web-console/frontend/app/components/input-dialog/input-dialog.tpl.pug b/modules/web-console/frontend/app/components/input-dialog/input-dialog.tpl.pug index 95cb059ba6ff9..23896e78d5840 100644 --- a/modules/web-console/frontend/app/components/input-dialog/input-dialog.tpl.pug +++ b/modules/web-console/frontend/app/components/input-dialog/input-dialog.tpl.pug @@ -21,7 +21,6 @@ include /app/helpers/jade/mixins form.modal-content(name='ctrl.form' novalidate) .modal-header h4.modal-title - i.fa.fa-clone span {{ ctrl.options.title }} button.close(type='button' aria-label='Close' ng-click='$hide()') svg(ignite-icon="cross") @@ -39,6 +38,7 @@ include /app/helpers/jade/mixins ignite-form-field-input-autofocus='true' ignite-on-enter='form.$valid && ctrl.confirm()' ) + .row(ng-switch-when='number') .col-100 +form-field__number({ @@ -53,6 +53,55 @@ include /app/helpers/jade/mixins required: true }) + .row(ng-switch-when='email') + .col-100 + +form-field__email({ + label: '{{ ctrl.options.label }}', + model: 'ctrl.options.value', + name: '"email"', + required: true, + placeholder: 'Input email' + })( + ignite-form-field-input-autofocus='true' + ignite-on-enter='form.$valid && ctrl.confirm()' + ) + + .row(ng-switch-when='date') + .col-100 + .form-field--inline + +form-field__datepicker({ + label: '{{ ctrl.options.label }}', + model: 'ctrl.options.value', + name: '"date"', + minview: 0, + format: 'dd/MM/yyyy' + }) + + .row(ng-switch-when='time') + .col-100 + .form-field--inline + +form-field__timepicker({ + label: '{{ ctrl.options.label }}', + model: 'ctrl.options.value', + name: '"time"' + }) + + .row(ng-switch-when='date-and-time') + .col-100 + .form-field--inline + +form-field__datepicker({ + label: '{{ ctrl.options.label }}', + model: 'ctrl.options.value', + name: '"date"', + minview: 0, + format: 'dd/MM/yyyy' + }) + .form-field--inline + +form-field__timepicker({ + model: 'ctrl.options.value', + format: '{{ ctrl.options.format }}', + name: '"time"' + }) .modal-footer div button#copy-btn-cancel.btn-ignite.btn-ignite--link-success(ng-click='$hide()') Cancel diff --git a/modules/web-console/frontend/app/components/list-editable/components/list-editable-cols/row.directive.js b/modules/web-console/frontend/app/components/list-editable/components/list-editable-cols/row.directive.js index 2753263ef03b3..8f3833119d8ce 100644 --- a/modules/web-console/frontend/app/components/list-editable/components/list-editable-cols/row.directive.js +++ b/modules/web-console/frontend/app/components/list-editable/components/list-editable-cols/row.directive.js @@ -15,6 +15,8 @@ * limitations under the License. */ +import {nonEmpty} from 'app/utils/lodashMixins'; + import {ListEditableColsController} from './cols.directive'; /** @returns {ng.IDirective} */ @@ -35,7 +37,8 @@ export default function() { el.addClass(ctrl.rowClass); ctrl.colDefs.forEach(({ cellClass }, index) => { - _.forEach((Array.isArray(cellClass) ? cellClass : [cellClass]), (item) => children[index].classList.add(item)); + if (nonEmpty(cellClass)) + children[index].classList.add(...(Array.isArray(cellClass) ? cellClass : cellClass.split(' '))); }); } }; diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/categories.js b/modules/web-console/frontend/app/components/list-of-registered-users/categories.js index e73dd17c0f8f9..aa70863f5e536 100644 --- a/modules/web-console/frontend/app/components/list-of-registered-users/categories.js +++ b/modules/web-console/frontend/app/components/list-of-registered-users/categories.js @@ -19,6 +19,7 @@ export default [ {name: 'Actions', visible: false, enableHiding: false}, {name: 'User', visible: true, enableHiding: false}, {name: 'Email', visible: true, enableHiding: true}, + {name: 'Activated', visible: false, enableHiding: true}, {name: 'Company', visible: true, enableHiding: true}, {name: 'Country', visible: true, enableHiding: true}, {name: 'Last login', visible: false, enableHiding: true}, diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/column-defs.js b/modules/web-console/frontend/app/components/list-of-registered-users/column-defs.js index 419a0636f23aa..b1c71f78448b1 100644 --- a/modules/web-console/frontend/app/components/list-of-registered-users/column-defs.js +++ b/modules/web-console/frontend/app/components/list-of-registered-users/column-defs.js @@ -25,36 +25,14 @@ const MODEL_HEADER_TEMPLATE = `
    ${ICON_SORT}
    `; const IGFS_HEADER_TEMPLATE = `
    ${ICON_SORT}
    `; -const ACTIONS_TEMPLATE = ` -`; - const EMAIL_TEMPLATE = ''; const DATE_WITH_TITLE = '
    '; const VALUE_WITH_TITLE = '
    '; export default [ - {name: 'actions', enableHiding: false, displayName: 'Actions', categoryDisplayName: 'Actions', cellTemplate: ACTIONS_TEMPLATE, field: 'actions', minWidth: 70, width: 70, enableFiltering: false, enableSorting: false, visible: false}, {name: 'user', enableHiding: false, displayName: 'User', categoryDisplayName: 'User', field: 'userName', cellTemplate: USER_TEMPLATE, minWidth: 160, enableFiltering: true, pinnedLeft: true, filter: { placeholder: 'Filter by name...' }}, {name: 'email', displayName: 'Email', categoryDisplayName: 'Email', field: 'email', cellTemplate: EMAIL_TEMPLATE, minWidth: 160, width: 220, enableFiltering: true, filter: { placeholder: 'Filter by email...' }}, + {name: 'activated', displayName: 'Activated', categoryDisplayName: 'Activated', field: 'activated', width: 220, enableFiltering: true, filter: { placeholder: 'Filter by activation...' }, visible: false}, {name: 'company', displayName: 'Company', categoryDisplayName: 'Company', field: 'company', cellTemplate: VALUE_WITH_TITLE, minWidth: 180, enableFiltering: true, filter: { placeholder: 'Filter by company...' }}, {name: 'country', displayName: 'Country', categoryDisplayName: 'Country', field: 'countryCode', cellTemplate: VALUE_WITH_TITLE, minWidth: 160, enableFiltering: true, filter: { placeholder: 'Filter by country...' }}, {name: 'lastlogin', displayName: 'Last login', categoryDisplayName: 'Last login', field: 'lastLogin', cellTemplate: DATE_WITH_TITLE, minWidth: 135, width: 135, enableFiltering: false, visible: false}, diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/controller.js b/modules/web-console/frontend/app/components/list-of-registered-users/controller.js index f8b2797359f52..6a7e098df0f55 100644 --- a/modules/web-console/frontend/app/components/list-of-registered-users/controller.js +++ b/modules/web-console/frontend/app/components/list-of-registered-users/controller.js @@ -15,11 +15,13 @@ * limitations under the License. */ -import headerTemplate from 'app/primitives/ui-grid-header/index.tpl.pug'; +import _ from 'lodash'; import columnDefs from './column-defs'; import categories from './categories'; +import headerTemplate from 'app/primitives/ui-grid-header/index.tpl.pug'; + const rowTemplate = `
    $ctrl.user = user); - - const becomeUser = () => { - const user = this.gridApi.selection.legacyGetSelectedRows()[0]; - - AdminData.becomeUser(user._id) - .then(() => User.load()) - .then(() => $state.go('default-state')) - .then(() => NotebookData.load()); - }; - - const removeUser = () => { - const user = this.gridApi.selection.legacyGetSelectedRows()[0]; - - Confirm.confirm(`Are you sure you want to remove user: "${user.userName}"?`) - .then(() => AdminData.removeUser(user)) - .then(() => { - const i = _.findIndex($ctrl.gridOptions.data, (u) => u._id === user._id); + this.uiGridPinningConstants = uiGridPinningConstants; + this.uiGridGroupingConstants = uiGridGroupingConstants; - if (i >= 0) { - $ctrl.gridOptions.data.splice(i, 1); - $ctrl.gridApi.selection.clearSelectedRows(); - } - - $ctrl.adjustHeight($ctrl.gridOptions.data.length); - - return $ctrl._refreshRows(); - }); - }; - - const toggleAdmin = () => { - const user = this.gridApi.selection.legacyGetSelectedRows()[0]; - - if (user.adminChanging) - return; - - user.adminChanging = true; - - AdminData.toggleAdmin(user) - .finally(() => { - $ctrl._updateSelected(); - - user.adminChanging = false; - }); - }; - - const showActivities = () => { - const user = this.gridApi.selection.legacyGetSelectedRows()[0]; - - return new ActivitiesUserDialog({ user }); - }; + User.read().then((user) => this.user = user); const companiesExcludeFilter = (renderableRows) => { - if (_.isNil($ctrl.params.companiesExclude)) + if (_.isNil(this.params.companiesExclude)) return renderableRows; _.forEach(renderableRows, (row) => { - row.visible = _.isEmpty($ctrl.params.companiesExclude) || - row.entity.company.toLowerCase().indexOf($ctrl.params.companiesExclude.toLowerCase()) === -1; + row.visible = _.isEmpty(this.params.companiesExclude) || + row.entity.company.toLowerCase().indexOf(this.params.companiesExclude.toLowerCase()) === -1; }); return renderableRows; }; - $ctrl.actionOptions = [ + this.actionOptions = [ { action: 'Become this user', - click: becomeUser.bind(this), + click: () => this.becomeUser(), available: true }, { action: 'Revoke admin', - click: toggleAdmin.bind(this), + click: () => this.toggleAdmin(), available: true }, { action: 'Grant admin', - click: toggleAdmin.bind(this), + click: () => this.toggleAdmin(), available: false }, + { + action: 'Add user', + sref: '.createUser', + available: true + }, { action: 'Remove user', - click: removeUser.bind(this), + click: () => this.removeUser(), available: true }, { action: 'Activity detail', - click: showActivities.bind(this), + click: () => this.showActivities(), available: true } ]; - $ctrl._userGridOptions = { + this._userGridOptions = { columnDefs, categories }; - $ctrl.gridOptions = { + this.gridOptions = { data: [], columnDefs, @@ -176,18 +138,18 @@ export default class IgniteListOfRegisteredUsersCtrl { rowIdentity: (row) => row._id, getRowIdentity: (row) => row._id, onRegisterApi: (api) => { - $ctrl.gridApi = api; + this.gridApi = api; - api.selection.on.rowSelectionChanged($scope, $ctrl._updateSelected.bind($ctrl)); - api.selection.on.rowSelectionChangedBatch($scope, $ctrl._updateSelected.bind($ctrl)); + api.selection.on.rowSelectionChanged($scope, this._updateSelected.bind(this)); + api.selection.on.rowSelectionChangedBatch($scope, this._updateSelected.bind(this)); - api.core.on.filterChanged($scope, $ctrl._filteredRows.bind($ctrl)); - api.core.on.rowsVisibleChanged($scope, $ctrl._filteredRows.bind($ctrl)); + api.core.on.filterChanged($scope, this._filteredRows.bind(this)); + api.core.on.rowsVisibleChanged($scope, this._filteredRows.bind(this)); api.grid.registerRowsProcessor(companiesExcludeFilter, 50); - $scope.$watch(() => $ctrl.gridApi.grid.getVisibleRows().length, (rows) => $ctrl.adjustHeight(rows)); - $scope.$watch(() => $ctrl.params.companiesExclude, () => $ctrl.gridApi.grid.refreshRows()); + $scope.$watch(() => this.gridApi.grid.getVisibleRows().length, (rows) => this.adjustHeight(rows)); + $scope.$watch(() => this.params.companiesExclude, () => this.gridApi.grid.refreshRows()); } }; @@ -197,20 +159,20 @@ export default class IgniteListOfRegisteredUsersCtrl { const reloadUsers = (params) => { AdminData.loadUsers(params) .then((data) => { - $ctrl.gridOptions.data = data; + this.gridOptions.data = data; - $ctrl.companies = _.values(_.groupBy(data, 'company')); - $ctrl.countries = _.values(_.groupBy(data, 'countryCode')); + this.companies = _.values(_.groupBy(data, 'company')); + this.countries = _.values(_.groupBy(data, 'countryCode')); - $ctrl._refreshRows(); + this._refreshRows(); }); }; const filterDates = _.debounce(() => { - const sdt = $ctrl.params.startDate; - const edt = $ctrl.params.endDate; + const sdt = this.params.startDate; + const edt = this.params.endDate; - $ctrl.exporterCsvFilename = `web_console_users_${dtFilter(sdt, 'yyyy_MM')}.csv`; + this.exporterCsvFilename = `web_console_users_${dtFilter(sdt, 'yyyy_MM')}.csv`; const startDate = Date.UTC(sdt.getFullYear(), sdt.getMonth(), 1); const endDate = Date.UTC(edt.getFullYear(), edt.getMonth() + 1, 1); @@ -218,8 +180,9 @@ export default class IgniteListOfRegisteredUsersCtrl { reloadUsers({ startDate, endDate }); }, 250); - $scope.$watch(() => $ctrl.params.startDate, filterDates); - $scope.$watch(() => $ctrl.params.endDate, filterDates); + $scope.$on('userCreated', filterDates); + $scope.$watch(() => this.params.startDate, filterDates); + $scope.$watch(() => this.params.endDate, filterDates); } adjustHeight(rows) { @@ -233,36 +196,95 @@ export default class IgniteListOfRegisteredUsersCtrl { _filteredRows() { const filtered = _.filter(this.gridApi.grid.rows, ({ visible}) => visible); - const entities = _.map(filtered, 'entity'); - this.filteredRows = entities; + this.filteredRows = _.map(filtered, 'entity'); } _updateSelected() { const ids = this.gridApi.selection.legacyGetSelectedRows().map(({ _id }) => _id).sort(); + if (!_.isEqual(ids, this.selected)) + this.selected = ids; + if (ids.length) { const user = this.gridApi.selection.legacyGetSelectedRows()[0]; const other = this.user._id !== user._id; - this.actionOptions[1].available = other && user.admin; - this.actionOptions[2].available = other && !user.admin; - - this.actionOptions[0].available = other; - this.actionOptions[3].available = other; + this.actionOptions[0].available = other; // Become this user. + this.actionOptions[1].available = other && user.admin; // Revoke admin. + this.actionOptions[2].available = other && !user.admin; // Grant admin. + this.actionOptions[4].available = other; // Remove user. + this.actionOptions[5].available = true; // Activity detail. + } + else { + this.actionOptions[0].available = false; // Become this user. + this.actionOptions[1].available = false; // Revoke admin. + this.actionOptions[2].available = false; // Grant admin. + this.actionOptions[4].available = false; // Remove user. + this.actionOptions[5].available = false; // Activity detail. } - - if (!_.isEqual(ids, this.selected)) - this.selected = ids; } _refreshRows() { if (this.gridApi) { this.gridApi.grid.refreshRows() - .then(() => this.selected.length && this._updateSelected()); + .then(() => this._updateSelected()); } } + becomeUser() { + const user = this.gridApi.selection.legacyGetSelectedRows()[0]; + + this.AdminData.becomeUser(user._id) + .then(() => this.User.load()) + .then(() => this.$state.go('default-state')) + .then(() => this.NotebookData.load()); + } + + toggleAdmin() { + if (!this.gridApi) + return; + + const user = this.gridApi.selection.legacyGetSelectedRows()[0]; + + if (user.adminChanging) + return; + + user.adminChanging = true; + + this.AdminData.toggleAdmin(user) + .finally(() => { + this._updateSelected(); + + user.adminChanging = false; + }); + } + + removeUser() { + const user = this.gridApi.selection.legacyGetSelectedRows()[0]; + + this.Confirm.confirm(`Are you sure you want to remove user: "${user.userName}"?`) + .then(() => this.AdminData.removeUser(user)) + .then(() => { + const i = _.findIndex(this.gridOptions.data, (u) => u._id === user._id); + + if (i >= 0) { + this.gridOptions.data.splice(i, 1); + this.gridApi.selection.clearSelectedRows(); + } + + this.adjustHeight(this.gridOptions.data.length); + + return this._refreshRows(); + }); + } + + showActivities() { + const user = this.gridApi.selection.legacyGetSelectedRows()[0]; + + return new this.ActivitiesDialogFactory({ user }); + } + groupByUser() { this.groupBy = 'user'; diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/template.tpl.pug b/modules/web-console/frontend/app/components/list-of-registered-users/template.tpl.pug index d32b64d082f12..ff1c851817f65 100644 --- a/modules/web-console/frontend/app/components/list-of-registered-users/template.tpl.pug +++ b/modules/web-console/frontend/app/components/list-of-registered-users/template.tpl.pug @@ -74,7 +74,6 @@ ul.tabs.tabs--blue label: 'Actions', model: '$ctrl.action', name: 'action', - disabled: '!$ctrl.selected.length', options: '$ctrl.actionOptions' }) diff --git a/modules/web-console/frontend/app/components/page-admin/controller.ts b/modules/web-console/frontend/app/components/page-admin/controller.ts new file mode 100644 index 0000000000000..45a5c0a5547e8 --- /dev/null +++ b/modules/web-console/frontend/app/components/page-admin/controller.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +import UserNotificationsService from '../user-notifications/service'; + +export default class PageAdminCtrl { + static $inject = ['UserNotifications']; + + constructor(private UserNotifications: UserNotificationsService) {} + + changeUserNotifications() { + this.UserNotifications.editor(); + } +} diff --git a/modules/web-console/frontend/app/components/page-admin/index.js b/modules/web-console/frontend/app/components/page-admin/index.js index 232d889eb46e1..69816f6823fef 100644 --- a/modules/web-console/frontend/app/components/page-admin/index.js +++ b/modules/web-console/frontend/app/components/page-admin/index.js @@ -17,23 +17,26 @@ import './style.scss'; +import controller from './controller'; import templateUrl from './template.tpl.pug'; +import {default as ActivitiesData} from 'app/core/activities/Activities.data'; -class PageAdminCtrl { - static $inject = ['UserNotifications']; - - constructor(UserNotifications) { - this.UserNotifications = UserNotifications; - } - - changeUserNotifications() { - this.UserNotifications.editor(); - } +/** + * @param {uirouter.UIRouter} $uiRouter + * @param {ActivitiesData} ActivitiesData + */ +function registerActivitiesHook($uiRouter, ActivitiesData) { + $uiRouter.transitionService.onSuccess({to: 'base.settings.**'}, (transition) => { + ActivitiesData.post({group: 'settings', action: transition.targetState().name()}); + }); } +registerActivitiesHook.$inject = ['$uiRouter', 'IgniteActivitiesData']; + export default angular .module('ignite-console.page-admin', []) .component('pageAdmin', { - templateUrl, - controller: PageAdminCtrl - }); + controller, + templateUrl + }) + .run(registerActivitiesHook); diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/cache-edit-form/controller.js b/modules/web-console/frontend/app/components/page-configure-advanced/components/cache-edit-form/controller.js index e044a7012d589..c1beec648a82f 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/cache-edit-form/controller.js +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/cache-edit-form/controller.js @@ -17,6 +17,7 @@ import cloneDeep from 'lodash/cloneDeep'; import get from 'lodash/get'; +import {tap} from 'rxjs/operators'; export default class CacheEditFormController { /** @type {ig.menu} */ @@ -61,10 +62,11 @@ export default class CacheEditFormController { }; - this.subscription = this.IgniteVersion.currentSbj - .do(rebuildDropdowns) - .do(filterModel) - .subscribe(); + this.subscription = this.IgniteVersion.currentSbj.pipe( + tap(rebuildDropdowns), + tap(filterModel) + ) + .subscribe(); // TODO: Do we really need this? this.$scope.ui = this.IgniteFormUtils.formUI(); diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/cache-edit-form/templates/general.pug b/modules/web-console/frontend/app/components/page-configure-advanced/components/cache-edit-form/templates/general.pug index 955239693354a..ba5d5ad3c2f3d 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/cache-edit-form/templates/general.pug +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/cache-edit-form/templates/general.pug @@ -74,16 +74,18 @@ panel-collapsible(opened=`::true` ng-form=form) name: '"atomicityMode"', placeholder: 'ATOMIC', options: '[\ - {value: "ATOMIC", label: "ATOMIC"},\ - {value: "TRANSACTIONAL", label: "TRANSACTIONAL"}\ - ]', + {value: "ATOMIC", label: "ATOMIC"},\ + {value: "TRANSACTIONAL", label: "TRANSACTIONAL"},\ + {value: "TRANSACTIONAL_SNAPSHOT", label: "TRANSACTIONAL_SNAPSHOT"}\ + ]', tip: 'Atomicity:\ -
      \ -
    • ATOMIC - in this mode distributed transactions and distributed locking are not supported
    • \ -
    • TRANSACTIONAL - in this mode specified fully ACID-compliant transactional cache behavior
    • \ -
    ' +
      \ +
    • ATOMIC - in this mode distributed transactions and distributed locking are not supported
    • \ +
    • TRANSACTIONAL - in this mode specified fully ACID-compliant transactional cache behavior
    • \ +
    • TRANSACTIONAL_SNAPSHOT - in this mode specified fully ACID-compliant transactional cache behavior for both key-value API and SQL transactions
    • \ +
    ' }) - .pc-form-grid-col-30(ng-is=`${model}.cacheMode === 'PARTITIONED'`) + .pc-form-grid-col-30(ng-if=`${model}.cacheMode === 'PARTITIONED'`) +form-field__number({ label: 'Backups:', model: `${model}.backups`, diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/controller.js b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/controller.js index 881e5430378b7..7400b4374b851 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/controller.js +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/controller.js @@ -19,12 +19,15 @@ import cloneDeep from 'lodash/cloneDeep'; import get from 'lodash/get'; import isEqual from 'lodash/isEqual'; import _ from 'lodash'; +import {tap} from 'rxjs/operators'; export default class ClusterEditFormController { /** @type {Array} */ caches; /** @type {ig.menu} */ cachesMenu; + /** @type {ig.menu} */ + servicesCachesMenu; /** @type {ng.ICompiledExpression} */ onSave; @@ -84,10 +87,11 @@ export default class ClusterEditFormController { } }; - this.subscription = this.IgniteVersion.currentSbj - .do(rebuildDropdowns) - .do(() => filterModel(this.clonedCluster)) - .subscribe(); + this.subscription = this.IgniteVersion.currentSbj.pipe( + tap(rebuildDropdowns), + tap(() => filterModel(this.clonedCluster)) + ) + .subscribe(); this.supportedJdbcTypes = this.IgniteLegacyUtils.mkOptions(this.IgniteLegacyUtils.SUPPORTED_JDBC_TYPES); @@ -108,8 +112,11 @@ export default class ClusterEditFormController { this.$scope.ui.inputForm.$setUntouched(); } } - if ('caches' in changes) + + if ('caches' in changes) { this.cachesMenu = (changes.caches.currentValue || []).map((c) => ({label: c.name, value: c._id})); + this.servicesCachesMenu = [{label: 'Key-affinity not used', value: null}].concat(this.cachesMenu); + } } /** diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/template.tpl.pug b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/template.tpl.pug index d5cb90930f8c2..e30cfdb7b5589 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/template.tpl.pug +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/template.tpl.pug @@ -50,6 +50,9 @@ form(id='cluster' name='ui.inputForm' novalidate) include ./templates/misc include ./templates/metrics + //- Since ignite 2.7 + include ./templates/mvcc + //- Deprecated in ignite 2.1 include ./templates/odbc diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/data-storage.pug b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/data-storage.pug index e18b0cbabaf78..8f9a33ebfe259 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/data-storage.pug +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/data-storage.pug @@ -256,6 +256,15 @@ panel-collapsible(ng-show='$ctrl.available("2.3.0")' ng-form=form on-open=`ui.lo min: '1', tip: 'Frequency which is a minimal interval when the dirty pages will be written to the Persistent Store' }) + .pc-form-grid-col-60(ng-if='$ctrl.available("2.7.0")') + +form-field__number({ + label: 'Checkpoint read lock timeout:', + model: `${model}.checkpointReadLockTimeout`, + name: '"DataStorageCheckpointReadLockTimeout"', + placeholder: 'System workers blocked timeout', + min: '1', + tip: 'Timeout for checkpoint read lock acquisition' + }) .pc-form-grid-col-20 +form-field__number({ label: 'Checkpoint threads:', diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/failover.pug b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/failover.pug index 3fafe9f86f845..27797ed1b0895 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/failover.pug +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/failover.pug @@ -47,6 +47,15 @@ panel-collapsible(ng-form=form on-open=`ui.loadPanel('${form}')`) min: '1', tip: 'Failure detection timeout is used to determine how long the communication or discovery SPIs should wait before considering a remote connection failed' }) + .pc-form-grid-col-60(ng-if='$ctrl.available("2.7.0")') + +form-field__number({ + label: 'System workers blocked timeout:', + model: model + '.systemWorkerBlockedTimeout', + name: '"SystemWorkerBlockedTimeout"', + placeholder: 'Failure detection timeout', + min: '1', + tip: 'Maximum inactivity period for system worker' + }) .pc-form-grid-col-60 mixin clusters-failover-spi diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/mvcc.pug b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/mvcc.pug new file mode 100644 index 0000000000000..2799520e2e614 --- /dev/null +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/mvcc.pug @@ -0,0 +1,46 @@ +//- + 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. + +include /app/helpers/jade/mixins + +-var form = 'mvcc' +-var model = '$ctrl.clonedCluster' + +panel-collapsible(ng-show='$ctrl.available("2.7.0")' ng-form=form on-open=`ui.loadPanel('${form}')`) + panel-title Multiversion concurrency control (MVCC) + panel-description Multiversion concurrency control (MVCC) configuration. + panel-content.pca-form-row(ng-if=`ui.isPanelLoaded('${form}')`) + .pca-form-column-6.pc-form-grid-row + .pc-form-grid-col-30(ng-if='$ctrl.available("2.1.0")') + +form-field__number({ + label: 'Vacuum thread pool size:', + model: `${model}.mvccVacuumThreadCount`, + name: '"MvccVacuumThreadCount"', + placeholder: '2', + min: '0', + tip: 'Number of MVCC vacuum cleanup threads' + }) + .pc-form-grid-col-30(ng-if='$ctrl.available("2.1.0")') + +form-field__number({ + label: 'Vacuum intervals:', + model: `${model}.mvccVacuumFrequency`, + name: '"MvccVacuumFrequency"', + placeholder: '5000', + min: '0', + tip: 'Time interval between vacuum runs in ms' + }) + .pca-form-column-6 + +preview-xml-java(model, 'clusterMvcc') diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/service.pug b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/service.pug index 10b5dd8385324..6a2f8a60d1af5 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/service.pug +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/service.pug @@ -83,9 +83,9 @@ panel-collapsible(ng-form=form on-open=`ui.loadPanel('${form}')`) label: 'Cache:', model: '$item.cache', name: '"serviceCache"', - placeholder: 'Choose cache', + placeholder: 'Key-affinity not used', placeholderEmpty: 'No caches configured for current cluster', - options: '$ctrl.cachesMenu', + options: '$ctrl.servicesCachesMenu', tip: 'Cache name used for key-to-node affinity calculation' })( pc-is-in-collection='$ctrl.clonedCluster.caches' diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/ssl.pug b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/ssl.pug index 61c722ee2d7a5..f9791243e1fb4 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/ssl.pug +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/cluster-edit-form/templates/ssl.pug @@ -51,7 +51,7 @@ panel-collapsible(ng-form=form on-open=`ui.loadPanel('${form}')`) .pc-form-grid-col-60 +form-field__text({ label: 'Key store file:', - model: `${secondaryFileSystem}.keyStoreFilePath`, + model: `${model}.keyStoreFilePath`, name: '"keyStoreFilePath"', disabled: `!(${enabled})`, required: enabled, diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-caches/controller.js b/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-caches/controller.js index da17c678fe6c2..2cfe08ae80d70 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-caches/controller.js +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-caches/controller.js @@ -15,10 +15,9 @@ * limitations under the License. */ -import {Subject} from 'rxjs/Subject'; -import {merge} from 'rxjs/observable/merge'; +import {Subject, merge, combineLatest} from 'rxjs'; +import {tap, map, refCount, pluck, publishReplay, switchMap, distinctUntilChanged} from 'rxjs/operators'; import naturalCompare from 'natural-compare-lite'; -import {combineLatest} from 'rxjs/observable/combineLatest'; import {removeClusterItems, advancedSaveCache} from 'app/components/page-configure/store/actionCreators'; import ConfigureState from 'app/components/page-configure/services/ConfigureState'; import ConfigSelectors from 'app/components/page-configure/store/selectors'; @@ -103,16 +102,23 @@ export default class Controller { } $onInit() { - const cacheID$ = this.$uiRouter.globals.params$.pluck('cacheID').publishReplay(1).refCount(); + const cacheID$ = this.$uiRouter.globals.params$.pipe( + pluck('cacheID'), + publishReplay(1), + refCount() + ); - this.shortCaches$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortCaches); - this.shortModels$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortModels); - this.shortIGFSs$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortIGFSs); - this.originalCache$ = cacheID$.distinctUntilChanged().switchMap((id) => { - return this.ConfigureState.state$.let(this.ConfigSelectors.selectCacheToEdit(id)); - }); + this.shortCaches$ = this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCurrentShortCaches); + this.shortModels$ = this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCurrentShortModels); + this.shortIGFSs$ = this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCurrentShortIGFSs); + this.originalCache$ = cacheID$.pipe( + distinctUntilChanged(), + switchMap((id) => { + return this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCacheToEdit(id)); + }) + ); - this.isNew$ = cacheID$.map((id) => id === 'new'); + this.isNew$ = cacheID$.pipe(map((id) => id === 'new')); this.itemEditTitle$ = combineLatest(this.isNew$, this.originalCache$, (isNew, cache) => { return `${isNew ? 'Create' : 'Edit'} cache ${!isNew && cache.name ? `‘${cache.name}’` : ''}`; }); @@ -125,13 +131,13 @@ export default class Controller { this.subscription = merge( this.originalCache$, - this.selectionManager.editGoes$.do((id) => this.edit(id)), - this.selectionManager.editLeaves$.do((options) => this.$state.go('base.configuration.edit.advanced.caches', null, options)) + this.selectionManager.editGoes$.pipe(tap((id) => this.edit(id))), + this.selectionManager.editLeaves$.pipe(tap((options) => this.$state.go('base.configuration.edit.advanced.caches', null, options))) ).subscribe(); this.isBlocked$ = cacheID$; - this.tableActions$ = this.selectionManager.selectedItemIDs$.map((selectedItems) => [ + this.tableActions$ = this.selectionManager.selectedItemIDs$.pipe(map((selectedItems) => [ { action: 'Clone', click: () => this.clone(selectedItems), @@ -144,7 +150,7 @@ export default class Controller { }, available: true } - ]); + ])); } /** diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-cluster/controller.js b/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-cluster/controller.js index f0348c353629e..2aae041ce8349 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-cluster/controller.js +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-cluster/controller.js @@ -18,7 +18,7 @@ import {default as ConfigSelectors} from 'app/components/page-configure/store/selectors'; import {default as ConfigureState} from 'app/components/page-configure/services/ConfigureState'; import {advancedSaveCluster} from 'app/components/page-configure/store/actionCreators'; -import 'rxjs/add/operator/publishReplay'; +import {take, pluck, switchMap, map, filter, distinctUntilChanged, publishReplay, refCount} from 'rxjs/operators'; // Controller for Clusters screen. export default class PageConfigureAdvancedCluster { @@ -36,12 +36,27 @@ export default class PageConfigureAdvancedCluster { } $onInit() { - const clusterID$ = this.$uiRouter.globals.params$.take(1).pluck('clusterID').filter((v) => v).take(1); - this.shortCaches$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortCaches); - this.originalCluster$ = clusterID$.distinctUntilChanged().switchMap((id) => { - return this.ConfigureState.state$.let(this.ConfigSelectors.selectClusterToEdit(id)); - }).distinctUntilChanged().publishReplay(1).refCount(); - this.isNew$ = this.$uiRouter.globals.params$.pluck('clusterID').map((id) => id === 'new'); + const clusterID$ = this.$uiRouter.globals.params$.pipe( + take(1), + pluck('clusterID'), + filter((v) => v), + take(1) + ); + + this.shortCaches$ = this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCurrentShortCaches); + + this.originalCluster$ = clusterID$.pipe( + distinctUntilChanged(), + switchMap((id) => { + return this.ConfigureState.state$.pipe(this.ConfigSelectors.selectClusterToEdit(id)); + }), + distinctUntilChanged(), + publishReplay(1), + refCount() + ); + + this.isNew$ = this.$uiRouter.globals.params$.pipe(pluck('clusterID'), map((id) => id === 'new')); + this.isBlocked$ = clusterID$; } diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-igfs/controller.js b/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-igfs/controller.js index 50eee7cad0dce..0e6345b088eec 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-igfs/controller.js +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-igfs/controller.js @@ -15,11 +15,9 @@ * limitations under the License. */ -import {Observable} from 'rxjs/Observable'; -import {Subject} from 'rxjs/Subject'; -import {combineLatest} from 'rxjs/observable/combineLatest'; +import {Observable, Subject, combineLatest, merge} from 'rxjs'; +import {tap, map, distinctUntilChanged, pluck, publishReplay, refCount, switchMap} from 'rxjs/operators'; import naturalCompare from 'natural-compare-lite'; -import {merge} from 'rxjs/observable/merge'; import get from 'lodash/get'; import {removeClusterItems, advancedSaveIGFS} from 'app/components/page-configure/store/actionCreators'; import ConfigureState from 'app/components/page-configure/services/ConfigureState'; @@ -82,31 +80,44 @@ export default class PageConfigureAdvancedIGFS { width: 130 } ]; - this.itemID$ = this.$uiRouter.globals.params$.pluck('igfsID'); + + this.itemID$ = this.$uiRouter.globals.params$.pipe(pluck('igfsID')); /** @type {Observable} */ - this.shortItems$ = this.ConfigureState.state$ - .let(this.ConfigSelectors.selectCurrentShortIGFSs) - .map((items = []) => items.map((i) => ({ + this.shortItems$ = this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectCurrentShortIGFSs, + map((items = []) => items.map((i) => ({ _id: i._id, name: i.name, affinnityGroupSize: i.affinnityGroupSize || this.IGFSs.affinnityGroupSize.default, defaultMode: i.defaultMode || this.IGFSs.defaultMode.default - }))); - this.originalItem$ = this.itemID$.distinctUntilChanged().switchMap((id) => { - return this.ConfigureState.state$.let(this.ConfigSelectors.selectIGFSToEdit(id)); - }).distinctUntilChanged().publishReplay(1).refCount(); - this.isNew$ = this.itemID$.map((id) => id === 'new'); + }))) + ); + + this.originalItem$ = this.itemID$.pipe( + distinctUntilChanged(), + switchMap((id) => { + return this.ConfigureState.state$.pipe(this.ConfigSelectors.selectIGFSToEdit(id)); + }), + distinctUntilChanged(), + publishReplay(1), + refCount() + ); + + this.isNew$ = this.itemID$.pipe(map((id) => id === 'new')); + this.itemEditTitle$ = combineLatest(this.isNew$, this.originalItem$, (isNew, item) => { return `${isNew ? 'Create' : 'Edit'} IGFS ${!isNew && get(item, 'name') ? `‘${get(item, 'name')}’` : ''}`; }); + this.selectionManager = this.configSelectionManager({ itemID$: this.itemID$, selectedItemRows$: this.selectedRows$, visibleRows$: this.visibleRows$, loadedItems$: this.shortItems$ }); - this.tableActions$ = this.selectionManager.selectedItemIDs$.map((selectedItems) => [ + + this.tableActions$ = this.selectionManager.selectedItemIDs$.pipe(map((selectedItems) => [ { action: 'Clone', click: () => this.clone(selectedItems), @@ -119,19 +130,23 @@ export default class PageConfigureAdvancedIGFS { }, available: true } - ]); + ])); + this.subscription = merge( this.originalItem$, - this.selectionManager.editGoes$.do((id) => this.edit(id)), - this.selectionManager.editLeaves$.do((options) => this.$state.go('base.configuration.edit.advanced.igfs', null, options)) + this.selectionManager.editGoes$.pipe(tap((id) => this.edit(id))), + this.selectionManager.editLeaves$.pipe(tap((options) => this.$state.go('base.configuration.edit.advanced.igfs', null, options))) ).subscribe(); } + edit(igfsID) { this.$state.go('base.configuration.edit.advanced.igfs.igfs', {igfsID}); } + save({igfs, download}) { this.ConfigureState.dispatchAction(advancedSaveIGFS(igfs, download)); } + remove(itemIDs) { this.ConfigureState.dispatchAction( removeClusterItems(this.$uiRouter.globals.params.clusterID, 'igfss', itemIDs, true, true) diff --git a/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-models/controller.js b/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-models/controller.js index fd1ccaa703a72..c2e30cfdf1960 100644 --- a/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-models/controller.js +++ b/modules/web-console/frontend/app/components/page-configure-advanced/components/page-configure-advanced-models/controller.js @@ -15,10 +15,9 @@ * limitations under the License. */ -import {Subject} from 'rxjs/Subject'; -import {Observable} from 'rxjs/Observable'; -import {combineLatest} from 'rxjs/observable/combineLatest'; -import {merge} from 'rxjs/observable/merge'; +import {Subject, Observable, combineLatest, merge} from 'rxjs'; +import {pluck, tap, publishReplay, refCount, distinctUntilChanged, switchMap, map} from 'rxjs/operators'; + import get from 'lodash/get'; import hasIndexTemplate from './hasIndex.template.pug'; @@ -100,25 +99,33 @@ export default class PageConfigureAdvancedModels { ]; /** @type {Observable} */ - this.itemID$ = this.$uiRouter.globals.params$.pluck('modelID'); + this.itemID$ = this.$uiRouter.globals.params$.pipe(pluck('modelID')); /** @type {Observable>} */ - this.shortItems$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortModels) - .do((shortModels = []) => { + this.shortItems$ = this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectCurrentShortModels, + tap((shortModels = []) => { const value = shortModels.every((m) => m.hasIndex); this.columnDefs[0].visible = !value; - }) - .publishReplay(1) - .refCount(); + }), + publishReplay(1), + refCount() + ); - this.shortCaches$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortCaches); + this.shortCaches$ = this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCurrentShortCaches); /** @type {Observable} */ - this.originalItem$ = this.itemID$.distinctUntilChanged().switchMap((id) => { - return this.ConfigureState.state$.let(this.ConfigSelectors.selectModelToEdit(id)); - }).distinctUntilChanged().publishReplay(1).refCount(); + this.originalItem$ = this.itemID$.pipe( + distinctUntilChanged(), + switchMap((id) => { + return this.ConfigureState.state$.pipe(this.ConfigSelectors.selectModelToEdit(id)); + }), + distinctUntilChanged(), + publishReplay(1), + refCount() + ); - this.isNew$ = this.itemID$.map((id) => id === 'new'); + this.isNew$ = this.itemID$.pipe(map((id) => id === 'new')); this.itemEditTitle$ = combineLatest(this.isNew$, this.originalItem$, (isNew, item) => { return `${isNew ? 'Create' : 'Edit'} model ${!isNew && get(item, 'valueType') ? `‘${get(item, 'valueType')}’` : ''}`; @@ -131,7 +138,7 @@ export default class PageConfigureAdvancedModels { loadedItems$: this.shortItems$ }); - this.tableActions$ = this.selectionManager.selectedItemIDs$.map((selectedItems) => [ + this.tableActions$ = this.selectionManager.selectedItemIDs$.pipe(map((selectedItems) => [ { action: 'Clone', click: () => this.clone(selectedItems), @@ -144,12 +151,12 @@ export default class PageConfigureAdvancedModels { }, available: true } - ]); + ])); this.subscription = merge( this.originalItem$, - this.selectionManager.editGoes$.do((id) => this.edit(id)), - this.selectionManager.editLeaves$.do((options) => this.$state.go('base.configuration.edit.advanced.models', null, options)) + this.selectionManager.editGoes$.pipe(tap((id) => this.edit(id))), + this.selectionManager.editLeaves$.pipe(tap((options) => this.$state.go('base.configuration.edit.advanced.models', null, options))) ).subscribe(); } diff --git a/modules/web-console/frontend/app/components/page-configure-basic/controller.js b/modules/web-console/frontend/app/components/page-configure-basic/controller.js index 88c61636f07ad..14b3a69d28aab 100644 --- a/modules/web-console/frontend/app/components/page-configure-basic/controller.js +++ b/modules/web-console/frontend/app/components/page-configure-basic/controller.js @@ -15,8 +15,8 @@ * limitations under the License. */ -import {Observable} from 'rxjs/Observable'; -import 'rxjs/add/operator/map'; +import {forkJoin, merge} from 'rxjs'; +import {map, tap, pluck, take, filter, distinctUntilChanged, switchMap, publishReplay, refCount} from 'rxjs/operators'; import cloneDeep from 'lodash/cloneDeep'; import get from 'lodash/get'; import naturalCompare from 'natural-compare-lite'; @@ -88,45 +88,64 @@ export default class PageConfigureBasicController { $transition$.onSuccess({}, () => this.reset()); - return Observable.forkJoin( - this.ConfigureState.state$.pluck('edit', 'changes').take(1), - this.clusterID$.switchMap((id) => this.ConfigureState.state$.let(this.ConfigSelectors.selectClusterShortCaches(id))).take(1), - this.shortCaches$.take(1) - ).toPromise() - .then(([changes, originalShortCaches, currentCaches]) => { - return this.ConfigChangesGuard.guard( - { - cluster: this.Clusters.normalize(this.originalCluster), - caches: originalShortCaches.map(this.Caches.normalize) - }, - { - cluster: {...this.Clusters.normalize(this.clonedCluster), caches: changes.caches.ids}, - caches: currentCaches.map(this.Caches.normalize) - } - ); - }); + return forkJoin( + this.ConfigureState.state$.pipe(pluck('edit', 'changes'), take(1)), + this.clusterID$.pipe( + switchMap((id) => this.ConfigureState.state$.pipe(this.ConfigSelectors.selectClusterShortCaches(id))), + take(1) + ), + this.shortCaches$.pipe(take(1)) + ) + .toPromise() + .then(([changes, originalShortCaches, currentCaches]) => { + return this.ConfigChangesGuard.guard( + { + cluster: this.Clusters.normalize(this.originalCluster), + caches: originalShortCaches.map(this.Caches.normalize) + }, + { + cluster: {...this.Clusters.normalize(this.clonedCluster), caches: changes.caches.ids}, + caches: currentCaches.map(this.Caches.normalize) + } + ); + }); } $onInit() { this.onBeforeTransition = this.$uiRouter.transitionService.onBefore({}, (t) => this._uiCanExit(t)); - this.memorySizeInputVisible$ = this.IgniteVersion.currentSbj - .map((version) => this.IgniteVersion.since(version.ignite, '2.0.0')); + this.memorySizeInputVisible$ = this.IgniteVersion.currentSbj.pipe( + map((version) => this.IgniteVersion.since(version.ignite, '2.0.0')) + ); - const clusterID$ = this.$uiRouter.globals.params$.take(1).pluck('clusterID').filter((v) => v).take(1); + const clusterID$ = this.$uiRouter.globals.params$.pipe( + take(1), + pluck('clusterID'), + filter((v) => v), + take(1) + ); this.clusterID$ = clusterID$; - this.isNew$ = this.$uiRouter.globals.params$.pluck('clusterID').map((id) => id === 'new'); - this.shortCaches$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortCaches); - this.shortClusters$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectShortClustersValue()); - this.originalCluster$ = clusterID$.distinctUntilChanged().switchMap((id) => { - return this.ConfigureState.state$.let(this.ConfigSelectors.selectClusterToEdit(id)); - }).distinctUntilChanged().publishReplay(1).refCount(); - - this.subscription = Observable.merge( - this.shortCaches$.map((caches) => caches.sort((a, b) => naturalCompare(a.name, b.name))).do((v) => this.shortCaches = v), - this.shortClusters$.do((v) => this.shortClusters = v), - this.originalCluster$.do((v) => { + this.isNew$ = this.$uiRouter.globals.params$.pipe(pluck('clusterID'), map((id) => id === 'new')); + this.shortCaches$ = this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCurrentShortCaches); + this.shortClusters$ = this.ConfigureState.state$.pipe(this.ConfigSelectors.selectShortClustersValue()); + this.originalCluster$ = clusterID$.pipe( + distinctUntilChanged(), + switchMap((id) => { + return this.ConfigureState.state$.pipe(this.ConfigSelectors.selectClusterToEdit(id)); + }), + distinctUntilChanged(), + publishReplay(1), + refCount() + ); + + this.subscription = merge( + this.shortCaches$.pipe( + map((caches) => caches.sort((a, b) => naturalCompare(a.name, b.name))), + tap((v) => this.shortCaches = v) + ), + this.shortClusters$.pipe(tap((v) => this.shortClusters = v)), + this.originalCluster$.pipe(tap((v) => { this.originalCluster = v; // clonedCluster should be set only when particular cluster edit starts. // @@ -136,7 +155,7 @@ export default class PageConfigureBasicController { // made by user and we don't want that. Advanced configuration forms do the same too. if (get(v, '_id') !== get(this.clonedCluster, '_id')) this.clonedCluster = cloneDeep(v); this.defaultMemoryPolicy = this.Clusters.getDefaultClusterMemoryPolicy(this.clonedCluster); - }) + })) ).subscribe(); this.formActionsMenu = [ @@ -155,11 +174,12 @@ export default class PageConfigureBasicController { this.cachesColDefs = [ {name: 'Name:', cellClass: 'pc-form-grid-col-10'}, {name: 'Mode:', cellClass: 'pc-form-grid-col-10'}, - {name: 'Atomicity:', cellClass: 'pc-form-grid-col-10', tip: ` + {name: 'Atomicity:', cellClass: 'pc-form-grid-col-20', tip: ` Atomicity:
    • ATOMIC - in this mode distributed transactions and distributed locking are not supported
    • TRANSACTIONAL - in this mode specified fully ACID-compliant transactional cache behavior
    • +
    • TRANSACTIONAL_SNAPSHOT - in this mode specified fully ACID-compliant transactional cache behavior for both key-value API and SQL transactions
    `}, {name: 'Backups:', cellClass: 'pc-form-grid-col-10', tip: ` diff --git a/modules/web-console/frontend/app/components/page-configure-basic/controller.spec.js b/modules/web-console/frontend/app/components/page-configure-basic/controller.spec.js index a35eb50a443ee..a4a1d309c4da9 100644 --- a/modules/web-console/frontend/app/components/page-configure-basic/controller.spec.js +++ b/modules/web-console/frontend/app/components/page-configure-basic/controller.spec.js @@ -19,10 +19,8 @@ import {suite, test} from 'mocha'; import {assert} from 'chai'; import {spy} from 'sinon'; -import {TestScheduler} from 'rxjs/testing/TestScheduler'; -import {Subject} from 'rxjs/Subject'; -import {BehaviorSubject} from 'rxjs/BehaviorSubject'; -import {Subscriber} from 'rxjs/Subscriber'; +import {TestScheduler} from 'rxjs/testing'; +import {Subscriber, Subject, BehaviorSubject} from 'rxjs'; import Controller from './controller'; const mocks = () => new Map([ diff --git a/modules/web-console/frontend/app/components/page-configure-overview/controller.js b/modules/web-console/frontend/app/components/page-configure-overview/controller.js index e49e5c68a8bb5..e170112ce76b1 100644 --- a/modules/web-console/frontend/app/components/page-configure-overview/controller.js +++ b/modules/web-console/frontend/app/components/page-configure-overview/controller.js @@ -15,7 +15,8 @@ * limitations under the License. */ -import {Subject} from 'rxjs/Subject'; +import {Subject} from 'rxjs'; +import {map} from 'rxjs/operators'; import naturalCompare from 'natural-compare-lite'; const cellTemplate = (state) => ` @@ -81,7 +82,7 @@ export default class PageConfigureOverviewController { } $onInit() { - this.shortClusters$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectShortClustersValue()); + this.shortClusters$ = this.ConfigureState.state$.pipe(this.ConfigSelectors.selectShortClustersValue()); /** @type {Array>} */ this.clustersColumnDefs = [ @@ -140,9 +141,9 @@ export default class PageConfigureOverviewController { /** @type {Subject>} */ this.selectedRows$ = new Subject(); - this.selectedRowsIDs$ = this.selectedRows$.map((selectedClusters) => selectedClusters.map((cluster) => cluster._id)); + this.selectedRowsIDs$ = this.selectedRows$.pipe(map((selectedClusters) => selectedClusters.map((cluster) => cluster._id))); - this.actions$ = this.selectedRows$.map((selectedClusters) => [ + this.actions$ = this.selectedRows$.pipe(map((selectedClusters) => [ { action: 'Edit', click: () => this.editCluster(selectedClusters[0]), @@ -163,6 +164,6 @@ export default class PageConfigureOverviewController { click: () => this.removeClusters(selectedClusters), available: true } - ]); + ])); } } diff --git a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js index e4b82530cdaca..7181b546b3b5c 100644 --- a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js +++ b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js @@ -21,7 +21,8 @@ import _ from 'lodash'; import naturalCompare from 'natural-compare-lite'; import find from 'lodash/fp/find'; import get from 'lodash/fp/get'; -import {Observable} from 'rxjs/Observable'; +import {race, timer, merge, of, from, combineLatest} from 'rxjs'; +import {tap, filter, take, pluck, switchMap} from 'rxjs/operators'; import ObjectID from 'bson-objectid'; import {uniqueName} from 'app/utils/uniqueName'; import {defaultNames} from '../../defaultNames'; @@ -126,34 +127,34 @@ export class ModalImportModels { } loadData() { - return Observable.of(this.clusterID) - .switchMap((id = 'new') => { - return this.ConfigureState.state$.let(this.ConfigSelectors.selectClusterToEdit(id, defaultNames.importedCluster)); - }) - .switchMap((cluster) => { - return (!(cluster.caches || []).length && !(cluster.models || []).length) - ? Observable.of({ - cluster, - caches: [], - models: [] - }) - : Observable.fromPromise(Promise.all([ - this.ConfigEffects.etp('LOAD_SHORT_CACHES', {ids: cluster.caches || [], clusterID: cluster._id}), - this.ConfigEffects.etp('LOAD_SHORT_MODELS', {ids: cluster.models || [], clusterID: cluster._id}) - ])) - .switchMap(() => { - return Observable.combineLatest( - this.ConfigureState.state$.let(this.ConfigSelectors.selectShortCachesValue()), - this.ConfigureState.state$.let(this.ConfigSelectors.selectShortModelsValue()), - (caches, models) => ({ - cluster, - caches, - models - }) - ).take(1); - }); - }) - .take(1); + return of(this.clusterID).pipe( + switchMap((id = 'new') => { + return this.ConfigureState.state$.pipe(this.ConfigSelectors.selectClusterToEdit(id, defaultNames.importedCluster)); + }), + switchMap((cluster) => { + return (!(cluster.caches || []).length && !(cluster.models || []).length) + ? of({ + cluster, + caches: [], + models: [] + }) + : from(Promise.all([ + this.ConfigEffects.etp('LOAD_SHORT_CACHES', {ids: cluster.caches || [], clusterID: cluster._id}), + this.ConfigEffects.etp('LOAD_SHORT_MODELS', {ids: cluster.models || [], clusterID: cluster._id}) + ])).pipe(switchMap(() => { + return combineLatest( + this.ConfigureState.state$.pipe(this.ConfigSelectors.selectShortCachesValue()), + this.ConfigureState.state$.pipe(this.ConfigSelectors.selectShortModelsValue()), + (caches, models) => ({ + cluster, + caches, + models + }) + ).pipe(take(1)); + })); + }), + take(1) + ); } saveBatch(batch) { @@ -169,15 +170,20 @@ export class ModalImportModels { prevActions: [] }); - this.saveSubscription = Observable.race( - this.ConfigureState.actions$.filter((a) => a.type === 'ADVANCED_SAVE_COMPLETE_CONFIGURATION_OK') - .do(() => this.onHide()), - this.ConfigureState.actions$.filter((a) => a.type === 'ADVANCED_SAVE_COMPLETE_CONFIGURATION_ERR') + this.saveSubscription = race( + this.ConfigureState.actions$.pipe( + filter((a) => a.type === 'ADVANCED_SAVE_COMPLETE_CONFIGURATION_OK'), + tap(() => this.onHide()) + ), + this.ConfigureState.actions$.pipe( + filter((a) => a.type === 'ADVANCED_SAVE_COMPLETE_CONFIGURATION_ERR') + ) + ).pipe( + take(1), + tap(() => { + this.Loading.finish('importDomainFromDb'); + }) ) - .take(1) - .do(() => { - this.Loading.finish('importDomainFromDb'); - }) .subscribe(); } @@ -231,18 +237,23 @@ export class ModalImportModels { if (this.loadedCaches[cacheID]) return; - return this.onCacheSelectSubcription = Observable.merge( - Observable.timer(0, 1).take(1) - .do(() => this.ConfigureState.dispatchAction({type: 'LOAD_CACHE', cacheID})), - Observable.race( - this.ConfigureState.actions$ - .filter((a) => a.type === 'LOAD_CACHE_OK' && a.cache._id === cacheID).pluck('cache') - .do((cache) => { + return this.onCacheSelectSubcription = merge( + timer(0, 1).pipe( + take(1), + tap(() => this.ConfigureState.dispatchAction({type: 'LOAD_CACHE', cacheID})) + ), + race( + this.ConfigureState.actions$.pipe( + filter((a) => a.type === 'LOAD_CACHE_OK' && a.cache._id === cacheID), + pluck('cache'), + tap((cache) => { this.loadedCaches[cacheID] = cache; - }), - this.ConfigureState.actions$ - .filter((a) => a.type === 'LOAD_CACHE_ERR' && a.action.cacheID === cacheID) - ).take(1) + }) + ), + this.ConfigureState.actions$.pipe( + filter((a) => a.type === 'LOAD_CACHE_ERR' && a.action.cacheID === cacheID) + ) + ).pipe(take(1)) ) .subscribe(); } @@ -291,7 +302,7 @@ export class ModalImportModels { this.$scope.importCommon = {}; - this.subscription = this.loadData().do((data) => { + this.subscription = this.loadData().pipe(tap((data) => { this.$scope.caches = _mapCaches(data.caches); this.$scope.domains = data.models; this.caches = data.caches; @@ -306,7 +317,7 @@ export class ModalImportModels { } this.$scope.$watch('importCommon.action', this._fillCommonCachesOrTemplates(this.$scope.importCommon), true); this.$scope.importCommon.action = IMPORT_DM_NEW_CACHE; - }).subscribe(); + })).subscribe(); // New this.loadedCaches = { diff --git a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/service.js b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/service.js index 3c0ecbbadc8b4..a76ec13505dc3 100644 --- a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/service.js +++ b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/service.js @@ -16,12 +16,26 @@ */ export default class ModalImportModels { - static $inject = ['$modal', 'AgentManager', '$uiRouter']; - constructor($modal, AgentManager, $uiRouter) { - Object.assign(this, {$modal, AgentManager, $uiRouter}); + static $inject = ['$modal', '$q', '$uiRouter', 'AgentManager']; + + deferred; + + constructor($modal, $q, $uiRouter, AgentManager) { + this.$modal = $modal; + this.$q = $q; + this.$uiRouter = $uiRouter; + this.AgentManager = AgentManager; } + _goToDynamicState() { - if (this._state) this.$uiRouter.stateRegistry.deregister(this._state); + if (this.deferred) + return this.deferred.promise; + + this.deferred = this.$q.defer(); + + if (this._state) + this.$uiRouter.stateRegistry.deregister(this._state); + this._state = this.$uiRouter.stateRegistry.register({ name: 'importModels', parent: this.$uiRouter.stateService.current, @@ -29,27 +43,49 @@ export default class ModalImportModels { this._open(); }, onExit: () => { + this.AgentManager.stopWatch(); this._modal && this._modal.hide(); } }); - return this.$uiRouter.stateService.go(this._state, this.$uiRouter.stateService.params); + + return this.$uiRouter.stateService.go(this._state, this.$uiRouter.stateService.params) + .catch(() => { + this.deferred.reject(false); + this.deferred = null; + }); } + _open() { + const self = this; + this._modal = this.$modal({ template: ` `, - controller: ['$state', function($state) {this.$state = $state;}], + controller: ['$state', function($state) { + this.$state = $state; + + this.onHide = () => { + self.deferred.resolve(true); + + this.$state.go('^'); + }; + }], controllerAs: '$ctrl', + backdrop: 'static', show: false }); + return this.AgentManager.startAgentWatch('Back', this.$uiRouter.globals.current.name) - .then(() => this._modal.$promise) - .then(() => this._modal.show()); + .then(() => this._modal.$promise) + .then(() => this._modal.show()) + .then(() => this.deferred.promise) + .finally(() => this.deferred = null); } + open() { this._goToDynamicState(); } diff --git a/modules/web-console/frontend/app/components/page-configure/components/pcValidation.js b/modules/web-console/frontend/app/components/page-configure/components/pcValidation.js index 1702c35ae9ee5..697e9e955aad0 100644 --- a/modules/web-console/frontend/app/components/page-configure/components/pcValidation.js +++ b/modules/web-console/frontend/app/components/page-configure/components/pcValidation.js @@ -21,21 +21,37 @@ export class IgniteFormField { static animName = 'ignite-form-field__error-blink'; static eventName = 'webkitAnimationEnd oAnimationEnd msAnimationEnd animationend'; static $inject = ['$element', '$scope']; + constructor($element, $scope) { Object.assign(this, {$element}); this.$scope = $scope; } + $postLink() { this.onAnimEnd = () => this.$element.removeClass(IgniteFormField.animName); this.$element.on(IgniteFormField.eventName, this.onAnimEnd); } + $onDestroy() { this.$element.off(IgniteFormField.eventName, this.onAnimEnd); this.$element = this.onAnimEnd = null; } + notifyAboutError() { - if (this.$element) this.$element.addClass(IgniteFormField.animName); + if (!this.$element) + return; + + this.$element.addClass(IgniteFormField.animName); + this.$element.find('.form-field__error [bs-tooltip]').trigger('mouseenter'); } + + hideError() { + if (!this.$element) + return; + + this.$element.find('.form-field__error [bs-tooltip]').trigger('mouseleave'); + } + /** * Exposes control in $scope * @param {ng.INgModelController} control diff --git a/modules/web-console/frontend/app/components/page-configure/controller.js b/modules/web-console/frontend/app/components/page-configure/controller.js index 91bdf504354be..7a83aa6304ad6 100644 --- a/modules/web-console/frontend/app/components/page-configure/controller.js +++ b/modules/web-console/frontend/app/components/page-configure/controller.js @@ -16,10 +16,8 @@ */ import get from 'lodash/get'; -import {Observable} from 'rxjs/Observable'; -import 'rxjs/add/observable/merge'; -import {combineLatest} from 'rxjs/observable/combineLatest'; -import 'rxjs/add/operator/distinctUntilChanged'; +import {Observable, combineLatest} from 'rxjs'; +import {pluck, switchMap, map} from 'rxjs/operators'; import {default as ConfigureState} from './services/ConfigureState'; import {default as ConfigSelectors} from './store/selectors'; @@ -39,9 +37,12 @@ export default class PageConfigureController { $onInit() { /** @type {Observable} */ - this.clusterID$ = this.$uiRouter.globals.params$.pluck('clusterID'); - const cluster$ = this.clusterID$.switchMap((id) => this.ConfigureState.state$.let(this.ConfigSelectors.selectCluster(id))); - const isNew$ = this.clusterID$.map((v) => v === 'new'); + this.clusterID$ = this.$uiRouter.globals.params$.pipe(pluck('clusterID')); + + const cluster$ = this.clusterID$.pipe(switchMap((id) => this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCluster(id)))); + + const isNew$ = this.clusterID$.pipe(map((v) => v === 'new')); + this.clusterName$ = combineLatest(cluster$, isNew$, (cluster, isNew) => { return `${isNew ? 'Create' : 'Edit'} cluster configuration ${isNew ? '' : `‘${get(cluster, 'name')}’`}`; }); diff --git a/modules/web-console/frontend/app/components/page-configure/icons/configuration.icon.svg b/modules/web-console/frontend/app/components/page-configure/icons/configuration.icon.svg new file mode 100644 index 0000000000000..7c0ac7aec54c3 --- /dev/null +++ b/modules/web-console/frontend/app/components/page-configure/icons/configuration.icon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/modules/web-console/frontend/app/components/page-configure/index.d.ts b/modules/web-console/frontend/app/components/page-configure/index.d.ts index 96773faab159a..c0eca6a93ea42 100644 --- a/modules/web-console/frontend/app/components/page-configure/index.d.ts +++ b/modules/web-console/frontend/app/components/page-configure/index.d.ts @@ -15,11 +15,10 @@ * limitations under the License. */ -import {Observable} from 'rxjs/Observable' /// declare namespace ig { - type menu = Array<{value: T, label: string}> + type menu < T > = Array<{value: T, label: string}>; namespace config { namespace formFieldSize { @@ -27,11 +26,12 @@ declare namespace ig { label: string, value: number } - type ISizeType = Array + type ISizeType = Array; interface ISizeTypes { [name: string]: ISizeType } } + namespace cluster { export type DiscoveryKinds = 'Vm' | 'Multicast' @@ -41,14 +41,14 @@ declare namespace ig { | 'Jdbc' | 'SharedFs' | 'ZooKeeper' - | 'Kubernetes' + | 'Kubernetes'; export type LoadBalancingKinds = 'RoundRobin' | 'Adaptive' | 'WeightedRandom' - | 'Custom' + | 'Custom'; - export type FailoverSPIs = 'JobStealing' | 'Never' | 'Always' | 'Custom' + export type FailoverSPIs = 'JobStealing' | 'Never' | 'Always' | 'Custom'; export interface ShortCluster { _id: string, @@ -59,9 +59,10 @@ declare namespace ig { igfs: number } } + namespace cache { - type CacheModes = 'PARTITIONED' | 'REPLICATED' | 'LOCAL' - type AtomicityModes = 'ATOMIC' | 'TRANSACTIONAL' + type CacheModes = 'PARTITIONED' | 'REPLICATED' | 'LOCAL'; + type AtomicityModes = 'ATOMIC' | 'TRANSACTIONAL'; export interface ShortCache { _id: string, cacheMode: CacheModes, @@ -69,9 +70,10 @@ declare namespace ig { backups: number } } + namespace model { - type QueryMetadataTypes = 'Annotations' | 'Configuration' - type DomainModelKinds = 'query' | 'store' | 'both' + type QueryMetadataTypes = 'Annotations' | 'Configuration'; + type DomainModelKinds = 'query' | 'store' | 'both'; export interface KeyField { databaseFieldName: string, databaseFieldType: string, @@ -92,7 +94,7 @@ declare namespace ig { field: string, alias: string } - type IndexTypes = 'SORTED' | 'FULLTEXT' | 'GEOSPATIAL' + type IndexTypes = 'SORTED' | 'FULLTEXT' | 'GEOSPATIAL'; export interface IndexField { _id: string, name?: string, @@ -135,8 +137,9 @@ declare namespace ig { hasIndex: boolean } } + namespace igfs { - type DefaultModes = 'PRIMARY' | 'PROXY' | 'DUAL_SYNC' | 'DUAL_ASYNC' + type DefaultModes = 'PRIMARY' | 'PROXY' | 'DUAL_SYNC' | 'DUAL_ASYNC'; export interface ShortIGFS { _id: string, name: string, @@ -148,4 +151,4 @@ declare namespace ig { } export as namespace ig -export = ig \ No newline at end of file +export = ig diff --git a/modules/web-console/frontend/app/components/page-configure/index.js b/modules/web-console/frontend/app/components/page-configure/index.ts similarity index 81% rename from modules/web-console/frontend/app/components/page-configure/index.js rename to modules/web-console/frontend/app/components/page-configure/index.ts index c1d51ee094be7..a2f76e13582b7 100644 --- a/modules/web-console/frontend/app/components/page-configure/index.js +++ b/modules/web-console/frontend/app/components/page-configure/index.ts @@ -19,7 +19,6 @@ import angular from 'angular'; import 'angular1-async-filter'; import {UIRouterRx} from '@uirouter/rx'; -import {Visualizer} from '@uirouter/visualizer'; import uiValidate from 'angular-ui-validate'; import component from './component'; @@ -50,18 +49,15 @@ import pcSplitButton from './components/pc-split-button'; import {errorState} from './transitionHooks/errorState'; import {default as ActivitiesData} from 'app/core/activities/Activities.data'; -import 'rxjs/add/operator/withLatestFrom'; -import 'rxjs/add/operator/skip'; +import {withLatestFrom, tap, filter, scan} from 'rxjs/operators'; -import {Observable} from 'rxjs/Observable'; -Observable.prototype.debug = function(l) { - return this.do((v) => console.log(l, v), (e) => console.error(l, e), () => console.log(l, 'completed')); -}; +import {navigationMenuItem, AppStore} from '../../store'; +import {default as configurationIcon} from './icons/configuration.icon.svg'; +import {default as IconsService} from '../ignite-icon/service'; import { editReducer2, shortObjectsReducer, - reducer, editReducer, loadingReducer, itemsEditReducerFactory, @@ -79,19 +75,19 @@ import { refsReducer } from './reducer'; -import {reducer as reduxDevtoolsReducer, devTools} from './reduxDevtoolsIntegration'; import {registerStates} from './states'; /** - * @param {ActivitiesData} ActivitiesData * @param {uirouter.UIRouter} $uiRouter + * @param {ActivitiesData} ActivitiesData */ -function registerActivitiesHook(ActivitiesData, $uiRouter) { +function registerActivitiesHook($uiRouter, ActivitiesData) { $uiRouter.transitionService.onSuccess({to: 'base.configuration.**'}, (transition) => { ActivitiesData.post({group: 'configuration', action: transition.targetState().name()}); }); } -registerActivitiesHook.$inject = ['IgniteActivitiesData', '$uiRouter']; + +registerActivitiesHook.$inject = ['$uiRouter', 'IgniteActivitiesData']; export default angular .module('ignite-console.page-configure', [ @@ -114,21 +110,10 @@ export default angular DefaultState.setRedirectTo(() => 'base.configuration.overview'); }]) .run(registerActivitiesHook) - .run(['ConfigEffects', 'ConfigureState', '$uiRouter', (ConfigEffects, ConfigureState, $uiRouter) => { - $uiRouter.plugin(UIRouterRx); - // $uiRouter.plugin(Visualizer); - if (devTools) { - devTools.subscribe((e) => { - if (e.type === 'DISPATCH' && e.state) ConfigureState.actions$.next(e); - }); + .run(['ConfigEffects', 'ConfigureState', '$uiRouter', 'Store', 'IgniteIcon', (ConfigEffects, ConfigureState, $uiRouter, store: AppStore, icons: IconsService) => { + icons.registerIcons({configuration: configurationIcon}); - ConfigureState.actions$ - .filter((e) => e.type !== 'DISPATCH') - .withLatestFrom(ConfigureState.state$.skip(1)) - .subscribe(([action, state]) => devTools.send(action, state)); - - ConfigureState.addReducer(reduxDevtoolsReducer); - } + $uiRouter.plugin(UIRouterRx); ConfigureState.addReducer(refsReducer({ models: {at: 'domains', store: 'caches'}, @@ -162,19 +147,28 @@ export default angular } }); - const la = ConfigureState.actions$.scan((acc, action) => [...acc, action], []); + const la = ConfigureState.actions$.pipe(scan((acc, action) => [...acc, action], [])); - ConfigureState.actions$ - .filter((a) => a.type === 'UNDO_ACTIONS') - .withLatestFrom(la, ({actions}, actionsWindow, initialState) => { + ConfigureState.actions$.pipe( + filter((a) => a.type === 'UNDO_ACTIONS'), + withLatestFrom(la, ({actions}, actionsWindow, initialState) => { return { type: 'APPLY_ACTIONS_UNDO', state: actionsWindow.filter((a) => !actions.includes(a)).reduce(ConfigureState._combinedReducer, {}) }; - }) - .do((a) => ConfigureState.dispatchAction(a)) - .subscribe(); + }), + tap((a) => ConfigureState.dispatchAction(a)) + ) + .subscribe(); ConfigEffects.connect(); + + store.dispatch(navigationMenuItem({ + activeSref: 'base.configuration.**', + icon: 'configuration', + label: 'Configuration', + order: 1, + sref: 'base.configuration.overview' + })); }]) .component('pageConfigure', component) .directive('pcIsInCollection', isInCollection) diff --git a/modules/web-console/frontend/app/components/page-configure/reduxDevtoolsIntegration.js b/modules/web-console/frontend/app/components/page-configure/reduxDevtoolsIntegration.js index 43fa3237ffcf6..f602539d1140e 100644 --- a/modules/web-console/frontend/app/components/page-configure/reduxDevtoolsIntegration.js +++ b/modules/web-console/frontend/app/components/page-configure/reduxDevtoolsIntegration.js @@ -36,6 +36,11 @@ const replacer = (key, value) => { __serializedType__: 'Symbol' }; } + if (value instanceof Promise) { + return { + data: {} + }; + } return value; }; diff --git a/modules/web-console/frontend/app/components/page-configure/services/ConfigChangesGuard.js b/modules/web-console/frontend/app/components/page-configure/services/ConfigChangesGuard.js index 7e2df806f9d05..cda9965e20dad 100644 --- a/modules/web-console/frontend/app/components/page-configure/services/ConfigChangesGuard.js +++ b/modules/web-console/frontend/app/components/page-configure/services/ConfigChangesGuard.js @@ -15,7 +15,8 @@ * limitations under the License. */ -import {of} from 'rxjs/observable/of'; +import {of} from 'rxjs'; +import {switchMap, catchError} from 'rxjs/operators'; import {Confirm} from 'app/services/Confirm.service'; import {DiffPatcher} from 'jsondiffpatch'; import {html} from 'jsondiffpatch/public/build/jsondiffpatch-formatters.js'; @@ -92,9 +93,9 @@ export default class ConfigChangesGuard { if (!a && !b) return Promise.resolve(true); - return of(this._hasChanges(a, b)) - .switchMap((changes) => changes ? this._confirm(changes).then(() => true) : of(true)) - .catch(() => of(false)) - .toPromise(); + return of(this._hasChanges(a, b)).pipe( + switchMap((changes) => changes ? this._confirm(changes).then(() => true) : of(true)), + catchError(() => of(false)) + ).toPromise(); } } diff --git a/modules/web-console/frontend/app/components/page-configure/services/ConfigSelectionManager.js b/modules/web-console/frontend/app/components/page-configure/services/ConfigSelectionManager.js index 243302a1995a3..b5b46d6bb6c2c 100644 --- a/modules/web-console/frontend/app/components/page-configure/services/ConfigSelectionManager.js +++ b/modules/web-console/frontend/app/components/page-configure/services/ConfigSelectionManager.js @@ -15,12 +15,9 @@ * limitations under the License. */ -import {Observable} from 'rxjs/Observable'; -import {merge} from 'rxjs/observable/merge'; +import {Observable, merge} from 'rxjs'; +import {share, distinctUntilChanged, startWith, filter, map, pluck, withLatestFrom, mapTo} from 'rxjs/operators'; import {RejectType} from '@uirouter/angularjs'; -import 'rxjs/add/operator/share'; -import 'rxjs/add/operator/mapTo'; -import 'rxjs/add/operator/startWith'; import isEqual from 'lodash/isEqual'; /** @@ -35,57 +32,63 @@ export default function configSelectionManager($transitions) { // but decides to stay after screen asks for leave confirmation. const abortedTransitions$ = Observable.create((observer) => { return $transitions.onError({}, (t) => observer.next(t)); - }) - .filter((t) => t.error().type === RejectType.ABORTED); + }).pipe(filter((t) => t.error().type === RejectType.ABORTED)); - const firstItemID$ = visibleRows$.withLatestFrom(itemID$, loadedItems$) - .filter(([rows, id, items]) => !id && rows && rows.length === items.length) - .pluck('0', '0', 'entity', '_id'); + const firstItemID$ = visibleRows$.pipe( + withLatestFrom(itemID$, loadedItems$), + filter(([rows, id, items]) => !id && rows && rows.length === items.length), + pluck('0', '0', 'entity', '_id') + ); - const selectedItemRowsIDs$ = selectedItemRows$.map((rows) => rows.map((r) => r._id)).share(); - const singleSelectionEdit$ = selectedItemRows$.filter((r) => r && r.length === 1).pluck('0', '_id'); - const selectedMultipleOrNone$ = selectedItemRows$.filter((r) => r.length > 1 || r.length === 0); - const loadedItemIDs$ = loadedItems$.map((rows) => new Set(rows.map((r) => r._id))).share(); - const currentItemWasRemoved$ = loadedItemIDs$ - .withLatestFrom( - itemID$.filter((v) => v && v !== 'new'), + const selectedItemRowsIDs$ = selectedItemRows$.pipe(map((rows) => rows.map((r) => r._id)), share()); + const singleSelectionEdit$ = selectedItemRows$.pipe(filter((r) => r && r.length === 1), pluck('0', '_id')); + const selectedMultipleOrNone$ = selectedItemRows$.pipe(filter((r) => r.length > 1 || r.length === 0)); + const loadedItemIDs$ = loadedItems$.pipe(map((rows) => new Set(rows.map((r) => r._id))), share()); + const currentItemWasRemoved$ = loadedItemIDs$.pipe( + withLatestFrom( + itemID$.pipe(filter((v) => v && v !== 'new')), /** * Without startWith currentItemWasRemoved$ won't emit in the following scenario: * 1. User opens items page (no item id in location). * 2. Selection manager commands to edit first item. * 3. User removes said item. */ - selectedItemRowsIDs$.startWith([]) - ) - .filter(([existingIDs, itemID, selectedIDs]) => !existingIDs.has(itemID)) - .map(([existingIDs, itemID, selectedIDs]) => selectedIDs.filter((id) => id !== itemID)) - .share(); + selectedItemRowsIDs$.pipe(startWith([])) + ), + filter(([existingIDs, itemID, selectedIDs]) => !existingIDs.has(itemID)), + map(([existingIDs, itemID, selectedIDs]) => selectedIDs.filter((id) => id !== itemID)), + share() + ); // Edit first loaded item or when there's only one item selected - const editGoes$ = merge(firstItemID$, singleSelectionEdit$) + const editGoes$ = merge(firstItemID$, singleSelectionEdit$).pipe( // Don't go to non-existing items. // Happens when user naviagtes to older history and some items were already removed. - .withLatestFrom(loadedItemIDs$).filter(([id, loaded]) => id && loaded.has(id)).pluck('0'); + withLatestFrom(loadedItemIDs$), + filter(([id, loaded]) => id && loaded.has(id)), + pluck('0') + ); // Stop edit when multiple or none items are selected or when current item was removed const editLeaves$ = merge( - selectedMultipleOrNone$.mapTo({}), - currentItemWasRemoved$.mapTo({location: 'replace', custom: {justIDUpdate: true}}) - ).share(); + selectedMultipleOrNone$.pipe(mapTo({})), + currentItemWasRemoved$.pipe(mapTo({location: 'replace', custom: {justIDUpdate: true}})) + ).pipe(share()); const selectedItemIDs$ = merge( // Select nothing when creating an item or select current item - itemID$.filter((id) => id).map((id) => id === 'new' ? [] : [id]), + itemID$.pipe(filter((id) => id), map((id) => id === 'new' ? [] : [id])), // Restore previous item selection when transition gets aborted - abortedTransitions$.withLatestFrom(itemID$, (_, id) => [id]), + abortedTransitions$.pipe(withLatestFrom(itemID$, (_, id) => [id])), // Select all incoming selected rows selectedItemRowsIDs$ - ) - // If nothing's selected and there are zero rows, ui-grid will behave as if all rows are selected - .startWith([]) - // Some scenarios cause same item to be selected multiple times in a row, - // so it makes sense to filter out duplicate entries - .distinctUntilChanged(isEqual) - .share(); + ).pipe( + // If nothing's selected and there are zero rows, ui-grid will behave as if all rows are selected + startWith([]), + // Some scenarios cause same item to be selected multiple times in a row, + // so it makes sense to filter out duplicate entries + distinctUntilChanged(isEqual), + share() + ); return {selectedItemIDs$, editGoes$, editLeaves$}; }; diff --git a/modules/web-console/frontend/app/components/page-configure/services/ConfigureState.js b/modules/web-console/frontend/app/components/page-configure/services/ConfigureState.js index 27e227d8dce9b..143944cf22a13 100644 --- a/modules/web-console/frontend/app/components/page-configure/services/ConfigureState.js +++ b/modules/web-console/frontend/app/components/page-configure/services/ConfigureState.js @@ -15,10 +15,8 @@ * limitations under the License. */ -import {Subject} from 'rxjs/Subject'; -import {BehaviorSubject} from 'rxjs/BehaviorSubject'; -import 'rxjs/add/operator/do'; -import 'rxjs/add/operator/scan'; +import {Subject, BehaviorSubject} from 'rxjs'; +import {tap, scan} from 'rxjs/operators'; export default class ConfigureState { constructor() { @@ -30,14 +28,18 @@ export default class ConfigureState { const reducer = (state = {}, action) => { try { return this._combinedReducer(state, action); - } catch (e) { + } + catch (e) { console.error(e); return state; } }; - this.actions$.scan(reducer, {}).do((v) => this.state$.next(v)).subscribe(); + this.actions$.pipe( + scan(reducer, {}), + tap((v) => this.state$.next(v)) + ).subscribe(); } addReducer(combineFn) { diff --git a/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.js b/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.js index d81921ea013be..5eaedde6ca1ad 100644 --- a/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.js +++ b/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.js @@ -15,21 +15,11 @@ * limitations under the License. */ -import {Observable} from 'rxjs/Observable'; -import 'rxjs/add/operator/filter'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/take'; -import 'rxjs/add/operator/switchMap'; -import 'rxjs/add/operator/merge'; -import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/withLatestFrom'; -import 'rxjs/add/observable/empty'; -import 'rxjs/add/observable/of'; -import 'rxjs/add/observable/from'; -import 'rxjs/add/observable/forkJoin'; -import 'rxjs/add/observable/timer'; import cloneDeep from 'lodash/cloneDeep'; +import {merge, timer} from 'rxjs'; +import {take, tap, ignoreElements, filter, map, pluck} from 'rxjs/operators'; + import { ofType } from '../store/effects'; @@ -50,20 +40,25 @@ export default class PageConfigure { } getClusterConfiguration({clusterID, isDemo}) { - return Observable.merge( - Observable - .timer(1) - .take(1) - .do(() => this.ConfigureState.dispatchAction({type: 'LOAD_COMPLETE_CONFIGURATION', clusterID, isDemo})) - .ignoreElements(), - this.ConfigureState.actions$.let(ofType('LOAD_COMPLETE_CONFIGURATION_ERR')).take(1).pluck('error').map((e) => Promise.reject(e)), - this.ConfigureState.state$ - .let(this.ConfigSelectors.selectCompleteClusterConfiguration({clusterID, isDemo})) - .filter((c) => c.__isComplete) - .take(1) - .map((data) => ({...data, clusters: [cloneDeep(data.cluster)]})) - ) - .take(1) + return merge( + timer(1).pipe( + take(1), + tap(() => this.ConfigureState.dispatchAction({type: 'LOAD_COMPLETE_CONFIGURATION', clusterID, isDemo})), + ignoreElements() + ), + this.ConfigureState.actions$.pipe( + ofType('LOAD_COMPLETE_CONFIGURATION_ERR'), + take(1), + pluck('error'), + map((e) => Promise.reject(e)) + ), + this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectCompleteClusterConfiguration({clusterID, isDemo}), + filter((c) => c.__isComplete), + take(1), + map((data) => ({...data, clusters: [cloneDeep(data.cluster)]})) + ) + ).pipe(take(1)) .toPromise(); } } diff --git a/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.spec.js b/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.spec.js index bc72cd338ea9a..145eed67f69bd 100644 --- a/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.spec.js +++ b/modules/web-console/frontend/app/components/page-configure/services/PageConfigure.spec.js @@ -18,11 +18,8 @@ import {suite, test} from 'mocha'; import {assert} from 'chai'; import {spy} from 'sinon'; -import {TestScheduler} from 'rxjs/testing/TestScheduler'; -import {Observable} from 'rxjs/Observable'; - -import 'rxjs/add/observable/of'; -import 'rxjs/add/observable/throw'; +import {of, throwError} from 'rxjs'; +import {TestScheduler} from 'rxjs/testing'; const mocks = () => new Map([ ['IgniteConfigurationResource', {}], @@ -79,7 +76,7 @@ suite.skip('PageConfigure service', () => { const deps = mocks() .set('Clusters', { - saveCluster$: (c) => Observable.of({data: 99}) + saveCluster$: (c) => of({data: 99}) }) .set('ConfigureState', { actions$: testScheduler.createHotObservable(actions, values), @@ -135,8 +132,8 @@ suite.skip('PageConfigure service', () => { const deps = mocks() .set('Clusters', { saveCluster$: (c) => c.name === values.b.clusters[0].name - ? Observable.of({data: 99}) - : Observable.throw() + ? of({data: 99}) + : throwError() }) .set('ConfigureState', { actions$: testScheduler.createHotObservable(actions, values), @@ -188,7 +185,7 @@ suite.skip('PageConfigure service', () => { dispatchAction: spy() }) .set('Clusters', { - removeCluster$: (v) => Observable.of(v) + removeCluster$: (v) => of(v) }); const s = new PageConfigure(...deps.values()); @@ -232,7 +229,7 @@ suite.skip('PageConfigure service', () => { dispatchAction: spy() }) .set('Clusters', { - removeCluster$: (v) => v._id % 2 ? Observable.of(v) : Observable.throw() + removeCluster$: (v) => v._id % 2 ? of(v) : throwError() }); const s = new PageConfigure(...deps.values()); diff --git a/modules/web-console/frontend/app/components/page-configure/states.js b/modules/web-console/frontend/app/components/page-configure/states.js index 3ba5bb70f18bc..3b8dec948d644 100644 --- a/modules/web-console/frontend/app/components/page-configure/states.js +++ b/modules/web-console/frontend/app/components/page-configure/states.js @@ -20,19 +20,21 @@ import pageConfigureAdvancedModelsComponent from '../page-configure-advanced/com import pageConfigureAdvancedCachesComponent from '../page-configure-advanced/components/page-configure-advanced-caches/component'; import pageConfigureAdvancedIGFSComponent from '../page-configure-advanced/components/page-configure-advanced-igfs/component'; -import {Observable} from 'rxjs/Observable'; +import {Observable, from, combineLatest} from 'rxjs'; +import {switchMap, take, map} from 'rxjs/operators'; const idRegex = `new|[a-z0-9]+`; const shortCachesResolve = ['ConfigSelectors', 'ConfigureState', 'ConfigEffects', '$transition$', function(ConfigSelectors, ConfigureState, {etp}, $transition$) { if ($transition$.params().clusterID === 'new') return Promise.resolve(); - return Observable.fromPromise($transition$.injector().getAsync('_cluster')) - .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1)) - .switchMap((cluster) => { + return from($transition$.injector().getAsync('_cluster')).pipe( + switchMap(() => ConfigureState.state$.pipe(ConfigSelectors.selectCluster($transition$.params().clusterID), take(1))), + switchMap((cluster) => { return etp('LOAD_SHORT_CACHES', {ids: cluster.caches, clusterID: cluster._id}); }) - .toPromise(); + ) + .toPromise(); }]; function registerStates($stateProvider) { @@ -77,17 +79,19 @@ function registerStates($stateProvider) { redirectTo: ($transition$) => { const [ConfigureState, ConfigSelectors] = ['ConfigureState', 'ConfigSelectors'].map((t) => $transition$.injector().get(t)); const waitFor = ['_cluster', '_shortClusters'].map((t) => $transition$.injector().getAsync(t)); - return Observable.fromPromise(Promise.all(waitFor)).switchMap(() => { - return Observable.combineLatest( - ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1), - ConfigureState.state$.let(ConfigSelectors.selectShortClusters()).take(1) - ); - }) - .map(([cluster = {caches: []}, clusters]) => { - return (clusters.value.size > 10 || cluster.caches.length > 5) - ? 'base.configuration.edit.advanced' - : 'base.configuration.edit.basic'; - }) + return from(Promise.all(waitFor)).pipe( + switchMap(() => { + return combineLatest( + ConfigureState.state$.pipe(ConfigSelectors.selectCluster($transition$.params().clusterID), take(1)), + ConfigureState.state$.pipe(ConfigSelectors.selectShortClusters(), take(1)) + ); + }), + map(([cluster = {caches: []}, clusters]) => { + return (clusters.value.size > 10 || cluster.caches.length > 5) + ? 'base.configuration.edit.advanced' + : 'base.configuration.edit.basic'; + }) + ) .toPromise(); }, failState: 'signin', @@ -138,16 +142,17 @@ function registerStates($stateProvider) { if ($transition$.params().clusterID === 'new') return Promise.resolve(); - return Observable.fromPromise($transition$.injector().getAsync('_cluster')) - .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1)) - .map((cluster) => { + return from($transition$.injector().getAsync('_cluster')).pipe( + switchMap(() => ConfigureState.state$.pipe(ConfigSelectors.selectCluster($transition$.params().clusterID), take(1))), + map((cluster) => { return Promise.all([ etp('LOAD_SHORT_CACHES', {ids: cluster.caches, clusterID: cluster._id}), etp('LOAD_SHORT_MODELS', {ids: cluster.models, clusterID: cluster._id}), etp('LOAD_SHORT_IGFSS', {ids: cluster.igfss, clusterID: cluster._id}) ]); }) - .toPromise(); + ) + .toPromise(); }] }, resolvePolicy: { @@ -163,6 +168,7 @@ function registerStates($stateProvider) { resolve: { _cache: ['ConfigEffects', '$transition$', ({etp}, $transition$) => { const {clusterID, cacheID} = $transition$.params(); + if (cacheID === 'new') return Promise.resolve(); @@ -188,15 +194,15 @@ function registerStates($stateProvider) { if ($transition$.params().clusterID === 'new') return Promise.resolve(); - return Observable.fromPromise($transition$.injector().getAsync('_cluster')) - .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1)) - .map((cluster) => { + return from($transition$.injector().getAsync('_cluster')).pipe( + switchMap(() => ConfigureState.state$.pipe(ConfigSelectors.selectCluster($transition$.params().clusterID), take(1))), + map((cluster) => { return Promise.all([ etp('LOAD_SHORT_CACHES', {ids: cluster.caches, clusterID: cluster._id}), etp('LOAD_SHORT_MODELS', {ids: cluster.models, clusterID: cluster._id}) ]); }) - .toPromise(); + ).toPromise(); }] }, resolvePolicy: { @@ -235,14 +241,14 @@ function registerStates($stateProvider) { if ($transition$.params().clusterID === 'new') return Promise.resolve(); - return Observable.fromPromise($transition$.injector().getAsync('_cluster')) - .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1)) - .map((cluster) => { + return from($transition$.injector().getAsync('_cluster')).pipe( + switchMap(() => ConfigureState.state$.pipe(ConfigSelectors.selectCluster($transition$.params().clusterID), take(1))), + map((cluster) => { return Promise.all([ etp('LOAD_SHORT_IGFSS', {ids: cluster.igfss, clusterID: cluster._id}) ]); }) - .toPromise(); + ).toPromise(); }] }, resolvePolicy: { diff --git a/modules/web-console/frontend/app/components/page-configure/store/effects.js b/modules/web-console/frontend/app/components/page-configure/store/effects.js index 014076b2b5a76..ac807dce95d7d 100644 --- a/modules/web-console/frontend/app/components/page-configure/store/effects.js +++ b/modules/web-console/frontend/app/components/page-configure/store/effects.js @@ -15,23 +15,8 @@ * limitations under the License. */ -import {Observable} from 'rxjs/Observable'; -import 'rxjs/add/operator/ignoreElements'; -import 'rxjs/add/operator/let'; -import 'rxjs/add/operator/exhaustMap'; -import 'rxjs/add/operator/switchMap'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/pluck'; -import 'rxjs/add/operator/withLatestFrom'; -import 'rxjs/add/operator/merge'; -import 'rxjs/add/operator/take'; -import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/zip'; -import {merge} from 'rxjs/observable/merge'; -import {empty} from 'rxjs/observable/empty'; -import {of} from 'rxjs/observable/of'; -import {from} from 'rxjs/observable/from'; -import {fromPromise} from 'rxjs/observable/fromPromise'; +import {merge, empty, of, from} from 'rxjs'; +import {mapTo, filter, tap, ignoreElements, exhaustMap, switchMap, map, pluck, withLatestFrom, take, catchError, zip} from 'rxjs/operators'; import uniq from 'lodash/uniq'; import {uniqueName} from 'app/utils/uniqueName'; import {defaultNames} from '../defaultNames'; @@ -81,7 +66,7 @@ import Models from 'app/services/Models'; import IGFSs from 'app/services/IGFSs'; import {Confirm} from 'app/services/Confirm.service'; -export const ofType = (type) => (s) => s.filter((a) => a.type === type); +export const ofType = (type) => (s) => s.pipe(filter((a) => a.type === type)); export default class ConfigEffects { static $inject = [ @@ -124,35 +109,37 @@ export default class ConfigEffects { this.Confirm = Confirm; this.configurationDownload = ConfigurationDownload; - this.loadConfigurationEffect$ = this.ConfigureState.actions$ - .let(ofType('LOAD_COMPLETE_CONFIGURATION')) - .exhaustMap((action) => { - return fromPromise(this.Clusters.getConfiguration(action.clusterID)) - .switchMap(({data}) => of( + this.loadConfigurationEffect$ = this.ConfigureState.actions$.pipe( + ofType('LOAD_COMPLETE_CONFIGURATION'), + exhaustMap((action) => { + return from(this.Clusters.getConfiguration(action.clusterID)).pipe( + switchMap(({data}) => of( completeConfiguration(data), {type: 'LOAD_COMPLETE_CONFIGURATION_OK', data} - )) - .catch((error) => of({ + )), + catchError((error) => of({ type: 'LOAD_COMPLETE_CONFIGURATION_ERR', error: { message: `Failed to load cluster configuration: ${error.data}.` }, action - })); - }); + }))); + }) + ); - this.storeConfigurationEffect$ = this.ConfigureState.actions$ - .let(ofType(COMPLETE_CONFIGURATION)) - .exhaustMap(({configuration: {cluster, caches, models, igfss}}) => of(...[ + this.storeConfigurationEffect$ = this.ConfigureState.actions$.pipe( + ofType(COMPLETE_CONFIGURATION), + exhaustMap(({configuration: {cluster, caches, models, igfss}}) => of(...[ cluster && {type: clustersActionTypes.UPSERT, items: [cluster]}, caches && caches.length && {type: cachesActionTypes.UPSERT, items: caches}, models && models.length && {type: modelsActionTypes.UPSERT, items: models}, igfss && igfss.length && {type: igfssActionTypes.UPSERT, items: igfss} - ].filter((v) => v))); + ].filter((v) => v))) + ); - this.saveCompleteConfigurationEffect$ = this.ConfigureState.actions$ - .let(ofType(ADVANCED_SAVE_COMPLETE_CONFIGURATION)) - .switchMap((action) => { + this.saveCompleteConfigurationEffect$ = this.ConfigureState.actions$.pipe( + ofType(ADVANCED_SAVE_COMPLETE_CONFIGURATION), + switchMap((action) => { const actions = [ { type: modelsActionTypes.UPSERT, @@ -188,62 +175,68 @@ export default class ConfigEffects { } ].filter((a) => a.items.length); - return of(...actions) - .merge( - fromPromise(Clusters.saveAdvanced(action.changedItems)) - .switchMap((res) => { - return of( - {type: 'EDIT_CLUSTER', cluster: action.changedItems.cluster}, - {type: 'ADVANCED_SAVE_COMPLETE_CONFIGURATION_OK', changedItems: action.changedItems} - ); - }) - .catch((res) => { - return of({ - type: 'ADVANCED_SAVE_COMPLETE_CONFIGURATION_ERR', - changedItems: action.changedItems, - action, - error: { - message: `Failed to save cluster "${action.changedItems.cluster.name}": ${res.data}.` - } - }, { - type: 'UNDO_ACTIONS', - actions - }); - }) + return merge( + of(...actions), + from(Clusters.saveAdvanced(action.changedItems)).pipe( + switchMap((res) => { + return of( + {type: 'EDIT_CLUSTER', cluster: action.changedItems.cluster}, + {type: 'ADVANCED_SAVE_COMPLETE_CONFIGURATION_OK', changedItems: action.changedItems} + ); + }), + catchError((res) => { + return of({ + type: 'ADVANCED_SAVE_COMPLETE_CONFIGURATION_ERR', + changedItems: action.changedItems, + action, + error: { + message: `Failed to save cluster "${action.changedItems.cluster.name}": ${res.data}.` + } + }, { + type: 'UNDO_ACTIONS', + actions + }); + }) + ) ); - }); - - this.addCacheToEditEffect$ = this.ConfigureState.actions$ - .let(ofType('ADD_CACHE_TO_EDIT')) - .switchMap(() => this.ConfigureState.state$.let(this.ConfigSelectors.selectCacheToEdit('new')).take(1)) - .map((cache) => ({type: 'UPSERT_CLUSTER_ITEM', itemType: 'caches', item: cache})); - - this.errorNotificationsEffect$ = this.ConfigureState.actions$ - .filter((a) => a.error) - .do((action) => this.IgniteMessages.showError(action.error)) - .ignoreElements(); - - this.loadUserClustersEffect$ = this.ConfigureState.actions$ - .let(ofType('LOAD_USER_CLUSTERS')) - .exhaustMap((a) => { - return fromPromise(this.Clusters.getClustersOverview()) - .switchMap(({data}) => of( + }) + ); + + this.addCacheToEditEffect$ = this.ConfigureState.actions$.pipe( + ofType('ADD_CACHE_TO_EDIT'), + switchMap(() => this.ConfigureState.state$.pipe(this.ConfigSelectors.selectCacheToEdit('new'), take(1))), + map((cache) => ({type: 'UPSERT_CLUSTER_ITEM', itemType: 'caches', item: cache})) + ); + + this.errorNotificationsEffect$ = this.ConfigureState.actions$.pipe( + filter((a) => a.error), + tap((action) => this.IgniteMessages.showError(action.error)), + ignoreElements() + ); + + this.loadUserClustersEffect$ = this.ConfigureState.actions$.pipe( + ofType('LOAD_USER_CLUSTERS'), + exhaustMap((a) => { + return from(this.Clusters.getClustersOverview()).pipe( + switchMap(({data}) => of( {type: shortClustersActionTypes.SET, items: data}, {type: `${a.type}_OK`} - )) - .catch((error) => of({ + )), + catchError((error) => of({ type: `${a.type}_ERR`, error: { message: `Failed to load clusters: ${error.data}` }, action: a - })); - }); + })) + ); + }) + ); - this.loadAndEditClusterEffect$ = ConfigureState.actions$ - .let(ofType('LOAD_AND_EDIT_CLUSTER')) - .withLatestFrom(this.ConfigureState.state$.let(this.ConfigSelectors.selectShortClustersValue())) - .exhaustMap(([a, shortClusters]) => { + this.loadAndEditClusterEffect$ = ConfigureState.actions$.pipe( + ofType('LOAD_AND_EDIT_CLUSTER'), + withLatestFrom(this.ConfigureState.state$.pipe(this.ConfigSelectors.selectShortClustersValue())), + exhaustMap(([a, shortClusters]) => { if (a.clusterID === 'new') { return of( { @@ -256,226 +249,268 @@ export default class ConfigEffects { {type: 'LOAD_AND_EDIT_CLUSTER_OK'} ); } - return this.ConfigureState.state$.let(this.ConfigSelectors.selectCluster(a.clusterID)).take(1) - .switchMap((cluster) => { + return this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectCluster(a.clusterID), + take(1), + switchMap((cluster) => { if (cluster) { return of( {type: 'EDIT_CLUSTER', cluster}, {type: 'LOAD_AND_EDIT_CLUSTER_OK'} ); } - return from(this.Clusters.getCluster(a.clusterID)) - .switchMap(({data}) => of( + return from(this.Clusters.getCluster(a.clusterID)).pipe( + switchMap(({data}) => of( {type: clustersActionTypes.UPSERT, items: [data]}, {type: 'EDIT_CLUSTER', cluster: data}, {type: 'LOAD_AND_EDIT_CLUSTER_OK'} - )) - .catch((error) => of({ + )), + catchError((error) => of({ type: 'LOAD_AND_EDIT_CLUSTER_ERR', error: { message: `Failed to load cluster: ${error.data}.` } - })); - }); - }); - - this.loadCacheEffect$ = this.ConfigureState.actions$ - .let(ofType('LOAD_CACHE')) - .exhaustMap((a) => { - return this.ConfigureState.state$.let(this.ConfigSelectors.selectCache(a.cacheID)).take(1) - .switchMap((cache) => { + })) + ); + }) + ); + }) + ); + + this.loadCacheEffect$ = this.ConfigureState.actions$.pipe( + ofType('LOAD_CACHE'), + exhaustMap((a) => { + return this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectCache(a.cacheID), + take(1), + switchMap((cache) => { if (cache) return of({type: `${a.type}_OK`, cache}); - return fromPromise(this.Caches.getCache(a.cacheID)) - .switchMap(({data}) => of( + return from(this.Caches.getCache(a.cacheID)).pipe( + switchMap(({data}) => of( {type: 'CACHE', cache: data}, {type: `${a.type}_OK`, cache: data} - )); - }) - .catch((error) => of({ + )) + ); + }), + catchError((error) => of({ type: `${a.type}_ERR`, error: { message: `Failed to load cache: ${error.data}.` } - })); - }); + })) + ); + }) + ); - this.storeCacheEffect$ = this.ConfigureState.actions$ - .let(ofType('CACHE')) - .map((a) => ({type: cachesActionTypes.UPSERT, items: [a.cache]})); + this.storeCacheEffect$ = this.ConfigureState.actions$.pipe( + ofType('CACHE'), + map((a) => ({type: cachesActionTypes.UPSERT, items: [a.cache]})) + ); - this.loadShortCachesEffect$ = ConfigureState.actions$ - .let(ofType('LOAD_SHORT_CACHES')) - .exhaustMap((a) => { + this.loadShortCachesEffect$ = ConfigureState.actions$.pipe( + ofType('LOAD_SHORT_CACHES'), + exhaustMap((a) => { if (!(a.ids || []).length) return of({type: `${a.type}_OK`}); - return this.ConfigureState.state$.let(this.ConfigSelectors.selectShortCaches()).take(1) - .switchMap((items) => { + return this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectShortCaches(), + take(1), + switchMap((items) => { if (!items.pristine && a.ids && a.ids.every((_id) => items.value.has(_id))) return of({type: `${a.type}_OK`}); - return fromPromise(this.Clusters.getClusterCaches(a.clusterID)) - .switchMap(({data}) => of( + return from(this.Clusters.getClusterCaches(a.clusterID)).pipe( + switchMap(({data}) => of( {type: shortCachesActionTypes.UPSERT, items: data}, {type: `${a.type}_OK`} - )); - }) - .catch((error) => of({ + )) + ); + }), + catchError((error) => of({ type: `${a.type}_ERR`, error: { message: `Failed to load caches: ${error.data}.` }, action: a - })); - }); - - this.loadIgfsEffect$ = this.ConfigureState.actions$ - .let(ofType('LOAD_IGFS')) - .exhaustMap((a) => { - return this.ConfigureState.state$.let(this.ConfigSelectors.selectIGFS(a.igfsID)).take(1) - .switchMap((igfs) => { + })) + ); + }) + ); + + this.loadIgfsEffect$ = this.ConfigureState.actions$.pipe( + ofType('LOAD_IGFS'), + exhaustMap((a) => { + return this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectIGFS(a.igfsID), + take(1), + switchMap((igfs) => { if (igfs) return of({type: `${a.type}_OK`, igfs}); - return fromPromise(this.IGFSs.getIGFS(a.igfsID)) - .switchMap(({data}) => of( + return from(this.IGFSs.getIGFS(a.igfsID)).pipe( + switchMap(({data}) => of( {type: 'IGFS', igfs: data}, {type: `${a.type}_OK`, igfs: data} - )); - }) - .catch((error) => of({ + )) + ); + }), + catchError((error) => of({ type: `${a.type}_ERR`, error: { message: `Failed to load IGFS: ${error.data}.` } - })); - }); + })) + ); + }) + ); - this.storeIgfsEffect$ = this.ConfigureState.actions$ - .let(ofType('IGFS')) - .map((a) => ({type: igfssActionTypes.UPSERT, items: [a.igfs]})); + this.storeIgfsEffect$ = this.ConfigureState.actions$.pipe( + ofType('IGFS'), + map((a) => ({type: igfssActionTypes.UPSERT, items: [a.igfs]})) + ); - this.loadShortIgfssEffect$ = ConfigureState.actions$ - .let(ofType('LOAD_SHORT_IGFSS')) - .exhaustMap((a) => { + this.loadShortIgfssEffect$ = ConfigureState.actions$.pipe( + ofType('LOAD_SHORT_IGFSS'), + exhaustMap((a) => { if (!(a.ids || []).length) { return of( {type: shortIGFSsActionTypes.UPSERT, items: []}, {type: `${a.type}_OK`} ); } - return this.ConfigureState.state$.let(this.ConfigSelectors.selectShortIGFSs()).take(1) - .switchMap((items) => { + return this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectShortIGFSs(), + take(1), + switchMap((items) => { if (!items.pristine && a.ids && a.ids.every((_id) => items.value.has(_id))) return of({type: `${a.type}_OK`}); - return fromPromise(this.Clusters.getClusterIGFSs(a.clusterID)) - .switchMap(({data}) => of( + return from(this.Clusters.getClusterIGFSs(a.clusterID)).pipe( + switchMap(({data}) => of( {type: shortIGFSsActionTypes.UPSERT, items: data}, {type: `${a.type}_OK`} - )); - }) - .catch((error) => of({ + )) + ); + }), + catchError((error) => of({ type: `${a.type}_ERR`, error: { message: `Failed to load IGFSs: ${error.data}.` }, action: a - })); - }); - - this.loadModelEffect$ = this.ConfigureState.actions$ - .let(ofType('LOAD_MODEL')) - .exhaustMap((a) => { - return this.ConfigureState.state$.let(this.ConfigSelectors.selectModel(a.modelID)).take(1) - .switchMap((model) => { + })) + ); + }) + ); + + this.loadModelEffect$ = this.ConfigureState.actions$.pipe( + ofType('LOAD_MODEL'), + exhaustMap((a) => { + return this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectModel(a.modelID), + take(1), + switchMap((model) => { if (model) return of({type: `${a.type}_OK`, model}); - return fromPromise(this.Models.getModel(a.modelID)) - .switchMap(({data}) => of( + return from(this.Models.getModel(a.modelID)).pipe( + switchMap(({data}) => of( {type: 'MODEL', model: data}, {type: `${a.type}_OK`, model: data} - )); - }) - .catch((error) => of({ + )) + ); + }), + catchError((error) => of({ type: `${a.type}_ERR`, error: { message: `Failed to load domain model: ${error.data}.` } - })); - }); + })) + ); + }) + ); - this.storeModelEffect$ = this.ConfigureState.actions$ - .let(ofType('MODEL')) - .map((a) => ({type: modelsActionTypes.UPSERT, items: [a.model]})); + this.storeModelEffect$ = this.ConfigureState.actions$.pipe( + ofType('MODEL'), + map((a) => ({type: modelsActionTypes.UPSERT, items: [a.model]})) + ); - this.loadShortModelsEffect$ = this.ConfigureState.actions$ - .let(ofType('LOAD_SHORT_MODELS')) - .exhaustMap((a) => { + this.loadShortModelsEffect$ = this.ConfigureState.actions$.pipe( + ofType('LOAD_SHORT_MODELS'), + exhaustMap((a) => { if (!(a.ids || []).length) { return of( {type: shortModelsActionTypes.UPSERT, items: []}, {type: `${a.type}_OK`} ); } - return this.ConfigureState.state$.let(this.ConfigSelectors.selectShortModels()).take(1) - .switchMap((items) => { + return this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectShortModels(), + take(1), + switchMap((items) => { if (!items.pristine && a.ids && a.ids.every((_id) => items.value.has(_id))) return of({type: `${a.type}_OK`}); - return fromPromise(this.Clusters.getClusterModels(a.clusterID)) - .switchMap(({data}) => of( + return from(this.Clusters.getClusterModels(a.clusterID)).pipe( + switchMap(({data}) => of( {type: shortModelsActionTypes.UPSERT, items: data}, {type: `${a.type}_OK`} - )); - }) - .catch((error) => of({ + )) + ); + }), + catchError((error) => of({ type: `${a.type}_ERR`, error: { message: `Failed to load domain models: ${error.data}.` }, action: a - })); - }); - - this.basicSaveRedirectEffect$ = this.ConfigureState.actions$ - .let(ofType(BASIC_SAVE_OK)) - .do((a) => this.$state.go('base.configuration.edit.basic', {clusterID: a.changedItems.cluster._id}, {location: 'replace', custom: {justIDUpdate: true}})) - .ignoreElements(); - - this.basicDownloadAfterSaveEffect$ = this.ConfigureState.actions$.let(ofType(BASIC_SAVE_AND_DOWNLOAD)) - .zip(this.ConfigureState.actions$.let(ofType(BASIC_SAVE_OK))) - .pluck('1') - .do((a) => this.configurationDownload.downloadClusterConfiguration(a.changedItems.cluster)) - .ignoreElements(); + })) + ); + }) + ); + + this.basicSaveRedirectEffect$ = this.ConfigureState.actions$.pipe( + ofType(BASIC_SAVE_OK), + tap((a) => this.$state.go('base.configuration.edit.basic', {clusterID: a.changedItems.cluster._id}, {location: 'replace', custom: {justIDUpdate: true}})), + ignoreElements() + ); + + this.basicDownloadAfterSaveEffect$ = this.ConfigureState.actions$.pipe( + ofType(BASIC_SAVE_AND_DOWNLOAD), + zip(this.ConfigureState.actions$.pipe(ofType(BASIC_SAVE_OK))), + pluck('1'), + tap((a) => this.configurationDownload.downloadClusterConfiguration(a.changedItems.cluster)), + ignoreElements() + ); this.advancedDownloadAfterSaveEffect$ = merge( - this.ConfigureState.actions$.let(ofType(ADVANCED_SAVE_CLUSTER)), - this.ConfigureState.actions$.let(ofType(ADVANCED_SAVE_CACHE)), - this.ConfigureState.actions$.let(ofType(ADVANCED_SAVE_IGFS)), - this.ConfigureState.actions$.let(ofType(ADVANCED_SAVE_MODEL)), - ) - .filter((a) => a.download) - .zip(this.ConfigureState.actions$.let(ofType('ADVANCED_SAVE_COMPLETE_CONFIGURATION_OK'))) - .pluck('1') - .do((a) => this.configurationDownload.downloadClusterConfiguration(a.changedItems.cluster)) - .ignoreElements(); - - this.advancedSaveRedirectEffect$ = this.ConfigureState.actions$ - .let(ofType('ADVANCED_SAVE_COMPLETE_CONFIGURATION_OK')) - .withLatestFrom(this.ConfigureState.actions$.let(ofType(ADVANCED_SAVE_COMPLETE_CONFIGURATION))) - .pluck('1', 'changedItems') - .map((req) => { + this.ConfigureState.actions$.pipe(ofType(ADVANCED_SAVE_CLUSTER)), + this.ConfigureState.actions$.pipe(ofType(ADVANCED_SAVE_CACHE)), + this.ConfigureState.actions$.pipe(ofType(ADVANCED_SAVE_IGFS)), + this.ConfigureState.actions$.pipe(ofType(ADVANCED_SAVE_MODEL)), + ).pipe( + filter((a) => a.download), + zip(this.ConfigureState.actions$.pipe(ofType('ADVANCED_SAVE_COMPLETE_CONFIGURATION_OK'))), + pluck('1'), + tap((a) => this.configurationDownload.downloadClusterConfiguration(a.changedItems.cluster)), + ignoreElements() + ); + + this.advancedSaveRedirectEffect$ = this.ConfigureState.actions$.pipe( + ofType('ADVANCED_SAVE_COMPLETE_CONFIGURATION_OK'), + withLatestFrom(this.ConfigureState.actions$.pipe(ofType(ADVANCED_SAVE_COMPLETE_CONFIGURATION))), + pluck('1', 'changedItems'), + map((req) => { const firstChangedItem = Object.keys(req).filter((k) => k !== 'cluster') .map((k) => Array.isArray(req[k]) ? [k, req[k][0]] : [k, req[k]]) .filter((v) => v[1]) .pop(); return firstChangedItem ? [...firstChangedItem, req.cluster] : ['cluster', req.cluster, req.cluster]; - }) - .do(([type, value, cluster]) => { + }), + tap(([type, value, cluster]) => { const go = (state, params = {}) => this.$state.go( state, {...params, clusterID: cluster._id}, {location: 'replace', custom: {justIDUpdate: true}} ); @@ -523,66 +558,76 @@ export default class ConfigEffects { default: break; } - }) - .ignoreElements(); + }), + ignoreElements() + ); - this.removeClusterItemsEffect$ = this.ConfigureState.actions$ - .let(ofType(REMOVE_CLUSTER_ITEMS)) - .exhaustMap((a) => { + this.removeClusterItemsEffect$ = this.ConfigureState.actions$.pipe( + ofType(REMOVE_CLUSTER_ITEMS), + exhaustMap((a) => { return a.confirm // TODO: list items to remove in confirmation - ? fromPromise(this.Confirm.confirm('Are you sure you want to remove these items?')) - .mapTo(a) - .catch(() => empty()) + ? from(this.Confirm.confirm('Are you sure you want to remove these items?')).pipe( + mapTo(a), + catchError(() => empty()) + ) : of(a); - }) - .map((a) => removeClusterItemsConfirmed(a.clusterID, a.itemType, a.itemIDs)); - - this.persistRemovedClusterItemsEffect$ = this.ConfigureState.actions$ - .let(ofType(REMOVE_CLUSTER_ITEMS_CONFIRMED)) - .withLatestFrom(this.ConfigureState.actions$.let(ofType(REMOVE_CLUSTER_ITEMS))) - .filter(([a, b]) => { + }), + map((a) => removeClusterItemsConfirmed(a.clusterID, a.itemType, a.itemIDs)) + ); + + this.persistRemovedClusterItemsEffect$ = this.ConfigureState.actions$.pipe( + ofType(REMOVE_CLUSTER_ITEMS_CONFIRMED), + withLatestFrom(this.ConfigureState.actions$.pipe(ofType(REMOVE_CLUSTER_ITEMS))), + filter(([a, b]) => { return a.itemType === b.itemType && b.save && JSON.stringify(a.itemIDs) === JSON.stringify(b.itemIDs); - }) - .pluck('0') - .withLatestFrom(this.ConfigureState.state$.pluck('edit')) - .map(([action, edit]) => advancedSaveCompleteConfiguration(edit)); - - this.confirmClustersRemovalEffect$ = this.ConfigureState.actions$ - .let(ofType(CONFIRM_CLUSTERS_REMOVAL)) - .pluck('clusterIDs') - .switchMap((ids) => this.ConfigureState.state$.let(this.ConfigSelectors.selectClusterNames(ids)).take(1)) - .exhaustMap((names) => { - return fromPromise(this.Confirm.confirm(` + }), + pluck('0'), + withLatestFrom(this.ConfigureState.state$.pipe(pluck('edit'))), + map(([action, edit]) => advancedSaveCompleteConfiguration(edit)) + ); + + this.confirmClustersRemovalEffect$ = this.ConfigureState.actions$.pipe( + ofType(CONFIRM_CLUSTERS_REMOVAL), + pluck('clusterIDs'), + switchMap((ids) => this.ConfigureState.state$.pipe( + this.ConfigSelectors.selectClusterNames(ids), + take(1) + )), + exhaustMap((names) => { + return from(this.Confirm.confirm(`

    Are you sure you want to remove these clusters?

      ${names.map((name) => `
    • ${name}
    • `).join('')}
    - `)) - .map(confirmClustersRemovalOK) - .catch(() => Observable.empty()); - }); - - this.persistRemovedClustersLocallyEffect$ = this.ConfigureState.actions$ - .let(ofType(CONFIRM_CLUSTERS_REMOVAL_OK)) - .withLatestFrom(this.ConfigureState.actions$.let(ofType(CONFIRM_CLUSTERS_REMOVAL))) - .switchMap(([, {clusterIDs}]) => of( + `)).pipe( + map(confirmClustersRemovalOK), + catchError(() => empty()) + ); + }) + ); + + this.persistRemovedClustersLocallyEffect$ = this.ConfigureState.actions$.pipe( + ofType(CONFIRM_CLUSTERS_REMOVAL_OK), + withLatestFrom(this.ConfigureState.actions$.pipe(ofType(CONFIRM_CLUSTERS_REMOVAL))), + switchMap(([, {clusterIDs}]) => of( {type: shortClustersActionTypes.REMOVE, ids: clusterIDs}, {type: clustersActionTypes.REMOVE, ids: clusterIDs} - )); - - this.persistRemovedClustersRemotelyEffect$ = this.ConfigureState.actions$ - .let(ofType(CONFIRM_CLUSTERS_REMOVAL_OK)) - .withLatestFrom( - this.ConfigureState.actions$.let(ofType(CONFIRM_CLUSTERS_REMOVAL)), - this.ConfigureState.actions$.let(ofType(shortClustersActionTypes.REMOVE)), - this.ConfigureState.actions$.let(ofType(clustersActionTypes.REMOVE)) - ) - .switchMap(([, {clusterIDs}, ...backup]) => this.Clusters.removeCluster$(clusterIDs) - .mapTo({ + )) + ); + + this.persistRemovedClustersRemotelyEffect$ = this.ConfigureState.actions$.pipe( + ofType(CONFIRM_CLUSTERS_REMOVAL_OK), + withLatestFrom( + this.ConfigureState.actions$.pipe(ofType(CONFIRM_CLUSTERS_REMOVAL)), + this.ConfigureState.actions$.pipe(ofType(shortClustersActionTypes.REMOVE)), + this.ConfigureState.actions$.pipe(ofType(clustersActionTypes.REMOVE)) + ), + switchMap(([, {clusterIDs}, ...backup]) => this.Clusters.removeCluster$(clusterIDs).pipe( + mapTo({ type: 'REMOVE_CLUSTERS_OK' - }) - .catch((e) => of( + }), + catchError((e) => of( { type: 'REMOVE_CLUSTERS_ERR', error: { @@ -594,13 +639,15 @@ export default class ConfigEffects { actions: backup } )) - ); + )) + ); - this.notifyRemoteClustersRemoveSuccessEffect$ = this.ConfigureState.actions$ - .let(ofType('REMOVE_CLUSTERS_OK')) - .withLatestFrom(this.ConfigureState.actions$.let(ofType(CONFIRM_CLUSTERS_REMOVAL))) - .do(([, {clusterIDs}]) => this.IgniteMessages.showInfo(`Cluster(s) removed: ${clusterIDs.length}`)) - .ignoreElements(); + this.notifyRemoteClustersRemoveSuccessEffect$ = this.ConfigureState.actions$.pipe( + ofType('REMOVE_CLUSTERS_OK'), + withLatestFrom(this.ConfigureState.actions$.pipe(ofType(CONFIRM_CLUSTERS_REMOVAL))), + tap(([, {clusterIDs}]) => this.IgniteMessages.showInfo(`Cluster(s) removed: ${clusterIDs.length}`)), + ignoreElements() + ); const _applyChangedIDs = (edit, {cache, igfs, model, cluster} = {}) => ({ cluster: { @@ -616,22 +663,24 @@ export default class ConfigEffects { }); this.advancedSaveCacheEffect$ = merge( - this.ConfigureState.actions$.let(ofType(ADVANCED_SAVE_CLUSTER)), - this.ConfigureState.actions$.let(ofType(ADVANCED_SAVE_CACHE)), - this.ConfigureState.actions$.let(ofType(ADVANCED_SAVE_IGFS)), - this.ConfigureState.actions$.let(ofType(ADVANCED_SAVE_MODEL)), - ) - .withLatestFrom(this.ConfigureState.state$.pluck('edit')) - .map(([action, edit]) => ({ + this.ConfigureState.actions$.pipe(ofType(ADVANCED_SAVE_CLUSTER)), + this.ConfigureState.actions$.pipe(ofType(ADVANCED_SAVE_CACHE)), + this.ConfigureState.actions$.pipe(ofType(ADVANCED_SAVE_IGFS)), + this.ConfigureState.actions$.pipe(ofType(ADVANCED_SAVE_MODEL)), + ).pipe( + withLatestFrom(this.ConfigureState.state$.pipe(pluck('edit'))), + map(([action, edit]) => ({ type: ADVANCED_SAVE_COMPLETE_CONFIGURATION, changedItems: _applyChangedIDs(edit, action) - })); - - this.basicSaveEffect$ = this.ConfigureState.actions$ - .let(ofType(BASIC_SAVE)) - .merge(this.ConfigureState.actions$.let(ofType(BASIC_SAVE_AND_DOWNLOAD))) - .withLatestFrom(this.ConfigureState.state$.pluck('edit')) - .switchMap(([action, edit]) => { + })) + ); + + this.basicSaveEffect$ = merge( + this.ConfigureState.actions$.pipe(ofType(BASIC_SAVE)), + this.ConfigureState.actions$.pipe(ofType(BASIC_SAVE_AND_DOWNLOAD)) + ).pipe( + withLatestFrom(this.ConfigureState.state$.pipe(pluck('edit'))), + switchMap(([action, edit]) => { const changedItems = _applyChangedIDs(edit, {cluster: action.cluster}); const actions = [{ type: cachesActionTypes.UPSERT, @@ -651,24 +700,27 @@ export default class ConfigEffects { } ].filter((a) => a.items.length); - return Observable.of(...actions) - .merge( - Observable.fromPromise(this.Clusters.saveBasic(changedItems)) - .switchMap((res) => Observable.of( - {type: 'EDIT_CLUSTER', cluster: changedItems.cluster}, - basicSaveOK(changedItems) - )) - .catch((res) => Observable.of( - basicSaveErr(changedItems, res), - {type: 'UNDO_ACTIONS', actions} - )) + return merge( + of(...actions), + from(this.Clusters.saveBasic(changedItems)).pipe( + switchMap((res) => of( + {type: 'EDIT_CLUSTER', cluster: changedItems.cluster}, + basicSaveOK(changedItems) + )), + catchError((res) => of( + basicSaveErr(changedItems, res), + {type: 'UNDO_ACTIONS', actions} + )) + ) ); - }); + }) + ); - this.basicSaveOKMessagesEffect$ = this.ConfigureState.actions$ - .let(ofType(BASIC_SAVE_OK)) - .do((action) => this.IgniteMessages.showInfo(`Cluster "${action.changedItems.cluster.name}" saved.`)) - .ignoreElements(); + this.basicSaveOKMessagesEffect$ = this.ConfigureState.actions$.pipe( + ofType(BASIC_SAVE_OK), + tap((action) => this.IgniteMessages.showInfo(`Cluster "${action.changedItems.cluster.name}" saved.`)), + ignoreElements() + ); } /** @@ -691,21 +743,21 @@ export default class ConfigEffects { setTimeout(() => this.ConfigureState.dispatchAction(action)); - return this.ConfigureState.actions$ - .filter((a) => a.type === ok || a.type === err) - .take(1) - .map((a) => { + return this.ConfigureState.actions$.pipe( + filter((a) => a.type === ok || a.type === err), + take(1), + map((a) => { if (a.type === err) throw a; else return a; }) - .toPromise(); + ).toPromise(); }; connect() { return merge( ...Object.keys(this).filter((k) => k.endsWith('Effect$')).map((k) => this[k]) - ).do((a) => this.ConfigureState.dispatchAction(a)).subscribe(); + ).pipe(tap((a) => this.ConfigureState.dispatchAction(a))).subscribe(); } } diff --git a/modules/web-console/frontend/app/components/page-configure/store/effects.spec.js b/modules/web-console/frontend/app/components/page-configure/store/effects.spec.js index 10e066330a795..f8b39098bcbbb 100644 --- a/modules/web-console/frontend/app/components/page-configure/store/effects.spec.js +++ b/modules/web-console/frontend/app/components/page-configure/store/effects.spec.js @@ -16,11 +16,10 @@ */ import {assert} from 'chai'; -import {of} from 'rxjs/observable/of'; -import {_throw} from 'rxjs/observable/throw'; +import {of, throwError} from 'rxjs'; +import {TestScheduler} from 'rxjs/testing'; import {default as Effects} from './effects'; import {default as Selectors} from './selectors'; -import {TestScheduler} from 'rxjs/testing/TestScheduler'; const makeMocks = (target, mocks) => new Map(target.$inject.map((provider) => { return (provider in mocks) ? [provider, mocks[provider]] : [provider, {}]; @@ -121,7 +120,7 @@ suite('Configuration store effects', () => { stateMarbles: 'AB', mocks: { ...mocks, - Clusters: {getCluster: () => _throw({data: 'Error'})} + Clusters: {getCluster: () => throwError({data: 'Error'})} } }); diff --git a/modules/web-console/frontend/app/components/page-configure/store/selectors.js b/modules/web-console/frontend/app/components/page-configure/store/selectors.js index c9df6436ca676..0c70e5991b0b9 100644 --- a/modules/web-console/frontend/app/components/page-configure/store/selectors.js +++ b/modules/web-console/frontend/app/components/page-configure/store/selectors.js @@ -16,13 +16,8 @@ */ import {uniqueName} from 'app/utils/uniqueName'; -import {of} from 'rxjs/observable/of'; -import {empty} from 'rxjs/observable/empty'; -import {combineLatest} from 'rxjs/observable/combineLatest'; -import 'rxjs/add/operator/filter'; -import 'rxjs/add/operator/mergeMap'; -import 'rxjs/add/observable/combineLatest'; -import {Observable} from 'rxjs/Observable'; +import {of, empty, combineLatest, forkJoin, pipe} from 'rxjs'; +import {filter, pluck, map, switchMap, take, distinctUntilChanged, exhaustMap} from 'rxjs/operators'; import {defaultNames} from '../defaultNames'; import {default as Caches} from 'app/services/Caches'; @@ -30,22 +25,22 @@ import {default as Clusters} from 'app/services/Clusters'; import {default as IGFSs} from 'app/services/IGFSs'; import {default as Models} from 'app/services/Models'; -const isDefined = (s) => s.filter((v) => v); +const isDefined = filter((v) => v); -const selectItems = (path) => (s) => s.filter((s) => s).pluck(path).filter((v) => v); +const selectItems = (path) => pipe(filter((s) => s), pluck(path), filter((v) => v)); -const selectValues = (s) => s.map((v) => v && [...v.value.values()]); +const selectValues = map((v) => v && [...v.value.values()]); -export const selectMapItem = (mapPath, key) => (s) => s.pluck(mapPath).map((v) => v && v.get(key)); +export const selectMapItem = (mapPath, key) => pipe(pluck(mapPath), map((v) => v && v.get(key))); -const selectMapItems = (mapPath, keys) => (s) => s.pluck(mapPath).map((v) => v && keys.map((key) => v.get(key))); +const selectMapItems = (mapPath, keys) => pipe(pluck(mapPath), map((v) => v && keys.map((key) => v.get(key)))); -const selectItemToEdit = ({items, itemFactory, defaultName = '', itemID}) => (s) => s.switchMap((item) => { +const selectItemToEdit = ({items, itemFactory, defaultName = '', itemID}) => switchMap((item) => { if (item) return of(Object.assign(itemFactory(), item)); if (itemID === 'new') - return items.take(1).map((items) => Object.assign(itemFactory(), {name: uniqueName(defaultName, items)})); + return items.pipe(take(1), map((items) => Object.assign(itemFactory(), {name: uniqueName(defaultName, items)}))); if (!itemID) return of(null); @@ -54,22 +49,24 @@ const selectItemToEdit = ({items, itemFactory, defaultName = '', itemID}) => (s) }); const currentShortItems = ({changesKey, shortKey}) => (state$) => { - return Observable.combineLatest( - state$.pluck('edit', 'changes', changesKey).let(isDefined).distinctUntilChanged(), - state$.pluck(shortKey, 'value').let(isDefined).distinctUntilChanged() - ) - .map(([{ids = [], changedItems}, shortItems]) => { + return combineLatest( + state$.pipe(pluck('edit', 'changes', changesKey), isDefined, distinctUntilChanged()), + state$.pipe(pluck(shortKey, 'value'), isDefined, distinctUntilChanged()) + ).pipe( + map(([{ids = [], changedItems}, shortItems]) => { if (!ids.length || !shortItems) return []; return ids.map((id) => changedItems.find(({_id}) => _id === id) || shortItems.get(id)); - }) - .map((v) => v.filter((v) => v)); + }), + map((v) => v.filter((v) => v)) + ); }; -const selectNames = (itemIDs, nameAt = 'name') => (items) => items - .pluck('value') - .map((items) => itemIDs.map((id) => items.get(id)[nameAt])); +const selectNames = (itemIDs, nameAt = 'name') => pipe( + pluck('value'), + map((items) => itemIDs.map((id) => items.get(id)[nameAt])) +); export default class ConfigSelectors { static $inject = ['Caches', 'Clusters', 'IGFSs', 'Models']; @@ -95,17 +92,18 @@ export default class ConfigSelectors { * @returns {(state$: Observable) => Observable<{pristine: boolean, value: Map}>} */ this.selectShortModels = () => selectItems('shortModels'); - this.selectShortModelsValue = () => (state$) => state$.let(this.selectShortModels()).let(selectValues); + this.selectShortModelsValue = () => (state$) => state$.pipe(this.selectShortModels(), selectValues); /** * @returns {(state$: Observable) => Observable>} */ - this.selectShortClustersValue = () => (state$) => state$.let(this.selectShortClusters()).let(selectValues); + this.selectShortClustersValue = () => (state$) => state$.pipe(this.selectShortClusters(), selectValues); /** * @returns {(state$: Observable) => Observable>} */ - this.selectClusterNames = (clusterIDs) => (state$) => state$ - .let(this.selectShortClusters()) - .let(selectNames(clusterIDs)); + this.selectClusterNames = (clusterIDs) => (state$) => state$.pipe( + this.selectShortClusters(), + selectNames(clusterIDs) + ); } selectCluster = (id) => selectMapItem('clusters', id); @@ -118,52 +116,56 @@ export default class ConfigSelectors { selectShortCaches = () => selectItems('shortCaches'); - selectShortCachesValue = () => (state$) => state$.let(this.selectShortCaches()).let(selectValues); + selectShortCachesValue = () => (state$) => state$.pipe(this.selectShortCaches(), selectValues); selectShortIGFSs = () => selectItems('shortIgfss'); - selectShortIGFSsValue = () => (state$) => state$.let(this.selectShortIGFSs()).let(selectValues); + selectShortIGFSsValue = () => (state$) => state$.pipe(this.selectShortIGFSs(), selectValues); - selectShortModelsValue = () => (state$) => state$.let(this.selectShortModels()).let(selectValues); + selectShortModelsValue = () => (state$) => state$.pipe(this.selectShortModels(), selectValues); - selectCacheToEdit = (cacheID) => (state$) => state$ - .let(this.selectCache(cacheID)) - .distinctUntilChanged() - .let(selectItemToEdit({ - items: state$.let(this.selectCurrentShortCaches), + selectCacheToEdit = (cacheID) => (state$) => state$.pipe( + this.selectCache(cacheID), + distinctUntilChanged(), + selectItemToEdit({ + items: state$.pipe(this.selectCurrentShortCaches), itemFactory: () => this.Caches.getBlankCache(), defaultName: defaultNames.cache, itemID: cacheID - })); + }) + ); - selectIGFSToEdit = (itemID) => (state$) => state$ - .let(this.selectIGFS(itemID)) - .distinctUntilChanged() - .let(selectItemToEdit({ - items: state$.let(this.selectCurrentShortIGFSs), + selectIGFSToEdit = (itemID) => (state$) => state$.pipe( + this.selectIGFS(itemID), + distinctUntilChanged(), + selectItemToEdit({ + items: state$.pipe(this.selectCurrentShortIGFSs), itemFactory: () => this.IGFSs.getBlankIGFS(), defaultName: defaultNames.igfs, itemID - })); + }) + ); - selectModelToEdit = (itemID) => (state$) => state$ - .let(this.selectModel(itemID)) - .distinctUntilChanged() - .let(selectItemToEdit({ - items: state$.let(this.selectCurrentShortModels), + selectModelToEdit = (itemID) => (state$) => state$.pipe( + this.selectModel(itemID), + distinctUntilChanged(), + selectItemToEdit({ + items: state$.pipe(this.selectCurrentShortModels), itemFactory: () => this.Models.getBlankModel(), itemID - })); + }) + ); - selectClusterToEdit = (clusterID, defaultName = defaultNames.cluster) => (state$) => state$ - .let(this.selectCluster(clusterID)) - .distinctUntilChanged() - .let(selectItemToEdit({ - items: state$.let(this.selectShortClustersValue()), + selectClusterToEdit = (clusterID, defaultName = defaultNames.cluster) => (state$) => state$.pipe( + this.selectCluster(clusterID), + distinctUntilChanged(), + selectItemToEdit({ + items: state$.pipe(this.selectShortClustersValue()), itemFactory: () => this.Clusters.getBlankCluster(), defaultName, itemID: clusterID - })); + }) + ); selectCurrentShortCaches = currentShortItems({changesKey: 'caches', shortKey: 'shortCaches'}); @@ -176,34 +178,33 @@ export default class ConfigSelectors { return of([]); return combineLatest( - state$.let(this.selectCluster(clusterID)).pluck('caches'), - state$.let(this.selectShortCaches()).pluck('value'), + state$.pipe(this.selectCluster(clusterID), pluck('caches')), + state$.pipe(this.selectShortCaches(), pluck('value')), (ids, items) => ids.map((id) => items.get(id)) ); }; selectCompleteClusterConfiguration = ({clusterID, isDemo}) => (state$) => { const hasValues = (array) => !array.some((v) => !v); - return state$.let(this.selectCluster(clusterID)) - .exhaustMap((cluster) => { - if (!cluster) - return of({__isComplete: false}); - - const withSpace = (array) => array.map((c) => ({...c, space: cluster.space})); - - return Observable.forkJoin( - state$.let(selectMapItems('caches', cluster.caches || [])).take(1), - state$.let(selectMapItems('models', cluster.models || [])).take(1), - state$.let(selectMapItems('igfss', cluster.igfss || [])).take(1), - ) - .map(([caches, models, igfss]) => ({ - cluster, - caches, - domains: models, - igfss, - spaces: [{_id: cluster.space, demo: isDemo}], - __isComplete: !!cluster && !(!hasValues(caches) || !hasValues(models) || !hasValues(igfss)) - })); - }); + return state$.pipe( + this.selectCluster(clusterID), + exhaustMap((cluster) => { + if (!cluster) + return of({__isComplete: false}); + + return forkJoin( + state$.pipe(selectMapItems('caches', cluster.caches || []), take(1)), + state$.pipe(selectMapItems('models', cluster.models || []), take(1)), + state$.pipe(selectMapItems('igfss', cluster.igfss || []), take(1)), + ).pipe(map(([caches, models, igfss]) => ({ + cluster, + caches, + domains: models, + igfss, + spaces: [{_id: cluster.space, demo: isDemo}], + __isComplete: !!cluster && !(!hasValues(caches) || !hasValues(models) || !hasValues(igfss)) + }))); + }) + ); }; } diff --git a/modules/web-console/frontend/app/components/page-configure/style.scss b/modules/web-console/frontend/app/components/page-configure/style.scss index 365e058cbbe31..9e9661cd2c1a8 100644 --- a/modules/web-console/frontend/app/components/page-configure/style.scss +++ b/modules/web-console/frontend/app/components/page-configure/style.scss @@ -222,6 +222,7 @@ list-editable .pc-form-group__text-title { &>.pc-form-grid-col-10 { flex-basis: calc(25%); } + &>.pc-form-grid-col-20 { flex-basis: calc(50%); } diff --git a/modules/web-console/frontend/app/components/page-configure/template.pug b/modules/web-console/frontend/app/components/page-configure/template.pug index 86180fa0d4c28..e161ba5da6046 100644 --- a/modules/web-console/frontend/app/components/page-configure/template.pug +++ b/modules/web-console/frontend/app/components/page-configure/template.pug @@ -32,7 +32,7 @@ div.pc-content-container svg.icon-left( ignite-icon='info' bs-tooltip='' - data-title='This setting is needed to hide and show tooltips with hints.' + data-title='Use this setting to hide or show tooltips with hints.' data-placement='left' ) span Tooltips @@ -46,4 +46,4 @@ div.pc-content-container ng-class=`{ 'pc-hide-tooltips': !$ctrl.tooltipsVisible }` - ) \ No newline at end of file + ) diff --git a/modules/web-console/frontend/app/components/page-forgot-password/controller.js b/modules/web-console/frontend/app/components/page-forgot-password/controller.js index 7d06773c58a72..86597aff4d7c8 100644 --- a/modules/web-console/frontend/app/components/page-forgot-password/controller.js +++ b/modules/web-console/frontend/app/components/page-forgot-password/controller.js @@ -24,22 +24,26 @@ export default class PageForgotPassword { data = {email: null}; /** @type {string} */ serverError = null; + /** @type {JQLite} */ + el; - static $inject = ['Auth', 'IgniteMessages', 'IgniteFormUtils']; + static $inject = ['Auth', 'IgniteMessages', 'IgniteFormUtils', '$element']; /** * @param {import('app/modules/user/Auth.service').default} Auth */ - constructor(Auth, IgniteMessages, IgniteFormUtils) { + constructor(Auth, IgniteMessages, IgniteFormUtils, el) { this.Auth = Auth; this.IgniteMessages = IgniteMessages; this.IgniteFormUtils = IgniteFormUtils; + this.el = el; } /** @param {import('./types').IForgotPasswordFormController} form */ canSubmitForm(form) { return form.$error.server ? true : !form.$invalid; } $postLink() { + this.el.addClass('public-page'); this.form.email.$validators.server = () => !this.serverError; } diff --git a/modules/web-console/frontend/app/components/page-forgot-password/run.js b/modules/web-console/frontend/app/components/page-forgot-password/run.js index c7ee6a64a1d3f..d9259e95fc1eb 100644 --- a/modules/web-console/frontend/app/components/page-forgot-password/run.js +++ b/modules/web-console/frontend/app/components/page-forgot-password/run.js @@ -15,6 +15,8 @@ * limitations under the License. */ +import publicTemplate from '../../../views/public.pug'; + /** * @param {import("@uirouter/angularjs").UIRouter} $uiRouter */ @@ -23,7 +25,14 @@ export function registerState($uiRouter) { const state = { name: 'forgotPassword', url: '/forgot-password', - component: 'pageForgotPassword', + views: { + '': { + template: publicTemplate + }, + 'page@forgotPassword': { + component: 'pageForgotPassword' + } + }, unsaved: true, tfMetaTags: { title: 'Forgot Password' diff --git a/modules/web-console/frontend/app/components/page-forgot-password/style.scss b/modules/web-console/frontend/app/components/page-forgot-password/style.scss index 86425c189806e..7893c625697a7 100644 --- a/modules/web-console/frontend/app/components/page-forgot-password/style.scss +++ b/modules/web-console/frontend/app/components/page-forgot-password/style.scss @@ -20,34 +20,22 @@ page-forgot-password { flex-direction: column; flex: 1 0 auto; - section { - margin-left: auto; - margin-right: auto; - width: 530px; - - h3 { - font-size: 38px; - font-weight: 300; - margin: 30px 0 30px; - } - - p { - margin-bottom: 20px; - } + p { + margin-bottom: 20px; + } - .form-field { - margin: 10px 0; - } + .form-field { + margin: 10px 0; + } - .form-footer { - padding: 15px 0; - text-align: right; - display: flex; - align-items: center; + .form-footer { + padding: 15px 0; + text-align: right; + display: flex; + align-items: center; - .btn-ignite { - margin-left: auto; - } + .btn-ignite { + margin-left: auto; } } } diff --git a/modules/web-console/frontend/app/components/page-forgot-password/template.pug b/modules/web-console/frontend/app/components/page-forgot-password/template.pug index 82e7898599873..309e9b93de32a 100644 --- a/modules/web-console/frontend/app/components/page-forgot-password/template.pug +++ b/modules/web-console/frontend/app/components/page-forgot-password/template.pug @@ -16,34 +16,25 @@ include /app/helpers/jade/mixins -web-console-header - web-console-header-left - ignite-header-title - -.container--responsive.body-container - section - - const form = '$ctrl.form' - h3 Forgot password? - p Enter the email address for your account & we'll email you a link to reset your password. - form(name=form novalidate ng-submit='$ctrl.remindPassword()') - +form-field__email({ - label: 'Email:', - model: '$ctrl.data.email', - name: '"email"', - placeholder: 'Input email', - required: true - })( - ng-model-options='{allowInvalid: true}' - autocomplete='email' - ignite-auto-focus - tabindex='0' - ) - +form-field__error({error: 'server', message: `{{$ctrl.serverError}}`}) - footer.form-footer - a(ui-sref='signin') Back to sign in - button.btn-ignite.btn-ignite--primary( - tabindex='1' - type='submit' - ) Send it to me - -web-console-footer +h3.public-page__title Forgot password? +p Enter the email address for your account & we'll email you a link to reset your password. +form(name='$ctrl.form' novalidate ng-submit='$ctrl.remindPassword()') + +form-field__email({ + label: 'Email:', + model: '$ctrl.data.email', + name: '"email"', + placeholder: 'Input email', + required: true + })( + ng-model-options='{allowInvalid: true}' + autocomplete='email' + ignite-auto-focus + tabindex='0' + ) + +form-field__error({error: 'server', message: `{{$ctrl.serverError}}`}) + footer.form-footer + a(ui-sref='signin') Back to sign in + button.btn-ignite.btn-ignite--primary( + tabindex='1' + type='submit' + ) Send it to me diff --git a/modules/web-console/frontend/app/components/page-landing/index.js b/modules/web-console/frontend/app/components/page-landing/index.js index ff6ee595950e7..cabb5bbdef6c1 100644 --- a/modules/web-console/frontend/app/components/page-landing/index.js +++ b/modules/web-console/frontend/app/components/page-landing/index.js @@ -17,6 +17,7 @@ import angular from 'angular'; +import baseTemplate from './public.pug'; import template from './template.pug'; import './style.scss'; @@ -44,7 +45,15 @@ export default angular $stateProvider .state('landing', { url: '/', - template: '', + views: { + '@': { + template: baseTemplate + }, + 'page@landing': { + component: 'pageLanding' + } + }, + // template: '', redirectTo: (trans) => { return trans.injector().get('User').read() .then(() => { @@ -54,7 +63,8 @@ export default angular const restored = trans.router.stateService.target(name, params); return restored.valid() ? restored : 'default-state'; - } catch (ignored) { + } + catch (ignored) { return 'default-state'; } }) diff --git a/modules/web-console/frontend/app/components/page-landing/public.pug b/modules/web-console/frontend/app/components/page-landing/public.pug new file mode 100644 index 0000000000000..d9153f52f2c16 --- /dev/null +++ b/modules/web-console/frontend/app/components/page-landing/public.pug @@ -0,0 +1,21 @@ +//- + 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. + +web-console-header(hide-menu-button='true') + .web-console-header-content__title Management console for Apache Ignite + .page-landing__button-signin.btn-ignite.btn-ignite--primary(ui-sref='signin') Sign In +.content(ui-view='page') +web-console-footer.web-console-footer__page-bottom \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/page-landing/style.scss b/modules/web-console/frontend/app/components/page-landing/style.scss index a92206ba27ec6..90f3ddaf7f2e9 100644 --- a/modules/web-console/frontend/app/components/page-landing/style.scss +++ b/modules/web-console/frontend/app/components/page-landing/style.scss @@ -24,8 +24,20 @@ @include custom_btn; } +.page-landing__button-signin { + align-self: center; + margin-left: 30px; + margin-right: var(--page-side-padding) !important; + min-width: 80px; + font-weight: 500; + padding: 10px 25px !important; + flex: 0 0 auto; +} + page-landing { font-family: Roboto; + display: block; + margin: 0 calc(var(--page-side-padding) * -1) calc(var(--page-side-padding) * -1); .btn-custom { @include custom_btn; diff --git a/modules/web-console/frontend/app/components/page-landing/template.pug b/modules/web-console/frontend/app/components/page-landing/template.pug index 0fc1f9c5ffb01..bf926fae07411 100644 --- a/modules/web-console/frontend/app/components/page-landing/template.pug +++ b/modules/web-console/frontend/app/components/page-landing/template.pug @@ -14,12 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. -web-console-header - web-console-header-left - ignite-header-title - web-console-header-right - a#signin_show.btn-ignite.btn-ignite--primary(ui-sref='signin') Sign In - section.intro-container-wrapper .container .col-lg-6.col-md-6.col-sm-6.col-xs-12.intro-content @@ -62,5 +56,3 @@ section.features-container-wrapper p The Web Console allows you to have accounts with different roles. .align-center.text-center a.btn.btn-lg.btn-primary.btn-custom(ui-sref='signup') Get Started - -web-console-footer diff --git a/modules/web-console/frontend/app/components/page-password-changed/controller.ts b/modules/web-console/frontend/app/components/page-password-changed/controller.ts new file mode 100644 index 0000000000000..9696a092fb114 --- /dev/null +++ b/modules/web-console/frontend/app/components/page-password-changed/controller.ts @@ -0,0 +1,32 @@ +/* + * 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. + */ + +import {StateService} from '@uirouter/angularjs'; + +export default class implements ng.IPostLink { + static $inject = ['$state', '$timeout', '$element']; + + constructor($state: StateService, $timeout: ng.ITimeoutService, private el: JQLite) { + $timeout(() => { + $state.go('signin'); + }, 10000); + } + + $postLink() { + this.el.addClass('public-page'); + } +} diff --git a/modules/web-console/frontend/app/components/page-password-changed/index.js b/modules/web-console/frontend/app/components/page-password-changed/index.js index 7c244beff0622..903138f0b1ef1 100644 --- a/modules/web-console/frontend/app/components/page-password-changed/index.js +++ b/modules/web-console/frontend/app/components/page-password-changed/index.js @@ -19,6 +19,7 @@ import angular from 'angular'; import template from './template.pug'; import controller from './controller'; +import publicTemplate from '../../../views/public.pug'; import './style.scss'; @@ -32,7 +33,14 @@ export default angular .config(['$stateProvider', ($stateProvider) => { $stateProvider.state('password.send', { url: '/changed', - component: 'pagePasswordChanged', + views: { + '@': { + template: publicTemplate + }, + 'page@password.send': { + component: 'pagePasswordChanged' + } + }, tfMetaTags: { title: 'Password send' }, diff --git a/modules/web-console/frontend/app/components/page-password-changed/style.scss b/modules/web-console/frontend/app/components/page-password-changed/style.scss index eeb44ec451eab..e32e9b2c4849c 100644 --- a/modules/web-console/frontend/app/components/page-password-changed/style.scss +++ b/modules/web-console/frontend/app/components/page-password-changed/style.scss @@ -19,17 +19,10 @@ page-password-changed { display: flex; flex: 1 0 auto; flex-direction: column; - min-height: 100%; - - font-family: Roboto; - - .body-container { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - } + justify-content: center; + align-items: center; + max-width: initial !important; h2 { margin-bottom: 30px; diff --git a/modules/web-console/frontend/app/components/page-password-changed/template.pug b/modules/web-console/frontend/app/components/page-password-changed/template.pug index 7d2d986c812b2..82c2cc1608ac7 100644 --- a/modules/web-console/frontend/app/components/page-password-changed/template.pug +++ b/modules/web-console/frontend/app/components/page-password-changed/template.pug @@ -14,9 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. -.container.body-container - h2 Ready! +h2 Ready! - p - | Further instructions for password reset have been sent to your e-mail address.#[br] - | You'll be redirected back automatically in a few seconds. If not, please #[a(ui-sref='signin') click here]. +p + | Further instructions for password reset have been sent to your e-mail address.#[br] + | You'll be redirected back automatically in a few seconds. If not, please #[a(ui-sref='signin') click here]. diff --git a/modules/web-console/frontend/app/components/page-password-reset/controller.js b/modules/web-console/frontend/app/components/page-password-reset/controller.js index 53d6c69393a95..b69e56610a7b3 100644 --- a/modules/web-console/frontend/app/components/page-password-reset/controller.js +++ b/modules/web-console/frontend/app/components/page-password-reset/controller.js @@ -16,7 +16,9 @@ */ export default class { - static $inject = ['$modal', '$http', '$state', 'IgniteMessages']; + static $inject = ['$modal', '$http', '$state', 'IgniteMessages', '$element']; + /** @type {JQLite} */ + el; /** * @param {mgcrea.ngStrap.modal.IModalService} $modal @@ -24,10 +26,15 @@ export default class { * @param {import('@uirouter/angularjs').StateService} $state * @param {ReturnType} Messages */ - constructor($modal, $http, $state, Messages) { + constructor($modal, $http, $state, Messages, el) { this.$http = $http; this.$state = $state; this.Messages = Messages; + this.el = el; + } + + $postLink() { + this.el.addClass('public-page'); } $onInit() { diff --git a/modules/web-console/frontend/app/components/page-password-reset/index.js b/modules/web-console/frontend/app/components/page-password-reset/index.js index e1042a6565c56..c07fa23eb7234 100644 --- a/modules/web-console/frontend/app/components/page-password-reset/index.js +++ b/modules/web-console/frontend/app/components/page-password-reset/index.js @@ -22,6 +22,7 @@ import _ from 'lodash'; import template from './template.pug'; import controller from './controller'; +import publicTemplate from '../../../views/public.pug'; import './style.scss'; @@ -42,7 +43,14 @@ export default angular }) .state('password.reset', { url: '/reset?{token}', - component: 'pagePasswordReset', + views: { + '@': { + template: publicTemplate + }, + 'page@password.reset': { + component: 'pagePasswordReset' + } + }, redirectTo: (trans) => { if (_.isEmpty(trans.params('to').token)) return 'signin'; diff --git a/modules/web-console/frontend/app/components/page-password-reset/style.scss b/modules/web-console/frontend/app/components/page-password-reset/style.scss index 75f758e676048..05ef953114218 100644 --- a/modules/web-console/frontend/app/components/page-password-reset/style.scss +++ b/modules/web-console/frontend/app/components/page-password-reset/style.scss @@ -20,12 +20,19 @@ page-password-reset { flex: 1 0 auto; flex-direction: column; - footer { + .form-footer { + padding: 15px 0; + text-align: right; display: flex; - justify-content: flex-end; + align-items: center; + + .btn-ignite { + margin-left: auto; + } } - .btn-ignite + .btn-ignite { - margin-left: 10px; + form { + display: grid; + grid-gap: 10px; } } diff --git a/modules/web-console/frontend/app/components/page-password-reset/template.pug b/modules/web-console/frontend/app/components/page-password-reset/template.pug index 1acfab82eb78f..c0df3c9bb27c6 100644 --- a/modules/web-console/frontend/app/components/page-password-reset/template.pug +++ b/modules/web-console/frontend/app/components/page-password-reset/template.pug @@ -16,65 +16,45 @@ include /app/helpers/jade/mixins -web-console-header - web-console-header-left - ignite-header-title +//- This doesn't seem to do anything 😵 +.main-content(ng-if='error') + .text-center + p {{::$ctrl.ui.error}} +h3.public-page__title(ng-if-start='$ctrl.ui.token && !$ctrl.ui.error') Reset Password +form.page-password-reset__grid(name='$ctrl.form' ng-init='reset_info.token = token' ng-if-end) + +form-field__email({ + label: 'E-mail:', + model: '$ctrl.ui.email', + disabled: true + }) + + +form-field__password({ + label: 'New password:', + model: '$ctrl.ui.password', + name: '"password"', + required: true, + placeholder: 'New password' + })( + ignite-auto-focus + ignite-on-enter-focus-move='passwordConfirmInput' + ) + +form-field__password({ + label: 'Confirm password:', + model: 'confirm', + name: '"passwordConfirm"', + required: true, + placeholder: 'Confirm new password' + })( + ignite-on-enter-focus-move='resetForm.$valid && resetPassword(user_info)' + ignite-match='$ctrl.ui.password' + ) + + footer.form-footer + a(ui-sref='default-state') Cancel + button.btn-ignite.btn-ignite--primary( + ng-disabled='$ctrl.form.$invalid' + ng-click='$ctrl.resetPassword()' + ) + svg.icon-left(ignite-icon='checkmark') + | Save Changes -.container.body-container - .row - .main-content(ng-if='error') - .text-center - p {{::$ctrl.ui.error}} - div(ng-if='$ctrl.ui.token && !$ctrl.ui.error') - header.header-with-selector - div - h1 Reset Password - - -var form = '$ctrl.form' - form.theme--ignite(name='$ctrl.form' ng-init='reset_info.token = token') - .row - .col-50 - +form-field__email({ - label: 'E-mail:', - model: '$ctrl.ui.email', - disabled: true - }) - - .row - .col-50 - +form-field__password({ - label: 'New password:', - model: '$ctrl.ui.password', - name: '"password"', - required: true, - placeholder: 'New password' - })( - ignite-auto-focus - ignite-on-enter-focus-move='passwordConfirmInput' - ) - - .row - .col-50 - +form-field__password({ - label: 'Confirm password:', - model: 'confirm', - name: '"passwordConfirm"', - required: true, - placeholder: 'Confirm new password' - })( - ignite-on-enter-focus-move='resetForm.$valid && resetPassword(user_info)' - ignite-match='$ctrl.ui.password' - ) - - hr - - footer - a.btn-ignite.btn-ignite--link-success(type='button' ui-sref='default-state') Cancel - button.btn-ignite.btn-ignite--success( - ng-disabled='$ctrl.form.$invalid' - ng-click='$ctrl.resetPassword()' - ) - svg.icon-left(ignite-icon='checkmark') - | Save Changes - -web-console-footer diff --git a/modules/web-console/frontend/app/components/page-profile/controller.js b/modules/web-console/frontend/app/components/page-profile/controller.js index 8586656743991..a2f344e98b9fc 100644 --- a/modules/web-console/frontend/app/components/page-profile/controller.js +++ b/modules/web-console/frontend/app/components/page-profile/controller.js @@ -19,7 +19,7 @@ import _ from 'lodash'; export default class PageProfileController { static $inject = [ - '$rootScope', '$scope', '$http', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteFocus', 'IgniteConfirm', 'IgniteCountries', 'User' + '$rootScope', '$scope', '$http', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteFocus', 'IgniteConfirm', 'IgniteCountries', 'User', 'IgniteFormUtils' ]; /** @@ -32,8 +32,9 @@ export default class PageProfileController { * @param {import('app/services/Confirm.service').Confirm} Confirm * @param {ReturnType} Countries * @param {ReturnType} User + * @param {ReturnType} FormUtils */ - constructor($root, $scope, $http, LegacyUtils, Messages, Focus, Confirm, Countries, User) { + constructor($root, $scope, $http, LegacyUtils, Messages, Focus, Confirm, Countries, User, FormUtils) { this.$root = $root; this.$scope = $scope; this.$http = $http; @@ -43,6 +44,7 @@ export default class PageProfileController { this.Confirm = Confirm; this.Countries = Countries; this.User = User; + this.FormUtils = FormUtils; } $onInit() { @@ -69,6 +71,12 @@ export default class PageProfileController { } saveUser() { + if (this.form.$invalid) { + this.FormUtils.triggerValidation(this.form); + + return; + } + return this.$http.post('/api/v1/profile/save', this.ui.user) .then(this.User.load) .then(() => { diff --git a/modules/web-console/frontend/app/components/page-profile/template.pug b/modules/web-console/frontend/app/components/page-profile/template.pug index 3c5fb52c980ba..2b2b7488e95cf 100644 --- a/modules/web-console/frontend/app/components/page-profile/template.pug +++ b/modules/web-console/frontend/app/components/page-profile/template.pug @@ -69,11 +69,11 @@ div ) .col-50 +form-field__dropdown({ - label: 'Country:', + label: 'Country/Region:', model: '$ctrl.ui.user.country', name: '"country"', required: true, - placeholder: 'Choose your country', + placeholder: 'Choose your country/region', options: '$ctrl.ui.countries' }) .row @@ -154,9 +154,6 @@ div footer a.btn-ignite.btn-ignite--link-success(type='button' ui-sref='default-state') Cancel - button.btn-ignite.btn-ignite--success( - ng-click='$ctrl.saveUser()' - ng-disabled='$ctrl.form.$invalid' - ) + button.btn-ignite.btn-ignite--success(ng-click='$ctrl.saveUser()') svg.icon-left(ignite-icon='checkmark') | Save Changes diff --git a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/components/query-actions-button/component.ts b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/components/query-actions-button/component.ts new file mode 100644 index 0000000000000..099efc20aba90 --- /dev/null +++ b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/components/query-actions-button/component.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +import template from './template.pug'; +import QueryActionsButton from './controller'; + +export const component: ng.IComponentOptions = { + controller: QueryActionsButton, + template, + bindings: { + actions: '<', + item: '<' + } +}; diff --git a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/components/query-actions-button/controller.ts b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/components/query-actions-button/controller.ts new file mode 100644 index 0000000000000..e71cf4603dbb2 --- /dev/null +++ b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/components/query-actions-button/controller.ts @@ -0,0 +1,53 @@ +/* + * 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. + */ + +export type QueryActions < T > = Array<{text: string, click?(item: T): any, available?(item: T): boolean}>; + +export default class QueryActionButton { + static $inject = ['$element']; + + item: T; + + actions: QueryActions; + + boundActions: QueryActions = []; + + constructor(private el: JQLite) {} + + $postLink() { + this.el[0].classList.add('btn-ignite-group'); + } + + $onChanges(changes: {actions: ng.IChangesObject['actions']>}) { + if ('actions' in changes) { + this.boundActions = changes.actions.currentValue.map((a) => { + const action = {...a}; + + const click = () => a.click(this.item); + + Object.defineProperty(action, 'click', { + get: () => { + return typeof a.available === 'function' + ? a.available(this.item) ? click : void 0 + : a.available ? click : void 0; + } + }); + return action; + }); + } + } +} diff --git a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/components/query-actions-button/template.pug b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/components/query-actions-button/template.pug new file mode 100644 index 0000000000000..32359bf3a4ed6 --- /dev/null +++ b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/components/query-actions-button/template.pug @@ -0,0 +1,28 @@ +//- + 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. + +button.btn-ignite.btn-ignite--primary( + ng-click='$ctrl.boundActions[0].click()' + type='button' + ng-disabled='!$ctrl.boundActions[0].click' +) + | {{ ::$ctrl.boundActions[0].text }} +button.btn-ignite.btn-ignite--primary( + bs-dropdown='$ctrl.boundActions' + data-placement='bottom-right' + type='button' +) + span.icon.fa.fa-caret-down diff --git a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/controller.js b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/controller.ts similarity index 88% rename from modules/web-console/frontend/app/components/page-queries/components/queries-notebook/controller.js rename to modules/web-console/frontend/app/components/page-queries/components/queries-notebook/controller.ts index 3ee08b31a9e56..d841cb524666e 100644 --- a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/controller.js +++ b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/controller.ts @@ -14,17 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import _ from 'lodash'; import {nonEmpty, nonNil} from 'app/utils/lodashMixins'; import id8 from 'app/utils/id8'; -import 'rxjs/add/operator/mergeMap'; -import 'rxjs/add/operator/merge'; -import 'rxjs/add/operator/switchMap'; -import 'rxjs/add/operator/exhaustMap'; -import 'rxjs/add/operator/distinctUntilChanged'; - -import { fromPromise } from 'rxjs/observable/fromPromise'; -import { timer } from 'rxjs/observable/timer'; -import { defer } from 'rxjs/observable/defer'; +import {timer, merge, defer, from} from 'rxjs'; +import {mergeMap, tap, switchMap, exhaustMap, take} from 'rxjs/operators'; import {CSV} from 'app/services/CSV'; @@ -33,6 +28,12 @@ import cacheMetadataTemplateUrl from 'views/sql/cache-metadata.tpl.pug'; import chartSettingsTemplateUrl from 'views/sql/chart-settings.tpl.pug'; import messageTemplateUrl from 'views/templates/message.tpl.pug'; +import {default as Notebook} from '../../notebook.service'; +import {default as MessagesServiceFactory} from 'app/services/Messages.service'; +import {default as LegacyConfirmServiceFactory} from 'app/services/Confirm.service'; +import {default as InputDialog} from 'app/components/input-dialog/input-dialog.service'; +import {QueryActions} from './components/query-actions-button/controller'; + // Time line X axis descriptor. const TIME_LINE = {value: -1, type: 'java.sql.Date', label: 'TIME_LINE'}; @@ -66,6 +67,9 @@ const _fullColName = (col) => { let paragraphId = 0; class Paragraph { + name: string; + qryType: 'scan' | 'query'; + constructor($animate, $timeout, JavaTypes, errorParser, paragraph) { const self = this; @@ -251,12 +255,12 @@ class Paragraph { // Controller for SQL notebook screen. export class NotebookCtrl { - static $inject = ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval', '$animate', '$location', '$anchorScroll', '$state', '$filter', '$modal', '$popover', 'IgniteLoading', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteConfirm', 'AgentManager', 'IgniteChartColors', 'IgniteNotebook', 'IgniteNodes', 'uiGridExporterConstants', 'IgniteVersion', 'IgniteActivitiesData', 'JavaTypes', 'IgniteCopyToClipboard', 'CSV', 'IgniteErrorParser', 'DemoInfo']; + static $inject = ['IgniteInput', '$rootScope', '$scope', '$http', '$q', '$timeout', '$interval', '$animate', '$location', '$anchorScroll', '$state', '$filter', '$modal', '$popover', 'IgniteLoading', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteConfirm', 'AgentManager', 'IgniteChartColors', 'IgniteNotebook', 'IgniteNodes', 'uiGridExporterConstants', 'IgniteVersion', 'IgniteActivitiesData', 'JavaTypes', 'IgniteCopyToClipboard', 'CSV', 'IgniteErrorParser', 'DemoInfo']; /** * @param {CSV} CSV */ - constructor($root, $scope, $http, $q, $timeout, $interval, $animate, $location, $anchorScroll, $state, $filter, $modal, $popover, Loading, LegacyUtils, Messages, Confirm, agentMgr, IgniteChartColors, Notebook, Nodes, uiGridExporterConstants, Version, ActivitiesData, JavaTypes, IgniteCopyToClipboard, CSV, errorParser, DemoInfo) { + constructor(private IgniteInput: InputDialog, $root, private $scope, $http, $q, $timeout, $interval, $animate, $location, $anchorScroll, $state, $filter, $modal, $popover, Loading, LegacyUtils, private Messages: ReturnType, private Confirm: ReturnType, agentMgr, IgniteChartColors, private Notebook: Notebook, Nodes, uiGridExporterConstants, Version, ActivitiesData, JavaTypes, IgniteCopyToClipboard, CSV, errorParser, DemoInfo) { const $ctrl = this; this.CSV = CSV; @@ -891,37 +895,13 @@ export class NotebookCtrl { /** * Update caches list. */ - const _refreshFn = () => { - return agentMgr.topology(true) - .then((nodes) => { - $scope.caches = _.sortBy(_.reduce(nodes, (cachesAcc, node) => { - _.forEach(node.caches, (cache) => { - let item = _.find(cachesAcc, {name: cache.name}); - - if (_.isNil(item)) { - cache.label = maskCacheName(cache.name, true); - cache.value = cache.name; - - cache.nodes = []; - - cachesAcc.push(item = cache); - } - - item.nodes.push({ - nid: node.nodeId.toUpperCase(), - ip: _.head(node.attributes['org.apache.ignite.ips'].split(', ')), - version: node.attributes['org.apache.ignite.build.ver'], - gridName: node.attributes['org.apache.ignite.ignite.name'], - os: `${node.attributes['os.name']} ${node.attributes['os.arch']} ${node.attributes['os.version']}`, - client: node.attributes['org.apache.ignite.cache.client'] - }); - }); - - return cachesAcc; - }, []), (cache) => cache.label.toLowerCase()); - - // Reset to first cache in case of stopped selected. - const cacheNames = _.map($scope.caches, (cache) => cache.value); + const _refreshCaches = () => { + return agentMgr.publicCacheNames() + .then((cacheNames) => { + $scope.caches = _.sortBy(_.map(cacheNames, (name) => ({ + label: maskCacheName(name, true), + value: name + })), (cache) => cache.label.toLowerCase()); _.forEach($scope.notebook.paragraphs, (paragraph) => { if (!_.includes(cacheNames, paragraph.cacheName)) @@ -936,32 +916,35 @@ export class NotebookCtrl { _.forEach($scope.notebook.paragraphs, (paragraph) => $scope.execute(paragraph)); } + + $scope.$applyAsync(); }) .catch((err) => Messages.showError(err)); }; const _startWatch = () => { - const awaitClusters$ = fromPromise( + const awaitClusters$ = from( agentMgr.startClusterWatch('Leave Queries', 'default-state')); const finishLoading$ = defer(() => { if (!$root.IgniteDemoMode) Loading.finish('sqlLoading'); - }).take(1); + }).pipe(take(1)); const refreshCaches = (period) => { - return timer(0, period).exhaustMap(() => _refreshFn()).merge(finishLoading$); + return merge(timer(0, period).pipe(exhaustMap(() => _refreshCaches())), finishLoading$); }; - this.refresh$ = awaitClusters$ - .mergeMap(() => agentMgr.currentCluster$) - .do(() => Loading.start('sqlLoading')) - .do(() => { + this.refresh$ = awaitClusters$.pipe( + mergeMap(() => agentMgr.currentCluster$), + tap(() => Loading.start('sqlLoading')), + tap(() => { _.forEach($scope.notebook.paragraphs, (paragraph) => { paragraph.reset($interval); }); - }) - .switchMap(() => refreshCaches(5000)) + }), + switchMap(() => refreshCaches(5000)) + ) .subscribe(); }; @@ -1025,23 +1008,6 @@ export class NotebookCtrl { $scope.removeNotebook = (notebook) => Notebook.remove(notebook); - $scope.renameParagraph = function(paragraph, newName) { - if (!newName) - return; - - if (paragraph.name !== newName) { - paragraph.name = newName; - - $scope.rebuildScrollParagraphs(); - - Notebook.save($scope.notebook) - .then(() => paragraph.edit = false) - .catch(Messages.showError); - } - else - paragraph.edit = false; - }; - $scope.addParagraph = (paragraph, sz) => { if ($scope.caches && $scope.caches.length > 0) paragraph.cacheName = _.head($scope.caches).value; @@ -1058,7 +1024,7 @@ export class NotebookCtrl { $scope.addQuery = function() { const sz = $scope.notebook.paragraphs.length; - ActivitiesData.post({ action: '/queries/add/query' }); + ActivitiesData.post({ group: 'sql', action: '/queries/add/query' }); const paragraph = _newParagraph({ name: 'Query' + (sz === 0 ? '' : sz), @@ -1087,7 +1053,7 @@ export class NotebookCtrl { $scope.addScan = function() { const sz = $scope.notebook.paragraphs.length; - ActivitiesData.post({ action: '/queries/add/scan' }); + ActivitiesData.post({ group: 'sql', action: '/queries/add/scan' }); const paragraph = _newParagraph({ name: 'Scan' + (sz === 0 ? '' : sz), @@ -1145,31 +1111,6 @@ export class NotebookCtrl { return (paragraph.result === result); }; - $scope.removeParagraph = function(paragraph) { - Confirm.confirm('Are you sure you want to remove query: "' + paragraph.name + '"?') - .then(function() { - $scope.stopRefresh(paragraph); - - const paragraph_idx = _.findIndex($scope.notebook.paragraphs, function(item) { - return paragraph === item; - }); - - const panel_idx = _.findIndex($scope.expandedParagraphs, function(item) { - return paragraph_idx === item; - }); - - if (panel_idx >= 0) - $scope.expandedParagraphs.splice(panel_idx, 1); - - $scope.notebook.paragraphs.splice(paragraph_idx, 1); - - $scope.rebuildScrollParagraphs(); - - Notebook.save($scope.notebook) - .catch(Messages.showError); - }); - }; - $scope.paragraphExpanded = function(paragraph) { const paragraph_idx = _.findIndex($scope.notebook.paragraphs, function(item) { return paragraph === item; @@ -1390,29 +1331,48 @@ export class NotebookCtrl { /** * @param {String} name Cache name. - * @return {Array.} Nids + * @param {Array.} nids Cache name. + * @return {Promise>} */ - const cacheNodes = (name) => { - return _.find($scope.caches, {name}).nodes; + const cacheNodesModel = (name, nids) => { + return agentMgr.topology(true) + .then((nodes) => + _.reduce(nodes, (acc, node) => { + if (_.includes(nids, node.nodeId)) { + acc.push({ + nid: node.nodeId.toUpperCase(), + ip: _.head(node.attributes['org.apache.ignite.ips'].split(', ')), + version: node.attributes['org.apache.ignite.build.ver'], + gridName: node.attributes['org.apache.ignite.ignite.name'], + os: `${node.attributes['os.name']} ${node.attributes['os.arch']} ${node.attributes['os.version']}`, + client: node.attributes['org.apache.ignite.cache.client'] + }); + } + + return acc; + }, []) + ); }; /** - * @param {String} name Cache name. - * @param {Boolean} local Local query. - * @return {String} Nid + * @param {string} name Cache name. + * @param {boolean} local Local query. + * @return {Promise} Nid */ const _chooseNode = (name, local) => { if (_.isEmpty(name)) return Promise.resolve(null); - const nodes = _.filter(cacheNodes(name), (node) => !node.client); - - if (local) { - return Nodes.selectNode(nodes, name) - .then((selectedNids) => _.head(selectedNids)); - } + return agentMgr.cacheNodes(name) + .then((nids) => { + if (local) { + return cacheNodesModel(name, nids) + .then((nodes) => Nodes.selectNode(nodes, name).catch(() => {})) + .then((selectedNids) => _.head(selectedNids)); + } - return Promise.resolve(nodes[_.random(0, nodes.length - 1)].nid); + return nids[_.random(0, nids.length - 1)]; + }); }; const _executeRefresh = (paragraph) => { @@ -1446,53 +1406,28 @@ export class NotebookCtrl { ${query} ) LIMIT ${limitSize}`; - $scope.nonCollocatedJoinsAvailable = (paragraph) => { - const cache = _.find($scope.caches, {name: paragraph.cacheName}); - - if (cache) - return !!_.find(cache.nodes, (node) => Version.since(node.version, NON_COLLOCATED_JOINS_SINCE)); - - return false; + $scope.nonCollocatedJoinsAvailable = () => { + return Version.since(this.agentMgr.clusterVersion, NON_COLLOCATED_JOINS_SINCE); }; - $scope.collocatedJoinsAvailable = (paragraph) => { - const cache = _.find($scope.caches, {name: paragraph.cacheName}); - - if (cache) - return !!_.find(cache.nodes, (node) => Version.since(node.version, ...COLLOCATED_QUERY_SINCE)); - - return false; + $scope.collocatedJoinsAvailable = () => { + return Version.since(this.agentMgr.clusterVersion, ...COLLOCATED_QUERY_SINCE); }; - $scope.enforceJoinOrderAvailable = (paragraph) => { - const cache = _.find($scope.caches, {name: paragraph.cacheName}); - - if (cache) - return !!_.find(cache.nodes, (node) => Version.since(node.version, ...ENFORCE_JOIN_SINCE)); - - return false; + $scope.enforceJoinOrderAvailable = () => { + return Version.since(this.agentMgr.clusterVersion, ...ENFORCE_JOIN_SINCE); }; - $scope.lazyQueryAvailable = (paragraph) => { - const cache = _.find($scope.caches, {name: paragraph.cacheName}); - - if (cache) - return !!_.find(cache.nodes, (node) => Version.since(node.version, ...LAZY_QUERY_SINCE)); - - return false; + $scope.lazyQueryAvailable = () => { + return Version.since(this.agentMgr.clusterVersion, ...LAZY_QUERY_SINCE); }; - $scope.ddlAvailable = (paragraph) => { - const cache = _.find($scope.caches, {name: paragraph.cacheName}); - - if (cache) - return !!_.find(cache.nodes, (node) => Version.since(node.version, ...DDL_SINCE)); - - return false; + $scope.ddlAvailable = () => { + return Version.since(this.agentMgr.clusterVersion, ...DDL_SINCE); }; $scope.cacheNameForSql = (paragraph) => { - return $scope.ddlAvailable(paragraph) && !paragraph.useAsDefaultSchema ? null : paragraph.cacheName; + return $scope.ddlAvailable() && !paragraph.useAsDefaultSchema ? null : paragraph.cacheName; }; $scope.execute = (paragraph, local = false) => { @@ -1529,7 +1464,7 @@ export class NotebookCtrl { collocated }; - ActivitiesData.post({ action: '/queries/execute' }); + ActivitiesData.post({ group: 'sql', action: '/queries/execute' }); const qry = args.maxPages ? addLimit(args.query, args.pageSize * args.maxPages) : query; @@ -1588,7 +1523,7 @@ export class NotebookCtrl { pageSize: paragraph.pageSize }; - ActivitiesData.post({ action: '/queries/explain' }); + ActivitiesData.post({ group: 'sql', action: '/queries/explain' }); return agentMgr.querySql(nid, args.cacheName, args.query, nonCollocatedJoins, enforceJoinOrder, false, false, args.pageSize, false, collocated); }) @@ -1632,7 +1567,7 @@ export class NotebookCtrl { localNid: local ? nid : null }; - ActivitiesData.post({ action: '/queries/scan' }); + ActivitiesData.post({ group: 'sql', action: '/queries/scan' }); return agentMgr.queryScan(nid, cacheName, filter, false, caseSensitive, false, local, pageSize); }) @@ -1882,7 +1817,7 @@ export class NotebookCtrl { $scope.dblclickMetadata = function(paragraph, node) { paragraph.ace.insert(node.name); - setTimeout(() => paragraph.ace.focus(), 1); + setTimeout(() => paragraph.ace.focus(), 100); }; $scope.importMetadata = function() { @@ -1893,7 +1828,7 @@ export class NotebookCtrl { agentMgr.metadata() .then((metadata) => { $scope.metadata = _.sortBy(_.filter(metadata, (meta) => { - const cache = _.find($scope.caches, { name: meta.cacheName }); + const cache = _.find($scope.caches, { value: meta.cacheName }); if (cache) { meta.name = (cache.sqlSchema || '"' + meta.cacheName + '"') + '.' + meta.typeName; @@ -1971,6 +1906,94 @@ export class NotebookCtrl { }; } + scanActions: QueryActions = [ + { + text: 'Scan', + click: (p) => this.$scope.scan(p), + available: (p) => this.$scope.scanAvailable(p) + }, + { + text: 'Scan on selected node', + click: (p) => this.$scope.scan(p, true), + available: (p) => this.$scope.scanAvailable(p) + }, + {text: 'Rename', click: (p) => this.renameParagraph(p), available: () => true}, + {text: 'Remove', click: (p) => this.removeParagraph(p), available: () => true} + ]; + + queryActions: QueryActions = [ + { + text: 'Execute', + click: (p) => this.$scope.execute(p), + available: (p) => this.$scope.queryAvailable(p) + }, + { + text: 'Execute on selected node', + click: (p) => this.$scope.execute(p, true), + available: (p) => this.$scope.queryAvailable(p) + }, + { + text: 'Explain', + click: (p) => this.$scope.explain(p), + available: (p) => this.$scope.queryAvailable(p) + }, + {text: 'Rename', click: (p) => this.renameParagraph(p), available: () => true}, + {text: 'Remove', click: (p) => this.removeParagraph(p), available: () => true} + ]; + + async renameParagraph(paragraph: Paragraph) { + try { + const newName = await this.IgniteInput.input('Rename Query', 'New query name:', paragraph.name); + + if (paragraph.name !== newName) { + paragraph.name = newName; + + this.$scope.rebuildScrollParagraphs(); + + await this.Notebook.save(this.$scope.notebook) + .catch(this.Messages.showError); + } + } + catch (ignored) { + // No-op. + } + } + + async removeParagraph(paragraph: Paragraph) { + try { + await this.Confirm.confirm('Are you sure you want to remove query: "' + paragraph.name + '"?'); + this.$scope.stopRefresh(paragraph); + + const paragraph_idx = _.findIndex(this.$scope.notebook.paragraphs, (item) => paragraph === item); + const panel_idx = _.findIndex(this.$scope.expandedParagraphs, (item) => paragraph_idx === item); + + if (panel_idx >= 0) + this.$scope.expandedParagraphs.splice(panel_idx, 1); + + this.$scope.notebook.paragraphs.splice(paragraph_idx, 1); + this.$scope.rebuildScrollParagraphs(); + + await this.Notebook.save(this.$scope.notebook) + .catch(this.Messages.showError); + } + catch (ignored) { + // No-op. + } + } + + isParagraphOpened(index: number) { + return this.$scope.notebook.expandedParagraphs.includes(index); + } + + onParagraphClose(index: number) { + const expanded = this.$scope.notebook.expandedParagraphs; + expanded.splice(expanded.indexOf(index), 1); + } + + onParagraphOpen(index: number) { + this.$scope.notebook.expandedParagraphs.push(index); + } + $onDestroy() { if (this.refresh$) this.refresh$.unsubscribe(); diff --git a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/index.js b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/index.js index bf93f42586d68..57aa779c05019 100644 --- a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/index.js +++ b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/index.js @@ -19,9 +19,11 @@ import angular from 'angular'; import templateUrl from './template.tpl.pug'; import { NotebookCtrl } from './controller'; import NotebookData from '../../notebook.data'; +import {component as actions} from './components/query-actions-button/component'; import './style.scss'; export default angular.module('ignite-console.sql.notebook', []) + .component('queryActionsButton', actions) .component('queriesNotebook', { controller: NotebookCtrl, templateUrl diff --git a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/style.scss b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/style.scss index fe0ede1b962e5..497870101dc67 100644 --- a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/style.scss +++ b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/style.scss @@ -124,7 +124,7 @@ queries-notebook { .form-field__sensitive { input[type='checkbox'] { - height: 0; + display: none; } input:checked + span { diff --git a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/template.tpl.pug b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/template.tpl.pug index 781ce5190268f..e2c440882bb6f 100644 --- a/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/template.tpl.pug +++ b/modules/web-console/frontend/app/components/page-queries/components/queries-notebook/template.tpl.pug @@ -71,24 +71,6 @@ mixin notebook-error label.col-sm-12 Notebook not accessible any more. Go back to notebooks list. button.h3.btn.btn-primary(ui-sref='default-state') Leave Notebook -mixin paragraph-rename - .col-sm-6(ng-hide='paragraph.edit') - i.fa(ng-class='paragraphExpanded(paragraph) ? "fa-chevron-circle-down" : "fa-chevron-circle-right"') - label {{paragraph.name}} - - .btn-group(ng-hide='notebook.paragraphs.length > 1') - +btn-toolbar('fa-pencil', 'paragraph.edit = true; paragraph.editName = paragraph.name; $event.stopPropagation();', 'Rename query', 'paragraph-name-{{paragraph.id}}') - - .btn-group(ng-show='notebook.paragraphs.length > 1' ng-click='$event.stopPropagation();') - +btn-toolbar('fa-pencil', 'paragraph.edit = true; paragraph.editName = paragraph.name;', 'Rename query', 'paragraph-name-{{paragraph.id}}') - +btn-toolbar('fa-remove', 'removeParagraph(paragraph)', 'Remove query') - - .col-sm-6(ng-show='paragraph.edit') - i.tipLabel.fa(style='float: left;' ng-class='paragraphExpanded(paragraph) ? "fa-chevron-circle-down" : "fa-chevron-circle-right"') - i.tipLabel.fa.fa-floppy-o(style='float: right;' ng-show='paragraph.editName' ng-click='renameParagraph(paragraph, paragraph.editName); $event.stopPropagation();' bs-tooltip data-title='Save query name' data-trigger='hover') - .input-tip - input.form-control(id='paragraph-name-{{paragraph.id}}' ng-model='paragraph.editName' required ng-click='$event.stopPropagation();' ignite-on-enter='renameParagraph(paragraph, paragraph.editName)' ignite-on-escape='paragraph.edit = false') - mixin query-settings div .form-field--inline( @@ -314,10 +296,10 @@ mixin chart-result label.margin-top-dflt Charts do not support #[b Explain] and #[b Scan] query mixin paragraph-scan - .panel-heading(bs-collapse-toggle) - .row - +paragraph-rename - .panel-collapse(role='tabpanel' bs-collapse-target) + panel-title {{ paragraph.name }} + panel-actions + query-actions-button(actions='$ctrl.scanActions' item='paragraph') + panel-content .col-sm-12.sql-controls .col-sm-3 +form-field__dropdown({ @@ -378,9 +360,10 @@ mixin paragraph-scan a Next mixin paragraph-query - .row.panel-heading(bs-collapse-toggle) - +paragraph-rename - .panel-collapse.ng-animate-disabled(role='tabpanel' bs-collapse-target) + panel-title {{ paragraph.name }} + panel-actions + query-actions-button(actions='$ctrl.queryActions' item='paragraph') + panel-content .col-sm-12 .col-xs-8.col-sm-9(style='border-right: 1px solid #eee') .sql-editor(ignite-ace='{onLoad: aceInit(paragraph), theme: "chrome", mode: "sql", require: ["ace/ext/language_tools"],' + @@ -394,12 +377,12 @@ mixin paragraph-query input.form-control(type='text' st-search='label' placeholder='Filter caches...') .queries-notebook-displayed-caches - div(ng-repeat='cache in displayedCaches track by cache.name') + div(ng-repeat='cache in displayedCaches track by cache.value') +form-field__radio({ label: '{{ cache.label }}', model: 'paragraph.cacheName', name: '"cache_" + [paragraph.id, $index].join("_")', - value: 'cache.name' + value: 'cache.value' }) .settings-row @@ -510,10 +493,19 @@ div div(ng-if='notebook' ignite-loading='sqlLoading' ignite-loading-text='{{ loadingText }}' ignite-loading-position='top') .docs-body.paragraphs - .panel-group(bs-collapse ng-model='notebook.expandedParagraphs' data-allow-multiple='true' data-start-collapsed='false') - + .panel-group .panel-paragraph(ng-repeat='paragraph in notebook.paragraphs' id='{{paragraph.id}}' ng-form='form_{{paragraph.id}}') - .panel.panel-default(ng-if='paragraph.qryType === "scan"') + panel-collapsible( + ng-if='paragraph.qryType === "scan"' + opened='$ctrl.isParagraphOpened($index)' + on-close='$ctrl.onParagraphClose($index)' + on-open='$ctrl.onParagraphOpen($index)' + ) +paragraph-scan - .panel.panel-default(ng-if='paragraph.qryType === "query"') + panel-collapsible( + ng-if='paragraph.qryType === "query"' + opened='$ctrl.isParagraphOpened($index)' + on-close='$ctrl.onParagraphClose($index)' + on-open='$ctrl.onParagraphOpen($index)' + ) +paragraph-query diff --git a/modules/web-console/frontend/app/components/page-queries/components/queries-notebooks-list/controller.js b/modules/web-console/frontend/app/components/page-queries/components/queries-notebooks-list/controller.js index 2e5ac39efd998..379f97453b934 100644 --- a/modules/web-console/frontend/app/components/page-queries/components/queries-notebooks-list/controller.js +++ b/modules/web-console/frontend/app/components/page-queries/components/queries-notebooks-list/controller.js @@ -98,14 +98,14 @@ export class NotebooksListCtrl { this.IgniteLoading.start('notebooksLoading'); this.notebooks = await this.IgniteNotebook.read(); this.gridOptions.data = this._preprocessNotebooksList(this.notebooks); - - } catch (err) { + } + catch (err) { this.IgniteMessages.showError(err); - - } finally { + } + finally { this.$scope.$applyAsync(); - await this.IgniteLoading.finish('notebooksLoading'); + this.IgniteLoading.finish('notebooksLoading'); } } @@ -135,19 +135,21 @@ export class NotebooksListCtrl { async createNotebook() { try { - const newNotebookName = await this.IgniteInput.input('New query notebook', 'Notebook name'); + const newNotebookName = await this.IgniteInput.input('New query notebook', 'Notebook name'); this.IgniteLoading.start('notebooksLoading'); + await this.IgniteNotebook.create(newNotebookName); - await this.IgniteLoading.finish('notebooksLoading'); - this._loadAllNotebooks(); + this.IgniteLoading.finish('notebooksLoading'); - } catch (err) { + this._loadAllNotebooks(); + } + catch (err) { this.IgniteMessages.showError(err); - - } finally { - await this.IgniteLoading.finish('notebooksLoading'); + } + finally { + this.IgniteLoading.finish('notebooksLoading'); if (this.createNotebookModal) this.createNotebookModal.$promise.then(this.createNotebookModal.hide); @@ -156,20 +158,22 @@ export class NotebooksListCtrl { async renameNotebok() { try { - const currentNotebook = this.gridApi.selection.legacyGetSelectedRows()[0]; - const newNotebookName = await this.IgniteInput.input('Rename notebook', 'Notebook name', currentNotebook.name); + const currentNotebook = this.gridApi.selection.legacyGetSelectedRows()[0]; + const newNotebookName = await this.IgniteInput.input('Rename notebook', 'Notebook name', currentNotebook.name); if (this.getNotebooksNames().find((name) => newNotebookName === name)) throw Error(`Notebook with name "${newNotebookName}" already exists!`); this.IgniteLoading.start('notebooksLoading'); - await this.IgniteNotebook.save(Object.assign(currentNotebook, {name: newNotebookName})); - } catch (err) { + await this.IgniteNotebook.save(Object.assign(currentNotebook, {name: newNotebookName})); + } + catch (err) { this.IgniteMessages.showError(err); + } + finally { + this.IgniteLoading.finish('notebooksLoading'); - } finally { - await this.IgniteLoading.finish('notebooksLoading'); this._loadAllNotebooks(); } } @@ -180,16 +184,18 @@ export class NotebooksListCtrl { const newNotebookName = await this.IgniteInput.clone(clonedNotebook.name, this.getNotebooksNames()); this.IgniteLoading.start('notebooksLoading'); + await this.IgniteNotebook.clone(newNotebookName, clonedNotebook); - await this.IgniteLoading.finish('notebooksLoading'); - this._loadAllNotebooks(); + this.IgniteLoading.finish('notebooksLoading'); - } catch (err) { + this._loadAllNotebooks(); + } + catch (err) { this.IgniteMessages.showError(err); - - } finally { - await this.IgniteLoading.finish('notebooksLoading'); + } + finally { + this.IgniteLoading.finish('notebooksLoading'); if (this.createNotebookModal) this.createNotebookModal.$promise.then(this.createNotebookModal.hide); @@ -203,15 +209,17 @@ export class NotebooksListCtrl { async deleteNotebooks() { try { this.IgniteLoading.start('notebooksLoading'); + await this.IgniteNotebook.removeBatch(this.gridApi.selection.legacyGetSelectedRows()); - await this.IgniteLoading.finish('notebooksLoading'); - this._loadAllNotebooks(); + this.IgniteLoading.finish('notebooksLoading'); - } catch (err) { + this._loadAllNotebooks(); + } + catch (err) { this.IgniteMessages.showError(err); - await this.IgniteLoading.finish('notebooksLoading'); + this.IgniteLoading.finish('notebooksLoading'); } } diff --git a/modules/web-console/frontend/app/components/page-queries/index.js b/modules/web-console/frontend/app/components/page-queries/index.ts similarity index 77% rename from modules/web-console/frontend/app/components/page-queries/index.js rename to modules/web-console/frontend/app/components/page-queries/index.ts index 9434dc19556a5..2e25cb0dad337 100644 --- a/modules/web-console/frontend/app/components/page-queries/index.js +++ b/modules/web-console/frontend/app/components/page-queries/index.ts @@ -22,14 +22,36 @@ import angular from 'angular'; import queriesNotebooksList from './components/queries-notebooks-list'; import queriesNotebook from './components/queries-notebook'; import pageQueriesCmp from './component'; - +import {default as ActivitiesData} from 'app/core/activities/Activities.data'; import Notebook from './notebook.service'; +import {navigationMenuItem, AppStore} from '../../store'; + +/** + * @param {uirouter.UIRouter} $uiRouter + * @param {ActivitiesData} ActivitiesData + */ +function registerActivitiesHook($uiRouter, ActivitiesData) { + $uiRouter.transitionService.onSuccess({to: 'base.sql.**'}, (transition) => { + ActivitiesData.post({group: 'sql', action: transition.targetState().name()}); + }); +} + +registerActivitiesHook.$inject = ['$uiRouter', 'IgniteActivitiesData']; export default angular.module('ignite-console.sql', [ 'ui.router', queriesNotebooksList.name, queriesNotebook.name ]) + .run(['Store', (store: AppStore) => { + store.dispatch(navigationMenuItem({ + activeSref: 'base.sql.**', + icon: 'sql', + label: 'Queries', + order: 2, + sref: 'base.sql.tabs.notebooks-list' + })); + }]) .component('pageQueries', pageQueriesCmp) .component('pageQueriesSlot', { require: { @@ -84,4 +106,5 @@ export default angular.module('ignite-console.sql', [ title: 'Query notebook' } }); - }]); + }]) + .run(registerActivitiesHook); diff --git a/modules/web-console/frontend/app/components/page-queries/notebook.data.js b/modules/web-console/frontend/app/components/page-queries/notebook.data.js index 6c784bfc3ea11..d9035c2445621 100644 --- a/modules/web-console/frontend/app/components/page-queries/notebook.data.js +++ b/modules/web-console/frontend/app/components/page-queries/notebook.data.js @@ -21,7 +21,6 @@ const DEMO_NOTEBOOK = { paragraphs: [ { name: 'Query with refresh rate', - cacheName: 'CarCache', qryType: 'query', pageSize: 100, limit: 0, @@ -39,7 +38,6 @@ const DEMO_NOTEBOOK = { }, { name: 'Simple query', - cacheName: 'CarCache', qryType: 'query', pageSize: 100, limit: 0, @@ -54,7 +52,6 @@ const DEMO_NOTEBOOK = { }, { name: 'Query with aggregates', - cacheName: 'ParkingCache', qryType: 'query', pageSize: 100, limit: 0, diff --git a/modules/web-console/frontend/app/components/page-queries/notebook.service.js b/modules/web-console/frontend/app/components/page-queries/notebook.service.js index dbfd6a6febf77..2a60cdcd74515 100644 --- a/modules/web-console/frontend/app/components/page-queries/notebook.service.js +++ b/modules/web-console/frontend/app/components/page-queries/notebook.service.js @@ -70,7 +70,7 @@ export default class Notebook { return this.confirmModal.confirm(`Are you sure you want to remove notebook: "${notebook.name}"?`) .then(() => this.NotebookData.findIndex(notebook)) .then((idx) => { - this.NotebookData.remove(notebook) + return this.NotebookData.remove(notebook) .then(() => { if (this.$state.includes('base.sql.tabs.notebook') && this.$state.params.noteId === notebook._id) return this._openNotebook(idx); diff --git a/modules/web-console/frontend/app/components/page-signin/component.ts b/modules/web-console/frontend/app/components/page-signin/component.ts index 968ff396e298d..6c5f46153c6e5 100644 --- a/modules/web-console/frontend/app/components/page-signin/component.ts +++ b/modules/web-console/frontend/app/components/page-signin/component.ts @@ -22,5 +22,8 @@ import './style.scss'; /** @type {ng.IComponentOptions} */ export default { controller, - template + template, + bindings: { + activationToken: '@?' + } }; diff --git a/modules/web-console/frontend/app/components/page-signin/controller.ts b/modules/web-console/frontend/app/components/page-signin/controller.ts index 724da41dadeb9..71caa0e245a9b 100644 --- a/modules/web-console/frontend/app/components/page-signin/controller.ts +++ b/modules/web-console/frontend/app/components/page-signin/controller.ts @@ -17,6 +17,8 @@ import AuthService from 'app/modules/user/Auth.service'; +import {PageSigninStateParams} from './run'; + interface ISiginData { email: string, password: string @@ -27,7 +29,9 @@ interface ISigninFormController extends ng.IFormController { password: ng.INgModelController } -export default class { +export default class PageSignIn implements ng.IPostLink { + activationToken?: PageSigninStateParams['activationToken']; + data: ISiginData = { email: null, password: null @@ -37,15 +41,16 @@ export default class { serverError: string = null; - static $inject = ['Auth', 'IgniteMessages', 'IgniteFormUtils']; + static $inject = ['Auth', 'IgniteMessages', 'IgniteFormUtils', '$element']; - constructor(private Auth: AuthService, private IgniteMessages, private IgniteFormUtils) {} + constructor(private Auth: AuthService, private IgniteMessages, private IgniteFormUtils, private el: JQLite) {} canSubmitForm(form: ISigninFormController) { return form.$error.server ? true : !form.$invalid; } $postLink() { + this.el.addClass('public-page'); this.form.email.$validators.server = () => !this.serverError; this.form.password.$validators.server = () => !this.serverError; } @@ -64,9 +69,12 @@ export default class { if (!this.canSubmitForm(this.form)) return; - return this.Auth.signin(this.data.email, this.data.password).catch((res) => { - this.IgniteMessages.showError(null, res.data); + return this.Auth.signin(this.data.email, this.data.password, this.activationToken).catch((res) => { + this.IgniteMessages.showError(null, res.data.errorMessage ? res.data.errorMessage : res.data); + this.setServerError(res.data); + + this.IgniteFormUtils.triggerValidation(this.form); }); } } diff --git a/modules/web-console/frontend/app/components/page-signin/run.ts b/modules/web-console/frontend/app/components/page-signin/run.ts index aa5647c44a363..1d13397e7b79c 100644 --- a/modules/web-console/frontend/app/components/page-signin/run.ts +++ b/modules/web-console/frontend/app/components/page-signin/run.ts @@ -15,14 +15,24 @@ * limitations under the License. */ -import {UIRouter} from '@uirouter/angularjs'; +import publicTemplate from '../../../views/public.pug'; +import {UIRouter, StateParams} from '@uirouter/angularjs'; import {IIgniteNg1StateDeclaration} from 'app/types'; +export type PageSigninStateParams = StateParams & {activationToken?: string}; + export function registerState($uiRouter: UIRouter) { const state: IIgniteNg1StateDeclaration = { - url: '/signin', + url: '/signin?{activationToken:string}', name: 'signin', - component: 'pageSignin', + views: { + '': { + template: publicTemplate + }, + 'page@signin': { + component: 'pageSignin' + } + }, unsaved: true, redirectTo: (trans) => { const skipStates = new Set(['signup', 'forgotPassword', 'landing']); @@ -46,6 +56,11 @@ export function registerState($uiRouter: UIRouter) { }, tfMetaTags: { title: 'Sign In' + }, + resolve: { + activationToken() { + return $uiRouter.stateService.transition.params().activationToken; + } } }; diff --git a/modules/web-console/frontend/app/components/page-signin/style.scss b/modules/web-console/frontend/app/components/page-signin/style.scss index 51da101770161..729d439dbb055 100644 --- a/modules/web-console/frontend/app/components/page-signin/style.scss +++ b/modules/web-console/frontend/app/components/page-signin/style.scss @@ -18,32 +18,19 @@ page-signin { display: flex; flex-direction: column; - flex: 1 0 auto; - section { - margin-left: auto; - margin-right: auto; - width: 530px; - - h3 { - font-size: 38px; - font-weight: 300; - margin: 30px 0 30px; - } - - .form-field { - margin: 10px 0; - } + .form-field { + margin: 10px 0; + } - .form-footer { - padding: 15px 0; - text-align: right; - display: flex; - align-items: center; + .form-footer { + padding: 15px 0; + text-align: right; + display: flex; + align-items: center; - .btn-ignite { - margin-left: auto; - } + .btn-ignite { + margin-left: auto; } } diff --git a/modules/web-console/frontend/app/components/page-signin/template.pug b/modules/web-console/frontend/app/components/page-signin/template.pug index b31a9bdb69798..c85976f639ed9 100644 --- a/modules/web-console/frontend/app/components/page-signin/template.pug +++ b/modules/web-console/frontend/app/components/page-signin/template.pug @@ -16,44 +16,37 @@ include /app/helpers/jade/mixins -web-console-header - web-console-header-left - ignite-header-title - -.container--responsive.body-container - section - -var form = '$ctrl.form' - h3 Sign In - form(name=form novalidate ng-submit='$ctrl.signin()') - +form-field__email({ - label: 'Email:', - model: '$ctrl.data.email', - name: '"email"', - placeholder: 'Input email', - required: true - })( - ng-model-options='{allowInvalid: true}' - autocomplete='email' - ignite-auto-focus - ) - +form-field__error({error: 'server', message: `{{$ctrl.serverError}}`}) - +form-field__password({ - label: 'Password:', - model: '$ctrl.data.password', - name: '"password"', - placeholder: 'Input password', - required: true - })( - ng-model-options='{allowInvalid: true}' - autocomplete='current-password' - ) - +form-field__error({error: 'server', message: `{{$ctrl.serverError}}`}) - footer.form-footer - a(ui-sref='forgotPassword({email: $ctrl.data.email})') Forgot password? - button.btn-ignite.btn-ignite--primary( - type='submit' - ) Sign In - footer.page-signin__no-account-message - | Don't have an account? #[a(ui-sref='signup') Get started] - -web-console-footer +h3.public-page__title Sign In +p(ng-if='$ctrl.activationToken') + | Please sign in to confirm your registration +form(name='$ctrl.form' novalidate ng-submit='$ctrl.signin()') + +form-field__email({ + label: 'Email:', + model: '$ctrl.data.email', + name: '"email"', + placeholder: 'Input email', + required: true + })( + ng-model-options='{allowInvalid: true}' + autocomplete='email' + ignite-auto-focus + ) + +form-field__error({error: 'server', message: `{{$ctrl.serverError}}`}) + +form-field__password({ + label: 'Password:', + model: '$ctrl.data.password', + name: '"password"', + placeholder: 'Input password', + required: true + })( + ng-model-options='{allowInvalid: true}' + autocomplete='current-password' + ) + +form-field__error({error: 'server', message: `{{$ctrl.serverError}}`}) + footer.form-footer + a(ui-sref='forgotPassword({email: $ctrl.data.email})') Forgot password? + button.btn-ignite.btn-ignite--primary( + type='submit' + ) {{ ::$ctrl.activationToken ? "Activate" : "Sign In" }} +footer.page-signin__no-account-message + | Don't have an account? #[a(ui-sref='signup') Get started] diff --git a/modules/web-console/frontend/app/components/page-signup-confirmation/component.ts b/modules/web-console/frontend/app/components/page-signup-confirmation/component.ts new file mode 100644 index 0000000000000..3a1cc8167b7ef --- /dev/null +++ b/modules/web-console/frontend/app/components/page-signup-confirmation/component.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +import controller from './controller'; +import templateUrl from './template.tpl.pug'; +import './style.scss'; + +export const component: ng.IComponentOptions = { + controller, + templateUrl, + bindings: { + email: '@' + } +}; diff --git a/modules/web-console/frontend/app/components/page-signup-confirmation/controller.ts b/modules/web-console/frontend/app/components/page-signup-confirmation/controller.ts new file mode 100644 index 0000000000000..e5f5c89dc0147 --- /dev/null +++ b/modules/web-console/frontend/app/components/page-signup-confirmation/controller.ts @@ -0,0 +1,42 @@ +/* + * 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. + */ + +import {default as Auth} from '../../modules/user/Auth.service'; +import {default as MessagesFactory} from '../../services/Messages.service'; + +export default class PageSignupConfirmation { + email: string; + + static $inject = ['Auth', 'IgniteMessages', '$element']; + + constructor(private auth: Auth, private messages: ReturnType, private el: JQLite) { + } + + $postLink() { + this.el.addClass('public-page'); + } + + async resendConfirmation() { + try { + await this.auth.resendSignupConfirmation(this.email); + this.messages.showInfo('Signup confirmation sent, check your email'); + } + catch (e) { + this.messages.showError(e); + } + } +} diff --git a/modules/web-console/frontend/app/components/ignite-status/style.scss b/modules/web-console/frontend/app/components/page-signup-confirmation/index.ts similarity index 78% rename from modules/web-console/frontend/app/components/ignite-status/style.scss rename to modules/web-console/frontend/app/components/page-signup-confirmation/index.ts index d2877fc5a71db..8df75327f1987 100644 --- a/modules/web-console/frontend/app/components/ignite-status/style.scss +++ b/modules/web-console/frontend/app/components/page-signup-confirmation/index.ts @@ -15,13 +15,9 @@ * limitations under the License. */ -@import "../../../public/stylesheets/variables"; +import {component} from './component'; +import {state} from './state'; -// Statuses coloring -.ignite-status__active { - color: $ignite-status-active !important; -} - -.ignite-status__inactive { - color: $ignite-status-inactive; -} +export default angular.module('ignite-console.page-signup-confirmation', []) + .run(state) + .component('pageSignupConfirmation', component); diff --git a/modules/web-console/frontend/app/components/page-signup-confirmation/state.ts b/modules/web-console/frontend/app/components/page-signup-confirmation/state.ts new file mode 100644 index 0000000000000..fb1b6a4bc5d9e --- /dev/null +++ b/modules/web-console/frontend/app/components/page-signup-confirmation/state.ts @@ -0,0 +1,48 @@ +/* + * 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. + */ + +import {UIRouter, StateParams} from '@uirouter/angularjs'; +import {IIgniteNg1StateDeclaration} from '../../types'; +import publicTemplate from '../../../views/public.pug'; + +export type PageSignupConfirmationStateParams = StateParams & {email: string}; + +state.$inject = ['$uiRouter']; + +export function state(router: UIRouter) { + router.stateRegistry.register({ + name: 'signup-confirmation', + url: '/signup-confirmation?{email:string}', + views: { + '': { + template: publicTemplate + }, + 'page@signup-confirmation': { + component: 'pageSignupConfirmation' + } + }, + unsaved: true, + tfMetaTags: { + title: 'Sign Up Confirmation' + }, + resolve: { + email() { + return router.stateService.transition.params().email; + } + } + } as IIgniteNg1StateDeclaration); +} diff --git a/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-extension/component.js b/modules/web-console/frontend/app/components/page-signup-confirmation/style.scss similarity index 89% rename from modules/web-console/frontend/app/components/web-console-header/components/web-console-header-extension/component.js rename to modules/web-console/frontend/app/components/page-signup-confirmation/style.scss index 1621adccceee4..d3c062b5cffff 100644 --- a/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-extension/component.js +++ b/modules/web-console/frontend/app/components/page-signup-confirmation/style.scss @@ -15,8 +15,8 @@ * limitations under the License. */ -import template from './template.pug'; - -export default { - template -}; +page-signup-confirmation { + display: flex; + flex-direction: column; + flex: 1 0 auto; +} diff --git a/modules/web-console/frontend/app/components/page-signup-confirmation/template.tpl.pug b/modules/web-console/frontend/app/components/page-signup-confirmation/template.tpl.pug new file mode 100644 index 0000000000000..a1d183cc69c1d --- /dev/null +++ b/modules/web-console/frontend/app/components/page-signup-confirmation/template.tpl.pug @@ -0,0 +1,24 @@ +//- + 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. + + +h3.public-page__title Confirm your email +p + | Thanks For Signing Up! + br + | Please check your email and click link in the message we just sent to {{::$ctrl.email}}. + br + | If you don’t receive email try to resend confirmation once more. diff --git a/modules/web-console/frontend/app/components/page-signup/component.js b/modules/web-console/frontend/app/components/page-signup/component.js index 789a68187e828..968ff396e298d 100644 --- a/modules/web-console/frontend/app/components/page-signup/component.js +++ b/modules/web-console/frontend/app/components/page-signup/component.js @@ -15,8 +15,6 @@ * limitations under the License. */ -import angular from 'angular'; - import template from './template.pug'; import controller from './controller'; import './style.scss'; diff --git a/modules/web-console/frontend/app/components/page-signup/controller.js b/modules/web-console/frontend/app/components/page-signup/controller.ts similarity index 52% rename from modules/web-console/frontend/app/components/page-signup/controller.js rename to modules/web-console/frontend/app/components/page-signup/controller.ts index 10397760c3d71..748bf7f0ef857 100644 --- a/modules/web-console/frontend/app/components/page-signup/controller.js +++ b/modules/web-console/frontend/app/components/page-signup/controller.ts @@ -15,11 +15,19 @@ * limitations under the License. */ -export default class PageSignup { - /** @type {import('./types').ISignupFormController} */ - form; - /** @type {import('./types').ISignupData} */ - data = { +import Auth from '../../modules/user/Auth.service'; +import MessagesFactory from '../../services/Messages.service'; +import FormUtilsFactoryFactory from '../../services/FormUtils.service'; +import {ISignupData} from '../form-signup'; +import {get, eq, pipe} from 'lodash/fp'; + +const EMAIL_NOT_CONFIRMED_ERROR_CODE = 10104; +const isEmailConfirmationError = pipe(get('data.errorCode'), eq(EMAIL_NOT_CONFIRMED_ERROR_CODE)); + +export default class PageSignup implements ng.IPostLink { + form: ng.IFormController; + + data: ISignupData = { email: null, password: null, firstName: null, @@ -27,37 +35,28 @@ export default class PageSignup { company: null, country: null }; - /** @type {string} */ - serverError = null; - static $inject = ['IgniteCountries', 'Auth', 'IgniteMessages', 'IgniteFormUtils']; + serverError: string | null = null; - /** - * @param {ReturnType} Countries - * @param {import('app/modules/user/Auth.service').default} Auth - * @param {ReturnType} IgniteMessages - * @param {ReturnType} IgniteFormUtils - */ - constructor(Countries, Auth, IgniteMessages, IgniteFormUtils) { - this.Auth = Auth; - this.IgniteMessages = IgniteMessages; - this.countries = Countries.getAll(); - this.IgniteFormUtils = IgniteFormUtils; - } + static $inject = ['Auth', 'IgniteMessages', 'IgniteFormUtils', '$element']; - /** @param {import('./types').ISignupFormController} form */ - canSubmitForm(form) { - return form.$error.server ? true : !form.$invalid; - } + constructor( + private Auth: Auth, + private IgniteMessages: ReturnType, + private IgniteFormUtils: ReturnType, + private el: JQLite + ) {} $postLink() { - this.form.email.$validators.server = () => !this.serverError; + this.el.addClass('public-page'); } - /** @param {string} error */ - setServerError(error) { + canSubmitForm(form: PageSignup['form']) { + return form.$error.server ? true : !form.$invalid; + } + + setServerError(error: PageSignup['serverError']) { this.serverError = error; - this.form.email.$validate(); } signup() { @@ -68,7 +67,10 @@ export default class PageSignup { if (!this.canSubmitForm(this.form)) return; - return this.Auth.signnup(this.data).catch((res) => { + return this.Auth.signup(this.data).catch((res) => { + if (isEmailConfirmationError(res)) + return; + this.IgniteMessages.showError(null, res.data); this.setServerError(res.data); }); diff --git a/modules/web-console/frontend/app/components/page-signup/index.js b/modules/web-console/frontend/app/components/page-signup/index.js index 4efadb5f47af5..001d26987d29a 100644 --- a/modules/web-console/frontend/app/components/page-signup/index.js +++ b/modules/web-console/frontend/app/components/page-signup/index.js @@ -22,7 +22,8 @@ import {registerState} from './run'; export default angular .module('ignite-console.page-signup', [ 'ui.router', - 'ignite-console.user' + 'ignite-console.user', + 'ignite-console.form-signup' ]) .component('pageSignup', component) .run(registerState); diff --git a/modules/web-console/frontend/app/components/page-signup/run.js b/modules/web-console/frontend/app/components/page-signup/run.js index 1d04fa257714f..bd2763802e85e 100644 --- a/modules/web-console/frontend/app/components/page-signup/run.js +++ b/modules/web-console/frontend/app/components/page-signup/run.js @@ -15,6 +15,8 @@ * limitations under the License. */ +import publicTemplate from '../../../views/public.pug'; + /** * @param {import("@uirouter/angularjs").UIRouter} $uiRouter */ @@ -23,7 +25,14 @@ export function registerState($uiRouter) { const state = { name: 'signup', url: '/signup', - component: 'pageSignup', + views: { + '': { + template: publicTemplate + }, + 'page@signup': { + component: 'pageSignup' + } + }, unsaved: true, tfMetaTags: { title: 'Sign Up' diff --git a/modules/web-console/frontend/app/components/page-signup/style.scss b/modules/web-console/frontend/app/components/page-signup/style.scss index 93167ce6856da..0930036fb8e14 100644 --- a/modules/web-console/frontend/app/components/page-signup/style.scss +++ b/modules/web-console/frontend/app/components/page-signup/style.scss @@ -20,36 +20,14 @@ page-signup { flex-direction: column; flex: 1 0 auto; - section { - h3 { - font-size: 38px; - font-weight: 300; - margin: 30px 0 30px; - } - - margin-left: auto; - margin-right: auto; - width: 530px; - - form footer { - padding: 15px 0; - text-align: right; - display: flex; - align-items: center; - - .btn-ignite { - margin-left: auto; - } - } - - form { - display: grid; - grid-gap: 10px; - grid-template-columns: 1fr 1fr; - - .full-width { - grid-column: 1 / 3; - } + form footer { + padding: 15px 0; + text-align: right; + display: flex; + align-items: center; + + .btn-ignite { + margin-left: auto; } } diff --git a/modules/web-console/frontend/app/components/page-signup/template.pug b/modules/web-console/frontend/app/components/page-signup/template.pug index 11bb50a15c733..686079ad94a1b 100644 --- a/modules/web-console/frontend/app/components/page-signup/template.pug +++ b/modules/web-console/frontend/app/components/page-signup/template.pug @@ -14,108 +14,16 @@ See the License for the specific language governing permissions and limitations under the License. -include /app/helpers/jade/mixins - -web-console-header - web-console-header-left - ignite-header-title - -.container--responsive.body-container - section - -var form = '$ctrl.form' - h3 Don't Have An Account? - form(name=form novalidate ng-submit='$ctrl.signup()') - .full-width - +form-field__email({ - label: 'Email:', - model: '$ctrl.data.email', - name: '"email"', - placeholder: 'Input email', - required: true - })( - ng-model-options='{allowInvalid: true}' - autocomplete='email' - ignite-auto-focus - ) - +form-field__error({error: 'server', message: `{{$ctrl.serverError}}`}) - div - +form-field__password({ - label: 'Password:', - model: '$ctrl.data.password', - name: '"password"', - placeholder: 'Input password', - required: true - })( - autocomplete='new-password' - ) - div - +form-field__password({ - label: 'Confirm:', - model: 'confirm', - name: '"confirm"', - placeholder: 'Confirm password', - required: true - })( - ignite-match='$ctrl.data.password' - autocomplete='off' - ) - div - +form-field__text({ - label: 'First name:', - model: '$ctrl.data.firstName', - name: '"firstName"', - placeholder: 'Input first name', - required: true - })( - autocomplete='given-name' - ) - div - +form-field__text({ - label: 'Last name:', - model: '$ctrl.data.lastName', - name: '"lastName"', - placeholder: 'Input last name', - required: true - })( - autocomplete='family-name' - ) - div - +form-field__phone({ - label: 'Phone:', - model: '$ctrl.data.phone', - name: '"phone"', - placeholder: 'Input phone (ex.: +15417543010)', - optional: true - })( - autocomplete='tel' - ) - div - +form-field__dropdown({ - label: 'Country:', - model: '$ctrl.data.country', - name: '"country"', - required: true, - placeholder: 'Choose your country', - options: '$ctrl.countries' - })( - autocomplete='country' - ) - .full-width - +form-field__text({ - label: 'Company:', - model: '$ctrl.data.company', - name: '"company"', - placeholder: 'Input company name', - required: true - })( - ignite-on-enter-focus-move='countryInput' - autocomplete='organization' - ) - footer.full-width.form-footer - button.btn-ignite.btn-ignite--primary( - type='submit' - ) Sign Up - footer.page-signup__has-account-message - | Already have an account? #[a(ui-sref='signin') Sign in here] - -web-console-footer +h3.public-page__title Don't Have An Account? +form(name='$ctrl.form' novalidate ng-submit='$ctrl.signup()') + form-signup( + outer-form='$ctrl.form' + ng-model='$ctrl.data' + server-error='$ctrl.serverError' + ) + footer.full-width.form-footer + button.btn-ignite.btn-ignite--primary( + type='submit' + ) Sign Up +footer.page-signup__has-account-message + | Already have an account? #[a(ui-sref='signin') Sign in here] diff --git a/modules/web-console/frontend/app/components/web-console-footer/components/web-console-footer-links/component.js b/modules/web-console/frontend/app/components/permanent-notifications/component.ts similarity index 88% rename from modules/web-console/frontend/app/components/web-console-footer/components/web-console-footer-links/component.js rename to modules/web-console/frontend/app/components/permanent-notifications/component.ts index 40a1051a75820..e86d3e512713a 100644 --- a/modules/web-console/frontend/app/components/web-console-footer/components/web-console-footer-links/component.js +++ b/modules/web-console/frontend/app/components/permanent-notifications/component.ts @@ -16,8 +16,10 @@ */ import template from './template.pug'; +import controller from './controller'; import './style.scss'; -export default { - template +export const component: ng.IComponentOptions = { + template, + controller }; diff --git a/modules/web-console/frontend/app/components/permanent-notifications/controller.ts b/modules/web-console/frontend/app/components/permanent-notifications/controller.ts new file mode 100644 index 0000000000000..d67230431b311 --- /dev/null +++ b/modules/web-console/frontend/app/components/permanent-notifications/controller.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +export default class PermanentNotifications { + static $inject = ['UserNotifications', '$rootScope', '$window'] + constructor( + private UserNotifications: unknown, + private $rootScope: ng.IRootScopeService, + private $window: ng.IWindowService + ) {} + closeDemo() { + this.$window.close(); + } +} diff --git a/modules/web-console/frontend/app/components/permanent-notifications/index.ts b/modules/web-console/frontend/app/components/permanent-notifications/index.ts new file mode 100644 index 0000000000000..33a9189132002 --- /dev/null +++ b/modules/web-console/frontend/app/components/permanent-notifications/index.ts @@ -0,0 +1,21 @@ +/* + * 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. + */ + +import {component} from './component'; + +export default angular.module('ignite-console.permanent-notifications', []) + .component('permanentNotifications', component); diff --git a/modules/web-console/frontend/app/components/permanent-notifications/style.scss b/modules/web-console/frontend/app/components/permanent-notifications/style.scss new file mode 100644 index 0000000000000..e40f21a359630 --- /dev/null +++ b/modules/web-console/frontend/app/components/permanent-notifications/style.scss @@ -0,0 +1,54 @@ +/* + * 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. + */ + +permanent-notifications { + display: block; + + @import "./../../../public/stylesheets/variables.scss"; + + .wch-notification { + line-height: 16px; + padding: 7px; + background: $brand-warning; + font-size: 16px; + text-align: center; + + a { + color: $brand-info; + } + + &+.wch-notification { + border-top: 1px solid darken($brand-warning, 15%); + } + } + + .wch-notification.wch-notification--demo { + color: white; + background: $ignite-brand-success; + border: none; + + a { + color: white; + text-decoration: underline; + + &:hover { + color: #ffab40; + text-decoration: none; + } + } + } +} \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/permanent-notifications/template.pug b/modules/web-console/frontend/app/components/permanent-notifications/template.pug new file mode 100644 index 0000000000000..6abe61181a512 --- /dev/null +++ b/modules/web-console/frontend/app/components/permanent-notifications/template.pug @@ -0,0 +1,23 @@ +//- + 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. + +.wch-notification(ng-show='$ctrl.UserNotifications.isShown && $ctrl.UserNotifications.message' ng-bind-html='$ctrl.UserNotifications.message') + +.wch-notification(ng-show='$ctrl.$rootScope.user.becomeUsed') + | You are currently viewing user #[strong {{$ctrl.$rootScope.user.firstName}} {{$ctrl.$rootScope.user.lastName}}] as administrator. #[a(ng-click='$ctrl.$rootScope.revertIdentity()') Revert to your identity?] + +.wch-notification.wch-notification--demo(ng-if='$ctrl.$rootScope.IgniteDemoMode') + | You are now in #[b Demo Mode]. #[a(ng-click='$ctrl.closeDemo()') Close Demo?] diff --git a/modules/web-console/frontend/app/components/status-output/component.ts b/modules/web-console/frontend/app/components/status-output/component.ts new file mode 100644 index 0000000000000..fed828080a755 --- /dev/null +++ b/modules/web-console/frontend/app/components/status-output/component.ts @@ -0,0 +1,31 @@ +/* + * 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. + */ + +import {Status} from './controller'; +import templateUrl from './template.tpl.pug'; +import './style.scss'; + +const component: ng.IComponentOptions = { + templateUrl, + bindings: { + options: '<', + value: '<' + }, + controller: Status +}; + +export {component}; diff --git a/modules/web-console/frontend/app/components/status-output/componentFactory.ts b/modules/web-console/frontend/app/components/status-output/componentFactory.ts new file mode 100644 index 0000000000000..192abb5c31319 --- /dev/null +++ b/modules/web-console/frontend/app/components/status-output/componentFactory.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +import {StatusOptions} from './index'; +import {Status} from './controller'; +import {component} from './component'; + +export const componentFactory = (options: StatusOptions) => ({ + ...component, + bindings: { + value: '<' + }, + controller: class extends Status { + options = options + } +}); diff --git a/modules/web-console/frontend/app/components/status-output/controller.ts b/modules/web-console/frontend/app/components/status-output/controller.ts new file mode 100644 index 0000000000000..e9baab1dbcf38 --- /dev/null +++ b/modules/web-console/frontend/app/components/status-output/controller.ts @@ -0,0 +1,53 @@ +/* + * 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. + */ + +import {StatusOptions, StatusOption} from './index'; + +interface Changes extends ng.IOnChangesObject { + value: ng.IChangesObject, + options: ng.IChangesObject +} + +const UNIVERSAL_CLASSNAME = 'status-output'; + +export class Status implements ng.IComponentController, ng.IOnChanges, ng.IPostLink, ng.IOnDestroy { + static $inject = ['$element']; + + value: string; + options: StatusOptions; + status: StatusOption | undefined; + statusClassName: string | undefined; + + constructor(private el: JQLite) {} + + $postLink() { + this.el[0].classList.add(UNIVERSAL_CLASSNAME); + } + + $onDestroy() { + delete this.el; + } + + $onChanges(changes: Changes) { + if ('value' in changes) { + this.status = this.options.find((option) => option.value === this.value); + + if (this.status) + this.statusClassName = `${UNIVERSAL_CLASSNAME}__${this.status.level.toLowerCase()}`; + } + } +} diff --git a/modules/web-console/frontend/app/components/status-output/index.ts b/modules/web-console/frontend/app/components/status-output/index.ts new file mode 100644 index 0000000000000..c24d438762411 --- /dev/null +++ b/modules/web-console/frontend/app/components/status-output/index.ts @@ -0,0 +1,40 @@ +/* + * 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. + */ + +import {component} from './component'; +export {componentFactory} from './componentFactory'; + +export interface StatusOption { + level: StatusLevel, + // Whether to show progress indicator or not + ongoing?: boolean, + value: string | boolean, + // What user will see + label: string +} + +export type StatusOptions = Array; + +export enum StatusLevel { + NEUTRAL = 'NEUTRAL', + GREEN = 'GREEN', + RED = 'RED' +} + +export default angular + .module('ignite-console.components.status-output', []) + .component('statusOutput', component); diff --git a/modules/web-console/frontend/app/components/status-output/style.scss b/modules/web-console/frontend/app/components/status-output/style.scss new file mode 100644 index 0000000000000..d49213f2eb9d3 --- /dev/null +++ b/modules/web-console/frontend/app/components/status-output/style.scss @@ -0,0 +1,38 @@ +/* + * 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. + */ + +.status-output { + @import 'public/stylesheets/variables'; + + display: inline-flex; + + .spinner-circle { + margin-left: 5px; + } + + .status-output__neutral { + color: inherit; + } + + .status-output__green { + color: $ignite-status-active; + } + + .status-output__red { + color: $ignite-status-inactive; + } +} diff --git a/modules/web-console/frontend/app/modules/branding/powered-by-apache.pug b/modules/web-console/frontend/app/components/status-output/template.tpl.pug similarity index 87% rename from modules/web-console/frontend/app/modules/branding/powered-by-apache.pug rename to modules/web-console/frontend/app/components/status-output/template.tpl.pug index 6031235968c8a..a79035e6aa56e 100644 --- a/modules/web-console/frontend/app/modules/branding/powered-by-apache.pug +++ b/modules/web-console/frontend/app/components/status-output/template.tpl.pug @@ -14,5 +14,5 @@ See the License for the specific language governing permissions and limitations under the License. -a(ng-if='poweredBy.show' href='//ignite.apache.org' target='_blank') - img(ng-src='/images/pb-ignite.png') +span(translate='{{$ctrl.status.label}}' ng-class='$ctrl.statusClassName') +.spinner-circle(ng-if='$ctrl.status.ongoing') diff --git a/modules/web-console/frontend/app/components/timed-redirection/component.ts b/modules/web-console/frontend/app/components/timed-redirection/component.ts new file mode 100644 index 0000000000000..5cab0c9dd6300 --- /dev/null +++ b/modules/web-console/frontend/app/components/timed-redirection/component.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +import template from './template.pug'; +import './style.scss'; +import {TimedRedirectionCtrl} from './controller'; + +export const component: ng.IComponentOptions = { + template, + controller: TimedRedirectionCtrl, + bindings: { + headerText: '<', + subHeaderText: '<' + } +}; diff --git a/modules/web-console/frontend/app/components/timed-redirection/controller.ts b/modules/web-console/frontend/app/components/timed-redirection/controller.ts new file mode 100644 index 0000000000000..034ff3c20f011 --- /dev/null +++ b/modules/web-console/frontend/app/components/timed-redirection/controller.ts @@ -0,0 +1,60 @@ +/* + * 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. + */ + +import {StateOrName, StateService} from '@uirouter/angularjs'; +import {RawParams} from '@uirouter/core/lib/params/interface'; + +interface State { + name: StateOrName, + params: RawParams +} + +export class TimedRedirectionCtrl implements ng.IComponentController, ng.IOnInit, ng.IOnDestroy { + static $inject = ['$state', '$interval']; + + lastSuccessState = JSON.parse(localStorage.getItem('lastStateChangeSuccess')); + + stateToGo: State = this.lastSuccessState || {name: 'default-state', params: {}}; + + secondsLeft: number = 10; + + countDown: ng.IPromise; + + constructor(private $state: StateService, private $interval: ng.IIntervalService) {} + + $onInit() { + this.startCountDown(); + } + + $onDestroy() { + this.$interval.cancel(this.countDown); + } + + go(): void { + this.$state.go(this.stateToGo.name, this.stateToGo.params); + } + + startCountDown(): void { + this.countDown = this.$interval(() => { + this.secondsLeft--; + + if (this.secondsLeft === 0) + this.go(); + + }, 1000, this.secondsLeft); + } +} diff --git a/modules/web-console/frontend/app/components/page-password-changed/controller.js b/modules/web-console/frontend/app/components/timed-redirection/index.ts similarity index 80% rename from modules/web-console/frontend/app/components/page-password-changed/controller.js rename to modules/web-console/frontend/app/components/timed-redirection/index.ts index e3b0a035b5e14..c4951f6c8edde 100644 --- a/modules/web-console/frontend/app/components/page-password-changed/controller.js +++ b/modules/web-console/frontend/app/components/timed-redirection/index.ts @@ -15,12 +15,9 @@ * limitations under the License. */ -export default class { - static $inject = ['$state', '$timeout']; +import * as angular from 'angular'; - constructor($state, $timeout) { - $timeout(() => { - $state.go('signin'); - }, 10000); - } -} +import {component} from './component'; + +export default angular.module('ignite-console.timed-redirection', []) + .component('timedRedirection', component); diff --git a/modules/web-console/frontend/app/modules/branding/footer.directive.js b/modules/web-console/frontend/app/components/timed-redirection/style.scss similarity index 63% rename from modules/web-console/frontend/app/modules/branding/footer.directive.js rename to modules/web-console/frontend/app/components/timed-redirection/style.scss index 3c0bb83e740f5..487fa2d8d2486 100644 --- a/modules/web-console/frontend/app/modules/branding/footer.directive.js +++ b/modules/web-console/frontend/app/components/timed-redirection/style.scss @@ -15,25 +15,34 @@ * limitations under the License. */ -const template = ''; +@import "./../../../public/stylesheets/variables.scss"; -/** - * @param {import('./branding.service').default} branding - */ -export default function factory(branding) { - function controller() { - const ctrl = this; +timed-redirection { + justify-content: center; + align-items: center; + display: flex; + flex-direction: column; + flex: 1; + min-height: 100%; - ctrl.html = branding.footerHtml; - } + .timed-redirection--wrapper { + text-align: center; + } - return { - restrict: 'E', - template, - controller, - controllerAs: 'footer', - replace: true - }; -} + h1, .sub-header { + color: $ignite-brand-primary; + } + + h1 { + font-size: 64px; + } -factory.$inject = ['IgniteBranding']; + .sub-header { + font-size: 30px; + } + + .redirection-text { + margin-top: 30px; + font-size: 16px; + } +} diff --git a/modules/web-console/frontend/views/403.tpl.pug b/modules/web-console/frontend/app/components/timed-redirection/template.pug similarity index 75% rename from modules/web-console/frontend/views/403.tpl.pug rename to modules/web-console/frontend/app/components/timed-redirection/template.pug index 491ff6b622651..77f8298158b74 100644 --- a/modules/web-console/frontend/views/403.tpl.pug +++ b/modules/web-console/frontend/app/components/timed-redirection/template.pug @@ -14,11 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. -web-console-header +.timed-redirection--wrapper + h1 {{::$ctrl.headerText}} -.container--responsive.body-container - .error-page - h1.error-page__title 403 - h2.error-page__description You are not authorized + .sub-header {{::$ctrl.subHeaderText}} -web-console-footer \ No newline at end of file + .redirection-text You’ll be redirected back automatically in {{$ctrl.secondsLeft}} seconds, or #[a(ng-click='$ctrl.go()') click here] to redirect now. diff --git a/modules/web-console/frontend/app/components/ui-grid-filters/template.pug b/modules/web-console/frontend/app/components/ui-grid-filters/template.pug index 4cdcc8705f6a2..a865395bdd34e 100644 --- a/modules/web-console/frontend/app/components/ui-grid-filters/template.pug +++ b/modules/web-console/frontend/app/components/ui-grid-filters/template.pug @@ -27,6 +27,7 @@ type='button' title='{{ colFilter.$$multiselectFilterTooltip() }}' ng-model='colFilter.term' + ng-disabled='col.colDef.multiselectFilterDisabled' bs-select bs-options='option.value as option.label for option in colFilter.selectOptions' data-multiple='true' @@ -41,7 +42,7 @@ }` ng-click='colFilter.selectDialog(grid, colFilter)' type='button' - title='{{ colFilter.$$multiselectFilterTooltip() }}' + title='{{ colFilter.$$multiselectFilterTooltip() }}' ) {{ col.displayName }} .ui-grid-cell-contents(role='button') diff --git a/modules/web-console/frontend/app/components/ui-grid/component.js b/modules/web-console/frontend/app/components/ui-grid/component.js index f0c3b06309055..d75cc6c2f1637 100644 --- a/modules/web-console/frontend/app/components/ui-grid/component.js +++ b/modules/web-console/frontend/app/components/ui-grid/component.js @@ -30,6 +30,7 @@ export default { gridHeight: ' { if (this.selectedRowsId) this.applyIncomingSelectionRowsId(this.selectedRowsId); }); + + this.resizeObserver = new ResizeObserver(() => api.core.handleWindowResize()); + this.resizeObserver.observe(this.$element[0]); } }; @@ -149,6 +158,11 @@ export default class IgniteUiGrid { this.adjustHeight(); } + $onDestroy() { + if (this.resizeObserver) + this.resizeObserver.disconnect(); + } + applyIncomingSelectionRows = (selected = []) => { this.gridApi.selection.clearSelectedRows({ ignore: true }); diff --git a/modules/web-console/frontend/app/components/ui-grid/style.scss b/modules/web-console/frontend/app/components/ui-grid/style.scss index dba5d359ea290..da31f67efab05 100644 --- a/modules/web-console/frontend/app/components/ui-grid/style.scss +++ b/modules/web-console/frontend/app/components/ui-grid/style.scss @@ -18,6 +18,7 @@ .ignite-grid-table, ignite-grid-table { @import 'public/stylesheets/variables'; + display: block; .ui-grid.ui-grid--ignite.ui-grid--thin { // Start section row height. diff --git a/modules/web-console/frontend/app/components/web-console-footer/component.js b/modules/web-console/frontend/app/components/web-console-footer/component.js index 40a1051a75820..bb2f7f7728cd0 100644 --- a/modules/web-console/frontend/app/components/web-console-footer/component.js +++ b/modules/web-console/frontend/app/components/web-console-footer/component.js @@ -17,7 +17,9 @@ import template from './template.pug'; import './style.scss'; +import controller from './controller'; export default { - template + template, + controller }; diff --git a/modules/web-console/frontend/app/components/web-console-footer/controller.ts b/modules/web-console/frontend/app/components/web-console-footer/controller.ts new file mode 100644 index 0000000000000..0811748f075d6 --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-footer/controller.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +import {default as Version} from '../../services/Version.service'; + +export default class WebConsoleFooter { + static $inject = ['IgniteVersion', '$rootScope'] + constructor(private Version: Version, private $root: ng.IRootScopeService) {} + year = new Date().getFullYear() + get userIsAuthorized() { + return !!this.$root.user; + } +} diff --git a/modules/web-console/frontend/app/components/web-console-footer/index.js b/modules/web-console/frontend/app/components/web-console-footer/index.js index e26b60238a6bb..4fa461779da83 100644 --- a/modules/web-console/frontend/app/components/web-console-footer/index.js +++ b/modules/web-console/frontend/app/components/web-console-footer/index.js @@ -17,9 +17,16 @@ import angular from 'angular'; import component from './component'; -import componentLinks from './components/web-console-footer-links/component'; export default angular .module('ignite-console.web-console-footer', []) .component('webConsoleFooter', component) - .component('webConsoleFooterLinks', componentLinks); + .directive('webConsoleFooterPageBottom', function() { + return { + restrict: 'C', + link(scope, el) { + el.parent().addClass('wrapper-public'); + scope.$on('$destroy', () => el.parent().removeClass('wrapper-public')); + } + }; + }); diff --git a/modules/web-console/frontend/app/components/web-console-footer/style.scss b/modules/web-console/frontend/app/components/web-console-footer/style.scss index f3de59fccedb5..fe5eb64e584b0 100644 --- a/modules/web-console/frontend/app/components/web-console-footer/style.scss +++ b/modules/web-console/frontend/app/components/web-console-footer/style.scss @@ -16,46 +16,87 @@ */ web-console-footer { - display: block; - color: #fafafa; - background: linear-gradient(to bottom, #5f5e5e, #393939); - font-family: Roboto; font-size: 12px; - font-weight: 300; - padding-top: 12px; - padding-bottom: 12px; - p { - margin-bottom: 0; + .#{&}__legal { + color: rgba(0, 0, 0, 0.54); + } + + &.web-console-footer__sidebar-closed { + width: var(--width-narrow); + border-top: 1px solid #dddddd; + + a { + color: var(--inactive-link-color); + margin-left: auto; + margin-right: auto; + width: 40px; + height: 40px; + display: inline-flex; + align-items: center; + justify-content: center; - &:first-of-type { - margin-bottom: 5px; + &:hover, &:focus { + color: var(--active-link-color); + } + [ignite-icon] { + transform: scale(1.25); + } + } + + .web-console-footer__sidebar-stuff { + position: sticky; + display: grid; + grid-row-gap: 15px; + padding-top: 20px; + padding-bottom: 20px; + } + + .web-console-footer__regular-stuff { + display: none; } } - .wcf-content { + &.web-console-footer__sidebar-opened { + width: var(--width-wide); display: flex; - flex-direction: row; - align-items: center; + flex-direction: column; + padding: 27px 18px 27px 27px; - & > :nth-child(2) { - margin-left: auto; + .web-console-footer__sidebar-stuff { + display: none; + } + + .web-console-footer__regular-stuff { + display: block; } } +} + +.web-console-footer__page-bottom { + grid-area: footer; + color: #fafafa; + background: #393939; + font-size: 12px; + font-weight: 300; + padding: 12px var(--page-side-padding); + + .web-console-footer__sidebar-stuff { + display: none; + } - ignite-powered-by-apache { - & > a { - margin-left: 40px; - } + p { + margin: 0; } a { - color: #ee8e89; - - &:hover, &.hover, - &:focus, &.focus { - color: #ee2b27; - text-decoration: none; + color: #ee8e89 !important; + &:hover, &:focus { + color: #ee2b27 !important; } } + + .web-console-footer__legal { + color: inherit; + } } diff --git a/modules/web-console/frontend/app/components/web-console-footer/template.pug b/modules/web-console/frontend/app/components/web-console-footer/template.pug index aa2812af64904..2c1495e342e09 100644 --- a/modules/web-console/frontend/app/components/web-console-footer/template.pug +++ b/modules/web-console/frontend/app/components/web-console-footer/template.pug @@ -14,7 +14,19 @@ See the License for the specific language governing permissions and limitations under the License. -.container--responsive.wcf-content - ignite-footer - web-console-footer-links(ng-if='$parent.user') - ignite-powered-by-apache \ No newline at end of file + +.web-console-footer__sidebar-stuff + a( + href="/api/v1/downloads/agent" + target="_self" + ng-if='$ctrl.userIsAuthorized' + title='Download Agent' + ) + svg(ignite-icon='downloadAgent') + +.web-console-footer__regular-stuff + p Apache Ignite Web Console ({{$ctrl.Version.webConsole}}) + p © {{::$ctrl.year}} The Apache Software Foundation. + p.web-console-footer__legal Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are trademarks of The Apache Software Foundation. + + a(href="/api/v1/downloads/agent" target="_self" ng-if='$ctrl.userIsAuthorized') Download Agent \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/web-console-header/component.js b/modules/web-console/frontend/app/components/web-console-header/component.ts similarity index 65% rename from modules/web-console/frontend/app/components/web-console-header/component.js rename to modules/web-console/frontend/app/components/web-console-header/component.ts index a0a8230c17863..ad7e8a78d0630 100644 --- a/modules/web-console/frontend/app/components/web-console-header/component.js +++ b/modules/web-console/frontend/app/components/web-console-header/component.ts @@ -17,33 +17,27 @@ import template from './template.pug'; import './style.scss'; +import {AppStore, toggleSidebar} from '../../store'; export default { template, controller: class { - static $inject = ['$rootScope', '$scope', '$state', 'IgniteBranding', 'UserNotifications']; + static $inject = ['$rootScope', '$scope', '$state', 'IgniteBranding', 'UserNotifications', 'Store']; - static connectedClustersUnvisibleStates = [ - '403', '404', 'signin' - ]; - - constructor($rootScope, $scope, $state, branding, UserNotifications) { + constructor($rootScope, $scope, $state, branding, UserNotifications, private store: AppStore) { Object.assign(this, {$rootScope, $scope, $state, branding, UserNotifications}); } - setConnectedClustersVisible() { - this.isConnectedClustersVisible = - !this.constructor.connectedClustersUnvisibleStates.some((state) => this.$state.includes(state)); + toggleSidebar() { + this.store.dispatch(toggleSidebar()); } - $onInit() { - this.setConnectedClustersVisible(); - - this.$scope.$on('$stateChangeSuccess', () => this.setConnectedClustersVisible()); + isAuthorized() { + return !!this.$rootScope.user; } }, - transclude: { - slotLeft: '?webConsoleHeaderLeft', - slotRight: '?webConsoleHeaderRight' + transclude: true, + bindings: { + hideMenuButton: ' + ) {} + + private _openTab(stateName: string) { + this.$window.open(this.$state.href(stateName, {}), '_blank'); + } + + startDemo() { + if (!this.$root.user.demoCreated) + return this._openTab('demo.reset'); + + this.Confirm.confirm('Would you like to continue with previous demo session?', true, false) + .then((resume) => { + if (resume) + return this._openTab('demo.resume'); + + this._openTab('demo.reset'); + }); + } +} diff --git a/modules/web-console/frontend/app/components/web-console-footer/components/web-console-footer-links/template.pug b/modules/web-console/frontend/app/components/web-console-header/components/demo-mode-button/template.pug similarity index 90% rename from modules/web-console/frontend/app/components/web-console-footer/components/web-console-footer-links/template.pug rename to modules/web-console/frontend/app/components/web-console-header/components/demo-mode-button/template.pug index 5c0446786bb26..f566ac4c65fdd 100644 --- a/modules/web-console/frontend/app/components/web-console-footer/components/web-console-footer-links/template.pug +++ b/modules/web-console/frontend/app/components/web-console-header/components/demo-mode-button/template.pug @@ -14,4 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. -a(href="/api/v1/downloads/agent" target="_self") Download Agent + +button.btn-ignite.btn-ignite--success( + ng-click='$ctrl.startDemo()' +) Start Demo \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/index.js b/modules/web-console/frontend/app/components/web-console-header/components/user-menu/component.ts similarity index 94% rename from modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/index.js rename to modules/web-console/frontend/app/components/web-console-header/components/user-menu/component.ts index 480fe54002ec1..f6141d9baf2b7 100644 --- a/modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/index.js +++ b/modules/web-console/frontend/app/components/web-console-header/components/user-menu/component.ts @@ -15,12 +15,11 @@ * limitations under the License. */ -import './style.scss'; import template from './template.pug'; +import controller from './controller'; +import './style.scss'; export default { template, - bindings: { - status: '<' - } + controller }; diff --git a/modules/web-console/frontend/app/modules/navbar/userbar.directive.js b/modules/web-console/frontend/app/components/web-console-header/components/user-menu/controller.ts similarity index 50% rename from modules/web-console/frontend/app/modules/navbar/userbar.directive.js rename to modules/web-console/frontend/app/components/web-console-header/components/user-menu/controller.ts index b636a34d82ff5..812d3b54ae3e9 100644 --- a/modules/web-console/frontend/app/modules/navbar/userbar.directive.js +++ b/modules/web-console/frontend/app/components/web-console-header/components/user-menu/controller.ts @@ -15,45 +15,39 @@ * limitations under the License. */ -/** - * @param {ng.IRootScopeService} $root - * @param {unknown} IgniteUserbar - * @param {unknown} AclService - */ -function controller($root, IgniteUserbar, AclService) { - const ctrl = this; - - this.$onInit = () => { - ctrl.items = [ +export default class UserMenu { + static $inject = ['$rootScope', 'IgniteUserbar', 'AclService', '$state', 'gettingStarted'] + constructor( + private $root: ng.IRootScopeService, + private IgniteUserbar: any, + private AclService: any, + private $state: any, + private gettingStarted: any + ) {} + $onInit() { + this.items = [ {text: 'Profile', sref: 'base.settings.profile'}, - {text: 'Getting started', click: 'gettingStarted.tryShow(true)'} + {text: 'Getting started', click: '$ctrl.gettingStarted.tryShow(true)'} ]; const _rebuildSettings = () => { - ctrl.items.splice(2); + this.items.splice(2); - if (AclService.can('admin_page')) - ctrl.items.push({text: 'Admin panel', sref: 'base.settings.admin'}); + if (this.AclService.can('admin_page')) + this.items.push({text: 'Admin panel', sref: 'base.settings.admin'}); - ctrl.items.push(...IgniteUserbar); + this.items.push(...this.IgniteUserbar); - if (AclService.can('logout')) - ctrl.items.push({text: 'Log out', sref: 'logout'}); + if (this.AclService.can('logout')) + this.items.push({text: 'Log out', sref: 'logout'}); }; - if ($root.user) - _rebuildSettings(null, $root.user); - - $root.$on('user', _rebuildSettings); - }; -} - -controller.$inject = ['$rootScope', 'IgniteUserbar', 'AclService']; + if (this.$root.user) + _rebuildSettings(null, this.$root.user); -export default function() { - return { - restrict: 'A', - controller, - controllerAs: 'userbar' - }; + this.$root.$on('user', _rebuildSettings); + } + get user() { + return this.$root.user; + } } diff --git a/modules/web-console/frontend/app/components/web-console-header/components/user-menu/style.scss b/modules/web-console/frontend/app/components/web-console-header/components/user-menu/style.scss new file mode 100644 index 0000000000000..898047b52a9ea --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-header/components/user-menu/style.scss @@ -0,0 +1,28 @@ +/* + * 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. + */ + +user-menu { + --active-link-color: #ee2b27; + font-size: 14px; + + &>.active { + color: var(--active-link-color) + } + .caret { + margin-left: 8px; + } +} \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/web-console-header/components/user-menu/template.pug b/modules/web-console/frontend/app/components/web-console-header/components/user-menu/template.pug new file mode 100644 index 0000000000000..e946c78a9b9ba --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-header/components/user-menu/template.pug @@ -0,0 +1,26 @@ +//- + 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. + +div( + ng-class='{active: $ctrl.$state.includes("base.settings")}' + ng-click='$event.stopPropagation()' + bs-dropdown='$ctrl.items' + data-placement='bottom-right' + data-trigger='hover focus' + data-container='self' +) + span {{$ctrl.user.firstName}} {{$ctrl.user.lastName}} + span.caret \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/component.ts b/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/component.ts new file mode 100644 index 0000000000000..e86d3e512713a --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/component.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ + +import template from './template.pug'; +import controller from './controller'; +import './style.scss'; + +export const component: ng.IComponentOptions = { + template, + controller +}; diff --git a/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/controller.ts b/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/controller.ts new file mode 100644 index 0000000000000..4345553d36b53 --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/controller.ts @@ -0,0 +1,45 @@ +/* + * 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. + */ + +import {StateService} from '@uirouter/angularjs'; + +export default class WebConsoleHeaderContent { + static $inject = ['$rootScope', '$state'] + constructor( + private $rootScope: ng.IRootScopeService, + private $state: StateService + ) {} + + static connectedClusterInvisibleStates = [ + '403', '404', 'signin' + ]; + + get showConnectedClusters(): boolean { + return this.$rootScope.user && + !this.$rootScope.IgniteDemoMode && + !this.constructor.connectedClusterInvisibleStates.some((state) => this.$state.includes(state)) && + !this.$rootScope.user.becomeUsed; + } + + get showUserMenu(): boolean { + return !!this.$rootScope.user; + } + + get showDemoModeButton(): boolean { + return this.$rootScope.user && !this.$rootScope.user.becomeUsed && !this.$rootScope.IgniteDemoMode; + } +} diff --git a/modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/style.scss b/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/style.scss similarity index 62% rename from modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/style.scss rename to modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/style.scss index 2f0c98149d1bc..f4836148c0585 100644 --- a/modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/style.scss +++ b/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/style.scss @@ -15,32 +15,30 @@ * limitations under the License. */ -connected-clusters-cell-status { - $color-active: #417505; - $color-not-active: #ee2b27; +web-console-header-content { + display: flex; + flex: 1; - display: block; - - div { + .web-console-header-content__right { + margin-left: auto; display: flex; - - &:before { - content: '●'; - - position: relative; - height: 16px; - margin-right: 10px; - - font-size: 24px; - line-height: 19px; - } } - .#{&}-active { - color: $color-active; + .web-console-header-item { + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + padding: 0 20px; + border-left: 1px solid #dddddd; + height: 100%; } +} - .#{&}-not-active { - color: $color-not-active; - } +.web-console-header-content__title { + display: flex; + align-items: center; + margin-left: 80px; + font-size: 1.4em; + margin-right: auto; } \ No newline at end of file diff --git a/modules/web-console/frontend/views/404.tpl.pug b/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/template.pug similarity index 74% rename from modules/web-console/frontend/views/404.tpl.pug rename to modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/template.pug index d9a0795dc73ad..8f1d4f8747013 100644 --- a/modules/web-console/frontend/views/404.tpl.pug +++ b/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-content/template.pug @@ -14,11 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. -web-console-header +.web-console-header-content__right + .web-console-header-item(ng-if='$ctrl.showConnectedClusters') + connected-clusters + .web-console-header-item(ng-if='$ctrl.showDemoModeButton') + demo-mode-button -.container--responsive.body-container - .error-page - h1.error-page__title 404 - h2.error-page__description Page not found - -web-console-footer \ No newline at end of file +.web-console-header-item(ng-if='$ctrl.showUserMenu') + user-menu \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-extension/template.pug b/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-extension/template.pug deleted file mode 100644 index 0545db18b96a7..0000000000000 --- a/modules/web-console/frontend/app/components/web-console-header/components/web-console-header-extension/template.pug +++ /dev/null @@ -1,15 +0,0 @@ -//- - 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. diff --git a/modules/web-console/frontend/app/components/web-console-header/index.js b/modules/web-console/frontend/app/components/web-console-header/index.js index 3fc5c66579fc1..2a106d47f8129 100644 --- a/modules/web-console/frontend/app/components/web-console-header/index.js +++ b/modules/web-console/frontend/app/components/web-console-header/index.js @@ -17,9 +17,13 @@ import angular from 'angular'; import component from './component'; -import componentExtension from './components/web-console-header-extension/component'; +import userMenu from './components/user-menu/component'; +import {component as content} from './components/web-console-header-content/component'; +import {component as demo} from './components/demo-mode-button/component'; export default angular .module('ignite-console.web-console-header', []) .component('webConsoleHeader', component) - .component('webConsoleHeaderExtension', componentExtension); + .component('webConsoleHeaderContent', content) + .component('userMenu', userMenu) + .component('demoModeButton', demo); diff --git a/modules/web-console/frontend/app/components/web-console-header/style.scss b/modules/web-console/frontend/app/components/web-console-header/style.scss index e92fdd5b66843..e34328433dc7c 100644 --- a/modules/web-console/frontend/app/components/web-console-header/style.scss +++ b/modules/web-console/frontend/app/components/web-console-header/style.scss @@ -21,16 +21,27 @@ web-console-header { $nav-item-margin: 30px; $bottom-border-width: 4px; - display: block; - min-height: 85px; + display: flex; + flex-direction: row; + align-items: center; + height: 62px; font-family: Roboto; font-size: 16px; border-bottom: $bottom-border-width solid red; background: white; position: relative; + padding-left: 16px; + + &>ng-transclude { + display: flex; + flex-direction: row; + justify-content: flex-end; + height: 100%; + flex: 1; + } &:after { - // Shows header shadow over absoluteley positioned child content, + // Shows header shadow over absolutely positioned child content, // otherwise z ordering issues happen. display: block; width: 100%; @@ -39,6 +50,7 @@ web-console-header { position: absolute; overflow: hidden; bottom: -4px; + pointer-events: none; } .wch-slot { @@ -59,153 +71,26 @@ web-console-header { } } - .wch-content { - display: flex; - flex-direction: row; - flex-wrap: wrap; - align-items: center; - padding: 18px 30px; - position: relative; - height: 81px; - } - .wch-logo { height: 40px; } - .wch-nav-item, - .wch-nav-item > a { - cursor: pointer; - white-space: nowrap; - - &, &.active { - font-size: 16px; - font-weight: normal; - text-decoration: none; - } - - $color-default: $text-color; - $color-hover: $brand-primary; - $color-active: $brand-primary; - - &, a { - color: $color-default; - text-decoration: none; - } - - &, ul { - margin: 0; - list-style: none; - -webkit-padding-start: 0; - } - - &:hover { - color: $color-hover; - } - - &:focus, :focus, - &.active, .active { - color: $color-active; - } - - &[disabled] { - opacity: 0.5; - cursor: default; - } - - .caret { - margin-left: 4px; - } - - &:not(:last-child) { - margin-right: $nav-item-margin; - } - - .dropdown-menu { - a { - &:hover, &:focus { - color: inherit; - } - } - li.active a { - color: inherit; - } - } - - .user-name-wrapper { - display: flex; - align-items: center; - - & > span { - max-width: 180px; - overflow: hidden; - text-overflow: ellipsis; - } - } - } - - .wch-demo-toggle { - margin-right: 10px; - - // When in demo mode and clusters are hidden - &:nth-last-child(2) { - margin-right: $nav-item-margin; - } - } - - .wch-notification { - line-height: 16px; - padding: 7px; - background: $brand-warning; - font-size: 16px; - text-align: center; - - a { - color: $brand-info; - } - - &+.wch-notification { - border-top: 1px solid darken($brand-warning, 15%); - } - } - - .wch-notification.wch-notification--demo { - z-index: 10000000; - position: fixed; - top: 0; - width: 100%; - - color: white; - background: $ignite-brand-success; - border: none; - - box-shadow: 0 0 15px #008eff; - animation: pulse 2s infinite; - - a { - color: white; - text-decoration: underline; - - &:hover { - color: #ffab40; - text-decoration: none; - } - } - } - .wch-additional-nav-items { display: flex; } -} -@keyframes pulse { - 0% { - box-shadow: 0 1px 2px #008eff; - } - 50% { - box-shadow: 0 1px 15px #008eff; + .web-console-header__togle-menu-button { + width: 40px; + height: 40px; + background: none !important; + border: none !important; + margin: 0 !important; + padding: 0 !important; + outline: none !important; + color: rgba(0, 0, 0, 0.54); + margin-right: 5px; } - 100% { - box-shadow: 0 1px 2px #008eff; + .web-console-header__togle-menu-button-hidden { + visibility: hidden; } } diff --git a/modules/web-console/frontend/app/components/web-console-header/template.pug b/modules/web-console/frontend/app/components/web-console-header/template.pug index 801b742e949d1..940f3a48f0bd3 100644 --- a/modules/web-console/frontend/app/components/web-console-header/template.pug +++ b/modules/web-console/frontend/app/components/web-console-header/template.pug @@ -14,20 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. -.wch-notification(ng-show='$ctrl.UserNotifications.isShown && $ctrl.UserNotifications.message' ng-bind-html='$ctrl.UserNotifications.message') - -.wch-notification(ng-show='$root.user.becomeUsed') - | You are currently viewing user #[strong {{$root.user.firstName}} {{$root.user.lastName}}] as administrator. #[a(ng-click='$root.revertIdentity()') Revert to your identity?] - -.wch-notification.wch-notification--demo(ng-if='$root.IgniteDemoMode') - div(ng-controller='demoController') - | You are now in #[b Demo Mode]. #[a(ng-click='closeDemo();') Close Demo?] - -.wch-content - connected-clusters(ng-if='$ctrl.$rootScope.user && !$ctrl.$rootScope.IgniteDemoMode && $ctrl.isConnectedClustersVisible && !$root.user.becomeUsed') - - a(ui-sref='landing') - img.wch-logo(ng-src='{{::$ctrl.branding.headerLogo}}') - - .wch-slot.wch-slot-left(ng-transclude='slotLeft') - .wch-slot.wch-slot-right(ng-transclude='slotRight') +button.web-console-header__togle-menu-button( + type='button' + title='Toggle menu' + ng-click='$ctrl.toggleSidebar()' + ng-class='::{"web-console-header__togle-menu-button-hidden": $ctrl.hideMenuButton}' +) + svg(ignite-icon='menu') + +a(ui-sref='{{$ctrl.isAuthorized() ? "default-state" : "landing"}}').wch-logo-anchor + img.wch-logo(src='/images/ignite-logo.svg') + +ng-transclude diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/component.ts b/modules/web-console/frontend/app/components/web-console-sidebar/component.ts new file mode 100644 index 0000000000000..e86d3e512713a --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/component.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ + +import template from './template.pug'; +import controller from './controller'; +import './style.scss'; + +export const component: ng.IComponentOptions = { + template, + controller +}; diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/controller.ts b/modules/web-console/frontend/app/components/web-console-sidebar/controller.ts new file mode 100644 index 0000000000000..bdf606b7bd481 --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/controller.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +import {AppStore, selectSidebarOpened} from '../../store'; + +export default class WebConsoleSidebar { + static $inject = ['$rootScope', 'Store'] + constructor( + private $rootScope: ng.IRootScopeService, + private store: AppStore + ) {} + sidebarOpened$ = this.store.state$.pipe(selectSidebarOpened()) + get showNavigation(): boolean { + return !!this.$rootScope.user; + } +} diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/index.ts b/modules/web-console/frontend/app/components/web-console-sidebar/index.ts new file mode 100644 index 0000000000000..717dca5a12711 --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/index.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ + +import {component as overflow} from './web-console-sidebar-overflow/component'; +import {component as nav} from './web-console-sidebar-navigation/component'; +import {component as sidebar} from './component'; + +export default angular.module('sidebar', []) + .component('webConsoleSidebarOverflow', overflow) + .component('webConsoleSidebarNavigation', nav) + .component('webConsoleSidebar', sidebar); diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/style.scss b/modules/web-console/frontend/app/components/web-console-sidebar/style.scss new file mode 100644 index 0000000000000..b625333b8b23d --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/style.scss @@ -0,0 +1,44 @@ +/* + * 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. + */ + +web-console-sidebar { + display: flex; + flex-direction: column; + background: white; + border-right: 1px #dddddd solid; + --width-narrow: 75px; + --width-wide: 280px; + --active-link-color: #ee2b27; + --inactive-link-color: #757575; + // Does not include notifications height + max-height: calc(100vh - var(--header-height)); + position: -webkit-sticky; + position: sticky; + top: var(--header-height); + + web-console-sidebar-overflow { + flex: 1; + } + + web-console-footer { + flex: 0 0 auto; + + &:first-child { + margin-top: auto; + } + } +} \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/template.pug b/modules/web-console/frontend/app/components/web-console-sidebar/template.pug new file mode 100644 index 0000000000000..f02f2c408f873 --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/template.pug @@ -0,0 +1,22 @@ +//- + 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. + +web-console-sidebar-overflow + web-console-sidebar-navigation(opened='$ctrl.sidebarOpened$|async:this' ng-if='$ctrl.showNavigation') +web-console-footer(ng-class=`{ + "web-console-footer__sidebar-opened": ($ctrl.sidebarOpened$|async:this), + "web-console-footer__sidebar-closed": !($ctrl.sidebarOpened$|async:this) +}`) \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/component.ts b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/component.ts new file mode 100644 index 0000000000000..4e4647f97605f --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/component.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +import './style.scss'; +import template from './template.pug'; +import controller from './controller'; + +export const component = { + controller, + template, + bindings: { + opened: '<' + } +}; diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/controller.ts b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/controller.ts new file mode 100644 index 0000000000000..8b5355a890782 --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/controller.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +import {AppStore, selectNavigationMenu} from '../../../store'; + +export default class WebConsoleSidebarNavigation { + static $inject = ['Store'] + constructor(private store: AppStore) {} + menu$ = this.store.state$.pipe(selectNavigationMenu()) +} diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/style.scss b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/style.scss new file mode 100644 index 0000000000000..b9c3e68a437f2 --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/style.scss @@ -0,0 +1,109 @@ +/* + * 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. + */ + +web-console-sidebar-navigation { + display: flex; + flex-direction: column; + padding-top: 14px; + + nav { + display: flex; + flex-direction: column; + list-style-type: none; + + &>li { + display: flex; + } + } + + .web-console-sidebar-navigation__link-icon { + width: 20px; + height: auto; + color: var(--inactive-link-color); + } + + .web-console-sidebar-navigation__link-narrow { + height: var(--width-narrow); + width: var(--width-narrow); + color: var(--inactive-link-color); + display: flex; + justify-content: center; + align-items: center; + + &:hover, &:focus { + color: var(--active-link-color); + + } + + &.web-console-sidebar-navigation__link-active { + color: var(--active-link-color); + position: relative; + + &:after { + content: ''; + display: block; + width: 2px; + // Line can't be outside of scrollable container + right: 0; + top: 0; + bottom: 0; + position: absolute; + background: var(--active-link-color); + } + .web-console-sidebar-navigation__link-icon { + color: inherit; + } + } + .web-console-sidebar-navigation__link-content { + display: none; + } + } + + li:first-of-type > .web-console-sidebar-navigation__link-wide { + margin-top: 18px; + } + + .web-console-sidebar-navigation__link-wide { + color: #393939; + text-decoration: none !important; + line-height: 19px; + font-size: 16px; + padding: 10px 28px 11px; + width: var(--width-wide); + display: inline-flex; + align-items: center; + + &:hover, &:focus { + color: var(--active-link-color); + + .web-console-sidebar-navigation__link-icon { + color: inherit; + } + } + &.web-console-sidebar-navigation__link-active { + color: white; + background: var(--active-link-color); + + .web-console-sidebar-navigation__link-icon { + color: inherit; + } + } + .web-console-sidebar-navigation__link-icon { + margin-right: 12px; + } + } +} \ No newline at end of file diff --git a/modules/web-console/frontend/views/includes/header-right.pug b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/template.pug similarity index 51% rename from modules/web-console/frontend/views/includes/header-right.pug rename to modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/template.pug index d2d89aa616d57..c35de9dfdbf56 100644 --- a/modules/web-console/frontend/views/includes/header-right.pug +++ b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-navigation/template.pug @@ -14,22 +14,22 @@ See the License for the specific language governing permissions and limitations under the License. -.wch-demo-toggle(ng-if='!$root.user.becomeUsed' ng-controller='demoController') - button.btn-ignite.btn-ignite--success( - ng-if='!IgniteDemoMode' - ng-click='startDemo()' - ) Start Demo - -web-console-header-extension - -.wch-nav-item(ignite-userbar) - .user-name-wrapper( - ng-class='{active: $state.includes("base.settings")}' - ng-click='$event.stopPropagation()' - bs-dropdown='userbar.items' - data-placement='bottom-right' - data-trigger='hover focus' - data-container='self' +nav + li( + ng-repeat='item in $ctrl.menu$|async:this track by item.sref' + ng-if='!item.hidden' ) - span {{$root.user.firstName}} {{$root.user.lastName}} - span.caret + a.web-console-sidebar-navigation__link( + ui-sref='{{item.sref}}' + ui-sref-active=`{ + "web-console-sidebar-navigation__link-active": item.activeSref + }` + title='{{item.label|translate}}' + ng-class=`{ + 'web-console-sidebar-navigation__link-narrow': !$ctrl.opened, + 'web-console-sidebar-navigation__link-wide': $ctrl.opened + }` + tabindex='0' + ) + svg.web-console-sidebar-navigation__link-icon(ignite-icon='{{item.icon}}') + span.web-console-sidebar-navigation__link-content(translate='{{item.label}}') diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/component.ts b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/component.ts new file mode 100644 index 0000000000000..0f69e2dcabc6d --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/component.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +import controller from './controller'; +import template from './template.pug'; +import './style.scss'; + +export const component: ng.IComponentOptions = { + controller, + transclude: true, + template +}; diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/controller.ts b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/controller.ts new file mode 100644 index 0000000000000..d5403f4caa1f0 --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/controller.ts @@ -0,0 +1,50 @@ +/* + * 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. + */ + +import ResizeObserver from 'resize-observer-polyfill'; + +export default class WebCOnsoleSidebarOverflow { + static $inject = ['$element', 'gridUtil', '$window'] + constructor(private el: JQLite, private gridUtil: {getScrollbarWidth(): number}, private $win: ng.IWindowService) {} + scrollEl!: JQLite + resizeObserver: ResizeObserver + $onInit() { + this.el.css('--scrollbar-width', this.gridUtil.getScrollbarWidth()); + } + $postLink() { + this.scrollEl[0].addEventListener('scroll', this.onScroll, {passive: true}); + this.resizeObserver = new ResizeObserver(() => this.applyStyles(this.scrollEl[0])); + this.resizeObserver.observe(this.el[0]); + } + $onDestroy() { + this.scrollEl[0].removeEventListener('scroll', this.onScroll); + this.resizeObserver.disconnect(); + } + applyStyles(target: HTMLElement) { + const {offsetHeight, scrollTop, scrollHeight} = target; + const top = scrollTop !== 0; + const bottom = Math.floor((offsetHeight + scrollTop)) !== Math.floor(scrollHeight); + + target.classList.toggle('top', top); + target.classList.toggle('bottom', bottom); + } + onScroll = (e: UIEvent) => { + this.$win.requestAnimationFrame(() => { + this.applyStyles(e.target as HTMLElement); + }); + } +} diff --git a/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/style.scss b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/style.scss new file mode 100644 index 0000000000000..cbc6adca2a9b8 --- /dev/null +++ b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/style.scss @@ -0,0 +1,52 @@ +/* + * 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. + */ + +web-console-sidebar-overflow { + overflow: hidden; + position: relative; + display: flex; + + &>.web-console-sidebar-overflow__scroll-root { + overflow-x: hidden; + overflow-y: scroll; + margin-right: calc(-1 * var(--scrollbar-width)); + + &.top:before { + display: block; + width: 100%; + content: ''; + height: 1px; + position: absolute; + top: -1px; + box-shadow: 0 0 9px 1px #a0a0a0; + transform: translateZ(1px); + } + &.bottom:after { + display: block; + width: 100%; + content: ''; + position: absolute; + bottom: 0; + box-shadow: 0 0 9px 1px #a0a0a0; + transform: translateZ(1px); + } + + &>ng-transclude { + display: block; + } + } +} \ No newline at end of file diff --git a/modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/template.pug b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/template.pug similarity index 82% rename from modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/template.pug rename to modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/template.pug index e4f21b6c4b39a..5b70da601f414 100644 --- a/modules/web-console/frontend/app/components/connected-clusters-dialog/components/cell-status/template.pug +++ b/modules/web-console/frontend/app/components/web-console-sidebar/web-console-sidebar-overflow/template.pug @@ -14,5 +14,5 @@ See the License for the specific language governing permissions and limitations under the License. -div(ng-class='["connected-clusters-cell-status-"+($ctrl.status ? "active" : "not-active")]') - i {{ $ctrl.status ? 'Active' : 'Not Active' }} \ No newline at end of file +.web-console-sidebar-overflow__scroll-root(ng-ref='$ctrl.scrollEl' ng-ref-read='$element') + ng-transclude(ng-style='::{"--scrollbar-width": $ctrl.SCROLLBAR_WIDTH}') \ No newline at end of file diff --git a/modules/web-console/frontend/app/core/activities/Activities.data.js b/modules/web-console/frontend/app/core/activities/Activities.data.js index 35b44e63bf55e..8786816422e1e 100644 --- a/modules/web-console/frontend/app/core/activities/Activities.data.js +++ b/modules/web-console/frontend/app/core/activities/Activities.data.js @@ -35,6 +35,9 @@ export default class ActivitiesData { action = action || this.$state.$current.url.source || ''; group = group || (action.match(/^\/([^/]+)/) || [])[1]; - return this.$http.post('/api/v1/activities/page', { group, action }); + return this.$http.post('/api/v1/activities/page', { group, action }) + .catch(() => { + // No-op. + }); } } diff --git a/modules/web-console/frontend/app/data/countries.json b/modules/web-console/frontend/app/data/countries.json index b340f02ff6bcd..8f274adb15b9c 100644 --- a/modules/web-console/frontend/app/data/countries.json +++ b/modules/web-console/frontend/app/data/countries.json @@ -64,26 +64,83 @@ "value": "China", "code": "CHN" }, - { - "label": "India", - "value": "India", - "code": "IND" - }, { "label": "Japan", "value": "Japan", "code": "JPN" }, { - "label": "Other Asia", - "value": "Other Asia", - "code": "Other Asia" + "label": "South Korea", + "value": "South Korea", + "code": "KR" + }, + { + "label": "Hong Kong", + "value": "Hong Kong", + "code": "HK" + }, + { + "label": "Taiwan", + "value": "Taiwan", + "code": "TW" }, { "label": "Australia", "value": "Australia", "code": "AUS" }, + { + "label": "Thailand", + "value": "Thailand", + "code": "TH" + }, + { + "label": "Singapore", + "value": "Singapore", + "code": "SG" + }, + { + "label": "Malaysia", + "value": "Malaysia", + "code": "MY" + }, + { + "label": "Philippines", + "value": "Philippines", + "code": "PH" + }, + { + "label": "Indonesia", + "value": "Indonesia", + "code": "ID" + }, + { + "label": "Vietnam", + "value": "Vietnam", + "code": "VN" + }, + { + "label": "Macau", + "value": "Macau", + "code": "MO" + }, + { + "label": "New Zealand", + "value": "New Zealand", + "code": "NZ" + }, + { + "label": "India", + "value": "India", + "code": "IND" + }, + + { + "label": "Other Asia", + "value": "Other Asia", + "code": "Other Asia" + }, + { "label": "Brazil", "value": "Brazil", diff --git a/modules/web-console/frontend/app/data/i18n.js b/modules/web-console/frontend/app/data/i18n.js index e21b8c5c338c8..20f9d25b2f338 100644 --- a/modules/web-console/frontend/app/data/i18n.js +++ b/modules/web-console/frontend/app/data/i18n.js @@ -18,20 +18,12 @@ export default { '/agent/start': 'Agent start', '/agent/download': 'Agent download', - 'base.configuration.overview': 'Cluster configurations', '/configuration/overview': 'Cluster configurations', - 'base.configuration.edit.basic': 'Basic cluster configuration edit', '/configuration/new': 'Cluster configuration create', '/configuration/new/basic': 'Basic cluster configuration create', '/configuration/new/advanced/cluster': 'Advanced cluster configuration create', - 'base.configuration.edit.advanced.cluster': 'Advanced cluster configuration edit', - 'base.configuration.edit.advanced.caches': 'Advanced cluster caches', - 'base.configuration.edit.advanced.caches.cache': 'Advanced cluster cache edit', - 'base.configuration.edit.advanced.models': 'Advanced cluster models', - 'base.configuration.edit.advanced.models.model': 'Advanced cluster model edit', - 'base.configuration.edit.advanced.igfs': 'Advanced cluster IGFSs', - 'base.configuration.edit.advanced.igfs.igfs': 'Advanced cluster IGFS edit', '/configuration/download': 'Download project', + 'configuration/import/model': 'Import cluster models', '/demo/resume': 'Demo resume', '/demo/reset': 'Demo reset', '/queries/execute': 'Query execute', @@ -43,5 +35,274 @@ export default { '/queries/notebook/': 'Query notebook', '/settings/profile': 'User profile', '/settings/admin': 'Admin panel', - '/logout': 'Logout' + '/logout': 'Logout', + + 'base.configuration.overview': 'Cluster configurations', + 'base.configuration.edit.basic': 'Basic cluster configuration edit', + 'base.configuration.edit.advanced.cluster': 'Advanced cluster configuration edit', + 'base.configuration.edit.advanced.caches': 'Advanced cluster caches', + 'base.configuration.edit.advanced.caches.cache': 'Advanced cluster cache edit', + 'base.configuration.edit.advanced.models': 'Advanced cluster models', + 'base.configuration.edit.advanced.models.model': 'Advanced cluster model edit', + 'base.configuration.edit.advanced.igfs': 'Advanced cluster IGFSs', + 'base.configuration.edit.advanced.igfs.igfs': 'Advanced cluster IGFS edit', + 'base.settings.admin': 'Admin panel', + 'base.settings.profile': 'User profile', + 'base.sql.notebook': 'Query notebook', + 'base.sql.tabs.notebooks-list': 'Query notebooks', + + // app/components/page-signin/template.pug + 'app.components.page-signin.m1': 'Sign In', + 'app.components.page-signin.m2': 'Email:', + 'app.components.page-signin.m3': 'Input email', + 'app.components.page-signin.m4': 'Password:', + 'app.components.page-signin.m5': 'Input password', + 'app.components.page-signin.m6': 'Forgot password?', + 'app.components.page-signin.m7': 'Sign In', + 'app.components.page-signin.m8': 'Don\'t have an account? #[a(ui-sref=\'signup\') Get started]', + + // app/components/page-signin/run.js + 'app.components.page-signin.m9': 'Sign In', + + + // app/components/page-queries/template.tpl.pug + 'app.components.page-queries.m1': 'Show data in tabular form', + 'app.components.page-queries.m2': 'Show bar chart
    By default first column - X values, second column - Y values
    In case of one column it will be treated as Y values', + 'app.components.page-queries.m3': 'Show pie chart
    By default first column - pie labels, second column - pie values
    In case of one column it will be treated as pie values', + 'app.components.page-queries.m4': 'Show line chart
    By default first column - X values, second column - Y values
    In case of one column it will be treated as Y values', + 'app.components.page-queries.m5': 'Show area chart
    By default first column - X values, second column - Y values
    In case of one column it will be treated as Y values', + 'app.components.page-queries.m6': 'Click to show chart settings dialog', + 'app.components.page-queries.m7': 'Chart settings', + 'app.components.page-queries.m8': 'Show', + 'app.components.page-queries.m9': 'min', + 'app.components.page-queries.m10': 'Duration: #[b {{paragraph.duration | duration}}]', + 'app.components.page-queries.m11': 'NodeID8: #[b {{paragraph.resNodeId | id8}}]', + 'app.components.page-queries.m12': 'Rename notebook', + 'app.components.page-queries.m13': 'Remove notebook', + 'app.components.page-queries.m14': 'Save notebook name', + 'app.components.page-queries.m15': 'Scroll to query', + 'app.components.page-queries.m16': 'Add query', + 'app.components.page-queries.m17': 'Add scan', + 'app.components.page-queries.m18': 'Failed to load notebook', + 'app.components.page-queries.m19': 'Notebook not accessible any more. Leave notebooks or open another notebook.', + 'app.components.page-queries.m20': 'Leave notebooks', + 'app.components.page-queries.m21': 'Rename query', + 'app.components.page-queries.m22': 'Rename query', + 'app.components.page-queries.m23': 'Remove query', + 'app.components.page-queries.m24': 'Save query name', + 'app.components.page-queries.m25': 'Configure periodical execution of last successfully executed query', + 'app.components.page-queries.m26': 'Refresh rate:', + 'app.components.page-queries.m27': 'Max number of rows to show in query result as one page', + 'app.components.page-queries.m28': 'Page size:', + 'app.components.page-queries.m29': 'Limit query max results to specified number of pages', + 'app.components.page-queries.m30': 'Max pages:', + 'app.components.page-queries.m31': 'Non-collocated joins is a special mode that allow to join data across cluster without collocation.
    Nested joins are not supported for now.
    NOTE: In some cases it may consume more heap memory or may take a long time than collocated joins.', + 'app.components.page-queries.m32': 'Allow non-collocated joins', + 'app.components.page-queries.m33': 'Enforce join order of tables in the query.
    If set, then query optimizer will not reorder tables within join.
    NOTE: It is not recommended to enable this property unless you have verified that indexes are not selected in optimal order.', + 'app.components.page-queries.m34': 'Enforce join order', + 'app.components.page-queries.m35': 'By default Ignite attempts to fetch the whole query result set to memory and send it to the client.
    For small and medium result sets this provides optimal performance and minimize duration of internal database locks, thus increasing concurrency.
    If result set is too big to fit in available memory this could lead to excessive GC pauses and even OutOfMemoryError.
    Use this flag as a hint for Ignite to fetch result set lazily, thus minimizing memory consumption at the cost of moderate performance hit.', + 'app.components.page-queries.m36': 'Lazy result set', + 'app.components.page-queries.m37': 'Execute', + 'app.components.page-queries.m38': 'Execute on selected node', + 'app.components.page-queries.m39': '{{queryTooltip(paragraph, "explain query")}}', + 'app.components.page-queries.m40': 'Explain', + 'app.components.page-queries.m41': 'Page: #[b {{paragraph.page}}]', + 'app.components.page-queries.m42': 'Results so far: #[b {{paragraph.rows.length + paragraph.total}}]', + 'app.components.page-queries.m43': 'Duration: #[b {{paragraph.duration | duration}}]', + 'app.components.page-queries.m44': 'NodeID8: #[b {{paragraph.resNodeId | id8}}]', + 'app.components.page-queries.m45': '{{ queryTooltip(paragraph, "export query results") }}', + 'app.components.page-queries.m46': 'Export', + 'app.components.page-queries.m47': 'Export', + 'app.components.page-queries.m48': 'Export all', + 'app.components.page-queries.m49': 'Copy current result page to clipboard', + 'app.components.page-queries.m50': 'Copy to clipboard', + 'app.components.page-queries.m51': 'Page: #[b {{paragraph.pa', + 'app.components.page-queries.m52': 'Results so far: #[b {{paragraph.rows.length + paragraph.total}}]', + 'app.components.page-queries.m53': 'Duration: #[b {{paragraph.duration | duration}}]', + 'app.components.page-queries.m54': 'NodeID8: #[b {{paragraph.resNodeId | id8}}]', + 'app.components.page-queries.m55': 'Export', + 'app.components.page-queries.m56': 'Export', + 'app.components.page-queries.m57': 'Export all', + 'app.components.page-queries.m58': 'Copy current result page to clipboard', + 'app.components.page-queries.m59': 'Copy to clipboard', + 'app.components.page-queries.m60': 'Cannot display chart. Please configure axis using #[b Chart settings]', + 'app.components.page-queries.m61': 'Cannot display chart. Result set must contain Java build-in type columns. Please change query and execute it again.', + 'app.components.page-queries.m62': 'Pie chart does not support \'TIME_LINE\' column for X-axis. Please use another column for X-axis or switch to another chart.', + 'app.components.page-queries.m63': 'Charts do not support #[b Explain] and #[b Scan] query', + 'app.components.page-queries.m64': 'Cache:', + 'app.components.page-queries.m65': 'Choose cache', + 'app.components.page-queries.m66': 'Filter:', + 'app.components.page-queries.m67': 'Enter filter', + 'app.components.page-queries.m68': 'Select this checkbox for case sensitive search', + 'app.components.page-queries.m69': 'Max number of rows to show in query result as one page', + 'app.components.page-queries.m70': 'Page size:', + 'app.components.page-queries.m71': 'Scan', + 'app.components.page-queries.m72': 'Scan on selected node', + 'app.components.page-queries.m73': 'Error: {{paragraph.error.message}}', + 'app.components.page-queries.m74': 'Result set is empty. Duration: #[b {{paragraph.duration | duration}}]', + 'app.components.page-queries.m75': 'Showing results for scan of #[b {{ paragraph.queryArgs.cacheName | defaultName }}]', + 'app.components.page-queries.m76': '  with filter: #[b {{ paragraph.queryArgs.filter }}]', + 'app.components.page-queries.m77': '  on node: #[b {{ paragraph.queryArgs.localNid | limitTo:8 }}]', + 'app.components.page-queries.m78': 'Next', + 'app.components.page-queries.m79': 'Caches:', + 'app.components.page-queries.m80': 'Click to show cache types metadata dialog', + 'app.components.page-queries.m81': 'Filter caches...', + 'app.components.page-queries.m82': 'Use selected cache as default schema name.
    This will allow to execute query on specified cache without specify schema name.
    NOTE: In future version of Ignite this feature will be removed.', + 'app.components.page-queries.m83': 'Use selected cache as default schema name', + 'app.components.page-queries.m84': 'Wrong caches filter', + 'app.components.page-queries.m85': 'No caches', + 'app.components.page-queries.m86': 'Error: {{paragraph.error.message}}', + 'app.components.page-queries.m87': 'Show more', + 'app.components.page-queries.m88': 'Show query', + 'app.components.page-queries.m89': 'Next', + 'app.components.page-queries.m90': 'Queries', + 'app.components.page-queries.m91': 'With query notebook you can', + 'app.components.page-queries.m92': 'Create any number of queries', + 'app.components.page-queries.m93': 'Execute and explain SQL queries', + 'app.components.page-queries.m94': 'Execute scan queries', + 'app.components.page-queries.m95': 'View data in tabular form and as charts', + 'app.components.page-queries.m96': 'Examples:', + // app/components/page-queries/Notebook.service.js + 'app.components.page-queries.m97': 'Are you sure you want to remove notebook: "${notebook.name}"?', + // app/components/page-queries/Notebook.data.js + 'app.components.page-queries.m98': 'SQL demo', + 'app.components.page-queries.m99': 'Query with refresh rate', + 'app.components.page-queries.m100': 'Simple query', + 'app.components.page-queries.m101': 'Query with aggregates', + 'app.components.page-queries.m102': 'Failed to load notebook.', + 'app.components.page-queries.m103': 'Removing "${notebook.name}" notebook is not supported.', + // app/components/page-queries/index.js + 'app.components.page-queries.m104': 'Query notebook', + 'app.components.page-queries.m105': 'SQL demo', + // app/components/page-queries/controller.js + 'app.components.page-queries.m106': 'Internal cluster error', + 'app.components.page-queries.m107': 'Unlimited', + 'app.components.page-queries.m108': 'Demo grid is starting. Please wait...', + 'app.components.page-queries.m109': 'Loading query notebook screen...', + 'app.components.page-queries.m110': 'seconds', + 'app.components.page-queries.m111': 's', + 'app.components.page-queries.m112': 'minutes', + 'app.components.page-queries.m113': 'm', + 'app.components.page-queries.m114': 'hours', + 'app.components.page-queries.m115': 'h', + 'app.components.page-queries.m116': 'Leave Queries', + 'app.components.page-queries.m117': 'Query ${sz === 0 ? "" : sz}', + 'app.components.page-queries.m118': 'Scan ${sz === 0 ? "" : sz}', + 'app.components.page-queries.m119': 'Are you sure you want to remove query: "${paragraph.name}"?', + 'app.components.page-queries.m120': 'Waiting for server response', + 'app.components.page-queries.m121': 'Input text to ${action}', + 'app.components.page-queries.m122': 'Waiting for server response', + 'app.components.page-queries.m123': 'Select cache to export scan results', + 'app.components.page-queries.m124': 'SCAN query', + 'app.components.page-queries.m125': 'SCAN query for cache: ${maskCacheName(paragraph.queryArgs.cacheName, true)}', + 'app.components.page-queries.m126': 'SCAN query for cache: ${maskCacheName(paragraph.queryArgs.cacheName, true)} with filter: ${filter}', + 'app.components.page-queries.m127': 'Explain query', + 'app.components.page-queries.m128': 'SQL query', + 'app.components.page-queries.m129': 'Duration: ${$filter(\'duration\')(paragraph.duration)}.', + 'app.components.page-queries.m130': 'Node ID8: ${_.id8(paragraph.resNodeId)}', + 'app.components.page-queries.m131': 'Error details', + + // app/components/page-queries/services/queries-navbar.js + 'app.components.page-queries.services.queries-navbar.m1': 'Queries', + 'app.components.page-queries.services.queries-navbar.m2': 'Create new notebook', + + // app/components/page-queries/services/create-query-dialog/template.pug + 'app.components.page-queries.services.create-query-dialog.m1': 'New query notebook', + 'app.components.page-queries.services.create-query-dialog.m2': 'Name: ', + 'app.components.page-queries.services.create-query-dialog.m3': 'Cancel', + 'app.components.page-queries.services.create-query-dialog.m4': 'Create', + + // app/components/page-profile/controller.js + 'app.components.page-profile.m1': 'Are you sure you want to change security token?', + 'app.components.page-profile.m2': 'Profile saved.', + 'app.components.page-profile.m3': 'Failed to save profile: ', + // app/components/page-profile/index.js + 'app.components.page-profile.m4': 'User profile', + // app/components/page-profile/template.pug + 'app.components.page-profile.m5': 'User profile', + 'app.components.page-profile.m6': 'First name:', + 'app.components.page-profile.m7': 'Input first name', + 'app.components.page-profile.m8': 'Last name:', + 'app.components.page-profile.m9': 'Input last name', + 'app.components.page-profile.m10': 'Email:', + 'app.components.page-profile.m11': 'Input email', + 'app.components.page-profile.m12': 'Phone:', + 'app.components.page-profile.m13': 'Input phone (ex.: +15417543010)', + 'app.components.page-profile.m14': 'Country:', + 'app.components.page-profile.m15': 'Choose your country', + 'app.components.page-profile.m16': 'Company:', + 'app.components.page-profile.m17': 'Input company name', + 'app.components.page-profile.m18': 'Cancel security token changing...', + 'app.components.page-profile.m19': 'Show security token...', + 'app.components.page-profile.m20': 'Security token:', + 'app.components.page-profile.m21': 'No security token. Regenerate please.', + 'app.components.page-profile.m22': 'Generate random security token', + 'app.components.page-profile.m23': 'Copy security token to clipboard', + 'app.components.page-profile.m24': 'The security token is used for authorization of web agent', + 'app.components.page-profile.m25': 'Cancel password changing...', + 'app.components.page-profile.m26': 'Change password...', + 'app.components.page-profile.m27': 'New password:', + 'app.components.page-profile.m28': 'New password', + 'app.components.page-profile.m29': 'Confirm password:', + 'app.components.page-profile.m30': 'Confirm new password', + 'app.components.page-profile.m31': 'Cancel', + 'app.components.page-profile.m32': 'Save Changes', + + // app/modules/navbar/userbar.directive.js + 'app/modules/navbar/userbar.m1': 'Profile', + 'app/modules/navbar/userbar.m2': 'Getting started', + 'app/modules/navbar/userbar.m3': 'Admin panel', + 'app/modules/navbar/userbar.m4': 'Log out', + + // app/components/page-forgot-password/run.js + 'app.components.page-forgot-password.m1': 'Forgot Password', + // app/components/page-forgot-password/template.pug + 'app.components.page-forgot-password.m2': 'Forgot password?', + 'app.components.page-forgot-password.m3': 'Enter the email address for your account & we\'ll email you a link to reset your password.', + 'app.components.page-forgot-password.m4': 'Email:', + 'app.components.page-forgot-password.m5': 'Input email', + 'app.components.page-forgot-password.m6': 'Back to sign in', + 'app.components.page-forgot-password.m7': 'Send it to me', + + // app/components/page-landing/template.pug + 'app.components.page-landing.m1': 'Sign In', + 'app.components.page-landing.m2': 'Web Console', + 'app.components.page-landing.m3': 'An Interactive Configuration Wizard and Management Tool for Apache™ Ignite®', + 'app.components.page-landing.m4': 'It provides an interactive configuration wizard which helps you create and download configuration files and code snippets for your Apache Ignite projects. Additionally, the tool allows you to automatically load SQL metadata from any RDBMS, run SQL queries on your in-memory cache, and view execution plans, in-memory schema, and streaming charts.', + 'app.components.page-landing.m5': 'Sign Up', + 'app.components.page-landing.m6': 'The Web Console allows you to:', + 'app.components.page-landing.m7': 'Configure Apache Ignite clusters and caches', + 'app.components.page-landing.m8': 'The Web Console configuration wizard takes you through a step-by-step process that helps you define all the required configuration parameters. The system then generates a ready-to-use project with all the required config files.', + 'app.components.page-landing.m9': 'Run free-form SQL queries on #[br] Apache Ignite caches', + 'app.components.page-landing.m10': 'By connecting the Web Console to your Apache Ignite cluster, you can execute SQL queries on your in-memory cache. You can also view the execution plan, in-memory schema, and streaming charts for your cluster.', + 'app.components.page-landing.m11': 'Import database schemas from #[br] virtually any RDBMS', + 'app.components.page-landing.m12': 'To speed the creation of your configuration files, the Web Console allows you to automatically import the database schema from virtually any RDBMS including Oracle, SAP, MySQL, PostgreSQL, and many more.', + 'app.components.page-landing.m13': 'Manage the Web Console users', + 'app.components.page-landing.m14': 'The Web Console allows you to have accounts with different roles.', + 'app.components.page-landing.m15': 'Get Started', + + // app/components/page-signup/template.pug + 'app.components.page-signup.m1': 'Don\'t Have An Account?', + 'app.components.page-signup.m2': 'Email:', + 'app.components.page-signup.m3': 'Input email', + 'app.components.page-signup.m4': 'Password:', + 'app.components.page-signup.m5': 'Input password', + 'app.components.page-signup.m6': 'Confirm:', + 'app.components.page-signup.m7': 'Confirm password', + 'app.components.page-signup.m8': 'First name:', + 'app.components.page-signup.m9': 'Input first name', + 'app.components.page-signup.m10': 'Last name:', + 'app.components.page-signup.m11': 'Input last name', + 'app.components.page-signup.m12': 'Phone:', + 'app.components.page-signup.m13': 'Input phone (ex.: +15417543010)', + 'app.components.page-signup.m14': 'Country:', + 'app.components.page-signup.m15': 'Choose your country', + 'app.components.page-signup.m16': 'Company:', + 'app.components.page-signup.m17': 'Input company name', + 'app.components.page-signup.m18': 'Sign Up', + 'app.components.page-signup.m19': 'Already have an account? #[a(ui-sref=\'signin\') Sign in here]', + + // app/components/password-visibility/toggle-button.component.js + 'app.components.password-visibility.m1': 'Hide password', + 'app.components.password-visibility.m2': 'Show password' }; diff --git a/modules/web-console/frontend/app/directives/auto-focus.directive.js b/modules/web-console/frontend/app/directives/auto-focus.directive.js index 8d269ce6d2cca..e67b50d08c27a 100644 --- a/modules/web-console/frontend/app/directives/auto-focus.directive.js +++ b/modules/web-console/frontend/app/directives/auto-focus.directive.js @@ -27,7 +27,7 @@ export default function directive($timeout) { * @param {JQLite} element */ link(scope, element) { - $timeout(() => element[0].focus()); + $timeout(() => element[0].focus(), 100); } }; } diff --git a/modules/web-console/frontend/app/filters/duration.filter.js b/modules/web-console/frontend/app/filters/duration.filter.js index 810cc4d44678f..0ce42265627de 100644 --- a/modules/web-console/frontend/app/filters/duration.filter.js +++ b/modules/web-console/frontend/app/filters/duration.filter.js @@ -18,11 +18,15 @@ export default () => { /** * @param {number} t Time in ms. + * @param {string} dflt Default value. */ - const filter = (t) => { + const filter = (t, dflt = '0') => { if (t === 9223372036854775807) return 'Infinite'; + if (t <= 0) + return dflt; + const a = (i, suffix) => i && i !== '00' ? i + suffix + ' ' : ''; const cd = 24 * 60 * 60 * 1000; diff --git a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js index f667374bbec2f..faf0672e8b9c8 100644 --- a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js +++ b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js @@ -18,11 +18,10 @@ import _ from 'lodash'; import {nonEmpty, nonNil} from 'app/utils/lodashMixins'; -import { BehaviorSubject } from 'rxjs/BehaviorSubject'; -import 'rxjs/add/operator/first'; -import 'rxjs/add/operator/partition'; -import 'rxjs/add/operator/takeUntil'; -import 'rxjs/add/operator/pluck'; +import {BehaviorSubject} from 'rxjs'; +import {first, pluck, tap, distinctUntilChanged, map, filter} from 'rxjs/operators'; + +import io from 'socket.io-client'; import AgentModal from './AgentModal.service'; // @ts-ignore @@ -30,11 +29,12 @@ import Worker from './decompress.worker'; import SimpleWorkerPool from '../../utils/SimpleWorkerPool'; import maskNull from 'app/core/utils/maskNull'; +import {CancellationError} from 'app/errors/CancellationError'; import {ClusterSecretsManager} from './types/ClusterSecretsManager'; import ClusterLoginService from './components/cluster-login/service'; const State = { - DISCONNECTED: 'DISCONNECTED', + INIT: 'INIT', AGENT_DISCONNECTED: 'AGENT_DISCONNECTED', CLUSTER_DISCONNECTED: 'CLUSTER_DISCONNECTED', CONNECTED: 'CONNECTED' @@ -43,9 +43,17 @@ const State = { const IGNITE_2_0 = '2.0.0'; const LAZY_QUERY_SINCE = [['2.1.4-p1', '2.2.0'], '2.2.1']; const COLLOCATED_QUERY_SINCE = [['2.3.5', '2.4.0'], ['2.4.6', '2.5.0'], ['2.5.1-p13', '2.6.0'], '2.7.0']; +const COLLECT_BY_CACHE_GROUPS_SINCE = '2.7.0'; -// Error codes from o.a.i.internal.processors.restGridRestResponse.java +/** Reserved cache names */ +const RESERVED_CACHE_NAMES = [ + 'ignite-hadoop-mr-sys-cache', + 'ignite-sys-cache', + 'MetaStorage', + 'TxLog' +]; +/** Error codes from o.a.i.internal.processors.restGridRestResponse.java */ const SuccessStatus = { /** Command succeeded. */ STATUS_SUCCESS: 0, @@ -59,10 +67,9 @@ const SuccessStatus = { class ConnectionState { constructor(cluster) { - this.agents = []; this.cluster = cluster; this.clusters = []; - this.state = State.DISCONNECTED; + this.state = State.INIT; } updateCluster(cluster) { @@ -73,10 +80,6 @@ class ConnectionState { } update(demo, count, clusters) { - _.forEach(clusters, (cluster) => { - cluster.name = cluster.id; - }); - this.clusters = clusters; if (_.isEmpty(this.clusters)) @@ -107,18 +110,16 @@ class ConnectionState { } disconnect() { - this.agents = []; - if (this.cluster) this.cluster.disconnect = true; this.clusters = []; - this.state = State.DISCONNECTED; + this.state = State.AGENT_DISCONNECTED; } } export default class AgentManager { - static $inject = ['$rootScope', '$q', '$transitions', 'igniteSocketFactory', 'AgentModal', 'UserNotifications', 'IgniteVersion', 'ClusterLoginService']; + static $inject = ['$rootScope', '$q', '$transitions', 'AgentModal', 'UserNotifications', 'IgniteVersion', 'ClusterLoginService']; /** @type {ng.IScope} */ $root; @@ -133,7 +134,7 @@ export default class AgentManager { ClusterLoginSrv; /** @type {String} */ - clusterVersion = '2.4.0'; + clusterVersion; connectionSbj = new BehaviorSubject(new ConnectionState(AgentManager.restoreActiveCluster())); @@ -163,32 +164,34 @@ export default class AgentManager { * @param {ng.IRootScopeService} $root * @param {ng.IQService} $q * @param {import('@uirouter/angularjs').TransitionService} $transitions - * @param {unknown} socketFactory * @param {import('./AgentModal.service').default} agentModal * @param {import('app/components/user-notifications/service').default} UserNotifications * @param {import('app/services/Version.service').default} Version * @param {import('./components/cluster-login/service').default} ClusterLoginSrv */ - constructor($root, $q, $transitions, socketFactory, agentModal, UserNotifications, Version, ClusterLoginSrv) { + constructor($root, $q, $transitions, agentModal, UserNotifications, Version, ClusterLoginSrv) { this.$root = $root; this.$q = $q; this.$transitions = $transitions; - this.socketFactory = socketFactory; this.agentModal = agentModal; this.UserNotifications = UserNotifications; this.Version = Version; this.ClusterLoginSrv = ClusterLoginSrv; + this.clusterVersion = this.Version.webConsole; + let prevCluster; - this.currentCluster$ = this.connectionSbj - .distinctUntilChanged(({ cluster }) => prevCluster === cluster) - .do(({ cluster }) => prevCluster = cluster); + this.currentCluster$ = this.connectionSbj.pipe( + distinctUntilChanged(({ cluster }) => prevCluster === cluster), + tap(({ cluster }) => prevCluster = cluster) + ); - this.clusterIsActive$ = this.connectionSbj - .map(({ cluster }) => cluster) - .filter((cluster) => Boolean(cluster)) - .pluck('active'); + this.clusterIsActive$ = this.connectionSbj.pipe( + map(({ cluster }) => cluster), + filter((cluster) => Boolean(cluster)), + pluck('active') + ); if (!this.isDemoMode()) { this.connectionSbj.subscribe({ @@ -216,7 +219,9 @@ export default class AgentManager { if (nonNil(this.socket)) return; - this.socket = this.socketFactory(); + const options = this.isDemoMode() ? {query: 'IgniteDemoMode=true'} : {}; + + this.socket = io.connect(options); const onDisconnect = () => { const conn = this.connectionSbj.getValue(); @@ -246,7 +251,8 @@ export default class AgentManager { saveToStorage(cluster = this.connectionSbj.getValue().cluster) { try { localStorage.cluster = JSON.stringify(cluster); - } catch (ignore) { + } + catch (ignore) { // No-op. } } @@ -375,11 +381,13 @@ export default class AgentManager { case State.AGENT_DISCONNECTED: this.agentModal.agentDisconnected(this.backText, this.backState); + this.ClusterLoginSrv.cancel(); break; case State.CLUSTER_DISCONNECTED: this.agentModal.clusterDisconnected(this.backText, this.backState); + this.ClusterLoginSrv.cancel(); break; @@ -389,7 +397,11 @@ export default class AgentManager { } }); - this.$transitions.onExit({}, () => this.stopWatch()); + const stopWatchUnsubscribe = this.$transitions.onExit({}, () => { + this.stopWatch(); + + stopWatchUnsubscribe(); + }); return this.awaitCluster(); } @@ -475,8 +487,13 @@ export default class AgentManager { if (cluster.secured) this.clustersSecrets.get(cluster.id).sessionToken = res.sessionToken; - if (res.zipped) - return this.pool.postMessage(res.data); + if (res.zipped) { + const taskId = _.get(params, 'taskId', ''); + + const useBigIntJson = taskId.startsWith('query'); + + return this.pool.postMessage({payload: res.data, useBigIntJson}); + } return res; @@ -513,7 +530,7 @@ export default class AgentManager { if (this.isDemoMode()) return Promise.resolve(this._executeOnActiveCluster({}, {}, event, params)); - return this.connectionSbj.first().toPromise() + return this.connectionSbj.pipe(first()).toPromise() .then(({cluster}) => { if (_.isNil(cluster)) throw new Error('Failed to execute request on cluster.'); @@ -536,16 +553,53 @@ export default class AgentManager { return {cluster, credentials: {}}; }) - .then(({cluster, credentials}) => this._executeOnActiveCluster(cluster, credentials, event, params)); + .then(({cluster, credentials}) => this._executeOnActiveCluster(cluster, credentials, event, params)) + .catch((err) => { + if (err instanceof CancellationError) + return; + + throw err; + }); } /** - * @param {Boolean} [attr] - * @param {Boolean} [mtr] + * @param {boolean} [attr] Collect node attributes. + * @param {boolean} [mtr] Collect node metrics. + * @param {boolean} [caches] Collect node caches descriptors. * @returns {Promise} */ - topology(attr = false, mtr = false) { - return this._executeOnCluster('node:rest', {cmd: 'top', attr, mtr}); + topology(attr = false, mtr = false, caches = false) { + return this._executeOnCluster('node:rest', {cmd: 'top', attr, mtr, caches}); + } + + collectCacheNames(nid) { + if (this.available(COLLECT_BY_CACHE_GROUPS_SINCE)) + return this.visorTask('cacheNamesCollectorTask', nid); + + return Promise.resolve({cacheGroupsNotAvailable: true}); + } + + publicCacheNames() { + return this.collectCacheNames() + .then((data) => { + if (nonEmpty(data.caches)) + return _.difference(_.keys(data.caches), RESERVED_CACHE_NAMES); + + return this.topology(false, false, true) + .then((nodes) => { + return _.map(_.uniqBy(_.flatMap(nodes, 'caches'), 'name'), 'name'); + }); + }); + } + + /** + * @param {string} cacheName Cache name. + */ + cacheNodes(cacheName) { + if (this.available(IGNITE_2_0)) + return this.visorTask('cacheNodesTaskX2', null, cacheName); + + return this.visorTask('cacheNodesTask', null, cacheName); } /** diff --git a/modules/web-console/frontend/app/modules/agent/components/cluster-login/service.js b/modules/web-console/frontend/app/modules/agent/components/cluster-login/service.js index 128f3ccc5966f..406152df2011d 100644 --- a/modules/web-console/frontend/app/modules/agent/components/cluster-login/service.js +++ b/modules/web-console/frontend/app/modules/agent/components/cluster-login/service.js @@ -22,6 +22,8 @@ import {CancellationError} from 'app/errors/CancellationError'; export default class ClusterLoginService { static $inject = ['$modal', '$q']; + deferred; + /** * @param {mgcrea.ngStrap.modal.IModalService} $modal * @param {ng.IQService} $q @@ -36,7 +38,12 @@ export default class ClusterLoginService { * @returns {ng.IPromise} */ askCredentials(baseSecrets) { - const deferred = this.$q.defer(); + if (this.deferred) + return this.deferred.promise; + + this.deferred = this.$q.defer(); + + const self = this; const modal = this.$modal({ template: ` @@ -50,11 +57,11 @@ export default class ClusterLoginService { this.secrets = _.clone(baseSecrets); this.onLogin = () => { - deferred.resolve(this.secrets); + self.deferred.resolve(this.secrets); }; this.onHide = () => { - deferred.reject(new CancellationError()); + self.deferred.reject(new CancellationError()); }; }], controllerAs: '$ctrl', @@ -63,7 +70,16 @@ export default class ClusterLoginService { }); return modal.$promise - .then(() => deferred.promise) - .finally(modal.hide); + .then(() => this.deferred.promise) + .finally(() => { + this.deferred = null; + + modal.hide(); + }); + } + + cancel() { + if (this.deferred) + this.deferred.reject(new CancellationError()); } } diff --git a/modules/web-console/frontend/app/modules/agent/decompress.worker.js b/modules/web-console/frontend/app/modules/agent/decompress.worker.js index 2fd294da5f1e1..deffca34abb54 100644 --- a/modules/web-console/frontend/app/modules/agent/decompress.worker.js +++ b/modules/web-console/frontend/app/modules/agent/decompress.worker.js @@ -24,11 +24,13 @@ import bigIntJSON from 'json-bigint'; onmessage = function(e) { const data = e.data; - const binaryString = atob(data); // Decode from BASE64 + const binaryString = atob(data.payload); // Decode from BASE64 const unzipped = pako.inflate(binaryString, {to: 'string'}); - const res = bigIntJSON({storeAsString: true}).parse(unzipped); + const res = data.useBigIntJson + ? bigIntJSON({storeAsString: true}).parse(unzipped) + : JSON.parse(unzipped); postMessage(_.get(res, 'result', res)); }; diff --git a/modules/web-console/frontend/app/modules/agent/types/Cluster.js b/modules/web-console/frontend/app/modules/agent/types/Cluster.js index dd054050e714f..efb303d9b6caa 100644 --- a/modules/web-console/frontend/app/modules/agent/types/Cluster.js +++ b/modules/web-console/frontend/app/modules/agent/types/Cluster.js @@ -15,7 +15,7 @@ * limitations under the License. */ -class Cluster { +export class Cluster { /** @type {String} */ id; diff --git a/modules/web-console/frontend/app/modules/branding/branding.module.js b/modules/web-console/frontend/app/modules/branding/branding.module.js index 20cd93e015f2b..8b23d04a8ef7a 100644 --- a/modules/web-console/frontend/app/modules/branding/branding.module.js +++ b/modules/web-console/frontend/app/modules/branding/branding.module.js @@ -19,12 +19,8 @@ import angular from 'angular'; import IgniteBranding from './branding.service'; -import igniteHeaderLogo from './header-logo.directive'; -import igniteHeaderTitle from './header-title.directive'; import igniteTerms from './terms.directive'; import igniteFeatures from './features.directive'; -import igniteFooter from './footer.directive'; -import ignitePoweredByApache from './powered-by-apache.directive'; angular .module('ignite-console.branding', [ @@ -41,9 +37,5 @@ angular tfMetaTagsProvider.setTitleSuffix(' – Apache Ignite Web Console'); }]) -.directive('ignitePoweredByApache', ignitePoweredByApache) -.directive('igniteHeaderLogo', igniteHeaderLogo) -.directive('igniteHeaderTitle', igniteHeaderTitle) .directive('igniteTerms', igniteTerms) -.directive('igniteFeatures', igniteFeatures) -.directive('igniteFooter', igniteFooter); +.directive('igniteFeatures', igniteFeatures); diff --git a/modules/web-console/frontend/app/modules/branding/branding.service.js b/modules/web-console/frontend/app/modules/branding/branding.service.js index 667dbfd0f6182..9985087640825 100644 --- a/modules/web-console/frontend/app/modules/branding/branding.service.js +++ b/modules/web-console/frontend/app/modules/branding/branding.service.js @@ -24,15 +24,11 @@ export default class { constructor(Version) { this.titleSuffix = ' - Apache Ignite Web Console'; - this.headerLogo = '/images/ignite-logo.svg'; - - this.headerText = 'Management console for Apache Ignite'; - this.showIgniteLogo = false; this.footerHtml = [ `

    Apache Ignite Web Console (${Version.webConsole})

    `, - '

    © 2018 The Apache Software Foundation.

    ', + '

    © 2019 The Apache Software Foundation.

    ', '

    Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are trademarks of The Apache Software Foundation.

    ' ].join('\n'); diff --git a/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js b/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js index 90d3a9bd8adab..609b181bf2d8e 100644 --- a/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js +++ b/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js @@ -55,5 +55,8 @@ export default class CacheMetrics { // Transaction metrics. this.commits = m.txCommits; this.rollbacks = m.txRollbacks; + + // Admin metrics. + this.statisticsEnabled = m.statisticsEnabled; } } diff --git a/modules/web-console/frontend/app/modules/configuration/generator/AbstractTransformer.js b/modules/web-console/frontend/app/modules/configuration/generator/AbstractTransformer.js index e0aece76a810c..ab69bb8fb638a 100644 --- a/modules/web-console/frontend/app/modules/configuration/generator/AbstractTransformer.js +++ b/modules/web-console/frontend/app/modules/configuration/generator/AbstractTransformer.js @@ -153,6 +153,11 @@ export default class AbstractTransformer { return this.toSection(this.generator.clusterMisc(cluster, available)); } + // Generate marshaller group. + static clusterMvcc(cluster, available) { + return this.toSection(this.generator.clusterMvcc(cluster, available)); + } + // Generate marshaller group. static clusterMarshaller(cluster, available) { return this.toSection(this.generator.clusterMarshaller(cluster, available)); diff --git a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js index 2a1a506d8b939..6fba32a9eb253 100644 --- a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js +++ b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js @@ -107,6 +107,7 @@ export default class IgniteConfigurationGenerator { this.clusterMisc(cluster, available, cfg); this.clusterMetrics(cluster, available, cfg); + this.clusterMvcc(cluster, available, cfg); this.clusterODBC(cluster.odbc, available, cfg); // Since ignite 2.1 deprecated in ignite 2.3 @@ -1130,6 +1131,9 @@ export default class IgniteConfigurationGenerator { if (available('2.0.0')) { cfg.longProperty('failureDetectionTimeout') .longProperty('clientFailureDetectionTimeout'); + + if (available('2.7.0')) + cfg.longProperty('systemWorkerBlockedTimeout'); } _.forEach(cluster.failoverSpi, (spi) => { @@ -1464,8 +1468,14 @@ export default class IgniteConfigurationGenerator { storageBean.varArgProperty('dataRegionConfigurations', 'dataRegionConfigurations', dataRegionCfgs, 'org.apache.ignite.configuration.DataRegionConfiguration'); storageBean.stringProperty('storagePath') - .longProperty('checkpointFrequency') - .intProperty('checkpointThreads') + .longProperty('checkpointFrequency'); + + if (available('2.7.0')) { + storageBean + .longProperty('checkpointReadLockTimeout'); + } + + storageBean.intProperty('checkpointThreads') .enumProperty('checkpointWriteOrder') .enumProperty('walMode') .stringProperty('walPath') @@ -1516,7 +1526,6 @@ export default class IgniteConfigurationGenerator { static clusterMisc(cluster, available, cfg = this.igniteConfigurationBean(cluster)) { cfg.stringProperty('workDirectory'); - // Since Ignite 2.0 if (available('2.0.0')) { cfg.stringProperty('consistentId') .emptyBeanProperty('warmupClosure') @@ -1530,6 +1539,16 @@ export default class IgniteConfigurationGenerator { return cfg; } + // Generate MVCC configuration. + static clusterMvcc(cluster, available, cfg = this.igniteConfigurationBean(cluster)) { + if (available('2.7.0')) { + cfg.intProperty('mvccVacuumThreadCount') + .intProperty('mvccVacuumFrequency'); + } + + return cfg; + } + // Generate IGFSs configs. static clusterIgfss(igfss, available, cfg = this.igniteConfigurationBean()) { const igfsCfgs = _.map(igfss, (igfs) => { diff --git a/modules/web-console/frontend/app/modules/demo/Demo.module.js b/modules/web-console/frontend/app/modules/demo/Demo.module.js index 6c14e4a4de518..57f3a022b7cf8 100644 --- a/modules/web-console/frontend/app/modules/demo/Demo.module.js +++ b/modules/web-console/frontend/app/modules/demo/Demo.module.js @@ -25,19 +25,15 @@ const DEMO_QUERY_STATE = {state: 'base.sql.notebook', params: {noteId: 'demo'}}; /** * @param {import('@uirouter/angularjs').StateProvider} $state * @param {ng.IHttpProvider} $http - * @param {unknown} socketFactory */ -export function DemoProvider($state, $http, socketFactory) { +export function DemoProvider($state, $http) { if (/(\/demo.*)/ig.test(location.pathname)) sessionStorage.setItem('IgniteDemoMode', 'true'); const enabled = sessionStorage.getItem('IgniteDemoMode') === 'true'; - if (enabled) { - socketFactory.set({query: 'IgniteDemoMode=true'}); - + if (enabled) $http.interceptors.push('demoInterceptor'); - } function service($root) { $root.IgniteDemoMode = enabled; @@ -50,7 +46,7 @@ export function DemoProvider($state, $http, socketFactory) { return this; } -DemoProvider.$inject = ['$stateProvider', '$httpProvider', 'igniteSocketFactoryProvider']; +DemoProvider.$inject = ['$stateProvider', '$httpProvider']; /** * @param {{enabled: boolean}} Demo @@ -71,34 +67,7 @@ function demoInterceptor(Demo) { demoInterceptor.$inject = ['Demo']; -/** - * @param {ng.IScope} $scope - * @param {import('@uirouter/angularjs').StateService} $state - * @param {ng.IWindowService} $window - * @param {ReturnType} Confirm - */ -function demoController($scope, $state, $window, Confirm) { - const _openTab = (stateName) => $window.open($state.href(stateName), '_blank'); - - $scope.startDemo = () => { - if (!$scope.user.demoCreated) - return _openTab('demo.reset'); - - Confirm.confirm('Would you like to continue with previous demo session?', true, false) - .then((resume) => { - if (resume) - return _openTab('demo.resume'); - - _openTab('demo.reset'); - }); - }; - - $scope.closeDemo = () => { - $window.close(); - }; -} -demoController.$inject = ['$scope', '$state', '$window', 'IgniteConfirm']; function igniteDemoInfoProvider() { const items = DEMO_INFO; @@ -205,12 +174,9 @@ function config($stateProvider) { config.$inject = ['$stateProvider']; angular -.module('ignite-console.demo', [ - 'ignite-console.socket' -]) -.config(config) -.provider('Demo', DemoProvider) -.factory('demoInterceptor', demoInterceptor) -.controller('demoController', demoController) -.provider('igniteDemoInfo', igniteDemoInfoProvider) -.service('DemoInfo', DemoInfo); + .module('ignite-console.demo', []) + .config(config) + .provider('Demo', DemoProvider) + .factory('demoInterceptor', demoInterceptor) + .provider('igniteDemoInfo', igniteDemoInfoProvider) + .service('DemoInfo', DemoInfo); diff --git a/modules/web-console/frontend/app/modules/navbar/navbar.module.js b/modules/web-console/frontend/app/modules/navbar/navbar.module.js index 63588c7ac4509..e2a4f83bf0576 100644 --- a/modules/web-console/frontend/app/modules/navbar/navbar.module.js +++ b/modules/web-console/frontend/app/modules/navbar/navbar.module.js @@ -17,17 +17,10 @@ import angular from 'angular'; -import IgniteNavbar from './Navbar.provider'; import IgniteUserbar from './Userbar.provider'; -import igniteNavbar from './navbar.directive'; -import igniteUserbar from './userbar.directive'; - angular .module('ignite-console.navbar', [ ]) -.provider('IgniteNavbar', IgniteNavbar) -.provider('IgniteUserbar', IgniteUserbar) -.directive('igniteNavbar', igniteNavbar) -.directive('igniteUserbar', igniteUserbar); +.provider('IgniteUserbar', IgniteUserbar); diff --git a/modules/web-console/frontend/app/modules/states/errors.state.js b/modules/web-console/frontend/app/modules/states/errors.state.js index 19a1947b60334..0311b41695a82 100644 --- a/modules/web-console/frontend/app/modules/states/errors.state.js +++ b/modules/web-console/frontend/app/modules/states/errors.state.js @@ -16,8 +16,6 @@ */ import angular from 'angular'; -import templateNotFoundPage from 'views/404.tpl.pug'; -import templateNotAuthorizedPage from 'views/403.tpl.pug'; angular .module('ignite-console.states.errors', [ @@ -26,17 +24,25 @@ angular .config(['$stateProvider', /** @param {import('@uirouter/angularjs').StateProvider} $stateProvider */ function($stateProvider) { // set up the states $stateProvider - .state('404', { + .state('base.404', { url: '/404', - templateUrl: templateNotFoundPage, + component: 'timedRedirection', + resolve: { + headerText: () => '404', + subHeaderText: () => 'Page not found' + }, tfMetaTags: { title: 'Page not found' }, unsaved: true }) - .state('403', { + .state('base.403', { url: '/403', - templateUrl: templateNotAuthorizedPage, + component: 'timedRedirection', + resolve: { + headerText: () => '403', + subHeaderText: () => 'You are not authorized' + }, tfMetaTags: { title: 'Not authorized' }, diff --git a/modules/web-console/frontend/app/modules/user/Auth.service.js b/modules/web-console/frontend/app/modules/user/Auth.service.js deleted file mode 100644 index 8c3cc4ea4e2db..0000000000000 --- a/modules/web-console/frontend/app/modules/user/Auth.service.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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. - */ - -/** - * @typedef {object} SignupUserInfo - * @prop {string} email - * @prop {string} password - * @prop {string} firstName - * @prop {string} lastName - * @prop {string} company - * @prop {string} country - */ - -export default class AuthService { - static $inject = ['$http', '$rootScope', '$state', '$window', 'IgniteMessages', 'gettingStarted', 'User']; - /** - * @param {ng.IHttpService} $http - * @param {ng.IRootScopeService} $root - * @param {import('@uirouter/angularjs').StateService} $state - * @param {ng.IWindowService} $window - * @param {ReturnType} Messages - * @param {ReturnType} gettingStarted - * @param {ReturnType} User - */ - constructor($http, $root, $state, $window, Messages, gettingStarted, User) { - this.$http = $http; - this.$root = $root; - this.$state = $state; - this.$window = $window; - this.Messages = Messages; - this.gettingStarted = gettingStarted; - this.User = User; - } - /** - * @param {SignupUserInfo} userInfo - */ - signnup(userInfo) { - return this._auth('signup', userInfo); - } - /** - * @param {string} email - * @param {string} password - */ - signin(email, password) { - return this._auth('signin', {email, password}); - } - /** - * @param {string} email - */ - remindPassword(email) { - return this._auth('password/forgot', {email}).then(() => this.$state.go('password.send')); - } - - // TODO IGNITE-7994: Remove _auth and move API calls to corresponding methods - /** - * Performs the REST API call. - * @private - * @param {('signin'|'signup'|'password/forgot')} action - * @param {{email:string,password:string}|SignupUserInfo|{email:string}} userInfo - */ - _auth(action, userInfo) { - return this.$http.post('/api/v1/' + action, userInfo) - .then(() => { - if (action === 'password/forgot') - return; - - this.User.read() - .then((user) => { - this.$root.$broadcast('user', user); - - this.$state.go('default-state'); - - this.$root.gettingStarted.tryShow(); - }); - }); - } - logout() { - return this.$http.post('/api/v1/logout') - .then(() => { - this.User.clean(); - - this.$window.open(this.$state.href('signin'), '_self'); - }) - .catch((e) => this.Messages.showError(e)); - } -} diff --git a/modules/web-console/frontend/app/modules/user/Auth.service.ts b/modules/web-console/frontend/app/modules/user/Auth.service.ts new file mode 100644 index 0000000000000..08cf2630a4e37 --- /dev/null +++ b/modules/web-console/frontend/app/modules/user/Auth.service.ts @@ -0,0 +1,98 @@ +/* + * 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. + */ + +import {StateService} from '@uirouter/angularjs'; +import MessagesFactory from '../../services/Messages.service'; +import {service as GettingsStartedFactory} from '../../modules/getting-started/GettingStarted.provider'; +import UserServiceFactory from './User.service'; + +type SignupUserInfo = { + email: string, + password: string, + firstName: string, + lastName: string, + company: string, + country: string, +}; + +type AuthActions = 'signin' | 'signup' | 'password/forgot'; +type AuthOptions = {email:string, password:string, activationToken?: string}|SignupUserInfo|{email:string}; + +export default class AuthService { + static $inject = ['$http', '$rootScope', '$state', '$window', 'IgniteMessages', 'gettingStarted', 'User']; + + constructor( + private $http: ng.IHttpService, + private $root: ng.IRootScopeService, + private $state: StateService, + private $window: ng.IWindowService, + private Messages: ReturnType, + private gettingStarted: ReturnType, + private User: ReturnType + ) {} + + signup(userInfo: SignupUserInfo, loginAfterSignup: boolean = true) { + return this._auth('signup', userInfo, loginAfterSignup); + } + + signin(email: string, password: string, activationToken?: string) { + return this._auth('signin', {email, password, activationToken}); + } + + remindPassword(email: string) { + return this._auth('password/forgot', {email}).then(() => this.$state.go('password.send')); + } + + // TODO IGNITE-7994: Remove _auth and move API calls to corresponding methods + /** + * Performs the REST API call. + */ + private _auth(action: AuthActions, userInfo: AuthOptions, loginAfterwards: boolean = true) { + return this.$http.post('/api/v1/' + action, userInfo) + .then(() => { + if (action === 'password/forgot') + return; + + this.User.read() + .then((user) => { + if (loginAfterwards) { + this.$root.$broadcast('user', user); + this.$state.go('default-state'); + this.$root.gettingStarted.tryShow(); + } else + this.$root.$broadcast('userCreated'); + }); + }); + } + logout() { + return this.$http.post('/api/v1/logout') + .then(() => { + this.User.clean(); + + this.$window.open(this.$state.href('signin'), '_self'); + }) + .catch((e) => this.Messages.showError(e)); + } + + async resendSignupConfirmation(email: string) { + try { + return await this.$http.post('/api/v1/activation/resend/', {email}); + } catch (res) { + throw res.data; + } + } +} diff --git a/modules/web-console/frontend/app/modules/user/User.service.js b/modules/web-console/frontend/app/modules/user/User.service.js index 3fdb9b9919fed..da84dcc7e9575 100644 --- a/modules/web-console/frontend/app/modules/user/User.service.js +++ b/modules/web-console/frontend/app/modules/user/User.service.js @@ -15,6 +15,8 @@ * limitations under the License. */ +import {ReplaySubject} from 'rxjs'; + /** * @typedef User * @prop {string} _id @@ -40,7 +42,10 @@ export default function User($q, $injector, $root, $state, $http) { /** @type {ng.IPromise} */ let user; + const current$ = new ReplaySubject(1); + return { + current$, /** * @returns {ng.IPromise} */ @@ -51,6 +56,8 @@ export default function User($q, $injector, $root, $state, $http) { $root.$broadcast('user', $root.user); + current$.next(data); + return $root.user; }) .catch(({data}) => { diff --git a/modules/web-console/frontend/app/modules/user/emailConfirmationInterceptor.ts b/modules/web-console/frontend/app/modules/user/emailConfirmationInterceptor.ts new file mode 100644 index 0000000000000..ce377b1fac43e --- /dev/null +++ b/modules/web-console/frontend/app/modules/user/emailConfirmationInterceptor.ts @@ -0,0 +1,37 @@ +/* + * 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. + */ + +import {UIRouter} from '@uirouter/angularjs'; + +registerInterceptor.$inject = ['$httpProvider']; + +export function registerInterceptor(http: ng.IHttpProvider) { + emailConfirmationInterceptor.$inject = ['$q', '$injector']; + + function emailConfirmationInterceptor($q: ng.IQService, $injector: ng.auto.IInjectorService): ng.IHttpInterceptor { + return { + responseError(res) { + if (res.status === 403 && res.data && res.data.errorCode === 10104) + $injector.get('$uiRouter').stateService.go('signup-confirmation', {email: res.data.email}); + + return $q.reject(res); + } + }; + } + + http.interceptors.push(emailConfirmationInterceptor as ng.IHttpInterceptorFactory); +} diff --git a/modules/web-console/frontend/app/modules/user/user.module.js b/modules/web-console/frontend/app/modules/user/user.module.js index 9591a98cc3f17..c78cc8cc0f900 100644 --- a/modules/web-console/frontend/app/modules/user/user.module.js +++ b/modules/web-console/frontend/app/modules/user/user.module.js @@ -20,6 +20,7 @@ import aclData from './permissions'; import Auth from './Auth.service'; import User from './User.service'; +import {registerInterceptor} from './emailConfirmationInterceptor'; /** * @param {ng.auto.IInjectorService} $injector @@ -35,7 +36,7 @@ function sessionRecoverer($injector, $q) { const stateName = $injector.get('$uiRouterGlobals').current.name; - if (!_.includes(['', 'signin'], stateName)) + if (!_.includes(['', 'signin', 'terms', '403', '404'], stateName)) $injector.get('$state').go('signin'); } @@ -76,20 +77,15 @@ function run($root, $transitions, AclService, User, Activities) { $transitions.onBefore({}, (trans) => { const $state = trans.router.stateService; - const {name, permission} = trans.to(); + const {permission} = trans.to(); if (_.isEmpty(permission)) return; return trans.injector().get('User').read() .then(() => { - if (AclService.can(permission)) { - Activities.post({action: $state.href(name, trans.params('to'))}); - - return; - } - - return $state.target(trans.to().failState || '403'); + if (!AclService.can(permission)) + throw new Error('Illegal access error'); }) .catch(() => { return $state.target(trans.to().failState || '403'); @@ -99,15 +95,17 @@ function run($root, $transitions, AclService, User, Activities) { run.$inject = ['$rootScope', '$transitions', 'AclService', 'User', 'IgniteActivitiesData']; -angular.module('ignite-console.user', [ - 'mm.acl', - 'ignite-console.config', - 'ignite-console.core' -]) -.factory('sessionRecoverer', sessionRecoverer) -.config(['$httpProvider', ($httpProvider) => { - $httpProvider.interceptors.push('sessionRecoverer'); -}]) -.service('Auth', Auth) -.service('User', User) -.run(run); +angular + .module('ignite-console.user', [ + 'mm.acl', + 'ignite-console.config', + 'ignite-console.core' + ]) + .factory('sessionRecoverer', sessionRecoverer) + .config(registerInterceptor) + .config(['$httpProvider', ($httpProvider) => { + $httpProvider.interceptors.push('sessionRecoverer'); + }]) + .service('Auth', Auth) + .service('User', User) + .run(run); diff --git a/modules/web-console/frontend/app/primitives/datepicker/index.pug b/modules/web-console/frontend/app/primitives/datepicker/index.pug index 28cd1a06c24c2..dd586dc7d39b8 100644 --- a/modules/web-console/frontend/app/primitives/datepicker/index.pug +++ b/modules/web-console/frontend/app/primitives/datepicker/index.pug @@ -58,8 +58,8 @@ mixin form-field__datepicker({ label, model, name, mindate, maxdate, minview = 1 ng-messages=`$input.$error` ng-show=`($input.$dirty || $input.$touched || $input.$submitted) && $input.$invalid` ) - if block - block - if required +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) + + if block + block diff --git a/modules/web-console/frontend/app/primitives/datepicker/index.scss b/modules/web-console/frontend/app/primitives/datepicker/index.scss index c8edab58f3558..c527a42dcca91 100644 --- a/modules/web-console/frontend/app/primitives/datepicker/index.scss +++ b/modules/web-console/frontend/app/primitives/datepicker/index.scss @@ -18,6 +18,7 @@ .datepicker.dropdown-menu { width: 250px; height: 270px; + z-index: 2000; button { outline: none; diff --git a/modules/web-console/frontend/app/primitives/dropdown/index.pug b/modules/web-console/frontend/app/primitives/dropdown/index.pug index 0099457be59ab..aad6efd003605 100644 --- a/modules/web-console/frontend/app/primitives/dropdown/index.pug +++ b/modules/web-console/frontend/app/primitives/dropdown/index.pug @@ -37,5 +37,6 @@ mixin ignite-form-field-bsdropdown({label, model, name, disabled, required, opti ul.dropdown-menu(role='menu') li(ng-repeat=`item in ${options}` ng-if='item.available') - a(ng-click='item.click()') {{ item.action }} + a(ng-if='item.click' ng-click='item.click()') {{ item.action }} + a(ng-if='item.sref' ui-sref='{{:: item.sref}}') {{ item.action }} diff --git a/modules/web-console/frontend/app/primitives/form-field/checkbox.pug b/modules/web-console/frontend/app/primitives/form-field/checkbox.pug index 88b8f5a2f9618..fe0f808574b3b 100644 --- a/modules/web-console/frontend/app/primitives/form-field/checkbox.pug +++ b/modules/web-console/frontend/app/primitives/form-field/checkbox.pug @@ -15,7 +15,7 @@ limitations under the License. mixin form-field__checkbox({ label, model, name, disabled, required, tip, tipOpts }) - .form-field.form-field__checkbox(id=`{{ ${name} }}Field`) + .form-field.ignite-form-field.form-field__checkbox(id=`{{ ${name} }}Field`) +form-field__label({ label, name, required, disabled }) +form-field__tooltip({ title: tip, options: tipOpts }) @@ -24,7 +24,8 @@ mixin form-field__checkbox({ label, model, name, disabled, required, tip, tipOpt +form-field__input({ name, model, disabled, required, placeholder })(attributes=attributes) .form-field__errors( - ng-messages=`(${form}[${name}].$dirty || ${form}[${name}].$touched || ${form}[${name}].$submitted) && ${form}[${name}].$invalid ? ${form}[${name}].$error : {}` + ng-messages=`$input.$error` + ng-show=`($input.$dirty || $input.$touched || $input.$submitted) && $input.$invalid` ) if block block diff --git a/modules/web-console/frontend/app/primitives/form-field/dropdown.pug b/modules/web-console/frontend/app/primitives/form-field/dropdown.pug index 96d8482cfc8af..b13a17749b19f 100644 --- a/modules/web-console/frontend/app/primitives/form-field/dropdown.pug +++ b/modules/web-console/frontend/app/primitives/form-field/dropdown.pug @@ -50,8 +50,8 @@ mixin form-field__dropdown({ label, model, name, disabled, required, multiple, p ng-messages=`$input.$error` ng-show=`($input.$dirty || $input.$touched || $input.$submitted) && $input.$invalid` ) - if block - block - if required +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) + + if block + block diff --git a/modules/web-console/frontend/app/primitives/form-field/email.pug b/modules/web-console/frontend/app/primitives/form-field/email.pug index b68a520811741..b1e120254cdd3 100644 --- a/modules/web-console/frontend/app/primitives/form-field/email.pug +++ b/modules/web-console/frontend/app/primitives/form-field/email.pug @@ -15,9 +15,9 @@ limitations under the License. mixin form-field__email({ label, model, name, disabled, required, placeholder, tip }) - -var errLbl = label.substring(0, label.length - 1) + -let errLbl = label[label.length - 1] === ':' ? label.substring(0, label.length - 1) : label - .form-field + .form-field.ignite-form-field +form-field__label({ label, name, required, disabled }) +form-field__tooltip({ title: tip, options: tipOpts }) @@ -26,12 +26,13 @@ mixin form-field__email({ label, model, name, disabled, required, placeholder, t +form-field__input({ name, model, disabled, required, placeholder })(attributes=attributes) .form-field__errors( - ng-messages=`(${form}[${name}].$dirty || ${form}[${name}].$touched || ${form}[${name}].$submitted) && ${form}[${name}].$invalid ? ${form}[${name}].$error : {}` + ng-messages=`$input.$error` + ng-show=`($input.$dirty || $input.$touched || $input.$submitted) && $input.$invalid` ) - if block - block - if required +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) +form-field__error({ error: 'email', message: `${errLbl} has invalid format!` }) + + if block + block diff --git a/modules/web-console/frontend/app/primitives/form-field/index.scss b/modules/web-console/frontend/app/primitives/form-field/index.scss index 0330e5886a42a..3e757f9eecca9 100644 --- a/modules/web-console/frontend/app/primitives/form-field/index.scss +++ b/modules/web-console/frontend/app/primitives/form-field/index.scss @@ -259,7 +259,7 @@ &--postfix::after { content: attr(data-postfix); display: inline-flex; - place-self: center; + align-self: center; margin-left: 10px; } diff --git a/modules/web-console/frontend/app/primitives/form-field/number.pug b/modules/web-console/frontend/app/primitives/form-field/number.pug index ea907090e69d2..dfcfff36937bd 100644 --- a/modules/web-console/frontend/app/primitives/form-field/number.pug +++ b/modules/web-console/frontend/app/primitives/form-field/number.pug @@ -33,9 +33,6 @@ mixin form-field__number({ label, model, name, disabled, required, placeholder, ng-messages=`$input.$error` ng-show=`($input.$dirty || $input.$touched || $input.$submitted) && $input.$invalid` ) - if block - block - if required +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) @@ -46,3 +43,6 @@ mixin form-field__number({ label, model, name, disabled, required, placeholder, +form-field__error({ error: 'step', message: `${errLbl} step should be ${step || 1}` }) +form-field__error({ error: 'number', message: 'Only numbers allowed' }) + + if block + block diff --git a/modules/web-console/frontend/app/primitives/form-field/password.pug b/modules/web-console/frontend/app/primitives/form-field/password.pug index 6b9818bc91f43..5103281fd7c50 100644 --- a/modules/web-console/frontend/app/primitives/form-field/password.pug +++ b/modules/web-console/frontend/app/primitives/form-field/password.pug @@ -17,9 +17,9 @@ mixin form-field__password({ label, model, name, disabled, required, placeholder, tip }) -var errLbl = label.substring(0, label.length - 1) - .form-field.form-field__password( + .form-field.form-field__password.ignite-form-field( password-visibility-root - on-password-visibility-toggle=`${form}[${name}].$setTouched()` + on-password-visibility-toggle=`$input1.$setTouched(); $input2.$setTouched()` ) +form-field__label({ label, name, required }) +form-field__tooltip({ title: tip, options: tipOpts }) @@ -27,21 +27,27 @@ mixin form-field__password({ label, model, name, disabled, required, placeholder .form-field__control - attributes.type='password' - attributes.class = 'password-visibility__password-hidden' + - attributes['ng-ref'] = '$input1' +form-field__input({ name, model, disabled, required, placeholder })(attributes=attributes) - attributes.class = 'password-visibility__password-visible' - attributes.type='text' - attributes.autocomplete = 'off' + - attributes['ng-ref'] = '$input2' +form-field__input({ name: name + `+"Text"`, model, disabled, required, placeholder })(attributes=attributes) password-visibility-toggle-button .form-field__errors( - ng-messages=`(${form}[${name}].$dirty || ${form}[${name}].$touched || ${form}[${name}].$submitted) && ${form}[${name}].$invalid ? ${form}[${name}].$error : {}` + ng-messages=`$input1.$error || $input2.$error` + ng-show=` + ($input1.$dirty || $input1.$touched || $input1.$submitted) && $input1.$invalid || + ($input2.$dirty || $input2.$touched || $input2.$submitted) && $input2.$invalid + ` ) - if block - block - if required +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) - + +form-field__error({ error: 'mismatch', message: `Password does not match the confirm password!` }) + + if block + block diff --git a/modules/web-console/frontend/app/primitives/form-field/phone.pug b/modules/web-console/frontend/app/primitives/form-field/phone.pug index 8b503018d3bda..4c794772dc621 100644 --- a/modules/web-console/frontend/app/primitives/form-field/phone.pug +++ b/modules/web-console/frontend/app/primitives/form-field/phone.pug @@ -17,7 +17,7 @@ mixin form-field__phone({ label, model, name, disabled, required, optional, placeholder, tip }) -var errLbl = label.substring(0, label.length - 1) - .form-field + .form-field.ignite-form-field +form-field__label({ label, name, required, optional }) +form-field__tooltip({ title: tip, options: tipOpts }) @@ -26,10 +26,12 @@ mixin form-field__phone({ label, model, name, disabled, required, optional, plac +form-field__input({ name, model, disabled, required, placeholder })(attributes=attributes) .form-field__errors( - ng-messages=`(${form}[${name}].$dirty || ${form}[${name}].$touched || ${form}[${name}].$submitted) && ${form}[${name}].$invalid ? ${form}[${name}].$error : {}` + ng-messages=`$input.$error` + ng-show=`($input.$dirty || $input.$touched || $input.$submitted) && $input.$invalid` ) + if required + +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) + if block block - if required - +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) diff --git a/modules/web-console/frontend/app/primitives/form-field/text.pug b/modules/web-console/frontend/app/primitives/form-field/text.pug index ab8d14d2cbd26..5a2595ecc4c79 100644 --- a/modules/web-console/frontend/app/primitives/form-field/text.pug +++ b/modules/web-console/frontend/app/primitives/form-field/text.pug @@ -29,8 +29,8 @@ mixin form-field__text({ label, model, name, disabled, required, placeholder, ti ng-messages=`$input.$error` ng-show=`($input.$dirty || $input.$touched || $input.$submitted) && $input.$invalid` ) - if block - block - if required +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) + + if block + block diff --git a/modules/web-console/frontend/app/primitives/form-field/typeahead.pug b/modules/web-console/frontend/app/primitives/form-field/typeahead.pug index b2c62ae3d464e..ee2312f56366d 100644 --- a/modules/web-console/frontend/app/primitives/form-field/typeahead.pug +++ b/modules/web-console/frontend/app/primitives/form-field/typeahead.pug @@ -48,8 +48,8 @@ mixin form-field__typeahead({ label, model, name, disabled, required, placeholde ng-messages=`$input.$error` ng-show=`($input.$dirty || $input.$touched || $input.$submitted) && $input.$invalid` ) - if block - block - if required +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) + + if block + block diff --git a/modules/web-console/frontend/app/primitives/modal/index.scss b/modules/web-console/frontend/app/primitives/modal/index.scss index 2be2ecdc2c276..eb621e531122a 100644 --- a/modules/web-console/frontend/app/primitives/modal/index.scss +++ b/modules/web-console/frontend/app/primitives/modal/index.scss @@ -54,7 +54,6 @@ .modal .modal-dialog { width: 650px; - transform: translateZ(1px); } .modal .modal-dialog--adjust-height { @@ -247,4 +246,27 @@ .modal--wide .modal-dialog { width: 900px; -} \ No newline at end of file +} + +.modal-with-ace { + .modal-body { + padding-left: 5px !important; + } + + .modal-dialog { + transform: none !important; + + .ace_warning:before, .ace_error:before { + position: absolute !important; + left: -7px !important; + } + } + + .ace_gutter, .ace_layer { + overflow: visible !important; + } + + .ace_gutter { + padding-left: 5px !important; + } +} diff --git a/modules/web-console/frontend/app/primitives/timepicker/index.pug b/modules/web-console/frontend/app/primitives/timepicker/index.pug index 5e3936c737c25..9a4dd97bfb394 100644 --- a/modules/web-console/frontend/app/primitives/timepicker/index.pug +++ b/modules/web-console/frontend/app/primitives/timepicker/index.pug @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. -mixin form-field__timepicker({ label, model, name, mindate, maxdate, disabled, required, placeholder, tip }) +mixin form-field__timepicker({ label, model, name, mindate, maxdate, disabled, required, placeholder, tip, format = 'HH:mm'}) mixin __form-field__timepicker() input( id=`{{ ${name} }}Input` @@ -28,9 +28,10 @@ mixin form-field__timepicker({ label, model, name, mindate, maxdate, disabled, r ng-disabled=disabled && `${disabled}` bs-timepicker - data-time-format='HH:mm' + data-time-format=format data-length='1' data-minute-step='1' + data-second-step='1' data-arrow-behavior='picker' data-placement='bottom' @@ -55,8 +56,8 @@ mixin form-field__timepicker({ label, model, name, mindate, maxdate, disabled, r ng-messages=`$input.$error` ng-show=`($input.$dirty || $input.$touched || $input.$submitted) && $input.$invalid` ) - if block - block - if required +form-field__error({ error: 'required', message: `${errLbl} could not be empty!` }) + + if block + block diff --git a/modules/web-console/frontend/app/primitives/timepicker/index.scss b/modules/web-console/frontend/app/primitives/timepicker/index.scss index 643c741b5f8f3..1b21c707239c2 100644 --- a/modules/web-console/frontend/app/primitives/timepicker/index.scss +++ b/modules/web-console/frontend/app/primitives/timepicker/index.scss @@ -18,6 +18,7 @@ .timepicker.dropdown-menu { padding: 0 4px; line-height: 30px; + z-index: 2000; button { outline: none; diff --git a/modules/web-console/frontend/app/primitives/tooltip/index.scss b/modules/web-console/frontend/app/primitives/tooltip/index.scss index a6cd79ff327d3..71076e26c9eef 100644 --- a/modules/web-console/frontend/app/primitives/tooltip/index.scss +++ b/modules/web-console/frontend/app/primitives/tooltip/index.scss @@ -39,4 +39,4 @@ border-color: #f34718; color: white; } -} \ No newline at end of file +} diff --git a/modules/web-console/frontend/app/services/Caches.js b/modules/web-console/frontend/app/services/Caches.js index 7df4bb6ec13d8..626395d7bf9d6 100644 --- a/modules/web-console/frontend/app/services/Caches.js +++ b/modules/web-console/frontend/app/services/Caches.js @@ -31,7 +31,8 @@ export default class Caches { /** @type {ig.menu} */ atomicityModes = [ {value: 'ATOMIC', label: 'ATOMIC'}, - {value: 'TRANSACTIONAL', label: 'TRANSACTIONAL'} + {value: 'TRANSACTIONAL', label: 'TRANSACTIONAL'}, + {value: 'TRANSACTIONAL_SNAPSHOT', label: 'TRANSACTIONAL_SNAPSHOT'} ]; /** diff --git a/modules/web-console/frontend/app/services/Clusters.js b/modules/web-console/frontend/app/services/Clusters.js index e0a2ec7ca40b4..5649f0af6aa42 100644 --- a/modules/web-console/frontend/app/services/Clusters.js +++ b/modules/web-console/frontend/app/services/Clusters.js @@ -16,8 +16,7 @@ */ import get from 'lodash/get'; -import {Observable} from 'rxjs/Observable'; -import 'rxjs/add/observable/fromPromise'; +import {from} from 'rxjs'; import ObjectID from 'bson-objectid/objectid'; import {uniqueName} from 'app/utils/uniqueName'; import omit from 'lodash/fp/omit'; @@ -117,7 +116,7 @@ export default class Clusters { } getClustersOverview$() { - return Observable.fromPromise(this.getClustersOverview()); + return from(this.getClustersOverview()); } saveCluster(cluster) { @@ -125,7 +124,7 @@ export default class Clusters { } saveCluster$(cluster) { - return Observable.fromPromise(this.saveCluster(cluster)); + return from(this.saveCluster(cluster)); } removeCluster(cluster) { @@ -133,7 +132,7 @@ export default class Clusters { } removeCluster$(cluster) { - return Observable.fromPromise(this.removeCluster(cluster)); + return from(this.removeCluster(cluster)); } saveBasic(changedItems) { diff --git a/modules/web-console/frontend/app/services/FormUtils.service.js b/modules/web-console/frontend/app/services/FormUtils.service.js index c8ce4b04f448d..aa4638194e1aa 100644 --- a/modules/web-console/frontend/app/services/FormUtils.service.js +++ b/modules/web-console/frontend/app/services/FormUtils.service.js @@ -339,7 +339,7 @@ export default function service($window, Focus, $rootScope) { return; const walk = (m) => { - if (!m.$error[e]) + if (!m || !m.$error[e]) return; if (m.$error[e] === true) diff --git a/modules/web-console/frontend/app/services/Version.service.js b/modules/web-console/frontend/app/services/Version.service.js index bbd03cb92f1d8..cbaeff1c20826 100644 --- a/modules/web-console/frontend/app/services/Version.service.js +++ b/modules/web-console/frontend/app/services/Version.service.js @@ -15,7 +15,7 @@ * limitations under the License. */ -import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +import { BehaviorSubject } from 'rxjs'; import _ from 'lodash'; /** diff --git a/modules/web-console/frontend/app/services/exceptionHandler.js b/modules/web-console/frontend/app/services/exceptionHandler.js index c6a09c3324495..6b5f4e472ea70 100644 --- a/modules/web-console/frontend/app/services/exceptionHandler.js +++ b/modules/web-console/frontend/app/services/exceptionHandler.js @@ -25,6 +25,10 @@ export function $exceptionHandler($log) { if (exception instanceof CancellationError) return; + // From ui-grid + if (exception === 'Possibly unhandled rejection: canceled') + return; + $log.error(exception, cause); }; } diff --git a/modules/web-console/frontend/app/services/store.ts b/modules/web-console/frontend/app/services/store.ts new file mode 100644 index 0000000000000..4498d1e0ecd66 --- /dev/null +++ b/modules/web-console/frontend/app/services/store.ts @@ -0,0 +1,73 @@ +/* + * 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. + */ + +import {BehaviorSubject, Subject, merge} from 'rxjs'; +import {scan, tap} from 'rxjs/operators'; + +interface Reducer { + (state: State, action: Actions): State +} + +export class Store { + static $inject = ['$injector']; + + actions$: Subject; + state$: BehaviorSubject; + private _reducers: Array>; + + constructor(private $injector: ng.auto.IInjectorService) { + this.$injector = $injector; + + this.actions$ = new Subject(); + this.state$ = new BehaviorSubject({}); + this.actions$.pipe( + scan((state, action) => this._reducers.reduce((state, reducer) => reducer(state, action), state), void 0), + tap((state) => this.state$.next(state)) + ).subscribe(); + this._reducers = [(state) => state]; + } + + dispatch(action: Actions) { + this.actions$.next(action); + } + + addReducer(path: T, reducer: Reducer): void + addReducer(reducer: Reducer): void + addReducer(...args) { + if (typeof args[0] === 'string') { + const [path, reducer] = args; + this._reducers = [ + ...this._reducers, + (state = {}, action) => { + const pathState = reducer(state[path], action); + // Don't update root state if child state changes + return state[path] !== pathState ? {...state, [path]: pathState} : state; + } + ]; + } else { + const [reducer] = args; + this._reducers = [...this._reducers, reducer]; + } + } + + addEffects(EffectsClass) { + const instance = this.$injector.instantiate(EffectsClass); + return merge( + ...Object.keys(instance).filter((k) => k.endsWith('Effect$')).map((k) => instance[k]), + ).pipe(tap((a) => this.dispatch(a))).subscribe(); + } +} diff --git a/modules/web-console/frontend/app/store/actions/ui.ts b/modules/web-console/frontend/app/store/actions/ui.ts new file mode 100644 index 0000000000000..25d9ba048b509 --- /dev/null +++ b/modules/web-console/frontend/app/store/actions/ui.ts @@ -0,0 +1,36 @@ +/* + * 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. + */ + +import {NavigationMenuItem} from '../../types'; + +export const TOGGLE_SIDEBAR: 'TOGGLE_SIDEBAR' = 'TOGGLE_SIDEBAR'; +export const toggleSidebar = () => ({type: TOGGLE_SIDEBAR}); + +export const NAVIGATION_MENU_ITEM: 'NAVIGATION_MENU_ITEM' = 'NAVIGATION_MENU_ITEM'; +export const navigationMenuItem = (menuItem: NavigationMenuItem) => ({type: NAVIGATION_MENU_ITEM, menuItem}); + +export const HIDE_NAVIGATION_MENU_ITEM: 'HIDE_NAVIGATION_MENU_ITEM' = 'HIDE_NAVIGATION_MENU_ITEM'; +export const hideNavigationMenuItem = (label: NavigationMenuItem['label']) => ({type: HIDE_NAVIGATION_MENU_ITEM, label}); + +export const SHOW_NAVIGATION_MENU_ITEM: 'SHOW_NAVIGATION_MENU_ITEM' = 'SHOW_NAVIGATION_MENU_ITEM'; +export const showNavigationMenuItem = (label: NavigationMenuItem['label']) => ({type: SHOW_NAVIGATION_MENU_ITEM, label}); + +export type UIActions = + | ReturnType + | ReturnType + | ReturnType + | ReturnType; diff --git a/modules/web-console/frontend/app/store/actions/user.ts b/modules/web-console/frontend/app/store/actions/user.ts new file mode 100644 index 0000000000000..34c8d2062674c --- /dev/null +++ b/modules/web-console/frontend/app/store/actions/user.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +import {User} from '../../types'; + +export const USER: 'USER' = 'USER'; +export const user = (user: User) => ({type: USER, user}); + +export type UserActions = + | ReturnType; diff --git a/modules/web-console/frontend/app/store/effects/ui.ts b/modules/web-console/frontend/app/store/effects/ui.ts new file mode 100644 index 0000000000000..2a635d6e362c6 --- /dev/null +++ b/modules/web-console/frontend/app/store/effects/ui.ts @@ -0,0 +1,32 @@ +/* + * 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. + */ + +import {AppStore, USER, ofType, hideNavigationMenuItem, showNavigationMenuItem} from '..'; +import {map} from 'rxjs/operators'; + +export class UIEffects { + static $inject = ['Store'] + constructor(private store: AppStore) {} + + toggleQueriesNavItemEffect$ = this.store.actions$.pipe( + ofType(USER), + map((action) => { + const QUERY_LABEL = 'Queries'; + return action.user.becomeUsed ? hideNavigationMenuItem(QUERY_LABEL) : showNavigationMenuItem(QUERY_LABEL); + }) + ) +} diff --git a/modules/web-console/frontend/app/store/index.ts b/modules/web-console/frontend/app/store/index.ts new file mode 100644 index 0000000000000..fa4a878e1637d --- /dev/null +++ b/modules/web-console/frontend/app/store/index.ts @@ -0,0 +1,48 @@ +/* + * 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. + */ + +import {Store} from '../services/store'; + +import {UIState, uiReducer} from './reducers/ui'; +import {UIActions} from './actions/ui'; +import {UIEffects} from './effects/ui'; + +import {UserActions} from './actions/user'; + +export * from './actions/ui'; +export * from './reducers/ui'; +export * from './selectors/ui'; + +export * from './actions/user'; + +export {ofType} from './ofType'; + +export type State = { + ui: UIState, +}; + +export type Actions = + | UserActions + | UIActions; + +export type AppStore = Store; + +register.$inject = ['Store']; +export function register(store: AppStore) { + store.addReducer('ui', uiReducer); + store.addEffects(UIEffects); +} diff --git a/modules/web-console/frontend/app/store/ofType.ts b/modules/web-console/frontend/app/store/ofType.ts new file mode 100644 index 0000000000000..220de5f7884f3 --- /dev/null +++ b/modules/web-console/frontend/app/store/ofType.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +import {OperatorFunction} from 'rxjs'; +import {filter} from 'rxjs/operators'; + +type Action = {type: string}; +export function ofType>(type: T): OperatorFunction +export function ofType(type): OperatorFunction { + return filter((action: U): boolean => type === action.type); +} + diff --git a/modules/web-console/frontend/app/store/reducers/ui.ts b/modules/web-console/frontend/app/store/reducers/ui.ts new file mode 100644 index 0000000000000..6f2859de6a74b --- /dev/null +++ b/modules/web-console/frontend/app/store/reducers/ui.ts @@ -0,0 +1,50 @@ +/* + * 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. + */ + +import {NavigationMenu} from '../../types'; +import {UIActions, TOGGLE_SIDEBAR, NAVIGATION_MENU_ITEM, HIDE_NAVIGATION_MENU_ITEM, SHOW_NAVIGATION_MENU_ITEM} from '..'; + +export type UIState = { + sidebarOpened: boolean, + navigationMenu: NavigationMenu +}; + +const defaults: UIState = { + sidebarOpened: false, + navigationMenu: [] +}; + +export function uiReducer(state: UIState = defaults, action: UIActions): UIState { + switch (action.type) { + case TOGGLE_SIDEBAR: + return {...state, sidebarOpened: !state.sidebarOpened}; + case NAVIGATION_MENU_ITEM: + return {...state, navigationMenu: [...state.navigationMenu, action.menuItem]}; + case HIDE_NAVIGATION_MENU_ITEM: + return { + ...state, + navigationMenu: state.navigationMenu.map((i) => i.label === action.label ? {...i, hidden: true} : i) + }; + case SHOW_NAVIGATION_MENU_ITEM: + return { + ...state, + navigationMenu: state.navigationMenu.map((i) => i.label === action.label ? {...i, hidden: false} : i) + }; + default: + return state; + } +} diff --git a/modules/web-console/frontend/app/store/reduxDebug.ts b/modules/web-console/frontend/app/store/reduxDebug.ts new file mode 100644 index 0000000000000..d7b1474ec052a --- /dev/null +++ b/modules/web-console/frontend/app/store/reduxDebug.ts @@ -0,0 +1,45 @@ +/* + * 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. + */ + +import {reducer, devTools} from '../components/page-configure/reduxDevtoolsIntegration'; +import {AppStore} from '.'; +import {filter, withLatestFrom, tap} from 'rxjs/operators'; + +run.$inject = ['Store']; + +export function run(store: AppStore) { + if (devTools) { + devTools.subscribe((e) => { + if (e.type === 'DISPATCH' && e.state) store.dispatch(e); + }); + + const ignoredActions = new Set([ + ]); + + store.actions$.pipe( + filter((e) => e.type !== 'DISPATCH'), + withLatestFrom(store.state$.skip(1)), + tap(([action, state]) => { + if (ignoredActions.has(action.type)) return; + devTools.send(action, state); + console.log(action); + }) + ).subscribe(); + + store.addReducer(reducer); + } +} diff --git a/modules/web-console/frontend/app/store/selectors/ui.ts b/modules/web-console/frontend/app/store/selectors/ui.ts new file mode 100644 index 0000000000000..0bd2fa92a95c5 --- /dev/null +++ b/modules/web-console/frontend/app/store/selectors/ui.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +import {State, AppStore} from '..'; +import {pluck, map} from 'rxjs/operators'; +import {pipe} from 'rxjs'; +import {memoize, orderBy} from 'lodash'; + +const orderMenu = (menu: Array) => orderBy(menu, 'order'); + +export const selectSidebarOpened = () => pluck('ui', 'sidebarOpened'); +export const selectNavigationMenu = () => pipe( + pluck('ui', 'navigationMenu'), + map(orderMenu) +); diff --git a/modules/web-console/frontend/app/types/index.ts b/modules/web-console/frontend/app/types/index.ts index 333c00be875d2..ad40c15308669 100644 --- a/modules/web-console/frontend/app/types/index.ts +++ b/modules/web-console/frontend/app/types/index.ts @@ -23,11 +23,42 @@ interface ITfMetatagsConfig { export interface IIgniteNg1StateDeclaration extends Ng1StateDeclaration { /** - * Whether to store state as last visited in local storage or not. - * true - will be saved - * false (default) - won't be saved + * Whether to store state as last visited in local storage or not: + * `true` - will be saved + * `false` (default) - won't be saved * @type {boolean} */ unsaved?: boolean, - tfMetaTags: ITfMetatagsConfig + tfMetaTags: ITfMetatagsConfig, + permission?: string } + +export type User = { + _id: string, + firstName: string, + lastName: string, + email: string, + phone?: string, + company: string, + country: string, + registered: string, + lastLogin: string, + lastActivity: string, + admin: boolean, + token: string, + resetPasswordToken: string, + // Assigned in UI + becomeUsed?: boolean +}; + +export type NavigationMenuItem = { + label: string, + icon: string, + order: number, + hidden?: boolean +} & ( + {sref: string, activeSref: string} | + {href: string} +); + +export type NavigationMenu = Array; diff --git a/modules/web-console/frontend/app/utils/SimpleWorkerPool.js b/modules/web-console/frontend/app/utils/SimpleWorkerPool.js index 8e7aab74e849c..b751dc3e5e235 100644 --- a/modules/web-console/frontend/app/utils/SimpleWorkerPool.js +++ b/modules/web-console/frontend/app/utils/SimpleWorkerPool.js @@ -16,15 +16,8 @@ */ import _ from 'lodash'; - -import {Observable} from 'rxjs/Observable'; -import {Subject} from 'rxjs/Subject'; -import 'rxjs/add/observable/race'; -import 'rxjs/add/operator/filter'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/pluck'; -import 'rxjs/add/operator/take'; -import 'rxjs/add/operator/toPromise'; +import {Subject, race} from 'rxjs'; +import {filter, take, pluck, map} from 'rxjs/operators'; /** * Simple implementation of workers pool. @@ -90,7 +83,7 @@ export default class SimpleWorkerPool { worker.postMessage(task.data); if (this.__dbg) - console.timeEnd('Post message'); + console.timeEnd(`Post message[pool=${this._name}]`); } terminate() { @@ -112,11 +105,11 @@ export default class SimpleWorkerPool { this._run(); - return Observable.race( - this.messages$.filter((e) => e.tid === tid).take(1).pluck('m', 'data'), - this.errors$.filter((e) => e.tid === tid).take(1).map((e) => { + return race( + this.messages$.pipe(filter((e) => e.tid === tid), take(1), pluck('m', 'data')), + this.errors$.pipe(filter((e) => e.tid === tid), take(1), map((e) => { throw e.e; })) - .take(1).toPromise(); + ).pipe(take(1)).toPromise(); } } diff --git a/modules/web-console/frontend/app/utils/dialogState.ts b/modules/web-console/frontend/app/utils/dialogState.ts new file mode 100644 index 0000000000000..d83c911035eb9 --- /dev/null +++ b/modules/web-console/frontend/app/utils/dialogState.ts @@ -0,0 +1,56 @@ +/* + * 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. + */ + +import {UIRouter, StateDeclaration, Transition} from '@uirouter/angularjs'; + +export function dialogState(component: string): Partial { + let dialog: mgcrea.ngStrap.modal.IModal | undefined; + let hide: (() => void) | undefined; + + onEnter.$inject = ['$transition$']; + + function onEnter(transition: Transition) { + const modal = transition.injector().get('$modal'); + const router = transition.injector().get('$uiRouter'); + + dialog = modal({ + template: ` + <${component} + class='modal center modal--ignite theme--ignite' + tabindex='-1' + role='dialog' + on-hide=$hide() + > + `, + onHide(modal) { + modal.destroy(); + } + }); + + hide = dialog.hide; + + dialog.hide = () => router.stateService.go('.^'); + } + + return { + onEnter, + onExit() { + if (hide) hide(); + dialog = hide = void 0; + } + }; +} diff --git a/modules/web-console/frontend/app/vendor.js b/modules/web-console/frontend/app/vendor.js index 6961e962e30b2..e9fc8e9567061 100644 --- a/modules/web-console/frontend/app/vendor.js +++ b/modules/web-console/frontend/app/vendor.js @@ -22,12 +22,13 @@ import 'angular-animate'; import 'angular-sanitize'; import 'angular-strap'; import 'angular-strap/dist/angular-strap.tpl'; -import 'angular-socket-io'; import 'angular-messages'; import '@uirouter/angularjs'; import '@uirouter/angularjs/lib/legacy/stateEvents'; +import 'resize-observer-polyfill'; + import 'tf-metatags'; import 'angular-translate'; import 'angular-smart-table'; diff --git a/modules/web-console/frontend/package.json b/modules/web-console/frontend/package.json index fce79ef5dbbd0..aa6e037530e04 100644 --- a/modules/web-console/frontend/package.json +++ b/modules/web-console/frontend/package.json @@ -10,7 +10,7 @@ "build": "webpack --config ./webpack/webpack.prod.js", "test": "karma start ./test/karma.conf.js", "test-watch": "npm test -- --no-single-run", - "eslint": "eslint --format node_modules/eslint-friendly-formatter app/ -- --eff-by-issue" + "eslint": "eslint --ignore-pattern node_modules/ --format node_modules/eslint-formatter-friendly . -- --eff-by-issue" }, "license": "Apache-2.0", "keywords": [ @@ -28,10 +28,9 @@ ], "dependencies": { "@babel/plugin-transform-parameters": "7.0.0", - "@types/angular-translate": "2.16.0", "@uirouter/angularjs": "1.0.20", "@uirouter/core": "5.0.19", - "@uirouter/rx": "0.4.1", + "@uirouter/rx": "0.5.0", "@uirouter/visualizer": "4.0.2", "angular": "1.7.4", "angular-acl": "0.1.10", @@ -45,7 +44,6 @@ "angular-nvd3": "1.0.9", "angular-sanitize": "1.7.4", "angular-smart-table": "2.1.11", - "angular-socket-io": "0.7.0", "angular-strap": "2.3.12", "angular-translate": "2.18.1", "angular-tree-control": "0.2.28", @@ -53,7 +51,7 @@ "angular-ui-grid": "4.6.1", "angular-ui-validate": "1.2.3", "angular1-async-filter": "1.1.0", - "brace": "0.10.0", + "brace": "0.11.1", "browser-update": "3.1.13", "bson-objectid": "1.1.5", "chart.js": "2.7.2", @@ -61,7 +59,7 @@ "file-saver": "1.3.3", "font-awesome": "4.7.0", "jquery": "3.2.1", - "json-bigint": "0.2.3", + "json-bigint": "0.3.0", "jsondiffpatch": "0.2.5", "jszip": "3.1.5", "lodash": "4.17.11", @@ -69,9 +67,10 @@ "nvd3": "1.8.6", "outdent": "0.5.0", "pako": "1.0.6", + "resize-observer-polyfill": "1.5.0", "roboto-font": "0.1.0", - "rxjs": "5.5.11", - "socket.io-client": "1.7.3", + "rxjs": "6.3.3", + "socket.io-client": "2.1.1", "tf-metatags": "2.0.0" }, "devDependencies": { @@ -85,6 +84,7 @@ "@types/angular-animate": "1.5.10", "@types/angular-mocks": "1.5.12", "@types/angular-strap": "2.3.1", + "@types/angular-translate": "2.16.0", "@types/chai": "4.1.4", "@types/copy-webpack-plugin": "4.4.2", "@types/karma": "1.7.4", @@ -108,7 +108,6 @@ "eslint": "4.19.1", "eslint-formatter-friendly": "6.0.0", "eslint-loader": "2.1.0", - "eslint-plugin-babel": "5.2.0", "eslint-plugin-typescript": "0.12.0", "expose-loader": "0.7.5", "file-loader": "1.1.11", @@ -130,7 +129,7 @@ "mocha": "3.4.2", "mocha-teamcity-reporter": "1.1.1", "node-fetch": "1.7.3", - "node-sass": "4.9.3", + "node-sass": "4.10.0", "progress": "2.0.0", "progress-bar-webpack-plugin": "1.11.0", "pug-html-loader": "1.1.0", diff --git a/modules/web-console/frontend/public/images/icons/cluster.icon.svg b/modules/web-console/frontend/public/images/icons/cluster.icon.svg new file mode 100644 index 0000000000000..757604970e52f --- /dev/null +++ b/modules/web-console/frontend/public/images/icons/cluster.icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/modules/web-console/frontend/public/images/icons/connectedClusters.icon.svg b/modules/web-console/frontend/public/images/icons/connectedClusters.icon.svg deleted file mode 100644 index f4053171c6591..0000000000000 --- a/modules/web-console/frontend/public/images/icons/connectedClusters.icon.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/web-console/frontend/public/images/icons/downloadAgent.icon.svg b/modules/web-console/frontend/public/images/icons/downloadAgent.icon.svg new file mode 100644 index 0000000000000..afb51eeb3cf96 --- /dev/null +++ b/modules/web-console/frontend/public/images/icons/downloadAgent.icon.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/modules/web-console/frontend/public/images/icons/index.js b/modules/web-console/frontend/public/images/icons/index.js index 0951d32550bc8..2e4108545eabb 100644 --- a/modules/web-console/frontend/public/images/icons/index.js +++ b/modules/web-console/frontend/public/images/icons/index.js @@ -21,7 +21,6 @@ export {default as check} from './check.icon.svg'; export {default as checkmark} from './checkmark.icon.svg'; export {default as clock} from './clock.icon.svg'; export {default as collapse} from './collapse.icon.svg'; -export {default as connectedClusters} from './connectedClusters.icon.svg'; export {default as copy} from './copy.icon.svg'; export {default as cross} from './cross.icon.svg'; export {default as csv} from './csv.icon.svg'; @@ -43,3 +42,7 @@ export {default as refresh} from './refresh.icon.svg'; export {default as search} from './search.icon.svg'; export {default as sort} from './sort.icon.svg'; export {default as structure} from './structure.icon.svg'; +export {default as cluster} from './cluster.icon.svg'; +export {default as sql} from './sql.icon.svg'; +export {default as menu} from './menu.icon.svg'; +export {default as downloadAgent} from './downloadAgent.icon.svg'; diff --git a/modules/web-console/frontend/public/images/icons/menu.icon.svg b/modules/web-console/frontend/public/images/icons/menu.icon.svg new file mode 100644 index 0000000000000..392d42ec945b1 --- /dev/null +++ b/modules/web-console/frontend/public/images/icons/menu.icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/modules/web-console/frontend/public/images/icons/sql.icon.svg b/modules/web-console/frontend/public/images/icons/sql.icon.svg new file mode 100644 index 0000000000000..bd54eeed2a0b8 --- /dev/null +++ b/modules/web-console/frontend/public/images/icons/sql.icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/modules/web-console/frontend/public/stylesheets/_bootstrap-variables.scss b/modules/web-console/frontend/public/stylesheets/_bootstrap-variables.scss index ded958e4e6cc0..e68dedf70eeac 100644 --- a/modules/web-console/frontend/public/stylesheets/_bootstrap-variables.scss +++ b/modules/web-console/frontend/public/stylesheets/_bootstrap-variables.scss @@ -726,7 +726,7 @@ $list-group-link-heading-color: #333 !default; $panel-bg: #fff !default; $panel-body-padding: 15px !default; -$panel-heading-padding: 10px 15px !default; +$panel-heading-padding: 5px 10px !default; $panel-footer-padding: $panel-heading-padding !default; $panel-border-radius: $border-radius-base !default; diff --git a/modules/web-console/frontend/public/stylesheets/style.scss b/modules/web-console/frontend/public/stylesheets/style.scss index a00a5857ba1bc..3f601be4570bb 100644 --- a/modules/web-console/frontend/public/stylesheets/style.scss +++ b/modules/web-console/frontend/public/stylesheets/style.scss @@ -255,17 +255,70 @@ body { flex-direction: column; } -body > .wrapper, - // Nested ui-view, like on password reset state -body > .wrapper > ui-view { - display: flex; - flex-direction: column; +:root { + --page-side-padding: 30px; +} + +.wrapper { + --header-height: 62px; + min-height: 100vh; + display: grid; + grid-template-columns: auto 1fr; + grid-template-rows: auto var(--header-height) 1fr; + grid-template-areas: 'notifications notifications' 'header header' 'sidebar content'; + + permanent-notifications { + grid-area: notifications; + } + + web-console-header { + grid-area: header; + position: -webkit-sticky; + position: sticky; + top: 0; + z-index: 10; + transform: translateZ(1px); + } + + web-console-sidebar { + grid-area: sidebar; + transform: translateZ(1px); + } + + &>.content { + grid-area: content; + padding-left: var(--page-side-padding); + padding-right: var(--page-side-padding); + padding-bottom: var(--page-side-padding); + display: flex; + flex-direction: column; + + &>ui-view { + display: flex; + flex-direction: column; + flex: 1; + } + } + + &.wrapper-public { + grid-template-columns: 1fr; + grid-template-rows: auto var(--header-height) 1fr auto; + grid-template-areas: 'notifications' 'header' 'content' 'footer'; + } +} + +.public-page { + margin-left: auto; + margin-right: auto; flex: 1 0 auto; + width: 100%; + max-width: 530px; - .body-container { - flex: 1 0 auto; - padding-bottom: 30px; + .public-page__title { + font-size: 38px; + font-weight: 300; + margin: 30px 0 30px; } } @@ -374,7 +427,6 @@ i.btn { h1, h2, h3 { - user-select: none; font-weight: normal; /* Makes the vertical size of the text the same for all fonts. */ line-height: 1; @@ -593,7 +645,6 @@ button.form-control { } .theme-line .panel-heading { - padding: 5px 10px; margin: 0; cursor: pointer; font-size: $font-size-large; @@ -1870,64 +1921,6 @@ treecontrol.tree-classic { border-bottom-width: 0; } -.ribbon-wrapper { - width: 150px; - height: 150px; - position: absolute; - overflow: hidden; - top: 0; - z-index: 1001; - pointer-events: none; -} - -.ribbon-wrapper.right { - right: 0; -} - -.ribbon { - position: absolute; - top: 42px; - width: 186px; - padding: 1px 0; - color: $btn-primary-color; - background: $btn-primary-border; - - right: -42px; - -moz-transform: rotate(45deg); - -webkit-transform: rotate(45deg); - -o-transform: rotate(45deg); - -ms-transform: rotate(45deg); - transform: rotate(45deg); - - > label { - padding: 1px 0; - height: 17px; - line-height: 12px; - text-align: center; - text-decoration: none; - font-family: Roboto, sans-serif; - font-size: 16px; - display: block; - font-weight: 400; - - border: 1px solid rgba(255,255,255,0.3); - - -moz-text-shadow: 0 0 10px rgba(0,0,0,0.31); - -webkit-text-shadow: 0 0 10px rgba(0,0,0,0.31); - text-shadow: 0 0 10px rgba(0,0,0,0.31); - } -} - -.ribbon-wrapper.left { - overflow: visible; - - .ribbon { - transform: rotate(-45deg); - left: -75px; - top: 10px; - } -} - html, body { width: 100%; min-height: 100vh; @@ -2063,10 +2056,6 @@ html, body { position: absolute !important; } -.demo-mode { - padding-top: 30px; -} - // Fix for injecting svg icon into BS btn .btn--with-icon { display: flex; diff --git a/modules/web-console/frontend/test/check-doc-links/check-doc-links.js b/modules/web-console/frontend/test/check-doc-links/check-doc-links.js index e8f3d169904ea..4ab64ed2d4431 100644 --- a/modules/web-console/frontend/test/check-doc-links/check-doc-links.js +++ b/modules/web-console/frontend/test/check-doc-links/check-doc-links.js @@ -66,7 +66,8 @@ const findLinks = (acc, ast) => { try { acc.push([JSON.parse(compiledAttr).href, ast.filePath]); - } catch (e) { + } + catch (e) { console.log(ast.filePath, e); } } diff --git a/modules/web-console/frontend/test/ci/Dockerfile b/modules/web-console/frontend/test/ci/Dockerfile index 2573534dfb1d3..7b1d602765446 100644 --- a/modules/web-console/frontend/test/ci/Dockerfile +++ b/modules/web-console/frontend/test/ci/Dockerfile @@ -15,10 +15,12 @@ # limitations under the License. # -FROM alpine:edge +FROM node:8-alpine + +ENV NPM_CONFIG_LOGLEVEL error RUN apk --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ add \ - nodejs nodejs-npm chromium xwininfo xvfb dbus eudev ttf-freefont fluxbox + chromium xwininfo xvfb dbus eudev ttf-freefont fluxbox ENV CHROME_BIN /usr/bin/chromium-browser diff --git a/modules/web-console/frontend/views/base.pug b/modules/web-console/frontend/views/base.pug index 967d469b569e0..b14cdac9d7e0c 100644 --- a/modules/web-console/frontend/views/base.pug +++ b/modules/web-console/frontend/views/base.pug @@ -14,13 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. +permanent-notifications web-console-header - web-console-header-left - include ./includes/header-left - web-console-header-right - include ./includes/header-right + web-console-header-content -.container--responsive.body-container.flex-full-height - div(ui-view='').flex-full-height +web-console-sidebar -web-console-footer +ui-view.content \ No newline at end of file diff --git a/modules/web-console/frontend/views/includes/header-left.pug b/modules/web-console/frontend/views/includes/header-left.pug deleted file mode 100644 index bf1ee9b71bd0f..0000000000000 --- a/modules/web-console/frontend/views/includes/header-left.pug +++ /dev/null @@ -1,42 +0,0 @@ -//- - 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. - -a.wch-nav-item( - ui-sref='base.configuration.overview' - ui-sref-active='{active: "base.configuration"}' -) - | Configure - -.wch-nav-item(ng-if='!$root.user.becomeUsed') - a(ui-sref='base.sql.tabs' ui-sref-active='active') - | Queries - -.wch-additional-nav-items(ignite-navbar) - .wch-nav-item(ng-repeat='item in navbar.items') - div(ng-if='$root.user.becomeUsed ? item.canBecomed : item.children' ng-click='$event.stopPropagation()' - ng-class='{active: $state.includes(item.sref)}' - bs-dropdown='item.children' - data-placement='bottom-left' - data-trigger='hover focus' - data-container='self' - aria-haspopup='true' - aria-expanded='false' - ) - span {{::item.text}} - span.caret - - a(ng-if='$root.user.becomeUsed ? item.canBecomed : !item.children' ui-sref='{{item.sref}}' ui-sref-active='active') - | {{::item.text}} diff --git a/modules/web-console/frontend/views/index.pug b/modules/web-console/frontend/views/index.pug index b9ba00bea21a8..a0c68103a120b 100644 --- a/modules/web-console/frontend/views/index.pug +++ b/modules/web-console/frontend/views/index.pug @@ -28,6 +28,8 @@ html meta(name='fragment' content='!') + link(rel='preload' as='font' href='assets/fonts/roboto-bold-webfont.woff' type='font/woff' crossorigin='anonymous') + body.theme-line.body-overlap(ng-class='{ "demo-mode": IgniteDemoMode }') .splash.splash-max-foreground(hide-on-state-change) @@ -39,8 +41,4 @@ html .splash-wellcome Loading... - .ribbon-wrapper.left(ng-if='!IgniteDemoMode') - .ribbon - label Beta - .wrapper(ui-view='') diff --git a/modules/web-console/frontend/app/modules/branding/header-logo.pug b/modules/web-console/frontend/views/public.pug similarity index 80% rename from modules/web-console/frontend/app/modules/branding/header-logo.pug rename to modules/web-console/frontend/views/public.pug index f0453d39da8ab..934ac56978a3f 100644 --- a/modules/web-console/frontend/app/modules/branding/header-logo.pug +++ b/modules/web-console/frontend/views/public.pug @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. -a(ui-sref='signin') - img.navbar-brand(ng-src='{{logo.url}}') +web-console-header(hide-menu-button='true') + .web-console-header-content__title Management console for Apache Ignite +.content(ui-view='page') +web-console-footer.web-console-footer__page-bottom \ No newline at end of file diff --git a/modules/web-console/frontend/webpack/webpack.dev.js b/modules/web-console/frontend/webpack/webpack.dev.js index 3af63776b4189..59e3d45470dcb 100644 --- a/modules/web-console/frontend/webpack/webpack.dev.js +++ b/modules/web-console/frontend/webpack/webpack.dev.js @@ -23,9 +23,11 @@ const commonCfg = require('./webpack.common'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const backendPort = process.env.BACKEND_PORT || 3000; -const devServerPort = process.env.PORT || 9000; -const devServerHost = process.env.HOST || '0.0.0.0'; +const backendUrl = process.env.BACKEND_URL || 'http://localhost:3000'; +const webpackDevServerHost = process.env.HOST || '0.0.0.0'; +const webpackDevServerPort = process.env.PORT || 9000; + +console.log(`Backend url: ${backendUrl}`); module.exports = merge(commonCfg, { mode: 'development', @@ -70,15 +72,18 @@ module.exports = merge(commonCfg, { inline: true, proxy: { '/socket.io': { - target: `http://localhost:${backendPort}`, - ws: true + target: backendUrl, + ws: true, + secure: false }, '/agents': { - target: `http://localhost:${backendPort}`, - ws: true + target: backendUrl, + ws: true, + secure: false }, '/api/*': { - target: `http://localhost:${backendPort}` + target: backendUrl, + secure: false } }, watchOptions: { @@ -86,7 +91,7 @@ module.exports = merge(commonCfg, { poll: 2000 }, stats: 'errors-only', - host: devServerHost, - port: devServerPort + host: webpackDevServerHost, + port: webpackDevServerPort } }); diff --git a/modules/web-console/pom.xml b/modules/web-console/pom.xml index 79293ff6fea94..273e5fe1f84d6 100644 --- a/modules/web-console/pom.xml +++ b/modules/web-console/pom.xml @@ -336,27 +336,6 @@ - - docker-build-standalone - package - - exec - - - docker - - build - -f - docker/standalone/Dockerfile - -t - - ${docker.registry.host}/${docker.repository}/${docker.standalone.image}:${project.version} - - ${project.basedir} - - - - docker-push-backend deploy @@ -390,23 +369,6 @@ - - - docker-push-standalone - deploy - - exec - - - docker - - push - - ${docker.registry.host}/${docker.repository}/${docker.standalone.image}:${project.version} - - - - diff --git a/modules/web-console/web-agent/README.txt b/modules/web-console/web-agent/README.txt index 86f12b884ae1f..6b2990202b891 100644 --- a/modules/web-console/web-agent/README.txt +++ b/modules/web-console/web-agent/README.txt @@ -23,6 +23,15 @@ Configuration file: node-login node-password driver-folder + node-key-store + node-key-store-password + node-trust-store + node-trust-store-password + server-key-store + server-key-store-password + server-trust-store + server-trust-store-password + cipher-suites Example configuration file: tokens=1a2b3c4d5f,2j1s134d12 @@ -41,23 +50,44 @@ Ignite Web agent requirements: Options: -h, --help - Print this help message. + Print this help message -c, --config - Path to configuration file + Path to agent property file + Default value: default.properties -d, --driver-folder - Path to folder with JDBC drivers, default value: ./jdbc-drivers + Path to folder with JDBC drivers + Default value: ./jdbc-drivers -n, --node-uri - Comma-separated list of URIs for connect to Ignite REST server, - default value: http://localhost:8080 + Comma-separated list of URIs for connect to Ignite node via REST + Default value: http://localhost:8080 -nl, --node-login - User name that will be used to connect to secured cluster. + User name that will be used to connect to secured cluster -np, --node-password - Password that will be used to connect to secured cluster + Password that will be used to connect to secured cluster -s, --server-uri - URI for connect to Ignite Web Console via web-socket protocol, - default value: http://localhost:3000 + URI for connect to Ignite Console via web-socket protocol + Default value: http://localhost:3000 -t, --tokens - Comma-separated list of user's security tokens. + User's tokens separated by comma used to connect to Ignite Console. + -nks, --node-key-store + Path to key store that will be used to connect to cluster + -nksp, --node-key-store-password + Optional password for node key store + -nts, --node-trust-store + Path to trust store that will be used to connect to cluster + -ntsp, --node-trust-store-password + Optional password for node trust store + -sks, --server-key-store + Path to key store that will be used to connect to Web server + -sksp, --server-key-store-password + Optional password for server key store + -sts, --server-trust-store + Path to trust store that will be used to connect to Web server + -stsp, --server-trust-store-password + Optional password for server trust store + -cs, --cipher-suites + Optional comma-separated list of SSL cipher suites to be used to connect + to server and cluster How to build: To build from sources run following command in Ignite project root folder: diff --git a/modules/web-console/web-agent/pom.xml b/modules/web-console/web-agent/pom.xml index 06778c3aad609..51bcabb0ddcc2 100644 --- a/modules/web-console/web-agent/pom.xml +++ b/modules/web-console/web-agent/pom.xml @@ -43,7 +43,7 @@ io.socket socket.io-client - 0.8.3 + 1.0.0 @@ -55,13 +55,13 @@ com.beust jcommander - 1.48 + 1.58 com.squareup.okhttp3 okhttp - 3.7.0 + 3.12.0 @@ -112,6 +112,18 @@ ignite-web-agent-${project.version} + + + src/test/java + + **/*.java + + + + src/test/resources + + + maven-jar-plugin diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentConfiguration.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentConfiguration.java index bb2a8a2a49f13..6eed5179847ee 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentConfiguration.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentConfiguration.java @@ -17,7 +17,6 @@ package org.apache.ignite.console.agent; -import com.beust.jcommander.Parameter; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; @@ -28,6 +27,8 @@ import java.util.Collections; import java.util.List; import java.util.Properties; +import java.util.stream.Collectors; +import com.beust.jcommander.Parameter; import org.apache.ignite.internal.util.typedef.F; import static java.nio.charset.StandardCharsets.UTF_8; @@ -59,7 +60,7 @@ public class AgentConfiguration { /** */ @Parameter(names = {"-n", "--node-uri"}, - description = "Comma-separated URIs for connect to Ignite node via REST" + + description = "Comma-separated list of URIs for connect to Ignite node via REST" + " " + " Default value: " + DFLT_NODE_URI) private List nodeURIs; @@ -95,6 +96,51 @@ public class AgentConfiguration { " Default value: false") private Boolean disableDemo; + /** */ + @Parameter(names = {"-nks", "--node-key-store"}, + description = "Path to key store that will be used to connect to cluster") + private String nodeKeyStore; + + /** */ + @Parameter(names = {"-nksp", "--node-key-store-password"}, + description = "Optional password for node key store") + private String nodeKeyStorePass; + + /** */ + @Parameter(names = {"-nts", "--node-trust-store"}, + description = "Path to trust store that will be used to connect to cluster") + private String nodeTrustStore; + + /** */ + @Parameter(names = {"-ntsp", "--node-trust-store-password"}, + description = "Optional password for node trust store") + private String nodeTrustStorePass; + + /** */ + @Parameter(names = {"-sks", "--server-key-store"}, + description = "Path to key store that will be used to connect to Web server") + private String srvKeyStore; + + /** */ + @Parameter(names = {"-sksp", "--server-key-store-password"}, + description = "Optional password for server key store") + private String srvKeyStorePass; + + /** */ + @Parameter(names = {"-sts", "--server-trust-store"}, + description = "Path to trust store that will be used to connect to Web server") + private String srvTrustStore; + + /** */ + @Parameter(names = {"-stsp", "--server-trust-store-password"}, + description = "Optional password for server trust store") + private String srvTrustStorePass; + + /** */ + @Parameter(names = {"-cs", "--cipher-suites"}, + description = "Optional comma-separated list of SSL cipher suites to be used to connect to server and cluster") + private List cipherSuites; + /** */ @Parameter(names = {"-h", "--help"}, help = true, description = "Print this help message") private Boolean help; @@ -218,6 +264,132 @@ public void disableDemo(Boolean disableDemo) { this.disableDemo = disableDemo; } + /** + * @return Path to node key store. + */ + public String nodeKeyStore() { + return nodeKeyStore; + } + + /** + * @param nodeKeyStore Path to node key store. + */ + public void nodeKeyStore(String nodeKeyStore) { + this.nodeKeyStore = nodeKeyStore; + } + + /** + * @return Node key store password. + */ + public String nodeKeyStorePassword() { + return nodeKeyStorePass; + } + + /** + * @param nodeKeyStorePass Node key store password. + */ + public void nodeKeyStorePassword(String nodeKeyStorePass) { + this.nodeKeyStorePass = nodeKeyStorePass; + } + + /** + * @return Path to node trust store. + */ + public String nodeTrustStore() { + return nodeTrustStore; + } + + /** + * @param nodeTrustStore Path to node trust store. + */ + public void nodeTrustStore(String nodeTrustStore) { + this.nodeTrustStore = nodeTrustStore; + } + + /** + * @return Node trust store password. + */ + public String nodeTrustStorePassword() { + return nodeTrustStorePass; + } + + /** + * @param nodeTrustStorePass Node trust store password. + */ + public void nodeTrustStorePassword(String nodeTrustStorePass) { + this.nodeTrustStorePass = nodeTrustStorePass; + } + + /** + * @return Path to server key store. + */ + public String serverKeyStore() { + return srvKeyStore; + } + + /** + * @param srvKeyStore Path to server key store. + */ + public void serverKeyStore(String srvKeyStore) { + this.srvKeyStore = srvKeyStore; + } + + /** + * @return Server key store password. + */ + public String serverKeyStorePassword() { + return srvKeyStorePass; + } + + /** + * @param srvKeyStorePass Server key store password. + */ + public void serverKeyStorePassword(String srvKeyStorePass) { + this.srvKeyStorePass = srvKeyStorePass; + } + + /** + * @return Path to server trust store. + */ + public String serverTrustStore() { + return srvTrustStore; + } + + /** + * @param srvTrustStore Path to server trust store. + */ + public void serverTrustStore(String srvTrustStore) { + this.srvTrustStore = srvTrustStore; + } + + /** + * @return Server trust store password. + */ + public String serverTrustStorePassword() { + return srvTrustStorePass; + } + + /** + * @param srvTrustStorePass Server trust store password. + */ + public void serverTrustStorePassword(String srvTrustStorePass) { + this.srvTrustStorePass = srvTrustStorePass; + } + + /** + * @return SSL cipher suites. + */ + public List cipherSuites() { + return cipherSuites; + } + + /** + * @param cipherSuites SSL cipher suites. + */ + public void cipherSuites(List cipherSuites) { + this.cipherSuites = cipherSuites; + } + /** * @return {@code true} If agent options usage should be printed. */ @@ -235,35 +407,81 @@ public void load(URL cfgUrl) throws IOException { props.load(reader); } - String val = (String)props.remove("tokens"); + String val = props.getProperty("tokens"); if (val != null) tokens(new ArrayList<>(Arrays.asList(val.split(",")))); - val = (String)props.remove("server-uri"); + val = props.getProperty("server-uri"); if (val != null) serverUri(val); - val = (String)props.remove("node-uri"); + val = props.getProperty("node-uri"); + // Intentionaly wrapped by ArrayList, for further maniulations. if (val != null) nodeURIs(new ArrayList<>(Arrays.asList(val.split(",")))); - val = (String)props.remove("node-login"); + val = props.getProperty("node-login"); if (val != null) nodeLogin(val); - val = (String)props.remove("node-password"); + val = props.getProperty("node-password"); if (val != null) nodePassword(val); - val = (String)props.remove("driver-folder"); + val = props.getProperty("driver-folder"); if (val != null) driversFolder(val); + + val = props.getProperty("node-key-store"); + + if (val != null) + nodeKeyStore(val); + + val = props.getProperty("node-key-store-password"); + + if (val != null) + nodeKeyStorePassword(val); + + val = props.getProperty("node-trust-store"); + + if (val != null) + nodeTrustStore(val); + + val = props.getProperty("node-trust-store-password"); + + if (val != null) + nodeTrustStorePassword(val); + + val = props.getProperty("server-key-store"); + + if (val != null) + serverKeyStore(val); + + val = props.getProperty("server-key-store-password"); + + if (val != null) + serverKeyStorePassword(val); + + val = props.getProperty("server-trust-store"); + + if (val != null) + serverTrustStore(val); + + val = props.getProperty("server-trust-store-password"); + + if (val != null) + serverTrustStorePassword(val); + + val = props.getProperty("cipher-suites"); + + if (val != null) + cipherSuites(Arrays.asList(val.split(","))); } /** @@ -296,43 +514,66 @@ public void merge(AgentConfiguration cfg) { if (disableDemo == null) disableDemo(cfg.disableDemo()); + + if (nodeKeyStore == null) + nodeKeyStore(cfg.nodeKeyStore()); + + if (nodeKeyStorePass == null) + nodeKeyStorePassword(cfg.nodeKeyStorePassword()); + + if (nodeTrustStore == null) + nodeTrustStore(cfg.nodeTrustStore()); + + if (nodeTrustStorePass == null) + nodeTrustStorePassword(cfg.nodeTrustStorePassword()); + + if (srvKeyStore == null) + serverKeyStore(cfg.serverKeyStore()); + + if (srvKeyStorePass == null) + serverKeyStorePassword(cfg.serverKeyStorePassword()); + + if (srvTrustStore == null) + serverTrustStore(cfg.serverTrustStore()); + + if (srvTrustStorePass == null) + serverTrustStorePassword(cfg.serverTrustStorePassword()); + + if (cipherSuites == null) + cipherSuites(cfg.cipherSuites()); + } + + /** + * @param s String with sensitive data. + * @return Secured string. + */ + private String secured(String s) { + int len = s.length(); + int toShow = len > 4 ? 4 : 1; + + return new String(new char[len - toShow]).replace('\0', '*') + s.substring(len - toShow, len); } /** {@inheritDoc} */ @Override public String toString() { StringBuilder sb = new StringBuilder(); + String nl = System.lineSeparator(); + if (!F.isEmpty(tokens)) { sb.append("User's security tokens : "); - boolean first = true; - - for (String tok : tokens) { - if (first) - first = false; - else - sb.append(','); - - if (tok.length() > 4) { - sb.append(new String(new char[tok.length() - 4]).replace('\0', '*')); - - sb.append(tok.substring(tok.length() - 4)); - } - else - sb.append(new String(new char[tok.length()]).replace('\0', '*')); - } - - sb.append('\n'); + sb.append(tokens.stream().map(this::secured).collect(Collectors.joining(", "))).append(nl); } sb.append("URI to Ignite node REST server : ") - .append(nodeURIs == null ? DFLT_NODE_URI : String.join(", ", nodeURIs)).append('\n'); + .append(nodeURIs == null ? DFLT_NODE_URI : String.join(", ", nodeURIs)).append(nl); if (nodeLogin != null) - sb.append("Login to Ignite node REST server: ").append(nodeLogin).append('\n'); + sb.append("Login to Ignite node REST server: ").append(nodeLogin).append(nl); - sb.append("URI to Ignite Console server : ").append(srvUri == null ? DFLT_SERVER_URI : srvUri).append('\n'); - sb.append("Path to agent property file : ").append(configPath()).append('\n'); + sb.append("URI to Ignite Console server : ").append(srvUri == null ? DFLT_SERVER_URI : srvUri).append(nl); + sb.append("Path to agent property file : ").append(configPath()).append(nl); String drvFld = driversFolder(); @@ -343,8 +584,35 @@ public void merge(AgentConfiguration cfg) { drvFld = new File(agentHome, "jdbc-drivers").getPath(); } - sb.append("Path to JDBC drivers folder : ").append(drvFld).append('\n'); - sb.append("Demo mode : ").append(disableDemo() ? "disabled" : "enabled"); + sb.append("Path to JDBC drivers folder : ").append(drvFld).append(nl); + sb.append("Demo mode : ").append(disableDemo() ? "disabled" : "enabled").append(nl); + + if (!F.isEmpty(nodeKeyStore)) + sb.append("Node key store : ").append(nodeKeyStore).append(nl); + + if (!F.isEmpty(nodeKeyStorePass)) + sb.append("Node key store password : ").append(secured(nodeKeyStorePass)).append(nl); + + if (!F.isEmpty(nodeTrustStore)) + sb.append("Node trust store : ").append(nodeTrustStore).append(nl); + + if (!F.isEmpty(nodeTrustStorePass)) + sb.append("Node trust store password : ").append(secured(nodeTrustStorePass)).append(nl); + + if (!F.isEmpty(srvKeyStore)) + sb.append("Server key store : ").append(srvKeyStore).append(nl); + + if (!F.isEmpty(srvKeyStorePass)) + sb.append("Server key store password : ").append(secured(srvKeyStorePass)).append(nl); + + if (!F.isEmpty(srvTrustStore)) + sb.append("Server trust store : ").append(srvTrustStore).append(nl); + + if (!F.isEmpty(srvTrustStorePass)) + sb.append("Server trust store password : ").append(secured(srvTrustStorePass)).append(nl); + + if (!F.isEmpty(cipherSuites)) + sb.append("Cipher suites : ").append(String.join(", ", cipherSuites)).append(nl); return sb.toString(); } diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java index 579f236536e95..4b42584f58d20 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java @@ -17,12 +17,6 @@ package org.apache.ignite.console.agent; -import com.beust.jcommander.JCommander; -import com.beust.jcommander.ParameterException; -import io.socket.client.Ack; -import io.socket.client.IO; -import io.socket.client.Socket; -import io.socket.emitter.Emitter; import java.io.File; import java.io.IOException; import java.net.Authenticator; @@ -40,9 +34,16 @@ import java.util.concurrent.CountDownLatch; import java.util.jar.Attributes; import java.util.jar.Manifest; -import javax.net.ssl.SSLContext; import javax.net.ssl.SSLHandshakeException; -import javax.net.ssl.TrustManager; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.X509TrustManager; +import com.beust.jcommander.JCommander; +import com.beust.jcommander.ParameterException; +import io.socket.client.Ack; +import io.socket.client.IO; +import io.socket.client.Socket; +import io.socket.emitter.Emitter; +import okhttp3.OkHttpClient; import org.apache.ignite.console.agent.handlers.ClusterListener; import org.apache.ignite.console.agent.handlers.DatabaseListener; import org.apache.ignite.console.agent.handlers.RestListener; @@ -61,6 +62,8 @@ import static io.socket.client.Socket.EVENT_DISCONNECT; import static io.socket.client.Socket.EVENT_ERROR; import static org.apache.ignite.console.agent.AgentUtils.fromJSON; +import static org.apache.ignite.console.agent.AgentUtils.sslConnectionSpec; +import static org.apache.ignite.console.agent.AgentUtils.sslSocketFactory; import static org.apache.ignite.console.agent.AgentUtils.toJSON; import static org.apache.ignite.console.agent.AgentUtils.trustManager; @@ -315,28 +318,84 @@ public static void main(String[] args) throws Exception { return; } + boolean serverTrustAll = Boolean.getBoolean("trust.all"); + boolean hasServerTrustStore = cfg.serverTrustStore() != null; + + if (serverTrustAll && hasServerTrustStore) { + log.warn("Options contains both '--server-trust-store' and '-Dtrust.all=true'. " + + "Option '-Dtrust.all=true' will be ignored on connect to Web server."); + + serverTrustAll = false; + } + + boolean nodeTrustAll = Boolean.getBoolean("trust.all"); + boolean hasNodeTrustStore = cfg.nodeTrustStore() != null; + + if (nodeTrustAll && hasNodeTrustStore) { + log.warn("Options contains both '--node-trust-store' and '-Dtrust.all=true'. " + + "Option '-Dtrust.all=true' will be ignored on connect to cluster."); + + nodeTrustAll = false; + } + cfg.nodeURIs(nodeURIs); IO.Options opts = new IO.Options(); - opts.path = "/agents"; - // Workaround for use self-signed certificate - if (Boolean.getBoolean("trust.all")) { - log.info("Trust to all certificates mode is enabled."); + List cipherSuites = cfg.cipherSuites(); + + if ( + serverTrustAll || + hasServerTrustStore || + cfg.serverKeyStore() != null + ) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + + X509TrustManager serverTrustMgr = trustManager( + serverTrustAll, + cfg.serverTrustStore(), + cfg.serverTrustStorePassword() + ); + + if (serverTrustAll) + builder.hostnameVerifier((hostname, session) -> true); + + SSLSocketFactory sslSocketFactory = sslSocketFactory( + cfg.serverKeyStore(), + cfg.serverKeyStorePassword(), + serverTrustMgr, + cipherSuites + ); + + if (sslSocketFactory != null) { + if (serverTrustMgr != null) + builder.sslSocketFactory(sslSocketFactory, serverTrustMgr); + else + builder.sslSocketFactory(sslSocketFactory); - SSLContext ctx = SSLContext.getInstance("TLS"); + if (!F.isEmpty(cipherSuites)) + builder.connectionSpecs(sslConnectionSpec(cipherSuites)); + } - // Create an SSLContext that uses our TrustManager - ctx.init(null, new TrustManager[] {trustManager()}, null); + OkHttpClient sslFactory = builder.build(); - opts.sslContext = ctx; + opts.callFactory = sslFactory; + opts.webSocketFactory = sslFactory; + opts.secure = true; } final Socket client = IO.socket(uri, opts); - try (RestExecutor restExecutor = new RestExecutor(); - ClusterListener clusterLsnr = new ClusterListener(cfg, client, restExecutor)) { + try ( + RestExecutor restExecutor = new RestExecutor( + nodeTrustAll, + cfg.nodeKeyStore(), cfg.nodeKeyStorePassword(), + cfg.nodeTrustStore(), cfg.nodeTrustStorePassword(), + cipherSuites); + + ClusterListener clusterLsnr = new ClusterListener(cfg, client, restExecutor) + ) { Emitter.Listener onConnect = connectRes -> { log.info("Connection established."); @@ -416,6 +475,7 @@ public static void main(String[] args) throws Exception { }; DatabaseListener dbHnd = new DatabaseListener(cfg); + RestListener restHnd = new RestListener(cfg, restExecutor); final CountDownLatch latch = new CountDownLatch(1); diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentUtils.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentUtils.java index 38edd976850e5..c109da664effb 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentUtils.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentUtils.java @@ -17,16 +17,32 @@ package org.apache.ignite.console.agent; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; -import io.socket.client.Ack; import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.security.GeneralSecurityException; +import java.security.KeyStore; import java.security.ProtectionDomain; import java.security.cert.X509Certificate; import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; +import io.socket.client.Ack; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; +import okhttp3.ConnectionSpec; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.ssl.SSLContextWrapper; import org.apache.log4j.Logger; import org.json.JSONArray; import org.json.JSONObject; @@ -38,6 +54,9 @@ public class AgentUtils { /** */ private static final Logger log = Logger.getLogger(AgentUtils.class.getName()); + /** */ + private static final char[] EMPTY_PWD = new char[0]; + /** JSON object mapper. */ private static final ObjectMapper MAPPER = new ObjectMapper(); @@ -50,7 +69,7 @@ public class AgentUtils { private static final Ack NOOP_CB = new Ack() { @Override public void call(Object... args) { if (args != null && args.length > 0 && args[0] instanceof Throwable) - log.error("Failed to execute request on agent.", (Throwable) args[0]); + log.error("Failed to execute request on agent.", (Throwable)args[0]); else log.info("Request on agent successfully executed " + Arrays.toString(args)); } @@ -186,9 +205,116 @@ public static T fromJSON(Object obj, Class toValType) throws IllegalArgum } /** - * Create a trust manager that trusts all certificates It is not using a particular keyStore + * @param pathToJks Path to java key store file. + * @param pwd Key store password. + * @return Key store. + * @throws GeneralSecurityException If failed to load key store. + * @throws IOException If failed to load key store file content. + */ + private static KeyStore keyStore(String pathToJks, char[] pwd) throws GeneralSecurityException, IOException { + KeyStore keyStore = KeyStore.getInstance("JKS"); + keyStore.load(new FileInputStream(pathToJks), pwd); + + return keyStore; + } + + /** + * @param keyStorePath Path to key store. + * @param keyStorePwd Key store password. + * @return Key managers. + * @throws GeneralSecurityException If failed to load key store. + * @throws IOException If failed to load key store file content. + */ + private static KeyManager[] keyManagers(String keyStorePath, String keyStorePwd) + throws GeneralSecurityException, IOException { + if (keyStorePath == null) + return null; + + char[] keyPwd = keyStorePwd != null ? keyStorePwd.toCharArray() : EMPTY_PWD; + + KeyStore keyStore = keyStore(keyStorePath, keyPwd); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); + kmf.init(keyStore, keyPwd); + + return kmf.getKeyManagers(); + } + + /** + * @param trustAll {@code true} If we trust to self-signed sertificates. + * @param trustStorePath Path to trust store file. + * @param trustStorePwd Trust store password. + * @return Trust manager + * @throws GeneralSecurityException If failed to load trust store. + * @throws IOException If failed to load trust store file content. + */ + public static X509TrustManager trustManager(boolean trustAll, String trustStorePath, String trustStorePwd) + throws GeneralSecurityException, IOException { + if (trustAll) + return disabledTrustManager(); + + if (trustStorePath == null) + return null; + + char[] trustPwd = trustStorePwd != null ? trustStorePwd.toCharArray() : EMPTY_PWD; + KeyStore trustKeyStore = keyStore(trustStorePath, trustPwd); + + TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); + tmf.init(trustKeyStore); + + TrustManager[] trustMgrs = tmf.getTrustManagers(); + + return (X509TrustManager)Arrays.stream(trustMgrs) + .filter(tm -> tm instanceof X509TrustManager) + .findFirst() + .orElseThrow(() -> new IllegalStateException("X509TrustManager manager not found")); + } + + /** + * Create SSL socket factory. + * + * @param keyStorePath Path to key store. + * @param keyStorePwd Key store password. + * @param trustMgr Trust manager. + * @param cipherSuites Optional cipher suites. + * @throws GeneralSecurityException If failed to load trust store. + * @throws IOException If failed to load store file content. + */ + public static SSLSocketFactory sslSocketFactory( + String keyStorePath, String keyStorePwd, + X509TrustManager trustMgr, + List cipherSuites + ) throws GeneralSecurityException, IOException { + KeyManager[] keyMgrs = keyManagers(keyStorePath, keyStorePwd); + + if (keyMgrs == null && trustMgr == null) + return null; + + SSLContext ctx = SSLContext.getInstance("TLS"); + + if (!F.isEmpty(cipherSuites)) + ctx = new SSLContextWrapper(ctx, new SSLParameters(cipherSuites.toArray(new String[0]))); + + ctx.init(keyMgrs, new TrustManager[] {trustMgr}, null); + + return ctx.getSocketFactory(); + } + + /** + * Create SSL configuration. + * + * @param cipherSuites SSL cipher suites. + */ + public static List sslConnectionSpec(List cipherSuites) { + return Collections.singletonList(new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) + .cipherSuites(cipherSuites.toArray(new String[0])) + .build()); + } + + /** + * Create a trust manager that trusts all certificates. */ - public static X509TrustManager trustManager() { + private static X509TrustManager disabledTrustManager() { return new X509TrustManager() { /** {@inheritDoc} */ @Override public X509Certificate[] getAcceptedIssuers() { diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/db/dialect/OracleMetadataDialect.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/db/dialect/OracleMetadataDialect.java index b8b72d5422b94..f7c183f2461d7 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/db/dialect/OracleMetadataDialect.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/db/dialect/OracleMetadataDialect.java @@ -39,7 +39,6 @@ import static java.sql.Types.BIGINT; import static java.sql.Types.BLOB; -import static java.sql.Types.BOOLEAN; import static java.sql.Types.CHAR; import static java.sql.Types.CLOB; import static java.sql.Types.DATE; diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/AbstractListener.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/AbstractListener.java index 33e4c2ba3becb..e0cd5953af485 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/AbstractListener.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/AbstractListener.java @@ -95,12 +95,17 @@ else if (args.length == 1) } cb.call(null, toJSON(res)); - } catch (Exception e) { + } + catch (Throwable e) { + log.error("Failed to process event in pool", e); + cb.call(e, null); } }); } - catch (Exception e) { + catch (Throwable e) { + log.error("Failed to process event", e); + cb.call(e, null); } } diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java index 1c93798b28819..a9f15798ce0b9 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java @@ -74,6 +74,9 @@ public class ClusterListener implements AutoCloseable { /** */ private static final IgniteProductVersion IGNITE_2_3 = IgniteProductVersion.fromString("2.3.0"); + /** Optional Ignite cluster ID. */ + public static final String IGNITE_CLUSTER_ID = "IGNITE_CLUSTER_ID"; + /** Unique Visor key to get events last order. */ private static final String EVT_LAST_ORDER_KEY = "WEB_AGENT_" + UUID.randomUUID().toString(); @@ -89,8 +92,8 @@ public class ClusterListener implements AutoCloseable { /** */ private static final String EVENT_CLUSTER_DISCONNECTED = "cluster:disconnected"; - /** Default timeout. */ - private static final long DFLT_TIMEOUT = 3000L; + /** Topology refresh frequency. */ + private static final long REFRESH_FREQ = 3000L; /** JSON object mapper. */ private static final ObjectMapper MAPPER = new GridJettyObjectMapper(); @@ -113,13 +116,13 @@ public class ClusterListener implements AutoCloseable { }; /** */ - private AgentConfiguration cfg; + private final AgentConfiguration cfg; /** */ - private Socket client; + private final Socket client; /** */ - private RestExecutor restExecutor; + private final RestExecutor restExecutor; /** */ private static final ScheduledExecutorService pool = Executors.newScheduledThreadPool(1); @@ -129,7 +132,7 @@ public class ClusterListener implements AutoCloseable { /** * @param client Client. - * @param restExecutor Client. + * @param restExecutor REST executor. */ public ClusterListener(AgentConfiguration cfg, Socket client, RestExecutor restExecutor) { this.cfg = cfg; @@ -176,7 +179,7 @@ private void safeStopRefresh() { public void watch() { safeStopRefresh(); - refreshTask = pool.scheduleWithFixedDelay(watchTask, 0L, DFLT_TIMEOUT, TimeUnit.MILLISECONDS); + refreshTask = pool.scheduleWithFixedDelay(watchTask, 0L, REFRESH_FREQ, TimeUnit.MILLISECONDS); } /** {@inheritDoc} */ @@ -188,6 +191,9 @@ public void watch() { /** */ private static class TopologySnapshot { + /** */ + private String clusterId; + /** */ private String clusterName; @@ -242,6 +248,9 @@ private static T attribute(Map attrs, String name) { Map attrs = node.getAttributes(); + if (F.isEmpty(clusterId)) + clusterId = attribute(attrs, IGNITE_CLUSTER_ID); + if (F.isEmpty(clusterName)) clusterName = attribute(attrs, IGNITE_CLUSTER_NAME); @@ -268,6 +277,13 @@ private static T attribute(Map attrs, String name) { } } + /** + * @return Cluster id. + */ + public String getClusterId() { + return clusterId; + } + /** * @return Cluster name. */ @@ -352,6 +368,14 @@ Collection nid8() { boolean differentCluster(TopologySnapshot prev) { return prev == null || F.isEmpty(prev.nids) || Collections.disjoint(nids, prev.nids); } + + /** + * @param prev Previous topology. + * @return {@code true} in case if current topology is the same cluster, but topology changed. + */ + boolean topologyChanged(TopologySnapshot prev) { + return prev != null && !prev.nids.equals(nids); + } } /** */ @@ -384,11 +408,11 @@ else if (!F.isEmpty(cfg.nodeLogin()) && !F.isEmpty(cfg.nodePassword())) { sesTok = res.getSessionToken(); return res; - + case STATUS_FAILED: if (res.getError().startsWith(EXPIRED_SES_ERROR_MSG)) { sesTok = null; - + params.remove("sessionToken"); return restCommand(params); @@ -402,14 +426,16 @@ else if (!F.isEmpty(cfg.nodeLogin()) && !F.isEmpty(cfg.nodePassword())) { /** * Collect topology. * - * @param full Full. + * @return REST result. + * @throws IOException If failed to collect topology. */ - private RestResult topology(boolean full) throws IOException { - Map params = U.newHashMap(3); + private RestResult topology() throws IOException { + Map params = U.newHashMap(4); params.put("cmd", "top"); params.put("attr", true); - params.put("mtr", full); + params.put("mtr", false); + params.put("caches", false); return restCommand(params); } @@ -451,55 +477,47 @@ public boolean active(IgniteProductVersion ver, UUID nid) throws IOException { RestResult res = restCommand(params); - switch (res.getStatus()) { - case STATUS_SUCCESS: - if (v23) - return Boolean.valueOf(res.getData()); - - return res.getData().contains("\"active\":true"); + if (res.getStatus() == STATUS_SUCCESS) + return v23 ? Boolean.valueOf(res.getData()) : res.getData().contains("\"active\":true"); - default: - throw new IOException(res.getError()); - } + throw new IOException(res.getError()); } - /** {@inheritDoc} */ @Override public void run() { try { - RestResult res = topology(false); - - switch (res.getStatus()) { - case STATUS_SUCCESS: - List nodes = MAPPER.readValue(res.getData(), - new TypeReference>() {}); + RestResult res = topology(); - TopologySnapshot newTop = new TopologySnapshot(nodes); + if (res.getStatus() == STATUS_SUCCESS) { + List nodes = MAPPER.readValue(res.getData(), + new TypeReference>() {}); - if (newTop.differentCluster(top)) - log.info("Connection successfully established to cluster with nodes: " + newTop.nid8()); + TopologySnapshot newTop = new TopologySnapshot(nodes); - boolean active = active(newTop.clusterVersion(), F.first(newTop.getNids())); + if (newTop.differentCluster(top)) + log.info("Connection successfully established to cluster with nodes: " + newTop.nid8()); + else if (newTop.topologyChanged(top)) + log.info("Cluster topology changed, new topology: " + newTop.nid8()); - newTop.setActive(active); - newTop.setSecured(!F.isEmpty(res.getSessionToken())); + boolean active = active(newTop.clusterVersion(), F.first(newTop.getNids())); - top = newTop; + newTop.setActive(active); + newTop.setSecured(!F.isEmpty(res.getSessionToken())); - client.emit(EVENT_CLUSTER_TOPOLOGY, toJSON(top)); + top = newTop; - break; - - default: - LT.warn(log, res.getError()); + client.emit(EVENT_CLUSTER_TOPOLOGY, toJSON(top)); + } + else { + LT.warn(log, res.getError()); - clusterDisconnect(); + clusterDisconnect(); } } catch (ConnectException ignored) { clusterDisconnect(); } - catch (Exception e) { + catch (Throwable e) { log.error("WatchTask failed", e); clusterDisconnect(); diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java index 24c2097531c6a..0db8904da234b 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java @@ -24,6 +24,7 @@ import org.apache.ignite.console.agent.rest.RestExecutor; import org.apache.ignite.console.agent.rest.RestResult; import org.apache.ignite.console.demo.AgentClusterDemo; +import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; /** @@ -38,7 +39,7 @@ public class RestListener extends AbstractListener { /** * @param cfg Config. - * @param restExecutor Executor. + * @param restExecutor REST executor. */ public RestListener(AgentConfiguration cfg, RestExecutor restExecutor) { this.cfg = cfg; @@ -65,6 +66,9 @@ public RestListener(AgentConfiguration cfg, RestExecutor restExecutor) { boolean demo = (boolean)args.get("demo"); + if (F.isEmpty((String)args.get("token"))) + return RestResult.fail(401, "Request does not contain user token."); + Map headers = null; if (args.containsKey("headers")) diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java index bb06c32579b86..d5f2c1e5d9d4b 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java @@ -20,11 +20,10 @@ import java.io.IOException; import java.io.StringWriter; import java.net.ConnectException; +import java.security.GeneralSecurityException; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; @@ -33,6 +32,8 @@ import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.X509TrustManager; import okhttp3.Dispatcher; import okhttp3.FormBody; import okhttp3.HttpUrl; @@ -41,6 +42,7 @@ import okhttp3.Response; import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyObjectMapper; +import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.logger.slf4j.Slf4jLogger; @@ -49,6 +51,8 @@ import static com.fasterxml.jackson.core.JsonToken.END_ARRAY; import static com.fasterxml.jackson.core.JsonToken.END_OBJECT; import static com.fasterxml.jackson.core.JsonToken.START_ARRAY; +import static org.apache.ignite.console.agent.AgentUtils.sslConnectionSpec; +import static org.apache.ignite.console.agent.AgentUtils.sslSocketFactory; import static org.apache.ignite.console.agent.AgentUtils.trustManager; import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_AUTH_FAILED; import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_FAILED; @@ -68,14 +72,30 @@ public class RestExecutor implements AutoCloseable { private final OkHttpClient httpClient; /** Index of alive node URI. */ - private Map, Integer> startIdxs = U.newHashMap(2); + private final Map, Integer> startIdxs = U.newHashMap(2); /** - * Default constructor. + * Constructor. + * + * @param trustAll {@code true} If we trust to self-signed sertificates. + * @param keyStorePath Optional path to key store file. + * @param keyStorePwd Optional password for key store. + * @param trustStorePath Optional path to trust store file. + * @param trustStorePwd Optional password for trust store. + * @param cipherSuites Optional cipher suites. + * @throws GeneralSecurityException If failed to initialize SSL. + * @throws IOException If failed to load content of key stores. */ - public RestExecutor() { + public RestExecutor( + boolean trustAll, + String keyStorePath, + String keyStorePwd, + String trustStorePath, + String trustStorePwd, + List cipherSuites + ) throws GeneralSecurityException, IOException { Dispatcher dispatcher = new Dispatcher(); - + dispatcher.setMaxRequests(Integer.MAX_VALUE); dispatcher.setMaxRequestsPerHost(Integer.MAX_VALUE); @@ -83,20 +103,25 @@ public RestExecutor() { .readTimeout(0, TimeUnit.MILLISECONDS) .dispatcher(dispatcher); - // Workaround for use self-signed certificate - if (Boolean.getBoolean("trust.all")) { - try { - SSLContext ctx = SSLContext.getInstance("TLS"); + X509TrustManager trustMgr = trustManager(trustAll, trustStorePath, trustStorePwd); - // Create an SSLContext that uses our TrustManager - ctx.init(null, new TrustManager[] {trustManager()}, null); + if (trustAll) + builder.hostnameVerifier((hostname, session) -> true); - builder.sslSocketFactory(ctx.getSocketFactory(), trustManager()); + SSLSocketFactory sslSocketFactory = sslSocketFactory( + keyStorePath, keyStorePwd, + trustMgr, + cipherSuites + ); - builder.hostnameVerifier((hostname, session) -> true); - } catch (Exception ignored) { - LT.warn(log, "Failed to initialize the Trust Manager for \"-Dtrust.all\" option to skip certificate validation."); - } + if (sslSocketFactory != null) { + if (trustMgr != null) + builder.sslSocketFactory(sslSocketFactory, trustMgr); + else + builder.sslSocketFactory(sslSocketFactory); + + if (!F.isEmpty(cipherSuites)) + builder.connectionSpecs(sslConnectionSpec(cipherSuites)); } httpClient = builder.build(); @@ -120,13 +145,10 @@ private RestResult parseResponse(Response res) throws IOException { int status = holder.getSuccessStatus(); - switch (status) { - case STATUS_SUCCESS: - return RestResult.success(holder.getResponse(), holder.getSessionToken()); + if (status == STATUS_SUCCESS) + return RestResult.success(holder.getResponse(), holder.getSessionToken()); - default: - return RestResult.fail(status, holder.getError()); - } + return RestResult.fail(status, holder.getError()); } if (res.code() == 401) @@ -136,15 +158,16 @@ private RestResult parseResponse(Response res) throws IOException { if (res.code() == 404) return RestResult.fail(STATUS_FAILED, "Failed connect to cluster."); - return RestResult.fail(STATUS_FAILED, "Failed to execute REST command: " + res.message()); + return RestResult.fail(STATUS_FAILED, "Failed to execute REST command: " + res); } /** */ private RestResult sendRequest(String url, Map params, Map headers) throws IOException { - HttpUrl httpUrl = HttpUrl.parse(url); - - HttpUrl.Builder urlBuilder = httpUrl.newBuilder() - .addPathSegment("ignite"); + HttpUrl httpUrl = HttpUrl + .parse(url) + .newBuilder() + .addPathSegment("ignite") + .build(); final Request.Builder reqBuilder = new Request.Builder(); @@ -163,26 +186,43 @@ private RestResult sendRequest(String url, Map params, Map nodeURIs, Map params, Map headers) throws IOException { + /** + * Send request to cluster. + * + * @param nodeURIs List of cluster nodes URIs. + * @param params Map with reques params. + * @param headers Map with reques headers. + * @return Response from cluster. + * @throws IOException If failed to send request to cluster. + */ + public RestResult sendRequest( + List nodeURIs, + Map params, + Map headers + ) throws IOException { Integer startIdx = startIdxs.getOrDefault(nodeURIs, 0); - for (int i = 0; i < nodeURIs.size(); i++) { - Integer currIdx = (startIdx + i) % nodeURIs.size(); + int urlsCnt = nodeURIs.size(); + + for (int i = 0; i < urlsCnt; i++) { + Integer currIdx = (startIdx + i) % urlsCnt; String nodeUrl = nodeURIs.get(currIdx); try { RestResult res = sendRequest(nodeUrl, params, headers); + // If first attempt failed then throttling should be cleared. + if (i > 0) + LT.clear(); + LT.info(log, "Connected to cluster [url=" + nodeUrl + "]"); startIdxs.put(nodeURIs, currIdx); @@ -190,7 +230,7 @@ public RestResult sendRequest(List nodeURIs, Map params, return res; } catch (ConnectException ignored) { - // No-op. + LT.warn(log, "Failed connect to cluster [url=" + nodeUrl + "]"); } } @@ -268,10 +308,10 @@ public String getSessionToken() { } /** - * @param sesTokStr String representation of session token. + * @param sesTok String representation of session token. */ - public void setSessionToken(String sesTokStr) { - this.sesTok = sesTokStr; + public void setSessionToken(String sesTok) { + this.sesTok = sesTok; } } diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoComputeLoadService.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoComputeLoadService.java index e775a9a6dd337..3c767c85dac91 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoComputeLoadService.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoComputeLoadService.java @@ -17,7 +17,6 @@ package org.apache.ignite.console.demo.service; -import java.util.Random; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.apache.ignite.Ignite; diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoRandomCacheLoadService.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoRandomCacheLoadService.java index e6242fcc91d37..5b73e9660b9a0 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoRandomCacheLoadService.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoRandomCacheLoadService.java @@ -29,6 +29,8 @@ import org.apache.ignite.services.Service; import org.apache.ignite.services.ServiceContext; +import static org.apache.ignite.internal.processors.query.QueryUtils.DFLT_SCHEMA; + /** * Demo service. Create cache and populate it by random int pairs. */ @@ -78,19 +80,19 @@ public DemoRandomCacheLoadService(int cnt) { @Override public void run() { try { for (String cacheName : ignite.cacheNames()) { - if (!DemoCachesLoadService.DEMO_CACHES.contains(cacheName)) { - IgniteCache cache = ignite.cache(cacheName); + IgniteCache cache = ignite.cache(cacheName); - if (cache != null) { - for (int i = 0, n = 1; i < cnt; i++, n++) { - Integer key = rnd.nextInt(RND_CNT); - Integer val = rnd.nextInt(RND_CNT); + if (cache != null && + !DemoCachesLoadService.DEMO_CACHES.contains(cacheName) && + !DFLT_SCHEMA.equalsIgnoreCase(cache.getConfiguration(CacheConfiguration.class).getSqlSchema())) { + for (int i = 0, n = 1; i < cnt; i++, n++) { + Integer key = rnd.nextInt(RND_CNT); + Integer val = rnd.nextInt(RND_CNT); - cache.put(key, val); + cache.put(key, val); - if (rnd.nextInt(100) < 30) - cache.remove(key); - } + if (rnd.nextInt(100) < 30) + cache.remove(key); } } } diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/task/DemoComputeTask.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/task/DemoComputeTask.java index 14f2508d82e9b..7dba1b73465c8 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/task/DemoComputeTask.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/task/DemoComputeTask.java @@ -22,7 +22,6 @@ import java.util.Map; import java.util.Random; import org.apache.ignite.IgniteException; -import org.apache.ignite.IgniteInterruptedException; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.compute.ComputeJob; import org.apache.ignite.compute.ComputeJobAdapter; diff --git a/modules/web-console/web-agent/src/test/java/org/apache/ignite/console/agent/rest/RestExecutorSelfTest.java b/modules/web-console/web-agent/src/test/java/org/apache/ignite/console/agent/rest/RestExecutorSelfTest.java new file mode 100644 index 0000000000000..dcf53f24be228 --- /dev/null +++ b/modules/web-console/web-agent/src/test/java/org/apache/ignite/console/agent/rest/RestExecutorSelfTest.java @@ -0,0 +1,330 @@ +/* + * 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. + */ + +package org.apache.ignite.console.agent.rest; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLHandshakeException; +import org.apache.ignite.Ignite; +import org.apache.ignite.Ignition; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.ConnectorConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyObjectMapper; +import org.apache.ignite.internal.util.IgniteUtils; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * Test for RestExecutor. + */ +public class RestExecutorSelfTest { + /** Name of the cache created by default in the cluster. */ + private static final String DEFAULT_CACHE_NAME = "default"; + + /** Path to certificates and configs. */ + private static final String PATH_TO_RESOURCES = "modules/web-console/web-agent/src/test/resources/"; + + /** JSON object mapper. */ + private static final ObjectMapper MAPPER = new GridJettyObjectMapper(); + + /** */ + private static final String HTTP_URI = "http://localhost:8080"; + + /** */ + private static final String HTTPS_URI = "https://localhost:8080"; + + /** */ + private static final String JETTY_WITH_SSL = "jetty-with-ssl.xml"; + + /** */ + private static final String JETTY_WITH_CIPHERS_0 = "jetty-with-ciphers-0.xml"; + + /** */ + private static final String JETTY_WITH_CIPHERS_1 = "jetty-with-ciphers-1.xml"; + + /** */ + private static final String JETTY_WITH_CIPHERS_2 = "jetty-with-ciphers-2.xml"; + + /** This cipher is disabled by default in JDK 8. */ + private static final List CIPHER_0 = Collections.singletonList("TLS_DH_anon_WITH_AES_256_GCM_SHA384"); + + /** */ + private static final List CIPHER_1 = Collections.singletonList("TLS_RSA_WITH_NULL_SHA256"); + + /** */ + private static final List CIPHER_2 = Collections.singletonList("TLS_ECDHE_ECDSA_WITH_NULL_SHA"); + + /** */ + private static final List COMMON_CIPHERS = Arrays.asList( + "TLS_RSA_WITH_NULL_SHA256", + "TLS_ECDHE_ECDSA_WITH_NULL_SHA" + ); + + /** */ + @Rule + public final ExpectedException ruleForExpectedException = ExpectedException.none(); + + /** + * @param jettyCfg Optional path to file with Jetty XML config. + * @return Prepare configuration for cluster node. + */ + private IgniteConfiguration nodeConfiguration(String jettyCfg) { + TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); + + ipFinder.registerAddresses(Collections.singletonList(new InetSocketAddress("127.0.0.1", 47500))); + + TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi(); + + discoverySpi.setIpFinder(ipFinder); + + IgniteConfiguration cfg = new IgniteConfiguration(); + + cfg.setDiscoverySpi(discoverySpi); + + CacheConfiguration dfltCacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); + + cfg.setCacheConfiguration(dfltCacheCfg); + + cfg.setIgniteInstanceName(UUID.randomUUID().toString()); + + if (!F.isEmpty(jettyCfg)) { + ConnectorConfiguration conCfg = new ConnectorConfiguration(); + conCfg.setJettyPath(resolvePath(jettyCfg)); + + cfg.setConnectorConfiguration(conCfg); + } + + return cfg; + } + + /** + * Convert response to JSON. + * + * @param res REST result. + * @return JSON object. + * @throws IOException If failed to parse. + */ + private JsonNode toJson(RestResult res) throws IOException { + Assert.assertNotNull(res); + + String data = res.getData(); + + Assert.assertNotNull(data); + Assert.assertFalse(data.isEmpty()); + + return MAPPER.readTree(data); + } + + /** + * @param file File name. + * @return Path to file. + */ + private String resolvePath(String file) { + return IgniteUtils.resolveIgnitePath(PATH_TO_RESOURCES + file).getAbsolutePath(); + } + + /** + * Try to execute REST command and check response. + * + * @param nodeCfg Node configuration. + * @param uri Node URI. + * @param keyStore Key store. + * @param keyStorePwd Key store password. + * @param trustStore Trust store. + * @param trustStorePwd Trust store password. + * @param cipherSuites Cipher suites. + * @throws Exception If failed. + */ + private void checkRest( + IgniteConfiguration nodeCfg, + String uri, + String keyStore, + String keyStorePwd, + String trustStore, + String trustStorePwd, + List cipherSuites + ) throws Exception { + try( + Ignite ignite = Ignition.getOrStart(nodeCfg); + RestExecutor exec = new RestExecutor(false, keyStore, keyStorePwd, trustStore, trustStorePwd, cipherSuites) + ) { + Map params = new HashMap<>(); + params.put("cmd", "top"); + params.put("attr", false); + params.put("mtr", false); + params.put("caches", false); + + RestResult res = exec.sendRequest(Collections.singletonList(uri), params, null); + + JsonNode json = toJson(res); + + Assert.assertTrue(json.isArray()); + + for (JsonNode item : json) { + Assert.assertTrue(item.get("attributes").isNull()); + Assert.assertTrue(item.get("metrics").isNull()); + Assert.assertTrue(item.get("caches").isNull()); + } + } + } + + /** */ + @Test + public void nodeNoSslAgentNoSsl() throws Exception { + checkRest( + nodeConfiguration(""), + HTTP_URI, + null, null, + null, null, + null + ); + } + + /** */ + @Test + public void nodeNoSslAgentWithSsl() throws Exception { + // Check Web Agent with SSL. + ruleForExpectedException.expect(SSLException.class); + checkRest( + nodeConfiguration(""), + HTTPS_URI, + resolvePath("client.jks"), "123456", + resolvePath("ca.jks"), "123456", + null + ); + } + + /** */ + @Test + public void nodeWithSslAgentNoSsl() throws Exception { + ruleForExpectedException.expect(IOException.class); + checkRest( + nodeConfiguration(JETTY_WITH_SSL), + HTTP_URI, + null, null, + null, null, + null + ); + } + + /** */ + @Test + public void nodeWithSslAgentWithSsl() throws Exception { + checkRest( + nodeConfiguration(JETTY_WITH_SSL), + HTTPS_URI, + resolvePath("client.jks"), "123456", + resolvePath("ca.jks"), "123456", + null + ); + } + + /** */ + @Test + public void nodeNoCiphersAgentWithCiphers() throws Exception { + ruleForExpectedException.expect(SSLHandshakeException.class); + checkRest( + nodeConfiguration(JETTY_WITH_SSL), + HTTPS_URI, + resolvePath("client.jks"), "123456", + resolvePath("ca.jks"), "123456", + CIPHER_0 + ); + } + + /** */ + @Test + public void nodeWithCiphersAgentNoCiphers() throws Exception { + ruleForExpectedException.expect(SSLHandshakeException.class); + checkRest( + nodeConfiguration(JETTY_WITH_CIPHERS_0), + HTTPS_URI, + resolvePath("client.jks"), "123456", + resolvePath("ca.jks"), "123456", + null + ); + } + + /** */ + @Test + public void nodeWithCiphersAgentWithCiphers() throws Exception { + checkRest( + nodeConfiguration(JETTY_WITH_CIPHERS_1), + HTTPS_URI, + resolvePath("client.jks"), "123456", + resolvePath("ca.jks"), "123456", + CIPHER_1 + ); + } + + /** */ + @Test + public void differentCiphers1() throws Exception { + ruleForExpectedException.expect(SSLHandshakeException.class); + checkRest( + nodeConfiguration(JETTY_WITH_CIPHERS_1), + HTTPS_URI, + resolvePath("client.jks"), "123456", + resolvePath("ca.jks"), "123456", + CIPHER_2 + ); + } + + /** */ + @Test + public void differentCiphers2() throws Exception { + ruleForExpectedException.expect(SSLException.class); + checkRest( + nodeConfiguration(JETTY_WITH_CIPHERS_2), + HTTPS_URI, + resolvePath("client.jks"), "123456", + resolvePath("ca.jks"), "123456", + CIPHER_1 + ); + } + + /** */ + @Test + public void commonCiphers() throws Exception { + checkRest( + nodeConfiguration(JETTY_WITH_CIPHERS_1), + HTTPS_URI, + resolvePath("client.jks"), "123456", + resolvePath("ca.jks"), "123456", + COMMON_CIPHERS + ); + } +} diff --git a/modules/web-console/web-agent/src/test/java/org/apache/ignite/testsuites/IgniteWebAgentTestSuite.java b/modules/web-console/web-agent/src/test/java/org/apache/ignite/testsuites/IgniteWebAgentTestSuite.java new file mode 100644 index 0000000000000..d0bc23841a8d0 --- /dev/null +++ b/modules/web-console/web-agent/src/test/java/org/apache/ignite/testsuites/IgniteWebAgentTestSuite.java @@ -0,0 +1,33 @@ +/* + * 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. + */ + +package org.apache.ignite.testsuites; + +import org.apache.ignite.console.agent.rest.RestExecutorSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Web Agent tests. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + RestExecutorSelfTest.class +}) +public class IgniteWebAgentTestSuite { + // No-op. +} diff --git a/modules/web-console/web-agent/src/test/resources/ca.jks b/modules/web-console/web-agent/src/test/resources/ca.jks new file mode 100644 index 0000000000000..9d50bcb2d9618 Binary files /dev/null and b/modules/web-console/web-agent/src/test/resources/ca.jks differ diff --git a/modules/web-console/web-agent/src/test/resources/client.jks b/modules/web-console/web-agent/src/test/resources/client.jks new file mode 100644 index 0000000000000..197c75b6d0acf Binary files /dev/null and b/modules/web-console/web-agent/src/test/resources/client.jks differ diff --git a/modules/web-console/web-agent/src/test/resources/generate.bat b/modules/web-console/web-agent/src/test/resources/generate.bat new file mode 100644 index 0000000000000..7bc87f15d006e --- /dev/null +++ b/modules/web-console/web-agent/src/test/resources/generate.bat @@ -0,0 +1,122 @@ +:: +:: 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. +:: + +:: +:: SSL certificates generation. +:: + +:: +:: Preconditions: +:: 1. If needed, download Open SSL for Windows from "https://wiki.openssl.org/index.php/Binaries". +:: and unpack it to some folder. +:: 2. If needed, install JDK 8 or newer. We need "keytool" from "JDK/bin." +:: 3. Create "openssl.cnf" in some folder. +:: You may use "https://github.com/openssl/openssl/blob/master/apps/openssl.cnf" as template. +:: 4. If needed, add "opensll" & "keytool" to PATH variable. +:: +:: NOTE: In case of custom SERVER_DOMAIN_NAME you may need to tweak your "etc/hosts" file. +:: + +:: Set Open SSL variables. +set RANDFILE=_path_where_open_ssl_was_unpacked\.rnd +set OPENSSL_CONF=_path_where_open_ssl_was_unpacked\openssl.cnf + +:: Certificates password. +set PWD=p123456 + +:: Server. +set SERVER_DOMAIN_NAME=localhost +set SERVER_EMAIL=support@test.com + +:: Client. +set CLIENT_DOMAIN_NAME=localhost +set CLIENT_EMAIL=client@test.com + +:: Cleanup. +del server.* +del client.* +del ca.* + +:: Generate server config. +( +echo [req] +echo prompt = no +echo distinguished_name = dn +echo req_extensions = req_ext + +echo [ dn ] +echo countryName = RU +echo stateOrProvinceName = Test +echo localityName = Test +echo organizationName = Apache +echo commonName = %SERVER_DOMAIN_NAME% +echo organizationalUnitName = IT +echo emailAddress = %SERVER_EMAIL% + +echo [ req_ext ] +echo subjectAltName = @alt_names + +echo [ alt_names ] +echo DNS.1 = %SERVER_DOMAIN_NAME% +) > "server.cnf" + +:: Generate client config. +( +echo [req] +echo prompt = no +echo distinguished_name = dn +echo req_extensions = req_ext + +echo [ dn ] +echo countryName = RU +echo stateOrProvinceName = Test +echo localityName = Test +echo organizationName = Apache +echo commonName = %CLIENT_DOMAIN_NAME% +echo organizationalUnitName = IT +echo emailAddress = %CLIENT_EMAIL% + +echo [ req_ext ] +echo subjectAltName = @alt_names + +echo [ alt_names ] +echo DNS.1 = %CLIENT_DOMAIN_NAME% +) > "client.cnf" + +:: Generate certificates. +openssl genrsa -des3 -passout pass:%PWD% -out server.key 1024 +openssl req -new -passin pass:%PWD% -key server.key -config server.cnf -out server.csr + +openssl req -new -newkey rsa:1024 -nodes -keyout ca.key -x509 -days 365 -config server.cnf -out ca.crt + +openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -extensions req_ext -extfile server.cnf -out server.crt +openssl rsa -passin pass:%PWD% -in server.key -out server.nopass.key + +openssl req -new -utf8 -nameopt multiline,utf8 -newkey rsa:1024 -nodes -keyout client.key -config client.cnf -out client.csr +openssl x509 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 02 -out client.crt + +openssl pkcs12 -export -in server.crt -inkey server.key -certfile server.crt -out server.p12 -passin pass:%PWD% -passout pass:%PWD% +openssl pkcs12 -export -in client.crt -inkey client.key -certfile ca.crt -out client.p12 -passout pass:%PWD% +openssl pkcs12 -export -in ca.crt -inkey ca.key -certfile ca.crt -out ca.p12 -passout pass:%PWD% + +keytool -importkeystore -srckeystore server.p12 -srcstoretype PKCS12 -destkeystore server.jks -deststoretype JKS -noprompt -srcstorepass %PWD% -deststorepass %PWD% +keytool -importkeystore -srckeystore client.p12 -srcstoretype PKCS12 -destkeystore client.jks -deststoretype JKS -noprompt -srcstorepass %PWD% -deststorepass %PWD% +keytool -importkeystore -srckeystore ca.p12 -srcstoretype PKCS12 -destkeystore ca.jks -deststoretype JKS -noprompt -srcstorepass %PWD% -deststorepass %PWD% + +openssl x509 -text -noout -in server.crt +openssl x509 -text -noout -in client.crt +openssl x509 -text -noout -in ca.crt diff --git a/modules/web-console/web-agent/src/test/resources/generate.sh b/modules/web-console/web-agent/src/test/resources/generate.sh new file mode 100644 index 0000000000000..95e62c395702a --- /dev/null +++ b/modules/web-console/web-agent/src/test/resources/generate.sh @@ -0,0 +1,111 @@ +#!/usr/bin/env bash +# +# 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. +# + +# +# SSL certificates generation. +# + +# +# Preconditions: +# 1. If needed, install Open SSL (for example: "sudo apt-get install openssl") +# 2. If needed, install JDK 8 or newer. We need "keytool" from "JDK/bin". +# 3. Create "openssl.cnf" in some folder (for example: "/opt/openssl"). +# You may use "https://github.com/openssl/openssl/blob/master/apps/openssl.cnf" as template. +# 4. If needed, add "opensll" & "keytool" to PATH variable. +# +# NOTE: In case of custom SERVER_DOMAIN_NAME you may need to tweak your "etc/hosts" file. +# + +set -x + +# Set Open SSL variables. +OPENSSL_CONF=/opt/openssl/openssl.cnf + +# Certificates password. +PWD=p123456 + +# Server. +SERVER_DOMAIN_NAME=localhost +SERVER_EMAIL=support@test.local + +# Client. +CLIENT_DOMAIN_NAME=localhost +CLIENT_EMAIL=client@test.local + +# Cleanup. +rm -vf server.* +rm -vf client.* +rm -vf ca.* + +# Generate server config. +cat << EOF > server.cnf +[req] +prompt = no +distinguished_name = dn +req_extensions = req_ext +[ dn ] +countryName = RU +stateOrProvinceName = Moscow +localityName = Moscow +organizationName = test +commonName = ${SERVER_DOMAIN_NAME} +organizationalUnitName = IT +emailAddress = ${SERVER_EMAIL} +[ req_ext ] +subjectAltName = @alt_names +[ alt_names ] +DNS.1 = ${SERVER_DOMAIN_NAME} +EOF + +# Generate client config. +cat << EOF > client.cnf +[req] +prompt = no +distinguished_name = dn +req_extensions = req_ext +[ dn ] +countryName = RU +stateOrProvinceName = Moscow +localityName = Moscow +organizationName = test +commonName = ${CLIENT_DOMAIN_NAME} +organizationalUnitName = IT +emailAddress = ${CLIENT_EMAIL} +[ req_ext ] +subjectAltName = @alt_names +[ alt_names ] +DNS.1 = ${CLIENT_DOMAIN_NAME} +EOF + +# Generate certificates. +openssl genrsa -des3 -passout pass:${PWD} -out server.key 1024 +openssl req -new -passin pass:${PWD} -key server.key -config server.cnf -out server.csr +openssl req -new -newkey rsa:1024 -nodes -keyout ca.key -x509 -days 365 -config server.cnf -out ca.crt +openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -extensions req_ext -extfile server.cnf -out server.crt +openssl rsa -passin pass:${PWD} -in server.key -out server.nopass.key +openssl req -new -utf8 -nameopt multiline,utf8 -newkey rsa:1024 -nodes -keyout client.key -config client.cnf -out client.csr +openssl x509 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 02 -out client.crt +openssl pkcs12 -export -in server.crt -inkey server.key -certfile server.crt -out server.p12 -passin pass:${PWD} -passout pass:${PWD} +openssl pkcs12 -export -in client.crt -inkey client.key -certfile ca.crt -out client.p12 -passout pass:${PWD} +openssl pkcs12 -export -in ca.crt -inkey ca.key -certfile ca.crt -out ca.p12 -passout pass:${PWD} +keytool -importkeystore -srckeystore server.p12 -srcstoretype PKCS12 -destkeystore server.jks -deststoretype JKS -noprompt -srcstorepass ${PWD} -deststorepass ${PWD} +keytool -importkeystore -srckeystore client.p12 -srcstoretype PKCS12 -destkeystore client.jks -deststoretype JKS -noprompt -srcstorepass ${PWD} -deststorepass ${PWD} +keytool -importkeystore -srckeystore ca.p12 -srcstoretype PKCS12 -destkeystore ca.jks -deststoretype JKS -noprompt -srcstorepass ${PWD} -deststorepass ${PWD} +openssl x509 -text -noout -in server.crt +openssl x509 -text -noout -in client.crt +openssl x509 -text -noout -in ca.crt diff --git a/modules/web-console/web-agent/src/test/resources/jetty-with-ciphers-0.xml b/modules/web-console/web-agent/src/test/resources/jetty-with-ciphers-0.xml new file mode 100644 index 0000000000000..40f08b552d97d --- /dev/null +++ b/modules/web-console/web-agent/src/test/resources/jetty-with-ciphers-0.xml @@ -0,0 +1,94 @@ + + + + + + + + + 5 + 10 + + + + + https + + true + true + + + + + + + modules/web-console/web-agent/src/test/resources/server.jks + 123456 + modules/web-console/web-agent/src/test/resources/ca.jks + 123456 + true + + + TLS_DH_anon_WITH_AES_256_GCM_SHA384 + + + + + + + + + + + + + + + + http/1.1 + + + + + + + + + + + + 30000 + true + + + + + + + + + + + + + + + + + false + diff --git a/modules/web-console/web-agent/src/test/resources/jetty-with-ciphers-1.xml b/modules/web-console/web-agent/src/test/resources/jetty-with-ciphers-1.xml new file mode 100644 index 0000000000000..cb3a293d5b796 --- /dev/null +++ b/modules/web-console/web-agent/src/test/resources/jetty-with-ciphers-1.xml @@ -0,0 +1,94 @@ + + + + + + + + + 5 + 10 + + + + + https + + true + true + + + + + + + modules/web-console/web-agent/src/test/resources/server.jks + 123456 + modules/web-console/web-agent/src/test/resources/ca.jks + 123456 + true + + + TLS_RSA_WITH_NULL_SHA256 + + + + + + + + + + + + + + + + http/1.1 + + + + + + + + + + + + 30000 + true + + + + + + + + + + + + + + + + + false + diff --git a/modules/web-console/web-agent/src/test/resources/jetty-with-ciphers-2.xml b/modules/web-console/web-agent/src/test/resources/jetty-with-ciphers-2.xml new file mode 100644 index 0000000000000..2251de26716ea --- /dev/null +++ b/modules/web-console/web-agent/src/test/resources/jetty-with-ciphers-2.xml @@ -0,0 +1,94 @@ + + + + + + + + + 5 + 10 + + + + + https + + true + true + + + + + + + modules/web-console/web-agent/src/test/resources/server.jks + 123456 + modules/web-console/web-agent/src/test/resources/ca.jks + 123456 + true + + + TLS_ECDHE_ECDSA_WITH_NULL_SHA + + + + + + + + + + + + + + + + http/1.1 + + + + + + + + + + + + 30000 + true + + + + + + + + + + + + + + + + + false + diff --git a/modules/web-console/web-agent/src/test/resources/jetty-with-ssl.xml b/modules/web-console/web-agent/src/test/resources/jetty-with-ssl.xml new file mode 100644 index 0000000000000..7e0682943a66c --- /dev/null +++ b/modules/web-console/web-agent/src/test/resources/jetty-with-ssl.xml @@ -0,0 +1,89 @@ + + + + + + + + + 5 + 10 + + + + + https + + true + true + + + + + + + modules/web-console/web-agent/src/test/resources/server.jks + 123456 + modules/web-console/web-agent/src/test/resources/ca.jks + 123456 + true + + + + + + + + + + + + + + http/1.1 + + + + + + + + + + + + 30000 + true + + + + + + + + + + + + + + + + + false + diff --git a/modules/web-console/web-agent/src/test/resources/server.jks b/modules/web-console/web-agent/src/test/resources/server.jks new file mode 100644 index 0000000000000..c673bb0c8d657 Binary files /dev/null and b/modules/web-console/web-agent/src/test/resources/server.jks differ diff --git a/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java b/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java index e1d5c3b757be6..86ad9f54c322b 100644 --- a/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java +++ b/modules/web/src/test/java/org/apache/ignite/internal/websession/IgniteWebSessionSelfTestSuite.java @@ -17,36 +17,38 @@ package org.apache.ignite.internal.websession; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.IgniteTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; import static org.apache.ignite.IgniteSystemProperties.IGNITE_OVERRIDE_MCAST_GRP; /** * Test suite for web sessions caching functionality. */ -@SuppressWarnings("PublicInnerClass") -public class IgniteWebSessionSelfTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteWebSessionSelfTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new IgniteTestSuite("Ignite Web Sessions Test Suite"); - suite.addTestSuite(WebSessionSelfTest.class); - suite.addTestSuite(WebSessionTransactionalSelfTest.class); - suite.addTestSuite(WebSessionReplicatedSelfTest.class); + suite.addTest(new JUnit4TestAdapter(WebSessionSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(WebSessionTransactionalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(WebSessionReplicatedSelfTest.class)); // Old implementation tests. - suite.addTestSuite(WebSessionV1SelfTest.class); - suite.addTestSuite(WebSessionTransactionalV1SelfTest.class); - suite.addTestSuite(WebSessionReplicatedV1SelfTest.class); + suite.addTest(new JUnit4TestAdapter(WebSessionV1SelfTest.class)); + suite.addTest(new JUnit4TestAdapter(WebSessionTransactionalV1SelfTest.class)); + suite.addTest(new JUnit4TestAdapter(WebSessionReplicatedV1SelfTest.class)); System.setProperty(IGNITE_OVERRIDE_MCAST_GRP, GridTestUtils.getNextMulticastGroup(IgniteWebSessionSelfTestSuite.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/web/src/test/java/org/apache/ignite/internal/websession/WebSessionSelfTest.java b/modules/web/src/test/java/org/apache/ignite/internal/websession/WebSessionSelfTest.java index 269b27320da36..bed35c1b60083 100644 --- a/modules/web/src/test/java/org/apache/ignite/internal/websession/WebSessionSelfTest.java +++ b/modules/web/src/test/java/org/apache/ignite/internal/websession/WebSessionSelfTest.java @@ -46,18 +46,22 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.testsuites.IgniteIgnore; import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.webapp.WebAppContext; import org.jetbrains.annotations.Nullable; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; /** * Tests the correctness of web sessions caching functionality. */ +@RunWith(JUnit4.class) public class WebSessionSelfTest extends GridCommonAbstractTest { /** Port for test Jetty server. */ private static final int TEST_JETTY_PORT = 49090; @@ -88,6 +92,7 @@ protected boolean keepBinary() { /** * @throws Exception If failed. */ + @Test public void testSingleRequest() throws Exception { testSingleRequest("/modules/core/src/test/config/websession/example-cache.xml"); } @@ -95,7 +100,8 @@ public void testSingleRequest() throws Exception { /** * @throws Exception If failed. */ - @IgniteIgnore("https://issues.apache.org/jira/browse/IGNITE-3663") + @Ignore("https://issues.apache.org/jira/browse/IGNITE-3663") + @Test public void testSessionRenewalDuringLogin() throws Exception { testSessionRenewalDuringLogin("/modules/core/src/test/config/websession/example-cache.xml"); } @@ -103,6 +109,7 @@ public void testSessionRenewalDuringLogin() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSingleRequestMetaInf() throws Exception { testSingleRequest("ignite-webapp-config.xml"); } @@ -110,6 +117,7 @@ public void testSingleRequestMetaInf() throws Exception { /** * @throws Exception If failed. */ + @Test public void testImplicitlyAttributeModification() throws Exception { testImplicitlyModification("ignite-webapp-config.xml"); } @@ -117,6 +125,7 @@ public void testImplicitlyAttributeModification() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectRequest() throws Exception { testClientReconnectRequest("/modules/core/src/test/config/websession/example-cache.xml", "/modules/core/src/test/config/websession/example-cache2.xml", @@ -477,6 +486,7 @@ private void testSessionRenewalDuringLogin(String cfg) throws Exception { * * @throws Exception Exception If failed. */ + @Test public void testInvalidatedSession() throws Exception { String invalidatedSesId; Server srv = null; @@ -594,6 +604,7 @@ public void testInvalidatedSession() throws Exception { * * @throws Exception Exception If failed. */ + @Test public void testChangeSessionId() throws Exception { String newWebSesId; Server srv = null; @@ -698,6 +709,7 @@ public void testChangeSessionId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestarts() throws Exception { final AtomicReference sesIdRef = new AtomicReference<>(); diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java index 5aec3084ec0ac..cbf3e6101dd92 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java @@ -25,6 +25,7 @@ import org.apache.ignite.Ignition; import org.apache.ignite.events.Event; import org.apache.ignite.lang.IgnitePredicate; +import org.jetbrains.annotations.NotNull; import org.yardstickframework.BenchmarkConfiguration; import org.yardstickframework.BenchmarkDriverAdapter; import org.yardstickframework.BenchmarkUtils; diff --git a/modules/yarn/src/test/java/org/apache/ignite/IgniteYarnTestSuite.java b/modules/yarn/src/test/java/org/apache/ignite/IgniteYarnTestSuite.java index ac002b51d7840..f144dd60e6cf3 100644 --- a/modules/yarn/src/test/java/org/apache/ignite/IgniteYarnTestSuite.java +++ b/modules/yarn/src/test/java/org/apache/ignite/IgniteYarnTestSuite.java @@ -17,22 +17,25 @@ package org.apache.ignite; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.ignite.yarn.IgniteApplicationMasterSelfTest; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * Apache Hadoop Yarn integration tests. */ -public class IgniteYarnTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteYarnTestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("Apache Yarn Integration Test Suite"); - suite.addTest(new TestSuite(IgniteApplicationMasterSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteApplicationMasterSelfTest.class)); return suite; } -} \ No newline at end of file +} diff --git a/modules/yarn/src/test/java/org/apache/ignite/yarn/IgniteApplicationMasterSelfTest.java b/modules/yarn/src/test/java/org/apache/ignite/yarn/IgniteApplicationMasterSelfTest.java index 6e82298edff53..575ef42a314f6 100644 --- a/modules/yarn/src/test/java/org/apache/ignite/yarn/IgniteApplicationMasterSelfTest.java +++ b/modules/yarn/src/test/java/org/apache/ignite/yarn/IgniteApplicationMasterSelfTest.java @@ -28,7 +28,6 @@ import java.util.Map; import java.util.concurrent.ThreadLocalRandom; import java.util.regex.Pattern; -import junit.framework.TestCase; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileStatus; @@ -51,11 +50,18 @@ import org.apache.hadoop.yarn.client.api.NMClient; import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync; import org.apache.hadoop.yarn.exceptions.YarnException; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.junit.Assert.assertEquals; /** * Application master tests. */ -public class IgniteApplicationMasterSelfTest extends TestCase { +@RunWith(JUnit4.class) +public class IgniteApplicationMasterSelfTest { /** */ private ApplicationMaster appMaster; @@ -68,9 +74,8 @@ public class IgniteApplicationMasterSelfTest extends TestCase { /** * @throws Exception If failed. */ - @Override protected void setUp() throws Exception { - super.setUp(); - + @Before + public void setUp() throws Exception { props = new ClusterProperties(); appMaster = new ApplicationMaster("test", props); @@ -82,6 +87,7 @@ public class IgniteApplicationMasterSelfTest extends TestCase { /** * @throws Exception If failed. */ + @Test public void testContainerAllocate() throws Exception { appMaster.setRmClient(rmMock); appMaster.setNmClient(new NMMock()); @@ -103,12 +109,13 @@ public void testContainerAllocate() throws Exception { assertEquals(1024, req.getCapability().getMemory()); } } - + /** * Tests whether memory overhead is allocated within container memory. * * @throws Exception If failed. */ + @Test public void testMemoryOverHeadAllocation() throws Exception { appMaster.setRmClient(rmMock); appMaster.setNmClient(new NMMock()); @@ -137,7 +144,8 @@ public void testMemoryOverHeadAllocation() throws Exception { * * @throws Exception If failed. */ - public void testMemoryOverHeadPreventAllocation() throws Exception { + @Test + public void testMemoryOverHeadPreventAllocation() throws Exception { rmMock.availableRes(new MockResource(1024, 2)); appMaster.setRmClient(rmMock); appMaster.setNmClient(new NMMock()); @@ -159,6 +167,7 @@ public void testMemoryOverHeadPreventAllocation() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterResource() throws Exception { rmMock.availableRes(new MockResource(1024, 2)); @@ -181,6 +190,7 @@ public void testClusterResource() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterAllocatedResource() throws Exception { rmMock.availableRes(new MockResource(1024, 2)); @@ -213,6 +223,7 @@ public void testClusterAllocatedResource() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartReleaseContainer() throws Exception { rmMock.availableRes(new MockResource(1024, 2)); @@ -246,6 +257,7 @@ public void testStartReleaseContainer() throws Exception { /** * @throws Exception If failed. */ + @Test public void testHostnameConstraint() throws Exception { rmMock.availableRes(new MockResource(1024, 2)); @@ -274,6 +286,7 @@ public void testHostnameConstraint() throws Exception { /** * @throws Exception If failed. */ + @Test public void testContainerEnvironment() throws Exception { props.memoryPerNode(1001); props.memoryOverHeadPerNode(2002); @@ -455,7 +468,7 @@ public void clear() { * @param blacklistRemovals list of resources which should be removed from the * application blacklist */ - public void updateBlacklist(List blacklistAdditions, List blacklistRemovals) { + @Override public void updateBlacklist(List blacklistAdditions, List blacklistRemovals) { // No-op. } } @@ -619,4 +632,4 @@ public MockFileSystem() { return null; } } -} \ No newline at end of file +} diff --git a/modules/zeromq/src/test/java/org/apache/ignite/stream/zeromq/IgniteZeroMqStreamerTest.java b/modules/zeromq/src/test/java/org/apache/ignite/stream/zeromq/IgniteZeroMqStreamerTest.java index 099212691366b..81441a74cdfcc 100644 --- a/modules/zeromq/src/test/java/org/apache/ignite/stream/zeromq/IgniteZeroMqStreamerTest.java +++ b/modules/zeromq/src/test/java/org/apache/ignite/stream/zeromq/IgniteZeroMqStreamerTest.java @@ -27,6 +27,9 @@ import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.zeromq.ZMQ; import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT; @@ -34,6 +37,7 @@ /** * Tests {@link IgniteZeroMqStreamer}. */ +@RunWith(JUnit4.class) public class IgniteZeroMqStreamerTest extends GridCommonAbstractTest { /** Cache entries count. */ private static final int CACHE_ENTRY_COUNT = 1000; @@ -65,6 +69,7 @@ public IgniteZeroMqStreamerTest() { /** * @throws Exception Test exception. */ + @Test public void testZeroMqPairSocket() throws Exception { try (IgniteDataStreamer dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) { try (IgniteZeroMqStreamer streamer = newStreamerInstance( @@ -77,6 +82,7 @@ public void testZeroMqPairSocket() throws Exception { /** * @throws Exception Test exception. */ + @Test public void testZeroMqSubSocketMultipart() throws Exception { try (IgniteDataStreamer dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) { try (IgniteZeroMqStreamer streamer = newStreamerInstance( @@ -90,6 +96,7 @@ public void testZeroMqSubSocketMultipart() throws Exception { /** * @throws Exception Test exception. */ + @Test public void testZeroMqSubSocket() throws Exception { try (IgniteDataStreamer dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) { try (IgniteZeroMqStreamer streamer = newStreamerInstance( @@ -102,6 +109,7 @@ public void testZeroMqSubSocket() throws Exception { /** * @throws Exception Test exception. */ + @Test public void testZeroMqPullSocket() throws Exception { try (IgniteDataStreamer dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME)) { try (IgniteZeroMqStreamer streamer = newStreamerInstance( diff --git a/modules/zeromq/src/test/java/org/apache/ignite/stream/zeromq/IgniteZeroMqStreamerTestSuite.java b/modules/zeromq/src/test/java/org/apache/ignite/stream/zeromq/IgniteZeroMqStreamerTestSuite.java index a98bf56e99714..0e806318afc8a 100644 --- a/modules/zeromq/src/test/java/org/apache/ignite/stream/zeromq/IgniteZeroMqStreamerTestSuite.java +++ b/modules/zeromq/src/test/java/org/apache/ignite/stream/zeromq/IgniteZeroMqStreamerTestSuite.java @@ -17,20 +17,23 @@ package org.apache.ignite.stream.zeromq; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * ZeroMQ streamer tests. */ -public class IgniteZeroMqStreamerTestSuite extends TestSuite { +@RunWith(AllTests.class) +public class IgniteZeroMqStreamerTestSuite { /** * @return ZeroMQ streamer tests suite. - * @throws Exception If failed. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { TestSuite suite = new TestSuite("ZeroMQ streamed Test Suite"); - suite.addTestSuite(IgniteZeroMqStreamerTest.class); + suite.addTest(new JUnit4TestAdapter(IgniteZeroMqStreamerTest.class)); return suite; } diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java index 52f77fcc8a871..2b8215750bccf 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java @@ -588,12 +588,17 @@ public ZookeeperDiscoverySpiMBeanImpl(IgniteSpiAdapter spiAdapter) { } /** {@inheritDoc} */ - @Nullable @Override public UUID getCoordinator() { + @Override public long getCommErrorProcNum() { + return stats.commErrorCount(); + } + + /** {@inheritDoc} */ + @Override public @Nullable UUID getCoordinator() { return impl.getCoordinator(); } /** {@inheritDoc} */ - @Nullable @Override public String getCoordinatorNodeFormatted() { + @Override public @Nullable String getCoordinatorNodeFormatted() { return String.valueOf(impl.node(impl.getCoordinator())); } diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiMBean.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiMBean.java index 1eed0b41d098d..05a3dc26778a3 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiMBean.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiMBean.java @@ -57,6 +57,14 @@ public interface ZookeeperDiscoverySpiMBean extends IgniteSpiManagementMBean, Di @MXBeanDescription("Zk Session Id.") public String getZkSessionId(); + /** + * Gets number of communication resolver called. + * + * @return Number of communication resolved oparations. + */ + @MXBeanDescription("Communication error resolver call count.") + public long getCommErrorProcNum(); + /** * Gets root path in ZooKeeper cluster Zk client uses to put data to. * diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java index 3d42042b850fb..5e05506de77ee 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java @@ -192,6 +192,9 @@ public class ZookeeperDiscoveryImpl { /** */ private final ZookeeperDiscoveryStatistics stats; + /** Last listener future. */ + private IgniteFuture lastCustomEvtLsnrFut; + /** * @param spi Discovery SPI. * @param igniteInstanceName Instance name. @@ -297,6 +300,9 @@ void clearCommunicationErrorProcessFuture(ZkCommunicationErrorProcessFuture fut) * @param err Connect error. */ public void resolveCommunicationError(ClusterNode node0, Exception err) { + if (node0.isClient()) + return; + ZookeeperClusterNode node = node(node0.id()); if (node == null) @@ -314,6 +320,8 @@ public void resolveCommunicationError(ClusterNode node0, Exception err) { this, node.sessionTimeout() + 1000); + stats.onCommunicationError(); + if (commErrProcFut.compareAndSet(fut, newFut)) { fut = newFut; @@ -2754,6 +2762,8 @@ private void processNewEvents(final ZkDiscoveryEventsData evtsData) throws Excep private boolean processBulkJoin(ZkDiscoveryEventsData evtsData, ZkDiscoveryNodeJoinEventData evtData) throws Exception { + waitForLastListenerFuture(); + boolean evtProcessed = false; for (int i = 0; i < evtData.joinedNodes.size(); i++) { @@ -3434,6 +3444,8 @@ private void notifyCustomEvent(final ZkDiscoveryCustomEventData evtData, final D if (msg != null && msg.isMutable()) fut.get(); + else + lastCustomEvtLsnrFut = fut; } /** @@ -3991,6 +4003,20 @@ public static byte[] unzip(byte[] zipBytes) throws DataFormatException { return out.toByteArray(); } + /** + * Wait for all the listeners from previous discovery message to be completed. + */ + private void waitForLastListenerFuture() { + if (lastCustomEvtLsnrFut != null) { + try { + lastCustomEvtLsnrFut.get(); + } + finally { + lastCustomEvtLsnrFut = null; + } + } + } + /** * */ diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryStatistics.java b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryStatistics.java index 678cf11cf1505..cc95dd3fe9f0e 100644 --- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryStatistics.java +++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryStatistics.java @@ -23,21 +23,29 @@ */ public class ZookeeperDiscoveryStatistics { /** */ - private int joinedNodesCnt; + private long joinedNodesCnt; /** */ - private int failedNodesCnt; + private long failedNodesCnt; + + /** Communication error count. */ + private long commErrCnt; /** */ - public int joinedNodesCnt() { + public long joinedNodesCnt() { return joinedNodesCnt; } /** */ - public int failedNodesCnt() { + public long failedNodesCnt() { return failedNodesCnt; } + /** */ + public long commErrorCount() { + return commErrCnt; + } + /** */ public void onNodeJoined() { joinedNodesCnt++; @@ -48,6 +56,11 @@ public void onNodeFailed() { failedNodesCnt++; } + /** */ + public void onCommunicationError() { + commErrCnt++; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(ZookeeperDiscoveryStatistics.class, this); diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java index ec5630f8a3209..1a7f8d4ff921f 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java @@ -37,13 +37,17 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Rule; +import org.junit.Test; import org.junit.rules.Timeout; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Test for {@link TcpDiscoveryZookeeperIpFinder}. * * @author Raul Kripalani */ +@RunWith(JUnit4.class) public class ZookeeperIpFinderTest extends GridCommonAbstractTest { /** Per test timeout */ @Rule @@ -142,6 +146,7 @@ else if (igniteInstanceName.equals(getTestIgniteInstanceName(1))) { /** * @throws Exception If failed. */ + @Test public void testOneIgniteNodeIsAlone() throws Exception { startGrid(0); @@ -153,6 +158,7 @@ public void testOneIgniteNodeIsAlone() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTwoIgniteNodesFindEachOther() throws Exception { // start one node startGrid(0); @@ -176,6 +182,7 @@ public void testTwoIgniteNodesFindEachOther() throws Exception { /** * @throws Exception If failed. */ + @Test public void testThreeNodesWithThreeDifferentConfigMethods() throws Exception { // start one node startGrid(0); @@ -207,6 +214,7 @@ public void testThreeNodesWithThreeDifferentConfigMethods() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFourNodesStartingAndStopping() throws Exception { // start one node startGrid(0); @@ -254,6 +262,7 @@ public void testFourNodesStartingAndStopping() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFourNodesWithDuplicateRegistrations() throws Exception { allowDuplicateRegistrations = true; @@ -277,6 +286,7 @@ public void testFourNodesWithDuplicateRegistrations() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFourNodesWithNoDuplicateRegistrations() throws Exception { allowDuplicateRegistrations = false; @@ -300,6 +310,7 @@ public void testFourNodesWithNoDuplicateRegistrations() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFourNodesRestartLastSeveralTimes() throws Exception { allowDuplicateRegistrations = false; @@ -336,6 +347,7 @@ public void testFourNodesRestartLastSeveralTimes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testFourNodesKillRestartZookeeper() throws Exception { allowDuplicateRegistrations = false; diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/IgniteCacheEntryListenerWithZkDiscoAtomicTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/IgniteCacheEntryListenerWithZkDiscoAtomicTest.java index 754a6bf05b10a..689daae4528ad 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/IgniteCacheEntryListenerWithZkDiscoAtomicTest.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/IgniteCacheEntryListenerWithZkDiscoAtomicTest.java @@ -17,6 +17,9 @@ package org.apache.ignite.spi.discovery.zk; import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Class is added to mute {@link #testConcurrentRegisterDeregister} test in ZooKeeper suite @@ -24,8 +27,10 @@ * * When slow down is tracked down and fixed this class can be replaced back with its parent. */ +@RunWith(JUnit4.class) public class IgniteCacheEntryListenerWithZkDiscoAtomicTest extends IgniteCacheEntryListenerAtomicTest { /** {@inheritDoc} */ + @Test @Override public void testConcurrentRegisterDeregister() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-8109"); } diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite1.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite1.java index 1a9e35136c9e0..ebed1a10fcf3c 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite1.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite1.java @@ -17,6 +17,7 @@ package org.apache.ignite.spi.discovery.zk; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; import org.apache.curator.test.ByteCodeRewrite; import org.apache.ignite.spi.discovery.zk.internal.ZookeeperClientTest; @@ -26,11 +27,14 @@ import org.apache.zookeeper.jmx.MBeanRegistry; import org.apache.zookeeper.server.ZooKeeperServer; import org.apache.zookeeper.server.quorum.LearnerZooKeeperServer; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; /** * */ -public class ZookeeperDiscoverySpiTestSuite1 extends TestSuite { +@RunWith(AllTests.class) +public class ZookeeperDiscoverySpiTestSuite1 { /** * During test suite processing GC can unload some classes whose bytecode has been rewritten here * {@link ByteCodeRewrite}. And the next time these classes will be loaded without bytecode rewriting. @@ -51,18 +55,17 @@ public class ZookeeperDiscoverySpiTestSuite1 extends TestSuite { /** * @return Test suite. - * @throws Exception Thrown in case of the failure. */ - public static TestSuite suite() throws Exception { + public static TestSuite suite() { System.setProperty("zookeeper.forceSync", "false"); System.setProperty("zookeeper.jmx.log4j.disable", "true"); TestSuite suite = new TestSuite("ZookeeperDiscoverySpi Test Suite"); - suite.addTestSuite(ZookeeperClientTest.class); - suite.addTestSuite(ZookeeperDiscoverySpiTest.class); - suite.addTestSuite(ZookeeperDiscoverySpiSaslFailedAuthTest.class); - suite.addTestSuite(ZookeeperDiscoverySpiSaslSuccessfulAuthTest.class); + suite.addTest(new JUnit4TestAdapter(ZookeeperClientTest.class)); + suite.addTest(new JUnit4TestAdapter(ZookeeperDiscoverySpiTest.class)); + suite.addTest(new JUnit4TestAdapter(ZookeeperDiscoverySpiSaslFailedAuthTest.class)); + suite.addTest(new JUnit4TestAdapter(ZookeeperDiscoverySpiSaslSuccessfulAuthTest.class)); return suite; } diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite2.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite2.java index 3b8ddeefefe1a..c6a67f3b33fc5 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite2.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite2.java @@ -17,27 +17,13 @@ package org.apache.ignite.spi.discovery.zk; +import junit.framework.JUnit4TestAdapter; import junit.framework.TestSuite; -import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.curator.TestingCluster; -import org.apache.ignite.internal.ClusterNodeMetricsUpdateTest; import org.apache.ignite.internal.IgniteClientReconnectCacheTest; -import org.apache.ignite.internal.processors.cache.datastructures.IgniteClientDataStructuresTest; -import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedNodeRestartTxSelfTest; -import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedSequenceApiSelfTest; -import org.apache.ignite.internal.processors.cache.datastructures.replicated.GridCacheReplicatedSequenceApiSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryTransactionalSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicMultiNodeFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiNodeFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedNodeRestartTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedAtomicMultiNodeFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedMultiNodeFullApiSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedNodeRestartSelfTest; -import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQuerySelfTest; -import org.apache.ignite.internal.processors.cache.multijvm.GridCacheAtomicMultiJvmFullApiSelfTest; -import org.apache.ignite.internal.processors.cache.multijvm.GridCachePartitionedMultiJvmFullApiSelfTest; -import org.apache.ignite.internal.processors.continuous.GridEventConsumeSelfTest; -import org.apache.ignite.p2p.GridP2PContinuousDeploymentSelfTest; +import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.curator.TestingCluster; import org.apache.ignite.util.GridCommandHandlerTest; /** @@ -58,41 +44,12 @@ public static TestSuite suite() throws Exception { TestSuite suite = new TestSuite("ZookeeperDiscoverySpi Test Suite"); - suite.addTestSuite(ZookeeperDiscoverySuitePreprocessorTest.class); - - suite.addTestSuite(GridCacheReplicatedNodeRestartSelfTest.class); - suite.addTestSuite(GridCachePartitionedNodeRestartTest.class); - - suite.addTestSuite(IgniteCacheEntryListenerWithZkDiscoAtomicTest.class); - - suite.addTestSuite(GridEventConsumeSelfTest.class); - - suite.addTestSuite(IgniteClientReconnectCacheTest.class); - - suite.addTestSuite(IgniteCachePutRetryAtomicSelfTest.class); - suite.addTestSuite(IgniteCachePutRetryTransactionalSelfTest.class); - - suite.addTestSuite(ClusterNodeMetricsUpdateTest.class); - - suite.addTestSuite(GridCachePartitionedMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedMultiNodeFullApiSelfTest.class); - - suite.addTestSuite(GridCacheAtomicMultiNodeFullApiSelfTest.class); - suite.addTestSuite(GridCacheReplicatedAtomicMultiNodeFullApiSelfTest.class); - - suite.addTestSuite(GridCachePartitionedNodeRestartTxSelfTest.class); - suite.addTestSuite(IgniteClientDataStructuresTest.class); - suite.addTestSuite(GridCacheReplicatedSequenceApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedSequenceApiSelfTest.class); - - suite.addTestSuite(IgniteCacheReplicatedQuerySelfTest.class); - - suite.addTestSuite(GridCacheAtomicMultiJvmFullApiSelfTest.class); - suite.addTestSuite(GridCachePartitionedMultiJvmFullApiSelfTest.class); - - suite.addTestSuite(GridCommandHandlerTest.class); - - suite.addTestSuite(GridP2PContinuousDeploymentSelfTest.class); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNodeRestartTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheEntryListenerWithZkDiscoAtomicTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientReconnectCacheTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCommandHandlerTest.class)); return suite; } diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite3.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite3.java new file mode 100644 index 0000000000000..403232d29c3f3 --- /dev/null +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite3.java @@ -0,0 +1,63 @@ +/* + * 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. + */ + +package org.apache.ignite.spi.discovery.zk; + +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.internal.processors.cache.datastructures.IgniteClientDataStructuresTest; +import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedNodeRestartTxSelfTest; +import org.apache.ignite.internal.processors.cache.datastructures.partitioned.GridCachePartitionedSequenceApiSelfTest; +import org.apache.ignite.internal.processors.cache.datastructures.replicated.GridCacheReplicatedSequenceApiSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedNodeRestartSelfTest; +import org.apache.ignite.internal.processors.cache.multijvm.GridCacheAtomicMultiJvmFullApiSelfTest; +import org.apache.ignite.internal.processors.cache.multijvm.GridCachePartitionedMultiJvmFullApiSelfTest; +import org.apache.ignite.internal.processors.continuous.GridEventConsumeSelfTest; +import org.apache.ignite.p2p.GridP2PContinuousDeploymentSelfTest; +import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.curator.TestingCluster; + +/** + * Regular Ignite tests executed with {@link ZookeeperDiscoverySpi}. + */ +public class ZookeeperDiscoverySpiTestSuite3 extends ZookeeperDiscoverySpiAbstractTestSuite { + /** */ + private static TestingCluster testingCluster; + + /** + * @return Test suite. + * @throws Exception Thrown in case of the failure. + */ + public static TestSuite suite() throws Exception { + System.setProperty("H2_JDBC_CONNECTIONS", "500"); // For multi-jvm tests. + + initSuite(); + + TestSuite suite = new TestSuite("ZookeeperDiscoverySpi Test Suite"); + + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedNodeRestartSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridEventConsumeSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedNodeRestartTxSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteClientDataStructuresTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedSequenceApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedSequenceApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCachePartitionedMultiJvmFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridP2PContinuousDeploymentSelfTest.class)); + + return suite; + } +} diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite4.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite4.java new file mode 100644 index 0000000000000..57262602b0058 --- /dev/null +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiTestSuite4.java @@ -0,0 +1,58 @@ +/* + * 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. + */ + +package org.apache.ignite.spi.discovery.zk; + +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.internal.ClusterNodeMetricsUpdateTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCachePutRetryTransactionalSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicMultiNodeFullApiSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedAtomicMultiNodeFullApiSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQuerySelfTest; +import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.curator.TestingCluster; + +/** + * Regular Ignite tests executed with {@link ZookeeperDiscoverySpi}. + */ +public class ZookeeperDiscoverySpiTestSuite4 extends ZookeeperDiscoverySpiAbstractTestSuite { + /** */ + private static TestingCluster testingCluster; + + /** + * @return Test suite. + * @throws Exception Thrown in case of the failure. + */ + public static TestSuite suite() throws Exception { + System.setProperty("H2_JDBC_CONNECTIONS", "500"); // For multi-jvm tests. + + initSuite(); + + TestSuite suite = new TestSuite("ZookeeperDiscoverySpi Test Suite"); + + suite.addTest(new JUnit4TestAdapter(ZookeeperDiscoverySuitePreprocessorTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePutRetryAtomicSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCachePutRetryTransactionalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(ClusterNodeMetricsUpdateTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheAtomicMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(GridCacheReplicatedAtomicMultiNodeFullApiSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(IgniteCacheReplicatedQuerySelfTest.class)); + + return suite; + } +} diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySuitePreprocessorTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySuitePreprocessorTest.java index 28cf17f017c42..0f9481bb5ea29 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySuitePreprocessorTest.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySuitePreprocessorTest.java @@ -27,6 +27,9 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.config.GridTestProperties; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Sanity test verifying that configuration callback specified via @@ -34,6 +37,7 @@ *

    * This test should be run as part of {@link ZookeeperDiscoverySpiTestSuite2}. */ +@RunWith(JUnit4.class) public class ZookeeperDiscoverySuitePreprocessorTest extends GridCommonAbstractTest { /** */ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); @@ -62,6 +66,7 @@ public class ZookeeperDiscoverySuitePreprocessorTest extends GridCommonAbstractT /** * @throws Exception If failed. */ + @Test public void testSpiConfigurationIsChanged() throws Exception { startGrid(0); diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClientTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClientTest.java index e3b91c74889f7..70edebbc6ba07 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClientTest.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClientTest.java @@ -39,10 +39,14 @@ import org.apache.zookeeper.ZooDefs; import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.data.Stat; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class ZookeeperClientTest extends GridCommonAbstractTest { /** */ private static final int SES_TIMEOUT = 60_000; @@ -69,6 +73,7 @@ private ZookeeperClient createClient(int sesTimeout) throws Exception { /** * @throws Exception If failed. */ + @Test public void testSaveLargeValue() throws Exception { startZK(1); @@ -100,6 +105,7 @@ public void testSaveLargeValue() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClose() throws Exception { startZK(1); @@ -121,6 +127,7 @@ public void testClose() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateAll() throws Exception { startZK(1); @@ -142,6 +149,7 @@ public void testCreateAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateAllRequestOverflow() throws Exception { startZK(1); @@ -164,6 +172,7 @@ public void testCreateAllRequestOverflow() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCreateAllNodeExists() throws Exception { startZK(1); @@ -187,6 +196,7 @@ public void testCreateAllNodeExists() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeleteAll() throws Exception { startZK(1); @@ -209,6 +219,7 @@ public void testDeleteAll() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeleteAllRequestOverflow() throws Exception { startZK(1); @@ -235,6 +246,7 @@ public void testDeleteAllRequestOverflow() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeleteAllNoNode() throws Exception { startZK(1); @@ -252,6 +264,7 @@ public void testDeleteAllNoNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionLoss1() throws Exception { ZookeeperClient client = new ZookeeperClient(log, "localhost:2200", 3000, null); @@ -268,6 +281,7 @@ public void testConnectionLoss1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionLoss2() throws Exception { startZK(1); @@ -290,6 +304,7 @@ public void testConnectionLoss2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionLoss3() throws Exception { startZK(1); @@ -318,6 +333,7 @@ public void testConnectionLoss3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionLoss4() throws Exception { startZK(1); @@ -355,6 +371,7 @@ public void testConnectionLoss4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnect1() throws Exception { startZK(1); @@ -386,6 +403,7 @@ public void testReconnect1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnect1_Callback() throws Exception { startZK(1); @@ -428,6 +446,7 @@ public void testReconnect1_Callback() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnect1_InCallback() throws Exception { startZK(1); @@ -474,6 +493,7 @@ public void testReconnect1_InCallback() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnect2() throws Exception { startZK(1); @@ -489,6 +509,7 @@ public void testReconnect2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnect3() throws Exception { startZK(3); @@ -512,6 +533,7 @@ public void testReconnect3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnect4() throws Exception { startZK(3); diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslFailedAuthTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslFailedAuthTest.java index c90f6d4c846c1..61d73828787f1 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslFailedAuthTest.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslFailedAuthTest.java @@ -18,16 +18,21 @@ import org.apache.zookeeper.client.ZooKeeperSaslClient; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static org.apache.ignite.IgniteSystemProperties.IGNITE_ZOOKEEPER_DISCOVERY_MAX_RETRY_COUNT; /** * */ +@RunWith(JUnit4.class) public class ZookeeperDiscoverySpiSaslFailedAuthTest extends ZookeeperDiscoverySpiSaslAuthAbstractTest { /** * @throws Exception If failed. */ + @Test public void testIgniteNodeWithInvalidPasswordFailsToJoin() throws Exception { System.setProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "InvalidZookeeperClient"); diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslSuccessfulAuthTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslSuccessfulAuthTest.java index 5ee0a4300af7a..065e4f566062e 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslSuccessfulAuthTest.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiSaslSuccessfulAuthTest.java @@ -17,14 +17,19 @@ package org.apache.ignite.spi.discovery.zk.internal; import org.apache.zookeeper.client.ZooKeeperSaslClient; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * */ +@RunWith(JUnit4.class) public class ZookeeperDiscoverySpiSaslSuccessfulAuthTest extends ZookeeperDiscoverySpiSaslAuthAbstractTest { /** * @throws Exception If failed. */ + @Test public void testIgniteNodesWithValidPasswordSuccessfullyJoins() throws Exception { System.setProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "ValidZookeeperClient"); @@ -37,6 +42,7 @@ public void testIgniteNodesWithValidPasswordSuccessfullyJoins() throws Exception /** * @throws Exception If failed. */ + @Test public void testIgniteNodeWithoutSaslConfigurationSuccessfullyJoins() throws Exception { //clearing SASL-related system properties that were set in beforeTest clearSaslSystemProperties(); diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiTest.java index f249b59d0372a..72e835ecea1d9 100644 --- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiTest.java +++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiTest.java @@ -138,6 +138,9 @@ import org.apache.zookeeper.server.quorum.QuorumPeer; import org.jetbrains.annotations.Nullable; import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; @@ -160,6 +163,7 @@ * */ @SuppressWarnings("deprecation") +@RunWith(JUnit4.class) public class ZookeeperDiscoverySpiTest extends GridCommonAbstractTest { /** */ private static final String IGNITE_ZK_ROOT = ZookeeperDiscoverySpi.DFLT_ROOT_PATH; @@ -200,6 +204,9 @@ public class ZookeeperDiscoverySpiTest extends GridCommonAbstractTest { /** */ private boolean failCommSpi; + /** */ + private boolean blockCommSpi; + /** */ private long sesTimeout; @@ -396,6 +403,13 @@ public class ZookeeperDiscoverySpiTest extends GridCommonAbstractTest { if (failCommSpi) cfg.setCommunicationSpi(new PeerToPeerCommunicationFailureSpi()); + if (blockCommSpi) { + cfg.setCommunicationSpi(new TcpBlockCommunicationSpi(igniteInstanceName.contains("block")) + .setUsePairedConnections(true)); + + cfg.setNetworkTimeout(500); + } + if (commFailureRslvr != null) cfg.setCommunicationFailureResolver(commFailureRslvr.apply()); @@ -554,6 +568,7 @@ private void checkInternalStructuresCleanup() throws Exception { * For more information about the problem refer to * IGNITE-8857. */ + @Test public void testNodeAttributesNotReferencingZookeeperClusterNode() throws Exception { userAttrs = new HashMap<>(); userAttrs.put("testAttr", "testAttr"); @@ -581,6 +596,7 @@ public void testNodeAttributesNotReferencingZookeeperClusterNode() throws Except /** * @throws Exception If failed. */ + @Test public void testZkRootNotExists() throws Exception { zkRootPath = "/a/b/c"; @@ -600,6 +616,7 @@ public void testZkRootNotExists() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMetadataUpdate() throws Exception { startGrid(0); @@ -616,6 +633,7 @@ public void testMetadataUpdate() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNodeAddresses() throws Exception { startGridsMultiThreaded(3); @@ -641,6 +659,7 @@ public void testNodeAddresses() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSetConsistentId() throws Exception { startGridsMultiThreaded(3); @@ -666,6 +685,7 @@ public void testSetConsistentId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDefaultConsistentId() throws Exception { dfltConsistenId = true; @@ -690,6 +710,7 @@ public void testDefaultConsistentId() throws Exception { /** * @throws Exception if failed. */ + @Test public void testMbean() throws Exception { startGrids(3); @@ -722,6 +743,7 @@ public void testMbean() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientNodesStatus() throws Exception { startGrid(0); @@ -774,7 +796,8 @@ public void testClientNodesStatus() throws Exception { /** * @throws Exception If failed. */ - public void _testLocalAuthenticationFails() throws Exception { + @Test + public void testLocalAuthenticationFails() throws Exception { auth = ZkTestNodeAuthenticator.factory(getTestIgniteInstanceName(0)); Throwable err = GridTestUtils.assertThrows(log, new Callable() { @@ -788,7 +811,7 @@ public void _testLocalAuthenticationFails() throws Exception { IgniteSpiException spiErr = X.cause(err, IgniteSpiException.class); assertNotNull(spiErr); - assertTrue(spiErr.getMessage().contains("Authentication failed for local node")); + assertTrue(spiErr.getMessage().contains("Failed to authenticate local node")); startGrid(1); startGrid(2); @@ -799,6 +822,7 @@ public void _testLocalAuthenticationFails() throws Exception { /** * @throws Exception If failed. */ + @Test public void testAuthentication() throws Exception { auth = ZkTestNodeAuthenticator.factory(getTestIgniteInstanceName(1), getTestIgniteInstanceName(5)); @@ -907,6 +931,7 @@ private void checkTestSecuritySubject(int expNodes) throws Exception { /** * @throws Exception If failed. */ + @Test public void testStopNode_1() throws Exception { startGrids(5); @@ -924,6 +949,7 @@ public void testStopNode_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomEventsSimple1_SingleNode() throws Exception { ackEveryEventSystemProperty(); @@ -937,6 +963,7 @@ public void testCustomEventsSimple1_SingleNode() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomEventsSimple1_5_Nodes() throws Exception { ackEveryEventSystemProperty(); @@ -952,6 +979,7 @@ public void testCustomEventsSimple1_5_Nodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomEvents_FastStopProcess_1() throws Exception { customEvents_FastStopProcess(1, 0); } @@ -959,6 +987,7 @@ public void testCustomEvents_FastStopProcess_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCustomEvents_FastStopProcess_2() throws Exception { customEvents_FastStopProcess(5, 5); } @@ -1133,6 +1162,7 @@ private void registerTestEventListeners(Ignite node, * * @see IGNITE-9040 ticket for more context of the test. */ + @Test public void testStopNodeOnSegmentaion() throws Exception { try { System.setProperty("IGNITE_WAL_LOG_TX_RECORDS", "true"); @@ -1234,6 +1264,7 @@ private void waitForNodeStop(String name) throws Exception { /** * @throws Exception If failed. */ + @Test public void testSegmentation1() throws Exception { sesTimeout = 2000; testSockNio = true; @@ -1271,6 +1302,7 @@ public void testSegmentation1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSegmentation2() throws Exception { sesTimeout = 2000; @@ -1301,6 +1333,7 @@ public void testSegmentation2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testSegmentation3() throws Exception { sesTimeout = 5000; @@ -1341,6 +1374,7 @@ public void testSegmentation3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testQuorumRestore() throws Exception { sesTimeout = 60_000; @@ -1378,6 +1412,7 @@ public void testQuorumRestore() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionRestore1() throws Exception { testSockNio = true; @@ -1393,6 +1428,7 @@ public void testConnectionRestore1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionRestore2() throws Exception { testSockNio = true; @@ -1408,6 +1444,7 @@ public void testConnectionRestore2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionRestore_NonCoordinator1() throws Exception { connectionRestore_NonCoordinator(false); } @@ -1415,6 +1452,7 @@ public void testConnectionRestore_NonCoordinator1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionRestore_NonCoordinator2() throws Exception { connectionRestore_NonCoordinator(true); } @@ -1474,6 +1512,7 @@ private void connectionRestore_NonCoordinator(boolean failWhenDisconnected) thro /** * @throws Exception If failed. */ + @Test public void testConnectionRestore_Coordinator1() throws Exception { connectionRestore_Coordinator(1, 1, 0); } @@ -1481,6 +1520,7 @@ public void testConnectionRestore_Coordinator1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionRestore_Coordinator1_1() throws Exception { connectionRestore_Coordinator(1, 1, 1); } @@ -1488,6 +1528,7 @@ public void testConnectionRestore_Coordinator1_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionRestore_Coordinator2() throws Exception { connectionRestore_Coordinator(1, 3, 0); } @@ -1495,6 +1536,7 @@ public void testConnectionRestore_Coordinator2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionRestore_Coordinator3() throws Exception { connectionRestore_Coordinator(3, 3, 0); } @@ -1502,6 +1544,7 @@ public void testConnectionRestore_Coordinator3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionRestore_Coordinator4() throws Exception { connectionRestore_Coordinator(3, 3, 1); } @@ -1665,6 +1708,7 @@ private static void waitNoAliveZkNodes(final IgniteLogger log, /** * @throws Exception If failed. */ + @Test public void testConcurrentStartWithClient() throws Exception { final int NODES = 20; @@ -1700,6 +1744,7 @@ public void testConcurrentStartWithClient() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStart() throws Exception { final int NODES = 20; @@ -1735,6 +1780,7 @@ public void testConcurrentStart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartStop1() throws Exception { concurrentStartStop(1); } @@ -1742,6 +1788,7 @@ public void testConcurrentStartStop1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartStop2() throws Exception { concurrentStartStop(5); } @@ -1749,6 +1796,7 @@ public void testConcurrentStartStop2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConcurrentStartStop2_EventsThrottle() throws Exception { System.setProperty(ZookeeperDiscoveryImpl.IGNITE_ZOOKEEPER_DISCOVERY_SPI_MAX_EVTS, "1"); @@ -1812,6 +1860,7 @@ private void concurrentStartStop(final int initNodes) throws Exception { /** * @throws Exception If failed. */ + @Test public void testClusterRestart() throws Exception { startGridsMultiThreaded(3, false); @@ -1827,6 +1876,7 @@ public void testClusterRestart() throws Exception { /** * @throws Exception If failed. */ + @Test public void testConnectionRestore4() throws Exception { testSockNio = true; @@ -1842,6 +1892,7 @@ public void testConnectionRestore4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStop_1_Node() throws Exception { startGrid(0); @@ -1853,6 +1904,7 @@ public void testStartStop_1_Node() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRestarts_2_Nodes() throws Exception { startGrid(0); @@ -1870,6 +1922,7 @@ public void testRestarts_2_Nodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStop_2_Nodes_WithCache() throws Exception { startGrids(2); @@ -1891,6 +1944,7 @@ public void testStartStop_2_Nodes_WithCache() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStop_2_Nodes() throws Exception { ackEveryEventSystemProperty(); @@ -1913,6 +1967,7 @@ public void testStartStop_2_Nodes() throws Exception { /** * @throws Exception If failed. */ + @Test public void testMultipleClusters() throws Exception { Ignite c0 = startGrid(0); @@ -1967,6 +2022,7 @@ private void checkNodesNumber(final Ignite node, final int expNodes) throws Exce /** * @throws Exception If failed. */ + @Test public void testStartStop1() throws Exception { ackEveryEventSystemProperty(); @@ -1997,6 +2053,7 @@ public void testStartStop1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStop3() throws Exception { startGrids(4); @@ -2012,6 +2069,7 @@ public void testStartStop3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStop4() throws Exception { startGrids(6); @@ -2040,6 +2098,7 @@ public void testStartStop4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStop2() throws Exception { startGridsMultiThreaded(10, false); @@ -2059,6 +2118,7 @@ public void testStartStop2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartStopWithClients() throws Exception { final int SRVS = 3; @@ -2090,6 +2150,7 @@ public void testStartStopWithClients() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopologyChangeMultithreaded() throws Exception { topologyChangeWithRestarts(false, false); } @@ -2097,6 +2158,7 @@ public void testTopologyChangeMultithreaded() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopologyChangeMultithreaded_RestartZk() throws Exception { try { topologyChangeWithRestarts(true, false); @@ -2111,6 +2173,7 @@ public void testTopologyChangeMultithreaded_RestartZk() throws Exception { /** * @throws Exception If failed. */ + @Test public void testTopologyChangeMultithreaded_RestartZk_CloseClients() throws Exception { try { topologyChangeWithRestarts(true, true); @@ -2226,6 +2289,7 @@ private void topologyChangeWithRestarts(boolean restartZk, boolean closeClientSo /** * @throws Exception If failed. */ + @Test public void testRandomTopologyChanges() throws Exception { randomTopologyChanges(false, false); } @@ -2301,6 +2365,7 @@ private void checkZkNodesCleanup() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomTopologyChanges_RestartZk() throws Exception { randomTopologyChanges(true, false); } @@ -2308,6 +2373,7 @@ public void testRandomTopologyChanges_RestartZk() throws Exception { /** * @throws Exception If failed. */ + @Test public void testRandomTopologyChanges_CloseClients() throws Exception { randomTopologyChanges(false, true); } @@ -2315,6 +2381,7 @@ public void testRandomTopologyChanges_CloseClients() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployService1() throws Exception { startGridsMultiThreaded(3); @@ -2324,6 +2391,7 @@ public void testDeployService1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployService2() throws Exception { clientMode(false); @@ -2339,6 +2407,7 @@ public void testDeployService2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDeployService3() throws Exception { IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable() { @Override public Object call() throws Exception { @@ -2364,6 +2433,7 @@ public void testDeployService3() throws Exception { * * @throws Exception If failed. */ + @Test public void testLargeUserAttribute1() throws Exception { initLargeAttribute(); @@ -2385,6 +2455,7 @@ public void testLargeUserAttribute1() throws Exception { * * @throws Exception If failed. */ + @Test public void testLargeUserAttribute2() throws Exception { startGrid(0); @@ -2403,6 +2474,7 @@ public void testLargeUserAttribute2() throws Exception { * * @throws Exception If failed. */ + @Test public void testLargeUserAttribute3() throws Exception { Set idxs = ThreadLocalRandom.current() .ints(0, 10) @@ -2444,6 +2516,7 @@ private void initLargeAttribute() { /** * @throws Exception If failed. */ + @Test public void testLargeCustomEvent() throws Exception { Ignite srv0 = startGrid(0); @@ -2475,6 +2548,7 @@ public void testLargeCustomEvent() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectSessionExpire1_1() throws Exception { clientReconnectSessionExpire(false); } @@ -2482,6 +2556,7 @@ public void testClientReconnectSessionExpire1_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testClientReconnectSessionExpire1_2() throws Exception { clientReconnectSessionExpire(true); } @@ -2511,6 +2586,7 @@ private void clientReconnectSessionExpire(boolean closeSock) throws Exception { /** * @throws Exception If failed. */ + @Test public void testForceClientReconnect() throws Exception { final int SRVS = 3; @@ -2536,6 +2612,7 @@ public void testForceClientReconnect() throws Exception { /** * @throws Exception If failed. */ + @Test public void testForcibleClientFail() throws Exception { final int SRVS = 3; @@ -2561,6 +2638,7 @@ public void testForcibleClientFail() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDuplicatedNodeId() throws Exception { UUID nodeId0 = nodeId = UUID.randomUUID(); @@ -2603,6 +2681,7 @@ public void testDuplicatedNodeId() throws Exception { /** * @throws Exception If failed. */ + @Test public void testPing() throws Exception { sesTimeout = 5000; @@ -2644,6 +2723,7 @@ public void testPing() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithPersistence1() throws Exception { startWithPersistence(false); } @@ -2651,6 +2731,7 @@ public void testWithPersistence1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testWithPersistence2() throws Exception { startWithPersistence(true); } @@ -2658,6 +2739,7 @@ public void testWithPersistence2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoOpCommunicationFailureResolve_1() throws Exception { communicationFailureResolve_Simple(2); } @@ -2665,6 +2747,7 @@ public void testNoOpCommunicationFailureResolve_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testNoOpCommunicationErrorResolve_2() throws Exception { communicationFailureResolve_Simple(10); } @@ -2708,6 +2791,7 @@ private void communicationFailureResolve_Simple(int nodes) throws Exception { * * @throws Exception If failed. */ + @Test public void testNoOpCommunicationErrorResolve_3() throws Exception { sesTimeout = 2000; commFailureRslvr = NoOpCommunicationFailureResolver.FACTORY; @@ -2754,6 +2838,7 @@ public void testNoOpCommunicationErrorResolve_3() throws Exception { * * @throws Exception If failed. */ + @Test public void testNoOpCommunicationErrorResolve_4() throws Exception { testCommSpi = true; @@ -2796,6 +2881,7 @@ public void testNoOpCommunicationErrorResolve_4() throws Exception { * * @throws Exception If failed. */ + @Test public void testNoOpCommunicationErrorResolve_5() throws Exception { testCommSpi = true; @@ -2857,6 +2943,7 @@ public void testNoOpCommunicationErrorResolve_5() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommunicationErrorResolve_KillNode_1() throws Exception { communicationFailureResolve_KillNodes(2, Collections.singleton(2L)); } @@ -2864,6 +2951,7 @@ public void testCommunicationErrorResolve_KillNode_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommunicationErrorResolve_KillNode_2() throws Exception { communicationFailureResolve_KillNodes(3, Collections.singleton(2L)); } @@ -2871,6 +2959,7 @@ public void testCommunicationErrorResolve_KillNode_2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommunicationErrorResolve_KillNode_3() throws Exception { communicationFailureResolve_KillNodes(10, Arrays.asList(2L, 4L, 6L)); } @@ -2878,6 +2967,7 @@ public void testCommunicationErrorResolve_KillNode_3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommunicationErrorResolve_KillCoordinator_1() throws Exception { communicationFailureResolve_KillNodes(2, Collections.singleton(1L)); } @@ -2885,6 +2975,7 @@ public void testCommunicationErrorResolve_KillCoordinator_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommunicationErrorResolve_KillCoordinator_2() throws Exception { communicationFailureResolve_KillNodes(3, Collections.singleton(1L)); } @@ -2892,6 +2983,7 @@ public void testCommunicationErrorResolve_KillCoordinator_2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommunicationErrorResolve_KillCoordinator_3() throws Exception { communicationFailureResolve_KillNodes(10, Arrays.asList(1L, 4L, 6L)); } @@ -2899,6 +2991,7 @@ public void testCommunicationErrorResolve_KillCoordinator_3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testCommunicationErrorResolve_KillCoordinator_4() throws Exception { communicationFailureResolve_KillNodes(10, Arrays.asList(1L, 2L, 3L)); } @@ -2958,6 +3051,7 @@ private void communicationFailureResolve_KillNodes(int startNodes, Collection cache = cli.getOrCreateCache(DEFAULT_CACHE_NAME); + + cache.put(1, 1); + + assertEquals(cache.get(1), 1); + + assertEquals(1, srv1.cluster().forClients().nodes().size()); + + MBeanServer srv = ManagementFactory.getPlatformMBeanServer(); + + IgniteEx ignite = grid("server1-block"); + + ObjectName spiName = U.makeMBeanName(ignite.context().igniteInstanceName(), "SPIs", + ZookeeperDiscoverySpi.class.getSimpleName()); + + ZookeeperDiscoverySpiMBean bean = JMX.newMBeanProxy(srv, spiName, ZookeeperDiscoverySpiMBean.class); + + assertNotNull(bean); + + assertEquals(0, bean.getCommErrorProcNum()); + } + + /** + * @throws Exception If failed. + */ + @Test public void testConnectionCheck() throws Exception { final int NODES = 5; @@ -3515,6 +3659,7 @@ public void testConnectionCheck() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectDisabled_ConnectionLost() throws Exception { clientReconnectDisabled = true; @@ -3556,6 +3701,7 @@ public void testReconnectDisabled_ConnectionLost() throws Exception { /** * @throws Exception If failed. */ + @Test public void testServersLeft_FailOnTimeout() throws Exception { startGrid(0); @@ -3593,6 +3739,7 @@ public void testServersLeft_FailOnTimeout() throws Exception { /** * */ + @Test public void testStartNoServers_FailOnTimeout() { joinTimeout = 3000; @@ -3619,6 +3766,7 @@ public void testStartNoServers_FailOnTimeout() { /** * @throws Exception If failed. */ + @Test public void testStartNoServer_WaitForServers1() throws Exception { startNoServer_WaitForServers(0); } @@ -3626,6 +3774,7 @@ public void testStartNoServer_WaitForServers1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartNoServer_WaitForServers2() throws Exception { startNoServer_WaitForServers(10_000); } @@ -3663,6 +3812,7 @@ private void startNoServer_WaitForServers(long joinTimeout) throws Exception { /** * @throws Exception If failed. */ + @Test public void testDisconnectOnServersLeft_1() throws Exception { disconnectOnServersLeft(1, 1); } @@ -3670,6 +3820,7 @@ public void testDisconnectOnServersLeft_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDisconnectOnServersLeft_2() throws Exception { disconnectOnServersLeft(5, 1); } @@ -3677,6 +3828,7 @@ public void testDisconnectOnServersLeft_2() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDisconnectOnServersLeft_3() throws Exception { disconnectOnServersLeft(1, 10); } @@ -3684,6 +3836,7 @@ public void testDisconnectOnServersLeft_3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDisconnectOnServersLeft_4() throws Exception { disconnectOnServersLeft(5, 10); } @@ -3691,6 +3844,7 @@ public void testDisconnectOnServersLeft_4() throws Exception { /** * @throws Exception If failed. */ + @Test public void testDisconnectOnServersLeft_5() throws Exception { joinTimeout = 10_000; @@ -3771,6 +3925,7 @@ else if (evt.type() == EVT_CLIENT_NODE_RECONNECTED) { /** * @throws Exception If failed. */ + @Test public void testReconnectServersRestart_1() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-8178"); @@ -3780,6 +3935,7 @@ public void testReconnectServersRestart_1() throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectServersRestart_2() throws Exception { fail("https://issues.apache.org/jira/browse/IGNITE-8178"); @@ -3794,6 +3950,7 @@ public void testReconnectServersRestart_2() throws Exception { * * @throws Exception If failed. */ + @Test public void testSimpleSplitBrain() throws Exception { failCommSpi = true; @@ -3844,6 +4001,7 @@ public void testSimpleSplitBrain() throws Exception { * * @throws Exception If failed. */ + @Test public void testNotActualSplitBrain() throws Exception { failCommSpi = true; @@ -3891,6 +4049,7 @@ public void testNotActualSplitBrain() throws Exception { * * @throws Exception If failed. */ + @Test public void testAlmostSplitBrain() throws Exception { failCommSpi = true; @@ -4231,6 +4390,7 @@ private void reconnectServersRestart(int srvs) throws Exception { /** * @throws Exception If failed. */ + @Test public void testReconnectServersRestart_3() throws Exception { startGrid(0); @@ -4267,6 +4427,7 @@ public void testReconnectServersRestart_3() throws Exception { /** * @throws Exception If failed. */ + @Test public void testStartNoZk() throws Exception { stopZkCluster(); @@ -5500,7 +5661,7 @@ static class TestFastStopProcessCustomMessageAck implements DiscoveryCustomMessa } /** {@inheritDoc} */ - @Nullable @Override public DiscoveryCustomMessage ackMessage() { + @Override public @Nullable DiscoveryCustomMessage ackMessage() { return null; } @@ -5543,4 +5704,49 @@ static class TestFastStopProcessCustomMessageAck implements DiscoveryCustomMessa return S.toString(TestFastStopProcessCustomMessageAck.class, this); } } + + /** + * Block communications. + */ + private static class TcpBlockCommunicationSpi extends TcpCommunicationSpi { + /** + * Whether this instance should actually block. + */ + private final boolean isBlocking; + + /** Blocked once. */ + private boolean alreadyBlocked; + + /** + * @param isBlocking Whether this instance should actually block. + */ + public TcpBlockCommunicationSpi(boolean isBlocking) { + this.isBlocking = isBlocking; + } + + /** {@inheritDoc} */ + @Override protected GridCommunicationClient createTcpClient(ClusterNode node, int connIdx) + throws IgniteCheckedException { + if (node.isClient() && blockHandshakeOnce(node.id())) { + ZookeeperDiscoverySpi spi = spi(ignite()); + + spi.resolveCommunicationFailure(spi.getRemoteNodes().iterator().next(), new Exception("test")); + + return null; + } + + return super.createTcpClient(node, connIdx); + } + + /** Check if this connection is blocked. */ + private boolean blockHandshakeOnce(UUID nodeId) { + if (isBlocking && !alreadyBlocked) { + alreadyBlocked = true; + + return true; + } + + return false; + } + } } diff --git a/parent/pom.xml b/parent/pom.xml index eeceb18e7c1ef..f01c6b9c5e105 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -76,20 +76,26 @@ 4.4.3 2.9.6 1.9.13 + 2.1 + 2.1.14 3.20.0-GA 1.0.0_1 1.0.1 1.0.0 - 13.0 + 1.0.6.Final + 16.0.3 9.4.11.v20180605 1.13 1.1.1 + 4.5.2 + 3.0.46 + 2.2.3 0.1.54_1 0.1.54 2.4_1 2.4 r938 - 1.1.1 + 2.0.1 4.0.2 2.11.0 7.4.0_1 @@ -107,6 +113,7 @@ 2.10.7 2.10.7 2.11.12 + 2.2.6 1.7.7 1.6.4 2.6.5 @@ -515,7 +522,7 @@ - 2018 Copyright © Apache Software Foundation + 2019 Copyright © Apache Software Foundation @@ -607,7 +614,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.20.1 + 3.0.0-M3 0 @@ -712,7 +719,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 1.4 + 3.0.0-M2 @@ -988,7 +995,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.20.1 + 3.0.0-M3 1